metheus-governance-mcp-cli 0.2.5 → 0.2.6
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 +35 -14
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -1876,8 +1876,23 @@ function syncCtxpackToLocalCache({ siteBaseURL, projectID, ctxpack, workspaceDir
|
|
|
1876
1876
|
const previousSig = previousMeta
|
|
1877
1877
|
? `${String(previousMeta.ctxpack_id || "").trim()}|${String(previousMeta.version || "").trim()}|${String(previousMeta.status || "").trim()}|${Number.parseInt(String(previousMeta.files_count || 0), 10) || 0}`
|
|
1878
1878
|
: "";
|
|
1879
|
+
const payload = {
|
|
1880
|
+
project_id: projectID,
|
|
1881
|
+
ctxpack_id: ctxpackID,
|
|
1882
|
+
version,
|
|
1883
|
+
status,
|
|
1884
|
+
files_count: files.length,
|
|
1885
|
+
files: files.map((f) => ({ path: f.path, doc_type: f.docType || "" })),
|
|
1886
|
+
source: `${String(siteBaseURL || "").replace(/\/+$/, "")}/api/v1/projects/${encodeURIComponent(projectID)}/ctxpack`,
|
|
1887
|
+
synced_at: new Date().toISOString(),
|
|
1888
|
+
};
|
|
1879
1889
|
|
|
1880
1890
|
if (previousSig === remoteSig && hasAllCtxpackFiles(cacheDir, files)) {
|
|
1891
|
+
try {
|
|
1892
|
+
fs.writeFileSync(workspaceMetaPath, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
|
|
1893
|
+
} catch {
|
|
1894
|
+
// Best-effort metadata refresh for workspace-root auto-detection.
|
|
1895
|
+
}
|
|
1881
1896
|
return {
|
|
1882
1897
|
sync_status: "current",
|
|
1883
1898
|
sync_message: "Local ctxpack cache is up to date.",
|
|
@@ -1897,16 +1912,6 @@ function syncCtxpackToLocalCache({ siteBaseURL, projectID, ctxpack, workspaceDir
|
|
|
1897
1912
|
fs.writeFileSync(target, file.content, "utf8");
|
|
1898
1913
|
}
|
|
1899
1914
|
|
|
1900
|
-
const payload = {
|
|
1901
|
-
project_id: projectID,
|
|
1902
|
-
ctxpack_id: ctxpackID,
|
|
1903
|
-
version,
|
|
1904
|
-
status,
|
|
1905
|
-
files_count: files.length,
|
|
1906
|
-
files: files.map((f) => ({ path: f.path, doc_type: f.docType || "" })),
|
|
1907
|
-
source: `${String(siteBaseURL || "").replace(/\/+$/, "")}/api/v1/projects/${encodeURIComponent(projectID)}/ctxpack`,
|
|
1908
|
-
synced_at: new Date().toISOString(),
|
|
1909
|
-
};
|
|
1910
1915
|
fs.writeFileSync(metaPath, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
|
|
1911
1916
|
fs.writeFileSync(workspaceMetaPath, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
|
|
1912
1917
|
|
|
@@ -2495,13 +2500,27 @@ function resolveSetupContext(flags) {
|
|
|
2495
2500
|
const projectID = String(flags["project-id"] || workspaceMeta.project_id || "").trim();
|
|
2496
2501
|
const ctxpackKey = String(flags["ctxpack-key"] || buildCtxpackKeyFromMeta(workspaceMeta) || "").trim();
|
|
2497
2502
|
const baseURL = String(flags["base-url"] || DEFAULT_SITE_URL).trim().replace(/\/+$/, "");
|
|
2498
|
-
const
|
|
2503
|
+
const workspaceDirRaw = String(flags["workspace-dir"] || "").trim();
|
|
2504
|
+
const hasExplicitWorkspaceDir = workspaceDirRaw.length > 0;
|
|
2505
|
+
const workspaceDir = resolveWorkspaceDir(hasExplicitWorkspaceDir ? workspaceDirRaw : process.cwd());
|
|
2499
2506
|
const serverName = String(flags.name || DEFAULT_SERVER_NAME).trim() || DEFAULT_SERVER_NAME;
|
|
2500
2507
|
const proxyArgs = ["--base-url", `${baseURL}/governance/mcp`];
|
|
2501
|
-
|
|
2508
|
+
// Default mode: do not pin workspace path in MCP registration.
|
|
2509
|
+
// Let client runtime cwd resolve per open folder/workspace.
|
|
2510
|
+
if (hasExplicitWorkspaceDir) {
|
|
2511
|
+
proxyArgs.push("--workspace-dir", workspaceDir);
|
|
2512
|
+
}
|
|
2502
2513
|
if (projectID) proxyArgs.push("--project-id", projectID);
|
|
2503
2514
|
if (ctxpackKey) proxyArgs.push("--ctxpack-key", ctxpackKey);
|
|
2504
|
-
return {
|
|
2515
|
+
return {
|
|
2516
|
+
projectID,
|
|
2517
|
+
ctxpackKey,
|
|
2518
|
+
baseURL,
|
|
2519
|
+
workspaceDir,
|
|
2520
|
+
hasExplicitWorkspaceDir,
|
|
2521
|
+
serverName,
|
|
2522
|
+
proxyArgs,
|
|
2523
|
+
};
|
|
2505
2524
|
}
|
|
2506
2525
|
|
|
2507
2526
|
function runSetupInternal(flags, options = {}) {
|
|
@@ -2530,7 +2549,9 @@ function runSetupInternal(flags, options = {}) {
|
|
|
2530
2549
|
process.stdout.write(ensureOnly ? "\nEnsure complete.\n" : "\nInstall complete.\n");
|
|
2531
2550
|
process.stdout.write(`Server: ${context.serverName}\n`);
|
|
2532
2551
|
process.stdout.write(`Gateway: ${context.baseURL}/governance/mcp\n`);
|
|
2533
|
-
process.stdout.write(
|
|
2552
|
+
process.stdout.write(
|
|
2553
|
+
`Workspace: ${context.hasExplicitWorkspaceDir ? context.workspaceDir : "auto (client current folder)"}\n`,
|
|
2554
|
+
);
|
|
2534
2555
|
process.stdout.write(`Project: ${context.projectID || "auto-detect from .metheus_ctxpack_sync.json"}\n`);
|
|
2535
2556
|
if (context.ctxpackKey) {
|
|
2536
2557
|
process.stdout.write(`Ctxpack: ${context.ctxpackKey}\n`);
|