@workit-dev/opencode 2.25.5 → 2.26.0

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 +568 -182
  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")) {
@@ -31723,7 +32107,7 @@ var PROCESS_START = performance.timeOrigin;
31723
32107
  // packages/workit-core/src/hooks/run.ts
31724
32108
  if (false) {}
31725
32109
  // packages/workit-opencode/src/shared/init-apply.ts
31726
- import path53 from "node:path";
32110
+ import path54 from "node:path";
31727
32111
 
31728
32112
  // packages/workit-core/src/core/gitignore.ts
31729
32113
  import { existsSync as existsSync18, readFileSync as readFileSync13, writeFileSync as writeFileSync6 } from "node:fs";
@@ -31774,26 +32158,131 @@ var ensureProjectGitignore = (workspaceRoot, confirmed) => {
31774
32158
  };
31775
32159
 
31776
32160
  // packages/workit-core/src/core/hygiene.ts
31777
- import { existsSync as existsSync19, readFileSync as readFileSync14, readdirSync as readdirSync6, writeFileSync as writeFileSync7 } from "node:fs";
32161
+ import { existsSync as existsSync20, readFileSync as readFileSync15, readdirSync as readdirSync7, writeFileSync as writeFileSync8 } from "node:fs";
32162
+ import path51 from "node:path";
32163
+
32164
+ // packages/workit-core/src/git/ops.ts
32165
+ import { spawnSync as spawnSync25 } from "node:child_process";
32166
+ import {
32167
+ copyFileSync as copyFileSync3,
32168
+ existsSync as existsSync19,
32169
+ mkdirSync as mkdirSync6,
32170
+ readdirSync as readdirSync6,
32171
+ readFileSync as readFileSync14,
32172
+ rmSync as rmSync3,
32173
+ writeFileSync as writeFileSync7
32174
+ } from "node:fs";
31778
32175
  import path50 from "node:path";
