@brainervirus/workit-cursor 8.0.1 → 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/.cursor-plugin/plugin.json +1 -1
- package/dist/cursor-session-start.js +161 -64
- package/dist/mcp-server.js +235 -136
- package/dist/workit-hook.js +161 -62
- package/package.json +3 -3
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 spawnSync14 } 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,7 +22901,140 @@ 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
|
|
23037
|
+
import { spawnSync as spawnSync8 } from "node:child_process";
|
|
22967
23038
|
import { createHash as createHash8 } from "node:crypto";
|
|
22968
23039
|
import { readFileSync as readFileSync4, realpathSync as realpathSync3 } from "node:fs";
|
|
22969
23040
|
import path13 from "node:path";
|
|
@@ -23208,6 +23279,53 @@ var validateWorkspaceGlob = (glob) => {
|
|
|
23208
23279
|
}
|
|
23209
23280
|
return { ok: true };
|
|
23210
23281
|
};
|
|
23282
|
+
|
|
23283
|
+
class WorkspaceConfigError extends Error {
|
|
23284
|
+
name = "WorkspaceConfigError";
|
|
23285
|
+
}
|
|
23286
|
+
var mainCheckouts = new Map;
|
|
23287
|
+
var mainCheckoutOf = (cwd) => {
|
|
23288
|
+
const cached = mainCheckouts.get(cwd);
|
|
23289
|
+
if (cached !== undefined)
|
|
23290
|
+
return cached;
|
|
23291
|
+
const env = { ...process.env };
|
|
23292
|
+
for (const name of ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_INDEX_FILE"])
|
|
23293
|
+
delete env[name];
|
|
23294
|
+
const git = (args) => {
|
|
23295
|
+
const run = spawnSync8("git", args, {
|
|
23296
|
+
cwd,
|
|
23297
|
+
env,
|
|
23298
|
+
encoding: "utf8",
|
|
23299
|
+
timeout: 5000,
|
|
23300
|
+
windowsHide: true
|
|
23301
|
+
});
|
|
23302
|
+
return run.status === 0 ? run.stdout : null;
|
|
23303
|
+
};
|
|
23304
|
+
let main = null;
|
|
23305
|
+
const dirs = git(["rev-parse", "--path-format=absolute", "--git-dir", "--git-common-dir"]);
|
|
23306
|
+
const [gitDir, common] = (dirs ?? "").trim().split(/\r?\n/u);
|
|
23307
|
+
if (gitDir && common && path13.resolve(gitDir) !== path13.resolve(common)) {
|
|
23308
|
+
const listed = /^worktree (.+)$/mu.exec(git(["worktree", "list", "--porcelain"]) ?? "")?.[1];
|
|
23309
|
+
main = listed?.trim() || (path13.basename(common) === ".git" ? path13.dirname(common) : common);
|
|
23310
|
+
}
|
|
23311
|
+
mainCheckouts.set(cwd, main);
|
|
23312
|
+
return main;
|
|
23313
|
+
};
|
|
23314
|
+
var matchingEntries = (cwd, entries) => {
|
|
23315
|
+
const match = (where) => {
|
|
23316
|
+
const targets = [where, realpathOf(where)].map((value) => value.replaceAll("\\", "/"));
|
|
23317
|
+
return entries.filter((entry) => {
|
|
23318
|
+
const glob = entry.glob.replaceAll("\\", "/");
|
|
23319
|
+
const canonical = canonicalGlob(glob);
|
|
23320
|
+
return targets.some((target) => matchWorkspace(glob, target) || canonical !== glob && matchWorkspace(canonical, target));
|
|
23321
|
+
});
|
|
23322
|
+
};
|
|
23323
|
+
const direct = match(cwd);
|
|
23324
|
+
if (direct.length)
|
|
23325
|
+
return direct;
|
|
23326
|
+
const main = mainCheckoutOf(cwd);
|
|
23327
|
+
return main ? match(main) : direct;
|
|
23328
|
+
};
|
|
23211
23329
|
var realpathOf = (p) => {
|
|
23212
23330
|
const real = realpathSync3.native ?? realpathSync3;
|
|
23213
23331
|
try {
|
|
@@ -23232,43 +23350,29 @@ var selectWorkspaceMatch = (matches, cwd, workspaceName) => {
|
|
|
23232
23350
|
if (named.length === 1)
|
|
23233
23351
|
return named[0];
|
|
23234
23352
|
if (named.length > 1)
|
|
23235
|
-
throw new
|
|
23353
|
+
throw new WorkspaceConfigError(`ambiguous workspace ${JSON.stringify(workspaceName)} for ${cwd}`);
|
|
23236
23354
|
if (matches.length > 0) {
|
|
23237
|
-
throw new
|
|
23355
|
+
throw new WorkspaceConfigError(`workspace ${JSON.stringify(workspaceName)} does not match ${cwd}; matching choices: ${matches.map((entry) => entry.name).join(", ")}`);
|
|
23238
23356
|
}
|
|
23239
|
-
throw new
|
|
23357
|
+
throw new WorkspaceConfigError(`workspace ${JSON.stringify(workspaceName)} does not match ${cwd}`);
|
|
23240
23358
|
}
|
|
23241
23359
|
if (matches.length < 2)
|
|
23242
23360
|
return matches[0];
|
|
23243
23361
|
const highestSpecificity = Math.max(...matches.map((entry) => globSpecificity(entry.glob)));
|
|
23244
23362
|
const mostSpecific = matches.filter((entry) => globSpecificity(entry.glob) === highestSpecificity);
|
|
23245
23363
|
if (mostSpecific.length > 1) {
|
|
23246
|
-
throw new
|
|
23364
|
+
throw new WorkspaceConfigError(`ambiguous workspace for ${cwd}; choose one of: ${mostSpecific.map((entry) => entry.name).join(", ")}`);
|
|
23247
23365
|
}
|
|
23248
23366
|
return mostSpecific[0];
|
|
23249
23367
|
};
|
|
23250
23368
|
var resolveWorkspaceFromEntries = (cwd, entries, workspaceName) => {
|
|
23251
|
-
const
|
|
23252
|
-
const matches = [];
|
|
23253
|
-
for (const ws of entries) {
|
|
23254
|
-
const glob = ws.glob.replaceAll("\\", "/");
|
|
23255
|
-
const canonical = canonicalGlob(glob);
|
|
23256
|
-
let matched = false;
|
|
23257
|
-
for (const target of targets) {
|
|
23258
|
-
if (matchWorkspace(glob, target) || canonical !== glob && matchWorkspace(canonical, target)) {
|
|
23259
|
-
matched = true;
|
|
23260
|
-
break;
|
|
23261
|
-
}
|
|
23262
|
-
}
|
|
23263
|
-
if (matched)
|
|
23264
|
-
matches.push(ws);
|
|
23265
|
-
}
|
|
23369
|
+
const matches = matchingEntries(cwd, entries);
|
|
23266
23370
|
return selectWorkspaceMatch(matches, cwd, workspaceName) ?? null;
|
|
23267
23371
|
};
|
|
23268
23372
|
var resolveWorkspaceFrom = (cwd, dir, workspaceName) => {
|
|
23269
23373
|
const result = readWorkspacesResult(dir);
|
|
23270
23374
|
if (result.status === "malformed" || result.status === "invalid")
|
|
23271
|
-
throw new
|
|
23375
|
+
throw new WorkspaceConfigError(result.error);
|
|
23272
23376
|
return resolveWorkspaceFromEntries(cwd, result.entries, workspaceName);
|
|
23273
23377
|
};
|
|
23274
23378
|
var runtimeWorkspacePolicySchema = (kind) => {
|
|
@@ -23300,31 +23404,26 @@ var matchRuntimeWorkspace = (cwd) => {
|
|
|
23300
23404
|
} catch (error) {
|
|
23301
23405
|
if (error.code === "ENOENT")
|
|
23302
23406
|
return null;
|
|
23303
|
-
throw new
|
|
23407
|
+
throw new WorkspaceConfigError(`${file} could not be read: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
23304
23408
|
}
|
|
23305
23409
|
let parsed;
|
|
23306
23410
|
try {
|
|
23307
23411
|
parsed = JSON.parse(raw);
|
|
23308
23412
|
} catch {
|
|
23309
|
-
throw new
|
|
23413
|
+
throw new WorkspaceConfigError(`${file} is not valid JSON`);
|
|
23310
23414
|
}
|
|
23311
23415
|
const validated = runtimeWorkspaceIndexSchema.safeParse(parsed);
|
|
23312
23416
|
if (!validated.success) {
|
|
23313
23417
|
const detail = validated.error.issues.map((issue) => `${issue.path.map(String).join(".") || "workspaces"}: ${issue.message}`).join("; ");
|
|
23314
|
-
throw new
|
|
23418
|
+
throw new WorkspaceConfigError(`${file} has invalid workspace matching data: ${detail}`);
|
|
23315
23419
|
}
|
|
23316
23420
|
const entries = validated.data.workspaces;
|
|
23317
23421
|
for (const entry of entries ?? []) {
|
|
23318
23422
|
const glob = validateWorkspaceGlob(entry.glob);
|
|
23319
23423
|
if (!glob.ok)
|
|
23320
|
-
throw new
|
|
23424
|
+
throw new WorkspaceConfigError(`${file} workspace ${entry.name}: ${glob.error}`);
|
|
23321
23425
|
}
|
|
23322
|
-
const
|
|
23323
|
-
const matches = (entries ?? []).filter((entry) => {
|
|
23324
|
-
const glob = entry.glob.replaceAll("\\", "/");
|
|
23325
|
-
const canonical = canonicalGlob(glob);
|
|
23326
|
-
return targets.some((target) => matchWorkspace(glob, target) || canonical !== glob && matchWorkspace(canonical, target));
|
|
23327
|
-
});
|
|
23426
|
+
const matches = matchingEntries(cwd, entries ?? []);
|
|
23328
23427
|
const workspaceName = process.env.WORKFLOW_WORKSPACE_NAME?.trim() || undefined;
|
|
23329
23428
|
const selected = selectWorkspaceMatch(matches, cwd, workspaceName);
|
|
23330
23429
|
return selected ? { file, selected } : null;
|
|
@@ -23341,7 +23440,7 @@ var resolveRuntimeWorkspaceCandidate = (cwd, kind) => {
|
|
|
23341
23440
|
const policy = runtimeWorkspacePolicySchema(kind).safeParse(selected);
|
|
23342
23441
|
if (!policy.success) {
|
|
23343
23442
|
const detail = policy.error.issues.map((issue) => `${issue.path.map(String).join(".") || "workspace"}: ${issue.message}`).join("; ");
|
|
23344
|
-
throw new
|
|
23443
|
+
throw new WorkspaceConfigError(`${file} has invalid ${kind} policy configuration: ${detail}`);
|
|
23345
23444
|
}
|
|
23346
23445
|
return policy.data;
|
|
23347
23446
|
};
|
|
@@ -23352,10 +23451,10 @@ var resolveRuntimeWorkspacePolicy = (cwd, kind, requestedProfile) => {
|
|
|
23352
23451
|
const key = kind === "branch" ? "branchPolicy" : "commitPolicy";
|
|
23353
23452
|
const profileName = requestedProfile?.trim() || candidate.defaultProfile;
|
|
23354
23453
|
if (candidate.defaultProfile && !Object.hasOwn(candidate.profiles ?? {}, candidate.defaultProfile))
|
|
23355
|
-
throw new
|
|
23454
|
+
throw new WorkspaceConfigError(`workspace ${JSON.stringify(candidate.name)} has no profile ${JSON.stringify(candidate.defaultProfile)}`);
|
|
23356
23455
|
const profile = profileName ? candidate.profiles?.[profileName] : undefined;
|
|
23357
23456
|
if (profileName && !profile)
|
|
23358
|
-
throw new
|
|
23457
|
+
throw new WorkspaceConfigError(`workspace ${JSON.stringify(candidate.name)} has no profile ${JSON.stringify(profileName)}`);
|
|
23359
23458
|
const profilePolicy = profile?.[key];
|
|
23360
23459
|
const workspacePolicy = candidate[key];
|
|
23361
23460
|
return {
|
|
@@ -23368,18 +23467,18 @@ function workspaceDefaultTarget(cwd, globalDefault) {
|
|
|
23368
23467
|
const wp = ws?.branchPolicy ?? {};
|
|
23369
23468
|
const hasWorkspacePolicy = typeof wp.preset === "string" && Object.hasOwn(PRESETS, wp.preset);
|
|
23370
23469
|
const selected = resolveRuntimeWorkspacePolicy(cwd, "branch", process.env.WORKFLOW_PROFILE?.trim() || undefined);
|
|
23371
|
-
const policyDefault = resolveBranchPolicy(readConfig(), selected.policy ? { branchPolicy: selected.policy } : null).defaultTargetBranch;
|
|
23470
|
+
const policyDefault = resolveBranchPolicy(readConfig(), selected.policy ? { branchPolicy: selected.policy } : null, () => repoBranchPreset(cwd)).defaultTargetBranch;
|
|
23372
23471
|
return String(ws?.vcs?.defaultTargetBranch ?? (hasWorkspacePolicy ? policyDefault : globalDefault ?? policyDefault) ?? "develop");
|
|
23373
23472
|
}
|
|
23374
23473
|
|
|
23375
23474
|
// packages/workit-core/src/core/vcs-config.ts
|
|
23376
23475
|
import fs12 from "node:fs";
|
|
23377
23476
|
import path14 from "node:path";
|
|
23378
|
-
import { spawnSync as
|
|
23477
|
+
import { spawnSync as spawnSync10 } from "node:child_process";
|
|
23379
23478
|
|
|
23380
23479
|
// packages/workit-core/src/core/release-tracks.ts
|
|
23381
23480
|
import { createHash as createHash9 } from "node:crypto";
|
|
23382
|
-
import { spawnSync as
|
|
23481
|
+
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
23383
23482
|
var KNOWN_FIELDS = new Set([
|
|
23384
23483
|
"strategy",
|
|
23385
23484
|
"productionBranch",
|
|
@@ -23651,7 +23750,7 @@ function resolveReleaseTrack(input) {
|
|
|
23651
23750
|
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
23751
|
}
|
|
23653
23752
|
var git4 = (cwd, args) => {
|
|
23654
|
-
const run =
|
|
23753
|
+
const run = spawnSync9("git", args, {
|
|
23655
23754
|
cwd,
|
|
23656
23755
|
encoding: "utf8",
|
|
23657
23756
|
timeout: 20000,
|
|
@@ -23766,7 +23865,7 @@ function resolveTrackFor(cwd, options) {
|
|
|
23766
23865
|
var workspacesPath = () => path14.join(configDir(), "workspaces.json");
|
|
23767
23866
|
var vcsCwd = (cwd) => cwd ?? process.env.WORKFLOW_WORKSPACE_ROOT ?? process.cwd();
|
|
23768
23867
|
var remoteProvider = (cwd) => {
|
|
23769
|
-
const r =
|
|
23868
|
+
const r = spawnSync10("git", ["remote", "get-url", "origin"], { cwd, encoding: "utf8" });
|
|
23770
23869
|
if (r.status !== 0)
|
|
23771
23870
|
return null;
|
|
23772
23871
|
const url = (r.stdout ?? "").trim();
|
|
@@ -23803,7 +23902,7 @@ var remoteEndpoint = (remote) => {
|
|
|
23803
23902
|
var configuredSshEndpoint = (host) => {
|
|
23804
23903
|
if (host.startsWith("-"))
|
|
23805
23904
|
return null;
|
|
23806
|
-
const resolved =
|
|
23905
|
+
const resolved = spawnSync10("ssh", ["-G", host], {
|
|
23807
23906
|
encoding: "utf8",
|
|
23808
23907
|
timeout: 5000,
|
|
23809
23908
|
maxBuffer: 1024 * 1024,
|
|
@@ -23976,7 +24075,7 @@ function mergedPrStyle(limit = 6, cwd) {
|
|
|
23976
24075
|
`).filter((l) => l.startsWith("## ")).map((l) => l.trim()),
|
|
23977
24076
|
descriptionPreview: desc.slice(0, 600)
|
|
23978
24077
|
});
|
|
23979
|
-
const remoteResult =
|
|
24078
|
+
const remoteResult = spawnSync10("git", ["remote", "get-url", "--push", "--all", "origin"], {
|
|
23980
24079
|
cwd,
|
|
23981
24080
|
encoding: "utf8"
|
|
23982
24081
|
});
|
|
@@ -23992,7 +24091,7 @@ function mergedPrStyle(limit = 6, cwd) {
|
|
|
23992
24091
|
if (!hostingApiHostMatches(remote, host))
|
|
23993
24092
|
return { ok: false, error: "PR style target does not match the provider host" };
|
|
23994
24093
|
if (provider === "gitlab") {
|
|
23995
|
-
const run = (args) =>
|
|
24094
|
+
const run = (args) => spawnSync10("glab", ["api", ...args], {
|
|
23996
24095
|
cwd,
|
|
23997
24096
|
encoding: "utf8",
|
|
23998
24097
|
env
|
|
@@ -24012,7 +24111,7 @@ function mergedPrStyle(limit = 6, cwd) {
|
|
|
24012
24111
|
});
|
|
24013
24112
|
}
|
|
24014
24113
|
} else if (provider === "github") {
|
|
24015
|
-
const r =
|
|
24114
|
+
const r = spawnSync10("gh", [
|
|
24016
24115
|
"pr",
|
|
24017
24116
|
"list",
|
|
24018
24117
|
"--repo",
|
|
@@ -25949,7 +26048,7 @@ class WorkitCore {
|
|
|
25949
26048
|
}
|
|
25950
26049
|
}
|
|
25951
26050
|
// packages/workit-core/src/core/repo-context.ts
|
|
25952
|
-
import { spawnSync as
|
|
26051
|
+
import { spawnSync as spawnSync11 } from "node:child_process";
|
|
25953
26052
|
import { existsSync as existsSync6, readFileSync as readFileSync5, readdirSync as readdirSync4 } from "node:fs";
|
|
25954
26053
|
import path16 from "node:path";
|
|
25955
26054
|
var isSafeContextRange = (value) => value.length <= 4096 && (() => {
|
|
@@ -25978,7 +26077,7 @@ var invalidRange = (cwd) => ({
|
|
|
25978
26077
|
cwd
|
|
25979
26078
|
});
|
|
25980
26079
|
var runGit = (cwd, args) => {
|
|
25981
|
-
const result =
|
|
26080
|
+
const result = spawnSync11("git", args, { cwd, encoding: "utf8" });
|
|
25982
26081
|
return {
|
|
25983
26082
|
stdout: (result.stdout ?? "").trimEnd(),
|
|
25984
26083
|
stderr: (result.stderr ?? "").trimEnd(),
|
|
@@ -26419,12 +26518,12 @@ function releaseNotesContext(root, rangeOrTag) {
|
|
|
26419
26518
|
}
|
|
26420
26519
|
|
|
26421
26520
|
// packages/workit-core/src/core/tracker-issues.ts
|
|
26422
|
-
import { spawnSync as
|
|
26521
|
+
import { spawnSync as spawnSync13 } from "node:child_process";
|
|
26423
26522
|
|
|
26424
26523
|
// packages/workit-core/src/core/pr-create.ts
|
|
26425
26524
|
import fs13 from "node:fs";
|
|
26426
26525
|
import path17 from "node:path";
|
|
26427
|
-
import { spawnSync as
|
|
26526
|
+
import { spawnSync as spawnSync12 } from "node:child_process";
|
|
26428
26527
|
// packages/workit-core/src/forge/pr-body.ts
|
|
26429
26528
|
function parseGhIssue(value) {
|
|
26430
26529
|
const m = /issues\/(\d+)/.exec(value);
|
|
@@ -26449,7 +26548,7 @@ function whichOnPath(tool) {
|
|
|
26449
26548
|
}
|
|
26450
26549
|
var hostingCliAvailable = (provider) => whichOnPath(provider === "gitlab" ? "glab" : "gh") !== null;
|
|
26451
26550
|
var pushRemote = (cwd) => {
|
|
26452
|
-
const result =
|
|
26551
|
+
const result = spawnSync12("git", ["remote", "get-url", "--push", "--all", "origin"], {
|
|
26453
26552
|
cwd,
|
|
26454
26553
|
encoding: "utf8"
|
|
26455
26554
|
});
|
|
@@ -26480,7 +26579,7 @@ var defaultCli = (bin, available) => {
|
|
|
26480
26579
|
if (!available)
|
|
26481
26580
|
return null;
|
|
26482
26581
|
return (args, root) => {
|
|
26483
|
-
const out =
|
|
26582
|
+
const out = spawnSync13(bin, args, {
|
|
26484
26583
|
cwd: root,
|
|
26485
26584
|
encoding: "utf8",
|
|
26486
26585
|
env: { ...process.env, PATH: process.env.PATH ?? "" }
|
|
@@ -26998,7 +27097,7 @@ function resolveInside(root, candidate) {
|
|
|
26998
27097
|
}
|
|
26999
27098
|
function run2(root, executable, args, env = {}) {
|
|
27000
27099
|
const cwd = realpathSync5(root);
|
|
27001
|
-
const result =
|
|
27100
|
+
const result = spawnSync14(executable, args, {
|
|
27002
27101
|
cwd,
|
|
27003
27102
|
encoding: "utf8",
|
|
27004
27103
|
env: { ...process.env, ...env }
|
|
@@ -27410,7 +27509,7 @@ var signals = new Map;
|
|
|
27410
27509
|
var cache = new Map;
|
|
27411
27510
|
// packages/workit-core/src/hooks/write-gate.ts
|
|
27412
27511
|
var CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "win32";
|
|
27413
|
-
var
|
|
27512
|
+
var PREFIXES2 = new Set(["sudo", "command", "env", "nohup", "time", "exec", "xargs"]);
|
|
27414
27513
|
var cache2 = new Map;
|
|
27415
27514
|
// packages/workit-core/src/hooks/hosts/fields.ts
|
|
27416
27515
|
var SHELLS = new Set(["sh", "bash", "zsh", "dash", "pwsh", "powershell", "cmd"]);
|