fix(opencode): use plural commands directory per official docs#2495
Open
tinesoft wants to merge 1 commit into
Open
fix(opencode): use plural commands directory per official docs#2495tinesoft wants to merge 1 commit into
commands directory per official docs#2495tinesoft wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Opencode integration to follow Opencode’s current convention of using the plural .opencode/commands/ directory for custom slash commands, aligning Spec Kit’s generated paths and registrar configuration with official Opencode docs.
Changes:
- Change Opencode integration
commands_subdirfromcommand→commands. - Change Opencode registrar output directory from
.opencode/command→.opencode/commands. - Update Opencode integration test constants to match the new directory naming.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/specify_cli/integrations/opencode/__init__.py |
Updates Opencode integration config and registrar directory to .opencode/commands. |
tests/integrations/test_integration_opencode.py |
Updates test expectations for the new Opencode commands directory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The official opencode documentation specifies that custom commands should now be placed in a directory named `.opencode/commands`. Although previus path is still supported, it is recommended to use the plural form to ensure compatibility with future updates and to follow the standard convention. (See <https://opencode.ai/docs/config/#precedence-order>) Updated commands_subdir and registrar dir from `.opencode/command` to `.opencode/commands` to match opencode's canonical configuration.
17e5797 to
80671d5
Compare
Contributor
There was a problem hiding this comment.
Copilot's findings
Comments suppressed due to low confidence (2)
src/specify_cli/integrations/opencode/init.py:26
- shutil.rmtree(legacy) can raise (e.g., permissions, transient FS errors, or if the path is a symlink). Because this runs during setup(), a failure here will abort the install even though the new
.opencode/commandsfiles were created. Handle errors explicitly (and treat symlinks specially: either refuse to touch them or unlink the symlink itself) so setup is robust and doesn’t risk acting on unexpected filesystem types.
legacy = project_root / ".opencode" / "command"
if not legacy.is_dir():
return 0
count = sum(1 for _ in legacy.iterdir())
shutil.rmtree(legacy)
return count
src/specify_cli/integrations/opencode/init.py:56
- The PR description says this is a directory-name update and notes the old singular directory “still works for backwards compatibility”, but setup() now actively removes the legacy directory. If intentional, this behavior change should be called out explicitly in the PR description/release notes; otherwise consider dropping the deletion or making it opt-in to preserve backwards compatibility expectations.
def setup(
self,
project_root: Path,
manifest: IntegrationManifest,
parsed_options: dict[str, Any] | None = None,
**opts: Any,
) -> list[Path]:
"""Install commands and remove any legacy `.opencode/command` directory."""
created = super().setup(project_root, manifest, parsed_options=parsed_options, **opts)
_migrate_legacy_command_dir(project_root)
return created
- Files reviewed: 2/2 changed files
- Comments generated: 2
Comment on lines
+14
to
+19
| """Remove the legacy `.opencode/command` directory. | ||
|
|
||
| Called after setup() has already written canonical files to | ||
| `.opencode/commands/`. The legacy directory only ever contained | ||
| spec-kit-managed files, so it is safe to remove. | ||
| Returns the number of entries that were in the legacy directory. |
Comment on lines
+67
to
+91
| def test_removes_legacy_command_dir(self, tmp_path): | ||
| legacy = tmp_path / ".opencode" / "command" | ||
| legacy.mkdir(parents=True) | ||
| (legacy / "speckit.specify.md").write_text("old content") | ||
|
|
||
| removed = _migrate_legacy_command_dir(tmp_path) | ||
|
|
||
| assert removed == 1 | ||
| assert not legacy.exists() | ||
|
|
||
| def test_no_op_when_no_legacy_dir(self, tmp_path): | ||
| removed = _migrate_legacy_command_dir(tmp_path) | ||
| assert removed == 0 | ||
|
|
||
| def test_setup_removes_legacy_dir(self, tmp_path): | ||
| """OpencodeIntegration.setup() cleans up legacy .opencode/command/.""" | ||
| legacy = tmp_path / ".opencode" / "command" | ||
| legacy.mkdir(parents=True) | ||
| (legacy / "speckit.specify.md").write_text("old content") | ||
|
|
||
| i = get_integration("opencode") | ||
| m = IntegrationManifest("opencode", tmp_path) | ||
| i.setup(tmp_path, m) | ||
|
|
||
| assert not legacy.exists() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
opencode's official documentation specifies
.opencode/commands/(plural) as the directory for custom slash commands(see https://opencode.ai/docs/commands/). The integration was using the old singular form
.opencode/command, whichstill works for backwards compatibility but is no longer the recommended convention.
This updates
commands_subdirandregistrar_config["dir"]in the opencode integration, along with the correspondingtest constants.
Testing
uv run specify --helpuv sync && uv run pytestAll 23 opencode integration tests pass (
uv run python -m pytest tests/integrations/test_integration_opencode.py -q).AI Disclosure
Code changes and documentation research generated by Claude Code (Claude Sonnet 4.6). The AI verified the correct
directory name against the official opencode docs and confirmed backwards compatibility before making the change.