openalmanac 0.2.26 → 0.2.27
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/auth.js +3 -0
- package/dist/browser.js +6 -5
- package/dist/server.js +6 -1
- package/dist/setup.js +1 -1
- package/dist/tools/articles.js +1 -1
- package/dist/validate.js +10 -6
- package/package.json +1 -1
package/dist/auth.js
CHANGED
|
@@ -88,6 +88,9 @@ export async function request(method, path, options = {}) {
|
|
|
88
88
|
}
|
|
89
89
|
const resp = await fetch(url, init);
|
|
90
90
|
if (!resp.ok) {
|
|
91
|
+
if (resp.status === 401 || resp.status === 403) {
|
|
92
|
+
throw new Error(`Authentication failed (${resp.status}). Your API key may be invalid or expired. Run 'login' to re-authenticate.`);
|
|
93
|
+
}
|
|
91
94
|
const text = await resp.text();
|
|
92
95
|
throw new Error(`${resp.status} ${resp.statusText}: ${text}`);
|
|
93
96
|
}
|
package/dist/browser.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
2
|
import { platform } from "node:os";
|
|
3
3
|
export function openBrowser(url) {
|
|
4
4
|
const cmd = platform() === "darwin"
|
|
5
|
-
?
|
|
5
|
+
? "open"
|
|
6
6
|
: platform() === "win32"
|
|
7
|
-
?
|
|
8
|
-
:
|
|
7
|
+
? "start"
|
|
8
|
+
: "xdg-open";
|
|
9
9
|
try {
|
|
10
|
-
|
|
10
|
+
const args = platform() === "win32" ? ["", url] : [url];
|
|
11
|
+
execFileSync(cmd, args, { stdio: "ignore" });
|
|
11
12
|
return true;
|
|
12
13
|
}
|
|
13
14
|
catch {
|
package/dist/server.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { readFileSync } from "fs";
|
|
2
|
+
import { join, dirname } from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
1
4
|
import { FastMCP } from "fastmcp";
|
|
2
5
|
import { registerAuthTools } from "./tools/auth.js";
|
|
3
6
|
import { registerArticleTools } from "./tools/articles.js";
|
|
@@ -5,6 +8,8 @@ import { registerResearchTools } from "./tools/research.js";
|
|
|
5
8
|
import { registerCommunityTools } from "./tools/communities.js";
|
|
6
9
|
import { registerPeopleTools } from "./tools/people.js";
|
|
7
10
|
import { getApiKey } from "./auth.js";
|
|
11
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
|
|
8
13
|
export function createServer() {
|
|
9
14
|
if (!getApiKey()) {
|
|
10
15
|
console.error(`
|
|
@@ -24,7 +29,7 @@ export function createServer() {
|
|
|
24
29
|
}
|
|
25
30
|
const server = new FastMCP({
|
|
26
31
|
name: "OpenAlmanac",
|
|
27
|
-
version:
|
|
32
|
+
version: pkg.version,
|
|
28
33
|
instructions: [
|
|
29
34
|
"OpenAlmanac is an open knowledge base — a Wikipedia anyone can read from and write to through an API. Articles are markdown files with YAML frontmatter and [N] citation markers mapped to sources.",
|
|
30
35
|
"",
|
package/dist/setup.js
CHANGED
|
@@ -155,7 +155,7 @@ function configureMcp() {
|
|
|
155
155
|
JSON.stringify(cur.args) === JSON.stringify(["-y", "openalmanac"])) {
|
|
156
156
|
return false; // already set
|
|
157
157
|
}
|
|
158
|
-
cfg.mcpServers.almanac = { command: "npx", args: ["-y", "openalmanac"] };
|
|
158
|
+
cfg.mcpServers.almanac = { command: "npx", args: ["-y", "openalmanac@latest"] };
|
|
159
159
|
writeJson(CLAUDE_JSON, cfg);
|
|
160
160
|
return true;
|
|
161
161
|
}
|
package/dist/tools/articles.js
CHANGED
|
@@ -218,7 +218,7 @@ export function registerArticleTools(server) {
|
|
|
218
218
|
? "\n\nThis is a STUB article — a placeholder that hasn't been fully written yet. " +
|
|
219
219
|
"Fill in the content body with a complete article, then push to publish."
|
|
220
220
|
: "";
|
|
221
|
-
return `
|
|
221
|
+
return `Downloaded "${title}" to ${filePath}\n${wordCount} words, ${frontmatter.sources?.length ?? 0} sources.${stubNote}\n\n${WRITING_GUIDE}`;
|
|
222
222
|
},
|
|
223
223
|
});
|
|
224
224
|
server.addTool({
|
package/dist/validate.js
CHANGED
|
@@ -47,14 +47,18 @@ export function validateArticle(raw) {
|
|
|
47
47
|
if (!s.title || typeof s.title !== "string") {
|
|
48
48
|
errors.push({ field: `sources[${i}].title`, message: "Title is required" });
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
const accessedDate = s.accessed_date;
|
|
51
|
+
if (!accessedDate) {
|
|
51
52
|
errors.push({ field: `sources[${i}].accessed_date`, message: "Accessed date is required" });
|
|
52
53
|
}
|
|
53
|
-
else if (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
});
|
|
54
|
+
else if (accessedDate instanceof Date) {
|
|
55
|
+
// YAML parsed it as a Date object — valid
|
|
56
|
+
}
|
|
57
|
+
else if (typeof accessedDate === "string" && !DATE_RE.test(accessedDate)) {
|
|
58
|
+
errors.push({ field: `sources[${i}].accessed_date`, message: "Must be YYYY-MM-DD format" });
|
|
59
|
+
}
|
|
60
|
+
else if (typeof accessedDate !== "string" && !(accessedDate instanceof Date)) {
|
|
61
|
+
errors.push({ field: `sources[${i}].accessed_date`, message: "Must be YYYY-MM-DD format" });
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
64
|
}
|