@workit-dev/opencode 1.8.1 → 1.8.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.
- package/dist/plugin.js +301 -41
- package/package.json +2 -2
package/dist/plugin.js
CHANGED
|
@@ -19267,7 +19267,9 @@ var tokenize = (command, dialect) => {
|
|
|
19267
19267
|
heredocs.push({ delimiter: text.replace(/^-/, ""), owner: current });
|
|
19268
19268
|
else if (pending === "herestring")
|
|
19269
19269
|
(current.stdin ??= []).push(text);
|
|
19270
|
-
else if (pending
|
|
19270
|
+
else if (pending === "input")
|
|
19271
|
+
(current.inputs ??= []).push(text);
|
|
19272
|
+
else {
|
|
19271
19273
|
const at = current.words.length;
|
|
19272
19274
|
current.words.push(...MARKERS.test(word) ? expandBraces(word) : [word]);
|
|
19273
19275
|
if (expanding || !posix && word.startsWith("@"))
|
|
@@ -25554,7 +25556,7 @@ function heavyGate(cwd, command, options) {
|
|
|
25554
25556
|
}
|
|
25555
25557
|
}
|
|
25556
25558
|
// packages/workit-core/src/hooks/write-gate.ts
|
|
25557
|
-
import { existsSync as existsSync13, realpathSync as realpathSync9, statSync as statSync5 } from "node:fs";
|
|
25559
|
+
import { existsSync as existsSync13, readdirSync as readdirSync5, readFileSync as readFileSync11, realpathSync as realpathSync9, statSync as statSync5 } from "node:fs";
|
|
25558
25560
|
import os9 from "node:os";
|
|
25559
25561
|
import path40 from "node:path";
|
|
25560
25562
|
|
|
@@ -25820,9 +25822,9 @@ var editsOf = (input) => {
|
|
|
25820
25822
|
case "cp":
|
|
25821
25823
|
case "ln":
|
|
25822
25824
|
case "install": {
|
|
25823
|
-
const
|
|
25824
|
-
if (
|
|
25825
|
-
return
|
|
25825
|
+
const into = valueOf(args, /^(?:-t|--target-directory=?)(.*)$/s);
|
|
25826
|
+
if (into !== undefined)
|
|
25827
|
+
return [into];
|
|
25826
25828
|
const last = operands(args).at(-1);
|
|
25827
25829
|
return last ? [last] : null;
|
|
25828
25830
|
}
|
|
@@ -25876,6 +25878,84 @@ var editsOf = (input) => {
|
|
|
25876
25878
|
return [];
|
|
25877
25879
|
}
|
|
25878
25880
|
};
|
|
25881
|
+
var WRAPPERS2 = {
|
|
25882
|
+
sudo: "ugCDhpRrTtU",
|
|
25883
|
+
doas: "uC",
|
|
25884
|
+
env: "uCS",
|
|
25885
|
+
nice: "n",
|
|
25886
|
+
ionice: "cnp",
|
|
25887
|
+
timeout: "sk",
|
|
25888
|
+
stdbuf: "ioe",
|
|
25889
|
+
time: "fo",
|
|
25890
|
+
nohup: "",
|
|
25891
|
+
command: "",
|
|
25892
|
+
exec: "a",
|
|
25893
|
+
setsid: "",
|
|
25894
|
+
builtin: "",
|
|
25895
|
+
"!": "",
|
|
25896
|
+
npx: "p",
|
|
25897
|
+
bunx: "p"
|
|
25898
|
+
};
|
|
25899
|
+
var INTERPRETERS = /^(?:python[\d.]*|node|bun|deno|ruby|perl|php|tsx|ts-node)$/;
|
|
25900
|
+
var isConfigDir = (file) => configDirs().some((dir) => canonical3(dir) === canonical3(file));
|
|
25901
|
+
var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals)$/.test(path40.relative(canonical3(resolveStateDir()), canonical3(file)));
|
|
25902
|
+
var READ_CALLS = /^(?:print|log|info|warn|error|debug|puts|readdir(?:Sync)?|listdir|scandir|iterdir|glob|l?stat(?:Sync)?|exists(?:Sync)?|isdir|isfile|is_dir|is_file|access(?:Sync)?|realpath(?:Sync)?|dirname|basename|relative|str|repr|len)$/;
|
|
25903
|
+
var MUTATING_CALLS = /^(?:renames?(?:Sync)?|move|copy(?:2|file|tree|File)?(?:Sync)?|cp(?:Sync)?|rm(?:tree|dir|Sync|dirSync)?|unlink(?:Sync)?|remove(?:dirs)?|mkdirs?(?:Sync)?|makedirs|mkdtemp(?:Sync)?|(?:sym|hard)?link(?:Sync|_to)?|write\w*|append\w*|truncate(?:Sync)?|ch(?:mod|own)(?:Sync)?|touch|open(?:Sync)?|dump|save|extractall|unpack_archive|put_contents|mv|FileUtils)$/;
|
|
25904
|
+
var PATH_CALLS = /^(?:join|resolve|normalize|abspath|expanduser|expandvars|Path|PurePath|fspath)$/;
|
|
25905
|
+
var readsRoot = (text, at) => {
|
|
25906
|
+
let call;
|
|
25907
|
+
for (let index = at, depth = 0;index > 0 && call === undefined; index--) {
|
|
25908
|
+
const char = text[index - 1];
|
|
25909
|
+
if (char === ")")
|
|
25910
|
+
depth++;
|
|
25911
|
+
else if (char === "(" && depth-- === 0)
|
|
25912
|
+
call = /([\w$]+)\s*$/.exec(text.slice(0, index - 1))?.[1] ?? "";
|
|
25913
|
+
else if (depth <= 0 && /[;\n]/.test(char))
|
|
25914
|
+
break;
|
|
25915
|
+
}
|
|
25916
|
+
if (call !== undefined && READ_CALLS.test(call))
|
|
25917
|
+
return true;
|
|
25918
|
+
if (call !== undefined && !PATH_CALLS.test(call))
|
|
25919
|
+
return false;
|
|
25920
|
+
return ![...text.matchAll(/([\w$]+)\s*\(/g)].some(([, name]) => MUTATING_CALLS.test(name));
|
|
25921
|
+
};
|
|
25922
|
+
var inertEdit = (command) => command.split("|").every((part) => /^:?(?:se(?:t)?|sy(?:ntax)?|colo(?:rscheme)?)(?:\s|$)|^[/?][^/?]*[/?]?$|^\d+$/.test(part.trim()));
|
|
25923
|
+
var SCRIPT_OPTIONS = [
|
|
25924
|
+
[/^(?:(?:ba|z|k|da)?sh|source|\.)$/, /^(?:[-+][oO]|--(?:rcfile|init-file))$/],
|
|
25925
|
+
[/^python/, /^-[WXQ]$/],
|
|
25926
|
+
[
|
|
25927
|
+
/./,
|
|
25928
|
+
/^(?:-[rCI]|--(?:require|import|(?:experimental-)?loader|preload|input-type|conditions|title|cwd|tsconfig|project|env-file|config))$/
|
|
25929
|
+
]
|
|
25930
|
+
];
|
|
25931
|
+
var PRELOAD = /^(?:-r|--(?:require|import|(?:experimental-)?loader|preload|rcfile|init-file))$/;
|
|
25932
|
+
var scriptArgs = (verb, args) => {
|
|
25933
|
+
const takes = SCRIPT_OPTIONS.find(([family]) => family.test(verb))?.[1] ?? /^$/;
|
|
25934
|
+
const preloads = [];
|
|
25935
|
+
for (let at = 0;at < args.length; at++) {
|
|
25936
|
+
const [option, value] = args[at].split(/=(.*)/s);
|
|
25937
|
+
if (value !== undefined && PRELOAD.test(option))
|
|
25938
|
+
preloads.push(value);
|
|
25939
|
+
else if (/^-[mce]$|^--(?:eval|print)$/.test(option))
|
|
25940
|
+
break;
|
|
25941
|
+
else if (takes.test(option)) {
|
|
25942
|
+
if (PRELOAD.test(option))
|
|
25943
|
+
preloads.push(args[at + 1] ?? "");
|
|
25944
|
+
at++;
|
|
25945
|
+
} else if (!/^[-+]/.test(option) && option !== "run")
|
|
25946
|
+
return { named: args[at], preloads };
|
|
25947
|
+
}
|
|
25948
|
+
return { preloads };
|
|
25949
|
+
};
|
|
25950
|
+
var unwrapped = (words) => {
|
|
25951
|
+
let at = 0;
|
|
25952
|
+
for (let takes;(takes = WRAPPERS2[words[at]?.split(/[\\/]/).at(-1) ?? ""]) !== undefined; ) {
|
|
25953
|
+
at++;
|
|
25954
|
+
while (at < words.length && /^-|^\w+=|^\d[\w.]*$/.test(words[at]))
|
|
25955
|
+
at += words[at].length === 2 && words[at][0] === "-" && takes.includes(words[at][1]) ? 2 : 1;
|
|
25956
|
+
}
|
|
25957
|
+
return at ? words.slice(at) : null;
|
|
25958
|
+
};
|
|
25879
25959
|
var shellScript2 = (words) => {
|
|
25880
25960
|
if (!SCRIPT_SHELLS.has((words[0]?.split(/[\\/]/).at(-1) ?? "").toLowerCase()))
|
|
25881
25961
|
return null;
|
|
@@ -26120,9 +26200,8 @@ var gitOutputs = (args) => {
|
|
|
26120
26200
|
const under = (file) => file === "." ? `${base}/${OPAQUE_TARGET}git` : /^[/~$]|^[A-Za-z]:[\\/]/.test(file) ? file : `${base}/${file}`;
|
|
26121
26201
|
return files.length ? files.map(under) : null;
|
|
26122
26202
|
};
|
|
26123
|
-
var
|
|
26124
|
-
|
|
26125
|
-
].map((match) => match[0]);
|
|
26203
|
+
var PATHS = /(?<![\w.~:/$-])(?:~\/|\/|[A-Za-z]:\/|\.\.(?:\/|$))[^\s'"`$),;:*?<>|\\[\]{}]*/g;
|
|
26204
|
+
var pathsIn = (text) => [...text.matchAll(PATHS)].map((match) => match[0]);
|
|
26126
26205
|
var linkSources = (args, at) => {
|
|
26127
26206
|
const names = operands([...args]);
|
|
26128
26207
|
const into = args.indexOf("-t");
|
|
@@ -26249,12 +26328,12 @@ var CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
|
|
|
26249
26328
|
var PUSHD2 = new Set(["pushd", "push-location"]);
|
|
26250
26329
|
var POPD2 = new Set(["popd", "pop-location"]);
|
|
26251
26330
|
var UNKNOWN_DIR = path40.resolve(path40.parse(process.cwd()).root, ".workit-unknown-dir");
|
|
26252
|
-
var cdInto = (dir, words, strict = false, vars = new Map) => {
|
|
26331
|
+
var cdInto = (dir, words, strict = false, vars = new Map, globs = false) => {
|
|
26253
26332
|
const lost = strict ? UNKNOWN_DIR : undefined;
|
|
26254
26333
|
const found = words.slice(1).find((word) => !word.startsWith("-") || word === "-");
|
|
26255
26334
|
const named = found === undefined ? undefined : expandVars(found, vars);
|
|
26256
26335
|
const target = named === undefined ? undefined : homeExpanded(named);
|
|
26257
|
-
if (target === "-" || target && /^~|[$`*?]
|
|
26336
|
+
if (target === "-" || target && (globs ? /^~|[$`]/ : /^~|[$`*?]/).test(target))
|
|
26258
26337
|
return lost;
|
|
26259
26338
|
if (dir === undefined)
|
|
26260
26339
|
return lost;
|
|
@@ -26277,7 +26356,8 @@ var assignmentsOf = (words) => {
|
|
|
26277
26356
|
var commandWords = (words) => {
|
|
26278
26357
|
let start = 0;
|
|
26279
26358
|
while (start < words.length && COMPOUND.has(words[start]))
|
|
26280
|
-
start
|
|
26359
|
+
if (words[start++] === "function")
|
|
26360
|
+
start++;
|
|
26281
26361
|
return words.slice(start);
|
|
26282
26362
|
};
|
|
26283
26363
|
var REBINDS_ANY = new Set([
|
|
@@ -26429,7 +26509,8 @@ var expansions = (text, vars, loops) => {
|
|
|
26429
26509
|
last = match.index + match[0].length;
|
|
26430
26510
|
const value = vars.get(name);
|
|
26431
26511
|
const values = loops.get(name) ?? (value === undefined ? null : [value]);
|
|
26432
|
-
const
|
|
26512
|
+
const fallback = /^:?[-=](.*)$/s.exec(match[2] ?? "")?.[1];
|
|
26513
|
+
const applied = values?.flatMap((item) => fallback === undefined ? [applyOperator(item, match[2] ?? "")] : item === "" ? expansions(fallback, vars, loops) : [item]);
|
|
26433
26514
|
const fits = applied && results.length * applied.length <= MAX_EXPANSIONS2;
|
|
26434
26515
|
results = fits && applied.every((item) => item !== null) ? results.flatMap((prefix) => applied.map((item) => prefix + literal + item)) : results.map((prefix) => prefix + literal + match[0]);
|
|
26435
26516
|
}
|
|
@@ -26475,6 +26556,7 @@ var homeExpanded = (file) => {
|
|
|
26475
26556
|
};
|
|
26476
26557
|
var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherited = new Map) => {
|
|
26477
26558
|
const targets = [];
|
|
26559
|
+
const written = new Map;
|
|
26478
26560
|
let dir = cwd;
|
|
26479
26561
|
let stack = [];
|
|
26480
26562
|
const segments = segmentsOf(command, dialect);
|
|
@@ -26537,6 +26619,8 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26537
26619
|
continue;
|
|
26538
26620
|
}
|
|
26539
26621
|
const body = commandWords(segment.words);
|
|
26622
|
+
const before = segments[segments.indexOf(segment) - 1];
|
|
26623
|
+
const feeder = before?.pipe ? before : undefined;
|
|
26540
26624
|
const keywords = segment.words.length - body.length;
|
|
26541
26625
|
for (const keyword of segment.words.slice(0, keywords))
|
|
26542
26626
|
if (OPENS.has(keyword))
|
|
@@ -26590,7 +26674,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26590
26674
|
}
|
|
26591
26675
|
const plain = !segment.conditional;
|
|
26592
26676
|
if (CD2.has(name)) {
|
|
26593
|
-
dir = cdInto(dir, words, strict, vars);
|
|
26677
|
+
dir = cdInto(dir, words, Boolean(strict), vars, strict === "registry");
|
|
26594
26678
|
moved(plain);
|
|
26595
26679
|
continue;
|
|
26596
26680
|
}
|
|
@@ -26601,7 +26685,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26601
26685
|
}
|
|
26602
26686
|
if (PUSHD2.has(name)) {
|
|
26603
26687
|
stack.push(dir);
|
|
26604
|
-
dir = cdInto(dir, words, strict, vars);
|
|
26688
|
+
dir = cdInto(dir, words, Boolean(strict), vars, strict === "registry");
|
|
26605
26689
|
moved(plain);
|
|
26606
26690
|
continue;
|
|
26607
26691
|
}
|
|
@@ -26610,15 +26694,94 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26610
26694
|
moved(plain);
|
|
26611
26695
|
continue;
|
|
26612
26696
|
}
|
|
26613
|
-
const
|
|
26697
|
+
const literal = depth < 4 ? wrappedScript(words) ?? (strict ? shellScript2(words) : null) : null;
|
|
26698
|
+
const held = literal !== null && strict === "registry" ? expansions(literal, vars, loops) : [];
|
|
26699
|
+
const inner = held.length === 1 ? held[0] : literal;
|
|
26614
26700
|
const unPwd = () => new Map([...vars].filter(([key]) => key !== "PWD"));
|
|
26615
26701
|
if (inner !== null && dir !== undefined)
|
|
26616
26702
|
for (const runIn of workitRunDir(dir, words, atAll))
|
|
26617
26703
|
targets.push(...segmentTargets(runIn, inner, "posix", depth + 1, strict, runIn === dir ? vars : unPwd()));
|
|
26704
|
+
const bare = strict === "registry" && depth < 4 ? unwrapped(words) : null;
|
|
26705
|
+
if (bare?.length && dir !== undefined)
|
|
26706
|
+
targets.push(...segmentTargets(dir, bare.flatMap((word) => expansions(word, vars, loops)).map(quoteWord2).join(" "), "posix", depth + 1, strict, vars));
|
|
26707
|
+
if (strict === "registry" && dir !== undefined && depth < 4) {
|
|
26708
|
+
const run = words.slice(Math.max(0, words.findIndex((word) => !PREFIXES2.has(word))));
|
|
26709
|
+
const [verb = "", ...args] = run.map((word, index) => index ? word : (word.split(/[\\/]/).at(-1) ?? "").toLowerCase());
|
|
26710
|
+
const fed = segment.stdin?.join(`
|
|
26711
|
+
`);
|
|
26712
|
+
if (fed !== undefined)
|
|
26713
|
+
for (const file of segment.redirects)
|
|
26714
|
+
for (const into of atAll(file))
|
|
26715
|
+
written.set(into, fed);
|
|
26716
|
+
const read = (file) => atAll(file).flatMap((script) => {
|
|
26717
|
+
const made = written.get(script);
|
|
26718
|
+
if (made !== undefined)
|
|
26719
|
+
return [made];
|
|
26720
|
+
try {
|
|
26721
|
+
const stat = statSync5(script);
|
|
26722
|
+
const text = stat.isFile() && stat.size <= 262144 ? readFileSync11(script, "utf8") : "\x00";
|
|
26723
|
+
return text.includes("\x00") ? [] : [text];
|
|
26724
|
+
} catch {
|
|
26725
|
+
return [];
|
|
26726
|
+
}
|
|
26727
|
+
});
|
|
26728
|
+
const { named: operand, preloads } = scriptArgs(verb, args);
|
|
26729
|
+
const named = operand === "/dev/stdin" ? undefined : operand;
|
|
26730
|
+
const maker = feeder ? commandWords(feeder.words) : [];
|
|
26731
|
+
const [format = "", ...values] = maker.slice(1);
|
|
26732
|
+
let filled = 0;
|
|
26733
|
+
const printed = format.replace(/%[sbq]/g, () => values[filled++] ?? "");
|
|
26734
|
+
const piped = /^(?:echo|printf)$/.test(maker[0] ?? "") ? [[maker[0] === "printf" ? printed : format, ...values].join(`
|
|
26735
|
+
`).replaceAll("\\n", `
|
|
26736
|
+
`)] : maker[0] === "cat" ? [...feeder?.stdin ?? [], ...operands(maker.slice(1)).flatMap(read)] : [];
|
|
26737
|
+
const inputs = (segment.inputs ?? []).filter((file) => file !== "/dev/null");
|
|
26738
|
+
const shells = verb === "eval" ? [args.join(" ")] : verb === "trap" ? args.slice(0, 1) : verb === "alias" ? args.map((arg) => arg.replace(/^[^=]*=/, "")) : [];
|
|
26739
|
+
const others = [];
|
|
26740
|
+
if (SCRIPT_SHELLS.has(verb) || verb === "." || verb === "source") {
|
|
26741
|
+
if (named === undefined && shellScript2(run) === null)
|
|
26742
|
+
shells.push(...segment.stdin ?? [], ...inputs.flatMap(read), ...piped);
|
|
26743
|
+
else if (named !== undefined && shellScript2(run) === null)
|
|
26744
|
+
shells.push(...read(named));
|
|
26745
|
+
shells.push(...preloads.flatMap(read));
|
|
26746
|
+
} else if (INTERPRETERS.test(verb)) {
|
|
26747
|
+
const code = args.findIndex((arg) => /^-[a-zA-Z]*[ce]$|^--eval$/.test(arg));
|
|
26748
|
+
if (code >= 0)
|
|
26749
|
+
others.push(...expansions(args[code + 1] ?? "", vars, loops));
|
|
26750
|
+
others.push(...named === undefined ? [...segment.stdin ?? [], ...inputs.flatMap(read), ...piped] : read(named), ...preloads.flatMap(read));
|
|
26751
|
+
} else if (/[\\/]/.test(run[0] ?? ""))
|
|
26752
|
+
for (const text of read(run[0]))
|
|
26753
|
+
(/^#!.*\b(?:python|node|bun|deno|ruby|perl|php)/.test(text) ? others : shells).push(text);
|
|
26754
|
+
for (const script of shells)
|
|
26755
|
+
targets.push(...segmentTargets(dir, script, "posix", depth + 1, strict, vars));
|
|
26756
|
+
for (const raw of others) {
|
|
26757
|
+
const text = raw.replace(/^\s*(?:#(?!!)|\/\/|\/?\*).*$/gm, "");
|
|
26758
|
+
const joined = [
|
|
26759
|
+
...text.matchAll(/(?:["'][^"'\s,*?[]+["']\s*[,/+]\s*)+["'][^"'\s,*?[]+["']/g)
|
|
26760
|
+
].map(({ 0: literals, index }) => ({
|
|
26761
|
+
word: literals.replace(/["']\s*[,/+]\s*["']/g, "/").replace(/["']/g, ""),
|
|
26762
|
+
index
|
|
26763
|
+
}));
|
|
26764
|
+
const homes = /homedir\(|expanduser\(|Path\.home\(|['"]HOME['"]|env\.HOME|\$HOME|~/.test(text);
|
|
26765
|
+
const under = (word) => homes ? [path40.join(homeExpanded("~"), word.replace(/^~/, ""))] : [];
|
|
26766
|
+
const found = [
|
|
26767
|
+
...[...text.matchAll(PATHS)].flatMap(({ 0: word, index }) => [...atAll(word), ...under(word)].map((file) => ({ file, index }))),
|
|
26768
|
+
...joined.flatMap(({ word, index }) => under(word).map((file) => ({ file, index })))
|
|
26769
|
+
];
|
|
26770
|
+
for (const { file, index } of found)
|
|
26771
|
+
if (!isRoot(file) || !readsRoot(text, index))
|
|
26772
|
+
targets.push(file);
|
|
26773
|
+
}
|
|
26774
|
+
if (/^(?:n?vim?|ex|ed|emacs)$/.test(verb) && (segment.stdin || inputs.length > 0 || feeder || args.some((arg, index) => /^(?:-[a-zA-Z]*[se]|--(?:batch|eval|script))$/.test(arg) || /^(?:-c|--cmd)$/.test(arg) && !inertEdit(args[index + 1] ?? "") || arg.startsWith("+") && !inertEdit(arg.slice(1) || "1"))))
|
|
26775
|
+
for (const file of operands(args))
|
|
26776
|
+
targets.push(...atAll(file));
|
|
26777
|
+
if (verb === "cp" && args.some((arg) => /^-[a-zA-Z]*l|^--link$/.test(arg)))
|
|
26778
|
+
for (const file of operands(args).slice(0, -1))
|
|
26779
|
+
targets.push(...atAll(file));
|
|
26780
|
+
}
|
|
26618
26781
|
if (strict && dir !== undefined) {
|
|
26619
26782
|
const runIn = dir;
|
|
26620
26783
|
for (const sub of depth < 4 ? segment.subs ?? [] : [])
|
|
26621
|
-
targets.push(...segmentTargets(runIn, sub, dialect, depth + 1,
|
|
26784
|
+
targets.push(...segmentTargets(runIn, sub, dialect, depth + 1, strict, vars));
|
|
26622
26785
|
const expanding = new Set(segment.expands ?? []);
|
|
26623
26786
|
const scriptOf = (index) => {
|
|
26624
26787
|
const word = body[index];
|
|
@@ -26634,12 +26797,15 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26634
26797
|
if (runner !== undefined && expanding.has(keywords + lead + ran) && unresolvedRefs(homeExpanded(runner)).length > 0)
|
|
26635
26798
|
targets.push(unknownVarTarget(runner));
|
|
26636
26799
|
const here = segment.unanalyzable ? DIR_TARGET : `${OPAQUE_TARGET}${encodeURIComponent(runner?.split(/[\\/]/).at(-1) ?? "a command")}`;
|
|
26800
|
+
const quiet = strict === "registry" && INTERPRETERS.test(runner?.split(/[\\/]/).at(-1) ?? "");
|
|
26637
26801
|
for (const file of opaque ?? [])
|
|
26638
26802
|
for (const resolved of atAll(file))
|
|
26639
|
-
|
|
26803
|
+
if (!quiet || !isRoot(resolved))
|
|
26804
|
+
targets.push(file === "." ? path40.join(resolved, here) : resolved);
|
|
26640
26805
|
const ln = words.findIndex((word) => /^ln$/i.test(word.split(/[\\/]/).at(-1) ?? ""));
|
|
26641
|
-
|
|
26642
|
-
|
|
26806
|
+
const lnArgs = words.slice(ln + 1);
|
|
26807
|
+
if (ln >= 0 && words.slice(0, ln).every((word) => PREFIXES2.has(word)) && (strict !== "registry" || !lnArgs.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg))))
|
|
26808
|
+
targets.push(...linkSources(lnArgs, at));
|
|
26643
26809
|
}
|
|
26644
26810
|
for (const file of segment.redirects)
|
|
26645
26811
|
if (!/^\/dev\/(?:null|stdout|stderr|tty)$/.test(file))
|
|
@@ -26674,11 +26840,14 @@ var workitCwd = (dir, args, resolve) => {
|
|
|
26674
26840
|
};
|
|
26675
26841
|
var shellMutationTargets = (cwd, command, dialect = "posix", strict = false) => {
|
|
26676
26842
|
try {
|
|
26843
|
+
const env = new Map(strict === "registry" ? [...command.matchAll(/\$\{?([A-Za-z_]\w*)/g)].filter((match) => !/^(?:OLD)?PWD$/.test(match[1])).map((match) => [match[1], process.env[match[1]] ?? ""]) : []);
|
|
26677
26844
|
return [
|
|
26678
|
-
...segmentTargets(cwd, command, dialect, 0, strict),
|
|
26845
|
+
...segmentTargets(cwd, command, dialect, 0, strict, env),
|
|
26679
26846
|
...gitMutationDirs(cwd, command, dialect).map((dir) => path40.join(dir, DIR_TARGET))
|
|
26680
26847
|
];
|
|
26681
|
-
} catch {
|
|
26848
|
+
} catch (error) {
|
|
26849
|
+
if (strict === "registry")
|
|
26850
|
+
throw error;
|
|
26682
26851
|
return [];
|
|
26683
26852
|
}
|
|
26684
26853
|
};
|
|
@@ -26736,12 +26905,79 @@ var claimAll = (owner, targets, deps) => {
|
|
|
26736
26905
|
};
|
|
26737
26906
|
var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path40.resolve(cwd, file)) : [path40.join(cwd, DIR_TARGET)];
|
|
26738
26907
|
var configDirs = () => [resolveConfigDir(), grantsDir()];
|
|
26908
|
+
var globbed = (cwd, target, state, configs) => {
|
|
26909
|
+
if (!/[*?[]/.test(target))
|
|
26910
|
+
return [];
|
|
26911
|
+
const raw = path40.resolve(cwd, target).split(path40.sep);
|
|
26912
|
+
const literal = raw.findIndex((part) => /[*?[]/.test(part));
|
|
26913
|
+
const pattern = [
|
|
26914
|
+
...canonical3(raw.slice(0, literal).join(path40.sep) || path40.sep).replace(/[\\/]+$/, "").split(path40.sep),
|
|
26915
|
+
...raw.slice(literal)
|
|
26916
|
+
];
|
|
26917
|
+
const segment = (glob, name) => {
|
|
26918
|
+
try {
|
|
26919
|
+
return new RegExp(`^${glob.startsWith(".") ? "" : "(?!\\.)"}${glob.replace(/[.+^$(){}|\\]/g, "\\$&").replace(/\[!/g, "[^").replaceAll("*", ".*").replaceAll("?", ".")}$`, CASE_INSENSITIVE ? "i" : "").test(name);
|
|
26920
|
+
} catch {
|
|
26921
|
+
return false;
|
|
26922
|
+
}
|
|
26923
|
+
};
|
|
26924
|
+
const hit = (file, below) => {
|
|
26925
|
+
const parts = canonical3(file).split(path40.sep);
|
|
26926
|
+
return (below ? pattern.length >= parts.length : pattern.length === parts.length) && parts.every((part, index) => segment(pattern[index], part));
|
|
26927
|
+
};
|
|
26928
|
+
let roots = [];
|
|
26929
|
+
try {
|
|
26930
|
+
roots = readdirSync5(state).filter((name) => /^(?:issued|approvals$)/.test(name));
|
|
26931
|
+
} catch {}
|
|
26932
|
+
return [
|
|
26933
|
+
...roots.map((name) => path40.join(state, name)).filter((root) => hit(root, true)),
|
|
26934
|
+
...configs.flatMap((dir) => [dir, path40.join(dir, "workspaces.json")]).filter((file) => hit(file, false))
|
|
26935
|
+
];
|
|
26936
|
+
};
|
|
26937
|
+
var guardedInodes = (state, configs) => {
|
|
26938
|
+
const seen = new Map;
|
|
26939
|
+
let budget = 2000;
|
|
26940
|
+
const add = (file, registry) => {
|
|
26941
|
+
if (budget-- <= 0)
|
|
26942
|
+
return;
|
|
26943
|
+
const stat = statSync5(file, { throwIfNoEntry: false });
|
|
26944
|
+
if (stat?.isFile())
|
|
26945
|
+
seen.set(`${stat.dev}:${stat.ino}`, registry);
|
|
26946
|
+
else if (stat?.isDirectory())
|
|
26947
|
+
for (const name of readdirSync5(file))
|
|
26948
|
+
add(path40.join(file, name), registry);
|
|
26949
|
+
};
|
|
26950
|
+
try {
|
|
26951
|
+
for (const dir of configs)
|
|
26952
|
+
add(path40.join(dir, "workspaces.json"), "grants");
|
|
26953
|
+
for (const name of readdirSync5(state))
|
|
26954
|
+
if (/^(?:issued|approvals$)/.test(name))
|
|
26955
|
+
add(path40.join(state, name), name === "approvals" ? "approvals" : "issued");
|
|
26956
|
+
} catch {}
|
|
26957
|
+
return seen;
|
|
26958
|
+
};
|
|
26959
|
+
var hardLinked = (file, state, configs, inodes) => {
|
|
26960
|
+
try {
|
|
26961
|
+
const stat = statSync5(file, { throwIfNoEntry: false });
|
|
26962
|
+
if (!stat?.isFile() || stat.nlink < 2 || !stat.ino)
|
|
26963
|
+
return;
|
|
26964
|
+
inodes.map ??= guardedInodes(state, configs);
|
|
26965
|
+
return inodes.map.get(`${stat.dev}:${stat.ino}`);
|
|
26966
|
+
} catch {
|
|
26967
|
+
return;
|
|
26968
|
+
}
|
|
26969
|
+
};
|
|
26739
26970
|
var registryTarget = (cwd, targets) => {
|
|
26740
26971
|
const state = resolveStateDir();
|
|
26741
26972
|
const configs = configDirs();
|
|
26973
|
+
const inodes = {};
|
|
26742
26974
|
for (const target of targets) {
|
|
26743
26975
|
const file = homeExpanded(target);
|
|
26744
|
-
const
|
|
26976
|
+
const glob = globbed(cwd, file, state, configs)[0];
|
|
26977
|
+
const viaGlob = glob === undefined ? null : registryTarget(cwd, [glob]);
|
|
26978
|
+
if (viaGlob)
|
|
26979
|
+
return { file: target, registry: viaGlob.registry };
|
|
26980
|
+
const registry = hardLinked(path40.resolve(cwd, file), state, configs, inodes) ?? underRegistry(state, cwd, file, process.platform, canonical3) ?? (configs.some((dir) => underConfig(dir, cwd, file, process.platform, canonical3)) ? "grants" : null);
|
|
26745
26981
|
if (registry)
|
|
26746
26982
|
return { file: target, registry };
|
|
26747
26983
|
}
|
|
@@ -26763,7 +26999,7 @@ var underRegistry = (state, cwd, target, platform = process.platform, real = (fi
|
|
|
26763
26999
|
};
|
|
26764
27000
|
var underConfig = (dir, cwd, target, platform = process.platform, real = (file) => file) => {
|
|
26765
27001
|
const parts = partsUnder(dir, cwd, target, platform, real);
|
|
26766
|
-
return parts?.length === 1 &&
|
|
27002
|
+
return parts?.length === 1 && ["", "workspaces.json", DIR_TARGET].includes(parts[0]);
|
|
26767
27003
|
};
|
|
26768
27004
|
var unquotedWindowsRegistry = (command, platform = process.platform) => {
|
|
26769
27005
|
if (platform !== "win32" || !command.includes("\\"))
|
|
@@ -26771,8 +27007,21 @@ var unquotedWindowsRegistry = (command, platform = process.platform) => {
|
|
|
26771
27007
|
const flat = (value) => value.replaceAll("\\", "/").toLowerCase();
|
|
26772
27008
|
const text = flat(command);
|
|
26773
27009
|
const state = flat(resolveStateDir());
|
|
26774
|
-
const
|
|
26775
|
-
|
|
27010
|
+
const configs = configDirs().map(flat);
|
|
27011
|
+
const registry = text.includes(`${state}/issued`) ? "issued" : text.includes(`${state}/approvals`) ? "approvals" : configs.some((dir) => text.includes(dir)) ? "grants" : null;
|
|
27012
|
+
if (!registry)
|
|
27013
|
+
return null;
|
|
27014
|
+
const spans = command.replace(/[^\s'"|;&<>()]*\\[^\s'"|;&<>()]*/g, (word) => word.replaceAll("\\", "/"));
|
|
27015
|
+
const writes = shellWrites(spans);
|
|
27016
|
+
const moved = [
|
|
27017
|
+
"",
|
|
27018
|
+
...[...spans.matchAll(/(?:^|[;&|(]\s*)(?:cd|pushd|chdir)\s+([^\s;&|)]+)/g)].map((match) => `${match[1]}/`)
|
|
27019
|
+
];
|
|
27020
|
+
const named = (target) => moved.some((dir) => {
|
|
27021
|
+
const at = flat(/^(?:[a-z]:)?\//i.test(target) ? target : dir + target).replace(/\/\.?\//g, "/");
|
|
27022
|
+
return registry === "grants" ? configs.some((cfg) => [cfg, `${cfg}/`, `${cfg}/workspaces.json`].includes(at)) : at.includes(`${state}/${registry}`);
|
|
27023
|
+
});
|
|
27024
|
+
return writes.writes && (writes.targets === null || writes.targets.some(named)) ? registry : null;
|
|
26776
27025
|
};
|
|
26777
27026
|
var REGISTRY_DENY = {
|
|
26778
27027
|
issued: {
|
|
@@ -26793,9 +27042,10 @@ var REGISTRY_DENY = {
|
|
|
26793
27042
|
};
|
|
26794
27043
|
var registryDeny = ({ file, registry }) => {
|
|
26795
27044
|
const { label, what, unblock } = REGISTRY_DENY[registry];
|
|
27045
|
+
const named = path40.basename(file).startsWith(".workit-") ? path40.dirname(file) : file;
|
|
26796
27046
|
return {
|
|
26797
27047
|
kind: "deny",
|
|
26798
|
-
reason: `workit ${label}: ${
|
|
27048
|
+
reason: `workit ${label}: ${named} is under ${what}. ${unblock}`,
|
|
26799
27049
|
unblock
|
|
26800
27050
|
};
|
|
26801
27051
|
};
|
|
@@ -26817,10 +27067,20 @@ function writeGate(cwd, paths, owner, deps) {
|
|
|
26817
27067
|
function shellGate(cwd, command, owner, dialect = "posix", deps) {
|
|
26818
27068
|
try {
|
|
26819
27069
|
const windows = unquotedWindowsRegistry(command);
|
|
26820
|
-
const forged = registryTarget(cwd,
|
|
27070
|
+
const forged = registryTarget(cwd, shellMutationTargets(cwd, command, dialect, "registry")) ?? (windows ? { file: `the ${windows} registry`, registry: windows } : null);
|
|
26821
27071
|
if (forged)
|
|
26822
27072
|
return registryDeny(forged);
|
|
26823
|
-
} catch {
|
|
27073
|
+
} catch {
|
|
27074
|
+
const text = command.replaceAll("\\", "/").replace(/['"]/g, "").toLowerCase();
|
|
27075
|
+
if (/issued|approvals|workspaces\.json|\.config\/workit|state\/workit/.test(text) || [resolveStateDir(), ...configDirs()].some((dir) => text.includes(dir.replaceAll("\\", "/").toLowerCase()))) {
|
|
27076
|
+
const { unblock } = REGISTRY_DENY.grants;
|
|
27077
|
+
return {
|
|
27078
|
+
kind: "deny",
|
|
27079
|
+
reason: `workit registry guard: Workit could not analyse this command, which names a guarded path; split it into plain commands. ${unblock}`,
|
|
27080
|
+
unblock
|
|
27081
|
+
};
|
|
27082
|
+
}
|
|
27083
|
+
}
|
|
26824
27084
|
const writes = shellWrites(command);
|
|
26825
27085
|
let targets = [];
|
|
26826
27086
|
if (owner)
|
|
@@ -28243,7 +28503,7 @@ if (false) {}
|
|
|
28243
28503
|
import path47 from "node:path";
|
|
28244
28504
|
|
|
28245
28505
|
// packages/workit-core/src/core/gitignore.ts
|
|
28246
|
-
import { existsSync as existsSync14, readFileSync as
|
|
28506
|
+
import { existsSync as existsSync14, readFileSync as readFileSync12, writeFileSync as writeFileSync5 } from "node:fs";
|
|
28247
28507
|
import path43 from "node:path";
|
|
28248
28508
|
var GITIGNORE_ENTRIES = [
|
|
28249
28509
|
"# workit: SDD working state (never commit)",
|
|
@@ -28265,7 +28525,7 @@ var ensureProjectGitignore = (workspaceRoot, confirmed) => {
|
|
|
28265
28525
|
if (!confirmed)
|
|
28266
28526
|
return { ok: false, error: "confirmed: true required" };
|
|
28267
28527
|
const file = path43.join(workspaceRoot, ".gitignore");
|
|
28268
|
-
const existing = existsSync14(file) ?
|
|
28528
|
+
const existing = existsSync14(file) ? readFileSync12(file, "utf8") : "";
|
|
28269
28529
|
const existingLines = new Set(existing.split(`
|
|
28270
28530
|
`).map((l) => l.trim()).filter(Boolean));
|
|
28271
28531
|
const added = [];
|
|
@@ -28291,7 +28551,7 @@ var ensureProjectGitignore = (workspaceRoot, confirmed) => {
|
|
|
28291
28551
|
};
|
|
28292
28552
|
|
|
28293
28553
|
// packages/workit-core/src/core/hygiene.ts
|
|
28294
|
-
import { existsSync as existsSync15, readFileSync as
|
|
28554
|
+
import { existsSync as existsSync15, readFileSync as readFileSync13, readdirSync as readdirSync6, writeFileSync as writeFileSync6 } from "node:fs";
|
|
28295
28555
|
import path44 from "node:path";
|
|
28296
28556
|
var repoRoot3 = assetRoot();
|
|
28297
28557
|
var templatesDir = () => path44.join(repoRoot3, "templates", "hygiene");
|
|
@@ -28299,7 +28559,7 @@ var packageJson = (root) => {
|
|
|
28299
28559
|
if (!existsSync15(path44.join(root, "package.json")))
|
|
28300
28560
|
return null;
|
|
28301
28561
|
try {
|
|
28302
|
-
return JSON.parse(
|
|
28562
|
+
return JSON.parse(readFileSync13(path44.join(root, "package.json"), "utf8"));
|
|
28303
28563
|
} catch {
|
|
28304
28564
|
return null;
|
|
28305
28565
|
}
|
|
@@ -28338,7 +28598,7 @@ var planHygieneFiles = (root, opts = {}) => {
|
|
|
28338
28598
|
const tpl = path44.join(templatesDir(), file);
|
|
28339
28599
|
if (!existsSync15(tpl))
|
|
28340
28600
|
continue;
|
|
28341
|
-
const content =
|
|
28601
|
+
const content = readFileSync13(tpl, "utf8").replace(/<PROJECT>/g, path44.basename(root)).replace(/<YEAR>/g, String(new Date().getFullYear())).replace(/<HOLDER>\s*/g, licenseHolder(root));
|
|
28342
28602
|
planned.push({ path: path44.join(root, file), content });
|
|
28343
28603
|
}
|
|
28344
28604
|
return planned;
|
|
@@ -28360,12 +28620,12 @@ import path46 from "node:path";
|
|
|
28360
28620
|
import { spawnSync as spawnSync25 } from "node:child_process";
|
|
28361
28621
|
|
|
28362
28622
|
// packages/workit-core/src/core/workspace-branch-policy.ts
|
|
28363
|
-
import { mkdirSync as mkdirSync5, readFileSync as
|
|
28623
|
+
import { mkdirSync as mkdirSync5, readFileSync as readFileSync14, renameSync as renameSync4, rmSync as rmSync3, writeFileSync as writeFileSync7 } from "node:fs";
|
|
28364
28624
|
import path45 from "node:path";
|
|
28365
28625
|
import { isDeepStrictEqual } from "node:util";
|
|
28366
28626
|
var readFileSafe = (p) => {
|
|
28367
28627
|
try {
|
|
28368
|
-
return
|
|
28628
|
+
return readFileSync14(p, "utf8");
|
|
28369
28629
|
} catch {
|
|
28370
28630
|
return null;
|
|
28371
28631
|
}
|
|
@@ -29081,7 +29341,7 @@ import path51 from "node:path";
|
|
|
29081
29341
|
|
|
29082
29342
|
// packages/workit-core/src/git/ops.ts
|
|
29083
29343
|
import { spawnSync as spawnSync27 } from "node:child_process";
|
|
29084
|
-
import { copyFileSync as copyFileSync2, existsSync as existsSync16, readdirSync as
|
|
29344
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync16, readdirSync as readdirSync7, readFileSync as readFileSync15, rmSync as rmSync4 } from "node:fs";
|
|
29085
29345
|
import path50 from "node:path";
|
|
29086
29346
|
var COMMIT_TIMEOUT_MS = 10 * 60000;
|
|
29087
29347
|
var git5 = (cwd, args, options = {}) => {
|
|
@@ -29126,7 +29386,7 @@ function operationInProgress(cwd) {
|
|
|
29126
29386
|
if (index === 0 && existsSync16(path50.join(marker, "amend")) && !conflicted()) {
|
|
29127
29387
|
let headName = "";
|
|
29128
29388
|
try {
|
|
29129
|
-
headName =
|
|
29389
|
+
headName = readFileSync15(path50.join(marker, "head-name"), "utf8").trim();
|
|
29130
29390
|
} catch {}
|
|
29131
29391
|
const branch = headName.startsWith("refs/heads/") ? headName.slice("refs/heads/".length) : null;
|
|
29132
29392
|
return { operation, commitAllowed: branch !== null, branch };
|
|
@@ -30752,7 +31012,7 @@ var createStopControl = (root, port) => {
|
|
|
30752
31012
|
};
|
|
30753
31013
|
|
|
30754
31014
|
// packages/workit-opencode/src/v2/registry.ts
|
|
30755
|
-
import { existsSync as existsSync18, readFileSync as
|
|
31015
|
+
import { existsSync as existsSync18, readFileSync as readFileSync16 } from "node:fs";
|
|
30756
31016
|
import path55 from "node:path";
|
|
30757
31017
|
|
|
30758
31018
|
// packages/workit-opencode/src/shared/assets.ts
|
|
@@ -30823,7 +31083,7 @@ var registerSkills = async (ctx) => {
|
|
|
30823
31083
|
for (const [id, file] of packaged) {
|
|
30824
31084
|
if (existing.has(id))
|
|
30825
31085
|
continue;
|
|
30826
|
-
const parsed = parseFrontmatter(
|
|
31086
|
+
const parsed = parseFrontmatter(readFileSync16(file, "utf8"));
|
|
30827
31087
|
editor.add({
|
|
30828
31088
|
id,
|
|
30829
31089
|
name: parsed.name || id,
|
|
@@ -30861,13 +31121,13 @@ var registerCommands = async (ctx, registeredSkills) => {
|
|
|
30861
31121
|
};
|
|
30862
31122
|
|
|
30863
31123
|
// packages/workit-opencode/src/stale-sources.ts
|
|
30864
|
-
import { existsSync as existsSync19, readdirSync as
|
|
31124
|
+
import { existsSync as existsSync19, readdirSync as readdirSync8 } from "node:fs";
|
|
30865
31125
|
import path56 from "node:path";
|
|
30866
31126
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
30867
31127
|
var typescriptFiles = (directory) => {
|
|
30868
31128
|
if (!existsSync19(directory))
|
|
30869
31129
|
return [];
|
|
30870
|
-
return
|
|
31130
|
+
return readdirSync8(directory, { withFileTypes: true }).flatMap((entry) => {
|
|
30871
31131
|
const file = path56.join(directory, entry.name);
|
|
30872
31132
|
return entry.isDirectory() ? typescriptFiles(file) : entry.isFile() && file.endsWith(".ts") ? [file] : [];
|
|
30873
31133
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workit-dev/opencode",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.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": "^1.8.
|
|
44
|
+
"@workit-dev/core": "^1.8.2"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=24"
|