@workit-dev/opencode 1.7.3 → 1.7.5
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 +92 -17
- package/package.json +2 -2
package/dist/plugin.js
CHANGED
|
@@ -26670,53 +26670,67 @@ var claimAll = (owner, targets, deps) => {
|
|
|
26670
26670
|
claimLiveSession(target, owner, deps);
|
|
26671
26671
|
};
|
|
26672
26672
|
var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path40.resolve(cwd, file)) : [path40.join(cwd, DIR_TARGET)];
|
|
26673
|
+
var configDirs = () => [resolveConfigDir(), grantsDir()];
|
|
26673
26674
|
var registryTarget = (cwd, targets) => {
|
|
26674
26675
|
const state = resolveStateDir();
|
|
26676
|
+
const configs = configDirs();
|
|
26675
26677
|
for (const target of targets) {
|
|
26676
|
-
const
|
|
26678
|
+
const file = homeExpanded(target);
|
|
26679
|
+
const registry = underRegistry(state, cwd, file, process.platform, canonical3) ?? (configs.some((dir) => underConfig(dir, cwd, file, process.platform, canonical3)) ? "grants" : null);
|
|
26677
26680
|
if (registry)
|
|
26678
26681
|
return { file: target, registry };
|
|
26679
26682
|
}
|
|
26680
26683
|
return null;
|
|
26681
26684
|
};
|
|
26682
|
-
var
|
|
26685
|
+
var partsUnder = (dir, cwd, target, platform, real) => {
|
|
26683
26686
|
const win = platform === "win32";
|
|
26684
26687
|
const p = win ? path40.win32 : path40.posix;
|
|
26685
26688
|
const fold = (value) => win || platform === "darwin" ? value.toLowerCase() : value;
|
|
26686
26689
|
const named = win ? target.replace(/^\/([a-zA-Z])(?=\/|$)/, "$1:") : target;
|
|
26687
|
-
const relative = p.relative(fold(real(p.resolve(
|
|
26688
|
-
|
|
26689
|
-
|
|
26690
|
-
|
|
26691
|
-
|
|
26690
|
+
const relative = p.relative(fold(real(p.resolve(dir))), fold(real(p.resolve(cwd, named))));
|
|
26691
|
+
return relative.startsWith("..") || p.isAbsolute(relative) ? null : relative.split(p.sep);
|
|
26692
|
+
};
|
|
26693
|
+
var underRegistry = (state, cwd, target, platform = process.platform, real = (file) => file) => {
|
|
26694
|
+
const first = partsUnder(state, cwd, target, platform, real)?.[0];
|
|
26695
|
+
if (first?.startsWith("issued"))
|
|
26692
26696
|
return "issued";
|
|
26693
26697
|
return first === "approvals" ? "approvals" : null;
|
|
26694
26698
|
};
|
|
26695
|
-
var
|
|
26696
|
-
|
|
26699
|
+
var underConfig = (dir, cwd, target, platform = process.platform, real = (file) => file) => {
|
|
26700
|
+
const parts = partsUnder(dir, cwd, target, platform, real);
|
|
26701
|
+
return parts?.length === 1 && (parts[0] === "" || parts[0] === "workspaces.json");
|
|
26702
|
+
};
|
|
26703
|
+
var unquotedWindowsRegistry = (command, platform = process.platform) => {
|
|
26704
|
+
if (platform !== "win32" || !command.includes("\\"))
|
|
26697
26705
|
return null;
|
|
26698
26706
|
const flat = (value) => value.replaceAll("\\", "/").toLowerCase();
|
|
26699
26707
|
const text = flat(command);
|
|
26700
26708
|
const state = flat(resolveStateDir());
|
|
26701
|
-
const registry = text.includes(`${state}/issued`) ? "issued" : text.includes(`${state}/approvals`) ? "approvals" : null;
|
|
26709
|
+
const registry = text.includes(`${state}/issued`) ? "issued" : text.includes(`${state}/approvals`) ? "approvals" : configDirs().some((dir) => text.includes(`${flat(dir)}/workspaces.json`)) ? "grants" : null;
|
|
26702
26710
|
return registry && shellWrites(command).writes ? registry : null;
|
|
26703
26711
|
};
|
|
26704
26712
|
var REGISTRY_DENY = {
|
|
26705
26713
|
issued: {
|
|
26706
26714
|
label: "issued-registry guard",
|
|
26715
|
+
what: "Workit's issued-session state",
|
|
26707
26716
|
unblock: "Issued ids and tokens are written only by Workit's SubagentStart hook. Run the verifier or reviewer agent so the host issues its own session; never edit the issued registries by hand."
|
|
26708
26717
|
},
|
|
26709
26718
|
approvals: {
|
|
26710
26719
|
label: "approvals guard",
|
|
26720
|
+
what: "Workit's host-approval state",
|
|
26711
26721
|
unblock: "Approval requests and the user's yes are written only by Workit: run `workit approve <id>` as its own call so the host asks the user, or ask the user to run it in their own terminal; never edit the approvals registry by hand."
|
|
26722
|
+
},
|
|
26723
|
+
grants: {
|
|
26724
|
+
label: "config guard",
|
|
26725
|
+
what: "the user's Workit config (grants, roles, youtrack.writes)",
|
|
26726
|
+
unblock: "Only the user changes it: ask them to run `workit grant set <ws> <kind>=<value>` or `workit workspace set <ws> <key>=<value>` in a terminal outside this host. `workit grant show` and `workit workspace list` read it."
|
|
26712
26727
|
}
|
|
26713
26728
|
};
|
|
26714
26729
|
var registryDeny = ({ file, registry }) => {
|
|
26715
|
-
const { label, unblock } = REGISTRY_DENY[registry];
|
|
26716
|
-
const what = registry === "issued" ? "issued-session state" : "host-approval state";
|
|
26730
|
+
const { label, what, unblock } = REGISTRY_DENY[registry];
|
|
26717
26731
|
return {
|
|
26718
26732
|
kind: "deny",
|
|
26719
|
-
reason: `workit ${label}: ${file} is under
|
|
26733
|
+
reason: `workit ${label}: ${file} is under ${what}. ${unblock}`,
|
|
26720
26734
|
unblock
|
|
26721
26735
|
};
|
|
26722
26736
|
};
|
|
@@ -27941,8 +27955,68 @@ var standingSinceStart = (input) => {
|
|
|
27941
27955
|
var DIR = String.raw`[A-Za-z0-9_./@%+:,=-]+|'[^'$${"`"}\\\n]*'|"[^"$${"`"}\\!\n]*"`;
|
|
27942
27956
|
var COMPOUND2 = new RegExp(String.raw`^\s*cd\s+(${DIR})\s*&&\s*(workit(?:\s[\s\S]*)?)$`, "u");
|
|
27943
27957
|
var GLOBALS_FIRST = new RegExp(String.raw`^(\s*workit)((?:\s+(?:--json|--cwd(?:=|\s+)(?:${DIR})))+)\s+([a-z][a-z-]*)(?=\s|$)`, "u");
|
|
27958
|
+
var VERB_FIRST = /^((?:--json\s+)*)([a-z][a-z-]*)(?=\s|$)/u;
|
|
27944
27959
|
var VERBS = new Set(WORKIT_ALLOWED_VERBS);
|
|
27945
27960
|
var FILTERS = new Set(["tail", "head", "grep"]);
|
|
27961
|
+
var clean = (s) => !s.unanalyzable && !s.group && !s.subs?.length && !s.stdin?.length && !s.redirects.length;
|
|
27962
|
+
var stdinOnly = (words) => {
|
|
27963
|
+
const [name, ...args] = words;
|
|
27964
|
+
const operands = args.filter((w) => !w.startsWith("-"));
|
|
27965
|
+
if (name === "grep")
|
|
27966
|
+
return operands.length <= 1 && !args.some((w) => /^-[^-]*[rRf]|^--(recursive|file)/u.test(w));
|
|
27967
|
+
return operands.every((w) => /^\d+$/u.test(w)) && !args.some((w) => w.startsWith("--output"));
|
|
27968
|
+
};
|
|
27969
|
+
var cwdRewrite = (command) => {
|
|
27970
|
+
const match = COMPOUND2.exec(command);
|
|
27971
|
+
const dir = match?.[1];
|
|
27972
|
+
const rest = match?.[2];
|
|
27973
|
+
if (!dir || !rest || dir.startsWith("-"))
|
|
27974
|
+
return null;
|
|
27975
|
+
if (/[&;<>`\n]/u.test(rest.replaceAll("2>&1", "").replaceAll(/'[^']*'|"([^"\\]|\\.)*"/gu, "")))
|
|
27976
|
+
return null;
|
|
27977
|
+
const segments = segmentsOf(rest);
|
|
27978
|
+
const [head, ...filters] = segments;
|
|
27979
|
+
if (!head || head.words[0] !== "workit")
|
|
27980
|
+
return null;
|
|
27981
|
+
if (!segments.every(clean))
|
|
27982
|
+
return null;
|
|
27983
|
+
if (!segments.slice(0, -1).every((s) => s.pipe))
|
|
27984
|
+
return null;
|
|
27985
|
+
if (!filters.every((s) => FILTERS.has(s.words[0] ?? "") && stdinOnly(s.words)))
|
|
27986
|
+
return null;
|
|
27987
|
+
const at = head.words.indexOf("--cwd");
|
|
27988
|
+
if (at >= 0) {
|
|
27989
|
+
const bare = dir.replace(/^(['"])(.*)\1$/u, "$2");
|
|
27990
|
+
return bare[0] === "/" && head.words[at + 1] === bare ? rest : null;
|
|
27991
|
+
}
|
|
27992
|
+
if (head.words.some((w) => w.startsWith("--cwd=")))
|
|
27993
|
+
return null;
|
|
27994
|
+
const args = rest.slice("workit".length).trimStart();
|
|
27995
|
+
const verb = VERB_FIRST.exec(args);
|
|
27996
|
+
if (!verb?.[2] || !VERBS.has(verb[2]))
|
|
27997
|
+
return `workit --cwd ${dir} ${args}`.trimEnd();
|
|
27998
|
+
const json = verb[1] ? " --json" : "";
|
|
27999
|
+
return `workit ${verb[2]} --cwd ${dir}${json}${args.slice(verb[0].length)}`.trimEnd();
|
|
28000
|
+
};
|
|
28001
|
+
var verbFirst = (command) => {
|
|
28002
|
+
const match = GLOBALS_FIRST.exec(command);
|
|
28003
|
+
const [whole, lead, globals, verb] = match ?? [];
|
|
28004
|
+
if (!whole || !verb || !VERBS.has(verb) || !globals?.includes("--cwd"))
|
|
28005
|
+
return null;
|
|
28006
|
+
const segments = segmentsOf(command);
|
|
28007
|
+
if (segments.length !== 1 || !segments.every(clean))
|
|
28008
|
+
return null;
|
|
28009
|
+
return `${lead} ${verb}${globals}${command.slice(whole.length)}`;
|
|
28010
|
+
};
|
|
28011
|
+
var NPX = new RegExp(String.raw`^(\s*(?:cd\s+(?:${DIR})\s*&&\s*)?)npx(?:\s+(?:-y|--yes))*\s+@workit-dev\/cli(?:@[\w.-]+)?(?=\s|$)`, "u");
|
|
28012
|
+
var npxWorkit = (command) => {
|
|
28013
|
+
const match = NPX.exec(command);
|
|
28014
|
+
if (!match)
|
|
28015
|
+
return null;
|
|
28016
|
+
const call = `${match[1]}workit${command.slice(match[0].length)}`;
|
|
28017
|
+
const left = segmentsOf(call).some((s) => s.unanalyzable || s.words.some((w) => /^(npx|@workit-dev\/cli(@\S*)?)$/u.test(w)));
|
|
28018
|
+
return left ? null : cwdRewrite(call) ?? verbFirst(call) ?? call;
|
|
28019
|
+
};
|
|
27946
28020
|
|
|
27947
28021
|
// packages/workit-core/src/hooks/model-limit.ts
|
|
27948
28022
|
var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
|
|
@@ -30368,10 +30442,11 @@ var observeShellBefore = (root, event, workdirs) => {
|
|
|
30368
30442
|
return;
|
|
30369
30443
|
const sessionID = String(event.sessionID);
|
|
30370
30444
|
const original = hookInput(root, sessionID, String(event.id), shell);
|
|
30371
|
-
const
|
|
30372
|
-
|
|
30373
|
-
|
|
30374
|
-
|
|
30445
|
+
const npx = npxWorkit(shell.command);
|
|
30446
|
+
const rewrite = leaseRewrite2(original) ?? (npx && workitOnPath2() ? npx : null);
|
|
30447
|
+
if (rewrite) {
|
|
30448
|
+
event.input.command = rewrite;
|
|
30449
|
+
shell.command = rewrite;
|
|
30375
30450
|
}
|
|
30376
30451
|
const input = hookInput(root, sessionID, String(event.id), shell);
|
|
30377
30452
|
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.5",
|
|
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.5"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=24"
|