Skip to content

feat: add OpenCode V2 adapter - #734

Open
ousamabenyounes wants to merge 1 commit into
DietrichGebert:mainfrom
ousamabenyounes:fix/issue-718
Open

feat: add OpenCode V2 adapter#734
ousamabenyounes wants to merge 1 commit into
DietrichGebert:mainfrom
ousamabenyounes:fix/issue-718

Conversation

@ousamabenyounes

Copy link
Copy Markdown
Contributor

Add a separate OpenCode V2 plugin export that injects the shared Ponytail instructions through the V2 session context hook. Preserve persisted mode handling and the existing V1 adapter.

Test verification (RED → GREEN)

With the fix reverted, the new test fails (RED):

TAP version 13
# Subtest: V2 adapter registers a unique plugin and injects the persisted mode
not ok 1 - V2 adapter registers a unique plugin and injects the persisted mode
  ---
  duration_ms: 1.07946
  type: 'test'
  location: '/home/ousama/www/public/ousamabenyounes/ponytail/tests/opencode-v2-plugin.test.js:41:1'
  failureType: 'hookFailed'
  error: "Cannot find module '/home/ousama/www/public/ousamabenyounes/ponytail/.opencode/v2/ponytail.mjs' imported from /home/ousama/www/public/ousamabenyounes/ponytail/tests/opencode-v2-plugin.test.js"
  code: 'ERR_MODULE_NOT_FOUND'
  stack: |-
    finalizeResolution (node:internal/modules/esm/resolve:274:11)
    moduleResolve (node:internal/modules/esm/resolve:859:10)
    defaultResolve (node:internal/modules/esm/resolve:983:11)
    #cachedDefaultResolve (node:internal/modules/esm/loader:731:20)
    ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
    ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:310:38)
    onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:664:36)
    TracingChannel.tracePromise (node:diagnostics_channel:350:14)
    ModuleLoader.import (node:internal/modules/esm/loader:663:21)
    defaultImportModuleDynamicallyForScript (node:internal/modules/esm/utils:235:31)
  ...
1..1
# tests 1
# suites 0
# pass 0
# fail 1
# cancelled 0
# skipped 0
# todo 0
# duration_ms 87.499084

With the fix applied, the test passes (GREEN):

GREEN attempt 1/2 (exit 0)
TAP version 13
# Subtest: V2 adapter registers a unique plugin and injects the persisted mode
ok 1 - V2 adapter registers a unique plugin and injects the persisted mode
  ---
  duration_ms: 11.759577
  type: 'test'
  ...
1..1
# tests 1
# suites 0
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms 134.866061

Full local suite

Command: node scripts/check-rule-copies.js && node scripts/check-versions.js && npm test

# tests 23
# suites 0
# pass 23
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms 115.320577

> ponytail-mcp@4.9.0 test
> node --test ./test/*.test.js

TAP version 13
# Subtest: resolveMode keeps valid intensities
ok 1 - resolveMode keeps valid intensities
  ---
  duration_ms: 3.530473
  type: 'test'
  ...
# Subtest: resolveMode falls back to a runtime intensity for off/unknown/empty
ok 2 - resolveMode falls back to a runtime intensity for off/unknown/empty
  ---
  duration_ms: 1.174411
  type: 'test'
  ...
# Subtest: buildInstructions returns the ruleset tagged with the resolved mode
ok 3 - buildInstructions returns the ruleset tagged with the resolved mode
  ---
  duration_ms: 1.280801
  type: 'test'
  ...
1..3
# tests 3
# suites 0
# pass 3
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms 111.474179

Fix #718

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plan OpenCode V2 plugin adapter

1 participant