@workit-dev/codex 2.20.1 → 2.20.3

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.20.1",
3
+ "version": "2.20.3",
4
4
  "description": "Adaptive engineering workflow rails for Codex",
5
5
  "author": {
6
6
  "name": "BrainerVirus"
@@ -21025,7 +21025,23 @@ function runsByGlob(command, name) {
21025
21025
  const tokens = command.split(/\s+/u).map((token) => token.replace(/^--filter=/u, "").replaceAll(/^["']|["']$/gu, "").replace(/^(?:npm|pnpm|yarn|bun):/u, ""));
21026
21026
  if (/\bpnpm\b/u.test(command) && tokens.some((token) => /^\/.+\/$/u.test(token)))
21027
21027
  return true;
21028
- return tokens.filter((token) => token.includes("*")).some((glob) => new RegExp(`^${glob.split(/\*+/u).map((part) => part.replaceAll(/[.+?^${}()|[\]\\]/gu, "\\$&")).join(".*")}$`, "u").test(name));
21028
+ return tokens.filter((token) => token.includes("*")).some((glob) => globMatches(glob, name));
21029
+ }
21030
+ function globMatches(glob, name) {
21031
+ const parts = glob.split("*");
21032
+ const first = parts[0];
21033
+ const last = parts.at(-1) ?? "";
21034
+ const end = name.length - last.length;
21035
+ if (end < first.length || !name.startsWith(first) || !name.endsWith(last))
21036
+ return false;
21037
+ let at = first.length;
21038
+ for (const part of parts.slice(1, -1)) {
21039
+ const found = name.indexOf(part, at);
21040
+ if (found < 0 || found + part.length > end)
21041
+ return false;
21042
+ at = found + part.length;
21043
+ }
21044
+ return true;
21029
21045
  }
21030
21046
  function goDirectives(text) {
21031
21047
  const out = [];
@@ -31303,6 +31319,7 @@ var WORKIT_USER_ONLY = [
31303
31319
  var WORKIT_ASKED_VERBS = ["feedback"];
31304
31320
  var USER_ONLY_WORD = new RegExp(`\\b(?:${[...new Set([...WORKIT_USER_ONLY.map((words) => words[0]), ...WORKIT_ASKED_VERBS])].join("|")})\\b`);
31305
31321
  var ALLOWED = new Set(WORKIT_ALLOWED_VERBS);
31322
+ var WRAPPERS2 = new Set(["env", "sudo", "nohup", "command", "timeout", "nice", "exec"]);
31306
31323
  // packages/workit-core/src/core/heavy-rules.ts
31307
31324
  var EFFECTS = new Set(["allow", "ask", "deny"]);
31308
31325
 
@@ -12635,7 +12635,23 @@ function runsByGlob(command, name) {
12635
12635
  const tokens = command.split(/\s+/u).map((token) => token.replace(/^--filter=/u, "").replaceAll(/^["']|["']$/gu, "").replace(/^(?:npm|pnpm|yarn|bun):/u, ""));
12636
12636
  if (/\bpnpm\b/u.test(command) && tokens.some((token) => /^\/.+\/$/u.test(token)))
12637
12637
  return true;
12638
- return tokens.filter((token) => token.includes("*")).some((glob) => new RegExp(`^${glob.split(/\*+/u).map((part) => part.replaceAll(/[.+?^${}()|[\]\\]/gu, "\\$&")).join(".*")}$`, "u").test(name));
12638
+ return tokens.filter((token) => token.includes("*")).some((glob) => globMatches(glob, name));
12639
+ }
12640
+ function globMatches(glob, name) {
12641
+ const parts = glob.split("*");
12642
+ const first = parts[0];
12643
+ const last = parts.at(-1) ?? "";
12644
+ const end = name.length - last.length;
12645
+ if (end < first.length || !name.startsWith(first) || !name.endsWith(last))
12646
+ return false;
12647
+ let at = first.length;
12648
+ for (const part of parts.slice(1, -1)) {
12649
+ const found = name.indexOf(part, at);
12650
+ if (found < 0 || found + part.length > end)
12651
+ return false;
12652
+ at = found + part.length;
12653
+ }
12654
+ return true;
12639
12655
  }
12640
12656
  function goDirectives(text) {
12641
12657
  const out = [];
@@ -17415,7 +17431,8 @@ var tokenize = (command, dialect) => {
17415
17431
  if (current.words.length) {
17416
17432
  current.pipe = true;
17417
17433
  current.conditional = true;
17418
- }
17434
+ } else if (segments.at(-1)?.group === "close")
17435
+ segments.at(-1).pipe = true;
17419
17436
  if (next === "&")
17420
17437
  index++;
17421
17438
  }
@@ -19434,7 +19451,53 @@ var hasWordsInOrder = (words, needle) => {
19434
19451
  return false;
19435
19452
  };
19436
19453
  var isBypass = (word) => WORKIT_BYPASS_FLAGS.some((flag) => word === flag || word.startsWith(`${flag}=`));
19437
- var isWorkitWord = (word) => /^(?:.*[\\/])?workit(?:-cli)?$/u.test(word);
19454
+ var isWorkitWord = (word) => /^(?:(?:.*[\\/])?workit(?:-cli)?|@workit-dev\/cli(?:@[\w.-]+)?)$/u.test(word);
19455
+ var verbAt = (words) => {
19456
+ let at = 0;
19457
+ for (;; ) {
19458
+ const word = words[at];
19459
+ if (word === "--json")
19460
+ at += 1;
19461
+ else if (word === "--cwd" || word === "--session")
19462
+ at += 2;
19463
+ else if (word?.startsWith("--cwd=") || word?.startsWith("--session="))
19464
+ at += 1;
19465
+ else
19466
+ return at;
19467
+ }
19468
+ };
19469
+ var WRAPPERS2 = new Set(["env", "sudo", "nohup", "command", "timeout", "nice", "exec"]);
19470
+ var VALUED = /^-(?:[ugnskCpD]|-user|-group|-signal|-kill-after|-unset|-chdir)$/u;
19471
+ var unwrapped = (words) => {
19472
+ let at = 0;
19473
+ for (;; ) {
19474
+ const word = words[at] ?? "";
19475
+ const name = word.split("/").at(-1) ?? "";
19476
+ if (/^[A-Za-z_]\w*=/u.test(word))
19477
+ at += 1;
19478
+ else if (WRAPPERS2.has(name)) {
19479
+ at += 1;
19480
+ while (words[at]?.startsWith("-"))
19481
+ at += VALUED.test(words[at] ?? "") ? 2 : 1;
19482
+ if (name === "timeout" && words[at] !== undefined)
19483
+ at += 1;
19484
+ } else
19485
+ return words.slice(at);
19486
+ }
19487
+ };
19488
+ var shellScript2 = (all) => {
19489
+ const words = unwrapped(all);
19490
+ const name = words[0]?.split("/").at(-1) ?? "";
19491
+ if (name === "eval")
19492
+ return words.slice(1).join(" ") || null;
19493
+ if (!/^(?:ba|z|da|k)?sh$/u.test(name))
19494
+ return null;
19495
+ const flag = words.findIndex((word, at) => at > 0 && /^-[a-z]*c[a-z]*$/u.test(word));
19496
+ if (flag < 0)
19497
+ return null;
19498
+ return words[words[flag + 1] === "--" ? flag + 2 : flag + 1] ?? null;
19499
+ };
19500
+ var SCRIPT_DEPTH = 4;
19438
19501
  var bypassReason = (flag) => `Workit: \`${flag}\` overrides a Workit gate, so the user decides this call (no allow rule covers it).`;
19439
19502
  var workitBypassFlag = (command, dialect = "posix") => {
19440
19503
  for (const segment of segmentsOf(command, dialect)) {
@@ -19469,47 +19532,30 @@ var userOnlyWorkitCall = (command, dialect = "posix") => {
19469
19532
  const words = segment.words.slice(start + 1);
19470
19533
  const end = words.indexOf("--");
19471
19534
  const args = end < 0 ? words : words.slice(0, end);
19472
- let at = 0;
19473
- for (;; ) {
19474
- const word = args[at];
19475
- if (word === "--json")
19476
- at += 1;
19477
- else if (word === "--cwd" || word === "--session")
19478
- at += 2;
19479
- else if (word?.startsWith("--cwd="))
19480
- at += 1;
19481
- else
19482
- break;
19483
- }
19484
- const call = args.slice(at);
19535
+ const call = args.slice(verbAt(args));
19485
19536
  const found = WORKIT_USER_ONLY.find((needle) => call[0] === needle[0] && hasWordsInOrder(call, needle));
19486
19537
  if (found && !helpOnly(call, found))
19487
19538
  return [...found];
19488
19539
  }
19489
19540
  return null;
19490
19541
  };
19491
- var askedWorkitCall = (command, dialect = "posix") => {
19542
+ var askedWorkitCall = (command, dialect = "posix", depth = 0) => {
19492
19543
  if (!mayRunUserOnly(command))
19493
19544
  return null;
19494
19545
  for (const segment of segmentsOf(command, dialect)) {
19495
19546
  if (segment.unanalyzable)
19496
19547
  continue;
19548
+ const script = shellScript2(segment.words);
19549
+ for (const inner of depth < SCRIPT_DEPTH ? [...script ? [script] : [], ...segment.subs ?? []] : []) {
19550
+ const found = askedWorkitCall(inner, "posix", depth + 1);
19551
+ if (found)
19552
+ return { ...found, plain: false };
19553
+ }
19497
19554
  const start = segment.words.findIndex(isWorkitWord);
19498
19555
  if (start < 0)
19499
19556
  continue;
19500
19557
  const words = segment.words.slice(start + 1);
19501
- let at = 0;
19502
- for (;; ) {
19503
- const word = words[at];
19504
- if (word === "--json")
19505
- at += 1;
19506
- else if (word === "--cwd" || word === "--session")
19507
- at += 2;
19508
- else if (word?.startsWith("--cwd="))
19509
- at += 1;
19510
- else
19511
- break;
19512
- }
19558
+ const at = verbAt(words);
19513
19559
  const verb = WORKIT_ASKED_VERBS.find((name) => words[at] === name);
19514
19560
  if (verb && !helpOnly(words.slice(at), [verb]))
19515
19561
  return {
@@ -20286,7 +20332,10 @@ function heavyPlan(command, options) {
20286
20332
  };
20287
20333
  }
20288
20334
  if (single) {
20289
- const rewrite = leaseRewrite(command.trim().replace(TAIL_FILTER, ""));
20335
+ const rewrite = leaseRewrite(command.trim().replace(TAIL_FILTER, (_, merged = "", redirects = "") => {
20336
+ const out = [...redirects.matchAll(/(\d*)(>>?)\s*(\S+)/gu)].findLast(([, fd]) => fd === "" || fd === "1");
20337
+ return out ? ` ${out[2]} ${out[3]}${merged}` : "";
20338
+ }));
20290
20339
  return rewrite ? { kind: "rewrite", command: rewrite, reason: single.reason } : { kind: "none" };
20291
20340
  }
20292
20341
  const parts = heavy.map((match) => leaseCommand(match.line));
@@ -20331,7 +20380,7 @@ function workitOnPath(env = process.env) {
20331
20380
  }
20332
20381
  return false;
20333
20382
  }
20334
- var TAIL_FILTER = /(?:\s+2>&1)?\s*\|\s*(?:tail|head)(?:\s+[\w=.+-]+)*\s*$/u;
20383
+ var TAIL_FILTER = /(\s+2>&1)?\s*\|\s*(?:tail|head)(?:\s+(?!\d*>)[\w=.+-]+)*((?:\s*\d*>>?\s*[\w./~-]+)*)\s*$/u;
20335
20384
  var ASSIGNMENTS = /^\s*((?:[A-Za-z_]\w*=(?:'[^']*'|"(?:[^"\\]|\\.)*"|[^\s'"])*\s+)*)/u;
20336
20385
  function leaseRewrite(command) {
20337
20386
  const text = command.trim();
@@ -20674,7 +20723,7 @@ var wrappedScript = (input) => {
20674
20723
  return null;
20675
20724
  if ("script" in tail)
20676
20725
  return tail.script;
20677
- const script = shellScript2(tail.argv);
20726
+ const script = shellScript3(tail.argv);
20678
20727
  if (SCRIPT_SHELLS.has((tail.argv[0]?.split(/[\\/]/).at(-1) ?? "").toLowerCase()) && script)
20679
20728
  return script;
20680
20729
  return tail.argv.map(quoteWord2).join(" ");
@@ -20756,7 +20805,7 @@ var editsOf = (input) => {
20756
20805
  return [];
20757
20806
  }
20758
20807
  };
20759
- var WRAPPERS2 = {
20808
+ var WRAPPERS3 = {
20760
20809
  sudo: "ugCDhpRrTtU",
20761
20810
  doas: "uC",
20762
20811
  env: "uCS",
@@ -20834,16 +20883,16 @@ var scriptArgs = (verb, args) => {
20834
20883
  }
20835
20884
  return { preloads };
20836
20885
  };
20837
- var unwrapped = (words) => {
20886
+ var unwrapped2 = (words) => {
20838
20887
  let at = 0;
20839
- for (let takes;(takes = WRAPPERS2[words[at]?.split(/[\\/]/).at(-1) ?? ""]) !== undefined; ) {
20888
+ for (let takes;(takes = WRAPPERS3[words[at]?.split(/[\\/]/).at(-1) ?? ""]) !== undefined; ) {
20840
20889
  at++;
20841
20890
  while (at < words.length && /^-|^\w+=|^\d[\w.]*$/.test(words[at]))
20842
20891
  at += words[at].length === 2 && words[at][0] === "-" && takes.includes(words[at][1]) ? 2 : 1;
20843
20892
  }
20844
20893
  return at ? words.slice(at) : null;
20845
20894
  };
20846
- var shellScript2 = (words) => {
20895
+ var shellScript3 = (words) => {
20847
20896
  if (!SCRIPT_SHELLS.has((words[0]?.split(/[\\/]/).at(-1) ?? "").toLowerCase()))
20848
20897
  return null;
20849
20898
  for (let index = 1;index < words.length; index++) {
@@ -20944,7 +20993,7 @@ var opaqueWrites = (input, scriptOf = (index) => input[index], fed) => {
20944
20993
  return [".", ...args.flatMap(pathsIn)];
20945
20994
  if (/^(?:python[\d.]*|node|bun|deno|ruby|php)$/.test(name))
20946
20995
  return inline(/^-[a-zA-Z]*[cep]$|^--(?:eval|print)$/);
20947
- return shellScript2(words) === null ? null : ["."];
20996
+ return shellScript3(words) === null ? null : ["."];
20948
20997
  };
20949
20998
  var CURL_LONG = [
20950
20999
  "output",
@@ -21626,14 +21675,14 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
21626
21675
  moved(plain);
21627
21676
  continue;
21628
21677
  }
21629
- const literal = depth < 4 ? wrappedScript(words) ?? (strict ? shellScript2(words) : null) : null;
21678
+ const literal = depth < 4 ? wrappedScript(words) ?? (strict ? shellScript3(words) : null) : null;
21630
21679
  const held = literal !== null && strict === "registry" ? expansions(literal, vars, loops) : [];
21631
21680
  const inner = held.length === 1 ? held[0] : literal;
21632
21681
  const unPwd = () => new Map([...vars].filter(([key]) => key !== "PWD"));
21633
21682
  if (inner !== null && dir !== undefined)
21634
21683
  for (const runIn of workitRunDir(dir, words, atAll))
21635
21684
  targets.push(...segmentTargets(runIn, inner, "posix", depth + 1, strict, runIn === dir ? vars : unPwd()));
21636
- const bare = strict === "registry" && depth < 4 ? unwrapped(words) : null;
21685
+ const bare = strict === "registry" && depth < 4 ? unwrapped2(words) : null;
21637
21686
  if (bare?.length && dir !== undefined)
21638
21687
  targets.push(...segmentTargets(dir, bare.flatMap((word) => expansions(word, vars, loops)).map(quoteWord2).join(" "), "posix", depth + 1, strict, vars));
21639
21688
  if (strict === "registry" && dir !== undefined && depth < 4) {
@@ -21670,9 +21719,9 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
21670
21719
  const shells = verb === "eval" ? [args.join(" ")] : verb === "trap" ? args.slice(0, 1) : verb === "alias" ? args.map((arg) => arg.replace(/^[^=]*=/, "")) : [];
21671
21720
  const others = [];
21672
21721
  if (SCRIPT_SHELLS.has(verb) || verb === "." || verb === "source") {
21673
- if (named === undefined && shellScript2(run) === null)
21722
+ if (named === undefined && shellScript3(run) === null)
21674
21723
  shells.push(...segment.stdin ?? [], ...inputs.flatMap(read), ...piped);
21675
- else if (named !== undefined && shellScript2(run) === null)
21724
+ else if (named !== undefined && shellScript3(run) === null)
21676
21725
  shells.push(...read(named));
21677
21726
  shells.push(...preloads.flatMap(read));
21678
21727
  } else if (INTERPRETERS.test(verb)) {
@@ -23659,7 +23708,7 @@ var FED = /^(?:-|\/dev\/stdin|\/dev\/fd\/0|\/proc\/self\/fd\/0)$|^<\(/;
23659
23708
  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;
23660
23709
  var RUNS = /^(?:sh|bash|zsh|dash|ksh|mksh|ash|python[\d.]*|node|bun|deno|ruby|perl|php|eval|source|\.|workit)$/;
23661
23710
  var INLINE = /^-[a-zA-Z]*[ceEpm]$|^--(?:eval|print|test|version|help)$|^-[hvV]$/;
23662
- var VALUED = /^-[WXIrC]$|^--(?:require|import|loader|conditions|input-type)$/;
23711
+ var VALUED2 = /^-[WXIrC]$|^--(?:require|import|loader|conditions|input-type)$/;
23663
23712
  var commonDir = (root) => gitDirsAt(root, null, false)?.[1] ?? "";
23664
23713
  var inScratch = (real, repo) => {
23665
23714
  for (let dir = real;path32.dirname(dir) !== dir; dir = path32.dirname(dir)) {
@@ -24053,7 +24102,7 @@ var judgeRefusal = (command, fed, depth = 0) => {
24053
24102
  }
24054
24103
  }
24055
24104
  if (INTERPRETERS2.test(name) && !args.some((arg) => INLINE.test(arg))) {
24056
- const operand = args.find((arg, index) => (arg === "-" || !arg.startsWith("-")) && !VALUED.test(args[index - 1] ?? ""));
24105
+ const operand = args.find((arg, index) => (arg === "-" || !arg.startsWith("-")) && !VALUED2.test(args[index - 1] ?? ""));
24057
24106
  if ((FED.test(operand ?? "") || operand === undefined && !/^(?:bun|deno)$/.test(name)) && !(segment.stdin?.length && /^(?:-|\/dev\/stdin)?$/.test(operand ?? "")))
24058
24107
  return unseen;
24059
24108
  }
@@ -25522,7 +25571,6 @@ var retryOf = ({ call, dir }) => {
25522
25571
  function exitPipeGate(command, dialect = "posix") {
25523
25572
  if (!/\bworkit/u.test(command) || !/\b(?:tail|head)\b/u.test(command))
25524
25573
  return null;
25525
- const subshellPiped = /\)\s*(?:\d*>&?\d*\s*)*\|(?!\|)/u.test(command);
25526
25574
  const groups = [];
25527
25575
  let carry = null;
25528
25576
  let pipefail = false;
@@ -25545,10 +25593,13 @@ function exitPipeGate(command, dialect = "posix") {
25545
25593
  }
25546
25594
  if (closes) {
25547
25595
  const inner = groups.pop() ?? null;
25548
- const piped = segment.pipe === true || segment.group === "close" && subshellPiped;
25549
- carry = piped ? inner ?? carry : null;
25596
+ if (inner && groups.length)
25597
+ groups[groups.length - 1] = inner;
25598
+ carry = segment.pipe ? inner ?? carry : null;
25550
25599
  continue;
25551
25600
  }
25601
+ if (!words.length && !segment.stdin && !segment.subs)
25602
+ continue;
25552
25603
  if (setsPipefail(words))
25553
25604
  pipefail = true;
25554
25605
  const filter = base2(words[0]);
@@ -101,7 +101,7 @@ if (quiet) {
101
101
  `);
102
102
  } else {
103
103
  try {
104
- const { runCodexHook } = await import("./workit-hook-684pewtc.js");
104
+ const { runCodexHook } = await import("./workit-hook-vzz5v5cy.js");
105
105
  await runCodexHook([payload]);
106
106
  } catch (error) {
107
107
  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.20.1",
3
+ "version": "2.20.3",
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.20.1",
45
- "@workit-dev/mcp": "^2.20.1"
44
+ "@workit-dev/core": "^2.20.3",
45
+ "@workit-dev/mcp": "^2.20.3"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=24"