fix(opencode): generate slash-command stubs for each skill
Problem
When installing the compound-engineering plugin to OpenCode, zero slash commands were written to ~/.config/opencode/commands/. The convertClaudeToOpenCode function only consumed plugin.commands (a commands/ directory), but the CE plugin ships only skills — so users had no /ce-work, /ce-plan, etc. available in OpenCode, even though all 54 skills were correctly installed.
Solution
Added convertSkillsToCommands(skills: ClaudeSkill[]): OpenCodeCommandFile[] that generates one slash-command stub per skill. Each stub:
- Carries the skill's
descriptionas frontmatter - Forwards
argument-hintwhen present - Has a body that tells the model to load and execute the named skill, with
$ARGUMENTSpassed through
Skills with disable-model-invocation: true are excluded. Platform-filtered skills (e.g. ce_platforms: [claude]) never reach the function.
The generated stubs are merged with any convertCommands() output in convertClaudeToOpenCode, so plugins that have both a commands/ directory and skills get both.
Tests
- Updated the existing "current compound-engineering output" test to assert
commandFiles.length > 0and≤ skillDirs.length - Added a new test asserting
skill-onegenerates a command with correct frontmatter, and thatdisabled-skill/claude-only-skillare absent fromcommandFiles - All 1338 tests pass
Does this handle the cleanup properly when skills change (renamed or deleted)?
@tmchow Yes — cleanup rides the existing managed-install-manifest plumbing.
convertSkillsToCommands produces OpenCodeCommandFile[] that get appended to bundle.commandFiles (claude-to-opencode.ts:104-110). The writer then:
- Builds
currentCommandsfrombundle.commandFiles(opencode.ts:73) - Calls
cleanupRemovedManagedFiles(commandDir, manifest, "commands", currentCommands)before writing (opencode.ts:79) — anything in the prior manifest'scommandsgroup that's not in the newcurrentCommandsgetsfs.rm-ed - Rewrites the manifest with the current set (
opencode.ts:135-144)
So:
| Scenario | Behavior |
|---|---|
| Skill renamed | Old stub path drops out of currentCommands → removed; new path written and tracked |
| Skill deleted | Old stub path drops out → removed |
Skill gains disable-model-invocation / user-invocable: false |
Filtered out of stubs (claude-to-opencode.ts:184-185) → removed on next install |
| First upgrade from a pre-776 install | Prior manifest had commands: [], so cleanup is a no-op; the 54 stubs become tracked from this install onward |
Test coverage for this contract already exists at tests/opencode-writer.test.ts:359 ("removes previously managed OpenCode artifacts that disappear on reinstall") — it writes old:cmd, re-installs with new:cmd only, and asserts commands/old/cmd.md is gone. Stubs ride the same path; nothing in this PR changes the writer/manifest contract, only what feeds into it.
One small caveat (pre-existing, not introduced here): cleanupRemovedManagedFiles removes files but doesn't prune empty parent dirs, so a colon-namespaced rename (foo:bar → foo:baz) could leave an empty commands/foo/. Happy to fix that in a follow-up if it's worth it, but it applies to any nested command path, not just skill stubs.
@tmchow do you have any updates for me? Anything else I can do to wrap this up?
Verified on macOS — the fix works correctly.
Before this PR, my install-manifest.json had "commands": [].
After installing from this branch, the command stubs were generated under ~/.config/opencode/commands, each with proper description and argument-hint frontmatter.
All skills are now directly invocable via / commands in OpenCode.
Thanks @lucabattistini!