Skip to content

Commit c449d3d

Browse files
authored
Migrate remaining legacy tools config tests (anomalyco#28363)
1 parent e4eb98b commit c449d3d

2 files changed

Lines changed: 31 additions & 60 deletions

File tree

packages/opencode/test/config/config.test.ts

Lines changed: 30 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,67 +1204,37 @@ test("keeps plugin origins aligned with merged plugin list", async () => {
12041204

12051205
// Legacy tools migration tests
12061206

1207-
test("migrates legacy tools config to permissions - allow", async () => {
1208-
await using tmp = await tmpdir({
1209-
init: async (dir) => {
1210-
await Filesystem.write(
1211-
path.join(dir, "opencode.json"),
1212-
JSON.stringify({
1213-
$schema: "https://opencode.ai/config.json",
1214-
agent: {
1215-
test: {
1216-
tools: {
1217-
bash: true,
1218-
read: true,
1219-
},
1220-
},
1221-
},
1222-
}),
1223-
)
1224-
},
1225-
})
1226-
await withTestInstance({
1227-
directory: tmp.path,
1228-
fn: async (ctx) => {
1229-
const config = await load(ctx)
1230-
expect(config.agent?.["test"]?.permission).toEqual({
1231-
bash: "allow",
1232-
read: "allow",
1233-
})
1234-
},
1235-
})
1236-
})
1207+
it.instance("migrates legacy tools config to permissions - allow", () =>
1208+
Effect.gen(function* () {
1209+
const test = yield* TestInstance
1210+
yield* writeConfigEffect(test.directory, {
1211+
$schema: "https://opencode.ai/config.json",
1212+
agent: { test: { tools: { bash: true, read: true } } },
1213+
})
12371214

1238-
test("migrates legacy tools config to permissions - deny", async () => {
1239-
await using tmp = await tmpdir({
1240-
init: async (dir) => {
1241-
await Filesystem.write(
1242-
path.join(dir, "opencode.json"),
1243-
JSON.stringify({
1244-
$schema: "https://opencode.ai/config.json",
1245-
agent: {
1246-
test: {
1247-
tools: {
1248-
bash: false,
1249-
webfetch: false,
1250-
},
1251-
},
1252-
},
1253-
}),
1254-
)
1255-
},
1256-
})
1257-
await withTestInstance({
1258-
directory: tmp.path,
1259-
fn: async (ctx) => {
1260-
const config = await load(ctx)
1261-
expect(config.agent?.["test"]?.permission).toEqual({
1262-
bash: "deny",
1263-
webfetch: "deny",
1264-
})
1265-
},
1266-
})
1267-
})
1215+
const config = yield* Config.Service.use((svc) => svc.get())
1216+
expect(config.agent?.["test"]?.permission).toEqual({
1217+
bash: "allow",
1218+
read: "allow",
1219+
})
1220+
}),
1221+
)
1222+
1223+
it.instance("migrates legacy tools config to permissions - deny", () =>
1224+
Effect.gen(function* () {
1225+
const test = yield* TestInstance
1226+
yield* writeConfigEffect(test.directory, {
1227+
$schema: "https://opencode.ai/config.json",
1228+
agent: { test: { tools: { bash: false, webfetch: false } } },
1229+
})
1230+
1231+
const config = yield* Config.Service.use((svc) => svc.get())
1232+
expect(config.agent?.["test"]?.permission).toEqual({
1233+
bash: "deny",
1234+
webfetch: "deny",
1235+
})
1236+
}),
1237+
)
12681238

12691239
it.instance("migrates legacy write tool to edit permission", () =>
12701240
Effect.gen(function* () {

perf/test-suite.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Repeated setup work, long sleeps/timeouts, serial integration tests, filesystem/
8181
| Managed settings config cases can use Effect-aware instance fixtures | Migrated managed override and missing-managed-file cases to `it.instance` | 2.40s | 1.76s | keep | Single baseline before edit; after median from three sequential reruns (1.75, 1.76, 1.80). |
8282
| Local plugin and subagent config fixtures can use Effect-aware instance fixtures | Migrated scoped npm plugin and custom subagent markdown cases to `it.instance` | 2.37s | 1.67s | keep | Single baseline before edit; after median from three sequential reruns (1.66, 1.67, 1.67). |
8383
| MCP merge config cases can use Effect-aware instance fixtures | Migrated three MCP merge/override cases to `it.instance` | 1.98s | 1.95s | keep | Neutral timing within noise; removes manual `tmpdir` + `withTestInstance` setup from isolated filesystem-only config cases. |
84+
| Remaining legacy tools config cases can use Effect-aware instance fixtures | Migrated allow/deny legacy `tools` permission cases to `it.instance` | 2.65s | 1.90s | keep | Single baseline before edit; after median from three sequential reruns (2.58, 1.90, 1.90). |
8485

8586
## Profiling Results
8687

0 commit comments

Comments
 (0)