Skip to content

Commit e171bd4

Browse files
committed
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 <[email protected]>
1 parent 8f3c150 commit e171bd4

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎src/cli/client_adapter.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,11 @@ char *cbm_client_adapter_opencode(const char *binary_path) {
303303
sb_append(
304304
&sb, "export default {\n"
305305
" id: 'codebase-memory-augment',\n"
306-
" async setup(ctx) {\n"
306+
" // V2 config loader: requires id + setup|effect; no tool domain yet\n"
307+
" // at this point, so there is nothing to register here.\n"
308+
" setup() {},\n"
309+
" // Server runtime: reads default.server and dispatches the hooks it returns.\n"
310+
" server: async (ctx) => {\n"
307311
" const dir = ctx?.directory;\n"
308312
" const seen = new Set();\n"
309313
" const lifecycle = () =>\n"

‎tests/test_agent_clients.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,11 @@ TEST(client_adapter_opencode_exports_the_v2_default_definition_issue2077) {
13231323
ASSERT_NOT_NULL(js);
13241324
ASSERT_NOT_NULL(strstr(js, "export default {"));
13251325
ASSERT_NOT_NULL(strstr(js, "id: 'codebase-memory-augment'"));
1326-
ASSERT_NOT_NULL(strstr(js, "async setup(ctx) {"));
1326+
/* Hooks live under server(), which the server runtime reads; setup()
1327+
* stays empty since the V2 config loader has no tool domain yet. */
1328+
ASSERT_NOT_NULL(strstr(js, "setup() {}"));
1329+
ASSERT_NOT_NULL(strstr(js, "server: async (ctx) => {"));
1330+
ASSERT_NULL(strstr(js, "async setup(ctx) {"));
13271331
ASSERT_NULL(strstr(js, "export const CodebaseMemory"));
13281332
free(js);
13291333
PASS();

0 commit comments

Comments
 (0)