@workit-dev/opencode 1.7.3 → 1.7.4
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 +65 -4
- package/package.json +2 -2
package/dist/plugin.js
CHANGED
|
@@ -27941,8 +27941,68 @@ var standingSinceStart = (input) => {
|
|
|
27941
27941
|
var DIR = String.raw`[A-Za-z0-9_./@%+:,=-]+|'[^'$${"`"}\\\n]*'|"[^"$${"`"}\\!\n]*"`;
|
|
27942
27942
|
var COMPOUND2 = new RegExp(String.raw`^\s*cd\s+(${DIR})\s*&&\s*(workit(?:\s[\s\S]*)?)$`, "u");
|
|
27943
27943
|
var GLOBALS_FIRST = new RegExp(String.raw`^(\s*workit)((?:\s+(?:--json|--cwd(?:=|\s+)(?:${DIR})))+)\s+([a-z][a-z-]*)(?=\s|$)`, "u");
|
|
27944
|
+
var VERB_FIRST = /^((?:--json\s+)*)([a-z][a-z-]*)(?=\s|$)/u;
|
|
27944
27945
|
var VERBS = new Set(WORKIT_ALLOWED_VERBS);
|
|
27945
27946
|
var FILTERS = new Set(["tail", "head", "grep"]);
|
|
27947
|
+
var clean = (s) => !s.unanalyzable && !s.group && !s.subs?.length && !s.stdin?.length && !s.redirects.length;
|
|
27948
|
+
var stdinOnly = (words) => {
|
|
27949
|
+
const [name, ...args] = words;
|
|
27950
|
+
const operands = args.filter((w) => !w.startsWith("-"));
|
|
27951
|
+
if (name === "grep")
|
|
27952
|
+
return operands.length <= 1 && !args.some((w) => /^-[^-]*[rRf]|^--(recursive|file)/u.test(w));
|
|
27953
|
+
return operands.every((w) => /^\d+$/u.test(w)) && !args.some((w) => w.startsWith("--output"));
|
|
27954
|
+
};
|
|
27955
|
+
var cwdRewrite = (command) => {
|
|
27956
|
+
const match = COMPOUND2.exec(command);
|
|
27957
|
+
const dir = match?.[1];
|
|
27958
|
+
const rest = match?.[2];
|
|
27959
|
+
if (!dir || !rest || dir.startsWith("-"))
|
|
27960
|
+
return null;
|
|
27961
|
+
if (/[&;<>`\n]/u.test(rest.replaceAll("2>&1", "").replaceAll(/'[^']*'|"([^"\\]|\\.)*"/gu, "")))
|
|
27962
|
+
return null;
|
|
27963
|
+
const segments = segmentsOf(rest);
|
|
27964
|
+
const [head, ...filters] = segments;
|
|
27965
|
+
if (!head || head.words[0] !== "workit")
|
|
27966
|
+
return null;
|
|
27967
|
+
if (!segments.every(clean))
|
|
27968
|
+
return null;
|
|
27969
|
+
if (!segments.slice(0, -1).every((s) => s.pipe))
|
|
27970
|
+
return null;
|
|
27971
|
+
if (!filters.every((s) => FILTERS.has(s.words[0] ?? "") && stdinOnly(s.words)))
|
|
27972
|
+
return null;
|
|
27973
|
+
const at = head.words.indexOf("--cwd");
|
|
27974
|
+
if (at >= 0) {
|
|
27975
|
+
const bare = dir.replace(/^(['"])(.*)\1$/u, "$2");
|
|
27976
|
+
return bare[0] === "/" && head.words[at + 1] === bare ? rest : null;
|
|
27977
|
+
}
|
|
27978
|
+
if (head.words.some((w) => w.startsWith("--cwd=")))
|
|
27979
|
+
return null;
|
|
27980
|
+
const args = rest.slice("workit".length).trimStart();
|
|
27981
|
+
const verb = VERB_FIRST.exec(args);
|
|
27982
|
+
if (!verb?.[2] || !VERBS.has(verb[2]))
|
|
27983
|
+
return `workit --cwd ${dir} ${args}`.trimEnd();
|
|
27984
|
+
const json = verb[1] ? " --json" : "";
|
|
27985
|
+
return `workit ${verb[2]} --cwd ${dir}${json}${args.slice(verb[0].length)}`.trimEnd();
|
|
27986
|
+
};
|
|
27987
|
+
var verbFirst = (command) => {
|
|
27988
|
+
const match = GLOBALS_FIRST.exec(command);
|
|
27989
|
+
const [whole, lead, globals, verb] = match ?? [];
|
|
27990
|
+
if (!whole || !verb || !VERBS.has(verb) || !globals?.includes("--cwd"))
|
|
27991
|
+
return null;
|
|
27992
|
+
const segments = segmentsOf(command);
|
|
27993
|
+
if (segments.length !== 1 || !segments.every(clean))
|
|
27994
|
+
return null;
|
|
27995
|
+
return `${lead} ${verb}${globals}${command.slice(whole.length)}`;
|
|
27996
|
+
};
|
|
27997
|
+
var NPX = new RegExp(String.raw`^(\s*(?:cd\s+(?:${DIR})\s*&&\s*)?)npx(?:\s+(?:-y|--yes))*\s+@workit-dev\/cli(?:@[\w.-]+)?(?=\s|$)`, "u");
|
|
27998
|
+
var npxWorkit = (command) => {
|
|
27999
|
+
const match = NPX.exec(command);
|
|
28000
|
+
if (!match)
|
|
28001
|
+
return null;
|
|
28002
|
+
const call = `${match[1]}workit${command.slice(match[0].length)}`;
|
|
28003
|
+
const left = segmentsOf(call).some((s) => s.unanalyzable || s.words.some((w) => /^(npx|@workit-dev\/cli(@\S*)?)$/u.test(w)));
|
|
28004
|
+
return left ? null : cwdRewrite(call) ?? verbFirst(call) ?? call;
|
|
28005
|
+
};
|
|
27946
28006
|
|
|
27947
28007
|
// packages/workit-core/src/hooks/model-limit.ts
|
|
27948
28008
|
var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
|
|
@@ -30368,10 +30428,11 @@ var observeShellBefore = (root, event, workdirs) => {
|
|
|
30368
30428
|
return;
|
|
30369
30429
|
const sessionID = String(event.sessionID);
|
|
30370
30430
|
const original = hookInput(root, sessionID, String(event.id), shell);
|
|
30371
|
-
const
|
|
30372
|
-
|
|
30373
|
-
|
|
30374
|
-
|
|
30431
|
+
const npx = npxWorkit(shell.command);
|
|
30432
|
+
const rewrite = leaseRewrite2(original) ?? (npx && workitOnPath2() ? npx : null);
|
|
30433
|
+
if (rewrite) {
|
|
30434
|
+
event.input.command = rewrite;
|
|
30435
|
+
shell.command = rewrite;
|
|
30375
30436
|
}
|
|
30376
30437
|
const input = hookInput(root, sessionID, String(event.id), shell);
|
|
30377
30438
|
workdirs.set(sessionID, input.cwd);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workit-dev/opencode",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.4",
|
|
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.7.
|
|
44
|
+
"@workit-dev/core": "^1.7.4"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=24"
|