@deathbeam/pi-delegate 0.0.31 → 0.0.33

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/index.ts CHANGED
@@ -270,14 +270,16 @@ export default function (pi: ExtensionAPI) {
270
270
  if (agent.prompt) args.push("--append-system-prompt", agent.prompt);
271
271
  const entrypoint = process.argv[1];
272
272
  if (!entrypoint) throw new Error("Pi CLI entrypoint missing; start Pi from its CLI to delegate.");
273
+ const cwd = isolation ? cloneCwd(isolation, ctx.cwd) : ctx.cwd;
273
274
  const child = spawn(process.execPath, [entrypoint, "--mode", "rpc", ...args], {
274
- cwd: isolation ? cloneCwd(isolation, ctx.cwd) : ctx.cwd,
275
+ cwd,
275
276
  shell: false,
276
277
  stdio: "pipe",
277
278
  });
278
279
  store.launch(job);
280
+ // The brief was written against the main tree, so its absolute paths need mapping to the clone.
279
281
  const isolatedPrompt = isolation
280
- ? `You are working in an isolated git clone at ${isolation.clone}; the main working tree is untouched. Commit freely here; the orchestrator applies your changes to the main tree. \`git diff main-snapshot\` shows all changes made in this clone.`
282
+ ? `You are working in an isolated git clone at ${isolation.clone}. Your working directory ${cwd} is already inside it, so use relative paths and do not cd into it. Paths under ${ctx.cwd} in the task refer to the same files under ${cwd}. The main working tree is untouched; any edits or commits you make stay in this clone until the orchestrator applies them.${tools.includes("bash") ? " `git diff main-snapshot` shows all changes made in this clone." : ""}`
281
283
  : "";
282
284
  const run = runChild(
283
285
  child,
@@ -432,9 +434,9 @@ export default function (pi: ExtensionAPI) {
432
434
  "",
433
435
  "A delegate gets the project instructions but not this conversation: it cannot see the user's request, the files you read, or your decisions. Write `task` as a self-contained brief: the goal and why, what you already know (paths, symbols, errors), scope and constraints, whether to edit files or only report, and what to return (format, length, path:line evidence).",
434
436
  "",
435
- "With isolated: true, the delegate runs in an isolated git clone at .pi/worktrees/<job id> (gitignore that path), starting from the main tree exactly as it is now, uncommitted and untracked files included. It never touches the main tree and may commit freely; delegate_apply brings its changes back, delegate_discard drops them.",
437
+ "With isolated: true, the delegate runs in an isolated git clone at .pi/worktrees/<job id>, starting from the main tree exactly as it is now, uncommitted and untracked files included. It never touches the main tree and may commit freely; delegate_apply brings its changes back, delegate_discard drops them.",
436
438
  "",
437
- "To run another delegate in an isolated job's clone, pass that job id as `clone`. Every job id that ran in a clone is a handle on it: delegate_apply or delegate_discard with any of them acts on the whole clone, and only one of them can run at a time.",
439
+ "To run another delegate in an isolated job's clone, pass that job id as `clone`. delegate_apply or delegate_discard with any job id from that clone acts on the whole clone, and only one job can run in a clone at a time.",
438
440
  "",
439
441
  "To follow up on or redirect an existing job, see delegate_steer.",
440
442
  ].join("\n"),
@@ -677,7 +679,7 @@ export default function (pi: ExtensionAPI) {
677
679
  store.save(shared);
678
680
  }
679
681
  throw new Error(
680
- `Main tree changed under delegate job "${job.id}"; conflicting files: ${result.files.join(", ") || "(unknown)"}. The clone at ${isolation.clone} was kept. Steer job ${job.id} with: "Main tree changed under you. In your clone run \`git rebase main-snapshot\` (or merge), resolve conflicts, commit." Then call delegate_apply again.`,
682
+ `Main tree changed under delegate job "${job.id}"; conflicting files: ${result.files.join(", ") || "(unknown)"}. The clone at ${isolation.clone} was kept. Steer job ${job.id} with: "The main tree changed under you. Run \`git rebase main-snapshot\`, resolve each conflict, then \`git add\` the files and run \`git rebase --continue\` until the rebase finishes." Then call delegate_apply again.`,
681
683
  );
682
684
  }
683
685
  const stat = result.kind === "applied" ? `\n${result.stat}` : "";
package/isolation.ts CHANGED
@@ -28,6 +28,8 @@ function git(
28
28
  cwd: options.cwd,
29
29
  input: options.input,
30
30
  encoding: "utf8",
31
+ // Without this, git's stderr (rebase hints etc.) leaks onto the TUI.
32
+ stdio: "pipe",
31
33
  // Binary diffs of real repositories blow past execFileSync's 1 MiB default.
32
34
  maxBuffer: 1024 ** 3,
33
35
  env: options.indexFile ? { ...process.env, GIT_INDEX_FILE: options.indexFile } : process.env,
@@ -72,7 +74,7 @@ export function createIsolation(cwd: string, jobId: string): IsolationState {
72
74
  try {
73
75
  root = git(["rev-parse", "--show-toplevel"], { cwd }).trim();
74
76
  } catch {
75
- throw new Error('isolation: "clone" requires the session to run inside a git repository.');
77
+ throw new Error("isolated: true requires the session to run inside a git repository.");
76
78
  }
77
79
  const clone = join(root, ".pi", "worktrees", jobId);
78
80
  rmSync(clone, { recursive: true, force: true });
@@ -118,7 +120,7 @@ export function isolationSummary(iso: IsolationState): string {
118
120
  // Staging first pulls uncommitted and untracked changes into the stat.
119
121
  git(["add", "-A"], { cwd: iso.clone });
120
122
  const stat = git(["diff", "--stat", iso.base], { cwd: iso.clone }).trimEnd();
121
- if (stat) lines.push(`Changes vs the main tree at launch:\n${stat}`);
123
+ if (stat) lines.push(`Changes in this clone:\n${stat}`);
122
124
  } catch {
123
125
  // The clone may already be applied or gone; the path alone still says where the work lives.
124
126
  }
@@ -142,7 +144,9 @@ export function applyClone(iso: IsolationState): ApplyResult {
142
144
  if (run(["status", "--porcelain"]).trim()) run([...IDENTITY, "commit", "--no-verify", "-m", "delegate work"]);
143
145
  const branch = run(["rev-parse", "--abbrev-ref", "HEAD"]).trim();
144
146
  if (branch === SNAPSHOT_BRANCH)
145
- throw new Error(`the clone is on ${SNAPSHOT_BRANCH}; the delegate must keep its work on its own branch`);
147
+ throw new Error(
148
+ `the clone is checked out on ${SNAPSHOT_BRANCH}; steer the delegate to move its work onto its own branch, then apply again`,
149
+ );
146
150
  // Snapshot the current main tree, then replay the delegate's commits onto it with a real 3-way
147
151
  // merge: git tolerates nearby, non-overlapping edits that raw patch context matching rejects.
148
152
  const snapshot = snapshotMainTree(iso, root);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deathbeam/pi-delegate",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "description": "Minimal extension for delegating tasks to subagents.",
5
5
  "type": "module",
6
6
  "license": "MIT",