@workit-dev/codex 1.2.0 → 1.2.2

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workit",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Adaptive engineering workflow rails for Codex",
5
5
  "author": {
6
6
  "name": "BrainerVirus"
@@ -2,12 +2,12 @@
2
2
  name = "workit-reviewer"
3
3
  description = "Fresh-context reviewer for a workit branch or PR - spec fidelity and standards as separate axes, test quality and blast radius - that records findings and a non-author verdict. Use for independent review of a diff, branch or PR."
4
4
  sandbox_mode = "read-only"
5
- developer_instructions = '''You are the workit reviewer. Review the real candidate, never the author's
6
- description of it. Follow the workit-review skill (`$workit-review`).
5
+ developer_instructions = '''You are the workit reviewer. Review the real candidate, not the author's
6
+ account. Follow the workit-review skill (`$workit-review`).
7
7
 
8
8
  1. Pin the candidate: `git rev-parse HEAD`, the base, `git diff <base>...HEAD`;
9
- for a PR, `workit pr status --json` for checks and unresolved threads.
10
- 2. Read the intent: brief or acceptance criteria, spec, PR body, and
9
+ for a PR, `workit pr status --json` (checks, unresolved threads).
10
+ 2. Read the intent: brief or acceptance, spec, PR body, and
11
11
  `workit ledger list --type decision`.
12
12
  3. Judge two axes separately: spec fidelity (missing, creep, wrong; quote the
13
13
  line) and standards (repo rules first, then smells). Then test quality
@@ -15,18 +15,20 @@ description of it. Follow the workit-review skill (`$workit-review`).
15
15
  touched contract or caller, run with `workit check -- <cmd>`; label anything
16
16
  unproven UNPROVEN.
17
17
  4. Each finding: file:line, severity (blocker, major, minor, nit), evidence
18
- (hunk, test or command output), concrete fix.
18
+ (hunk, test or output), concrete fix.
19
19
  5. Record the verdict:
20
- start from the exact verdict command the SubagentStart hook put in your context (it names no --session or --token: your shell already acts as your own session); it already names `--kind review`:
20
+ start from the exact verdict command the SubagentStart hook gave you (it names no --session or --token: your shell already acts as your own session); it names `--kind review`:
21
21
  `workit ledger verdict verified|failed|blocked --kind review --branch <b> --how "<what you read and ran>"`
22
- (`verified` with `--kind review`: no blocker or major finding left).
23
- Record a design choice you had to make as `workit ledger ruling`.
22
+ (`verified`: no blocker or major left).
23
+ Record a design choice as `workit ledger ruling`.
24
24
 
25
25
  Before your final report, wait for or stop every background command you started
26
26
  (the host shows you running while one lives); never report with one still running.
27
27
 
28
- Stay read-only: read and test commands only, never commits, pushes, merges or
29
- edits. If the ledger refuses you as an author, report that instead of a verdict.
28
+ Never commit, push, merge or edit. Write only in the checkout's
29
+ `.workit-scratch/`: generated test cases go into files there via a quoted
30
+ heredoc (`<<'EOF'`), never run by the shell. If the ledger refuses you as an
31
+ author, report that instead of a verdict.
30
32
 
31
33
  Codex runs you in a read-only sandbox. `workit check` and `workit ledger verdict` write outside it: run them with escalated permissions (Codex asks the user). If escalation is refused or unavailable, record nothing and report the verdict you would record as blocked.
32
34
  '''
@@ -2,37 +2,38 @@
2
2
  name = "workit-verifier"
3
3
  description = "Independently verifies a workit candidate (branch, commit or PR) on its real surface and records a SHA-keyed verdict in the ledger. Use after an implementer finishes and before shipping, never on work this session authored."
4
4
  sandbox_mode = "read-only"
5
- developer_instructions = '''You are the workit verifier. You did not write the candidate and you never
6
- change it: you observe, judge and record. Start from the goal and work
7
- backward: what must be true, what must exist, what must be wired. The author's
8
- summary is a claim, not evidence; assume the goal is not met until you observe
9
- it.
5
+ developer_instructions = '''You are the workit verifier. You did not write the candidate and never
6
+ change it: you observe, judge and record. Work backward from the goal: what
7
+ must be true, exist and be wired. The author's summary is a claim:
8
+ the goal is unmet until you observe it.
10
9
 
11
10
  1. Pin the candidate in its own checkout (run workit as
12
11
  `workit <verb> --cwd <worktree> …`, verb first; never `cd` first): `git -C <worktree> rev-parse HEAD` and `git -C <worktree> status --short`. A dirty tree
13
- or a moving HEAD is itself a finding, and the ledger refuses a verdict on it.
12
+ or a moving HEAD is a finding; the ledger refuses a verdict on it.
14
13
  2. Read the brief: goal, acceptance (Given/When/Then), verify commands.
15
- 3. Run every verify command through the CLI so the result is observed:
14
+ 3. Run every verify command through the CLI:
16
15
  `workit check <name>` for configured checks, `workit check -- <cmd>` for the
17
16
  rest. Never substitute an easier command. Run every configured check by name
18
- (your SubagentStart context lists them) or cite green CI on that head; otherwise, `verified` is refused.
17
+ (your SubagentStart context lists them) or cite green CI on that head, else `verified` is refused.
19
18
  4. Drive the real surface with the project's `verify-<app>` skill when it
20
19
  exists (`$workit-verify-app` generates one). Tests alone are unit evidence.
21
- 5. Judge each acceptance line as met, not met, or not verifiable, citing what
20
+ 5. Judge each acceptance line met, not met or not verifiable, citing what
22
21
  you observed. Label every claim measured, inferred or guess.
23
22
  6. Record the verdict, then report it:
24
23
  start from the exact verdict command the SubagentStart hook put in your context (it names no --session or --token: your shell already acts as your own session, never set WORKIT_SESSION_ID) and pick its `--kind <live|unit>`:
25
24
  `workit ledger verdict verified|tests-verified|type-check-only|failed|blocked --kind <live|unit> --branch <b> --how "<what you ran and saw>"`.
26
- `verified` means the change was observed working on its real surface
25
+ `verified` means the change was seen working on its real surface
27
26
  (verify-<app>, `--kind live`); `tests-verified` means only tests ran. If the ledger refuses you as an author, report that;
28
- never pass `--self` to get around it.
27
+ never pass `--self`.
29
28
 
30
29
  Before your final report, wait for or stop every background command you started
31
30
  (the host shows you running while one lives); never report with one still running.
32
31
 
32
+ Write only in the checkout's `.workit-scratch/`: a generated test case goes in
33
+ a file there via a quoted heredoc (`<<'EOF'`), never run by the shell.
34
+
33
35
  Report: candidate SHA, each check with its exit code, each acceptance line,
34
- the verdict row you recorded. Do not fix anything you find: a failing check is
35
- a verdict, not a task.
36
+ the verdict row you recorded. Fix nothing: a failing check is a verdict.
36
37
 
37
38
  Codex runs you in a read-only sandbox. `workit check` and `workit ledger verdict` write outside it: run them with escalated permissions (Codex asks the user). If escalation is refused or unavailable, record nothing and report the verdict you would record as blocked.
38
39
  '''
@@ -22037,6 +22037,19 @@ function verdictBasis(verdict, current) {
22037
22037
  return "stale";
22038
22038
  }
22039
22039
  var isLiveVerdict = (row, retired) => row.type === "verdict" && typeof row.result === "string" && !retired.has(row.id);
22040
+ var VOID_TYPE = "verdict.voided";
22041
+ function verdictVoids(rows, options = {}) {
22042
+ const voids = new Map;
22043
+ for (const row of rows)
22044
+ if (row.type === VOID_TYPE && row.observer === "workit_cli" && typeof row.target === "string" && (options.chained ? row.integrity === "verified" : row.integrity !== "unverified") && !voids.has(row.target))
22045
+ voids.set(row.target, {
22046
+ id: row.id,
22047
+ at: row.at,
22048
+ reason: str2(row.reason) ?? "",
22049
+ by: row.actor.session
22050
+ });
22051
+ return voids;
22052
+ }
22040
22053
  function trailerSessions(cwd, base, head) {
22041
22054
  if (!base || !head || !safeRef2(base) || !safeRef2(head))
22042
22055
  return [];
@@ -22375,6 +22388,8 @@ function checkVerdictsOnce(cwd, branch, ledgerRows) {
22375
22388
  for (const row of rows)
22376
22389
  if (row.type === "verdict" && row.supersedes && !row.supersedeIgnored && trustReasons(cwd, row).length === 0)
22377
22390
  retired.add(row.supersedes);
22391
+ for (const id of verdictVoids(rows, { chained: true }).keys())
22392
+ retired.add(id);
22378
22393
  const byKind = new Map;
22379
22394
  for (const row of rows.toSorted(byRank))
22380
22395
  if (isLiveVerdict(row, retired) && scope(row)) {
@@ -22508,7 +22523,7 @@ function importMirroredVerdicts(cwd, branch) {
22508
22523
  const mirror = readLedgerAt(cwd, file, { integrity: true });
22509
22524
  if (!mirror.ok)
22510
22525
  return [];
22511
- const candidates = mirror.value.rows.filter((row) => row.type === "verdict" && row.branch === branch && row.integrity === "verified");
22526
+ const candidates = mirror.value.rows.filter((row) => (row.type === "verdict" || row.type === VOID_TYPE) && row.branch === branch && row.integrity === "verified");
22512
22527
  const added = new Set;
22513
22528
  try {
22514
22529
  fs15.mkdirSync(path19.dirname(local.value), { recursive: true });
@@ -22534,7 +22549,10 @@ function importMirroredVerdicts(cwd, branch) {
22534
22549
  integrityReason: _reason,
22535
22550
  ...fields
22536
22551
  } = row;
22537
- const written = appendLine(local.value, (previous) => ({ ok: true, value: sealed(fields, id, at, previous).line }), { heldLock: true });
22552
+ const written = appendLine(local.value, (previous) => ({
22553
+ ok: true,
22554
+ value: sealed(fields, id, at, previous).line
22555
+ }), { heldLock: true });
22538
22556
  if (!written.ok)
22539
22557
  return false;
22540
22558
  ids.add(id);
@@ -22553,6 +22571,7 @@ var OBSERVED_ONLY = new Set([
22553
22571
  "check",
22554
22572
  "merge.unverified",
22555
22573
  "policy.judged",
22574
+ "verdict.voided",
22556
22575
  ...PR_ROW_TYPES
22557
22576
  ]);
22558
22577
 
@@ -31133,6 +31152,19 @@ var MUTATING_REMOTE = new Set([
31133
31152
  "set-branches",
31134
31153
  "prune"
31135
31154
  ]);
31155
+ var JUDGE_VERBS = {
31156
+ check: true,
31157
+ dir: true,
31158
+ help: true,
31159
+ "test-audit": true,
31160
+ ledger: ["verdict", "finding", "list", "check", "ruling"],
31161
+ pr: ["status"],
31162
+ ci: ["wait", "logs"],
31163
+ fanout: ["status", "brief"],
31164
+ models: ["show"],
31165
+ lock: ["status"]
31166
+ };
31167
+ var JUDGE_JOB = Object.entries(JUDGE_VERBS).map(([verb, subs]) => `workit ${verb}${subs === true ? "" : ` ${subs.join("|")}`}`).join(", ");
31136
31168
 
31137
31169
  // packages/workit-core/src/hooks/standing.ts
31138
31170
  var DESCRIPTORS = {
@@ -14938,6 +14938,19 @@ function verdictBasis(verdict, current) {
14938
14938
  return "stale";
14939
14939
  }
14940
14940
  var isLiveVerdict = (row, retired) => row.type === "verdict" && typeof row.result === "string" && !retired.has(row.id);
14941
+ var VOID_TYPE = "verdict.voided";
14942
+ function verdictVoids(rows, options = {}) {
14943
+ const voids = new Map;
14944
+ for (const row of rows)
14945
+ if (row.type === VOID_TYPE && row.observer === "workit_cli" && typeof row.target === "string" && (options.chained ? row.integrity === "verified" : row.integrity !== "unverified") && !voids.has(row.target))
14946
+ voids.set(row.target, {
14947
+ id: row.id,
14948
+ at: row.at,
14949
+ reason: str(row.reason) ?? "",
14950
+ by: row.actor.session
14951
+ });
14952
+ return voids;
14953
+ }
14941
14954
  function trailerSessions(cwd, base, head) {
14942
14955
  if (!base || !head || !safeRef2(base) || !safeRef2(head))
14943
14956
  return [];
@@ -15276,6 +15289,8 @@ function checkVerdictsOnce(cwd, branch, ledgerRows) {
15276
15289
  for (const row of rows)
15277
15290
  if (row.type === "verdict" && row.supersedes && !row.supersedeIgnored && trustReasons(cwd, row).length === 0)
15278
15291
  retired.add(row.supersedes);
15292
+ for (const id of verdictVoids(rows, { chained: true }).keys())
15293
+ retired.add(id);
15279
15294
  const byKind = new Map;
15280
15295
  for (const row of rows.toSorted(byRank))
15281
15296
  if (isLiveVerdict(row, retired) && scope(row)) {
@@ -15409,7 +15424,7 @@ function importMirroredVerdicts(cwd, branch) {
15409
15424
  const mirror = readLedgerAt(cwd, file, { integrity: true });
15410
15425
  if (!mirror.ok)
15411
15426
  return [];
15412
- const candidates = mirror.value.rows.filter((row) => row.type === "verdict" && row.branch === branch && row.integrity === "verified");
15427
+ const candidates = mirror.value.rows.filter((row) => (row.type === "verdict" || row.type === VOID_TYPE) && row.branch === branch && row.integrity === "verified");
15413
15428
  const added = new Set;
15414
15429
  try {
15415
15430
  fs12.mkdirSync(path16.dirname(local.value), { recursive: true });
@@ -15435,7 +15450,10 @@ function importMirroredVerdicts(cwd, branch) {
15435
15450
  integrityReason: _reason,
15436
15451
  ...fields
15437
15452
  } = row;
15438
- const written = appendLine(local.value, (previous) => ({ ok: true, value: sealed(fields, id, at, previous).line }), { heldLock: true });
15453
+ const written = appendLine(local.value, (previous) => ({
15454
+ ok: true,
15455
+ value: sealed(fields, id, at, previous).line
15456
+ }), { heldLock: true });
15439
15457
  if (!written.ok)
15440
15458
  return false;
15441
15459
  ids.add(id);
@@ -15476,6 +15494,7 @@ var OBSERVED_ONLY = new Set([
15476
15494
  "check",
15477
15495
  "merge.unverified",
15478
15496
  "policy.judged",
15497
+ "verdict.voided",
15479
15498
  ...PR_ROW_TYPES
15480
15499
  ]);
15481
15500
 
@@ -19287,7 +19306,8 @@ var WORKIT_BYPASS_FLAGS = ["--unverified", "--overwrite-unintegrated"];
19287
19306
  var WORKIT_USER_ONLY = [
19288
19307
  ["release", "notes", "approve"],
19289
19308
  ["grant", "set"],
19290
- ["grant", "raise"]
19309
+ ["grant", "raise"],
19310
+ ["ledger", "void"]
19291
19311
  ];
19292
19312
  var ALLOWED = new Set(WORKIT_ALLOWED_VERBS);
19293
19313
  var hasWordsInOrder = (words, needle) => {
@@ -20418,7 +20438,7 @@ var shellScript2 = (words) => {
20418
20438
  return null;
20419
20439
  for (let index = 1;index < words.length; index++) {
20420
20440
  const word = words[index];
20421
- if (/^-[a-z]*c$/.test(word))
20441
+ if (/^-[a-z]*c[a-z]*$/.test(word))
20422
20442
  return words[index + 1] ?? null;
20423
20443
  if (/^[-+][oO]$/.test(word))
20424
20444
  index++;
@@ -20449,8 +20469,16 @@ var opaqueWrites = (input, scriptOf = (index) => input[index]) => {
20449
20469
  const files = operands(args);
20450
20470
  const has = (pattern) => args.some((arg) => pattern.test(arg));
20451
20471
  const listed = (named) => named.length ? named : ["."];
20452
- if (name === "unlink" || name === "shred")
20472
+ if (name === "unlink" || name === "shred" || name === "mkfifo")
20453
20473
  return listed(files);
20474
+ if (name === "wget")
20475
+ return wgetOutputs(args);
20476
+ if (name === "tar")
20477
+ return tarOutputs(args);
20478
+ if (name === "unzip")
20479
+ return has(/^-[a-zA-Z]*[lptvzZ]/) ? null : listed(args.flatMap((arg, at) => arg.startsWith("-d") ? [arg.slice(2) || args[at + 1] || "."] : []));
20480
+ if (name === "git")
20481
+ return gitOutputs(args);
20454
20482
  if (/^(?:chmod|chown|chgrp|chattr)$/.test(name))
20455
20483
  return listed(has(/^--reference/) ? files : files.slice(1));
20456
20484
  if (name === "rsync") {
@@ -20570,6 +20598,85 @@ var curlOutputs = (args) => {
20570
20598
  files.push(...dirs.length ? dirs : ["."]);
20571
20599
  return files.length > 0 ? files : null;
20572
20600
  };
20601
+ var valueOf = (args, option) => {
20602
+ const at = args.findIndex((arg) => option.test(arg));
20603
+ return at < 0 ? undefined : option.exec(args[at])?.[1] || args[at + 1];
20604
+ };
20605
+ var wgetOutputs = (args) => {
20606
+ const named = valueOf(args, /^(?:-[a-zA-Z]*O|--output-document=?)(.*)$/s);
20607
+ const logs = [/^-[a-zA-Z]*[oa](.*)$/s, /^--(?:output-file|append-output)=?(.*)$/s].flatMap((option) => valueOf(args, option) ?? []);
20608
+ if (named === undefined)
20609
+ return [...logs, valueOf(args, /^(?:-[a-zA-Z]*P|--directory-prefix=?)(.*)$/s) ?? "."];
20610
+ return named === "-" ? logs : [...logs, named];
20611
+ };
20612
+ var tarOutputs = (args) => {
20613
+ const letters = args.filter((arg, at) => at === 0 && !arg.startsWith("-") || /^-[a-zA-Z]+$/.test(arg)).join("").replaceAll("C", "");
20614
+ const long = (pattern) => args.some((arg) => pattern.test(arg));
20615
+ const extract = /x/.test(letters) || long(/^--(?:extract|get)$/);
20616
+ const creates = /[cruA]/.test(letters) || long(/^--(?:create|append|update|concatenate|delete)$/);
20617
+ if (!extract && !creates)
20618
+ return null;
20619
+ const files = [];
20620
+ if (extract) {
20621
+ const dirs = args.flatMap((arg, at) => /^-C|^--directory(?:=|$)/.test(arg) ? [arg.replace(/^-C|^--directory=?/, "") || args[at + 1] || "."] : []);
20622
+ files.push(...dirs.length ? dirs : ["."]);
20623
+ }
20624
+ const old = args[0] !== undefined && !args[0].startsWith("-") && args[0].includes("f");
20625
+ const archive = old ? args[1] : valueOf(args, /^(?:-[a-zA-Z]*f|--file=?)(.*)$/s);
20626
+ if (creates && archive !== undefined && archive !== "-")
20627
+ files.push(archive);
20628
+ return files;
20629
+ };
20630
+ var CONFIG_READ = /^(?:--get(?:-all|-regexp|-urlmatch)?|--list|-l|get|list)$/;
20631
+ var CONFIG_WRITE = /^(?:--(?:unset(?:-all)?|add|replace-all|rename-section|remove-section|edit)|-e|set|unset|rename-section|remove-section|edit)$/;
20632
+ var CONFIG_VALUE = /^(?:--file|-f|--blob|--type|--default|--comment)$/;
20633
+ var configWrites = (rest) => {
20634
+ if (rest.some((arg) => CONFIG_READ.test(arg)))
20635
+ return false;
20636
+ if (rest.some((arg) => CONFIG_WRITE.test(arg)))
20637
+ return true;
20638
+ let named = 0;
20639
+ for (let index = 0;index < rest.length; index++)
20640
+ if (CONFIG_VALUE.test(rest[index]))
20641
+ index++;
20642
+ else if (!rest[index].startsWith("-"))
20643
+ named++;
20644
+ return named > 1;
20645
+ };
20646
+ var GIT_VALUE = /^(?:-[Ccbouj]|--(?:git-dir|work-tree|namespace|config-env|branch|origin|config|depth|reference(?:-if-able)?|template|separate-git-dir|upload-pack|jobs|filter|initial-branch|object-format))$/;
20647
+ var gitOutputs = (args) => {
20648
+ let at = 0;
20649
+ let base;
20650
+ for (;args[at]?.startsWith("-"); at += GIT_VALUE.test(args[at]) ? 2 : 1)
20651
+ if (args[at] === "-C")
20652
+ base = args[at + 1];
20653
+ const [sub = "", ...rest] = args.slice(at);
20654
+ if (rest.some((arg) => arg === "--help" || arg === "-h"))
20655
+ return null;
20656
+ const names = rest.filter((arg, index) => !arg.startsWith("-") && !GIT_VALUE.test(rest[index - 1] ?? ""));
20657
+ const has = (pattern) => rest.some((arg) => pattern.test(arg));
20658
+ const files = [];
20659
+ const output = valueOf(rest, sub === "archive" ? /^(?:-o|--output=?)(.*)$/s : /^--output=?(.*)$/s);
20660
+ if (output !== undefined)
20661
+ files.push(output);
20662
+ if (sub === "init")
20663
+ files.push(names[0] ?? ".");
20664
+ if (sub === "clone")
20665
+ files.push(names[1] ?? names[0]?.replace(/(?:\.git)?[\\/]*$/, "").split(/[\\/:]/).at(-1) ?? ".");
20666
+ if (sub === "format-patch" && !has(/^--stdout$/))
20667
+ files.push(valueOf(rest, /^(?:-o|--output-directory=?)(.*)$/s) ?? ".");
20668
+ if (sub === "bundle" && names[0] === "create" && names[1])
20669
+ files.push(names[1]);
20670
+ if (sub === "config" && configWrites(rest))
20671
+ files.push(has(/^--global$/) ? "~/.gitconfig" : has(/^--system$/) ? "/etc/gitconfig" : valueOf(rest, /^(?:-f|--file=?)(.*)$/s) ?? ".");
20672
+ const branchWrite = has(/^-[a-zA-Z]*[dDfmMcCu]|^--(?:delete|force|move|copy|set-upstream|unset-upstream|edit)/) || names.length > 0 && !has(/^-[a-zA-Z]*[lavr]|^--(?:list|all|remotes|verbose|show|contains|no-contains|merged|no-merged|points-at|format|sort)/);
20673
+ if (sub === "fetch" || sub === "gc" || sub === "branch" && branchWrite)
20674
+ files.push(".");
20675
+ if (base === undefined)
20676
+ return files.length ? files : null;
20677
+ const under = (file) => file === "." ? `${base}/${OPAQUE_TARGET}git` : /^[/~$]|^[A-Za-z]:[\\/]/.test(file) ? file : `${base}/${file}`;
20678
+ return files.length ? files.map(under) : null;
20679
+ };
20573
20680
  var pathsIn = (text) => [
20574
20681
  ...text.matchAll(/(?<![\w.~:/$-])(?:~\/|\/|[A-Za-z]:\/|\.\.(?:\/|$))[^\s'"`$),;:*?<>|\\[\]{}]*/g)
20575
20682
  ].map((match) => match[0]);
@@ -22726,9 +22833,6 @@ var MUTATING_REMOTE = new Set([
22726
22833
  "set-branches",
22727
22834
  "prune"
22728
22835
  ]);
22729
- var CONFIG_READ = /^(?:--get(?:-all|-regexp|-urlmatch)?|--list|-l|get|list)$/;
22730
- var CONFIG_WRITE = /^(?:--(?:unset(?:-all)?|add|replace-all|rename-section|remove-section|edit)|-e|set|unset|rename-section|remove-section|edit)$/;
22731
- var CONFIG_VALUE = /^(?:--file|-f|--blob|--type|--default|--comment)$/;
22732
22836
  var leadOwnedGit = (args) => {
22733
22837
  const [sub = "", ...rest] = args;
22734
22838
  if (rest.some((arg) => arg === "--help" || arg === "-h"))
@@ -22767,19 +22871,8 @@ var leadOwnedGit = (args) => {
22767
22871
  return names[0] === "drop" || names[0] === "clear";
22768
22872
  case "remote":
22769
22873
  return MUTATING_REMOTE.has(names[0] ?? "");
22770
- case "config": {
22771
- if (rest.some((arg) => CONFIG_READ.test(arg)))
22772
- return false;
22773
- if (rest.some((arg) => CONFIG_WRITE.test(arg)))
22774
- return true;
22775
- let operands = 0;
22776
- for (let index = 0;index < rest.length; index++)
22777
- if (CONFIG_VALUE.test(rest[index]))
22778
- index++;
22779
- else if (!rest[index].startsWith("-"))
22780
- operands++;
22781
- return operands > 1;
22782
- }
22874
+ case "config":
22875
+ return configWrites(rest);
22783
22876
  default:
22784
22877
  return false;
22785
22878
  }
@@ -22807,6 +22900,223 @@ function confineImplementerShell(input, command, dialect = "posix") {
22807
22900
  } catch {}
22808
22901
  return confineImplementer(input, shellMutationTargets(input.cwd, command, dialect, true), command);
22809
22902
  }
22903
+ var SCRATCH = ".workit-scratch";
22904
+ var SHELL_NAMES = /^(?:sh|bash|zsh|dash|ksh|mksh|ash)$/;
22905
+ var INTERPRETERS = /^(?:python[\d.]*|node|bun|deno|ruby|perl|php)$/;
22906
+ var FED = /^(?:-|\/dev\/stdin|\/dev\/fd\/0|\/proc\/self\/fd\/0)$|^<\(/;
22907
+ var LEADS = /^(?:sudo|doas|env|command|builtin|exec|nohup|time|nice|timeout|stdbuf|xargs|busybox|!|\{|if|then|else|elif|do|while|until|\w+=.*|[-\d].*)$/s;
22908
+ var RUNS = /^(?:sh|bash|zsh|dash|ksh|mksh|ash|python[\d.]*|node|bun|deno|ruby|perl|php|eval|source|\.|workit)$/;
22909
+ var INLINE = /^-[a-zA-Z]*[ceEpm]$|^--(?:eval|print|test|version|help)$|^-[hvV]$/;
22910
+ var VALUED = /^-[WXIrC]$|^--(?:require|import|loader|conditions|input-type)$/;
22911
+ var commonDir = (root) => {
22912
+ const dotGit = path30.join(root, ".git");
22913
+ if (!fs21.statSync(dotGit).isFile())
22914
+ return canonical4(dotGit);
22915
+ const admin = path30.resolve(root, /^gitdir:\s*(.+)$/mu.exec(fs21.readFileSync(dotGit, "utf8"))?.[1]?.trim() ?? "");
22916
+ const common = path30.join(admin, "commondir");
22917
+ return canonical4(fs21.existsSync(common) ? path30.resolve(admin, fs21.readFileSync(common, "utf8").trim()) : admin);
22918
+ };
22919
+ var inScratch = (real, repo) => {
22920
+ const checkout = checkoutOf2(real);
22921
+ return checkout !== null && within(real, path30.join(checkout.root, SCRATCH)) && (repo === null || commonDir(checkout.root) === repo);
22922
+ };
22923
+ var JUDGE_VERBS = {
22924
+ check: true,
22925
+ dir: true,
22926
+ help: true,
22927
+ "test-audit": true,
22928
+ ledger: ["verdict", "finding", "list", "check", "ruling"],
22929
+ pr: ["status"],
22930
+ ci: ["wait", "logs"],
22931
+ fanout: ["status", "brief"],
22932
+ models: ["show"],
22933
+ lock: ["status"]
22934
+ };
22935
+ var HELP = /^(?:--help|-h)$/;
22936
+ var judgeVerbRefused = (args) => {
22937
+ const { rest } = skipWorkitGlobals(args);
22938
+ const end = rest.indexOf("--");
22939
+ const call = end < 0 ? rest : rest.slice(0, end);
22940
+ const [verb, sub = ""] = call;
22941
+ if (verb === undefined || verb === "--version" || HELP.test(verb) || HELP.test(sub))
22942
+ return null;
22943
+ const allowed = Object.hasOwn(JUDGE_VERBS, verb) ? JUDGE_VERBS[verb] : [];
22944
+ const ok = allowed === true ? !(verb === "test-audit" && call.some((arg) => /^--mutate(?:=|$)/.test(arg))) : allowed.includes(sub);
22945
+ return ok ? null : `workit ${call.join(" ")}`;
22946
+ };
22947
+ var CLI_RUNNERS = /^(?:npx|bunx|pnpx|npm|pnpm|yarn|bun|node|nodejs|deno|tsx|ts-node)$/;
22948
+ var CLI_ENTRY = /(?:^|[=\\/])(?:workit(?:\.(?:exe|cmd|[cm]?js))?|@workit-dev\/cli(?:@\S*)?)$|(?:workit-cli|@workit-dev[\\/]cli)[\\/](?:src[\\/](?:index|main)|dist[\\/]index)\.[cm]?[jt]sx?$/;
22949
+ var workitCalls = (command, depth = 0, aliases = new Map) => depth > 4 ? [] : commandLines(command).flatMap((words) => {
22950
+ const name = path30.basename(words[0] ?? "").toLowerCase();
22951
+ if (name === "alias")
22952
+ return words.flatMap((word) => {
22953
+ const set = /^([\w-]+)=(.*)$/s.exec(word);
22954
+ if (!set)
22955
+ return [];
22956
+ aliases.set(set[1], set[2]);
22957
+ return workitCalls(set[2], depth + 1, aliases);
22958
+ });
22959
+ const body = aliases.get(words[0] ?? "");
22960
+ if (body !== undefined)
22961
+ return workitCalls([body, ...words.slice(1).map((word) => `'${word.replaceAll("'", `'\\''`)}'`)].join(" "), depth + 1, aliases);
22962
+ let at = /^workit(?:\.exe|\.cmd)?$/.test(name) ? 0 : CLI_RUNNERS.test(name) ? words.findIndex((word, index) => index > 0 && CLI_ENTRY.test(word)) : -1;
22963
+ if (at < 0)
22964
+ return [];
22965
+ while (words[at + 1] === "--" || CLI_ENTRY.test(words[at + 1] ?? ""))
22966
+ at++;
22967
+ return [words.slice(at + 1)];
22968
+ });
22969
+ var JUDGE_JOB = Object.entries(JUDGE_VERBS).map(([verb, subs]) => `workit ${verb}${subs === true ? "" : ` ${subs.join("|")}`}`).join(", ");
22970
+ var judgeRefusal = (command, fed, depth = 0) => {
22971
+ let moved = false;
22972
+ for (const segment of segmentsOf(command)) {
22973
+ const nested = (script) => script !== undefined && depth < 4 ? judgeRefusal(script, fed, depth + 1) : null;
22974
+ for (const sub of segment.subs ?? []) {
22975
+ const why = nested(sub);
22976
+ if (why)
22977
+ return why;
22978
+ }
22979
+ const { words } = segment;
22980
+ const runs = (word = "") => RUNS.test(path30.basename(word).toLowerCase());
22981
+ let at = 0;
22982
+ while (at < words.length && (LEADS.test(words[at]) || /^-\w$/.test(words[at - 1] ?? "") && !runs(words[at])))
22983
+ at++;
22984
+ const name = path30.basename(words[at] ?? "").toLowerCase();
22985
+ const args = words.slice(at + 1);
22986
+ const unseen = `\`${words.join(" ").slice(0, 80)}\` runs a script Workit cannot read (piped, on stdin, a process substitution or eval): write the case to a file in ${SCRATCH} and dispatch it from a test instead`;
22987
+ if (/^(?:cd|chdir|pushd|popd)$/.test(name))
22988
+ moved = true;
22989
+ if (name === "eval" || (name === "source" || name === ".") && FED.test(args[0] ?? ""))
22990
+ return unseen;
22991
+ if (SHELL_NAMES.test(name)) {
22992
+ let operand;
22993
+ let stdin = false;
22994
+ let inline;
22995
+ for (let index = 0;index < args.length && inline === undefined; index++) {
22996
+ const arg = args[index];
22997
+ if (/^-[a-zA-Z]*c[a-zA-Z]*$/.test(arg))
22998
+ inline = index + 1;
22999
+ else if (/^[-+][oO]$/.test(arg))
23000
+ index++;
23001
+ else if (arg === "--" || !/^[-+]/.test(arg)) {
23002
+ operand = arg === "--" ? args[index + 1] : arg;
23003
+ break;
23004
+ } else if (/^-[a-zA-Z]*s/.test(arg))
23005
+ stdin = true;
23006
+ }
23007
+ if (inline !== undefined) {
23008
+ const why = nested(args[inline]);
23009
+ if (why)
23010
+ return why;
23011
+ } else if (operand === undefined || stdin || FED.test(operand)) {
23012
+ if (!segment.stdin?.length || moved || operand !== undefined && !stdin)
23013
+ return unseen;
23014
+ fed.push(...segment.stdin);
23015
+ for (const body of segment.stdin) {
23016
+ const why = nested(body);
23017
+ if (why)
23018
+ return why;
23019
+ }
23020
+ }
23021
+ }
23022
+ if (INTERPRETERS.test(name) && !args.some((arg) => INLINE.test(arg))) {
23023
+ const operand = args.find((arg, index) => (arg === "-" || !arg.startsWith("-")) && !VALUED.test(args[index - 1] ?? ""));
23024
+ if (FED.test(operand ?? "") || operand === undefined && !/^(?:bun|deno)$/.test(name))
23025
+ return unseen;
23026
+ }
23027
+ const tail = workitCheckTail(words.slice(at));
23028
+ if (tail) {
23029
+ const why = nested("script" in tail ? tail.script : tail.argv.map((word) => `'${word.replaceAll("'", `'\\''`)}'`).join(" "));
23030
+ if (why)
23031
+ return why;
23032
+ }
23033
+ }
23034
+ for (const args of workitCalls(command)) {
23035
+ const call = judgeVerbRefused(args);
23036
+ if (call)
23037
+ return `\`${call}\` is not a judge's job: a judge runs only ${JUDGE_JOB}`;
23038
+ }
23039
+ return null;
23040
+ };
23041
+ var substitutingHeredoc = (command) => {
23042
+ for (const match of command.matchAll(/(?<!<)<<-?[ \t]*([^\s<>;&|()]+)/g)) {
23043
+ const delimiter = match[1];
23044
+ if (/['"\\]/.test(delimiter))
23045
+ continue;
23046
+ const newline = command.indexOf(`
23047
+ `, match.index + match[0].length);
23048
+ if (newline < 0)
23049
+ continue;
23050
+ const lines = command.slice(newline + 1).split(`
23051
+ `);
23052
+ const end = lines.findIndex((line) => line.trim() === delimiter);
23053
+ if (/\$\((?!\()|`/.test((end < 0 ? lines : lines.slice(0, end)).join(`
23054
+ `)))
23055
+ return true;
23056
+ }
23057
+ return false;
23058
+ };
23059
+ var judgeDeny = (input, what) => {
23060
+ const role = input.session.agentType?.endsWith("reviewer") ? "reviewer" : "verifier";
23061
+ const root = checkoutOf2(input.cwd)?.root;
23062
+ const scratch = root ? path30.join(root, SCRATCH) : `${SCRATCH}/ at the root of the checkout you judge`;
23063
+ const unblock = `Write only under ${scratch} (mkdir -p it): put a generated case in a file there with a quoted heredoc (<<'EOF') and never run it in the shell. Reads, \`workit check\` and \`workit ledger verdict|finding\` stay allowed; a change the candidate needs is a finding, not an edit.`;
23064
+ return {
23065
+ kind: "deny",
23066
+ reason: `workit scratch confinement: ${role} ${input.session.agentId} may write only in its scratch dir ${scratch}, and ${what}. ${unblock}`,
23067
+ unblock
23068
+ };
23069
+ };
23070
+ function confineJudge(input, targets) {
23071
+ try {
23072
+ if (!input.session.agentId)
23073
+ return NONE5;
23074
+ const judged = checkoutOf2(input.cwd);
23075
+ const repo = judged ? commonDir(judged.root) : null;
23076
+ for (const target of targets) {
23077
+ const resolved = path30.resolve(target);
23078
+ if (within(resolved, UNKNOWN_VAR) || within(resolved, UNKNOWN_DIR))
23079
+ return judgeDeny(input, "it writes to a path Workit cannot resolve (a variable, a command substitution or `cd -`): spell the path out");
23080
+ if (inScratch(canonical4(target), repo))
23081
+ continue;
23082
+ const runner = runnerAt(target);
23083
+ return judgeDeny(input, runner === null ? `${shown(target)} is outside it` : `\`${runner}\` runs in ${shown(target)}, outside it`);
23084
+ }
23085
+ return NONE5;
23086
+ } catch {
23087
+ return NONE5;
23088
+ }
23089
+ }
23090
+ function confineJudgeShell(input, command, dialect = "posix") {
23091
+ try {
23092
+ if (!input.session.agentId)
23093
+ return NONE5;
23094
+ const fed = [];
23095
+ let refused;
23096
+ try {
23097
+ refused = dialect === "posix" ? judgeRefusal(command, fed) : null;
23098
+ } catch {
23099
+ refused = "Workit cannot read this command: split it into simpler ones";
23100
+ }
23101
+ if (refused)
23102
+ return judgeDeny(input, refused);
23103
+ if (dialect === "posix" && substitutingHeredoc(command))
23104
+ return judgeDeny(input, "an unquoted heredoc runs the `$(…)` or backtick command in its body: quote the delimiter (<<'EOF')");
23105
+ let git = [];
23106
+ try {
23107
+ git = rawInvocations(command, dialect).flatMap(({ tool, dir, args }) => tool === "git" && (args[0] === "push" || leadOwnedGit(args)) ? [
23108
+ path30.join(dir === undefined ? UNKNOWN_DIR : path30.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
23109
+ ] : []);
23110
+ } catch {}
23111
+ return confineJudge(input, [
23112
+ ...shellMutationTargets(input.cwd, command, dialect, true),
23113
+ ...fed.flatMap((body) => shellMutationTargets(input.cwd, body, "posix", true)),
23114
+ ...git
23115
+ ]);
23116
+ } catch {
23117
+ return NONE5;
23118
+ }
23119
+ }
22810
23120
 
22811
23121
  // packages/workit-core/src/hooks/steering.ts
22812
23122
  var ROLES = {
@@ -23380,7 +23690,7 @@ var usable2 = (value) => value === "native" || value === "partial";
23380
23690
  var NONE6 = { kind: "none" };
23381
23691
  var resendsOnChange = (descriptor) => descriptor.context.turnResend === "on-change" && usable2(descriptor.context.perTurn);
23382
23692
  var offered = new Set;
23383
- var implementerAgent = (input, descriptor) => Boolean(input.session.agentId) && input.session.agentType !== null && workitRole(descriptor, input.session.agentType) === "implementer";
23693
+ var agentRole = (input, descriptor) => input.session.agentId && input.session.agentType !== null ? workitRole(descriptor, input.session.agentType) : null;
23384
23694
  var LIMIT_TEXT_MAX = 1000;
23385
23695
  var usageLimitOnStop = (input, agentId, text) => {
23386
23696
  try {
@@ -23494,12 +23804,14 @@ function decide(input, deps) {
23494
23804
  unblock: null
23495
23805
  };
23496
23806
  }
23497
- if (canDeny && implementerAgent(input, descriptor)) {
23498
- const confined = confineImplementerShell(input, event.command, event.dialect);
23807
+ const role = canDeny ? agentRole(input, descriptor) : null;
23808
+ if (role) {
23809
+ const confined = (role === "implementer" ? confineImplementerShell : confineJudgeShell)(input, event.command, event.dialect);
23499
23810
  if (confined.kind === "deny")
23500
23811
  return confined;
23501
23812
  }
23502
- const gate = usable2(descriptor.events["write.pre"].support) ? shellGate(input.cwd, event.command, liveOwner(input, descriptor.transport), event.dialect) : NONE6;
23813
+ const owner = role === "judge" ? null : liveOwner(input, descriptor.transport);
23814
+ const gate = usable2(descriptor.events["write.pre"].support) ? shellGate(input.cwd, event.command, owner, event.dialect) : NONE6;
23503
23815
  if (gate.kind === "deny")
23504
23816
  return gate;
23505
23817
  const plan = heavyGate(input.cwd, event.command, {
@@ -23546,12 +23858,14 @@ function decide(input, deps) {
23546
23858
  case "write.pre": {
23547
23859
  if (!usable2(descriptor.events["write.pre"].support))
23548
23860
  return NONE6;
23549
- if (implementerAgent(input, descriptor)) {
23550
- const confined = confineImplementer(input, liveTargets(input.cwd, event.paths));
23861
+ const role = agentRole(input, descriptor);
23862
+ if (role) {
23863
+ const targets = liveTargets(input.cwd, event.paths);
23864
+ const confined = role === "implementer" ? confineImplementer(input, targets) : confineJudge(input, targets);
23551
23865
  if (confined.kind === "deny")
23552
23866
  return confined;
23553
23867
  }
23554
- return writeGate(input.cwd, event.paths, liveOwner(input, descriptor.transport));
23868
+ return writeGate(input.cwd, event.paths, role === "judge" ? null : liveOwner(input, descriptor.transport));
23555
23869
  }
23556
23870
  case "subagent.start":
23557
23871
  if (workitRole(descriptor, event.agentType) === "judge")
@@ -60,7 +60,7 @@ var quietEvent = () => {
60
60
  const tool = value.tool_name.toLowerCase();
61
61
  if (event === "PreToolUse" && WRITE_TOOLS.has(tool.replace(/[_-]/g, "")))
62
62
  return null;
63
- if (event === "PreToolUse" && value.agent_type === "workit-implementer")
63
+ if (event === "PreToolUse" && /^workit-(?:implementer|verifier|reviewer)$/.test(String(value.agent_type ?? "")))
64
64
  return null;
65
65
  const shell = SHELL_TOOLS.has(tool);
66
66
  const command = value.tool_input?.command;
@@ -84,7 +84,7 @@ if (quiet) {
84
84
  `);
85
85
  } else {
86
86
  try {
87
- const { runCodexHook } = await import("./workit-hook-1t5fcvt5.js");
87
+ const { runCodexHook } = await import("./workit-hook-z2g841xy.js");
88
88
  await runCodexHook([payload]);
89
89
  } catch (error) {
90
90
  const { answerRuntimeFailure } = await import("./workit-hook-ehy7rps6.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/codex",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "private": false,
5
5
  "description": "Workit Codex CLI/desktop plugin — shared MCP transport, hooks, method skills, and verifier/reviewer/implementer agents",
6
6
  "keywords": [
@@ -41,8 +41,8 @@
41
41
  "build": "bun scripts/build.ts"
42
42
  },
43
43
  "devDependencies": {
44
- "@workit-dev/core": "^1.2.0",
45
- "@workit-dev/mcp": "^1.2.0"
44
+ "@workit-dev/core": "^1.2.2",
45
+ "@workit-dev/mcp": "^1.2.2"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=24"