Skip to content

feat: Add Opencode Plugin#21

Merged
Tomáš Ďuriš (TommYDeeee) merged 10 commits into
gendigitalinc:mainfrom
FeiyouG:main
Mar 3, 2026
Merged

feat: Add Opencode Plugin#21
Tomáš Ďuriš (TommYDeeee) merged 10 commits into
gendigitalinc:mainfrom
FeiyouG:main

Conversation

@FeiyouG

Copy link
Copy Markdown
Contributor

Summary

  • Integrates Sage guardrails into OpenCode tool calls via a new OpenCode plugin.
  • Aligns verdict handling with existing hooks: tool.execute.before and experimental.text.complete.
  • Adds OpenCode tools: sage_approve, sage_allowlist_add, and sage_allowlist_remove.

Tests

- Create opencode plugin for
  - Plugin scans on session starts
  - Tool evaluation on tool.execute.before
  - Temporarily allow tool execution via sage_approve
  - Permanently allow tool execution via sage_allowlist_add
- Create unit, integration, and e2e tests
- insert plugin scan result at text.complete
- update walkPluginFiles to also handle the case when installPath is a
  file
- Update instructions for install Opencode Plugin
- fix linting issues

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR, really appreciate it! I have left few notes bellow. Once it is sorted it looks good!

Regarding the:

  • Added E2E tests for the plugin, but they currently cannot pass due to an unaddressed upstream OpenCode bug

Do you expect this to be resolved and addressed in other PR (or here?) once it can be? For now those tests probably can be marked to be skipped.

Comment thread packages/opencode/src/index.ts Outdated
Comment thread packages/opencode/src/logger-adaptor.ts Outdated
Comment thread packages/core/src/heuristics.ts Outdated
Comment thread packages/claude-code/src/__tests__/e2e.test.ts Outdated
Comment thread packages/core/src/plugin-scanner.ts
Comment thread packages/opencode/src/__tests__/e2e.test.ts Outdated
Comment thread packages/opencode/src/index.ts Outdated
Comment thread packages/opencode/src/__tests__/e2e.test.ts Outdated
@FeiyouG

Copy link
Copy Markdown
Contributor Author

Thanks, Tomáš Ďuriš (@TommYDeeee). I’ve addressed all of the review comments.

I also found a workaround for the --command flag issue in OpenCode, and the E2E tests are now passing locally on my machine.

Please let me know if you have any further comments or suggestions.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks, now just the small typo (nitpick) and it can be merged.

@FeiyouG

Copy link
Copy Markdown
Contributor Author

Oh right my bad. It is now fixed.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for your contribution! I have to ask you to address a few issues, two of which are major.

Major:

  • fragile handling of Sage's verdict via try/catch could lead to a security hole if the message changes
  • sage_approve is inferior to a proper ask which seems to be supported by OpenCode

Minor:

  • closing tag in the prompt/instructions

Comment thread packages/opencode/src/index.ts Outdated
Comment thread packages/opencode/src/startup-scan.ts
Comment thread packages/opencode/src/index.ts
Comment thread packages/opencode/src/tool-handler.ts
- Fix cache dir resolution on plugin-scan
- Refactor E2E test structure to parse opencode output as JSON

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thank you

@TommYDeeee
Tomáš Ďuriš (TommYDeeee) merged commit ca03c44 into gendigitalinc:main Mar 3, 2026
1 check passed
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.

3 participants