Skip to content

Commit e95c2d0

Browse files
byapparovclaude
andcommitted
fix: keep deprecated lsp config on rewrite and scope review follow-ups (#144)
Keep the accepted `lsp` block in the parsed config instead of stripping it, so Config.update no longer drops it from disk; it stays a no-op and each config file that sets it warns once. Drop the deleted util/archive.ts from the Bun shell migration plan, and let the no-download assertion ignore a ripgrep install on hosts without rg. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent acd62bd commit e95c2d0

4 files changed

Lines changed: 52 additions & 11 deletions

File tree

‎packages/cli/BUN_SHELL_MIGRATION_PLAN.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ Migrate git-centric call sites to `Process.git*` helpers:
9999
Migrate residual non-git usages:
100100

101101
- `src/cli/cmd/tui/util/clipboard.ts`
102-
- `src/util/archive.ts`
103102
- `src/file/ripgrep.ts`
104103
- `src/tool/bash.ts`
105104
- `src/cli/cmd/uninstall.ts`

‎packages/cli/src/config/config.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,15 +1177,14 @@ export namespace Config {
11771177
return load(text, { path: filepath })
11781178
}
11791179

1180-
// The LSP subsystem was removed (#144). Configs written before then may still set
1181-
// the `lsp` block or an `lsp` permission rule; both load as no-ops with one warning.
1182-
function withoutDeprecatedLsp(config: Record<string, unknown>, source: string) {
1180+
// The LSP subsystem was removed (#144). Configs written before then may still set the
1181+
// `lsp` block or an `lsp` permission rule. The schema accepts both as no-ops and keeps
1182+
// them, so rewriting a config file preserves them; each config file that sets one warns once.
1183+
function warnDeprecatedLsp(config: Record<string, unknown>, source: string) {
11831184
const permission = config.permission
11841185
const hasLspPermission = typeof permission === "object" && permission !== null && "lsp" in permission
1185-
if (!("lsp" in config) && !hasLspPermission) return config
1186+
if (!("lsp" in config) && !hasLspPermission) return
11861187
log.warn("lsp config is deprecated and ignored; the LSP subsystem was removed", { path: source })
1187-
const { lsp: _, ...rest } = config
1188-
return rest
11891188
}
11901189

11911190
async function load(text: string, options: { path: string } | { dir: string; source: string }) {
@@ -1199,7 +1198,8 @@ export namespace Config {
11991198

12001199
const normalized = (() => {
12011200
if (!data || typeof data !== "object" || Array.isArray(data)) return data
1202-
const copy = withoutDeprecatedLsp({ ...(data as Record<string, unknown>) }, source)
1201+
const copy = { ...(data as Record<string, unknown>) }
1202+
warnDeprecatedLsp(copy, source)
12031203
const hadLegacy = "theme" in copy || "keybinds" in copy || "tui" in copy
12041204
if (!hadLegacy) return copy
12051205
delete copy.theme

‎packages/cli/test/cli/run-no-lsp.test.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ async function aictrl(args: string[], cwd: string, env: Record<string, string |
9191
}
9292
}
9393

94+
function isRipgrep(name: string) {
95+
return name === "rg" || name === "rg.exe" || name.startsWith("ripgrep-")
96+
}
97+
9498
function declaredTools(request: any): string[] {
9599
return (request.tools ?? []).flatMap((tool: any) => tool.functionDeclarations ?? []).map((tool: any) => tool.name)
96100
}
@@ -130,7 +134,10 @@ describe("headless run without the LSP subsystem (#144)", () => {
130134
for (const part of tools) expect(part.state.metadata).not.toHaveProperty("diagnostics")
131135
expect(result.stdout).not.toContain("<diagnostics")
132136
expect(declaredTools(model.requests[0])).not.toContain("lsp")
133-
expect(await fs.readdir(ws.binDir).catch(() => [])).toEqual([])
137+
// The bin dir is also where ripgrep lands on hosts without a system `rg`; anything else
138+
// there would be a downloaded language server.
139+
const installed = await fs.readdir(ws.binDir).catch(() => [])
140+
expect(installed.filter((name) => !isRipgrep(name))).toEqual([])
134141
} finally {
135142
model.server.stop(true)
136143
}

‎packages/cli/test/config/config.test.ts‎

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ describe("removed LSP config (#144)", () => {
105105
})
106106

107107
expect(config.model).toBe("test/model")
108-
expect(config).not.toHaveProperty("lsp")
109108
expect(config.permission?.edit).toBe("allow")
110109
expect(lspWarnings).toHaveLength(1)
111110
})
@@ -114,10 +113,46 @@ describe("removed LSP config (#144)", () => {
114113
const { config, lspWarnings } = await loadWithWarnings({ model: "test/model", lsp: false })
115114

116115
expect(config.model).toBe("test/model")
117-
expect(config).not.toHaveProperty("lsp")
118116
expect(lspWarnings).toHaveLength(1)
119117
})
120118

119+
test("each config layer that sets lsp warns once with its own path", async () => {
120+
const warn = spyOn(Log.create({ service: "config" }), "warn")
121+
await using tmp = await tmpdir({
122+
init: async (dir) => {
123+
await writeConfig(dir, { lsp: false })
124+
await writeConfig(path.join(dir, ".aictrl"), { permission: { lsp: "deny" } })
125+
},
126+
})
127+
try {
128+
await Instance.provide({ directory: tmp.path, fn: () => Config.get() })
129+
const paths = warn.mock.calls
130+
.filter(([message]) => String(message).includes("lsp"))
131+
.map(([, extra]) => extra?.path)
132+
expect(paths.toSorted()).toEqual(
133+
[path.join(tmp.path, ".aictrl", "aictrl.json"), path.join(tmp.path, "aictrl.json")].toSorted(),
134+
)
135+
} finally {
136+
warn.mockRestore()
137+
}
138+
})
139+
140+
test("Config.update keeps a deprecated lsp block on disk", async () => {
141+
await using tmp = await tmpdir({
142+
init: (dir) => writeConfig(dir, { lsp: { custom: { command: ["ls"] } } }, "config.json"),
143+
})
144+
await Instance.provide({
145+
directory: tmp.path,
146+
fn: async () => {
147+
await Config.update({ model: "updated/model" })
148+
149+
const written = await Filesystem.readJson<Record<string, unknown>>(path.join(tmp.path, "config.json"))
150+
expect(written.model).toBe("updated/model")
151+
expect(written.lsp).toEqual({ custom: { command: ["ls"] } })
152+
},
153+
})
154+
})
155+
121156
test("a config without lsp keys logs no lsp warning", async () => {
122157
const { lspWarnings } = await loadWithWarnings({ model: "test/model", permission: { edit: "allow" } })
123158

0 commit comments

Comments
 (0)