@brainervirus/workit-opencode 8.1.0 → 8.1.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 +80 -51
- package/package.json +2 -2
package/dist/plugin.js
CHANGED
|
@@ -4,7 +4,7 @@ function define(plugin) {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
// packages/workit-core/src/core.ts
|
|
7
|
-
import { spawnSync as
|
|
7
|
+
import { spawnSync as spawnSync14 } from "node:child_process";
|
|
8
8
|
import { existsSync as existsSync7, realpathSync as realpathSync5 } from "node:fs";
|
|
9
9
|
import path19 from "node:path";
|
|
10
10
|
|
|
@@ -14291,6 +14291,7 @@ var gitContext = (workspaceRoot, paths = []) => {
|
|
|
14291
14291
|
};
|
|
14292
14292
|
|
|
14293
14293
|
// packages/workit-core/src/core/workspaces.ts
|
|
14294
|
+
import { spawnSync as spawnSync8 } from "node:child_process";
|
|
14294
14295
|
import { createHash as createHash8 } from "node:crypto";
|
|
14295
14296
|
import { readFileSync as readFileSync4, realpathSync as realpathSync3 } from "node:fs";
|
|
14296
14297
|
import path13 from "node:path";
|
|
@@ -14535,6 +14536,53 @@ var validateWorkspaceGlob = (glob) => {
|
|
|
14535
14536
|
}
|
|
14536
14537
|
return { ok: true };
|
|
14537
14538
|
};
|
|
14539
|
+
|
|
14540
|
+
class WorkspaceConfigError extends Error {
|
|
14541
|
+
name = "WorkspaceConfigError";
|
|
14542
|
+
}
|
|
14543
|
+
var mainCheckouts = new Map;
|
|
14544
|
+
var mainCheckoutOf = (cwd) => {
|
|
14545
|
+
const cached = mainCheckouts.get(cwd);
|
|
14546
|
+
if (cached !== undefined)
|
|
14547
|
+
return cached;
|
|
14548
|
+
const env = { ...process.env };
|
|
14549
|
+
for (const name of ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_INDEX_FILE"])
|
|
14550
|
+
delete env[name];
|
|
14551
|
+
const git = (args) => {
|
|
14552
|
+
const run = spawnSync8("git", args, {
|
|
14553
|
+
cwd,
|
|
14554
|
+
env,
|
|
14555
|
+
encoding: "utf8",
|
|
14556
|
+
timeout: 5000,
|
|
14557
|
+
windowsHide: true
|
|
14558
|
+
});
|
|
14559
|
+
return run.status === 0 ? run.stdout : null;
|
|
14560
|
+
};
|
|
14561
|
+
let main = null;
|
|
14562
|
+
const dirs = git(["rev-parse", "--path-format=absolute", "--git-dir", "--git-common-dir"]);
|
|
14563
|
+
const [gitDir, common] = (dirs ?? "").trim().split(/\r?\n/u);
|
|
14564
|
+
if (gitDir && common && path13.resolve(gitDir) !== path13.resolve(common)) {
|
|
14565
|
+
const listed = /^worktree (.+)$/mu.exec(git(["worktree", "list", "--porcelain"]) ?? "")?.[1];
|
|
14566
|
+
main = listed?.trim() || (path13.basename(common) === ".git" ? path13.dirname(common) : common);
|
|
14567
|
+
}
|
|
14568
|
+
mainCheckouts.set(cwd, main);
|
|
14569
|
+
return main;
|
|
14570
|
+
};
|
|
14571
|
+
var matchingEntries = (cwd, entries) => {
|
|
14572
|
+
const match = (where) => {
|
|
14573
|
+
const targets = [where, realpathOf(where)].map((value) => value.replaceAll("\\", "/"));
|
|
14574
|
+
return entries.filter((entry) => {
|
|
14575
|
+
const glob = entry.glob.replaceAll("\\", "/");
|
|
14576
|
+
const canonical = canonicalGlob(glob);
|
|
14577
|
+
return targets.some((target) => matchWorkspace(glob, target) || canonical !== glob && matchWorkspace(canonical, target));
|
|
14578
|
+
});
|
|
14579
|
+
};
|
|
14580
|
+
const direct = match(cwd);
|
|
14581
|
+
if (direct.length)
|
|
14582
|
+
return direct;
|
|
14583
|
+
const main = mainCheckoutOf(cwd);
|
|
14584
|
+
return main ? match(main) : direct;
|
|
14585
|
+
};
|
|
14538
14586
|
var realpathOf = (p) => {
|
|
14539
14587
|
const real = realpathSync3.native ?? realpathSync3;
|
|
14540
14588
|
try {
|
|
@@ -14559,43 +14607,29 @@ var selectWorkspaceMatch = (matches, cwd, workspaceName) => {
|
|
|
14559
14607
|
if (named.length === 1)
|
|
14560
14608
|
return named[0];
|
|
14561
14609
|
if (named.length > 1)
|
|
14562
|
-
throw new
|
|
14610
|
+
throw new WorkspaceConfigError(`ambiguous workspace ${JSON.stringify(workspaceName)} for ${cwd}`);
|
|
14563
14611
|
if (matches.length > 0) {
|
|
14564
|
-
throw new
|
|
14612
|
+
throw new WorkspaceConfigError(`workspace ${JSON.stringify(workspaceName)} does not match ${cwd}; matching choices: ${matches.map((entry) => entry.name).join(", ")}`);
|
|
14565
14613
|
}
|
|
14566
|
-
throw new
|
|
14614
|
+
throw new WorkspaceConfigError(`workspace ${JSON.stringify(workspaceName)} does not match ${cwd}`);
|
|
14567
14615
|
}
|
|
14568
14616
|
if (matches.length < 2)
|
|
14569
14617
|
return matches[0];
|
|
14570
14618
|
const highestSpecificity = Math.max(...matches.map((entry) => globSpecificity(entry.glob)));
|
|
14571
14619
|
const mostSpecific = matches.filter((entry) => globSpecificity(entry.glob) === highestSpecificity);
|
|
14572
14620
|
if (mostSpecific.length > 1) {
|
|
14573
|
-
throw new
|
|
14621
|
+
throw new WorkspaceConfigError(`ambiguous workspace for ${cwd}; choose one of: ${mostSpecific.map((entry) => entry.name).join(", ")}`);
|
|
14574
14622
|
}
|
|
14575
14623
|
return mostSpecific[0];
|
|
14576
14624
|
};
|
|
14577
14625
|
var resolveWorkspaceFromEntries = (cwd, entries, workspaceName) => {
|
|
14578
|
-
const
|
|
14579
|
-
const matches = [];
|
|
14580
|
-
for (const ws of entries) {
|
|
14581
|
-
const glob = ws.glob.replaceAll("\\", "/");
|
|
14582
|
-
const canonical = canonicalGlob(glob);
|
|
14583
|
-
let matched = false;
|
|
14584
|
-
for (const target of targets) {
|
|
14585
|
-
if (matchWorkspace(glob, target) || canonical !== glob && matchWorkspace(canonical, target)) {
|
|
14586
|
-
matched = true;
|
|
14587
|
-
break;
|
|
14588
|
-
}
|
|
14589
|
-
}
|
|
14590
|
-
if (matched)
|
|
14591
|
-
matches.push(ws);
|
|
14592
|
-
}
|
|
14626
|
+
const matches = matchingEntries(cwd, entries);
|
|
14593
14627
|
return selectWorkspaceMatch(matches, cwd, workspaceName) ?? null;
|
|
14594
14628
|
};
|
|
14595
14629
|
var resolveWorkspaceFrom = (cwd, dir, workspaceName) => {
|
|
14596
14630
|
const result = readWorkspacesResult(dir);
|
|
14597
14631
|
if (result.status === "malformed" || result.status === "invalid")
|
|
14598
|
-
throw new
|
|
14632
|
+
throw new WorkspaceConfigError(result.error);
|
|
14599
14633
|
return resolveWorkspaceFromEntries(cwd, result.entries, workspaceName);
|
|
14600
14634
|
};
|
|
14601
14635
|
var runtimeWorkspacePolicySchema = (kind) => {
|
|
@@ -14627,31 +14661,26 @@ var matchRuntimeWorkspace = (cwd) => {
|
|
|
14627
14661
|
} catch (error) {
|
|
14628
14662
|
if (error.code === "ENOENT")
|
|
14629
14663
|
return null;
|
|
14630
|
-
throw new
|
|
14664
|
+
throw new WorkspaceConfigError(`${file} could not be read: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
14631
14665
|
}
|
|
14632
14666
|
let parsed;
|
|
14633
14667
|
try {
|
|
14634
14668
|
parsed = JSON.parse(raw);
|
|
14635
14669
|
} catch {
|
|
14636
|
-
throw new
|
|
14670
|
+
throw new WorkspaceConfigError(`${file} is not valid JSON`);
|
|
14637
14671
|
}
|
|
14638
14672
|
const validated = runtimeWorkspaceIndexSchema.safeParse(parsed);
|
|
14639
14673
|
if (!validated.success) {
|
|
14640
14674
|
const detail = validated.error.issues.map((issue) => `${issue.path.map(String).join(".") || "workspaces"}: ${issue.message}`).join("; ");
|
|
14641
|
-
throw new
|
|
14675
|
+
throw new WorkspaceConfigError(`${file} has invalid workspace matching data: ${detail}`);
|
|
14642
14676
|
}
|
|
14643
14677
|
const entries = validated.data.workspaces;
|
|
14644
14678
|
for (const entry of entries ?? []) {
|
|
14645
14679
|
const glob = validateWorkspaceGlob(entry.glob);
|
|
14646
14680
|
if (!glob.ok)
|
|
14647
|
-
throw new
|
|
14681
|
+
throw new WorkspaceConfigError(`${file} workspace ${entry.name}: ${glob.error}`);
|
|
14648
14682
|
}
|
|
14649
|
-
const
|
|
14650
|
-
const matches = (entries ?? []).filter((entry) => {
|
|
14651
|
-
const glob = entry.glob.replaceAll("\\", "/");
|
|
14652
|
-
const canonical = canonicalGlob(glob);
|
|
14653
|
-
return targets.some((target) => matchWorkspace(glob, target) || canonical !== glob && matchWorkspace(canonical, target));
|
|
14654
|
-
});
|
|
14683
|
+
const matches = matchingEntries(cwd, entries ?? []);
|
|
14655
14684
|
const workspaceName = process.env.WORKFLOW_WORKSPACE_NAME?.trim() || undefined;
|
|
14656
14685
|
const selected = selectWorkspaceMatch(matches, cwd, workspaceName);
|
|
14657
14686
|
return selected ? { file, selected } : null;
|
|
@@ -14668,7 +14697,7 @@ var resolveRuntimeWorkspaceCandidate = (cwd, kind) => {
|
|
|
14668
14697
|
const policy = runtimeWorkspacePolicySchema(kind).safeParse(selected);
|
|
14669
14698
|
if (!policy.success) {
|
|
14670
14699
|
const detail = policy.error.issues.map((issue) => `${issue.path.map(String).join(".") || "workspace"}: ${issue.message}`).join("; ");
|
|
14671
|
-
throw new
|
|
14700
|
+
throw new WorkspaceConfigError(`${file} has invalid ${kind} policy configuration: ${detail}`);
|
|
14672
14701
|
}
|
|
14673
14702
|
return policy.data;
|
|
14674
14703
|
};
|
|
@@ -14679,10 +14708,10 @@ var resolveRuntimeWorkspacePolicy = (cwd, kind, requestedProfile) => {
|
|
|
14679
14708
|
const key = kind === "branch" ? "branchPolicy" : "commitPolicy";
|
|
14680
14709
|
const profileName = requestedProfile?.trim() || candidate.defaultProfile;
|
|
14681
14710
|
if (candidate.defaultProfile && !Object.hasOwn(candidate.profiles ?? {}, candidate.defaultProfile))
|
|
14682
|
-
throw new
|
|
14711
|
+
throw new WorkspaceConfigError(`workspace ${JSON.stringify(candidate.name)} has no profile ${JSON.stringify(candidate.defaultProfile)}`);
|
|
14683
14712
|
const profile = profileName ? candidate.profiles?.[profileName] : undefined;
|
|
14684
14713
|
if (profileName && !profile)
|
|
14685
|
-
throw new
|
|
14714
|
+
throw new WorkspaceConfigError(`workspace ${JSON.stringify(candidate.name)} has no profile ${JSON.stringify(profileName)}`);
|
|
14686
14715
|
const profilePolicy = profile?.[key];
|
|
14687
14716
|
const workspacePolicy = candidate[key];
|
|
14688
14717
|
return {
|
|
@@ -14702,11 +14731,11 @@ function workspaceDefaultTarget(cwd, globalDefault) {
|
|
|
14702
14731
|
// packages/workit-core/src/core/vcs-config.ts
|
|
14703
14732
|
import fs12 from "node:fs";
|
|
14704
14733
|
import path14 from "node:path";
|
|
14705
|
-
import { spawnSync as
|
|
14734
|
+
import { spawnSync as spawnSync10 } from "node:child_process";
|
|
14706
14735
|
|
|
14707
14736
|
// packages/workit-core/src/core/release-tracks.ts
|
|
14708
14737
|
import { createHash as createHash9 } from "node:crypto";
|
|
14709
|
-
import { spawnSync as
|
|
14738
|
+
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
14710
14739
|
class ReleaseTrackError extends Error {
|
|
14711
14740
|
}
|
|
14712
14741
|
var KNOWN_FIELDS = new Set([
|
|
@@ -14991,7 +15020,7 @@ function resolveReleaseTrack(input) {
|
|
|
14991
15020
|
return fallback(`${branch} has the same or unrelated fork points with ${[...new Set(newest.map((fork) => `${fork.ref} (${fork.track.name === IMPLICIT ? "workspace default" : fork.track.name})`))].join(" and ")}`);
|
|
14992
15021
|
}
|
|
14993
15022
|
var git4 = (cwd, args) => {
|
|
14994
|
-
const run =
|
|
15023
|
+
const run = spawnSync9("git", args, {
|
|
14995
15024
|
cwd,
|
|
14996
15025
|
encoding: "utf8",
|
|
14997
15026
|
timeout: 20000,
|
|
@@ -15106,7 +15135,7 @@ function resolveTrackFor(cwd, options) {
|
|
|
15106
15135
|
var workspacesPath = () => path14.join(configDir(), "workspaces.json");
|
|
15107
15136
|
var vcsCwd = (cwd) => cwd ?? process.env.WORKFLOW_WORKSPACE_ROOT ?? process.cwd();
|
|
15108
15137
|
var remoteProvider = (cwd) => {
|
|
15109
|
-
const r =
|
|
15138
|
+
const r = spawnSync10("git", ["remote", "get-url", "origin"], { cwd, encoding: "utf8" });
|
|
15110
15139
|
if (r.status !== 0)
|
|
15111
15140
|
return null;
|
|
15112
15141
|
const url = (r.stdout ?? "").trim();
|
|
@@ -15143,7 +15172,7 @@ var remoteEndpoint = (remote) => {
|
|
|
15143
15172
|
var configuredSshEndpoint = (host) => {
|
|
15144
15173
|
if (host.startsWith("-"))
|
|
15145
15174
|
return null;
|
|
15146
|
-
const resolved =
|
|
15175
|
+
const resolved = spawnSync10("ssh", ["-G", host], {
|
|
15147
15176
|
encoding: "utf8",
|
|
15148
15177
|
timeout: 5000,
|
|
15149
15178
|
maxBuffer: 1024 * 1024,
|
|
@@ -15316,7 +15345,7 @@ function mergedPrStyle(limit = 6, cwd) {
|
|
|
15316
15345
|
`).filter((l) => l.startsWith("## ")).map((l) => l.trim()),
|
|
15317
15346
|
descriptionPreview: desc.slice(0, 600)
|
|
15318
15347
|
});
|
|
15319
|
-
const remoteResult =
|
|
15348
|
+
const remoteResult = spawnSync10("git", ["remote", "get-url", "--push", "--all", "origin"], {
|
|
15320
15349
|
cwd,
|
|
15321
15350
|
encoding: "utf8"
|
|
15322
15351
|
});
|
|
@@ -15332,7 +15361,7 @@ function mergedPrStyle(limit = 6, cwd) {
|
|
|
15332
15361
|
if (!hostingApiHostMatches(remote, host))
|
|
15333
15362
|
return { ok: false, error: "PR style target does not match the provider host" };
|
|
15334
15363
|
if (provider === "gitlab") {
|
|
15335
|
-
const run = (args) =>
|
|
15364
|
+
const run = (args) => spawnSync10("glab", ["api", ...args], {
|
|
15336
15365
|
cwd,
|
|
15337
15366
|
encoding: "utf8",
|
|
15338
15367
|
env
|
|
@@ -15352,7 +15381,7 @@ function mergedPrStyle(limit = 6, cwd) {
|
|
|
15352
15381
|
});
|
|
15353
15382
|
}
|
|
15354
15383
|
} else if (provider === "github") {
|
|
15355
|
-
const r =
|
|
15384
|
+
const r = spawnSync10("gh", [
|
|
15356
15385
|
"pr",
|
|
15357
15386
|
"list",
|
|
15358
15387
|
"--repo",
|
|
@@ -17423,7 +17452,7 @@ class WorkitCore {
|
|
|
17423
17452
|
}
|
|
17424
17453
|
}
|
|
17425
17454
|
// packages/workit-core/src/core/repo-context.ts
|
|
17426
|
-
import { spawnSync as
|
|
17455
|
+
import { spawnSync as spawnSync11 } from "node:child_process";
|
|
17427
17456
|
import { existsSync as existsSync6, readFileSync as readFileSync5, readdirSync as readdirSync4 } from "node:fs";
|
|
17428
17457
|
import path16 from "node:path";
|
|
17429
17458
|
var isSafeContextRange = (value) => value.length <= 4096 && (() => {
|
|
@@ -17452,7 +17481,7 @@ var invalidRange = (cwd) => ({
|
|
|
17452
17481
|
cwd
|
|
17453
17482
|
});
|
|
17454
17483
|
var runGit = (cwd, args) => {
|
|
17455
|
-
const result =
|
|
17484
|
+
const result = spawnSync11("git", args, { cwd, encoding: "utf8" });
|
|
17456
17485
|
return {
|
|
17457
17486
|
stdout: (result.stdout ?? "").trimEnd(),
|
|
17458
17487
|
stderr: (result.stderr ?? "").trimEnd(),
|
|
@@ -17893,12 +17922,12 @@ function releaseNotesContext(root, rangeOrTag) {
|
|
|
17893
17922
|
}
|
|
17894
17923
|
|
|
17895
17924
|
// packages/workit-core/src/core/tracker-issues.ts
|
|
17896
|
-
import { spawnSync as
|
|
17925
|
+
import { spawnSync as spawnSync13 } from "node:child_process";
|
|
17897
17926
|
|
|
17898
17927
|
// packages/workit-core/src/core/pr-create.ts
|
|
17899
17928
|
import fs13 from "node:fs";
|
|
17900
17929
|
import path17 from "node:path";
|
|
17901
|
-
import { spawnSync as
|
|
17930
|
+
import { spawnSync as spawnSync12 } from "node:child_process";
|
|
17902
17931
|
// packages/workit-core/src/forge/pr-body.ts
|
|
17903
17932
|
function parseGhIssue(value) {
|
|
17904
17933
|
const m = /issues\/(\d+)/.exec(value);
|
|
@@ -17923,7 +17952,7 @@ function whichOnPath(tool) {
|
|
|
17923
17952
|
}
|
|
17924
17953
|
var hostingCliAvailable = (provider) => whichOnPath(provider === "gitlab" ? "glab" : "gh") !== null;
|
|
17925
17954
|
var pushRemote = (cwd) => {
|
|
17926
|
-
const result =
|
|
17955
|
+
const result = spawnSync12("git", ["remote", "get-url", "--push", "--all", "origin"], {
|
|
17927
17956
|
cwd,
|
|
17928
17957
|
encoding: "utf8"
|
|
17929
17958
|
});
|
|
@@ -17954,7 +17983,7 @@ var defaultCli = (bin, available) => {
|
|
|
17954
17983
|
if (!available)
|
|
17955
17984
|
return null;
|
|
17956
17985
|
return (args, root) => {
|
|
17957
|
-
const out =
|
|
17986
|
+
const out = spawnSync13(bin, args, {
|
|
17958
17987
|
cwd: root,
|
|
17959
17988
|
encoding: "utf8",
|
|
17960
17989
|
env: { ...process.env, PATH: process.env.PATH ?? "" }
|
|
@@ -18530,7 +18559,7 @@ function resolveInside(root, candidate) {
|
|
|
18530
18559
|
}
|
|
18531
18560
|
function run2(root, executable, args, env = {}) {
|
|
18532
18561
|
const cwd = realpathSync5(root);
|
|
18533
|
-
const result =
|
|
18562
|
+
const result = spawnSync14(executable, args, {
|
|
18534
18563
|
cwd,
|
|
18535
18564
|
encoding: "utf8",
|
|
18536
18565
|
env: { ...process.env, ...env }
|
|
@@ -19151,7 +19180,7 @@ var ensureHygieneFiles = (root, opts) => {
|
|
|
19151
19180
|
// packages/workit-core/src/core/init.ts
|
|
19152
19181
|
import fs15 from "node:fs";
|
|
19153
19182
|
import path25 from "node:path";
|
|
19154
|
-
import { spawnSync as
|
|
19183
|
+
import { spawnSync as spawnSync15 } from "node:child_process";
|
|
19155
19184
|
|
|
19156
19185
|
// packages/workit-core/src/core/workspace-branch-policy.ts
|
|
19157
19186
|
import { mkdirSync as mkdirSync4, readFileSync as readFileSync8, renameSync as renameSync3, rmSync as rmSync2, writeFileSync as writeFileSync6 } from "node:fs";
|
|
@@ -19274,7 +19303,7 @@ var resolveInitProvider = (cwd) => {
|
|
|
19274
19303
|
return env.toLowerCase();
|
|
19275
19304
|
const root = cwd ?? process.env.WORKFLOW_WORKSPACE_ROOT ?? process.cwd();
|
|
19276
19305
|
try {
|
|
19277
|
-
const out =
|
|
19306
|
+
const out = spawnSync15("git", ["remote", "get-url", "origin"], {
|
|
19278
19307
|
cwd: root,
|
|
19279
19308
|
encoding: "utf8"
|
|
19280
19309
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brainervirus/workit-opencode",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Workit OpenCode plugin — native tools, adaptive policy, and sixteen method skills",
|
|
6
6
|
"keywords": [
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"typecheck": "tsc --noEmit"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@brainervirus/workit-core": "^8.1.
|
|
42
|
+
"@brainervirus/workit-core": "^8.1.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@opencode/plugin": "2.0.18"
|