Skip to content

feat(opencode): add bridge adapter with hardened lifecycle plugin#29

Closed
aayoawoyemi wants to merge 13 commits into
mainfrom
fix/opencode-bridge-pr25
Closed

feat(opencode): add bridge adapter with hardened lifecycle plugin#29
aayoawoyemi wants to merge 13 commits into
mainfrom
fix/opencode-bridge-pr25

Conversation

@aayoawoyemi

Copy link
Copy Markdown
Owner

Supersedes external PR #25 with the same OpenCode bridge adapter plus review fixes.

Includes the PR #25 OpenCode bridge work:

  • ori bridge opencode
  • OpenCode MCP config writing/removal
  • lifecycle plugin install/uninstall
  • AGENTS.md bridge instructions
  • ori add --content, --content-file, and --content-stdin CLI wiring

Review fixes added here:

  • remove Windows shell: true command construction from lifecycle plugin
  • run ori via spawnSync(command, args, { shell: false }), with ori.cmd fallback on Windows
  • resolve vault path from any OpenCode MCP entry with ORI_VAULT or --vault, not only mcp.ori
  • bound write-validation to resolved files inside the vault root under notes/inbox/self/ops
  • update stale tests from session.idle to session.compacted/session.deleted

Verification:

  • node --check adapters/opencode/plugin/lifecycle.js
  • npm run build
  • npx vitest run tests/bridge.test.ts --environment node ✅ 37/37
  • npm test -- --run runs but still fails on pre-existing ambient failures unrelated to this branch: global vault discovery tests on this machine, activation decay date drift tests, and stale MCP tool-count expectation.

pktron and others added 13 commits May 18, 2026 10:56
Add ori bridge opencode command with full lifecycle parity to Claude Code integration.

- MCP config written to opencode.json (default ori entry)
- Lifecycle plugin at .opencode/plugins/lifecycle.js
  - session.created -> auto-orient
  - session.idle -> auto-capture
  - tool.execute.after (write) -> auto-validate
- Supports --scope project|global and --activation auto|manual
- Plugin reads ORI_VAULT from env, works with any named MCP entry
- Full test suite (7 new tests, 37 total bridge tests passing)
Plugin now reads vault path from opencode.json MCP config instead of
relying solely on process.env.ORI_VAULT. This fixes auto-orient failing
when the plugin runs in OpenCode's process context where the env var
isn't available.

- Adds getVaultPath() helper that checks env var first, then parses
  opencode.json to extract vault from command args or environment
- Adds error logging when no vault path is found
- Adds verbose logging for orient, capture, and validate operations
- Uses directory context parameter from OpenCode plugin API
ori orient is an MCP tool (ori_orient), not a CLI command. The plugin
was trying to run it via CLI which caused 'unknown option --vault' error.

Changes:
- Remove auto-orient CLI call from lifecycle plugin
- Auto-orient is handled by MCP instructions (identity auto-injected)
- Plugin now logs that ori_orient tool is available for manual use
- Update AGENTS.md instructions to reflect MCP-based orient
- Keep auto-capture (ori add) and auto-validate (ori validate) working
…te guard

- Replace $ shell executor with spawnSync for silent ori add/validate
- Implement isFirstRun() detection by parsing blank identity.md scaffold
- Inject ONBOARDING_PROMPT via client.session.prompt() on first session
- Add onboardedSessions Set guard to prevent duplicate prompt injection
- Update README, CHANGELOG, and cross-client docs
- Plugin had no access to session content; ori add --auto flag doesn't exist
- Session capture is now agent-driven via ori_add MCP tool with content param
- Updated cross-client docs and changelog
- Updated Godofredo methodology to clarify end-of-session capture
- Add Orient/Work/Persist rhythm structure to blank template
- Clarify ori_add must use content parameter (no template stubs)
- Add end-of-session capture step
- Ensures all fresh installs get the same methodology guidance
- Plugin now fetches session messages via client.session.messages()
- Builds conversation transcript (user + assistant text parts only)
- Calls ori add --content to save real content (not template stubs)
- Added --content flag to ori add CLI command
- Reverted scaffold methodology.md to blank template
- Updated changelog and cross-client docs
… piping

- Replace session.idle with session.compacted + session.deleted for reliable capture
- Add capturedSessions guard to prevent duplicate captures
- Fix Windows spawnSync with shell:true and quoted args for spaces
- Add --content-stdin and --content-file flags to ori add CLI
- Add debug logging to lifecycle.js for troubleshooting
- remove Windows shell command construction from lifecycle commands
- resolve vaults from any OpenCode MCP entry with ORI_VAULT or --vault
- validate only notes resolved under the vault root
- update OpenCode bridge test expectations for compacted/deleted capture hooks
@aayoawoyemi aayoawoyemi changed the title fix/opencode bridge pr25 feat(opencode): add bridge adapter with hardened lifecycle plugin Jun 21, 2026
@aayoawoyemi

Copy link
Copy Markdown
Owner Author

Closing-PR-per-new-workflow-branch-remains-pushed-for-review

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.

2 participants