Files
get-shit-done/tests/windsurf-conversion.test.cjs
Tom Boucher 8579a30065 feat: add Windsurf runtime support
Adds full Windsurf (by Codeium) runtime integration, following the same
pattern as the existing Cursor support. Windsurf uses .windsurf/ for
local config and ~/.windsurf/ for global config, with skills in
.windsurf/skills/ using the SKILL.md structure.

What:
- CLI flag --windsurf and interactive prompt option (8)
- Directory mapping (.windsurf local, ~/.windsurf global)
- Content converter functions (tool names, path replacements, brand refs)
- Skill copy function (copyCommandsAsWindsurfSkills)
- Agent conversion (convertClaudeAgentToWindsurfAgent)
- Install/uninstall branches
- Banner, help text, and issue template updates
- Windsurf conversion test suite (windsurf-conversion.test.cjs)
- Updated multi-runtime selection tests for 8 runtimes

Closes #1336

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 13:50:23 -04:00

139 lines
4.7 KiB
JavaScript

/**
* Windsurf conversion regression tests.
*
* Ensures Windsurf frontmatter names are emitted as plain identifiers
* (without surrounding quotes), so Windsurf does not treat quotes as
* literal parts of skill/subagent names.
*/
process.env.GSD_TEST_MODE = '1';
const { describe, test } = require('node:test');
const assert = require('node:assert');
const {
convertClaudeCommandToWindsurfSkill,
convertClaudeAgentToWindsurfAgent,
convertClaudeToWindsurfMarkdown,
} = require('../bin/install.js');
describe('convertClaudeCommandToWindsurfSkill', () => {
test('writes unquoted Windsurf skill name in frontmatter', () => {
const input = `---
name: quick
description: Execute a quick task
---
<objective>
Test body
</objective>
`;
const result = convertClaudeCommandToWindsurfSkill(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 = convertClaudeCommandToWindsurfSkill(input, 'gsd-plan-phase');
// Slash commands: /gsd:execute-phase -> /gsd-execute-phase
assert.ok(result.includes('/gsd-execute-phase 17'), 'slash command gsd: -> gsd-');
assert.ok(result.includes('/gsd-help'), '/gsd-help preserved');
assert.ok(result.includes('gsd-progress'), 'bare gsd: -> gsd-');
});
test('includes windsurf_skill_adapter block', () => {
const input = `---
name: test
description: A test skill
---
Body content.
`;
const result = convertClaudeCommandToWindsurfSkill(input, 'gsd-test');
assert.ok(result.includes('<windsurf_skill_adapter>'), 'adapter header present');
assert.ok(result.includes('</windsurf_skill_adapter>'), 'adapter footer present');
assert.ok(result.includes('Shell'), 'Shell tool mentioned');
assert.ok(result.includes('StrReplace'), 'StrReplace tool mentioned');
});
});
describe('convertClaudeAgentToWindsurfAgent', () => {
test('converts agent frontmatter with unquoted name', () => {
const input = `---
name: gsd-bugfix
description: "Fix bugs automatically"
color: blue
skills:
- debug
- test
---
Agent body content.
`;
const result = convertClaudeAgentToWindsurfAgent(input);
const nameMatch = result.match(/^name:\s*(.+)$/m);
assert.ok(nameMatch, 'name field present');
assert.strictEqual(nameMatch[1], 'gsd-bugfix', 'agent name is plain scalar');
// Should strip unsupported fields
assert.ok(!result.includes('color:'), 'color field stripped');
assert.ok(!result.includes('skills:'), 'skills field stripped');
});
});
describe('convertClaudeToWindsurfMarkdown', () => {
test('replaces Claude Code brand with Windsurf', () => {
const input = 'Claude Code is a great tool for development.';
const result = convertClaudeToWindsurfMarkdown(input);
assert.ok(result.includes('Windsurf'), 'brand replaced');
assert.ok(!result.includes('Claude Code'), 'original brand removed');
});
test('replaces CLAUDE.md with .windsurf/rules/', () => {
const input = 'See `CLAUDE.md` for configuration. Also check ./CLAUDE.md file.';
const result = convertClaudeToWindsurfMarkdown(input);
assert.ok(result.includes('.windsurf/rules/'), 'CLAUDE.md replaced');
});
test('replaces .claude/skills/ with .windsurf/skills/', () => {
const input = 'Skills are stored in .claude/skills/ directory.';
const result = convertClaudeToWindsurfMarkdown(input);
assert.ok(result.includes('.windsurf/skills/'), 'skills path replaced');
});
test('replaces Bash( with Shell( and Edit( with StrReplace(', () => {
const input = 'Use Bash(command) and Edit(file) tools.';
const result = convertClaudeToWindsurfMarkdown(input);
assert.ok(result.includes('Shell('), 'Bash -> Shell');
assert.ok(result.includes('StrReplace('), 'Edit -> StrReplace');
});
test('replaces $ARGUMENTS with {{GSD_ARGS}}', () => {
const input = 'Pass $ARGUMENTS to the command.';
const result = convertClaudeToWindsurfMarkdown(input);
assert.ok(result.includes('{{GSD_ARGS}}'), '$ARGUMENTS replaced');
});
test('removes classifyHandoffIfNeeded workarounds', () => {
const input = '**Known Claude Code bug (classifyHandoffIfNeeded):** Some workaround text here\nNext line.';
const result = convertClaudeToWindsurfMarkdown(input);
assert.ok(!result.includes('classifyHandoffIfNeeded'), 'workaround removed');
});
});