@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.
- package/CHANGELOG.md +17 -0
- package/README.md +35 -13
- package/dist/core/agent-session.d.ts +3 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +11 -9
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/sdk.d.ts +2 -2
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +42 -23
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager.d.ts +5 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +19 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +17 -6
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt.d.ts +2 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +1 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +9 -6
- package/dist/main.js.map +1 -1
- package/docs/sdk.md +8 -2
- package/examples/custom-tools/subagent/index.ts +8 -4
- package/package.json +4 -4
|
@@ -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.
|
|
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.
|
|
43
|
-
"@mariozechner/pi-ai": "^0.27.
|
|
44
|
-
"@mariozechner/pi-tui": "^0.27.
|
|
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",
|