@workit-dev/codex 2.1.0 → 2.3.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workit",
3
- "version": "2.1.0",
3
+ "version": "2.3.0",
4
4
  "description": "Adaptive engineering workflow rails for Codex",
5
5
  "author": {
6
6
  "name": "BrainerVirus"
@@ -6,7 +6,7 @@ import {
6
6
  } from "./workit-hook-7jv519ep.js";
7
7
 
8
8
  // packages/workit-core/src/hooks/write-reach.ts
9
- import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
9
+ import { existsSync, readFileSync, readlinkSync, realpathSync, statSync } from "node:fs";
10
10
  import os from "node:os";
11
11
  import path from "node:path";
12
12
  var hasTaskStore = (cwd) => {
@@ -36,17 +36,36 @@ var hasTaskStore = (cwd) => {
36
36
  return true;
37
37
  }
38
38
  };
39
+ var LOST = "\x00lost";
39
40
  var reachTests = (dirs) => {
40
41
  const fold = (value) => dirs.fold ? value.toLowerCase() : value;
41
42
  const canon = (file) => {
43
+ let dir = path.resolve(file);
42
44
  let rest = "";
43
- for (let dir = path.resolve(file);; dir = path.dirname(dir)) {
45
+ for (let hops = 0;; ) {
44
46
  try {
45
47
  return fold(path.join(realpathSync.native(dir), rest));
46
48
  } catch {
47
- if (path.dirname(dir) === dir)
49
+ let link = null;
50
+ try {
51
+ const to = readlinkSync(dir);
52
+ let from = path.dirname(dir);
53
+ try {
54
+ from = realpathSync.native(from);
55
+ } catch {}
56
+ link = path.resolve(from, to);
57
+ } catch {}
58
+ if (link !== null) {
59
+ if (++hops > 40)
60
+ return LOST;
61
+ dir = path.join(link, rest);
62
+ rest = "";
63
+ } else if (path.dirname(dir) === dir)
48
64
  return fold(path.resolve(file));
49
- rest = rest ? path.join(path.basename(dir), rest) : path.basename(dir);
65
+ else {
66
+ rest = rest ? path.join(path.basename(dir), rest) : path.basename(dir);
67
+ dir = path.dirname(dir);
68
+ }
50
69
  }
51
70
  }
52
71
  };
@@ -56,7 +75,7 @@ var reachTests = (dirs) => {
56
75
  };
57
76
  const state = canon(dirs.state);
58
77
  const configs = dirs.configs.map(canon);
59
- const at = (file) => configs.some((dir) => within(dir, file)) || within(state, file) && /^(?:issued[^\\/]*|approvals)(?:[\\/]|$)/.test(path.relative(state, file));
78
+ const at = (file) => file === LOST || configs.some((dir) => within(dir, file)) || within(state, file) && /^(?:issued[^\\/]*|approvals)(?:[\\/]|$)/.test(path.relative(state, file));
60
79
  const above = (file) => within(file, state) || configs.some((dir) => within(file, dir));
61
80
  const linked = (file) => {
62
81
  try {
@@ -16392,6 +16392,7 @@ var tokenize = (command, dialect) => {
16392
16392
  let expanding = false;
16393
16393
  let afterOperator = false;
16394
16394
  let pending = null;
16395
+ let duplicate = false;
16395
16396
  const heredocs = [];
16396
16397
  const escape = posix ? "\\" : "`";
16397
16398
  const flushWord = () => {
@@ -16399,7 +16400,7 @@ var tokenize = (command, dialect) => {
16399
16400
  return;
16400
16401
  const text = MARKERS.test(word) ? literal2(word) : word;
16401
16402
  if (pending === "redirect") {
16402
- if (!text.startsWith("&"))
16403
+ if (!duplicate || !/^(?:\d+-?|-)$/.test(text))
16403
16404
  current.redirects.push(text);
16404
16405
  } else if (pending === "heredoc")
16405
16406
  heredocs.push({ delimiter: text.replace(/^-/, ""), owner: current });
@@ -16414,6 +16415,7 @@ var tokenize = (command, dialect) => {
16414
16415
  (current.expands ??= []).push(...current.words.slice(at).map((_, i) => at + i));
16415
16416
  }
16416
16417
  pending = null;
16418
+ duplicate = false;
16417
16419
  word = "";
16418
16420
  inWord = false;
16419
16421
  expanding = false;
@@ -16562,11 +16564,9 @@ var tokenize = (command, dialect) => {
16562
16564
  flushWord();
16563
16565
  if (command[index + 1] === ">")
16564
16566
  index++;
16565
- if (command[index + 1] === "&") {
16567
+ duplicate = command[index + 1] === "&";
16568
+ if (duplicate)
16566
16569
  index++;
16567
- word = "&";
16568
- inWord = true;
16569
- }
16570
16570
  pending = "redirect";
16571
16571
  } else if (char === "<" && posix) {
16572
16572
  flushWord();
@@ -19356,7 +19356,14 @@ var splitDenial = (plan) => ({
19356
19356
  unblock: plan.unblock
19357
19357
  });
19358
19358
  // packages/workit-core/src/hooks/write-gate.ts
19359
- import { existsSync as existsSync10, readdirSync as readdirSync3, readFileSync as readFileSync10, realpathSync as realpathSync7, statSync as statSync3 } from "node:fs";
19359
+ import {
19360
+ existsSync as existsSync10,
19361
+ readdirSync as readdirSync3,
19362
+ readFileSync as readFileSync10,
19363
+ readlinkSync as readlinkSync2,
19364
+ realpathSync as realpathSync7,
19365
+ statSync as statSync3
19366
+ } from "node:fs";
19360
19367
  import os8 from "node:os";
19361
19368
  import path29 from "node:path";
19362
19369
 
@@ -19564,21 +19571,44 @@ var claimLiveSession = (target, owner, deps = {}) => {
19564
19571
  // packages/workit-core/src/hooks/write-gate.ts
19565
19572
  var NONE3 = { kind: "none" };
19566
19573
  var CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "win32";
19567
- var canonical4 = (file) => {
19574
+ var linkTarget = (file) => {
19575
+ try {
19576
+ const to = readlinkSync2(file);
19577
+ let from = path29.dirname(file);
19578
+ try {
19579
+ from = realpathSync7.native(from);
19580
+ } catch {}
19581
+ return path29.resolve(from, to);
19582
+ } catch {
19583
+ return null;
19584
+ }
19585
+ };
19586
+ var realPath = (file, dangling = true) => {
19587
+ let dir = path29.resolve(file);
19568
19588
  let rest = "";
19569
- for (let dir = path29.resolve(file);; dir = path29.dirname(dir)) {
19589
+ for (let hops = 0;; ) {
19570
19590
  try {
19571
19591
  return path29.join(realpathSync7.native(dir), rest);
19572
19592
  } catch {
19573
- if (path29.dirname(dir) === dir)
19593
+ const link = dangling ? linkTarget(dir) : null;
19594
+ if (link !== null) {
19595
+ if (++hops > 40)
19596
+ return null;
19597
+ dir = path29.join(link, rest);
19598
+ rest = "";
19599
+ } else if (path29.dirname(dir) === dir)
19574
19600
  return path29.resolve(file);
19575
- rest = rest ? path29.join(path29.basename(dir), rest) : path29.basename(dir);
19601
+ else {
19602
+ rest = rest ? path29.join(path29.basename(dir), rest) : path29.basename(dir);
19603
+ dir = path29.dirname(dir);
19604
+ }
19576
19605
  }
19577
19606
  }
19578
19607
  };
19608
+ var canonical4 = (file, dangling = true) => realPath(file, dangling) ?? path29.resolve(file);
19579
19609
  var exempt = (cwd, root, file, plans) => {
19580
19610
  const fold = (value) => CASE_INSENSITIVE ? value.toLowerCase() : value;
19581
- const relative = path29.relative(fold(canonical4(root)), fold(canonical4(path29.resolve(cwd, file))));
19611
+ const relative = path29.relative(fold(canonical4(root, false)), fold(canonical4(path29.resolve(cwd, file), false)));
19582
19612
  if (relative.startsWith("..") || path29.isAbsolute(relative))
19583
19613
  return true;
19584
19614
  const posix = relative.split(path29.sep).join("/");
@@ -19616,6 +19646,7 @@ var editsOf = (input) => {
19616
19646
  case "rm":
19617
19647
  case "rmdir":
19618
19648
  case "tee":
19649
+ case "sponge":
19619
19650
  case "mv":
19620
19651
  case "truncate":
19621
19652
  return operands(args);
@@ -19702,7 +19733,7 @@ var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals)$/.test
19702
19733
  var READ_CALLS = /^(?:print|log|info|warn|error|debug|puts|readdir(?:Sync)?|listdir|scandir|iterdir|glob|l?stat(?:Sync)?|exists(?:Sync)?|isdir|isfile|is_dir|is_file|access(?:Sync)?|realpath(?:Sync)?|dirname|basename|relative|str|repr|len)$/;
19703
19734
  var MUTATING_CALLS = /^(?:renames?(?:Sync)?|move|copy(?:2|file|tree|File)?(?:Sync)?|cp(?:Sync)?|rm(?:tree|dir|Sync|dirSync)?|unlink(?:Sync)?|remove(?:dirs)?|mkdirs?(?:Sync)?|makedirs|mkdtemp(?:Sync)?|(?:sym|hard)?link(?:Sync|_to)?|write\w*|append\w*|truncate(?:Sync)?|ch(?:mod|own)(?:Sync)?|touch|open(?:Sync)?|dump|save|extractall|unpack_archive|put_contents|mv|FileUtils)$/;
19704
19735
  var PATH_CALLS = /^(?:join|resolve|normalize|abspath|expanduser|expandvars|Path|PurePath|fspath)$/;
19705
- var readsRoot = (text, at) => {
19736
+ var rootUse = (text, at) => {
19706
19737
  let call;
19707
19738
  for (let index = at, depth = 0;index > 0 && call === undefined; index--) {
19708
19739
  const char = text[index - 1];
@@ -19714,10 +19745,10 @@ var readsRoot = (text, at) => {
19714
19745
  break;
19715
19746
  }
19716
19747
  if (call !== undefined && READ_CALLS.test(call))
19717
- return true;
19748
+ return "reads";
19718
19749
  if (call !== undefined && !PATH_CALLS.test(call))
19719
- return false;
19720
- return ![...text.matchAll(/([\w$]+)\s*\(/g)].some(([, name]) => MUTATING_CALLS.test(name));
19750
+ return "takes";
19751
+ return [...text.matchAll(/([\w$]+)\s*\(/g)].some(([, name]) => MUTATING_CALLS.test(name)) ? "builds" : "reads";
19721
19752
  };
19722
19753
  var inertEdit = (command) => command.split("|").every((part) => /^:?(?:se(?:t)?|sy(?:ntax)?|colo(?:rscheme)?)(?:\s|$)|^[/?][^/?]*[/?]?$|^\d+$/.test(part.trim()));
19723
19754
  var SCRIPT_OPTIONS = [
@@ -19731,12 +19762,15 @@ var SCRIPT_OPTIONS = [
19731
19762
  var PRELOAD = /^(?:-r|--(?:require|import|(?:experimental-)?loader|preload|rcfile|init-file))$/;
19732
19763
  var scriptArgs = (verb, args) => {
19733
19764
  const takes = SCRIPT_OPTIONS.find(([family]) => family.test(verb))?.[1] ?? /^$/;
19765
+ const shell = SCRIPT_OPTIONS[0][0].test(verb);
19734
19766
  const preloads = [];
19735
19767
  for (let at = 0;at < args.length; at++) {
19736
19768
  const [option, value] = args[at].split(/=(.*)/s);
19737
19769
  if (value !== undefined && PRELOAD.test(option))
19738
19770
  preloads.push(value);
19739
- else if (/^-[mce]$|^--(?:eval|print)$/.test(option))
19771
+ else if (/^-[mce]$|^--(?:eval|print)$|^-$/.test(option))
19772
+ break;
19773
+ else if (shell && /^-[a-zA-Z]*s[a-zA-Z]*$/.test(option))
19740
19774
  break;
19741
19775
  else if (takes.test(option)) {
19742
19776
  if (PRELOAD.test(option))
@@ -20102,6 +20136,7 @@ var DRY_N = new Set(["add", "clean", "rm", "mv"]);
20102
20136
  var MUTATING_WORKIT_GIT = new Set(["commit", "branch", "stage", "unstage"]);
20103
20137
  var DIR_TARGET = ".workit-live-target";
20104
20138
  var OPAQUE_TARGET = ".workit-runs-";
20139
+ var UNRESOLVED_TARGET = ".workit-unresolved-target";
20105
20140
  var OVERRIDE = "WORKIT_LIVE_SESSION=override";
20106
20141
  var inert = (args, sub) => args.some((arg) => arg === "--help" || arg === "-h" || arg === "--dry-run" || DRY_N.has(sub) && /^-[a-zA-Z]*n[a-zA-Z]*$/.test(arg) && !arg.startsWith("--"));
20107
20142
  var gitMutationDirs = (cwd, command, dialect) => {
@@ -20567,9 +20602,11 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
20567
20602
  ...[...text.matchAll(PATHS)].flatMap(({ 0: word, index }) => [...atAll(word), ...under(word)].map((file) => ({ file, index }))),
20568
20603
  ...joined.flatMap(({ word, index }) => under(word).map((file) => ({ file, index })))
20569
20604
  ];
20570
- for (const { file, index } of found)
20571
- if (!isRoot(file) || !readsRoot(text, index))
20572
- targets.push(file);
20605
+ for (const { file, index } of found) {
20606
+ const use = isRoot(file) ? rootUse(text, index) : "takes";
20607
+ if (use !== "reads")
20608
+ targets.push(use === "builds" ? path29.join(file, UNRESOLVED_TARGET) : file);
20609
+ }
20573
20610
  }
20574
20611
  if (/^(?:n?vim?|ex|ed|emacs)$/.test(verb) && (segment.stdin || inputs.length > 0 || feeder || args.some((arg, index) => /^(?:-[a-zA-Z]*[se]|--(?:batch|eval|script))$/.test(arg) || /^(?:-c|--cmd)$/.test(arg) && !inertEdit(args[index + 1] ?? "") || arg.startsWith("+") && !inertEdit(arg.slice(1) || "1"))))
20575
20612
  for (const file of operands(args))
@@ -20775,6 +20812,8 @@ var registryTarget = (cwd, targets) => {
20775
20812
  const inodes = {};
20776
20813
  for (const target of targets) {
20777
20814
  const file = homeExpanded(target);
20815
+ if (realPath(path29.resolve(cwd, file)) === null)
20816
+ return { file: target, registry: "link" };
20778
20817
  const glob = globbed(cwd, file, state, configs)[0];
20779
20818
  const viaGlob = glob === undefined ? null : registryTarget(cwd, [glob]);
20780
20819
  if (viaGlob)
@@ -20801,7 +20840,7 @@ var underRegistry = (state, cwd, target, platform = process.platform, real = (fi
20801
20840
  };
20802
20841
  var underConfig = (dir, cwd, target, platform = process.platform, real = (file) => file) => {
20803
20842
  const parts = partsUnder(dir, cwd, target, platform, real);
20804
- return parts?.length === 1 && ["", ...CONFIG_FILES, DIR_TARGET].includes(parts[0]);
20843
+ return parts?.length === 1 && ["", ...CONFIG_FILES, DIR_TARGET, UNRESOLVED_TARGET].includes(parts[0]);
20805
20844
  };
20806
20845
  var unquotedWindowsRegistry = (command, platform = process.platform) => {
20807
20846
  if (platform !== "win32" || !command.includes("\\"))
@@ -20826,6 +20865,11 @@ var unquotedWindowsRegistry = (command, platform = process.platform) => {
20826
20865
  return writes.writes && (writes.targets === null || writes.targets.some(named)) ? registry : null;
20827
20866
  };
20828
20867
  var REGISTRY_DENY = {
20868
+ link: {
20869
+ label: "registry guard",
20870
+ what: "a symlink chain Workit could not resolve (over 40 links), which may reach a guarded path",
20871
+ unblock: "Write to the file's real path."
20872
+ },
20829
20873
  issued: {
20830
20874
  label: "issued-registry guard",
20831
20875
  what: "Workit's issued-session state",
@@ -20844,6 +20888,12 @@ var REGISTRY_DENY = {
20844
20888
  };
20845
20889
  var registryDeny = ({ file, registry }) => {
20846
20890
  const { label, what, unblock } = REGISTRY_DENY[registry];
20891
+ if (path29.basename(file) === UNRESOLVED_TARGET)
20892
+ return {
20893
+ kind: "deny",
20894
+ reason: `workit ${label}: Workit could not resolve the file this command's script writes, which it builds from a path under ${what}. ${unblock}`,
20895
+ unblock
20896
+ };
20847
20897
  const named = path29.basename(file).startsWith(".workit-") ? path29.dirname(file) : file;
20848
20898
  return {
20849
20899
  kind: "deny",
@@ -39,7 +39,7 @@ var { configDir } = await import("./workit-hook-z09frbdk.js");
39
39
  var { standingPending } = await import("./workit-hook-mk64s4fk.js");
40
40
  var { recordHookRun } = await import("./workit-hook-zyj0kzc5.js");
41
41
  var { observeHookBudget } = await import("./workit-hook-3g6cv3hd.js");
42
- var { hasTaskStore, mayReach } = await import("./workit-hook-8da7z381.js");
42
+ var { hasTaskStore, mayReach } = await import("./workit-hook-7dwf87hc.js");
43
43
  var YTRACK_WORD = /ytrack(?![\w/-]|\.(?!exe|cmd))/i;
44
44
  var namesYtrack = (text) => {
45
45
  const bare = text.replace(/['"\\]/g, "");
@@ -84,7 +84,7 @@ var quietEvent = () => {
84
84
  return null;
85
85
  if (event === "PostToolUse")
86
86
  return /\bcommit\b/.test(text) ? null : event;
87
- const writes = /\b(?:git|gh|glab)\b|>|\b(?:tee|touch|mkdir|rm|rmdir|mv|cp|truncate|install|ln|patch|dd|sed|perl|set-content|add-content|out-file|new-item|ni|remove-item|del|copy-item|move-item)\b/i.test(text.replace(/\d*>&(?:\d+|-)(?![^\s;&|()<>])|[\d&]*>>?\s*\/dev\/(?:null|stdout|stderr|tty)(?![^\s;&|()<>])/g, " "));
87
+ const writes = /\b(?:git|gh|glab)\b|>|\b(?:tee|sponge|touch|mkdir|rm|rmdir|mv|cp|truncate|install|ln|patch|dd|sed|perl|set-content|add-content|out-file|new-item|ni|remove-item|del|copy-item|move-item)\b/i.test(text.replace(/\d*>&(?:\d+|-)(?![^\s;&|()<>])|[\d&]*>>?\s*\/dev\/(?:null|stdout|stderr|tty)(?![^\s;&|()<>])/g, " "));
88
88
  return /\b(?:git|gh|glab|node|tsx|ts-node|bash|sh|zsh|dash|ksh|ruby|perl|php|source)\b|(?:^|[;&|(\n])\s*(?:\w+=\S*\s+)*(?:(?:time|exec|sudo|nice|nohup|env|command|builtin|timeout|stdbuf|if|then|do|while|until|!)\s+(?:-\S+\s+|\d\S*\s+)*)*(?:\.\s+\S|\.{0,2}\/)/.test(text) || guarded(text) || namesYtrack(text) || mayRunUserOnly(text) || writes && (process.platform === "win32" || hasTaskStore(value.cwd)) || mayReach(text, value.cwd) || maybeHeavy(text, value.cwd) ? null : event;
89
89
  } catch {
90
90
  return null;
@@ -98,7 +98,7 @@ if (quiet) {
98
98
  `);
99
99
  } else {
100
100
  try {
101
- const { runCodexHook } = await import("./workit-hook-6vxn9800.js");
101
+ const { runCodexHook } = await import("./workit-hook-qc9gv46t.js");
102
102
  await runCodexHook([payload]);
103
103
  } catch (error) {
104
104
  const { answerRuntimeFailure } = await import("./workit-hook-9k8dtngs.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/codex",
3
- "version": "2.1.0",
3
+ "version": "2.3.0",
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": "^2.1.0",
45
- "@workit-dev/mcp": "^2.1.0"
44
+ "@workit-dev/core": "^2.3.0",
45
+ "@workit-dev/mcp": "^2.3.0"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=24"