Skip to content

feat: add OpenCode as a translator output target#30

Merged
santosomar merged 4 commits into
mainfrom
feat/opencode-translator-output
Feb 26, 2026
Merged

feat: add OpenCode as a translator output target#30
santosomar merged 4 commits into
mainfrom
feat/opencode-translator-output

Conversation

@santosomar

@santosomar santosomar commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

Add OpenCode (https://opencode.ai/) as a supported output target in the convert_to_ide_formats.py translator pipeline, closing #29.

  • Create OpenCodeFormat class that generates rule .md files into .opencode/skills/software-security/rules/
  • Generate OpenCode-compliant SKILL.md with validated frontmatter (name, description, license, compatibility, metadata)
  • Validate skill names against OpenCode spec regex (^[a-z0-9]+(-[a-z0-9]+)*$, 1-64 chars)
  • Enforce description length limit (1-1024 chars)
  • Include language-to-rules mapping table in SKILL.md
  • Wire OpenCode into the pipeline alongside Agent Skills (core only)

Output structure

dist/.opencode/skills/software-security/
├── SKILL.md
└── rules/
├── codeguard-0-.md (20 context-specific rules)
└── codeguard-1-.md (3 always-apply rules)

Files changed

File Change
src/formats/opencode.py New — OpenCodeFormat class, name validation, description truncation
src/formats/__init__.py Updated — export OpenCodeFormat
src/convert_to_ide_formats.py Updated — wire OpenCode into pipeline, generate_opencode_skill_md()

Test plan

  • Run python src/convert_to_ide_formats.py --source core — all 23 rules convert successfully
  • Verify .opencode/skills/software-security/SKILL.md has valid OpenCode frontmatter
  • Verify rules/ directory contains all 23 rule files with preserved frontmatter
  • Confirm rule files are identical between Agent Skills and OpenCode outputs (diff shows no differences)
  • Confirm existing format outputs (Cursor, Windsurf, Copilot, Antigravity, Agent Skills) are unaffected

Add OpenCode (https://opencode.ai/) as a supported output target in the
convert_to_ide_formats.py translator pipeline, closing #29.

- Create OpenCodeFormat class that generates rule .md files into
  .opencode/skills/software-security/rules/
- Generate OpenCode-compliant SKILL.md with validated frontmatter
  (name, description, license, compatibility, metadata)
- Validate skill names against OpenCode spec regex
  (^[a-z0-9]+(-[a-z0-9]+)*$, 1-64 chars)
- Enforce description length limit (1-1024 chars)
- Include language-to-rules mapping table in SKILL.md
- Wire OpenCode into the pipeline alongside Agent Skills (core only)

Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds OpenCode as a new output target to the rule translation pipeline so core Project CodeGuard rules can be distributed in OpenCode’s expected .opencode/skills/<skill>/ structure alongside existing IDE/agent formats.

Changes:

  • Introduces OpenCodeFormat to emit rule .md files under dist/.opencode/skills/software-security/rules/.
  • Adds OpenCode SKILL.md generation with OpenCode-compliant frontmatter plus language-to-rules mapping injection.
  • Wires OpenCode into convert_to_ide_formats.py (core-only, alongside Agent Skills).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/formats/opencode.py Adds OpenCode rule-format writer plus skill-name validation and description truncation helpers.
src/formats/__init__.py Exports OpenCodeFormat from the formats package.
src/convert_to_ide_formats.py Integrates OpenCode into conversion flow and generates OpenCode-specific SKILL.md.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/convert_to_ide_formats.py Outdated
Comment thread src/convert_to_ide_formats.py Outdated
Comment thread src/convert_to_ide_formats.py Outdated
@jorcleme

Copy link
Copy Markdown

Thanks for picking this up so quickly, @santosomar . I just reviewed the diff and this is exactly what I had in mind when I filed #29. The OpenCodeFormat class follows the existing translator patterns nicely, name validation matches OpenCode spec and has compliant frontmatter.

Appreciate you and @thomas-bartlett jumping on this - excited to see OpenCode supported alongside other IDE targets.

@thomas-bartlett thomas-bartlett left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The skills approach works well, even though the rules/ subdirectory pattern isn't explicitly documented. OpenCode's skill tool discovers bundled files in the skill directory at runtime. One caveat: file discovery is capped at 10, but the language mapping table in SKILL.md references all rules by name so the agent can still load them by path.

An alternative would be an opencode.json with remote URLs (see Custom Instructions):

  • Pro: no local files needed, users always get the latest rules automatically
  • Con: all 23 rules are injected into context every session, ignoring language scoping

The skills approach is the better fit to avoid polluting the context, but the current implementation can be simplified:

  • Rule files are identical to Agent Skills output -- OpenCodeFormat should inherit from AgentSkillsFormat and only override get_format_name() and get_output_subpath(), no other changes needed
  • generate_opencode_skill_md() can be removed: the dist just needs skills/ copied under .opencode/ with an OpenCode-compliant SKILL.md (frontmatter fields differ slightly from Agent Skills)

Happy to implement the simplified skills approach if that helps.

@thomas-bartlett

Copy link
Copy Markdown
Contributor

Built on @santosomar's initial implementation. Simplified OpenCodeFormat to inherit from AgentSkillsFormat (removing duplicated logic) and replaced custom SKILL.md generation with a copy of the Agent Skills output. Also added:

  • CI/CD: OpenCode zip bundling, auto-updates, and validation
  • Docs: per-tool installation tabs, OpenCode remote instructions option, terminology cleanup
  • Issue templates: added OpenCode to tool dropdown

@santosomar

Copy link
Copy Markdown
Contributor Author

Thank you so much, @thomas-bartlett !

@santosomar

Copy link
Copy Markdown
Contributor Author

Please do a final review @ramraaj25 @aacarter1

@ramraaj25 ramraaj25 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Thank You

@santosomar santosomar merged commit 8b9a9ba into main Feb 26, 2026
2 checks passed
@santosomar santosomar deleted the feat/opencode-translator-output branch February 26, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Add OpenCode as a Translator Output Target

5 participants