-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix(adapters): reference slash commands by the names each tool registers #1471
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
Merged
+998
−200
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bf2b09a
fix(adapters): reference slash commands by the names each tool registers
clay-good 6ce948a
docs: name the per-tool invocation exceptions in the table itself
clay-good 4e5e358
docs: make every invocation reference match what OpenSpec generates
clay-good 101fece
test: cover the update and migration paths a mutation run found ungua…
clay-good e4db819
test: assert the rewritten form, not just the absence of the old one
clay-good a264853
fix(adapters): spell Amazon Q's prompts with @, not as slash commands
clay-good f40e156
Merge branch 'main' into fix/command-invocation-parity
clay-good a7ebe52
fix(init): stop naming slash commands where none are registered
clay-good bc270ea
docs: name Amazon Q's @ form where the other exceptions are listed
clay-good 8fea739
test(migration): cover the legacy-upgrade hint for amazon-q
clay-good File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /** | ||
| * Command Invocation Styles | ||
| * | ||
| * How a tool spells an OpenSpec slash command is decided by the file the | ||
| * adapter writes, not by a list maintained by hand: | ||
| * | ||
| * - `.../commands/opsx/<id>.md` — the directory namespaces the command, so the | ||
| * tool registers `/opsx:<id>` (Claude Code, Gemini, Crush, ...). | ||
| * - `.../commands/opsx-<id>.md` — the filename *is* the command name, so the | ||
| * tool registers `/opsx-<id>` (Cursor, GitHub Copilot, OpenCode, ...). | ||
| * | ||
| * Deriving the style from `getFilePath` keeps generated cross-references and | ||
| * onboarding hints in step with the files OpenSpec actually writes. A | ||
| * hand-maintained list drifted before: only OpenCode was rewritten when the | ||
| * hyphen form was introduced (#727), and Cursor still advertised `/opsx:` | ||
| * commands its palette never registered (#1307). | ||
| */ | ||
|
|
||
| import path from 'path'; | ||
| import type { ToolCommandAdapter } from './types.js'; | ||
|
|
||
| export type CommandInvocationStyle = 'namespaced' | 'flat'; | ||
|
|
||
| /** | ||
| * Classifies a generated command file by the name the tool will answer to. | ||
| * | ||
| * @param commandFilePath - Path returned by an adapter's `getFilePath` | ||
| * @returns 'flat' when the filename carries the `opsx-` prefix, otherwise | ||
| * 'namespaced' | ||
| */ | ||
| export function getInvocationStyleForPath(commandFilePath: string): CommandInvocationStyle { | ||
| return path.basename(commandFilePath).startsWith('opsx-') ? 'flat' : 'namespaced'; | ||
| } | ||
|
|
||
| /** | ||
| * Classifies an adapter by the command files it writes. | ||
| * | ||
| * @param adapter - The tool-specific command adapter | ||
| * @returns The invocation style the tool's command files produce | ||
| */ | ||
| export function getInvocationStyleForAdapter(adapter: ToolCommandAdapter): CommandInvocationStyle { | ||
| // Any command id works: every adapter applies one naming rule to all of them. | ||
| return getInvocationStyleForPath(adapter.getFilePath('explore')); | ||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.