fix(cli): self-hosted 注入 cypher KBDB_BASE_URL 指向用戶自己的 kbdb(issue #2)

injectWranglerConfig 的 self-hosted 分支原本只注 database_id / MULTI_TENANT,
漏了 KBDB_BASE_URL → cypher /kbdb/* 一律指向官方 arcrun-kbdb.uncle6-me,
self-hosted 用戶資料默默寫進官方庫(隔離破損)。

比照既有注入模式,用 ctx.workerSubdomain 把 KBDB_BASE_URL 就地改寫成
arcrun-kbdb.<subdomain>.workers.dev。init 與 update 共用此注入點,一處修兩條路。

驗證:tsc --noEmit 通過;真實 cypher toml 注入 subdomain=leo21c →
KBDB_BASE_URL = "https://arcrun-kbdb.leo21c.workers.dev"。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
uncle6me-web
2026-06-24 12:26:36 +08:00
parent 4d6e77ff2d
commit 9c4333defb
+10
View File
@@ -397,6 +397,16 @@ function injectWranglerConfig(tomlPath: string, ctx: DeployContext): void {
// 只對有 [vars] 的 workermcp / cypher-executor)生效;其餘無 [vars] 的不動。
if (ctx.selfHosted) {
toml = injectMultiTenant(toml);
// self-hosted:把 cypher 的 KBDB_BASE_URL 從官方 arcrun-kbdb.uncle6-me 改成用戶自己帳號的
// arcrun-kbdb.<subdomain>.workers.devissue #2)。比照 database_id / MULTI_TENANT 注入模式。
// 漏這一個 → cypher /kbdb/* fallback 到官方 kbdb workerself-hosted 資料寫進官方庫(隔離破損)。
if (ctx.workerSubdomain) {
toml = toml.replace(
/(KBDB_BASE_URL\s*=\s*")[^"]*(")/,
`$1https://arcrun-kbdb.${ctx.workerSubdomain}.workers.dev$2`,
);
}
}
toml = stripOfficialOnlyBindings(toml);