* enh(#2876): retire the dead and pass-through exports from bin/install.js The installer exported 197 names and had zero production consumers - every non-test require of it repo-wide sits inside a comment. Its interface was shaped by test access, not by callers. Removes 9 dead exports and 61 pass-throughs, repointing their tests onto the extracted modules' own interfaces. 197 down to 127. Every count in the issue was wrong: 197 exports not 188, 9 dead not 12, 61 pass-throughs not 49, 44 test files not 42 - and the audit itself then missed 7 more consumer files. restoreUserArtifacts was on the dead list but ceased to exist in phase 6, and two _GSD_EFFORT_MANIFEST_* names listed as dead are now genuinely asserted, so acting on that list would have deleted live exports. 7 of the 9 dead names collide with an independent declaration that install.js delegates TO. Each removal was justified by which declaration a reference resolves to, never by whether the name appears somewhere. Coverage parity was the gate rather than test greenness: per-file counts were captured before any edit and diffed after. 44 of 45 files are byte-identical; the single delta is one added assertion, not a loss. The sweep for scattered require sites found two forms static grep misses - require(VARIABLE) and multi-line require() - plus tests asserting that install.js re-exports the SAME object, which now assert retirement instead. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(#2876): close review findings — restore the duplicate-body guard, sweep orphaned code Both review engines found real defects in the first cut. The DEFECT.GENERATIVE-FIX single-owner guard from #1511 had been repointed from a reference-identity check to install.X === undefined. Those are not equivalent: the guard exists to catch a duplicate function body reintroduced into install.js, and the replacement passes cleanly if that duplicate is used internally and never exported. It now walks bin/install.js's real top-level bindings, so it catches a duplicate under either shape, exported or not - strictly stronger than the check it replaced. Proved by injecting a duplicate and watching it go red. That weakening survived the coverage-parity gate because the assertion count never moved. The gate compares counts, so an assertion that changes meaning rather than number is invisible to it. Removing the exports had orphaned their wrapper bodies: 14 dead wrappers, 9 consts and 9 destructure entries, several pre-existing and found by the same sweep. Dead code left in the file this phase exists to shrink. Three more comments claimed re-exports this phase removed, and tests were reading Cursor and Windsurf hook constants from install.js's local copy while calling functions from the hooks surface - equal today, with nothing holding them equal. The local consts now reference the owning module. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * chore(#2876): backfill changeset pr number Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: sim <sim@local> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
171 lines
5.1 KiB
JavaScript
171 lines
5.1 KiB
JavaScript
/**
|
|
* Augment conversion regression tests.
|
|
*
|
|
* Ensures Augment frontmatter names are emitted as plain identifiers
|
|
* (without surrounding quotes), so Augment 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/strict');
|
|
|
|
const {
|
|
convertClaudeCommandToAugmentSkill,
|
|
convertClaudeAgentToAugmentAgent,
|
|
convertClaudeToAugmentMarkdown,
|
|
} = require('../gsd-core/bin/lib/runtime-artifact-conversion.cjs');
|
|
|
|
describe('convertClaudeCommandToAugmentSkill', () => {
|
|
test('writes unquoted Augment skill name in frontmatter', () => {
|
|
const input = `---
|
|
name: quick
|
|
description: Execute a quick task
|
|
---
|
|
|
|
<objective>
|
|
Test body
|
|
</objective>
|
|
`;
|
|
|
|
const result = convertClaudeCommandToAugmentSkill(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 = convertClaudeCommandToAugmentSkill(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 augment_skill_adapter block', () => {
|
|
const input = `---
|
|
name: test
|
|
description: A test skill
|
|
---
|
|
|
|
Body content.
|
|
`;
|
|
|
|
const result = convertClaudeCommandToAugmentSkill(input, 'gsd-test');
|
|
assert.ok(result.includes('<augment_skill_adapter>'), 'adapter header present');
|
|
assert.ok(result.includes('</augment_skill_adapter>'), 'adapter footer present');
|
|
assert.ok(result.includes('launch-process'), 'launch-process tool mentioned');
|
|
assert.ok(result.includes('str-replace-editor'), 'str-replace-editor tool mentioned');
|
|
});
|
|
|
|
test('converts tool names to Augment format', () => {
|
|
const input = `---
|
|
name: test
|
|
description: Test
|
|
---
|
|
|
|
Use Bash() to run commands.
|
|
Use Edit() to modify files.
|
|
Use Read() to view files.
|
|
`;
|
|
|
|
const result = convertClaudeCommandToAugmentSkill(input, 'gsd-test');
|
|
assert.ok(result.includes('launch-process('), 'Bash converted to launch-process');
|
|
assert.ok(result.includes('str-replace-editor('), 'Edit converted to str-replace-editor');
|
|
assert.ok(result.includes('view('), 'Read converted to view');
|
|
});
|
|
});
|
|
|
|
describe('convertClaudeAgentToAugmentAgent', () => {
|
|
test('converts agent frontmatter with unquoted name', () => {
|
|
const input = `---
|
|
name: gsd-bugfix
|
|
description: "Fix bugs automatically"
|
|
tools: Read, Write, Edit, Bash
|
|
color: green
|
|
---
|
|
|
|
<role>
|
|
You are a bug fixer.
|
|
</role>
|
|
`;
|
|
|
|
const result = convertClaudeAgentToAugmentAgent(input);
|
|
const nameMatch = result.match(/^name:\s*(.+)$/m);
|
|
|
|
assert.ok(nameMatch, 'frontmatter contains name field');
|
|
assert.strictEqual(nameMatch[1], 'gsd-bugfix', 'agent name is plain scalar');
|
|
assert.ok(!result.includes('name: "gsd-bugfix"'), 'quoted agent name is not emitted');
|
|
});
|
|
|
|
test('removes color and skills from frontmatter', () => {
|
|
const input = `---
|
|
name: gsd-test
|
|
description: Test agent
|
|
color: blue
|
|
skills:
|
|
- some-skill
|
|
tools: Read, Write
|
|
---
|
|
|
|
<role>
|
|
Test role
|
|
</role>
|
|
`;
|
|
|
|
const result = convertClaudeAgentToAugmentAgent(input);
|
|
|
|
assert.ok(result.includes('name: gsd-test'), 'name preserved');
|
|
assert.ok(result.includes('description:'), 'description preserved');
|
|
assert.ok(!result.includes('color:'), 'color removed');
|
|
assert.ok(!result.includes('skills:'), 'skills removed');
|
|
});
|
|
|
|
test('replaces CLAUDE.md with .augment/rules/', () => {
|
|
const input = `---
|
|
name: gsd-test
|
|
description: Test
|
|
---
|
|
|
|
See CLAUDE.md for details.
|
|
`;
|
|
|
|
const result = convertClaudeAgentToAugmentAgent(input);
|
|
assert.ok(result.includes('.augment/rules/'), 'CLAUDE.md replaced with .augment/rules/');
|
|
assert.ok(!result.includes('CLAUDE.md'), 'CLAUDE.md reference removed');
|
|
});
|
|
});
|
|
|
|
describe('convertClaudeToAugmentMarkdown', () => {
|
|
test('replaces Claude Code with Augment', () => {
|
|
const input = 'Use Claude Code tools for this task.';
|
|
const result = convertClaudeToAugmentMarkdown(input);
|
|
assert.strictEqual(result, 'Use Augment tools for this task.');
|
|
});
|
|
|
|
test('replaces .claude/skills/ with .augment/skills/', () => {
|
|
const input = 'Check .claude/skills/ for more info.';
|
|
const result = convertClaudeToAugmentMarkdown(input);
|
|
assert.strictEqual(result, 'Check .augment/skills/ for more info.');
|
|
});
|
|
|
|
test('normalizes gsd: to gsd-', () => {
|
|
const input = 'Run /gsd:new-project for new projects.';
|
|
const result = convertClaudeToAugmentMarkdown(input);
|
|
assert.strictEqual(result, 'Run /gsd-new-project for new projects.');
|
|
});
|
|
}); |