@workit-dev/pi 2.25.4 → 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.
package/dist/worker.js CHANGED
@@ -8435,7 +8435,7 @@ var GIT_VALUE_OPTIONS = new Set([
8435
8435
  "--super-prefix"
8436
8436
  ]);
8437
8437
  var GIT_CONFIG_OPTIONS = new Set(["-c", "--config-env", "--git-dir"]);
8438
- var XARGS_VALUES = new Set(["-n", "-L", "-l", "-P", "-d", "-E", "-e", "-s", "-a", "--arg-file", "--delimiter"].concat([
8438
+ var XARGS_VALUES = new Set(["-n", "-L", "-l", "-P", "-d", "-E", "-e", "-s", "-a", "-R", "--arg-file", "--delimiter"].concat([
8439
8439
  "--max-args",
8440
8440
  "--max-lines",
8441
8441
  "--max-procs",
@@ -9963,6 +9963,34 @@ var liveProbe = {
9963
9963
  };
9964
9964
  var PIDS = new Map;
9965
9965
 
9966
+ // packages/workit-core/src/hooks/windows-reads.ts
9967
+ var READ_CMDLETS = new Set([
9968
+ "foreach-object",
9969
+ "out-string",
9970
+ "out-null",
9971
+ "out-host",
9972
+ "write-output",
9973
+ "write-host",
9974
+ "write-verbose",
9975
+ "write-warning",
9976
+ "write-error",
9977
+ "write-debug",
9978
+ "write-information",
9979
+ "test-path",
9980
+ "test-json",
9981
+ "resolve-path",
9982
+ "convert-path",
9983
+ "join-path",
9984
+ "split-path",
9985
+ "compare-object",
9986
+ "group-object",
9987
+ "set-location",
9988
+ "push-location",
9989
+ "pop-location",
9990
+ "help"
9991
+ ]);
9992
+ 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;
9993
+
9966
9994
  // packages/workit-core/src/hooks/write-gate.ts
9967
9995
  var CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "win32";
9968
9996
  var PREFIXES = new Set(["sudo", "command", "env", "nohup", "time", "exec", "xargs", "busybox"]);
@@ -9998,6 +10026,7 @@ var PUSHD2 = new Set(["pushd", "push-location"]);
9998
10026
  var POPD2 = new Set(["popd", "pop-location"]);
9999
10027
  var UNKNOWN_DIR = path14.resolve(path14.parse(process.cwd()).root, ".workit-unknown-dir");
10000
10028
  var DECLARERS = new Set(["export", "declare", "typeset", "local", "readonly"]);
10029
+ var POSIX_LOADER = new RegExp(LOADER_ENV.source);
10001
10030
  var REBINDS_ANY = new Set([
10002
10031
  "source",
10003
10032
  ".",
package/dist/workit.js CHANGED
@@ -20295,7 +20295,7 @@ var literalOutput = (segment) => {
20295
20295
  };
20296
20296
  var stdinOf = (segment, previous) => segment.stdin ? segment.stdin.join(`
20297
20297
  `) : literalOutput(previous);
20298
- var XARGS_VALUES = new Set(["-n", "-L", "-l", "-P", "-d", "-E", "-e", "-s", "-a", "--arg-file", "--delimiter"].concat([
20298
+ var XARGS_VALUES = new Set(["-n", "-L", "-l", "-P", "-d", "-E", "-e", "-s", "-a", "-R", "--arg-file", "--delimiter"].concat([
20299
20299
  "--max-args",
20300
20300
  "--max-lines",
20301
20301
  "--max-procs",
@@ -20305,6 +20305,7 @@ var XARGS_VALUES = new Set(["-n", "-L", "-l", "-P", "-d", "-E", "-e", "-s", "-a"
20305
20305
  ]));
20306
20306
  var xargsCommands = (words, input) => {
20307
20307
  let replace = null;
20308
+ let insert = null;
20308
20309
  let index = 1;
20309
20310
  for (;index < words.length; index++) {
20310
20311
  const word = words[index];
@@ -20316,6 +20317,10 @@ var xargsCommands = (words, input) => {
20316
20317
  break;
20317
20318
  if (word === "-I")
20318
20319
  replace = words[++index] ?? "{}";
20320
+ else if (word === "-J")
20321
+ insert = words[++index] ?? null;
20322
+ else if (/^-J./.test(word))
20323
+ insert = word.slice(2);
20319
20324
  else if (word === "--replace" || word === "-i")
20320
20325
  replace = "{}";
20321
20326
  else if (word.startsWith("--replace="))
@@ -20330,8 +20335,12 @@ var xargsCommands = (words, input) => {
20330
20335
  return [];
20331
20336
  if (input === undefined)
20332
20337
  return [command];
20338
+ const fed = input.split(/\s+/).filter(Boolean);
20339
+ const at = insert === null ? -1 : command.indexOf(insert);
20340
+ if (at >= 0)
20341
+ return [[...command.slice(0, at), ...fed, ...command.slice(at + 1)]];
20333
20342
  if (replace === null)
20334
- return [[...command, ...input.split(/\s+/).filter(Boolean)]];
20343
+ return [[...command, ...fed]];
20335
20344
  const token = replace;
20336
20345
  return input.split(`
20337
20346
  `).map((line) => line.trim()).filter(Boolean).slice(0, MAX_EXPANSIONS).map((line) => command.map((word) => word.replaceAll(token, line)));
@@ -20349,34 +20358,83 @@ var findCommands = (words) => {
20349
20358
  }
20350
20359
  return found;
20351
20360
  };
20352
- var POWERSHELL_VALUES = /^-(?:f|file|ex|executionpolicy|wd|workingdirectory|config|configurationname|o|outputformat|if|inputformat|inp|w|windowstyle|settingsfile|custompipename|psconsolefile)$/;
20353
- var powershellScript = (words, stdin) => {
20361
+ var POWERSHELL_PARAMETERS = [
20362
+ { name: "command", min: 1, kind: "script" },
20363
+ { name: "commandwithargs", min: 8, aliases: ["cwa"], kind: "args", host: "pwsh" },
20364
+ { name: "configurationname", min: 7, aliases: ["config"], kind: "opaque" },
20365
+ { name: "configurationfile", min: 14, kind: "opaque", host: "pwsh" },
20366
+ { name: "custompipename", min: 2, kind: "value", host: "pwsh" },
20367
+ { name: "encodedcommand", min: 3, aliases: ["e", "ec"], kind: "encoded" },
20368
+ { name: "encodedarguments", min: 8, aliases: ["ea"], kind: "opaque", host: "pwsh" },
20369
+ { name: "executionpolicy", min: 2, aliases: ["ep"], kind: "value" },
20370
+ { name: "file", min: 1, kind: "opaque" },
20371
+ { name: "help", min: 1, aliases: ["?"], kind: "info" },
20372
+ { name: "inputformat", min: 3, aliases: ["if"], kind: "value" },
20373
+ { name: "interactive", min: 4, aliases: ["i"], kind: "switch", host: "pwsh" },
20374
+ { name: "login", min: 1, kind: "opaque", host: "pwsh" },
20375
+ { name: "mta", min: 3, kind: "switch" },
20376
+ { name: "noexit", min: 3, kind: "opaque" },
20377
+ { name: "nologo", min: 3, kind: "switch" },
20378
+ { name: "noninteractive", min: 3, kind: "switch" },
20379
+ { name: "noprofile", min: 3, kind: "switch" },
20380
+ { name: "noprofileloadtime", min: 10, kind: "switch", host: "pwsh" },
20381
+ { name: "outputformat", min: 1, aliases: ["of"], kind: "value" },
20382
+ { name: "psconsolefile", min: 2, kind: "opaque", host: "powershell" },
20383
+ { name: "settingsfile", min: 2, aliases: ["settings"], kind: "opaque", host: "pwsh" },
20384
+ { name: "sshservermode", min: 2, aliases: ["sshs"], kind: "opaque", host: "pwsh" },
20385
+ { name: "sta", min: 3, kind: "switch" },
20386
+ { name: "version", min: 1, kind: "info", host: "pwsh" },
20387
+ { name: "version", min: 1, kind: "value", host: "powershell" },
20388
+ { name: "windowstyle", min: 1, kind: "value" },
20389
+ { name: "workingdirectory", min: 2, aliases: ["wd"], kind: "value" }
20390
+ ];
20391
+ var powershellRun = (words, stdin) => {
20392
+ const host = /powershell/i.test(words[0] ?? "") ? "powershell" : "pwsh";
20393
+ let opaque = false;
20354
20394
  for (let index = 1;index < words.length; index++) {
20355
20395
  const word = words[index];
20356
20396
  if (!/^[-/]/.test(word))
20357
- return null;
20358
- const flag = word.replace(/^[-/]+/, "").toLowerCase();
20359
- if (!flag)
20360
- return null;
20361
- if (flag === "e" || flag === "ec" || flag.length >= 2 && "encodedcommand".startsWith(flag)) {
20397
+ return host === "powershell" ? { script: words.slice(index).join(" "), opaque } : { script: null, opaque: true };
20398
+ const [, key = "", glued] = /^(?:--?|\/)([^:=]*)(?:[:=](.*))?$/s.exec(word) ?? [];
20399
+ const flag = key.toLowerCase();
20400
+ const matches = POWERSHELL_PARAMETERS.filter((parameter) => (parameter.host ?? host) === host && flag !== "" && (parameter.aliases?.includes(flag) || flag.length >= parameter.min && parameter.name.startsWith(flag)));
20401
+ if (matches.length !== 1) {
20402
+ opaque = true;
20403
+ continue;
20404
+ }
20405
+ const [{ kind }] = matches;
20406
+ const value = glued ?? words[index + 1];
20407
+ if (kind === "info")
20408
+ return { script: null, opaque: opaque || index < words.length - 1 };
20409
+ if (kind === "encoded") {
20362
20410
  try {
20363
- return Buffer.from(words[index + 1] ?? "", "base64").toString("utf16le");
20411
+ return { script: Buffer.from(value ?? "", "base64").toString("utf16le"), opaque: true };
20364
20412
  } catch {
20365
- return null;
20413
+ return { script: null, opaque: true };
20366
20414
  }
20367
20415
  }
20368
- if (flag === "cwa" || flag.length >= 8 && "commandwithargs".startsWith(flag))
20369
- return words[index + 1] ?? null;
20370
- if ("command".startsWith(flag))
20371
- return words[index + 1] === "-" ? stdin ?? null : words.slice(index + 1).join(" ");
20372
- if (POWERSHELL_VALUES.test(`-${flag}`)) {
20373
- if (flag === "f" || flag === "file")
20374
- return null;
20375
- index++;
20416
+ if (kind === "args")
20417
+ return {
20418
+ script: value ?? null,
20419
+ opaque: opaque || glued !== undefined || value === undefined
20420
+ };
20421
+ if (kind === "script") {
20422
+ if (value === "-")
20423
+ return { script: stdin ?? null, opaque: true };
20424
+ const rest = glued === undefined ? words.slice(index + 1) : [glued, ...words.slice(index + 1)];
20425
+ return {
20426
+ script: rest.join(" ") || null,
20427
+ opaque: opaque || glued !== undefined || !rest.length
20428
+ };
20376
20429
  }
20430
+ opaque ||= kind === "opaque";
20431
+ if (kind !== "switch" && glued === undefined)
20432
+ index++;
20377
20433
  }
20378
- return null;
20434
+ return { script: null, opaque: true };
20379
20435
  };
20436
+ var powershellScript = (words, stdin) => powershellRun(words, stdin).script;
20437
+ var powershellOpaque = (words) => powershellRun(words).opaque;
20380
20438
  var cmdScript = (words) => {
20381
20439
  const at = words.findIndex((word, index) => index > 0 && /^\/[ck]$/i.test(word));
20382
20440
  if (at > 0)
@@ -27523,6 +27581,315 @@ var claimLiveSession = (target, owner, deps = {}) => {
27523
27581
  } catch {}
27524
27582
  };
27525
27583
 
27584
+ // packages/workit-core/src/hooks/windows-reads.ts
27585
+ var READ_CMDLETS = new Set([
27586
+ "foreach-object",
27587
+ "out-string",
27588
+ "out-null",
27589
+ "out-host",
27590
+ "write-output",
27591
+ "write-host",
27592
+ "write-verbose",
27593
+ "write-warning",
27594
+ "write-error",
27595
+ "write-debug",
27596
+ "write-information",
27597
+ "test-path",
27598
+ "test-json",
27599
+ "resolve-path",
27600
+ "convert-path",
27601
+ "join-path",
27602
+ "split-path",
27603
+ "compare-object",
27604
+ "group-object",
27605
+ "set-location",
27606
+ "push-location",
27607
+ "pop-location",
27608
+ "help"
27609
+ ]);
27610
+ var READ_VERBS = /^(?:get|select|where|measure|sort|format|convertfrom|convertto)-/;
27611
+ var ALIASES2 = {
27612
+ "?": "where-object",
27613
+ "%": "foreach-object",
27614
+ foreach: "foreach-object",
27615
+ where: "where-object",
27616
+ cat: "get-content",
27617
+ gc: "get-content",
27618
+ type: "get-content",
27619
+ cd: "set-location",
27620
+ chdir: "set-location",
27621
+ sl: "set-location",
27622
+ pushd: "push-location",
27623
+ popd: "pop-location",
27624
+ pwd: "get-location",
27625
+ gl: "get-location",
27626
+ dir: "get-childitem",
27627
+ ls: "get-childitem",
27628
+ gci: "get-childitem",
27629
+ gi: "get-item",
27630
+ gp: "get-itemproperty",
27631
+ gpv: "get-itempropertyvalue",
27632
+ gcm: "get-command",
27633
+ gm: "get-member",
27634
+ gal: "get-alias",
27635
+ gv: "get-variable",
27636
+ gmo: "get-module",
27637
+ gps: "get-process",
27638
+ ps: "get-process",
27639
+ gsv: "get-service",
27640
+ gdr: "get-psdrive",
27641
+ gcb: "get-clipboard",
27642
+ gin: "get-computerinfo",
27643
+ gtz: "get-timezone",
27644
+ gu: "get-unique",
27645
+ ghy: "get-history",
27646
+ h: "get-history",
27647
+ history: "get-history",
27648
+ gjb: "get-job",
27649
+ gerr: "get-error",
27650
+ select: "select-object",
27651
+ sls: "select-string",
27652
+ sort: "sort-object",
27653
+ measure: "measure-object",
27654
+ group: "group-object",
27655
+ compare: "compare-object",
27656
+ diff: "compare-object",
27657
+ fl: "format-list",
27658
+ ft: "format-table",
27659
+ fw: "format-wide",
27660
+ fc: "format-custom",
27661
+ fhx: "format-hex",
27662
+ echo: "write-output",
27663
+ write: "write-output",
27664
+ oh: "out-host",
27665
+ rvpa: "resolve-path",
27666
+ cvpa: "convert-path",
27667
+ man: "help",
27668
+ ac: "add-content",
27669
+ sc: "set-content",
27670
+ clc: "clear-content",
27671
+ cli: "clear-item",
27672
+ clp: "clear-itemproperty",
27673
+ clv: "clear-variable",
27674
+ copy: "copy-item",
27675
+ cp: "copy-item",
27676
+ cpi: "copy-item",
27677
+ cpp: "copy-itemproperty",
27678
+ del: "remove-item",
27679
+ erase: "remove-item",
27680
+ rd: "remove-item",
27681
+ ri: "remove-item",
27682
+ rm: "remove-item",
27683
+ rmdir: "remove-item",
27684
+ rp: "remove-itemproperty",
27685
+ rv: "remove-variable",
27686
+ mi: "move-item",
27687
+ move: "move-item",
27688
+ mv: "move-item",
27689
+ mp: "move-itemproperty",
27690
+ ren: "rename-item",
27691
+ rni: "rename-item",
27692
+ rnp: "rename-itemproperty",
27693
+ ni: "new-item",
27694
+ md: "new-item",
27695
+ mkdir: "new-item",
27696
+ mount: "new-psdrive",
27697
+ ndr: "new-psdrive",
27698
+ nal: "new-alias",
27699
+ nv: "new-variable",
27700
+ nmo: "new-module",
27701
+ si: "set-item",
27702
+ sp: "set-itemproperty",
27703
+ sv: "set-variable",
27704
+ set: "set-variable",
27705
+ sal: "set-alias",
27706
+ scb: "set-clipboard",
27707
+ epal: "export-alias",
27708
+ epcsv: "export-csv",
27709
+ ipal: "import-alias",
27710
+ ipmo: "import-module",
27711
+ ipcsv: "import-csv",
27712
+ tee: "tee-object",
27713
+ start: "start-process",
27714
+ saps: "start-process",
27715
+ sajb: "start-job",
27716
+ sleep: "start-sleep",
27717
+ ii: "invoke-item",
27718
+ icm: "invoke-command",
27719
+ iex: "invoke-expression",
27720
+ ihy: "invoke-history",
27721
+ r: "invoke-history",
27722
+ irm: "invoke-restmethod",
27723
+ iwr: "invoke-webrequest",
27724
+ kill: "stop-process",
27725
+ spps: "stop-process",
27726
+ ogv: "out-gridview"
27727
+ };
27728
+ var KEYWORDS2 = /^(?:if|elseif|else|switch|while|do|until|for|foreach|try|catch|finally|return|break|continue|exit|throw|param|begin|process|end)$/;
27729
+ 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)$/;
27730
+ 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;
27731
+ 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;
27732
+ 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;
27733
+ var CMD_VAR = /%[^%\s]+%|![^!\s]+!/;
27734
+ var NULL_SINK = /^(?:\$null|nul|\/dev\/null)$/i;
27735
+ var pwshCode = (text) => {
27736
+ let out = "";
27737
+ for (let at = 0;at < text.length; at++) {
27738
+ const char = text[at];
27739
+ const here = char === "@" && /['"]/.test(text[at + 1] ?? "") ? text[at + 1] : null;
27740
+ if (char === "<" && text[at + 1] === "#") {
27741
+ const end = text.indexOf("#>", at + 2);
27742
+ at = end < 0 ? text.length : end + 1;
27743
+ } else if (char === "#" && (at === 0 || /[\s;|{(]/.test(text[at - 1])))
27744
+ for (;at < text.length && text[at] !== `
27745
+ `; at++)
27746
+ ;
27747
+ else if (here !== null || char === "'" || char === '"') {
27748
+ const quote = here ?? char;
27749
+ const close = here === null ? quote : `
27750
+ ${quote}@`;
27751
+ let end = at + (here === null ? 1 : 2);
27752
+ const kept = [];
27753
+ while (end < text.length && !text.startsWith(close, end)) {
27754
+ if (quote === '"' && text[end] === "`")
27755
+ end++;
27756
+ else if (quote === "'" && here === null && text.startsWith("''", end))
27757
+ end++;
27758
+ else if (quote === '"' && text.startsWith("$(", end)) {
27759
+ let depth = 0;
27760
+ const start = end;
27761
+ for (;end < text.length; end++)
27762
+ if (text[end] === "(")
27763
+ depth++;
27764
+ else if (text[end] === ")" && --depth === 0)
27765
+ break;
27766
+ kept.push(text.slice(start, end + 1));
27767
+ }
27768
+ end++;
27769
+ }
27770
+ out += `S${kept.join(" ")}`;
27771
+ at = end + close.length - 1;
27772
+ } else
27773
+ out += char;
27774
+ }
27775
+ return out;
27776
+ };
27777
+ var powershellTextWriter = (text) => {
27778
+ const code = pwshCode(text);
27779
+ if (/(?<![&>])&(?![&>])/.test(code))
27780
+ return "&";
27781
+ const statics = /([^\s;|{(]*)\s*::\s*(\w*)/.exec(code);
27782
+ if (statics)
27783
+ return `${statics[1]}::${statics[2]}`;
27784
+ for (const [, name] of code.matchAll(/\$\{?env:(\w+)\}?\s*[-+]?=/gi))
27785
+ if (LOADER_ENV.test(name))
27786
+ return `$env:${name} =`;
27787
+ for (const [, name] of code.matchAll(/\.([A-Za-z_]\w*)\(/g))
27788
+ if (!READ_METHODS.test(name))
27789
+ return `.${name}()`;
27790
+ const member = /\.([A-Za-z_]\w*)\s*[-+*/%]?=/.exec(code);
27791
+ if (member)
27792
+ return `.${member[1]} =`;
27793
+ const drive = /\$\{?(function|alias):/i.exec(code);
27794
+ return drive ? `$${drive[1]}:` : null;
27795
+ };
27796
+ var subexpressions = (word) => {
27797
+ const found = [];
27798
+ for (let at = word.indexOf("$(");at >= 0; at = word.indexOf("$(", at + 1)) {
27799
+ let depth = 0;
27800
+ let end = at + 1;
27801
+ for (;end < word.length; end++)
27802
+ if (word[end] === "(")
27803
+ depth++;
27804
+ else if (word[end] === ")" && --depth === 0)
27805
+ break;
27806
+ found.push(word.slice(at + 2, end));
27807
+ }
27808
+ return found;
27809
+ };
27810
+ var cmdletOf = (name) => {
27811
+ const lower = name.toLowerCase().replace(/[\u2013-\u2015]/g, "-");
27812
+ if (ALIASES2[lower] !== undefined)
27813
+ return ALIASES2[lower];
27814
+ return /^[a-z]+-[a-z0-9]+$/.test(lower) ? lower : null;
27815
+ };
27816
+ var readCmdlet = (cmdlet) => READ_VERBS.test(cmdlet) || READ_CMDLETS.has(cmdlet);
27817
+ var pwshStatementWriter = (segment, depth, prev, next) => {
27818
+ if (segment.redirects.some((file) => !NULL_SINK.test(file)))
27819
+ return ">";
27820
+ let words = segment.words;
27821
+ const glued = /^((?:\[[^\]]*\])*\$[^=\s]+)[-+*/%?]?=(.+)$/s.exec(words[0] ?? "");
27822
+ if (glued)
27823
+ words = [glued[2], ...words.slice(1)];
27824
+ else if (/^(?:\[[^\]]*\])*\$/.test(words[0] ?? "") && /^[-+*/%?]?=$/.test(words[1] ?? ""))
27825
+ words = words.slice(2);
27826
+ for (const word of words)
27827
+ for (const inner of depth < 4 ? subexpressions(word) : [])
27828
+ if (/\S/.test(inner)) {
27829
+ const why = pwshScriptWriter(inner, depth + 1);
27830
+ if (why)
27831
+ return why;
27832
+ }
27833
+ const first = words[0];
27834
+ if (first === undefined)
27835
+ return null;
27836
+ if (first === ".")
27837
+ return ". (dot-source)";
27838
+ if (CMD_VAR.test(first))
27839
+ return first;
27840
+ if (/^[$@(['"\d-]/.test(first) || /^\.[A-Za-z_]/.test(first))
27841
+ return null;
27842
+ if (/[\\/:.]/.test(first))
27843
+ return first;
27844
+ const lower = first.toLowerCase();
27845
+ if (KEYWORDS2.test(lower) && (lower !== "foreach" || words.length === 1 && !prev?.pipe))
27846
+ return null;
27847
+ if (/^(?:function|filter|class|enum|workflow|configuration)$/.test(lower))
27848
+ return first;
27849
+ if (/^(?:pwsh|powershell|cmd)$/.test(lower))
27850
+ return null;
27851
+ const cmdlet = cmdletOf(first);
27852
+ if (cmdlet === null)
27853
+ return WINDOWS_WRITERS.test(lower) ? first : null;
27854
+ if (!readCmdlet(cmdlet))
27855
+ return first;
27856
+ if (cmdlet === "foreach-object") {
27857
+ if (next?.group === "open")
27858
+ return `${first} (…)`;
27859
+ for (const arg of words.slice(1))
27860
+ if (!arg.startsWith("-") && !/^\d+$/.test(arg) && !READ_MEMBERS.test(arg) && !READ_METHODS.test(arg))
27861
+ return `${first} ${arg}`;
27862
+ }
27863
+ return null;
27864
+ };
27865
+ var pwshScriptWriter = (script, depth = 0) => {
27866
+ const why = powershellTextWriter(script);
27867
+ if (why)
27868
+ return why;
27869
+ const segments = segmentsOf(script, "powershell");
27870
+ for (const [at, segment] of segments.entries()) {
27871
+ const statement = pwshStatementWriter(segment, depth, segments[at - 1], segments[at + 1]);
27872
+ if (statement)
27873
+ return statement;
27874
+ }
27875
+ return null;
27876
+ };
27877
+ var CMD_READS = /^(?:dir|type|echo|cd|chdir|set|where|findstr|find|ver|vol|tree|more|rem)$/;
27878
+ var cmdStatementWriter = (segment) => {
27879
+ if (segment.redirects.some((file) => !NULL_SINK.test(file)))
27880
+ return ">";
27881
+ const [first, ...args] = segment.words;
27882
+ if (first === undefined)
27883
+ return null;
27884
+ const name = first.replace(/^@/, "").toLowerCase().replace(/^(echo)[.:(/\\].*$/, "$1");
27885
+ if (!CMD_READS.test(name))
27886
+ return first;
27887
+ if (name === "set" && args.some((arg) => arg.includes("=") || /^\/[ap]$/i.test(arg)))
27888
+ return first;
27889
+ return null;
27890
+ };
27891
+ var windowsStatementWriter = (segment, cmd, text, prev, next) => cmd ? cmdStatementWriter(segment) : text ?? pwshStatementWriter(segment, 0, prev, next);
27892
+
27526
27893
  // packages/workit-core/src/hooks/write-gate.ts
27527
27894
  var NONE3 = { kind: "none" };
27528
27895
  var CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "win32";
@@ -27641,11 +28008,17 @@ var editsOf = (input) => {
27641
28008
  case "cp":
27642
28009
  case "ln":
27643
28010
  case "install": {
27644
- const into = valueOf(args, /^(?:-t|--target-directory=?)(.*)$/s);
28011
+ const into = valueOf(args, /^(?:-[a-zA-Z]*t|--target-directory=?)(.*)$/s);
27645
28012
  if (into !== undefined)
27646
28013
  return [into];
27647
- const last = operands(args).at(-1);
27648
- return last ? [last] : null;
28014
+ const files = operands(args);
28015
+ if (name === "ln" && files.length === 1)
28016
+ return [path42.basename(files[0])];
28017
+ return files.length ? [files.at(-1)] : null;
28018
+ }
28019
+ case "mklink": {
28020
+ const link = args.find((arg) => !/^\/[dhj]$/i.test(arg));
28021
+ return link ? [link] : null;
27649
28022
  }
27650
28023
  case "dd":
27651
28024
  return args.filter((item) => item.startsWith("of=")).map((item) => item.slice(3));
@@ -27674,10 +28047,15 @@ var editsOf = (input) => {
27674
28047
  case "del":
27675
28048
  case "copy-item":
27676
28049
  case "move-item": {
27677
- const flag = args.findIndex((item) => /^-(?:path|filepath|literalpath|destination)$/i.test(item));
27678
- if (flag >= 0)
27679
- return args[flag + 1] ? [args[flag + 1]] : null;
27680
- const files = operands(args);
28050
+ const named = valueOf(args, /^-(?:path|filepath|literalpath|destination)(?::(.+))?$/is);
28051
+ if (named !== undefined || args.some((item) => /^-(?:path|filepath|literalpath|destination)$/i.test(item)))
28052
+ return named ? [named] : null;
28053
+ const files = args.filter((item, at) => !item.startsWith("-") && !/^-(?:itemtype|type|value|target|encoding|name)$/i.test(args[at - 1] ?? ""));
28054
+ if (files.length === 0 && (name === "new-item" || name === "ni")) {
28055
+ const leaf = valueOf(args, /^-name(?::(.+))?$/is);
28056
+ if (leaf)
28057
+ return [leaf];
28058
+ }
27681
28059
  if (name === "move-item")
27682
28060
  return files.length ? files : null;
27683
28061
  const file = name === "copy-item" ? files.at(-1) : files[0];
@@ -27935,12 +28313,14 @@ var shellScript3 = (words) => {
27935
28313
  }
27936
28314
  return null;
27937
28315
  };
27938
- var XARGS_VALUE = /^-[IinLPdsEa]$/;
28316
+ var XARGS_VALUE = /^-[InLPdsEaJR]$/;
27939
28317
  var runsWriter = (words) => {
27940
28318
  const filled = [
27941
28319
  ...words.filter((word) => word !== ";" && word !== "+").map((word) => word.includes("{}") ? "eval" : word),
27942
28320
  "eval"
27943
28321
  ];
28322
+ if (pastLead(filled)[0] === "eval")
28323
+ return true;
27944
28324
  const edits = editsOf(filled);
27945
28325
  return edits === null || edits.length > 0 || opaqueWrites(filled) !== null;
27946
28326
  };
@@ -27948,13 +28328,23 @@ var opaqueWrites = (input, scriptOf = (index) => input[index], fed, loads = fals
27948
28328
  const words = pastLead(input);
27949
28329
  if (words[0] === "xargs") {
27950
28330
  let at = 1;
27951
- while (words[at]?.startsWith("-"))
27952
- at += XARGS_VALUE.test(words[at]) ? 2 : 1;
27953
- return runsWriter(words.slice(at)) ? ["."] : null;
28331
+ let token = "{}";
28332
+ for (;words[at]?.startsWith("-"); at += XARGS_VALUE.test(words[at]) ? 2 : 1)
28333
+ token = words[at] === "-I" ? words[at + 1] ?? token : /^-[Ii](.+)|^--replace=(.+)/s.exec(words[at])?.slice(1).join("") ?? token;
28334
+ const named = pastLead(words.slice(at))[0] ?? "";
28335
+ if (at >= words.length)
28336
+ return null;
28337
+ return named.includes(token) || named.includes("{}") || words.slice(1, at).some((word) => word.startsWith("-J")) || runsWriter(words.slice(at)) ? ["."] : null;
27954
28338
  }
27955
28339
  const [verb, ...args] = words;
27956
- const name = (verb?.split(/[\\/]/).at(-1) ?? "").toLowerCase();
27957
- if (/^(?:flock|watch|ssh|parallel|script|su|runuser|strace)$/.test(name))
28340
+ const name = (verb?.split(/[\\/]/).at(-1) ?? "").toLowerCase().replace(/\.exe$/, "");
28341
+ if (/^(?:flock|watch|ssh|parallel|script|su|runuser|strace|iex|invoke-expression)$/.test(name) || (name === "pwsh" || name === "powershell") && powershellOpaque(words))
28342
+ return ["."];
28343
+ if (CMD_VAR.test(verb ?? ""))
28344
+ return ["."];
28345
+ if (name === "mklink" && args.some((arg) => CMD_VAR.test(arg)))
28346
+ return ["."];
28347
+ if (name === "cmd" && cmdScript(words) === null && !args.includes("/?"))
27958
28348
  return ["."];
27959
28349
  const files = operands(args);
27960
28350
  const has = (pattern) => args.some((arg) => pattern.test(arg));
@@ -28228,7 +28618,7 @@ var PATHS = /(?<![\w.~:/$-])(?:~\/|\/|[A-Za-z]:\/|\.\.(?:\/|$))[^\s'"`$),;:*?<>|
28228
28618
  var pathsIn = (text) => [...text.matchAll(PATHS)].map((match) => match[0]);
28229
28619
  var linkSources = (args, at) => {
28230
28620
  const names = operands([...args]);
28231
- const into = args.indexOf("-t");
28621
+ const into = args.findIndex((arg) => /^-[a-zA-Z]*t$/.test(arg));
28232
28622
  const dest = into >= 0 ? args[into + 1] : names.length > 1 ? names.at(-1) : ".";
28233
28623
  const sources = names.filter((name, index) => into >= 0 ? name !== dest : index < names.length - 1 || names.length === 1);
28234
28624
  const target = dest === undefined ? null : at(dest);
@@ -28466,6 +28856,20 @@ var commandWords = (words) => {
28466
28856
  start++;
28467
28857
  return words.slice(start);
28468
28858
  };
28859
+ var POSIX_LOADER = new RegExp(LOADER_ENV.source);
28860
+ var loaderAssignment = (words) => {
28861
+ for (const word of words) {
28862
+ const name = /^(\w+)\+?=/.exec(word)?.[1];
28863
+ if (/^(?:(?:GIT_)?PAGER=cat|GIT_OPTIONAL_LOCKS=0)$/.test(word))
28864
+ continue;
28865
+ if (name !== undefined) {
28866
+ if (POSIX_LOADER.test(name))
28867
+ return word.split("=")[0];
28868
+ } else if (!DECLARERS.has(word) && word !== "env" && !word.startsWith("-"))
28869
+ return;
28870
+ }
28871
+ return;
28872
+ };
28469
28873
  var REBINDS_ANY = new Set([
28470
28874
  "source",
28471
28875
  ".",
@@ -28660,8 +29064,11 @@ var homeExpanded = (file) => {
28660
29064
  const match = /^(?:~|\$HOME|\$\{HOME\})(?=\/|$)/.exec(file);
28661
29065
  return match ? (process.env.HOME || os10.homedir()) + file.slice(match[0].length) : file;
28662
29066
  };
28663
- var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherited = new Map) => {
29067
+ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherited = new Map, inCmd = false) => {
28664
29068
  const targets = [];
29069
+ const windowsReads = strict === true && dialect === "powershell";
29070
+ const textWriter = windowsReads && !inCmd ? powershellTextWriter(command) : null;
29071
+ let loader;
28665
29072
  const written = new Map;
28666
29073
  let dir = cwd;
28667
29074
  let stack = [];
@@ -28726,6 +29133,13 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
28726
29133
  ({ dir, stack, vars, loops } = saved);
28727
29134
  continue;
28728
29135
  }
29136
+ const unreadable = windowsReads && dir !== undefined && segment.words.length > 0 ? windowsStatementWriter(segment, inCmd, textWriter, segments[segments.indexOf(segment) - 1], segments[segments.indexOf(segment) + 1]) : null;
29137
+ if (unreadable !== null && dir !== undefined)
29138
+ targets.push(placeholderIn(dir, `${OPAQUE_TARGET}${encodeURIComponent(unreadable)}`));
29139
+ if (strict === true && dialect === "posix")
29140
+ loader ??= loaderAssignment(commandWords(segment.words));
29141
+ if (loader !== undefined && dir !== undefined && segment.words.length > 0)
29142
+ targets.push(placeholderIn(dir, `${OPAQUE_TARGET}${encodeURIComponent(loader)}`));
28729
29143
  const body = commandWords(segment.words);
28730
29144
  const before = segments[segments.indexOf(segment) - 1];
28731
29145
  const feeder = before?.pipe ? before : undefined;
@@ -28811,8 +29225,12 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
28811
29225
  targets.push(...segmentTargets(runIn, inner, "posix", depth + 1, strict, runIn === dir ? vars : unPwd()));
28812
29226
  const windows = strict && depth < 4 ? windowsScript(words, segment.stdin?.join(`
28813
29227
  `)) : null;
29228
+ const cmd = /^cmd(?:\.exe)?$/.test(commandName2(pastLead(words)[0] ?? ""));
29229
+ if (windows !== null && dir !== undefined && dialect === "posix" && segment.expands?.length)
29230
+ targets.push(placeholderIn(dir, `${OPAQUE_TARGET}${commandName2(pastLead(words)[0] ?? "")}`));
28814
29231
  if (windows !== null && dir !== undefined)
28815
- targets.push(...segmentTargets(dir, windows, "powershell", depth + 1, strict, vars));
29232
+ for (const file of segmentTargets(dir, windows, "powershell", depth + 1, strict, vars, cmd))
29233
+ targets.push(cmd && CMD_VAR.test(file) ? placeholderIn(dir, `${OPAQUE_TARGET}cmd`) : file);
28816
29234
  const bare = strict && depth < 4 ? unwrapped2(words) : null;
28817
29235
  if (bare?.length && dir !== undefined)
28818
29236
  targets.push(...segmentTargets(dir, bare.flatMap((word) => expansions(word, vars, loops)).map(quoteWord2).join(" "), "posix", depth + 1, strict, vars));
@@ -28941,7 +29359,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
28941
29359
  targets.push(placeholderIn(dir, DIR_TARGET));
28942
29360
  }
28943
29361
  for (const file of [...segment.redirects, ...edits ?? []])
28944
- if (!/^\/dev\/(?:null|stdout|stderr|tty)$/.test(file))
29362
+ if (!/^\/dev\/(?:null|stdout|stderr|tty)$/.test(file) && !(dialect === "powershell" && /^(?:\$null|nul)$/i.test(file)))
28945
29363
  targets.push(...atAll(file));
28946
29364
  if (dir !== undefined)
28947
29365
  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/pi",
3
- "version": "2.25.4",
3
+ "version": "2.25.6",
4
4
  "description": "Workit native extension for Pi — tools, method skills, and session continuity",
5
5
  "keywords": [
6
6
  "agentic-coding",