fix: add handoff validation for cross-module references

Filter out invalid handoff references when modules aren't selected.
Builds a Set of available prompt names and validates handoffs against it.
This commit is contained in:
Sjoerd Bozon 2025-12-29 00:17:25 +01:00
parent bbe030a96f
commit a493151d8b
1 changed files with 8 additions and 2 deletions

View File

@ -49,6 +49,9 @@ class WorkflowPromptGenerator {
const recommendations = {}; const recommendations = {};
const suggestedHandoffs = {}; const suggestedHandoffs = {};
// Build set of available prompt names for handoff validation
const availablePromptNames = new Set(prompts.map((p) => p.name));
for (const prompt of prompts) { for (const prompt of prompts) {
const promptContent = ['---', `agent: ${prompt.agent}`, `description: "${prompt.description}"`, '---', '', prompt.prompt, ''].join( const promptContent = ['---', `agent: ${prompt.agent}`, `description: "${prompt.description}"`, '---', '', prompt.prompt, ''].join(
'\n', '\n',
@ -58,9 +61,12 @@ class WorkflowPromptGenerator {
await fs.writeFile(promptFilePath, promptContent); await fs.writeFile(promptFilePath, promptContent);
recommendations[`bmd-${prompt.name}`] = true; recommendations[`bmd-${prompt.name}`] = true;
// Generate suggested handoffs for this prompt // Generate suggested handoffs for this prompt, filtering out invalid references
if (prompt.handoffs && prompt.handoffs.length > 0) { if (prompt.handoffs && prompt.handoffs.length > 0) {
suggestedHandoffs[`bmd-${prompt.name}`] = prompt.handoffs.map((h) => `bmd-${h}`); const validHandoffs = prompt.handoffs.filter((h) => availablePromptNames.has(h));
if (validHandoffs.length > 0) {
suggestedHandoffs[`bmd-${prompt.name}`] = validHandoffs.map((h) => `bmd-${h}`);
}
} }
} }