* feat(#785): write .cursor/commands/ as Cursor 1.6 slash-command surface Cursor 1.6 (released 2025-09-12) introduced plain-markdown slash commands in `.cursor/commands/<name>.md` — no frontmatter, invocable via `/` in the Agent input. GSD previously emitted only `~/.cursor/skills/` for Cursor. This PR wires a second artifact kind for `cursor` in `runtime-artifact-layout.cts`: `convertedCommandsKind('commands', 'gsd-', 'convertClaudeCommandToCursorCommand', configDir)`. The new kind applies the same `convertClaudeToCursorMarkdown` transforms (tool renames, brand substitution, slash-command normalisation) and then strips YAML frontmatter so the output is plain prose. Skills output is unchanged. `stageCommandsForRuntimeFlat` in `install-profiles.cts` stages each source `.md` as a flat `<stem>.md` in a temp dir; the existing `_copyStaged` commands path then prefixes and copies to `<configDir>/commands/`. `.cursor/mcp.json` is explicitly OUT OF SCOPE: GSD ships no MCP server; the `mcpServers` schema cannot be usefully populated by the installer. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor(#785): address review nit --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
154 lines
4.8 KiB
JavaScript
154 lines
4.8 KiB
JavaScript
/**
|
|
* Cursor conversion regression tests.
|
|
*
|
|
* Ensures Cursor frontmatter names are emitted as plain identifiers
|
|
* (without surrounding quotes), so Cursor does not treat quotes as
|
|
* literal parts of skill/subagent names.
|
|
*
|
|
* Also covers convertClaudeCommandToCursorCommand (#785 — Cursor 1.6
|
|
* slash commands via .cursor/commands/).
|
|
*/
|
|
|
|
process.env.GSD_TEST_MODE = '1';
|
|
|
|
const { describe, test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
|
|
const {
|
|
convertClaudeCommandToCursorSkill,
|
|
convertClaudeAgentToCursorAgent,
|
|
convertClaudeCommandToCursorCommand,
|
|
} = require('../bin/install.js');
|
|
|
|
describe('convertClaudeCommandToCursorSkill', () => {
|
|
test('writes unquoted Cursor skill name in frontmatter', () => {
|
|
const input = `---
|
|
name: quick
|
|
description: Execute a quick task
|
|
---
|
|
|
|
<objective>
|
|
Test body
|
|
</objective>
|
|
`;
|
|
|
|
const result = convertClaudeCommandToCursorSkill(input, 'gsd-quick');
|
|
const nameMatch = result.match(/^name:\s*(.+)$/m);
|
|
|
|
assert.ok(nameMatch, 'frontmatter contains name field');
|
|
assert.strictEqual(nameMatch[1], 'gsd-quick', 'skill name is plain scalar');
|
|
assert.ok(!result.includes('name: "gsd-quick"'), 'quoted skill name is not emitted');
|
|
});
|
|
|
|
test('preserves slash for slash commands in markdown body', () => {
|
|
const input = `---
|
|
name: gsd:plan-phase
|
|
description: Plan a phase
|
|
---
|
|
|
|
Next:
|
|
/gsd:execute-phase 17
|
|
/gsd-help
|
|
gsd:progress
|
|
`;
|
|
|
|
const result = convertClaudeCommandToCursorSkill(input, 'gsd-plan-phase');
|
|
|
|
assert.ok(result.includes('/gsd-execute-phase 17'), 'slash command remains slash-prefixed');
|
|
assert.ok(result.includes('/gsd-help'), 'existing slash command is preserved');
|
|
assert.ok(result.includes('gsd-progress'), 'non-slash gsd: references still normalize');
|
|
assert.ok(!result.includes('/gsd:execute-phase'), 'legacy colon command form is removed');
|
|
});
|
|
});
|
|
|
|
describe('convertClaudeAgentToCursorAgent', () => {
|
|
test('writes unquoted Cursor agent name in frontmatter', () => {
|
|
const input = `---
|
|
name: gsd-planner
|
|
description: Planner agent
|
|
tools: Read, Write
|
|
color: green
|
|
---
|
|
|
|
<role>
|
|
Planner body
|
|
</role>
|
|
`;
|
|
|
|
const result = convertClaudeAgentToCursorAgent(input);
|
|
const nameMatch = result.match(/^name:\s*(.+)$/m);
|
|
|
|
assert.ok(nameMatch, 'frontmatter contains name field');
|
|
assert.strictEqual(nameMatch[1], 'gsd-planner', 'agent name is plain scalar');
|
|
assert.ok(!result.includes('name: "gsd-planner"'), 'quoted agent name is not emitted');
|
|
});
|
|
});
|
|
|
|
// ─── convertClaudeCommandToCursorCommand (#785) ───────────────────────────────
|
|
|
|
describe('convertClaudeCommandToCursorCommand (#785 — Cursor 1.6 .cursor/commands/)', () => {
|
|
test('strips YAML frontmatter — output is plain markdown', () => {
|
|
const input = `---
|
|
name: help
|
|
description: Show help for GSD commands
|
|
---
|
|
|
|
# GSD Help
|
|
|
|
Use \`/gsd-help\` to see available commands.
|
|
`;
|
|
|
|
const result = convertClaudeCommandToCursorCommand(input);
|
|
assert.ok(!result.startsWith('---'), 'cursor commands must not have YAML frontmatter');
|
|
assert.ok(!result.includes('name: help'), 'name field must be stripped');
|
|
assert.ok(!result.includes('description:'), 'description field must be stripped');
|
|
assert.ok(result.includes('GSD Help'), 'body content must be preserved');
|
|
});
|
|
|
|
test('applies convertClaudeToCursorMarkdown transforms (Bash → Shell, Claude Code → Cursor)', () => {
|
|
const input = `---
|
|
name: quick
|
|
description: Quick task
|
|
---
|
|
|
|
Use Bash( to run commands.
|
|
This runs in Claude Code.
|
|
`;
|
|
|
|
const result = convertClaudeCommandToCursorCommand(input);
|
|
assert.ok(result.includes('Shell('), 'Bash( should be renamed to Shell(');
|
|
assert.ok(!result.includes('Claude Code'), 'Claude Code brand reference should be replaced');
|
|
assert.ok(result.includes('Cursor'), 'should reference Cursor instead');
|
|
});
|
|
|
|
test('normalizes gsd: colon slash commands to gsd- hyphen form', () => {
|
|
const input = `---
|
|
name: plan-phase
|
|
description: Plan a phase
|
|
---
|
|
|
|
Next step: /gsd:execute-phase 17
|
|
`;
|
|
|
|
const result = convertClaudeCommandToCursorCommand(input);
|
|
assert.ok(result.includes('/gsd-execute-phase 17'), 'colon form should become hyphen form');
|
|
assert.ok(!result.includes('/gsd:execute-phase'), 'colon form should be removed');
|
|
});
|
|
|
|
test('handles input with no frontmatter gracefully', () => {
|
|
const input = `# No Frontmatter Command
|
|
|
|
Some body content.
|
|
`;
|
|
|
|
const result = convertClaudeCommandToCursorCommand(input);
|
|
assert.ok(!result.startsWith('---'), 'output must not start with ---');
|
|
assert.ok(result.includes('No Frontmatter Command'), 'body should be preserved');
|
|
});
|
|
|
|
test('is exported from install.js', () => {
|
|
assert.strictEqual(typeof convertClaudeCommandToCursorCommand, 'function',
|
|
'convertClaudeCommandToCursorCommand must be exported from install.js');
|
|
});
|
|
});
|