metheus-governance-mcp-cli 0.2.44 → 0.2.46

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/cli.mjs +37 -6
  2. package/package.json +1 -1
package/cli.mjs CHANGED
@@ -520,6 +520,10 @@ function isEditorInstallDirectory(candidatePath) {
520
520
  if (normalized.includes("\\appdata\\local\\programs\\microsoft vs code")) return true;
521
521
  if (normalized.includes("\\appdata\\local\\programs\\antigravity")) return true;
522
522
  if (normalized.includes("\\appdata\\local\\programs\\cursor")) return true;
523
+ if (normalized.includes("\\program files\\antigravity")) return true;
524
+ if (normalized.includes("\\program files (x86)\\antigravity")) return true;
525
+ if (normalized.includes("\\program files\\cursor")) return true;
526
+ if (normalized.includes("\\program files (x86)\\cursor")) return true;
523
527
  if (normalized.includes("\\program files\\microsoft vs code")) return true;
524
528
  if (normalized.includes("\\program files (x86)\\microsoft vs code")) return true;
525
529
  return false;
@@ -3612,6 +3616,28 @@ function appendToolAliasesToToolsListResponse(responseObj, canonicalToAlias) {
3612
3616
  return responseObj;
3613
3617
  }
3614
3618
 
3619
+ function rewriteToolsListToSafeAliasesOnly(responseObj, canonicalToAlias) {
3620
+ const result = safeObject(responseObj.result);
3621
+ const tools = ensureArray(result.tools);
3622
+ const out = [];
3623
+ const used = new Set();
3624
+
3625
+ for (const tool of tools) {
3626
+ const safeTool = safeObject(tool);
3627
+ const canonicalName = String(safeTool.name || "").trim();
3628
+ if (!canonicalName) continue;
3629
+ const aliasName = String(canonicalToAlias.get(canonicalName) || "").trim();
3630
+ const finalName = aliasName || canonicalName;
3631
+ if (used.has(finalName)) continue;
3632
+ used.add(finalName);
3633
+ out.push({ ...safeTool, name: finalName });
3634
+ }
3635
+
3636
+ result.tools = out;
3637
+ responseObj.result = result;
3638
+ return responseObj;
3639
+ }
3640
+
3615
3641
  function rewriteAliasedToolCallToCanonical(requestObj, aliasToCanonical) {
3616
3642
  if (!isJsonRpcMethod(requestObj, "tools/call")) return requestObj;
3617
3643
  const params = safeObject(requestObj.params);
@@ -3641,10 +3667,12 @@ function shouldUseSafeToolAliasesForClient(initParamsRaw) {
3641
3667
  function canTrustProcessCwdForClient(clientNameRaw) {
3642
3668
  const name = String(clientNameRaw || "").trim().toLowerCase();
3643
3669
  if (!name) return false;
3644
- // Codex app-server may not pass workspace signals reliably; never trust bare process.cwd().
3670
+ // Codex/Cursor/Antigravity can run MCP from app/install directories.
3645
3671
  if (name.includes("codex")) return false;
3646
- // VS Code forks generally spawn MCP in active workspace folder.
3647
- return name.includes("cursor") || name.includes("antigravity");
3672
+ if (name.includes("cursor")) return false;
3673
+ if (name.includes("antigravity")) return false;
3674
+ // CLI-style clients (e.g., Gemini/Claude Code) usually launch from active project cwd.
3675
+ return name.includes("gemini") || name.includes("claude");
3648
3676
  }
3649
3677
 
3650
3678
  function displayToolNameForClient(canonicalName, useSafeToolAliases = false) {
@@ -3697,7 +3725,7 @@ function appendProjectHintToInitialize(responseObj, args, options = {}) {
3697
3725
  "High-priority project bootstrap rule:",
3698
3726
  ...(useSafeToolAliases
3699
3727
  ? [
3700
- "- This session supports safe MCP tool aliases (underscore format). Prefer `project_summary` / `ctxpack_ensure` / `workitem_list`; dotted names are also accepted.",
3728
+ "- This session uses safe MCP tool aliases (underscore format). Use `project_summary` / `ctxpack_ensure` / `workitem_list` style names, not dotted names.",
3701
3729
  ]
3702
3730
  : []),
3703
3731
  `- MUST call \`${projectSummaryTool}\` first when the user provides only a Project ID or asks project overview/agenda.`,
@@ -4389,7 +4417,10 @@ async function runProxy(flags) {
4389
4417
  sessionWorkspaceDir = strongRequestWorkspaceCandidate;
4390
4418
  sessionWorkspaceTrusted = true;
4391
4419
  } else if (weakRequestWorkspaceCandidate) {
4392
- sessionWorkspaceDir = weakRequestWorkspaceCandidate;
4420
+ // Keep trusted session workspace (e.g., roots/list) stable against weak per-request cwd noise.
4421
+ if (!sessionWorkspaceTrusted || !sessionWorkspaceDir) {
4422
+ sessionWorkspaceDir = weakRequestWorkspaceCandidate;
4423
+ }
4393
4424
  } else if (weakEnvWorkspaceCandidate) {
4394
4425
  sessionWorkspaceDir = weakEnvWorkspaceCandidate;
4395
4426
  }
@@ -4641,7 +4672,7 @@ async function runProxy(flags) {
4641
4672
  const aliasMaps = buildToolAliasMaps(tools);
4642
4673
  sessionToolAliasToCanonical = aliasMaps.aliasToCanonical;
4643
4674
  sessionToolCanonicalToAlias = aliasMaps.canonicalToAlias;
4644
- patched = appendToolAliasesToToolsListResponse(patched, sessionToolCanonicalToAlias);
4675
+ patched = rewriteToolsListToSafeAliasesOnly(patched, sessionToolCanonicalToAlias);
4645
4676
  }
4646
4677
  } else if (isJsonRpcMethod(requestObj, "initialize")) {
4647
4678
  patched = appendProjectHintToInitialize(patched, args, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metheus-governance-mcp-cli",
3
- "version": "0.2.44",
3
+ "version": "0.2.46",
4
4
  "description": "Metheus Governance MCP CLI (setup + stdio proxy)",
5
5
  "type": "module",
6
6
  "files": [