@workit-dev/opencode 2.28.0 → 2.29.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 +55 -19
- package/package.json +2 -2
package/dist/plugin.js
CHANGED
|
@@ -8803,7 +8803,7 @@ var workspaceConfigSchema = looseObject({
|
|
|
8803
8803
|
})),
|
|
8804
8804
|
models: optional(looseObject({ roles: modelRoles })),
|
|
8805
8805
|
resources: optional(unknown()),
|
|
8806
|
-
remotes: optional(array(nonBlank.check(refine((pattern) =>
|
|
8806
|
+
remotes: optional(array(nonBlank.check(refine((pattern) => isRemotePattern(pattern), "is not a remote URL (https://host/owner/repo, git@host:owner/repo, a path, or owner/*)")))),
|
|
8807
8807
|
externalRepos: optional(array(nonBlank.check(_regex(/^[\w-]+(?:\/\w[\w.-]*)*\/(?:\w[\w.-]*|\*)$/u, "is owner/name, group/project or owner/* on the checkout's forge host, without the host")))),
|
|
8808
8808
|
additiveRiskPaths: optional(array(nonBlank)),
|
|
8809
8809
|
autonomy: optional(looseObject(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
|
|
@@ -9173,6 +9173,7 @@ var canonicalGlob = (glob) => {
|
|
|
9173
9173
|
return real + (prefix.endsWith("/") ? "/" : "") + rest;
|
|
9174
9174
|
};
|
|
9175
9175
|
var globSpecificity = (glob) => glob.replaceAll("\\", "/").split("/").filter((segment) => segment.length > 0 && !/[*?[\]{]/.test(segment)).length;
|
|
9176
|
+
var workspaceMatches = (cwd, entries) => matchingEntries(cwd, entries);
|
|
9176
9177
|
var selectWorkspaceMatch = (matches, cwd, workspaceName) => {
|
|
9177
9178
|
if (workspaceName !== undefined) {
|
|
9178
9179
|
const named = matches.filter((entry) => entry.name === workspaceName);
|
|
@@ -9194,15 +9195,32 @@ var selectWorkspaceMatch = (matches, cwd, workspaceName) => {
|
|
|
9194
9195
|
}
|
|
9195
9196
|
return mostSpecific[0];
|
|
9196
9197
|
};
|
|
9197
|
-
var
|
|
9198
|
-
|
|
9199
|
-
|
|
9200
|
-
|
|
9201
|
-
|
|
9198
|
+
var HOSTLESS_REMOTE = /^[\w-]+\/\*$/u;
|
|
9199
|
+
var expandRemotePattern = (entry, pattern) => {
|
|
9200
|
+
if (!HOSTLESS_REMOTE.test(pattern.trim()))
|
|
9201
|
+
return pattern;
|
|
9202
|
+
const vcs = entry.vcs ?? {};
|
|
9203
|
+
const host = typeof vcs.host === "string" && vcs.host.trim().replace(/^https?:\/\/|\/.*$/giu, "") || `${vcs.provider === "gitlab" ? "gitlab" : "github"}.com`;
|
|
9204
|
+
return `https://${host}/${pattern.trim()}`;
|
|
9205
|
+
};
|
|
9206
|
+
var isRemotePattern = (pattern) => !!remotePattern(expandRemotePattern({}, pattern));
|
|
9207
|
+
var remoteClaimOf = (entry, key, exact = false) => (Array.isArray(entry.remotes) ? entry.remotes : []).find((pattern) => typeof pattern === "string" && !(exact && pattern.trim().endsWith("/*")) && remoteMatches(expandRemotePattern(entry, pattern), key));
|
|
9208
|
+
var resolveWorkspaceFromEntries = (cwd, entries, workspaceName, remotes) => {
|
|
9209
|
+
const globbed = matchingEntries(cwd, entries);
|
|
9210
|
+
const listed = !remotes || globbed.length || !entries.some((entry) => entry.remotes) ? [] : checkoutRemotes(cwd);
|
|
9211
|
+
const origin = listed instanceof Error ? [] : listed.filter((item) => item.name === "origin");
|
|
9212
|
+
const hits = entries.filter((entry) => origin.length && origin.every((item) => remoteClaimOf(entry, item.key)));
|
|
9213
|
+
const exact = hits.filter((entry) => origin.every((item) => remoteClaimOf(entry, item.key, true)));
|
|
9214
|
+
const ranked = exact.length ? exact : hits;
|
|
9215
|
+
if (workspaceName === undefined && ranked.length > 1)
|
|
9216
|
+
return null;
|
|
9217
|
+
return selectWorkspaceMatch(hits.length ? workspaceName ? hits : ranked : globbed, cwd, workspaceName) ?? null;
|
|
9218
|
+
};
|
|
9219
|
+
var resolveWorkspaceFrom = (cwd, dir, workspaceName, remotes) => {
|
|
9202
9220
|
const result = readWorkspacesResult(dir);
|
|
9203
9221
|
if (result.status === "malformed" || result.status === "invalid")
|
|
9204
9222
|
throw new WorkspaceConfigError(result.error);
|
|
9205
|
-
return resolveWorkspaceFromEntries(cwd, result.entries, workspaceName);
|
|
9223
|
+
return resolveWorkspaceFromEntries(cwd, result.entries, workspaceName, remotes);
|
|
9206
9224
|
};
|
|
9207
9225
|
var runtimeWorkspacePolicySchema = (kind) => {
|
|
9208
9226
|
const key = kind === "branch" ? "branchPolicy" : kind === "commit" ? "commitPolicy" : "vcs";
|
|
@@ -9252,10 +9270,12 @@ var matchRuntimeWorkspace = (cwd, dir = configDir2()) => {
|
|
|
9252
9270
|
if (!glob.ok)
|
|
9253
9271
|
throw new WorkspaceConfigError(`${file} workspace ${entry.name}: ${glob.error}`);
|
|
9254
9272
|
}
|
|
9255
|
-
const matches = matchingEntries(cwd, entries ?? []);
|
|
9256
9273
|
const workspaceName = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
|
|
9257
|
-
const selected =
|
|
9258
|
-
|
|
9274
|
+
const selected = resolveWorkspaceFromEntries(cwd, entries ?? [], workspaceName, true);
|
|
9275
|
+
if (!selected)
|
|
9276
|
+
return null;
|
|
9277
|
+
const matches = matchingEntries(cwd, entries ?? []);
|
|
9278
|
+
return { file, selected, matches: matches.length ? matches : [selected] };
|
|
9259
9279
|
};
|
|
9260
9280
|
var resolveRuntimeReleaseTracks = (cwd) => {
|
|
9261
9281
|
const matched = matchRuntimeWorkspace(cwd);
|
|
@@ -19281,6 +19301,7 @@ function ytrackReadiness(run, host) {
|
|
|
19281
19301
|
}
|
|
19282
19302
|
|
|
19283
19303
|
// packages/workit-core/src/autonomy.ts
|
|
19304
|
+
var resolveWorkspaceFrom2 = (cwd, dir, name) => resolveWorkspaceFrom(cwd, dir, name, true);
|
|
19284
19305
|
var accountHomeDir = () => {
|
|
19285
19306
|
const home = grantsHome.resolve();
|
|
19286
19307
|
return home === null ? null : configDir({ HOME: home });
|
|
@@ -19313,11 +19334,11 @@ var accountUnread = () => {
|
|
|
19313
19334
|
};
|
|
19314
19335
|
var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
|
|
19315
19336
|
var fileSource = (dir = accountDir()) => ({
|
|
19316
|
-
resolve: (cwd, name) => dir === null ? null :
|
|
19337
|
+
resolve: (cwd, name) => dir === null ? null : resolveWorkspaceFrom2(cwd, dir, name),
|
|
19317
19338
|
entries: () => entriesIn(dir)
|
|
19318
19339
|
});
|
|
19319
19340
|
var sealedSource = (entries) => ({
|
|
19320
|
-
resolve: (cwd, name) => resolveWorkspaceFromEntries(cwd, entries, name),
|
|
19341
|
+
resolve: (cwd, name) => resolveWorkspaceFromEntries(cwd, entries, name, true),
|
|
19321
19342
|
entries: () => entries
|
|
19322
19343
|
});
|
|
19323
19344
|
var sealOf = () => {
|
|
@@ -19343,8 +19364,8 @@ var youTrackWritesPolicy = (cwd) => {
|
|
|
19343
19364
|
return ASK;
|
|
19344
19365
|
const auto = (entry) => youtrackOf(entry)?.writes === "auto";
|
|
19345
19366
|
const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
|
|
19346
|
-
const named =
|
|
19347
|
-
const folder = name ?
|
|
19367
|
+
const named = resolveWorkspaceFrom2(cwd, dir, name);
|
|
19368
|
+
const folder = name ? resolveWorkspaceFrom2(cwd, dir) : named;
|
|
19348
19369
|
if (!auto(named) || !auto(folder))
|
|
19349
19370
|
return ASK;
|
|
19350
19371
|
const [a, b] = [autoHostsOf(named), autoHostsOf(folder)];
|
|
@@ -19599,7 +19620,8 @@ function resolveWith(source, cwd, world, target) {
|
|
|
19599
19620
|
const above = checkoutsAbove(cwd);
|
|
19600
19621
|
for (const where of above instanceof Error ? [above] : above)
|
|
19601
19622
|
autonomy = capAt(source, autonomy, where, where instanceof Error ? "git" : `checkout ${where}`, "a worktree or submodule never exceeds it", true);
|
|
19602
|
-
|
|
19623
|
+
const own = real && workspaceMatches(cwd, source.entries()).length === 0 ? real : undefined;
|
|
19624
|
+
return capAtRemotes(source, autonomy, cwd, target, own);
|
|
19603
19625
|
}
|
|
19604
19626
|
var needsAccount = (autonomy) => autonomy.configured.length > 0 && !autonomy.accountConfigured;
|
|
19605
19627
|
function stricter(current, sealed, note, unblock) {
|
|
@@ -19638,17 +19660,31 @@ function stricter(current, sealed, note, unblock) {
|
|
|
19638
19660
|
note: current.note ? `${current.note}; ${note}` : note
|
|
19639
19661
|
};
|
|
19640
19662
|
}
|
|
19641
|
-
function capAtRemotes(source, autonomy, cwd, target) {
|
|
19663
|
+
function capAtRemotes(source, autonomy, cwd, target, own) {
|
|
19642
19664
|
const claiming = source.entries().filter((entry) => entry.remotes?.length);
|
|
19643
19665
|
if (claiming.length === 0)
|
|
19644
19666
|
return autonomy;
|
|
19645
19667
|
const remotes = target === undefined ? checkoutRemotes(cwd) : typeof target === "function" ? target() : target;
|
|
19646
19668
|
if (remotes instanceof Error)
|
|
19647
19669
|
return capAt(source, autonomy, remotes, target === undefined ? "git" : "target", "a target that cannot be resolved never raises grants");
|
|
19670
|
+
const listed = Array.isArray(remotes) ? remotes : remotes.remotes;
|
|
19671
|
+
const capped = own ? capAtOwnClaim(source, autonomy, cwd, own, target && listed) : autonomy;
|
|
19672
|
+
return capAtClaims(source, capped, listed, claiming);
|
|
19673
|
+
}
|
|
19674
|
+
function capAtOwnClaim(source, autonomy, cwd, own, judged) {
|
|
19675
|
+
const push = judged ? { remotes: judged } : pushTarget(cwd, pushRemoteName(cwd) ?? "");
|
|
19676
|
+
if (push instanceof Error)
|
|
19677
|
+
return capAt(source, autonomy, push, "push target", "a target that cannot be resolved never raises grants");
|
|
19678
|
+
const unclaimed = push.remotes.filter((remote) => !remoteClaimOf(own, remote.key));
|
|
19679
|
+
if (unclaimed.length === 0 && push.remotes.length > 0)
|
|
19680
|
+
return autonomy;
|
|
19681
|
+
return stricter(autonomy, autonomyOf(null), `${unclaimed.map((remote) => `remote ${remote.name} ${remote.url}`).join(", ") || "no target"}: not in workspace ${own.name}'s remotes, which matched this checkout by its origin; grants capped at the defaults`, `ask the user to add that repository to workspace ${own.name}'s remotes, in their own terminal: workit workspace set ${own.name} remotes=<patterns>`);
|
|
19682
|
+
}
|
|
19683
|
+
function capAtClaims(source, autonomy, listed, claiming) {
|
|
19648
19684
|
let capped = autonomy;
|
|
19649
|
-
for (const remote of
|
|
19685
|
+
for (const remote of listed)
|
|
19650
19686
|
for (const entry of claiming) {
|
|
19651
|
-
const pattern = entry
|
|
19687
|
+
const pattern = remoteClaimOf(entry, remote.key);
|
|
19652
19688
|
if (pattern)
|
|
19653
19689
|
capped = capAt(source, capped, { entry }, `remote ${remote.name} ${remote.url} (workspace ${entry.name} claims ${pattern})`, "a checkout never exceeds the workspace that owns its remote");
|
|
19654
19690
|
}
|
|
@@ -19676,7 +19712,7 @@ function claimsIn(target, entries) {
|
|
|
19676
19712
|
return target;
|
|
19677
19713
|
const claiming = entries.filter((entry) => entry.remotes?.length);
|
|
19678
19714
|
return target.remotes.flatMap((remote) => claiming.flatMap((entry) => {
|
|
19679
|
-
const pattern = entry
|
|
19715
|
+
const pattern = remoteClaimOf(entry, remote.key);
|
|
19680
19716
|
return pattern ? [{ url: remote.url, workspace: entry.name, pattern }] : [];
|
|
19681
19717
|
}));
|
|
19682
19718
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workit-dev/opencode",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.29.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.3.2",
|
|
44
|
-
"@workit-dev/core": "^2.
|
|
44
|
+
"@workit-dev/core": "^2.29.0"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=24"
|