@brainervirus/workit-cursor 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/.cursor-plugin/plugin.json +1 -1
- package/dist/cursor-session-start.js +102 -31
- package/dist/mcp-server.js +173 -103
- package/dist/workit-hook.js +99 -29
- package/package.json +3 -3
|
@@ -10041,7 +10041,7 @@ var diagnosticLogger, PRESETS, mergePreset = (preset, input = {}, current = {
|
|
|
10041
10041
|
if (!migrationFailed)
|
|
10042
10042
|
migratedDir = dir;
|
|
10043
10043
|
return dir;
|
|
10044
|
-
}, configDir = () => ensureConfigDir(), LOCALE_RE, DEFAULTS, readSafe = (p) => {
|
|
10044
|
+
}, configDir = () => ensureConfigDir(), LOCALE_RE, DEFAULTS, unchosenBranchPolicy, readSafe = (p) => {
|
|
10045
10045
|
try {
|
|
10046
10046
|
return readFileSync(p, "utf8");
|
|
10047
10047
|
} catch {
|
|
@@ -10063,22 +10063,21 @@ var diagnosticLogger, PRESETS, mergePreset = (preset, input = {}, current = {
|
|
|
10063
10063
|
const locale = LOCALE_RE.test(String(input.locale ?? "")) ? input.locale : DEFAULTS.locale;
|
|
10064
10064
|
const preset = Object.hasOwn(PRESETS, input.branchPolicy?.preset) ? input.branchPolicy?.preset : "gitflow";
|
|
10065
10065
|
const commitPreset = COMMIT_PRESETS.includes(String(input.commitPolicy?.preset ?? "")) ? input.commitPolicy?.preset : "conventional";
|
|
10066
|
-
|
|
10067
|
-
|
|
10068
|
-
|
|
10069
|
-
|
|
10070
|
-
|
|
10071
|
-
|
|
10072
|
-
|
|
10073
|
-
|
|
10074
|
-
|
|
10075
|
-
}
|
|
10076
|
-
commitPolicy: {
|
|
10077
|
-
preset: commitPreset,
|
|
10078
|
-
...typeof input.commitPolicy?.pattern === "string" ? { pattern: input.commitPolicy.pattern } : {}
|
|
10079
|
-
}
|
|
10066
|
+
const config = {
|
|
10067
|
+
locale,
|
|
10068
|
+
localeOptions: Array.isArray(input.localeOptions) ? input.localeOptions : DEFAULTS.localeOptions,
|
|
10069
|
+
branchPolicy: mergePreset(preset, {
|
|
10070
|
+
allowed: Array.isArray(input.branchPolicy?.allowed) ? input.branchPolicy.allowed : undefined,
|
|
10071
|
+
protectedNames: Array.isArray(input.branchPolicy?.protected) ? input.branchPolicy.protected : undefined
|
|
10072
|
+
}, DEFAULTS),
|
|
10073
|
+
commitPolicy: {
|
|
10074
|
+
preset: commitPreset,
|
|
10075
|
+
...typeof input.commitPolicy?.pattern === "string" ? { pattern: input.commitPolicy.pattern } : {}
|
|
10080
10076
|
}
|
|
10081
10077
|
};
|
|
10078
|
+
if (!Object.hasOwn(PRESETS, input.branchPolicy?.preset))
|
|
10079
|
+
unchosenBranchPolicy.add(config);
|
|
10080
|
+
return { status: "valid", path: file, config };
|
|
10082
10081
|
}, readConfigTyped = (dir) => {
|
|
10083
10082
|
const file = path5.join(dir ?? configDir(), "config.json");
|
|
10084
10083
|
return parseConfigResult(readSafe(file), file);
|
|
@@ -10087,9 +10086,11 @@ var diagnosticLogger, PRESETS, mergePreset = (preset, input = {}, current = {
|
|
|
10087
10086
|
if (result.status === "malformed")
|
|
10088
10087
|
throw new Error(result.error);
|
|
10089
10088
|
return result.config ?? DEFAULTS;
|
|
10090
|
-
}, branchGlobPattern = (glob) => new RegExp(`^${glob.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*")}$`, "i"), resolveBranchPolicy = (config, workspace) => {
|
|
10089
|
+
}, branchGlobPattern = (glob) => new RegExp(`^${glob.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*")}$`, "i"), resolveBranchPolicy = (config, workspace, repoPreset) => {
|
|
10091
10090
|
const wp = workspace?.branchPolicy ?? {};
|
|
10092
|
-
const
|
|
10091
|
+
const workspacePreset = Object.hasOwn(PRESETS, wp.preset);
|
|
10092
|
+
const detected = !workspacePreset && unchosenBranchPolicy.has(config) ? repoPreset?.() ?? null : null;
|
|
10093
|
+
const preset = workspacePreset ? wp.preset : detected ?? config.branchPolicy?.preset ?? "gitflow";
|
|
10093
10094
|
const merged = mergePreset(preset, {
|
|
10094
10095
|
allowed: wp.allowed,
|
|
10095
10096
|
protectedNames: wp.protected
|
|
@@ -10098,9 +10099,10 @@ var diagnosticLogger, PRESETS, mergePreset = (preset, input = {}, current = {
|
|
|
10098
10099
|
return {
|
|
10099
10100
|
preset,
|
|
10100
10101
|
allowed,
|
|
10101
|
-
protected: new Set(merged.protected.map((p) => p.toLowerCase())),
|
|
10102
|
+
protected: new Set([...merged.protected, ...detected ? PRESETS.gitflow.protected : []].map((p) => p.toLowerCase())),
|
|
10102
10103
|
integration: wp.integration === "merge" ? "merge" : "pr",
|
|
10103
|
-
defaultTargetBranch: preset === "github-flow" ? "main" : preset === "trunk-based" ? "master" : "develop"
|
|
10104
|
+
defaultTargetBranch: preset === "github-flow" ? "main" : preset === "trunk-based" ? "master" : "develop",
|
|
10105
|
+
detected: detected !== null
|
|
10104
10106
|
};
|
|
10105
10107
|
}, COMMIT_PRESETS, resolveCommitPolicy = (config, workspace) => {
|
|
10106
10108
|
const wp = workspace?.commitPolicy ?? {};
|
|
@@ -10134,6 +10136,7 @@ var init_config = __esm(() => {
|
|
|
10134
10136
|
},
|
|
10135
10137
|
commitPolicy: { preset: "conventional" }
|
|
10136
10138
|
};
|
|
10139
|
+
unchosenBranchPolicy = new WeakSet([DEFAULTS]);
|
|
10137
10140
|
COMMIT_PRESETS = [
|
|
10138
10141
|
"conventional",
|
|
10139
10142
|
"gitmoji",
|
|
@@ -10147,6 +10150,72 @@ var init_config = __esm(() => {
|
|
|
10147
10150
|
// packages/workit-core/src/core/safe-write.ts
|
|
10148
10151
|
var init_safe_write = () => {};
|
|
10149
10152
|
|
|
10153
|
+
// packages/workit-core/src/core/branch-policy.ts
|
|
10154
|
+
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
10155
|
+
var PREFIXES, branchNames = (workspaceRoot) => {
|
|
10156
|
+
const r = spawnSync4("git", ["for-each-ref", "--format=%(refname)", "refs/heads", "refs/remotes/origin"], { cwd: workspaceRoot, encoding: "utf8" });
|
|
10157
|
+
if (r.status !== 0)
|
|
10158
|
+
return new Set;
|
|
10159
|
+
return new Set((r.stdout ?? "").split(`
|
|
10160
|
+
`).filter(Boolean).map((ref) => ref.startsWith("refs/heads/") ? ref.slice("refs/heads/".length) : ref.slice("refs/remotes/origin/".length)));
|
|
10161
|
+
}, detectBranchPolicy = (workspaceRoot) => {
|
|
10162
|
+
const names = branchNames(workspaceRoot);
|
|
10163
|
+
const develop = names.has("develop");
|
|
10164
|
+
const main = names.has("main");
|
|
10165
|
+
const master = names.has("master");
|
|
10166
|
+
const root = main ? "main" : master ? "master" : null;
|
|
10167
|
+
if (develop) {
|
|
10168
|
+
return {
|
|
10169
|
+
preset: "gitflow",
|
|
10170
|
+
developBranch: "develop",
|
|
10171
|
+
integration: "merge",
|
|
10172
|
+
protected: root ? [root, "develop"] : ["develop"],
|
|
10173
|
+
allowed: [...PRESETS.gitflow.allowed],
|
|
10174
|
+
prefixes: PREFIXES
|
|
10175
|
+
};
|
|
10176
|
+
}
|
|
10177
|
+
if (root === "main") {
|
|
10178
|
+
return {
|
|
10179
|
+
preset: "github-flow",
|
|
10180
|
+
developBranch: null,
|
|
10181
|
+
integration: "pr",
|
|
10182
|
+
protected: [root],
|
|
10183
|
+
allowed: ["*"],
|
|
10184
|
+
prefixes: PREFIXES
|
|
10185
|
+
};
|
|
10186
|
+
}
|
|
10187
|
+
if (root === "master") {
|
|
10188
|
+
return {
|
|
10189
|
+
preset: "trunk-based",
|
|
10190
|
+
developBranch: null,
|
|
10191
|
+
integration: "pr",
|
|
10192
|
+
protected: [root],
|
|
10193
|
+
allowed: ["*"],
|
|
10194
|
+
prefixes: PREFIXES
|
|
10195
|
+
};
|
|
10196
|
+
}
|
|
10197
|
+
return {
|
|
10198
|
+
preset: "gitflow",
|
|
10199
|
+
developBranch: null,
|
|
10200
|
+
integration: "merge",
|
|
10201
|
+
protected: [],
|
|
10202
|
+
allowed: [],
|
|
10203
|
+
prefixes: PREFIXES
|
|
10204
|
+
};
|
|
10205
|
+
}, repoBranchPreset = (workspaceRoot) => {
|
|
10206
|
+
const detected = detectBranchPolicy(workspaceRoot);
|
|
10207
|
+
return detected.developBranch || detected.allowed.length ? detected.preset : null;
|
|
10208
|
+
};
|
|
10209
|
+
var init_branch_policy = __esm(() => {
|
|
10210
|
+
init_config();
|
|
10211
|
+
PREFIXES = {
|
|
10212
|
+
feature: "feature/*",
|
|
10213
|
+
bugfix: "bugfix/*",
|
|
10214
|
+
release: "release/*",
|
|
10215
|
+
hotfix: "hotfix/*"
|
|
10216
|
+
};
|
|
10217
|
+
});
|
|
10218
|
+
|
|
10150
10219
|
// packages/workit-core/src/core/workspaces.ts
|
|
10151
10220
|
import { createHash as createHash5 } from "node:crypto";
|
|
10152
10221
|
import { readFileSync as readFileSync2, realpathSync } from "node:fs";
|
|
@@ -10411,6 +10480,7 @@ var nonBlank, branchPreset, commitPreset, workspaceBranchPolicySchema, workspace
|
|
|
10411
10480
|
var init_workspaces = __esm(() => {
|
|
10412
10481
|
init_zod();
|
|
10413
10482
|
init_config();
|
|
10483
|
+
init_branch_policy();
|
|
10414
10484
|
nonBlank = string2().refine((value) => value.trim().length > 0, "must not be blank");
|
|
10415
10485
|
branchPreset = custom((value) => typeof value === "string" && Object.hasOwn(PRESETS, value), "unsupported branch preset");
|
|
10416
10486
|
commitPreset = custom((value) => typeof value === "string" && COMMIT_PRESETS.includes(value), "unsupported commit preset");
|
|
@@ -11308,7 +11378,7 @@ var packageRoot = () => {
|
|
|
11308
11378
|
var init_package_root = () => {};
|
|
11309
11379
|
|
|
11310
11380
|
// packages/workit-core/src/core/store-lock.ts
|
|
11311
|
-
import { spawnSync as
|
|
11381
|
+
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
11312
11382
|
import fs7 from "node:fs";
|
|
11313
11383
|
import { hostname } from "node:os";
|
|
11314
11384
|
var metadataLockSchema, FOREIGN_LOCK_TTL_MS, UNREADABLE_LOCK_TTL_MS = 30000, RECLAIM_GUARD_TTL_MS = 30000, defaultLockTimeoutMs = 250, defaultLockTimeout = () => defaultLockTimeoutMs, parseMetadataLock = (raw) => {
|
|
@@ -11343,7 +11413,7 @@ var metadataLockSchema, FOREIGN_LOCK_TTL_MS, UNREADABLE_LOCK_TTL_MS = 30000, REC
|
|
|
11343
11413
|
}
|
|
11344
11414
|
if (process.platform === "darwin" || process.platform === "freebsd") {
|
|
11345
11415
|
try {
|
|
11346
|
-
const run =
|
|
11416
|
+
const run = spawnSync5("ps", ["-o", "lstart=", "-p", String(pid)], {
|
|
11347
11417
|
encoding: "utf8",
|
|
11348
11418
|
timeout: 1000
|
|
11349
11419
|
});
|
|
@@ -13465,7 +13535,7 @@ var init_workers = __esm(() => {
|
|
|
13465
13535
|
});
|
|
13466
13536
|
|
|
13467
13537
|
// packages/workit-core/src/check-config.ts
|
|
13468
|
-
import { spawnSync as
|
|
13538
|
+
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
13469
13539
|
import fs10 from "node:fs";
|
|
13470
13540
|
import path13 from "node:path";
|
|
13471
13541
|
function splitCommand(command) {
|
|
@@ -13633,7 +13703,7 @@ function checkCommand(args, version, onPath = workitAvailable()) {
|
|
|
13633
13703
|
return onPath ? `workit check ${args}` : `npx -y @brainervirus/workit-cli@${version} check ${args}`;
|
|
13634
13704
|
}
|
|
13635
13705
|
var SCRIPT_CHECKS, CHECKS_FILE = "workit.checks.json", isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), SHELL_META, git3 = (cwd, args) => {
|
|
13636
|
-
const run =
|
|
13706
|
+
const run = spawnSync6("git", args, {
|
|
13637
13707
|
cwd,
|
|
13638
13708
|
encoding: "utf8",
|
|
13639
13709
|
timeout: 20000,
|
|
@@ -13668,7 +13738,7 @@ var init_check_config = __esm(() => {
|
|
|
13668
13738
|
// packages/workit-core/src/core/task-evaluation.ts
|
|
13669
13739
|
import { createHash as createHash8 } from "node:crypto";
|
|
13670
13740
|
import * as fs11 from "node:fs";
|
|
13671
|
-
import { spawnSync as
|
|
13741
|
+
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
13672
13742
|
import path14 from "node:path";
|
|
13673
13743
|
function captureCandidate(root, scope, environment = []) {
|
|
13674
13744
|
let checkout;
|
|
@@ -13746,7 +13816,7 @@ function captureCandidate(root, scope, environment = []) {
|
|
|
13746
13816
|
const values = supplied.toSorted((left, right) => compareCodeUnits3(left.name, right.name)).map(({ name, value }) => ({ name, value, refs: [] }));
|
|
13747
13817
|
if (values.some(({ value }) => value === null))
|
|
13748
13818
|
completeness = "uncertain";
|
|
13749
|
-
const headResult =
|
|
13819
|
+
const headResult = spawnSync7("git", ["rev-parse", "HEAD"], { cwd: checkout, encoding: "utf8" });
|
|
13750
13820
|
if (headResult.status !== 0 && !/not a git repository/i.test(headResult.stderr ?? ""))
|
|
13751
13821
|
completeness = "uncertain";
|
|
13752
13822
|
const head = headResult.status === 0 ? headResult.stdout.trim() : null;
|
|
@@ -14119,7 +14189,7 @@ var digestBytes = (value) => createHash8("sha256").update(value).digest("hex"),
|
|
|
14119
14189
|
}
|
|
14120
14190
|
return left.length - right.length;
|
|
14121
14191
|
}, gitPaths = (root) => {
|
|
14122
|
-
const result =
|
|
14192
|
+
const result = spawnSync7("git", ["ls-files", "-z", "--cached", "--others", "--exclude-standard"], {
|
|
14123
14193
|
cwd: root,
|
|
14124
14194
|
encoding: "buffer"
|
|
14125
14195
|
});
|
|
@@ -14132,7 +14202,7 @@ var digestBytes = (value) => createHash8("sha256").update(value).digest("hex"),
|
|
|
14132
14202
|
};
|
|
14133
14203
|
}
|
|
14134
14204
|
const paths = result.stdout ? result.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(path14.sep).join("/")) : [];
|
|
14135
|
-
const stagedDeleted =
|
|
14205
|
+
const stagedDeleted = spawnSync7("git", ["diff", "--cached", "--name-only", "--diff-filter=D", "-z"], { cwd: root, encoding: "buffer" });
|
|
14136
14206
|
if (stagedDeleted.status !== 0) {
|
|
14137
14207
|
const stderr = stagedDeleted.stderr?.toString("utf8") ?? "";
|
|
14138
14208
|
if (!/not a git repository/i.test(stderr))
|
|
@@ -16441,7 +16511,7 @@ function effectiveWorkspacePolicy(workspaceRoot, kind, profileName) {
|
|
|
16441
16511
|
const selected = resolveRuntimeWorkspacePolicy(workspaceRoot, kind, profileName?.trim() || process.env.WORKFLOW_PROFILE?.trim() || undefined);
|
|
16442
16512
|
const config = readConfig();
|
|
16443
16513
|
return kind === "branch" ? {
|
|
16444
|
-
branchPolicy: withReleaseTracks(workspaceRoot, resolveBranchPolicy(config, selected.policy ? { branchPolicy: selected.policy } : null)),
|
|
16514
|
+
branchPolicy: withReleaseTracks(workspaceRoot, resolveBranchPolicy(config, selected.policy ? { branchPolicy: selected.policy } : null, () => repoBranchPreset(workspaceRoot))),
|
|
16445
16515
|
provenance: { branchPolicy: selected.source }
|
|
16446
16516
|
} : {
|
|
16447
16517
|
commitPolicy: resolveCommitPolicy(config, selected.policy ? { commitPolicy: selected.policy } : null),
|
|
@@ -16526,6 +16596,7 @@ var withReleaseTracks = (workspaceRoot, policy) => {
|
|
|
16526
16596
|
}
|
|
16527
16597
|
};
|
|
16528
16598
|
var init_branch = __esm(() => {
|
|
16599
|
+
init_branch_policy();
|
|
16529
16600
|
init_commit_flavors();
|
|
16530
16601
|
init_git();
|
|
16531
16602
|
init_config();
|
|
@@ -16685,9 +16756,9 @@ var NONE2, CASE_INSENSITIVE, canonical2 = (file) => {
|
|
|
16685
16756
|
}
|
|
16686
16757
|
flushSegment();
|
|
16687
16758
|
return segments;
|
|
16688
|
-
},
|
|
16759
|
+
}, PREFIXES2, operands = (words) => words.filter((item) => !item.startsWith("-")), editsOf = (input) => {
|
|
16689
16760
|
let words = input;
|
|
16690
|
-
while (words.length && (
|
|
16761
|
+
while (words.length && (PREFIXES2.has(words[0]) || /^\w+=/.test(words[0])))
|
|
16691
16762
|
words = words.slice(1);
|
|
16692
16763
|
const [verb, ...args] = words;
|
|
16693
16764
|
const name = (verb?.split(/[\\/]/).at(-1) ?? "").toLowerCase();
|
|
@@ -16818,7 +16889,7 @@ var init_write_gate = __esm(() => {
|
|
|
16818
16889
|
init_ledger();
|
|
16819
16890
|
NONE2 = { kind: "none" };
|
|
16820
16891
|
CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "win32";
|
|
16821
|
-
|
|
16892
|
+
PREFIXES2 = new Set(["sudo", "command", "env", "nohup", "time", "exec", "xargs"]);
|
|
16822
16893
|
cache2 = new Map;
|
|
16823
16894
|
});
|
|
16824
16895
|
|
package/dist/mcp-server.js
CHANGED
|
@@ -16576,7 +16576,7 @@ class StdioServerTransport {
|
|
|
16576
16576
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
16577
16577
|
|
|
16578
16578
|
// packages/workit-core/src/core.ts
|
|
16579
|
-
import { spawnSync as
|
|
16579
|
+
import { spawnSync as spawnSync13 } from "node:child_process";
|
|
16580
16580
|
import { existsSync as existsSync7, realpathSync as realpathSync5 } from "node:fs";
|
|
16581
16581
|
import path19 from "node:path";
|
|
16582
16582
|
|
|
@@ -22693,73 +22693,8 @@ var exportDigest = (bundle) => sha256({
|
|
|
22693
22693
|
sourceWorkspaceId: bundle.sourceWorkspaceId,
|
|
22694
22694
|
task: bundle.task
|
|
22695
22695
|
});
|
|
22696
|
-
// packages/workit-core/src/core/
|
|
22697
|
-
import {
|
|
22698
|
-
var run = (cwd, args) => {
|
|
22699
|
-
try {
|
|
22700
|
-
const stdout = execFileSync("git", args, {
|
|
22701
|
-
cwd,
|
|
22702
|
-
encoding: "utf8",
|
|
22703
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
22704
|
-
});
|
|
22705
|
-
return { stdout: stdout.trimEnd(), stderr: "", exitCode: 0 };
|
|
22706
|
-
} catch (error) {
|
|
22707
|
-
const e = error;
|
|
22708
|
-
return {
|
|
22709
|
-
stdout: (e.stdout ?? "").trimEnd(),
|
|
22710
|
-
stderr: (e.stderr ?? "").trimEnd(),
|
|
22711
|
-
exitCode: e.status ?? 1
|
|
22712
|
-
};
|
|
22713
|
-
}
|
|
22714
|
-
};
|
|
22715
|
-
var gitContext = (workspaceRoot, paths = []) => {
|
|
22716
|
-
const cwd = workspaceRoot;
|
|
22717
|
-
let failure;
|
|
22718
|
-
const runHere = (args) => {
|
|
22719
|
-
const result = run(cwd, args);
|
|
22720
|
-
if (!failure && result.exitCode !== 0) {
|
|
22721
|
-
failure = { stderr: result.stderr, exitCode: result.exitCode };
|
|
22722
|
-
}
|
|
22723
|
-
return result.stdout;
|
|
22724
|
-
};
|
|
22725
|
-
const branch = runHere(["rev-parse", "--abbrev-ref", "HEAD"]) || "unknown";
|
|
22726
|
-
const status_short = runHere(["status", "--porcelain"]);
|
|
22727
|
-
const staged = [];
|
|
22728
|
-
const unstaged = [];
|
|
22729
|
-
const untracked = [];
|
|
22730
|
-
for (const line of status_short.split(`
|
|
22731
|
-
`).filter(Boolean)) {
|
|
22732
|
-
const code = line.slice(0, 2);
|
|
22733
|
-
const file = line.slice(3);
|
|
22734
|
-
if (code === "??") {
|
|
22735
|
-
untracked.push(file);
|
|
22736
|
-
} else {
|
|
22737
|
-
if (code[0] !== " " && code[0] !== "?")
|
|
22738
|
-
staged.push(file);
|
|
22739
|
-
if (code[1] !== " " && code[1] !== "?")
|
|
22740
|
-
unstaged.push(file);
|
|
22741
|
-
}
|
|
22742
|
-
}
|
|
22743
|
-
const pathArgs = paths.length ? ["--", ...paths] : [];
|
|
22744
|
-
const diff_stat = runHere(["diff", "--stat", ...pathArgs]);
|
|
22745
|
-
const cached_stat = runHere(["diff", "--cached", "--stat", ...pathArgs]);
|
|
22746
|
-
const stagedSet = new Set(staged);
|
|
22747
|
-
const unstagedSet = new Set(unstaged);
|
|
22748
|
-
const partial_staged = [...stagedSet].filter((f) => unstagedSet.has(f));
|
|
22749
|
-
return {
|
|
22750
|
-
workspace_root: cwd,
|
|
22751
|
-
branch,
|
|
22752
|
-
status_short,
|
|
22753
|
-
staged,
|
|
22754
|
-
unstaged,
|
|
22755
|
-
untracked,
|
|
22756
|
-
diff_stat: [diff_stat, cached_stat].filter(Boolean).join(`
|
|
22757
|
-
`),
|
|
22758
|
-
partial_staged: partial_staged.length > 0,
|
|
22759
|
-
partial_staged_files: partial_staged,
|
|
22760
|
-
...failure ? { stderr: failure.stderr, exitCode: failure.exitCode } : {}
|
|
22761
|
-
};
|
|
22762
|
-
};
|
|
22696
|
+
// packages/workit-core/src/core/branch-policy.ts
|
|
22697
|
+
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
22763
22698
|
|
|
22764
22699
|
// packages/workit-core/src/core/config.ts
|
|
22765
22700
|
import {
|
|
@@ -22885,6 +22820,7 @@ var DEFAULTS = {
|
|
|
22885
22820
|
},
|
|
22886
22821
|
commitPolicy: { preset: "conventional" }
|
|
22887
22822
|
};
|
|
22823
|
+
var unchosenBranchPolicy = new WeakSet([DEFAULTS]);
|
|
22888
22824
|
var readSafe = (p) => {
|
|
22889
22825
|
try {
|
|
22890
22826
|
return readFileSync3(p, "utf8");
|
|
@@ -22909,22 +22845,21 @@ var parseConfigResult = (raw, file) => {
|
|
|
22909
22845
|
const locale = LOCALE_RE.test(String(input.locale ?? "")) ? input.locale : DEFAULTS.locale;
|
|
22910
22846
|
const preset = Object.hasOwn(PRESETS, input.branchPolicy?.preset) ? input.branchPolicy?.preset : "gitflow";
|
|
22911
22847
|
const commitPreset = COMMIT_PRESETS.includes(String(input.commitPolicy?.preset ?? "")) ? input.commitPolicy?.preset : "conventional";
|
|
22912
|
-
|
|
22913
|
-
|
|
22914
|
-
|
|
22915
|
-
|
|
22916
|
-
|
|
22917
|
-
|
|
22918
|
-
|
|
22919
|
-
|
|
22920
|
-
|
|
22921
|
-
}
|
|
22922
|
-
commitPolicy: {
|
|
22923
|
-
preset: commitPreset,
|
|
22924
|
-
...typeof input.commitPolicy?.pattern === "string" ? { pattern: input.commitPolicy.pattern } : {}
|
|
22925
|
-
}
|
|
22848
|
+
const config = {
|
|
22849
|
+
locale,
|
|
22850
|
+
localeOptions: Array.isArray(input.localeOptions) ? input.localeOptions : DEFAULTS.localeOptions,
|
|
22851
|
+
branchPolicy: mergePreset(preset, {
|
|
22852
|
+
allowed: Array.isArray(input.branchPolicy?.allowed) ? input.branchPolicy.allowed : undefined,
|
|
22853
|
+
protectedNames: Array.isArray(input.branchPolicy?.protected) ? input.branchPolicy.protected : undefined
|
|
22854
|
+
}, DEFAULTS),
|
|
22855
|
+
commitPolicy: {
|
|
22856
|
+
preset: commitPreset,
|
|
22857
|
+
...typeof input.commitPolicy?.pattern === "string" ? { pattern: input.commitPolicy.pattern } : {}
|
|
22926
22858
|
}
|
|
22927
22859
|
};
|
|
22860
|
+
if (!Object.hasOwn(PRESETS, input.branchPolicy?.preset))
|
|
22861
|
+
unchosenBranchPolicy.add(config);
|
|
22862
|
+
return { status: "valid", path: file, config };
|
|
22928
22863
|
};
|
|
22929
22864
|
var readConfigTyped = (dir) => {
|
|
22930
22865
|
const file = path12.join(dir ?? configDir(), "config.json");
|
|
@@ -22938,9 +22873,11 @@ var readConfig = () => {
|
|
|
22938
22873
|
};
|
|
22939
22874
|
var vcsConfigPath = () => process.env.WORKFLOW_VCS_CONFIG ?? path12.join(configDir(), "vcs.json");
|
|
22940
22875
|
var branchGlobPattern = (glob) => new RegExp(`^${glob.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*")}$`, "i");
|
|
22941
|
-
var resolveBranchPolicy = (config, workspace) => {
|
|
22876
|
+
var resolveBranchPolicy = (config, workspace, repoPreset) => {
|
|
22942
22877
|
const wp = workspace?.branchPolicy ?? {};
|
|
22943
|
-
const
|
|
22878
|
+
const workspacePreset = Object.hasOwn(PRESETS, wp.preset);
|
|
22879
|
+
const detected = !workspacePreset && unchosenBranchPolicy.has(config) ? repoPreset?.() ?? null : null;
|
|
22880
|
+
const preset = workspacePreset ? wp.preset : detected ?? config.branchPolicy?.preset ?? "gitflow";
|
|
22944
22881
|
const merged = mergePreset(preset, {
|
|
22945
22882
|
allowed: wp.allowed,
|
|
22946
22883
|
protectedNames: wp.protected
|
|
@@ -22949,9 +22886,10 @@ var resolveBranchPolicy = (config, workspace) => {
|
|
|
22949
22886
|
return {
|
|
22950
22887
|
preset,
|
|
22951
22888
|
allowed,
|
|
22952
|
-
protected: new Set(merged.protected.map((p) => p.toLowerCase())),
|
|
22889
|
+
protected: new Set([...merged.protected, ...detected ? PRESETS.gitflow.protected : []].map((p) => p.toLowerCase())),
|
|
22953
22890
|
integration: wp.integration === "merge" ? "merge" : "pr",
|
|
22954
|
-
defaultTargetBranch: preset === "github-flow" ? "main" : preset === "trunk-based" ? "master" : "develop"
|
|
22891
|
+
defaultTargetBranch: preset === "github-flow" ? "main" : preset === "trunk-based" ? "master" : "develop",
|
|
22892
|
+
detected: detected !== null
|
|
22955
22893
|
};
|
|
22956
22894
|
};
|
|
22957
22895
|
var COMMIT_PRESETS = [
|
|
@@ -22963,6 +22901,138 @@ var COMMIT_PRESETS = [
|
|
|
22963
22901
|
"auto"
|
|
22964
22902
|
];
|
|
22965
22903
|
|
|
22904
|
+
// packages/workit-core/src/core/branch-policy.ts
|
|
22905
|
+
var PREFIXES = {
|
|
22906
|
+
feature: "feature/*",
|
|
22907
|
+
bugfix: "bugfix/*",
|
|
22908
|
+
release: "release/*",
|
|
22909
|
+
hotfix: "hotfix/*"
|
|
22910
|
+
};
|
|
22911
|
+
var branchNames = (workspaceRoot) => {
|
|
22912
|
+
const r = spawnSync7("git", ["for-each-ref", "--format=%(refname)", "refs/heads", "refs/remotes/origin"], { cwd: workspaceRoot, encoding: "utf8" });
|
|
22913
|
+
if (r.status !== 0)
|
|
22914
|
+
return new Set;
|
|
22915
|
+
return new Set((r.stdout ?? "").split(`
|
|
22916
|
+
`).filter(Boolean).map((ref) => ref.startsWith("refs/heads/") ? ref.slice("refs/heads/".length) : ref.slice("refs/remotes/origin/".length)));
|
|
22917
|
+
};
|
|
22918
|
+
var detectBranchPolicy = (workspaceRoot) => {
|
|
22919
|
+
const names = branchNames(workspaceRoot);
|
|
22920
|
+
const develop = names.has("develop");
|
|
22921
|
+
const main = names.has("main");
|
|
22922
|
+
const master = names.has("master");
|
|
22923
|
+
const root = main ? "main" : master ? "master" : null;
|
|
22924
|
+
if (develop) {
|
|
22925
|
+
return {
|
|
22926
|
+
preset: "gitflow",
|
|
22927
|
+
developBranch: "develop",
|
|
22928
|
+
integration: "merge",
|
|
22929
|
+
protected: root ? [root, "develop"] : ["develop"],
|
|
22930
|
+
allowed: [...PRESETS.gitflow.allowed],
|
|
22931
|
+
prefixes: PREFIXES
|
|
22932
|
+
};
|
|
22933
|
+
}
|
|
22934
|
+
if (root === "main") {
|
|
22935
|
+
return {
|
|
22936
|
+
preset: "github-flow",
|
|
22937
|
+
developBranch: null,
|
|
22938
|
+
integration: "pr",
|
|
22939
|
+
protected: [root],
|
|
22940
|
+
allowed: ["*"],
|
|
22941
|
+
prefixes: PREFIXES
|
|
22942
|
+
};
|
|
22943
|
+
}
|
|
22944
|
+
if (root === "master") {
|
|
22945
|
+
return {
|
|
22946
|
+
preset: "trunk-based",
|
|
22947
|
+
developBranch: null,
|
|
22948
|
+
integration: "pr",
|
|
22949
|
+
protected: [root],
|
|
22950
|
+
allowed: ["*"],
|
|
22951
|
+
prefixes: PREFIXES
|
|
22952
|
+
};
|
|
22953
|
+
}
|
|
22954
|
+
return {
|
|
22955
|
+
preset: "gitflow",
|
|
22956
|
+
developBranch: null,
|
|
22957
|
+
integration: "merge",
|
|
22958
|
+
protected: [],
|
|
22959
|
+
allowed: [],
|
|
22960
|
+
prefixes: PREFIXES
|
|
22961
|
+
};
|
|
22962
|
+
};
|
|
22963
|
+
var repoBranchPreset = (workspaceRoot) => {
|
|
22964
|
+
const detected = detectBranchPolicy(workspaceRoot);
|
|
22965
|
+
return detected.developBranch || detected.allowed.length ? detected.preset : null;
|
|
22966
|
+
};
|
|
22967
|
+
|
|
22968
|
+
// packages/workit-core/src/core/git.ts
|
|
22969
|
+
import { execFileSync } from "node:child_process";
|
|
22970
|
+
var run = (cwd, args) => {
|
|
22971
|
+
try {
|
|
22972
|
+
const stdout = execFileSync("git", args, {
|
|
22973
|
+
cwd,
|
|
22974
|
+
encoding: "utf8",
|
|
22975
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
22976
|
+
});
|
|
22977
|
+
return { stdout: stdout.trimEnd(), stderr: "", exitCode: 0 };
|
|
22978
|
+
} catch (error) {
|
|
22979
|
+
const e = error;
|
|
22980
|
+
return {
|
|
22981
|
+
stdout: (e.stdout ?? "").trimEnd(),
|
|
22982
|
+
stderr: (e.stderr ?? "").trimEnd(),
|
|
22983
|
+
exitCode: e.status ?? 1
|
|
22984
|
+
};
|
|
22985
|
+
}
|
|
22986
|
+
};
|
|
22987
|
+
var gitContext = (workspaceRoot, paths = []) => {
|
|
22988
|
+
const cwd = workspaceRoot;
|
|
22989
|
+
let failure;
|
|
22990
|
+
const runHere = (args) => {
|
|
22991
|
+
const result = run(cwd, args);
|
|
22992
|
+
if (!failure && result.exitCode !== 0) {
|
|
22993
|
+
failure = { stderr: result.stderr, exitCode: result.exitCode };
|
|
22994
|
+
}
|
|
22995
|
+
return result.stdout;
|
|
22996
|
+
};
|
|
22997
|
+
const branch = runHere(["rev-parse", "--abbrev-ref", "HEAD"]) || "unknown";
|
|
22998
|
+
const status_short = runHere(["status", "--porcelain"]);
|
|
22999
|
+
const staged = [];
|
|
23000
|
+
const unstaged = [];
|
|
23001
|
+
const untracked = [];
|
|
23002
|
+
for (const line of status_short.split(`
|
|
23003
|
+
`).filter(Boolean)) {
|
|
23004
|
+
const code = line.slice(0, 2);
|
|
23005
|
+
const file = line.slice(3);
|
|
23006
|
+
if (code === "??") {
|
|
23007
|
+
untracked.push(file);
|
|
23008
|
+
} else {
|
|
23009
|
+
if (code[0] !== " " && code[0] !== "?")
|
|
23010
|
+
staged.push(file);
|
|
23011
|
+
if (code[1] !== " " && code[1] !== "?")
|
|
23012
|
+
unstaged.push(file);
|
|
23013
|
+
}
|
|
23014
|
+
}
|
|
23015
|
+
const pathArgs = paths.length ? ["--", ...paths] : [];
|
|
23016
|
+
const diff_stat = runHere(["diff", "--stat", ...pathArgs]);
|
|
23017
|
+
const cached_stat = runHere(["diff", "--cached", "--stat", ...pathArgs]);
|
|
23018
|
+
const stagedSet = new Set(staged);
|
|
23019
|
+
const unstagedSet = new Set(unstaged);
|
|
23020
|
+
const partial_staged = [...stagedSet].filter((f) => unstagedSet.has(f));
|
|
23021
|
+
return {
|
|
23022
|
+
workspace_root: cwd,
|
|
23023
|
+
branch,
|
|
23024
|
+
status_short,
|
|
23025
|
+
staged,
|
|
23026
|
+
unstaged,
|
|
23027
|
+
untracked,
|
|
23028
|
+
diff_stat: [diff_stat, cached_stat].filter(Boolean).join(`
|
|
23029
|
+
`),
|
|
23030
|
+
partial_staged: partial_staged.length > 0,
|
|
23031
|
+
partial_staged_files: partial_staged,
|
|
23032
|
+
...failure ? { stderr: failure.stderr, exitCode: failure.exitCode } : {}
|
|
23033
|
+
};
|
|
23034
|
+
};
|
|
23035
|
+
|
|
22966
23036
|
// packages/workit-core/src/core/workspaces.ts
|
|
22967
23037
|
import { createHash as createHash8 } from "node:crypto";
|
|
22968
23038
|
import { readFileSync as readFileSync4, realpathSync as realpathSync3 } from "node:fs";
|
|
@@ -23368,18 +23438,18 @@ function workspaceDefaultTarget(cwd, globalDefault) {
|
|
|
23368
23438
|
const wp = ws?.branchPolicy ?? {};
|
|
23369
23439
|
const hasWorkspacePolicy = typeof wp.preset === "string" && Object.hasOwn(PRESETS, wp.preset);
|
|
23370
23440
|
const selected = resolveRuntimeWorkspacePolicy(cwd, "branch", process.env.WORKFLOW_PROFILE?.trim() || undefined);
|
|
23371
|
-
const policyDefault = resolveBranchPolicy(readConfig(), selected.policy ? { branchPolicy: selected.policy } : null).defaultTargetBranch;
|
|
23441
|
+
const policyDefault = resolveBranchPolicy(readConfig(), selected.policy ? { branchPolicy: selected.policy } : null, () => repoBranchPreset(cwd)).defaultTargetBranch;
|
|
23372
23442
|
return String(ws?.vcs?.defaultTargetBranch ?? (hasWorkspacePolicy ? policyDefault : globalDefault ?? policyDefault) ?? "develop");
|
|
23373
23443
|
}
|
|
23374
23444
|
|
|
23375
23445
|
// packages/workit-core/src/core/vcs-config.ts
|
|
23376
23446
|
import fs12 from "node:fs";
|
|
23377
23447
|
import path14 from "node:path";
|
|
23378
|
-
import { spawnSync as
|
|
23448
|
+
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
23379
23449
|
|
|
23380
23450
|
// packages/workit-core/src/core/release-tracks.ts
|
|
23381
23451
|
import { createHash as createHash9 } from "node:crypto";
|
|
23382
|
-
import { spawnSync as
|
|
23452
|
+
import { spawnSync as spawnSync8 } from "node:child_process";
|
|
23383
23453
|
var KNOWN_FIELDS = new Set([
|
|
23384
23454
|
"strategy",
|
|
23385
23455
|
"productionBranch",
|
|
@@ -23651,7 +23721,7 @@ function resolveReleaseTrack(input) {
|
|
|
23651
23721
|
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 ")}`);
|
|
23652
23722
|
}
|
|
23653
23723
|
var git4 = (cwd, args) => {
|
|
23654
|
-
const run =
|
|
23724
|
+
const run = spawnSync8("git", args, {
|
|
23655
23725
|
cwd,
|
|
23656
23726
|
encoding: "utf8",
|
|
23657
23727
|
timeout: 20000,
|
|
@@ -23766,7 +23836,7 @@ function resolveTrackFor(cwd, options) {
|
|
|
23766
23836
|
var workspacesPath = () => path14.join(configDir(), "workspaces.json");
|
|
23767
23837
|
var vcsCwd = (cwd) => cwd ?? process.env.WORKFLOW_WORKSPACE_ROOT ?? process.cwd();
|
|
23768
23838
|
var remoteProvider = (cwd) => {
|
|
23769
|
-
const r =
|
|
23839
|
+
const r = spawnSync9("git", ["remote", "get-url", "origin"], { cwd, encoding: "utf8" });
|
|
23770
23840
|
if (r.status !== 0)
|
|
23771
23841
|
return null;
|
|
23772
23842
|
const url = (r.stdout ?? "").trim();
|
|
@@ -23803,7 +23873,7 @@ var remoteEndpoint = (remote) => {
|
|
|
23803
23873
|
var configuredSshEndpoint = (host) => {
|
|
23804
23874
|
if (host.startsWith("-"))
|
|
23805
23875
|
return null;
|
|
23806
|
-
const resolved =
|
|
23876
|
+
const resolved = spawnSync9("ssh", ["-G", host], {
|
|
23807
23877
|
encoding: "utf8",
|
|
23808
23878
|
timeout: 5000,
|
|
23809
23879
|
maxBuffer: 1024 * 1024,
|
|
@@ -23976,7 +24046,7 @@ function mergedPrStyle(limit = 6, cwd) {
|
|
|
23976
24046
|
`).filter((l) => l.startsWith("## ")).map((l) => l.trim()),
|
|
23977
24047
|
descriptionPreview: desc.slice(0, 600)
|
|
23978
24048
|
});
|
|
23979
|
-
const remoteResult =
|
|
24049
|
+
const remoteResult = spawnSync9("git", ["remote", "get-url", "--push", "--all", "origin"], {
|
|
23980
24050
|
cwd,
|
|
23981
24051
|
encoding: "utf8"
|
|
23982
24052
|
});
|
|
@@ -23992,7 +24062,7 @@ function mergedPrStyle(limit = 6, cwd) {
|
|
|
23992
24062
|
if (!hostingApiHostMatches(remote, host))
|
|
23993
24063
|
return { ok: false, error: "PR style target does not match the provider host" };
|
|
23994
24064
|
if (provider === "gitlab") {
|
|
23995
|
-
const run = (args) =>
|
|
24065
|
+
const run = (args) => spawnSync9("glab", ["api", ...args], {
|
|
23996
24066
|
cwd,
|
|
23997
24067
|
encoding: "utf8",
|
|
23998
24068
|
env
|
|
@@ -24012,7 +24082,7 @@ function mergedPrStyle(limit = 6, cwd) {
|
|
|
24012
24082
|
});
|
|
24013
24083
|
}
|
|
24014
24084
|
} else if (provider === "github") {
|
|
24015
|
-
const r =
|
|
24085
|
+
const r = spawnSync9("gh", [
|
|
24016
24086
|
"pr",
|
|
24017
24087
|
"list",
|
|
24018
24088
|
"--repo",
|
|
@@ -25949,7 +26019,7 @@ class WorkitCore {
|
|
|
25949
26019
|
}
|
|
25950
26020
|
}
|
|
25951
26021
|
// packages/workit-core/src/core/repo-context.ts
|
|
25952
|
-
import { spawnSync as
|
|
26022
|
+
import { spawnSync as spawnSync10 } from "node:child_process";
|
|
25953
26023
|
import { existsSync as existsSync6, readFileSync as readFileSync5, readdirSync as readdirSync4 } from "node:fs";
|
|
25954
26024
|
import path16 from "node:path";
|
|
25955
26025
|
var isSafeContextRange = (value) => value.length <= 4096 && (() => {
|
|
@@ -25978,7 +26048,7 @@ var invalidRange = (cwd) => ({
|
|
|
25978
26048
|
cwd
|
|
25979
26049
|
});
|
|
25980
26050
|
var runGit = (cwd, args) => {
|
|
25981
|
-
const result =
|
|
26051
|
+
const result = spawnSync10("git", args, { cwd, encoding: "utf8" });
|
|
25982
26052
|
return {
|
|
25983
26053
|
stdout: (result.stdout ?? "").trimEnd(),
|
|
25984
26054
|
stderr: (result.stderr ?? "").trimEnd(),
|
|
@@ -26419,12 +26489,12 @@ function releaseNotesContext(root, rangeOrTag) {
|
|
|
26419
26489
|
}
|
|
26420
26490
|
|
|
26421
26491
|
// packages/workit-core/src/core/tracker-issues.ts
|
|
26422
|
-
import { spawnSync as
|
|
26492
|
+
import { spawnSync as spawnSync12 } from "node:child_process";
|
|
26423
26493
|
|
|
26424
26494
|
// packages/workit-core/src/core/pr-create.ts
|
|
26425
26495
|
import fs13 from "node:fs";
|
|
26426
26496
|
import path17 from "node:path";
|
|
26427
|
-
import { spawnSync as
|
|
26497
|
+
import { spawnSync as spawnSync11 } from "node:child_process";
|
|
26428
26498
|
// packages/workit-core/src/forge/pr-body.ts
|
|
26429
26499
|
function parseGhIssue(value) {
|
|
26430
26500
|
const m = /issues\/(\d+)/.exec(value);
|
|
@@ -26449,7 +26519,7 @@ function whichOnPath(tool) {
|
|
|
26449
26519
|
}
|
|
26450
26520
|
var hostingCliAvailable = (provider) => whichOnPath(provider === "gitlab" ? "glab" : "gh") !== null;
|
|
26451
26521
|
var pushRemote = (cwd) => {
|
|
26452
|
-
const result =
|
|
26522
|
+
const result = spawnSync11("git", ["remote", "get-url", "--push", "--all", "origin"], {
|
|
26453
26523
|
cwd,
|
|
26454
26524
|
encoding: "utf8"
|
|
26455
26525
|
});
|
|
@@ -26480,7 +26550,7 @@ var defaultCli = (bin, available) => {
|
|
|
26480
26550
|
if (!available)
|
|
26481
26551
|
return null;
|
|
26482
26552
|
return (args, root) => {
|
|
26483
|
-
const out =
|
|
26553
|
+
const out = spawnSync12(bin, args, {
|
|
26484
26554
|
cwd: root,
|
|
26485
26555
|
encoding: "utf8",
|
|
26486
26556
|
env: { ...process.env, PATH: process.env.PATH ?? "" }
|
|
@@ -26998,7 +27068,7 @@ function resolveInside(root, candidate) {
|
|
|
26998
27068
|
}
|
|
26999
27069
|
function run2(root, executable, args, env = {}) {
|
|
27000
27070
|
const cwd = realpathSync5(root);
|
|
27001
|
-
const result =
|
|
27071
|
+
const result = spawnSync13(executable, args, {
|
|
27002
27072
|
cwd,
|
|
27003
27073
|
encoding: "utf8",
|
|
27004
27074
|
env: { ...process.env, ...env }
|
|
@@ -27410,7 +27480,7 @@ var signals = new Map;
|
|
|
27410
27480
|
var cache = new Map;
|
|
27411
27481
|
// packages/workit-core/src/hooks/write-gate.ts
|
|
27412
27482
|
var CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "win32";
|
|
27413
|
-
var
|
|
27483
|
+
var PREFIXES2 = new Set(["sudo", "command", "env", "nohup", "time", "exec", "xargs"]);
|
|
27414
27484
|
var cache2 = new Map;
|
|
27415
27485
|
// packages/workit-core/src/hooks/hosts/fields.ts
|
|
27416
27486
|
var SHELLS = new Set(["sh", "bash", "zsh", "dash", "pwsh", "powershell", "cmd"]);
|
package/dist/workit-hook.js
CHANGED
|
@@ -10008,6 +10008,7 @@ var DEFAULTS = {
|
|
|
10008
10008
|
},
|
|
10009
10009
|
commitPolicy: { preset: "conventional" }
|
|
10010
10010
|
};
|
|
10011
|
+
var unchosenBranchPolicy = new WeakSet([DEFAULTS]);
|
|
10011
10012
|
var readSafe = (p) => {
|
|
10012
10013
|
try {
|
|
10013
10014
|
return readFileSync(p, "utf8");
|
|
@@ -10032,22 +10033,21 @@ var parseConfigResult = (raw, file) => {
|
|
|
10032
10033
|
const locale = LOCALE_RE.test(String(input.locale ?? "")) ? input.locale : DEFAULTS.locale;
|
|
10033
10034
|
const preset = Object.hasOwn(PRESETS, input.branchPolicy?.preset) ? input.branchPolicy?.preset : "gitflow";
|
|
10034
10035
|
const commitPreset = COMMIT_PRESETS.includes(String(input.commitPolicy?.preset ?? "")) ? input.commitPolicy?.preset : "conventional";
|
|
10035
|
-
|
|
10036
|
-
|
|
10037
|
-
|
|
10038
|
-
|
|
10039
|
-
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
|
-
|
|
10043
|
-
|
|
10044
|
-
}
|
|
10045
|
-
commitPolicy: {
|
|
10046
|
-
preset: commitPreset,
|
|
10047
|
-
...typeof input.commitPolicy?.pattern === "string" ? { pattern: input.commitPolicy.pattern } : {}
|
|
10048
|
-
}
|
|
10036
|
+
const config = {
|
|
10037
|
+
locale,
|
|
10038
|
+
localeOptions: Array.isArray(input.localeOptions) ? input.localeOptions : DEFAULTS.localeOptions,
|
|
10039
|
+
branchPolicy: mergePreset(preset, {
|
|
10040
|
+
allowed: Array.isArray(input.branchPolicy?.allowed) ? input.branchPolicy.allowed : undefined,
|
|
10041
|
+
protectedNames: Array.isArray(input.branchPolicy?.protected) ? input.branchPolicy.protected : undefined
|
|
10042
|
+
}, DEFAULTS),
|
|
10043
|
+
commitPolicy: {
|
|
10044
|
+
preset: commitPreset,
|
|
10045
|
+
...typeof input.commitPolicy?.pattern === "string" ? { pattern: input.commitPolicy.pattern } : {}
|
|
10049
10046
|
}
|
|
10050
10047
|
};
|
|
10048
|
+
if (!Object.hasOwn(PRESETS, input.branchPolicy?.preset))
|
|
10049
|
+
unchosenBranchPolicy.add(config);
|
|
10050
|
+
return { status: "valid", path: file, config };
|
|
10051
10051
|
};
|
|
10052
10052
|
var readConfigTyped = (dir) => {
|
|
10053
10053
|
const file = path5.join(dir ?? configDir(), "config.json");
|
|
@@ -10060,9 +10060,11 @@ var readConfig = () => {
|
|
|
10060
10060
|
return result.config ?? DEFAULTS;
|
|
10061
10061
|
};
|
|
10062
10062
|
var branchGlobPattern = (glob) => new RegExp(`^${glob.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*")}$`, "i");
|
|
10063
|
-
var resolveBranchPolicy = (config, workspace) => {
|
|
10063
|
+
var resolveBranchPolicy = (config, workspace, repoPreset) => {
|
|
10064
10064
|
const wp = workspace?.branchPolicy ?? {};
|
|
10065
|
-
const
|
|
10065
|
+
const workspacePreset = Object.hasOwn(PRESETS, wp.preset);
|
|
10066
|
+
const detected = !workspacePreset && unchosenBranchPolicy.has(config) ? repoPreset?.() ?? null : null;
|
|
10067
|
+
const preset = workspacePreset ? wp.preset : detected ?? config.branchPolicy?.preset ?? "gitflow";
|
|
10066
10068
|
const merged = mergePreset(preset, {
|
|
10067
10069
|
allowed: wp.allowed,
|
|
10068
10070
|
protectedNames: wp.protected
|
|
@@ -10071,9 +10073,10 @@ var resolveBranchPolicy = (config, workspace) => {
|
|
|
10071
10073
|
return {
|
|
10072
10074
|
preset,
|
|
10073
10075
|
allowed,
|
|
10074
|
-
protected: new Set(merged.protected.map((p) => p.toLowerCase())),
|
|
10076
|
+
protected: new Set([...merged.protected, ...detected ? PRESETS.gitflow.protected : []].map((p) => p.toLowerCase())),
|
|
10075
10077
|
integration: wp.integration === "merge" ? "merge" : "pr",
|
|
10076
|
-
defaultTargetBranch: preset === "github-flow" ? "main" : preset === "trunk-based" ? "master" : "develop"
|
|
10078
|
+
defaultTargetBranch: preset === "github-flow" ? "main" : preset === "trunk-based" ? "master" : "develop",
|
|
10079
|
+
detected: detected !== null
|
|
10077
10080
|
};
|
|
10078
10081
|
};
|
|
10079
10082
|
var COMMIT_PRESETS = [
|
|
@@ -10099,6 +10102,73 @@ var resolveCommitPolicy = (config, workspace) => {
|
|
|
10099
10102
|
import { createHash as createHash5 } from "node:crypto";
|
|
10100
10103
|
import { readFileSync as readFileSync2, realpathSync } from "node:fs";
|
|
10101
10104
|
import path6 from "node:path";
|
|
10105
|
+
|
|
10106
|
+
// packages/workit-core/src/core/branch-policy.ts
|
|
10107
|
+
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
10108
|
+
var PREFIXES = {
|
|
10109
|
+
feature: "feature/*",
|
|
10110
|
+
bugfix: "bugfix/*",
|
|
10111
|
+
release: "release/*",
|
|
10112
|
+
hotfix: "hotfix/*"
|
|
10113
|
+
};
|
|
10114
|
+
var branchNames = (workspaceRoot) => {
|
|
10115
|
+
const r = spawnSync4("git", ["for-each-ref", "--format=%(refname)", "refs/heads", "refs/remotes/origin"], { cwd: workspaceRoot, encoding: "utf8" });
|
|
10116
|
+
if (r.status !== 0)
|
|
10117
|
+
return new Set;
|
|
10118
|
+
return new Set((r.stdout ?? "").split(`
|
|
10119
|
+
`).filter(Boolean).map((ref) => ref.startsWith("refs/heads/") ? ref.slice("refs/heads/".length) : ref.slice("refs/remotes/origin/".length)));
|
|
10120
|
+
};
|
|
10121
|
+
var detectBranchPolicy = (workspaceRoot) => {
|
|
10122
|
+
const names = branchNames(workspaceRoot);
|
|
10123
|
+
const develop = names.has("develop");
|
|
10124
|
+
const main = names.has("main");
|
|
10125
|
+
const master = names.has("master");
|
|
10126
|
+
const root = main ? "main" : master ? "master" : null;
|
|
10127
|
+
if (develop) {
|
|
10128
|
+
return {
|
|
10129
|
+
preset: "gitflow",
|
|
10130
|
+
developBranch: "develop",
|
|
10131
|
+
integration: "merge",
|
|
10132
|
+
protected: root ? [root, "develop"] : ["develop"],
|
|
10133
|
+
allowed: [...PRESETS.gitflow.allowed],
|
|
10134
|
+
prefixes: PREFIXES
|
|
10135
|
+
};
|
|
10136
|
+
}
|
|
10137
|
+
if (root === "main") {
|
|
10138
|
+
return {
|
|
10139
|
+
preset: "github-flow",
|
|
10140
|
+
developBranch: null,
|
|
10141
|
+
integration: "pr",
|
|
10142
|
+
protected: [root],
|
|
10143
|
+
allowed: ["*"],
|
|
10144
|
+
prefixes: PREFIXES
|
|
10145
|
+
};
|
|
10146
|
+
}
|
|
10147
|
+
if (root === "master") {
|
|
10148
|
+
return {
|
|
10149
|
+
preset: "trunk-based",
|
|
10150
|
+
developBranch: null,
|
|
10151
|
+
integration: "pr",
|
|
10152
|
+
protected: [root],
|
|
10153
|
+
allowed: ["*"],
|
|
10154
|
+
prefixes: PREFIXES
|
|
10155
|
+
};
|
|
10156
|
+
}
|
|
10157
|
+
return {
|
|
10158
|
+
preset: "gitflow",
|
|
10159
|
+
developBranch: null,
|
|
10160
|
+
integration: "merge",
|
|
10161
|
+
protected: [],
|
|
10162
|
+
allowed: [],
|
|
10163
|
+
prefixes: PREFIXES
|
|
10164
|
+
};
|
|
10165
|
+
};
|
|
10166
|
+
var repoBranchPreset = (workspaceRoot) => {
|
|
10167
|
+
const detected = detectBranchPolicy(workspaceRoot);
|
|
10168
|
+
return detected.developBranch || detected.allowed.length ? detected.preset : null;
|
|
10169
|
+
};
|
|
10170
|
+
|
|
10171
|
+
// packages/workit-core/src/core/workspaces.ts
|
|
10102
10172
|
var nonBlank = string2().refine((value) => value.trim().length > 0, "must not be blank");
|
|
10103
10173
|
var branchPreset = custom((value) => typeof value === "string" && Object.hasOwn(PRESETS, value), "unsupported branch preset");
|
|
10104
10174
|
var commitPreset = custom((value) => typeof value === "string" && COMMIT_PRESETS.includes(value), "unsupported commit preset");
|
|
@@ -11251,7 +11321,7 @@ var packageRoot = () => {
|
|
|
11251
11321
|
};
|
|
11252
11322
|
|
|
11253
11323
|
// packages/workit-core/src/core/store-lock.ts
|
|
11254
|
-
import { spawnSync as
|
|
11324
|
+
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
11255
11325
|
import fs7 from "node:fs";
|
|
11256
11326
|
import { hostname } from "node:os";
|
|
11257
11327
|
var metadataLockSchema = object({
|
|
@@ -11301,7 +11371,7 @@ var processStartOf = (pid) => {
|
|
|
11301
11371
|
}
|
|
11302
11372
|
if (process.platform === "darwin" || process.platform === "freebsd") {
|
|
11303
11373
|
try {
|
|
11304
|
-
const run =
|
|
11374
|
+
const run = spawnSync5("ps", ["-o", "lstart=", "-p", String(pid)], {
|
|
11305
11375
|
encoding: "utf8",
|
|
11306
11376
|
timeout: 1000
|
|
11307
11377
|
});
|
|
@@ -13441,11 +13511,11 @@ var workerBlocksTransition = (transition, state) => transition === "pause" ? fal
|
|
|
13441
13511
|
// packages/workit-core/src/core/task-evaluation.ts
|
|
13442
13512
|
import { createHash as createHash8 } from "node:crypto";
|
|
13443
13513
|
import * as fs11 from "node:fs";
|
|
13444
|
-
import { spawnSync as
|
|
13514
|
+
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
13445
13515
|
import path14 from "node:path";
|
|
13446
13516
|
|
|
13447
13517
|
// packages/workit-core/src/check-config.ts
|
|
13448
|
-
import { spawnSync as
|
|
13518
|
+
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
13449
13519
|
import fs10 from "node:fs";
|
|
13450
13520
|
import path13 from "node:path";
|
|
13451
13521
|
var SCRIPT_CHECKS = ["test", "lint", "typecheck", "check"];
|
|
@@ -13489,7 +13559,7 @@ function splitCommand(command) {
|
|
|
13489
13559
|
return argv.length ? argv : new Error("empty command");
|
|
13490
13560
|
}
|
|
13491
13561
|
var git3 = (cwd, args) => {
|
|
13492
|
-
const run =
|
|
13562
|
+
const run = spawnSync6("git", args, {
|
|
13493
13563
|
cwd,
|
|
13494
13564
|
encoding: "utf8",
|
|
13495
13565
|
timeout: 20000,
|
|
@@ -13694,7 +13764,7 @@ var compareCodeUnits3 = (left, right) => {
|
|
|
13694
13764
|
return left.length - right.length;
|
|
13695
13765
|
};
|
|
13696
13766
|
var gitPaths = (root) => {
|
|
13697
|
-
const result =
|
|
13767
|
+
const result = spawnSync7("git", ["ls-files", "-z", "--cached", "--others", "--exclude-standard"], {
|
|
13698
13768
|
cwd: root,
|
|
13699
13769
|
encoding: "buffer"
|
|
13700
13770
|
});
|
|
@@ -13707,7 +13777,7 @@ var gitPaths = (root) => {
|
|
|
13707
13777
|
};
|
|
13708
13778
|
}
|
|
13709
13779
|
const paths = result.stdout ? result.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(path14.sep).join("/")) : [];
|
|
13710
|
-
const stagedDeleted =
|
|
13780
|
+
const stagedDeleted = spawnSync7("git", ["diff", "--cached", "--name-only", "--diff-filter=D", "-z"], { cwd: root, encoding: "buffer" });
|
|
13711
13781
|
if (stagedDeleted.status !== 0) {
|
|
13712
13782
|
const stderr = stagedDeleted.stderr?.toString("utf8") ?? "";
|
|
13713
13783
|
if (!/not a git repository/i.test(stderr))
|
|
@@ -13838,7 +13908,7 @@ function captureCandidate(root, scope, environment = []) {
|
|
|
13838
13908
|
const values = supplied.toSorted((left, right) => compareCodeUnits3(left.name, right.name)).map(({ name, value }) => ({ name, value, refs: [] }));
|
|
13839
13909
|
if (values.some(({ value }) => value === null))
|
|
13840
13910
|
completeness = "uncertain";
|
|
13841
|
-
const headResult =
|
|
13911
|
+
const headResult = spawnSync7("git", ["rev-parse", "HEAD"], { cwd: checkout, encoding: "utf8" });
|
|
13842
13912
|
if (headResult.status !== 0 && !/not a git repository/i.test(headResult.stderr ?? ""))
|
|
13843
13913
|
completeness = "uncertain";
|
|
13844
13914
|
const head = headResult.status === 0 ? headResult.stdout.trim() : null;
|
|
@@ -16466,7 +16536,7 @@ function effectiveWorkspacePolicy(workspaceRoot, kind, profileName) {
|
|
|
16466
16536
|
const selected = resolveRuntimeWorkspacePolicy(workspaceRoot, kind, profileName?.trim() || process.env.WORKFLOW_PROFILE?.trim() || undefined);
|
|
16467
16537
|
const config = readConfig();
|
|
16468
16538
|
return kind === "branch" ? {
|
|
16469
|
-
branchPolicy: withReleaseTracks(workspaceRoot, resolveBranchPolicy(config, selected.policy ? { branchPolicy: selected.policy } : null)),
|
|
16539
|
+
branchPolicy: withReleaseTracks(workspaceRoot, resolveBranchPolicy(config, selected.policy ? { branchPolicy: selected.policy } : null, () => repoBranchPreset(workspaceRoot))),
|
|
16470
16540
|
provenance: { branchPolicy: selected.source }
|
|
16471
16541
|
} : {
|
|
16472
16542
|
commitPolicy: resolveCommitPolicy(config, selected.policy ? { commitPolicy: selected.policy } : null),
|
|
@@ -16663,11 +16733,11 @@ var segmentsOf = (command) => {
|
|
|
16663
16733
|
flushSegment();
|
|
16664
16734
|
return segments;
|
|
16665
16735
|
};
|
|
16666
|
-
var
|
|
16736
|
+
var PREFIXES2 = new Set(["sudo", "command", "env", "nohup", "time", "exec", "xargs"]);
|
|
16667
16737
|
var operands = (words) => words.filter((item) => !item.startsWith("-"));
|
|
16668
16738
|
var editsOf = (input) => {
|
|
16669
16739
|
let words = input;
|
|
16670
|
-
while (words.length && (
|
|
16740
|
+
while (words.length && (PREFIXES2.has(words[0]) || /^\w+=/.test(words[0])))
|
|
16671
16741
|
words = words.slice(1);
|
|
16672
16742
|
const [verb, ...args] = words;
|
|
16673
16743
|
const name = (verb?.split(/[\\/]/).at(-1) ?? "").toLowerCase();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brainervirus/workit-cursor",
|
|
3
|
-
"version": "8.0
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Workit Cursor plugin — shared MCP transport, native hooks, and sixteen method skills",
|
|
6
6
|
"keywords": [
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"build": "bun scripts/build.ts"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@brainervirus/workit-core": "^8.0
|
|
48
|
-
"@brainervirus/workit-mcp": "^8.0
|
|
47
|
+
"@brainervirus/workit-core": "^8.1.0",
|
|
48
|
+
"@brainervirus/workit-mcp": "^8.1.0"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
51
|
"node": ">=24"
|