@workit-dev/codex 1.14.2 → 1.16.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": "1.14.2",
3
+ "version": "1.16.0",
4
4
  "description": "Adaptive engineering workflow rails for Codex",
5
5
  "author": {
6
6
  "name": "BrainerVirus"
@@ -30479,6 +30479,18 @@ var WORKIT_ALLOWED_VERBS = [
30479
30479
  "doctor",
30480
30480
  "help"
30481
30481
  ];
30482
+ var WORKIT_USER_ONLY = [
30483
+ ["release", "notes", "approve"],
30484
+ ["grant", "set"],
30485
+ ["grant", "raise"],
30486
+ ["ledger", "void"],
30487
+ ["approve"],
30488
+ ["setup"],
30489
+ ["uninstall"],
30490
+ ["install"],
30491
+ ["workspace", "seal"]
30492
+ ];
30493
+ var USER_ONLY_WORD = new RegExp(`\\b(?:${[...new Set(WORKIT_USER_ONLY.map((words) => words[0]))].join("|")})\\b`);
30482
30494
  var ALLOWED = new Set(WORKIT_ALLOWED_VERBS);
30483
30495
  // packages/workit-core/src/core/heavy.ts
30484
30496
  var INFO_FLAGS = new Set(["--version", "-v", "-V", "--help", "-h", "help", "version"]);
@@ -0,0 +1,151 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ userHome2,
4
+ configDir2,
5
+ stateDir3
6
+ } from "./workit-hook-7jv519ep.js";
7
+
8
+ // packages/workit-core/src/hooks/write-reach.ts
9
+ import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
10
+ import os from "node:os";
11
+ import path from "node:path";
12
+ var hasTaskStore = (cwd) => {
13
+ try {
14
+ for (let dir = path.resolve(cwd);; dir = path.dirname(dir)) {
15
+ const dotGit = path.join(dir, ".git");
16
+ if (existsSync(dotGit)) {
17
+ let gitDir = dotGit;
18
+ if (statSync(dotGit).isFile()) {
19
+ const target = /^gitdir:\s*(.+)$/m.exec(readFileSync(dotGit, "utf8"))?.[1]?.trim();
20
+ if (!target)
21
+ return true;
22
+ gitDir = path.resolve(dir, target);
23
+ const common = path.join(gitDir, "commondir");
24
+ if (existsSync(common))
25
+ gitDir = path.resolve(gitDir, readFileSync(common, "utf8").trim());
26
+ }
27
+ const store = path.join(gitDir, "workit");
28
+ return existsSync(path.join(store, "tasks")) || existsSync(path.join(store, "task-index.json"));
29
+ }
30
+ if (existsSync(path.join(dir, ".workit")))
31
+ return true;
32
+ if (path.dirname(dir) === dir)
33
+ return false;
34
+ }
35
+ } catch {
36
+ return true;
37
+ }
38
+ };
39
+ var reachTests = (dirs) => {
40
+ const fold = (value) => dirs.fold ? value.toLowerCase() : value;
41
+ const canon = (file) => {
42
+ let rest = "";
43
+ for (let dir = path.resolve(file);; dir = path.dirname(dir)) {
44
+ try {
45
+ return fold(path.join(realpathSync.native(dir), rest));
46
+ } catch {
47
+ if (path.dirname(dir) === dir)
48
+ return fold(path.resolve(file));
49
+ rest = rest ? path.join(path.basename(dir), rest) : path.basename(dir);
50
+ }
51
+ }
52
+ };
53
+ const within = (parent, child) => {
54
+ const rel = path.relative(parent, child);
55
+ return rel === "" || !rel.startsWith("..") && !path.isAbsolute(rel);
56
+ };
57
+ const state = canon(dirs.state);
58
+ 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));
60
+ const above = (file) => within(file, state) || configs.some((dir) => within(file, dir));
61
+ const linked = (file) => {
62
+ try {
63
+ const stat = statSync(file, { throwIfNoEntry: false });
64
+ return Boolean(stat?.isFile() && stat.nlink > 1);
65
+ } catch {
66
+ return false;
67
+ }
68
+ };
69
+ return { canon, at, above, linked };
70
+ };
71
+ var mayReachWith = (text, cwd, dirs) => {
72
+ const { canon, at, above, linked } = reachTests(dirs);
73
+ const here = canon(cwd);
74
+ if (at(here) || above(here))
75
+ return true;
76
+ const BREAKS = /[\s;&|()<>=:,]/;
77
+ if ([dirs.state, ...dirs.configs].some((dir) => BREAKS.test(dir)) && /[/~]/.test(text))
78
+ return true;
79
+ const joined = text.replace(/\\\r?\n/g, "");
80
+ const bare = joined.replace(/['"\\]/g, "");
81
+ if (/\$['"]/.test(joined) || /~[\w+-]|\$\{(?:!|\w+[^\w}])|\bpopd\b/.test(bare) || /(?:^|[\s;&|(])(?:cd|pushd|chdir)(?:\s+-\S*)*\s*(?:$|[;&|)\n$`])/.test(bare) || dirs.env.CDPATH !== undefined && /\b(?:cd|pushd)\b/.test(bare))
82
+ return true;
83
+ const bound = (name) => new RegExp(`(?:^|[^\\w$])${name}=|\\bfor\\s+${name}\\b|\\bread\\b[^;&|\\n]*\\b${name}\\b`).test(bare);
84
+ const expanded = bare.replace(/\$\{([A-Za-z_]\w*)\}|\$([A-Za-z_]\w*)/g, (all, braced, plain) => {
85
+ const name = braced ?? plain ?? "";
86
+ return /^(?:OLD)?PWD$/.test(name) || bound(name) ? all : dirs.env[name] ?? "";
87
+ });
88
+ const words = expanded.split(/[\s;&|()<>=:,]+/).filter(Boolean);
89
+ if (words.length > 64)
90
+ return true;
91
+ const home = dirs.env.HOME || dirs.home;
92
+ const literal = (word) => {
93
+ const cut = word.split(/[$`*?[{]/)[0] ?? "";
94
+ return cut === "~" || cut.startsWith("~/") ? home + cut.slice(1) : cut;
95
+ };
96
+ const bases = [path.resolve(cwd)];
97
+ for (let index = 0;index < words.length; index++) {
98
+ if (!/^(?:cd|pushd|chdir)$/.test(words[index] ?? ""))
99
+ continue;
100
+ let next = index + 1;
101
+ while (words[next]?.startsWith("-"))
102
+ next++;
103
+ const target = literal(words[next] ?? "");
104
+ bases.push(...bases.map((base) => path.resolve(base, target)));
105
+ if (bases.length > 8)
106
+ return true;
107
+ }
108
+ const globby = /[$`*?[{]/.test(expanded);
109
+ const seen = new Set;
110
+ for (const word of words) {
111
+ const forms = [word];
112
+ if (word.startsWith("-"))
113
+ for (let from = 1;from < word.length; from++)
114
+ forms.push(word.slice(from));
115
+ for (const form of forms)
116
+ for (const base of bases) {
117
+ const file = canon(path.resolve(base, literal(form)));
118
+ if (seen.has(file))
119
+ continue;
120
+ seen.add(file);
121
+ if (at(file) || linked(file))
122
+ return true;
123
+ if (globby && (above(file) || above(path.dirname(file))))
124
+ return true;
125
+ }
126
+ }
127
+ return false;
128
+ };
129
+ var guardedDirs = (env, paths) => {
130
+ let account = null;
131
+ try {
132
+ account = os.userInfo().homedir;
133
+ } catch {}
134
+ return {
135
+ state: paths.stateDir(env),
136
+ configs: [
137
+ paths.configDir(env),
138
+ paths.configDir({}),
139
+ ...account ? [paths.configDir({ HOME: account, USERPROFILE: account })] : []
140
+ ],
141
+ home: paths.userHome(env),
142
+ env,
143
+ fold: process.platform === "darwin" || process.platform === "win32"
144
+ };
145
+ };
146
+ var reachDirs = (env = process.env) => guardedDirs(env, { configDir: configDir2, stateDir: stateDir3, userHome: userHome2 });
147
+ var mayReach = (text, cwd) => mayReachWith(text, cwd, reachDirs());
148
+ export {
149
+ hasTaskStore,
150
+ mayReach
151
+ };
@@ -18497,8 +18497,18 @@ var WORKIT_USER_ONLY = [
18497
18497
  ["grant", "set"],
18498
18498
  ["grant", "raise"],
18499
18499
  ["ledger", "void"],
18500
- ["approve"]
18500
+ ["approve"],
18501
+ ["setup"],
18502
+ ["uninstall"],
18503
+ ["install"],
18504
+ ["workspace", "seal"]
18501
18505
  ];
18506
+ var USER_ONLY_WORD = new RegExp(`\\b(?:${[...new Set(WORKIT_USER_ONLY.map((words) => words[0]))].join("|")})\\b`);
18507
+ var mayRunUserOnly = (text) => {
18508
+ const joined = text.replace(/\\\r?\n/g, "");
18509
+ const bare = joined.replace(/['"\\]/g, "");
18510
+ return [bare, bare.replace(/`/g, "")].some((all) => /\bworkit\b/.test(all) && (USER_ONLY_WORD.test(all) || /\$['"]/.test(joined)));
18511
+ };
18502
18512
  var ALLOWED = new Set(WORKIT_ALLOWED_VERBS);
18503
18513
  var hasWordsInOrder = (words, needle) => {
18504
18514
  let at = 0;
@@ -18531,6 +18541,8 @@ var workitBypassFlag = (command, dialect = "posix") => {
18531
18541
  return null;
18532
18542
  };
18533
18543
  var userOnlyWorkitCall = (command, dialect = "posix") => {
18544
+ if (!mayRunUserOnly(command))
18545
+ return null;
18534
18546
  for (const segment of segmentsOf(command, dialect)) {
18535
18547
  if (segment.unanalyzable)
18536
18548
  continue;
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // packages/workit-codex/hooks/launcher.ts
4
- import { readFileSync, realpathSync, statSync } from "node:fs";
4
+ import { readFileSync } from "node:fs";
5
5
  import path from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
7
  var foundNode = process.env.WORKIT_HOOK_NODE_VERSION || process.versions.node;
@@ -39,11 +39,18 @@ 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
43
  var YTRACK_WORD = /ytrack(?![\w/-]|\.(?!exe|cmd))/i;
43
44
  var namesYtrack = (text) => {
44
45
  const bare = text.replace(/['"\\]/g, "");
45
46
  return YTRACK_WORD.test(bare) || YTRACK_WORD.test(bare.replace(/`/g, ""));
46
47
  };
48
+ var USER_ONLY_WORD = /\b(?:release|grant|ledger|approve|setup|uninstall|install|workspace)\b/;
49
+ var mayRunUserOnly = (text) => {
50
+ const joined = text.replace(/\\\r?\n/g, "");
51
+ const bare = joined.replace(/['"\\]/g, "");
52
+ return [bare, bare.replace(/`/g, "")].some((all) => /\bworkit\b/.test(all) && (USER_ONLY_WORD.test(all) || /\$['"]/.test(joined)));
53
+ };
47
54
  var payload = "";
48
55
  for await (const chunk of process.stdin)
49
56
  payload += String(chunk);
@@ -77,19 +84,8 @@ var quietEvent = () => {
77
84
  return null;
78
85
  if (event === "PostToolUse")
79
86
  return /\bcommit\b/.test(text) ? null : event;
80
- const writes = /[>]|\b(?:cp|mv|rm|rmdir|mkdir|tee|ln|install|rsync|touch|sed|perl|dd|curl|wget|tar|unzip|truncate|patch|chmod|chown|chgrp|chattr|find|xargs|unlink|g?awk|shred|mkfifo)\b/.test(text) && (/(?:^|[\s=<>|;&("'])(?:~|\/|\$|\.\.)[^\s'"]*[*?[]|\$\{?(?:WORKIT_|XDG_|APPDATA|HOME)/.test(text) || text.split(/[\s;&|()<>`'"]+/).some((word) => {
81
- const file = path.resolve(String(value.cwd), word);
82
- try {
83
- const stat = statSync(file, { throwIfNoEntry: false });
84
- if (stat?.isFile() && stat.nlink > 1)
85
- return true;
86
- const real = stat ? realpathSync(file) : path.join(realpathSync(path.dirname(file)), path.basename(file));
87
- return real !== file && guarded(real);
88
- } catch {
89
- return false;
90
- }
91
- }));
92
- 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) || writes || maybeHeavy(text, value.cwd) ? 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, " "));
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;
93
89
  } catch {
94
90
  return null;
95
91
  }
@@ -102,7 +98,7 @@ if (quiet) {
102
98
  `);
103
99
  } else {
104
100
  try {
105
- const { runCodexHook } = await import("./workit-hook-fz351gv7.js");
101
+ const { runCodexHook } = await import("./workit-hook-gta6gwg4.js");
106
102
  await runCodexHook([payload]);
107
103
  } catch (error) {
108
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": "1.14.2",
3
+ "version": "1.16.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": "^1.14.2",
45
- "@workit-dev/mcp": "^1.14.2"
44
+ "@workit-dev/core": "^1.16.0",
45
+ "@workit-dev/mcp": "^1.16.0"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=24"