@brainervirus/workit-codex 8.22.1 → 8.22.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": "8.22.1",
3
+ "version": "8.22.2",
4
4
  "description": "Adaptive engineering workflow rails for Codex",
5
5
  "author": {
6
6
  "name": "BrainerVirus"
@@ -18236,9 +18236,17 @@ var sessionMarkerFile = (input, session, store) => {
18236
18236
  return path18.join(dir, "hooks", `skills-${name}.json`);
18237
18237
  };
18238
18238
  var list2 = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
18239
- var readSessionMarker = (file) => {
18239
+ var EMPTY = { nudged: [], loaded: [], raw: [], stops: [], judges: [] };
18240
+ var readRaw = (file) => {
18240
18241
  try {
18241
- const value = JSON.parse(fs14.readFileSync(file, "utf8"));
18242
+ return fs14.readFileSync(file, "utf8");
18243
+ } catch {
18244
+ return "";
18245
+ }
18246
+ };
18247
+ var parseMarker = (text) => {
18248
+ try {
18249
+ const value = JSON.parse(text);
18242
18250
  return {
18243
18251
  nudged: list2(value.nudged),
18244
18252
  loaded: list2(value.loaded),
@@ -18247,13 +18255,36 @@ var readSessionMarker = (file) => {
18247
18255
  judges: list2(value.judges)
18248
18256
  };
18249
18257
  } catch {
18250
- return { nudged: [], loaded: [], raw: [], stops: [], judges: [] };
18258
+ return { ...EMPTY };
18259
+ }
18260
+ };
18261
+ var readSessionMarker = (file) => parseMarker(readRaw(file));
18262
+ var writeAtomic = (file, marker) => {
18263
+ fs14.mkdirSync(path18.dirname(file), { recursive: true });
18264
+ const temp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
18265
+ try {
18266
+ fs14.writeFileSync(temp, JSON.stringify(marker));
18267
+ fs14.renameSync(temp, file);
18268
+ } catch (error) {
18269
+ fs14.rmSync(temp, { force: true });
18270
+ throw error;
18251
18271
  }
18252
18272
  };
18253
18273
  var writeSessionMarker = (file, marker) => {
18254
18274
  try {
18255
- fs14.mkdirSync(path18.dirname(file), { recursive: true });
18256
- fs14.writeFileSync(file, JSON.stringify(marker));
18275
+ writeAtomic(file, marker);
18276
+ } catch {}
18277
+ };
18278
+ var updateSessionMarker = (file, change) => {
18279
+ try {
18280
+ for (let attempt = 0;attempt < 2; attempt++) {
18281
+ const before = readRaw(file);
18282
+ const next = change(parseMarker(before));
18283
+ if (attempt === 0 && readRaw(file) !== before)
18284
+ continue;
18285
+ writeAtomic(file, next);
18286
+ return;
18287
+ }
18257
18288
  } catch {}
18258
18289
  };
18259
18290
  var trackJudge = (input, agentId, running) => {
@@ -18261,9 +18292,10 @@ var trackJudge = (input, agentId, running) => {
18261
18292
  const file = session && agentId ? sessionMarkerFile(input, session) : null;
18262
18293
  if (!file || !agentId)
18263
18294
  return;
18264
- const marker = readSessionMarker(file);
18265
- const rest = marker.judges.filter((id) => id !== agentId);
18266
- writeSessionMarker(file, { ...marker, judges: running ? [...rest, agentId] : rest });
18295
+ updateSessionMarker(file, (marker) => {
18296
+ const rest = marker.judges.filter((id) => id !== agentId);
18297
+ return { ...marker, judges: running ? [...rest, agentId] : rest };
18298
+ });
18267
18299
  };
18268
18300
 
18269
18301
  // packages/workit-core/src/hooks/shell-words.ts
@@ -19912,8 +19944,8 @@ var offPolicyPush = (action, repo, facts, remote) => {
19912
19944
  var nudgeFor = (action, host, session) => {
19913
19945
  switch (action.kind) {
19914
19946
  case "commit": {
19915
- const prefix = host === "cursor" && session ? `WORKIT_SESSION_ID=${session} ` : "";
19916
- return action.amend ? `workit: raw ${quote("git commit --amend")} is recorded for this session; for new commits prefer ${quote(`${prefix}workit git commit -m '<msg>'`)} (adds the Workit-Session trailer and checks branch and commit policy).` : `workit: prefer ${quote(`${prefix}workit git commit -m '<msg>' [--all | -- <paths>]`)}: it adds the Workit-Session trailer and checks branch and commit policy.`;
19947
+ const workit = host === "cursor" && session ? `workit --session ${session}` : "workit";
19948
+ return action.amend ? `workit: raw ${quote("git commit --amend")} is recorded for this session; for new commits prefer ${quote(`${workit} git commit -m '<msg>'`)} (adds the Workit-Session trailer and checks branch and commit policy).` : `workit: prefer ${quote(`${workit} git commit -m '<msg>' [--all | -- <paths>]`)}: it adds the Workit-Session trailer and checks branch and commit policy.`;
19917
19949
  }
19918
19950
  case "push":
19919
19951
  return action.blindForce ? `workit: ${quote("git push --force")} overwrites without a lease; use ${quote("workit git push --force-with-lease")}.` : `workit: prefer ${quote("workit git push")}: it refuses protected branches and verifies the remote tip.`;
@@ -20314,7 +20346,7 @@ var shellPolicy = (cwd, command, dialect = "posix") => {
20314
20346
  import fs16 from "node:fs";
20315
20347
  import os6 from "node:os";
20316
20348
  import path21 from "node:path";
20317
- var EMPTY = () => ({ deny: [], allow: [] });
20349
+ var EMPTY2 = () => ({ deny: [], allow: [] });
20318
20350
  var readText2 = (file) => {
20319
20351
  try {
20320
20352
  return fs16.readFileSync(file, "utf8");
@@ -20391,7 +20423,7 @@ var bashPattern = (entry) => {
20391
20423
  return match ? match[1] ?? "" : null;
20392
20424
  };
20393
20425
  function claudeRules(cwd, env = process.env) {
20394
- const rules = EMPTY();
20426
+ const rules = EMPTY2();
20395
20427
  try {
20396
20428
  for (const file of claudeSettingsFiles(cwd, env)) {
20397
20429
  const text = readText2(file);
@@ -20471,7 +20503,7 @@ var opencodeConfig = (value, rules) => {
20471
20503
  return Object.values(value.agent).every((agent) => isRecord3(agent) && opencodePermission(agent.permission, rules));
20472
20504
  };
20473
20505
  function opencodeRules(cwd, env = process.env) {
20474
- const rules = EMPTY();
20506
+ const rules = EMPTY2();
20475
20507
  try {
20476
20508
  const config = env.XDG_CONFIG_HOME || path21.join(homeOf(env), ".config");
20477
20509
  const files = [
@@ -20518,7 +20550,7 @@ var codexRule = (body) => {
20518
20550
  return { pattern: words.join(" "), decision };
20519
20551
  };
20520
20552
  function codexRules(cwd, env = process.env) {
20521
- const rules = EMPTY();
20553
+ const rules = EMPTY2();
20522
20554
  try {
20523
20555
  const home = env.CODEX_HOME || path21.join(homeOf(env), ".codex");
20524
20556
  const top = gitTop(cwd) ?? cwd;
@@ -20547,7 +20579,7 @@ function codexRules(cwd, env = process.env) {
20547
20579
  return rules;
20548
20580
  }
20549
20581
  function cursorRules(cwd, env = process.env) {
20550
- const rules = EMPTY();
20582
+ const rules = EMPTY2();
20551
20583
  try {
20552
20584
  const top = gitTop(cwd) ?? cwd;
20553
20585
  for (const file of [
@@ -21814,25 +21846,29 @@ var redChecks = (rows, pr, head, endpoint) => {
21814
21846
  reason: `PR #${pr}'s checks were last seen ${state} at ${short(head)}, and this workspace's endpoint is \`${endpoint}\`: run \`workit ci wait --pr ${pr}\`${state === "failing" ? " after fixing the failures `workit pr status` lists (then push)" : ""}.`
21815
21847
  };
21816
21848
  };
21817
- var highRisk = (cwd) => {
21849
+ var taskJudgment = (cwd) => {
21818
21850
  try {
21819
21851
  const store = new TaskStore(cwd);
21820
21852
  const listed = store.listTaskIndex();
21821
21853
  const key = store.currentKey();
21822
21854
  if (!listed.ok || !key.ok)
21823
- return false;
21855
+ return null;
21824
21856
  const entry = listed.data.filter((item) => item.key === key.data.key && item.status !== "closed").toSorted((left, right) => right.updatedAt.localeCompare(left.updatedAt))[0];
21825
21857
  const task = entry ? store.readTask(entry.id) : null;
21826
- return task?.ok === true && latestJudgment(task.data)?.riskTier === "high";
21858
+ return task?.ok === true ? latestJudgment(task.data) : null;
21827
21859
  } catch {
21828
- return false;
21860
+ return null;
21829
21861
  }
21830
21862
  };
21831
21863
  var unverified = (cwd, branch, all, descriptor, verification) => {
21832
21864
  const check = checkVerdicts(cwd, branch, all);
21833
21865
  if (check.accepted.accepted || check.accepted.reasons.includes("failing_verdict"))
21834
21866
  return null;
21835
- const independent = verification === "independent" || highRisk(cwd);
21867
+ const judgment = taskJudgment(cwd);
21868
+ const high = judgment?.riskTier === "high";
21869
+ if (judgment && !judgment.behaviorChange && !high)
21870
+ return null;
21871
+ const independent = verification === "independent" || high;
21836
21872
  if (!independent && check.review === "self-reviewed")
21837
21873
  return null;
21838
21874
  const has = check.review === "self-reviewed" ? "only a self verdict" : "no current verdict";
@@ -21903,7 +21939,7 @@ function stopDecision(input, descriptor) {
21903
21939
  if (file && marker) {
21904
21940
  if (marker.stops.includes(key))
21905
21941
  return NONE4;
21906
- writeSessionMarker(file, { ...marker, stops: [...marker.stops, key] });
21942
+ updateSessionMarker(file, (fresh) => ({ ...fresh, stops: [...fresh.stops, key] }));
21907
21943
  }
21908
21944
  return {
21909
21945
  kind: "continue",
@@ -23500,7 +23536,7 @@ var cursorAdapter = {
23500
23536
  };
23501
23537
  },
23502
23538
  render: render3,
23503
- addendum: (input) => input.session.id ? `<workit-session>Cursor puts no session id in the shell: prefix workit commands that record authorship with WORKIT_SESSION_ID=${input.session.id} (e.g. \`WORKIT_SESSION_ID=${input.session.id} workit git commit -m …\`). A verifier uses its own id, never this one.</workit-session>` : null
23539
+ addendum: (input) => input.session.id ? `<workit-session>Cursor puts no session id in the shell: start workit commands that record authorship with the global flag \`--session ${input.session.id}\` (e.g. \`workit --session ${input.session.id} git commit -m …\`; a leading env assignment can miss the \`Shell(workit)\` allowlist). A verifier uses its own id, never this one.</workit-session>` : null
23504
23540
  };
23505
23541
 
23506
23542
  // packages/workit-core/src/hooks/run.ts
@@ -47,6 +47,6 @@ if (quiet)
47
47
  process.stdout.write(`${JSON.stringify({ hookSpecificOutput: { hookEventName: quiet } })}
48
48
  `);
49
49
  else {
50
- const { runCodexHook } = await import("./workit-hook-gay8t9a5.js");
50
+ const { runCodexHook } = await import("./workit-hook-aq4zdwdp.js");
51
51
  await runCodexHook([payload]);
52
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brainervirus/workit-codex",
3
- "version": "8.22.1",
3
+ "version": "8.22.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": [
@@ -39,8 +39,8 @@
39
39
  "build": "bun scripts/build.ts"
40
40
  },
41
41
  "devDependencies": {
42
- "@brainervirus/workit-core": "^8.22.1",
43
- "@brainervirus/workit-mcp": "^8.22.1"
42
+ "@brainervirus/workit-core": "^8.22.2",
43
+ "@brainervirus/workit-mcp": "^8.22.2"
44
44
  },
45
45
  "engines": {
46
46
  "node": ">=24"