@mariozechner/pi-coding-agent 0.27.2 → 0.27.4

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.
@@ -203,6 +203,7 @@ async function runSingleAgent(
203
203
  agents: AgentConfig[],
204
204
  agentName: string,
205
205
  task: string,
206
+ cwd: string | undefined,
206
207
  step: number | undefined,
207
208
  signal: AbortSignal | undefined,
208
209
  onUpdate: OnUpdateCallback | undefined,
@@ -263,7 +264,7 @@ async function runSingleAgent(
263
264
  let wasAborted = false;
264
265
 
265
266
  const exitCode = await new Promise<number>((resolve) => {
266
- const proc = spawn("pi", args, { cwd: pi.cwd, shell: false, stdio: ["ignore", "pipe", "pipe"] });
267
+ const proc = spawn("pi", args, { cwd: cwd ?? pi.cwd, shell: false, stdio: ["ignore", "pipe", "pipe"] });
267
268
  let buffer = "";
268
269
 
269
270
  const processLine = (line: string) => {
@@ -338,11 +339,13 @@ async function runSingleAgent(
338
339
  const TaskItem = Type.Object({
339
340
  agent: Type.String({ description: "Name of the agent to invoke" }),
340
341
  task: Type.String({ description: "Task to delegate to the agent" }),
342
+ cwd: Type.Optional(Type.String({ description: "Working directory for the agent process" })),
341
343
  });
342
344
 
343
345
  const ChainItem = Type.Object({
344
346
  agent: Type.String({ description: "Name of the agent to invoke" }),
345
347
  task: Type.String({ description: "Task with optional {previous} placeholder for prior output" }),
348
+ cwd: Type.Optional(Type.String({ description: "Working directory for the agent process" })),
346
349
  });
347
350
 
348
351
  const AgentScopeSchema = StringEnum(["user", "project", "both"] as const, {
@@ -357,6 +360,7 @@ const SubagentParams = Type.Object({
357
360
  chain: Type.Optional(Type.Array(ChainItem, { description: "Array of {agent, task} for sequential execution" })),
358
361
  agentScope: Type.Optional(AgentScopeSchema),
359
362
  confirmProjectAgents: Type.Optional(Type.Boolean({ description: "Prompt before running project-local agents. Default: true.", default: true })),
363
+ cwd: Type.Optional(Type.String({ description: "Working directory for the agent process (single mode)" })),
360
364
  });
361
365
 
362
366
  const factory: CustomToolFactory = (pi) => {
@@ -441,7 +445,7 @@ const factory: CustomToolFactory = (pi) => {
441
445
  }
442
446
  } : undefined;
443
447
 
444
- const result = await runSingleAgent(pi, agents, step.agent, taskWithContext, i + 1, signal, chainUpdate, makeDetails("chain"));
448
+ const result = await runSingleAgent(pi, agents, step.agent, taskWithContext, step.cwd, i + 1, signal, chainUpdate, makeDetails("chain"));
445
449
  results.push(result);
446
450
 
447
451
  const isError = result.exitCode !== 0 || result.stopReason === "error" || result.stopReason === "aborted";
@@ -486,7 +490,7 @@ const factory: CustomToolFactory = (pi) => {
486
490
 
487
491
  const results = await mapWithConcurrencyLimit(params.tasks, MAX_CONCURRENCY, async (t, index) => {
488
492
  const result = await runSingleAgent(
489
- pi, agents, t.agent, t.task, undefined, signal,
493
+ pi, agents, t.agent, t.task, t.cwd, undefined, signal,
490
494
  // Per-task update callback
491
495
  (partial) => {
492
496
  if (partial.details?.results[0]) {
@@ -511,7 +515,7 @@ const factory: CustomToolFactory = (pi) => {
511
515
  }
512
516
 
513
517
  if (params.agent && params.task) {
514
- const result = await runSingleAgent(pi, agents, params.agent, params.task, undefined, signal, onUpdate, makeDetails("single"));
518
+ const result = await runSingleAgent(pi, agents, params.agent, params.task, params.cwd, undefined, signal, onUpdate, makeDetails("single"));
515
519
  const isError = result.exitCode !== 0 || result.stopReason === "error" || result.stopReason === "aborted";
516
520
  if (isError) {
517
521
  const errorMsg = result.errorMessage || result.stderr || getFinalOutput(result.messages) || "(no output)";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mariozechner/pi-coding-agent",
3
- "version": "0.27.2",
3
+ "version": "0.27.4",
4
4
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "piConfig": {
@@ -39,9 +39,9 @@
39
39
  "prepublishOnly": "npm run clean && npm run build"
40
40
  },
41
41
  "dependencies": {
42
- "@mariozechner/pi-agent-core": "^0.27.2",
43
- "@mariozechner/pi-ai": "^0.27.2",
44
- "@mariozechner/pi-tui": "^0.27.2",
42
+ "@mariozechner/pi-agent-core": "^0.27.4",
43
+ "@mariozechner/pi-ai": "^0.27.4",
44
+ "@mariozechner/pi-tui": "^0.27.4",
45
45
  "chalk": "^5.5.0",
46
46
  "cli-highlight": "^2.1.11",
47
47
  "diff": "^8.0.2",