@workit-dev/opencode 2.20.0 → 2.20.2

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 +48 -23
  2. package/package.json +2 -2
package/dist/plugin.js CHANGED
@@ -15353,7 +15353,23 @@ function runsByGlob(command, name) {
15353
15353
  const tokens = command.split(/\s+/u).map((token) => token.replace(/^--filter=/u, "").replaceAll(/^["']|["']$/gu, "").replace(/^(?:npm|pnpm|yarn|bun):/u, ""));
15354
15354
  if (/\bpnpm\b/u.test(command) && tokens.some((token) => /^\/.+\/$/u.test(token)))
15355
15355
  return true;
15356
- return tokens.filter((token) => token.includes("*")).some((glob) => new RegExp(`^${glob.split(/\*+/u).map((part) => part.replaceAll(/[.+?^${}()|[\]\\]/gu, "\\$&")).join(".*")}$`, "u").test(name));
15356
+ return tokens.filter((token) => token.includes("*")).some((glob) => globMatches(glob, name));
15357
+ }
15358
+ function globMatches(glob, name) {
15359
+ const parts = glob.split("*");
15360
+ const first = parts[0];
15361
+ const last = parts.at(-1) ?? "";
15362
+ const end = name.length - last.length;
15363
+ if (end < first.length || !name.startsWith(first) || !name.endsWith(last))
15364
+ return false;
15365
+ let at = first.length;
15366
+ for (const part of parts.slice(1, -1)) {
15367
+ const found = name.indexOf(part, at);
15368
+ if (found < 0 || found + part.length > end)
15369
+ return false;
15370
+ at = found + part.length;
15371
+ }
15372
+ return true;
15357
15373
  }
15358
15374
  function goDirectives(text) {
15359
15375
  const out = [];
@@ -20453,7 +20469,8 @@ var tokenize = (command, dialect) => {
20453
20469
  if (current.words.length) {
20454
20470
  current.pipe = true;
20455
20471
  current.conditional = true;
20456
- }
20472
+ } else if (segments.at(-1)?.group === "close")
20473
+ segments.at(-1).pipe = true;
20457
20474
  if (next === "&")
20458
20475
  index++;
20459
20476
  }
@@ -25811,7 +25828,22 @@ var hasWordsInOrder = (words, needle) => {
25811
25828
  return false;
25812
25829
  };
25813
25830
  var isBypass = (word) => WORKIT_BYPASS_FLAGS.some((flag) => word === flag || word.startsWith(`${flag}=`));
25814
- var isWorkitWord = (word) => /^(?:.*[\\/])?workit(?:-cli)?$/u.test(word);
25831
+ var isWorkitWord = (word) => /^(?:(?:.*[\\/])?workit(?:-cli)?|@workit-dev\/cli(?:@[\w.-]+)?)$/u.test(word);
25832
+ var verbAt = (words) => {
25833
+ let at = 0;
25834
+ for (;; ) {
25835
+ const word = words[at];
25836
+ if (word === "--json")
25837
+ at += 1;
25838
+ else if (word === "--cwd" || word === "--session")
25839
+ at += 2;
25840
+ else if (word?.startsWith("--cwd=") || word?.startsWith("--session="))
25841
+ at += 1;
25842
+ else
25843
+ return at;
25844
+ }
25845
+ };
25846
+ var WRAPPERS2 = new Set(["env", "sudo", "nohup", "command", "timeout", "nice", "exec"]);
25815
25847
  var isAllowedWorkitCall = (words, expands = []) => {
25816
25848
  if (words[0] !== "workit")
25817
25849
  return false;
@@ -25854,19 +25886,7 @@ var userOnlyWorkitCall = (command, dialect = "posix") => {
25854
25886
  const words = segment.words.slice(start + 1);
25855
25887
  const end = words.indexOf("--");
25856
25888
  const args = end < 0 ? words : words.slice(0, end);
25857
- let at = 0;
25858
- for (;; ) {
25859
- const word = args[at];
25860
- if (word === "--json")
25861
- at += 1;
25862
- else if (word === "--cwd" || word === "--session")
25863
- at += 2;
25864
- else if (word?.startsWith("--cwd="))
25865
- at += 1;
25866
- else
25867
- break;
25868
- }
25869
- const call = args.slice(at);
25889
+ const call = args.slice(verbAt(args));
25870
25890
  const found = WORKIT_USER_ONLY.find((needle) => call[0] === needle[0] && hasWordsInOrder(call, needle));
25871
25891
  if (found && !helpOnly(call, found))
25872
25892
  return [...found];
@@ -26644,7 +26664,10 @@ function heavyPlan(command, options) {
26644
26664
  };
26645
26665
  }
26646
26666
  if (single) {
26647
- const rewrite = leaseRewrite(command.trim().replace(TAIL_FILTER, ""));
26667
+ const rewrite = leaseRewrite(command.trim().replace(TAIL_FILTER, (_, merged = "", redirects = "") => {
26668
+ const out = [...redirects.matchAll(/(\d*)(>>?)\s*(\S+)/gu)].findLast(([, fd]) => fd === "" || fd === "1");
26669
+ return out ? ` ${out[2]} ${out[3]}${merged}` : "";
26670
+ }));
26648
26671
  return rewrite ? { kind: "rewrite", command: rewrite, reason: single.reason } : { kind: "none" };
26649
26672
  }
26650
26673
  const parts = heavy.map((match) => leaseCommand(match.line));
@@ -26689,7 +26712,7 @@ function workitOnPath2(env = process.env) {
26689
26712
  }
26690
26713
  return false;
26691
26714
  }
26692
- var TAIL_FILTER = /(?:\s+2>&1)?\s*\|\s*(?:tail|head)(?:\s+[\w=.+-]+)*\s*$/u;
26715
+ var TAIL_FILTER = /(\s+2>&1)?\s*\|\s*(?:tail|head)(?:\s+(?!\d*>)[\w=.+-]+)*((?:\s*\d*>>?\s*[\w./~-]+)*)\s*$/u;
26693
26716
  var ASSIGNMENTS = /^\s*((?:[A-Za-z_]\w*=(?:'[^']*'|"(?:[^"\\]|\\.)*"|[^\s'"])*\s+)*)/u;
26694
26717
  function leaseRewrite(command) {
26695
26718
  const text = command.trim();
@@ -27144,7 +27167,7 @@ var editsOf = (input) => {
27144
27167
  return [];
27145
27168
  }
27146
27169
  };
27147
- var WRAPPERS2 = {
27170
+ var WRAPPERS3 = {
27148
27171
  sudo: "ugCDhpRrTtU",
27149
27172
  doas: "uC",
27150
27173
  env: "uCS",
@@ -27224,7 +27247,7 @@ var scriptArgs = (verb, args) => {
27224
27247
  };
27225
27248
  var unwrapped = (words) => {
27226
27249
  let at = 0;
27227
- for (let takes;(takes = WRAPPERS2[words[at]?.split(/[\\/]/).at(-1) ?? ""]) !== undefined; ) {
27250
+ for (let takes;(takes = WRAPPERS3[words[at]?.split(/[\\/]/).at(-1) ?? ""]) !== undefined; ) {
27228
27251
  at++;
27229
27252
  while (at < words.length && /^-|^\w+=|^\d[\w.]*$/.test(words[at]))
27230
27253
  at += words[at].length === 2 && words[at][0] === "-" && takes.includes(words[at][1]) ? 2 : 1;
@@ -30628,7 +30651,6 @@ var retryOf = ({ call, dir }) => {
30628
30651
  function exitPipeGate(command, dialect = "posix") {
30629
30652
  if (!/\bworkit/u.test(command) || !/\b(?:tail|head)\b/u.test(command))
30630
30653
  return null;
30631
- const subshellPiped = /\)\s*(?:\d*>&?\d*\s*)*\|(?!\|)/u.test(command);
30632
30654
  const groups = [];
30633
30655
  let carry = null;
30634
30656
  let pipefail = false;
@@ -30651,10 +30673,13 @@ function exitPipeGate(command, dialect = "posix") {
30651
30673
  }
30652
30674
  if (closes) {
30653
30675
  const inner = groups.pop() ?? null;
30654
- const piped = segment.pipe === true || segment.group === "close" && subshellPiped;
30655
- carry = piped ? inner ?? carry : null;
30676
+ if (inner && groups.length)
30677
+ groups[groups.length - 1] = inner;
30678
+ carry = segment.pipe ? inner ?? carry : null;
30656
30679
  continue;
30657
30680
  }
30681
+ if (!words.length && !segment.stdin && !segment.subs)
30682
+ continue;
30658
30683
  if (setsPipefail(words))
30659
30684
  pipefail = true;
30660
30685
  const filter = base2(words[0]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/opencode",
3
- "version": "2.20.0",
3
+ "version": "2.20.2",
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.0.18",
44
- "@workit-dev/core": "^2.20.0"
44
+ "@workit-dev/core": "^2.20.2"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=24"