Skip to content

Commit 74f71a4

Browse files
committed
fix(agent): improved repo parsing to correctly extract labeled repo, template, and provider for pipeline generation
1 parent fa1b3c9 commit 74f71a4

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

server/agent/wizardAgent.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,23 @@ export async function runWizardAgent(userPrompt) {
6969
console.log('🔧 Triggering MCP tool:', toolName);
7070

7171
// --- Extract context dynamically from userPrompt or decision ---
72-
const repoMatch = userPrompt.match(/\b([\w-]+\/[\w-]+)\b/) || decision.match(/\b([\w-]+\/[\w-]+)\b/);
73-
const providerMatch = userPrompt.match(/\b(aws|jenkins|github actions|gcp|azure)\b/i) || decision.match(/\b(aws|jenkins|github actions|gcp|azure)\b/i);
74-
const templateMatch = userPrompt.match(/\b(node|python|react|express|django|flask|java|go)\b/i) || decision.match(/\b(node|python|react|express|django|flask|java|go)\b/i);
75-
76-
const repo = repoMatch ? repoMatch[0] : null;
77-
const provider = providerMatch ? providerMatch[0].toLowerCase() : null;
78-
const template = templateMatch ? templateMatch[0].toLowerCase() : null;
72+
// Prefer explicit labels like: "repo owner/name", "template node_app", "provider aws"
73+
const labeledRepo = userPrompt.match(/\brepo\s+([A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)\b/i)
74+
|| decision.match(/\brepo\s+([A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)\b/i);
75+
const genericRepo = (userPrompt + " " + decision).match(/\b(?!ci\/cd\b)([A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)\b/);
76+
const repo = (labeledRepo?.[1] || genericRepo?.[1] || null);
77+
78+
const labeledProvider = userPrompt.match(/\bprovider\s+(aws|jenkins|gcp|azure)\b/i)
79+
|| decision.match(/\bprovider\s+(aws|jenkins|gcp|azure)\b/i);
80+
const genericProvider = userPrompt.match(/\b(aws|jenkins|github actions|gcp|azure)\b/i)
81+
|| decision.match(/\b(aws|jenkins|github actions|gcp|azure)\b/i);
82+
const provider = (labeledProvider?.[1] || genericProvider?.[1] || null)?.toLowerCase().replace(/\s+/g, ' ');
83+
84+
const labeledTemplate = userPrompt.match(/\btemplate\s+([a-z_][a-z0-9_]+)\b/i)
85+
|| decision.match(/\btemplate\s+([a-z_][a-z0-9_]+)\b/i);
86+
const genericTemplate = userPrompt.match(/\b(node_app|python_app|container_service|node|python|react|express|django|flask|java|go)\b/i)
87+
|| decision.match(/\b(node_app|python_app|container_service|node|python|react|express|django|flask|java|go)\b/i);
88+
const template = (labeledTemplate?.[1] || genericTemplate?.[1] || null)?.toLowerCase();
7989

8090
if (toolName === "repo_reader") {
8191
// Extract optional username, user_id, and repo info

server/agent/wizardAgent_prompts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Use these to fetch repositories, metadata, and details from GitHub.
1818
node server/agent/wizardAgent.js "What GitHub repos are available for pveazie951"
1919
node server/agent/wizardAgent.js "List all repos I have access to on GitHub"
2020
node server/agent/wizardAgent.js "Tell me about PVeazie951/google-extention-ai-summarizer"
21-
node server/agent/wizardAgent.js "Read the info of PVeazie951/soloProject"
21+
node server/agent/wizardAgent.js "Tell me about PVeazie951/google-extention-ai-summarizer"
2222
node server/agent/wizardAgent.js "Get branches for PVeazie951/soloProject"
2323
node server/agent/wizardAgent.js "List workflows for PVeazie951/soloProject"
2424
node server/agent/wizardAgent.js "Get recent commits for PVeazie951/google-extention-ai-summarizer"

0 commit comments

Comments
 (0)