@phi-code-admin/phi-code 0.61.5 ā 0.61.7
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 +32 -58
- package/package.json +1 -1
|
@@ -274,12 +274,8 @@ export default function orchestratorExtension(pi: ExtensionAPI) {
|
|
|
274
274
|
}
|
|
275
275
|
await writeFile(progressPath, progress, "utf-8");
|
|
276
276
|
|
|
277
|
-
//
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
notify(`š ${totalTasks} tasks sent to LLM. Progress: \`${progressFile}\``, "info");
|
|
281
|
-
|
|
282
|
-
return { results, progressFile };
|
|
277
|
+
// Return the mega-prompt as tool result ā LLM sees it and executes
|
|
278
|
+
return { results, progressFile, megaPrompt };
|
|
283
279
|
}
|
|
284
280
|
|
|
285
281
|
// āāā Generate Plan Files āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
@@ -412,23 +408,19 @@ export default function orchestratorExtension(pi: ExtensionAPI) {
|
|
|
412
408
|
p.constraints?.length ? `Constraints: ${p.constraints.join("; ")}` : "",
|
|
413
409
|
].filter(Boolean).join("\n");
|
|
414
410
|
|
|
415
|
-
const { results, progressFile } = await executePlan(
|
|
411
|
+
const { results, progressFile, megaPrompt } = await executePlan(
|
|
416
412
|
p.tasks, todoFile, notify,
|
|
417
413
|
{ title: p.title, description: p.description, specSummary },
|
|
418
414
|
);
|
|
419
415
|
|
|
420
|
-
const
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
**Progress:** \`${progressFile}\`
|
|
424
|
-
|
|
425
|
-
**Tasks queued:**
|
|
426
|
-
${results.map(r => `š Task ${r.taskIndex}: ${r.title} [${r.agent}]`).join("\n")}
|
|
427
|
-
|
|
428
|
-
The LLM is now executing all tasks in-session.`;
|
|
416
|
+
const header = `**š Project "${p.title}" ā ${p.tasks.length} tasks planned!**\n` +
|
|
417
|
+
`Plan: \`${specFile}\`, \`${todoFile}\` | Progress: \`${progressFile}\`\n\n` +
|
|
418
|
+
`---\n\n`;
|
|
429
419
|
|
|
420
|
+
// Return the mega-prompt as tool result
|
|
421
|
+
// The LLM sees this and executes all tasks in its current turn
|
|
430
422
|
return {
|
|
431
|
-
content: [{ type: "text", text:
|
|
423
|
+
content: [{ type: "text", text: header + megaPrompt }],
|
|
432
424
|
details: {
|
|
433
425
|
specFile, todoFile, progressFile,
|
|
434
426
|
taskCount: p.tasks.length,
|
|
@@ -446,67 +438,49 @@ The LLM is now executing all tasks in-session.`;
|
|
|
446
438
|
// āāā /plan Command ā Full workflow āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
447
439
|
|
|
448
440
|
pi.registerCommand("plan", {
|
|
449
|
-
description: "Plan AND execute a project
|
|
441
|
+
description: "Plan AND execute a project ā describe what to build and the LLM does it all",
|
|
450
442
|
handler: async (args, ctx) => {
|
|
451
443
|
const description = args.trim();
|
|
452
444
|
|
|
453
445
|
if (!description) {
|
|
454
446
|
ctx.ui.notify(`**Usage:** \`/plan <project description>\`
|
|
455
447
|
|
|
456
|
-
**Full workflow in one command:**
|
|
457
|
-
1. LLM analyzes your description
|
|
458
|
-
2. Creates spec.md + todo.md
|
|
459
|
-
3. Executes each task with an isolated sub-agent
|
|
460
|
-
4. Each agent has its own context, model, and system prompt
|
|
461
|
-
5. Results saved to progress.md
|
|
462
|
-
|
|
463
448
|
**Examples:**
|
|
464
449
|
/plan Build a REST API for user authentication with JWT
|
|
450
|
+
/plan Create a cyberpunk Pong browser game
|
|
465
451
|
/plan Add test coverage to the payment module
|
|
466
|
-
/plan Refactor the frontend to use TypeScript
|
|
467
452
|
|
|
468
453
|
**Other commands:**
|
|
469
|
-
/
|
|
470
|
-
/plans ā List all plans and status`, "info");
|
|
454
|
+
/plans ā List all plans`, "info");
|
|
471
455
|
return;
|
|
472
456
|
}
|
|
473
457
|
|
|
474
|
-
|
|
475
|
-
|
|
458
|
+
// Create plan files
|
|
459
|
+
await ensurePlansDir();
|
|
460
|
+
const ts = timestamp();
|
|
461
|
+
const specFile = `spec-${ts}.md`;
|
|
462
|
+
const todoFile = `todo-${ts}.md`;
|
|
476
463
|
|
|
477
|
-
##
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
## Instructions
|
|
481
|
-
|
|
482
|
-
1. **Analyze** the project: identify goals, requirements, technical constraints, and architecture decisions.
|
|
464
|
+
const spec = `# Project Plan\n\n**Created:** ${new Date().toLocaleString()}\n\n## Description\n\n${description}\n`;
|
|
465
|
+
await writeFile(join(plansDir, specFile), spec, "utf-8");
|
|
466
|
+
await writeFile(join(plansDir, todoFile), `# Todo\n\n(LLM will execute directly)\n`, "utf-8");
|
|
483
467
|
|
|
484
|
-
|
|
485
|
-
- NO access to this conversation
|
|
486
|
-
- NO shared memory or context
|
|
487
|
-
- Its own model and system prompt
|
|
488
|
-
- Full tool access (read, write, edit, bash, grep, find, ls)
|
|
468
|
+
ctx.ui.notify(`š Plan created: \`${specFile}\`\nš Executing project now...`, "info");
|
|
489
469
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
- FORMAT: Expected output (files created, test results, etc.)
|
|
494
|
-
- CONSTRAINTS: Rules, conventions, things to avoid
|
|
470
|
+
// Paste the structured prompt into the editor so the user just presses Enter
|
|
471
|
+
// This avoids sendUserMessage which fails with "Agent is already processing"
|
|
472
|
+
const prompt = `Build this project completely. Create all necessary files, implement all features, test everything.
|
|
495
473
|
|
|
496
|
-
|
|
474
|
+
## Project
|
|
475
|
+
${description}
|
|
497
476
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
477
|
+
## Rules
|
|
478
|
+
- Create ALL files needed for a complete, working project
|
|
479
|
+
- Use best practices and clean code
|
|
480
|
+
- Test that everything works (run the code if possible)
|
|
481
|
+
- Report what you created when done`;
|
|
503
482
|
|
|
504
|
-
|
|
505
|
-
- title, description, goals, requirements, constraints (project metadata)
|
|
506
|
-
- tasks (array of ALL task objects with title, description, agent, dependencies)
|
|
507
|
-
|
|
508
|
-
ā ļø 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.`
|
|
509
|
-
);
|
|
483
|
+
ctx.ui.pasteToEditor(prompt);
|
|
510
484
|
},
|
|
511
485
|
});
|
|
512
486
|
|