@workit-dev/codex 1.5.1 → 1.6.1

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.5.1",
3
+ "version": "1.6.1",
4
4
  "description": "Adaptive engineering workflow rails for Codex",
5
5
  "author": {
6
6
  "name": "BrainerVirus"
@@ -30586,6 +30586,10 @@ var writeTargets = (input) => {
30586
30586
  const paths = writePaths(input);
30587
30587
  return paths.length > 0 ? paths : null;
30588
30588
  };
30589
+ // packages/workit-core/src/approvals/store.ts
30590
+ var REQUEST_TTL_MS = 30 * 60000;
30591
+ var GRANT_TTL_MS = 15 * 60000;
30592
+
30589
30593
  // packages/workit-core/src/hooks/hosts/claude-code.ts
30590
30594
  var CLAUDE_CODE_DESCRIPTOR = {
30591
30595
  host: "claude_code",
@@ -30627,7 +30631,11 @@ var CLAUDE_CODE_DESCRIPTOR = {
30627
30631
  maxConcurrency: "undocumented",
30628
30632
  agentPrefix: "workit:"
30629
30633
  },
30630
- provenance: { sessionId: "native", agentIdOnTool: "native", postToolObserve: "native" },
30634
+ provenance: {
30635
+ sessionId: "native",
30636
+ agentIdOnTool: "native",
30637
+ postToolObserve: "native"
30638
+ },
30631
30639
  interaction: { questions: "undocumented", writeBoundary: "partial" },
30632
30640
  stopControl: "native",
30633
30641
  shellAvailable: "native",
@@ -30689,6 +30697,7 @@ var CONTEXT_EVENTS = new Set([
30689
30697
  "PreToolUse",
30690
30698
  "PostToolUse"
30691
30699
  ]);
30700
+ var ASKING_MODES = new Set(["default", "acceptEdits", "plan"]);
30692
30701
 
30693
30702
  // packages/workit-core/src/hooks/hosts/codex.ts
30694
30703
  function detectCodexSurface(env) {
@@ -18897,7 +18897,10 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
18897
18897
  continue;
18898
18898
  const action = rawAction(invocation);
18899
18899
  const at = !action ? null : repoFor(invocation.dir) ?? (all && invocation.tool !== "git" && explicitRepo(invocation.tool === "gh", "repo" in action && action.repo || "", invocation.env ?? {}) ? {
18900
- repo: { dir: path23.resolve(cwd, invocation.dir ?? "."), branch: null },
18900
+ repo: {
18901
+ dir: path23.resolve(cwd, invocation.dir ?? "."),
18902
+ branch: null
18903
+ },
18901
18904
  workit: false
18902
18905
  } : null);
18903
18906
  if (action && at)
@@ -18944,6 +18947,109 @@ var pkillSelfMatch = (command, dialect) => {
18944
18947
  }
18945
18948
  return null;
18946
18949
  };
18950
+ var policyDeclared = () => {
18951
+ try {
18952
+ return !!readConfigTyped().config?.branchPolicy?.protected?.length;
18953
+ } catch {
18954
+ return false;
18955
+ }
18956
+ };
18957
+ var word = (text) => /^[\w./@%+:,=-]+$/u.test(text) ? text : shellQuote(text);
18958
+ var HEREDOC = /^cat <<(['"])(\w+)\1\n([\s\S]*)\n\2\n?$/u;
18959
+ var messageOf = (segment, index) => {
18960
+ const text = segment.words[index];
18961
+ if (text === undefined)
18962
+ return null;
18963
+ if (!segment.expands?.includes(index))
18964
+ return text;
18965
+ const sub = segment.subs?.find((each) => text === `$(${each})`);
18966
+ const match = sub === undefined ? null : HEREDOC.exec(sub);
18967
+ if (!match || match[3].split(`
18968
+ `).includes(match[2]))
18969
+ return null;
18970
+ return match[3].replace(/\n+$/u, "");
18971
+ };
18972
+ var cdCommitCall = (input, command, target, repo) => {
18973
+ const { top, git, dir: store } = repo.location;
18974
+ if (!top || !git || git.gitDir === path23.dirname(store) || repoAt(input.cwd)?.location.top === top)
18975
+ return null;
18976
+ const bare = command.replaceAll(/'[^']*'|"(?:[^"\\]|\\.)*"/gu, "").replaceAll("&&", "");
18977
+ if (/[;|&<>`$()\n\\]/u.test(bare))
18978
+ return null;
18979
+ const [cd, ...rest] = segmentsOf(command);
18980
+ const commit = rest.at(-1);
18981
+ if (cd?.words[0] !== "cd" || cd.words.length !== 2 || cd.expands?.length || !commit)
18982
+ return null;
18983
+ if (path23.resolve(input.cwd, cd.words[1]) !== target)
18984
+ return null;
18985
+ if (rest.some((each) => each.redirects.length || each.stdin?.length || each.group))
18986
+ return null;
18987
+ const adds = rest.slice(0, -1);
18988
+ if (!adds.length || commit.words[0] !== "git" || commit.words[1] !== "commit")
18989
+ return null;
18990
+ const paths = [];
18991
+ let all = false;
18992
+ for (const add of adds) {
18993
+ const [tool, verb, ...args] = add.words;
18994
+ if (tool !== "git" || verb !== "add" || add.expands?.length || add.subs?.length)
18995
+ return null;
18996
+ const named = args.filter((arg) => !["-A", "--all", "--"].includes(arg));
18997
+ if (named.some((arg) => arg.startsWith("-") || /[*?[\]]/u.test(arg)))
18998
+ return null;
18999
+ if (!named.length && !args.some((arg) => arg === "-A" || arg === "--all"))
19000
+ return null;
19001
+ if (named.length)
19002
+ paths.push(...named);
19003
+ else
19004
+ all = true;
19005
+ }
19006
+ const messages = [];
19007
+ let allowEmpty = false;
19008
+ for (let index = 2;index < commit.words.length; index++) {
19009
+ const arg = commit.words[index];
19010
+ let message = null;
19011
+ if (arg === "--allow-empty") {
19012
+ allowEmpty = true;
19013
+ continue;
19014
+ }
19015
+ if (arg === "-m" || arg === "--message")
19016
+ message = messageOf(commit, ++index);
19017
+ else if (!commit.expands?.includes(index) && /^(?:-m|--message=)./u.test(arg))
19018
+ message = arg.replace(/^(?:-m|--message=)/u, "");
19019
+ if (!message || message.startsWith("-"))
19020
+ return null;
19021
+ messages.push(message);
19022
+ }
19023
+ if (!messages.length)
19024
+ return null;
19025
+ if (!all) {
19026
+ const staged = spawnSync12("git", ["diff", "--cached", "--quiet"], {
19027
+ cwd: target,
19028
+ timeout: 5000
19029
+ });
19030
+ if (staged.status !== 0)
19031
+ return null;
19032
+ }
19033
+ return [
19034
+ `workit git --cwd ${word(target)} commit`,
19035
+ ...messages.map((message) => `-m ${shellQuote(message)}`),
19036
+ ...allowEmpty ? ["--allow-empty"] : [],
19037
+ all ? "--all" : `-- ${[...new Set(paths)].map(word).join(" ")}`
19038
+ ].join(" ");
19039
+ };
19040
+ var commitRefusal = (input, command, dialect, { action, repo, invocation, workit }) => {
19041
+ if (action.kind !== "commit" || !(workit || policyDeclared()))
19042
+ return null;
19043
+ const switches = workitInvocations(command, dialect).length > 0 || rawInvocations(command, dialect).some((raw) => ["switch", "checkout", "worktree"].includes(raw.args[0] ?? ""));
19044
+ let guarded = false;
19045
+ try {
19046
+ guarded = !!repo.branch && resolveBranchPolicyFor(repo.dir).protected.has(repo.branch.toLowerCase());
19047
+ } catch {}
19048
+ if (guarded && !switches)
19049
+ return `workit: raw ${quote("git commit")} on ${repo.branch}, a protected branch. Branch first: ${quote("workit git branch --kind feature --slug <slug>")} (uncommitted changes come along), then ${quote("workit git commit -m '<msg>' -- <paths>")}.`;
19050
+ const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command, path23.resolve(input.cwd, invocation.dir), repo);
19051
+ return call && `workit: no ${quote("cd … &&")} chain; run ${quote(call)}.`;
19052
+ };
18947
19053
  function rawGitPre(input, command, options = {}) {
18948
19054
  try {
18949
19055
  const dialect = dialectOf(input);
@@ -18959,6 +19065,11 @@ function rawGitPre(input, command, options = {}) {
18959
19065
  if (refused)
18960
19066
  return deny(refused);
18961
19067
  }
19068
+ for (const found of located) {
19069
+ const refused = commitRefusal(input, command, dialect, found);
19070
+ if (refused)
19071
+ return deny(refused);
19072
+ }
18962
19073
  for (const { action, repo, invocation, workit } of located) {
18963
19074
  if (!workit)
18964
19075
  continue;
@@ -19365,7 +19476,8 @@ var WORKIT_USER_ONLY = [
19365
19476
  ["release", "notes", "approve"],
19366
19477
  ["grant", "set"],
19367
19478
  ["grant", "raise"],
19368
- ["ledger", "void"]
19479
+ ["ledger", "void"],
19480
+ ["approve"]
19369
19481
  ];
19370
19482
  var ALLOWED = new Set(WORKIT_ALLOWED_VERBS);
19371
19483
  var hasWordsInOrder = (words, needle) => {
@@ -21137,7 +21249,12 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
21137
21249
  };
21138
21250
  for (const segment of segments) {
21139
21251
  if (segment.group === "open") {
21140
- groups.push({ dir, stack: [...stack], vars: new Map(vars), loops: new Map(loops) });
21252
+ groups.push({
21253
+ dir,
21254
+ stack: [...stack],
21255
+ vars: new Map(vars),
21256
+ loops: new Map(loops)
21257
+ });
21141
21258
  continue;
21142
21259
  }
21143
21260
  if (segment.group === "close") {
@@ -21345,39 +21462,60 @@ var claimAll = (owner, targets, deps) => {
21345
21462
  claimLiveSession(target, owner, deps);
21346
21463
  };
21347
21464
  var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path28.resolve(cwd, file)) : [path28.join(cwd, DIR_TARGET)];
21348
- var issuedTarget = (cwd, targets) => {
21465
+ var registryTarget = (cwd, targets) => {
21349
21466
  const state = resolveStateDir();
21350
- const found = targets.find((target) => underIssued(state, cwd, homeExpanded(target), process.platform, canonical3));
21351
- return found ?? null;
21467
+ for (const target of targets) {
21468
+ const registry = underRegistry(state, cwd, homeExpanded(target), process.platform, canonical3);
21469
+ if (registry)
21470
+ return { file: target, registry };
21471
+ }
21472
+ return null;
21352
21473
  };
21353
- var underIssued = (state, cwd, target, platform = process.platform, real = (file) => file) => {
21474
+ var underRegistry = (state, cwd, target, platform = process.platform, real = (file) => file) => {
21354
21475
  const win = platform === "win32";
21355
21476
  const p = win ? path28.win32 : path28.posix;
21356
21477
  const fold = (value) => win || platform === "darwin" ? value.toLowerCase() : value;
21357
21478
  const named = win ? target.replace(/^\/([a-zA-Z])(?=\/|$)/, "$1:") : target;
21358
21479
  const relative = p.relative(fold(real(p.resolve(state))), fold(real(p.resolve(cwd, named))));
21359
21480
  if (relative.startsWith("..") || p.isAbsolute(relative))
21360
- return false;
21361
- return relative.split(p.sep)[0].startsWith("issued");
21481
+ return null;
21482
+ const first = relative.split(p.sep)[0];
21483
+ if (first.startsWith("issued"))
21484
+ return "issued";
21485
+ return first === "approvals" ? "approvals" : null;
21362
21486
  };
21363
- var unquotedWindowsIssued = (command) => {
21487
+ var unquotedWindowsRegistry = (command) => {
21364
21488
  if (process.platform !== "win32" || !command.includes("\\"))
21365
- return false;
21489
+ return null;
21366
21490
  const flat = (value) => value.replaceAll("\\", "/").toLowerCase();
21367
- return flat(command).includes(`${flat(resolveStateDir())}/issued`) && shellWrites(command).writes;
21491
+ const text = flat(command);
21492
+ const state = flat(resolveStateDir());
21493
+ const registry = text.includes(`${state}/issued`) ? "issued" : text.includes(`${state}/approvals`) ? "approvals" : null;
21494
+ return registry && shellWrites(command).writes ? registry : null;
21495
+ };
21496
+ var REGISTRY_DENY = {
21497
+ issued: {
21498
+ label: "issued-registry guard",
21499
+ unblock: "Issued ids and tokens are written only by Workit's SubagentStart hook. Run the verifier or reviewer agent so the host issues its own session; never edit the issued registries by hand."
21500
+ },
21501
+ approvals: {
21502
+ label: "approvals guard",
21503
+ unblock: "Approval requests and the user's yes are written only by Workit: run `workit approve <id>` as its own call so the host asks the user, or ask the user to run it in their own terminal; never edit the approvals registry by hand."
21504
+ }
21368
21505
  };
21369
- var issuedDeny = (file) => {
21370
- const unblock = "Issued ids and tokens are written only by Workit's SubagentStart hook. Run the verifier or reviewer agent so the host issues its own session; never edit the issued registries by hand.";
21506
+ var registryDeny = ({ file, registry }) => {
21507
+ const { label, unblock } = REGISTRY_DENY[registry];
21508
+ const what = registry === "issued" ? "issued-session state" : "host-approval state";
21371
21509
  return {
21372
21510
  kind: "deny",
21373
- reason: `workit issued-registry guard: ${file} is under Workit's issued-session state. ${unblock}`,
21511
+ reason: `workit ${label}: ${file} is under Workit's ${what}. ${unblock}`,
21374
21512
  unblock
21375
21513
  };
21376
21514
  };
21377
21515
  function writeGate(cwd, paths, owner, deps) {
21378
- const forged = paths?.length ? issuedTarget(cwd, paths) : null;
21516
+ const forged = paths?.length ? registryTarget(cwd, paths) : null;
21379
21517
  if (forged)
21380
- return issuedDeny(forged);
21518
+ return registryDeny(forged);
21381
21519
  if (!owner)
21382
21520
  return beforeWriteGate(cwd, paths);
21383
21521
  const targets = liveTargets(cwd, paths);
@@ -21391,9 +21529,10 @@ function writeGate(cwd, paths, owner, deps) {
21391
21529
  }
21392
21530
  function shellGate(cwd, command, owner, dialect = "posix", deps) {
21393
21531
  try {
21394
- const forged = issuedTarget(cwd, segmentTargets(cwd, command, dialect)) ?? (unquotedWindowsIssued(command) ? "the issued registry" : null);
21532
+ const windows = unquotedWindowsRegistry(command);
21533
+ const forged = registryTarget(cwd, segmentTargets(cwd, command, dialect)) ?? (windows ? { file: `the ${windows} registry`, registry: windows } : null);
21395
21534
  if (forged)
21396
- return issuedDeny(forged);
21535
+ return registryDeny(forged);
21397
21536
  } catch {}
21398
21537
  const writes = shellWrites(command);
21399
21538
  let targets = [];
@@ -22027,6 +22166,10 @@ var writeTargets = (input) => {
22027
22166
  import fs22 from "node:fs";
22028
22167
  import path32 from "node:path";
22029
22168
 
22169
+ // packages/workit-core/src/approvals/store.ts
22170
+ var REQUEST_TTL_MS = 30 * 60000;
22171
+ var GRANT_TTL_MS = 15 * 60000;
22172
+
22030
22173
  // packages/workit-core/src/hooks/hosts/claude-code.ts
22031
22174
  var CLAUDE_CODE_DESCRIPTOR = {
22032
22175
  host: "claude_code",
@@ -22068,7 +22211,11 @@ var CLAUDE_CODE_DESCRIPTOR = {
22068
22211
  maxConcurrency: "undocumented",
22069
22212
  agentPrefix: "workit:"
22070
22213
  },
22071
- provenance: { sessionId: "native", agentIdOnTool: "native", postToolObserve: "native" },
22214
+ provenance: {
22215
+ sessionId: "native",
22216
+ agentIdOnTool: "native",
22217
+ postToolObserve: "native"
22218
+ },
22072
22219
  interaction: { questions: "undocumented", writeBoundary: "partial" },
22073
22220
  stopControl: "native",
22074
22221
  shellAvailable: "native",
@@ -22130,6 +22277,7 @@ var CONTEXT_EVENTS = new Set([
22130
22277
  "PreToolUse",
22131
22278
  "PostToolUse"
22132
22279
  ]);
22280
+ var ASKING_MODES = new Set(["default", "acceptEdits", "plan"]);
22133
22281
 
22134
22282
  // packages/workit-core/src/hooks/hosts/codex.ts
22135
22283
  function detectCodexSurface(env) {
@@ -23768,7 +23916,11 @@ var usageLimitOnStop = (input, agentId, text) => {
23768
23916
  return;
23769
23917
  if (!firstSighting(`subagent-stop:${input.session.id}:${agentId ?? ""}`))
23770
23918
  return;
23771
- recordUsageLimit(text, { cwd: input.cwd, host: input.host, model: input.model ?? null });
23919
+ recordUsageLimit(text, {
23920
+ cwd: input.cwd,
23921
+ host: input.host,
23922
+ model: input.model ?? null
23923
+ });
23772
23924
  } catch {}
23773
23925
  };
23774
23926
  var subagentSession = (session, agentId) => [session, agentId].filter((part) => Boolean(part)).join(":").replace(/[^A-Za-z0-9_.:@/+-]/g, "-").slice(0, 128);
@@ -23864,9 +24016,6 @@ function decide(input, deps) {
23864
24016
  const postTool = usable2(descriptor.events["shell.post"].support);
23865
24017
  if (!postTool)
23866
24018
  settlePendingCommit(input);
23867
- const raw = canDeny ? rawGitPre(input, event.command, { nudge: false }) : NONE6;
23868
- if (raw.kind === "deny")
23869
- return raw;
23870
24019
  const userOnly = userOnlyWorkitCall(event.command, event.dialect);
23871
24020
  if (userOnly) {
23872
24021
  if (input.host === "claude_code")
@@ -23887,6 +24036,9 @@ function decide(input, deps) {
23887
24036
  if (confined.kind === "deny")
23888
24037
  return confined;
23889
24038
  }
24039
+ const raw = canDeny ? rawGitPre(input, event.command, { nudge: false }) : NONE6;
24040
+ if (raw.kind === "deny")
24041
+ return raw;
23890
24042
  const owner = role === "judge" ? null : liveOwner(input, descriptor.transport);
23891
24043
  const gate = usable2(descriptor.events["write.pre"].support) ? shellGate(input.cwd, event.command, owner, event.dialect) : NONE6;
23892
24044
  if (gate.kind === "deny")
@@ -23949,7 +24101,11 @@ function decide(input, deps) {
23949
24101
  trackJudge(input, event.agentId, true);
23950
24102
  seedStanding({
23951
24103
  ...input,
23952
- session: { ...input.session, agentId: event.agentId, agentType: event.agentType }
24104
+ session: {
24105
+ ...input.session,
24106
+ agentId: event.agentId,
24107
+ agentType: event.agentType
24108
+ }
23953
24109
  });
23954
24110
  deps.budget?.start(input, event.agentId, event.agentType);
23955
24111
  return {
@@ -84,7 +84,7 @@ if (quiet) {
84
84
  `);
85
85
  } else {
86
86
  try {
87
- const { runCodexHook } = await import("./workit-hook-t6n924zv.js");
87
+ const { runCodexHook } = await import("./workit-hook-n63mrn52.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.5.1",
3
+ "version": "1.6.1",
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.5.1",
45
- "@workit-dev/mcp": "^1.5.1"
44
+ "@workit-dev/core": "^1.6.1",
45
+ "@workit-dev/mcp": "^1.6.1"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=24"