@ureck/alexandria 1.5.0 → 1.6.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 +33 -4
- package/dist/{chunk-BV2KJV5W.js → chunk-44QPE5IM.js} +46 -2
- package/dist/{chunk-Y6S6SKH4.js → chunk-47S5I3D3.js} +2 -2
- package/dist/chunk-ADA25MTF.js +142 -0
- package/dist/chunk-BXVNQVLX.js +831 -0
- package/dist/{chunk-UU4MGB2C.js → chunk-I5H4BN3F.js} +3 -2
- package/dist/chunk-OGVWOBYH.js +197 -0
- package/dist/{chunk-GP5A2GWI.js → chunk-SSTG2NOO.js} +1 -1
- package/dist/{chunk-B7HCWKPJ.js → chunk-WSVNMMNN.js} +43 -9
- package/dist/{chunk-ZDS6VULX.js → chunk-WVZQGLRI.js} +1 -1
- package/dist/chunk-X4V6SYYA.js +131 -0
- package/dist/{chunk-CEHNXDUE.js → chunk-YICWI3U3.js} +20 -2
- package/dist/cli.js +167 -24
- package/dist/hooks/on-bash.js +45 -0
- package/dist/hooks/on-prompt.js +35 -13
- package/dist/hooks/on-read.js +3 -3
- package/dist/hooks/on-session-start.js +18 -9
- package/dist/hooks/on-stop.js +26 -8
- package/dist/mcp/server.js +88 -21
- package/dist/{viewer-WQQSQETT.js → viewer-T2SEBP6Z.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-POA77JSS.js +0 -76
- package/dist/chunk-SAKIVZMP.js +0 -495
package/dist/mcp/server.js
CHANGED
|
@@ -2,31 +2,39 @@
|
|
|
2
2
|
import {
|
|
3
3
|
architectBlock,
|
|
4
4
|
ingestAndOutline,
|
|
5
|
+
isUrl,
|
|
6
|
+
outlineDir,
|
|
7
|
+
outlineFile,
|
|
5
8
|
pkgVersion,
|
|
6
9
|
planContext,
|
|
7
10
|
planQualityHints,
|
|
8
|
-
readDoc
|
|
9
|
-
|
|
11
|
+
readDoc,
|
|
12
|
+
symbolSource
|
|
13
|
+
} from "../chunk-BXVNQVLX.js";
|
|
10
14
|
import {
|
|
11
15
|
hybridSearch
|
|
12
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-47S5I3D3.js";
|
|
13
17
|
import {
|
|
14
18
|
searchArchive
|
|
15
|
-
} from "../chunk-
|
|
16
|
-
import "../chunk-POA77JSS.js";
|
|
17
|
-
import "../chunk-UU4MGB2C.js";
|
|
18
|
-
import {
|
|
19
|
-
ensureVaultStructure,
|
|
20
|
-
resolveVault,
|
|
21
|
-
toggleEnabled
|
|
22
|
-
} from "../chunk-CEHNXDUE.js";
|
|
19
|
+
} from "../chunk-WSVNMMNN.js";
|
|
23
20
|
import {
|
|
24
21
|
VaultIndex,
|
|
25
22
|
createNote,
|
|
26
23
|
setNoteStatus,
|
|
27
24
|
slugify,
|
|
25
|
+
supersedeNote,
|
|
28
26
|
upsertNote
|
|
29
|
-
} from "../chunk-
|
|
27
|
+
} from "../chunk-44QPE5IM.js";
|
|
28
|
+
import "../chunk-I5H4BN3F.js";
|
|
29
|
+
import {
|
|
30
|
+
showRun
|
|
31
|
+
} from "../chunk-OGVWOBYH.js";
|
|
32
|
+
import "../chunk-X4V6SYYA.js";
|
|
33
|
+
import {
|
|
34
|
+
ensureVaultStructure,
|
|
35
|
+
resolveVault,
|
|
36
|
+
toggleEnabled
|
|
37
|
+
} from "../chunk-YICWI3U3.js";
|
|
30
38
|
import "../chunk-EDYBSJSS.js";
|
|
31
39
|
|
|
32
40
|
// src/mcp/server.ts
|
|
@@ -89,7 +97,7 @@ server.registerTool(
|
|
|
89
97
|
);
|
|
90
98
|
}
|
|
91
99
|
const out = results.map(
|
|
92
|
-
(r, i) => `${i + 1}. \xAB${r.note.title}\xBB (${r.note.rel}, tipo: ${r.note.type})
|
|
100
|
+
(r, i) => `${i + 1}. \xAB${r.note.title}\xBB (${r.note.rel}, tipo: ${r.note.type})${r.note.status === "superseded" ? ` [reemplazada por \xAB${r.note.supersededBy ?? "?"}\xBB]` : ""}
|
|
93
101
|
${r.excerpts.map((e) => " " + e.replace(/\n/g, "\n ").slice(0, 900)).join("\n")}`
|
|
94
102
|
).join("\n\n");
|
|
95
103
|
return text(out);
|
|
@@ -98,14 +106,15 @@ ${r.excerpts.map((e) => " " + e.replace(/\n/g, "\n ").slice(0, 900)).join("\
|
|
|
98
106
|
server.registerTool(
|
|
99
107
|
"vault_save",
|
|
100
108
|
{
|
|
101
|
-
description: 'Guarda conocimiento destilado en la b\xF3veda (decisiones, arquitectura, soluciones). Si title empieza con "Mapa - " actualiza/crea el mapa del proyecto (se inyecta al inicio de cada sesi\xF3n).',
|
|
109
|
+
description: 'Guarda conocimiento destilado en la b\xF3veda (decisiones, arquitectura, soluciones). Si title empieza con "Mapa - " actualiza/crea el mapa del proyecto (se inyecta al inicio de cada sesi\xF3n). Si esta nota CAMBIA una decisi\xF3n o hecho anterior, pasa `supersedes` con el t\xEDtulo de la vieja: queda marcada como reemplazada y deja de inyectarse (no se borra).',
|
|
102
110
|
inputSchema: {
|
|
103
111
|
title: z.string(),
|
|
104
112
|
content: z.string().describe("Markdown; puede incluir [[wikilinks]] a otras notas"),
|
|
105
|
-
tags: z.array(z.string()).optional()
|
|
113
|
+
tags: z.array(z.string()).optional(),
|
|
114
|
+
supersedes: z.array(z.string()).optional().describe("T\xEDtulos o rutas de notas que esta reemplaza (decisi\xF3n cambiada, hecho desactualizado)")
|
|
106
115
|
}
|
|
107
116
|
},
|
|
108
|
-
async ({ title, content, tags }) => {
|
|
117
|
+
async ({ title, content, tags, supersedes }) => {
|
|
109
118
|
ensureVaultStructure(vault);
|
|
110
119
|
if (!title.startsWith("Mapa - ") && !/\[\[/.test(content)) {
|
|
111
120
|
const map = findMap(VaultIndex.load(vault));
|
|
@@ -126,9 +135,22 @@ Proyecto: [[${map.title}]]`;
|
|
|
126
135
|
} else {
|
|
127
136
|
file = createNote(vault.managed, { title, content, tags: tags ?? [], type: "note" });
|
|
128
137
|
}
|
|
138
|
+
const replaced = [];
|
|
139
|
+
if (supersedes?.length) {
|
|
140
|
+
const idxS = VaultIndex.load(vault);
|
|
141
|
+
for (const ref of supersedes) {
|
|
142
|
+
const old = findByTitle(idxS, ref);
|
|
143
|
+
if (old && path.join(vault.root, old.rel) !== file) {
|
|
144
|
+
supersedeNote(path.join(vault.root, old.rel), title);
|
|
145
|
+
replaced.push(old.title);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
129
149
|
await VaultIndex.load(vault).refresh().catch(() => {
|
|
130
150
|
});
|
|
131
|
-
return text(
|
|
151
|
+
return text(
|
|
152
|
+
`Guardado en ${path.relative(vault.root, file)}` + (replaced.length ? `. Reemplaza a: ${replaced.map((t) => `\xAB${t}\xBB`).join(", ")} (marcadas, ya no se inyectan).` : "") + (supersedes?.length && replaced.length < supersedes.length ? ` No encontr\xE9: ${supersedes.length - replaced.length}.` : "")
|
|
153
|
+
);
|
|
132
154
|
}
|
|
133
155
|
);
|
|
134
156
|
server.registerTool(
|
|
@@ -177,15 +199,15 @@ server.registerTool(
|
|
|
177
199
|
server.registerTool(
|
|
178
200
|
"doc_ingest",
|
|
179
201
|
{
|
|
180
|
-
description: "\xDAsala EN VEZ de leer directamente un PDF, DOCX, XLSX, CSV o HTML (leer un PDF cuesta ~2,000 tokens por p\xE1gina). La convierte localmente a markdown por secciones, la indexa y devuelve SOLO el \xEDndice de secciones (~200 tokens). Si el archivo no cambi\xF3, reutiliza la conversi\xF3n. Despu\xE9s pide lo que necesites con doc_read.",
|
|
202
|
+
description: "\xDAsala EN VEZ de leer directamente un PDF, DOCX, XLSX, CSV o HTML (leer un PDF cuesta ~2,000 tokens por p\xE1gina), o una p\xE1gina de documentaci\xF3n web por URL (se baja una vez y se reutiliza 7 d\xEDas). La convierte localmente a markdown por secciones, la indexa y devuelve SOLO el \xEDndice de secciones (~200 tokens). Si el archivo no cambi\xF3, reutiliza la conversi\xF3n. Despu\xE9s pide lo que necesites con doc_read.",
|
|
181
203
|
inputSchema: {
|
|
182
|
-
path: z.string().describe("Ruta del archivo (absoluta o relativa al proyecto)"),
|
|
183
|
-
force: z.boolean().optional().describe("Reconvertir aunque no haya cambiado")
|
|
204
|
+
path: z.string().describe("Ruta del archivo (absoluta o relativa al proyecto) o URL http(s) de una p\xE1gina de documentaci\xF3n"),
|
|
205
|
+
force: z.boolean().optional().describe("Reconvertir (o volver a bajar la URL) aunque no haya cambiado")
|
|
184
206
|
}
|
|
185
207
|
},
|
|
186
208
|
async ({ path: p, force }) => {
|
|
187
209
|
try {
|
|
188
|
-
const abs = path.isAbsolute(p) ? p : path.resolve(process.cwd(), p);
|
|
210
|
+
const abs = isUrl(p) || path.isAbsolute(p) ? p : path.resolve(process.cwd(), p);
|
|
189
211
|
const res = await ingestAndOutline(vault, abs, { force });
|
|
190
212
|
return text(res.text);
|
|
191
213
|
} catch (e) {
|
|
@@ -206,6 +228,51 @@ server.registerTool(
|
|
|
206
228
|
},
|
|
207
229
|
async ({ doc, sections, query, max_tokens }) => text(await readDoc(vault, doc, { sections, query, maxTokens: max_tokens }))
|
|
208
230
|
);
|
|
231
|
+
var resolvePath = (p) => path.isAbsolute(p) ? p : path.resolve(process.cwd(), p);
|
|
232
|
+
server.registerTool(
|
|
233
|
+
"code_outline",
|
|
234
|
+
{
|
|
235
|
+
description: "\xDAsala ANTES de leer un archivo de c\xF3digo completo: devuelve solo las firmas (funciones, clases, m\xE9todos, tipos) con su rango de l\xEDneas, sin cuerpos \u2014 una fracci\xF3n de los tokens del archivo. Con una carpeta, lista los s\xEDmbolos de primer nivel de cada archivo. Luego pide solo lo que necesites con code_symbol. JS/TS, Python, PHP, Go, Java, C#, Kotlin, Rust.",
|
|
236
|
+
inputSchema: {
|
|
237
|
+
path: z.string().describe("Archivo o carpeta (absoluta o relativa al proyecto)"),
|
|
238
|
+
max_tokens: z.number().int().min(200).max(2e4).optional().describe("Tope para carpetas (default 2500)")
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
async ({ path: p, max_tokens }) => {
|
|
242
|
+
const abs = resolvePath(p);
|
|
243
|
+
if (!fs.existsSync(abs)) return text(`No existe: ${abs}`);
|
|
244
|
+
return text(fs.statSync(abs).isDirectory() ? outlineDir(abs, max_tokens) : outlineFile(abs));
|
|
245
|
+
}
|
|
246
|
+
);
|
|
247
|
+
server.registerTool(
|
|
248
|
+
"code_symbol",
|
|
249
|
+
{
|
|
250
|
+
description: 'Devuelve SOLO el cuerpo de un s\xEDmbolo (funci\xF3n, clase o "Clase.metodo") con n\xFAmeros de l\xEDnea, en vez del archivo entero. Si no lo encuentra, sugiere nombres parecidos.',
|
|
251
|
+
inputSchema: {
|
|
252
|
+
path: z.string().describe("Archivo"),
|
|
253
|
+
name: z.string().describe("Nombre del s\xEDmbolo o Clase.metodo"),
|
|
254
|
+
max_tokens: z.number().int().min(200).max(2e4).optional()
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
async ({ path: p, name, max_tokens }) => {
|
|
258
|
+
const abs = resolvePath(p);
|
|
259
|
+
if (!fs.existsSync(abs)) return text(`No existe: ${abs}`);
|
|
260
|
+
return text(symbolSource(abs, name, max_tokens));
|
|
261
|
+
}
|
|
262
|
+
);
|
|
263
|
+
server.registerTool(
|
|
264
|
+
"run_output",
|
|
265
|
+
{
|
|
266
|
+
description: 'Lee la salida COMPLETA de una corrida plegada por Alexandria (ale run / hook) sin volver a ejecutarla: por rango de l\xEDneas o filtrada con regex, sin pasar de max_tokens. El id viene en la l\xEDnea "salida completa: ale run show <id>"; "last" = la \xFAltima.',
|
|
267
|
+
inputSchema: {
|
|
268
|
+
id: z.string().describe('Id de la corrida o "last"'),
|
|
269
|
+
grep: z.string().optional().describe("Regex: solo l\xEDneas que coinciden"),
|
|
270
|
+
lines: z.string().optional().describe('Rango "a-b"'),
|
|
271
|
+
max_tokens: z.number().int().min(100).max(2e4).optional()
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
async ({ id, grep, lines, max_tokens }) => text(showRun(id, { grep, lines, maxTokens: max_tokens }))
|
|
275
|
+
);
|
|
209
276
|
server.registerTool(
|
|
210
277
|
"plan_create",
|
|
211
278
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ureck/alexandria",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.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",
|
package/dist/chunk-POA77JSS.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/core/stats.ts
|
|
4
|
-
import fs from "fs";
|
|
5
|
-
import path from "path";
|
|
6
|
-
var charsToTokens = (chars) => Math.round(chars / 4);
|
|
7
|
-
function logInjection(vault, line) {
|
|
8
|
-
try {
|
|
9
|
-
fs.mkdirSync(vault.cache, { recursive: true });
|
|
10
|
-
fs.appendFileSync(
|
|
11
|
-
path.join(vault.cache, "stats.jsonl"),
|
|
12
|
-
JSON.stringify({ t: (/* @__PURE__ */ new Date()).toISOString(), ...line }) + "\n"
|
|
13
|
-
);
|
|
14
|
-
} catch {
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
function logDocUse(vault, line) {
|
|
18
|
-
try {
|
|
19
|
-
fs.mkdirSync(vault.cache, { recursive: true });
|
|
20
|
-
fs.appendFileSync(path.join(vault.cache, "stats.jsonl"), JSON.stringify({ t: (/* @__PURE__ */ new Date()).toISOString(), kind: "doc", ...line }) + "\n");
|
|
21
|
-
} catch {
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
var EST_LOW = 3;
|
|
25
|
-
var EST_HIGH = 8;
|
|
26
|
-
function readStats(vault) {
|
|
27
|
-
const file = path.join(vault.cache, "stats.jsonl");
|
|
28
|
-
const summary = {
|
|
29
|
-
injections: 0,
|
|
30
|
-
solutionCacheHits: 0,
|
|
31
|
-
injectedTokens: 0,
|
|
32
|
-
cacheHitTokens: 0,
|
|
33
|
-
estSavedLow: 0,
|
|
34
|
-
estSavedHigh: 0,
|
|
35
|
-
docIngests: 0,
|
|
36
|
-
docReads: 0,
|
|
37
|
-
docTokensOriginal: 0,
|
|
38
|
-
docTokensServed: 0
|
|
39
|
-
};
|
|
40
|
-
try {
|
|
41
|
-
for (const raw of fs.readFileSync(file, "utf8").split("\n")) {
|
|
42
|
-
if (!raw.trim()) continue;
|
|
43
|
-
try {
|
|
44
|
-
const line = JSON.parse(raw);
|
|
45
|
-
if (line.kind === "doc") {
|
|
46
|
-
const d = line;
|
|
47
|
-
if (d.op === "ingest") summary.docIngests++;
|
|
48
|
-
else summary.docReads++;
|
|
49
|
-
summary.docTokensOriginal += d.tokensOriginal ?? 0;
|
|
50
|
-
summary.docTokensServed += d.tokensServed ?? 0;
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
const n = line.count ?? 1;
|
|
54
|
-
summary.injections += n;
|
|
55
|
-
const tk = line.tokens ?? charsToTokens(line.injectedChars);
|
|
56
|
-
summary.injectedTokens += tk;
|
|
57
|
-
if (line.kind === "solution-cache") {
|
|
58
|
-
summary.solutionCacheHits += n;
|
|
59
|
-
summary.cacheHitTokens += tk;
|
|
60
|
-
}
|
|
61
|
-
} catch {
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
} catch {
|
|
65
|
-
}
|
|
66
|
-
summary.estSavedLow = summary.injectedTokens * EST_LOW;
|
|
67
|
-
summary.estSavedHigh = summary.injectedTokens * EST_HIGH;
|
|
68
|
-
return summary;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export {
|
|
72
|
-
charsToTokens,
|
|
73
|
-
logInjection,
|
|
74
|
-
logDocUse,
|
|
75
|
-
readStats
|
|
76
|
-
};
|