open-pstack 0.9.161 → 0.9.163
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/lib/bundle.mjs +6 -3
- package/lib/harnesses.mjs +10 -3
- package/lib/steps.mjs +7 -1
- package/package.json +1 -1
- package/plugin/.antigravity-plugin/plugin.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/.codex-plugin/plugin.json +1 -1
- package/plugin/.github/plugin/plugin.json +1 -1
- package/plugin/.grok-plugin/plugin.json +1 -1
- package/plugin/.muse-plugin/plugin.json +1 -1
- package/plugin/hooks.json +1 -1
- package/plugin/package.json +1 -1
- package/plugin/pi/agent-text.ts +10 -1
- package/plugin/pi/agent-tools.ts +5 -3
- package/plugin/pi/agents.ts +22 -12
- package/plugin/pi/child.ts +6 -0
- package/plugin/pi/orca-child.ts +40 -16
- package/plugin/pi/t3-child.ts +32 -6
- package/plugin/skills/poteto-mode/references/agy-tools.md +8 -7
- package/plugin/skills/poteto-mode/references/pi-tools.md +5 -5
package/lib/bundle.mjs
CHANGED
|
@@ -31,14 +31,17 @@ export const withoutNodeModules = (root) => (src) =>
|
|
|
31
31
|
!relative(root, src).split(sep).includes("node_modules");
|
|
32
32
|
|
|
33
33
|
// Copy to a sibling, then swap, so a rerun converges and a crash leaves the
|
|
34
|
-
// previous copy whole.
|
|
35
|
-
|
|
34
|
+
// previous copy whole. `exclude` names top-level entries only, so a nested
|
|
35
|
+
// directory of the same name is still copied.
|
|
36
|
+
export function stagePlugin(source, dest, { exclude = [] } = {}) {
|
|
37
|
+
const keep = withoutNodeModules(source);
|
|
38
|
+
const filter = (src) => keep(src) && !exclude.includes(relative(source, src).split(sep)[0]);
|
|
36
39
|
mkdirSync(dirname(dest), { recursive: true });
|
|
37
40
|
const fresh = `${dest}.new-${process.pid}`;
|
|
38
41
|
const old = `${dest}.old-${process.pid}`;
|
|
39
42
|
rmSync(fresh, { recursive: true, force: true });
|
|
40
43
|
try {
|
|
41
|
-
cpSync(source, fresh, { recursive: true, filter
|
|
44
|
+
cpSync(source, fresh, { recursive: true, filter });
|
|
42
45
|
if (entryExists(dest)) renameSync(dest, old);
|
|
43
46
|
renameSync(fresh, dest);
|
|
44
47
|
} catch (error) {
|
package/lib/harnesses.mjs
CHANGED
|
@@ -7,8 +7,9 @@ const SKILLS_LABEL =
|
|
|
7
7
|
const run = (...argv) => ({ kind: "run", argv });
|
|
8
8
|
|
|
9
9
|
// One row per harness, copied from the README install recipes. `steps` is a
|
|
10
|
-
// list of tagged steps: run (spawn the CLI), copy (a tree),
|
|
11
|
-
//
|
|
10
|
+
// list of tagged steps: run (spawn the CLI), copy (a tree), stage (a fresh copy
|
|
11
|
+
// without the top-level entries in exclude), link-skills (one symlink per
|
|
12
|
+
// skill) or manual (in-session instructions, nothing to run).
|
|
12
13
|
export const HARNESSES = [
|
|
13
14
|
{
|
|
14
15
|
id: "claude",
|
|
@@ -118,7 +119,13 @@ export const HARNESSES = [
|
|
|
118
119
|
name: "Antigravity (agy)",
|
|
119
120
|
bin: "agy",
|
|
120
121
|
needsBundle: true,
|
|
121
|
-
steps: ({ pluginDir }) =>
|
|
122
|
+
steps: ({ pluginDir }) => {
|
|
123
|
+
const agyDir = `${pluginDir}-agy`;
|
|
124
|
+
return [
|
|
125
|
+
{ kind: "stage", from: pluginDir, to: agyDir, exclude: ["agents"] },
|
|
126
|
+
run("agy", "plugin", "install", agyDir),
|
|
127
|
+
];
|
|
128
|
+
},
|
|
122
129
|
},
|
|
123
130
|
{
|
|
124
131
|
id: "skills",
|
package/lib/steps.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import { dirname, join } from "node:path";
|
|
10
10
|
|
|
11
11
|
import { which } from "./detect.mjs";
|
|
12
|
-
import { withoutNodeModules } from "./bundle.mjs";
|
|
12
|
+
import { stagePlugin, withoutNodeModules } from "./bundle.mjs";
|
|
13
13
|
|
|
14
14
|
export function describeStep(step) {
|
|
15
15
|
switch (step.kind) {
|
|
@@ -17,6 +17,8 @@ export function describeStep(step) {
|
|
|
17
17
|
return `run: ${step.argv.join(" ")}`;
|
|
18
18
|
case "copy":
|
|
19
19
|
return `copy: ${step.from} -> ${step.to}`;
|
|
20
|
+
case "stage":
|
|
21
|
+
return `stage: ${step.from} -> ${step.to}${step.exclude?.length ? ` (without ${step.exclude.join(", ")})` : ""}`;
|
|
20
22
|
case "link-skills":
|
|
21
23
|
return `link each skill under ${step.from} into ${step.to}`;
|
|
22
24
|
case "manual":
|
|
@@ -70,6 +72,10 @@ const EXECUTORS = {
|
|
|
70
72
|
cpSync(step.from, step.to, { recursive: true, filter: withoutNodeModules(step.from) });
|
|
71
73
|
return { ok: true };
|
|
72
74
|
},
|
|
75
|
+
stage: (step) => {
|
|
76
|
+
stagePlugin(step.from, step.to, { exclude: step.exclude });
|
|
77
|
+
return { ok: true };
|
|
78
|
+
},
|
|
73
79
|
"link-skills": (step, ctx) => {
|
|
74
80
|
mkdirSync(step.to, { recursive: true });
|
|
75
81
|
const names = readdirSync(step.from, { withFileTypes: true })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "open-pstack",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.163",
|
|
4
4
|
"description": "Install pstack into the agent harnesses on this machine: Claude Code, Codex, Pi, Copilot, Muse, OMP, Kimi, Grok, MiniMax, OpenCode, Antigravity, and the shared skills directory.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pstack",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.163",
|
|
4
4
|
"description": "If you want to go fast, go deep first. pstack helps you write less, but higher quality code. rigorous agent workflows you can parallelize with confidence. Ported from cursor/plugins/pstack to Antigravity. Original pstack by Lauren Tan (poteto).",
|
|
5
5
|
"author": "Michael Denyer",
|
|
6
6
|
"logo": "assets/pstack-icon.png",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pstack",
|
|
3
3
|
"displayName": "pstack (Claude Code port)",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.163",
|
|
5
5
|
"description": "If you want to go fast, go deep first. pstack helps you write less, but higher quality code. rigorous agent workflows you can parallelize with confidence. Ported from cursor/plugins/pstack to Claude Code. Original pstack by Lauren Tan (poteto).",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Michael Denyer",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pstack",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.163",
|
|
4
4
|
"description": "If you want to go fast, go deep first. pstack helps you write less, but higher quality code. rigorous agent workflows you can parallelize with confidence. Codex port of the Claude Code plugin; skills are shared, tool names resolve via skills/poteto-mode/references/codex-tools.md. Original pstack by Lauren Tan (poteto).",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Michael Denyer",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pstack",
|
|
3
3
|
"displayName": "pstack (GitHub Copilot port)",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.163",
|
|
5
5
|
"description": "If you want to go fast, go deep first. pstack helps you write less, but higher quality code. rigorous agent workflows you can parallelize with confidence. Ported from cursor/plugins/pstack to GitHub Copilot CLI and app. Original pstack by Lauren Tan (poteto).",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Michael Denyer",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"name": "pstack",
|
|
4
4
|
"displayName": "pstack (Muse port)",
|
|
5
|
-
"version": "0.9.
|
|
5
|
+
"version": "0.9.163",
|
|
6
6
|
"description": "If you want to go fast, go deep first. pstack helps you write less, but higher quality code. Rigorous agent workflows you can parallelize with confidence. Muse port of the Claude Code plugin; skills are shared, tool names resolve via skills/poteto-mode/references/muse-tools.md. Original pstack by Lauren Tan (poteto).",
|
|
7
7
|
"compat": {
|
|
8
8
|
"source": "native",
|
package/plugin/hooks.json
CHANGED
package/plugin/package.json
CHANGED
package/plugin/pi/agent-text.ts
CHANGED
|
@@ -25,6 +25,14 @@ function header({ agent, ...record }: EndedRecord, transcript: string | undefine
|
|
|
25
25
|
const state = record.worktreeKept === false ? "no changes; removed" : `branch ${agent.worktree.branch}`;
|
|
26
26
|
lines.push(`worktree: ${agent.worktree.path} (${state})`);
|
|
27
27
|
}
|
|
28
|
+
if (agent.hostWorktree?.path) {
|
|
29
|
+
const branch = agent.hostWorktree.branch ? `branch ${agent.hostWorktree.branch}; ` : "";
|
|
30
|
+
// Not "orca worktree ...": on Linux a bare orca is the screen reader.
|
|
31
|
+
const removal = agent.host === "t3" ? "T3 Code's cleanup settings decide when it is removed" : "Orca keeps it until you remove the workspace, e.g. with the Orca CLI's worktree rm";
|
|
32
|
+
lines.push(`worktree: ${agent.hostWorktree.path} (${branch}${removal})`);
|
|
33
|
+
} else if (agent.hostWorktree && agent.t3ThreadId) {
|
|
34
|
+
lines.push(`worktree: not reported (isolation "worktree" was asked for, but T3 Code did not report a checkout for the agent's thread, so the agent may have run in the session thread's folder)`);
|
|
35
|
+
}
|
|
28
36
|
if (transcript) lines.push(`transcript: ${transcript}`);
|
|
29
37
|
return lines.join("\n");
|
|
30
38
|
}
|
|
@@ -54,7 +62,8 @@ export function listing(records: AgentRecord[], { transcriptOf, activityOf }: Lo
|
|
|
54
62
|
pid: r.pid,
|
|
55
63
|
startedAt: agent.startedAt,
|
|
56
64
|
endedAt: r.status === "running" ? undefined : r.endedAt,
|
|
57
|
-
worktree: agent.worktree?.path,
|
|
65
|
+
worktree: agent.worktree?.path ?? agent.hostWorktree?.path,
|
|
66
|
+
branch: agent.worktree?.branch ?? agent.hostWorktree?.branch,
|
|
58
67
|
sessionFile: transcriptOf(agent),
|
|
59
68
|
activity: r.status === "running" ? activityOf(agent) : undefined,
|
|
60
69
|
}));
|
package/plugin/pi/agent-tools.ts
CHANGED
|
@@ -33,7 +33,7 @@ const agentParams = (types: Map<string, AgentDefinition>) => Type.Object(
|
|
|
33
33
|
),
|
|
34
34
|
run_in_background: Type.Optional(Type.Boolean({ description: "Return at once; a completion notice arrives when the agent exits." })),
|
|
35
35
|
isolation: Type.Optional(Type.Unsafe<"worktree">({ type: "string", enum: ["worktree"], description: "Run the agent in its own git worktree." })),
|
|
36
|
-
readonly: Type.Optional(Type.Boolean({ description: "Run the agent without the edit and write tools." })),
|
|
36
|
+
readonly: Type.Optional(Type.Boolean({ description: "Run the agent without the edit and write tools. A T3 Code agent keeps them and is told in its first message that it is read-only." })),
|
|
37
37
|
},
|
|
38
38
|
{ additionalProperties: false },
|
|
39
39
|
);
|
|
@@ -83,7 +83,7 @@ export function registerAgentTools(pi: ExtensionAPI, runner: AgentRunner, settin
|
|
|
83
83
|
promptSnippet: "Launch a subagent (foreground or background, optional worktree isolation)",
|
|
84
84
|
parameters: agentParams(loadAgentTypes(settings)),
|
|
85
85
|
async execute(_id, params, signal, _onUpdate, ctx) {
|
|
86
|
-
const started = runner.start(params, ctx);
|
|
86
|
+
const started = await runner.start(params, ctx);
|
|
87
87
|
if (params.run_in_background) {
|
|
88
88
|
return {
|
|
89
89
|
content: [{ type: "text", text: `${JSON.stringify({ agentId: started.agent.id, status: "running" })}\n\n${BACKGROUND_NOTE}` }],
|
|
@@ -91,7 +91,9 @@ export function registerAgentTools(pi: ExtensionAPI, runner: AgentRunner, settin
|
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
93
|
const onAbort = () => void runner.stop(started.agent.id);
|
|
94
|
-
|
|
94
|
+
// start can wait on Orca's worktree show, so the abort may already have fired.
|
|
95
|
+
if (signal?.aborted) onAbort();
|
|
96
|
+
else signal?.addEventListener("abort", onAbort, { once: true });
|
|
95
97
|
const record = await runner.wait(started.agent.id).finally(() => signal?.removeEventListener("abort", onAbort));
|
|
96
98
|
return {
|
|
97
99
|
content: [{ type: "text", text: resultText(record, sessionFile(record.agent)) }],
|
package/plugin/pi/agents.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { Value } from "typebox/value";
|
|
|
8
8
|
|
|
9
9
|
import { AGENTS_ENTRY, noticeOf, OUTPUT_CAP_BYTES, statusText, truncateUtf8 } from "./agent-text.ts";
|
|
10
10
|
import type { AgentParams } from "./agent-tools.ts";
|
|
11
|
-
import { type Activity, type AgentChild, alive, type ChildExit, type Fate, PiChild, terminateGroup } from "./child.ts";
|
|
11
|
+
import { type Activity, type AgentChild, alive, type ChildExit, type Fate, type HostCheckout, PiChild, terminateGroup } from "./child.ts";
|
|
12
12
|
import { HcChild, pidOfTerminal } from "./hc-child.ts";
|
|
13
13
|
import { OrcaChild, opensTabs, orcaSession } from "./orca-child.ts";
|
|
14
14
|
import { t3Brief, T3_ENV_REMOVED, T3Child, t3Host, t3Session, type T3Task } from "./t3-child.ts";
|
|
@@ -48,6 +48,8 @@ const identitySchema = Type.Object({
|
|
|
48
48
|
worktree: Type.Optional(worktreeSchema),
|
|
49
49
|
host: Type.Optional(hostSchema),
|
|
50
50
|
t3ThreadId: Type.Optional(Type.String()),
|
|
51
|
+
// Set when the host makes the agent's checkout; empty until the host reports it.
|
|
52
|
+
hostWorktree: Type.Optional(Type.Object({ id: Type.Optional(Type.String()), path: Type.Optional(Type.String()), branch: Type.Optional(Type.String()) })),
|
|
51
53
|
startedAt: Type.String(),
|
|
52
54
|
});
|
|
53
55
|
const runningSchema = Type.Object({
|
|
@@ -261,7 +263,7 @@ export class AgentRunner {
|
|
|
261
263
|
private readonly settings: Settings,
|
|
262
264
|
) {}
|
|
263
265
|
|
|
264
|
-
start(params: AgentParams, ctx: ExtensionContext): RunningRecord {
|
|
266
|
+
async start(params: AgentParams, ctx: ExtensionContext): Promise<RunningRecord> {
|
|
265
267
|
const type = params.subagent_type || GENERAL_PURPOSE;
|
|
266
268
|
const types = loadAgentTypes(this.settings);
|
|
267
269
|
const def = types.get(type);
|
|
@@ -278,16 +280,14 @@ export class AgentRunner {
|
|
|
278
280
|
const sessionDir = join(state, "agents");
|
|
279
281
|
mkdirSync(sessionDir, { recursive: true });
|
|
280
282
|
const systemPromptFile = def.body ? join(state, "prompts", `${id}.md`) : undefined;
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
// cannot remove a thread's tools, so a read-only agent and one at the depth limit stay local, where
|
|
284
|
-
// --exclude-tools enforces them.
|
|
285
|
-
const t3 = sheet?.t3Host && t3Session() && !worktree && !params.readonly && this.settings.depth + 1 < MAX_SPAWN_DEPTH;
|
|
286
|
-
const orca = sheet?.orcaHost ? orcaSession(worktree?.repo ?? projectRoot(ctx.cwd)) : undefined;
|
|
287
|
-
const host: Host = t3 ? "t3"
|
|
283
|
+
const orca = sheet?.orcaHost ? orcaSession(projectRoot(ctx.cwd)) : undefined;
|
|
284
|
+
const host: Host = sheet?.t3Host && t3Session() ? "t3"
|
|
288
285
|
: sheet?.hcHost && process.env.HC_TERMINAL_ID ? "hc"
|
|
289
|
-
: orca && opensTabs(orca) ? "orca"
|
|
286
|
+
: orca && (await opensTabs(orca)) ? "orca"
|
|
290
287
|
: "rpc";
|
|
288
|
+
const isolated = params.isolation === "worktree";
|
|
289
|
+
const hostIsolates = isolated && (host === "t3" || host === "orca");
|
|
290
|
+
const worktree = isolated && !hostIsolates ? planWorktree(ctx.cwd, id) : undefined;
|
|
291
291
|
const identity: AgentIdentity = {
|
|
292
292
|
id,
|
|
293
293
|
description: params.description,
|
|
@@ -301,6 +301,7 @@ export class AgentRunner {
|
|
|
301
301
|
cwd: worktree?.path ?? ctx.cwd,
|
|
302
302
|
worktree,
|
|
303
303
|
host,
|
|
304
|
+
hostWorktree: hostIsolates ? {} : undefined,
|
|
304
305
|
startedAt: now(),
|
|
305
306
|
};
|
|
306
307
|
this.attachSession(ctx);
|
|
@@ -341,6 +342,11 @@ export class AgentRunner {
|
|
|
341
342
|
// T3 Code runs a task in its thread's folder, so an agent in a worktree must not hand its own agents to T3 Code.
|
|
342
343
|
const env = { [PARENT_SESSION_ENV]: this.ownSessionId, ...(identity.worktree && T3_ENV_REMOVED) };
|
|
343
344
|
const host = identity.host ?? "rpc";
|
|
345
|
+
const onWorktree = (checkout: HostCheckout) => {
|
|
346
|
+
identity.hostWorktree = { ...identity.hostWorktree, ...checkout };
|
|
347
|
+
identity.cwd = checkout.path;
|
|
348
|
+
this.track(identity.id, {});
|
|
349
|
+
};
|
|
344
350
|
if (host === "t3") {
|
|
345
351
|
const t3 = t3Session();
|
|
346
352
|
if (!t3) throw new Error(`Agent ${identity.id} runs in T3 Code; message it from a Pi session inside T3 Code.`);
|
|
@@ -349,7 +355,7 @@ export class AgentRunner {
|
|
|
349
355
|
this.track(identity.id, { t3TaskId: taskId });
|
|
350
356
|
};
|
|
351
357
|
const requestId = identity.t3ThreadId ? undefined : randomUUID();
|
|
352
|
-
const launch = { title: identity.description, model: identity.model, thinking: identity.thinking, threadId: identity.t3ThreadId, requestId, graceMs: this.settings.killGraceMs, onStart };
|
|
358
|
+
const launch = { title: identity.description, model: identity.model, thinking: identity.thinking, threadId: identity.t3ThreadId, requestId, onWorktree: identity.hostWorktree && onWorktree, graceMs: this.settings.killGraceMs, onStart };
|
|
353
359
|
return { child: new T3Child(t3, launch, identity.t3ThreadId ? prompt : t3Brief(identity, prompt)), host, t3RequestId: requestId };
|
|
354
360
|
}
|
|
355
361
|
// An interactive pi asks whether to trust the project before it reports any status; the parent already decided.
|
|
@@ -367,9 +373,11 @@ export class AgentRunner {
|
|
|
367
373
|
return { child, host };
|
|
368
374
|
}
|
|
369
375
|
const orca = host === "orca" ? orcaSession(identity.worktree?.repo ?? projectRoot(identity.cwd)) : undefined;
|
|
376
|
+
const workspace = identity.hostWorktree?.id;
|
|
370
377
|
if (orca) {
|
|
371
378
|
const child = new OrcaChild(command, interactiveArgs, {
|
|
372
|
-
session: orca,
|
|
379
|
+
session: workspace ? { ...orca, worktree: { id: workspace } } : orca,
|
|
380
|
+
create: identity.hostWorktree && !workspace ? { name: `agent-${identity.id}`, onWorktree } : undefined,
|
|
373
381
|
title: `${identity.description} (${identity.id})`,
|
|
374
382
|
cwd: identity.cwd,
|
|
375
383
|
env: { ...env, PI_CODING_AGENT_DIR: this.settings.agentDir },
|
|
@@ -380,6 +388,8 @@ export class AgentRunner {
|
|
|
380
388
|
}, prompt);
|
|
381
389
|
return { child, host: "orca" };
|
|
382
390
|
}
|
|
391
|
+
// Its cwd is still the parent's checkout until Orca makes the workspace, so no other host may run it.
|
|
392
|
+
if (host === "orca" && identity.hostWorktree && !workspace) throw new Error(`Agent ${identity.id} has no Orca workspace yet; message it from a Pi session inside Orca.`);
|
|
383
393
|
const child = new PiChild(command, [...base, "--mode", "rpc", ...flags], { cwd: identity.cwd, env, exitGraceMs: this.settings.exitGraceMs, onActivity: () => this.showStatus() }, prompt);
|
|
384
394
|
return { child, host: "rpc" };
|
|
385
395
|
}
|
package/plugin/pi/child.ts
CHANGED
|
@@ -43,6 +43,12 @@ export interface ChildExit {
|
|
|
43
43
|
interruption?: string;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
export interface HostCheckout {
|
|
47
|
+
id?: string;
|
|
48
|
+
path: string;
|
|
49
|
+
branch?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
46
52
|
// What a running child is doing, last event wins. It lives only in this
|
|
47
53
|
// process's memory: nothing appends it to the session or sends it as a message,
|
|
48
54
|
// and the model sees it only in a list_agents result.
|
package/plugin/pi/orca-child.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { execFile
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
2
|
import { readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
4
4
|
import { promisify } from "node:util";
|
|
@@ -6,15 +6,17 @@ import { type Static, type TSchema, Type } from "typebox";
|
|
|
6
6
|
import { Value } from "typebox/value";
|
|
7
7
|
|
|
8
8
|
import { AGENTS_ENTRY, NOTICE_TYPE } from "./agent-text.ts";
|
|
9
|
-
import { alive, type ChildExit, signalGroup, terminateGroup } from "./child.ts";
|
|
9
|
+
import { alive, type ChildExit, type HostCheckout, signalGroup, terminateGroup } from "./child.ts";
|
|
10
10
|
import { envScript, jsonLines, replyOf, sizeOf } from "./hc-child.ts";
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const execFileAsync = promisify(execFile);
|
|
13
13
|
export const SETTLE_POLL_MS = 500;
|
|
14
14
|
const CLOSE_POLL_MS = 200;
|
|
15
15
|
const CALL_TIMEOUT_MS = 10_000;
|
|
16
|
+
const CREATE_TIMEOUT_MS = 60_000;
|
|
16
17
|
|
|
17
18
|
const createResult = Type.Object({ result: Type.Object({ terminal: Type.Object({ handle: Type.String(), processId: Type.Number() }) }) });
|
|
19
|
+
const worktreeResult = Type.Object({ result: Type.Object({ worktree: Type.Object({ id: Type.String(), path: Type.String(), branch: Type.String() }) }) });
|
|
18
20
|
const sendResult = Type.Object({ result: Type.Object({ send: Type.Object({ accepted: Type.Boolean() }) }) });
|
|
19
21
|
const readResult = Type.Object({ result: Type.Object({ terminal: Type.Object({ tail: Type.Array(Type.String()) }) }) });
|
|
20
22
|
const failedResult = Type.Object({ error: Type.Object({ message: Type.String() }) });
|
|
@@ -44,14 +46,12 @@ export function orcaSession(root: string, env: NodeJS.ProcessEnv = process.env,
|
|
|
44
46
|
return inOrca && cli ? { cli, worktree: id ? { id } : { path: root } } : undefined;
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
export function opensTabs(session: OrcaSession): boolean {
|
|
49
|
+
export async function opensTabs(session: OrcaSession): Promise<boolean> {
|
|
48
50
|
if ("id" in session.worktree) return true;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
51
|
+
return execFileAsync(session.cli, ["worktree", "show", `--worktree=${selector(session.worktree)}`, "--json"], { timeout: CALL_TIMEOUT_MS }).then(
|
|
52
|
+
() => true,
|
|
53
|
+
() => false,
|
|
54
|
+
);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
export function settledRun(entries: unknown[], steers: number): Pick<ChildExit, "interruption"> | undefined {
|
|
@@ -77,6 +77,7 @@ export interface OrcaOptions {
|
|
|
77
77
|
graceMs: number;
|
|
78
78
|
transcript: () => string | undefined;
|
|
79
79
|
onStart: (pid: number) => void;
|
|
80
|
+
create?: { name: string; onWorktree: (checkout: HostCheckout) => void };
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
export class OrcaChild {
|
|
@@ -102,10 +103,8 @@ export class OrcaChild {
|
|
|
102
103
|
writeFileSync(files.env, envScript({ ...process.env, ...opts.env }, "ORCA_"), { mode: 0o600 });
|
|
103
104
|
// Pi reads an argument that starts with @ as a file, even after --, and one that starts with / as a command.
|
|
104
105
|
writeFileSync(files.prompt, /^[@/]/.test(prompt) ? ` ${prompt}` : prompt, { mode: 0o600 });
|
|
105
|
-
const launch = `. ${quote(files.env)} && rm -- ${quote(files.env)} && p=$(cat ${quote(files.prompt)}; printf x) && p=\${p%x} && rm -- ${quote(files.prompt)} && cd ${quote(opts.cwd)} && exec ${[command, ...args].map(quote).join(" ")} -- "$p" 2>>${quote(files.err)}\n`;
|
|
106
|
-
writeFileSync(files.script, launch, { mode: 0o600 });
|
|
107
106
|
const from = sizeOf(opts.transcript());
|
|
108
|
-
const created = this.
|
|
107
|
+
const created = this.open([command, ...args], opts);
|
|
109
108
|
this.exited = this.drive(created, from, opts);
|
|
110
109
|
}
|
|
111
110
|
|
|
@@ -143,6 +142,31 @@ export class OrcaChild {
|
|
|
143
142
|
else this.removeFiles();
|
|
144
143
|
}
|
|
145
144
|
|
|
145
|
+
private async open(argv: string[], opts: OrcaOptions): Promise<Static<typeof createResult>> {
|
|
146
|
+
const { worktree, cwd } = opts.create ? await this.createWorkspace(opts.create, opts) : { worktree: opts.session.worktree, cwd: opts.cwd };
|
|
147
|
+
const { env, prompt, script, err } = this.files;
|
|
148
|
+
const launch = `. ${quote(env)} && rm -- ${quote(env)} && p=$(cat ${quote(prompt)}; printf x) && p=\${p%x} && rm -- ${quote(prompt)} && cd ${quote(cwd)} && exec ${argv.map(quote).join(" ")} -- "$p" 2>>${quote(err)}\n`;
|
|
149
|
+
writeFileSync(script, launch, { mode: 0o600 });
|
|
150
|
+
return this.orca(createResult, ["terminal", "create", `--worktree=${selector(worktree)}`, `--title=${opts.title}`, `--command=exec sh ${quote(script)}`]);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// No --repo: Orca takes the repo from the workspace the CLI's directory is in.
|
|
154
|
+
private async createWorkspace({ name, onWorktree }: NonNullable<OrcaOptions["create"]>, { session, cwd }: OrcaOptions): Promise<{ worktree: OrcaSession["worktree"]; cwd: string }> {
|
|
155
|
+
const { stdout } = await execFileAsync("git", ["rev-parse", "HEAD"], { cwd, timeout: CALL_TIMEOUT_MS }).catch((e: { stderr?: string; message: string }) => {
|
|
156
|
+
throw new Error(`git rev-parse HEAD, for the commit of the Orca workspace, failed: ${e.stderr?.trim() || e.message}`);
|
|
157
|
+
});
|
|
158
|
+
if (this.ending) throw new Error("stopped before its tab opened");
|
|
159
|
+
const head = stdout.trim();
|
|
160
|
+
const args = ["worktree", "create", `--name=${name}`, `--parent-worktree=${selector(session.worktree)}`, `--base-branch=${head}`];
|
|
161
|
+
// A create whose reply was lost may still have made the workspace.
|
|
162
|
+
const made = await this.orca(worktreeResult, ["worktree", "show", `--worktree=name:${name}`], { cwd }).catch(() => undefined);
|
|
163
|
+
if (!made && this.ending) throw new Error("stopped before its tab opened");
|
|
164
|
+
const { id, path, branch } = (made ?? (await this.orca(worktreeResult, args, { cwd, timeout: CREATE_TIMEOUT_MS }))).result.worktree;
|
|
165
|
+
onWorktree({ id, path, branch: branch.replace(/^refs\/heads\//, "") });
|
|
166
|
+
if (this.ending) throw new Error("stopped before its tab opened");
|
|
167
|
+
return { worktree: { id }, cwd: path };
|
|
168
|
+
}
|
|
169
|
+
|
|
146
170
|
private async drive(created: Promise<Static<typeof createResult>>, from: number, opts: OrcaOptions): Promise<ChildExit> {
|
|
147
171
|
const written = () => {
|
|
148
172
|
const file = opts.transcript();
|
|
@@ -206,9 +230,9 @@ export class OrcaChild {
|
|
|
206
230
|
);
|
|
207
231
|
}
|
|
208
232
|
|
|
209
|
-
private async orca<T extends TSchema>(schema: T, args: string[]): Promise<Static<T>> {
|
|
210
|
-
const { stdout } = await
|
|
211
|
-
throw e.killed ? new Error(`orca ${args[0]} ${args[1]} did not answer within ${
|
|
233
|
+
private async orca<T extends TSchema>(schema: T, args: string[], { cwd, timeout = CALL_TIMEOUT_MS }: { cwd?: string; timeout?: number } = {}): Promise<Static<T>> {
|
|
234
|
+
const { stdout } = await execFileAsync(this.cli, [...args, "--json"], { cwd, timeout }).catch((e: { killed?: boolean }) => {
|
|
235
|
+
throw e.killed ? new Error(`orca ${args[0]} ${args[1]} did not answer within ${timeout / 1000} s`) : e;
|
|
212
236
|
});
|
|
213
237
|
let answer: unknown;
|
|
214
238
|
try {
|
package/plugin/pi/t3-child.ts
CHANGED
|
@@ -3,10 +3,11 @@ import { setTimeout as sleep } from "node:timers/promises";
|
|
|
3
3
|
import { type Static, type TSchema, Type } from "typebox";
|
|
4
4
|
import { Value } from "typebox/value";
|
|
5
5
|
|
|
6
|
-
import { alive, type ChildExit, type Fate } from "./child.ts";
|
|
6
|
+
import { alive, type ChildExit, type Fate, type HostCheckout } from "./child.ts";
|
|
7
7
|
|
|
8
8
|
const PROTOCOL = "2025-06-18";
|
|
9
9
|
const WAIT_MS = 30_000;
|
|
10
|
+
const STOPPED_READ_MS = 1_000;
|
|
10
11
|
const LOST_LAUNCH = "pstack: the Pi session that started this agent ended before T3 Code answered its launch, so the task is cancelled.";
|
|
11
12
|
const LATE_STEER = "T3 Code put it in the agent's thread after pstack stopped following the agent's run, so pstack does not read the reply.";
|
|
12
13
|
// T3 Code's terminal task statuses (OrchestratorMcpTerminalDelegatedTaskStatus).
|
|
@@ -21,6 +22,7 @@ const delegated = Type.Object({ taskId: Type.String(), childThreadId: Type.Strin
|
|
|
21
22
|
const sent = Type.Object({ taskId: Type.Optional(Type.Union([Type.String(), Type.Null()])), runId: Type.String(), delivery: Type.String() });
|
|
22
23
|
const waited = Type.Object({ timedOut: Type.Boolean() });
|
|
23
24
|
const taskResult = Type.Object({ status: Type.String(), summary: Type.Union([Type.String(), Type.Null()]) });
|
|
25
|
+
const threadRead = Type.Object({ thread: Type.Object({ worktreePath: Type.Union([Type.String(), Type.Null()]), branch: Type.Union([Type.String(), Type.Null()]) }) });
|
|
24
26
|
const capabilities = Type.Object({
|
|
25
27
|
inheritedProviderInstanceId: Type.String(),
|
|
26
28
|
inheritedModel: Type.Optional(Type.Union([Type.String(), Type.Null()])),
|
|
@@ -56,6 +58,7 @@ export interface T3Launch {
|
|
|
56
58
|
thinking?: string;
|
|
57
59
|
threadId?: string;
|
|
58
60
|
requestId?: string;
|
|
61
|
+
onWorktree?: (checkout: HostCheckout) => void;
|
|
59
62
|
graceMs: number;
|
|
60
63
|
onStart: (task: T3Task) => void;
|
|
61
64
|
}
|
|
@@ -66,10 +69,11 @@ interface T3Request {
|
|
|
66
69
|
}
|
|
67
70
|
|
|
68
71
|
// A T3 Code thread takes no launch flags, so its first message carries the agent file's body.
|
|
69
|
-
export function t3Brief(agent: { subagentType: string; systemPromptFile?: string }, prompt: string): string {
|
|
72
|
+
export function t3Brief(agent: { subagentType: string; systemPromptFile?: string; readonly?: boolean }, prompt: string): string {
|
|
70
73
|
const body = agent.systemPromptFile ? readFileSync(agent.systemPromptFile, "utf8").trim() : "";
|
|
71
74
|
const parts = [
|
|
72
75
|
body && `<agent name="${agent.subagentType}">\n${body}\n</agent>`,
|
|
76
|
+
agent.readonly && "You are read-only: do not create, change, or delete any file.",
|
|
73
77
|
prompt,
|
|
74
78
|
];
|
|
75
79
|
return parts.filter(Boolean).join("\n\n");
|
|
@@ -101,8 +105,9 @@ export class T3Child {
|
|
|
101
105
|
|
|
102
106
|
async steer(message: string): Promise<{ response: { success: boolean; error?: string } | undefined; taken: boolean }> {
|
|
103
107
|
const threadId = this.threadId;
|
|
104
|
-
if (this.done || threadId === undefined) return { response: undefined, taken: false };
|
|
108
|
+
if (this.done || this.ending || threadId === undefined) return { response: undefined, taken: false };
|
|
105
109
|
const send = this.steers.then(async () => {
|
|
110
|
+
if (this.ending) return;
|
|
106
111
|
this.stopWaiting.signal.throwIfAborted();
|
|
107
112
|
// A stop never aborts a sent steer, so an answer that names a task the steer started still arrives, and that task is cancelled. Only ten grace periods of silence end it.
|
|
108
113
|
const { taskId, runId, delivery } = await this.mcp.call(sent, "t3_thread_send", { threadId, message, mode: "steer" }, AbortSignal.timeout(10 * this.graceMs));
|
|
@@ -117,9 +122,11 @@ export class T3Child {
|
|
|
117
122
|
if (!(await this.steersAnswered())) return { response: undefined, taken: false };
|
|
118
123
|
try {
|
|
119
124
|
await send;
|
|
125
|
+
if (this.ending) return { response: undefined, taken: false };
|
|
120
126
|
return this.done ? { response: { success: false, error: LATE_STEER }, taken: false } : { response: { success: true }, taken: true };
|
|
121
|
-
} catch {
|
|
122
|
-
return { response: undefined, taken: false };
|
|
127
|
+
} catch (e) {
|
|
128
|
+
if ((e as Error).name !== "TimeoutError") return { response: undefined, taken: false };
|
|
129
|
+
return { response: { success: false, error: `T3 Code had not answered after ${(10 * this.graceMs) / 1000} s and may have put it, or may still put it, in the agent's thread, so pstack does not send it again.` }, taken: false };
|
|
123
130
|
}
|
|
124
131
|
}
|
|
125
132
|
|
|
@@ -134,6 +141,24 @@ export class T3Child {
|
|
|
134
141
|
signal(): void {}
|
|
135
142
|
|
|
136
143
|
private async drive(launch: T3Launch, prompt: string): Promise<ChildExit> {
|
|
144
|
+
const exit = await this.run(launch, prompt);
|
|
145
|
+
if (!launch.onWorktree || this.threadId === undefined) return exit;
|
|
146
|
+
const checkout = await this.checkout(this.threadId, this.ending ? STOPPED_READ_MS : launch.graceMs);
|
|
147
|
+
if (checkout) launch.onWorktree(checkout);
|
|
148
|
+
return exit;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// T3 Code may rename the branch after the first turn, so the thread is read after each run.
|
|
152
|
+
private async checkout(threadId: string, timeoutMs: number): Promise<HostCheckout | undefined> {
|
|
153
|
+
try {
|
|
154
|
+
const { thread } = await this.mcp.call(threadRead, "t3_thread_read", { threadId, limit: 1, maxCharsPerItem: 1 }, AbortSignal.timeout(timeoutMs));
|
|
155
|
+
return thread.worktreePath === null ? undefined : { path: thread.worktreePath, ...(thread.branch !== null && { branch: thread.branch }) };
|
|
156
|
+
} catch {
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
private async run(launch: T3Launch, prompt: string): Promise<ChildExit> {
|
|
137
162
|
try {
|
|
138
163
|
const threadId = await this.start(launch, prompt);
|
|
139
164
|
if (this.ending) await this.cancel();
|
|
@@ -174,7 +199,8 @@ export class T3Child {
|
|
|
174
199
|
}
|
|
175
200
|
const thinking = launch.thinking && (await this.takesThinking(launch.model, launch.thinking)) ? { options: { thinking: launch.thinking } } : {};
|
|
176
201
|
const target = { ...(launch.model && { model: launch.model }), ...thinking };
|
|
177
|
-
const
|
|
202
|
+
const isolation = launch.onWorktree ? { isolation: "worktree" } : {};
|
|
203
|
+
const task = await this.mcp.call(delegated, "delegate_task", { task: prompt, title: launch.title, target, mode: "async", ...isolation, clientRequestId: launch.requestId });
|
|
178
204
|
this.threadId = task.childThreadId;
|
|
179
205
|
this.taskId = task.taskId;
|
|
180
206
|
this.runId = task.childRunId ?? undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Antigravity tool mapping for pstack
|
|
2
2
|
|
|
3
|
-
The Antigravity CLI (`agy`) loads the native pstack plugin manifest, the skills,
|
|
3
|
+
The Antigravity CLI (`agy`) loads the native pstack plugin manifest, the skills, and the `SessionStart` hook. Resolve each Claude Code tool, model, and path a pstack skill names here.
|
|
4
4
|
|
|
5
5
|
## Tool actions
|
|
6
6
|
|
|
@@ -28,11 +28,12 @@ The Antigravity CLI (`agy`) loads the native pstack plugin manifest, the skills,
|
|
|
28
28
|
|
|
29
29
|
poteto-mode's Subagents section sets Claude-specific defaults (`subagent_type: "pstack:poteto-agent"`, `run_in_background: true`). On Antigravity:
|
|
30
30
|
|
|
31
|
-
-
|
|
32
|
-
- `pstack:poteto-agent` and `general-purpose` map to `TypeName: "self"` when the subagent writes files, runs commands, or uses MCP tools
|
|
33
|
-
-
|
|
31
|
+
- Antigravity bills custom and plugin agents at 4x the standard Gemini quota rate, as reported in [antigravity-cli#1890](https://github.com/google-antigravity/antigravity-cli/issues/1890), while the default agent and the built-in `self` and `research` subagents run at the standard rate. The Antigravity install omits the plugin's agent definitions. Even if an older install still lists them in `<subagents>`, never pass `poteto-agent`, `comment-sicko`, `thermo-nuclear-review-subagent`, `thermo-nuclear-code-quality-review-subagent`, or their `pstack:` forms as `TypeName` or `--agent`.
|
|
32
|
+
- `pstack:poteto-agent` and `general-purpose` map to `TypeName: "self"` when the subagent writes files, runs commands, or uses MCP tools, and to `TypeName: "research"` for read-only work that needs no shell, network, or MCP access. Give each `poteto-mode` delegate the installed path to `poteto-mode/SKILL.md` from `<skills>` with `~` expanded, and tell it in `Prompt` to read the entire file with `read_file` first, including the Models and Reasoning effort sections at the end.
|
|
33
|
+
- `pstack:comment-sicko`, which the **no-comments** skill spawns on Claude Code, maps to `TypeName: "self"` because it edits files to delete comments and may run commands or web searches to verify external rules. Resolve `poteto-mode/references/agents/comment-sicko.md` from `poteto-mode`'s path in `<skills>` with `~` expanded, and tell the subagent in `Prompt` to read that file in full with `read_file` first.
|
|
34
|
+
- `pstack:thermo-nuclear-review-subagent` and `pstack:thermo-nuclear-code-quality-review-subagent`, which the **thermos** skill spawns on Claude Code, map to two `TypeName: "research"` calls. When a reviewer needs `gh` or shell access to read pull request discussion, use `TypeName: "self"` and tell it in `Prompt` not to write files. Give each subagent the installed path to `thermo-nuclear-review/SKILL.md` or `thermo-nuclear-code-quality-review/SKILL.md` from `<skills>` with `~` expanded, and tell it in `Prompt` to read that skill in full with `read_file` first and review only the diff and file excerpts in `Prompt`.
|
|
34
35
|
- `invoke_subagent` always runs asynchronously in the background, so `run_in_background: true` needs no extra flag.
|
|
35
|
-
- `readonly: true` (reviewers, explorers, critics) maps to `TypeName: "research"`
|
|
36
|
+
- `readonly: true` (reviewers, explorers, critics) maps to `TypeName: "research"` when no shell, network, MCP, or write tools are needed. When a read-only subagent needs `run_command`, network access, or MCP tools, use `TypeName: "self"` and tell it in `Prompt` not to write files.
|
|
36
37
|
- `isolation: "worktree"` maps to `Workspace: "share"` (creates a shared git worktree-style workspace) or `Workspace: "branch"` on `invoke_subagent`, or a manual `git worktree add` path named in `Prompt`.
|
|
37
38
|
- Keep the rest of the policy unchanged. Pass file pointers not inlined context, and review every subagent's diff yourself.
|
|
38
39
|
|
|
@@ -76,8 +77,8 @@ Most skills need only the tables above. These need one more mapping:
|
|
|
76
77
|
| `architect` | A large or contested design goes through the **arena** skill: one `invoke_subagent` call per runner, each with a `Model` from the sheet's `arena runners` line. |
|
|
77
78
|
| `how` | The one read-only subagent maps to `invoke_subagent`. |
|
|
78
79
|
| `arena` | The parallel candidates and the cross-judge map to `invoke_subagent` calls with the sheet's panel lines. |
|
|
79
|
-
| `no-comments` | Dispatch
|
|
80
|
-
| `thermos` | Dispatch
|
|
80
|
+
| `no-comments` | Dispatch via `invoke_subagent` with `TypeName: "self"` and tell it in `Prompt` to read `poteto-mode/references/agents/comment-sicko.md` in full with `read_file` first, as Subagent policy describes. |
|
|
81
|
+
| `thermos` | Dispatch two `invoke_subagent` calls with `TypeName: "research"`, telling each in `Prompt` to read `thermo-nuclear-review/SKILL.md` or `thermo-nuclear-code-quality-review/SKILL.md` in full with `read_file` first and review only the diff and file excerpts in `Prompt`. When a reviewer needs `gh` or shell access, use `TypeName: "self"` and tell it in `Prompt` not to write files. |
|
|
81
82
|
| `swarm` | Each worker is an `invoke_subagent` call; use `Workspace: "share"` or `git worktree add` for writing workers. |
|
|
82
83
|
| `teach` | Running `how` and `why` in parallel maps to two `invoke_subagent` calls in one response; image generation uses `image-generator` via `invoke_subagent`. |
|
|
83
84
|
| `why` | List MCP servers from the tools Antigravity exposes to the session, not from Claude Code's MCP files. |
|
|
@@ -33,13 +33,13 @@ pstack skills are written in Claude Code tool language (the `Skill` tool, the `A
|
|
|
33
33
|
poteto-mode's Subagents section applies on Pi through the `agent` tool:
|
|
34
34
|
|
|
35
35
|
- `subagent_type` takes the same values. `pstack:poteto-agent`, `pstack:comment-sicko`, `pstack:thermo-nuclear-review-subagent`, and `pstack:thermo-nuclear-code-quality-review-subagent` resolve to the plugin's agent files. A `.md` file in `pstack-agents` in the Pi agent directory adds a type under its file name with no `pstack:` prefix, as a Claude Code user agent has no plugin prefix, and the body after the frontmatter is the child's system prompt. Its `tools:`, `disallowedTools:`, and `isolation:` fields are ignored, so pass `readonly: true` or `isolation: "worktree"` on the `agent` call instead. A hidden file, a file whose name has a colon, and one that cannot be read are skipped. The extension reads the frontmatter as YAML, and a repeated key keeps its last value, as in Claude Code. When the YAML does not parse, it retries as Claude Code 2.1.310 does, reading an unquoted top-level value that holds YAML syntax, such as `description: Use for a: b`, as text and turning leading tabs into spaces. It skips a user file whose frontmatter still does not parse. A user file never replaces a type, so `poteto-agent.md` there adds `poteto-agent` and leaves `pstack:poteto-agent` alone. The extension does not read Pi's `agents` folder, whose files other subagent extensions write with their own frontmatter. `general-purpose`, or no `subagent_type`, runs a child with no agent file. Claude Code's built-in types such as `Explore` and `Plan` do not exist on Pi, so use `general-purpose` and put the constraint in the prompt. An unknown type errors and lists the valid ones. The `agent` tool's `subagent_type` description lists each type the session starts with and what it is for, from each agent file's `description:`, the user's files included.
|
|
36
|
-
- `readonly: true`, which the `how` subagent sets, runs the child without the `edit` and `write` tools. It keeps `bash`, so a reviewer can still run `git diff`; say in the prompt that it must not change files.
|
|
36
|
+
- `readonly: true`, which the `how` subagent sets, runs the child without the `edit` and `write` tools, except a T3 agent, which is only told in its first message that it is read-only. It keeps `bash`, so a reviewer can still run `git diff`; say in the prompt that it must not change files.
|
|
37
37
|
- Each child is its own `pi --mode rpc` process in your working directory, and the extension sends it the prompt on its stdin. It loads the packages and settings saved on disk, so it sees the pstack skills when pstack was installed with `pi install`. It does not inherit the parent's command-line flags, such as `-e`, `--api-key`, or a one-off `-a` project trust, so a pstack loaded only through `-e` gives children no extension.
|
|
38
38
|
- With a `pi agent host: hc` line in the sheet and the session inside herdr-core (`HC_TERMINAL_ID` is set), each child started there is instead an interactive `pi` in its own `hc` terminal, named by its agent id, with the same flags. The user can watch it and type into it, and `hc read <agentId>` shows its screen. Stop it with `stop_agent`, not `hc kill`. `send_message` to a running one types into its terminal with `hc send`, its reply is read from its transcript, `list_agents` shows no `activity` for it, and its terminal is removed when the run ends. A child that stops at a dialog fails with its screen as the error. It gets your environment, except herdr-core's own terminal variables, and your session's project trust. A prompt over 128 KiB fails on Linux; put long material in a file and name the file in the prompt. A prompt that is empty once trimmed is refused, as is such a message to a finished one. Messaged from a session outside herdr-core, it runs that turn as an RPC child.
|
|
39
|
-
- With a `pi agent host: t3` line in the sheet and the session inside T3 Code (`T3_MCP_URL` and `T3_MCP_BEARER_TOKEN` are set), each child started there
|
|
40
|
-
- With a `pi agent host: orca` line in the sheet and the session in an [Orca](https://github.com/stablyai/orca) terminal or its chat panel (`ORCA_TERMINAL_HANDLE` or `ORCA_STRUCTURED_SESSION` is set, and `ORCA_CLI_COMMAND` too except on macOS, where the `orca` on `PATH` is used), each child started there is instead an interactive `pi` in its own tab of your Orca workspace, titled with the agent's description and its id, as in `review the diff (a1b2c3d4e5f6a7b8)`, with the same flags as an RPC child. The workspace is the one `ORCA_WORKTREE_ID` or `ORCA_WORKSPACE_ID` names. Without either, as in a structured worker from Orca's `orchestration worker-start` or the Pi in Orca's chat panel, it is the workspace at the git top level of your session's working directory, or at that directory when git gives no top level, as outside a git repository, and when Orca's `worktree show` does not confirm that directory as one Orca registered, or its CLI is missing, the agent runs as an RPC child. When the sheet also has `pi agent host: hc` and the session is inside herdr-core, hc wins. The user can watch it and type into it. `send_message` to a running one types into its tab with Orca's `terminal send`, and its reply is read from its transcript. Pi's editor takes that message, so a message that starts with `!` or `/`, which the editor would run as a command, is refused, and the editor trims the message's ends and turns tabs into spaces and CRLF into LF, so an empty message is refused too. A prompt that starts with `@` or `/` reaches the child with one leading space. A prompt that is empty once trimmed is refused, as is such a message to a finished one. A run that the user stops with Escape in Orca ends `stopped`, and its notice starts a turn. Each Orca CLI call gives up after 10 seconds. A child that stops at a dialog waits until someone answers it in Orca. Stop it with `stop_agent`, not by closing its tab. Its tab closes when the run ends, and a message to a finished one resumes it in a new tab. It gets your environment, except Orca's own terminal variables (`ORCA_*`), and your session's project trust.
|
|
41
|
-
- A child can start its own agents, down to three layers below the main session, as on Claude Code. A child at the third layer runs without the `agent` tool.
|
|
42
|
-
- `isolation: "worktree"` runs the child in its own git worktree under `.claude/worktrees
|
|
39
|
+
- With a `pi agent host: t3` line in the sheet and the session inside T3 Code (`T3_MCP_URL` and `T3_MCP_BEARER_TOKEN` are set), each child started there is instead a T3 Code child thread of your thread, titled with the agent's description, on the agent's model, in your thread's folder. With `isolation: "worktree"`, the thread runs in a new checkout that T3 Code makes from your thread's commit, and the result names its path and branch; T3 Code's worktree cleanup settings, not the extension, decide when it is removed. Its effort goes to T3 Code only when T3 Code lists that level for the model. The user can watch it and type into it in T3 Code. `send_message` to a running one steers its turn, a finished one resumes in the same thread, and `stop_agent` cancels its task; when T3 Code refuses the cancel, the agent reads as stopped with the refusal as its text, and its thread can go on running. When T3 Code accepts the cancel but the thread has not settled after the kill grace, the agent also reads as stopped. A message that T3 Code queues or starts as a new turn instead of steering, such as one that starts with a slash command, is sent once, and the agent runs until that turn ends. T3 Code cannot remove a thread's tools, so a `readonly: true` agent is only told, in its first message, that it is read-only, and the third-layer limit does not apply to a T3 agent. A question it asks waits until someone answers it in T3 Code. T3 Code marks its first message as sent by an agent, so say in the prompt that the user started the task. The agent file's body arrives at the top of its first message. Only a Pi session inside T3 Code can message it. `list_agents` shows no `activity` and no transcript for it; its transcript is the T3 Code thread.
|
|
40
|
+
- With a `pi agent host: orca` line in the sheet and the session in an [Orca](https://github.com/stablyai/orca) terminal or its chat panel (`ORCA_TERMINAL_HANDLE` or `ORCA_STRUCTURED_SESSION` is set, and `ORCA_CLI_COMMAND` too except on macOS, where the `orca` on `PATH` is used), each child started there is instead an interactive `pi` in its own tab of your Orca workspace, titled with the agent's description and its id, as in `review the diff (a1b2c3d4e5f6a7b8)`, with the same flags as an RPC child. The workspace is the one `ORCA_WORKTREE_ID` or `ORCA_WORKSPACE_ID` names. Without either, as in a structured worker from Orca's `orchestration worker-start` or the Pi in Orca's chat panel, it is the workspace at the git top level of your session's working directory, or at that directory when git gives no top level, as outside a git repository, and when Orca's `worktree show` does not confirm that directory as one Orca registered, or its CLI is missing, the agent runs as an RPC child. When the sheet also has `pi agent host: hc` and the session is inside herdr-core, hc wins. The user can watch it and type into it. `send_message` to a running one types into its tab with Orca's `terminal send`, and its reply is read from its transcript. Pi's editor takes that message, so a message that starts with `!` or `/`, which the editor would run as a command, is refused, and the editor trims the message's ends and turns tabs into spaces and CRLF into LF, so an empty message is refused too. A prompt that starts with `@` or `/` reaches the child with one leading space. A prompt that is empty once trimmed is refused, as is such a message to a finished one. A run that the user stops with Escape in Orca ends `stopped`, and its notice starts a turn. Each Orca CLI call gives up after 10 seconds, and `worktree create` after 60. A child that stops at a dialog waits until someone answers it in Orca. Stop it with `stop_agent`, not by closing its tab. Its tab closes when the run ends, and a message to a finished one resumes it in a new tab. It gets your environment, except Orca's own terminal variables (`ORCA_*`), and your session's project trust. With `isolation: "worktree"`, Orca makes a new workspace from your commit, as a child of your workspace, and the tab runs there; the result names its path and branch, a resume reuses it, and Orca keeps it until you remove it. When Orca cannot make it, the agent fails with Orca's or git's error. `list_agents` shows no `activity` for it. On Linux, a prompt over 128 KiB fails and a message over 128 KiB is refused; put long material in a file and name the file in the prompt. Messaged from a session outside an Orca terminal, it runs that turn as an RPC child. Orca on Windows is not supported.
|
|
41
|
+
- A child can start its own agents, down to three layers below the main session, as on Claude Code. A child at the third layer runs without the `agent` tool. A T3 agent's own Pi counts its layers from zero.
|
|
42
|
+
- `isolation: "worktree"` runs the child in its own git worktree under `.claude/worktrees/`, except a T3 or Orca agent, whose checkout its host makes. T3 Code's cleanup settings decide when a T3 checkout goes, and an Orca workspace stays until you remove it. A worktree the extension made and the agent left nothing in is removed when the agent finishes; a change, a gitignored file it wrote, or a commit on its branch or on any commit its HEAD visited keeps it.
|
|
43
43
|
- `run_in_background: true` returns the agent id at once. The completion joins the conversation after your current tool calls finish, as on Claude Code, or starts a turn when you are idle. In print and JSON mode (`pi -p`), where Pi exits once the run settles, the extension holds the settle while a background agent runs, so each completion still arrives as a turn and the process ends after the last one. A child agent holds its settle the same way while its own background agents run, because its parent closes its stdin once it settles, and a message from the parent ends the hold. Interactive and RPC main sessions settle as usual and take the completion when it arrives.
|
|
44
44
|
- While a background agent runs, the extension blocks a `bash` command line in which the word `sleep` is followed by a literal duration of two seconds or more, anywhere in the line, poll loops included: `sleep 30`, `npm test; sleep 30`, `until gh pr checks 1; do sleep 30; done`, `sleep infinity`. A shorter sleep, a sleep backgrounded as `sleep 30 &`, and `sleep` inside a quoted string, a comment, or a heredoc all run. The rule errs toward blocking, so `timeout 5 sleep 30` and a sleep inside a backgrounded group are blocked too. The completion notice arrives on its own, so continue other work or end your turn.
|
|
45
45
|
- An agent's status follows its process. `completed` means the child exited, and `stop_agent` reports `stopped` only once the child has exited, so the Claude Code caveat about a `completed` agent that keeps running does not apply to the agent itself. Stopping an agent, like the session shutdown that stops every agent, ends the child pi and the `bash` command it still has running, because Pi kills that command's process tree on SIGTERM. A process that a finished `bash` command left in the background (`cmd &`, `nohup cmd`) runs in its own process group and outlives the agent; stop it yourself. A stopped agent's notice joins the conversation without starting a turn, since `stop_agent` already returned.
|