@workit-dev/opencode 1.5.1 → 1.6.1
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 +169 -21
- package/package.json +2 -2
package/dist/plugin.js
CHANGED
|
@@ -20715,7 +20715,10 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
|
|
|
20715
20715
|
continue;
|
|
20716
20716
|
const action = rawAction(invocation);
|
|
20717
20717
|
const at = !action ? null : repoFor(invocation.dir) ?? (all && invocation.tool !== "git" && explicitRepo(invocation.tool === "gh", "repo" in action && action.repo || "", invocation.env ?? {}) ? {
|
|
20718
|
-
repo: {
|
|
20718
|
+
repo: {
|
|
20719
|
+
dir: path27.resolve(cwd, invocation.dir ?? "."),
|
|
20720
|
+
branch: null
|
|
20721
|
+
},
|
|
20719
20722
|
workit: false
|
|
20720
20723
|
} : null);
|
|
20721
20724
|
if (action && at)
|
|
@@ -20762,6 +20765,109 @@ var pkillSelfMatch = (command, dialect) => {
|
|
|
20762
20765
|
}
|
|
20763
20766
|
return null;
|
|
20764
20767
|
};
|
|
20768
|
+
var policyDeclared = () => {
|
|
20769
|
+
try {
|
|
20770
|
+
return !!readConfigTyped().config?.branchPolicy?.protected?.length;
|
|
20771
|
+
} catch {
|
|
20772
|
+
return false;
|
|
20773
|
+
}
|
|
20774
|
+
};
|
|
20775
|
+
var word = (text) => /^[\w./@%+:,=-]+$/u.test(text) ? text : shellQuote(text);
|
|
20776
|
+
var HEREDOC = /^cat <<(['"])(\w+)\1\n([\s\S]*)\n\2\n?$/u;
|
|
20777
|
+
var messageOf = (segment, index) => {
|
|
20778
|
+
const text = segment.words[index];
|
|
20779
|
+
if (text === undefined)
|
|
20780
|
+
return null;
|
|
20781
|
+
if (!segment.expands?.includes(index))
|
|
20782
|
+
return text;
|
|
20783
|
+
const sub = segment.subs?.find((each) => text === `$(${each})`);
|
|
20784
|
+
const match = sub === undefined ? null : HEREDOC.exec(sub);
|
|
20785
|
+
if (!match || match[3].split(`
|
|
20786
|
+
`).includes(match[2]))
|
|
20787
|
+
return null;
|
|
20788
|
+
return match[3].replace(/\n+$/u, "");
|
|
20789
|
+
};
|
|
20790
|
+
var cdCommitCall = (input, command, target, repo) => {
|
|
20791
|
+
const { top, git, dir: store } = repo.location;
|
|
20792
|
+
if (!top || !git || git.gitDir === path27.dirname(store) || repoAt(input.cwd)?.location.top === top)
|
|
20793
|
+
return null;
|
|
20794
|
+
const bare = command.replaceAll(/'[^']*'|"(?:[^"\\]|\\.)*"/gu, "").replaceAll("&&", "");
|
|
20795
|
+
if (/[;|&<>`$()\n\\]/u.test(bare))
|
|
20796
|
+
return null;
|
|
20797
|
+
const [cd, ...rest] = segmentsOf(command);
|
|
20798
|
+
const commit = rest.at(-1);
|
|
20799
|
+
if (cd?.words[0] !== "cd" || cd.words.length !== 2 || cd.expands?.length || !commit)
|
|
20800
|
+
return null;
|
|
20801
|
+
if (path27.resolve(input.cwd, cd.words[1]) !== target)
|
|
20802
|
+
return null;
|
|
20803
|
+
if (rest.some((each) => each.redirects.length || each.stdin?.length || each.group))
|
|
20804
|
+
return null;
|
|
20805
|
+
const adds = rest.slice(0, -1);
|
|
20806
|
+
if (!adds.length || commit.words[0] !== "git" || commit.words[1] !== "commit")
|
|
20807
|
+
return null;
|
|
20808
|
+
const paths = [];
|
|
20809
|
+
let all = false;
|
|
20810
|
+
for (const add of adds) {
|
|
20811
|
+
const [tool, verb, ...args] = add.words;
|
|
20812
|
+
if (tool !== "git" || verb !== "add" || add.expands?.length || add.subs?.length)
|
|
20813
|
+
return null;
|
|
20814
|
+
const named = args.filter((arg) => !["-A", "--all", "--"].includes(arg));
|
|
20815
|
+
if (named.some((arg) => arg.startsWith("-") || /[*?[\]]/u.test(arg)))
|
|
20816
|
+
return null;
|
|
20817
|
+
if (!named.length && !args.some((arg) => arg === "-A" || arg === "--all"))
|
|
20818
|
+
return null;
|
|
20819
|
+
if (named.length)
|
|
20820
|
+
paths.push(...named);
|
|
20821
|
+
else
|
|
20822
|
+
all = true;
|
|
20823
|
+
}
|
|
20824
|
+
const messages = [];
|
|
20825
|
+
let allowEmpty = false;
|
|
20826
|
+
for (let index = 2;index < commit.words.length; index++) {
|
|
20827
|
+
const arg = commit.words[index];
|
|
20828
|
+
let message = null;
|
|
20829
|
+
if (arg === "--allow-empty") {
|
|
20830
|
+
allowEmpty = true;
|
|
20831
|
+
continue;
|
|
20832
|
+
}
|
|
20833
|
+
if (arg === "-m" || arg === "--message")
|
|
20834
|
+
message = messageOf(commit, ++index);
|
|
20835
|
+
else if (!commit.expands?.includes(index) && /^(?:-m|--message=)./u.test(arg))
|
|
20836
|
+
message = arg.replace(/^(?:-m|--message=)/u, "");
|
|
20837
|
+
if (!message || message.startsWith("-"))
|
|
20838
|
+
return null;
|
|
20839
|
+
messages.push(message);
|
|
20840
|
+
}
|
|
20841
|
+
if (!messages.length)
|
|
20842
|
+
return null;
|
|
20843
|
+
if (!all) {
|
|
20844
|
+
const staged = spawnSync15("git", ["diff", "--cached", "--quiet"], {
|
|
20845
|
+
cwd: target,
|
|
20846
|
+
timeout: 5000
|
|
20847
|
+
});
|
|
20848
|
+
if (staged.status !== 0)
|
|
20849
|
+
return null;
|
|
20850
|
+
}
|
|
20851
|
+
return [
|
|
20852
|
+
`workit git --cwd ${word(target)} commit`,
|
|
20853
|
+
...messages.map((message) => `-m ${shellQuote(message)}`),
|
|
20854
|
+
...allowEmpty ? ["--allow-empty"] : [],
|
|
20855
|
+
all ? "--all" : `-- ${[...new Set(paths)].map(word).join(" ")}`
|
|
20856
|
+
].join(" ");
|
|
20857
|
+
};
|
|
20858
|
+
var commitRefusal = (input, command, dialect, { action, repo, invocation, workit }) => {
|
|
20859
|
+
if (action.kind !== "commit" || !(workit || policyDeclared()))
|
|
20860
|
+
return null;
|
|
20861
|
+
const switches = workitInvocations(command, dialect).length > 0 || rawInvocations(command, dialect).some((raw) => ["switch", "checkout", "worktree"].includes(raw.args[0] ?? ""));
|
|
20862
|
+
let guarded = false;
|
|
20863
|
+
try {
|
|
20864
|
+
guarded = !!repo.branch && resolveBranchPolicyFor(repo.dir).protected.has(repo.branch.toLowerCase());
|
|
20865
|
+
} catch {}
|
|
20866
|
+
if (guarded && !switches)
|
|
20867
|
+
return `workit: raw ${quote("git commit")} on ${repo.branch}, a protected branch. Branch first: ${quote("workit git branch --kind feature --slug <slug>")} (uncommitted changes come along), then ${quote("workit git commit -m '<msg>' -- <paths>")}.`;
|
|
20868
|
+
const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command, path27.resolve(input.cwd, invocation.dir), repo);
|
|
20869
|
+
return call && `workit: no ${quote("cd … &&")} chain; run ${quote(call)}.`;
|
|
20870
|
+
};
|
|
20765
20871
|
function rawGitPre(input, command, options = {}) {
|
|
20766
20872
|
try {
|
|
20767
20873
|
const dialect = dialectOf(input);
|
|
@@ -20777,6 +20883,11 @@ function rawGitPre(input, command, options = {}) {
|
|
|
20777
20883
|
if (refused)
|
|
20778
20884
|
return deny(refused);
|
|
20779
20885
|
}
|
|
20886
|
+
for (const found of located) {
|
|
20887
|
+
const refused = commitRefusal(input, command, dialect, found);
|
|
20888
|
+
if (refused)
|
|
20889
|
+
return deny(refused);
|
|
20890
|
+
}
|
|
20780
20891
|
for (const { action, repo, invocation, workit } of located) {
|
|
20781
20892
|
if (!workit)
|
|
20782
20893
|
continue;
|
|
@@ -24513,7 +24624,8 @@ var WORKIT_USER_ONLY = [
|
|
|
24513
24624
|
["release", "notes", "approve"],
|
|
24514
24625
|
["grant", "set"],
|
|
24515
24626
|
["grant", "raise"],
|
|
24516
|
-
["ledger", "void"]
|
|
24627
|
+
["ledger", "void"],
|
|
24628
|
+
["approve"]
|
|
24517
24629
|
];
|
|
24518
24630
|
var ALLOWED = new Set(WORKIT_ALLOWED_VERBS);
|
|
24519
24631
|
var hasWordsInOrder = (words, needle) => {
|
|
@@ -26305,7 +26417,12 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
26305
26417
|
};
|
|
26306
26418
|
for (const segment of segments) {
|
|
26307
26419
|
if (segment.group === "open") {
|
|
26308
|
-
groups.push({
|
|
26420
|
+
groups.push({
|
|
26421
|
+
dir,
|
|
26422
|
+
stack: [...stack],
|
|
26423
|
+
vars: new Map(vars),
|
|
26424
|
+
loops: new Map(loops)
|
|
26425
|
+
});
|
|
26309
26426
|
continue;
|
|
26310
26427
|
}
|
|
26311
26428
|
if (segment.group === "close") {
|
|
@@ -26513,39 +26630,60 @@ var claimAll = (owner, targets, deps) => {
|
|
|
26513
26630
|
claimLiveSession(target, owner, deps);
|
|
26514
26631
|
};
|
|
26515
26632
|
var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path39.resolve(cwd, file)) : [path39.join(cwd, DIR_TARGET)];
|
|
26516
|
-
var
|
|
26633
|
+
var registryTarget = (cwd, targets) => {
|
|
26517
26634
|
const state = resolveStateDir();
|
|
26518
|
-
const
|
|
26519
|
-
|
|
26635
|
+
for (const target of targets) {
|
|
26636
|
+
const registry = underRegistry(state, cwd, homeExpanded(target), process.platform, canonical3);
|
|
26637
|
+
if (registry)
|
|
26638
|
+
return { file: target, registry };
|
|
26639
|
+
}
|
|
26640
|
+
return null;
|
|
26520
26641
|
};
|
|
26521
|
-
var
|
|
26642
|
+
var underRegistry = (state, cwd, target, platform = process.platform, real = (file) => file) => {
|
|
26522
26643
|
const win = platform === "win32";
|
|
26523
26644
|
const p = win ? path39.win32 : path39.posix;
|
|
26524
26645
|
const fold = (value) => win || platform === "darwin" ? value.toLowerCase() : value;
|
|
26525
26646
|
const named = win ? target.replace(/^\/([a-zA-Z])(?=\/|$)/, "$1:") : target;
|
|
26526
26647
|
const relative = p.relative(fold(real(p.resolve(state))), fold(real(p.resolve(cwd, named))));
|
|
26527
26648
|
if (relative.startsWith("..") || p.isAbsolute(relative))
|
|
26528
|
-
return
|
|
26529
|
-
|
|
26649
|
+
return null;
|
|
26650
|
+
const first = relative.split(p.sep)[0];
|
|
26651
|
+
if (first.startsWith("issued"))
|
|
26652
|
+
return "issued";
|
|
26653
|
+
return first === "approvals" ? "approvals" : null;
|
|
26530
26654
|
};
|
|
26531
|
-
var
|
|
26655
|
+
var unquotedWindowsRegistry = (command) => {
|
|
26532
26656
|
if (process.platform !== "win32" || !command.includes("\\"))
|
|
26533
|
-
return
|
|
26657
|
+
return null;
|
|
26534
26658
|
const flat = (value) => value.replaceAll("\\", "/").toLowerCase();
|
|
26535
|
-
|
|
26659
|
+
const text = flat(command);
|
|
26660
|
+
const state = flat(resolveStateDir());
|
|
26661
|
+
const registry = text.includes(`${state}/issued`) ? "issued" : text.includes(`${state}/approvals`) ? "approvals" : null;
|
|
26662
|
+
return registry && shellWrites(command).writes ? registry : null;
|
|
26663
|
+
};
|
|
26664
|
+
var REGISTRY_DENY = {
|
|
26665
|
+
issued: {
|
|
26666
|
+
label: "issued-registry guard",
|
|
26667
|
+
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."
|
|
26668
|
+
},
|
|
26669
|
+
approvals: {
|
|
26670
|
+
label: "approvals guard",
|
|
26671
|
+
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."
|
|
26672
|
+
}
|
|
26536
26673
|
};
|
|
26537
|
-
var
|
|
26538
|
-
const
|
|
26674
|
+
var registryDeny = ({ file, registry }) => {
|
|
26675
|
+
const { label, unblock } = REGISTRY_DENY[registry];
|
|
26676
|
+
const what = registry === "issued" ? "issued-session state" : "host-approval state";
|
|
26539
26677
|
return {
|
|
26540
26678
|
kind: "deny",
|
|
26541
|
-
reason: `workit
|
|
26679
|
+
reason: `workit ${label}: ${file} is under Workit's ${what}. ${unblock}`,
|
|
26542
26680
|
unblock
|
|
26543
26681
|
};
|
|
26544
26682
|
};
|
|
26545
26683
|
function writeGate(cwd, paths, owner, deps) {
|
|
26546
|
-
const forged = paths?.length ?
|
|
26684
|
+
const forged = paths?.length ? registryTarget(cwd, paths) : null;
|
|
26547
26685
|
if (forged)
|
|
26548
|
-
return
|
|
26686
|
+
return registryDeny(forged);
|
|
26549
26687
|
if (!owner)
|
|
26550
26688
|
return beforeWriteGate(cwd, paths);
|
|
26551
26689
|
const targets = liveTargets(cwd, paths);
|
|
@@ -26559,9 +26697,10 @@ function writeGate(cwd, paths, owner, deps) {
|
|
|
26559
26697
|
}
|
|
26560
26698
|
function shellGate(cwd, command, owner, dialect = "posix", deps) {
|
|
26561
26699
|
try {
|
|
26562
|
-
const
|
|
26700
|
+
const windows = unquotedWindowsRegistry(command);
|
|
26701
|
+
const forged = registryTarget(cwd, segmentTargets(cwd, command, dialect)) ?? (windows ? { file: `the ${windows} registry`, registry: windows } : null);
|
|
26563
26702
|
if (forged)
|
|
26564
|
-
return
|
|
26703
|
+
return registryDeny(forged);
|
|
26565
26704
|
} catch {}
|
|
26566
26705
|
const writes = shellWrites(command);
|
|
26567
26706
|
let targets = [];
|
|
@@ -27130,6 +27269,10 @@ var WRITE_TOOLS = new Set([
|
|
|
27130
27269
|
import fs28 from "node:fs";
|
|
27131
27270
|
import path41 from "node:path";
|
|
27132
27271
|
|
|
27272
|
+
// packages/workit-core/src/approvals/store.ts
|
|
27273
|
+
var REQUEST_TTL_MS = 30 * 60000;
|
|
27274
|
+
var GRANT_TTL_MS = 15 * 60000;
|
|
27275
|
+
|
|
27133
27276
|
// packages/workit-core/src/hooks/hosts/claude-code.ts
|
|
27134
27277
|
var CLAUDE_CODE_DESCRIPTOR = {
|
|
27135
27278
|
host: "claude_code",
|
|
@@ -27171,7 +27314,11 @@ var CLAUDE_CODE_DESCRIPTOR = {
|
|
|
27171
27314
|
maxConcurrency: "undocumented",
|
|
27172
27315
|
agentPrefix: "workit:"
|
|
27173
27316
|
},
|
|
27174
|
-
provenance: {
|
|
27317
|
+
provenance: {
|
|
27318
|
+
sessionId: "native",
|
|
27319
|
+
agentIdOnTool: "native",
|
|
27320
|
+
postToolObserve: "native"
|
|
27321
|
+
},
|
|
27175
27322
|
interaction: { questions: "undocumented", writeBoundary: "partial" },
|
|
27176
27323
|
stopControl: "native",
|
|
27177
27324
|
shellAvailable: "native",
|
|
@@ -27233,6 +27380,7 @@ var CONTEXT_EVENTS = new Set([
|
|
|
27233
27380
|
"PreToolUse",
|
|
27234
27381
|
"PostToolUse"
|
|
27235
27382
|
]);
|
|
27383
|
+
var ASKING_MODES = new Set(["default", "acceptEdits", "plan"]);
|
|
27236
27384
|
|
|
27237
27385
|
// packages/workit-core/src/hooks/hosts/codex.ts
|
|
27238
27386
|
var CODEX_DESCRIPTOR = {
|
|
@@ -28742,7 +28890,7 @@ var DEFAULT_MAX_HOLD_MS = 15 * 60000;
|
|
|
28742
28890
|
var SILENT_MS = 5 * 60000;
|
|
28743
28891
|
var UNITS2 = { "": 1, K: 1024, M: 1024 ** 2, G: 1024 ** 3, T: 1024 ** 4 };
|
|
28744
28892
|
var START_CACHE = new Map;
|
|
28745
|
-
var
|
|
28893
|
+
var GRANT_TTL_MS2 = 2 * 3600000;
|
|
28746
28894
|
var NOTICE_TTL_MS = 7 * 86400000;
|
|
28747
28895
|
|
|
28748
28896
|
// packages/workit-core/src/stack.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workit-dev/opencode",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
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.
|
|
44
|
+
"@workit-dev/core": "^1.6.1"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=24"
|