Merge pull request #1360 from gsd-build/fix/clear-agent-recognition-1357
fix: add <available_agent_types> to all agent-spawning workflows
This commit is contained in:
@@ -152,6 +152,52 @@ describe('SPAWN: spawn type consistency', () => {
|
||||
);
|
||||
});
|
||||
|
||||
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'
|
||||
|
||||
Reference in New Issue
Block a user