Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describe('FinalizationCommand', () => {
const agentCommand = new FinalizationCommand({
logfile: undefined,
showAgentFollowUp: true,
showAiInstructions: false,
showAiInstructions: true,
});
vi.mocked(find.up).mockReturnValue(undefined);

Expand All @@ -127,6 +127,9 @@ describe('FinalizationCommand', () => {
expect.stringContaining('is not entirely set up yet')
);
expect(logger.step).toHaveBeenCalledWith(expect.stringContaining('npx storybook ai setup'));
const logCalls = vi.mocked(logger.log).mock.calls.map((c) => String(c[0]));
expect(logCalls.some((msg) => msg.includes('https://storybook.js.org/llms.txt'))).toBe(true);
expect(logCalls.some((msg) => msg.includes('https://discord.gg/storybook/'))).toBe(false);
});

it('should show standard success message when showAgentFollowUp=false with AI instructions', async () => {
Expand Down Expand Up @@ -163,6 +166,10 @@ describe('FinalizationCommand', () => {
// Ensure the agent message is NOT shown
const stepCalls = vi.mocked(logger.step).mock.calls.map((c) => String(c[0]));
expect(stepCalls.some((msg) => msg.includes('is not entirely set up yet'))).toBe(false);
const logCalls = vi.mocked(logger.log).mock.calls.map((c) => String(c[0]));
expect(logCalls.some((msg) => msg.includes('https://storybook.js.org/'))).toBe(true);
expect(logCalls.some((msg) => msg.includes('https://discord.gg/storybook/'))).toBe(true);
expect(logCalls.some((msg) => msg.includes('https://storybook.js.org/llms.txt'))).toBe(false);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,17 @@ export class FinalizationCommand {
logger.log(`To run Storybook, run ${CLI_COLORS.cta(storybookCommand)}. CTRL+C to stop.`);
}

logger.log(dedent`
// We don't want to tell agents about Discord, and we want to customise their docs URL.
if (this.options.showAiInstructions) {
logger.log(dedent`
Official documentation reference: ${CLI_COLORS.cta('https://storybook.js.org/llms.txt')}
`);
} else {
logger.log(dedent`
Want to learn more about Storybook? ${CLI_COLORS.cta('https://storybook.js.org/')}
Having trouble or want to chat? ${CLI_COLORS.cta('https://discord.gg/storybook/')}
`);
}
Comment thread
Sidnioulz marked this conversation as resolved.
Comment on lines +106 to +116
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Use the agent-mode flag for this branch, not showAiInstructions

At Line 107, the condition is keyed to showAiInstructions (AI feature opt-in), but the intent/comment is “don’t tell agents about Discord.” Based on code/lib/create-storybook/src/initiate.ts:154-162, agent mode is represented by showAgentFollowUp, so this can hide human docs/Discord for non-agent users who enabled AI.

Suggested fix
-    if (this.options.showAiInstructions) {
+    if (this.options.showAgentFollowUp) {
       logger.log(dedent`
       Official documentation reference: ${CLI_COLORS.cta('https://storybook.js.org/llms.txt')}
     `);
     } else {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// We don't want to tell agents about Discord, and we want to customise their docs URL.
if (this.options.showAiInstructions) {
logger.log(dedent`
Official documentation reference: ${CLI_COLORS.cta('https://storybook.js.org/llms.txt')}
`);
} else {
logger.log(dedent`
Want to learn more about Storybook? ${CLI_COLORS.cta('https://storybook.js.org/')}
Having trouble or want to chat? ${CLI_COLORS.cta('https://discord.gg/storybook/')}
`);
}
// We don't want to tell agents about Discord, and we want to customise their docs URL.
if (this.options.showAgentFollowUp) {
logger.log(dedent`
Official documentation reference: ${CLI_COLORS.cta('https://storybook.js.org/llms.txt')}
`);
} else {
logger.log(dedent`
Want to learn more about Storybook? ${CLI_COLORS.cta('https://storybook.js.org/')}
Having trouble or want to chat? ${CLI_COLORS.cta('https://discord.gg/storybook/')}
`);
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@code/lib/create-storybook/src/commands/FinalizationCommand.ts` around lines
106 - 116, The branch is using this.options.showAiInstructions but should use
the agent-mode flag; update the condition on the FinalizationCommand code block
to check this.options.showAgentFollowUp instead of
this.options.showAiInstructions so agents see the LLM docs URL
(https://storybook.js.org/llms.txt) and non-agent users see the human
docs/Discord message; keep the existing logger.log/dedent strings intact.


if (this.options.showAiInstructions) {
logger.step(dedent`To finalize setting up with AI, paste this prompt to your AI agent:
Expand Down
Loading