@brainervirus/workit-mcp 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.
Files changed (2) hide show
  1. package/dist/index.js +172 -102
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -16574,7 +16574,7 @@ class StdioServerTransport {
16574
16574
  import { fileURLToPath as fileURLToPath2 } from "node:url";
16575
16575
 
16576
16576
  // packages/workit-core/src/core.ts
16577
- import { spawnSync as spawnSync12 } from "node:child_process";
16577
+ import { spawnSync as spawnSync13 } from "node:child_process";
16578
16578
  import { existsSync as existsSync7, realpathSync as realpathSync5 } from "node:fs";
16579
16579
  import path19 from "node:path";
16580
16580
 
@@ -22691,73 +22691,8 @@ var exportDigest = (bundle) => sha256({
22691
22691
  sourceWorkspaceId: bundle.sourceWorkspaceId,
22692
22692
  task: bundle.task
22693
22693
  });
22694
- // packages/workit-core/src/core/git.ts
22695
- import { execFileSync } from "node:child_process";
22696
- var run = (cwd, args) => {
22697
- try {
22698
- const stdout = execFileSync("git", args, {
22699
- cwd,
22700
- encoding: "utf8",
22701
- stdio: ["pipe", "pipe", "pipe"]
22702
- });
22703
- return { stdout: stdout.trimEnd(), stderr: "", exitCode: 0 };
22704
- } catch (error) {
22705
- const e = error;
22706
- return {
22707
- stdout: (e.stdout ?? "").trimEnd(),
22708
- stderr: (e.stderr ?? "").trimEnd(),
22709
- exitCode: e.status ?? 1
22710
- };
22711
- }
22712
- };
22713
- var gitContext = (workspaceRoot, paths = []) => {
22714
- const cwd = workspaceRoot;
22715
- let failure;
22716
- const runHere = (args) => {
22717
- const result = run(cwd, args);
22718
- if (!failure && result.exitCode !== 0) {
22719
- failure = { stderr: result.stderr, exitCode: result.exitCode };
22720
- }
22721
- return result.stdout;
22722
- };
22723
- const branch = runHere(["rev-parse", "--abbrev-ref", "HEAD"]) || "unknown";
22724
- const status_short = runHere(["status", "--porcelain"]);
22725
- const staged = [];
22726
- const unstaged = [];
22727
- const untracked = [];
22728
- for (const line of status_short.split(`
22729
- `).filter(Boolean)) {
22730
- const code = line.slice(0, 2);
22731
- const file = line.slice(3);
22732
- if (code === "??") {
22733
- untracked.push(file);
22734
- } else {
22735
- if (code[0] !== " " && code[0] !== "?")
22736
- staged.push(file);
22737
- if (code[1] !== " " && code[1] !== "?")
22738
- unstaged.push(file);
22739
- }
22740
- }
22741
- const pathArgs = paths.length ? ["--", ...paths] : [];
22742
- const diff_stat = runHere(["diff", "--stat", ...pathArgs]);
22743
- const cached_stat = runHere(["diff", "--cached", "--stat", ...pathArgs]);
22744
- const stagedSet = new Set(staged);
22745
- const unstagedSet = new Set(unstaged);
22746
- const partial_staged = [...stagedSet].filter((f) => unstagedSet.has(f));
22747
- return {
22748
- workspace_root: cwd,
22749
- branch,
22750
- status_short,
22751
- staged,
22752
- unstaged,
22753
- untracked,
22754
- diff_stat: [diff_stat, cached_stat].filter(Boolean).join(`
22755
- `),
22756
- partial_staged: partial_staged.length > 0,
22757
- partial_staged_files: partial_staged,
22758
- ...failure ? { stderr: failure.stderr, exitCode: failure.exitCode } : {}
22759
- };
22760
- };
22694
+ // packages/workit-core/src/core/branch-policy.ts
22695
+ import { spawnSync as spawnSync7 } from "node:child_process";
22761
22696
 
22762
22697
  // packages/workit-core/src/core/config.ts
22763
22698
  import {
@@ -22883,6 +22818,7 @@ var DEFAULTS = {
22883
22818
  },
22884
22819
  commitPolicy: { preset: "conventional" }
22885
22820
  };
22821
+ var unchosenBranchPolicy = new WeakSet([DEFAULTS]);
22886
22822
  var readSafe = (p) => {
22887
22823
  try {
22888
22824
  return readFileSync3(p, "utf8");
@@ -22907,22 +22843,21 @@ var parseConfigResult = (raw, file) => {
22907
22843
  const locale = LOCALE_RE.test(String(input.locale ?? "")) ? input.locale : DEFAULTS.locale;
22908
22844
  const preset = Object.hasOwn(PRESETS, input.branchPolicy?.preset) ? input.branchPolicy?.preset : "gitflow";
22909
22845
  const commitPreset = COMMIT_PRESETS.includes(String(input.commitPolicy?.preset ?? "")) ? input.commitPolicy?.preset : "conventional";
22910
- return {
22911
- status: "valid",
22912
- path: file,
22913
- config: {
22914
- locale,
22915
- localeOptions: Array.isArray(input.localeOptions) ? input.localeOptions : DEFAULTS.localeOptions,
22916
- branchPolicy: mergePreset(preset, {
22917
- allowed: Array.isArray(input.branchPolicy?.allowed) ? input.branchPolicy.allowed : undefined,
22918
- protectedNames: Array.isArray(input.branchPolicy?.protected) ? input.branchPolicy.protected : undefined
22919
- }, DEFAULTS),
22920
- commitPolicy: {
22921
- preset: commitPreset,
22922
- ...typeof input.commitPolicy?.pattern === "string" ? { pattern: input.commitPolicy.pattern } : {}
22923
- }
22846
+ const config = {
22847
+ locale,
22848
+ localeOptions: Array.isArray(input.localeOptions) ? input.localeOptions : DEFAULTS.localeOptions,
22849
+ branchPolicy: mergePreset(preset, {
22850
+ allowed: Array.isArray(input.branchPolicy?.allowed) ? input.branchPolicy.allowed : undefined,
22851
+ protectedNames: Array.isArray(input.branchPolicy?.protected) ? input.branchPolicy.protected : undefined
22852
+ }, DEFAULTS),
22853
+ commitPolicy: {
22854
+ preset: commitPreset,
22855
+ ...typeof input.commitPolicy?.pattern === "string" ? { pattern: input.commitPolicy.pattern } : {}
22924
22856
  }
22925
22857
  };
22858
+ if (!Object.hasOwn(PRESETS, input.branchPolicy?.preset))
22859
+ unchosenBranchPolicy.add(config);
22860
+ return { status: "valid", path: file, config };
22926
22861
  };
22927
22862
  var readConfigTyped = (dir) => {
22928
22863
  const file = path12.join(dir ?? configDir(), "config.json");
@@ -22936,9 +22871,11 @@ var readConfig = () => {
22936
22871
  };
22937
22872
  var vcsConfigPath = () => process.env.WORKFLOW_VCS_CONFIG ?? path12.join(configDir(), "vcs.json");
22938
22873
  var branchGlobPattern = (glob) => new RegExp(`^${glob.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*")}$`, "i");
22939
- var resolveBranchPolicy = (config, workspace) => {
22874
+ var resolveBranchPolicy = (config, workspace, repoPreset) => {
22940
22875
  const wp = workspace?.branchPolicy ?? {};
22941
- const preset = Object.hasOwn(PRESETS, wp.preset) ? wp.preset : config.branchPolicy?.preset ?? "gitflow";
22876
+ const workspacePreset = Object.hasOwn(PRESETS, wp.preset);
22877
+ const detected = !workspacePreset && unchosenBranchPolicy.has(config) ? repoPreset?.() ?? null : null;
22878
+ const preset = workspacePreset ? wp.preset : detected ?? config.branchPolicy?.preset ?? "gitflow";
22942
22879
  const merged = mergePreset(preset, {
22943
22880
  allowed: wp.allowed,
22944
22881
  protectedNames: wp.protected
@@ -22947,9 +22884,10 @@ var resolveBranchPolicy = (config, workspace) => {
22947
22884
  return {
22948
22885
  preset,
22949
22886
  allowed,
22950
- protected: new Set(merged.protected.map((p) => p.toLowerCase())),
22887
+ protected: new Set([...merged.protected, ...detected ? PRESETS.gitflow.protected : []].map((p) => p.toLowerCase())),
22951
22888
  integration: wp.integration === "merge" ? "merge" : "pr",
22952
- defaultTargetBranch: preset === "github-flow" ? "main" : preset === "trunk-based" ? "master" : "develop"
22889
+ defaultTargetBranch: preset === "github-flow" ? "main" : preset === "trunk-based" ? "master" : "develop",
22890
+ detected: detected !== null
22953
22891
  };
22954
22892
  };
22955
22893
  var COMMIT_PRESETS = [
@@ -22961,6 +22899,138 @@ var COMMIT_PRESETS = [
22961
22899
  "auto"
22962
22900
  ];
22963
22901
 
22902
+ // packages/workit-core/src/core/branch-policy.ts
22903
+ var PREFIXES = {
22904
+ feature: "feature/*",
22905
+ bugfix: "bugfix/*",
22906
+ release: "release/*",
22907
+ hotfix: "hotfix/*"
22908
+ };
22909
+ var branchNames = (workspaceRoot) => {
22910
+ const r = spawnSync7("git", ["for-each-ref", "--format=%(refname)", "refs/heads", "refs/remotes/origin"], { cwd: workspaceRoot, encoding: "utf8" });
22911
+ if (r.status !== 0)
22912
+ return new Set;
22913
+ return new Set((r.stdout ?? "").split(`
22914
+ `).filter(Boolean).map((ref) => ref.startsWith("refs/heads/") ? ref.slice("refs/heads/".length) : ref.slice("refs/remotes/origin/".length)));
22915
+ };
22916
+ var detectBranchPolicy = (workspaceRoot) => {
22917
+ const names = branchNames(workspaceRoot);
22918
+ const develop = names.has("develop");
22919
+ const main = names.has("main");
22920
+ const master = names.has("master");
22921
+ const root = main ? "main" : master ? "master" : null;
22922
+ if (develop) {
22923
+ return {
22924
+ preset: "gitflow",
22925
+ developBranch: "develop",
22926
+ integration: "merge",
22927
+ protected: root ? [root, "develop"] : ["develop"],
22928
+ allowed: [...PRESETS.gitflow.allowed],
22929
+ prefixes: PREFIXES
22930
+ };
22931
+ }
22932
+ if (root === "main") {
22933
+ return {
22934
+ preset: "github-flow",
22935
+ developBranch: null,
22936
+ integration: "pr",
22937
+ protected: [root],
22938
+ allowed: ["*"],
22939
+ prefixes: PREFIXES
22940
+ };
22941
+ }
22942
+ if (root === "master") {
22943
+ return {
22944
+ preset: "trunk-based",
22945
+ developBranch: null,
22946
+ integration: "pr",
22947
+ protected: [root],
22948
+ allowed: ["*"],
22949
+ prefixes: PREFIXES
22950
+ };
22951
+ }
22952
+ return {
22953
+ preset: "gitflow",
22954
+ developBranch: null,
22955
+ integration: "merge",
22956
+ protected: [],
22957
+ allowed: [],
22958
+ prefixes: PREFIXES
22959
+ };
22960
+ };
22961
+ var repoBranchPreset = (workspaceRoot) => {
22962
+ const detected = detectBranchPolicy(workspaceRoot);
22963
+ return detected.developBranch || detected.allowed.length ? detected.preset : null;
22964
+ };
22965
+
22966
+ // packages/workit-core/src/core/git.ts
22967
+ import { execFileSync } from "node:child_process";
22968
+ var run = (cwd, args) => {
22969
+ try {
22970
+ const stdout = execFileSync("git", args, {
22971
+ cwd,
22972
+ encoding: "utf8",
22973
+ stdio: ["pipe", "pipe", "pipe"]
22974
+ });
22975
+ return { stdout: stdout.trimEnd(), stderr: "", exitCode: 0 };
22976
+ } catch (error) {
22977
+ const e = error;
22978
+ return {
22979
+ stdout: (e.stdout ?? "").trimEnd(),
22980
+ stderr: (e.stderr ?? "").trimEnd(),
22981
+ exitCode: e.status ?? 1
22982
+ };
22983
+ }
22984
+ };
22985
+ var gitContext = (workspaceRoot, paths = []) => {
22986
+ const cwd = workspaceRoot;
22987
+ let failure;
22988
+ const runHere = (args) => {
22989
+ const result = run(cwd, args);
22990
+ if (!failure && result.exitCode !== 0) {
22991
+ failure = { stderr: result.stderr, exitCode: result.exitCode };
22992
+ }
22993
+ return result.stdout;
22994
+ };
22995
+ const branch = runHere(["rev-parse", "--abbrev-ref", "HEAD"]) || "unknown";
22996
+ const status_short = runHere(["status", "--porcelain"]);
22997
+ const staged = [];
22998
+ const unstaged = [];
22999
+ const untracked = [];
23000
+ for (const line of status_short.split(`
23001
+ `).filter(Boolean)) {
23002
+ const code = line.slice(0, 2);
23003
+ const file = line.slice(3);
23004
+ if (code === "??") {
23005
+ untracked.push(file);
23006
+ } else {
23007
+ if (code[0] !== " " && code[0] !== "?")
23008
+ staged.push(file);
23009
+ if (code[1] !== " " && code[1] !== "?")
23010
+ unstaged.push(file);
23011
+ }
23012
+ }
23013
+ const pathArgs = paths.length ? ["--", ...paths] : [];
23014
+ const diff_stat = runHere(["diff", "--stat", ...pathArgs]);
23015
+ const cached_stat = runHere(["diff", "--cached", "--stat", ...pathArgs]);
23016
+ const stagedSet = new Set(staged);
23017
+ const unstagedSet = new Set(unstaged);
23018
+ const partial_staged = [...stagedSet].filter((f) => unstagedSet.has(f));
23019
+ return {
23020
+ workspace_root: cwd,
23021
+ branch,
23022
+ status_short,
23023
+ staged,
23024
+ unstaged,
23025
+ untracked,
23026
+ diff_stat: [diff_stat, cached_stat].filter(Boolean).join(`
23027
+ `),
23028
+ partial_staged: partial_staged.length > 0,
23029
+ partial_staged_files: partial_staged,
23030
+ ...failure ? { stderr: failure.stderr, exitCode: failure.exitCode } : {}
23031
+ };
23032
+ };
23033
+
22964
23034
  // packages/workit-core/src/core/workspaces.ts
22965
23035
  import { createHash as createHash8 } from "node:crypto";
22966
23036
  import { readFileSync as readFileSync4, realpathSync as realpathSync3 } from "node:fs";
@@ -23366,18 +23436,18 @@ function workspaceDefaultTarget(cwd, globalDefault) {
23366
23436
  const wp = ws?.branchPolicy ?? {};
23367
23437
  const hasWorkspacePolicy = typeof wp.preset === "string" && Object.hasOwn(PRESETS, wp.preset);
23368
23438
  const selected = resolveRuntimeWorkspacePolicy(cwd, "branch", process.env.WORKFLOW_PROFILE?.trim() || undefined);
23369
- const policyDefault = resolveBranchPolicy(readConfig(), selected.policy ? { branchPolicy: selected.policy } : null).defaultTargetBranch;
23439
+ const policyDefault = resolveBranchPolicy(readConfig(), selected.policy ? { branchPolicy: selected.policy } : null, () => repoBranchPreset(cwd)).defaultTargetBranch;
23370
23440
  return String(ws?.vcs?.defaultTargetBranch ?? (hasWorkspacePolicy ? policyDefault : globalDefault ?? policyDefault) ?? "develop");
23371
23441
  }
23372
23442
 
23373
23443
  // packages/workit-core/src/core/vcs-config.ts
23374
23444
  import fs12 from "node:fs";
23375
23445
  import path14 from "node:path";
23376
- import { spawnSync as spawnSync8 } from "node:child_process";
23446
+ import { spawnSync as spawnSync9 } from "node:child_process";
23377
23447
 
23378
23448
  // packages/workit-core/src/core/release-tracks.ts
23379
23449
  import { createHash as createHash9 } from "node:crypto";
23380
- import { spawnSync as spawnSync7 } from "node:child_process";
23450
+ import { spawnSync as spawnSync8 } from "node:child_process";
23381
23451
  var KNOWN_FIELDS = new Set([
23382
23452
  "strategy",
23383
23453
  "productionBranch",
@@ -23649,7 +23719,7 @@ function resolveReleaseTrack(input) {
23649
23719
  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 ")}`);
23650
23720
  }
23651
23721
  var git4 = (cwd, args) => {
23652
- const run = spawnSync7("git", args, {
23722
+ const run = spawnSync8("git", args, {
23653
23723
  cwd,
23654
23724
  encoding: "utf8",
23655
23725
  timeout: 20000,
@@ -23764,7 +23834,7 @@ function resolveTrackFor(cwd, options) {
23764
23834
  var workspacesPath = () => path14.join(configDir(), "workspaces.json");
23765
23835
  var vcsCwd = (cwd) => cwd ?? process.env.WORKFLOW_WORKSPACE_ROOT ?? process.cwd();
23766
23836
  var remoteProvider = (cwd) => {
23767
- const r = spawnSync8("git", ["remote", "get-url", "origin"], { cwd, encoding: "utf8" });
23837
+ const r = spawnSync9("git", ["remote", "get-url", "origin"], { cwd, encoding: "utf8" });
23768
23838
  if (r.status !== 0)
23769
23839
  return null;
23770
23840
  const url = (r.stdout ?? "").trim();
@@ -23801,7 +23871,7 @@ var remoteEndpoint = (remote) => {
23801
23871
  var configuredSshEndpoint = (host) => {
23802
23872
  if (host.startsWith("-"))
23803
23873
  return null;
23804
- const resolved = spawnSync8("ssh", ["-G", host], {
23874
+ const resolved = spawnSync9("ssh", ["-G", host], {
23805
23875
  encoding: "utf8",
23806
23876
  timeout: 5000,
23807
23877
  maxBuffer: 1024 * 1024,
@@ -23974,7 +24044,7 @@ function mergedPrStyle(limit = 6, cwd) {
23974
24044
  `).filter((l) => l.startsWith("## ")).map((l) => l.trim()),
23975
24045
  descriptionPreview: desc.slice(0, 600)
23976
24046
  });
23977
- const remoteResult = spawnSync8("git", ["remote", "get-url", "--push", "--all", "origin"], {
24047
+ const remoteResult = spawnSync9("git", ["remote", "get-url", "--push", "--all", "origin"], {
23978
24048
  cwd,
23979
24049
  encoding: "utf8"
23980
24050
  });
@@ -23990,7 +24060,7 @@ function mergedPrStyle(limit = 6, cwd) {
23990
24060
  if (!hostingApiHostMatches(remote, host))
23991
24061
  return { ok: false, error: "PR style target does not match the provider host" };
23992
24062
  if (provider === "gitlab") {
23993
- const run = (args) => spawnSync8("glab", ["api", ...args], {
24063
+ const run = (args) => spawnSync9("glab", ["api", ...args], {
23994
24064
  cwd,
23995
24065
  encoding: "utf8",
23996
24066
  env
@@ -24010,7 +24080,7 @@ function mergedPrStyle(limit = 6, cwd) {
24010
24080
  });
24011
24081
  }
24012
24082
  } else if (provider === "github") {
24013
- const r = spawnSync8("gh", [
24083
+ const r = spawnSync9("gh", [
24014
24084
  "pr",
24015
24085
  "list",
24016
24086
  "--repo",
@@ -25947,7 +26017,7 @@ class WorkitCore {
25947
26017
  }
25948
26018
  }
25949
26019
  // packages/workit-core/src/core/repo-context.ts
25950
- import { spawnSync as spawnSync9 } from "node:child_process";
26020
+ import { spawnSync as spawnSync10 } from "node:child_process";
25951
26021
  import { existsSync as existsSync6, readFileSync as readFileSync5, readdirSync as readdirSync4 } from "node:fs";
25952
26022
  import path16 from "node:path";
25953
26023
  var isSafeContextRange = (value) => value.length <= 4096 && (() => {
@@ -25976,7 +26046,7 @@ var invalidRange = (cwd) => ({
25976
26046
  cwd
25977
26047
  });
25978
26048
  var runGit = (cwd, args) => {
25979
- const result = spawnSync9("git", args, { cwd, encoding: "utf8" });
26049
+ const result = spawnSync10("git", args, { cwd, encoding: "utf8" });
25980
26050
  return {
25981
26051
  stdout: (result.stdout ?? "").trimEnd(),
25982
26052
  stderr: (result.stderr ?? "").trimEnd(),
@@ -26417,12 +26487,12 @@ function releaseNotesContext(root, rangeOrTag) {
26417
26487
  }
26418
26488
 
26419
26489
  // packages/workit-core/src/core/tracker-issues.ts
26420
- import { spawnSync as spawnSync11 } from "node:child_process";
26490
+ import { spawnSync as spawnSync12 } from "node:child_process";
26421
26491
 
26422
26492
  // packages/workit-core/src/core/pr-create.ts
26423
26493
  import fs13 from "node:fs";
26424
26494
  import path17 from "node:path";
26425
- import { spawnSync as spawnSync10 } from "node:child_process";
26495
+ import { spawnSync as spawnSync11 } from "node:child_process";
26426
26496
  // packages/workit-core/src/forge/pr-body.ts
26427
26497
  function parseGhIssue(value) {
26428
26498
  const m = /issues\/(\d+)/.exec(value);
@@ -26447,7 +26517,7 @@ function whichOnPath(tool) {
26447
26517
  }
26448
26518
  var hostingCliAvailable = (provider) => whichOnPath(provider === "gitlab" ? "glab" : "gh") !== null;
26449
26519
  var pushRemote = (cwd) => {
26450
- const result = spawnSync10("git", ["remote", "get-url", "--push", "--all", "origin"], {
26520
+ const result = spawnSync11("git", ["remote", "get-url", "--push", "--all", "origin"], {
26451
26521
  cwd,
26452
26522
  encoding: "utf8"
26453
26523
  });
@@ -26478,7 +26548,7 @@ var defaultCli = (bin, available) => {
26478
26548
  if (!available)
26479
26549
  return null;
26480
26550
  return (args, root) => {
26481
- const out = spawnSync11(bin, args, {
26551
+ const out = spawnSync12(bin, args, {
26482
26552
  cwd: root,
26483
26553
  encoding: "utf8",
26484
26554
  env: { ...process.env, PATH: process.env.PATH ?? "" }
@@ -26996,7 +27066,7 @@ function resolveInside(root, candidate) {
26996
27066
  }
26997
27067
  function run2(root, executable, args, env = {}) {
26998
27068
  const cwd = realpathSync5(root);
26999
- const result = spawnSync12(executable, args, {
27069
+ const result = spawnSync13(executable, args, {
27000
27070
  cwd,
27001
27071
  encoding: "utf8",
27002
27072
  env: { ...process.env, ...env }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brainervirus/workit-mcp",
3
- "version": "8.0.1",
3
+ "version": "8.1.0",
4
4
  "private": false,
5
5
  "description": "Workit shared MCP transport for the eight task and policy operation families",
6
6
  "keywords": [
@@ -42,7 +42,7 @@
42
42
  "build": "bun scripts/build.ts"
43
43
  },
44
44
  "dependencies": {
45
- "@brainervirus/workit-core": "^8.0.1",
45
+ "@brainervirus/workit-core": "^8.1.0",
46
46
  "@modelcontextprotocol/sdk": "1.32.0",
47
47
  "zod": "4.6.5"
48
48
  },