Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion client/src/pages/ConfigurePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions server/agent/wizardAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,18 @@ 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:
- repo_reader: reads local and remote repositories, useful for listing or describing repositories
- 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.

Expand Down Expand Up @@ -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 {
Expand Down
23 changes: 22 additions & 1 deletion server/routes/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading