metheus-governance-mcp-cli 0.2.45 → 0.2.47
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 +34 -3
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -3616,6 +3616,28 @@ function appendToolAliasesToToolsListResponse(responseObj, canonicalToAlias) {
|
|
|
3616
3616
|
return responseObj;
|
|
3617
3617
|
}
|
|
3618
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
|
+
|
|
3619
3641
|
function rewriteAliasedToolCallToCanonical(requestObj, aliasToCanonical) {
|
|
3620
3642
|
if (!isJsonRpcMethod(requestObj, "tools/call")) return requestObj;
|
|
3621
3643
|
const params = safeObject(requestObj.params);
|
|
@@ -3697,17 +3719,20 @@ function appendProjectHintToInitialize(responseObj, args, options = {}) {
|
|
|
3697
3719
|
const projectSummaryTool = displayToolNameForClient("project.summary", useSafeToolAliases);
|
|
3698
3720
|
const projectDescribeTool = displayToolNameForClient("project.describe", useSafeToolAliases);
|
|
3699
3721
|
const projectGetTool = displayToolNameForClient("project.get", useSafeToolAliases);
|
|
3722
|
+
const ctxpackEnsureTool = displayToolNameForClient("ctxpack.ensure", useSafeToolAliases);
|
|
3700
3723
|
const ctxpackMergeBriefTool = displayToolNameForClient("ctxpack.merge.brief", useSafeToolAliases);
|
|
3701
3724
|
const ctxpackMergeExecuteTool = displayToolNameForClient("ctxpack.merge.execute", useSafeToolAliases);
|
|
3702
3725
|
const hintLines = [
|
|
3703
3726
|
"High-priority project bootstrap rule:",
|
|
3704
3727
|
...(useSafeToolAliases
|
|
3705
3728
|
? [
|
|
3706
|
-
"- This session
|
|
3729
|
+
"- This session uses safe MCP tool aliases (underscore format). Use `project_summary` / `ctxpack_ensure` / `workitem_list` style names, not dotted names.",
|
|
3707
3730
|
]
|
|
3708
3731
|
: []),
|
|
3709
3732
|
`- MUST call \`${projectSummaryTool}\` first when the user provides only a Project ID or asks project overview/agenda.`,
|
|
3710
3733
|
`- \`${projectDescribeTool}\` and \`${projectGetTool}\` are aliases of \`${projectSummaryTool}\`.`,
|
|
3734
|
+
`- Never handle a bare Project ID by local file/transcript search before \`${projectSummaryTool}\` succeeds.`,
|
|
3735
|
+
`- Run \`${ctxpackEnsureTool}\` only after \`${projectSummaryTool}\`, and only when additional ctxpack refresh/export context is needed.`,
|
|
3711
3736
|
"- After project summary, use workitem/evidence/decision tools as follow-up.",
|
|
3712
3737
|
`- Before any ctxpack merge, call \`${ctxpackMergeBriefTool}\` first, share recommendation to owner, get explicit owner confirmation, then call \`${ctxpackMergeExecuteTool}\`.`,
|
|
3713
3738
|
"- 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.",
|
|
@@ -3716,7 +3741,13 @@ function appendProjectHintToInitialize(responseObj, args, options = {}) {
|
|
|
3716
3741
|
hintLines.splice(1, 0, `- Default project_id is ${args.projectID}.`);
|
|
3717
3742
|
}
|
|
3718
3743
|
const hint = `${hintLines.join("\n")}\n`;
|
|
3719
|
-
|
|
3744
|
+
let current = String(result.instructions || "").trimEnd();
|
|
3745
|
+
if (current) {
|
|
3746
|
+
current = current.replace(
|
|
3747
|
+
/If a user provides only Project ID,\s*call ctxpack\.ensure first[^.\n]*[.\n]?/gi,
|
|
3748
|
+
`If a user provides only Project ID, call ${projectSummaryTool} first. Then call ${ctxpackEnsureTool} only if additional ctxpack refresh is needed.\n`,
|
|
3749
|
+
);
|
|
3750
|
+
}
|
|
3720
3751
|
result.instructions = current ? `${hint}\n${current}` : hint;
|
|
3721
3752
|
responseObj.result = result;
|
|
3722
3753
|
return responseObj;
|
|
@@ -4650,7 +4681,7 @@ async function runProxy(flags) {
|
|
|
4650
4681
|
const aliasMaps = buildToolAliasMaps(tools);
|
|
4651
4682
|
sessionToolAliasToCanonical = aliasMaps.aliasToCanonical;
|
|
4652
4683
|
sessionToolCanonicalToAlias = aliasMaps.canonicalToAlias;
|
|
4653
|
-
patched =
|
|
4684
|
+
patched = rewriteToolsListToSafeAliasesOnly(patched, sessionToolCanonicalToAlias);
|
|
4654
4685
|
}
|
|
4655
4686
|
} else if (isJsonRpcMethod(requestObj, "initialize")) {
|
|
4656
4687
|
patched = appendProjectHintToInitialize(patched, args, {
|