fix(opencode): use plural commands/ directory to match OpenCode convention#760
fix(opencode): use plural commands/ directory to match OpenCode convention#760fsilvaortiz wants to merge 2 commits intoFission-AI:mainfrom
Conversation
…vention The OpenCode adapter was using `.opencode/command/` (singular) but OpenCode's official documentation specifies `.opencode/commands/` (plural). This aligns with every other adapter in the codebase. Legacy cleanup updated to detect old singular-path artifacts. Fixes Fission-AI#748. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR corrects the OpenCode adapter to use the plural Key changes:
Quality notes:
Confidence Score: 5/5
Important Files Changed
Last reviewed commit: c58d3c8 |
|
|
||
| #### Scenario: Detect old singular-path OpenCode command files | ||
|
|
||
| - **WHEN** running legacy artifact detection on a project with files matching `.opencode/command/openspec-*.md` or `.opencode/command/opsx-*.md` |
There was a problem hiding this comment.
This scenario says we detect both openspec-* and opsx-* in .opencode/command/, but the implementation currently only has opsx-*. Can we align code and spec here so behavior is clear?
There was a problem hiding this comment.
Aligned — LegacySlashCommandPattern.pattern now accepts string | string[], and the opencode entry uses both patterns: ['.opencode/command/opsx-*.md', '.opencode/command/openspec-*.md']. Added 6 tests covering detection and tool ID mapping for both prefixes.
src/core/legacy-cleanup.ts
Outdated
| 'auggie': { type: 'files', pattern: '.augment/commands/openspec-*.md' }, | ||
| 'factory': { type: 'files', pattern: '.factory/commands/openspec-*.md' }, | ||
| 'opencode': { type: 'files', pattern: '.opencode/command/openspec-*.md' }, | ||
| 'opencode': { type: 'files', pattern: '.opencode/command/opsx-*.md' }, |
There was a problem hiding this comment.
Nice fix on the directory rename. One compatibility gap: this only matches .opencode/command/opsx-*.md. Some older installs may still have .opencode/command/openspec-*.md. Can we detect both so those users are migrated too?
There was a problem hiding this comment.
Done — same change as above. The opencode entry now detects both opsx-*.md and openspec-*.md in .opencode/command/. Both patterns map to the opencode tool ID, so legacy cleanup and tool re-detection work for either prefix. Verified with detectLegacyArtifacts and getToolsFromLegacyArtifacts.
|
|
||
| #### Scenario: Clean up old OpenCode command files on init | ||
|
|
||
| - **WHEN** a user runs `openspec init` in a project with old `.opencode/command/` artifacts |
There was a problem hiding this comment.
Can we also account for non-interactive openspec init here? Right now legacy artifacts cause init to exit unless --force is set. That could surprise existing /command users in CI. Either auto-handle this rename migration or call out the one-time --force requirement in release notes.
There was a problem hiding this comment.
Good call — handleLegacyCleanup now auto-cleans in non-interactive mode instead of aborting with exit 1. Legacy slash commands are 100% OpenSpec-managed, and config file cleanup only removes markers (never deletes files), so auto-cleanup is safe without --force.
Added a test verifying that openspec init --tools opencode in non-interactive mode cleans up .opencode/command/ legacy files and generates new ones at .opencode/commands/. Spec updated with the new scenario.
… in CI - Extend LegacySlashCommandPattern.pattern to accept string | string[] - OpenCode legacy entry now detects both opsx-*.md and openspec-*.md - Auto-cleanup legacy artifacts in non-interactive mode instead of aborting with exit 1 (safe: slash commands are OpenSpec-managed, config cleanup only removes markers) - Add 7 tests (6 legacy detection + 1 non-interactive init) - Update spec with array pattern support and auto-cleanup scenario Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughUpdates the OpenCode adapter to use the directory path Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
openspec/changes/fix-opencode-commands-directory/tasks.md (1)
7-7: Minor discrepancy: Task description doesn't fully reflect the implementation.The task description says to change the pattern from
openspec-*.mdtoopsx-*.md, but the actual implementation insrc/core/legacy-cleanup.tssupports both patterns as an array:['.opencode/command/opsx-*.md', '.opencode/command/openspec-*.md'].Consider updating this task description to accurately reflect that both legacy prefixes are now supported:
-- [x] 2.1 Update `src/core/legacy-cleanup.ts`: change the `'opencode'` entry in `LEGACY_SLASH_COMMAND_PATHS` from `'.opencode/command/openspec-*.md'` to `'.opencode/command/opsx-*.md'` to detect old singular-path artifacts with the current `opsx-*` prefix ++ [x] 2.1 Update `src/core/legacy-cleanup.ts`: update the `'opencode'` entry in `LEGACY_SLASH_COMMAND_PATHS` to detect both `opsx-*.md` and `openspec-*.md` patterns at `.opencode/command/` for backward compatibility🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@openspec/changes/fix-opencode-commands-directory/tasks.md` at line 7, Update the task description in tasks.md to match the implementation: state that LEGACY_SLASH_COMMAND_PATHS in src/core/legacy-cleanup.ts now supports both legacy patterns (the opsx-* prefix and the openspec-* prefix) rather than only replacing openspec-*.md with opsx-*.md, so reword the checklist item to explicitly mention both opsx-* and openspec-* patterns are supported.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@openspec/changes/fix-opencode-commands-directory/tasks.md`:
- Line 7: Update the task description in tasks.md to match the implementation:
state that LEGACY_SLASH_COMMAND_PATHS in src/core/legacy-cleanup.ts now supports
both legacy patterns (the opsx-* prefix and the openspec-* prefix) rather than
only replacing openspec-*.md with opsx-*.md, so reword the checklist item to
explicitly mention both opsx-* and openspec-* patterns are supported.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (13)
.changeset/fix-opencode-commands-directory.mddocs/supported-tools.mdopenspec/changes/fix-opencode-commands-directory/.openspec.yamlopenspec/changes/fix-opencode-commands-directory/design.mdopenspec/changes/fix-opencode-commands-directory/proposal.mdopenspec/changes/fix-opencode-commands-directory/specs/command-generation/spec.mdopenspec/changes/fix-opencode-commands-directory/tasks.mdsrc/core/command-generation/adapters/opencode.tssrc/core/init.tssrc/core/legacy-cleanup.tstest/core/command-generation/adapters.test.tstest/core/init.test.tstest/core/legacy-cleanup.test.ts
Summary
.opencode/command/(singular) to.opencode/commands/(plural) to match OpenCode's official directory conventionopsx-*.mdandopenspec-*.mdin old singular path (viastring | string[]pattern support)Fixes #748.
Test plan
pnpm vitest run test/core/command-generation/adapters.test.ts)pnpm vitest run test/core/legacy-cleanup.test.ts)pnpm vitest run test/core/init.test.ts)pnpm build)openspec init --tools opencodegenerates files at.opencode/commands/.opencode/command/opsx-*.mdartifacts.opencode/command/openspec-*.mdartifactsopencodetool ID (deduplicated)--force🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Documentation