@workit-dev/codex 2.27.7 → 2.27.9

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.27.7",
3
+ "version": "2.27.9",
4
4
  "description": "Adaptive engineering workflow rails for Codex",
5
5
  "author": {
6
6
  "name": "BrainerVirus"
@@ -16144,12 +16144,6 @@ var applyPatterns = (value) => {
16144
16144
  };
16145
16145
  var redactSecrets = (value) => applyPatterns(value);
16146
16146
 
16147
- // packages/workit-core/src/store/paths.ts
16148
- import { spawnSync as spawnSync9 } from "node:child_process";
16149
- import { createHash as createHash6 } from "node:crypto";
16150
- import fs6 from "node:fs";
16151
- import path10 from "node:path";
16152
-
16153
16147
  // packages/workit-core/src/store/folder-store.ts
16154
16148
  import fs5 from "node:fs";
16155
16149
  import os5 from "node:os";
@@ -16366,13 +16360,14 @@ var below = (parent, child) => {
16366
16360
  const rel = path9.relative(parent, child);
16367
16361
  return rel !== "" && !rel.startsWith("..") && !path9.isAbsolute(rel);
16368
16362
  };
16363
+ var insideTempDir = (dir, tempDir = os5.tmpdir()) => below(canonical3(tempDir), canonical3(dir));
16369
16364
  var TEST_RUN_REFUSALS = "folder-store-refusals.log";
16370
16365
  var testRunFolderRefusal = (folder, hasStray, env = process.env, tempDir = os5.tmpdir()) => {
16371
16366
  if (env.WORKIT_TEST_RUN === undefined || !hasStray)
16372
16367
  return null;
16373
16368
  const real = canonical3(folder);
16374
16369
  const tmp = canonical3(tempDir);
16375
- if (below(tmp, real))
16370
+ if (insideTempDir(folder, tempDir))
16376
16371
  return null;
16377
16372
  return `workit test run (WORKIT_TEST_RUN): refusing to move ${path9.join(real, ".workit")} into the run's throwaway state dir; a test must work in a fresh dir inside ${tmp}, never the temp dir itself, a parent of it or a folder outside it (#892)`;
16378
16373
  };
@@ -16458,6 +16453,10 @@ Merge them by hand (cp -Rn ${workit}/. ${target}/), then delete them here.
16458
16453
  }
16459
16454
 
16460
16455
  // packages/workit-core/src/store/paths.ts
