@phi-code-admin/phi-code 0.61.6 → 0.61.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/extensions/phi/orchestrator.ts +34 -46
- package/package.json +1 -1
|
@@ -438,67 +438,55 @@ export default function orchestratorExtension(pi: ExtensionAPI) {
|
|
|
438
438
|
// ─── /plan Command — Full workflow ───────────────────────────────
|
|
439
439
|
|
|
440
440
|
pi.registerCommand("plan", {
|
|
441
|
-
description: "Plan AND execute a project
|
|
441
|
+
description: "Plan AND execute a project with agents — describe what to build",
|
|
442
442
|
handler: async (args, ctx) => {
|
|
443
443
|
const description = args.trim();
|
|
444
444
|
|
|
445
445
|
if (!description) {
|
|
446
446
|
ctx.ui.notify(`**Usage:** \`/plan <project description>\`
|
|
447
447
|
|
|
448
|
-
**Full workflow in one command:**
|
|
449
|
-
1. LLM analyzes your description
|
|
450
|
-
2. Creates spec.md + todo.md
|
|
451
|
-
3. Executes each task with an isolated sub-agent
|
|
452
|
-
4. Each agent has its own context, model, and system prompt
|
|
453
|
-
5. Results saved to progress.md
|
|
454
|
-
|
|
455
448
|
**Examples:**
|
|
456
449
|
/plan Build a REST API for user authentication with JWT
|
|
450
|
+
/plan Create a cyberpunk Pong browser game
|
|
457
451
|
/plan Add test coverage to the payment module
|
|
458
|
-
/plan Refactor the frontend to use TypeScript
|
|
459
452
|
|
|
460
453
|
**Other commands:**
|
|
461
|
-
/
|
|
462
|
-
/plans — List all plans and status`, "info");
|
|
454
|
+
/plans — List all plans`, "info");
|
|
463
455
|
return;
|
|
464
456
|
}
|
|
465
457
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
${description}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
458
|
+
// Create plan files
|
|
459
|
+
await ensurePlansDir();
|
|
460
|
+
const ts = timestamp();
|
|
461
|
+
const specFile = `spec-${ts}.md`;
|
|
462
|
+
await writeFile(join(plansDir, specFile), `# ${description}\n\n**Created:** ${new Date().toLocaleString()}\n`, "utf-8");
|
|
463
|
+
|
|
464
|
+
ctx.ui.notify(`📋 Plan created. Executing with agents...`, "info");
|
|
465
|
+
|
|
466
|
+
// Load agent definitions for system prompts
|
|
467
|
+
const agentDefs = loadAgentDefs();
|
|
468
|
+
const phases = [
|
|
469
|
+
{ agent: "explore", label: "🔍 Exploring", instruction: `Analyze the project requirements and existing codebase. Identify what exists, what's needed, and any constraints.\n\nProject: ${description}` },
|
|
470
|
+
{ agent: "plan", label: "📐 Planning", instruction: `Design the architecture, file structure, and implementation approach.\n\nProject: ${description}` },
|
|
471
|
+
{ agent: "code", label: "💻 Coding", instruction: `Implement the complete project. Create ALL necessary files with production-quality code.\n\nProject: ${description}\n\nCreate every file needed. Do NOT leave placeholders or TODOs. Complete implementation.` },
|
|
472
|
+
{ agent: "test", label: "🧪 Testing", instruction: `Test the implementation. Run the code, check for errors, verify it works.\n\nProject: ${description}` },
|
|
473
|
+
{ agent: "review", label: "🔍 Reviewing", instruction: `Review code quality, security, and performance. Fix any issues found.\n\nProject: ${description}` },
|
|
474
|
+
];
|
|
475
|
+
|
|
476
|
+
// Execute each phase sequentially using sendUserMessage + waitForIdle
|
|
477
|
+
for (const phase of phases) {
|
|
478
|
+
const agentDef = agentDefs.get(phase.agent);
|
|
479
|
+
const systemPromptNote = agentDef?.systemPrompt
|
|
480
|
+
? `\n\n[Agent: ${phase.agent}] ${agentDef.systemPrompt.slice(0, 200)}`
|
|
481
|
+
: "";
|
|
482
|
+
|
|
483
|
+
ctx.ui.notify(`\n${phase.label} (agent: ${phase.agent})...`, "info");
|
|
484
|
+
|
|
485
|
+
pi.sendUserMessage(phase.instruction + systemPromptNote);
|
|
486
|
+
await ctx.waitForIdle();
|
|
487
|
+
}
|
|
495
488
|
|
|
496
|
-
|
|
497
|
-
- title, description, goals, requirements, constraints (project metadata)
|
|
498
|
-
- tasks (array of ALL task objects with title, description, agent, dependencies)
|
|
499
|
-
|
|
500
|
-
⚠️ CRITICAL: Include the \`tasks\` array in the SAME tool call as the project metadata. Do NOT make separate calls. All data must be in ONE orchestrate() invocation.`
|
|
501
|
-
);
|
|
489
|
+
ctx.ui.notify(`\n✅ **Project complete!** Plan: \`${specFile}\``, "info");
|
|
502
490
|
},
|
|
503
491
|
});
|
|
504
492
|
|