@brainervirus/workit-mcp 8.1.0 → 8.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +78 -49
  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 spawnSync13 } from "node:child_process";
16577
+ import { spawnSync as spawnSync14 } 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
 
@@ -23032,6 +23032,7 @@ var gitContext = (workspaceRoot, paths = []) => {
23032
23032
  };
23033
23033
 
23034
23034
  // packages/workit-core/src/core/workspaces.ts
23035
+ import { spawnSync as spawnSync8 } from "node:child_process";
23035
23036
  import { createHash as createHash8 } from "node:crypto";
23036
23037
  import { readFileSync as readFileSync4, realpathSync as realpathSync3 } from "node:fs";
23037
23038
  import path13 from "node:path";
@@ -23276,6 +23277,53 @@ var validateWorkspaceGlob = (glob) => {
23276
23277
  }
23277
23278
  return { ok: true };
23278
23279
  };
23280
+
23281
+ class WorkspaceConfigError extends Error {
23282
+ name = "WorkspaceConfigError";
23283
+ }
23284
+ var mainCheckouts = new Map;
23285
+ var mainCheckoutOf = (cwd) => {
23286
+ const cached = mainCheckouts.get(cwd);
23287
+ if (cached !== undefined)
23288
+ return cached;
23289
+ const env = { ...process.env };
23290
+ for (const name of ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_INDEX_FILE"])
23291
+ delete env[name];
23292
+ const git = (args) => {
23293
+ const run = spawnSync8("git", args, {
23294
+ cwd,
23295
+ env,
23296
+ encoding: "utf8",
23297
+ timeout: 5000,
23298
+ windowsHide: true
23299
+ });
23300
+ return run.status === 0 ? run.stdout : null;
23301
+ };
23302
+ let main = null;
23303
+ const dirs = git(["rev-parse", "--path-format=absolute", "--git-dir", "--git-common-dir"]);
23304
+ const [gitDir, common] = (dirs ?? "").trim().split(/\r?\n/u);
23305
+ if (gitDir && common && path13.resolve(gitDir) !== path13.resolve(common)) {
23306
+ const listed = /^worktree (.+)$/mu.exec(git(["worktree", "list", "--porcelain"]) ?? "")?.[1];
23307
+ main = listed?.trim() || (path13.basename(common) === ".git" ? path13.dirname(common) : common);
23308
+ }
23309
+ mainCheckouts.set(cwd, main);
23310
+ return main;
23311
+ };
23312
+ var matchingEntries = (cwd, entries) => {
23313
+ const match = (where) => {
23314
+ const targets = [where, realpathOf(where)].map((value) => value.replaceAll("\\", "/"));
23315
+ return entries.filter((entry) => {
23316
+ const glob = entry.glob.replaceAll("\\", "/");
23317
+ const canonical = canonicalGlob(glob);
23318
+ return targets.some((target) => matchWorkspace(glob, target) || canonical !== glob && matchWorkspace(canonical, target));
23319
+ });
23320
+ };
23321
+ const direct = match(cwd);
23322
+ if (direct.length)
23323
+ return direct;
23324
+ const main = mainCheckoutOf(cwd);
23325
+ return main ? match(main) : direct;
23326
+ };
23279
23327
  var realpathOf = (p) => {
23280
23328
  const real = realpathSync3.native ?? realpathSync3;
23281
23329
  try {
@@ -23300,43 +23348,29 @@ var selectWorkspaceMatch = (matches, cwd, workspaceName) => {
23300
23348
  if (named.length === 1)
23301
23349
  return named[0];
23302
23350
  if (named.length > 1)
23303
- throw new Error(`ambiguous workspace ${JSON.stringify(workspaceName)} for ${cwd}`);
23351
+ throw new WorkspaceConfigError(`ambiguous workspace ${JSON.stringify(workspaceName)} for ${cwd}`);
23304
23352
  if (matches.length > 0) {
23305
- throw new Error(`workspace ${JSON.stringify(workspaceName)} does not match ${cwd}; matching choices: ${matches.map((entry) => entry.name).join(", ")}`);
23353
+ throw new WorkspaceConfigError(`workspace ${JSON.stringify(workspaceName)} does not match ${cwd}; matching choices: ${matches.map((entry) => entry.name).join(", ")}`);
23306
23354
  }
23307
- throw new Error(`workspace ${JSON.stringify(workspaceName)} does not match ${cwd}`);
23355
+ throw new WorkspaceConfigError(`workspace ${JSON.stringify(workspaceName)} does not match ${cwd}`);
23308
23356
  }
23309
23357
  if (matches.length < 2)
23310
23358
  return matches[0];
23311
23359
  const highestSpecificity = Math.max(...matches.map((entry) => globSpecificity(entry.glob)));
23312
23360
  const mostSpecific = matches.filter((entry) => globSpecificity(entry.glob) === highestSpecificity);
23313
23361
  if (mostSpecific.length > 1) {
23314
- throw new Error(`ambiguous workspace for ${cwd}; choose one of: ${mostSpecific.map((entry) => entry.name).join(", ")}`);
23362
+ throw new WorkspaceConfigError(`ambiguous workspace for ${cwd}; choose one of: ${mostSpecific.map((entry) => entry.name).join(", ")}`);
23315
23363
  }
23316
23364
  return mostSpecific[0];
23317
23365
  };
23318
23366
  var resolveWorkspaceFromEntries = (cwd, entries, workspaceName) => {
23319
- const targets = [cwd, realpathOf(cwd)].map((p) => p.replaceAll("\\", "/"));
23320
- const matches = [];
23321
- for (const ws of entries) {
23322
- const glob = ws.glob.replaceAll("\\", "/");
23323
- const canonical = canonicalGlob(glob);
23324
- let matched = false;
23325
- for (const target of targets) {
23326
- if (matchWorkspace(glob, target) || canonical !== glob && matchWorkspace(canonical, target)) {
23327
- matched = true;
23328
- break;
23329
- }
23330
- }
23331
- if (matched)
23332
- matches.push(ws);
23333
- }
23367
+ const matches = matchingEntries(cwd, entries);
23334
23368
  return selectWorkspaceMatch(matches, cwd, workspaceName) ?? null;
23335
23369
  };
23336
23370
  var resolveWorkspaceFrom = (cwd, dir, workspaceName) => {
23337
23371
  const result = readWorkspacesResult(dir);
23338
23372
  if (result.status === "malformed" || result.status === "invalid")
23339
- throw new Error(result.error);
23373
+ throw new WorkspaceConfigError(result.error);
23340
23374
  return resolveWorkspaceFromEntries(cwd, result.entries, workspaceName);
23341
23375
  };
23342
23376
  var runtimeWorkspacePolicySchema = (kind) => {
@@ -23368,31 +23402,26 @@ var matchRuntimeWorkspace = (cwd) => {
23368
23402
  } catch (error) {
23369
23403
  if (error.code === "ENOENT")
23370
23404
  return null;
23371
- throw new Error(`${file} could not be read: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
23405
+ throw new WorkspaceConfigError(`${file} could not be read: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
23372
23406
  }
23373
23407
  let parsed;
23374
23408
  try {
23375
23409
  parsed = JSON.parse(raw);
23376
23410
  } catch {
23377
- throw new Error(`${file} is not valid JSON`);
23411
+ throw new WorkspaceConfigError(`${file} is not valid JSON`);
23378
23412
  }
23379
23413
  const validated = runtimeWorkspaceIndexSchema.safeParse(parsed);
23380
23414
  if (!validated.success) {
23381
23415
  const detail = validated.error.issues.map((issue) => `${issue.path.map(String).join(".") || "workspaces"}: ${issue.message}`).join("; ");
23382
- throw new Error(`${file} has invalid workspace matching data: ${detail}`);
23416
+ throw new WorkspaceConfigError(`${file} has invalid workspace matching data: ${detail}`);
23383
23417
  }
23384
23418
  const entries = validated.data.workspaces;
23385
23419
  for (const entry of entries ?? []) {
23386
23420
  const glob = validateWorkspaceGlob(entry.glob);
23387
23421
  if (!glob.ok)
23388
- throw new Error(`${file} workspace ${entry.name}: ${glob.error}`);
23422
+ throw new WorkspaceConfigError(`${file} workspace ${entry.name}: ${glob.error}`);
23389
23423
  }
23390
- const targets = [cwd, realpathOf(cwd)].map((value) => value.replaceAll("\\", "/"));
23391
- const matches = (entries ?? []).filter((entry) => {
23392
- const glob = entry.glob.replaceAll("\\", "/");
23393
- const canonical = canonicalGlob(glob);
23394
- return targets.some((target) => matchWorkspace(glob, target) || canonical !== glob && matchWorkspace(canonical, target));
23395
- });
23424
+ const matches = matchingEntries(cwd, entries ?? []);
23396
23425
  const workspaceName = process.env.WORKFLOW_WORKSPACE_NAME?.trim() || undefined;
23397
23426
  const selected = selectWorkspaceMatch(matches, cwd, workspaceName);
23398
23427
  return selected ? { file, selected } : null;
@@ -23409,7 +23438,7 @@ var resolveRuntimeWorkspaceCandidate = (cwd, kind) => {
23409
23438
  const policy = runtimeWorkspacePolicySchema(kind).safeParse(selected);
23410
23439
  if (!policy.success) {
23411
23440
  const detail = policy.error.issues.map((issue) => `${issue.path.map(String).join(".") || "workspace"}: ${issue.message}`).join("; ");
23412
- throw new Error(`${file} has invalid ${kind} policy configuration: ${detail}`);
23441
+ throw new WorkspaceConfigError(`${file} has invalid ${kind} policy configuration: ${detail}`);
23413
23442
  }
23414
23443
  return policy.data;
23415
23444
  };
@@ -23420,10 +23449,10 @@ var resolveRuntimeWorkspacePolicy = (cwd, kind, requestedProfile) => {
23420
23449
  const key = kind === "branch" ? "branchPolicy" : "commitPolicy";
23421
23450
  const profileName = requestedProfile?.trim() || candidate.defaultProfile;
23422
23451
  if (candidate.defaultProfile && !Object.hasOwn(candidate.profiles ?? {}, candidate.defaultProfile))
23423
- throw new Error(`workspace ${JSON.stringify(candidate.name)} has no profile ${JSON.stringify(candidate.defaultProfile)}`);
23452
+ throw new WorkspaceConfigError(`workspace ${JSON.stringify(candidate.name)} has no profile ${JSON.stringify(candidate.defaultProfile)}`);
23424
23453
  const profile = profileName ? candidate.profiles?.[profileName] : undefined;
23425
23454
  if (profileName && !profile)
23426
- throw new Error(`workspace ${JSON.stringify(candidate.name)} has no profile ${JSON.stringify(profileName)}`);
23455
+ throw new WorkspaceConfigError(`workspace ${JSON.stringify(candidate.name)} has no profile ${JSON.stringify(profileName)}`);
23427
23456
  const profilePolicy = profile?.[key];
23428
23457
  const workspacePolicy = candidate[key];
23429
23458
  return {
@@ -23443,11 +23472,11 @@ function workspaceDefaultTarget(cwd, globalDefault) {
23443
23472
  // packages/workit-core/src/core/vcs-config.ts
23444
23473
  import fs12 from "node:fs";
23445
23474
  import path14 from "node:path";
23446
- import { spawnSync as spawnSync9 } from "node:child_process";
23475
+ import { spawnSync as spawnSync10 } from "node:child_process";
23447
23476
 
23448
23477
  // packages/workit-core/src/core/release-tracks.ts
23449
23478
  import { createHash as createHash9 } from "node:crypto";
23450
- import { spawnSync as spawnSync8 } from "node:child_process";
23479
+ import { spawnSync as spawnSync9 } from "node:child_process";
23451
23480
  var KNOWN_FIELDS = new Set([
23452
23481
  "strategy",
23453
23482
  "productionBranch",
@@ -23719,7 +23748,7 @@ function resolveReleaseTrack(input) {
23719
23748
  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 ")}`);
23720
23749
  }
23721
23750
  var git4 = (cwd, args) => {
23722
- const run = spawnSync8("git", args, {
23751
+ const run = spawnSync9("git", args, {
23723
23752
  cwd,
23724
23753
  encoding: "utf8",
23725
23754
  timeout: 20000,
@@ -23834,7 +23863,7 @@ function resolveTrackFor(cwd, options) {
23834
23863
  var workspacesPath = () => path14.join(configDir(), "workspaces.json");
23835
23864
  var vcsCwd = (cwd) => cwd ?? process.env.WORKFLOW_WORKSPACE_ROOT ?? process.cwd();
23836
23865
  var remoteProvider = (cwd) => {
23837
- const r = spawnSync9("git", ["remote", "get-url", "origin"], { cwd, encoding: "utf8" });
23866
+ const r = spawnSync10("git", ["remote", "get-url", "origin"], { cwd, encoding: "utf8" });
23838
23867
  if (r.status !== 0)
23839
23868
  return null;
23840
23869
  const url = (r.stdout ?? "").trim();
@@ -23871,7 +23900,7 @@ var remoteEndpoint = (remote) => {
23871
23900
  var configuredSshEndpoint = (host) => {
23872
23901
  if (host.startsWith("-"))
23873
23902
  return null;
23874
- const resolved = spawnSync9("ssh", ["-G", host], {
23903
+ const resolved = spawnSync10("ssh", ["-G", host], {
23875
23904
  encoding: "utf8",
23876
23905
  timeout: 5000,
23877
23906
  maxBuffer: 1024 * 1024,
@@ -24044,7 +24073,7 @@ function mergedPrStyle(limit = 6, cwd) {
24044
24073
  `).filter((l) => l.startsWith("## ")).map((l) => l.trim()),
24045
24074
  descriptionPreview: desc.slice(0, 600)
24046
24075
  });
24047
- const remoteResult = spawnSync9("git", ["remote", "get-url", "--push", "--all", "origin"], {
24076
+ const remoteResult = spawnSync10("git", ["remote", "get-url", "--push", "--all", "origin"], {
24048
24077
  cwd,
24049
24078
  encoding: "utf8"
24050
24079
  });
@@ -24060,7 +24089,7 @@ function mergedPrStyle(limit = 6, cwd) {
24060
24089
  if (!hostingApiHostMatches(remote, host))
24061
24090
  return { ok: false, error: "PR style target does not match the provider host" };
24062
24091
  if (provider === "gitlab") {
24063
- const run = (args) => spawnSync9("glab", ["api", ...args], {
24092
+ const run = (args) => spawnSync10("glab", ["api", ...args], {
24064
24093
  cwd,
24065
24094
  encoding: "utf8",
24066
24095
  env
@@ -24080,7 +24109,7 @@ function mergedPrStyle(limit = 6, cwd) {
24080
24109
  });
24081
24110
  }
24082
24111
  } else if (provider === "github") {
24083
- const r = spawnSync9("gh", [
24112
+ const r = spawnSync10("gh", [
24084
24113
  "pr",
24085
24114
  "list",
24086
24115
  "--repo",
@@ -26017,7 +26046,7 @@ class WorkitCore {
26017
26046
  }
26018
26047
  }
26019
26048
  // packages/workit-core/src/core/repo-context.ts
26020
- import { spawnSync as spawnSync10 } from "node:child_process";
26049
+ import { spawnSync as spawnSync11 } from "node:child_process";
26021
26050
  import { existsSync as existsSync6, readFileSync as readFileSync5, readdirSync as readdirSync4 } from "node:fs";
26022
26051
  import path16 from "node:path";
26023
26052
  var isSafeContextRange = (value) => value.length <= 4096 && (() => {
@@ -26046,7 +26075,7 @@ var invalidRange = (cwd) => ({
26046
26075
  cwd
26047
26076
  });
26048
26077
  var runGit = (cwd, args) => {
26049
- const result = spawnSync10("git", args, { cwd, encoding: "utf8" });
26078
+ const result = spawnSync11("git", args, { cwd, encoding: "utf8" });
26050
26079
  return {
26051
26080
  stdout: (result.stdout ?? "").trimEnd(),
26052
26081
  stderr: (result.stderr ?? "").trimEnd(),
@@ -26487,12 +26516,12 @@ function releaseNotesContext(root, rangeOrTag) {
26487
26516
  }
26488
26517
 
26489
26518
  // packages/workit-core/src/core/tracker-issues.ts
26490
- import { spawnSync as spawnSync12 } from "node:child_process";
26519
+ import { spawnSync as spawnSync13 } from "node:child_process";
26491
26520
 
26492
26521
  // packages/workit-core/src/core/pr-create.ts
26493
26522
  import fs13 from "node:fs";
26494
26523
  import path17 from "node:path";
26495
- import { spawnSync as spawnSync11 } from "node:child_process";
26524
+ import { spawnSync as spawnSync12 } from "node:child_process";
26496
26525
  // packages/workit-core/src/forge/pr-body.ts
26497
26526
  function parseGhIssue(value) {
26498
26527
  const m = /issues\/(\d+)/.exec(value);
@@ -26517,7 +26546,7 @@ function whichOnPath(tool) {
26517
26546
  }
26518
26547
  var hostingCliAvailable = (provider) => whichOnPath(provider === "gitlab" ? "glab" : "gh") !== null;
26519
26548
  var pushRemote = (cwd) => {
26520
- const result = spawnSync11("git", ["remote", "get-url", "--push", "--all", "origin"], {
26549
+ const result = spawnSync12("git", ["remote", "get-url", "--push", "--all", "origin"], {
26521
26550
  cwd,
26522
26551
  encoding: "utf8"
26523
26552
  });
@@ -26548,7 +26577,7 @@ var defaultCli = (bin, available) => {
26548
26577
  if (!available)
26549
26578
  return null;
26550
26579
  return (args, root) => {
26551
- const out = spawnSync12(bin, args, {
26580
+ const out = spawnSync13(bin, args, {
26552
26581
  cwd: root,
26553
26582
  encoding: "utf8",
26554
26583
  env: { ...process.env, PATH: process.env.PATH ?? "" }
@@ -27066,7 +27095,7 @@ function resolveInside(root, candidate) {
27066
27095
  }
27067
27096
  function run2(root, executable, args, env = {}) {
27068
27097
  const cwd = realpathSync5(root);
27069
- const result = spawnSync13(executable, args, {
27098
+ const result = spawnSync14(executable, args, {
27070
27099
  cwd,
27071
27100
  encoding: "utf8",
27072
27101
  env: { ...process.env, ...env }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brainervirus/workit-mcp",
3
- "version": "8.1.0",
3
+ "version": "8.1.1",
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.1.0",
45
+ "@brainervirus/workit-core": "^8.1.1",
46
46
  "@modelcontextprotocol/sdk": "1.32.0",
47
47
  "zod": "4.6.5"
48
48
  },