@ureck/alexandria 1.4.0 → 1.5.0
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/README.md +30 -3
- package/dist/{chunk-2ESJQAP4.js → chunk-B7HCWKPJ.js} +6 -4
- package/dist/{chunk-3CB7GRFJ.js → chunk-BV2KJV5W.js} +7 -3
- package/dist/{chunk-MDGFK6UC.js → chunk-CEHNXDUE.js} +9 -53
- package/dist/{chunk-4ZSTD3CU.js → chunk-GP5A2GWI.js} +1 -1
- package/dist/chunk-POA77JSS.js +76 -0
- package/dist/chunk-SAKIVZMP.js +495 -0
- package/dist/chunk-UU4MGB2C.js +262 -0
- package/dist/{chunk-FPKJVQ2X.js → chunk-Y6S6SKH4.js} +1 -1
- package/dist/{chunk-U2U53TU2.js → chunk-ZDS6VULX.js} +1 -1
- package/dist/cli.js +84 -8
- package/dist/hooks/on-prompt.js +7 -5
- package/dist/hooks/on-read.js +70 -0
- package/dist/hooks/on-session-start.js +6 -4
- package/dist/hooks/on-stop.js +5 -4
- package/dist/mcp/server.js +42 -6
- package/dist/{viewer-OU4TB3X5.js → viewer-WQQSQETT.js} +2 -2
- package/package.json +15 -3
- package/dist/chunk-JI2L66DF.js +0 -189
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ureck/alexandria",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Alexandria — bóveda de conocimiento local para agentes de IA (Claude Code, Codex, Gemini CLI, Cursor, OpenCode y más): captura automática por hooks, búsqueda semántica offline y grafo estilo Obsidian. Ahorra tokens inyectando solo el contexto relevante.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,22 +37,34 @@
|
|
|
37
37
|
"opencode",
|
|
38
38
|
"hooks",
|
|
39
39
|
"ai-memory",
|
|
40
|
-
"agents-md"
|
|
40
|
+
"agents-md",
|
|
41
|
+
"pdf",
|
|
42
|
+
"docx",
|
|
43
|
+
"xlsx",
|
|
44
|
+
"document-reading",
|
|
45
|
+
"token-optimization"
|
|
41
46
|
],
|
|
42
47
|
"dependencies": {
|
|
43
48
|
"@huggingface/transformers": "^4.3.2",
|
|
44
49
|
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
45
50
|
"commander": "^15.0.0",
|
|
51
|
+
"exceljs": "^4.4.0",
|
|
46
52
|
"gray-matter": "^4.0.3",
|
|
53
|
+
"mammoth": "^1.13.0",
|
|
47
54
|
"minisearch": "^7.1.2",
|
|
48
55
|
"picocolors": "^1.1.1",
|
|
56
|
+
"turndown": "^7.2.4",
|
|
57
|
+
"unpdf": "^1.9.1",
|
|
49
58
|
"zod": "^4.6.7"
|
|
50
59
|
},
|
|
51
60
|
"overrides": {
|
|
52
|
-
"sharp": "^0.35.5"
|
|
61
|
+
"sharp": "^0.35.5",
|
|
62
|
+
"uuid": "^11.1.1"
|
|
53
63
|
},
|
|
54
64
|
"devDependencies": {
|
|
55
65
|
"@types/node": "^22.20.5",
|
|
66
|
+
"@types/turndown": "^5.0.6",
|
|
67
|
+
"jszip": "^3.10.2",
|
|
56
68
|
"tsup": "^9.0.0",
|
|
57
69
|
"typescript": "^5.7.3",
|
|
58
70
|
"vitest": "^5.0.5"
|
package/dist/chunk-JI2L66DF.js
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
hybridSearch
|
|
4
|
-
} from "./chunk-FPKJVQ2X.js";
|
|
5
|
-
|
|
6
|
-
// src/core/planning.ts
|
|
7
|
-
var MAX_ITEMS = 2;
|
|
8
|
-
var EXCERPT_CHARS = 150;
|
|
9
|
-
async function planContext(vault, query) {
|
|
10
|
-
const out = { similarPlans: [], lessons: [] };
|
|
11
|
-
try {
|
|
12
|
-
const results = await hybridSearch(vault, query, 8);
|
|
13
|
-
for (const r of results) {
|
|
14
|
-
const excerpt = (r.excerpts[0] ?? "").replace(/\n+/g, " ").slice(0, EXCERPT_CHARS);
|
|
15
|
-
if (r.note.type === "plan" && out.similarPlans.length < MAX_ITEMS) {
|
|
16
|
-
out.similarPlans.push(`\xAB${r.note.title}\xBB (${r.note.status ?? "?"}): ${excerpt}`);
|
|
17
|
-
} else if ((r.note.type === "lesson" || r.note.type === "solution") && out.lessons.length < MAX_ITEMS) {
|
|
18
|
-
out.lessons.push(`\xAB${r.note.title}\xBB: ${excerpt}`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
} catch {
|
|
22
|
-
}
|
|
23
|
-
return out;
|
|
24
|
-
}
|
|
25
|
-
var FAT_TASK_CHARS = 140;
|
|
26
|
-
var MAX_HINTS = 3;
|
|
27
|
-
function planQualityHints(dod, tasks, design) {
|
|
28
|
-
const hints = [];
|
|
29
|
-
const fat = tasks.filter((t) => t.length > FAT_TASK_CHARS);
|
|
30
|
-
if (fat.length) hints.push(`${fat.length} tarea(s) gorda(s) (>${FAT_TASK_CHARS}c) \u2014 1 tarea = 1 task_verify`);
|
|
31
|
-
if (dod.length < 2) hints.push("DoD <2 criterios verificables");
|
|
32
|
-
const vague = dod.filter((d) => /funcione bien|quede bonito|esté listo|sea mejor/i.test(d));
|
|
33
|
-
if (vague.length) hints.push(`${vague.length} criterio(s) no verificable(s) por comando`);
|
|
34
|
-
if (tasks.length > 5 && !design?.trim()) hints.push("sin `design` (plan grande)");
|
|
35
|
-
return hints.slice(0, MAX_HINTS);
|
|
36
|
-
}
|
|
37
|
-
function architectBlock(ctx, hints) {
|
|
38
|
-
const parts = [];
|
|
39
|
-
for (const p of ctx.similarPlans) parts.push(`Similar: ${p}`);
|
|
40
|
-
for (const l of ctx.lessons) parts.push(`Lecci\xF3n: ${l}`);
|
|
41
|
-
if (hints.length) parts.push(`Hints: ${hints.join(" \xB7 ")}`);
|
|
42
|
-
return parts.join("\n");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// src/core/register.ts
|
|
46
|
-
import fs from "fs";
|
|
47
|
-
import os from "os";
|
|
48
|
-
import path from "path";
|
|
49
|
-
import { fileURLToPath } from "url";
|
|
50
|
-
import { execFileSync } from "child_process";
|
|
51
|
-
function distDir() {
|
|
52
|
-
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
53
|
-
return here.endsWith(`${path.sep}hooks`) || here.endsWith(`${path.sep}mcp`) ? path.dirname(here) : here;
|
|
54
|
-
}
|
|
55
|
-
var MARKER = "alexandria";
|
|
56
|
-
function hookCommand(script, timeout) {
|
|
57
|
-
return { type: "command", command: `node "${script}"`, timeout };
|
|
58
|
-
}
|
|
59
|
-
function isOurs(cmd) {
|
|
60
|
-
return cmd.includes(MARKER) || cmd.includes(distDir());
|
|
61
|
-
}
|
|
62
|
-
function registerHooks(settingsPath) {
|
|
63
|
-
const d = distDir();
|
|
64
|
-
const wanted = {
|
|
65
|
-
SessionStart: hookCommand(path.join(d, "hooks", "on-session-start.js"), 20),
|
|
66
|
-
UserPromptSubmit: hookCommand(path.join(d, "hooks", "on-prompt.js"), 30),
|
|
67
|
-
Stop: hookCommand(path.join(d, "hooks", "on-stop.js"), 30),
|
|
68
|
-
PreCompact: hookCommand(path.join(d, "hooks", "on-stop.js"), 30)
|
|
69
|
-
};
|
|
70
|
-
fs.mkdirSync(path.dirname(settingsPath), { recursive: true });
|
|
71
|
-
let settings = {};
|
|
72
|
-
try {
|
|
73
|
-
settings = JSON.parse(fs.readFileSync(settingsPath, "utf8"));
|
|
74
|
-
} catch {
|
|
75
|
-
if (fs.existsSync(settingsPath)) {
|
|
76
|
-
throw new Error(`No pude parsear ${settingsPath} \u2014 rev\xEDsalo manualmente antes de registrar hooks.`);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
settings.hooks ??= {};
|
|
80
|
-
for (const [event, cmd] of Object.entries(wanted)) {
|
|
81
|
-
const matchers = (settings.hooks[event] ?? []).filter(
|
|
82
|
-
(m) => !m.hooks?.some((h) => isOurs(h.command))
|
|
83
|
-
);
|
|
84
|
-
matchers.push({ hooks: [cmd] });
|
|
85
|
-
settings.hooks[event] = matchers;
|
|
86
|
-
}
|
|
87
|
-
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
|
|
88
|
-
}
|
|
89
|
-
function unregisterHooks(settingsPath) {
|
|
90
|
-
try {
|
|
91
|
-
const settings = JSON.parse(fs.readFileSync(settingsPath, "utf8"));
|
|
92
|
-
if (!settings.hooks) return;
|
|
93
|
-
for (const event of Object.keys(settings.hooks)) {
|
|
94
|
-
settings.hooks[event] = settings.hooks[event].map((m) => ({ ...m, hooks: m.hooks.filter((h) => !isOurs(h.command)) })).filter((m) => m.hooks.length > 0);
|
|
95
|
-
if (settings.hooks[event].length === 0) delete settings.hooks[event];
|
|
96
|
-
}
|
|
97
|
-
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
|
|
98
|
-
} catch {
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
function projectSettingsPath(projectDir) {
|
|
102
|
-
return path.join(projectDir, ".claude", "settings.json");
|
|
103
|
-
}
|
|
104
|
-
function globalSettingsPath() {
|
|
105
|
-
return path.join(os.homedir(), ".claude", "settings.json");
|
|
106
|
-
}
|
|
107
|
-
function hooksRegistered(settingsPath) {
|
|
108
|
-
try {
|
|
109
|
-
const settings = JSON.parse(fs.readFileSync(settingsPath, "utf8"));
|
|
110
|
-
const hooks = settings.hooks ?? {};
|
|
111
|
-
return ["SessionStart", "UserPromptSubmit"].every(
|
|
112
|
-
(ev) => (hooks[ev] ?? []).some((m) => m.hooks?.some((h) => isOurs(h.command)))
|
|
113
|
-
);
|
|
114
|
-
} catch {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
function serverCommand(portable) {
|
|
119
|
-
return portable ? { command: "npx", args: ["-y", "@ureck/alexandria", "alexandria", "serve-mcp"] } : { command: "node", args: [path.join(distDir(), "mcp", "server.js")] };
|
|
120
|
-
}
|
|
121
|
-
function registerMcpProject(projectDir, portable = false) {
|
|
122
|
-
const file = path.join(projectDir, ".mcp.json");
|
|
123
|
-
let cfg = {};
|
|
124
|
-
try {
|
|
125
|
-
cfg = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
126
|
-
} catch {
|
|
127
|
-
if (fs.existsSync(file)) {
|
|
128
|
-
throw new Error(`No pude parsear ${file} \u2014 rev\xEDsalo manualmente.`);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
cfg.mcpServers ??= {};
|
|
132
|
-
cfg.mcpServers["alexandria"] = serverCommand(portable);
|
|
133
|
-
fs.writeFileSync(file, JSON.stringify(cfg, null, 2) + "\n");
|
|
134
|
-
return file;
|
|
135
|
-
}
|
|
136
|
-
function registerMcpGlobal(portable = false) {
|
|
137
|
-
const { command, args } = serverCommand(portable);
|
|
138
|
-
try {
|
|
139
|
-
execFileSync("claude", ["mcp", "add", "--scope", "user", "alexandria", "--", command, ...args], {
|
|
140
|
-
stdio: "pipe",
|
|
141
|
-
timeout: 15e3,
|
|
142
|
-
shell: process.platform === "win32"
|
|
143
|
-
// en Windows los binarios globales de npm son shims .cmd/.ps1
|
|
144
|
-
});
|
|
145
|
-
return true;
|
|
146
|
-
} catch {
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
function mcpRegisteredProject(projectDir) {
|
|
151
|
-
try {
|
|
152
|
-
const cfg = JSON.parse(fs.readFileSync(path.join(projectDir, ".mcp.json"), "utf8"));
|
|
153
|
-
return Boolean(cfg.mcpServers?.alexandria);
|
|
154
|
-
} catch {
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// src/core/pkg.ts
|
|
160
|
-
import fs2 from "fs";
|
|
161
|
-
import path2 from "path";
|
|
162
|
-
var cached = null;
|
|
163
|
-
function pkgVersion() {
|
|
164
|
-
if (cached) return cached;
|
|
165
|
-
try {
|
|
166
|
-
const pkg = JSON.parse(fs2.readFileSync(path2.join(distDir(), "..", "package.json"), "utf8"));
|
|
167
|
-
cached = String(pkg.version);
|
|
168
|
-
} catch {
|
|
169
|
-
cached = "0.0.0";
|
|
170
|
-
}
|
|
171
|
-
return cached;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export {
|
|
175
|
-
planContext,
|
|
176
|
-
planQualityHints,
|
|
177
|
-
architectBlock,
|
|
178
|
-
distDir,
|
|
179
|
-
registerHooks,
|
|
180
|
-
unregisterHooks,
|
|
181
|
-
projectSettingsPath,
|
|
182
|
-
globalSettingsPath,
|
|
183
|
-
hooksRegistered,
|
|
184
|
-
serverCommand,
|
|
185
|
-
registerMcpProject,
|
|
186
|
-
registerMcpGlobal,
|
|
187
|
-
mcpRegisteredProject,
|
|
188
|
-
pkgVersion
|
|
189
|
-
};
|