@phi-code-admin/phi-code 0.58.6 → 0.58.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.
@@ -144,6 +144,12 @@ export default function orchestratorExtension(pi: ExtensionAPI) {
144
144
  task: TaskDef,
145
145
  agentDefs: Map<string, AgentDef>,
146
146
  cwd: string,
147
+ sharedContext: {
148
+ projectTitle: string;
149
+ projectDescription: string;
150
+ specSummary: string;
151
+ completedTasks: Array<{ index: number; title: string; agent: string; output: string }>;
152
+ },
147
153
  timeoutMs: number = 300000,
148
154
  ): Promise<TaskResult> {
149
155
  return new Promise((resolve) => {
@@ -153,7 +159,33 @@ export default function orchestratorExtension(pi: ExtensionAPI) {
153
159
  const phiBin = findPhiBinary();
154
160
  const startTime = Date.now();
155
161
 
156
- let taskPrompt = `Task: ${task.title}\n\n${task.description}`;
162
+ // Build prompt with shared context
163
+ let taskPrompt = "";
164
+
165
+ // Inject shared project context (lightweight, always included)
166
+ taskPrompt += `# Project Context\n\n`;
167
+ taskPrompt += `**Project:** ${sharedContext.projectTitle}\n`;
168
+ taskPrompt += `**Description:** ${sharedContext.projectDescription}\n\n`;
169
+
170
+ if (sharedContext.specSummary) {
171
+ taskPrompt += `## Specification Summary\n${sharedContext.specSummary}\n\n`;
172
+ }
173
+
174
+ // Inject results from dependency tasks (only the ones this task depends on)
175
+ const deps = task.dependencies || [];
176
+ if (deps.length > 0) {
177
+ const depResults = sharedContext.completedTasks.filter(ct => deps.includes(ct.index));
178
+ if (depResults.length > 0) {
179
+ taskPrompt += `## Previous Task Results (your dependencies)\n\n`;
180
+ for (const dep of depResults) {
181
+ const truncatedOutput = dep.output.length > 1500 ? dep.output.slice(0, 1500) + "\n...(truncated)" : dep.output;
182
+ taskPrompt += `### Task ${dep.index}: ${dep.title} [${dep.agent}]\n\`\`\`\n${truncatedOutput}\n\`\`\`\n\n`;
183
+ }
184
+ }
185
+ }
186
+
187
+ // The actual task
188
+ taskPrompt += `---\n\n# Your Task\n\n**${task.title}**\n\n${task.description}`;
157
189
  if (task.subtasks && task.subtasks.length > 0) {
158
190
  taskPrompt += "\n\nSub-tasks:\n" + task.subtasks.map((st, i) => `${i + 1}. ${st}`).join("\n");
159
191
  }
@@ -199,17 +231,25 @@ export default function orchestratorExtension(pi: ExtensionAPI) {
199
231
  tasks: TaskDef[],
200
232
  todoFile: string,
201
233
  notify: (msg: string, type: "info" | "error" | "warning") => void,
234
+ projectContext?: { title: string; description: string; specSummary: string },
202
235
  ): Promise<{ results: TaskResult[]; progressFile: string }> {
203
236
  const agentDefs = loadAgentDefs();
204
237
  const progressFile = todoFile.replace("todo-", "progress-");
205
238
  const progressPath = join(plansDir, progressFile);
206
239
  let progress = `# Progress: ${todoFile}\n\n`;
207
240
  progress += `**Started:** ${new Date().toLocaleString()}\n`;
208
- progress += `**Tasks:** ${tasks.length}\n**Mode:** parallel (dependency-aware)\n\n`;
241
+ progress += `**Tasks:** ${tasks.length}\n**Mode:** parallel (dependency-aware, shared context)\n\n`;
209
242
  await writeFile(progressPath, progress, "utf-8");
210
243
 
244
+ // Shared context for sub-agents
245
+ const sharedContext = {
246
+ projectTitle: projectContext?.title || "Project",
247
+ projectDescription: projectContext?.description || "",
248
+ specSummary: projectContext?.specSummary || "",
249
+ completedTasks: [] as Array<{ index: number; title: string; agent: string; output: string }>,
250
+ };
251
+
211
252
  // Build dependency graph
212
- // Task indices are 1-based in the plan files
213
253
  const completed = new Set<number>();
214
254
  const failed = new Set<number>();
215
255
  const results: TaskResult[] = [];
@@ -268,22 +308,29 @@ export default function orchestratorExtension(pi: ExtensionAPI) {
268
308
  notify(`⏳ Task ${idx + 1}: **${t.title}** [${t.agent || "code"}]`, "info");
269
309
  }
270
310
 
271
- // Launch all ready tasks simultaneously
311
+ // Launch all ready tasks simultaneously (each gets shared context)
272
312
  const promises = readyIndices.map(async (idx) => {
273
313
  const task = tasks[idx];
274
- const result = await executeTask(task, agentDefs, process.cwd());
314
+ const result = await executeTask(task, agentDefs, process.cwd(), sharedContext);
275
315
  result.taskIndex = idx + 1;
276
316
  return result;
277
317
  });
278
318
 
279
319
  const waveResults = await Promise.all(promises);
280
320
 
281
- // Process results
321
+ // Process results and feed into shared context for next wave
282
322
  for (const result of waveResults) {
283
323
  results.push(result);
284
324
 
285
325
  if (result.status === "success") {
286
326
  completed.add(result.taskIndex);
327
+ // Add to shared context so dependent tasks can see this result
328
+ sharedContext.completedTasks.push({
329
+ index: result.taskIndex,
330
+ title: result.title,
331
+ agent: result.agent,
332
+ output: result.output,
333
+ });
287
334
  } else {
288
335
  failed.add(result.taskIndex);
289
336
  }
@@ -459,7 +506,18 @@ export default function orchestratorExtension(pi: ExtensionAPI) {
459
506
  notify(`📋 Plan created: **${p.title}** (${p.tasks.length} tasks)\nNow executing with sub-agents...`, "info");
460
507
 
461
508
  // Auto-execute all tasks
462
- const { results, progressFile } = await executePlan(p.tasks, todoFile, notify);
509
+ // Build spec summary for shared context
510
+ const specSummary = [
511
+ `Goals: ${p.goals.join("; ")}`,
512
+ `Requirements: ${p.requirements.join("; ")}`,
513
+ p.architecture?.length ? `Architecture: ${p.architecture.join("; ")}` : "",
514
+ p.constraints?.length ? `Constraints: ${p.constraints.join("; ")}` : "",
515
+ ].filter(Boolean).join("\n");
516
+
517
+ const { results, progressFile } = await executePlan(
518
+ p.tasks, todoFile, notify,
519
+ { title: p.title, description: p.description, specSummary },
520
+ );
463
521
 
464
522
  const succeeded = results.filter(r => r.status === "success").length;
465
523
  const failed = results.filter(r => r.status === "error").length;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phi-code-admin/phi-code",
3
- "version": "0.58.6",
3
+ "version": "0.58.7",
4
4
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "piConfig": {