@workit-dev/pi 2.16.2 → 2.17.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.
package/dist/workit.js CHANGED
@@ -30178,6 +30178,10 @@ var cdWorkitSplit = (command) => {
30178
30178
  return null;
30179
30179
  };
30180
30180
 
30181
+ // packages/workit-core/src/hooks/spawn-gate.ts
30182
+ import fs31 from "node:fs";
30183
+ import path50 from "node:path";
30184
+
30181
30185
  // packages/workit-core/src/hooks/model-limit.ts
30182
30186
  import { closeSync as closeSync4, openSync as openSync4, readdirSync as readdirSync7, readSync, statSync as statSync5 } from "node:fs";
30183
30187
  import os11 from "node:os";
@@ -30501,20 +30505,37 @@ var agentModelDecision = (cwd, tool, options = {}) => {
30501
30505
 
30502
30506
  // packages/workit-core/src/hooks/spawn-gate.ts
30503
30507
  var MADE_WORKTREE = /^WORKTREE:[ \t]*(?!not made yet)\S(?![^\n]*not made yet)/mu;
30504
- var UNBLOCK = "workit fanout worktree create <slice>";
30505
- var BRIEF = "workit fanout brief <slice>";
30508
+ var namesMade = (word) => {
30509
+ try {
30510
+ const stat = fs31.statSync(word);
30511
+ if (stat.isFile())
30512
+ return stat.size < 1e6 && MADE_WORKTREE.test(fs31.readFileSync(word, "utf8"));
30513
+ const dotGit = path50.join(word, ".git");
30514
+ const link = fs31.statSync(dotGit);
30515
+ const admin = link.isFile() && link.size <= 4096 && /^gitdir: *(.+)/u.exec(fs31.readFileSync(dotGit, "utf8"));
30516
+ return !!admin && fs31.existsSync(path50.resolve(word, admin[1].trim(), FANOUT_TOKEN_FILE));
30517
+ } catch {
30518
+ return false;
30519
+ }
30520
+ };
30521
+ var namesWorktree = (prompt) => MADE_WORKTREE.test(prompt) || (prompt.match(/(?<![\w.~])(?:[a-z]:[\\/]|\/)[^\s'"`<>|;,()]+/giu) ?? []).some((word) => namesMade(word.replace(/[.:]+$/u, "")));
30522
+ var sliceWord = (tool) => (/(?:\bfanout brief|\bworktree create|\bWORKER:) +([a-z0-9][\w.-]*)/iu.exec(String(tool.prompt))?.[1] ?? String(tool.description ?? "")).toLowerCase().replace(/[^a-z0-9._-]+/gu, "-").replace(/^[-._]+|-+$/gu, "").slice(0, 40) || "slice";
30506
30523
  var gate = (descriptor, tool) => {
30507
30524
  const type = typeof tool.subagent_type === "string" ? tool.subagent_type : "";
30508
30525
  const implementer = workitRole(descriptor, type) === "implementer";
30509
- if (implementer && (typeof tool.prompt !== "string" || !MADE_WORKTREE.test(tool.prompt)))
30526
+ if (implementer && (typeof tool.prompt !== "string" || !namesWorktree(tool.prompt))) {
30527
+ const slice = sliceWord(tool);
30528
+ const unblock = `workit fanout worktree create ${slice}`;
30510
30529
  return {
30511
30530
  kind: "deny",
30512
30531
  decision: {
30513
30532
  kind: "deny",
30514
- reason: `workit spawn gate: a ${type} spawn needs a Workit brief with a WORKTREE line, and this prompt has none. Even for one slice: run \`${UNBLOCK}\`, then \`${BRIEF}\`, and spawn again with its text as the prompt and the Agent args its SPAWN line names (a slice no plan registers needs \`workit fanout plan <plan.json>\` first).`,
30515
- unblock: UNBLOCK
30533
+ reason: `workit spawn gate: this ${type} prompt names no worktree Workit made.
30534
+ Retry as: ${unblock} (or --name <plan> for a planned slice), then spawn again with the WORKTREE line it prints as the prompt's first line.`,
30535
+ unblock
30516
30536
  }
30517
30537
  };
30538
+ }
30518
30539
  if (tool.isolation === undefined)
30519
30540
  return { kind: "run", input: tool, change: { dropped: [], reasons: [], notes: [] } };
30520
30541
  const { isolation: _dropped, ...input } = tool;
@@ -30537,9 +30558,9 @@ var spawnDecision = (descriptor, cwd, tool, permissionMode = null) => {
30537
30558
  };
30538
30559
 
30539
30560
  // packages/workit-core/src/hooks/server-gate.ts
30540
- import fs31 from "node:fs";
30541
- import path50 from "node:path";
30542
- var procNoticeFile = (env, session) => path50.join(stateDir(env), "procs", "notices", `${session.replace(/[^A-Za-z0-9_.@+-]/gu, "-").slice(0, 120) || "none"}.json`);
30561
+ import fs32 from "node:fs";
30562
+ import path51 from "node:path";
30563
+ var procNoticeFile = (env, session) => path51.join(stateDir(env), "procs", "notices", `${session.replace(/[^A-Za-z0-9_.@+-]/gu, "-").slice(0, 120) || "none"}.json`);
30543
30564
  var mb = (bytes) => `${Math.round(Number(bytes) / 1048576)} MB`;
30544
30565
  function takeProcNotice(session, env = process.env) {
30545
30566
  if (!session)
@@ -30547,12 +30568,12 @@ function takeProcNotice(session, env = process.env) {
30547
30568
  const file = procNoticeFile(env, session);
30548
30569
  const taken = `${file}.${process.pid}.taken`;
30549
30570
  try {
30550
- fs31.renameSync(file, taken);
30571
+ fs32.renameSync(file, taken);
30551
30572
  } catch {
30552
30573
  return null;
30553
30574
  }
30554
30575
  try {
30555
- const { notices } = JSON.parse(fs31.readFileSync(taken, "utf8"));
30576
+ const { notices } = JSON.parse(fs32.readFileSync(taken, "utf8"));
30556
30577
  const lines = (Array.isArray(notices) ? notices : []).flatMap((notice) => {
30557
30578
  if (!notice || typeof notice !== "object")
30558
30579
  return [];
@@ -30569,29 +30590,29 @@ function takeProcNotice(session, env = process.env) {
30569
30590
  return null;
30570
30591
  } finally {
30571
30592
  try {
30572
- fs31.rmSync(taken, { force: true });
30593
+ fs32.rmSync(taken, { force: true });
30573
30594
  } catch {}
30574
30595
  }
30575
30596
  }
30576
30597
 
30577
30598
  // packages/workit-core/src/hooks/teardown.ts
30578
30599
  import { spawn } from "node:child_process";
30579
- import fs32 from "node:fs";
30580
- import path52 from "node:path";
30600
+ import fs33 from "node:fs";
30601
+ import path53 from "node:path";
30581
30602
 
30582
30603
  // packages/workit-core/src/core/cli-locate.ts
30583
30604
  import { closeSync as closeSync5, existsSync as existsSync17, openSync as openSync5, readSync as readSync2 } from "node:fs";
30584
- import path51 from "node:path";
30605
+ import path52 from "node:path";
30585
30606
  var LAUNCHER_MARKER = "workit-owned-launcher";
30586
30607
  var CLI_PACKAGE_PATH = ["node_modules", "@workit-dev", "cli"];
30587
30608
  var installRoot = (env, platform = process.platform) => {
30588
30609
  if (env.WORKIT_INSTALL_ROOT)
30589
30610
  return env.WORKIT_INSTALL_ROOT;
30590
30611
  const data = dataDir(env, platform);
30591
- return platform === "win32" ? path51.join(data, "install") : data;
30612
+ return platform === "win32" ? path52.join(data, "install") : data;
30592
30613
  };
30593
- var ownedLauncherPath = (env, platform = process.platform) => path51.join(installRoot(env, platform), "bin", platform === "win32" ? "workit.cmd" : "workit");
30594
- var ownedCurrentEntry = (env, platform = process.platform) => path51.join(installRoot(env, platform), "current", ...CLI_PACKAGE_PATH, "dist", "index.js");
30614
+ var ownedLauncherPath = (env, platform = process.platform) => path52.join(installRoot(env, platform), "bin", platform === "win32" ? "workit.cmd" : "workit");
30615
+ var ownedCurrentEntry = (env, platform = process.platform) => path52.join(installRoot(env, platform), "current", ...CLI_PACKAGE_PATH, "dist", "index.js");
30595
30616
  var head = (file) => {
30596
30617
  let fd;
30597
30618
  try {
@@ -30618,7 +30639,7 @@ var locateWorkitCli = (options = {}) => {
30618
30639
  source: "owned-launcher",
30619
30640
  command: launcher,
30620
30641
  args: [],
30621
- binDir: path51.dirname(launcher)
30642
+ binDir: path52.dirname(launcher)
30622
30643
  };
30623
30644
  const current = ownedCurrentEntry(env, platform);
30624
30645
  if (exists(current))
@@ -30647,7 +30668,7 @@ var workitCliEnv = (located, env = process.env, platform = process.platform) =>
30647
30668
  if (located.binDir) {
30648
30669
  const key = pathKey(env);
30649
30670
  const delimiter = platform === "win32" ? ";" : ":";
30650
- const same = (dir) => platform === "win32" ? path51.win32.normalize(dir).toLowerCase() === path51.win32.normalize(located.binDir).toLowerCase() : path51.posix.normalize(dir) === path51.posix.normalize(located.binDir);
30671
+ const same = (dir) => platform === "win32" ? path52.win32.normalize(dir).toLowerCase() === path52.win32.normalize(located.binDir).toLowerCase() : path52.posix.normalize(dir) === path52.posix.normalize(located.binDir);
30651
30672
  const rest = (env[key] ?? "").split(delimiter).filter((dir) => dir && !same(dir));
30652
30673
  patch[key] = [located.binDir, ...rest].join(delimiter);
30653
30674
  }
@@ -30671,9 +30692,9 @@ var ENDS = {
30671
30692
  };
30672
30693
  var SAFE_SESSION = /^[\w.@+][\w.:@/+-]{0,127}$/u;
30673
30694
  var HOST_SESSION_VARS2 = ["OPENCODE_SESSION_ID", "PI_SESSION_ID", "CODEX_THREAD_ID"];
30674
- var teardownDir = (env) => path52.join(stateDir(env), "procs");
30675
- var teardownLog = (env) => path52.join(teardownDir(env), "teardown.log");
30676
- var reapStamp = (env) => path52.join(teardownDir(env), "reap-at-start.stamp");
30695
+ var teardownDir = (env) => path53.join(stateDir(env), "procs");
30696
+ var teardownLog = (env) => path53.join(teardownDir(env), "teardown.log");
30697
+ var reapStamp = (env) => path53.join(teardownDir(env), "reap-at-start.stamp");
30677
30698
  function spawnDetached(request) {
30678
30699
  try {
30679
30700
  const shell = process.platform === "win32" && !/\.exe$/iu.test(request.command);
@@ -30700,13 +30721,13 @@ var teardownDeps = {
30700
30721
  var openLog = (env, args) => {
30701
30722
  try {
30702
30723
  const file = teardownLog(env);
30703
- fs32.mkdirSync(path52.dirname(file), { recursive: true });
30724
+ fs33.mkdirSync(path53.dirname(file), { recursive: true });
30704
30725
  let size = 0;
30705
30726
  try {
30706
- size = fs32.statSync(file).size;
30727
+ size = fs33.statSync(file).size;
30707
30728
  } catch {}
30708
- const fd = fs32.openSync(file, size > LOG_MAX_BYTES ? "w" : "a", 384);
30709
- fs32.writeSync(fd, `${new Date(teardownDeps.now()).toISOString()} workit ${args.join(" ")}
30729
+ const fd = fs33.openSync(file, size > LOG_MAX_BYTES ? "w" : "a", 384);
30730
+ fs33.writeSync(fd, `${new Date(teardownDeps.now()).toISOString()} workit ${args.join(" ")}
30710
30731
  `);
30711
30732
  return fd;
30712
30733
  } catch {
@@ -30718,7 +30739,7 @@ function runCli(args, env) {
30718
30739
  try {
30719
30740
  const cli = locateWorkitCli({ env });
30720
30741
  const cwd = teardownDir(env);
30721
- fs32.mkdirSync(cwd, { recursive: true });
30742
+ fs33.mkdirSync(cwd, { recursive: true });
30722
30743
  log = openLog(env, args);
30723
30744
  const started = teardownDeps.spawn({
30724
30745
  command: cli.command,
@@ -30728,7 +30749,7 @@ function runCli(args, env) {
30728
30749
  log
30729
30750
  });
30730
30751
  if (!started && log !== null)
30731
- fs32.writeSync(log, ` not started
30752
+ fs33.writeSync(log, ` not started
30732
30753
  `);
30733
30754
  return started;
30734
30755
  } catch {
@@ -30736,7 +30757,7 @@ function runCli(args, env) {
30736
30757
  } finally {
30737
30758
  if (log !== null)
30738
30759
  try {
30739
- fs32.closeSync(log);
30760
+ fs33.closeSync(log);
30740
30761
  } catch {}
30741
30762
  }
30742
30763
  }
@@ -30755,24 +30776,24 @@ function endSession(end, env = process.env) {
30755
30776
  var claim2 = (file, now) => {
30756
30777
  for (let attempt = 0;attempt < 2; attempt += 1)
30757
30778
  try {
30758
- fs32.writeFileSync(file, String(now), { flag: "wx", mode: 384 });
30779
+ fs33.writeFileSync(file, String(now), { flag: "wx", mode: 384 });
30759
30780
  return true;
30760
30781
  } catch (error) {
30761
30782
  if (error.code !== "EEXIST")
30762
30783
  return false;
30763
30784
  let held = Number.NaN;
30764
30785
  try {
30765
- held = Number(fs32.readFileSync(file, "utf8"));
30786
+ held = Number(fs33.readFileSync(file, "utf8"));
30766
30787
  } catch {}
30767
30788
  if (now - held < REAP_INTERVAL_MS)
30768
30789
  return false;
30769
- fs32.rmSync(file, { force: true });
30790
+ fs33.rmSync(file, { force: true });
30770
30791
  }
30771
30792
  return false;
30772
30793
  };
30773
30794
  var fresh = (stamp, now) => {
30774
30795
  try {
30775
- const last = Number(fs32.readFileSync(stamp, "utf8"));
30796
+ const last = Number(fs33.readFileSync(stamp, "utf8"));
30776
30797
  return now - last < REAP_INTERVAL_MS && last <= now;
30777
30798
  } catch {
30778
30799
  return false;
@@ -30785,7 +30806,7 @@ function reapAtStart(_cwd, env = process.env) {
30785
30806
  try {
30786
30807
  if (fresh(stamp, now))
30787
30808
  return false;
30788
- fs32.mkdirSync(path52.dirname(stamp), { recursive: true });
30809
+ fs33.mkdirSync(path53.dirname(stamp), { recursive: true });
30789
30810
  if (!claim2(lock, now))
30790
30811
  return false;
30791
30812
  } catch {
@@ -30798,12 +30819,12 @@ function reapAtStart(_cwd, env = process.env) {
30798
30819
  started = runCli(["stop", "--orphans", "--reason", "session-start"], env);
30799
30820
  if (started) {
30800
30821
  const temp = `${stamp}.${process.pid}`;
30801
- fs32.writeFileSync(temp, String(now), { mode: 384 });
30802
- fs32.renameSync(temp, stamp);
30822
+ fs33.writeFileSync(temp, String(now), { mode: 384 });
30823
+ fs33.renameSync(temp, stamp);
30803
30824
  }
30804
30825
  } catch {} finally {
30805
30826
  try {
30806
- fs32.rmSync(lock, { force: true });
30827
+ fs33.rmSync(lock, { force: true });
30807
30828
  } catch {}
30808
30829
  }
30809
30830
  return started;
@@ -31600,11 +31621,11 @@ var modelKey = (model) => {
31600
31621
 
31601
31622
  // packages/workit-core/src/hooks/budget-signal.ts
31602
31623
  import { createHash as createHash23 } from "node:crypto";
31603
- import fs33 from "node:fs";
31604
- import path53 from "node:path";
31624
+ import fs34 from "node:fs";
31625
+ import path54 from "node:path";
31605
31626
  var hash2 = (text) => createHash23("sha256").update(text).digest("hex").slice(0, 32);
31606
- var budgetDir = (store) => path53.join(store, "budget");
31607
- var agentBase = (store, session, agentId) => path53.join(budgetDir(store), hash2(`${session}\x00${agentId ?? ""}`));
31627
+ var budgetDir = (store) => path54.join(store, "budget");
31628
+ var agentBase = (store, session, agentId) => path54.join(budgetDir(store), hash2(`${session}\x00${agentId ?? ""}`));
31608
31629
  var spawnBudget = (prompt) => {
31609
31630
  const found = /^TIMEBOX:[^\n]*?\b(\d+)\s+tool calls\b/mu.exec(prompt);
31610
31631
  const n = found ? Number(found[1]) : NaN;
@@ -31612,7 +31633,7 @@ var spawnBudget = (prompt) => {
31612
31633
  };
31613
31634
  var readBudget = (file) => {
31614
31635
  try {
31615
- const { limit, told } = JSON.parse(fs33.readFileSync(file, "utf8"));
31636
+ const { limit, told } = JSON.parse(fs34.readFileSync(file, "utf8"));
31616
31637
  return typeof limit === "number" && limit > 0 ? { limit, told: Number(told) || 0 } : null;
31617
31638
  } catch {
31618
31639
  return null;
@@ -31620,16 +31641,16 @@ var readBudget = (file) => {
31620
31641
  };
31621
31642
  var startBudget = (store, session, agentId, n) => {
31622
31643
  const dir = budgetDir(store);
31623
- fs33.mkdirSync(dir, { recursive: true });
31644
+ fs34.mkdirSync(dir, { recursive: true });
31624
31645
  const cutoff = Date.now() - 604800000;
31625
- for (const name of fs33.readdirSync(dir))
31646
+ for (const name of fs34.readdirSync(dir))
31626
31647
  try {
31627
- if (fs33.statSync(path53.join(dir, name)).mtimeMs < cutoff)
31628
- fs33.rmSync(path53.join(dir, name));
31648
+ if (fs34.statSync(path54.join(dir, name)).mtimeMs < cutoff)
31649
+ fs34.rmSync(path54.join(dir, name));
31629
31650
  } catch {}
31630
31651
  const base = agentBase(store, session, agentId);
31631
- fs33.writeFileSync(`${base}.json`, JSON.stringify({ limit: n, told: 0 }));
31632
- fs33.rmSync(`${base}.calls`, { force: true });
31652
+ fs34.writeFileSync(`${base}.json`, JSON.stringify({ limit: n, told: 0 }));
31653
+ fs34.rmSync(`${base}.calls`, { force: true });
31633
31654
  };
31634
31655
  var bindBudget = (cwd, session, agentId, prompt) => {
31635
31656
  try {
@@ -31652,8 +31673,8 @@ var tickBudget = (cwd, session, agentId) => {
31652
31673
  const budget = readBudget(`${base}.json`);
31653
31674
  if (!budget)
31654
31675
  return false;
31655
- fs33.appendFileSync(`${base}.calls`, ".");
31656
- return fs33.statSync(`${base}.calls`).size >= budget.limit * (budget.told + 1);
31676
+ fs34.appendFileSync(`${base}.calls`, ".");
31677
+ return fs34.statSync(`${base}.calls`).size >= budget.limit * (budget.told + 1);
31657
31678
  } catch {
31658
31679
  return false;
31659
31680
  }
@@ -31665,14 +31686,14 @@ var reachedOf = (cwd, session, agentId) => {
31665
31686
  const budget = base && readBudget(`${base}.json`);
31666
31687
  if (!budget)
31667
31688
  return null;
31668
- return { base, budget, reached: Math.floor(fs33.statSync(`${base}.calls`).size / budget.limit) };
31689
+ return { base, budget, reached: Math.floor(fs34.statSync(`${base}.calls`).size / budget.limit) };
31669
31690
  };
31670
31691
  var budgetLine = (cwd, session, agentId) => {
31671
31692
  try {
31672
31693
  const at = reachedOf(cwd, session, agentId);
31673
31694
  if (!at || at.reached <= at.budget.told)
31674
31695
  return null;
31675
- fs33.writeFileSync(`${at.base}.json`, JSON.stringify({ ...at.budget, told: at.reached }));
31696
+ fs34.writeFileSync(`${at.base}.json`, JSON.stringify({ ...at.budget, told: at.reached }));
31676
31697
  return lineFor(at.budget.limit * at.reached);
31677
31698
  } catch {
31678
31699
  return null;
@@ -32080,12 +32101,12 @@ var skillPromptNudge = (prompt, ctx) => process.env.WORKIT_PI_WORKER_SESSION ? n
32080
32101
  // packages/workit-pi/src/launches.ts
32081
32102
  import { mkdirSync as mkdirSync7, readFileSync as readFileSync16, readdirSync as readdirSync8, rmSync as rmSync4, writeFileSync as writeFileSync6 } from "node:fs";
32082
32103
  import os12 from "node:os";
32083
- import path54 from "node:path";
32104
+ import path55 from "node:path";
32084
32105
  var launchDir = (root) => {
32085
32106
  const location = resolveStore(root);
32086
- return location instanceof Error ? null : path54.join(location.dir, "pi-launches");
32107
+ return location instanceof Error ? null : path55.join(location.dir, "pi-launches");
32087
32108
  };
32088
- var fileFor = (dir, workerId) => path54.join(dir, `${workerId.replace(/[^A-Za-z0-9-]/g, "_")}.json`);
32109
+ var fileFor = (dir, workerId) => path55.join(dir, `${workerId.replace(/[^A-Za-z0-9-]/g, "_")}.json`);
32089
32110
  var recordLaunch = (root, attempt) => {
32090
32111
  const dir = launchDir(root);
32091
32112
  if (!dir)
@@ -32131,7 +32152,7 @@ var abandonedLaunches = (root) => {
32131
32152
  const found = [];
32132
32153
  for (const name of names) {
32133
32154
  try {
32134
- const attempt = JSON.parse(readFileSync16(path54.join(dir, name), "utf8"));
32155
+ const attempt = JSON.parse(readFileSync16(path55.join(dir, name), "utf8"));
32135
32156
  if (typeof attempt.workerId === "string" && typeof attempt.session === "string") {
32136
32157
  if (!alive(attempt))
32137
32158
  found.push(attempt);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/pi",
3
- "version": "2.16.2",
3
+ "version": "2.17.0",
4
4
  "description": "Workit native extension for Pi — tools, method skills, and session continuity",
5
5
  "keywords": [
6
6
  "agentic-coding",
@@ -20,16 +20,15 @@ units of ~100+ lines each. Coupled work stays with one owner. Workit never spawn
20
20
  PR (`references/orchestration.md`).
21
21
  2. **Record standing orders** (`workit ledger standing add "<order>"`): every
22
22
  user directive all workers share. Directives decay across resumes.
23
- 3. **Brief each worker verbatim**: `workit fanout worktree create <slice>`
24
- (every host), then `workit fanout brief <slice>` (WORKTREE, SCRATCH, rules).
25
- Never hand-edit it; change the plan or the standing orders and render again.
23
+ 3. **Make the worktrees**: `workit fanout worktree create <slice>…` (every host; `--name <plan.json>`
24
+ registers the file) prints per slice its `WORKTREE:` line and the exact spawn, whose prompt points
25
+ the worker at `workit fanout brief <slice> --name <plan>`. Never hand-edit it; change the plan or
26
+ the standing orders. One unplanned slice needs no plan (`--branch <b>` optional).
26
27
  4. **Spawn in a rolling window**, in the background, each in its own worktree:
27
- keep 4-6 in flight and refill from `spawnable` in `workit fanout status` as
28
- each one finishes. Assign before spawn (OpenCode: `workit worker assign`); each prompt carries
29
- the brief, or a pointer: its `WORKER`, `TIER`, `TIMEBOX` and `WORKTREE` lines plus "run `workit fanout brief <slice>` and follow it"
30
- (budget and model hooks read those lines), so batched OpenCode launches each bind their worker.
31
- Model: the brief's `model:` and `effort:` lines (`workit models show`), else TIER (`references/orchestration.md`).
32
- Claude Code: the `implementer` agent; its spawn hook drops `isolation` and refuses a prompt without a WORKTREE line.
28
+ keep 4-6 in flight and refill from `spawnable` in `workit fanout status`.
29
+ Assign before spawn (OpenCode: `workit worker assign`); each prompt is the printed one
30
+ (budget and model hooks read its WORKTREE, WORKER, TIER and TIMEBOX lines), so batched OpenCode launches each bind their worker.
31
+ Claude Code: copy the printed `SPAWN:` args (a model only when the TIER differs from the agent file); the hook drops `isolation` and refuses a prompt naming no Workit worktree with a `Retry as:`.
33
32
  5. **Judge liveness by side effects only:** `workit fanout status` (head age,
34
33
  PR, CI, verdict, landed; STUCK past the TIMEBOX). Stop a stuck worker and
35
34
  observe that it exited (a timeout is not proof); stop a finished one when its
@@ -103,6 +103,27 @@ is the slice's STUCK threshold in `workit fanout status`. `"fanIn":
103
103
  }
104
104
  ```
105
105
 
106
+ ## Worktrees and the spawn they print
107
+
108
+ `workit fanout worktree create a b c` makes each slice's worktree and prints,
109
+ per slice, `WORKTREE: <path>` and the spawn that carries it. Its prompt starts
110
+ with that WORKTREE line, then `WORKER`, `TIER`, `TIMEBOX` and
111
+ "Run `workit fanout brief <slice> --name <plan>` and follow it exactly.";
112
+ Claude Code's `SPAWN:` line names `model` only when the TIER differs from the
113
+ `implementer` agent file. `--name` takes the plan's name or its file (`--plan`
114
+ is the same flag): a file is registered in that call, and a name no plan has
115
+ registers the one file in `workit dir plans` that starts with it. The plan
116
+ check refuses a slice branch the workspace branch policy refuses and names the
117
+ allowed one.
118
+
119
+ One unplanned slice: `workit fanout worktree create fix-login [--branch
120
+ fix/login] [--base <b>] [--tier <t>]` (no plan holds it) records a one-slice plan named after it
121
+ (the lead's prompt states the task) and prints the same lines; two or more
122
+ slices need a plan file. Claude Code's spawn gate passes a
123
+ `workit:implementer` prompt that names a Workit-made worktree as a WORKTREE
124
+ line, as its path, or as a brief file holding a WORKTREE line; otherwise its
125
+ deny is two lines ending in that ad-hoc command as `Retry as:`.
126
+
106
127
  ## Identity and git rules per host
107
128
 
108
129
  `workit fanout brief` renders the identity line, the model lines and RULES 1