metheus-governance-mcp-cli 0.2.23 → 0.2.25
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 +43 -8
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -3288,13 +3288,32 @@ function ensureArray(value) {
|
|
|
3288
3288
|
return Array.isArray(value) ? value : [];
|
|
3289
3289
|
}
|
|
3290
3290
|
|
|
3291
|
+
function injectWorkspaceDirIntoToolSchemas(tools) {
|
|
3292
|
+
const workspaceDirProp = {
|
|
3293
|
+
type: "string",
|
|
3294
|
+
description: "Current working directory / project folder path. Include this so ctxpack files sync to the correct workspace.",
|
|
3295
|
+
};
|
|
3296
|
+
for (const tool of tools) {
|
|
3297
|
+
if (!tool || typeof tool !== "object") continue;
|
|
3298
|
+
if (!tool.inputSchema || typeof tool.inputSchema !== "object") continue;
|
|
3299
|
+
const schema = tool.inputSchema;
|
|
3300
|
+
if (!schema.properties || typeof schema.properties !== "object") {
|
|
3301
|
+
schema.properties = {};
|
|
3302
|
+
}
|
|
3303
|
+
if (!schema.properties.workspace_dir) {
|
|
3304
|
+
schema.properties.workspace_dir = workspaceDirProp;
|
|
3305
|
+
}
|
|
3306
|
+
}
|
|
3307
|
+
return tools;
|
|
3308
|
+
}
|
|
3309
|
+
|
|
3291
3310
|
function appendLocalToolToToolsList(responseObj) {
|
|
3292
3311
|
const result = safeObject(responseObj.result);
|
|
3293
3312
|
const tools = ensureArray(result.tools);
|
|
3294
3313
|
const localSpecs = buildLocalToolSpecs();
|
|
3295
3314
|
const localNames = new Set(localSpecs.map((spec) => spec.name));
|
|
3296
3315
|
const filtered = tools.filter((tool) => !localNames.has(String(tool?.name || "").trim()));
|
|
3297
|
-
result.tools = [...localSpecs, ...filtered];
|
|
3316
|
+
result.tools = injectWorkspaceDirIntoToolSchemas([...localSpecs, ...filtered]);
|
|
3298
3317
|
responseObj.result = result;
|
|
3299
3318
|
return responseObj;
|
|
3300
3319
|
}
|
|
@@ -3307,6 +3326,7 @@ function appendProjectHintToInitialize(responseObj, args) {
|
|
|
3307
3326
|
"- `project.describe` and `project.get` are aliases of `project.summary`.",
|
|
3308
3327
|
"- After project summary, use workitem/evidence/decision tools as follow-up.",
|
|
3309
3328
|
"- Before any ctxpack merge, call `ctxpack.merge.brief` first, share recommendation to owner, get explicit owner confirmation, then call `ctxpack.merge.execute`.",
|
|
3329
|
+
"- 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.",
|
|
3310
3330
|
];
|
|
3311
3331
|
if (args.projectID) {
|
|
3312
3332
|
hintLines.splice(1, 0, `- Default project_id is ${args.projectID}.`);
|
|
@@ -3563,6 +3583,19 @@ function appendCtxpackEnsureSyncHints(responseObj, args, toolArgs, requestObj, w
|
|
|
3563
3583
|
return responseObj;
|
|
3564
3584
|
}
|
|
3565
3585
|
|
|
3586
|
+
function stripLocalOnlyToolArgs(requestObj) {
|
|
3587
|
+
if (!isJsonRpcMethod(requestObj, "tools/call")) return requestObj;
|
|
3588
|
+
const params = safeObject(requestObj.params);
|
|
3589
|
+
const rawArgs = safeObject(params.arguments ?? params.args);
|
|
3590
|
+
if (!rawArgs.workspace_dir && !rawArgs.workspaceDir) return requestObj;
|
|
3591
|
+
const nextArgs = { ...rawArgs };
|
|
3592
|
+
delete nextArgs.workspace_dir;
|
|
3593
|
+
delete nextArgs.workspaceDir;
|
|
3594
|
+
const nextParams = { ...params };
|
|
3595
|
+
nextParams.arguments = nextArgs;
|
|
3596
|
+
return { ...requestObj, params: nextParams };
|
|
3597
|
+
}
|
|
3598
|
+
|
|
3566
3599
|
function injectCtxpackPushDefaults(requestObj, toolName, workspaceDir) {
|
|
3567
3600
|
if (!isJsonRpcMethod(requestObj, "tools/call")) return requestObj;
|
|
3568
3601
|
const normalizedTool = String(toolName || "").trim().toLowerCase();
|
|
@@ -4031,13 +4064,15 @@ async function runProxy(flags) {
|
|
|
4031
4064
|
|
|
4032
4065
|
try {
|
|
4033
4066
|
const requestWithDefaults = injectCtxpackPushDefaults(requestObj, toolName, requestWorkspaceDir);
|
|
4034
|
-
const outboundRequestObj =
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4067
|
+
const outboundRequestObj = stripLocalOnlyToolArgs(
|
|
4068
|
+
await injectCtxpackPreflightToken(
|
|
4069
|
+
requestWithDefaults,
|
|
4070
|
+
toolName,
|
|
4071
|
+
toolArgs,
|
|
4072
|
+
args,
|
|
4073
|
+
token,
|
|
4074
|
+
requestWorkspaceDir,
|
|
4075
|
+
),
|
|
4041
4076
|
);
|
|
4042
4077
|
const responseText = await postJSON(gatewayURL, args.timeoutSeconds, token, outboundRequestObj);
|
|
4043
4078
|
if (responseText) {
|