-
Notifications
You must be signed in to change notification settings - Fork 4.4k
fix(init): only advertise slash commands the profile installs #1410
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
Merged
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@fission-ai/openspec": patch | ||
| --- | ||
|
|
||
| Only advertise onboarding commands that will actually exist. The `openspec init` welcome screen and the `openspec update` "Getting started" summary listed `/opsx:new` and `/opsx:continue`, which the default `core` profile never generates, so users were told to run commands that did not exist. Both surfaces now list the commands for the installed workflows. The `init` and `update` completion hints also name the skill (`/openspec-propose`) instead of a command for tools that receive no command files — Codex, and any tool under skills-only delivery. |
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,50 @@ | ||
| /** | ||
| * Onboarding command hints. | ||
| * | ||
| * The commands shown to a user after setup must be limited to the workflows | ||
| * their profile actually installs, otherwise we advertise slash commands that | ||
| * were correctly never generated. | ||
| * | ||
| * This module decides WHICH hints to show. How each one is spelled for a given | ||
| * tool — command, skill, or a tool-specific skill prefix — is decided by | ||
| * src/utils/command-references.ts at the call site. | ||
| */ | ||
|
|
||
| import type { WorkflowId } from './profiles.js'; | ||
|
|
||
| export type OnboardingCommand = { | ||
| workflow: WorkflowId; | ||
| command: string; | ||
| description: string; | ||
| }; | ||
|
|
||
| /** | ||
| * Longest description the welcome screen can render. It shows these beside a | ||
| * 24-column art column and only animates at MIN_WIDTH (60) columns or wider; a | ||
| * longer line wraps, and the animation's cursor-up count assumes unwrapped | ||
| * lines. See src/ui/welcome-screen.ts. | ||
| */ | ||
| export const DESCRIPTION_BUDGET = 17; | ||
|
|
||
| /** | ||
| * Ordered onboarding hints. Each entry is shown only when its workflow is | ||
| * installed, so the list follows the change lifecycle: start, then build, | ||
| * then implement. | ||
| */ | ||
| const ONBOARDING_COMMANDS: readonly OnboardingCommand[] = [ | ||
| { workflow: 'propose', command: '/opsx:propose', description: 'Start a change' }, | ||
| { workflow: 'new', command: '/opsx:new', description: 'Scaffold a change' }, | ||
| { workflow: 'continue', command: '/opsx:continue', description: 'Next artifact' }, | ||
| { workflow: 'apply', command: '/opsx:apply', description: 'Implement tasks' }, | ||
| ]; | ||
|
|
||
| /** | ||
| * Returns the onboarding hints for the installed workflows, in lifecycle order. | ||
| * Returns an empty array when none of the onboarding workflows are installed. | ||
| */ | ||
| export function getOnboardingCommands( | ||
| workflows: readonly string[] | ||
| ): OnboardingCommand[] { | ||
| const installed = new Set(workflows); | ||
| return ONBOARDING_COMMANDS.filter((entry) => installed.has(entry.workflow)); | ||
| } |
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,43 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { | ||
| DESCRIPTION_BUDGET, | ||
| getOnboardingCommands, | ||
| } from '../../src/core/onboarding-commands.js'; | ||
| import { ALL_WORKFLOWS, CORE_WORKFLOWS } from '../../src/core/profiles.js'; | ||
|
|
||
| describe('getOnboardingCommands', () => { | ||
| it('omits commands the profile does not install', () => { | ||
| const commands = getOnboardingCommands(CORE_WORKFLOWS).map((c) => c.command); | ||
|
|
||
| expect(commands).toEqual(['/opsx:propose', '/opsx:apply']); | ||
| expect(commands).not.toContain('/opsx:new'); | ||
| expect(commands).not.toContain('/opsx:continue'); | ||
| }); | ||
|
|
||
| it('includes expanded commands when a custom profile installs them', () => { | ||
| const commands = getOnboardingCommands(['new', 'continue', 'apply']).map((c) => c.command); | ||
|
|
||
| expect(commands).toEqual(['/opsx:new', '/opsx:continue', '/opsx:apply']); | ||
| }); | ||
|
|
||
| it('returns lifecycle order regardless of the order workflows are given', () => { | ||
| const commands = getOnboardingCommands(['apply', 'continue', 'propose']).map((c) => c.command); | ||
|
|
||
| expect(commands).toEqual(['/opsx:propose', '/opsx:continue', '/opsx:apply']); | ||
| }); | ||
|
|
||
| it('returns nothing when no onboarding workflow is installed', () => { | ||
| expect(getOnboardingCommands(['archive', 'sync'])).toEqual([]); | ||
| expect(getOnboardingCommands([])).toEqual([]); | ||
| }); | ||
|
|
||
| it('keeps descriptions within the welcome screen width budget', () => { | ||
| // A longer description wraps the welcome screen at 60 columns, which desyncs | ||
| // its animation. See the width test in test/ui/welcome-screen.test.ts. | ||
| for (const { command, description } of getOnboardingCommands(ALL_WORKFLOWS)) { | ||
| expect(description.length, `${command} description is too long`).toBeLessThanOrEqual( | ||
| DESCRIPTION_BUDGET | ||
| ); | ||
| } | ||
| }); | ||
| }); |
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.