metheus-governance-mcp-cli 0.2.38 → 0.2.39
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/cli.mjs +47 -10
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -3603,6 +3603,14 @@ function shouldUseSafeToolAliasesForClient(initParamsRaw) {
|
|
|
3603
3603
|
return name.includes("cursor") || name.includes("antigravity");
|
|
3604
3604
|
}
|
|
3605
3605
|
|
|
3606
|
+
function displayToolNameForClient(canonicalName, useSafeToolAliases = false) {
|
|
3607
|
+
const canonical = String(canonicalName || "").trim();
|
|
3608
|
+
if (!canonical) return "";
|
|
3609
|
+
if (!useSafeToolAliases) return canonical;
|
|
3610
|
+
const alias = normalizeSafeToolAliasName(canonical);
|
|
3611
|
+
return alias || canonical;
|
|
3612
|
+
}
|
|
3613
|
+
|
|
3606
3614
|
function injectWorkspaceDirIntoToolSchemas(tools) {
|
|
3607
3615
|
const workspaceDirProp = {
|
|
3608
3616
|
type: "string",
|
|
@@ -3633,14 +3641,25 @@ function appendLocalToolToToolsList(responseObj) {
|
|
|
3633
3641
|
return responseObj;
|
|
3634
3642
|
}
|
|
3635
3643
|
|
|
3636
|
-
function appendProjectHintToInitialize(responseObj, args) {
|
|
3644
|
+
function appendProjectHintToInitialize(responseObj, args, options = {}) {
|
|
3645
|
+
const useSafeToolAliases = Boolean(options.useSafeToolAliases);
|
|
3637
3646
|
const result = safeObject(responseObj.result);
|
|
3647
|
+
const projectSummaryTool = displayToolNameForClient("project.summary", useSafeToolAliases);
|
|
3648
|
+
const projectDescribeTool = displayToolNameForClient("project.describe", useSafeToolAliases);
|
|
3649
|
+
const projectGetTool = displayToolNameForClient("project.get", useSafeToolAliases);
|
|
3650
|
+
const ctxpackMergeBriefTool = displayToolNameForClient("ctxpack.merge.brief", useSafeToolAliases);
|
|
3651
|
+
const ctxpackMergeExecuteTool = displayToolNameForClient("ctxpack.merge.execute", useSafeToolAliases);
|
|
3638
3652
|
const hintLines = [
|
|
3639
3653
|
"High-priority project bootstrap rule:",
|
|
3640
|
-
|
|
3641
|
-
|
|
3654
|
+
...(useSafeToolAliases
|
|
3655
|
+
? [
|
|
3656
|
+
"- This session uses safe MCP tool aliases (underscore format). Use `project_summary` / `ctxpack_ensure` / `workitem_list` style names, not dotted names.",
|
|
3657
|
+
]
|
|
3658
|
+
: []),
|
|
3659
|
+
`- MUST call \`${projectSummaryTool}\` first when the user provides only a Project ID or asks project overview/agenda.`,
|
|
3660
|
+
`- \`${projectDescribeTool}\` and \`${projectGetTool}\` are aliases of \`${projectSummaryTool}\`.`,
|
|
3642
3661
|
"- After project summary, use workitem/evidence/decision tools as follow-up.",
|
|
3643
|
-
|
|
3662
|
+
`- Before any ctxpack merge, call \`${ctxpackMergeBriefTool}\` first, share recommendation to owner, get explicit owner confirmation, then call \`${ctxpackMergeExecuteTool}\`.`,
|
|
3644
3663
|
"- IMPORTANT: When calling ANY tool, always include your current working directory / project folder path as the `workspace_dir` argument. This enables ctxpack files to be synced to the correct workspace location.",
|
|
3645
3664
|
];
|
|
3646
3665
|
if (args.projectID) {
|
|
@@ -3767,7 +3786,16 @@ function appendAutoCtxpackSyncHint(responseObj, summary) {
|
|
|
3767
3786
|
return responseObj;
|
|
3768
3787
|
}
|
|
3769
3788
|
|
|
3770
|
-
async function appendWorkitemListHints(
|
|
3789
|
+
async function appendWorkitemListHints(
|
|
3790
|
+
responseObj,
|
|
3791
|
+
args,
|
|
3792
|
+
toolArgs,
|
|
3793
|
+
token,
|
|
3794
|
+
workspaceSignalTrusted = true,
|
|
3795
|
+
options = {},
|
|
3796
|
+
) {
|
|
3797
|
+
const useSafeToolAliases = Boolean(options.useSafeToolAliases);
|
|
3798
|
+
const projectSummaryTool = displayToolNameForClient("project.summary", useSafeToolAliases);
|
|
3771
3799
|
const result = safeObject(responseObj.result);
|
|
3772
3800
|
const content = ensureArray(result.content);
|
|
3773
3801
|
if (!content.length) return responseObj;
|
|
@@ -3777,7 +3805,7 @@ async function appendWorkitemListHints(responseObj, args, toolArgs, token, works
|
|
|
3777
3805
|
|
|
3778
3806
|
const text = String(first.text || "");
|
|
3779
3807
|
if (!text) return responseObj;
|
|
3780
|
-
if (text.includes("Call `project.summary`")) return responseObj;
|
|
3808
|
+
if (text.includes(`Call \`${projectSummaryTool}\``) || text.includes("Call `project.summary`")) return responseObj;
|
|
3781
3809
|
|
|
3782
3810
|
const parsed = parseGatewayResponseText(text);
|
|
3783
3811
|
if (!parsed) return responseObj;
|
|
@@ -3794,7 +3822,7 @@ async function appendWorkitemListHints(responseObj, args, toolArgs, token, works
|
|
|
3794
3822
|
const nextLines = [""];
|
|
3795
3823
|
if (isEmptyBody) {
|
|
3796
3824
|
nextLines.push("No work items found for this project.");
|
|
3797
|
-
nextLines.push(
|
|
3825
|
+
nextLines.push(`- Call \`${projectSummaryTool}\` to confirm project context/agenda and access state first.`);
|
|
3798
3826
|
}
|
|
3799
3827
|
|
|
3800
3828
|
let responseProjectID = "";
|
|
@@ -4560,7 +4588,9 @@ async function runProxy(flags) {
|
|
|
4560
4588
|
patched = applyToolAliasesToToolsListResponse(patched, sessionToolCanonicalToAlias);
|
|
4561
4589
|
}
|
|
4562
4590
|
} else if (isJsonRpcMethod(requestObj, "initialize")) {
|
|
4563
|
-
patched = appendProjectHintToInitialize(patched, args
|
|
4591
|
+
patched = appendProjectHintToInitialize(patched, args, {
|
|
4592
|
+
useSafeToolAliases: sessionUseSafeToolAliases,
|
|
4593
|
+
});
|
|
4564
4594
|
// Log initialize params for workspace debugging.
|
|
4565
4595
|
try {
|
|
4566
4596
|
const _diagDir = path.join(String(process.env.USERPROFILE || process.env.HOME || "."), ".metheus");
|
|
@@ -4577,7 +4607,14 @@ async function runProxy(flags) {
|
|
|
4577
4607
|
setImmediate(() => sendRootsListProbe());
|
|
4578
4608
|
}
|
|
4579
4609
|
} else if (isJsonRpcMethod(requestObj, "tools/call") && toolName === "workitem.list") {
|
|
4580
|
-
patched = await appendWorkitemListHints(
|
|
4610
|
+
patched = await appendWorkitemListHints(
|
|
4611
|
+
patched,
|
|
4612
|
+
args,
|
|
4613
|
+
toolArgs,
|
|
4614
|
+
token,
|
|
4615
|
+
workspaceSignalTrusted,
|
|
4616
|
+
{ useSafeToolAliases: sessionUseSafeToolAliases },
|
|
4617
|
+
);
|
|
4581
4618
|
} else if (isJsonRpcMethod(requestObj, "tools/call") && toolName === "ctxpack.ensure") {
|
|
4582
4619
|
patched = appendCtxpackEnsureSyncHints(
|
|
4583
4620
|
patched,
|
|
@@ -5019,7 +5056,7 @@ function resolveSetupContext(flags) {
|
|
|
5019
5056
|
const workspaceMeta = loadWorkspaceMeta(process.cwd());
|
|
5020
5057
|
const projectID = String(flags["project-id"] || workspaceMeta.project_id || "").trim();
|
|
5021
5058
|
const ctxpackKey = String(flags["ctxpack-key"] || buildCtxpackKeyFromMeta(workspaceMeta) || "").trim();
|
|
5022
|
-
const baseURL =
|
|
5059
|
+
const baseURL = normalizeSiteBaseURL(flags["base-url"] || DEFAULT_SITE_URL);
|
|
5023
5060
|
const workspaceDirRaw = String(flags["workspace-dir"] || "").trim();
|
|
5024
5061
|
const workspaceFallbackDirRaw = String(flags["workspace-fallback-dir"] || "").trim();
|
|
5025
5062
|
const hasWorkspaceDirFlag = Object.prototype.hasOwnProperty.call(flags, "workspace-dir");
|