-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix(opencode): transform command references from colon to hyphen format #626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(opencode): transform command references from colon to hyphen format #626
Conversation
📝 WalkthroughWalkthroughThis PR implements a transformation system for OpenCode command references, converting Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review CompleteYour review story is ready! Comment !reviewfast on this PR to re-generate the story. |
Greptile OverviewGreptile SummaryThis PR fixes command reference inconsistency in OpenCode by transforming Key Changes:
Implementation Quality:
Verification:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant InitUpdate as init.ts / update.ts
participant SkillGen as skill-generation.ts
participant OpenCodeAdapter as opencode.ts adapter
participant Transformer as transformToHyphenCommands()
participant FileSystem as File System
User->>InitUpdate: Run openspec init/update --tools opencode
Note over InitUpdate: Skill Generation Flow
InitUpdate->>InitUpdate: Check if tool.value === 'opencode'
InitUpdate->>SkillGen: generateSkillContent(template, version, transformToHyphenCommands)
SkillGen->>Transformer: transformInstructions(template.instructions)
Transformer->>Transformer: Replace /opsx: with /opsx-
Transformer-->>SkillGen: Transformed instructions
SkillGen-->>InitUpdate: Skill content with /opsx- references
InitUpdate->>FileSystem: Write skill file to .opencode/skills/
Note over InitUpdate: Command Generation Flow
InitUpdate->>OpenCodeAdapter: formatFile(commandContent)
OpenCodeAdapter->>Transformer: transformToHyphenCommands(content.body)
Transformer->>Transformer: Replace /opsx: with /opsx-
Transformer-->>OpenCodeAdapter: Transformed body
OpenCodeAdapter-->>InitUpdate: Formatted command with /opsx- references
InitUpdate->>FileSystem: Write command file to .opencode/command/
FileSystem-->>User: OpenCode files with consistent /opsx- syntax
|
| // Use hyphen-based command references for OpenCode | ||
| const transformer = tool.value === 'opencode' ? transformToHyphenCommands : undefined; | ||
| const skillContent = generateSkillContent(template, OPENSPEC_VERSION, transformer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach works for the immediate fix, but we should look into a more robust way to handle tool-specific transformations as we add support for more tools, similar to how it's handled in src/core/command-generation/.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@webrgp Yeah you're right, it's something I mentioned here as well: #603 (comment)
Didn't think this would bite us back so soon. The way you've done it makes sense, but yes we need to find a better way to handle these transformations between different coding agents.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, totally agree! This was a quick fix to unblock things, but it's definitely not the long-term solution.
I like the idea of mirroring what we already have for commands - basically a skill adapter system that sits alongside the command adapters. Each tool could have its own adapter that knows how to transform content if needed. That way we keep all the tool-specific quirks in one place instead of sprinkling if (tool === 'opencode') checks everywhere.
Happy to open an issue or start a change for this if you want!
TabishB
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is amazing thank you, you're right though that this dosen't fix this problem at the root. I think we need to find a better pattern to do this reliably for all coding agent.s
|
@webrgp Seems like there's quite a few HappyCog folks using OpenSpec! Would love to setup a slack-connect channel here if you guys are keen! I've sent an email to Kyle from HappyCog since I had his email on file from the waitlist, but let me know if I should reach out to someone else! |
Summary
/opsx-new) instead of colon format (/opsx:)transformToHyphenCommands()utility for consistent transformationChanges
src/utils/command-references.ts- Shared transformation utilityWhy
OpenCode uses hyphen-based command syntax but templates use colon-based format, causing inconsistency in generated files.
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.