32176
+ var COMMIT_TIMEOUT_MS = 10 * 60000;
32177
+ var git5 = (cwd, args, options = {}) => {
32178
+ const result = spawnSync25("git", args, {
32179
+ cwd,
32180
+ encoding: "utf8",
32181
+ env: { ...options.env ?? process.env, GIT_TERMINAL_PROMPT: "0" },
32182
+ maxBuffer: 64 * 1024 * 1024,
32183
+ timeout: options.timeoutMs ?? GIT_TIMEOUTS.local,
32184
+ killSignal: "SIGKILL",
32185
+ windowsHide: true,
32186
+ ...options.input === undefined ? { stdio: ["ignore", "pipe", "pipe"] } : { input: options.input, stdio: ["pipe", "pipe", "pipe"] }
32187
+ });
32188
+ return {
32189
+ ok: result.status === 0,
32190
+ status: result.status,
32191
+ stdout: result.stdout ?? "",
32192
+ stderr: result.stderr ?? "",
32193
+ signal: result.signal
32194
+ };
32195
+ };
32196
+ function operationInProgress(cwd) {
32197
+ const markers = [
32198
+ ["rebase-merge", "rebase"],
32199
+ ["rebase-apply", "rebase"],
32200
+ ["MERGE_HEAD", "merge"],
32201
+ ["CHERRY_PICK_HEAD", "cherry-pick"],
32202
+ ["REVERT_HEAD", "revert"]
32203
+ ];
32204
+ const run = git5(cwd, ["rev-parse", ...markers.flatMap(([name]) => ["--git-path", name])]);
32205
+ if (!run.ok)
32206
+ return null;
32207
+ const found = run.stdout.split(`
32208
+ `).map((line) => path50.resolve(cwd, line.trim()));
32209
+ const conflicted = () => git5(cwd, ["ls-files", "-u"]).stdout.trim() !== "";
32210
+ for (const [index, [, operation]] of markers.entries()) {
32211
+ const marker = found[index];
32212
+ if (!marker || !existsSync19(marker))
32213
+ continue;
32214
+ if (index === 1 && existsSync19(path50.join(marker, "applying")))
32215
+ return { operation: "am", commitAllowed: false, branch: null };
32216
+ if (index === 0 && existsSync19(path50.join(marker, "amend")) && !conflicted()) {
32217
+ let headName = "";
32218
+ try {
32219
+ headName = readFileSync14(path50.join(marker, "head-name"), "utf8").trim();
32220
+ } catch {}
32221
+ const branch = headName.startsWith("refs/heads/") ? headName.slice("refs/heads/".length) : null;
32222
+ return { operation, commitAllowed: branch !== null, branch };
32223
+ }
32224
+ if ((operation === "revert" || operation === "merge") && !conflicted())
32225
+ return { operation, commitAllowed: true, branch: null };
32226
+ return { operation, commitAllowed: false, branch: null };
32227
+ }
32228
+ return null;
32229
+ }
32230
+ function inProgressFailure(operation, verb) {
32231
+ const command = operation === "am" ? "git am" : `git ${operation}`;
32232
+ return failure3("blocked", `${operation.replace("-", "_")}_in_progress: a ${operation === "am" ? "git am" : operation} is in progress; finish or abort it before workit can ${verb}`, `resolve the conflicts, git add <files>, then ${command} --continue # or ${command} --abort to return to where you started`);
32233
+ }
32234
+ var PRIVATE_INDEX_TTL_MS = 60 * 60000;
32235
+ function pushPreflight(cwd, options = {}) {
32236
+ const progress = operationInProgress(cwd);
32237
+ if (progress)
32238
+ return inProgressFailure(progress.operation, "push");
32239
+ const branch = options.branch ?? currentBranch(cwd);
32240
+ if (!branch)
32241
+ return failure3("invalid_input", "HEAD is detached; push a branch");
32242
+ if (isProtectedTarget(cwd, branch))
32243
+ return failure3("blocked", `protected_branch: ${branch} is protected by the workspace branch policy; workit git push never pushes to it`, releaseBranch(cwd, branch) ? `workit git push --release ${branch} # finishing a release or hotfix; needs the release grant` : "workit git branch <feature/name> # push a feature branch and open a PR");
32244
+ const sha = resolveRef(cwd, `refs/heads/${branch}`);
32245
+ if (!sha)
32246
+ return failure3("not_found", `branch ${branch} has no commit to push`);
32247
+ const remote = pushRemoteName(cwd, branch);
32248
+ if (!remote)
32249
+ return failure3("not_found", "no push remote is configured for this branch", "git remote add origin <url>");
32250
+ const raw = pushUrl(cwd, remote);
32251
+ if (!raw)
32252
+ return failure3("blocked", `remote "${remote}" has no single push URL`, `git remote get-url --push --all ${remote} # keep exactly one push URL`);
32253
+ const parsed = parseRemoteUrl(raw);
32254
+ const local = parsed?.protocol === "file";
32255
+ if (!local && !pushTargetIsStable(cwd, raw))
32256
+ return failure3("blocked", `push_target_rewritten: the push URL of "${remote}" is rewritten by a url.*.insteadOf rule, so the destination is not the one checked`, "git config --get-regexp '^url\\.' # remove the rewrite for this remote");
32257
+ return success2({
32258
+ branch,
32259
+ sha,
32260
+ remote,
32261
+ url: redactRemote(raw),
32262
+ rawUrl: raw,
32263
+ local
32264
+ });
32265
+ }
32266
+
32267
+ // packages/workit-core/src/core/hygiene.ts
31779
32268
  var repoRoot3 = assetRoot();
