openalmanac 0.2.27 → 0.2.28
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 +29 -12
- 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) {
|
|
@@ -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}`;
|