@workit-dev/opencode 1.1.6 → 1.1.8

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 +129 -11
  2. package/package.json +2 -2
package/dist/plugin.js CHANGED
@@ -25259,7 +25259,7 @@ function heavyGate(cwd, command, options) {
25259
25259
  }
25260
25260
  }
25261
25261
  // packages/workit-core/src/hooks/write-gate.ts
25262
- import { existsSync as existsSync11, realpathSync as realpathSync8 } from "node:fs";
25262
+ import { existsSync as existsSync11, realpathSync as realpathSync8, statSync as statSync4 } from "node:fs";
25263
25263
  import os9 from "node:os";
25264
25264
  import path38 from "node:path";
25265
25265
 
@@ -25663,12 +25663,81 @@ var opaqueWrites = (input, scriptOf = (index) => input[index]) => {
25663
25663
  })
25664
25664
  ];
25665
25665
  };
25666
+ if (name === "curl")
25667
+ return curlOutputs(args);
25666
25668
  if (name === "perl")
25667
25669
  return inline(/^-[a-zA-Z]*[eE]$/);
25668
25670
  if (/^(?:python[\d.]*|node|bun|deno|ruby|php)$/.test(name))
25669
25671
  return inline(/^-[a-zA-Z]*[ce]$|^--eval$|^-p$/);
25670
25672
  return shellScript2(words) === null ? null : ["."];
25671
25673
  };
