@workit-dev/opencode 2.25.5 → 2.25.6

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 +425 -41
  2. package/package.json +2 -2
package/dist/plugin.js CHANGED
@@ -20496,7 +20496,7 @@ var literalOutput = (segment) => {
20496
20496
  };
20497
20497
  var stdinOf = (segment, previous) => segment.stdin ? segment.stdin.join(`
20498
20498
  `) : literalOutput(previous);
20499
- var XARGS_VALUES = new Set(["-n", "-L", "-l", "-P", "-d", "-E", "-e", "-s", "-a", "--arg-file", "--delimiter"].concat([
20499
+ var XARGS_VALUES = new Set(["-n", "-L", "-l", "-P", "-d", "-E", "-e", "-s", "-a", "-R", "--arg-file", "--delimiter"].concat([
20500
20500
  "--max-args",
20501
20501
  "--max-lines",
20502
20502
  "--max-procs",
@@ -20506,6 +20506,7 @@ var XARGS_VALUES = new Set(["-n", "-L", "-l", "-P", "-d", "-E", "-e", "-s", "-a"
20506
20506
  ]));
20507
20507
  var xargsCommands = (words, input) => {
20508
20508
  let replace = null;
20509
+ let insert = null;
20509
20510
  let index = 1;
20510
20511
  for (;index < words.length; index++) {
20511
20512
  const word = words[index];
@@ -20517,6 +20518,10 @@ var xargsCommands = (words, input) => {
20517
20518
  break;
20518
20519
  if (word === "-I")
20519
20520
  replace = words[++index] ?? "{}";
20521
+ else if (word === "-J")
20522
+ insert = words[++index] ?? null;
20523
+ else if (/^-J./.test(word))
20524
+ insert = word.slice(2);
20520
20525
  else if (word === "--replace" || word === "-i")
20521
20526
  replace = "{}";
20522
20527
  else if (word.startsWith("--replace="))
@@ -20531,8 +20536,12 @@ var xargsCommands = (words, input) => {
20531
20536
  return [];
20532
20537
  if (input === undefined)
20533
20538
  return [command];
20539
+ const fed = input.split(/\s+/).filter(Boolean);
20540
+ const at = insert === null ? -1 : command.indexOf(insert);
20541
+ if (at >= 0)
20542
+ return [[...command.slice(0, at), ...fed, ...command.slice(at + 1)]];
20534
20543
  if (replace === null)
20535
- return [[...command, ...input.split(/\s+/).filter(Boolean)]];
20544
+ return [[...command, ...fed]];
20536
20545
  const token = replace;
20537
20546
  return input.split(`
20538
20547
  `).map((line) => line.trim()).filter(Boolean).slice(0, MAX_EXPANSIONS).map((line) => command.map((word) => word.replaceAll(token, line)));
@@ -20550,50 +20559,83 @@ var findCommands = (words) => {
20550
20559
  }
20551
20560
  return found;
20552
20561
  };
20553
- var POWERSHELL_VALUES = /^-(?:f|file|ex|executionpolicy|wd|workingdirectory|config|configurationname|o|outputformat|if|inputformat|inp|w|windowstyle|settingsfile|custompipename|psconsolefile)$/;
20554
- var powershellScript = (words, stdin) => {
20562
+ var POWERSHELL_PARAMETERS = [
20563
+ { name: "command", min: 1, kind: "script" },
20564
+ { name: "commandwithargs", min: 8, aliases: ["cwa"], kind: "args", host: "pwsh" },
20565
+ { name: "configurationname", min: 7, aliases: ["config"], kind: "opaque" },
20566
+ { name: "configurationfile", min: 14, kind: "opaque", host: "pwsh" },
20567
+ { name: "custompipename", min: 2, kind: "value", host: "pwsh" },
20568
+ { name: "encodedcommand", min: 3, aliases: ["e", "ec"], kind: "encoded" },
20569
+ { name: "encodedarguments", min: 8, aliases: ["ea"], kind: "opaque", host: "pwsh" },
20570
+ { name: "executionpolicy", min: 2, aliases: ["ep"], kind: "value" },
20571
+ { name: "file", min: 1, kind: "opaque" },
20572
+ { name: "help", min: 1, aliases: ["?"], kind: "info" },
20573
+ { name: "inputformat", min: 3, aliases: ["if"], kind: "value" },
20574
+ { name: "interactive", min: 4, aliases: ["i"], kind: "switch", host: "pwsh" },
20575
+ { name: "login", min: 1, kind: "opaque", host: "pwsh" },
20576
+ { name: "mta", min: 3, kind: "switch" },
20577
+ { name: "noexit", min: 3, kind: "opaque" },
20578
+ { name: "nologo", min: 3, kind: "switch" },
20579
+ { name: "noninteractive", min: 3, kind: "switch" },
20580
+ { name: "noprofile", min: 3, kind: "switch" },
20581
+ { name: "noprofileloadtime", min: 10, kind: "switch", host: "pwsh" },
20582
+ { name: "outputformat", min: 1, aliases: ["of"], kind: "value" },
20583
+ { name: "psconsolefile", min: 2, kind: "opaque", host: "powershell" },
20584
+ { name: "settingsfile", min: 2, aliases: ["settings"], kind: "opaque", host: "pwsh" },
20585
+ { name: "sshservermode", min: 2, aliases: ["sshs"], kind: "opaque", host: "pwsh" },
20586
+ { name: "sta", min: 3, kind: "switch" },
20587
+ { name: "version", min: 1, kind: "info", host: "pwsh" },
20588
+ { name: "version", min: 1, kind: "value", host: "powershell" },
20589
+ { name: "windowstyle", min: 1, kind: "value" },
20590
+ { name: "workingdirectory", min: 2, aliases: ["wd"], kind: "value" }
20591
+ ];
20592
+ var powershellRun = (words, stdin) => {
20593
+ const host = /powershell/i.test(words[0] ?? "") ? "powershell" : "pwsh";
20594
+ let opaque = false;
20555
20595
  for (let index = 1;index < words.length; index++) {
20556
20596
  const word = words[index];
20557
20597
  if (!/^[-/]/.test(word))
20558
- return null;
20559
- const flag = word.replace(/^[-/]+/, "").toLowerCase();
20560
- if (!flag)
20561
- return null;
20562
- if (flag === "e" || flag === "ec" || flag.length >= 2 && "encodedcommand".startsWith(flag)) {
20598
+ return host === "powershell" ? { script: words.slice(index).join(" "), opaque } : { script: null, opaque: true };
20599
+ const [, key = "", glued] = /^(?:--?|\/)([^:=]*)(?:[:=](.*))?$/s.exec(word) ?? [];
20600
+ const flag = key.toLowerCase();
20601
+ const matches = POWERSHELL_PARAMETERS.filter((parameter) => (parameter.host ?? host) === host && flag !== "" && (parameter.aliases?.includes(flag) || flag.length >= parameter.min && parameter.name.startsWith(flag)));
20602
+ if (matches.length !== 1) {
20603
+ opaque = true;
20604
+ continue;
20605
+ }
20606
+ const [{ kind }] = matches;
20607
+ const value = glued ?? words[index + 1];
20608
+ if (kind === "info")
20609
+ return { script: null, opaque: opaque || index < words.length - 1 };
20610
+ if (kind === "encoded") {
20563
20611
  try {
20564
- return Buffer.from(words[index + 1] ?? "", "base64").toString("utf16le");
20612
+ return { script: Buffer.from(value ?? "", "base64").toString("utf16le"), opaque: true };
20565
20613
  } catch {
20566
- return null;
20614
+ return { script: null, opaque: true };
20567
20615
  }
20568
20616
  }
20569
- if (flag === "cwa" || flag.length >= 8 && "commandwithargs".startsWith(flag))
20570
- return words[index + 1] ?? null;
20571
- if ("command".startsWith(flag))
20572
- return words[index + 1] === "-" ? stdin ?? null : words.slice(index + 1).join(" ");
20573
- if (POWERSHELL_VALUES.test(`-${flag}`)) {
20574
- if (flag === "f" || flag === "file")
20575
- return null;
20576
- index++;
20617
+ if (kind === "args")
20618
+ return {
20619
+ script: value ?? null,
20620
+ opaque: opaque || glued !== undefined || value === undefined
20621
+ };
20622
+ if (kind === "script") {
20623
+ if (value === "-")
20624
+ return { script: stdin ?? null, opaque: true };
20625
+ const rest = glued === undefined ? words.slice(index + 1) : [glued, ...words.slice(index + 1)];
20626
+ return {
20627
+ script: rest.join(" ") || null,
20628
+ opaque: opaque || glued !== undefined || !rest.length
20629
+ };
20577
20630
  }
20578
- }
20579
- return null;
20580
- };
20581
- var powershellOpaque = (words) => {
20582
- for (let index = 1;index < words.length; index++) {
20583
- const flag = /^[-/]+(.+)/.exec(words[index])?.[1].toLowerCase();
20584
- if (flag === undefined)
20585
- return !/powershell/i.test(words[0]);
20586
- if (flag === "e" || flag === "ec" || flag.length >= 2 && "encodedcommand".startsWith(flag))
20587
- return true;
20588
- if ("command".startsWith(flag) || flag === "cwa" || flag.startsWith("commandwith"))
20589
- return false;
20590
- if (flag === "f" || flag === "file")
20591
- return true;
20592
- if (POWERSHELL_VALUES.test(`-${flag}`))
20631
+ opaque ||= kind === "opaque";
20632
+ if (kind !== "switch" && glued === undefined)
20593
20633
  index++;
20594
20634
  }
20595
- return false;
20635
+ return { script: null, opaque: true };
20596
20636
  };
20637
+ var powershellScript = (words, stdin) => powershellRun(words, stdin).script;
20638
+ var powershellOpaque = (words) => powershellRun(words).opaque;
20597
20639
  var cmdScript = (words) => {
20598
20640
  const at = words.findIndex((word, index) => index > 0 && /^\/[ck]$/i.test(word));
20599
20641
  if (at > 0)
@@ -27572,6 +27614,315 @@ var claimLiveSession = (target, owner, deps = {}) => {
27572
27614
  } catch {}
27573
27615
  };
27574
27616
 
27617
+ // packages/workit-core/src/hooks/windows-reads.ts
27618
+ var READ_CMDLETS = new Set([
27619
+ "foreach-object",
27620
+ "out-string",
27621
+ "out-null",
27622
+ "out-host",
27623
+ "write-output",
27624
+ "write-host",
27625
+ "write-verbose",
27626
+ "write-warning",
27627
+ "write-error",
27628
+ "write-debug",
27629
+ "write-information",
27630
+ "test-path",
27631
+ "test-json",
27632
+ "resolve-path",
27633
+ "convert-path",
27634
+ "join-path",
27635
+ "split-path",
27636
+ "compare-object",
27637
+ "group-object",
27638
+ "set-location",
27639
+ "push-location",
27640
+ "pop-location",
27641
+ "help"
27642
+ ]);
27643
+ var READ_VERBS = /^(?:get|select|where|measure|sort|format|convertfrom|convertto)-/;
27644
+ var ALIASES2 = {
27645
+ "?": "where-object",
27646
+ "%": "foreach-object",
27647
+ foreach: "foreach-object",
27648
+ where: "where-object",
27649
+ cat: "get-content",
27650
+ gc: "get-content",
27651
+ type: "get-content",
27652
+ cd: "set-location",
27653
+ chdir: "set-location",
27654
+ sl: "set-location",
27655
+ pushd: "push-location",
27656
+ popd: "pop-location",
27657
+ pwd: "get-location",
27658
+ gl: "get-location",
27659
+ dir: "get-childitem",
27660
+ ls: "get-childitem",
27661
+ gci: "get-childitem",
27662
+ gi: "get-item",
27663
+ gp: "get-itemproperty",
27664
+ gpv: "get-itempropertyvalue",
27665
+ gcm: "get-command",
27666
+ gm: "get-member",
27667
+ gal: "get-alias",
27668
+ gv: "get-variable",
27669
+ gmo: "get-module",
27670
+ gps: "get-process",
27671
+ ps: "get-process",
27672
+ gsv: "get-service",
27673
+ gdr: "get-psdrive",
27674
+ gcb: "get-clipboard",
27675
+ gin: "get-computerinfo",
27676
+ gtz: "get-timezone",
27677
+ gu: "get-unique",
27678
+ ghy: "get-history",
27679
+ h: "get-history",
27680
+ history: "get-history",
27681
+ gjb: "get-job",
27682
+ gerr: "get-error",
27683
+ select: "select-object",
27684
+ sls: "select-string",
27685
+ sort: "sort-object",
27686
+ measure: "measure-object",
27687
+ group: "group-object",
27688
+ compare: "compare-object",
27689
+ diff: "compare-object",
27690
+ fl: "format-list",
27691
+ ft: "format-table",
27692
+ fw: "format-wide",
27693
+ fc: "format-custom",
27694
+ fhx: "format-hex",
27695
+ echo: "write-output",
27696
+ write: "write-output",
27697
+ oh: "out-host",
27698
+ rvpa: "resolve-path",
27699
+ cvpa: "convert-path",
27700
+ man: "help",
27701
+ ac: "add-content",
27702
+ sc: "set-content",
27703
+ clc: "clear-content",
27704
+ cli: "clear-item",
27705
+ clp: "clear-itemproperty",
27706
+ clv: "clear-variable",
27707
+ copy: "copy-item",
27708
+ cp: "copy-item",
27709
+ cpi: "copy-item",
27710
+ cpp: "copy-itemproperty",
27711
+ del: "remove-item",
27712
+ erase: "remove-item",
27713
+ rd: "remove-item",
27714
+ ri: "remove-item",
27715
+ rm: "remove-item",
27716
+ rmdir: "remove-item",
27717
+ rp: "remove-itemproperty",
27718
+ rv: "remove-variable",
27719
+ mi: "move-item",
27720
+ move: "move-item",
27721
+ mv: "move-item",
27722
+ mp: "move-itemproperty",
27723
+ ren: "rename-item",
27724
+ rni: "rename-item",
27725
+ rnp: "rename-itemproperty",
27726
+ ni: "new-item",
27727
+ md: "new-item",
27728
+ mkdir: "new-item",
27729
+ mount: "new-psdrive",
27730
+ ndr: "new-psdrive",
27731
+ nal: "new-alias",
27732
+ nv: "new-variable",
27733
+ nmo: "new-module",
27734
+ si: "set-item",
27735
+ sp: "set-itemproperty",
27736
+ sv: "set-variable",
27737
+ set: "set-variable",
27738
+ sal: "set-alias",
27739
+ scb: "set-clipboard",
27740
+ epal: "export-alias",
27741
+ epcsv: "export-csv",
27742
+ ipal: "import-alias",
27743
+ ipmo: "import-module",
27744
+ ipcsv: "import-csv",
27745
+ tee: "tee-object",
27746
+ start: "start-process",
27747
+ saps: "start-process",
27748
+ sajb: "start-job",
27749
+ sleep: "start-sleep",
27750
+ ii: "invoke-item",
27751
+ icm: "invoke-command",
27752
+ iex: "invoke-expression",
27753
+ ihy: "invoke-history",
27754
+ r: "invoke-history",
27755
+ irm: "invoke-restmethod",
27756
+ iwr: "invoke-webrequest",
27757
+ kill: "stop-process",
27758
+ spps: "stop-process",
27759
+ ogv: "out-gridview"
27760
+ };
27761
+ var KEYWORDS2 = /^(?:if|elseif|else|switch|while|do|until|for|foreach|try|catch|finally|return|break|continue|exit|throw|param|begin|process|end)$/;
27762
+ var WINDOWS_WRITERS = /^(?:xcopy|robocopy|attrib|icacls|cacls|takeown|compact|cipher|expand|extrac32|makecab|fsutil|reg|regedit|setx|schtasks|msiexec|certutil|bitsadmin|replace|subst|mountvol|format|diskpart|wsl|cscript|wscript|mshta|rundll32|regsvr32|call)$/;
27763
+ var READ_METHODS = /^(?:trim(?:start|end)?|split|contains(?:key|value)?|startswith|endswith|substring|(?:last)?indexof(?:any)?|to(?:lower|upper)(?:invariant)?|tostring|tochararray|pad(?:left|right)|equals|compareto|gettype|gethashcode|normalize|where)$/i;
27764
+ var READ_MEMBERS = /^(?:name|fullname|basename|extension|length|count|directory|directoryname|parent|root|exists|mode|lastwritetime(?:utc)?|creationtime(?:utc)?|lastaccesstime(?:utc)?|attributes|linktype|target|pspath|pschildname|path|line|linenumber|filename|matches|value|key|keys|values|id|processname|source|definition|version)$/i;
27765
+ var LOADER_ENV = /^(?:GIT_\w*|PAGER|EDITOR|VISUAL|PATH|LD_\w*|DYLD_\w*|NODE_OPTIONS|PYTHON\w*|BASH_ENV|ENV|PERL5(?:OPT|LIB)|RUBY(?:OPT|LIB))$/i;
27766
+ var CMD_VAR = /%[^%\s]+%|![^!\s]+!/;
27767
+ var NULL_SINK = /^(?:\$null|nul|\/dev\/null)$/i;
27768
+ var pwshCode = (text) => {
27769
+ let out = "";
27770
+ for (let at = 0;at < text.length; at++) {
27771
+ const char = text[at];
27772
+ const here = char === "@" && /['"]/.test(text[at + 1] ?? "") ? text[at + 1] : null;
27773
+ if (char === "<" && text[at + 1] === "#") {
27774
+ const end = text.indexOf("#>", at + 2);
27775
+ at = end < 0 ? text.length : end + 1;
27776
+ } else if (char === "#" && (at === 0 || /[\s;|{(]/.test(text[at - 1])))
27777
+ for (;at < text.length && text[at] !== `
27778
+ `; at++)
27779
+ ;
27780
+ else if (here !== null || char === "'" || char === '"') {
27781
+ const quote = here ?? char;
27782
+ const close = here === null ? quote : `
27783
+ ${quote}@`;
27784
+ let end = at + (here === null ? 1 : 2);
27785
+ const kept = [];
27786
+ while (end < text.length && !text.startsWith(close, end)) {
27787
+ if (quote === '"' && text[end] === "`")
27788
+ end++;
27789
+ else if (quote === "'" && here === null && text.startsWith("''", end))
27790
+ end++;
27791
+ else if (quote === '"' && text.startsWith("$(", end)) {
27792
+ let depth = 0;
27793
+ const start = end;
27794
+ for (;end < text.length; end++)
27795
+ if (text[end] === "(")
27796
+ depth++;
27797
+ else if (text[end] === ")" && --depth === 0)
27798
+ break;
27799
+ kept.push(text.slice(start, end + 1));
27800
+ }
27801
+ end++;
27802
+ }
27803
+ out += `S${kept.join(" ")}`;
27804
+ at = end + close.length - 1;
27805
+ } else
27806
+ out += char;
27807
+ }
27808
+ return out;
27809
+ };
27810
+ var powershellTextWriter = (text) => {
27811
+ const code = pwshCode(text);
27812
+ if (/(?<![&>])&(?![&>])/.test(code))
27813
+ return "&";
27814
+ const statics = /([^\s;|{(]*)\s*::\s*(\w*)/.exec(code);
27815
+ if (statics)
27816
+ return `${statics[1]}::${statics[2]}`;
27817
+ for (const [, name] of code.matchAll(/\$\{?env:(\w+)\}?\s*[-+]?=/gi))
27818
+ if (LOADER_ENV.test(name))
27819
+ return `$env:${name} =`;
27820
+ for (const [, name] of code.matchAll(/\.([A-Za-z_]\w*)\(/g))
27821
+ if (!READ_METHODS.test(name))
27822
+ return `.${name}()`;
27823
+ const member = /\.([A-Za-z_]\w*)\s*[-+*/%]?=/.exec(code);
27824
+ if (member)
27825
+ return `.${member[1]} =`;
27826
+ const drive = /\$\{?(function|alias):/i.exec(code);
27827
+ return drive ? `$${drive[1]}:` : null;
27828
+ };
27829
+ var subexpressions = (word) => {
27830
+ const found = [];
27831
+ for (let at = word.indexOf("$(");at >= 0; at = word.indexOf("$(", at + 1)) {
27832
+ let depth = 0;
27833
+ let end = at + 1;
27834
+ for (;end < word.length; end++)
27835
+ if (word[end] === "(")
27836
+ depth++;
27837
+ else if (word[end] === ")" && --depth === 0)
27838
+ break;
27839
+ found.push(word.slice(at + 2, end));
27840
+ }
27841
+ return found;
27842
+ };
27843
+ var cmdletOf = (name) => {
27844
+ const lower = name.toLowerCase().replace(/[\u2013-\u2015]/g, "-");
27845
+ if (ALIASES2[lower] !== undefined)
27846
+ return ALIASES2[lower];
27847
+ return /^[a-z]+-[a-z0-9]+$/.test(lower) ? lower : null;
27848
+ };
27849
+ var readCmdlet = (cmdlet) => READ_VERBS.test(cmdlet) || READ_CMDLETS.has(cmdlet);
27850
+ var pwshStatementWriter = (segment, depth, prev, next) => {
27851
+ if (segment.redirects.some((file) => !NULL_SINK.test(file)))
27852
+ return ">";
27853
+ let words = segment.words;
27854
+ const glued = /^((?:\[[^\]]*\])*\$[^=\s]+)[-+*/%?]?=(.+)$/s.exec(words[0] ?? "");
27855
+ if (glued)
27856
+ words = [glued[2], ...words.slice(1)];
27857
+ else if (/^(?:\[[^\]]*\])*\$/.test(words[0] ?? "") && /^[-+*/%?]?=$/.test(words[1] ?? ""))
27858
+ words = words.slice(2);
27859
+ for (const word of words)
27860
+ for (const inner of depth < 4 ? subexpressions(word) : [])
27861
+ if (/\S/.test(inner)) {
27862
+ const why = pwshScriptWriter(inner, depth + 1);
27863
+ if (why)
27864
+ return why;
27865
+ }
27866
+ const first = words[0];
27867
+ if (first === undefined)
27868
+ return null;
27869
+ if (first === ".")
27870
+ return ". (dot-source)";
27871
+ if (CMD_VAR.test(first))
27872
+ return first;
27873
+ if (/^[$@(['"\d-]/.test(first) || /^\.[A-Za-z_]/.test(first))
27874
+ return null;
27875
+ if (/[\\/:.]/.test(first))
27876
+ return first;
27877
+ const lower = first.toLowerCase();
27878
+ if (KEYWORDS2.test(lower) && (lower !== "foreach" || words.length === 1 && !prev?.pipe))
27879
+ return null;
27880
+ if (/^(?:function|filter|class|enum|workflow|configuration)$/.test(lower))
27881
+ return first;
27882
+ if (/^(?:pwsh|powershell|cmd)$/.test(lower))
27883
+ return null;
27884
+ const cmdlet = cmdletOf(first);
27885
+ if (cmdlet === null)
27886
+ return WINDOWS_WRITERS.test(lower) ? first : null;
27887
+ if (!readCmdlet(cmdlet))
27888
+ return first;
27889
+ if (cmdlet === "foreach-object") {
27890
+ if (next?.group === "open")
27891
+ return `${first} (…)`;
27892
+ for (const arg of words.slice(1))
27893
+ if (!arg.startsWith("-") && !/^\d+$/.test(arg) && !READ_MEMBERS.test(arg) && !READ_METHODS.test(arg))
27894
+ return `${first} ${arg}`;
27895
+ }
27896
+ return null;
27897
+ };
27898
+ var pwshScriptWriter = (script, depth = 0) => {
27899
+ const why = powershellTextWriter(script);
27900
+ if (why)
27901
+ return why;
27902
+ const segments = segmentsOf(script, "powershell");
27903
+ for (const [at, segment] of segments.entries()) {
27904
+ const statement = pwshStatementWriter(segment, depth, segments[at - 1], segments[at + 1]);
27905
+ if (statement)
27906
+ return statement;
27907
+ }
27908
+ return null;
27909
+ };
27910
+ var CMD_READS = /^(?:dir|type|echo|cd|chdir|set|where|findstr|find|ver|vol|tree|more|rem)$/;
27911
+ var cmdStatementWriter = (segment) => {
27912
+ if (segment.redirects.some((file) => !NULL_SINK.test(file)))
27913
+ return ">";
27914
+ const [first, ...args] = segment.words;
27915
+ if (first === undefined)
27916
+ return null;
27917
+ const name = first.replace(/^@/, "").toLowerCase().replace(/^(echo)[.:(/\\].*$/, "$1");
27918
+ if (!CMD_READS.test(name))
27919
+ return first;
27920
+ if (name === "set" && args.some((arg) => arg.includes("=") || /^\/[ap]$/i.test(arg)))
27921
+ return first;
27922
+ return null;
27923
+ };
27924
+ var windowsStatementWriter = (segment, cmd, text, prev, next) => cmd ? cmdStatementWriter(segment) : text ?? pwshStatementWriter(segment, 0, prev, next);
27925
+
27575
27926
  // packages/workit-core/src/hooks/write-gate.ts
27576
27927
  var NONE3 = { kind: "none" };
27577
27928
  var CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "win32";
@@ -27995,13 +28346,14 @@ var shellScript2 = (words) => {
27995
28346
  }
27996
28347
  return null;
27997
28348
  };
27998
- var CMD_VAR = /%[^%\s]+%|![^!\s]+!/;
27999
- var XARGS_VALUE = /^-[InLPdsEa]$/;
28349
+ var XARGS_VALUE = /^-[InLPdsEaJR]$/;
28000
28350
  var runsWriter = (words) => {
28001
28351
  const filled = [
28002
28352
  ...words.filter((word) => word !== ";" && word !== "+").map((word) => word.includes("{}") ? "eval" : word),
28003
28353
  "eval"
28004
28354
  ];
28355
+ if (pastLead(filled)[0] === "eval")
28356
+ return true;
28005
28357
  const edits = editsOf(filled);
28006
28358
  return edits === null || edits.length > 0 || opaqueWrites(filled) !== null;
28007
28359
  };
@@ -28013,14 +28365,20 @@ var opaqueWrites = (input, scriptOf = (index) => input[index], fed, loads = fals
28013
28365
  for (;words[at]?.startsWith("-"); at += XARGS_VALUE.test(words[at]) ? 2 : 1)
28014
28366
  token = words[at] === "-I" ? words[at + 1] ?? token : /^-[Ii](.+)|^--replace=(.+)/s.exec(words[at])?.slice(1).join("") ?? token;
28015
28367
  const named = pastLead(words.slice(at))[0] ?? "";
28016
- return named.includes(token) || named.includes("{}") || runsWriter(words.slice(at)) ? ["."] : null;
28368
+ if (at >= words.length)
28369
+ return null;
28370
+ return named.includes(token) || named.includes("{}") || words.slice(1, at).some((word) => word.startsWith("-J")) || runsWriter(words.slice(at)) ? ["."] : null;
28017
28371
  }
28018
28372
  const [verb, ...args] = words;
28019
28373
  const name = (verb?.split(/[\\/]/).at(-1) ?? "").toLowerCase().replace(/\.exe$/, "");
28020
28374
  if (/^(?:flock|watch|ssh|parallel|script|su|runuser|strace|iex|invoke-expression)$/.test(name) || (name === "pwsh" || name === "powershell") && powershellOpaque(words))
28021
28375
  return ["."];
28376
+ if (CMD_VAR.test(verb ?? ""))
28377
+ return ["."];
28022
28378
  if (name === "mklink" && args.some((arg) => CMD_VAR.test(arg)))
28023
28379
  return ["."];
28380
+ if (name === "cmd" && cmdScript(words) === null && !args.includes("/?"))
28381
+ return ["."];
28024
28382
  const files = operands(args);
28025
28383
  const has = (pattern) => args.some((arg) => pattern.test(arg));
28026
28384
  const listed = (named) => named.length ? named : ["."];
@@ -28529,6 +28887,20 @@ var commandWords = (words) => {
28529
28887
  start++;
28530
28888
  return words.slice(start);
28531
28889
  };
28890
+ var POSIX_LOADER = new RegExp(LOADER_ENV.source);
28891
+ var loaderAssignment = (words) => {
28892
+ for (const word of words) {
28893
+ const name = /^(\w+)\+?=/.exec(word)?.[1];
28894
+ if (/^(?:(?:GIT_)?PAGER=cat|GIT_OPTIONAL_LOCKS=0)$/.test(word))
28895
+ continue;
28896
+ if (name !== undefined) {
28897
+ if (POSIX_LOADER.test(name))
28898
+ return word.split("=")[0];
28899
+ } else if (!DECLARERS.has(word) && word !== "env" && !word.startsWith("-"))
28900
+ return;
28901
+ }
28902
+ return;
28903
+ };
28532
28904
  var REBINDS_ANY = new Set([
28533
28905
  "source",
28534
28906
  ".",
@@ -28723,8 +29095,11 @@ var homeExpanded = (file) => {
28723
29095
  const match = /^(?:~|\$HOME|\$\{HOME\})(?=\/|$)/.exec(file);
28724
29096
  return match ? (process.env.HOME || os10.homedir()) + file.slice(match[0].length) : file;
28725
29097
  };
28726
- var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherited = new Map) => {
29098
+ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherited = new Map, inCmd = false) => {
28727
29099
  const targets = [];
29100
+ const windowsReads = strict === true && dialect === "powershell";
29101
+ const textWriter = windowsReads && !inCmd ? powershellTextWriter(command) : null;
29102
+ let loader;
28728
29103
  const written = new Map;
28729
29104
  let dir = cwd;
28730
29105
  let stack = [];
@@ -28789,6 +29164,13 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
28789
29164
  ({ dir, stack, vars, loops } = saved);
28790
29165
  continue;
28791
29166
  }
29167
+ const unreadable = windowsReads && dir !== undefined && segment.words.length > 0 ? windowsStatementWriter(segment, inCmd, textWriter, segments[segments.indexOf(segment) - 1], segments[segments.indexOf(segment) + 1]) : null;
29168
+ if (unreadable !== null && dir !== undefined)
29169
+ targets.push(placeholderIn(dir, `${OPAQUE_TARGET}${encodeURIComponent(unreadable)}`));
29170
+ if (strict === true && dialect === "posix")
29171
+ loader ??= loaderAssignment(commandWords(segment.words));
29172
+ if (loader !== undefined && dir !== undefined && segment.words.length > 0)
29173
+ targets.push(placeholderIn(dir, `${OPAQUE_TARGET}${encodeURIComponent(loader)}`));
28792
29174
  const body = commandWords(segment.words);
28793
29175
  const before = segments[segments.indexOf(segment) - 1];
28794
29176
  const feeder = before?.pipe ? before : undefined;
@@ -28875,8 +29257,10 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
28875
29257
  const windows = strict && depth < 4 ? windowsScript(words, segment.stdin?.join(`
28876
29258
  `)) : null;
28877
29259
  const cmd = /^cmd(?:\.exe)?$/.test(commandName2(pastLead(words)[0] ?? ""));
29260
+ if (windows !== null && dir !== undefined && dialect === "posix" && segment.expands?.length)
29261
+ targets.push(placeholderIn(dir, `${OPAQUE_TARGET}${commandName2(pastLead(words)[0] ?? "")}`));
28878
29262
  if (windows !== null && dir !== undefined)
28879
- for (const file of segmentTargets(dir, windows, "powershell", depth + 1, strict, vars))
29263
+ for (const file of segmentTargets(dir, windows, "powershell", depth + 1, strict, vars, cmd))
28880
29264
  targets.push(cmd && CMD_VAR.test(file) ? placeholderIn(dir, `${OPAQUE_TARGET}cmd`) : file);
28881
29265
  const bare = strict && depth < 4 ? unwrapped(words) : null;
28882
29266
  if (bare?.length && dir !== undefined)
@@ -29006,7 +29390,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
29006
29390
  targets.push(placeholderIn(dir, DIR_TARGET));
29007
29391
  }
29008
29392
  for (const file of [...segment.redirects, ...edits ?? []])
29009
- if (!/^\/dev\/(?:null|stdout|stderr|tty)$/.test(file))
29393
+ if (!/^\/dev\/(?:null|stdout|stderr|tty)$/.test(file) && !(dialect === "powershell" && /^(?:\$null|nul)$/i.test(file)))
29010
29394
  targets.push(...atAll(file));
29011
29395
  if (dir !== undefined)
29012
29396
  for (const invocation of workitInvocations(body.map(quoteWord2).join(" "), "posix")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/opencode",
3
- "version": "2.25.5",
3
+ "version": "2.25.6",
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.5"
44
+ "@workit-dev/core": "^2.25.6"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=24"