@workit-dev/codex 1.8.1 → 1.8.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.
|
@@ -16225,7 +16225,9 @@ var tokenize = (command, dialect) => {
|
|
|
16225
16225
|
heredocs.push({ delimiter: text.replace(/^-/, ""), owner: current });
|
|
16226
16226
|
else if (pending === "herestring")
|
|
16227
16227
|
(current.stdin ??= []).push(text);
|
|
16228
|
-
else if (pending
|
|
16228
|
+
else if (pending === "input")
|
|
16229
|
+
(current.inputs ??= []).push(text);
|
|
16230
|
+
else {
|
|
16229
16231
|
const at = current.words.length;
|
|
16230
16232
|
current.words.push(...MARKERS.test(word) ? expandBraces(word) : [word]);
|
|
16231
16233
|
if (expanding || !posix && word.startsWith("@"))
|
|
@@ -19162,7 +19164,7 @@ var splitDenial = (plan) => ({
|
|
|
19162
19164
|
unblock: plan.unblock
|
|
19163
19165
|
});
|
|
19164
19166
|
// packages/workit-core/src/hooks/write-gate.ts
|
|
19165
|
-
import { existsSync as existsSync10, realpathSync as realpathSync7, statSync as statSync3 } from "node:fs";
|
|
19167
|
+
import { existsSync as existsSync10, readdirSync as readdirSync3, readFileSync as readFileSync9, realpathSync as realpathSync7, statSync as statSync3 } from "node:fs";
|
|
19166
19168
|
import os8 from "node:os";
|
|
19167
19169
|
import path28 from "node:path";
|
|
19168
19170
|
|
|
@@ -19428,9 +19430,9 @@ var editsOf = (input) => {
|
|
|
19428
19430
|
case "cp":
|
|
19429
19431
|
case "ln":
|
|
19430
19432
|
case "install": {
|
|
19431
|
-
const
|
|
19432
|
-
if (
|
|
19433
|
-
return
|
|
19433
|
+
const into = valueOf(args, /^(?:-t|--target-directory=?)(.*)$/s);
|
|
19434
|
+
if (into !== undefined)
|
|
19435
|
+
return [into];
|
|
19434
19436
|
const last = operands(args).at(-1);
|
|
19435
19437
|
return last ? [last] : null;
|
|
19436
19438
|
}
|
|
@@ -19484,6 +19486,84 @@ var editsOf = (input) => {
|
|
|
19484
19486
|
return [];
|
|
19485
19487
|
}
|
|
19486
19488
|
};
|
|
19489
|
+
var WRAPPERS2 = {
|
|
19490
|
+
sudo: "ugCDhpRrTtU",
|
|
19491
|
+
doas: "uC",
|
|
19492
|
+
env: "uCS",
|
|
19493
|
+
nice: "n",
|
|
19494
|
+
ionice: "cnp",
|
|
19495
|
+
timeout: "sk",
|
|
19496
|
+
stdbuf: "ioe",
|
|
19497
|
+
time: "fo",
|
|
19498
|
+
nohup: "",
|
|
19499
|
+
command: "",
|
|
19500
|
+
exec: "a",
|
|
19501
|
+
setsid: "",
|
|
19502
|
+
builtin: "",
|
|
19503
|
+
"!": "",
|
|
19504
|
+
npx: "p",
|
|
19505
|
+
bunx: "p"
|
|
19506
|
+
};
|
|
19507
|
+
var INTERPRETERS = /^(?:python[\d.]*|node|bun|deno|ruby|perl|php|tsx|ts-node)$/;
|
|
19508
|
+
var isConfigDir = (file) => configDirs().some((dir) => canonical3(dir) === canonical3(file));
|
|
19509
|
+
var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals)$/.test(path28.relative(canonical3(resolveStateDir()), canonical3(file)));
|
|
19510
|
+
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)$/;
|
|
19511
|
+
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)$/;
|
|
19512
|
+
var PATH_CALLS = /^(?:join|resolve|normalize|abspath|expanduser|expandvars|Path|PurePath|fspath)$/;
|
|
19513
|
+
var readsRoot = (text, at) => {
|
|
19514
|
+
let call;
|
|
19515
|
+
for (let index = at, depth = 0;index > 0 && call === undefined; index--) {
|
|
19516
|
+
const char = text[index - 1];
|
|
19517
|
+
if (char === ")")
|
|
19518
|
+
depth++;
|
|
19519
|
+
else if (char === "(" && depth-- === 0)
|
|
19520
|
+
call = /([\w$]+)\s*$/.exec(text.slice(0, index - 1))?.[1] ?? "";
|
|
19521
|
+
else if (depth <= 0 && /[;\n]/.test(char))
|
|
19522
|
+
break;
|
|
19523
|
+
}
|
|
19524
|
+
if (call !== undefined && READ_CALLS.test(call))
|
|
19525
|
+
return true;
|
|
19526
|
+
if (call !== undefined && !PATH_CALLS.test(call))
|
|
19527
|
+
return false;
|
|
19528
|
+
return ![...text.matchAll(/([\w$]+)\s*\(/g)].some(([, name]) => MUTATING_CALLS.test(name));
|
|
19529
|
+
};
|
|
19530
|
+
var inertEdit = (command) => command.split("|").every((part) => /^:?(?:se(?:t)?|sy(?:ntax)?|colo(?:rscheme)?)(?:\s|$)|^[/?][^/?]*[/?]?$|^\d+$/.test(part.trim()));
|
|
19531
|
+
var SCRIPT_OPTIONS = [
|
|
19532
|
+
[/^(?:(?:ba|z|k|da)?sh|source|\.)$/, /^(?:[-+][oO]|--(?:rcfile|init-file))$/],
|
|
19533
|
+
[/^python/, /^-[WXQ]$/],
|
|
19534
|
+
[
|
|
19535
|
+
/./,
|
|
19536
|
+
/^(?:-[rCI]|--(?:require|import|(?:experimental-)?loader|preload|input-type|conditions|title|cwd|tsconfig|project|env-file|config))$/
|
|
19537
|
+
]
|
|
19538
|
+
];
|
|
19539
|
+
var PRELOAD = /^(?:-r|--(?:require|import|(?:experimental-)?loader|preload|rcfile|init-file))$/;
|
|
19540
|
+
var scriptArgs = (verb, args) => {
|
|
19541
|
+
const takes = SCRIPT_OPTIONS.find(([family]) => family.test(verb))?.[1] ?? /^$/;
|
|
19542
|
+
const preloads = [];
|
|
19543
|
+
for (let at = 0;at < args.length; at++) {
|
|
19544
|
+
const [option, value] = args[at].split(/=(.*)/s);
|
|
19545
|
+
if (value !== undefined && PRELOAD.test(option))
|
|
19546
|
+
preloads.push(value);
|
|
19547
|
+
else if (/^-[mce]$|^--(?:eval|print)$/.test(option))
|
|
19548
|
+
break;
|
|
19549
|
+
else if (takes.test(option)) {
|
|
19550
|
+
if (PRELOAD.test(option))
|
|
19551
|
+
preloads.push(args[at + 1] ?? "");
|
|
19552
|
+
at++;
|
|
19553
|
+
} else if (!/^[-+]/.test(option) && option !== "run")
|
|
19554
|
+
return { named: args[at], preloads };
|
|
19555
|
+
}
|
|
19556
|
+
return { preloads };
|
|
19557
|
+
};
|
|
19558
|
+
var unwrapped = (words) => {
|
|
19559
|
+
let at = 0;
|
|
19560
|
+
for (let takes;(takes = WRAPPERS2[words[at]?.split(/[\\/]/).at(-1) ?? ""]) !== undefined; ) {
|
|
19561
|
+
at++;
|
|
19562
|
+
while (at < words.length && /^-|^\w+=|^\d[\w.]*$/.test(words[at]))
|
|
19563
|
+
at += words[at].length === 2 && words[at][0] === "-" && takes.includes(words[at][1]) ? 2 : 1;
|
|
19564
|
+
}
|
|
19565
|
+
return at ? words.slice(at) : null;
|
|
19566
|
+
};
|
|
19487
19567
|
var shellScript2 = (words) => {
|
|
19488
19568
|
if (!SCRIPT_SHELLS.has((words[0]?.split(/[\\/]/).at(-1) ?? "").toLowerCase()))
|
|
19489
19569
|
return null;
|
|
@@ -19728,9 +19808,8 @@ var gitOutputs = (args) => {
|
|
|
19728
19808
|
const under = (file) => file === "." ? `${base}/${OPAQUE_TARGET}git` : /^[/~$]|^[A-Za-z]:[\\/]/.test(file) ? file : `${base}/${file}`;
|
|
19729
19809
|
return files.length ? files.map(under) : null;
|
|
19730
19810
|
};
|
|
19731
|
-
var
|
|
19732
|
-
|
|
19733
|
-
].map((match) => match[0]);
|
|
19811
|
+
var PATHS = /(?<![\w.~:/$-])(?:~\/|\/|[A-Za-z]:\/|\.\.(?:\/|$))[^\s'"`$),;:*?<>|\\[\]{}]*/g;
|
|
19812
|
+
var pathsIn = (text) => [...text.matchAll(PATHS)].map((match) => match[0]);
|
|
19734
19813
|
var linkSources = (args, at) => {
|
|
19735
19814
|
const names = operands([...args]);
|
|
19736
19815
|
const into = args.indexOf("-t");
|
|
@@ -19857,12 +19936,12 @@ var CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
|
|
|
19857
19936
|
var PUSHD2 = new Set(["pushd", "push-location"]);
|
|
19858
19937
|
var POPD2 = new Set(["popd", "pop-location"]);
|
|
19859
19938
|
var UNKNOWN_DIR = path28.resolve(path28.parse(process.cwd()).root, ".workit-unknown-dir");
|
|
19860
|
-
var cdInto = (dir, words, strict = false, vars = new Map) => {
|
|
19939
|
+
var cdInto = (dir, words, strict = false, vars = new Map, globs = false) => {
|
|
19861
19940
|
const lost = strict ? UNKNOWN_DIR : undefined;
|
|
19862
19941
|
const found = words.slice(1).find((word) => !word.startsWith("-") || word === "-");
|
|
19863
19942
|
const named = found === undefined ? undefined : expandVars(found, vars);
|
|
19864
19943
|
const target = named === undefined ? undefined : homeExpanded(named);
|
|
19865
|
-
if (target === "-" || target && /^~|[$`*?]
|
|
19944
|
+
if (target === "-" || target && (globs ? /^~|[$`]/ : /^~|[$`*?]/).test(target))
|
|
19866
19945
|
return lost;
|
|
19867
19946
|
if (dir === undefined)
|
|
19868
19947
|
return lost;
|
|
@@ -19885,7 +19964,8 @@ var assignmentsOf = (words) => {
|
|
|
19885
19964
|
var commandWords = (words) => {
|
|
19886
19965
|
let start = 0;
|
|
19887
19966
|
while (start < words.length && COMPOUND.has(words[start]))
|
|
19888
|
-
start
|
|
19967
|
+
if (words[start++] === "function")
|
|
19968
|
+
start++;
|
|
19889
19969
|
return words.slice(start);
|
|
19890
19970
|
};
|
|
19891
19971
|
var REBINDS_ANY = new Set([
|
|
@@ -20037,7 +20117,8 @@ var expansions = (text, vars, loops) => {
|
|
|
20037
20117
|
last = match.index + match[0].length;
|
|
20038
20118
|
const value = vars.get(name);
|
|
20039
20119
|
const values = loops.get(name) ?? (value === undefined ? null : [value]);
|
|
20040
|
-
const
|
|
20120
|
+
const fallback = /^:?[-=](.*)$/s.exec(match[2] ?? "")?.[1];
|
|
20121
|
+
const applied = values?.flatMap((item) => fallback === undefined ? [applyOperator(item, match[2] ?? "")] : item === "" ? expansions(fallback, vars, loops) : [item]);
|
|
20041
20122
|
const fits = applied && results.length * applied.length <= MAX_EXPANSIONS2;
|
|
20042
20123
|
results = fits && applied.every((item) => item !== null) ? results.flatMap((prefix) => applied.map((item) => prefix + literal + item)) : results.map((prefix) => prefix + literal + match[0]);
|
|
20043
20124
|
}
|
|
@@ -20083,6 +20164,7 @@ var homeExpanded = (file) => {
|
|
|
20083
20164
|
};
|
|
20084
20165
|
var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherited = new Map) => {
|
|
20085
20166
|
const targets = [];
|
|
20167
|
+
const written = new Map;
|
|
20086
20168
|
let dir = cwd;
|
|
20087
20169
|
let stack = [];
|
|
20088
20170
|
const segments = segmentsOf(command, dialect);
|
|
@@ -20145,6 +20227,8 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
20145
20227
|
continue;
|
|
20146
20228
|
}
|
|
20147
20229
|
const body = commandWords(segment.words);
|
|
20230
|
+
const before = segments[segments.indexOf(segment) - 1];
|
|
20231
|
+
const feeder = before?.pipe ? before : undefined;
|
|
20148
20232
|
const keywords = segment.words.length - body.length;
|
|
20149
20233
|
for (const keyword of segment.words.slice(0, keywords))
|
|
20150
20234
|
if (OPENS.has(keyword))
|
|
@@ -20198,7 +20282,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
20198
20282
|
}
|
|
20199
20283
|
const plain = !segment.conditional;
|
|
20200
20284
|
if (CD2.has(name)) {
|
|
20201
|
-
dir = cdInto(dir, words, strict, vars);
|
|
20285
|
+
dir = cdInto(dir, words, Boolean(strict), vars, strict === "registry");
|
|
20202
20286
|
moved(plain);
|
|
20203
20287
|
continue;
|
|
20204
20288
|
}
|
|
@@ -20209,7 +20293,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
20209
20293
|
}
|
|
20210
20294
|
if (PUSHD2.has(name)) {
|
|
20211
20295
|
stack.push(dir);
|
|
20212
|
-
dir = cdInto(dir, words, strict, vars);
|
|
20296
|
+
dir = cdInto(dir, words, Boolean(strict), vars, strict === "registry");
|
|
20213
20297
|
moved(plain);
|
|
20214
20298
|
continue;
|
|
20215
20299
|
}
|
|
@@ -20218,15 +20302,94 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
20218
20302
|
moved(plain);
|
|
20219
20303
|
continue;
|
|
20220
20304
|
}
|
|
20221
|
-
const
|
|
20305
|
+
const literal = depth < 4 ? wrappedScript(words) ?? (strict ? shellScript2(words) : null) : null;
|
|
20306
|
+
const held = literal !== null && strict === "registry" ? expansions(literal, vars, loops) : [];
|
|
20307
|
+
const inner = held.length === 1 ? held[0] : literal;
|
|
20222
20308
|
const unPwd = () => new Map([...vars].filter(([key]) => key !== "PWD"));
|
|
20223
20309
|
if (inner !== null && dir !== undefined)
|
|
20224
20310
|
for (const runIn of workitRunDir(dir, words, atAll))
|
|
20225
20311
|
targets.push(...segmentTargets(runIn, inner, "posix", depth + 1, strict, runIn === dir ? vars : unPwd()));
|
|
20312
|
+
const bare = strict === "registry" && depth < 4 ? unwrapped(words) : null;
|
|
20313
|
+
if (bare?.length && dir !== undefined)
|
|
20314
|
+
targets.push(...segmentTargets(dir, bare.flatMap((word) => expansions(word, vars, loops)).map(quoteWord2).join(" "), "posix", depth + 1, strict, vars));
|
|
20315
|
+
if (strict === "registry" && dir !== undefined && depth < 4) {
|
|
20316
|
+
const run = words.slice(Math.max(0, words.findIndex((word) => !PREFIXES2.has(word))));
|
|
20317
|
+
const [verb = "", ...args] = run.map((word, index) => index ? word : (word.split(/[\\/]/).at(-1) ?? "").toLowerCase());
|
|
20318
|
+
const fed = segment.stdin?.join(`
|
|
20319
|
+
`);
|
|
20320
|
+
if (fed !== undefined)
|
|
20321
|
+
for (const file of segment.redirects)
|
|
20322
|
+
for (const into of atAll(file))
|
|
20323
|
+
written.set(into, fed);
|
|
20324
|
+
const read = (file) => atAll(file).flatMap((script) => {
|
|
20325
|
+
const made = written.get(script);
|
|
20326
|
+
if (made !== undefined)
|
|
20327
|
+
return [made];
|
|
20328
|
+
try {
|
|
20329
|
+
const stat = statSync3(script);
|
|
20330
|
+
const text = stat.isFile() && stat.size <= 262144 ? readFileSync9(script, "utf8") : "\x00";
|
|
20331
|
+
return text.includes("\x00") ? [] : [text];
|
|
20332
|
+
} catch {
|
|
20333
|
+
return [];
|
|
20334
|
+
}
|
|
20335
|
+
});
|
|
20336
|
+
const { named: operand, preloads } = scriptArgs(verb, args);
|
|
20337
|
+
const named = operand === "/dev/stdin" ? undefined : operand;
|
|
20338
|
+
const maker = feeder ? commandWords(feeder.words) : [];
|
|
20339
|
+
const [format = "", ...values] = maker.slice(1);
|
|
20340
|
+
let filled = 0;
|
|
20341
|
+
const printed = format.replace(/%[sbq]/g, () => values[filled++] ?? "");
|
|
20342
|
+
const piped = /^(?:echo|printf)$/.test(maker[0] ?? "") ? [[maker[0] === "printf" ? printed : format, ...values].join(`
|
|
20343
|
+
`).replaceAll("\\n", `
|
|
20344
|
+
`)] : maker[0] === "cat" ? [...feeder?.stdin ?? [], ...operands(maker.slice(1)).flatMap(read)] : [];
|
|
20345
|
+
const inputs = (segment.inputs ?? []).filter((file) => file !== "/dev/null");
|
|
20346
|
+
const shells = verb === "eval" ? [args.join(" ")] : verb === "trap" ? args.slice(0, 1) : verb === "alias" ? args.map((arg) => arg.replace(/^[^=]*=/, "")) : [];
|
|
20347
|
+
const others = [];
|
|
20348
|
+
if (SCRIPT_SHELLS.has(verb) || verb === "." || verb === "source") {
|
|
20349
|
+
if (named === undefined && shellScript2(run) === null)
|
|
20350
|
+
shells.push(...segment.stdin ?? [], ...inputs.flatMap(read), ...piped);
|
|
20351
|
+
else if (named !== undefined && shellScript2(run) === null)
|
|
20352
|
+
shells.push(...read(named));
|
|
20353
|
+
shells.push(...preloads.flatMap(read));
|
|
20354
|
+
} else if (INTERPRETERS.test(verb)) {
|
|
20355
|
+
const code = args.findIndex((arg) => /^-[a-zA-Z]*[ce]$|^--eval$/.test(arg));
|
|
20356
|
+
if (code >= 0)
|
|
20357
|
+
others.push(...expansions(args[code + 1] ?? "", vars, loops));
|
|
20358
|
+
others.push(...named === undefined ? [...segment.stdin ?? [], ...inputs.flatMap(read), ...piped] : read(named), ...preloads.flatMap(read));
|
|
20359
|
+
} else if (/[\\/]/.test(run[0] ?? ""))
|
|
20360
|
+
for (const text of read(run[0]))
|
|
20361
|
+
(/^#!.*\b(?:python|node|bun|deno|ruby|perl|php)/.test(text) ? others : shells).push(text);
|
|
20362
|
+
for (const script of shells)
|
|
20363
|
+
targets.push(...segmentTargets(dir, script, "posix", depth + 1, strict, vars));
|
|
20364
|
+
for (const raw of others) {
|
|
20365
|
+
const text = raw.replace(/^\s*(?:#(?!!)|\/\/|\/?\*).*$/gm, "");
|
|
20366
|
+
const joined = [
|
|
20367
|
+
...text.matchAll(/(?:["'][^"'\s,*?[]+["']\s*[,/+]\s*)+["'][^"'\s,*?[]+["']/g)
|
|
20368
|
+
].map(({ 0: literals, index }) => ({
|
|
20369
|
+
word: literals.replace(/["']\s*[,/+]\s*["']/g, "/").replace(/["']/g, ""),
|
|
20370
|
+
index
|
|
20371
|
+
}));
|
|
20372
|
+
const homes = /homedir\(|expanduser\(|Path\.home\(|['"]HOME['"]|env\.HOME|\$HOME|~/.test(text);
|
|
20373
|
+
const under = (word) => homes ? [path28.join(homeExpanded("~"), word.replace(/^~/, ""))] : [];
|
|
20374
|
+
const found = [
|
|
20375
|
+
...[...text.matchAll(PATHS)].flatMap(({ 0: word, index }) => [...atAll(word), ...under(word)].map((file) => ({ file, index }))),
|
|
20376
|
+
...joined.flatMap(({ word, index }) => under(word).map((file) => ({ file, index })))
|
|
20377
|
+
];
|
|
20378
|
+
for (const { file, index } of found)
|
|
20379
|
+
if (!isRoot(file) || !readsRoot(text, index))
|
|
20380
|
+
targets.push(file);
|
|
20381
|
+
}
|
|
20382
|
+
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"))))
|
|
20383
|
+
for (const file of operands(args))
|
|
20384
|
+
targets.push(...atAll(file));
|
|
20385
|
+
if (verb === "cp" && args.some((arg) => /^-[a-zA-Z]*l|^--link$/.test(arg)))
|
|
20386
|
+
for (const file of operands(args).slice(0, -1))
|
|
20387
|
+
targets.push(...atAll(file));
|
|
20388
|
+
}
|
|
20226
20389
|
if (strict && dir !== undefined) {
|
|
20227
20390
|
const runIn = dir;
|
|
20228
20391
|
for (const sub of depth < 4 ? segment.subs ?? [] : [])
|
|
20229
|
-
targets.push(...segmentTargets(runIn, sub, dialect, depth + 1,
|
|
20392
|
+
targets.push(...segmentTargets(runIn, sub, dialect, depth + 1, strict, vars));
|
|
20230
20393
|
const expanding = new Set(segment.expands ?? []);
|
|
20231
20394
|
const scriptOf = (index) => {
|
|
20232
20395
|
const word = body[index];
|
|
@@ -20242,12 +20405,15 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
20242
20405
|
if (runner !== undefined && expanding.has(keywords + lead + ran) && unresolvedRefs(homeExpanded(runner)).length > 0)
|
|
20243
20406
|
targets.push(unknownVarTarget(runner));
|
|
20244
20407
|
const here = segment.unanalyzable ? DIR_TARGET : `${OPAQUE_TARGET}${encodeURIComponent(runner?.split(/[\\/]/).at(-1) ?? "a command")}`;
|
|
20408
|
+
const quiet = strict === "registry" && INTERPRETERS.test(runner?.split(/[\\/]/).at(-1) ?? "");
|
|
20245
20409
|
for (const file of opaque ?? [])
|
|
20246
20410
|
for (const resolved of atAll(file))
|
|
20247
|
-
|
|
20411
|
+
if (!quiet || !isRoot(resolved))
|
|
20412
|
+
targets.push(file === "." ? path28.join(resolved, here) : resolved);
|
|
20248
20413
|
const ln = words.findIndex((word) => /^ln$/i.test(word.split(/[\\/]/).at(-1) ?? ""));
|
|
20249
|
-
|
|
20250
|
-
|
|
20414
|
+
const lnArgs = words.slice(ln + 1);
|
|
20415
|
+
if (ln >= 0 && words.slice(0, ln).every((word) => PREFIXES2.has(word)) && (strict !== "registry" || !lnArgs.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg))))
|
|
20416
|
+
targets.push(...linkSources(lnArgs, at));
|
|
20251
20417
|
}
|
|
20252
20418
|
for (const file of segment.redirects)
|
|
20253
20419
|
if (!/^\/dev\/(?:null|stdout|stderr|tty)$/.test(file))
|
|
@@ -20282,11 +20448,14 @@ var workitCwd = (dir, args, resolve) => {
|
|
|
20282
20448
|
};
|
|
20283
20449
|
var shellMutationTargets = (cwd, command, dialect = "posix", strict = false) => {
|
|
20284
20450
|
try {
|
|
20451
|
+
const env = new Map(strict === "registry" ? [...command.matchAll(/\$\{?([A-Za-z_]\w*)/g)].filter((match) => !/^(?:OLD)?PWD$/.test(match[1])).map((match) => [match[1], process.env[match[1]] ?? ""]) : []);
|
|
20285
20452
|
return [
|
|
20286
|
-
...segmentTargets(cwd, command, dialect, 0, strict),
|
|
20453
|
+
...segmentTargets(cwd, command, dialect, 0, strict, env),
|
|
20287
20454
|
...gitMutationDirs(cwd, command, dialect).map((dir) => path28.join(dir, DIR_TARGET))
|
|
20288
20455
|
];
|
|
20289
|
-
} catch {
|
|
20456
|
+
} catch (error) {
|
|
20457
|
+
if (strict === "registry")
|
|
20458
|
+
throw error;
|
|
20290
20459
|
return [];
|
|
20291
20460
|
}
|
|
20292
20461
|
};
|
|
@@ -20344,12 +20513,79 @@ var claimAll = (owner, targets, deps) => {
|
|
|
20344
20513
|
};
|
|
20345
20514
|
var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path28.resolve(cwd, file)) : [path28.join(cwd, DIR_TARGET)];
|
|
20346
20515
|
var configDirs = () => [resolveConfigDir(), grantsDir()];
|
|
20516
|
+
var globbed = (cwd, target, state, configs) => {
|
|
20517
|
+
if (!/[*?[]/.test(target))
|
|
20518
|
+
return [];
|
|
20519
|
+
const raw = path28.resolve(cwd, target).split(path28.sep);
|
|
20520
|
+
const literal = raw.findIndex((part) => /[*?[]/.test(part));
|
|
20521
|
+
const pattern = [
|
|
20522
|
+
...canonical3(raw.slice(0, literal).join(path28.sep) || path28.sep).replace(/[\\/]+$/, "").split(path28.sep),
|
|
20523
|
+
...raw.slice(literal)
|
|
20524
|
+
];
|
|
20525
|
+
const segment = (glob, name) => {
|
|
20526
|
+
try {
|
|
20527
|
+
return new RegExp(`^${glob.startsWith(".") ? "" : "(?!\\.)"}${glob.replace(/[.+^$(){}|\\]/g, "\\$&").replace(/\[!/g, "[^").replaceAll("*", ".*").replaceAll("?", ".")}$`, CASE_INSENSITIVE ? "i" : "").test(name);
|
|
20528
|
+
} catch {
|
|
20529
|
+
return false;
|
|
20530
|
+
}
|
|
20531
|
+
};
|
|
20532
|
+
const hit = (file, below) => {
|
|
20533
|
+
const parts = canonical3(file).split(path28.sep);
|
|
20534
|
+
return (below ? pattern.length >= parts.length : pattern.length === parts.length) && parts.every((part, index) => segment(pattern[index], part));
|
|
20535
|
+
};
|
|
20536
|
+
let roots = [];
|
|
20537
|
+
try {
|
|
20538
|
+
roots = readdirSync3(state).filter((name) => /^(?:issued|approvals$)/.test(name));
|
|
20539
|
+
} catch {}
|
|
20540
|
+
return [
|
|
20541
|
+
...roots.map((name) => path28.join(state, name)).filter((root) => hit(root, true)),
|
|
20542
|
+
...configs.flatMap((dir) => [dir, path28.join(dir, "workspaces.json")]).filter((file) => hit(file, false))
|
|
20543
|
+
];
|
|
20544
|
+
};
|
|
20545
|
+
var guardedInodes = (state, configs) => {
|
|
20546
|
+
const seen = new Map;
|
|
20547
|
+
let budget = 2000;
|
|
20548
|
+
const add = (file, registry) => {
|
|
20549
|
+
if (budget-- <= 0)
|
|
20550
|
+
return;
|
|
20551
|
+
const stat = statSync3(file, { throwIfNoEntry: false });
|
|
20552
|
+
if (stat?.isFile())
|
|
20553
|
+
seen.set(`${stat.dev}:${stat.ino}`, registry);
|
|
20554
|
+
else if (stat?.isDirectory())
|
|
20555
|
+
for (const name of readdirSync3(file))
|
|
20556
|
+
add(path28.join(file, name), registry);
|
|
20557
|
+
};
|
|
20558
|
+
try {
|
|
20559
|
+
for (const dir of configs)
|
|
20560
|
+
add(path28.join(dir, "workspaces.json"), "grants");
|
|
20561
|
+
for (const name of readdirSync3(state))
|
|
20562
|
+
if (/^(?:issued|approvals$)/.test(name))
|
|
20563
|
+
add(path28.join(state, name), name === "approvals" ? "approvals" : "issued");
|
|
20564
|
+
} catch {}
|
|
20565
|
+
return seen;
|
|
20566
|
+
};
|
|
20567
|
+
var hardLinked = (file, state, configs, inodes) => {
|
|
20568
|
+
try {
|
|
20569
|
+
const stat = statSync3(file, { throwIfNoEntry: false });
|
|
20570
|
+
if (!stat?.isFile() || stat.nlink < 2 || !stat.ino)
|
|
20571
|
+
return;
|
|
20572
|
+
inodes.map ??= guardedInodes(state, configs);
|
|
20573
|
+
return inodes.map.get(`${stat.dev}:${stat.ino}`);
|
|
20574
|
+
} catch {
|
|
20575
|
+
return;
|
|
20576
|
+
}
|
|
20577
|
+
};
|
|
20347
20578
|
var registryTarget = (cwd, targets) => {
|
|
20348
20579
|
const state = resolveStateDir();
|
|
20349
20580
|
const configs = configDirs();
|
|
20581
|
+
const inodes = {};
|
|
20350
20582
|
for (const target of targets) {
|
|
20351
20583
|
const file = homeExpanded(target);
|
|
20352
|
-
const
|
|
20584
|
+
const glob = globbed(cwd, file, state, configs)[0];
|
|
20585
|
+
const viaGlob = glob === undefined ? null : registryTarget(cwd, [glob]);
|
|
20586
|
+
if (viaGlob)
|
|
20587
|
+
return { file: target, registry: viaGlob.registry };
|
|
20588
|
+
const registry = hardLinked(path28.resolve(cwd, file), state, configs, inodes) ?? underRegistry(state, cwd, file, process.platform, canonical3) ?? (configs.some((dir) => underConfig(dir, cwd, file, process.platform, canonical3)) ? "grants" : null);
|
|
20353
20589
|
if (registry)
|
|
20354
20590
|
return { file: target, registry };
|
|
20355
20591
|
}
|
|
@@ -20371,7 +20607,7 @@ var underRegistry = (state, cwd, target, platform = process.platform, real = (fi
|
|
|
20371
20607
|
};
|
|
20372
20608
|
var underConfig = (dir, cwd, target, platform = process.platform, real = (file) => file) => {
|
|
20373
20609
|
const parts = partsUnder(dir, cwd, target, platform, real);
|
|
20374
|
-
return parts?.length === 1 &&
|
|
20610
|
+
return parts?.length === 1 && ["", "workspaces.json", DIR_TARGET].includes(parts[0]);
|
|
20375
20611
|
};
|
|
20376
20612
|
var unquotedWindowsRegistry = (command, platform = process.platform) => {
|
|
20377
20613
|
if (platform !== "win32" || !command.includes("\\"))
|
|
@@ -20379,8 +20615,21 @@ var unquotedWindowsRegistry = (command, platform = process.platform) => {
|
|
|
20379
20615
|
const flat = (value) => value.replaceAll("\\", "/").toLowerCase();
|
|
20380
20616
|
const text = flat(command);
|
|
20381
20617
|
const state = flat(resolveStateDir());
|
|
20382
|
-
const
|
|
20383
|
-
|
|
20618
|
+
const configs = configDirs().map(flat);
|
|
20619
|
+
const registry = text.includes(`${state}/issued`) ? "issued" : text.includes(`${state}/approvals`) ? "approvals" : configs.some((dir) => text.includes(dir)) ? "grants" : null;
|
|
20620
|
+
if (!registry)
|
|
20621
|
+
return null;
|
|
20622
|
+
const spans = command.replace(/[^\s'"|;&<>()]*\\[^\s'"|;&<>()]*/g, (word) => word.replaceAll("\\", "/"));
|
|
20623
|
+
const writes = shellWrites(spans);
|
|
20624
|
+
const moved = [
|
|
20625
|
+
"",
|
|
20626
|
+
...[...spans.matchAll(/(?:^|[;&|(]\s*)(?:cd|pushd|chdir)\s+([^\s;&|)]+)/g)].map((match) => `${match[1]}/`)
|
|
20627
|
+
];
|
|
20628
|
+
const named = (target) => moved.some((dir) => {
|
|
20629
|
+
const at = flat(/^(?:[a-z]:)?\//i.test(target) ? target : dir + target).replace(/\/\.?\//g, "/");
|
|
20630
|
+
return registry === "grants" ? configs.some((cfg) => [cfg, `${cfg}/`, `${cfg}/workspaces.json`].includes(at)) : at.includes(`${state}/${registry}`);
|
|
20631
|
+
});
|
|
20632
|
+
return writes.writes && (writes.targets === null || writes.targets.some(named)) ? registry : null;
|
|
20384
20633
|
};
|
|
20385
20634
|
var REGISTRY_DENY = {
|
|
20386
20635
|
issued: {
|
|
@@ -20401,9 +20650,10 @@ var REGISTRY_DENY = {
|
|
|
20401
20650
|
};
|
|
20402
20651
|
var registryDeny = ({ file, registry }) => {
|
|
20403
20652
|
const { label, what, unblock } = REGISTRY_DENY[registry];
|
|
20653
|
+
const named = path28.basename(file).startsWith(".workit-") ? path28.dirname(file) : file;
|
|
20404
20654
|
return {
|
|
20405
20655
|
kind: "deny",
|
|
20406
|
-
reason: `workit ${label}: ${
|
|
20656
|
+
reason: `workit ${label}: ${named} is under ${what}. ${unblock}`,
|
|
20407
20657
|
unblock
|
|
20408
20658
|
};
|
|
20409
20659
|
};
|
|
@@ -20425,10 +20675,20 @@ function writeGate(cwd, paths, owner, deps) {
|
|
|
20425
20675
|
function shellGate(cwd, command, owner, dialect = "posix", deps) {
|
|
20426
20676
|
try {
|
|
20427
20677
|
const windows = unquotedWindowsRegistry(command);
|
|
20428
|
-
const forged = registryTarget(cwd,
|
|
20678
|
+
const forged = registryTarget(cwd, shellMutationTargets(cwd, command, dialect, "registry")) ?? (windows ? { file: `the ${windows} registry`, registry: windows } : null);
|
|
20429
20679
|
if (forged)
|
|
20430
20680
|
return registryDeny(forged);
|
|
20431
|
-
} catch {
|
|
20681
|
+
} catch {
|
|
20682
|
+
const text = command.replaceAll("\\", "/").replace(/['"]/g, "").toLowerCase();
|
|
20683
|
+
if (/issued|approvals|workspaces\.json|\.config\/workit|state\/workit/.test(text) || [resolveStateDir(), ...configDirs()].some((dir) => text.includes(dir.replaceAll("\\", "/").toLowerCase()))) {
|
|
20684
|
+
const { unblock } = REGISTRY_DENY.grants;
|
|
20685
|
+
return {
|
|
20686
|
+
kind: "deny",
|
|
20687
|
+
reason: `workit registry guard: Workit could not analyse this command, which names a guarded path; split it into plain commands. ${unblock}`,
|
|
20688
|
+
unblock
|
|
20689
|
+
};
|
|
20690
|
+
}
|
|
20691
|
+
}
|
|
20432
20692
|
const writes = shellWrites(command);
|
|
20433
20693
|
let targets = [];
|
|
20434
20694
|
if (owner)
|
|
@@ -22035,7 +22295,7 @@ function confineImplementerShell(input, command, dialect = "posix") {
|
|
|
22035
22295
|
}
|
|
22036
22296
|
var SCRATCH = ".workit-scratch";
|
|
22037
22297
|
var SHELL_NAMES = /^(?:sh|bash|zsh|dash|ksh|mksh|ash)$/;
|
|
22038
|
-
var
|
|
22298
|
+
var INTERPRETERS2 = /^(?:python[\d.]*|node|bun|deno|ruby|perl|php)$/;
|
|
22039
22299
|
var FED = /^(?:-|\/dev\/stdin|\/dev\/fd\/0|\/proc\/self\/fd\/0)$|^<\(/;
|
|
22040
22300
|
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;
|
|
22041
22301
|
var RUNS = /^(?:sh|bash|zsh|dash|ksh|mksh|ash|python[\d.]*|node|bun|deno|ruby|perl|php|eval|source|\.|workit)$/;
|
|
@@ -22152,7 +22412,7 @@ var judgeRefusal = (command, fed, depth = 0) => {
|
|
|
22152
22412
|
}
|
|
22153
22413
|
}
|
|
22154
22414
|
}
|
|
22155
|
-
if (
|
|
22415
|
+
if (INTERPRETERS2.test(name) && !args.some((arg) => INLINE.test(arg))) {
|
|
22156
22416
|
const operand = args.find((arg, index) => (arg === "-" || !arg.startsWith("-")) && !VALUED.test(args[index - 1] ?? ""));
|
|
22157
22417
|
if (FED.test(operand ?? "") || operand === undefined && !/^(?:bun|deno)$/.test(name))
|
|
22158
22418
|
return unseen;
|
|
@@ -22504,7 +22764,7 @@ var cdWorkitSplit = (command) => {
|
|
|
22504
22764
|
};
|
|
22505
22765
|
|
|
22506
22766
|
// packages/workit-core/src/hooks/model-limit.ts
|
|
22507
|
-
import { closeSync as closeSync2, openSync as openSync2, readdirSync as
|
|
22767
|
+
import { closeSync as closeSync2, openSync as openSync2, readdirSync as readdirSync4, readSync, statSync as statSync5 } from "node:fs";
|
|
22508
22768
|
import os9 from "node:os";
|
|
22509
22769
|
import path33 from "node:path";
|
|
22510
22770
|
var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
|
|
@@ -22704,7 +22964,7 @@ var firstPrompt = (file) => {
|
|
|
22704
22964
|
var claudeProjectSlug = (cwd) => cwd.replace(/[^A-Za-z0-9]/gu, "-");
|
|
22705
22965
|
var listDir = (dir) => {
|
|
22706
22966
|
try {
|
|
22707
|
-
return
|
|
22967
|
+
return readdirSync4(dir).map((name) => path33.join(dir, name));
|
|
22708
22968
|
} catch {
|
|
22709
22969
|
return [];
|
|
22710
22970
|
}
|
package/dist/workit-hook.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// packages/workit-codex/hooks/launcher.ts
|
|
4
|
-
import { readFileSync } from "node:fs";
|
|
4
|
+
import { readFileSync, realpathSync, statSync } 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;
|
|
@@ -46,8 +46,7 @@ var SHELL_TOOLS = new Set(["bash", "unified-exec"]);
|
|
|
46
46
|
var WRITE_TOOLS = new Set(["applypatch", "edit", "write"]);
|
|
47
47
|
var guarded = (text) => {
|
|
48
48
|
const flat = (s) => s.replaceAll("\\", "/").toLowerCase();
|
|
49
|
-
|
|
50
|
-
return /issued|workspaces\.json|\.config\/workit/.test(all) || [stateDir, configDir].some((dir) => all.includes(flat(dir(process.env))));
|
|
49
|
+
return [flat(text), text.replace(/['"\\]/g, "").toLowerCase()].some((all) => /issued|approvals|workspaces\.json|\.config\/workit|state\/workit/.test(all) || [stateDir, configDir].some((dir) => all.includes(flat(dir(process.env)))));
|
|
51
50
|
};
|
|
52
51
|
var quietEvent = () => {
|
|
53
52
|
try {
|
|
@@ -73,7 +72,19 @@ var quietEvent = () => {
|
|
|
73
72
|
return null;
|
|
74
73
|
if (event === "PostToolUse")
|
|
75
74
|
return /\bcommit\b/.test(text) ? null : event;
|
|
76
|
-
|
|
75
|
+
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) => {
|
|
76
|
+
const file = path.resolve(String(value.cwd), word);
|
|
77
|
+
try {
|
|
78
|
+
const stat = statSync(file, { throwIfNoEntry: false });
|
|
79
|
+
if (stat?.isFile() && stat.nlink > 1)
|
|
80
|
+
return true;
|
|
81
|
+
const real = stat ? realpathSync(file) : path.join(realpathSync(path.dirname(file)), path.basename(file));
|
|
82
|
+
return real !== file && guarded(real);
|
|
83
|
+
} catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}));
|
|
87
|
+
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) || writes || maybeHeavy(text, value.cwd) ? null : event;
|
|
77
88
|
} catch {
|
|
78
89
|
return null;
|
|
79
90
|
}
|
|
@@ -86,7 +97,7 @@ if (quiet) {
|
|
|
86
97
|
`);
|
|
87
98
|
} else {
|
|
88
99
|
try {
|
|
89
|
-
const { runCodexHook } = await import("./workit-hook-
|
|
100
|
+
const { runCodexHook } = await import("./workit-hook-1k0ds68w.js");
|
|
90
101
|
await runCodexHook([payload]);
|
|
91
102
|
} catch (error) {
|
|
92
103
|
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.8.
|
|
3
|
+
"version": "1.8.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": [
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"build": "bun scripts/build.ts"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@workit-dev/core": "^1.8.
|
|
45
|
-
"@workit-dev/mcp": "^1.8.
|
|
44
|
+
"@workit-dev/core": "^1.8.2",
|
|
45
|
+
"@workit-dev/mcp": "^1.8.2"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": ">=24"
|