From e72f1e68248167518564f37a7a4f0fd8aae1f9c6 Mon Sep 17 00:00:00 2001 From: van3hardy Date: Tue, 11 Aug 2026 22:09:32 -0400 Subject: [PATCH] test(opencode): assert init does not call shell and root plugin tools --- tests/scripts/build-opencode.test.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/scripts/build-opencode.test.js b/tests/scripts/build-opencode.test.js index b05fa8d1c..4a3aac797 100644 --- a/tests/scripts/build-opencode.test.js +++ b/tests/scripts/build-opencode.test.js @@ -62,12 +62,17 @@ function main() { assert.deepStrictEqual(Object.keys(mod).sort(), ["default"]) assert.strictEqual(typeof mod.default, "function") + let shellCalls = 0 const plugin = await mod.default({ client: { app: { log: () => {} } }, - $: async () => { throw new Error("$ must not be called during plugin init") }, + $: async () => { + shellCalls += 1 + throw new Error("$ must not be called during plugin init") + }, directory: process.cwd(), worktree: process.cwd(), }) + assert.strictEqual(shellCalls, 0, "$ must not be called during plugin init") assert.ok(plugin && typeof plugin === "object", "default export must return a plugin record") const expectedHooks = [ "file.edited", @@ -85,6 +90,18 @@ function main() { for (const hook of expectedHooks) { assert.strictEqual(typeof plugin[hook], "function", "missing hook: " + hook) } + assert.deepStrictEqual( + Object.keys(plugin.tool).sort(), + ["changed-files", "dependency-analyzer"], + "plugin.tool must expose exactly the custom tools" + ) + for (const toolName of ["changed-files", "dependency-analyzer"]) { + const toolDefinition = plugin.tool[toolName] + assert.ok(toolDefinition && typeof toolDefinition === "object", "missing tool: " + toolName) + assert.strictEqual(typeof toolDefinition.description, "string", toolName + " must declare a description") + assert.ok(toolDefinition.args && typeof toolDefinition.args === "object", toolName + " must declare args") + assert.strictEqual(typeof toolDefinition.execute, "function", toolName + " must declare an execute function") + } } main().catch((error) => {