@phi-code-admin/phi-code 0.60.8 → 0.61.0

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.
@@ -129,13 +129,40 @@ export default function orchestratorExtension(pi: ExtensionAPI) {
129
129
  }
130
130
 
131
131
  function findPhiBinary(): string {
132
+ // Try the bundled CLI relative to extensions dir
132
133
  const bundledCli = join(__dirname, "..", "..", "..", "dist", "cli.js");
133
134
  if (existsSync(bundledCli)) return bundledCli;
135
+
136
+ // Try npm global install paths
137
+ const npmGlobalPaths = [
138
+ join(homedir(), "AppData", "Roaming", "npm", "node_modules", "@phi-code-admin", "phi-code", "dist", "cli.js"), // Windows
139
+ join(homedir(), ".npm-global", "lib", "node_modules", "@phi-code-admin", "phi-code", "dist", "cli.js"), // Linux custom
140
+ "/usr/local/lib/node_modules/@phi-code-admin/phi-code/dist/cli.js", // Linux/Mac default
141
+ "/usr/lib/node_modules/@phi-code-admin/phi-code/dist/cli.js", // Some Linux
142
+ ];
143
+ for (const p of npmGlobalPaths) {
144
+ if (existsSync(p)) return p;
145
+ }
146
+
147
+ // Try `which phi` (Linux/Mac) or `where phi` (Windows)
134
148
  try {
135
- const which = require("child_process").execSync("which phi 2>/dev/null", { encoding: "utf-8" }).trim();
136
- if (which) return which;
149
+ const isWin = process.platform === "win32";
150
+ const cmd = isWin ? "where" : "which";
151
+ const result = require("child_process").execSync(`${cmd} phi 2>${isWin ? "NUL" : "/dev/null"}`, { encoding: "utf-8" }).trim();
152
+ if (result) {
153
+ const firstLine = result.split("\n")[0].trim();
154
+ // On Windows, `where phi` returns the .cmd shim; we need the actual JS
155
+ if (isWin && firstLine.endsWith(".cmd")) {
156
+ const npmPrefix = require("child_process").execSync("npm prefix -g", { encoding: "utf-8" }).trim();
157
+ const jsPath = join(npmPrefix, "node_modules", "@phi-code-admin", "phi-code", "dist", "cli.js");
158
+ if (existsSync(jsPath)) return jsPath;
159
+ }
160
+ return firstLine;
161
+ }
137
162
  } catch { /* not in PATH */ }
138
- return "npx";
163
+
164
+ // Last resort: assume phi is in PATH (works with shell:true on Windows)
165
+ return "phi";
139
166
  }
140
167
 
141
168
  // ─── Sub-Agent Execution ─────────────────────────────────────────
@@ -197,7 +224,6 @@ export default function orchestratorExtension(pi: ExtensionAPI) {
197
224
  taskPrompt += `- Report exactly what you did, what worked, and what didn't.\n`;
198
225
 
199
226
  const args: string[] = [];
200
- if (phiBin === "npx") args.push("@phi-code-admin/phi-code");
201
227
 
202
228
  args.push("--print");
203
229
  if (model && model !== "default") args.push("--model", model);
@@ -205,14 +231,26 @@ export default function orchestratorExtension(pi: ExtensionAPI) {
205
231
  args.push("--no-session");
206
232
  args.push(taskPrompt);
207
233
 
208
- const cmd = phiBin === "npx" ? "npx" : "node";
209
- const cmdArgs = phiBin === "npx" ? args : [phiBin, ...args];
234
+ // Determine command: use node + cli.js for JS paths, or phi directly on Windows
235
+ let cmd: string;
236
+ let cmdArgs: string[];
237
+ if (phiBin.endsWith(".js")) {
238
+ cmd = "node";
239
+ cmdArgs = [phiBin, ...args];
240
+ } else if (phiBin === "phi") {
241
+ cmd = "phi";
242
+ cmdArgs = args;
243
+ } else {
244
+ cmd = phiBin;
245
+ cmdArgs = args;
246
+ }
210
247
 
211
248
  execFile(cmd, cmdArgs, {
212
249
  cwd,
213
250
  timeout: timeoutMs,
214
251
  maxBuffer: 10 * 1024 * 1024,
215
252
  env: { ...process.env },
253
+ shell: process.platform === "win32", // Windows needs shell for .cmd shims
216
254
  }, (error, stdout, stderr) => {
217
255
  const durationMs = Date.now() - startTime;
218
256
  if (error) {
@@ -292,7 +330,9 @@ export default function orchestratorExtension(pi: ExtensionAPI) {
292
330
  const totalTasks = tasks.length;
293
331
  let wave = 1;
294
332
 
333
+ const phiBinPath = findPhiBinary();
295
334
  notify(`🚀 Executing ${totalTasks} tasks with sub-agents (parallel mode)...`, "info");
335
+ notify(`📍 Phi binary: \`${phiBinPath}\``, "info");
296
336
 
297
337
  // Execute in waves — each wave runs independent tasks in parallel
298
338
  while (completed.size + failed.size < totalTasks) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phi-code-admin/phi-code",
3
- "version": "0.60.8",
3
+ "version": "0.61.0",
4
4
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "piConfig": {