openalmanac 0.2.27 → 0.2.29
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/setup.js +32 -15
- package/package.json +1 -1
package/dist/setup.js
CHANGED
|
@@ -127,7 +127,8 @@ const vis = (s) => s.replace(/\x1b\[[0-9;]*m/g, "").length;
|
|
|
127
127
|
const w = (s) => process.stdout.write(s + "\n");
|
|
128
128
|
/* ── File helpers ───────────────────────────────────────────────── */
|
|
129
129
|
const CLAUDE_DIR = join(homedir(), ".claude");
|
|
130
|
-
const CLAUDE_JSON = join(homedir(), ".claude.json");
|
|
130
|
+
const CLAUDE_JSON = join(homedir(), ".claude.json"); // Claude Desktop
|
|
131
|
+
const CLAUDE_CODE_MCP = join(CLAUDE_DIR, "mcp.json"); // Claude Code
|
|
131
132
|
const SETTINGS_JSON = join(CLAUDE_DIR, "settings.json");
|
|
132
133
|
function ensureDir(dir) {
|
|
133
134
|
if (!existsSync(dir))
|
|
@@ -145,19 +146,35 @@ function writeJson(path, data) {
|
|
|
145
146
|
writeFileSync(path, JSON.stringify(data, null, 2) + "\n");
|
|
146
147
|
}
|
|
147
148
|
/* ── Step 1 — MCP server ───────────────────────────────────────── */
|
|
149
|
+
const ALMANAC_MCP_ENTRY = { command: "npx", args: ["-y", "openalmanac@latest"] };
|
|
150
|
+
function isAlmanacCurrent(server) {
|
|
151
|
+
return (server?.command === "npx" &&
|
|
152
|
+
JSON.stringify(server.args) === JSON.stringify(ALMANAC_MCP_ENTRY.args));
|
|
153
|
+
}
|
|
148
154
|
function configureMcp() {
|
|
155
|
+
let changed = false;
|
|
156
|
+
// Claude Desktop — ~/.claude.json
|
|
157
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
158
|
+
const desktop = readJson(CLAUDE_JSON);
|
|
159
|
+
if (!desktop.mcpServers)
|
|
160
|
+
desktop.mcpServers = {};
|
|
161
|
+
if (!isAlmanacCurrent(desktop.mcpServers.almanac)) {
|
|
162
|
+
desktop.mcpServers.almanac = { ...ALMANAC_MCP_ENTRY };
|
|
163
|
+
writeJson(CLAUDE_JSON, desktop);
|
|
164
|
+
changed = true;
|
|
165
|
+
}
|
|
166
|
+
// Claude Code — ~/.claude/mcp.json
|
|
167
|
+
ensureDir(CLAUDE_DIR);
|
|
149
168
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
150
|
-
const
|
|
151
|
-
if (!
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
169
|
+
const code = readJson(CLAUDE_CODE_MCP);
|
|
170
|
+
if (!code.mcpServers)
|
|
171
|
+
code.mcpServers = {};
|
|
172
|
+
if (!isAlmanacCurrent(code.mcpServers.almanac)) {
|
|
173
|
+
code.mcpServers.almanac = { ...ALMANAC_MCP_ENTRY };
|
|
174
|
+
writeJson(CLAUDE_CODE_MCP, code);
|
|
175
|
+
changed = true;
|
|
157
176
|
}
|
|
158
|
-
|
|
159
|
-
writeJson(CLAUDE_JSON, cfg);
|
|
160
|
-
return true;
|
|
177
|
+
return changed;
|
|
161
178
|
}
|
|
162
179
|
/* ── Step 2 — Permissions ──────────────────────────────────────── */
|
|
163
180
|
function configurePermissions(tools) {
|
|
@@ -260,7 +277,7 @@ async function runLoginStep(agent, mcpChanged, toolCount) {
|
|
|
260
277
|
const priorSteps = () => {
|
|
261
278
|
stepDone(`Agent \u2192 ${WHITE_BOLD}${agent}${RST}`);
|
|
262
279
|
w(BAR);
|
|
263
|
-
stepDone(`MCP server ${mcpChanged ?
|
|
280
|
+
stepDone(`MCP server ${mcpChanged ? "configured" : `${DIM}already configured${RST}`}`);
|
|
264
281
|
w(BAR);
|
|
265
282
|
stepDone(`${BLUE}${toolCount}${RST} tool${toolCount !== 1 ? "s" : ""} allowed`);
|
|
266
283
|
w(BAR);
|
|
@@ -414,7 +431,7 @@ function renderToolSelect(selected, cursor, agent, mcpChanged) {
|
|
|
414
431
|
w("");
|
|
415
432
|
stepDone(`Agent \u2192 ${WHITE_BOLD}${agent}${RST}`);
|
|
416
433
|
w(BAR);
|
|
417
|
-
stepDone(`MCP server ${mcpChanged ?
|
|
434
|
+
stepDone(`MCP server ${mcpChanged ? "configured" : `${DIM}already configured${RST}`}`);
|
|
418
435
|
w(BAR);
|
|
419
436
|
stepActive(`Select tool permissions ${DIM}deselect any you'd rather approve manually${RST}`);
|
|
420
437
|
w(BAR);
|
|
@@ -483,7 +500,7 @@ function printResult(agent, loginResult, mcpChanged, toolCount) {
|
|
|
483
500
|
w("");
|
|
484
501
|
stepDone(`Agent \u2192 ${WHITE_BOLD}${agent}${RST}`);
|
|
485
502
|
w(BAR);
|
|
486
|
-
stepDone(`MCP server ${mcpChanged ?
|
|
503
|
+
stepDone(`MCP server ${mcpChanged ? "configured" : `${DIM}already configured${RST}`}`);
|
|
487
504
|
w(BAR);
|
|
488
505
|
stepDone(`${BLUE}${toolCount}${RST} tool${toolCount !== 1 ? "s" : ""} allowed in ${DIM}~/.claude/settings.json${RST}`);
|
|
489
506
|
w(BAR);
|
|
@@ -492,7 +509,7 @@ function printResult(agent, loginResult, mcpChanged, toolCount) {
|
|
|
492
509
|
stepDone(`${BLUE}Setup complete${RST}`);
|
|
493
510
|
w("");
|
|
494
511
|
// Next steps box
|
|
495
|
-
const innerW =
|
|
512
|
+
const innerW = 62;
|
|
496
513
|
const row = (content) => {
|
|
497
514
|
const padding = Math.max(0, innerW - vis(content));
|
|
498
515
|
return ` ${BLUE_DIM}\u2502${RST}${content}${" ".repeat(padding)}${BLUE_DIM}\u2502${RST}`;
|