From e171bd48b5e5845ec6f00db65ff300caac4f7304 Mon Sep 17 00:00:00 2001 From: Amir Fathi Date: Sun, 20 Sep 2026 09:15:32 +0000 Subject: [PATCH] fix(cli): move opencode plugin hooks under server(), leave setup() empty DeusData asked (2026-09-19T20:25:34Z on PR #2089) to place the hooks in the server entry rather than returning them from setup(), since the server runtime reads default.server and dispatches the hooks it returns, while the V2 config loader only reads id + setup()/effect() and has no tool domain yet to register against. Moved the existing hook body under server: async (ctx) => {...} and added an empty setup() {}. Updated the emission test to check for both and to assert the old async setup(ctx) { shape is gone. Signed-off-by: Amir Fathi --- src/cli/client_adapter.c | 6 +++++- tests/test_agent_clients.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cli/client_adapter.c b/src/cli/client_adapter.c index ed77bd67a..16f2b3ba0 100644 --- a/src/cli/client_adapter.c +++ b/src/cli/client_adapter.c @@ -303,7 +303,11 @@ char *cbm_client_adapter_opencode(const char *binary_path) { sb_append( &sb, "export default {\n" " id: 'codebase-memory-augment',\n" - " async setup(ctx) {\n" + " // V2 config loader: requires id + setup|effect; no tool domain yet\n" + " // at this point, so there is nothing to register here.\n" + " setup() {},\n" + " // Server runtime: reads default.server and dispatches the hooks it returns.\n" + " server: async (ctx) => {\n" " const dir = ctx?.directory;\n" " const seen = new Set();\n" " const lifecycle = () =>\n" diff --git a/tests/test_agent_clients.c b/tests/test_agent_clients.c index a1e4c4020..1cf5cab02 100644 --- a/tests/test_agent_clients.c +++ b/tests/test_agent_clients.c @@ -1323,7 +1323,11 @@ TEST(client_adapter_opencode_exports_the_v2_default_definition_issue2077) { ASSERT_NOT_NULL(js); ASSERT_NOT_NULL(strstr(js, "export default {")); ASSERT_NOT_NULL(strstr(js, "id: 'codebase-memory-augment'")); - ASSERT_NOT_NULL(strstr(js, "async setup(ctx) {")); + /* Hooks live under server(), which the server runtime reads; setup() + * stays empty since the V2 config loader has no tool domain yet. */ + ASSERT_NOT_NULL(strstr(js, "setup() {}")); + ASSERT_NOT_NULL(strstr(js, "server: async (ctx) => {")); + ASSERT_NULL(strstr(js, "async setup(ctx) {")); ASSERT_NULL(strstr(js, "export const CodebaseMemory")); free(js); PASS();