mrmainspring 0.2.3 → 0.2.5
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 +52 -13
- package/dist/client-setup.js +31 -10
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -35,6 +35,15 @@ Advanced users can still set SIGIL_ENV_FILE, SIGIL_DATA_DIR, Supabase, Casper,
|
|
|
35
35
|
and x402 env vars. No env vars are required for local memory, Grimoire, audit,
|
|
36
36
|
or payment preflight tools.
|
|
37
37
|
`;
|
|
38
|
+
function appendEnvVars(envFile, vars) {
|
|
39
|
+
const existing = existsSync(envFile) ? readFileSync(envFile, "utf8") : "";
|
|
40
|
+
const toWrite = Object.entries(vars).filter(([k]) => !existing.includes(`${k}=`));
|
|
41
|
+
if (toWrite.length === 0)
|
|
42
|
+
return [];
|
|
43
|
+
const block = "\n# Mainspring setup\n" + toWrite.map(([k, v]) => `${k}=${v}`).join("\n") + "\n";
|
|
44
|
+
appendFileSync(envFile, block, "utf8");
|
|
45
|
+
return toWrite.map(([k]) => k);
|
|
46
|
+
}
|
|
38
47
|
export async function runCliCommand(args) {
|
|
39
48
|
const [command, target] = args;
|
|
40
49
|
if (!command || command === "stdio" || command === "server" || command === "mcp") {
|
|
@@ -261,11 +270,22 @@ async function runInteractiveSetup() {
|
|
|
261
270
|
}
|
|
262
271
|
}
|
|
263
272
|
const keyPath = keyAction === "generate" ? "./keys/secret_key.pem" : "./keys/your-secret-key.pem";
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
273
|
+
const casperVars = {
|
|
274
|
+
CASPER_ENABLE_REAL_SUBMISSION: "true",
|
|
275
|
+
CASPER_RPC_URL: casperRpcUrl,
|
|
276
|
+
CASPER_ACCOUNT_KEY_PATH: keyPath
|
|
277
|
+
};
|
|
278
|
+
clack.log.info("Casper vars:\n\n" +
|
|
279
|
+
Object.entries(casperVars).map(([k, v]) => ` ${k}=${v}`).join("\n") +
|
|
280
|
+
`\n\n .env: ${result.envFile}`);
|
|
281
|
+
const writeCasper = await clack.confirm({ message: "Write these to your .env now?", initialValue: true });
|
|
282
|
+
if (!clack.isCancel(writeCasper) && writeCasper) {
|
|
283
|
+
const written = appendEnvVars(result.envFile, casperVars);
|
|
284
|
+
if (written.length > 0)
|
|
285
|
+
clack.log.success(`Written: ${written.join(", ")}`);
|
|
286
|
+
else
|
|
287
|
+
clack.log.info("Already set in .env — skipped.");
|
|
288
|
+
}
|
|
269
289
|
}
|
|
270
290
|
// ── 5. x402 payments ────────────────────────────────────────────────────────
|
|
271
291
|
const wantX402 = await clack.confirm({ message: "Enable x402 micropayments?", initialValue: false });
|
|
@@ -302,14 +322,33 @@ async function runInteractiveSetup() {
|
|
|
302
322
|
" Output looks like:\n" +
|
|
303
323
|
" account-hash-d0a57c6a95e74463de156cac761e17f0923eafc730ce3ce3a0c747c6598b0500\n\n" +
|
|
304
324
|
" No casper-client? Install: cargo install casper-client");
|
|
305
|
-
|
|
306
|
-
"
|
|
307
|
-
"
|
|
308
|
-
"
|
|
309
|
-
"
|
|
310
|
-
|
|
311
|
-
"
|
|
312
|
-
|
|
325
|
+
const x402Vars = {
|
|
326
|
+
X402_ENABLE_REAL_SETTLEMENT: "true",
|
|
327
|
+
X402_SETTLEMENT_MODE: "casper-cli",
|
|
328
|
+
X402_BUYER_ACCOUNT_HASH: "account-hash-REPLACE_WITH_YOUR_HASH",
|
|
329
|
+
CASPER_ENABLE_REAL_SUBMISSION: "true",
|
|
330
|
+
CASPER_RPC_URL: x402RpcUrl,
|
|
331
|
+
CASPER_ACCOUNT_KEY_PATH: "./keys/secret_key.pem"
|
|
332
|
+
};
|
|
333
|
+
clack.log.info("Step 2 — .env vars:\n\n" +
|
|
334
|
+
Object.entries(x402Vars).map(([k, v]) => ` ${k}=${v}`).join("\n") +
|
|
335
|
+
`\n\n .env: ${result.envFile}`);
|
|
336
|
+
const writeX402 = await clack.confirm({
|
|
337
|
+
message: "Write these to your .env? (you'll still need to replace X402_BUYER_ACCOUNT_HASH)",
|
|
338
|
+
initialValue: true
|
|
339
|
+
});
|
|
340
|
+
if (!clack.isCancel(writeX402) && writeX402) {
|
|
341
|
+
const written = appendEnvVars(result.envFile, x402Vars);
|
|
342
|
+
if (written.length > 0) {
|
|
343
|
+
clack.log.success(`Written: ${written.join(", ")}`);
|
|
344
|
+
if (written.includes("X402_BUYER_ACCOUNT_HASH")) {
|
|
345
|
+
clack.log.warn(`Edit X402_BUYER_ACCOUNT_HASH in ${result.envFile} with your actual account hash after running Step 1.`);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
clack.log.info("Already set in .env — skipped.");
|
|
350
|
+
}
|
|
351
|
+
}
|
|
313
352
|
clack.log.info("Step 3 — Fund your account\n\n" +
|
|
314
353
|
(x402Network === "testnet"
|
|
315
354
|
? ` Faucet: ${explorerBase}/tools/faucet\n`
|
package/dist/client-setup.js
CHANGED
|
@@ -11,19 +11,38 @@ const CLIENTS = [
|
|
|
11
11
|
{ name: "Claude Desktop", path: "%APPDATA%/Claude/claude_desktop_config.json", platforms: ["win32"], format: "standard" },
|
|
12
12
|
{ name: "Claude Desktop", path: "~/.config/Claude/claude_desktop_config.json", platforms: ["linux"], format: "standard" },
|
|
13
13
|
// Claude Code CLI
|
|
14
|
-
{
|
|
14
|
+
{
|
|
15
|
+
name: "Claude Code", path: "~/.claude/settings.json", platforms: ["darwin", "linux", "win32"], format: "standard",
|
|
16
|
+
appPaths: ["/usr/local/bin/claude", "/usr/bin/claude"]
|
|
17
|
+
},
|
|
15
18
|
// Cursor
|
|
16
|
-
{
|
|
17
|
-
|
|
19
|
+
{
|
|
20
|
+
name: "Cursor", path: "~/.cursor/mcp.json", platforms: ["darwin", "linux"], format: "standard",
|
|
21
|
+
appPaths: ["/Applications/Cursor.app", `${homedir()}/Applications/Cursor.app`]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "Cursor", path: "%USERPROFILE%/.cursor/mcp.json", platforms: ["win32"], format: "standard",
|
|
25
|
+
appPaths: ["C:/Users/Default/AppData/Local/Programs/cursor/Cursor.exe"]
|
|
26
|
+
},
|
|
18
27
|
// Windsurf
|
|
19
|
-
{
|
|
28
|
+
{
|
|
29
|
+
name: "Windsurf", path: "~/.codeium/windsurf/mcp_config.json", platforms: ["darwin", "linux", "win32"], format: "standard",
|
|
30
|
+
appPaths: ["/Applications/Windsurf.app", `${homedir()}/Applications/Windsurf.app`]
|
|
31
|
+
},
|
|
20
32
|
{ name: "Windsurf", path: "%APPDATA%/Windsurf/User/globalStorage/codeium.windsurf/mcp_config.json", platforms: ["win32"], format: "standard" },
|
|
21
33
|
// Zed
|
|
22
|
-
{
|
|
34
|
+
{
|
|
35
|
+
name: "Zed", path: "~/.config/zed/settings.json", platforms: ["darwin", "linux"], format: "zed",
|
|
36
|
+
appPaths: ["/Applications/Zed.app", `${homedir()}/Applications/Zed.app`]
|
|
37
|
+
},
|
|
23
38
|
// Continue.dev
|
|
24
39
|
{ name: "Continue", path: "~/.continue/config.json", platforms: ["darwin", "linux", "win32"], format: "continue" },
|
|
25
40
|
// VS Code (user-level MCP config — requires GitHub Copilot or MCP extension)
|
|
26
|
-
{
|
|
41
|
+
{
|
|
42
|
+
name: "VS Code", path: "~/.vscode/mcp.json", platforms: ["darwin", "linux"], format: "standard",
|
|
43
|
+
appPaths: ["/Applications/Visual Studio Code.app", `${homedir()}/Applications/Visual Studio Code.app`, "/usr/bin/code", "/usr/local/bin/code"]
|
|
44
|
+
},
|
|
45
|
+
{ name: "VS Code", path: "~/.vscode/mcp.json", platforms: ["win32"], format: "standard" },
|
|
27
46
|
// Cline (VS Code extension by saoudrizwan)
|
|
28
47
|
{
|
|
29
48
|
name: "Cline",
|
|
@@ -100,9 +119,11 @@ function expandPath(p, env) {
|
|
|
100
119
|
.replace(/%APPDATA%/gi, env.APPDATA ?? "")
|
|
101
120
|
.replace(/%USERPROFILE%/gi, env.USERPROFILE ?? home);
|
|
102
121
|
}
|
|
103
|
-
function isInstalled(configPath, detectDir) {
|
|
122
|
+
function isInstalled(configPath, detectDir, appPaths) {
|
|
104
123
|
const dir = detectDir ?? dirname(configPath);
|
|
105
|
-
|
|
124
|
+
if (existsSync(dir) || existsSync(configPath))
|
|
125
|
+
return true;
|
|
126
|
+
return appPaths?.some(p => existsSync(p)) ?? false;
|
|
106
127
|
}
|
|
107
128
|
function readJson(path) {
|
|
108
129
|
if (!existsSync(path))
|
|
@@ -163,7 +184,7 @@ export function detectClients(env = process.env) {
|
|
|
163
184
|
continue;
|
|
164
185
|
seen.add(key);
|
|
165
186
|
const detectDir = client.detectDir ? expandPath(client.detectDir, env) : undefined;
|
|
166
|
-
results.push({ name: client.name, configPath, installed: isInstalled(configPath, detectDir), format: client.format });
|
|
187
|
+
results.push({ name: client.name, configPath, installed: isInstalled(configPath, detectDir, client.appPaths), format: client.format });
|
|
167
188
|
}
|
|
168
189
|
return results;
|
|
169
190
|
}
|
|
@@ -199,7 +220,7 @@ export function setupAllClients(env = process.env) {
|
|
|
199
220
|
continue;
|
|
200
221
|
seen.add(key);
|
|
201
222
|
const detectDir = client.detectDir ? expandPath(client.detectDir, env) : undefined;
|
|
202
|
-
if (!isInstalled(configPath, detectDir)) {
|
|
223
|
+
if (!isInstalled(configPath, detectDir, client.appPaths)) {
|
|
203
224
|
results.push({ name: client.name, configPath, status: "not-installed" });
|
|
204
225
|
continue;
|
|
205
226
|
}
|
package/package.json
CHANGED