mrmainspring 0.1.2 → 0.1.4
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/dist/cli.js +21 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { dirname } from "node:path";
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
3
5
|
import { loadConfig } from "./config.js";
|
|
4
6
|
import { ensureGrimoireMasterKey, loadLocalEnvFile, resolveEnvPath } from "./env-file.js";
|
|
5
7
|
import { getDefaultMainspringPaths } from "./paths.js";
|
|
6
|
-
const
|
|
8
|
+
const _pkgRoot = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
9
|
+
const VERSION = JSON.parse(readFileSync(join(_pkgRoot, "package.json"), "utf8")).version;
|
|
7
10
|
const HELP = `Mr Mainspring MCP server
|
|
8
11
|
|
|
9
12
|
Usage:
|
|
@@ -14,12 +17,14 @@ Usage:
|
|
|
14
17
|
mainspring config Print MCP client config JSON
|
|
15
18
|
mainspring setup [client] Initialize local files and print MCP config
|
|
16
19
|
mainspring doctor Check the local setup
|
|
20
|
+
mainspring update Show how to update to the latest version
|
|
17
21
|
|
|
18
22
|
MCP client config:
|
|
19
23
|
{
|
|
20
24
|
"mcpServers": {
|
|
21
25
|
"mainspring": {
|
|
22
|
-
"command": "
|
|
26
|
+
"command": "npx",
|
|
27
|
+
"args": ["-y", "mrmainspring"]
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
30
|
}
|
|
@@ -61,6 +66,13 @@ export function runCliCommand(args) {
|
|
|
61
66
|
process.stdout.write(formatDoctorReport());
|
|
62
67
|
return true;
|
|
63
68
|
}
|
|
69
|
+
if (command === "update") {
|
|
70
|
+
process.stdout.write("To update Mr Mainspring:\n\n" +
|
|
71
|
+
" npm install -g mrmainspring@latest\n\n" +
|
|
72
|
+
"or if using npx (no install needed):\n\n" +
|
|
73
|
+
" npx mrmainspring@latest\n\n");
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
64
76
|
process.stderr.write(`Unknown command: ${command}\n\n${HELP}`);
|
|
65
77
|
process.exitCode = 1;
|
|
66
78
|
return true;
|
|
@@ -93,7 +105,8 @@ export function formatMcpConfig() {
|
|
|
93
105
|
return JSON.stringify({
|
|
94
106
|
mcpServers: {
|
|
95
107
|
mainspring: {
|
|
96
|
-
command: "
|
|
108
|
+
command: "npx",
|
|
109
|
+
args: ["-y", "mrmainspring"]
|
|
97
110
|
}
|
|
98
111
|
}
|
|
99
112
|
}, null, 2);
|
|
@@ -118,6 +131,9 @@ function formatDoctorReport(env = process.env) {
|
|
|
118
131
|
lines.push(formatCheck(existsSync(envFile), `Config file: ${envFile}`, "Config file missing; run mainspring init"));
|
|
119
132
|
lines.push(formatCheck(existsSync(paths.dataDir), `Data dir: ${paths.dataDir}`, "Data dir missing; run mainspring init"));
|
|
120
133
|
lines.push(formatCheck(existsSync(paths.logsDir), `Logs dir: ${paths.logsDir}`, "Logs dir missing; run mainspring init"));
|
|
134
|
+
const casperBin = envCopy.CASPER_CLIENT_BIN ?? "casper-client";
|
|
135
|
+
const casperProbe = spawnSync(casperBin, ["--version"], { stdio: "pipe" });
|
|
136
|
+
lines.push(formatCheck(!casperProbe.error, `casper-client: ${casperBin}`, `casper-client not found at "${casperBin}" — optional, needed for on-chain anchoring (cargo install casper-client)`));
|
|
121
137
|
try {
|
|
122
138
|
const config = loadConfig(envCopy);
|
|
123
139
|
lines.push(`[ok] Storage backend: ${config.storage.backend}`);
|
package/package.json
CHANGED