25674
+ var CURL_LONG = [
25675
+ "output",
25676
+ "output-dir",
25677
+ "cookie-jar",
25678
+ "dump-header",
25679
+ "trace",
25680
+ "trace-ascii",
25681
+ "stderr",
25682
+ "libcurl",
25683
+ "hsts",
25684
+ "alt-svc",
25685
+ "etag-save",
25686
+ "config",
25687
+ "write-out",
25688
+ "remote-name",
25689
+ "remote-name-all"
25690
+ ];
25691
+ var CURL_SHORT_LONG = {
25692
+ o: "output",
25693
+ c: "cookie-jar",
25694
+ D: "dump-header",
25695
+ K: "config",
25696
+ w: "write-out"
25697
+ };
25698
+ var CURL_SHORT = /^-([^-AbcCdDeEFHKmoPQrtTuUwxXyYz]*)(?:([AbcCdDeEFHKmoPQrtTuUwxXyYz])(.*))?$/s;
25699
+ var curlOutputs = (args) => {
25700
+ const files = [];
25701
+ const named = [];
25702
+ const dirs = [];
25703
+ let remote = false;
25704
+ for (let index = 0;index < args.length; index++) {
25705
+ const long = /^--([\w.-]+)(?:=(.*))?$/s.exec(args[index]);
25706
+ const short = long ? null : CURL_SHORT.exec(args[index]);
25707
+ if (short?.[1].includes("O"))
25708
+ remote = true;
25709
+ const option = long ? long[1] === "cookie" ? undefined : CURL_LONG.find((name) => name === long[1]) ?? CURL_LONG.find((name) => name.startsWith(long[1])) : CURL_SHORT_LONG[short?.[2] ?? ""];
25710
+ if (option?.startsWith("remote-name"))
25711
+ remote = true;
25712
+ if (option === undefined || option.startsWith("remote-name")) {
25713
+ if (short?.[2] && !short[3])
25714
+ index++;
25715
+ continue;
25716
+ }
25717
+ const value = (long ? long[2] : short?.[3]) || args[++index];
25718
+ if (option === "config" || option === "write-out" && value?.startsWith("@"))
25719
+ files.push(unknownVarTarget(`curl ${option === "config" ? "-K <config>" : "-w @<format>"}`));
25720
+ else if (value === undefined || value === "-")
25721
+ continue;
25722
+ else if (option === "output")
25723
+ named.push(value);
25724
+ else if (option === "output-dir")
25725
+ dirs.push(value);
25726
+ else if (option === "write-out")
25727
+ for (const match of value.matchAll(/%output\{(?:>>)?([^}]*)\}/g))
25728
+ files.push(match[1]);
25729
+ else
25730
+ files.push(value);
25731
+ }
25732
+ for (const name of named) {
25733
+ if (dirs.length === 0 || /^[/~$]|^[A-Za-z]:[\\/]/.test(name))
25734
+ files.push(name);
25735
+ files.push(...dirs.map((dir) => `${dir}/${name}`));
25736
+ }
25737
+ if (remote)
25738
+ files.push(...dirs.length ? dirs : ["."]);
25739
+ return files.length > 0 ? files : null;
25740
+ };
25672
25741
  var pathsIn = (text) => [
25673
25742
  ...text.matchAll(/(?<![\w.~:/$-])(?:~\/|\/|[A-Za-z]:\/|\.\.(?:\/|$))[^\s'"`$),;:*?<>|\\[\]{}]*/g)
25674
25743
  ].map((match) => match[0]);
@@ -25771,6 +25840,7 @@ var MUTATING_GIT = new Set([
25771
25840
  var DRY_N = new Set(["add", "clean", "rm", "mv"]);
25772
25841
  var MUTATING_WORKIT_GIT = new Set(["commit", "branch", "stage", "unstage"]);
25773
25842
  var DIR_TARGET = ".workit-live-target";
25843
+ var OPAQUE_TARGET = ".workit-runs-";
25774
25844
  var OVERRIDE = "WORKIT_LIVE_SESSION=override";
25775
25845
  var inert = (args, sub) => args.some((arg) => arg === "--help" || arg === "-h" || arg === "--dry-run" || DRY_N.has(sub) && /^-[a-zA-Z]*n[a-zA-Z]*$/.test(arg) && !arg.startsWith("--"));
25776
25846
  var gitMutationDirs = (cwd, command, dialect) => {
@@ -25900,6 +25970,10 @@ var untrustedVars = (segments) => {
25900
25970
  depth = Math.max(0, depth - 1);
25901
25971
  }
25902
25972
  const words = segment.words.slice(start);
25973
+ const at = words.findIndex((word) => !/^\w+=/.test(word));
25974
+ const ifs = (word) => /\bIFS\b/.test(word);
25975
+ if (segment.subs?.some(ifs) || words.some((w, i) => ifs(w) && !(i < at && words[at] === "read")))
25976
+ all = true;
25903
25977
  if (depth > 0)
25904
25978
  for (const [key] of assignmentsOf(words))
25905
25979
  names.add(key);
@@ -25944,7 +26018,10 @@ var unresolvedRefs = (text) => [
25944
26018
  return name === undefined ? match[0] : `$${name}`;
25945
26019
  }))
25946
26020
  ];
25947
- var unknownVarTarget = (text) => path38.join(UNKNOWN_VAR, encodeURIComponent(unresolvedRefs(text).join(" ") || text));
26021
+ var unknownVarTarget = (text) => {
26022
+ const refs = unresolvedRefs(text);
26023
+ return path38.join(UNKNOWN_VAR, (refs.length > 0 ? refs : [text]).map(encodeURIComponent).join("+"));
26024
+ };
25948
26025
  var applyOperator = (value, operator) => {
25949
26026
  if (operator === "")
25950
26027
  return value;
@@ -26040,6 +26117,20 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
26040
26117
  const name = /^\$(\w+)$/.exec(ref)?.[1];
26041
26118
  return name === undefined || new RegExp(`(?<!\\\\)\\$(?:${name}(?!\\w)|\\{${name}\\b)`).test(command);
26042
26119
  };
26120
+ const listWord = (word) => unresolvedRefs(word).length > 0 || /[\s*?[]/.test(word) ? null : word;
26121
+ const listWords = (item) => expansions(item, vars, loops).map((text) => listWord(homeExpanded(text)));
26122
+ const redefined = untrusted.all || Boolean(process.env.CDPATH) || /\bCDPATH\b/.test(command) || segments.some((s, i) => s.words.length > 0 && segments[i + 1]?.group === "open" && segments[i + 2]?.group === "close");
26123
+ const moved = (plain) => {
26124
+ if (plain && !redefined && !untrusted.names.has("PWD") && dir !== undefined && dir !== UNKNOWN_DIR && statSync4(dir, { throwIfNoEntry: false })?.isDirectory())
26125
+ vars.set("PWD", dir);
26126
+ else
26127
+ vars.delete("PWD");
26128
+ };
26129
+ const lost = () => {
26130
+ dir = strict ? UNKNOWN_DIR : undefined;
26131
+ stack = [];
26132
+ moved(false);
26133
+ };
26043
26134
  const assigned = (value) => {
26044
26135
  const made = mktempPath(value, dir);
26045
26136
  if (made !== null)
@@ -26069,10 +26160,10 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
26069
26160
  if (loop >= 0) {
26070
26161
  const [name = "", keyword, ...items] = segment.words.slice(loop + 1);
26071
26162
  const expanding = new Set(segment.expands ?? []);
26072
- const literal = keyword === "in" && items.every((_, index) => !expanding.has(loop + 3 + index));
26163
+ const list = items.flatMap((item, index) => expanding.has(loop + 3 + index) ? listWords(item) : [listWord(homeExpanded(item))]);
26073
26164
  vars.delete(name);
26074
- if (literal && !untrusted.all && !untrusted.names.has(name))
26075
- loops.set(name, items.map(homeExpanded));
26165
+ if (keyword === "in" && list.length <= MAX_EXPANSIONS2 && !list.includes(null) && !untrusted.all && !untrusted.names.has(name))
26166
+ loops.set(name, list);
26076
26167
  else
26077
26168
  loops.delete(name);
26078
26169
  continue;
@@ -26090,31 +26181,53 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
26090
26181
  vars.set(key, resolved);
26091
26182
  }
26092
26183
  }
26184
+ const moving = (word = "") => {
26185
+ const verb = (word.split(/[\\/]/).at(-1) ?? "").toLowerCase();
26186
+ return CD2.has(verb) || PUSHD2.has(verb) || POPD2.has(verb);
26187
+ };
26093
26188
  const name = (words[0]?.split(/[\\/]/).at(-1) ?? "").toLowerCase();
26094
- const moves = CD2.has(name) || PUSHD2.has(name) || POPD2.has(name);
26189
+ const moves = moving(name);
26095
26190
  if (moves && strict && nesting > 0) {
26096
26191
  dir = UNKNOWN_DIR;
26192
+ moved(false);
26097
26193
  continue;
26098
26194
  }
26099
- if (moves && keywords > 0)
26195
+ if (moves && keywords > 0) {
26196
+ moved(false);
26100
26197
  continue;
26198
+ }
26199
+ const wrapper = words.findIndex((word) => !TRANSPARENT.has(word) && !PREFIXES2.has(word));
26200
+ if (wrapper > 0 && moving(words[wrapper])) {
26201
+ lost();
26202
+ continue;
26203
+ }
26204
+ const plain = !segment.conditional;
26101
26205
  if (CD2.has(name)) {
26102
26206
  dir = cdInto(dir, words, strict, vars);
26207
+ moved(plain);
26208
+ continue;
26209
+ }
26210
+ const rotates = words.length < 2 || words.slice(1).some((word) => /^[-+]/.test(word));
26211
+ if (dialect === "posix" && (PUSHD2.has(name) ? rotates : POPD2.has(name) && words.length > 1)) {
26212
+ lost();
26103
26213
  continue;
26104
26214
  }
26105
26215
  if (PUSHD2.has(name)) {
26106
26216
  stack.push(dir);
26107
26217
  dir = cdInto(dir, words, strict, vars);
26218
+ moved(plain);
26108
26219
  continue;
26109
26220
  }
26110
26221
  if (POPD2.has(name)) {
26111
26222
  dir = stack.length ? stack.pop() : strict ? UNKNOWN_DIR : undefined;
26223
+ moved(plain);
26112
26224
  continue;
26113
26225
  }
26114
26226
  const inner = depth < 4 ? wrappedScript(words) ?? (strict ? shellScript2(words) : null) : null;
26227
+ const unPwd = () => new Map([...vars].filter(([key]) => key !== "PWD"));
26115
26228
  if (inner !== null && dir !== undefined)
26116
26229
  for (const runIn of workitRunDir(dir, words, atAll))
26117
- targets.push(...segmentTargets(runIn, inner, "posix", depth + 1, strict, vars));
26230
+ targets.push(...segmentTargets(runIn, inner, "posix", depth + 1, strict, runIn === dir ? vars : unPwd()));
26118
26231
  if (strict && dir !== undefined) {
26119
26232
  const runIn = dir;
26120
26233
  for (const sub of depth < 4 ? segment.subs ?? [] : [])
@@ -26125,13 +26238,18 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
26125
26238
  if (word === undefined || !expanding.has(keywords + index))
26126
26239
  return word;
26127
26240
  const all = expansions(word, vars, loops);
26128
- const open = all.length === 1 ? unresolvedRefs(all[0]).filter(unescaped) : [];
26129
- return all.length === 1 && open.length === 0 ? all[0] : undefined;
26241
+ return all.some((text) => unresolvedRefs(text).some(unescaped)) ? undefined : all.join(`
26242
+ `);
26130
26243
  };
26131
26244
  const opaque = segment.unanalyzable ? ["."] : inner === null ? opaqueWrites(body, scriptOf) : null;
26245
+ const ran = words.findIndex((word) => word === "xargs" || !PREFIXES2.has(word));
26246
+ const runner = words[ran];
26247
+ if (runner !== undefined && expanding.has(keywords + lead + ran) && unresolvedRefs(homeExpanded(runner)).length > 0)
26248
+ targets.push(unknownVarTarget(runner));
26249
+ const here = segment.unanalyzable ? DIR_TARGET : `${OPAQUE_TARGET}${encodeURIComponent(runner?.split(/[\\/]/).at(-1) ?? "a command")}`;
26132
26250
  for (const file of opaque ?? [])
26133
26251
  for (const resolved of atAll(file))
26134
- targets.push(file === "." ? path38.join(resolved, DIR_TARGET) : resolved);
26252
+ targets.push(file === "." ? path38.join(resolved, here) : resolved);
26135
26253
  const ln = words.findIndex((word) => /^ln$/i.test(word.split(/[\\/]/).at(-1) ?? ""));
26136
26254
  if (ln >= 0 && words.slice(0, ln).every((word) => PREFIXES2.has(word)))
26137
26255
  targets.push(...linkSources(words.slice(ln + 1), at));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/opencode",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
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": "^1.1.6"
44
+ "@workit-dev/core": "^1.1.8"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=24"