16456
+ import { spawnSync as spawnSync9 } from "node:child_process";
16457
+ import { createHash as createHash6 } from "node:crypto";
16458
+ import fs6 from "node:fs";
16459
+ import path10 from "node:path";
16461
16460
  var NOT_A_REPO = /not a git repository \(or any (of the parent directories|parent up to)/u;
16462
16461
  var gitRun = (cwd, args) => {
16463
16462
  const run = spawnSync9("git", args, {
@@ -16768,8 +16767,40 @@ function hostSessionFromEnv(env) {
16768
16767
  return inner ? { host: inner.host, session: inner.session } : { host: declared, session: null };
16769
16768
  }
16770
16769
  var hash = (value) => createHash7("sha256").update(value).digest("hex").slice(0, 32);
16771
- var userIssuedRoot = () => path11.join(resolveStateDir(), "issued");
16772
- var userTokenRoot = () => path11.join(resolveStateDir(), "issued-tokens");
16770
+ var PIN_FILE = "issued-registry";
16771
+ var pinFiles = new Map;
16772
+ var pinFile = (cwd) => {
16773
+ if (cwd === undefined)
16774
+ return null;
16775
+ const key = path11.resolve(cwd);
16776
+ const known = pinFiles.get(key);
16777
+ if (known !== undefined)
16778
+ return known;
16779
+ try {
16780
+ const location = resolveStore(key);
16781
+ if (location instanceof Error)
16782
+ return null;
16783
+ const file = location.shared ? path11.join(location.dir, "ledger", PIN_FILE) : null;
16784
+ pinFiles.set(key, file);
16785
+ return file;
16786
+ } catch {
16787
+ return null;
16788
+ }
16789
+ };
16790
+ var pinnedStateDir = (cwd) => {
16791
+ const file = pinFile(cwd);
16792
+ if (file === null)
16793
+ return null;
16794
+ try {
16795
+ const pinned = fs7.readFileSync(file, "utf8").trim();
16796
+ return path11.isAbsolute(pinned) ? pinned : null;
16797
+ } catch {
16798
+ return null;
16799
+ }
16800
+ };
16801
+ var registryDir = (cwd) => pinnedStateDir(cwd) ?? resolveStateDir();
16802
+ var userIssuedRoot = (cwd) => path11.join(registryDir(cwd), "issued");
16803
+ var userTokenRoot = (cwd) => path11.join(registryDir(cwd), "issued-tokens");
16773
16804
  function migrateRepoIssued(cwd) {
16774
16805
  if (cwd === undefined)
16775
16806
  return;
@@ -16789,7 +16820,7 @@ function migrateRepoIssued(cwd) {
16789
16820
  const from = path11.join(old, lead);
16790
16821
  if (!fs7.statSync(from).isDirectory())
16791
16822
  continue;
16792
- const to = path11.join(userIssuedRoot(), lead);
16823
+ const to = path11.join(userIssuedRoot(cwd), lead);
16793
16824
  fs7.mkdirSync(to, { recursive: true, mode: 448 });
16794
16825
  for (const id of fs7.readdirSync(from)) {
16795
16826
  try {
@@ -16823,17 +16854,17 @@ var issuedRecord = (cwd, claimed) => {
16823
16854
  return null;
16824
16855
  migrateRepoIssued(cwd);
16825
16856
  try {
16826
- return fs7.readFileSync(path11.join(userIssuedRoot(), hash(claimed.slice(0, cut)), hash(claimed)), "utf8");
16857
+ return fs7.readFileSync(path11.join(userIssuedRoot(cwd), hash(claimed.slice(0, cut)), hash(claimed)), "utf8");
16827
16858
  } catch {
16828
16859
  return null;
16829
16860
  }
16830
16861
  };
16831
16862
  var TOKEN_HASH = /^([0-9a-f]{64})$/mu;
16832
- var issuedToken = (claimed) => {
16863
+ var issuedToken = (cwd, claimed) => {
16833
16864
  const cut = claimed.lastIndexOf(":");
16834
16865
  if (cut <= 0)
16835
16866
  return { stored: null, leadBound: false };
16836
- const dir = path11.join(userTokenRoot(), hash(claimed.slice(0, cut)));
16867
+ const dir = path11.join(userTokenRoot(cwd), hash(claimed.slice(0, cut)));
16837
16868
  try {
16838
16869
  const text = fs7.readFileSync(path11.join(dir, hash(claimed)), "utf8");
16839
16870
  return { stored: TOKEN_HASH.exec(text)?.[1] ?? null, leadBound: true };
@@ -16843,7 +16874,7 @@ var issuedToken = (claimed) => {
16843
16874
  };
16844
16875
  function issuedBinding(cwd, claimed) {
16845
16876
  const record = issuedRecord(cwd, claimed);
16846
- const { stored, leadBound } = issuedToken(claimed);
16877
+ const { stored, leadBound } = issuedToken(cwd, claimed);
16847
16878
  if (stored)
16848
16879
  return "token";
16849
16880
  if (record === null)
@@ -33075,14 +33106,82 @@ var gap = (part) => ({ workit: null, gap: part });
33075
33106
  var READ = new Map;
33076
33107
  var NOT_PLAIN = gap("a ytrack call that is not a plain command of its own (a wrapper, loop, substitution or script around it can change or repeat it)");
33077
33108
 
33109
+ // packages/workit-core/src/hooks/hook-entry.ts
33110
+ var RUNNERS2 = new Set([
33111
+ "node",
33112
+ "nodejs",
33113
+ "bun",
33114
+ "deno",
33115
+ "tsx",
33116
+ "ts-node",
33117
+ "sh",
33118
+ "bash",
33119
+ "zsh",
33120
+ "dash",
33121
+ "ksh",
33122
+ "fish",
33123
+ "source",
33124
+ "."
33125
+ ]);
33126
+ var PACKAGE_RUNNERS2 = new Set(["npx", "bunx", "pnpx"]);
33127
+ var NO_RUN = new Set([
33128
+ "build",
33129
+ "test",
33130
+ "fmt",
33131
+ "lint",
33132
+ "check",
33133
+ "doc",
33134
+ "info",
33135
+ "install",
33136
+ "add",
33137
+ "pm"
33138
+ ]);
33139
+ var MORE_WRAPPERS = new Set(["strace", "ltrace", "watch", "unshare", "firejail", "xargs", "&"]);
33140
+ var KEYWORDS2 = new Set([
33141
+ "{",
33142
+ "}",
33143
+ "if",
33144
+ "then",
33145
+ "elif",
33146
+ "else",
33147
+ "fi",
33148
+ "while",
33149
+ "until",
33150
+ "do",
33151
+ "done",
33152
+ "esac",
33153
+ "!"
33154
+ ]);
33155
+ var READERS2 = new Set(("cat less more head tail ls dir stat file wc grep egrep fgrep rg ag diff cmp sha256sum md5sum " + "shasum du bat echo printf cp mv rm chmod touch mkdir realpath readlink dirname basename tee " + "oxfmt oxlint prettier eslint tsc gh jq sort uniq cut tr nl od xxd hexdump strings code vim " + "nano sed get-content gc type select-string get-childitem test-path").split(" "));
33156
+
33078
33157
  // packages/workit-core/src/hooks/identity-env.ts
33079
33158
  var NAMES = "WORKIT_(?:AGENT_ID|HOST|SESSION_ID|SESSION_TOKEN)";
33080
- var HOST_NAMES = "(?:OPENCODE_SESSION_ID|PI_SESSION_ID|CODEX_THREAD_ID|CLAUDECODE|CLAUDE_CODE_ENTRYPOINT)";
33081
33159
  var IDENTITY = new RegExp(`^${NAMES}$`, "u");
33160
+ var HOST_NAMES = "(?:OPENCODE_SESSION_ID|PI_SESSION_ID|CODEX_THREAD_ID|CLAUDECODE|CLAUDE_CODE_ENTRYPOINT)";
33082
33161
  var HOST_VARIABLE = new RegExp(`^${HOST_NAMES}$`, "u");
33083
- var powershell = (names) => new RegExp(`\\$env:${names}\\b|env:[\\\\/]?${names}\\b|EnvironmentVariable\\(\\s*['"]${names}\\b`, "iu");
33162
+ var IDENTITY_ANY = new RegExp(NAMES, "iu");
33163
+ var STATE_NAMES = "(?:WORKIT_(?:STATE_DIR|CONFIG(?:_DIR)?)|XDG_(?:STATE|CONFIG|DATA)_HOME|HOME|USERPROFILE|(?:LOCAL)?APPDATA)";
33164
+ var STATE2 = new RegExp(`^${STATE_NAMES}$`, "u");
33165
+ var STATE_ANY = new RegExp(STATE_NAMES, "iu");
33166
+ var powershell = (names) => new RegExp([
33167
+ `\\$\\{?env:${names}\\}?\\s*(?:[-+*/]|\\?\\?)?=(?!=)`,
33168
+ `${PS_ITEM}[^;|\\n]*?(?<![$\\w{])env:[\\\\/]?${names}\\b`,
33169
+ `SetEnvironmentVariable\\(\\s*['"]${names}\\b`
33170
+ ].join("|"), "iu");
33171
+ var PS_ITEM = "\\b(?:(?:Set|New|Remove|Clear|Rename|Move|Copy)-Item(?:Property)?|(?:Set|Add|Clear)-Content|si|ni|ri|rm|del|erase|rd|rmdir|cli|sc|ac|clc|rni|mi|move|mv|cpi|copy|cp|ren)\\b";
33084
33172
  var POWERSHELL = powershell(NAMES);
33173
+ var POWERSHELL_STATE = powershell(STATE_NAMES);
33085
33174
  var POWERSHELL_HOST = powershell(HOST_NAMES);
33175
+ var POWERSHELL_OPAQUE = new RegExp([
33176
+ `SetEnvironmentVariable\\(\\s*(?:[^'"\\s]|"[^"]*\\$)`,
33177
+ `${PS_ITEM}[^;|\\n]*?(?<![$\\w{])env:[\\\\/]?["']?[$(]`,
33178
+ `(?:^|[;&|{(\\n])\\s*\\.\\s+[^\\s.]`,
33179
+ `\\b(?:iex|Invoke-Expression)\\b`
33180
+ ].join("|"), "iu");
33181
+ var cmdSet = (names) => new RegExp(`(?:^|[&|(\\s"])set\\s+(?:/[ap]\\s+)?"?(${names})\\s*\\+?=`, "iu");
33182
+ var CMD_IDENTITY = cmdSet(NAMES);
33183
+ var CMD_STATE = cmdSet(STATE_NAMES);
33184
+ var CMD_HOST = cmdSet(HOST_NAMES);
33086
33185
  var DECLARES = new Set(["export", "unset", "declare", "typeset", "local", "readonly"]);
33087
33186
  var OPAQUE = new Set([
33088
33187
  "watch",
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+
3
+ // packages/workit-core/src/hooks/hook-entry-hint.ts
4
+ var HOOK_ENTRY_TEXT = /workit-hook|workit-(?:codex|cursor)-hook|session-start|launch(?:-runtime)?\.mjs|\b(?:run|hook|launcher)\.ts\b|PLUGIN_ROOT|@workit-dev\//u;
5
+ var RUNS_SCRIPT = /(?:^|[\s;&|(`])(?:\S*[\\/])?(?:node|bunx?|deno|npx|pnpx|tsx|ts-node)(?:\.exe)?\s[^\n;&|]*(?:[*?[$`]|\.[cm]?[jt]s\b)/u;
6
+ var REMOVES_ABOVE = /\b(?:rm|rmdir|rd|mv|unlink|shred|rsync|remove-item|move-item|ri|mi|del|erase)\b[^\n;&|]*\s(?:\.{1,2}(?:[\\/\s]|$)|[~/$*?]|[A-Za-z]:)|\bfind\b[^\n;&|]*\s-(?:delete|exec)/iu;
7
+ var mayHitHookGuard = (text) => {
8
+ const bare = text.replace(/['"\\]/gu, "");
9
+ return [text, bare].some((all) => HOOK_ENTRY_TEXT.test(all) || RUNS_SCRIPT.test(all) || REMOVES_ABOVE.test(all));
10
+ };
11
+ export {
12
+ mayHitHookGuard
13
+ };