@brainervirus/workit-codex 8.0.1 → 8.1.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/.codex-plugin/plugin.json +1 -1
- package/dist/launch-mcp.js +173 -103
- package/dist/workit-hook.js +91 -21
- package/package.json +3 -3
package/dist/launch-mcp.js
CHANGED
|
@@ -6625,7 +6625,7 @@ import { existsSync as existsSync9, realpathSync as realpathSync7, statSync as s
|
|
|
6625
6625
|
import path21 from "node:path";
|
|
6626
6626
|
|
|
6627
6627
|
// packages/workit-core/src/core.ts
|
|
6628
|
-
import { spawnSync as
|
|
6628
|
+
import { spawnSync as spawnSync13 } from "node:child_process";
|
|
6629
6629
|
import { existsSync as existsSync7, realpathSync as realpathSync5 } from "node:fs";
|
|
6630
6630
|
import path19 from "node:path";
|
|
6631
6631
|
|
|
@@ -20315,73 +20315,8 @@ var exportDigest = (bundle) => sha256({
|
|
|
20315
20315
|
sourceWorkspaceId: bundle.sourceWorkspaceId,
|
|
20316
20316
|
task: bundle.task
|
|
20317
20317
|
});
|
|
20318
|
-
// packages/workit-core/src/core/
|
|
20319
|
-
import {
|
|
20320
|
-
var run = (cwd, args) => {
|
|
20321
|
-
try {
|
|
20322
|
-
const stdout = execFileSync("git", args, {
|
|
20323
|
-
cwd,
|
|
20324
|
-
encoding: "utf8",
|
|
20325
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
20326
|
-
});
|
|
20327
|
-
return { stdout: stdout.trimEnd(), stderr: "", exitCode: 0 };
|
|
20328
|
-
} catch (error) {
|
|
20329
|
-
const e = error;
|
|
20330
|
-
return {
|
|
20331
|
-
stdout: (e.stdout ?? "").trimEnd(),
|
|
20332
|
-
stderr: (e.stderr ?? "").trimEnd(),
|
|
20333
|
-
exitCode: e.status ?? 1
|
|
20334
|
-
};
|
|
20335
|
-
}
|
|
20336
|
-
};
|
|
20337
|
-
var gitContext = (workspaceRoot, paths = []) => {
|
|
20338
|
-
const cwd = workspaceRoot;
|
|
20339
|
-
let failure;
|
|
20340
|
-
const runHere = (args) => {
|
|
20341
|
-
const result = run(cwd, args);
|
|
20342
|
-
if (!failure && result.exitCode !== 0) {
|
|
20343
|
-
failure = { stderr: result.stderr, exitCode: result.exitCode };
|
|
20344
|
-
}
|
|
20345
|
-
return result.stdout;
|
|
20346
|
-
};
|
|
20347
|
-
const branch = runHere(["rev-parse", "--abbrev-ref", "HEAD"]) || "unknown";
|
|
20348
|
-
const status_short = runHere(["status", "--porcelain"]);
|
|
20349
|
-
const staged = [];
|
|
20350
|
-
const unstaged = [];
|
|
20351
|
-
const untracked = [];
|
|
20352
|
-
for (const line of status_short.split(`
|
|
20353
|
-
`).filter(Boolean)) {
|
|
20354
|
-
const code = line.slice(0, 2);
|
|
20355
|
-
const file = line.slice(3);
|
|
20356
|
-
if (code === "??") {
|
|
20357
|
-
untracked.push(file);
|
|
20358
|
-
} else {
|
|
20359
|
-
if (code[0] !== " " && code[0] !== "?")
|
|
20360
|
-
staged.push(file);
|
|
20361
|
-
if (code[1] !== " " && code[1] !== "?")
|
|
20362
|
-
unstaged.push(file);
|
|
20363
|
-
}
|
|
20364
|
-
}
|
|
20365
|
-
const pathArgs = paths.length ? ["--", ...paths] : [];
|
|
20366
|
-
const diff_stat = runHere(["diff", "--stat", ...pathArgs]);
|
|
20367
|
-
const cached_stat = runHere(["diff", "--cached", "--stat", ...pathArgs]);
|
|
20368
|
-
const stagedSet = new Set(staged);
|
|
20369
|
-
const unstagedSet = new Set(unstaged);
|
|
20370
|
-
const partial_staged = [...stagedSet].filter((f) => unstagedSet.has(f));
|
|
20371
|
-
return {
|
|
20372
|
-
workspace_root: cwd,
|
|
20373
|
-
branch,
|
|
20374
|
-
status_short,
|
|
20375
|
-
staged,
|
|
20376
|
-
unstaged,
|
|
20377
|
-
untracked,
|
|
20378
|
-
diff_stat: [diff_stat, cached_stat].filter(Boolean).join(`
|
|
20379
|
-
`),
|
|
20380
|
-
partial_staged: partial_staged.length > 0,
|
|
20381
|
-
partial_staged_files: partial_staged,
|
|
20382
|
-
...failure ? { stderr: failure.stderr, exitCode: failure.exitCode } : {}
|
|
20383
|
-
};
|
|
20384
|
-
};
|
|
20318
|
+
// packages/workit-core/src/core/branch-policy.ts
|
|
20319
|
+
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
20385
20320
|
|
|
20386
20321
|
// packages/workit-core/src/core/config.ts
|
|
20387
20322
|
import {
|
|
@@ -20507,6 +20442,7 @@ var DEFAULTS = {
|
|
|
20507
20442
|
},
|
|
20508
20443
|
commitPolicy: { preset: "conventional" }
|
|
20509
20444
|
};
|
|
20445
|
+
var unchosenBranchPolicy = new WeakSet([DEFAULTS]);
|
|
20510
20446
|
var readSafe = (p) => {
|
|
20511
20447
|
try {
|
|
20512
20448
|
return readFileSync3(p, "utf8");
|
|
@@ -20531,22 +20467,21 @@ var parseConfigResult = (raw, file) => {
|
|
|
20531
20467
|
const locale = LOCALE_RE.test(String(input.locale ?? "")) ? input.locale : DEFAULTS.locale;
|
|
20532
20468
|
const preset = Object.hasOwn(PRESETS, input.branchPolicy?.preset) ? input.branchPolicy?.preset : "gitflow";
|
|
20533
20469
|
const commitPreset = COMMIT_PRESETS.includes(String(input.commitPolicy?.preset ?? "")) ? input.commitPolicy?.preset : "conventional";
|
|
20534
|
-
|
|
20535
|
-
|
|
20536
|
-
|
|
20537
|
-
|
|
20538
|
-
|
|
20539
|
-
|
|
20540
|
-
|
|
20541
|
-
|
|
20542
|
-
|
|
20543
|
-
}
|
|
20544
|
-
commitPolicy: {
|
|
20545
|
-
preset: commitPreset,
|
|
20546
|
-
...typeof input.commitPolicy?.pattern === "string" ? { pattern: input.commitPolicy.pattern } : {}
|
|
20547
|
-
}
|
|
20470
|
+
const config = {
|
|
20471
|
+
locale,
|
|
20472
|
+
localeOptions: Array.isArray(input.localeOptions) ? input.localeOptions : DEFAULTS.localeOptions,
|
|
20473
|
+
branchPolicy: mergePreset(preset, {
|
|
20474
|
+
allowed: Array.isArray(input.branchPolicy?.allowed) ? input.branchPolicy.allowed : undefined,
|
|
20475
|
+
protectedNames: Array.isArray(input.branchPolicy?.protected) ? input.branchPolicy.protected : undefined
|
|
20476
|
+
}, DEFAULTS),
|
|
20477
|
+
commitPolicy: {
|
|
20478
|
+
preset: commitPreset,
|
|
20479
|
+
...typeof input.commitPolicy?.pattern === "string" ? { pattern: input.commitPolicy.pattern } : {}
|
|
20548
20480
|
}
|
|
20549
20481
|
};
|
|
20482
|
+
if (!Object.hasOwn(PRESETS, input.branchPolicy?.preset))
|
|
20483
|
+
unchosenBranchPolicy.add(config);
|
|
20484
|
+
return { status: "valid", path: file, config };
|
|
20550
20485
|
};
|
|
20551
20486
|
var readConfigTyped = (dir) => {
|
|
20552
20487
|
const file = path12.join(dir ?? configDir(), "config.json");
|
|
@@ -20560,9 +20495,11 @@ var readConfig = () => {
|
|
|
20560
20495
|
};
|
|
20561
20496
|
var vcsConfigPath = () => process.env.WORKFLOW_VCS_CONFIG ?? path12.join(configDir(), "vcs.json");
|
|
20562
20497
|
var branchGlobPattern = (glob) => new RegExp(`^${glob.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*")}$`, "i");
|
|
20563
|
-
var resolveBranchPolicy = (config, workspace) => {
|
|
20498
|
+
var resolveBranchPolicy = (config, workspace, repoPreset) => {
|
|
20564
20499
|
const wp = workspace?.branchPolicy ?? {};
|
|
20565
|
-
const
|
|
20500
|
+
const workspacePreset = Object.hasOwn(PRESETS, wp.preset);
|
|
20501
|
+
const detected = !workspacePreset && unchosenBranchPolicy.has(config) ? repoPreset?.() ?? null : null;
|
|
20502
|
+
const preset = workspacePreset ? wp.preset : detected ?? config.branchPolicy?.preset ?? "gitflow";
|
|
20566
20503
|
const merged = mergePreset(preset, {
|
|
20567
20504
|
allowed: wp.allowed,
|
|
20568
20505
|
protectedNames: wp.protected
|
|
@@ -20571,9 +20508,10 @@ var resolveBranchPolicy = (config, workspace) => {
|
|
|
20571
20508
|
return {
|
|
20572
20509
|
preset,
|
|
20573
20510
|
allowed,
|
|
20574
|
-
protected: new Set(merged.protected.map((p) => p.toLowerCase())),
|
|
20511
|
+
protected: new Set([...merged.protected, ...detected ? PRESETS.gitflow.protected : []].map((p) => p.toLowerCase())),
|
|
20575
20512
|
integration: wp.integration === "merge" ? "merge" : "pr",
|
|
20576
|
-
defaultTargetBranch: preset === "github-flow" ? "main" : preset === "trunk-based" ? "master" : "develop"
|
|
20513
|
+
defaultTargetBranch: preset === "github-flow" ? "main" : preset === "trunk-based" ? "master" : "develop",
|
|
20514
|
+
detected: detected !== null
|
|
20577
20515
|
};
|
|
20578
20516
|
};
|
|
20579
20517
|
var COMMIT_PRESETS = [
|
|
@@ -20585,6 +20523,138 @@ var COMMIT_PRESETS = [
|
|
|
20585
20523
|
"auto"
|
|
20586
20524
|
];
|
|
20587
20525
|
|
|
20526
|
+
// packages/workit-core/src/core/branch-policy.ts
|
|
20527
|
+
var PREFIXES = {
|
|
20528
|
+
feature: "feature/*",
|
|
20529
|
+
bugfix: "bugfix/*",
|
|
20530
|
+
release: "release/*",
|
|
20531
|
+
hotfix: "hotfix/*"
|
|
20532
|
+
};
|
|
20533
|
+
var branchNames = (workspaceRoot) => {
|
|
20534
|
+
const r = spawnSync7("git", ["for-each-ref", "--format=%(refname)", "refs/heads", "refs/remotes/origin"], { cwd: workspaceRoot, encoding: "utf8" });
|
|
20535
|
+
if (r.status !== 0)
|
|
20536
|
+
return new Set;
|
|
20537
|
+
return new Set((r.stdout ?? "").split(`
|
|
20538
|
+
`).filter(Boolean).map((ref) => ref.startsWith("refs/heads/") ? ref.slice("refs/heads/".length) : ref.slice("refs/remotes/origin/".length)));
|
|
20539
|
+
};
|
|
20540
|
+
var detectBranchPolicy = (workspaceRoot) => {
|
|
20541
|
+
const names = branchNames(workspaceRoot);
|
|
20542
|
+
const develop = names.has("develop");
|
|
20543
|
+
const main = names.has("main");
|
|
20544
|
+
const master = names.has("master");
|
|
20545
|
+
const root = main ? "main" : master ? "master" : null;
|
|
20546
|
+
if (develop) {
|
|
20547
|
+
return {
|
|
20548
|
+
preset: "gitflow",
|
|
20549
|
+
developBranch: "develop",
|
|
20550
|
+
integration: "merge",
|
|
20551
|
+
protected: root ? [root, "develop"] : ["develop"],
|
|
20552
|
+
allowed: [...PRESETS.gitflow.allowed],
|
|
20553
|
+
prefixes: PREFIXES
|
|
20554
|
+
};
|
|
20555
|
+
}
|
|
20556
|
+
if (root === "main") {
|
|
20557
|
+
return {
|
|
20558
|
+
preset: "github-flow",
|
|
20559
|
+
developBranch: null,
|
|
20560
|
+
integration: "pr",
|
|
20561
|
+
protected: [root],
|
|
20562
|
+
allowed: ["*"],
|
|
20563
|
+
prefixes: PREFIXES
|
|
20564
|
+
};
|
|
20565
|
+
}
|
|
20566
|
+
if (root === "master") {
|
|
20567
|
+
return {
|
|
20568
|
+
preset: "trunk-based",
|
|
20569
|
+
developBranch: null,
|
|
20570
|
+
integration: "pr",
|
|
20571
|
+
protected: [root],
|
|
20572
|
+
allowed: ["*"],
|
|
20573
|
+
prefixes: PREFIXES
|
|
20574
|
+
};
|
|
20575
|
+
}
|
|
20576
|
+
return {
|
|
20577
|
+
preset: "gitflow",
|
|
20578
|
+
developBranch: null,
|
|
20579
|
+
integration: "merge",
|
|
20580
|
+
protected: [],
|
|
20581
|
+
allowed: [],
|
|
20582
|
+
prefixes: PREFIXES
|
|
20583
|
+
};
|
|
20584
|
+
};
|
|
20585
|
+
var repoBranchPreset = (workspaceRoot) => {
|
|
20586
|
+
const detected = detectBranchPolicy(workspaceRoot);
|
|
20587
|
+
return detected.developBranch || detected.allowed.length ? detected.preset : null;
|
|
20588
|
+
};
|
|
20589
|
+
|
|
20590
|
+
// packages/workit-core/src/core/git.ts
|
|
20591
|
+
import { execFileSync } from "node:child_process";
|
|
20592
|
+
var run = (cwd, args) => {
|
|
20593
|
+
try {
|
|
20594
|
+
const stdout = execFileSync("git", args, {
|
|
20595
|
+
cwd,
|
|
20596
|
+
encoding: "utf8",
|
|
20597
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
20598
|
+
});
|
|
20599
|
+
return { stdout: stdout.trimEnd(), stderr: "", exitCode: 0 };
|
|
20600
|
+
} catch (error) {
|
|
20601
|
+
const e = error;
|
|
20602
|
+
return {
|
|
20603
|
+
stdout: (e.stdout ?? "").trimEnd(),
|
|
20604
|
+
stderr: (e.stderr ?? "").trimEnd(),
|
|
20605
|
+
exitCode: e.status ?? 1
|
|
20606
|
+
};
|
|
20607
|
+
}
|
|
20608
|
+
};
|
|
20609
|
+
var gitContext = (workspaceRoot, paths = []) => {
|
|
20610
|
+
const cwd = workspaceRoot;
|
|
20611
|
+
let failure;
|
|
20612
|
+
const runHere = (args) => {
|
|
20613
|
+
const result = run(cwd, args);
|
|
20614
|
+
if (!failure && result.exitCode !== 0) {
|
|
20615
|
+
failure = { stderr: result.stderr, exitCode: result.exitCode };
|
|
20616
|
+
}
|
|
20617
|
+
return result.stdout;
|
|
20618
|
+
};
|
|
20619
|
+
const branch = runHere(["rev-parse", "--abbrev-ref", "HEAD"]) || "unknown";
|
|
20620
|
+
const status_short = runHere(["status", "--porcelain"]);
|
|
20621
|
+
const staged = [];
|
|
20622
|
+
const unstaged = [];
|
|
20623
|
+
const untracked = [];
|
|
20624
|
+
for (const line of status_short.split(`
|
|
20625
|
+
`).filter(Boolean)) {
|
|
20626
|
+
const code = line.slice(0, 2);
|
|
20627
|
+
const file = line.slice(3);
|
|
20628
|
+
if (code === "??") {
|
|
20629
|
+
untracked.push(file);
|
|
20630
|
+
} else {
|
|
20631
|
+
if (code[0] !== " " && code[0] !== "?")
|
|
20632
|
+
staged.push(file);
|
|
20633
|
+
if (code[1] !== " " && code[1] !== "?")
|
|
20634
|
+
unstaged.push(file);
|
|
20635
|
+
}
|
|
20636
|
+
}
|
|
20637
|
+
const pathArgs = paths.length ? ["--", ...paths] : [];
|
|
20638
|
+
const diff_stat = runHere(["diff", "--stat", ...pathArgs]);
|
|
20639
|
+
const cached_stat = runHere(["diff", "--cached", "--stat", ...pathArgs]);
|
|
20640
|
+
const stagedSet = new Set(staged);
|
|
20641
|
+
const unstagedSet = new Set(unstaged);
|
|
20642
|
+
const partial_staged = [...stagedSet].filter((f) => unstagedSet.has(f));
|
|
20643
|
+
return {
|
|
20644
|
+
workspace_root: cwd,
|
|
20645
|
+
branch,
|
|
20646
|
+
status_short,
|
|
20647
|
+
staged,
|
|
20648
|
+
unstaged,
|
|
20649
|
+
untracked,
|
|
20650
|
+
diff_stat: [diff_stat, cached_stat].filter(Boolean).join(`
|
|
20651
|
+
`),
|
|
20652
|
+
partial_staged: partial_staged.length > 0,
|
|
20653
|
+
partial_staged_files: partial_staged,
|
|
20654
|
+
...failure ? { stderr: failure.stderr, exitCode: failure.exitCode } : {}
|
|
20655
|
+
};
|
|
20656
|
+
};
|
|
20657
|
+
|
|
20588
20658
|
// packages/workit-core/src/core/workspaces.ts
|
|
20589
20659
|
import { createHash as createHash8 } from "node:crypto";
|
|
20590
20660
|
import { readFileSync as readFileSync4, realpathSync as realpathSync3 } from "node:fs";
|
|
@@ -20990,18 +21060,18 @@ function workspaceDefaultTarget(cwd, globalDefault) {
|
|
|
20990
21060
|
const wp = ws?.branchPolicy ?? {};
|
|
20991
21061
|
const hasWorkspacePolicy = typeof wp.preset === "string" && Object.hasOwn(PRESETS, wp.preset);
|
|
20992
21062
|
const selected = resolveRuntimeWorkspacePolicy(cwd, "branch", process.env.WORKFLOW_PROFILE?.trim() || undefined);
|
|
20993
|
-
const policyDefault = resolveBranchPolicy(readConfig(), selected.policy ? { branchPolicy: selected.policy } : null).defaultTargetBranch;
|
|
21063
|
+
const policyDefault = resolveBranchPolicy(readConfig(), selected.policy ? { branchPolicy: selected.policy } : null, () => repoBranchPreset(cwd)).defaultTargetBranch;
|
|
20994
21064
|
return String(ws?.vcs?.defaultTargetBranch ?? (hasWorkspacePolicy ? policyDefault : globalDefault ?? policyDefault) ?? "develop");
|
|
20995
21065
|
}
|
|
20996
21066
|
|
|
20997
21067
|
// packages/workit-core/src/core/vcs-config.ts
|
|
20998
21068
|
import fs12 from "node:fs";
|
|
20999
21069
|
import path14 from "node:path";
|
|
21000
|
-
import { spawnSync as
|
|
21070
|
+
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
21001
21071
|
|
|
21002
21072
|
// packages/workit-core/src/core/release-tracks.ts
|
|
21003
21073
|
import { createHash as createHash9 } from "node:crypto";
|
|
21004
|
-
import { spawnSync as
|
|
21074
|
+
import { spawnSync as spawnSync8 } from "node:child_process";
|
|
21005
21075
|
var KNOWN_FIELDS = new Set([
|
|
21006
21076
|
"strategy",
|
|
21007
21077
|
"productionBranch",
|
|
@@ -21273,7 +21343,7 @@ function resolveReleaseTrack(input) {
|
|
|
21273
21343
|
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 ")}`);
|
|
21274
21344
|
}
|
|
21275
21345
|
var git4 = (cwd, args) => {
|
|
21276
|
-
const run =
|
|
21346
|
+
const run = spawnSync8("git", args, {
|
|
21277
21347
|
cwd,
|
|
21278
21348
|
encoding: "utf8",
|
|
21279
21349
|
timeout: 20000,
|
|
@@ -21388,7 +21458,7 @@ function resolveTrackFor(cwd, options) {
|
|
|
21388
21458
|
var workspacesPath = () => path14.join(configDir(), "workspaces.json");
|
|
21389
21459
|
var vcsCwd = (cwd) => cwd ?? process.env.WORKFLOW_WORKSPACE_ROOT ?? process.cwd();
|
|
21390
21460
|
var remoteProvider = (cwd) => {
|
|
21391
|
-
const r =
|
|
21461
|
+
const r = spawnSync9("git", ["remote", "get-url", "origin"], { cwd, encoding: "utf8" });
|
|
21392
21462
|
if (r.status !== 0)
|
|
21393
21463
|
return null;
|
|
21394
21464
|
const url = (r.stdout ?? "").trim();
|
|
@@ -21425,7 +21495,7 @@ var remoteEndpoint = (remote) => {
|
|
|
21425
21495
|
var configuredSshEndpoint = (host) => {
|
|
21426
21496
|
if (host.startsWith("-"))
|
|
21427
21497
|
return null;
|
|
21428
|
-
const resolved =
|
|
21498
|
+
const resolved = spawnSync9("ssh", ["-G", host], {
|
|
21429
21499
|
encoding: "utf8",
|
|
21430
21500
|
timeout: 5000,
|
|
21431
21501
|
maxBuffer: 1024 * 1024,
|
|
@@ -21598,7 +21668,7 @@ function mergedPrStyle(limit = 6, cwd) {
|
|
|
21598
21668
|
`).filter((l) => l.startsWith("## ")).map((l) => l.trim()),
|
|
21599
21669
|
descriptionPreview: desc.slice(0, 600)
|
|
21600
21670
|
});
|
|
21601
|
-
const remoteResult =
|
|
21671
|
+
const remoteResult = spawnSync9("git", ["remote", "get-url", "--push", "--all", "origin"], {
|
|
21602
21672
|
cwd,
|
|
21603
21673
|
encoding: "utf8"
|
|
21604
21674
|
});
|
|
@@ -21614,7 +21684,7 @@ function mergedPrStyle(limit = 6, cwd) {
|
|
|
21614
21684
|
if (!hostingApiHostMatches(remote, host))
|
|
21615
21685
|
return { ok: false, error: "PR style target does not match the provider host" };
|
|
21616
21686
|
if (provider === "gitlab") {
|
|
21617
|
-
const run = (args) =>
|
|
21687
|
+
const run = (args) => spawnSync9("glab", ["api", ...args], {
|
|
21618
21688
|
cwd,
|
|
21619
21689
|
encoding: "utf8",
|
|
21620
21690
|
env
|
|
@@ -21634,7 +21704,7 @@ function mergedPrStyle(limit = 6, cwd) {
|
|
|
21634
21704
|
});
|
|
21635
21705
|
}
|
|
21636
21706
|
} else if (provider === "github") {
|
|
21637
|
-
const r =
|
|
21707
|
+
const r = spawnSync9("gh", [
|
|
21638
21708
|
"pr",
|
|
21639
21709
|
"list",
|
|
21640
21710
|
"--repo",
|
|
@@ -23571,7 +23641,7 @@ class WorkitCore {
|
|
|
23571
23641
|
}
|
|
23572
23642
|
}
|
|
23573
23643
|
// packages/workit-core/src/core/repo-context.ts
|
|
23574
|
-
import { spawnSync as
|
|
23644
|
+
import { spawnSync as spawnSync10 } from "node:child_process";
|
|
23575
23645
|
import { existsSync as existsSync6, readFileSync as readFileSync5, readdirSync as readdirSync4 } from "node:fs";
|
|
23576
23646
|
import path16 from "node:path";
|
|
23577
23647
|
var isSafeContextRange = (value) => value.length <= 4096 && (() => {
|
|
@@ -23600,7 +23670,7 @@ var invalidRange = (cwd) => ({
|
|
|
23600
23670
|
cwd
|
|
23601
23671
|
});
|
|
23602
23672
|
var runGit = (cwd, args) => {
|
|
23603
|
-
const result =
|
|
23673
|
+
const result = spawnSync10("git", args, { cwd, encoding: "utf8" });
|
|
23604
23674
|
return {
|
|
23605
23675
|
stdout: (result.stdout ?? "").trimEnd(),
|
|
23606
23676
|
stderr: (result.stderr ?? "").trimEnd(),
|
|
@@ -24041,12 +24111,12 @@ function releaseNotesContext(root, rangeOrTag) {
|
|
|
24041
24111
|
}
|
|
24042
24112
|
|
|
24043
24113
|
// packages/workit-core/src/core/tracker-issues.ts
|
|
24044
|
-
import { spawnSync as
|
|
24114
|
+
import { spawnSync as spawnSync12 } from "node:child_process";
|
|
24045
24115
|
|
|
24046
24116
|
// packages/workit-core/src/core/pr-create.ts
|
|
24047
24117
|
import fs13 from "node:fs";
|
|
24048
24118
|
import path17 from "node:path";
|
|
24049
|
-
import { spawnSync as
|
|
24119
|
+
import { spawnSync as spawnSync11 } from "node:child_process";
|
|
24050
24120
|
// packages/workit-core/src/forge/pr-body.ts
|
|
24051
24121
|
function parseGhIssue(value) {
|
|
24052
24122
|
const m = /issues\/(\d+)/.exec(value);
|
|
@@ -24071,7 +24141,7 @@ function whichOnPath(tool) {
|
|
|
24071
24141
|
}
|
|
24072
24142
|
var hostingCliAvailable = (provider) => whichOnPath(provider === "gitlab" ? "glab" : "gh") !== null;
|
|
24073
24143
|
var pushRemote = (cwd) => {
|
|
24074
|
-
const result =
|
|
24144
|
+
const result = spawnSync11("git", ["remote", "get-url", "--push", "--all", "origin"], {
|
|
24075
24145
|
cwd,
|
|
24076
24146
|
encoding: "utf8"
|
|
24077
24147
|
});
|
|
@@ -24102,7 +24172,7 @@ var defaultCli = (bin, available) => {
|
|
|
24102
24172
|
if (!available)
|
|
24103
24173
|
return null;
|
|
24104
24174
|
return (args, root) => {
|
|
24105
|
-
const out =
|
|
24175
|
+
const out = spawnSync12(bin, args, {
|
|
24106
24176
|
cwd: root,
|
|
24107
24177
|
encoding: "utf8",
|
|
24108
24178
|
env: { ...process.env, PATH: process.env.PATH ?? "" }
|
|
@@ -24620,7 +24690,7 @@ function resolveInside(root, candidate) {
|
|
|
24620
24690
|
}
|
|
24621
24691
|
function run2(root, executable, args, env = {}) {
|
|
24622
24692
|
const cwd = realpathSync5(root);
|
|
24623
|
-
const result =
|
|
24693
|
+
const result = spawnSync13(executable, args, {
|
|
24624
24694
|
cwd,
|
|
24625
24695
|
encoding: "utf8",
|
|
24626
24696
|
env: { ...process.env, ...env }
|
|
@@ -27404,7 +27474,7 @@ var signals = new Map;
|
|
|
27404
27474
|
var cache = new Map;
|
|
27405
27475
|
// packages/workit-core/src/hooks/write-gate.ts
|
|
27406
27476
|
var CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "win32";
|
|
27407
|
-
var
|
|
27477
|
+
var PREFIXES2 = new Set(["sudo", "command", "env", "nohup", "time", "exec", "xargs"]);
|
|
27408
27478
|
var cache2 = new Map;
|
|
27409
27479
|
// packages/workit-core/src/hooks/hosts/fields.ts
|
|
27410
27480
|
var SHELLS = new Set(["sh", "bash", "zsh", "dash", "pwsh", "powershell", "cmd"]);
|
package/dist/workit-hook.js
CHANGED
|
@@ -13822,6 +13822,7 @@ var DEFAULTS = {
|
|
|
13822
13822
|
},
|
|
13823
13823
|
commitPolicy: { preset: "conventional" }
|
|
13824
13824
|
};
|
|
13825
|
+
var unchosenBranchPolicy = new WeakSet([DEFAULTS]);
|
|
13825
13826
|
var readSafe = (p) => {
|
|
13826
13827
|
try {
|
|
13827
13828
|
return readFileSync3(p, "utf8");
|
|
@@ -13846,22 +13847,21 @@ var parseConfigResult = (raw, file) => {
|
|
|
13846
13847
|
const locale = LOCALE_RE.test(String(input.locale ?? "")) ? input.locale : DEFAULTS.locale;
|
|
13847
13848
|
const preset = Object.hasOwn(PRESETS, input.branchPolicy?.preset) ? input.branchPolicy?.preset : "gitflow";
|
|
13848
13849
|
const commitPreset = COMMIT_PRESETS.includes(String(input.commitPolicy?.preset ?? "")) ? input.commitPolicy?.preset : "conventional";
|
|
13849
|
-
|
|
13850
|
-
|
|
13851
|
-
|
|
13852
|
-
|
|
13853
|
-
|
|
13854
|
-
|
|
13855
|
-
|
|
13856
|
-
|
|
13857
|
-
|
|
13858
|
-
}
|
|
13859
|
-
commitPolicy: {
|
|
13860
|
-
preset: commitPreset,
|
|
13861
|
-
...typeof input.commitPolicy?.pattern === "string" ? { pattern: input.commitPolicy.pattern } : {}
|
|
13862
|
-
}
|
|
13850
|
+
const config = {
|
|
13851
|
+
locale,
|
|
13852
|
+
localeOptions: Array.isArray(input.localeOptions) ? input.localeOptions : DEFAULTS.localeOptions,
|
|
13853
|
+
branchPolicy: mergePreset(preset, {
|
|
13854
|
+
allowed: Array.isArray(input.branchPolicy?.allowed) ? input.branchPolicy.allowed : undefined,
|
|
13855
|
+
protectedNames: Array.isArray(input.branchPolicy?.protected) ? input.branchPolicy.protected : undefined
|
|
13856
|
+
}, DEFAULTS),
|
|
13857
|
+
commitPolicy: {
|
|
13858
|
+
preset: commitPreset,
|
|
13859
|
+
...typeof input.commitPolicy?.pattern === "string" ? { pattern: input.commitPolicy.pattern } : {}
|
|
13863
13860
|
}
|
|
13864
13861
|
};
|
|
13862
|
+
if (!Object.hasOwn(PRESETS, input.branchPolicy?.preset))
|
|
13863
|
+
unchosenBranchPolicy.add(config);
|
|
13864
|
+
return { status: "valid", path: file, config };
|
|
13865
13865
|
};
|
|
13866
13866
|
var readConfigTyped = (dir) => {
|
|
13867
13867
|
const file = path12.join(dir ?? configDir(), "config.json");
|
|
@@ -13874,9 +13874,11 @@ var readConfig = () => {
|
|
|
13874
13874
|
return result.config ?? DEFAULTS;
|
|
13875
13875
|
};
|
|
13876
13876
|
var branchGlobPattern = (glob) => new RegExp(`^${glob.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*")}$`, "i");
|
|
13877
|
-
var resolveBranchPolicy = (config, workspace) => {
|
|
13877
|
+
var resolveBranchPolicy = (config, workspace, repoPreset) => {
|
|
13878
13878
|
const wp = workspace?.branchPolicy ?? {};
|
|
13879
|
-
const
|
|
13879
|
+
const workspacePreset = Object.hasOwn(PRESETS, wp.preset);
|
|
13880
|
+
const detected = !workspacePreset && unchosenBranchPolicy.has(config) ? repoPreset?.() ?? null : null;
|
|
13881
|
+
const preset = workspacePreset ? wp.preset : detected ?? config.branchPolicy?.preset ?? "gitflow";
|
|
13880
13882
|
const merged = mergePreset(preset, {
|
|
13881
13883
|
allowed: wp.allowed,
|
|
13882
13884
|
protectedNames: wp.protected
|
|
@@ -13885,9 +13887,10 @@ var resolveBranchPolicy = (config, workspace) => {
|
|
|
13885
13887
|
return {
|
|
13886
13888
|
preset,
|
|
13887
13889
|
allowed,
|
|
13888
|
-
protected: new Set(merged.protected.map((p) => p.toLowerCase())),
|
|
13890
|
+
protected: new Set([...merged.protected, ...detected ? PRESETS.gitflow.protected : []].map((p) => p.toLowerCase())),
|
|
13889
13891
|
integration: wp.integration === "merge" ? "merge" : "pr",
|
|
13890
|
-
defaultTargetBranch: preset === "github-flow" ? "main" : preset === "trunk-based" ? "master" : "develop"
|
|
13892
|
+
defaultTargetBranch: preset === "github-flow" ? "main" : preset === "trunk-based" ? "master" : "develop",
|
|
13893
|
+
detected: detected !== null
|
|
13891
13894
|
};
|
|
13892
13895
|
};
|
|
13893
13896
|
var COMMIT_PRESETS = [
|
|
@@ -13913,6 +13916,73 @@ var resolveCommitPolicy = (config, workspace) => {
|
|
|
13913
13916
|
import { createHash as createHash8 } from "node:crypto";
|
|
13914
13917
|
import { readFileSync as readFileSync4, realpathSync as realpathSync3 } from "node:fs";
|
|
13915
13918
|
import path13 from "node:path";
|
|
13919
|
+
|
|
13920
|
+
// packages/workit-core/src/core/branch-policy.ts
|
|
13921
|
+
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
13922
|
+
var PREFIXES = {
|
|
13923
|
+
feature: "feature/*",
|
|
13924
|
+
bugfix: "bugfix/*",
|
|
13925
|
+
release: "release/*",
|
|
13926
|
+
hotfix: "hotfix/*"
|
|
13927
|
+
};
|
|
13928
|
+
var branchNames = (workspaceRoot) => {
|
|
13929
|
+
const r = spawnSync7("git", ["for-each-ref", "--format=%(refname)", "refs/heads", "refs/remotes/origin"], { cwd: workspaceRoot, encoding: "utf8" });
|
|
13930
|
+
if (r.status !== 0)
|
|
13931
|
+
return new Set;
|
|
13932
|
+
return new Set((r.stdout ?? "").split(`
|
|
13933
|
+
`).filter(Boolean).map((ref) => ref.startsWith("refs/heads/") ? ref.slice("refs/heads/".length) : ref.slice("refs/remotes/origin/".length)));
|
|
13934
|
+
};
|
|
13935
|
+
var detectBranchPolicy = (workspaceRoot) => {
|
|
13936
|
+
const names = branchNames(workspaceRoot);
|
|
13937
|
+
const develop = names.has("develop");
|
|
13938
|
+
const main = names.has("main");
|
|
13939
|
+
const master = names.has("master");
|
|
13940
|
+
const root = main ? "main" : master ? "master" : null;
|
|
13941
|
+
if (develop) {
|
|
13942
|
+
return {
|
|
13943
|
+
preset: "gitflow",
|
|
13944
|
+
developBranch: "develop",
|
|
13945
|
+
integration: "merge",
|
|
13946
|
+
protected: root ? [root, "develop"] : ["develop"],
|
|
13947
|
+
allowed: [...PRESETS.gitflow.allowed],
|
|
13948
|
+
prefixes: PREFIXES
|
|
13949
|
+
};
|
|
13950
|
+
}
|
|
13951
|
+
if (root === "main") {
|
|
13952
|
+
return {
|
|
13953
|
+
preset: "github-flow",
|
|
13954
|
+
developBranch: null,
|
|
13955
|
+
integration: "pr",
|
|
13956
|
+
protected: [root],
|
|
13957
|
+
allowed: ["*"],
|
|
13958
|
+
prefixes: PREFIXES
|
|
13959
|
+
};
|
|
13960
|
+
}
|
|
13961
|
+
if (root === "master") {
|
|
13962
|
+
return {
|
|
13963
|
+
preset: "trunk-based",
|
|
13964
|
+
developBranch: null,
|
|
13965
|
+
integration: "pr",
|
|
13966
|
+
protected: [root],
|
|
13967
|
+
allowed: ["*"],
|
|
13968
|
+
prefixes: PREFIXES
|
|
13969
|
+
};
|
|
13970
|
+
}
|
|
13971
|
+
return {
|
|
13972
|
+
preset: "gitflow",
|
|
13973
|
+
developBranch: null,
|
|
13974
|
+
integration: "merge",
|
|
13975
|
+
protected: [],
|
|
13976
|
+
allowed: [],
|
|
13977
|
+
prefixes: PREFIXES
|
|
13978
|
+
};
|
|
13979
|
+
};
|
|
13980
|
+
var repoBranchPreset = (workspaceRoot) => {
|
|
13981
|
+
const detected = detectBranchPolicy(workspaceRoot);
|
|
13982
|
+
return detected.developBranch || detected.allowed.length ? detected.preset : null;
|
|
13983
|
+
};
|
|
13984
|
+
|
|
13985
|
+
// packages/workit-core/src/core/workspaces.ts
|
|
13916
13986
|
var nonBlank = string2().refine((value) => value.trim().length > 0, "must not be blank");
|
|
13917
13987
|
var branchPreset = custom((value) => typeof value === "string" && Object.hasOwn(PRESETS, value), "unsupported branch preset");
|
|
13918
13988
|
var commitPreset = custom((value) => typeof value === "string" && COMMIT_PRESETS.includes(value), "unsupported commit preset");
|
|
@@ -16468,7 +16538,7 @@ function effectiveWorkspacePolicy(workspaceRoot, kind, profileName) {
|
|
|
16468
16538
|
const selected = resolveRuntimeWorkspacePolicy(workspaceRoot, kind, profileName?.trim() || process.env.WORKFLOW_PROFILE?.trim() || undefined);
|
|
16469
16539
|
const config = readConfig();
|
|
16470
16540
|
return kind === "branch" ? {
|
|
16471
|
-
branchPolicy: withReleaseTracks(workspaceRoot, resolveBranchPolicy(config, selected.policy ? { branchPolicy: selected.policy } : null)),
|
|
16541
|
+
branchPolicy: withReleaseTracks(workspaceRoot, resolveBranchPolicy(config, selected.policy ? { branchPolicy: selected.policy } : null, () => repoBranchPreset(workspaceRoot))),
|
|
16472
16542
|
provenance: { branchPolicy: selected.source }
|
|
16473
16543
|
} : {
|
|
16474
16544
|
commitPolicy: resolveCommitPolicy(config, selected.policy ? { commitPolicy: selected.policy } : null),
|
|
@@ -16665,11 +16735,11 @@ var segmentsOf = (command) => {
|
|
|
16665
16735
|
flushSegment();
|
|
16666
16736
|
return segments;
|
|
16667
16737
|
};
|
|
16668
|
-
var
|
|
16738
|
+
var PREFIXES2 = new Set(["sudo", "command", "env", "nohup", "time", "exec", "xargs"]);
|
|
16669
16739
|
var operands = (words) => words.filter((item) => !item.startsWith("-"));
|
|
16670
16740
|
var editsOf = (input) => {
|
|
16671
16741
|
let words = input;
|
|
16672
|
-
while (words.length && (
|
|
16742
|
+
while (words.length && (PREFIXES2.has(words[0]) || /^\w+=/.test(words[0])))
|
|
16673
16743
|
words = words.slice(1);
|
|
16674
16744
|
const [verb, ...args] = words;
|
|
16675
16745
|
const name = (verb?.split(/[\\/]/).at(-1) ?? "").toLowerCase();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brainervirus/workit-codex",
|
|
3
|
-
"version": "8.0
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Workit Codex CLI/desktop plugin — shared MCP transport, hooks, and sixteen method skills",
|
|
6
6
|
"keywords": [
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"build": "bun scripts/build.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@brainervirus/workit-core": "^8.0
|
|
42
|
-
"@brainervirus/workit-mcp": "^8.0
|
|
41
|
+
"@brainervirus/workit-core": "^8.1.0",
|
|
42
|
+
"@brainervirus/workit-mcp": "^8.1.0"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|
|
45
45
|
"node": ">=24"
|