31780
- var templatesDir = () => path50.join(repoRoot3, "templates", "hygiene");
32269
+ var templatesDir = () => path51.join(repoRoot3, "templates", "hygiene");
31781
32270
  var packageJson2 = (root) => {
31782
- if (!existsSync19(path50.join(root, "package.json")))
32271
+ if (!existsSync20(path51.join(root, "package.json")))
31783
32272
  return null;
31784
32273
  try {
31785
- return JSON.parse(readFileSync14(path50.join(root, "package.json"), "utf8"));
32274
+ return JSON.parse(readFileSync15(path51.join(root, "package.json"), "utf8"));
31786
32275
  } catch {
31787
32276
  return null;
31788
32277
  }
31789
32278
  };
31790
32279
  var isOpenSource = (root) => {
31791
- if (existsSync19(path50.join(root, "LICENSE")))
32280
+ if (existsSync20(path51.join(root, "LICENSE")))
31792
32281
  return true;
31793
32282
  const pkg = packageJson2(root);
31794
32283
  if (pkg && !pkg.private)
31795
32284
  return true;
31796
- return path50.basename(root) === "workit";
32285
+ return path51.basename(root) === "workit";
31797
32286
  };
31798
32287
  var licenseHolder = (root) => {
31799
32288
  const pkg = packageJson2(root);
@@ -31816,13 +32305,13 @@ var planHygieneFiles = (root, opts = {}) => {
31816
32305
  files.push("LICENSE", "CONTRIBUTING.md");
31817
32306
  const planned = [];
31818
32307
  for (const file of files) {
31819
- if (existsSync19(path50.join(root, file)))
32308
+ if (existsSync20(path51.join(root, file)))
31820
32309
  continue;
31821
- const tpl = path50.join(templatesDir(), file);
31822
- if (!existsSync19(tpl))
32310
+ const tpl = path51.join(templatesDir(), file);
32311
+ if (!existsSync20(tpl))
31823
32312
  continue;
31824
- const content = readFileSync14(tpl, "utf8").replace(/<PROJECT>/g, path50.basename(root)).replace(/<YEAR>/g, String(new Date().getFullYear())).replace(/<HOLDER>\s*/g, licenseHolder(root));
31825
- planned.push({ path: path50.join(root, file), content });
32313
+ const content = readFileSync15(tpl, "utf8").replace(/<PROJECT>/g, path51.basename(root)).replace(/<YEAR>/g, String(new Date().getFullYear())).replace(/<HOLDER>\s*/g, licenseHolder(root));
32314
+ planned.push({ path: path51.join(root, file), content });
31826
32315
  }
31827
32316
  return planned;
31828
32317
  };
@@ -31831,31 +32320,31 @@ var ensureHygieneFiles = (root, opts) => {
31831
32320
  return { ok: false, error: "confirmed: true required" };
31832
32321
  const created = [];
31833
32322
  for (const planned of planHygieneFiles(root, opts)) {
31834
- writeFileSync7(planned.path, planned.content, "utf8");
31835
- created.push(path50.basename(planned.path));
32323
+ writeFileSync8(planned.path, planned.content, "utf8");
32324
+ created.push(path51.basename(planned.path));
31836
32325
  }
31837
32326
  return { ok: true, created };
31838
32327
  };
31839
32328
 
31840
32329
  // packages/workit-core/src/core/init.ts
31841
32330
  import fs33 from "node:fs";
31842
- import path52 from "node:path";
31843
- import { spawnSync as spawnSync25 } from "node:child_process";
32331
+ import path53 from "node:path";
32332
+ import { spawnSync as spawnSync26 } from "node:child_process";
31844
32333
 
31845
32334
  // packages/workit-core/src/core/workspace-branch-policy.ts
31846
- import { mkdirSync as mkdirSync6, readFileSync as readFileSync15, renameSync as renameSync5, rmSync as rmSync3, writeFileSync as writeFileSync8 } from "node:fs";
31847
- import path51 from "node:path";
32335
+ import { mkdirSync as mkdirSync7, readFileSync as readFileSync16, renameSync as renameSync5, rmSync as rmSync4, writeFileSync as writeFileSync9 } from "node:fs";
32336
+ import path52 from "node:path";
31848
32337
  import { isDeepStrictEqual } from "node:util";
31849
32338
  var readFileSafe = (p) => {
31850
32339
  try {
31851
- return readFileSync15(p, "utf8");
32340
+ return readFileSync16(p, "utf8");
31852
32341
  } catch {
31853
32342
  return null;
31854
32343
  }
31855
32344
  };
31856
32345
  function applyWorkspaceBranchPolicy(opts) {
31857
32346
  const { workspace_root, env = process.env } = opts;
31858
- const dir = path51.join(env.WORKIT_CONFIG ?? configDir2());
32347
+ const dir = path52.join(env.WORKIT_CONFIG ?? configDir2());
31859
32348
  const {
31860
32349
  status,
31861
32350
  path: wsPath,
@@ -31867,7 +32356,7 @@ function applyWorkspaceBranchPolicy(opts) {
31867
32356
  if (status === "malformed" || status === "invalid")
31868
32357
  return { ok: false, error: workspacesError ?? `invalid workspaces.json: ${wsPath}` };
31869
32358
  const detection = detectBranchPolicy(workspace_root);
31870
- const name = String(env.WORKIT_BP_NAME ?? path51.basename(workspace_root));
32359
+ const name = String(env.WORKIT_BP_NAME ?? path52.basename(workspace_root));
31871
32360
  const integration = env.WORKIT_BP_INTEGRATION ?? detection.integration;
31872
32361
  const policy = {
31873
32362
  preset: detection.preset,
@@ -31916,13 +32405,13 @@ function applyWorkspaceBranchPolicy(opts) {
31916
32405
  ok: false,
31917
32406
  error: `workspaces.json changed while applying the branch policy: ${wsPath}`
31918
32407
  };
31919
- mkdirSync6(path51.dirname(wsPath), { recursive: true });
32408
+ mkdirSync7(path52.dirname(wsPath), { recursive: true });
31920
32409
  const tmp = `${wsPath}.${process.pid}.tmp`;
31921
32410
  try {
31922
- writeFileSync8(tmp, JSON.stringify({ ...document, workspaces: next }, null, 2) + `
32411
+ writeFileSync9(tmp, JSON.stringify({ ...document, workspaces: next }, null, 2) + `
31923
32412
  `, "utf8");
31924
32413
  if (workspacesRevision(readFileSafe(wsPath)) !== revision) {
31925
- rmSync3(tmp, { force: true });
32414
+ rmSync4(tmp, { force: true });
31926
32415
  return {
31927
32416
  ok: false,
31928
32417
  error: `workspaces.json changed while applying the branch policy: ${wsPath}`
@@ -31931,7 +32420,7 @@ function applyWorkspaceBranchPolicy(opts) {
31931
32420
  renameSync5(tmp, wsPath);
31932
32421
  } catch (error) {
31933
32422
  try {
31934
- rmSync3(tmp, { force: true });
32423
+ rmSync4(tmp, { force: true });
31935
32424
  } catch {}
31936
32425
  return {
31937
32426
  ok: false,
@@ -31962,7 +32451,7 @@ var resolveInitProvider = (cwd) => {
31962
32451
  return env.toLowerCase();
31963
32452
  const root = cwd ?? process.env.WORKIT_WORKSPACE_ROOT ?? process.cwd();
31964
32453
  try {
31965
- const out = spawnSync25("git", ["remote", "get-url", "origin"], {
32454
+ const out = spawnSync26("git", ["remote", "get-url", "origin"], {
31966
32455
  cwd: root,
31967
32456
  encoding: "utf8"
31968
32457
  });
@@ -32016,7 +32505,7 @@ function initApplyData(action, env = process.env) {
32016
32505
  fs33.mkdirSync(dir, { recursive: true });
32017
32506
  switch (action) {
32018
32507
  case "youtrack_json": {
32019
- const out = path52.join(dir, "youtrack.json");
32508
+ const out = path53.join(dir, "youtrack.json");
32020
32509
  fs33.writeFileSync(out, JSON.stringify(youtrackJsonContent(), null, 2) + `
32021
32510
  `, "utf8");
32022
32511
  return { action, ok: true, path: out };
@@ -32030,10 +32519,10 @@ function initApplyData(action, env = process.env) {
32030
32519
  };
32031
32520
  }
32032
32521
  case "youtrack_scaffold": {
32033
- const jsonOut = path52.join(dir, "youtrack.json");
32522
+ const jsonOut = path53.join(dir, "youtrack.json");
32034
32523
  fs33.writeFileSync(jsonOut, JSON.stringify(youtrackJsonContent(), null, 2) + `
32035
32524
  `, "utf8");
32036
- const configPath = path52.resolve(jsonOut);
32525
+ const configPath = path53.resolve(jsonOut);
32037
32526
  const cfg = readJson3(configPath) ?? {};
32038
32527
  const base = String(cfg.baseUrl ?? "").replace(/\/+$/, "");
32039
32528
  const meeting = String(cfg.meetingIssue ?? "");
@@ -32069,10 +32558,10 @@ function initApplyData(action, env = process.env) {
32069
32558
  };
32070
32559
  }
32071
32560
  case "vcs_scaffold": {
32072
- const jsonOut = path52.join(dir, "vcs.json");
32561
+ const jsonOut = path53.join(dir, "vcs.json");
32073
32562
  fs33.writeFileSync(jsonOut, JSON.stringify(vcsJsonContent(), null, 2) + `
32074
32563
  `, "utf8");
32075
- const configPath = path52.resolve(jsonOut);
32564
+ const configPath = path53.resolve(jsonOut);
32076
32565
  const prev = process.env.WORKIT_VCS_CONFIG;
32077
32566
  process.env.WORKIT_VCS_CONFIG = configPath;
32078
32567
  try {
@@ -32191,7 +32680,7 @@ var executeInitApply = (args, directory, runtime) => {
32191
32680
  protectedNames: args.branch_policy_protected
32192
32681
  }, current);
32193
32682
  writeConfig(next);
32194
- return output(ok({ action: "config", path: path53.join(configDir2(), "config.json"), ...next }));
32683
+ return output(ok({ action: "config", path: path54.join(configDir2(), "config.json"), ...next }));
32195
32684
  }
32196
32685
  const env = Object.fromEntries(Object.entries({
32197
32686
  WORKIT_YT_BASE_URL: args.base_url,
@@ -32208,14 +32697,14 @@ var executeInitApply = (args, directory, runtime) => {
32208
32697
 
32209
32698
  // packages/workit-opencode/src/shared/session.ts
32210
32699
  import { realpathSync as realpathSync12 } from "node:fs";
32211
- import path54 from "node:path";
32700
+ import path55 from "node:path";
32212
32701
  var sameWorkspace = (expected, observed) => {
32213
32702
  if (typeof observed !== "string" || !observed)
32214
32703
  return false;
32215
32704
  try {
32216
32705
  return realpathSync12(expected) === realpathSync12(observed);
32217
32706
  } catch {
32218
- return path54.resolve(expected) === path54.resolve(observed);
32707
+ return path55.resolve(expected) === path55.resolve(observed);
32219
32708
  }
32220
32709
  };
32221
32710
 
@@ -32287,7 +32776,7 @@ var workitFamilyOf = (toolName) => {
32287
32776
 
32288
32777
  // packages/workit-opencode/src/tools/context.ts
32289
32778
  import { realpathSync as realpathSync13 } from "node:fs";
32290
- import path55 from "node:path";
32779
+ import path56 from "node:path";
32291
32780
  var createContextTool = () => ({
32292
32781
  description: "Read Git, pull request, YouTrack, issue, changelog, release, or affected-file context.",
32293
32782
  execute: async (args, context) => {
@@ -32297,7 +32786,7 @@ var createContextTool = () => ({
32297
32786
  let root;
32298
32787
  try {
32299
32788
  const cwd = parsed.data.cwd;
32300
- root = realpathSync13(cwd ? path55.resolve(context.directory, cwd) : context.directory);
32789
+ root = realpathSync13(cwd ? path56.resolve(context.directory, cwd) : context.directory);
32301
32790
  } catch {
32302
32791
  return JSON.stringify(failure2("invalid_input", "context target directory cannot be resolved"), null, 2);
32303
32792
  }
@@ -32333,7 +32822,7 @@ import fs35 from "node:fs";
32333
32822
  import path58 from "node:path";
32334
32823
 
32335
32824
  // packages/workit-core/src/fanout-landed.ts
32336
- import { spawnSync as spawnSync26 } from "node:child_process";
32825
+ import { spawnSync as spawnSync27 } from "node:child_process";
32337
32826
  function trunkRefresher(cwd, trunk) {
32338
32827
  const match = /^refs\/remotes\/([^/]+)\/(.+)$/u.exec(trunk);
32339
32828
  if (!match)
@@ -32422,7 +32911,7 @@ function trunkPatchIds(ctx, fork) {
32422
32911
  "--"
32423
32912
  ]);
32424
32913
  if (log.ok && log.stdout.trim()) {
32425
- const run = spawnSync26("git", ["patch-id", "--stable"], {
32914
+ const run = spawnSync27("git", ["patch-id", "--stable"], {
32426
32915
  cwd: ctx.cwd,
32427
32916
  input: log.stdout,
32428
32917
  encoding: "utf8",
@@ -32566,109 +33055,6 @@ import { createHash as createHash20, randomBytes as randomBytes4 } from "node:cr
32566
33055
  import fs34 from "node:fs";
32567
33056
  import path57 from "node:path";
32568
33057
 
32569
- // packages/workit-core/src/git/ops.ts
32570
- import { spawnSync as spawnSync27 } from "node:child_process";
32571
- import {
32572
- copyFileSync as copyFileSync3,
32573
- existsSync as existsSync20,
32574
- mkdirSync as mkdirSync7,
32575
- readdirSync as readdirSync7,
32576
- readFileSync as readFileSync16,
32577
- rmSync as rmSync4,
32578
- writeFileSync as writeFileSync9
32579
- } from "node:fs";
32580
- import path56 from "node:path";
32581
- var COMMIT_TIMEOUT_MS = 10 * 60000;
32582
- var git5 = (cwd, args, options = {}) => {
32583
- const result = spawnSync27("git", args, {
32584
- cwd,
32585
- encoding: "utf8",
32586
- env: { ...options.env ?? process.env, GIT_TERMINAL_PROMPT: "0" },
32587
- maxBuffer: 64 * 1024 * 1024,
32588
- timeout: options.timeoutMs ?? GIT_TIMEOUTS.local,
32589
- killSignal: "SIGKILL",
32590
- windowsHide: true,
32591
- ...options.input === undefined ? { stdio: ["ignore", "pipe", "pipe"] } : { input: options.input, stdio: ["pipe", "pipe", "pipe"] }
32592
- });
32593
- return {
32594
- ok: result.status === 0,
32595
- status: result.status,
32596
- stdout: result.stdout ?? "",
32597
- stderr: result.stderr ?? "",
32598
- signal: result.signal
32599
- };
32600
- };
32601
- function operationInProgress(cwd) {
32602
- const markers = [
32603
- ["rebase-merge", "rebase"],
32604
- ["rebase-apply", "rebase"],
32605
- ["MERGE_HEAD", "merge"],
32606
- ["CHERRY_PICK_HEAD", "cherry-pick"],
32607
- ["REVERT_HEAD", "revert"]
32608
- ];
32609
- const run = git5(cwd, ["rev-parse", ...markers.flatMap(([name]) => ["--git-path", name])]);
32610
- if (!run.ok)
32611
- return null;
32612
- const found = run.stdout.split(`
32613
- `).map((line) => path56.resolve(cwd, line.trim()));
32614
- const conflicted = () => git5(cwd, ["ls-files", "-u"]).stdout.trim() !== "";
32615
- for (const [index, [, operation]] of markers.entries()) {
32616
- const marker = found[index];
32617
- if (!marker || !existsSync20(marker))
32618
- continue;
32619
- if (index === 1 && existsSync20(path56.join(marker, "applying")))
32620
- return { operation: "am", commitAllowed: false, branch: null };
32621
- if (index === 0 && existsSync20(path56.join(marker, "amend")) && !conflicted()) {
32622
- let headName = "";
32623
- try {
32624
- headName = readFileSync16(path56.join(marker, "head-name"), "utf8").trim();
32625
- } catch {}
32626
- const branch = headName.startsWith("refs/heads/") ? headName.slice("refs/heads/".length) : null;
32627
- return { operation, commitAllowed: branch !== null, branch };
32628
- }
32629
- if ((operation === "revert" || operation === "merge") && !conflicted())
32630
- return { operation, commitAllowed: true, branch: null };
32631
- return { operation, commitAllowed: false, branch: null };
32632
- }
32633
- return null;
32634
- }
32635
- function inProgressFailure(operation, verb) {
32636
- const command = operation === "am" ? "git am" : `git ${operation}`;
32637
- return failure3("blocked", `${operation.replace("-", "_")}_in_progress: a ${operation === "am" ? "git am" : operation} is in progress; finish or abort it before workit can ${verb}`, `resolve the conflicts, git add <files>, then ${command} --continue # or ${command} --abort to return to where you started`);
32638
- }
32639
- var PRIVATE_INDEX_TTL_MS = 60 * 60000;
32640
- function pushPreflight(cwd, options = {}) {
32641
- const progress = operationInProgress(cwd);
32642
- if (progress)
32643
- return inProgressFailure(progress.operation, "push");
32644
- const branch = options.branch ?? currentBranch(cwd);
32645
- if (!branch)
32646
- return failure3("invalid_input", "HEAD is detached; push a branch");
32647
- if (isProtectedTarget(cwd, branch))
32648
- return failure3("blocked", `protected_branch: ${branch} is protected by the workspace branch policy; workit git push never pushes to it`, releaseBranch(cwd, branch) ? `workit git push --release ${branch} # finishing a release or hotfix; needs the release grant` : "workit git branch <feature/name> # push a feature branch and open a PR");
32649
- const sha = resolveRef(cwd, `refs/heads/${branch}`);
32650
- if (!sha)
32651
- return failure3("not_found", `branch ${branch} has no commit to push`);
32652
- const remote = pushRemoteName(cwd, branch);
32653
- if (!remote)
32654
- return failure3("not_found", "no push remote is configured for this branch", "git remote add origin <url>");
32655
- const raw = pushUrl(cwd, remote);
32656
- if (!raw)
32657
- return failure3("blocked", `remote "${remote}" has no single push URL`, `git remote get-url --push --all ${remote} # keep exactly one push URL`);
32658
- const parsed = parseRemoteUrl(raw);
32659
- const local = parsed?.protocol === "file";
32660
- if (!local && !pushTargetIsStable(cwd, raw))
32661
- return failure3("blocked", `push_target_rewritten: the push URL of "${remote}" is rewritten by a url.*.insteadOf rule, so the destination is not the one checked`, "git config --get-regexp '^url\\.' # remove the rewrite for this remote");
32662
- return success2({
32663
- branch,
32664
- sha,
32665
- remote,
32666
- url: redactRemote(raw),
32667
- rawUrl: raw,
32668
- local
32669
- });
32670
- }
32671
-
32672
33058
  // packages/workit-core/src/forge/report.ts
32673
33059
  var GITLAB_MERGEABLE = new Set(["mergeable"]);
32674
33060
  var GITHUB_MERGEABLE = new Set(["clean", "unstable", "has_hooks"]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/opencode",
3
- "version": "2.25.5",
3
+ "version": "2.26.0",
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.26.0"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=24"