diff --git a/client/src/pages/ConfigurePage.tsx b/client/src/pages/ConfigurePage.tsx index a5c7a98..b676f57 100644 --- a/client/src/pages/ConfigurePage.tsx +++ b/client/src/pages/ConfigurePage.tsx @@ -108,12 +108,24 @@ export default function ConfigurePage() { setChatLoading(true); try { + // Send the same provider/config context that the manual generator uses. + // This prevents the wizard from producing generic placeholder provider steps. + const pipelineSnapshot = { + template, + provider, + branch, + stages, + options, + }; + const res = await api.askYamlWizard({ repoUrl: repo, provider, branch: branch, message: trimmed, yaml, + // Extra context for the backend/wizard toolchain (safe to ignore if unused) + pipelineSnapshot, }); if ((res as any)?.tool_called) { @@ -148,7 +160,10 @@ export default function ConfigurePage() { branch, provider, stages, - }); + // Keep a copy of the current options in wizard context so follow-up prompts + // can reference the selected provider identity (AWS role / GCP service account). + options, + } as any); } let text: string; diff --git a/server/agent/wizardAgent.js b/server/agent/wizardAgent.js index fb30eac..ecfb1b1 100644 --- a/server/agent/wizardAgent.js +++ b/server/agent/wizardAgent.js @@ -135,6 +135,10 @@ Tell me what you’d like to do next. } const cookie = userPrompt?.cookie || ''; + const pipelineSnapshot = + userPrompt?.pipelineSnapshot || + userPrompt?.body?.pipelineSnapshot || + null; const systemPrompt = ` You are the MCP Wizard Agent. You have full access to the following connected tools and APIs: @@ -142,6 +146,7 @@ Tell me what you’d like to do next. - pipeline_generator: generates CI/CD YAMLs - oidc_adapter: lists AWS roles or Jenkins jobs - github_adapter: fetches real-time GitHub repository data through an authenticated API connection + - gcp_adapter: fetches Google Cloud information Do not say that you lack access to GitHub or external data — you can retrieve this information directly through the available tools. Only call tools when the user explicitly asks for data retrieval or actions. Do NOT call tools for explanations, help, or capability questions. @@ -311,6 +316,17 @@ Tell me what you’d like to do next. if (provider) payload.provider = provider; if (template) payload.template = template; + // 🔑 Inject authoritative pipeline options from the frontend (Option A) + if (pipelineSnapshot?.options) { + payload.options = pipelineSnapshot.options; + } + if (pipelineSnapshot?.stages) { + payload.stages = pipelineSnapshot.stages; + } + if (pipelineSnapshot?.branch) { + payload.branch = pipelineSnapshot.branch; + } + // Fetch GitHub repo details before pipeline generation let repoInfo = null; try { diff --git a/server/routes/agent.js b/server/routes/agent.js index a3ee9fb..4f21598 100644 --- a/server/routes/agent.js +++ b/server/routes/agent.js @@ -39,16 +39,37 @@ router.post('/wizard', requireSession, async (req, res) => { // Trigger wizard agent with AI prompt router.post('/wizard/ai', requireSession, async (req, res) => { try { - const { prompt } = req.body; + const { + prompt, + repoUrl, + provider, + branch, + pipelineSnapshot, + } = req.body; + if (!prompt) { return res .status(400) .json({ success: false, error: 'Missing required field: prompt' }); } + + console.log('🧠 Wizard AI request received:', { + repoUrl, + provider, + branch, + hasPipelineSnapshot: !!pipelineSnapshot, + snapshotKeys: pipelineSnapshot ? Object.keys(pipelineSnapshot) : [], + }); + const result = await runWizardAgent({ prompt, + repoUrl, + provider, + branch, + pipelineSnapshot, cookie: req.headers.cookie, }); + res.json({ success: true, data: result }); } catch (err) { console.error('Wizard AI Error:', err);