-
Notifications
You must be signed in to change notification settings - Fork 6k
feat: add .claude/commands/ compatibility for command discovery #6990
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
base: dev
Are you sure you want to change the base?
Conversation
Add support for Claude Code compatible command paths: - .claude/commands/ (project-level) - ~/.claude/commands/ (global) OpenCode native paths take precedence over Claude-compatible paths. Fixes anomalyco#6985
|
The following comment was made by an LLM, it may be inaccurate: Duplicate PR Search ResultsPOTENTIAL RELATED PR FOUND:
OTHER POTENTIALLY RELEVANT PRs:
Recommendation: Verify PR #6963 carefully, as it may already address some of the command discovery issues this PR is fixing, or they may be working on different aspects of the same feature. |
|
Thanks for flagging #6963! I checked it - there's significant overlap in the Key difference:
I believe OpenCode should take precedence (matching how skills work), allowing users to override Claude Code commands with OpenCode-specific versions. Happy to coordinate with the author of #6963 or close this if they update their PR with the correct precedence order. |
| // Load Claude-compatible commands first (lower precedence) | ||
| // OpenCode commands loaded later will override these | ||
| for (const dir of await getClaudeDirectories()) { | ||
| result.command = mergeDeep(result.command ?? {}, await loadCommand(dir)) | ||
| } | ||
|
|
||
| for (const dir of unique(directories)) { |
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.
Claude commands aren't opencode compatible, if we are gonna read them then we need to translate them
These tests document the expected behavior for translating Claude Code's allowed-tools field to OpenCode's permission system. Related: anomalyco#6990 (comment) Tests: - translates claude allowed-tools to opencode command permissions (FAILS) - translates claude allowed-tools with multiple tool types (FAILS) - claude commands without allowed-tools have no permission field (PASSES)
TODOs for
|
| Claude Code | OpenCode |
|---|---|
Bash(git checkout:*) |
permission.bash: ["git checkout *"] |
Bash(gh issue list:*) |
permission.bash: ["gh issue list *"] |
TodoWrite |
permission.todowrite: "allow" |
Implementation TODOs:
- Add
permissionfield toCommandschema - Parse Claude's
allowed-toolssyntax inloadCommand() - Translate
Bash(pattern:*)to bash permission patterns - Translate simple tool names (e.g.,
TodoWrite) to"allow" - Emit warning for untranslatable patterns
- Make the failing tests pass
Let me know if you'd like me to proceed with the implementation or if you'd prefer a different approach!
I think PR #6963 should drop the Claude command-loading changes and just focus on fixing the CWD issue. Thanks for calling it out. |
Summary
Adds support for Claude Code compatible command paths, enabling seamless migration for users coming from Claude Code.
.claude/commands/(project-level)~/.claude/commands/(global)OpenCode native paths take precedence over Claude-compatible paths.
Fixes #6985
Changes
getClaudeDirectories()helper and integrated Claude command loading before OpenCode directories