@workit-dev/pi 2.12.0 → 2.14.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/worker.js CHANGED
@@ -7410,7 +7410,7 @@ var workspaceConfigSchema = object({
7410
7410
  fanout: object({
7411
7411
  tierModels: unknown().optional().describe("The model per slice TIER (mundane, standard, hard), as one name or per host.")
7412
7412
  }).passthrough().optional().describe("Fanout settings."),
7413
- models: object({ roles: modelRoles }).passthrough().optional().describe("Model and effort per role and host (roles), the lead's own advisory model (lead) and whether a model the lead names on a spawn wins (allowLeadOverride, default false); the same key at the top of workspaces.json is the global default."),
7413
+ models: object({ roles: modelRoles }).passthrough().optional().describe("Model and effort per role and host (roles), the lead's own advisory model (lead), how a role model applies (enforce: advise, the default, or strict) and, under strict, whether a model the lead names on a spawn wins (allowLeadOverride, default false); the same key at the top of workspaces.json is the global default."),
7414
7414
  resources: unknown().optional().describe("Heavy-check limits on this machine: slots, scope, heavy, light, memoryMax, cpuQuota, wait."),
7415
7415
  remotes: array(nonBlank.refine((pattern) => remotePattern(pattern) !== null, "is not a remote URL (https://host/owner/repo, git@host:owner/repo, a path, or owner/*)")).optional().describe("Remote URLs this entry owns: a checkout pushing to or opening PRs on one never exceeds this entry's grants, wherever the folder is (`owner/*` claims a whole owner). Only the user changes it, in their own terminal."),
7416
7416
  autonomy: object(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
@@ -7448,7 +7448,7 @@ var workspaceConfigSchema = object({
7448
7448
  });
7449
7449
  var workspacesFileSchema = object({
7450
7450
  workspaces: array(workspaceConfigSchema).optional().describe("Workspace entries, each mapping a path glob to its forge, policies and grants."),
7451
- models: object({ roles: modelRoles }).passthrough().optional().describe("The global default model and effort per role and host (roles), the lead's own advisory model (lead) and whether a model the lead names on a spawn wins (allowLeadOverride, default false).")
7451
+ models: object({ roles: modelRoles }).passthrough().optional().describe("The global default model and effort per role and host (roles), the lead's own advisory model (lead), how a role model applies (enforce: advise, the default, or strict) and, under strict, whether a model the lead names on a spawn wins (allowLeadOverride, default false).")
7452
7452
  }).passthrough().superRefine((file, context) => {
7453
7453
  const names = new Set;
7454
7454
  for (const [index, workspace] of (file.workspaces ?? []).entries()) {
@@ -8716,16 +8716,19 @@ var HOST_KEYS = new Set([
8716
8716
  "pi",
8717
8717
  "default"
8718
8718
  ]);
8719
- var BUILT_IN_CLAUDE_CODE = {
8719
+ var CLAUDE_AGENT_FILES = {
8720
8720
  decider: { model: "fable", effort: "high" },
8721
- "implementer.hard": { model: "opus" },
8722
- "implementer.standard": { model: "sonnet" },
8723
- "implementer.mundane": { model: "haiku" },
8721
+ implementer: { model: "sonnet" },
8724
8722
  verifier: { model: "sonnet" },
8725
8723
  reviewer: { model: "opus" },
8726
- explore: { model: "haiku" },
8727
8724
  babysit: { model: "haiku" }
8728
8725
  };
8726
+ var BUILT_IN_CLAUDE_CODE = {
8727
+ ...CLAUDE_AGENT_FILES,
8728
+ "implementer.hard": { model: "opus" },
8729
+ "implementer.standard": { model: "sonnet" },
8730
+ "implementer.mundane": { model: "haiku" }
8731
+ };
8729
8732
  var isObject3 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
8730
8733
  var name = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
8731
8734
  var leaf = (value) => {
@@ -8809,18 +8812,20 @@ var firstAvailable = (candidates, host, now = new Date) => {
8809
8812
  }
8810
8813
  return { ...primary, skipped, allExhausted: true };
8811
8814
  };
8815
+ var FILE_ROLES = new Set(["decider", "verifier", "reviewer", "babysit"]);
8812
8816
  var CLAUDE_ALIASES = new Set(["sonnet", "opus", "haiku", "fable"]);
8813
8817
  var CLAUDE_EFFORTS = new Set(["low", "medium", "high", "xhigh", "max"]);
8814
8818
  var CLAUDE_SPAWNS = [
8815
- ...["hard", "standard", "mundane"].map((tier) => ({
8816
- label: tier === "hard" ? "workit:implementer hard" : tier,
8819
+ ...MODEL_TIERS.map((tier) => ({
8820
+ label: `workit:implementer ${tier}`,
8817
8821
  selector: { role: "implementer", tier }
8818
8822
  })),
8819
- { label: "workit:verifier", selector: { role: "verifier" } },
8820
- { label: "workit:reviewer", selector: { role: "reviewer" } },
8823
+ ...["verifier", "reviewer", "decider"].map((role) => ({
8824
+ label: `workit:${role}`,
8825
+ selector: { role }
8826
+ })),
8827
+ { label: "workit:babysitter", selector: { role: "babysit" } },
8821
8828
  { label: "Explore", selector: { role: "explore" } },
8822
- { label: "ROLE: decider", selector: { role: "decider" } },
8823
- { label: "ROLE: babysit", selector: { role: "babysit" } },
8824
8829
  { label: "general-purpose", selector: { role: "default" } }
8825
8830
  ];
8826
8831
  var uniformImplementerModel = (cwd, host, dir) => {
package/dist/workit.js CHANGED
@@ -4,7 +4,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
4
4
 
5
5
  // packages/workit-core/src/core.ts
6
6
  import { spawnSync as spawnSync22 } from "node:child_process";
7
- import { existsSync as existsSync13, realpathSync as realpathSync9 } from "node:fs";
7
+ import { existsSync as existsSync14, realpathSync as realpathSync9 } from "node:fs";
8
8
  import path35 from "node:path";
9
9
 
10
10
  // packages/workit-core/src/core/task-contract.ts
@@ -9171,7 +9171,7 @@ var workspaceConfigSchema = object({
9171
9171
  fanout: object({
9172
9172
  tierModels: unknown().optional().describe("The model per slice TIER (mundane, standard, hard), as one name or per host.")
9173
9173
  }).passthrough().optional().describe("Fanout settings."),
9174
- models: object({ roles: modelRoles }).passthrough().optional().describe("Model and effort per role and host (roles), the lead's own advisory model (lead) and whether a model the lead names on a spawn wins (allowLeadOverride, default false); the same key at the top of workspaces.json is the global default."),
9174
+ models: object({ roles: modelRoles }).passthrough().optional().describe("Model and effort per role and host (roles), the lead's own advisory model (lead), how a role model applies (enforce: advise, the default, or strict) and, under strict, whether a model the lead names on a spawn wins (allowLeadOverride, default false); the same key at the top of workspaces.json is the global default."),
9175
9175
  resources: unknown().optional().describe("Heavy-check limits on this machine: slots, scope, heavy, light, memoryMax, cpuQuota, wait."),
9176
9176
  remotes: array(nonBlank.refine((pattern) => remotePattern(pattern) !== null, "is not a remote URL (https://host/owner/repo, git@host:owner/repo, a path, or owner/*)")).optional().describe("Remote URLs this entry owns: a checkout pushing to or opening PRs on one never exceeds this entry's grants, wherever the folder is (`owner/*` claims a whole owner). Only the user changes it, in their own terminal."),
9177
9177
  autonomy: object(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
@@ -9209,7 +9209,7 @@ var workspaceConfigSchema = object({
9209
9209
  });
9210
9210
  var workspacesFileSchema = object({
9211
9211
  workspaces: array(workspaceConfigSchema).optional().describe("Workspace entries, each mapping a path glob to its forge, policies and grants."),
9212
- models: object({ roles: modelRoles }).passthrough().optional().describe("The global default model and effort per role and host (roles), the lead's own advisory model (lead) and whether a model the lead names on a spawn wins (allowLeadOverride, default false).")
9212
+ models: object({ roles: modelRoles }).passthrough().optional().describe("The global default model and effort per role and host (roles), the lead's own advisory model (lead), how a role model applies (enforce: advise, the default, or strict) and, under strict, whether a model the lead names on a spawn wins (allowLeadOverride, default false).")
9213
9213
  }).passthrough().superRefine((file, context) => {
9214
9214
  const names = new Set;
9215
9215
  for (const [index, workspace] of (file.workspaces ?? []).entries()) {
@@ -17886,16 +17886,19 @@ var HOST_KEYS = new Set([
17886
17886
  "pi",
17887
17887
  "default"
17888
17888
  ]);
17889
- var BUILT_IN_CLAUDE_CODE = {
17889
+ var CLAUDE_AGENT_FILES = {
17890
17890
  decider: { model: "fable", effort: "high" },
17891
- "implementer.hard": { model: "opus" },
17892
- "implementer.standard": { model: "sonnet" },
17893
- "implementer.mundane": { model: "haiku" },
17891
+ implementer: { model: "sonnet" },
17894
17892
  verifier: { model: "sonnet" },
17895
17893
  reviewer: { model: "opus" },
17896
- explore: { model: "haiku" },
17897
17894
  babysit: { model: "haiku" }
17898
17895
  };
17896
+ var BUILT_IN_CLAUDE_CODE = {
17897
+ ...CLAUDE_AGENT_FILES,
17898
+ "implementer.hard": { model: "opus" },
17899
+ "implementer.standard": { model: "sonnet" },
17900
+ "implementer.mundane": { model: "haiku" }
17901
+ };
17899
17902
  var isObject6 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
17900
17903
  var name = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
17901
17904
  var leaf = (value) => {
@@ -17985,12 +17988,15 @@ var fallbackText = (chosen) => {
17985
17988
  const passed = chosen.skipped.map((one) => `${one.model} (${one.provider} exhausted until ${shortTime(one.until)})`).join(", ");
17986
17989
  return chosen.allExhausted ? `every model configured for it is exhausted: ${passed}; it runs on ${chosen.model} anyway. Add a model of another provider to the list in workspaces.json, then run \`workit models show\`.` : `fell back past ${passed}.`;
17987
17990
  };
17988
- var leadOverrideAllowed = (cwd, dir) => {
17991
+ var modelsKey = (cwd, key, dir) => {
17989
17992
  for (const source of modelSources(cwd, dir))
17990
- if (isObject6(source.models) && Object.hasOwn(source.models, "allowLeadOverride"))
17991
- return source.models.allowLeadOverride === true;
17992
- return false;
17993
+ if (isObject6(source.models) && Object.hasOwn(source.models, key))
17994
+ return source.models[key];
17995
+ return;
17993
17996
  };
17997
+ var leadOverrideAllowed = (cwd, dir) => modelsKey(cwd, "allowLeadOverride", dir) === true;
17998
+ var enforceMode = (cwd, dir) => modelsKey(cwd, "enforce", dir) === "strict" ? "strict" : "advise";
17999
+ var FILE_ROLES = new Set(["decider", "verifier", "reviewer", "babysit"]);
17994
18000
  var CLAUDE_ALIASES = new Set(["sonnet", "opus", "haiku", "fable"]);
17995
18001
  var CLAUDE_EFFORTS = new Set(["low", "medium", "high", "xhigh", "max"]);
17996
18002
  var FULL_CLAUDE_ID = /^(?:[\w.-]+[./])?claude-(?:\d[\d.-]*-)?(sonnet|opus|haiku|fable)(?:[-.@[]|$)/u;
@@ -18016,7 +18022,7 @@ var chooseSpawnModel = (cwd, selector, host, given, accept, dir) => {
18016
18022
  const givenModel = name(given.model);
18017
18023
  const label = roleLabel(selector);
18018
18024
  const configured = resolved.source !== "built-in";
18019
- if (givenModel && (!configured || leadOverrideAllowed(cwd, dir)))
18025
+ if (givenModel && (!configured || enforceMode(cwd, dir) === "advise" || leadOverrideAllowed(cwd, dir)))
18020
18026
  return none;
18021
18027
  const model = accept(resolved.model);
18022
18028
  const effort = resolved.effort && !name(given.effort) ? resolved.effort : null;
@@ -18042,37 +18048,31 @@ var chooseSpawnModel = (cwd, selector, host, given, accept, dir) => {
18042
18048
  model,
18043
18049
  effort,
18044
18050
  basis,
18045
- note: givenModel ? `Workit replaced model ${givenModel} with ${model} on this spawn: role ${label} is set in ${resolved.source}.${why} Next time ${next} on the spawn. To let a spawn's own model win, set "allowLeadOverride": true under models in workspaces.json.` : `Workit set ${model}${effort ? ` (effort ${effort})` : ""} on this spawn: role ${label}, ${resolved.source}.${why}${configured ? "" : " Name a model to choose another."}`
18046
- };
18047
- };
18048
- var claudeSpawnArgs = (cwd, selector, dir) => {
18049
- const choice = chooseSpawnModel(cwd, selector, "claude_code", {}, claudeAgentModel, dir);
18050
- if (!choice.model)
18051
- return null;
18052
- const effort = choice.effort?.toLowerCase() ?? null;
18053
- return {
18054
- model: choice.model,
18055
- effort: effort && CLAUDE_EFFORTS.has(effort) ? effort : null
18051
+ note: givenModel ? `Workit replaced model ${givenModel} with ${model} on this spawn: role ${label} is set in ${resolved.source}.${why} Next time ${next} on the spawn, or set models.enforce "advise" so a named model wins.` : `Workit set ${model}${effort ? ` (effort ${effort})` : ""} on this spawn: role ${label}, ${resolved.source}.${why}${configured ? "" : " Name a model to choose another."}`
18056
18052
  };
18057
18053
  };
18058
18054
  var CLAUDE_SPAWNS = [
18059
- ...["hard", "standard", "mundane"].map((tier) => ({
18060
- label: tier === "hard" ? "workit:implementer hard" : tier,
18055
+ ...MODEL_TIERS.map((tier) => ({
18056
+ label: `workit:implementer ${tier}`,
18061
18057
  selector: { role: "implementer", tier }
18062
18058
  })),
18063
- { label: "workit:verifier", selector: { role: "verifier" } },
18064
- { label: "workit:reviewer", selector: { role: "reviewer" } },
18059
+ ...["verifier", "reviewer", "decider"].map((role) => ({
18060
+ label: `workit:${role}`,
18061
+ selector: { role }
18062
+ })),
18063
+ { label: "workit:babysitter", selector: { role: "babysit" } },
18065
18064
  { label: "Explore", selector: { role: "explore" } },
18066
- { label: "ROLE: decider", selector: { role: "decider" } },
18067
- { label: "ROLE: babysit", selector: { role: "babysit" } },
18068
18065
  { label: "general-purpose", selector: { role: "default" } }
18069
18066
  ];
18070
18067
  var claudeSpawnTable = (cwd, dir) => {
18071
18068
  const rows = CLAUDE_SPAWNS.flatMap(({ label, selector }) => {
18072
- const args = claudeSpawnArgs(cwd, selector, dir);
18073
- return args ? [`${label} ${args.model}${args.effort ? `/${args.effort}` : ""}`] : [];
18069
+ const want = resolveRoleModel(cwd, selector, "claude_code", dir);
18070
+ const model = want && want.source !== "built-in" ? claudeAgentModel(want.model) : null;
18071
+ const effort = want?.effort?.toLowerCase();
18072
+ const file = label.startsWith("workit:") ? CLAUDE_AGENT_FILES[selector.role] : undefined;
18073
+ return model && (model !== file?.model || effort !== file.effort) ? [`${label} ${model}${effort ? `/${effort}` : ""}`] : [];
18074
18074
  });
18075
- return rows.length ? `Agent spawn model/effort (pass them, workers with run_in_background: true): ${rows.join(", ")}. Implementer prompt: \`workit fanout brief <slice>\` after \`workit fanout worktree create <slice>\`, even for one slice.` : null;
18075
+ return `Spawn Workit roles by name (workit:implementer, workit:verifier, workit:reviewer, workit:decider, workit:babysitter; search: Explore), workers with run_in_background: true, and pass no model or effort unless the user named one${rows.length ? `; configured here (pass them): ${rows.join(", ")}` : ""}. Implementer prompt: \`workit fanout brief <slice>\` after \`workit fanout worktree create <slice>\`, even for one slice.`;
18076
18076
  };
18077
18077
  var uniformImplementerModel = (cwd, host, dir) => {
18078
18078
  const tiers = MODEL_TIERS.map((tier) => resolveRoleModel(cwd, { role: "implementer", tier }, host, dir));
@@ -18080,7 +18080,7 @@ var uniformImplementerModel = (cwd, host, dir) => {
18080
18080
  return first && tiers.every((t) => t?.model === first.model && t.effort === first.effort) ? first : null;
18081
18081
  };
18082
18082
  var ROLE_SELECTORS = MODEL_ROLES.flatMap((role) => role === "implementer" ? MODEL_TIERS.map((tier) => ({ role, tier })) : [{ role }]);
18083
- var AGENT_ROLE = /^(?:workit[:-])?(decider|implementer|verifier|reviewer|explore|babysit)$/iu;
18083
+ var AGENT_ROLE = /^(?:workit[:-])?(decider|implementer|verifier|reviewer|explore|babysit)(?:(?<=babysit)ter)?$/iu;
18084
18084
  var ROLE_LINE = /^[ \t]*ROLE:[ \t]*(decider|implementer|verifier|reviewer|explore|babysit)\b/imu;
18085
18085
  var TIER_LINE = /^[ \t]*TIER:[ \t]*(mundane|standard|hard)\b/imu;
18086
18086
  var isBrief = (text) => TIER_LINE.test(text) && /^WORKTREE:/mu.test(text);
@@ -18359,7 +18359,7 @@ var exportDigest = (bundle) => sha256({
18359
18359
  });
18360
18360
  // packages/workit-core/src/core/route-intent.ts
18361
18361
  import { spawnSync as spawnSync17 } from "node:child_process";
18362
- import { existsSync as existsSync11 } from "node:fs";
18362
+ import { existsSync as existsSync12 } from "node:fs";
18363
18363
  import path30 from "node:path";
18364
18364
 
18365
18365
  // packages/workit-core/src/hooks/raw-git.ts
@@ -18370,6 +18370,7 @@ import os6 from "node:os";
18370
18370
  import path29 from "node:path";
18371
18371
 
18372
18372
  // packages/workit-core/src/autonomy.ts
18373
+ import { closeSync as closeSync3, copyFileSync as copyFileSync2, existsSync as existsSync11, openSync as openSync3 } from "node:fs";
18373
18374
  import path27 from "node:path";
18374
18375
 
18375
18376
  // packages/workit-core/src/core/eval-world.ts
@@ -18535,12 +18536,36 @@ function checkSeal(dir) {
18535
18536
  }
18536
18537
 
18537
18538
  // packages/workit-core/src/autonomy.ts
18538
- var accountDir = () => {
18539
+ var accountHomeDir = () => {
18539
18540
  const home = grantsHome.resolve();
18540
18541
  return home === null ? null : configDir({ HOME: home });
18541
18542
  };
18542
- var grantsDir = () => accountDir() ?? resolveConfigDir();
18543
+ var deniedFile = (dir) => {
18544
+ for (const name of ["workspaces.json", SEAL_FILE]) {
18545
+ const file = path27.join(dir, name);
18546
+ try {
18547
+ closeSync3(openSync3(file, "r"));
18548
+ } catch (error) {
18549
+ const code = error.code;
18550
+ if (code === "EACCES" || code === "EPERM")
18551
+ return file;
18552
+ }
18553
+ }
18554
+ return null;
18555
+ };
18556
+ var accountDir = () => {
18557
+ const dir = accountHomeDir();
18558
+ return dir === null || deniedFile(dir) !== null ? null : dir;
18559
+ };
18560
+ var grantsDir = () => accountHomeDir() ?? resolveConfigDir();
18543
18561
  var NO_ACCOUNT = "no OS account record answered (core/account-home.ts), so no grants are read: the D4 defaults apply";
18562
+ var accountUnread = () => {
18563
+ const dir = accountHomeDir();
18564
+ if (dir === null)
18565
+ return NO_ACCOUNT;
18566
+ const file = deniedFile(dir);
18567
+ return file === null ? null : `the account's ${path27.basename(file)} cannot be read (permission denied), so it reads as no workspace entries: no grants, no models, the D4 defaults apply`;
18568
+ };
18544
18569
  var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
18545
18570
  var fileSource = (dir = accountDir()) => ({
18546
18571
  resolve: (cwd, name) => dir === null ? null : resolveWorkspaceFrom(cwd, dir, name),
@@ -18600,7 +18625,7 @@ var benchWorld = (cwd) => {
18600
18625
  var grantsOverride = () => {
18601
18626
  const shown = shownGrantsDir();
18602
18627
  if (shown === null)
18603
- return NO_ACCOUNT;
18628
+ return accountUnread() ?? NO_ACCOUNT;
18604
18629
  const configured = path27.resolve(resolveConfigDir());
18605
18630
  return configured === path27.resolve(shown) ? null : `the config directory is redirected to ${configured} (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), but that override does not apply to grants: grants are read only from ${path27.join(grantsDir(), "workspaces.json")}, and under a redirect they never exceed the D4 defaults`;
18606
18631
  };
@@ -18769,9 +18794,10 @@ function capAt(source, named, where, by, why, main = false) {
18769
18794
  }
18770
18795
  function resolveAutonomy(cwd, target) {
18771
18796
  const world = benchWorld(cwd);
18797
+ const unread = world ? null : accountUnread();
18798
+ if (unread !== null)
18799
+ return { ...autonomyOf(null), note: unread };
18772
18800
  const override = world ? null : grantsOverride();
18773
- if (override === NO_ACCOUNT)
18774
- return { ...autonomyOf(null), note: override };
18775
18801
  let resolved;
18776
18802
  const once = typeof target === "function" ? () => resolved ??= target() : target;
18777
18803
  const account = accountAuthority(cwd, world, once);
@@ -18870,9 +18896,9 @@ function capAtRemotes(source, autonomy, cwd, target) {
18870
18896
  return capped;
18871
18897
  }
18872
18898
  var grantsMatter = (kind) => {
18873
- const override = grantsOverride();
18874
- if (override === NO_ACCOUNT)
18899
+ if (accountUnread() !== null)
18875
18900
  return false;
18901
+ const override = grantsOverride();
18876
18902
  const entries = entriesIn(accountDir());
18877
18903
  const matters = entries.some((entry) => {
18878
18904
  const autonomy = autonomyOf(entry);
@@ -21485,7 +21511,7 @@ var judgedDir = (root, dir) => {
21485
21511
  if (dir === null)
21486
21512
  return root;
21487
21513
  const resolved = path30.resolve(root, dir);
21488
- return existsSync11(resolved) && inWorkitWorkspace(resolved) ? resolved : null;
21514
+ return existsSync12(resolved) && inWorkitWorkspace(resolved) ? resolved : null;
21489
21515
  };
21490
21516
  var shellBranchPolicyViolation = (root, command, dialect = "posix") => {
21491
21517
  let judged = false;
@@ -23481,7 +23507,7 @@ class WorkitCore {
23481
23507
  }
23482
23508
  // packages/workit-core/src/core/repo-context.ts
23483
23509
  import { spawnSync as spawnSync18 } from "node:child_process";
23484
- import { existsSync as existsSync12, readFileSync as readFileSync11, readdirSync as readdirSync4 } from "node:fs";
23510
+ import { existsSync as existsSync13, readFileSync as readFileSync11, readdirSync as readdirSync4 } from "node:fs";
23485
23511
  import path31 from "node:path";
23486
23512
  var isSafeContextRange = (value) => value.length <= 4096 && (() => {
23487
23513
  try {
@@ -23663,7 +23689,7 @@ var diffStatForRange = (cwd, range) => {
23663
23689
  };
23664
23690
  var packageScripts = (cwd, keys) => {
23665
23691
  const pkgPath = path31.join(cwd, "package.json");
23666
- if (!existsSync12(pkgPath))
23692
+ if (!existsSync13(pkgPath))
23667
23693
  return [];
23668
23694
  try {
23669
23695
  const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
@@ -23698,7 +23724,7 @@ var documentationFiles = (cwd) => {
23698
23724
  return matches.toSorted().slice(0, 200);
23699
23725
  };
23700
23726
  var readTrimmed2 = (file, maxLines) => {
23701
- if (!existsSync12(file))
23727
+ if (!existsSync13(file))
23702
23728
  return "";
23703
23729
  const lines = readFileSync11(file, "utf8").split(`
23704
23730
  `);
@@ -23774,7 +23800,7 @@ ${status.stderr}` : "");
23774
23800
  stdout += `
23775
23801
  `;
23776
23802
  stdout += printSection("Recent Validation Signals");
23777
- if (existsSync12(path31.join(cwd, "package.json"))) {
23803
+ if (existsSync13(path31.join(cwd, "package.json"))) {
23778
23804
  stdout += `package.json detected. Common scripts:
23779
23805
  `;
23780
23806
  const found = packageScripts(cwd, ["lint", "format:check", "test", "build"]);
@@ -23783,7 +23809,7 @@ ${status.stderr}` : "");
23783
23809
  `) + `
23784
23810
  `;
23785
23811
  }
23786
- if (existsSync12(path31.join(cwd, "Cargo.toml")) || existsSync12(path31.join(cwd, "src-tauri/Cargo.toml"))) {
23812
+ if (existsSync13(path31.join(cwd, "Cargo.toml")) || existsSync13(path31.join(cwd, "src-tauri/Cargo.toml"))) {
23787
23813
  stdout += `Rust project detected.
23788
23814
  `;
23789
23815
  }
@@ -23835,7 +23861,7 @@ function changelogContext(root, range) {
23835
23861
  `;
23836
23862
  stdout += printSection("Existing CHANGELOG.md");
23837
23863
  const changelogPath = path31.join(cwd, "CHANGELOG.md");
23838
- if (existsSync12(changelogPath)) {
23864
+ if (existsSync13(changelogPath)) {
23839
23865
  stdout += readTrimmed2(changelogPath, 260) + `
23840
23866
  `;
23841
23867
  } else {
@@ -23877,7 +23903,7 @@ function docsRefreshContext(root, range) {
23877
23903
  `;
23878
23904
  stdout += printSection("README Preview");
23879
23905
  const readme = path31.join(cwd, "README.md");
23880
- if (existsSync12(readme)) {
23906
+ if (existsSync13(readme)) {
23881
23907
  stdout += readTrimmed2(readme, 220) + `
23882
23908
  `;
23883
23909
  } else {
@@ -23886,7 +23912,7 @@ function docsRefreshContext(root, range) {
23886
23912
  }
23887
23913
  stdout += printSection("Package Scripts");
23888
23914
  const pkgPath = path31.join(cwd, "package.json");
23889
- if (existsSync12(pkgPath)) {
23915
+ if (existsSync13(pkgPath)) {
23890
23916
  try {
23891
23917
  const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
23892
23918
  stdout += JSON.stringify({ name: pkg.name, version: pkg.version, scripts: pkg.scripts }, null, 2) + `
@@ -23942,7 +23968,7 @@ function releaseNotesContext(root, rangeOrTag) {
23942
23968
  `;
23943
23969
  stdout += printSection("Existing Release Files");
23944
23970
  for (const rel of ["CHANGELOG.md", "RELEASE_NOTES.md", ".github/releases.md"]) {
23945
- if (existsSync12(path31.join(cwd, rel)))
23971
+ if (existsSync13(path31.join(cwd, rel)))
23946
23972
  stdout += rel + `
23947
23973
  `;
23948
23974
  }
@@ -24565,7 +24591,7 @@ function resolveInside(root, candidate) {
24565
24591
  throw new Error("path must stay inside repository root");
24566
24592
  }
24567
24593
  let ancestor = target;
24568
- while (!existsSync13(ancestor))
24594
+ while (!existsSync14(ancestor))
24569
24595
  ancestor = path35.dirname(ancestor);
24570
24596
  const canonicalAncestor = realpathSync9(ancestor);
24571
24597
  if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base + path35.sep)) {
@@ -25904,7 +25930,7 @@ var splitDenial = (plan) => ({
25904
25930
  });
25905
25931
  // packages/workit-core/src/hooks/write-gate.ts
25906
25932
  import {
25907
- existsSync as existsSync14,
25933
+ existsSync as existsSync15,
25908
25934
  readdirSync as readdirSync5,
25909
25935
  readFileSync as readFileSync12,
25910
25936
  readlinkSync as readlinkSync3,
@@ -26616,7 +26642,7 @@ var linkSources = (args, at) => {
26616
26642
  const sources = names.filter((name, index) => into >= 0 ? name !== dest : index < names.length - 1 || names.length === 1);
26617
26643
  const target = dest === undefined ? null : at(dest);
26618
26644
  const symbolic = args.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg));
26619
- const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync14(target) || /[\\/]$/.test(dest ?? "") ? target : path41.dirname(target);
26645
+ const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync15(target) || /[\\/]$/.test(dest ?? "") ? target : path41.dirname(target);
26620
26646
  return sources.flatMap((source) => {
26621
26647
  if (symbolic && base !== null && !path41.isAbsolute(homeExpanded(source)))
26622
26648
  return [path41.resolve(base, source)];
@@ -28345,7 +28371,7 @@ import path46 from "node:path";
28345
28371
 
28346
28372
  // packages/workit-core/src/approvals/release-notes-ask.ts
28347
28373
  import { createHash as createHash20 } from "node:crypto";
28348
- import { existsSync as existsSync15, readFileSync as readFileSync14 } from "node:fs";
28374
+ import { existsSync as existsSync16, readFileSync as readFileSync14 } from "node:fs";
28349
28375
  import path44 from "node:path";
28350
28376
  var sha2563 = (data) => createHash20("sha256").update(data).digest("hex");
28351
28377
  var isReleaseNotesApprove = (words) => words[0] === "notes" && words[1] === "approve";
@@ -28391,7 +28417,7 @@ var releaseNotesAskAt = (args, cwd) => {
28391
28417
  path44.join(dir, "packages", `${version.replaceAll("/", "%2F")}.md`),
28392
28418
  path44.join(dir, `${version}.md`)
28393
28419
  ])
28394
- if (existsSync15(file))
28420
+ if (existsSync16(file))
28395
28421
  try {
28396
28422
  return releaseNotesAsk(args, { path: file, notes: readFileSync14(file, "utf8") });
28397
28423
  } catch {
@@ -30131,7 +30157,7 @@ var cdWorkitSplit = (command) => {
30131
30157
  };
30132
30158
 
30133
30159
  // packages/workit-core/src/hooks/model-limit.ts
30134
- import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync7, readSync, statSync as statSync5 } from "node:fs";
30160
+ import { closeSync as closeSync4, openSync as openSync4, readdirSync as readdirSync7, readSync, statSync as statSync5 } from "node:fs";
30135
30161
  import os11 from "node:os";
30136
30162
  import path49 from "node:path";
30137
30163
  var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
@@ -30272,21 +30298,21 @@ var TAIL_BYTES2 = 16384;
30272
30298
  var tail = (file, size) => {
30273
30299
  const length = Math.min(size, TAIL_BYTES2);
30274
30300
  const buffer = Buffer.alloc(length);
30275
- const fd = openSync3(file, "r");
30301
+ const fd = openSync4(file, "r");
30276
30302
  try {
30277
30303
  readSync(fd, buffer, 0, length, size - length);
30278
30304
  } finally {
30279
- closeSync3(fd);
30305
+ closeSync4(fd);
30280
30306
  }
30281
30307
  return buffer.toString("utf8");
30282
30308
  };
30283
30309
  var start = (file) => {
30284
30310
  const buffer = Buffer.alloc(TAIL_BYTES2);
30285
- const fd = openSync3(file, "r");
30311
+ const fd = openSync4(file, "r");
30286
30312
  try {
30287
30313
  return buffer.subarray(0, readSync(fd, buffer, 0, TAIL_BYTES2, 0)).toString("utf8");
30288
30314
  } finally {
30289
- closeSync3(fd);
30315
+ closeSync4(fd);
30290
30316
  }
30291
30317
  };
30292
30318
  var parse5 = (line) => {
@@ -30375,11 +30401,12 @@ var respawn = (input, reasons, dropped, limits) => {
30375
30401
  return {
30376
30402
  kind: "deny",
30377
30403
  reason: [
30378
- `workit spawn args: spawn again with exactly ${args} (description and prompt as written${without}).`,
30379
- ...reasons,
30380
- "Workit denies instead of rewriting the spawn: Claude Code's auto mode refuses a hook-rewritten spawn.",
30404
+ `workit spawn args: ${reasons.join(" ")}`,
30405
+ `Retry as: Agent ${args} (description and prompt as written${without}).`,
30406
+ "Why: auto mode refuses a hook-rewritten spawn.",
30381
30407
  limits
30382
- ].filter(Boolean).join(" "),
30408
+ ].filter(Boolean).join(`
30409
+ `),
30383
30410
  unblock: args
30384
30411
  };
30385
30412
  };
@@ -30414,18 +30441,19 @@ var agentModelDecision = (cwd, tool, options = {}) => {
30414
30441
  if (!selector)
30415
30442
  return asWritten(null);
30416
30443
  const choice = chooseSpawnModel(cwd, selector, "claude_code", tool, claudeAgentModel);
30444
+ const file = String(tool.subagent_type).startsWith("workit:") ? CLAUDE_AGENT_FILES[selector.role] : undefined;
30417
30445
  const effort = choice.effort?.toLowerCase() ?? null;
30418
30446
  const input = { ...tool };
30419
- if (choice.model)
30447
+ if (choice.model && (given(tool.model) || choice.model !== file?.model))
30420
30448
  input.model = choice.model;
30421
- if (effort && CLAUDE_EFFORTS.has(effort) && !given(tool.effort))
30449
+ if (effort && CLAUDE_EFFORTS.has(effort) && !given(tool.effort) && effort !== file?.effort)
30422
30450
  input.effort = effort;
30423
30451
  const needs = [
30424
30452
  input.model === tool.model ? null : `model ${String(input.model)}`,
30425
30453
  input.effort === tool.effort ? null : `effort ${String(input.effort)}`
30426
30454
  ].filter(Boolean);
30427
30455
  if (!needs.length)
30428
- return asWritten(choice.note);
30456
+ return asWritten(choice.model ? null : choice.note);
30429
30457
  if (!auto) {
30430
30458
  const note = choice.note ?? `Workit set effort ${String(input.effort)} on this spawn: its role's configured effort.`;
30431
30459
  return {
@@ -30435,12 +30463,18 @@ var agentModelDecision = (cwd, tool, options = {}) => {
30435
30463
  `)
30436
30464
  };
30437
30465
  }
30466
+ if (enforceMode(cwd) === "advise") {
30467
+ if (changed)
30468
+ return respawn(tool, change.reasons, change.dropped, limits);
30469
+ const ran = file ? `${file.model}${file.effort ? `/${file.effort}` : ""}` : "its default model";
30470
+ const pass = spawnArgsText({ model: input.model, effort: input.effort });
30471
+ return asWritten(`Workit: this ${String(tool.subagent_type || "general-purpose")} spawn runs on ${ran}; ${choice.basis} sets ${needs.join(" and ")}. To use it, pass ${pass} on the spawn.`);
30472
+ }
30438
30473
  const replaced = given(tool.model) && input.model !== tool.model;
30439
30474
  return respawn(input, [
30440
30475
  ...change.reasons,
30441
- `It needs ${needs.join(" and ")}: ${choice.basis ?? "its role"}.`,
30442
- replaced ? `That replaces model ${String(tool.model)}: a configured role model wins unless "allowLeadOverride": true is set under models in workspaces.json.` : ""
30443
- ].filter(Boolean), change.dropped, limits);
30476
+ `It needs ${needs.join(" and ")} (${choice.basis}, models.enforce strict)${replaced ? `, not ${String(tool.model)}` : ""}.`
30477
+ ], change.dropped, limits);
30444
30478
  };
30445
30479
 
30446
30480
  // packages/workit-core/src/hooks/spawn-gate.ts
@@ -31841,7 +31875,7 @@ var abandonedLaunches = (root) => {
31841
31875
  var cancelHint = (workerId) => `cancel it first: workit_worker {"action":"cancel","workerId":"${workerId}","reason":"launch outcome unknown"} (CLI: workit worker cancel --payload '{"workerId":"${workerId}","reason":"launch outcome unknown"}')`;
31842
31876
 
31843
31877
  // packages/workit-core/src/core/cli-locate.ts
31844
- import { closeSync as closeSync4, existsSync as existsSync16, openSync as openSync4, readSync as readSync2 } from "node:fs";
31878
+ import { closeSync as closeSync5, existsSync as existsSync17, openSync as openSync5, readSync as readSync2 } from "node:fs";
31845
31879
  import path53 from "node:path";
31846
31880
  var LAUNCHER_MARKER = "workit-owned-launcher";
31847
31881
  var CLI_PACKAGE_PATH = ["node_modules", "@workit-dev", "cli"];
@@ -31856,7 +31890,7 @@ var ownedCurrentEntry = (env, platform = process.platform) => path53.join(instal
31856
31890
  var head = (file) => {
31857
31891
  let fd;
31858
31892
  try {
31859
- fd = openSync4(file, "r");
31893
+ fd = openSync5(file, "r");
31860
31894
  const buffer = Buffer.alloc(256);
31861
31895
  const read = readSync2(fd, buffer, 0, buffer.length, 0);
31862
31896
  return buffer.subarray(0, read).toString("utf8");
@@ -31864,13 +31898,13 @@ var head = (file) => {
31864
31898
  return "";
31865
31899
  } finally {
31866
31900
  if (fd !== undefined)
31867
- closeSync4(fd);
31901
+ closeSync5(fd);
31868
31902
  }
31869
31903
  };
31870
31904
  var locateWorkitCli = (options = {}) => {
31871
31905
  const env = options.env ?? process.env;
31872
31906
  const platform = options.platform ?? process.platform;
31873
- const exists = options.exists ?? existsSync16;
31907
+ const exists = options.exists ?? existsSync17;
31874
31908
  const read = options.read ?? head;
31875
31909
  const node = options.node ?? process.execPath;
31876
31910
  const launcher = ownedLauncherPath(env, platform);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/pi",
3
- "version": "2.12.0",
3
+ "version": "2.14.0",
4
4
  "description": "Workit native extension for Pi — tools, method skills, and session continuity",
5
5
  "keywords": [
6
6
  "agentic-coding",
@@ -39,7 +39,7 @@ units of ~100+ lines each. Coupled work stays with one owner. Workit never spawn
39
39
  6. **Retry once, then escalate.** A stuck or failed slice gets one retry with
40
40
  a fresh brief (`workit fanout brief <slice> --mode resume`, same branch);
41
41
  if that fails too, re-slice it, take it over, or report the gap. Never
42
- chain resumes. A fix round and recheck that both fail: a decider, not a
42
+ chain resumes. A fix round and recheck that both fail: the decider agent, not a
43
43
  third round; product choices go to the user (`references/orchestration.md`).
44
44
  7. **Verify by the workspace `verification` setting** (`workit grant show`).
45
45
  A report is a pointer, never evidence. `proportional` (default): each slice's lane (`workit pr status`) decides; none needs no verdict, self the author's `--self`, focused and full a verifier (Claude Code: the `model` and `effort` of `workit models show --role verifier`) after the last push; one verdict at a stack's top covers its unchanged lower PRs, and a stale one with `reverify: focused` re-checks only the new diff, reusing green CI. `self`: a verifier that wrote none
@@ -5,35 +5,37 @@ and fans in. Workit records and checks; the host's own subagents run the work.
5
5
 
6
6
  ## TIER to model
7
7
 
8
- TIER is a field of each slice and of its brief. Role models come from the
9
- workspace (`models.roles`; `fanout.tierModels` still feeds the implementer
10
- tiers) and, on Claude Code, built-in defaults: the brief has a `model:` line
11
- (with `effort:` when set) under TIER and a `verifier:` line; `workit fanout
12
- status` names the model next to each spawnable slice; `workit models show
13
- [--role r] [--host h] --json` lists every role (decider, implementer tiers,
14
- verifier, reviewer, explore, babysit). Pass exactly that `model` (and `effort`
15
- where the host's spawn call takes one) on the spawn call: a subagent that
16
- passes none inherits your model. Scouting and PR babysitting use the `explore`
17
- and `babysit` roles. A role with no model (other hosts without config) runs
18
- on the host's model, and TIER only sizes the timebox and decides whether to
19
- race. Claude Code's built-in defaults, when nothing is configured:
20
-
21
- | Role or TIER | `model` on the Agent call |
8
+ TIER is a field of each slice and of its brief. Each Workit role is a host
9
+ agent that carries its own model: spawn it by name and pass no `model` or
10
+ `effort` unless the user named one (a named model always wins).
11
+
12
+ | Host | Spawn by name |
13
+ | --- | --- |
14
+ | Claude Code | `workit:implementer`, `workit:verifier`, `workit:reviewer`, `workit:decider`, `workit:babysitter`; search: `Explore` |
15
+ | OpenCode | `workit-implementer`, `workit-verifier`, `workit-reviewer`, `workit-decider`, `workit-babysitter` |
16
+ | Codex | the same `workit-*` names |
17
+ | Cursor | `workit-verifier`, `workit-reviewer`, `workit-decider`, `workit-babysitter` |
18
+
19
+ Claude Code, with nothing configured (pass a brief's `SPAWN:` line as printed):
20
+
21
+ | Role or TIER | Model |
22
22
  | --- | --- |
23
- | decider | `fable`, effort `high` |
24
- | hard | `opus` |
25
- | standard | `sonnet` |
26
- | mundane | `haiku` |
27
- | verifier | `sonnet` |
28
- | reviewer | `opus` |
29
- | explore, babysit | `haiku` |
30
-
31
- Claude Code and OpenCode also get the role's model set on the spawn by
32
- Workit; a configured one beats a `model` you pass unless
33
- `models.allowLeadOverride` is true. A general spawn takes
34
- `models.roles.default`, or the role its prompt's `ROLE: <role>` line names.
35
- `models.lead` (your own model) is advisory. `workit models show` marks each
36
- role `enforced` or `advisory` per host: on advisory, pass the model.
23
+ | decider | `fable`, effort `high` (agent file) |
24
+ | hard | `opus` (the brief's SPAWN line) |
25
+ | standard, verifier | `sonnet` (agent file) |
26
+ | mundane | `haiku` (the brief's SPAWN line) |
27
+ | reviewer | `opus` (agent file) |
28
+ | babysitter | `haiku` (agent file) |
29
+
30
+ A role
31
+ configured in `models.roles` to another model is listed in your session
32
+ contract (Claude Code) or set on the host's agent (OpenCode, Codex); `workit
33
+ models show [--role r] [--host h]` prints per host whether it comes from the
34
+ `agent file`, a `spawn fill` or is `advisory` (pass it yourself), and the
35
+ `models.enforce` mode. Under `strict` a configured role model beats a named
36
+ one and Claude Code's auto mode denies a spawn that lacks it. A role with no
37
+ model runs on the host's model, and TIER only sizes the timebox and decides
38
+ whether to race. `models.lead` (your own model) is advisory.
37
39
 
38
40
  ## Rolling window
39
41
 
@@ -66,10 +68,9 @@ reversibility (the option cheapest to undo wins a tie), and the exact change
66
68
  list. The fixer applies that list once, then one focused recheck follows.
67
69
 
68
70
  - Hard call (shared contract, security, migration): two deciders on different
69
- models (Claude Code, OpenCode, Cursor: the `decider` role model and a
70
- different `model` on the spawn, kept on a configured decider role only with
71
- `models.allowLeadOverride`; Codex and Pi: one decider). If they disagree, you take the
72
- more reversible option.
71
+ models (Claude Code, OpenCode, Cursor: one bare decider spawn and one that
72
+ names another `model`; Codex and Pi: one decider). If they disagree, you
73
+ take the more reversible option.
73
74
  - Record it: `workit ledger decision "<pick>" --by decider --why "<why it is
74
75
  the more reversible>" --view "<decider A: view>" --view "<decider B: view>"`.
75
76
  The row is listed as a decider call; it is never the user's answer to a
@@ -45,7 +45,7 @@ those files since the judged head and reuse green CI there (no fresh install, no
45
45
  under your own session (the one the lead or the hook gave you).
46
46
  8. **Bound the loop.** A failed verdict gets one fix round and one recheck of
47
47
  the changed hunks. Still failing, or stuck: no third round; the lead spawns
48
- a decider (read the `workit-fanout` skill's SKILL.md and follow it). A product choice goes to the user.
48
+ the decider agent by name, no model (read the `workit-fanout` skill's SKILL.md and follow it). A product choice: the user.
49
49
  9. **Harness note** (optional): friction caused by the repo or harness, not
50
50
  the change (a flaky fixture, a missing check, a misleading doc or skill
51
51
  line), goes on its own `Harness note:` line in the report and any PR
@@ -29,7 +29,7 @@ once the verdict is accepted. `merged`: step 7. `null` (closed, not merged):
29
29
  stop and report. Stop early only for a new consequential choice, a host
30
30
  denial, a review comment that needs a product decision, a required update
31
31
  that repeats because the base keeps moving, or after 3 failed fix attempts on
32
- the same check. Fix round and recheck both failed: a decider (read the `workit-fanout` skill's SKILL.md and follow it).
32
+ the same check. Fix round and recheck both failed: the decider agent (read the `workit-fanout` skill's SKILL.md and follow it).
33
33
 
34
34
  1. **Open.** Last before the PR, if `workit grant show` has `changelog: update|create`: write the Unreleased entry with `workit changelog apply`, commit it; with `docs: when-user-facing` fix only docs the diff made false (`references/changelog.md`).
35
35
  Full local check (`workit check ci` when `.workit/checks.json` has a `ci` group), push once: `workit git push`, then `workit pr template` and fill the template it prints: every heading, each `<!-- -->` replaced (Workit's: `references/pr-body.md`).