@workit-dev/opencode 1.16.0 → 2.0.0
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 +61 -18
- package/package.json +2 -2
package/dist/plugin.js
CHANGED
|
@@ -9094,6 +9094,7 @@ var accountHome = (platform = process.platform, io = hostIo) => {
|
|
|
9094
9094
|
return null;
|
|
9095
9095
|
}
|
|
9096
9096
|
};
|
|
9097
|
+
var grantsHome = { resolve: () => accountHome() };
|
|
9097
9098
|
|
|
9098
9099
|
// packages/workit-core/src/core/remotes.ts
|
|
9099
9100
|
var FORGE_SCHEMES = new Set(["ssh", "git", "http", "https", "git+ssh", "ssh+git"]);
|
|
@@ -18629,11 +18630,12 @@ var ENTRY_KEYS = [
|
|
|
18629
18630
|
"verification",
|
|
18630
18631
|
"youtrack"
|
|
18631
18632
|
];
|
|
18633
|
+
var IDENTITY_KEYS = ["provider", "account", "tokenFile", "host"];
|
|
18632
18634
|
var sealProjection = (entries) => entries.map((entry) => {
|
|
18633
18635
|
const all = pick2(entry, ENTRY_KEYS) ?? {};
|
|
18634
18636
|
return pick2({
|
|
18635
18637
|
...all,
|
|
18636
|
-
vcs: pick2(all.vcs,
|
|
18638
|
+
vcs: pick2(all.vcs, IDENTITY_KEYS),
|
|
18637
18639
|
youtrack: pick2(all.youtrack, ["writes"])
|
|
18638
18640
|
}, ENTRY_KEYS);
|
|
18639
18641
|
});
|
|
@@ -18665,7 +18667,6 @@ function checkSeal(dir) {
|
|
|
18665
18667
|
}
|
|
18666
18668
|
|
|
18667
18669
|
// packages/workit-core/src/autonomy.ts
|
|
18668
|
-
var grantsHome = { resolve: accountHome };
|
|
18669
18670
|
var accountDir = () => {
|
|
18670
18671
|
const home = grantsHome.resolve();
|
|
18671
18672
|
return home === null ? null : configDir({ HOME: home });
|
|
@@ -18686,11 +18687,26 @@ var sealOf = () => {
|
|
|
18686
18687
|
return dir === null ? { state: "none" } : checkSeal(dir);
|
|
18687
18688
|
};
|
|
18688
18689
|
var SEAL_UNBLOCK = `if the user made this change, ask them to run, in their own terminal: ${SEAL_COMMAND}`;
|
|
18690
|
+
var NO_SEAL_UNBLOCK = `ask the user to review and seal the grants, in their own terminal: ${SEAL_COMMAND}`;
|
|
18691
|
+
var NO_SEAL_NOTE = `workspaces.json has no seal yet (${SEAL_COMMAND} has never run), so grants, endpoint, verification and youtrack.writes stay at or below the D4 defaults; ${NO_SEAL_UNBLOCK}`;
|
|
18689
18692
|
var sealNote = (seal = sealOf()) => seal.state === "broken" ? `workspaces.json does not match its seal (${seal.reason}), so grants, endpoint, verification and youtrack.writes are the stricter of their current and last sealed values; ${SEAL_UNBLOCK}` : null;
|
|
18690
18693
|
var youTrackWritesMode = (cwd) => {
|
|
18691
|
-
|
|
18692
|
-
|
|
18694
|
+
try {
|
|
18695
|
+
const dir = accountDir();
|
|
18696
|
+
if (dir === null || redirected(dir) || evalWorld(cwd))
|
|
18697
|
+
return "ask";
|
|
18698
|
+
if (checkSeal(dir).state !== "valid")
|
|
18699
|
+
return "ask";
|
|
18700
|
+
const auto = (entry) => entry?.youtrack?.writes === "auto";
|
|
18701
|
+
const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
|
|
18702
|
+
if (!auto(resolveWorkspaceFrom(cwd, dir, name)))
|
|
18703
|
+
return "ask";
|
|
18704
|
+
return !name || auto(resolveWorkspaceFrom(cwd, dir)) ? "auto" : "ask";
|
|
18705
|
+
} catch {
|
|
18706
|
+
return "ask";
|
|
18707
|
+
}
|
|
18693
18708
|
};
|
|
18709
|
+
var redirected = (dir) => path27.resolve(resolveConfigDir()) !== path27.resolve(dir);
|
|
18694
18710
|
var shownGrantsDir = () => {
|
|
18695
18711
|
const world = evalWorld(process.cwd());
|
|
18696
18712
|
return world ? path27.join(world, "config") : accountDir();
|
|
@@ -18718,8 +18734,9 @@ var grantsOverride = () => {
|
|
|
18718
18734
|
if (shown === null)
|
|
18719
18735
|
return NO_ACCOUNT;
|
|
18720
18736
|
const configured = path27.resolve(resolveConfigDir());
|
|
18721
|
-
return configured === path27.resolve(shown) ? null : `the config directory is redirected to ${configured} (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), but that override does not apply to grants: grants are read only from ${path27.join(grantsDir(), "workspaces.json")},
|
|
18737
|
+
return configured === path27.resolve(shown) ? null : `the config directory is redirected to ${configured} (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), but that override does not apply to grants: grants are read only from ${path27.join(grantsDir(), "workspaces.json")}, and under a redirect they never exceed the D4 defaults`;
|
|
18722
18738
|
};
|
|
18739
|
+
var redirectUnblock = () => `ask the user: grants above the D4 defaults apply only without a config redirect (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), and are read from ${path27.join(grantsDir(), "workspaces.json")}`;
|
|
18723
18740
|
var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
|
|
18724
18741
|
var DEFAULT_GRANTS = Object.freeze({
|
|
18725
18742
|
push: true,
|
|
@@ -18885,23 +18902,39 @@ function capAt(source, named, where, by, why, main = false) {
|
|
|
18885
18902
|
function resolveAutonomy(cwd, target) {
|
|
18886
18903
|
const world = benchWorld(cwd);
|
|
18887
18904
|
const override = world ? null : grantsOverride();
|
|
18888
|
-
if (override)
|
|
18905
|
+
if (override === NO_ACCOUNT)
|
|
18889
18906
|
return { ...autonomyOf(null), note: override };
|
|
18890
18907
|
let resolved;
|
|
18891
18908
|
const once = typeof target === "function" ? () => resolved ??= target() : target;
|
|
18892
|
-
const
|
|
18909
|
+
const account = accountAuthority(cwd, world, once);
|
|
18910
|
+
return override ? stricter(account, autonomyOf(null), override, redirectUnblock()) : account;
|
|
18911
|
+
}
|
|
18912
|
+
function accountAuthority(cwd, world, target) {
|
|
18913
|
+
const current = resolveWith(fileSource(), cwd, world, target);
|
|
18893
18914
|
const seal = sealOf();
|
|
18894
|
-
if (seal.state !== "broken")
|
|
18895
|
-
|
|
18915
|
+
if (seal.state !== "broken") {
|
|
18916
|
+
if (seal.state === "valid" || current.world)
|
|
18917
|
+
return current;
|
|
18918
|
+
const capped = stricter(current, autonomyOf(null), NO_SEAL_NOTE, NO_SEAL_UNBLOCK);
|
|
18919
|
+
return authorityKey(capped) === authorityKey(current) ? current : capped;
|
|
18920
|
+
}
|
|
18896
18921
|
let sealed = autonomyOf(null);
|
|
18897
18922
|
try {
|
|
18898
18923
|
if (seal.sealed)
|
|
18899
|
-
sealed = resolveWith(sealedSource(seal.sealed), cwd, world,
|
|
18924
|
+
sealed = resolveWith(sealedSource(seal.sealed), cwd, world, target);
|
|
18900
18925
|
} catch {
|
|
18901
18926
|
sealed = null;
|
|
18902
18927
|
}
|
|
18903
|
-
return stricter(current, sealed, sealNote(seal));
|
|
18928
|
+
return stricter(current, sealed, sealNote(seal), SEAL_UNBLOCK);
|
|
18904
18929
|
}
|
|
18930
|
+
var authorityKey = (autonomy) => JSON.stringify([
|
|
18931
|
+
autonomy.grants,
|
|
18932
|
+
autonomy.configured,
|
|
18933
|
+
autonomy.accountConfigured,
|
|
18934
|
+
autonomy.defaultEndpoint,
|
|
18935
|
+
autonomy.effectiveEndpoint,
|
|
18936
|
+
autonomy.verification
|
|
18937
|
+
]);
|
|
18905
18938
|
function resolveWith(source, cwd, world, target) {
|
|
18906
18939
|
const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
|
|
18907
18940
|
const real = source.resolve(cwd, name);
|
|
@@ -18916,7 +18949,7 @@ function resolveWith(source, cwd, world, target) {
|
|
|
18916
18949
|
return capAtRemotes(source, autonomy, cwd, target);
|
|
18917
18950
|
}
|
|
18918
18951
|
var needsAccount = (autonomy) => autonomy.configured.length > 0 && !autonomy.accountConfigured;
|
|
18919
|
-
function stricter(current, sealed, note) {
|
|
18952
|
+
function stricter(current, sealed, note, unblock) {
|
|
18920
18953
|
const grants = { ...current.grants };
|
|
18921
18954
|
const unblocks = { ...current.unblocks };
|
|
18922
18955
|
for (const kind of GRANT_KINDS) {
|
|
@@ -18924,7 +18957,7 @@ function stricter(current, sealed, note) {
|
|
|
18924
18957
|
if (!raises(kind, floor, grants[kind]))
|
|
18925
18958
|
continue;
|
|
18926
18959
|
grants[kind] = floor;
|
|
18927
|
-
unblocks[kind] =
|
|
18960
|
+
unblocks[kind] = unblock;
|
|
18928
18961
|
}
|
|
18929
18962
|
const configured = GRANT_KINDS.filter((kind) => current.configured.includes(kind) || sealed?.configured.includes(kind));
|
|
18930
18963
|
const accountConfigured = !needsAccount(current) && !(sealed && needsAccount(sealed)) && (current.accountConfigured || Boolean(sealed?.accountConfigured));
|
|
@@ -18946,9 +18979,9 @@ function stricter(current, sealed, note) {
|
|
|
18946
18979
|
accountConfigured,
|
|
18947
18980
|
defaultEndpoint,
|
|
18948
18981
|
effectiveEndpoint: endpoint,
|
|
18949
|
-
endpointReason: endpoint === current.effectiveEndpoint ? current.endpointReason :
|
|
18982
|
+
endpointReason: endpoint === current.effectiveEndpoint ? current.endpointReason : unblock,
|
|
18950
18983
|
verification: looser ? strict : current.verification,
|
|
18951
|
-
unblocks,
|
|
18984
|
+
unblocks: Object.keys(unblocks).length > 0 ? unblocks : current.unblocks,
|
|
18952
18985
|
note: current.note ? `${current.note}; ${note}` : note
|
|
18953
18986
|
};
|
|
18954
18987
|
}
|
|
@@ -18969,14 +19002,17 @@ function capAtRemotes(source, autonomy, cwd, target) {
|
|
|
18969
19002
|
return capped;
|
|
18970
19003
|
}
|
|
18971
19004
|
var grantsMatter = (kind) => {
|
|
18972
|
-
|
|
19005
|
+
const override = grantsOverride();
|
|
19006
|
+
if (override === NO_ACCOUNT)
|
|
18973
19007
|
return false;
|
|
18974
|
-
const
|
|
19008
|
+
const entries = entriesIn(accountDir());
|
|
19009
|
+
const matters = entries.some((entry) => {
|
|
18975
19010
|
const autonomy = autonomyOf(entry);
|
|
18976
19011
|
return entry.remotes?.length || autonomy.grants[kind] === false || needsAccount(autonomy);
|
|
18977
19012
|
});
|
|
18978
19013
|
const seal = sealOf();
|
|
18979
|
-
|
|
19014
|
+
const defaults = entries.length > 0 && DEFAULT_GRANTS[kind] === false;
|
|
19015
|
+
return matters || (seal.state === "none" || override !== null) && defaults || seal.state === "broken" && (seal.sealed ? seal.sealed.length > 0 : DEFAULT_GRANTS[kind] === false);
|
|
18980
19016
|
};
|
|
18981
19017
|
var authorityEntries = () => {
|
|
18982
19018
|
const seal = sealOf();
|
|
@@ -19034,6 +19070,13 @@ var raises = (kind, current, next) => {
|
|
|
19034
19070
|
const rank = (value) => value === true ? 2 : value === "verified" ? 1 : 0;
|
|
19035
19071
|
return rank(normalized(kind, next)) > rank(normalized(kind, current));
|
|
19036
19072
|
};
|
|
19073
|
+
var SCOPE_FIELDS = new Set([
|
|
19074
|
+
"autonomy",
|
|
19075
|
+
"autoApprove",
|
|
19076
|
+
"defaultEndpoint",
|
|
19077
|
+
"verification",
|
|
19078
|
+
"youtrack"
|
|
19079
|
+
]);
|
|
19037
19080
|
|
|
19038
19081
|
// packages/workit-core/src/hooks/session-marker.ts
|
|
19039
19082
|
import { createHash as createHash16 } from "node:crypto";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workit-dev/opencode",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
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": "^
|
|
44
|
+
"@workit-dev/core": "^2.0.0"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=24"
|