Files
get-shit-done/tests/bug-2419-project-researcher-agent.test.cjs
Tom Boucher dfa1ecce99 fix(#2418,#2399,#2419,#2421): four workflow and installer bug fixes (#2462)
- #2418: convertClaudeToAntigravityContent now replaces bare ~/.claude and
  $HOME/.claude (no trailing slash) for both global and local installs,
  eliminating the "unreplaced .claude path reference" warnings in
  gsd-debugger.md and update.md during Antigravity installs.

- #2399: plan-phase workflow gains step 13c that commits PLAN.md files
  and STATE.md via gsd-sdk query commit when commit_docs is true.
  Previously commit_docs:true was read but never acted on in plan-phase.

- #2419: new-project.md and new-milestone.md now parse agents_installed
  and missing_agents from the init JSON and warn users clearly when GSD
  agents are not installed, rather than silently failing with "agent type
  not found" when trying to spawn gsd-project-researcher subagents.

- #2421: gsd-planner.md gains a "Grep gate hygiene" rule immediately after
  the Nyquist Rule explaining the self-invalidating grep gate anti-pattern
  and providing comment-stripping alternatives (grep -v, ast-grep).

Tests: 4 new test files (30 tests) all passing.

Closes #2418
Closes #2399
Closes #2419
Closes #2421

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-20 10:09:33 -04:00

97 lines
4.1 KiB
JavaScript

/**
* Bug #2419: gsd-project-researcher agent type not found
*
* When gsd-new-project spawns gsd-project-researcher subagents, it fails with
* "agent type not found" if the user has a local-only install (agents in
* .claude/agents/ of a different project, not the global ~/.claude/agents/).
*
* Fix: new-project.md and new-milestone.md must parse agents_installed from
* the init JSON and warn the user (rather than silently failing) when agents
* are missing.
*/
const { describe, test } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('fs');
const path = require('path');
const NEW_PROJECT_PATH = path.join(__dirname, '..', 'get-shit-done', 'workflows', 'new-project.md');
const NEW_MILESTONE_PATH = path.join(__dirname, '..', 'get-shit-done', 'workflows', 'new-milestone.md');
const AGENTS_DIR = path.join(__dirname, '..', 'agents');
describe('gsd-project-researcher agent registration (#2419)', () => {
test('gsd-project-researcher.md exists in agents source dir', () => {
const agentFile = path.join(AGENTS_DIR, 'gsd-project-researcher.md');
assert.ok(
fs.existsSync(agentFile),
'agents/gsd-project-researcher.md must exist in the source agents directory'
);
});
test('gsd-project-researcher.md has correct name in frontmatter', () => {
const content = fs.readFileSync(path.join(AGENTS_DIR, 'gsd-project-researcher.md'), 'utf-8');
assert.ok(
content.includes('name: gsd-project-researcher'),
'agents/gsd-project-researcher.md must have name: gsd-project-researcher in frontmatter'
);
});
test('new-project.md parses agents_installed from init JSON', () => {
const content = fs.readFileSync(NEW_PROJECT_PATH, 'utf-8');
assert.ok(
content.includes('agents_installed'),
'new-project.md must parse agents_installed from the init JSON to detect missing agents'
);
});
test('new-project.md warns user when agents_installed is false', () => {
const content = fs.readFileSync(NEW_PROJECT_PATH, 'utf-8');
assert.ok(
content.includes('agents_installed') && content.includes('agent type not found') ||
content.includes('agents_installed') && content.includes('missing') ||
content.includes('agents_installed') && content.includes('not installed'),
'new-project.md must warn the user when agents are not installed (agents_installed is false)'
);
});
test('new-milestone.md parses agents_installed from init JSON', () => {
const content = fs.readFileSync(NEW_MILESTONE_PATH, 'utf-8');
assert.ok(
content.includes('agents_installed'),
'new-milestone.md must parse agents_installed from the init JSON to detect missing agents'
);
});
test('new-milestone.md warns user when agents_installed is false', () => {
const content = fs.readFileSync(NEW_MILESTONE_PATH, 'utf-8');
assert.ok(
content.includes('agents_installed') && (
content.includes('agent type not found') ||
content.includes('missing') ||
content.includes('not installed')
),
'new-milestone.md must warn the user when agents are not installed (agents_installed is false)'
);
});
test('new-project.md lists gsd-project-researcher in available_agent_types', () => {
const content = fs.readFileSync(NEW_PROJECT_PATH, 'utf-8');
const agentTypesMatch = content.match(/<available_agent_types>([\s\S]*?)<\/available_agent_types>/);
assert.ok(agentTypesMatch, 'new-project.md must have <available_agent_types> section');
assert.ok(
agentTypesMatch[1].includes('gsd-project-researcher'),
'new-project.md <available_agent_types> must list gsd-project-researcher'
);
});
test('new-milestone.md lists gsd-project-researcher in available_agent_types', () => {
const content = fs.readFileSync(NEW_MILESTONE_PATH, 'utf-8');
const agentTypesMatch = content.match(/<available_agent_types>([\s\S]*?)<\/available_agent_types>/);
assert.ok(agentTypesMatch, 'new-milestone.md must have <available_agent_types> section');
assert.ok(
agentTypesMatch[1].includes('gsd-project-researcher'),
'new-milestone.md <available_agent_types> must list gsd-project-researcher'
);
});
});