@workit-dev/opencode 2.25.2 → 2.25.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/plugin.js +295 -62
  2. package/package.json +2 -2
package/dist/plugin.js CHANGED
@@ -11014,7 +11014,7 @@ function verdictCommand(options) {
11014
11014
  const kind = options.judge === "verifier" ? "<live|unit>" : options.judge === "reviewer" ? "review" : "<live|unit|review>";
11015
11015
  return [
11016
11016
  "workit ledger verdict <verified|failed|blocked>",
11017
- options.cwd ? `--cwd ${shellQuote(options.cwd)}` : null,
11017
+ `--cwd ${options.cwd ? shellQuote(options.cwd) : "<candidate worktree>"}`,
11018
11018
  `--kind ${kind}`,
11019
11019
  `--branch ${options.branch ?? "<branch>"}`,
11020
11020
  options.session ? `--session ${options.session}` : null,
@@ -20111,6 +20111,10 @@ var segmentsOf = (command, dialect = "posix") => {
20111
20111
  return [{ words: [], redirects: [], unanalyzable: why }];
20112
20112
  }
20113
20113
  };
20114
+ var afterEnv = (words) => {
20115
+ const at = words.map((word) => word.split(/[\\/]/).at(-1)).lastIndexOf("env");
20116
+ return at >= 0 && words.slice(at + 1).every((word, index, rest) => /^-|=/.test(word) || /^-[^-]*[uCS]$|^--(?:unset|chdir|split-string)$/.test(rest[index - 1] ?? ""));
20117
+ };
20114
20118
  var tokenize = (command, dialect) => {
20115
20119
  const posix = dialect === "posix";
20116
20120
  const segments = [];
@@ -20138,6 +20142,8 @@ var tokenize = (command, dialect) => {
20138
20142
  (current.inputs ??= []).push(text);
20139
20143
  else {
20140
20144
  const at = current.words.length;
20145
+ if (/^[^=-][^=]*=/.test(word) && afterEnv(current.words))
20146
+ word = word.replace(/^[^=]*/, (name) => name.replace(/\W/g, "_"));
20141
20147
  current.words.push(...MARKERS.test(word) ? expandBraces(word) : [word]);
20142
20148
  if (expanding || !posix && word.startsWith("@"))
20143
20149
  (current.expands ??= []).push(...current.words.slice(at).map((_, i) => at + i));
@@ -20400,7 +20406,7 @@ var stripPrefixes = (input) => {
20400
20406
  const first = words[0];
20401
20407
  if (first === undefined)
20402
20408
  return { words, env };
20403
- const assignment = ASSIGNMENT2.exec(first);
20409
+ const assignment = ASSIGNMENT2.exec(first.replace(/^(\w+)\+=/, "$1="));
20404
20410
  if (assignment) {
20405
20411
  if (GIT_CONFIG_ENV.test(assignment[1]))
20406
20412
  env[assignment[1]] = assignment[2];
@@ -20926,7 +20932,7 @@ function simpleCommand(command, dialect = "posix", depth = 0, shaped = false) {
20926
20932
  function workitInvocations(command, dialect = "posix", depth = 0) {
20927
20933
  const found = [];
20928
20934
  for (const { words } of segmentsOf(command, dialect)) {
20929
- const at = words.findIndex((word) => !/^\w+=/.test(word) && !LAUNCHERS.has(word));
20935
+ const at = words.findIndex((word) => !/^\w+\+?=/.test(word) && !LAUNCHERS.has(word));
20930
20936
  if (at < 0)
20931
20937
  continue;
20932
20938
  if (WORKIT_BIN.test(words[at])) {
@@ -27345,6 +27351,7 @@ import {
27345
27351
  realpathSync as realpathSync11,
27346
27352
  statSync as statSync5
27347
27353
  } from "node:fs";
27354
+ import { builtinModules } from "node:module";
27348
27355
  import os10 from "node:os";
27349
27356
  import path42 from "node:path";
27350
27357
 
@@ -27599,10 +27606,45 @@ var exempt = (cwd, root, file, plans) => {
27599
27606
  var PREFIXES2 = new Set(["sudo", "command", "env", "nohup", "time", "exec", "xargs", "busybox"]);
27600
27607
  var operands = (words) => words.filter((item) => !item.startsWith("-"));
27601
27608
  var SCRIPT_SHELLS = new Set(["sh", "bash", "zsh", "dash", "ksh"]);
27609
+ var pastOptions = (words, at, takes, assigns = false) => {
27610
+ for (let operand = !takes.includes("#");; at++) {
27611
+ for (;at < words.length && /^-|^\d[\w.,-]*$|^\w+\+?=/.test(words[at]); ) {
27612
+ if (/^\w+\+?=/.test(words[at]) && !assigns)
27613
+ break;
27614
+ operand ||= /^\d/.test(words[at]);
27615
+ at += words[at].length === 2 && words[at][0] === "-" && takes.includes(words[at][1]) ? 2 : 1;
27616
+ }
27617
+ if (operand || at >= words.length)
27618
+ return at;
27619
+ operand = true;
27620
+ }
27621
+ };
27622
+ var pastLead = (input) => {
27623
+ let words = [...input];
27624
+ for (let env = false;words.length && words[0] !== "xargs"; ) {
27625
+ const [word, next = ""] = words;
27626
+ const name = word.split(/[\\/]/).at(-1) ?? "";
27627
+ const split = env ? /^(?:-[^-S]*S|--split-string=?)(.*)$/s.exec(word) : null;
27628
+ let at = 1;
27629
+ if (split)
27630
+ words = [
27631
+ ...(split[1] || next).split(/\s+/).filter(Boolean),
27632
+ ...words.slice(split[1] ? 1 : 2)
27633
+ ];
27634
+ else if (env && word.startsWith("-"))
27635
+ words = words.slice(/^-[^-]*[uC]$|^--(?:unset|chdir)$/.test(word) ? 2 : 1);
27636
+ else if (name !== "env" && WRAPPERS3[name] !== undefined)
27637
+ words = words.slice(pastOptions(words, at, WRAPPERS3[name]));
27638
+ else if (PREFIXES2.has(word) || /^\w+\+?=/.test(word))
27639
+ words = words.slice(1);
27640
+ else
27641
+ break;
27642
+ env = name === "env" || env && word.startsWith("-");
27643
+ }
27644
+ return words;
27645
+ };
27602
27646
  var wrappedScript = (input) => {
27603
- let words = input;
27604
- while (words.length && (PREFIXES2.has(words[0]) || /^\w+=/.test(words[0])))
27605
- words = words.slice(1);
27647
+ const words = pastLead(input);
27606
27648
  const tail = workitCheckTail(words);
27607
27649
  if (!tail)
27608
27650
  return null;
@@ -27614,9 +27656,7 @@ var wrappedScript = (input) => {
27614
27656
  return tail.argv.map(quoteWord2).join(" ");
27615
27657
  };
27616
27658
  var editsOf = (input) => {
27617
- let words = input;
27618
- while (words.length && (PREFIXES2.has(words[0]) || /^\w+=/.test(words[0])))
27619
- words = words.slice(1);
27659
+ const words = pastLead(input);
27620
27660
  const [verb, ...args] = words;
27621
27661
  const name = (verb?.split(/[\\/]/).at(-1) ?? "").toLowerCase();
27622
27662
  if (!name || name === "workit" || name === "npx" && args.some((item) => /workit/.test(item)))
@@ -27696,7 +27736,9 @@ var WRAPPERS3 = {
27696
27736
  env: "uCS",
27697
27737
  nice: "n",
27698
27738
  ionice: "cnp",
27699
- timeout: "sk",
27739
+ timeout: "#sk",
27740
+ chrt: "#TPD",
27741
+ taskset: "#",
27700
27742
  stdbuf: "ioe",
27701
27743
  time: "fo",
27702
27744
  nohup: "",
@@ -27709,16 +27751,154 @@ var WRAPPERS3 = {
27709
27751
  bunx: "p"
27710
27752
  };
27711
27753
  var INTERPRETERS = /^(?:python[\d.]*|node|bun|deno|ruby|perl|php|tsx|ts-node)$/;
27754
+ var INLINE_CODE = /^-[a-zA-Z]*[cep]$|^--(?:eval|print)(?:=|$)/;
27712
27755
  var isConfigDir = (file) => configDirs().some((dir) => canonical5(dir) === canonical5(file));
27713
27756
  var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals|verdicts)$/.test(path42.relative(canonical5(resolveStateDir()), canonical5(file)));
27714
27757
  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)$/;
27715
- 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)$/;
27716
- var SPAWNS = /subprocess|child_process|WriteStream|tempfile|sqlite|inplace|getattr|spawn|\bvm\b|Function\s*\(|FileIO|ZipFile|tarfile|shelve|FileHandler|filename\s*=|savefig|utime|ch(?:mod|own)|mkfifo|mknod|\.(?:delete|to_\w+)\s*\(|Path\b.*\.replace\(|Bun\.\$|O_(?:WR|RDW|CR|AP|TR)|(?:PYTHON|NODE_)\w*=|-r\b|--(?:require|import|[\w-]*loader)|\bos\.replace|\b(?:system|popen|exec\w*|fork|eval|shutil|(?:unlink|rename|remove)\w*)\b|\]\s*\(|\brequire\s*\(\s*(?!(['"])(?:(?![a-zA-Z]:)[\w@][^'"]*|[^'"]*\.json)\1)/;
27717
- var FREE_OPEN = /\bopen\w*\s*\(\s*(?:(['"])(?![rbtUwax+]*\1)[^'"]*\1|[\w.]+)?\s*(?:,\s*(?:(['"])[rbt]*\2|encoding\s*=\s*(['"])[\w-]+\3)\s*)*\)/g;
27718
- var writesIn = (text) => {
27719
- const bare = text.replace(FREE_OPEN, "").replace(/std(?:out|err)\.write|(?<![fF][rR]?)(['"])(?:\\.|(?!\1)[^\\\n])*\1/g, "");
27720
- return SPAWNS.test(text) || /['"]/.test(bare) || /\$\{|\\[ux]|(?:^|[(,=:;!&|?{}[\s])\/(?![/*])[^/\n]*['"]/.test(text) || [...bare.matchAll(/[\w$]+/g)].some(([word]) => !/^(?:append|copy)$/.test(word) && MUTATING_CALLS.test(word));
27721
- };
27758
+ 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)$/;
27759
+ 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*\(/;
27760
+ 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;
27761
+ var strip = (text, python, modules = []) => text.replace(TOKENS, (token, comment, _path, _mode, _encoding, prefix, triple, template, _quote, fstring, string, at) => {
27762
+ const code = template ?? fstring;
27763
+ if (comment)
27764
+ return python || comment[0] !== "#" ? token.replace(/['"`]/g, "") : token;
27765
+ if (code !== undefined)
27766
+ return `
27767
+ ${strip(code.match(/\{[^{}]*\}/g)?.join(`
27768
+ `) ?? "", python, modules)}
27769
+ `;
27770
+ 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)))
27771
+ return `«${modules.push(token.slice(1, -1)) - 1}»`;
27772
+ if (string || triple && !/f/i.test(prefix ?? ""))
27773
+ return "0";
27774
+ return token[0] === "o" ? "" : token[0] === "s" ? token.slice(0, 6) : token;
27775
+ });
27776
+ 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(" "));
27777
+ var NODE_WHOLE = new Set("path os url util crypto assert zlib querystring readline buffer".split(" "));
27778
+ var FS_READS = "readFileSync readFile readdirSync readdir statSync lstatSync stat lstat existsSync accessSync realpathSync readlinkSync createReadStream promises constants";
27779
+ var MEMBERS = {
27780
+ "py os": "path getcwd listdir scandir walk stat environ getenv sep linesep",
27781
+ "py sys": "argv stdin stdout stderr exit version version_info platform path maxsize",
27782
+ "py yaml": "safe_load safe_load_all safe_dump safe_dump_all YAMLError",
27783
+ fs: FS_READS,
27784
+ "fs/promises": FS_READS,
27785
+ process: "argv env cwd exit exitCode stdout stderr stdin platform version versions hrtime",
27786
+ Bun: "file argv env version inspect"
27787
+ };
27788
+ var AMBIENT = {
27789
+ 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)/,
27790
+ js: /__\w+__|\.\s*_|(?<![\w$.])(?:globalThis|global|module|Function|WebAssembly|Worker|Deno)(?![\w$])|[{,]\s*\[[^\]]*\]\s*:/,
27791
+ raw: /constructor|[gs]etPrototypeOf|getOwnPropertyNames|\bflags?\b/
27792
+ };
27793
+ var OUTSIDE2 = " is outside the modules Workit reads in inline code (json, re, pathlib, os.path, fs reads…)";
27794
+ var unread = (bare, modules, python, text) => {
27795
+ let why = null;
27796
+ const refuse = (what) => {
27797
+ why ??= `\`${what.trim().replace(/«(\d+)»/g, (_, at) => `'${modules[at]}'`)}\`${OUTSIDE2}`;
27798
+ return " ";
27799
+ };
27800
+ const bound = new Map;
27801
+ const members = (module) => python ? PY_WHOLE.has(module) ? "" : MEMBERS[`py ${module}`] : NODE_WHOLE.has(module) || module.endsWith(".json") ? "" : MEMBERS[module];
27802
+ const allows = (list, member) => !list || list.split(" ").includes(member);
27803
+ let rest = bare.replace(python ? /^[ \t]*#.*/gm : /^[ \t]*(?:\/\/.*|\/\*[\s\S]*?\*\/)/gm, " ");
27804
+ if (python) {
27805
+ 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) => {
27806
+ for (const item of list.replace(/[()]/g, "").split(",")) {
27807
+ const [name, alias = name] = item.trim().split(/\s+as\s+/);
27808
+ const of = members(module);
27809
+ if (members(`${module}.${name}`) !== undefined)
27810
+ bound.set(alias, members(`${module}.${name}`));
27811
+ else if (name === "*" || of === undefined || name && !allows(of, name))
27812
+ return refuse(statement);
27813
+ }
27814
+ return " ";
27815
+ }).replace(/(?<![\w.])import\s+([\w.]+(?:\s+as\s+\w+)?(?:\s*,\s*[\w.]+(?:\s+as\s+\w+)?)*)/g, (statement, list) => {
27816
+ for (const item of list.split(",")) {
27817
+ const [module, alias] = item.trim().split(/\s+as\s+/);
27818
+ const of = members(module);
27819
+ if (of === undefined)
27820
+ return refuse(statement);
27821
+ const [top, next] = module.split(".");
27822
+ if (alias)
27823
+ bound.set(alias, of);
27824
+ else
27825
+ bound.set(top, members(top) ?? next);
27826
+ }
27827
+ return " ";
27828
+ });
27829
+ } else {
27830
+ const use = (statement, at, names, list, member) => {
27831
+ const module = modules[Number(at)].replace(/^node:/, "");
27832
+ const of = members(module);
27833
+ if (of === undefined)
27834
+ return refuse(statement);
27835
+ if (member !== undefined)
27836
+ return allows(of, member) ? " " : refuse(statement);
27837
+ for (const name of names)
27838
+ if (name && !module.endsWith(".json"))
27839
+ bound.set(name, of);
27840
+ for (const item of list?.split(",") ?? []) {
27841
+ const key = item.trim().split(/\s*(?::|\bas\b|=)\s*/)[0];
27842
+ if (key && (!/^[\w$]+$/.test(key) || !allows(of, key)))
27843
+ return refuse(statement);
27844
+ }
27845
+ return of && !names.some(Boolean) && list === undefined ? refuse(statement) : " ";
27846
+ };
27847
+ 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));
27848
+ }
27849
+ const left = /(?<![\w$.])(?:require|import|__import__)(?![\w$])[^;\n]{0,24}/.exec(rest);
27850
+ if (left)
27851
+ refuse(left[0]);
27852
+ const ambient = python ? AMBIENT.py.exec(rest) : AMBIENT.js.exec(rest) ?? AMBIENT.raw.exec(text);
27853
+ if (ambient)
27854
+ refuse(ambient[0]);
27855
+ if (!python) {
27856
+ for (const name of [...builtinModules, "Bun"])
27857
+ if (/^[A-Za-z_]\w*$/.test(name) && name !== "console" && !bound.has(name) && !NODE_WHOLE.has(name))
27858
+ bound.set(name, MEMBERS[name] ?? "-");
27859
+ }
27860
+ for (const [name, of] of bound)
27861
+ for (const use of rest.matchAll(new RegExp(`(?<![\\w$.])${name.replaceAll("$", "\\$")}(?![\\w$])(?:\\s*\\.\\s*([\\w$]+))?`, "g")))
27862
+ if (use[1] === undefined || !allows(of, use[1]))
27863
+ refuse(use[0]);
27864
+ return why;
27865
+ };
27866
+ var renames = (code) => [...code.matchAll(/\.replace\s*\(/g)].some(({ index, 0: call }) => {
27867
+ const given = [""];
27868
+ for (let at = index + call.length, depth = 0;at < code.length; at++) {
27869
+ const char = code[at];
27870
+ if (!depth && char === ")")
27871
+ break;
27872
+ if (!depth && char === ",")
27873
+ given.push("");
27874
+ else {
27875
+ depth += "([{".includes(char) ? 1 : ")]}".includes(char) ? -1 : 0;
27876
+ given[given.length - 1] += char;
27877
+ }
27878
+ }
27879
+ const used = given.map((text) => text.trim());
27880
+ if (used.length > 1 && !used.at(-1))
27881
+ used.pop();
27882
+ return !(used.length >= 2 && used.length <= 3 && used.every((text, at) => text && !text.startsWith("*") && (!/^\w+\s*=(?![=>])/.test(text) || at === 2 && /^count\s*=/.test(text))));
27883
+ });
27884
+ var callsResult = (code) => [...code.matchAll(/\)\s*\(/g)].some(({ index }) => {
27885
+ let at = index;
27886
+ for (let depth = 0;at >= 0; at--) {
27887
+ depth += code[at] === ")" ? 1 : code[at] === "(" ? -1 : 0;
27888
+ if (!depth)
27889
+ break;
27890
+ }
27891
+ 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));
27892
+ });
27893
+ var writesIn = (text, python = false, code = true) => {
27894
+ const modules = [];
27895
+ const bare = strip(text, python, modules);
27896
+ const spawns = SPAWNS.exec(text)?.[0];
27897
+ const word = [...bare.matchAll(/[\w$]+/g)].find(([name]) => !/^(?:append|copy)$/.test(name) && MUTATING_CALLS.test(name))?.[0];
27898
+ 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`);
27899
+ };
27900
+ var REASONS = new WeakMap;
27901
+ var noted;
27722
27902
  var PATH_CALLS = /^(?:join|resolve|normalize|abspath|expanduser|expandvars|Path|PurePath|fspath)$/;
27723
27903
  var rootUse = (text, at) => {
27724
27904
  let call;
@@ -27770,11 +27950,8 @@ var scriptArgs = (verb, args) => {
27770
27950
  };
27771
27951
  var unwrapped = (words) => {
27772
27952
  let at = 0;
27773
- for (let takes;(takes = WRAPPERS3[words[at]?.split(/[\\/]/).at(-1) ?? ""]) !== undefined; ) {
27774
- at++;
27775
- while (at < words.length && /^-|^\w+=|^\d[\w.]*$/.test(words[at]))
27776
- at += words[at].length === 2 && words[at][0] === "-" && takes.includes(words[at][1]) ? 2 : 1;
27777
- }
27953
+ for (let takes;(takes = WRAPPERS3[words[at]?.split(/[\\/]/).at(-1) ?? ""]) !== undefined; )
27954
+ at = pastOptions(words, at + 1, takes, true);
27778
27955
  return at ? words.slice(at) : null;
27779
27956
  };
27780
27957
  var shellScript2 = (words) => {
@@ -27800,19 +27977,18 @@ var runsWriter = (words) => {
27800
27977
  const edits = editsOf(filled);
27801
27978
  return edits === null || edits.length > 0 || opaqueWrites(filled) !== null;
27802
27979
  };
27803
- var opaqueWrites = (input, scriptOf = (index) => input[index], fed) => {
27804
- let words = input;
27805
- while (words.length && (PREFIXES2.has(words[0]) || /^\w+=/.test(words[0]))) {
27806
- if (words[0] === "xargs") {
27807
- let at = 1;
27808
- while (words[at]?.startsWith("-"))
27809
- at += XARGS_VALUE.test(words[at]) ? 2 : 1;
27810
- return runsWriter(words.slice(at)) ? ["."] : null;
27811
- }
27812
- words = words.slice(1);
27980
+ var opaqueWrites = (input, scriptOf = (index) => input[index], fed, loads = false) => {
27981
+ const words = pastLead(input);
27982
+ if (words[0] === "xargs") {
27983
+ let at = 1;
27984
+ while (words[at]?.startsWith("-"))
27985
+ at += XARGS_VALUE.test(words[at]) ? 2 : 1;
27986
+ return runsWriter(words.slice(at)) ? ["."] : null;
27813
27987
  }
27814
27988
  const [verb, ...args] = words;
27815
27989
  const name = (verb?.split(/[\\/]/).at(-1) ?? "").toLowerCase();
27990
+ if (/^(?:flock|watch|ssh|parallel|script|su|runuser|strace)$/.test(name))
27991
+ return ["."];
27816
27992
  const files = operands(args);
27817
27993
  const has = (pattern) => args.some((arg) => pattern.test(arg));
27818
27994
  const listed = (named) => named.length ? named : ["."];
@@ -27839,32 +28015,70 @@ var opaqueWrites = (input, scriptOf = (index) => input[index], fed) => {
27839
28015
  const end = args.findIndex((arg) => /^[-(!]/.test(arg));
27840
28016
  return writes ? listed(end < 0 ? args : args.slice(0, end)) : null;
27841
28017
  }
27842
- if (/^g?awk$/.test(name)) {
27843
- if (!has(/^-i|^--include/))
27844
- return null;
28018
+ if (/^[gmn]?awk$/.test(name)) {
27845
28019
  const named = [];
27846
- let program = !has(/^-f$|^--file/);
28020
+ const file = has(/^-f$|^--file/);
28021
+ let program;
27847
28022
  for (let index = 0;index < args.length; index++)
27848
- if (/^(?:-[ifvF]|--(?:include|file|assign|field-separator))$/.test(args[index]))
27849
- index++;
28023
+ if (/^(?:-[ifvFe]|--(?:include|file|assign|field-separator|source))$/.test(args[index]))
28024
+ program = /^-e$|^--source$/.test(args[index++]) ? args[index] : program;
27850
28025
  else if (args[index].startsWith("-"))
27851
28026
  continue;
27852
- else if (program)
27853
- program = false;
28027
+ else if (program === undefined && !file)
28028
+ program = args[index];
27854
28029
  else
27855
28030
  named.push(args[index]);
27856
- return listed(named);
28031
+ if (has(/^-i|^--include/))
28032
+ return listed(named);
28033
+ return file || /system|printf?[^;}\n]*[>|]|\|&?\s*getline/.test(program ?? "") ? [".", ...pathsIn(program ?? "")] : null;
28034
+ }
28035
+ if (name === "sed") {
28036
+ const scripts = [];
28037
+ let first;
28038
+ for (let index = 0;index < args.length; index++) {
28039
+ const arg = args[index];
28040
+ if (/^-[nErsuz]*f|^--file/.test(arg))
28041
+ return ["."];
28042
+ if (/^-[nErsuz]*e$|^--expression$/.test(arg))
28043
+ scripts.push(args[++index] ?? "");
28044
+ else if (arg.startsWith("--expression="))
28045
+ scripts.push(arg.slice(13));
28046
+ else if (/^-l$|^--line-length$/.test(arg))
28047
+ index++;
28048
+ else if (!arg.startsWith("-"))
28049
+ first ??= arg;
28050
+ }
28051
+ if (!scripts.length && first !== undefined)
28052
+ scripts.push(first);
28053
+ 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, "")));
28054
+ if (writes)
28055
+ return [".", ...scripts.flatMap(pathsIn)];
27857
28056
  }
27858
28057
  const inline = (flag) => {
27859
- const at = args.findIndex((arg) => flag.test(arg));
28058
+ const codes = args.flatMap((arg, at) => flag.test(arg) ? [at] : []);
28059
+ const at = codes[0] ?? -1;
27860
28060
  if (at < 0 && (fed === undefined || !/^(?:-|\/dev\/stdin)?$/.test(scriptArgs(name, args).named ?? "")))
27861
28061
  return null;
27862
28062
  const runs = input.length - args.length - 1;
27863
- const texts = input.map((word, index) => index === runs || index < runs && !/^\w+=/.test(word) ? "" : scriptOf(index));
27864
- return /^(?:python[\d.]*|node|bun)$/.test(name) && [
27865
- at < 0 ? fed : texts[runs + at + 2],
27866
- ...texts.slice(0, runs + 1 + (at < 0 ? args.length : at))
27867
- ].every((text) => text !== undefined && text !== null && !writesIn(text)) ? null : [
28063
+ const texts = input.map((word, index) => index === runs || index < runs && !/^\w+\+?=/.test(word) ? "" : scriptOf(index));
28064
+ const joined = (index) => args[index].includes("=");
28065
+ const code = new Set(codes.map((index) => runs + index + (joined(index) ? 1 : 2)));
28066
+ const python = name.startsWith("py");
28067
+ let why = null;
28068
+ if (loads || !/^(?:python[\d.]*|node|bun)$/.test(name))
28069
+ why = "";
28070
+ const given = [
28071
+ ...at < 0 ? [fed] : [],
28072
+ ...codes.map((index) => joined(index) ? texts[runs + index + 1]?.replace(/^[^=]*=/, "") : texts[runs + index + 2])
28073
+ ];
28074
+ for (const [index, text] of [
28075
+ ...given,
28076
+ ...texts.slice(0, runs + 1 + (at < 0 || !python ? args.length : at)).filter((_, place) => !code.has(place))
28077
+ ].entries())
28078
+ why ??= text === undefined || text === null ? "Workit cannot read its code" : writesIn(text, python, index < given.length);
28079
+ if (why)
28080
+ noted ??= why;
28081
+ return why === null ? null : [
27868
28082
  ".",
27869
28083
  ...pathsIn(fed ?? ""),
27870
28084
  ...texts.flatMap((text, index) => text === undefined ? [unknownVarTarget(input[index])] : pathsIn(text))
@@ -27874,10 +28088,12 @@ var opaqueWrites = (input, scriptOf = (index) => input[index], fed) => {
27874
28088
  return curlOutputs(args);
27875
28089
  if (name === "perl")
27876
28090
  return inline(/^-[a-zA-Z]*[eE]$/);
27877
- if (name.startsWith("python") && args.some((arg, at) => arg === "-m" && args[at + 1] !== "json.tool"))
28091
+ 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)))
27878
28092
  return [".", ...args.flatMap(pathsIn)];
27879
- if (/^(?:python[\d.]*|node|bun|deno|ruby|php)$/.test(name))
27880
- return inline(/^-[a-zA-Z]*[cep]$|^--(?:eval|print)$/);
28093
+ if (name === "deno" && operands(args)[0] === "eval")
28094
+ return ["."];
28095
+ if (/^(?:python[\d.]*|node|bun|deno|ruby|php|tsx|ts-node)$/.test(name))
28096
+ return inline(INLINE_CODE);
27881
28097
  return shellScript2(words) === null ? null : ["."];
27882
28098
  };
27883
28099
  var CURL_LONG = [
@@ -28203,16 +28419,21 @@ var placeholderIn = (dir, name) => {
28203
28419
  };
28204
28420
  var recording = (make) => {
28205
28421
  const outer = collecting;
28422
+ const before = noted;
28206
28423
  const found = new Set;
28207
28424
  collecting = found;
28425
+ noted = undefined;
28208
28426
  try {
28209
28427
  const targets = make();
28210
28428
  PLACEHOLDERS.set(targets, found);
28429
+ if (noted !== undefined)
28430
+ REASONS.set(targets, noted);
28211
28431
  for (const target of found)
28212
28432
  outer?.add(target);
28213
28433
  return targets;
28214
28434
  } finally {
28215
28435
  collecting = outer;
28436
+ noted = before ?? noted;
28216
28437
  }
28217
28438
  };
28218
28439
  var OPAQUE_TARGET = ".workit-runs-";
@@ -28262,7 +28483,7 @@ var expandVars = (text, vars) => vars.size === 0 || !text.includes("$") ? text :
28262
28483
  });
28263
28484
  var DECLARERS = new Set(["export", "declare", "typeset", "local", "readonly"]);
28264
28485
  var assignmentsOf = (words) => {
28265
- const first = words.findIndex((word) => !/^\w+=/.test(word));
28486
+ const first = words.findIndex((word) => !/^\w+\+?=/.test(word));
28266
28487
  const named = first < 0 ? words : first === 0 && DECLARERS.has(words[0]) ? words.slice(1).filter((word) => !word.startsWith("-")) : [];
28267
28488
  return named.flatMap((word) => {
28268
28489
  const match = /^(\w+)=(.*)$/s.exec(word);
@@ -28348,7 +28569,7 @@ var untrustedVars = (segments) => {
28348
28569
  depth = Math.max(0, depth - 1);
28349
28570
  }
28350
28571
  const words = segment.words.slice(start);
28351
- const at = words.findIndex((word) => !/^\w+=/.test(word));
28572
+ const at = words.findIndex((word) => !/^\w+\+?=/.test(word));
28352
28573
  const ifs = (word) => /\bIFS\b/.test(word);
28353
28574
  if (segment.subs?.some(ifs) || words.some((w, i) => ifs(w) && !(i < at && words[at] === "read")))
28354
28575
  all = true;
@@ -28557,7 +28778,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
28557
28778
  loops.delete(name);
28558
28779
  continue;
28559
28780
  }
28560
- const lead = body.findIndex((word) => !/^\w+=/.test(word));
28781
+ const lead = body.findIndex((word) => !/^\w+\+?=/.test(word));
28561
28782
  const words = lead < 0 ? [] : body.slice(lead);
28562
28783
  if (!segment.conditional && !untrusted.all) {
28563
28784
  for (const [key, value] of assignmentsOf(segment.words))
@@ -28612,7 +28833,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
28612
28833
  moved(plain);
28613
28834
  continue;
28614
28835
  }
28615
- const literal = depth < 4 ? wrappedScript(words) ?? (strict ? shellScript2(words) : null) : null;
28836
+ const literal = depth < 4 ? wrappedScript(words) ?? (strict ? shellScript2(pastLead(words)) : null) : null;
28616
28837
  const held = literal !== null && strict === "registry" ? expansions(literal, vars, loops) : [];
28617
28838
  const inner = held.length === 1 ? held[0] : literal;
28618
28839
  const unPwd = () => new Map([...vars].filter(([key]) => key !== "PWD"));
@@ -28623,7 +28844,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
28623
28844
  `)) : null;
28624
28845
  if (windows !== null && dir !== undefined)
28625
28846
  targets.push(...segmentTargets(dir, windows, "powershell", depth + 1, strict, vars));
28626
- const bare = strict === "registry" && depth < 4 ? unwrapped(words) : null;
28847
+ const bare = strict && depth < 4 ? unwrapped(words) : null;
28627
28848
  if (bare?.length && dir !== undefined)
28628
28849
  targets.push(...segmentTargets(dir, bare.flatMap((word) => expansions(word, vars, loops)).map(quoteWord2).join(" "), "posix", depth + 1, strict, vars));
28629
28850
  if (strict === "registry" && dir !== undefined && depth < 4) {
@@ -28666,9 +28887,9 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
28666
28887
  shells.push(...read(named));
28667
28888
  shells.push(...preloads.flatMap(read));
28668
28889
  } else if (INTERPRETERS.test(verb)) {
28669
- const code = args.findIndex((arg) => /^-[a-zA-Z]*[cep]$|^--(?:eval|print)$/.test(arg));
28890
+ const code = args.findIndex((arg) => INLINE_CODE.test(arg));
28670
28891
  if (code >= 0)
28671
- others.push(...expansions(args[code + 1] ?? "", vars, loops));
28892
+ others.push(...expansions(args[code].includes("=") ? args[code] : args[code + 1] ?? "", vars, loops));
28672
28893
  others.push(...named === undefined ? [...segment.stdin ?? [], ...inputs.flatMap(read), ...piped] : read(named), ...preloads.flatMap(read));
28673
28894
  } else if (/[\\/]/.test(run[0] ?? ""))
28674
28895
  for (const text of read(run[0]))
@@ -28719,7 +28940,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
28719
28940
  return all.some((text) => unresolvedRefs(text).some(unescaped)) ? undefined : all.join(`
28720
28941
  `);
28721
28942
  };
28722
- const opaque = segment.unanalyzable ? ["."] : inner === null ? opaqueWrites(body, scriptOf, stdin && (/[$`]/.test(stdin) && /<<-?[ \t]*[^'"\\\s]/.test(command.replaceAll("\\\n", "")) ? null : stdin)) : null;
28943
+ 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;
28723
28944
  const ran = words.findIndex((word) => word === "xargs" || !PREFIXES2.has(word));
28724
28945
  const runner = words[ran];
28725
28946
  if (runner !== undefined && expanding.has(keywords + lead + ran) && unresolvedRefs(homeExpanded(runner)).length > 0)
@@ -28730,6 +28951,16 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
28730
28951
  for (const resolved of atAll(file))
28731
28952
  if (!quiet || !isRoot(resolved))
28732
28953
  targets.push(file === "." ? placeholderIn(resolved, here) : path42.basename(resolved).startsWith(OPAQUE_TARGET) ? placeholderIn(path42.dirname(resolved), path42.basename(resolved)) : resolved);
28954
+ const [shell = "", ...shellArgs] = pastLead(words);
28955
+ const verb = (shell.split(/[\\/]/).at(-1) ?? "").toLowerCase();
28956
+ const named = (SCRIPT_SHELLS.has(verb) || verb === "source" || verb === ".") && shellScript2([verb, ...shellArgs]) === null ? scriptArgs(verb, shellArgs).named ?? "" : null;
28957
+ if (depth < 4 && verb === "eval")
28958
+ targets.push(...segmentTargets(runIn, shellArgs.join(" "), dialect, depth + 1, strict, vars));
28959
+ else if (named !== null && /^<\(|^\/dev\/fd\/[1-9]/.test(named))
28960
+ targets.push(placeholderIn(runIn, `${OPAQUE_TARGET}${verb}`));
28961
+ else if (depth < 4 && segment.stdin && named !== null && /^(?:-|\/dev\/stdin|\/dev\/fd\/0|\/proc\/self\/fd\/0)?$/.test(named))
28962
+ for (const script of segment.stdin)
28963
+ targets.push(...segmentTargets(runIn, script, dialect, depth + 1, strict, vars));
28733
28964
  const ln = words.findIndex((word) => /^ln$/i.test(word.split(/[\\/]/).at(-1) ?? ""));
28734
28965
  const lnArgs = words.slice(ln + 1);
28735
28966
  if (ln >= 0 && words.slice(0, ln).every((word) => PREFIXES2.has(word)) && (strict !== "registry" || !lnArgs.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg))))
@@ -32566,7 +32797,7 @@ var SETTLED_BY_RESTACK = new Set(["checks_pending", "behind_base_required"]);
32566
32797
  // packages/workit-core/src/fanout.ts
32567
32798
  var FANOUT_VERSION = 1;
32568
32799
  var TIERS = ["mundane", "standard", "hard"];
32569
- var REASONS = ["explore", "parallel", "backstop", "high-risk-verify"];
32800
+ var REASONS2 = ["explore", "parallel", "backstop", "high-risk-verify"];
32570
32801
  var fanoutFail = (code, error, unblock, data) => ({
32571
32802
  ok: false,
32572
32803
  code,
@@ -32733,7 +32964,7 @@ function parseStored(raw) {
32733
32964
  base: text(item.base) || raw.trunk,
32734
32965
  worktree: text(item.worktree),
32735
32966
  tier: TIERS.includes(item.tier) ? item.tier : "standard",
32736
- reason: REASONS.includes(item.reason) ? item.reason : null,
32967
+ reason: REASONS2.includes(item.reason) ? item.reason : null,
32737
32968
  dependsOn: list(item.dependsOn),
32738
32969
  scope: globs(item.scope),
32739
32970
  owns: globs(item.owns),
@@ -33568,9 +33799,11 @@ var judgeVerdictText = (root, session, workerContext) => {
33568
33799
  const role = workerRole(workerContext);
33569
33800
  if (role === "implementer")
33570
33801
  return null;
33802
+ const cwd = session.directory ?? root;
33571
33803
  const line = verdictCommand({
33572
- branch: judgeBranch(session.directory ?? root),
33573
- judge: role === "reviewer" ? "reviewer" : null
33804
+ branch: judgeBranch(cwd),
33805
+ judge: role === "reviewer" ? "reviewer" : null,
33806
+ cwd
33574
33807
  });
33575
33808
  return `If this session verifies or reviews a candidate, record its verdict with exactly this command (pick the result and kind, live when you drove the real surface, name the candidate branch if it differs, say what you ran): \`${line}\`. Your shell already acts as your own Workit session ${childSessionId(session.parentID ?? "", session.id)}: pass no --session or --token, and never set WORKIT_SESSION_ID by hand.`;
33576
33809
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/opencode",
3
- "version": "2.25.2",
3
+ "version": "2.25.3",
4
4
  "private": false,
5
5
  "description": "Workit OpenCode plugin — native tools, adaptive policy, and sixteen method skills",
6
6
  "keywords": [
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "@opencode/plugin": "2.3.2",
44
- "@workit-dev/core": "^2.25.2"
44
+ "@workit-dev/core": "^2.25.3"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=24"