* chore(#604): rename get-shit-done/ runtime directory to gsd-core/ Renames the installed runtime directory `get-shit-done/` to `gsd-core/` so the on-disk name matches the package (`@opengsd/gsd-core`), repo, and binary (`gsd-tools`). The npm package name and binary are unchanged; npx/npm consumers are unaffected. Mechanical (bulk, ~90% of the diff): - `git mv get-shit-done gsd-core` - Swept path/identifier references across the repo via `perl -pe 's/get-shit-done(?!-\w)/gsd-core/g'`. The negative lookahead preserves the five legitimate slug variants that are NOT the directory: get-shit-done-{OLD,cc,classic,cli,redux} (old package/repo names). - Build/manifest wiring: package.json (bin, files, coverage globs), tsconfig.build.json (outDir), ~86 .gitignore build-output entries, stryker.config.mjs, scan-ignore files, install.js path strings. - Frozen (not rewritten): CHANGELOG.md history; translated docs (README.<locale>.md and docs/{ja-JP,ko-KR,pt-BR,zh-CN}/). New logic (review here): - src/installer-migrations/003-rename-get-shit-done-to-gsd-core.cts: a proper ADR-0008 installer migration. On upgrade it walks the legacy `~/.claude/get-shit-done/` tree, classifies each file via the prior install manifest, and emits remove-managed / backup-and-remove for managed files while PRESERVING unknown user-added files. Symlink-safe (skips a symlinked root and symlinked entries; bounds-checks every path under configDir). The framework rolls back on install failure. Emptied dirs may remain (framework has no recursive dir-removal primitive) — documented. - scripts/lint-legacy-dir-name.cjs: CI regression guard forbidding the bare `get-shit-done` directory token (split token to avoid self-match; case- insensitive; `(?!-\w)` lookahead allows the slug variants; allowlists CHANGELOG, translated docs, and `gsd-allow-legacy-name` marker lines). Wired into the lint-tests CI job. - Restored scripts/lint-package-identity-drift.cjs detection regexes (the mechanical sweep had wrongly rewritten the old-name patterns it exists to detect) and marked them as intentional legacy references. - TDD tests for the migration and the guard; do.md slash-command guard regex tightened so a `/gsd-core/bin` path segment is not mistaken for a command; changeset + docs/installer-migrations.md row added. Breaking: the installed runtime path moves `~/.claude/get-shit-done/` -> `~/.claude/gsd-core/`. Migration 003 removes the stale legacy dir's managed files (preserving user files) on upgrade. Users with custom hooks/configs hardcoding the old path must update them. Closes #604 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(#604): unsweep pending changesets + allowlist injection-example docs CI fixes for the rename PR: - Do not sweep pending .changeset/*.md (ephemeral release-note fragments, like CHANGELOG); reverted those body edits so 5 pre-existing malformed fragments (missing type/pr) no longer enter the PR diff and trip docs-lint. Allowlisted .changeset/ in the legacy-name guard accordingly. - Allowlisted TEST-EXAMPLES.md and docs/explanation/security-model.md in prompt-injection-scan.sh: they contain intentional injection examples / security-model prose; the path-reference rewrites are kept. CodeQL alerts on this PR are pre-existing (alert lines unchanged by this PR; none in the new migration/guard) and are out of scope for the rename. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(#604): resolve CodeQL alerts surfaced on this PR The rename diff touched files carrying pre-existing CodeQL findings; per the no-pre-existing-dismissal rule, fixing every surfaced alert rather than waving them off. All behavior-preserving: - scripts/ci-test-scope.cjs: build the config-path match from string .includes() instead of a RegExp over an arg-derived value (js/regex-injection). - src/profile-output.cts: escape backslashes before pipe-escaping desc/safeName so the table-cell escape is complete (js/incomplete-sanitization). - tests/{bug-2643,bug-2808,docs-parity-live-registry}: two-pass HTML-comment strip so a bare/unclosed `<!--` cannot survive (js/incomplete-multi-character-sanitization). - tests/inline-plan-threshold: drop the no-op `\s`->`\s` identity replace, keep the meaningful POSIX-class conversion (js/identity-replacement). Verified: build:lib green; the touched test files + ci-test-scope + profile-output suites pass; lint:legacy-name clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(#604): correctly resolve remaining CodeQL alerts (regex-injection + sanitization) The prior commit's fixes for two alerts were ineffective: - ci-test-scope.cjs js/regex-injection: the alert is the CLI-arg-derived `file` reaching static regex `.test(file)` calls (not the config rule). Removed ALL regex over file/t — startsWith/includes/=== string checks + an isWindowsHint helper — so there is no regex sink for the tainted value. - js/incomplete-multi-character-sanitization (3 test files): a single `.replace(/<!--...-->/g,'')` can let `<!--` re-form. Replaced with a fixpoint loop (replace until stable) plus a final bare-opener strip. Verified: no regex over file/t remains; ci-test-scope + the 3 test suites pass; lint:legacy-name clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(#604): make ci-test-scope + comment-strippers regex-free to clear CodeQL CodeQL flags the regex PATTERNS syntactically (regex-injection on the --files arg split; incomplete-multi-character-sanitization on the <!--...--> replace), so loop fixes do not satisfy it. Made these paths regex-free: - ci-test-scope.cjs splitFiles: char-by-char separator tokenizer (no /[,\\s]+/). - 3 test files: indexOf/slice HTML-comment stripper (no .replace(/<!--/)). Behavior preserved; ci-test-scope + the 3 suites pass; guard clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(#604): unblock security base64 scan on the large rename diff The security job hit its 10m timeout: base64-scan.sh choked on the binary test fixture tests/feat-3594-parser-property-style.test.cjs (embedded NUL/ non-UTF8 bytes -> thousands of bogus blobs + "ignored null byte" warnings), and the ~800-file rename diff is slow to scan regardless. - scripts/base64-scan.sh: skip binary-by-content files (grep -Iq .) — they can't carry base64-obfuscated *text* and feeding NUL bytes through the per-line scanner is pathologically slow. collect_files already filtered binary *extensions*; this catches binary *content* in text extensions. - .github/workflows/security-scan.yml: raise the security job timeout 10m->30m to accommodate very large diffs (the scan itself is unchanged). Verified locally: scan skips the fixture, 0 "ignored null byte" warnings, 0 findings, exit 0. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(#604): sweep get-shit-done refs introduced by merging next The branch was updated with next (#614/#384/#618 etc.), which reference the get-shit-done/ dir (still named that on next). Swept the stale references in the merged files to gsd-core so the rename stays consistent and lint:legacy-name passes: - commands/gsd/discuss-phase.md (runtime-launcher shim paths) - src/core.cts (getAgentsDir layout comments) - tests/bug-384-agents-runtime-aware.test.cjs (require path to runtime lib) Verified: guard 0 violations; build green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(#604): exclude gsd-core/ path segments from bug-3683 command cross-ref invariant The #614 runtime-launcher shim added to discuss-phase.md references `${_GSD_RUNTIME_ROOT}/gsd-core/bin/...`. bug-3683's REF_PATTERN excluded path-y refs only via lookbehind, but `}` precedes `/gsd-core/` in the shim, so it mis-read the directory path as a dangling `/gsd-core` command ref (same class as the #604 bug-2954 fix). Added a trailing `(?![\w-]*\/)` so `/gsd-<x>/...` path segments are not treated as slash-command references. Verified locally on BOTH platforms before pushing: - mac (node 26) full suite: 0 failures - gsd-test-runner (linux, node22 image) full suite: 0 failures - bug-3683 + bug-2954 pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(#604): lazily resolve findProjectRoot in gsd-tools (harden flaky CI) CI intermittently failed state.test's gsd-tools subprocess with "findProjectRoot is not a function" (flip-flopping across legs; not reproducible on mac full suite, gsd-test linux full suite, test:unit, or state.test x8). findProjectRoot is a re-export from core.cjs (sourced from project-root.cjs); binding it via destructure at module-load can be undefined under a load-ordering edge. Resolve it lazily at call time via a small wrapper so the lookup happens after core.cjs is fully initialized. Verified green on BOTH platforms before pushing: - mac (node 26) full suite: 0 failures - gsd-test-runner (linux, node22) full suite: 0 failures - state.test.cjs: 106/106; gsd-tools loads cleanly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(#604): allowlist verification-patterns.md placeholder examples in secret scan The rename git-mv'd references/verification-patterns.md into gsd-core/, pulling it into the secret-scan diff. It documents stub/placeholder RED-FLAG env-var examples (illustrative Stripe test-key / database-URL / API-key placeholders) — not real credentials. Added it to .secretscanignore with the strict annotation, mirroring the existing gsd-core/workflows/plan-phase.md exception. Verified locally: secret-scan-lint --strict OK; secret-scan --diff origin/next exits 0 with 0 findings. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
455 lines
19 KiB
JavaScript
455 lines
19 KiB
JavaScript
// allow-test-rule: source-text-is-the-product
|
|
// Agent .md files are the installed AI agents — their frontmatter and body text IS what
|
|
// Claude Code loads at runtime. Checking text content IS checking the deployed contract.
|
|
|
|
/**
|
|
* GSD Agent Frontmatter Tests
|
|
*
|
|
* Validates that all agent .md files have correct frontmatter fields:
|
|
* - Anti-heredoc instruction present in file-writing agents
|
|
* - skills: field absent from all agents (breaks Gemini CLI)
|
|
* - Commented hooks: pattern in file-writing agents
|
|
* - Spawn type consistency across workflows
|
|
*/
|
|
|
|
const { test, describe } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const AGENTS_DIR = path.join(__dirname, '..', 'agents');
|
|
const WORKFLOWS_DIR = path.join(__dirname, '..', 'gsd-core', 'workflows');
|
|
const COMMANDS_DIR = path.join(__dirname, '..', 'commands', 'gsd');
|
|
|
|
const ALL_AGENTS = fs.readdirSync(AGENTS_DIR)
|
|
.filter(f => f.startsWith('gsd-') && f.endsWith('.md'))
|
|
.map(f => f.replace('.md', ''));
|
|
|
|
const FILE_WRITING_AGENTS = ALL_AGENTS.filter(name => {
|
|
const content = fs.readFileSync(path.join(AGENTS_DIR, name + '.md'), 'utf-8');
|
|
const toolsMatch = content.match(/^tools:\s*(.+)$/m);
|
|
return toolsMatch && toolsMatch[1].includes('Write');
|
|
});
|
|
|
|
const READ_ONLY_AGENTS = ALL_AGENTS.filter(name => !FILE_WRITING_AGENTS.includes(name));
|
|
|
|
// ─── Anti-Heredoc Instruction ────────────────────────────────────────────────
|
|
|
|
describe('HDOC: anti-heredoc instruction', () => {
|
|
for (const agent of FILE_WRITING_AGENTS) {
|
|
test(`${agent} has anti-heredoc instruction`, () => {
|
|
const content = fs.readFileSync(path.join(AGENTS_DIR, agent + '.md'), 'utf-8');
|
|
assert.ok(
|
|
content.includes("never use `Bash(cat << 'EOF')` or heredoc"),
|
|
`${agent} missing anti-heredoc instruction`
|
|
);
|
|
});
|
|
}
|
|
|
|
test('no active heredoc patterns in any agent file', () => {
|
|
for (const agent of ALL_AGENTS) {
|
|
const content = fs.readFileSync(path.join(AGENTS_DIR, agent + '.md'), 'utf-8');
|
|
// Match actual heredoc commands (not references in anti-heredoc instruction)
|
|
const lines = content.split('\n');
|
|
for (let i = 0; i < lines.length; i++) {
|
|
const line = lines[i];
|
|
// Skip lines that are part of the anti-heredoc instruction or markdown code fences
|
|
if (line.includes('never use') || line.includes('NEVER') || line.trim().startsWith('```')) continue;
|
|
// Check for actual heredoc usage instructions
|
|
if (/^cat\s+<<\s*'?EOF'?\s*>/.test(line.trim())) {
|
|
assert.fail(`${agent}:${i + 1} has active heredoc pattern: ${line.trim()}`);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
// ─── Skills Frontmatter ──────────────────────────────────────────────────────
|
|
|
|
describe('SKILL: skills frontmatter absent', () => {
|
|
for (const agent of ALL_AGENTS) {
|
|
test(`${agent} does not have skills: in frontmatter`, () => {
|
|
const content = fs.readFileSync(path.join(AGENTS_DIR, agent + '.md'), 'utf-8');
|
|
const frontmatter = content.split('---')[1] || '';
|
|
assert.ok(
|
|
!frontmatter.includes('skills:'),
|
|
`${agent} has skills: in frontmatter — skills: breaks Gemini CLI and must be removed`
|
|
);
|
|
});
|
|
}
|
|
});
|
|
|
|
// ─── Hooks Frontmatter ───────────────────────────────────────────────────────
|
|
|
|
describe('HOOK: hooks frontmatter pattern', () => {
|
|
for (const agent of FILE_WRITING_AGENTS) {
|
|
test(`${agent} has commented hooks pattern`, () => {
|
|
const content = fs.readFileSync(path.join(AGENTS_DIR, agent + '.md'), 'utf-8');
|
|
const frontmatter = content.split('---')[1] || '';
|
|
assert.ok(
|
|
frontmatter.includes('# hooks:'),
|
|
`${agent} missing commented hooks: pattern in frontmatter`
|
|
);
|
|
});
|
|
}
|
|
|
|
for (const agent of READ_ONLY_AGENTS) {
|
|
test(`${agent} (read-only) does not need hooks`, () => {
|
|
const content = fs.readFileSync(path.join(AGENTS_DIR, agent + '.md'), 'utf-8');
|
|
const frontmatter = content.split('---')[1] || '';
|
|
// Read-only agents may or may not have hooks — just verify they parse
|
|
assert.ok(frontmatter.includes('name:'), `${agent} has valid frontmatter`);
|
|
});
|
|
}
|
|
});
|
|
|
|
// ─── Spawn Type Consistency ──────────────────────────────────────────────────
|
|
|
|
describe('SPAWN: spawn type consistency', () => {
|
|
test('no "First, read agent .md" workaround pattern remains', () => {
|
|
const dirs = [WORKFLOWS_DIR, COMMANDS_DIR];
|
|
for (const dir of dirs) {
|
|
if (!fs.existsSync(dir)) continue;
|
|
const files = fs.readdirSync(dir).filter(f => f.endsWith('.md'));
|
|
for (const file of files) {
|
|
const content = fs.readFileSync(path.join(dir, file), 'utf-8');
|
|
const hasWorkaround = content.includes('First, read ~/.claude/agents/gsd-');
|
|
assert.ok(
|
|
!hasWorkaround,
|
|
`${file} still has "First, read agent .md" workaround — use named subagent_type instead`
|
|
);
|
|
}
|
|
}
|
|
});
|
|
|
|
test('named agent spawns use correct agent names', () => {
|
|
const validAgentTypes = new Set([
|
|
...ALL_AGENTS,
|
|
'general-purpose', // Allowed for orchestrator spawns
|
|
]);
|
|
|
|
const dirs = [WORKFLOWS_DIR, COMMANDS_DIR];
|
|
for (const dir of dirs) {
|
|
if (!fs.existsSync(dir)) continue;
|
|
const files = fs.readdirSync(dir).filter(f => f.endsWith('.md'));
|
|
for (const file of files) {
|
|
const content = fs.readFileSync(path.join(dir, file), 'utf-8');
|
|
const matches = content.matchAll(/subagent_type="([^"]+)"/g);
|
|
for (const match of matches) {
|
|
const agentType = match[1];
|
|
assert.ok(
|
|
validAgentTypes.has(agentType),
|
|
`${file} references unknown agent type: ${agentType}`
|
|
);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
test('diagnose-issues uses gsd-debugger (not general-purpose)', () => {
|
|
const content = fs.readFileSync(
|
|
path.join(WORKFLOWS_DIR, 'diagnose-issues.md'), 'utf-8'
|
|
);
|
|
assert.ok(
|
|
content.includes('subagent_type="gsd-debugger"'),
|
|
'diagnose-issues should spawn gsd-debugger, not general-purpose'
|
|
);
|
|
});
|
|
|
|
test('workflows spawning named agents have <available_agent_types> listing (#1357)', () => {
|
|
// After /clear, Claude Code re-reads workflow instructions but loses agent
|
|
// context. Without an <available_agent_types> section, the orchestrator may
|
|
// fall back to general-purpose, silently breaking agent capabilities.
|
|
// PR #1139 added this to plan-phase and execute-phase but missed all other
|
|
// workflows that spawn named GSD agents.
|
|
const dirs = [WORKFLOWS_DIR, COMMANDS_DIR];
|
|
for (const dir of dirs) {
|
|
if (!fs.existsSync(dir)) continue;
|
|
const files = fs.readdirSync(dir).filter(f => f.endsWith('.md'));
|
|
for (const file of files) {
|
|
const content = fs.readFileSync(path.join(dir, file), 'utf-8');
|
|
// Find all named subagent_type references (excluding general-purpose)
|
|
const matches = [...content.matchAll(/subagent_type="([^"]+)"/g)];
|
|
const namedAgents = matches
|
|
.map(m => m[1])
|
|
.filter(t => t !== 'general-purpose');
|
|
|
|
if (namedAgents.length === 0) continue;
|
|
|
|
// Workflow spawns named agents — must have <available_agent_types>
|
|
assert.ok(
|
|
content.includes('<available_agent_types>'),
|
|
`${file} spawns named agents (${[...new Set(namedAgents)].join(', ')}) ` +
|
|
`but has no <available_agent_types> section — after /clear, the ` +
|
|
`orchestrator may fall back to general-purpose (#1357)`
|
|
);
|
|
|
|
// Every spawned agent type must appear in the listing
|
|
for (const agent of new Set(namedAgents)) {
|
|
const agentTypesMatch = content.match(
|
|
/<available_agent_types>([\s\S]*?)<\/available_agent_types>/
|
|
);
|
|
assert.ok(
|
|
agentTypesMatch,
|
|
`${file} has malformed <available_agent_types> section`
|
|
);
|
|
assert.ok(
|
|
agentTypesMatch[1].includes(agent),
|
|
`${file} spawns ${agent} but does not list it in <available_agent_types>`
|
|
);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
test('execute-phase has Copilot sequential fallback in runtime_compatibility', () => {
|
|
const content = fs.readFileSync(
|
|
path.join(WORKFLOWS_DIR, 'execute-phase.md'), 'utf-8'
|
|
);
|
|
assert.ok(
|
|
content.includes('sequential inline execution'),
|
|
'execute-phase must document sequential inline execution as Copilot fallback'
|
|
);
|
|
assert.ok(
|
|
content.includes('spot-check'),
|
|
'execute-phase must have spot-check fallback for completion detection'
|
|
);
|
|
});
|
|
});
|
|
|
|
// ─── Required Frontmatter Fields ─────────────────────────────────────────────
|
|
|
|
describe('AGENT: required frontmatter fields', () => {
|
|
for (const agent of ALL_AGENTS) {
|
|
test(`${agent} has name, description, tools, color`, () => {
|
|
const content = fs.readFileSync(path.join(AGENTS_DIR, agent + '.md'), 'utf-8');
|
|
const frontmatter = content.split('---')[1] || '';
|
|
assert.ok(frontmatter.includes('name:'), `${agent} missing name:`);
|
|
assert.ok(frontmatter.includes('description:'), `${agent} missing description:`);
|
|
assert.ok(frontmatter.includes('tools:'), `${agent} missing tools:`);
|
|
assert.ok(frontmatter.includes('color:'), `${agent} missing color:`);
|
|
});
|
|
}
|
|
});
|
|
|
|
// ─── CLAUDE.md Compliance ───────────────────────────────────────────────────
|
|
|
|
describe('CLAUDEMD: CLAUDE.md compliance enforcement', () => {
|
|
test('gsd-plan-checker has Dimension 10: CLAUDE.md Compliance', () => {
|
|
const content = fs.readFileSync(path.join(AGENTS_DIR, 'gsd-plan-checker.md'), 'utf-8');
|
|
assert.ok(
|
|
content.includes('Dimension 10: CLAUDE.md Compliance'),
|
|
'gsd-plan-checker must have Dimension 10 for CLAUDE.md compliance checking'
|
|
);
|
|
assert.ok(
|
|
content.includes('claude_md_compliance'),
|
|
'gsd-plan-checker must use claude_md_compliance as dimension identifier'
|
|
);
|
|
});
|
|
|
|
test('gsd-phase-researcher has CLAUDE.md enforcement directive', () => {
|
|
const content = fs.readFileSync(path.join(AGENTS_DIR, 'gsd-phase-researcher.md'), 'utf-8');
|
|
assert.ok(
|
|
content.includes('CLAUDE.md enforcement'),
|
|
'gsd-phase-researcher must enforce CLAUDE.md directives during research'
|
|
);
|
|
assert.ok(
|
|
content.includes('Project Constraints (from CLAUDE.md)'),
|
|
'gsd-phase-researcher must output a Project Constraints section from CLAUDE.md'
|
|
);
|
|
});
|
|
|
|
test('gsd-executor has CLAUDE.md enforcement directive', () => {
|
|
const content = fs.readFileSync(path.join(AGENTS_DIR, 'gsd-executor.md'), 'utf-8');
|
|
assert.ok(
|
|
content.includes('CLAUDE.md enforcement'),
|
|
'gsd-executor must enforce CLAUDE.md directives during execution'
|
|
);
|
|
assert.ok(
|
|
content.includes('CLAUDE.md rule — it takes precedence over plan instructions'),
|
|
'gsd-executor must specify CLAUDE.md precedence over plan instructions'
|
|
);
|
|
});
|
|
|
|
test('all three agents read CLAUDE.md in project_context', () => {
|
|
const agents = ['gsd-plan-checker', 'gsd-phase-researcher', 'gsd-executor'];
|
|
for (const agent of agents) {
|
|
const content = fs.readFileSync(path.join(AGENTS_DIR, agent + '.md'), 'utf-8');
|
|
assert.ok(
|
|
content.includes('Read `./CLAUDE.md`'),
|
|
`${agent} must read ./CLAUDE.md in project_context section`
|
|
);
|
|
}
|
|
});
|
|
});
|
|
|
|
// ─── Verification Data-Flow and Environment Audit (#1245) ────────────────────
|
|
|
|
describe('VERIFY: data-flow trace, environment audit, and behavioral spot-checks', () => {
|
|
test('gsd-verifier has Step 4b: Data-Flow Trace', () => {
|
|
const content = fs.readFileSync(path.join(AGENTS_DIR, 'gsd-verifier.md'), 'utf-8');
|
|
assert.ok(
|
|
content.includes('Step 4b: Data-Flow Trace'),
|
|
'gsd-verifier must have Step 4b for data-flow tracing'
|
|
);
|
|
assert.ok(
|
|
content.includes('HOLLOW'),
|
|
'gsd-verifier must define HOLLOW status for wired-but-disconnected artifacts'
|
|
);
|
|
assert.ok(
|
|
content.includes('DISCONNECTED'),
|
|
'gsd-verifier must define DISCONNECTED status for missing data sources'
|
|
);
|
|
});
|
|
|
|
test('gsd-verifier has Step 7b: Behavioral Spot-Checks', () => {
|
|
const content = fs.readFileSync(path.join(AGENTS_DIR, 'gsd-verifier.md'), 'utf-8');
|
|
assert.ok(
|
|
content.includes('Step 7b: Behavioral Spot-Checks'),
|
|
'gsd-verifier must have Step 7b for behavioral spot-checks'
|
|
);
|
|
assert.ok(
|
|
content.includes('SKIP'),
|
|
'gsd-verifier spot-checks must support SKIP status for untestable items'
|
|
);
|
|
});
|
|
|
|
test('gsd-verifier VERIFICATION.md template includes data-flow and spot-check sections', () => {
|
|
const content = fs.readFileSync(path.join(AGENTS_DIR, 'gsd-verifier.md'), 'utf-8');
|
|
assert.ok(
|
|
content.includes('Data-Flow Trace (Level 4)'),
|
|
'VERIFICATION.md template must include Data-Flow Trace section'
|
|
);
|
|
assert.ok(
|
|
content.includes('Behavioral Spot-Checks'),
|
|
'VERIFICATION.md template must include Behavioral Spot-Checks section'
|
|
);
|
|
});
|
|
|
|
test('gsd-verifier success criteria include data-flow and spot-checks', () => {
|
|
const content = fs.readFileSync(path.join(AGENTS_DIR, 'gsd-verifier.md'), 'utf-8');
|
|
assert.ok(
|
|
content.includes('Data-flow trace (Level 4)'),
|
|
'success criteria must include data-flow trace step'
|
|
);
|
|
assert.ok(
|
|
content.includes('Behavioral spot-checks run'),
|
|
'success criteria must include behavioral spot-checks step'
|
|
);
|
|
});
|
|
|
|
test('gsd-phase-researcher has Step 2.6: Environment Availability Audit', () => {
|
|
const content = fs.readFileSync(path.join(AGENTS_DIR, 'gsd-phase-researcher.md'), 'utf-8');
|
|
assert.ok(
|
|
content.includes('Step 2.6: Environment Availability Audit'),
|
|
'gsd-phase-researcher must have Step 2.6 for environment availability auditing'
|
|
);
|
|
assert.ok(
|
|
content.includes('Environment Availability'),
|
|
'gsd-phase-researcher must include Environment Availability section in RESEARCH.md template'
|
|
);
|
|
});
|
|
|
|
test('gsd-phase-researcher success criteria include environment audit', () => {
|
|
const content = fs.readFileSync(path.join(AGENTS_DIR, 'gsd-phase-researcher.md'), 'utf-8');
|
|
assert.ok(
|
|
content.includes('Environment availability audited'),
|
|
'success criteria must include environment availability audit step'
|
|
);
|
|
});
|
|
});
|
|
|
|
// ─── Discussion Log ──────────────────────────────────────────────────────────
|
|
|
|
describe('DISCUSS: discussion log generation', () => {
|
|
test('discuss-phase workflow references DISCUSSION-LOG.md generation', () => {
|
|
// After #2551 progressive-disclosure refactor, the DISCUSSION-LOG.md template
|
|
// body lives in workflows/discuss-phase/templates/discussion-log.md and is
|
|
// read at the git_commit step. Both files together must satisfy the
|
|
// documentation contract.
|
|
const parent = fs.readFileSync(
|
|
path.join(WORKFLOWS_DIR, 'discuss-phase.md'), 'utf-8'
|
|
);
|
|
const tplPath = path.join(WORKFLOWS_DIR, 'discuss-phase', 'templates', 'discussion-log.md');
|
|
const tpl = fs.existsSync(tplPath) ? fs.readFileSync(tplPath, 'utf-8') : '';
|
|
const content = parent + '\n' + tpl;
|
|
assert.ok(
|
|
content.includes('DISCUSSION-LOG.md'),
|
|
'discuss-phase must reference DISCUSSION-LOG.md generation'
|
|
);
|
|
assert.ok(
|
|
content.includes('Audit trail only'),
|
|
'discuss-phase (or its discussion-log template after #2551) must mark discussion log as audit-only'
|
|
);
|
|
});
|
|
|
|
test('discussion-log template exists', () => {
|
|
const templatePath = path.join(__dirname, '..', 'gsd-core', 'templates', 'discussion-log.md');
|
|
assert.ok(
|
|
fs.existsSync(templatePath),
|
|
'discussion-log.md template must exist'
|
|
);
|
|
const content = fs.readFileSync(templatePath, 'utf-8');
|
|
assert.ok(
|
|
content.includes('Do not use as input to planning'),
|
|
'template must contain audit-only notice'
|
|
);
|
|
});
|
|
});
|
|
|
|
// ─── Section-writer agents must carry both Write and Edit (#581) ────────────
|
|
|
|
describe('EDITWRITE: section-writer agents must have both Write and Edit in tools', () => {
|
|
// These agents perform in-place section edits on shared/existing files (e.g.
|
|
// AI-SPEC.md). Without Edit in tools:, the "Edit-only" discipline in their
|
|
// spawn-prompt is unenforceable — they fall back to whole-file Write and
|
|
// clobber sibling sections. Same bug class as #571/#575 (fixed gsd-doc-writer).
|
|
// Issue #581.
|
|
const SECTION_WRITER_AGENTS = [
|
|
'gsd-eval-planner',
|
|
'gsd-ai-researcher',
|
|
'gsd-domain-researcher',
|
|
'gsd-phase-researcher',
|
|
'gsd-ui-researcher',
|
|
'gsd-debug-session-manager',
|
|
];
|
|
|
|
for (const agent of SECTION_WRITER_AGENTS) {
|
|
test(`${agent} has both Write and Edit in tools: (#581)`, () => {
|
|
const content = fs.readFileSync(path.join(AGENTS_DIR, agent + '.md'), 'utf-8');
|
|
const toolsMatch = content.match(/^tools:\s*(.+)$/m);
|
|
assert.ok(toolsMatch, `${agent} missing tools: line in frontmatter`);
|
|
const tools = toolsMatch[1].split(',').map(t => t.trim());
|
|
assert.ok(
|
|
tools.includes('Write'),
|
|
`${agent} missing Write in tools: — required for file creation`
|
|
);
|
|
assert.ok(
|
|
tools.includes('Edit'),
|
|
`${agent} missing Edit in tools: — required to enforce Edit-only discipline on shared files (#581)`
|
|
);
|
|
});
|
|
}
|
|
});
|
|
|
|
// ─── Cross-runtime agent compatibility (#1522) ──────────────────────────────
|
|
|
|
describe('COMPAT: agents must not use runtime-specific frontmatter keys', () => {
|
|
// permissionMode is Claude Code-specific and breaks Gemini CLI agent loading.
|
|
// It also has no effect on subagent Write permissions in Claude Code (blocked
|
|
// at runtime level regardless). See #1522, #1387.
|
|
const AGENTS_WITH_WRITE = ['gsd-executor', 'gsd-debugger'];
|
|
|
|
for (const agent of AGENTS_WITH_WRITE) {
|
|
test(`${agent} does not have permissionMode (breaks Gemini CLI)`, () => {
|
|
const content = fs.readFileSync(path.join(AGENTS_DIR, agent + '.md'), 'utf-8');
|
|
const frontmatter = content.split('---')[1] || '';
|
|
assert.ok(
|
|
!frontmatter.includes('permissionMode'),
|
|
`${agent} must not have permissionMode — it breaks Gemini CLI agent loading (#1522) ` +
|
|
`and has no effect in Claude Code (#1387)`
|
|
);
|
|
});
|
|
}
|
|
});
|