@workit-dev/pi 2.25.2 → 2.25.4
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.
- package/dist/worker.js +3 -0
- package/dist/workit.js +302 -69
- package/package.json +1 -1
package/dist/worker.js
CHANGED
|
@@ -9967,6 +9967,9 @@ var PIDS = new Map;
|
|
|
9967
9967
|
var CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "win32";
|
|
9968
9968
|
var PREFIXES = new Set(["sudo", "command", "env", "nohup", "time", "exec", "xargs", "busybox"]);
|
|
9969
9969
|
var SCRIPT_SHELLS = new Set(["sh", "bash", "zsh", "dash", "ksh"]);
|
|
9970
|
+
var PY_WHOLE = new Set("json re math collections itertools functools datetime time hashlib base64 glob fnmatch csv io string textwrap statistics difflib shlex pprint typing ast tomllib configparser pathlib urllib.parse xml.etree.ElementTree os.path".split(" "));
|
|
9971
|
+
var NODE_WHOLE = new Set("path os url util crypto assert zlib querystring readline buffer".split(" "));
|
|
9972
|
+
var REASONS = new WeakMap;
|
|
9970
9973
|
var cache2 = new Map;
|
|
9971
9974
|
var MUTATING_GIT = new Set([
|
|
9972
9975
|
"add",
|
package/dist/workit.js
CHANGED
|
@@ -10744,7 +10744,7 @@ function verdictCommand(options) {
|
|
|
10744
10744
|
const kind = options.judge === "verifier" ? "<live|unit>" : options.judge === "reviewer" ? "review" : "<live|unit|review>";
|
|
10745
10745
|
return [
|
|
10746
10746
|
"workit ledger verdict <verified|failed|blocked>",
|
|
10747
|
-
options.cwd ?
|
|
10747
|
+
`--cwd ${options.cwd ? shellQuote(options.cwd) : "<candidate worktree>"}`,
|
|
10748
10748
|
`--kind ${kind}`,
|
|
10749
10749
|
`--branch ${options.branch ?? "<branch>"}`,
|
|
10750
10750
|
options.session ? `--session ${options.session}` : null,
|
|
@@ -19910,6 +19910,10 @@ var segmentsOf = (command, dialect = "posix") => {
|
|
|
19910
19910
|
return [{ words: [], redirects: [], unanalyzable: why }];
|
|
19911
19911
|
}
|
|
19912
19912
|
};
|
|
19913
|
+
var afterEnv = (words) => {
|
|
19914
|
+
const at = words.map((word) => word.split(/[\\/]/).at(-1)).lastIndexOf("env");
|
|
19915
|
+
return at >= 0 && words.slice(at + 1).every((word, index, rest) => /^-|=/.test(word) || /^-[^-]*[uCS]$|^--(?:unset|chdir|split-string)$/.test(rest[index - 1] ?? ""));
|
|
19916
|
+
};
|
|
19913
19917
|
var tokenize = (command, dialect) => {
|
|
19914
19918
|
const posix = dialect === "posix";
|
|
19915
19919
|
const segments = [];
|
|
@@ -19937,6 +19941,8 @@ var tokenize = (command, dialect) => {
|
|
|
19937
19941
|
(current.inputs ??= []).push(text);
|
|
19938
19942
|
else {
|
|
19939
19943
|
const at = current.words.length;
|
|
19944
|
+
if (/^[^=-][^=]*=/.test(word) && afterEnv(current.words))
|
|
19945
|
+
word = word.replace(/^[^=]*/, (name) => name.replace(/\W/g, "_"));
|
|
19940
19946
|
current.words.push(...MARKERS.test(word) ? expandBraces(word) : [word]);
|
|
19941
19947
|
if (expanding || !posix && word.startsWith("@"))
|
|
19942
19948
|
(current.expands ??= []).push(...current.words.slice(at).map((_, i) => at + i));
|
|
@@ -20199,7 +20205,7 @@ var stripPrefixes = (input) => {
|
|
|
20199
20205
|
const first = words[0];
|
|
20200
20206
|
if (first === undefined)
|
|
20201
20207
|
return { words, env };
|
|
20202
|
-
const assignment = ASSIGNMENT2.exec(first);
|
|
20208
|
+
const assignment = ASSIGNMENT2.exec(first.replace(/^(\w+)\+=/, "$1="));
|
|
20203
20209
|
if (assignment) {
|
|
20204
20210
|
if (GIT_CONFIG_ENV.test(assignment[1]))
|
|
20205
20211
|
env[assignment[1]] = assignment[2];
|
|
@@ -20725,7 +20731,7 @@ function simpleCommand(command, dialect = "posix", depth = 0, shaped = false) {
|
|
|
20725
20731
|
function workitInvocations(command, dialect = "posix", depth = 0) {
|
|
20726
20732
|
const found = [];
|
|
20727
20733
|
for (const { words } of segmentsOf(command, dialect)) {
|
|
20728
|
-
const at = words.findIndex((word) => !/^\w
|
|
20734
|
+
const at = words.findIndex((word) => !/^\w+\+?=/.test(word) && !LAUNCHERS.has(word));
|
|
20729
20735
|
if (at < 0)
|
|
20730
20736
|
continue;
|
|
20731
20737
|
if (WORKIT_BIN.test(words[at])) {
|
|
@@ -27312,6 +27318,7 @@ import {
|
|
|
27312
27318
|
realpathSync as realpathSync11,
|
|
27313
27319
|
statSync as statSync4
|
|
27314
27320
|
} from "node:fs";
|
|
27321
|
+
import { builtinModules } from "node:module";
|
|
27315
27322
|
import os10 from "node:os";
|
|
27316
27323
|
import path42 from "node:path";
|
|
27317
27324
|
|
|
@@ -27566,10 +27573,45 @@ var exempt = (cwd, root, file, plans) => {
|
|
|
27566
27573
|
var PREFIXES2 = new Set(["sudo", "command", "env", "nohup", "time", "exec", "xargs", "busybox"]);
|
|
27567
27574
|
var operands = (words) => words.filter((item) => !item.startsWith("-"));
|
|
27568
27575
|
var SCRIPT_SHELLS = new Set(["sh", "bash", "zsh", "dash", "ksh"]);
|
|
27576
|
+
var pastOptions = (words, at, takes, assigns = false) => {
|
|
27577
|
+
for (let operand = !takes.includes("#");; at++) {
|
|
27578
|
+
for (;at < words.length && /^-|^\d[\w.,-]*$|^\w+\+?=/.test(words[at]); ) {
|
|
27579
|
+
if (/^\w+\+?=/.test(words[at]) && !assigns)
|
|
27580
|
+
break;
|
|
27581
|
+
operand ||= /^\d/.test(words[at]);
|
|
27582
|
+
at += words[at].length === 2 && words[at][0] === "-" && takes.includes(words[at][1]) ? 2 : 1;
|
|
27583
|
+
}
|
|
27584
|
+
if (operand || at >= words.length)
|
|
27585
|
+
return at;
|
|
27586
|
+
operand = true;
|
|
27587
|
+
}
|
|
27588
|
+
};
|
|
27589
|
+
var pastLead = (input) => {
|
|
27590
|
+
let words = [...input];
|
|
27591
|
+
for (let env = false;words.length && words[0] !== "xargs"; ) {
|
|
27592
|
+
const [word, next = ""] = words;
|
|
27593
|
+
const name = word.split(/[\\/]/).at(-1) ?? "";
|
|
27594
|
+
const split = env ? /^(?:-[^-S]*S|--split-string=?)(.*)$/s.exec(word) : null;
|
|
27595
|
+
let at = 1;
|
|
27596
|
+
if (split)
|
|
27597
|
+
words = [
|
|
27598
|
+
...(split[1] || next).split(/\s+/).filter(Boolean),
|
|
27599
|
+
...words.slice(split[1] ? 1 : 2)
|
|
27600
|
+
];
|
|
27601
|
+
else if (env && word.startsWith("-"))
|
|
27602
|
+
words = words.slice(/^-[^-]*[uC]$|^--(?:unset|chdir)$/.test(word) ? 2 : 1);
|
|
27603
|
+
else if (name !== "env" && WRAPPERS3[name] !== undefined)
|
|
27604
|
+
words = words.slice(pastOptions(words, at, WRAPPERS3[name]));
|
|
27605
|
+
else if (PREFIXES2.has(word) || /^\w+\+?=/.test(word))
|
|
27606
|
+
words = words.slice(1);
|
|
27607
|
+
else
|
|
27608
|
+
break;
|
|
27609
|
+
env = name === "env" || env && word.startsWith("-");
|
|
27610
|
+
}
|
|
27611
|
+
return words;
|
|
27612
|
+
};
|
|
27569
27613
|
var wrappedScript = (input) => {
|
|
27570
|
-
|
|
27571
|
-
while (words.length && (PREFIXES2.has(words[0]) || /^\w+=/.test(words[0])))
|
|
27572
|
-
words = words.slice(1);
|
|
27614
|
+
const words = pastLead(input);
|
|
27573
27615
|
const tail = workitCheckTail(words);
|
|
27574
27616
|
if (!tail)
|
|
27575
27617
|
return null;
|
|
@@ -27581,9 +27623,7 @@ var wrappedScript = (input) => {
|
|
|
27581
27623
|
return tail.argv.map(quoteWord2).join(" ");
|
|
27582
27624
|
};
|
|
27583
27625
|
var editsOf = (input) => {
|
|
27584
|
-
|
|
27585
|
-
while (words.length && (PREFIXES2.has(words[0]) || /^\w+=/.test(words[0])))
|
|
27586
|
-
words = words.slice(1);
|
|
27626
|
+
const words = pastLead(input);
|
|
27587
27627
|
const [verb, ...args] = words;
|
|
27588
27628
|
const name = (verb?.split(/[\\/]/).at(-1) ?? "").toLowerCase();
|
|
27589
27629
|
if (!name || name === "workit" || name === "npx" && args.some((item) => /workit/.test(item)))
|
|
@@ -27663,7 +27703,9 @@ var WRAPPERS3 = {
|
|
|
27663
27703
|
env: "uCS",
|
|
27664
27704
|
nice: "n",
|
|
27665
27705
|
ionice: "cnp",
|
|
27666
|
-
timeout: "sk",
|
|
27706
|
+
timeout: "#sk",
|
|
27707
|
+
chrt: "#TPD",
|
|
27708
|
+
taskset: "#",
|
|
27667
27709
|
stdbuf: "ioe",
|
|
27668
27710
|
time: "fo",
|
|
27669
27711
|
nohup: "",
|
|
@@ -27676,16 +27718,154 @@ var WRAPPERS3 = {
|
|
|
27676
27718
|
bunx: "p"
|
|
27677
27719
|
};
|
|
27678
27720
|
var INTERPRETERS = /^(?:python[\d.]*|node|bun|deno|ruby|perl|php|tsx|ts-node)$/;
|
|
27721
|
+
var INLINE_CODE = /^-[a-zA-Z]*[cep]$|^--(?:eval|print)(?:=|$)/;
|
|
27679
27722
|
var isConfigDir = (file) => configDirs().some((dir) => canonical5(dir) === canonical5(file));
|
|
27680
27723
|
var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals|verdicts)$/.test(path42.relative(canonical5(resolveStateDir()), canonical5(file)));
|
|
27681
27724
|
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)$/;
|
|
27682
|
-
var MUTATING_CALLS = /^(?:renames?(?:Sync)?|move
|
|
27683
|
-
var SPAWNS = /
|
|
27684
|
-
var
|
|
27685
|
-
var
|
|
27686
|
-
const
|
|
27687
|
-
|
|
27688
|
-
|
|
27725
|
+
var MUTATING_CALLS = /^(?:renames?(?:Sync)?|move(?:_into)?|copy(?:2|file|tree|File|_into)?(?: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*|f?truncate(?:Sync)?|ch(?:mod|own)(?:Sync)?|touch|open(?:Sync)?|dump|save|extractall|unpack_archive|put_contents|mv|FileUtils)$/;
|
|
27726
|
+
var SPAWNS = /getattr|Reflect|getOwnPropertyDescriptor|FileIO|\.copy\s*\((?!\s*\))|utime|ch(?:mod|own)|\.delete\s*\(\s*\)|(?:PYTHON|NODE_)\w*\+?=|-r\b|--(?:require|import|env-file|[\w-]*loader)|\b(?:exec\w*|eval|(?:unlink|rename|remove)\w*)\b|\]\s*\(/;
|
|
27727
|
+
var TOKENS = /^[ \t]*(#.*|\/\/.*|\/\*[\s\S]*?\*\/)|\bopen\w*\s*\(\s*(?:(['"])(?![rbtUwax+]*\2)[^'"\\\n]*\2|[\w.]+)?\s*(?:,\s*(?:(['"])[rbt]*\3|encoding\s*=\s*(['"])[\w-]+\4)\s*)*\)|std(?:out|err)\.write|([rRbBuUfF]{0,2})('''|""")(?:\\[\s\S]|(?!\6)[\s\S])*?\6|`((?:\\[\s\S]|\$\{[^{}`]*\}|[^\\`$]|\$(?!\{))*)`|[rR]?[fF][rR]?(['"])((?:\\.|\{[^{}\n]*\}|(?!\8)[^\\\n{}])*)\8|(?<![fF][rR]?)(['"])(?:\\.|(?!\10)[^\\\n])*\10|(?<=(?:^|[^\w$.\]'"`\s]|\b(?:return|typeof|void|delete|case|in|yield|await|else|do))\s*)\/(?![*/])(?:\\.|\[(?:\\.|[^\]\\\n])*\]|[^/\\\n[])+\//gm;
|
|
27728
|
+
var strip = (text, python, modules = []) => text.replace(TOKENS, (token, comment, _path, _mode, _encoding, prefix, triple, template, _quote, fstring, string, at) => {
|
|
27729
|
+
const code = template ?? fstring;
|
|
27730
|
+
if (comment)
|
|
27731
|
+
return python || comment[0] !== "#" ? token.replace(/['"`]/g, "") : token;
|
|
27732
|
+
if (code !== undefined)
|
|
27733
|
+
return `
|
|
27734
|
+
${strip(code.match(/\{[^{}]*\}/g)?.join(`
|
|
27735
|
+
`) ?? "", python, modules)}
|
|
27736
|
+
`;
|
|
27737
|
+
if (string && /^[\w@.:/-]+$/.test(token.slice(1, -1)) && /(?:\b(?:require|import)\s*\(\s*|\b(?:from|import)\s*)$/.test(text.slice(Math.max(0, at - 24), at)))
|
|
27738
|
+
return `«${modules.push(token.slice(1, -1)) - 1}»`;
|
|
27739
|
+
if (string || triple && !/f/i.test(prefix ?? ""))
|
|
27740
|
+
return "0";
|
|
27741
|
+
return token[0] === "o" ? "" : token[0] === "s" ? token.slice(0, 6) : token;
|
|
27742
|
+
});
|
|
27743
|
+
var PY_WHOLE = new Set("json re math collections itertools functools datetime time hashlib base64 glob fnmatch csv io string textwrap statistics difflib shlex pprint typing ast tomllib configparser pathlib urllib.parse xml.etree.ElementTree os.path".split(" "));
|
|
27744
|
+
var NODE_WHOLE = new Set("path os url util crypto assert zlib querystring readline buffer".split(" "));
|
|
27745
|
+
var FS_READS = "readFileSync readFile readdirSync readdir statSync lstatSync stat lstat existsSync accessSync realpathSync readlinkSync createReadStream promises constants";
|
|
27746
|
+
var MEMBERS = {
|
|
27747
|
+
"py os": "path getcwd listdir scandir walk stat environ getenv sep linesep",
|
|
27748
|
+
"py sys": "argv stdin stdout stderr exit version version_info platform path maxsize",
|
|
27749
|
+
"py yaml": "safe_load safe_load_all safe_dump safe_dump_all YAMLError",
|
|
27750
|
+
fs: FS_READS,
|
|
27751
|
+
"fs/promises": FS_READS,
|
|
27752
|
+
process: "argv env cwd exit exitCode stdout stderr stdin platform version versions hrtime",
|
|
27753
|
+
Bun: "file argv env version inspect"
|
|
27754
|
+
};
|
|
27755
|
+
var AMBIENT = {
|
|
27756
|
+
py: /__\w+__|\.\s*_|(?<![\w.])(?:compile|globals|locals|vars|setattr|delattr|breakpoint|help)(?!\w)|get_type_hints|ForwardRef|\.\s*(?:os|sys|subprocess|shutil|builtins|importlib|ctypes|posix|codecs)(?!\w)/,
|
|
27757
|
+
js: /__\w+__|\.\s*_|(?<![\w$.])(?:globalThis|global|module|Function|WebAssembly|Worker|Deno)(?![\w$])|[{,]\s*\[[^\]]*\]\s*:/,
|
|
27758
|
+
raw: /constructor|[gs]etPrototypeOf|getOwnPropertyNames|\bflags?\b/
|
|
27759
|
+
};
|
|
27760
|
+
var OUTSIDE2 = " is outside the modules Workit reads in inline code (json, re, pathlib, os.path, fs reads…)";
|
|
27761
|
+
var unread = (bare, modules, python, text) => {
|
|
27762
|
+
let why = null;
|
|
27763
|
+
const refuse = (what) => {
|
|
27764
|
+
why ??= `\`${what.trim().replace(/«(\d+)»/g, (_, at) => `'${modules[at]}'`)}\`${OUTSIDE2}`;
|
|
27765
|
+
return " ";
|
|
27766
|
+
};
|
|
27767
|
+
const bound = new Map;
|
|
27768
|
+
const members = (module) => python ? PY_WHOLE.has(module) ? "" : MEMBERS[`py ${module}`] : NODE_WHOLE.has(module) || module.endsWith(".json") ? "" : MEMBERS[module];
|
|
27769
|
+
const allows = (list, member) => !list || list.split(" ").includes(member);
|
|
27770
|
+
let rest = bare.replace(python ? /^[ \t]*#.*/gm : /^[ \t]*(?:\/\/.*|\/\*[\s\S]*?\*\/)/gm, " ");
|
|
27771
|
+
if (python) {
|
|
27772
|
+
rest = rest.replace(/(?<![\w.])from\s+([\w.]+)\s+import\s+(\*|\([\w\s,]*\)|\w+(?:\s+as\s+\w+)?(?:\s*,\s*\w+(?:\s+as\s+\w+)?)*)/g, (statement, module, list) => {
|
|
27773
|
+
for (const item of list.replace(/[()]/g, "").split(",")) {
|
|
27774
|
+
const [name, alias = name] = item.trim().split(/\s+as\s+/);
|
|
27775
|
+
const of = members(module);
|
|
27776
|
+
if (members(`${module}.${name}`) !== undefined)
|
|
27777
|
+
bound.set(alias, members(`${module}.${name}`));
|
|
27778
|
+
else if (name === "*" || of === undefined || name && !allows(of, name))
|
|
27779
|
+
return refuse(statement);
|
|
27780
|
+
}
|
|
27781
|
+
return " ";
|
|
27782
|
+
}).replace(/(?<![\w.])import\s+([\w.]+(?:\s+as\s+\w+)?(?:\s*,\s*[\w.]+(?:\s+as\s+\w+)?)*)/g, (statement, list) => {
|
|
27783
|
+
for (const item of list.split(",")) {
|
|
27784
|
+
const [module, alias] = item.trim().split(/\s+as\s+/);
|
|
27785
|
+
const of = members(module);
|
|
27786
|
+
if (of === undefined)
|
|
27787
|
+
return refuse(statement);
|
|
27788
|
+
const [top, next] = module.split(".");
|
|
27789
|
+
if (alias)
|
|
27790
|
+
bound.set(alias, of);
|
|
27791
|
+
else
|
|
27792
|
+
bound.set(top, members(top) ?? next);
|
|
27793
|
+
}
|
|
27794
|
+
return " ";
|
|
27795
|
+
});
|
|
27796
|
+
} else {
|
|
27797
|
+
const use = (statement, at, names, list, member) => {
|
|
27798
|
+
const module = modules[Number(at)].replace(/^node:/, "");
|
|
27799
|
+
const of = members(module);
|
|
27800
|
+
if (of === undefined)
|
|
27801
|
+
return refuse(statement);
|
|
27802
|
+
if (member !== undefined)
|
|
27803
|
+
return allows(of, member) ? " " : refuse(statement);
|
|
27804
|
+
for (const name of names)
|
|
27805
|
+
if (name && !module.endsWith(".json"))
|
|
27806
|
+
bound.set(name, of);
|
|
27807
|
+
for (const item of list?.split(",") ?? []) {
|
|
27808
|
+
const key = item.trim().split(/\s*(?::|\bas\b|=)\s*/)[0];
|
|
27809
|
+
if (key && (!/^[\w$]+$/.test(key) || !allows(of, key)))
|
|
27810
|
+
return refuse(statement);
|
|
27811
|
+
}
|
|
27812
|
+
return of && !names.some(Boolean) && list === undefined ? refuse(statement) : " ";
|
|
27813
|
+
};
|
|
27814
|
+
rest = rest.replace(/(?<![\w$.])import\s*(?:([\w$]+)\s*,?\s*)?(?:\*\s*as\s+([\w$]+)\s*|\{([^{}]*)\}\s*)?(?:from\s*)?«(\d+)»/g, (statement, name, all, list, at = "") => use(statement, at, [name, all], list)).replace(/(?:(?<![\w$.])(?:(?:const|let|var)\s+)?(?:([\w$]+)|\{([^{}]*)\})\s*=\s*(?:await\s+)?)?(?<![\w$.])(?:require|import)\s*\(\s*«(\d+)»\s*\)(?:\s*\.\s*([\w$]+))?/g, (statement, name, list, at = "", member) => use(statement, at, [name], list, member));
|
|
27815
|
+
}
|
|
27816
|
+
const left = /(?<![\w$.])(?:require|import|__import__)(?![\w$])[^;\n]{0,24}/.exec(rest);
|
|
27817
|
+
if (left)
|
|
27818
|
+
refuse(left[0]);
|
|
27819
|
+
const ambient = python ? AMBIENT.py.exec(rest) : AMBIENT.js.exec(rest) ?? AMBIENT.raw.exec(text);
|
|
27820
|
+
if (ambient)
|
|
27821
|
+
refuse(ambient[0]);
|
|
27822
|
+
if (!python) {
|
|
27823
|
+
for (const name of [...builtinModules, "Bun"])
|
|
27824
|
+
if (/^[A-Za-z_]\w*$/.test(name) && name !== "console" && !bound.has(name) && !NODE_WHOLE.has(name))
|
|
27825
|
+
bound.set(name, MEMBERS[name] ?? "-");
|
|
27826
|
+
}
|
|
27827
|
+
for (const [name, of] of bound)
|
|
27828
|
+
for (const use of rest.matchAll(new RegExp(`(?<![\\w$.])${name.replaceAll("$", "\\$")}(?![\\w$])(?:\\s*\\.\\s*([\\w$]+))?`, "g")))
|
|
27829
|
+
if (use[1] === undefined || !allows(of, use[1]))
|
|
27830
|
+
refuse(use[0]);
|
|
27831
|
+
return why;
|
|
27832
|
+
};
|
|
27833
|
+
var renames = (code) => [...code.matchAll(/\.replace\s*\(/g)].some(({ index, 0: call }) => {
|
|
27834
|
+
const given = [""];
|
|
27835
|
+
for (let at = index + call.length, depth = 0;at < code.length; at++) {
|
|
27836
|
+
const char = code[at];
|
|
27837
|
+
if (!depth && char === ")")
|
|
27838
|
+
break;
|
|
27839
|
+
if (!depth && char === ",")
|
|
27840
|
+
given.push("");
|
|
27841
|
+
else {
|
|
27842
|
+
depth += "([{".includes(char) ? 1 : ")]}".includes(char) ? -1 : 0;
|
|
27843
|
+
given[given.length - 1] += char;
|
|
27844
|
+
}
|
|
27845
|
+
}
|
|
27846
|
+
const used = given.map((text) => text.trim());
|
|
27847
|
+
if (used.length > 1 && !used.at(-1))
|
|
27848
|
+
used.pop();
|
|
27849
|
+
return !(used.length >= 2 && used.length <= 3 && used.every((text, at) => text && !text.startsWith("*") && (!/^\w+\s*=(?![=>])/.test(text) || at === 2 && /^count\s*=/.test(text))));
|
|
27850
|
+
});
|
|
27851
|
+
var callsResult = (code) => [...code.matchAll(/\)\s*\(/g)].some(({ index }) => {
|
|
27852
|
+
let at = index;
|
|
27853
|
+
for (let depth = 0;at >= 0; at--) {
|
|
27854
|
+
depth += code[at] === ")" ? 1 : code[at] === "(" ? -1 : 0;
|
|
27855
|
+
if (!depth)
|
|
27856
|
+
break;
|
|
27857
|
+
}
|
|
27858
|
+
return /[\w$\])]\s*$/.test(code.slice(0, Math.max(at, 0))) || !/^\(\s*(?:async\b|function\b|lambda\b|\(?[\w$,\s]*\)?\s*=>)/.test(code.slice(at));
|
|
27859
|
+
});
|
|
27860
|
+
var writesIn = (text, python = false, code = true) => {
|
|
27861
|
+
const modules = [];
|
|
27862
|
+
const bare = strip(text, python, modules);
|
|
27863
|
+
const spawns = SPAWNS.exec(text)?.[0];
|
|
27864
|
+
const word = [...bare.matchAll(/[\w$]+/g)].find(([name]) => !/^(?:append|copy)$/.test(name) && MUTATING_CALLS.test(name))?.[0];
|
|
27865
|
+
return spawns !== undefined ? `\`${spawns}\` may run code or change files` : /['"`]/.test(bare) || /\\[ux]/.test(text) || callsResult(bare) ? "Workit cannot read its strings or a call on a returned value" : (code ? unread(bare, modules, python, text) : null) ?? (renames(bare) ? "`.replace(` may rename a path" : word === undefined ? null : `\`${word}\` may change files`);
|
|
27866
|
+
};
|
|
27867
|
+
var REASONS = new WeakMap;
|
|
27868
|
+
var noted;
|
|
27689
27869
|
var PATH_CALLS = /^(?:join|resolve|normalize|abspath|expanduser|expandvars|Path|PurePath|fspath)$/;
|
|
27690
27870
|
var rootUse = (text, at) => {
|
|
27691
27871
|
let call;
|
|
@@ -27737,11 +27917,8 @@ var scriptArgs = (verb, args) => {
|
|
|
27737
27917
|
};
|
|
27738
27918
|
var unwrapped2 = (words) => {
|
|
27739
27919
|
let at = 0;
|
|
27740
|
-
for (let takes;(takes = WRAPPERS3[words[at]?.split(/[\\/]/).at(-1) ?? ""]) !== undefined; )
|
|
27741
|
-
at
|
|
27742
|
-
while (at < words.length && /^-|^\w+=|^\d[\w.]*$/.test(words[at]))
|
|
27743
|
-
at += words[at].length === 2 && words[at][0] === "-" && takes.includes(words[at][1]) ? 2 : 1;
|
|
27744
|
-
}
|
|
27920
|
+
for (let takes;(takes = WRAPPERS3[words[at]?.split(/[\\/]/).at(-1) ?? ""]) !== undefined; )
|
|
27921
|
+
at = pastOptions(words, at + 1, takes, true);
|
|
27745
27922
|
return at ? words.slice(at) : null;
|
|
27746
27923
|
};
|
|
27747
27924
|
var shellScript3 = (words) => {
|
|
@@ -27767,19 +27944,18 @@ var runsWriter = (words) => {
|
|
|
27767
27944
|
const edits = editsOf(filled);
|
|
27768
27945
|
return edits === null || edits.length > 0 || opaqueWrites(filled) !== null;
|
|
27769
27946
|
};
|
|
27770
|
-
var opaqueWrites = (input, scriptOf = (index) => input[index], fed) => {
|
|
27771
|
-
|
|
27772
|
-
|
|
27773
|
-
|
|
27774
|
-
|
|
27775
|
-
|
|
27776
|
-
|
|
27777
|
-
return runsWriter(words.slice(at)) ? ["."] : null;
|
|
27778
|
-
}
|
|
27779
|
-
words = words.slice(1);
|
|
27947
|
+
var opaqueWrites = (input, scriptOf = (index) => input[index], fed, loads = false) => {
|
|
27948
|
+
const words = pastLead(input);
|
|
27949
|
+
if (words[0] === "xargs") {
|
|
27950
|
+
let at = 1;
|
|
27951
|
+
while (words[at]?.startsWith("-"))
|
|
27952
|
+
at += XARGS_VALUE.test(words[at]) ? 2 : 1;
|
|
27953
|
+
return runsWriter(words.slice(at)) ? ["."] : null;
|
|
27780
27954
|
}
|
|
27781
27955
|
const [verb, ...args] = words;
|
|
27782
27956
|
const name = (verb?.split(/[\\/]/).at(-1) ?? "").toLowerCase();
|
|
27957
|
+
if (/^(?:flock|watch|ssh|parallel|script|su|runuser|strace)$/.test(name))
|
|
27958
|
+
return ["."];
|
|
27783
27959
|
const files = operands(args);
|
|
27784
27960
|
const has = (pattern) => args.some((arg) => pattern.test(arg));
|
|
27785
27961
|
const listed = (named) => named.length ? named : ["."];
|
|
@@ -27806,32 +27982,70 @@ var opaqueWrites = (input, scriptOf = (index) => input[index], fed) => {
|
|
|
27806
27982
|
const end = args.findIndex((arg) => /^[-(!]/.test(arg));
|
|
27807
27983
|
return writes ? listed(end < 0 ? args : args.slice(0, end)) : null;
|
|
27808
27984
|
}
|
|
27809
|
-
if (/^
|
|
27810
|
-
if (!has(/^-i|^--include/))
|
|
27811
|
-
return null;
|
|
27985
|
+
if (/^[gmn]?awk$/.test(name)) {
|
|
27812
27986
|
const named = [];
|
|
27813
|
-
|
|
27987
|
+
const file = has(/^-f$|^--file/);
|
|
27988
|
+
let program;
|
|
27814
27989
|
for (let index = 0;index < args.length; index++)
|
|
27815
|
-
if (/^(?:-[
|
|
27816
|
-
index
|
|
27990
|
+
if (/^(?:-[ifvFe]|--(?:include|file|assign|field-separator|source))$/.test(args[index]))
|
|
27991
|
+
program = /^-e$|^--source$/.test(args[index++]) ? args[index] : program;
|
|
27817
27992
|
else if (args[index].startsWith("-"))
|
|
27818
27993
|
continue;
|
|
27819
|
-
else if (program)
|
|
27820
|
-
program =
|
|
27994
|
+
else if (program === undefined && !file)
|
|
27995
|
+
program = args[index];
|
|
27821
27996
|
else
|
|
27822
27997
|
named.push(args[index]);
|
|
27823
|
-
|
|
27998
|
+
if (has(/^-i|^--include/))
|
|
27999
|
+
return listed(named);
|
|
28000
|
+
return file || /system|printf?[^;}\n]*[>|]|\|&?\s*getline/.test(program ?? "") ? [".", ...pathsIn(program ?? "")] : null;
|
|
28001
|
+
}
|
|
28002
|
+
if (name === "sed") {
|
|
28003
|
+
const scripts = [];
|
|
28004
|
+
let first;
|
|
28005
|
+
for (let index = 0;index < args.length; index++) {
|
|
28006
|
+
const arg = args[index];
|
|
28007
|
+
if (/^-[nErsuz]*f|^--file/.test(arg))
|
|
28008
|
+
return ["."];
|
|
28009
|
+
if (/^-[nErsuz]*e$|^--expression$/.test(arg))
|
|
28010
|
+
scripts.push(args[++index] ?? "");
|
|
28011
|
+
else if (arg.startsWith("--expression="))
|
|
28012
|
+
scripts.push(arg.slice(13));
|
|
28013
|
+
else if (/^-l$|^--line-length$/.test(arg))
|
|
28014
|
+
index++;
|
|
28015
|
+
else if (!arg.startsWith("-"))
|
|
28016
|
+
first ??= arg;
|
|
28017
|
+
}
|
|
28018
|
+
if (!scripts.length && first !== undefined)
|
|
28019
|
+
scripts.push(first);
|
|
28020
|
+
const writes = scripts.some((script) => /[wWe]/.test(script.replace(/s(.)(?:\\.|(?!\1)[^\\\n])*\1(?:\\.|(?!\1)[^\\\n])*\1([^;}\n]*)/g, (_, _at, flags) => /[we]/.test(flags) ? "w" : "").replace(/y(.)(?:\\.|(?!\1)[^\\\n])*\1(?:\\.|(?!\1)[^\\\n])*\1/g, "").replace(/\\(.)(?:\\.|(?!\1)[^\\\n])*\1|\/(?:\\.|[^/\\\n])*\//g, "")));
|
|
28021
|
+
if (writes)
|
|
28022
|
+
return [".", ...scripts.flatMap(pathsIn)];
|
|
27824
28023
|
}
|
|
27825
28024
|
const inline = (flag) => {
|
|
27826
|
-
const
|
|
28025
|
+
const codes = args.flatMap((arg, at) => flag.test(arg) ? [at] : []);
|
|
28026
|
+
const at = codes[0] ?? -1;
|
|
27827
28027
|
if (at < 0 && (fed === undefined || !/^(?:-|\/dev\/stdin)?$/.test(scriptArgs(name, args).named ?? "")))
|
|
27828
28028
|
return null;
|
|
27829
28029
|
const runs = input.length - args.length - 1;
|
|
27830
|
-
const texts = input.map((word, index) => index === runs || index < runs && !/^\w
|
|
27831
|
-
|
|
27832
|
-
|
|
27833
|
-
|
|
27834
|
-
|
|
28030
|
+
const texts = input.map((word, index) => index === runs || index < runs && !/^\w+\+?=/.test(word) ? "" : scriptOf(index));
|
|
28031
|
+
const joined = (index) => args[index].includes("=");
|
|
28032
|
+
const code = new Set(codes.map((index) => runs + index + (joined(index) ? 1 : 2)));
|
|
28033
|
+
const python = name.startsWith("py");
|
|
28034
|
+
let why = null;
|
|
28035
|
+
if (loads || !/^(?:python[\d.]*|node|bun)$/.test(name))
|
|
28036
|
+
why = "";
|
|
28037
|
+
const given = [
|
|
28038
|
+
...at < 0 ? [fed] : [],
|
|
28039
|
+
...codes.map((index) => joined(index) ? texts[runs + index + 1]?.replace(/^[^=]*=/, "") : texts[runs + index + 2])
|
|
28040
|
+
];
|
|
28041
|
+
for (const [index, text] of [
|
|
28042
|
+
...given,
|
|
28043
|
+
...texts.slice(0, runs + 1 + (at < 0 || !python ? args.length : at)).filter((_, place) => !code.has(place))
|
|
28044
|
+
].entries())
|
|
28045
|
+
why ??= text === undefined || text === null ? "Workit cannot read its code" : writesIn(text, python, index < given.length);
|
|
28046
|
+
if (why)
|
|
28047
|
+
noted ??= why;
|
|
28048
|
+
return why === null ? null : [
|
|
27835
28049
|
".",
|
|
27836
28050
|
...pathsIn(fed ?? ""),
|
|
27837
28051
|
...texts.flatMap((text, index) => text === undefined ? [unknownVarTarget(input[index])] : pathsIn(text))
|
|
@@ -27841,10 +28055,12 @@ var opaqueWrites = (input, scriptOf = (index) => input[index], fed) => {
|
|
|
27841
28055
|
return curlOutputs(args);
|
|
27842
28056
|
if (name === "perl")
|
|
27843
28057
|
return inline(/^-[a-zA-Z]*[eE]$/);
|
|
27844
|
-
if (name.startsWith("python") && args.some((arg, at) => arg
|
|
28058
|
+
if (name.startsWith("python") && args.some((arg, at) => /^-[^-m]*m/.test(arg) && ((arg.replace(/^-[^-m]*m/, "") || args[at + 1]) !== "json.tool" || operands(args.slice(at + (arg.length > 2 ? 1 : 2))).filter((word) => !/^\d+$/.test(word)).length > 1)))
|
|
27845
28059
|
return [".", ...args.flatMap(pathsIn)];
|
|
27846
|
-
if (
|
|
27847
|
-
return
|
|
28060
|
+
if (name === "deno" && operands(args)[0] === "eval")
|
|
28061
|
+
return ["."];
|
|
28062
|
+
if (/^(?:python[\d.]*|node|bun|deno|ruby|php|tsx|ts-node)$/.test(name))
|
|
28063
|
+
return inline(INLINE_CODE);
|
|
27848
28064
|
return shellScript3(words) === null ? null : ["."];
|
|
27849
28065
|
};
|
|
27850
28066
|
var CURL_LONG = [
|
|
@@ -28170,19 +28386,25 @@ var placeholderIn = (dir, name) => {
|
|
|
28170
28386
|
};
|
|
28171
28387
|
var recording = (make) => {
|
|
28172
28388
|
const outer = collecting;
|
|
28389
|
+
const before = noted;
|
|
28173
28390
|
const found = new Set;
|
|
28174
28391
|
collecting = found;
|
|
28392
|
+
noted = undefined;
|
|
28175
28393
|
try {
|
|
28176
28394
|
const targets = make();
|
|
28177
28395
|
PLACEHOLDERS.set(targets, found);
|
|
28396
|
+
if (noted !== undefined)
|
|
28397
|
+
REASONS.set(targets, noted);
|
|
28178
28398
|
for (const target of found)
|
|
28179
28399
|
outer?.add(target);
|
|
28180
28400
|
return targets;
|
|
28181
28401
|
} finally {
|
|
28182
28402
|
collecting = outer;
|
|
28403
|
+
noted = before ?? noted;
|
|
28183
28404
|
}
|
|
28184
28405
|
};
|
|
28185
28406
|
var placeholdersOf = (targets) => PLACEHOLDERS.get(targets) ?? new Set;
|
|
28407
|
+
var inlineWhy = (targets) => REASONS.get(targets);
|
|
28186
28408
|
var OPAQUE_TARGET = ".workit-runs-";
|
|
28187
28409
|
var UNRESOLVED_TARGET = ".workit-unresolved-target";
|
|
28188
28410
|
var LINK_SOURCE = ".workit-link-source";
|
|
@@ -28230,7 +28452,7 @@ var expandVars = (text, vars) => vars.size === 0 || !text.includes("$") ? text :
|
|
|
28230
28452
|
});
|
|
28231
28453
|
var DECLARERS = new Set(["export", "declare", "typeset", "local", "readonly"]);
|
|
28232
28454
|
var assignmentsOf = (words) => {
|
|
28233
|
-
const first = words.findIndex((word) => !/^\w
|
|
28455
|
+
const first = words.findIndex((word) => !/^\w+\+?=/.test(word));
|
|
28234
28456
|
const named = first < 0 ? words : first === 0 && DECLARERS.has(words[0]) ? words.slice(1).filter((word) => !word.startsWith("-")) : [];
|
|
28235
28457
|
return named.flatMap((word) => {
|
|
28236
28458
|
const match = /^(\w+)=(.*)$/s.exec(word);
|
|
@@ -28316,7 +28538,7 @@ var untrustedVars = (segments) => {
|
|
|
28316
28538
|
depth = Math.max(0, depth - 1);
|
|
28317
28539
|
}
|
|
28318
28540
|
const words = segment.words.slice(start);
|
|
28319
|
-
const at = words.findIndex((word) => !/^\w
|
|
28541
|
+
const at = words.findIndex((word) => !/^\w+\+?=/.test(word));
|
|
28320
28542
|
const ifs = (word) => /\bIFS\b/.test(word);
|
|
28321
28543
|
if (segment.subs?.some(ifs) || words.some((w, i) => ifs(w) && !(i < at && words[at] === "read")))
|
|
28322
28544
|
all = true;
|
|
@@ -28525,7 +28747,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
28525
28747
|
loops.delete(name);
|
|
28526
28748
|
continue;
|
|
28527
28749
|
}
|
|
28528
|
-
const lead = body.findIndex((word) => !/^\w
|
|
28750
|
+
const lead = body.findIndex((word) => !/^\w+\+?=/.test(word));
|
|
28529
28751
|
const words = lead < 0 ? [] : body.slice(lead);
|
|
28530
28752
|
if (!segment.conditional && !untrusted.all) {
|
|
28531
28753
|
for (const [key, value] of assignmentsOf(segment.words))
|
|
@@ -28580,7 +28802,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
28580
28802
|
moved(plain);
|
|
28581
28803
|
continue;
|
|
28582
28804
|
}
|
|
28583
|
-
const literal = depth < 4 ? wrappedScript(words) ?? (strict ? shellScript3(words) : null) : null;
|
|
28805
|
+
const literal = depth < 4 ? wrappedScript(words) ?? (strict ? shellScript3(pastLead(words)) : null) : null;
|
|
28584
28806
|
const held = literal !== null && strict === "registry" ? expansions(literal, vars, loops) : [];
|
|
28585
28807
|
const inner = held.length === 1 ? held[0] : literal;
|
|
28586
28808
|
const unPwd = () => new Map([...vars].filter(([key]) => key !== "PWD"));
|
|
@@ -28591,7 +28813,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
28591
28813
|
`)) : null;
|
|
28592
28814
|
if (windows !== null && dir !== undefined)
|
|
28593
28815
|
targets.push(...segmentTargets(dir, windows, "powershell", depth + 1, strict, vars));
|
|
28594
|
-
const bare = strict
|
|
28816
|
+
const bare = strict && depth < 4 ? unwrapped2(words) : null;
|
|
28595
28817
|
if (bare?.length && dir !== undefined)
|
|
28596
28818
|
targets.push(...segmentTargets(dir, bare.flatMap((word) => expansions(word, vars, loops)).map(quoteWord2).join(" "), "posix", depth + 1, strict, vars));
|
|
28597
28819
|
if (strict === "registry" && dir !== undefined && depth < 4) {
|
|
@@ -28634,9 +28856,9 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
28634
28856
|
shells.push(...read(named));
|
|
28635
28857
|
shells.push(...preloads.flatMap(read));
|
|
28636
28858
|
} else if (INTERPRETERS.test(verb)) {
|
|
28637
|
-
const code = args.findIndex((arg) =>
|
|
28859
|
+
const code = args.findIndex((arg) => INLINE_CODE.test(arg));
|
|
28638
28860
|
if (code >= 0)
|
|
28639
|
-
others.push(...expansions(args[code + 1] ?? "", vars, loops));
|
|
28861
|
+
others.push(...expansions(args[code].includes("=") ? args[code] : args[code + 1] ?? "", vars, loops));
|
|
28640
28862
|
others.push(...named === undefined ? [...segment.stdin ?? [], ...inputs.flatMap(read), ...piped] : read(named), ...preloads.flatMap(read));
|
|
28641
28863
|
} else if (/[\\/]/.test(run[0] ?? ""))
|
|
28642
28864
|
for (const text of read(run[0]))
|
|
@@ -28687,7 +28909,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
28687
28909
|
return all.some((text) => unresolvedRefs(text).some(unescaped)) ? undefined : all.join(`
|
|
28688
28910
|
`);
|
|
28689
28911
|
};
|
|
28690
|
-
const opaque = segment.unanalyzable ? ["."] : inner === null ? opaqueWrites(body, scriptOf, stdin && (
|
|
28912
|
+
const opaque = segment.unanalyzable ? ["."] : inner === null ? opaqueWrites(body, scriptOf, stdin && (/<<-?[ \t]*[^'"\\\s]/.test(command.replaceAll("\\\n", "")) ? /[$`]/.test(stdin) ? null : stdin.replaceAll("\\\n", "") : stdin), /\b(?:NODE_OPTIONS|PYTHON[A-Z]+)\b/.test(command)) : null;
|
|
28691
28913
|
const ran = words.findIndex((word) => word === "xargs" || !PREFIXES2.has(word));
|
|
28692
28914
|
const runner = words[ran];
|
|
28693
28915
|
if (runner !== undefined && expanding.has(keywords + lead + ran) && unresolvedRefs(homeExpanded(runner)).length > 0)
|
|
@@ -28698,6 +28920,16 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
28698
28920
|
for (const resolved of atAll(file))
|
|
28699
28921
|
if (!quiet || !isRoot(resolved))
|
|
28700
28922
|
targets.push(file === "." ? placeholderIn(resolved, here) : path42.basename(resolved).startsWith(OPAQUE_TARGET) ? placeholderIn(path42.dirname(resolved), path42.basename(resolved)) : resolved);
|
|
28923
|
+
const [shell = "", ...shellArgs] = pastLead(words);
|
|
28924
|
+
const verb = (shell.split(/[\\/]/).at(-1) ?? "").toLowerCase();
|
|
28925
|
+
const named = (SCRIPT_SHELLS.has(verb) || verb === "source" || verb === ".") && shellScript3([verb, ...shellArgs]) === null ? scriptArgs(verb, shellArgs).named ?? "" : null;
|
|
28926
|
+
if (depth < 4 && verb === "eval")
|
|
28927
|
+
targets.push(...segmentTargets(runIn, shellArgs.join(" "), dialect, depth + 1, strict, vars));
|
|
28928
|
+
else if (named !== null && /^<\(|^\/dev\/fd\/[1-9]/.test(named))
|
|
28929
|
+
targets.push(placeholderIn(runIn, `${OPAQUE_TARGET}${verb}`));
|
|
28930
|
+
else if (depth < 4 && segment.stdin && named !== null && /^(?:-|\/dev\/stdin|\/dev\/fd\/0|\/proc\/self\/fd\/0)?$/.test(named))
|
|
28931
|
+
for (const script of segment.stdin)
|
|
28932
|
+
targets.push(...segmentTargets(runIn, script, dialect, depth + 1, strict, vars));
|
|
28701
28933
|
const ln = words.findIndex((word) => /^ln$/i.test(word.split(/[\\/]/).at(-1) ?? ""));
|
|
28702
28934
|
const lnArgs = words.slice(ln + 1);
|
|
28703
28935
|
if (ln >= 0 && words.slice(0, ln).every((word) => PREFIXES2.has(word)) && (strict !== "registry" || !lnArgs.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg))))
|
|
@@ -30865,9 +31097,9 @@ var SCRATCH = ".workit-scratch";
|
|
|
30865
31097
|
var SHELL_NAMES = /^(?:sh|bash|zsh|dash|ksh|mksh|ash)$/;
|
|
30866
31098
|
var INTERPRETERS2 = /^(?:python[\d.]*|node|bun|deno|ruby|perl|php)$/;
|
|
30867
31099
|
var FED = /^(?:-|\/dev\/stdin|\/dev\/fd\/0|\/proc\/self\/fd\/0)$|^<\(/;
|
|
30868
|
-
var LEADS = /^(?:sudo|doas|env|command|builtin|exec|nohup|time|nice|timeout|stdbuf|xargs|busybox|!|\{|if|then|else|elif|do|while|until|\w
|
|
31100
|
+
var LEADS = /^(?:sudo|doas|env|command|builtin|exec|nohup|time|nice|ionice|chrt|taskset|setsid|timeout|stdbuf|npx|bunx|xargs|busybox|!|\{|if|then|else|elif|do|while|until|\w+\+?=.*|[-\d].*)$/s;
|
|
30869
31101
|
var RUNS = /^(?:sh|bash|zsh|dash|ksh|mksh|ash|python[\d.]*|node|bun|deno|ruby|perl|php|eval|source|\.|workit)$/;
|
|
30870
|
-
var INLINE = /^-[a-zA-Z]*[ceEpm]$|^--(?:eval|print
|
|
31102
|
+
var INLINE = /^-[a-zA-Z]*[ceEpm]$|^--(?:eval|print)(?:=|$)|^--(?:test|version|help)$|^-[hvV]$/;
|
|
30871
31103
|
var VALUED2 = /^-[WXIrC]$|^--(?:require|import|loader|conditions|input-type)$/;
|
|
30872
31104
|
var commonDir = (root) => gitDirsAt(root, null, false)?.[1] ?? "";
|
|
30873
31105
|
var inScratch = (real, repo) => {
|
|
@@ -31227,7 +31459,7 @@ var judgeRefusal = (command, fed, depth = 0) => {
|
|
|
31227
31459
|
moved = true;
|
|
31228
31460
|
if (name === "eval" || (name === "source" || name === ".") && FED.test(args[0] ?? ""))
|
|
31229
31461
|
return unseen;
|
|
31230
|
-
const set = words.find((word) => /^(?:NODE_OPTIONS|PYTHON(?:STARTUP|PATH|HOME)|PERL5(?:OPT|LIB)|RUBY(?:OPT|LIB)|LD_\w+|DYLD_\w+|REPLY|OPTARG|OPTIND|MAPFILE|READLINE_\w+|S?RANDOM|SECONDS|LINENO|E?UID|PPID|OLDPWD|_|HOSTNAME|HISTCMD|EPOCH\w*)
|
|
31462
|
+
const set = words.find((word) => /^(?:NODE_OPTIONS|PYTHON(?:STARTUP|PATH|HOME)|PERL5(?:OPT|LIB)|RUBY(?:OPT|LIB)|LD_\w+|DYLD_\w+|REPLY|OPTARG|OPTIND|MAPFILE|READLINE_\w+|S?RANDOM|SECONDS|LINENO|E?UID|PPID|OLDPWD|_|HOSTNAME|HISTCMD|EPOCH\w*)\+?=/.test(word));
|
|
31231
31463
|
if (set)
|
|
31232
31464
|
return `\`${set.slice(0, 80)}\` sets a loader or shell-set name`;
|
|
31233
31465
|
if (SHELL_NAMES.test(name)) {
|
|
@@ -31298,14 +31530,14 @@ var substitutingHeredoc = (command) => {
|
|
|
31298
31530
|
}
|
|
31299
31531
|
return false;
|
|
31300
31532
|
};
|
|
31301
|
-
var judgeDeny = (input, what, target, retry) => {
|
|
31533
|
+
var judgeDeny = (input, what, target, retry, why = "write only there (mkdir -p it); a fix the candidate needs is a finding (`workit finding record`).") => {
|
|
31302
31534
|
const role = input.session.agentType?.endsWith("reviewer") ? "reviewer" : "verifier";
|
|
31303
31535
|
const root = checkoutOf2(input.cwd)?.root;
|
|
31304
31536
|
const candidate = target ? checkoutOf2(target)?.root : undefined;
|
|
31305
31537
|
const other = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ? path49.join(candidate, SCRATCH) : undefined;
|
|
31306
31538
|
const scratch = root ? `${path49.join(root, SCRATCH)}${other ? ` or ${other}` : ""}` : `${SCRATCH}/ at the root of the checkout you judge`;
|
|
31307
31539
|
const call = root ? retry?.((other ?? path49.join(root, SCRATCH)).replaceAll("\\", "/")) : null;
|
|
31308
|
-
const unblock = call ? `Retry as: ${call}` :
|
|
31540
|
+
const unblock = call ? `Retry as: ${call}` : `Why: ${why.replaceAll("<scratch>", other ?? (root ? path49.join(root, SCRATCH) : SCRATCH))}`;
|
|
31309
31541
|
return {
|
|
31310
31542
|
kind: "deny",
|
|
31311
31543
|
reason: `workit scratch confinement: ${role} ${input.session.agentId} may write only in its scratch dir ${scratch}, and ${what}.
|
|
@@ -31322,7 +31554,7 @@ var movedInto = (command, cwd, target, dir) => {
|
|
|
31322
31554
|
}
|
|
31323
31555
|
return null;
|
|
31324
31556
|
};
|
|
31325
|
-
function confineJudge(input, targets, placeholders = placeholdersOf(targets), command) {
|
|
31557
|
+
function confineJudge(input, targets, placeholders = placeholdersOf(targets), command, why = inlineWhy(targets)) {
|
|
31326
31558
|
try {
|
|
31327
31559
|
if (!input.session.agentId)
|
|
31328
31560
|
return NONE5;
|
|
@@ -31347,7 +31579,9 @@ function confineJudge(input, targets, placeholders = placeholdersOf(targets), co
|
|
|
31347
31579
|
if (runsGit ? gitDirs.length > 0 ? gitDirs.every(scratch) : scratch(real) : scratch(real) && !inGitDir(real))
|
|
31348
31580
|
continue;
|
|
31349
31581
|
const runner = runnerAt(target);
|
|
31350
|
-
|
|
31582
|
+
const inline = runner !== null && INTERPRETERS2.test(runner) && why ? why : undefined;
|
|
31583
|
+
const relative = inline !== undefined && /(?<![\w/~$.-])(?:\.{1,2}\/|[\w-]+(?:\/[\w.-]+)*\.(?:json|[cm]?[jt]sx?|py|ya?ml|toml|txt|md|lock|cfg|ini|csv|xml|html?)(?![\w(]))/.test(command ?? "");
|
|
31584
|
+
return judgeDeny(input, runner === null ? `${shown(target)} is outside it` : `\`${runner}\` runs in ${shown(target)}, outside it${inline ? `, and ${inline}` : ""}`, target, (dir) => !command || runsGit || relative ? null : runner === null ? movedInto(command, input.cwd, target, dir) : runFrom(dir, command), relative ? "read with cat, jq, grep or the Read tool, or keep to json/re/pathlib/fs reads; a script that needs more goes in a file in <scratch>." : undefined);
|
|
31351
31585
|
}
|
|
31352
31586
|
return NONE5;
|
|
31353
31587
|
} catch {
|
|
@@ -31414,7 +31648,7 @@ function confineJudgeShell(input, command, dialect = "posix") {
|
|
|
31414
31648
|
shellMutationTargets(input.cwd, command, dialect, true),
|
|
31415
31649
|
...fed.map((body) => shellMutationTargets(input.cwd, body, "posix", true))
|
|
31416
31650
|
];
|
|
31417
|
-
return confineJudge(input, [...lists.flat(), ...git], new Set([...git, ...lists.flatMap((list) => [...placeholdersOf(list)])]), command);
|
|
31651
|
+
return confineJudge(input, [...lists.flat(), ...git], new Set([...git, ...lists.flatMap((list) => [...placeholdersOf(list)])]), command, lists.map(inlineWhy).find(Boolean));
|
|
31418
31652
|
} catch {
|
|
31419
31653
|
return NONE5;
|
|
31420
31654
|
}
|
|
@@ -33009,7 +33243,6 @@ var usageLimitOnStop = (input, agentId, text) => {
|
|
|
33009
33243
|
};
|
|
33010
33244
|
var subagentSession = (session, agentId) => [session, agentId].filter((part) => Boolean(part)).join(":").replace(/[^A-Za-z0-9_.:@/+-]/g, "-").slice(0, 128);
|
|
33011
33245
|
var isolatedGit = (cwd) => `Run git as plain, separate commands inside your worktree (\`git switch -c <branch> <base>\`, ${workspaceTrailers(cwd).enabled ? '`git commit --trailer "Workit-Session=<your session>"`, `git push`; `workit doctor --fix` can install a prepare-commit-msg hook that adds the trailer' : "`git commit` (this workspace sets trailers: false: add no Workit-Session trailer), `git push`"}; add Co-Authored-By with \`git commit --trailer\` in the same commit, never by amending), never \`workit git …\`: Claude Code's worktree isolation refuses a command that wraps git and cannot be turned off (https://code.claude.com/docs/en/worktrees#how-claude-code-enforces-isolation). Never dodge that check by renaming or re-wrapping git. Use workit for the non-git verbs (\`workit check\`, \`workit ledger\`, \`workit pr\`).`;
|
|
33012
|
-
var JUDGE_CWD = " Add `--cwd <candidate worktree>` when your shell is elsewhere.";
|
|
33013
33246
|
var subagentStartText = (input, descriptor, event) => {
|
|
33014
33247
|
const session = input.session.id ?? null;
|
|
33015
33248
|
const { role, isolated, git } = agentSteering(descriptor, input.cwd, {
|
|
@@ -33037,12 +33270,12 @@ ${subagentStartText({ ...input, cwd: "" }, descriptor, event)}`;
|
|
|
33037
33270
|
const checks = judgeChecksLine(cwd);
|
|
33038
33271
|
const checksText = checks ? ` ${checks}` : "";
|
|
33039
33272
|
if (descriptor.host === "codex_cli" || descriptor.host === "codex_desktop")
|
|
33040
|
-
return `${readOnly} Its shell already acts as its own Workit session, so the ledger tells its verdicts apart from the author's. Record the verdict with exactly this command (pick the result${pick}, name the candidate branch if it differs, say what you ran): \`${verdictCommand({ branch, judge, cwd: at })}
|
|
33273
|
+
return `${readOnly} Its shell already acts as its own Workit session, so the ledger tells its verdicts apart from the author's. Record the verdict with exactly this command (pick the result${pick}, name the candidate branch if it differs, say what you ran): \`${verdictCommand({ branch, judge, cwd: at })}\`. Add no session or token option to it, and never set WORKIT_SESSION_ID by hand.${checksText}`;
|
|
33041
33274
|
const token = session ? recordIssuedSession(cwd, session, own) : null;
|
|
33042
33275
|
if (session && !token)
|
|
33043
33276
|
return `${readOnly} ${own} was already issued to an earlier subagent, so no token is handed out again and a verdict under it would be refused (unbound_session). Record no verdict as ${own}: spawn a fresh verifier or reviewer, which gets its own session and token.`;
|
|
33044
33277
|
const line = verdictCommand({ branch, judge, session: own, token, cwd: at });
|
|
33045
|
-
return `${readOnly} Its own Workit session is ${own}, so the ledger tells its verdicts apart from the author's. Record the verdict with exactly this command (pick the result${pick}, name the candidate branch if it differs, say what you ran): \`${line}\`.${
|
|
33278
|
+
return `${readOnly} Its own Workit session is ${own}, so the ledger tells its verdicts apart from the author's. Record the verdict with exactly this command (pick the result${pick}, name the candidate branch if it differs, say what you ran): \`${line}\`.${token ? " The token is this subagent's alone: never write it into a report, a file or a commit. --token needs a workit CLI at least as new as this plugin; if the CLI answers that --token is an unknown option, update the workit CLI (workit upgrade --cli) and record again." : ""}${checksText}`;
|
|
33046
33279
|
};
|
|
33047
33280
|
var PRE_TOOL = new Set(["shell.pre", "write.pre", "tool.pre"]);
|
|
33048
33281
|
function handleHook(input, deps) {
|