@ureck/alexandria 1.4.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.
@@ -1,24 +1,30 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ injectedInSession,
4
+ rememberInjected
5
+ } from "../chunk-ADA25MTF.js";
2
6
  import {
3
7
  emitContext,
4
8
  projectName,
5
9
  runHook,
6
10
  truncate
7
- } from "../chunk-U2U53TU2.js";
11
+ } from "../chunk-WVZQGLRI.js";
8
12
  import {
9
13
  hybridSearch
10
- } from "../chunk-FPKJVQ2X.js";
14
+ } from "../chunk-47S5I3D3.js";
15
+ import {
16
+ createNote,
17
+ touchNote
18
+ } from "../chunk-44QPE5IM.js";
19
+ import {
20
+ logInjection
21
+ } from "../chunk-X4V6SYYA.js";
11
22
  import {
12
23
  isHarnessInjected,
13
- logInjection,
14
24
  resolveVault,
15
25
  toggleEnabled,
16
26
  vaultExists
17
- } from "../chunk-MDGFK6UC.js";
18
- import {
19
- createNote,
20
- touchNote
21
- } from "../chunk-3CB7GRFJ.js";
27
+ } from "../chunk-YICWI3U3.js";
22
28
  import "../chunk-EDYBSJSS.js";
23
29
 
24
30
  // src/hooks/on-prompt.ts
@@ -39,6 +45,7 @@ runHook(5e3, async (input) => {
39
45
  const rawResults = await hybridSearch(vault, prompt, 5, { expand: true, refresh: false });
40
46
  const STALE_DAYS = 60;
41
47
  const results = rawResults.filter((r) => {
48
+ if (r.note.status === "superseded") return false;
42
49
  if (r.note.type !== "prompt" && r.note.type !== "session") return true;
43
50
  if ((r.note.hits ?? 1) > 1) return true;
44
51
  const age = r.note.created ? (Date.now() - Date.parse(r.note.created)) / 864e5 : 0;
@@ -67,14 +74,24 @@ runHook(5e3, async (input) => {
67
74
  ${truncate(cached.excerpts.join("\n"), 2e3)}`
68
75
  );
69
76
  }
77
+ const session = input.session_id;
78
+ const dedupe = Boolean(session) && toggleEnabled("context.dedupe");
79
+ const already = dedupe ? injectedInSession(vault.cache, session) : /* @__PURE__ */ new Set();
80
+ let skipped = 0;
70
81
  if (promptSearchOn) {
71
82
  for (const r of relevant) {
72
83
  if (r === cached) continue;
84
+ if (already.has(r.note.rel)) {
85
+ lines.push(`\u21BA ya en contexto: \xAB${r.note.title}\xBB`);
86
+ skipped += Math.min(900, r.excerpts.join("\n").length);
87
+ continue;
88
+ }
73
89
  lines.push(`\u2022 \xAB${r.note.title}\xBB (${r.note.rel}):
74
90
  ${truncate(r.excerpts.join("\n"), 900)}`);
75
91
  if (lines.join("\n\n").length > MAX_INJECT_CHARS) break;
76
92
  }
77
93
  }
94
+ if (lines.length > 0 && lines.every((l) => l.startsWith("\u21BA"))) lines.length = 0;
78
95
  if (lines.length > 0) {
79
96
  injected = `<alexandria-contexto>
80
97
  Contexto recuperado de la b\xF3veda local (usa esto antes de releer archivos o re-explorar):
@@ -82,11 +99,18 @@ Contexto recuperado de la b\xF3veda local (usa esto antes de releer archivos o r
82
99
  ` + truncate(lines.join("\n\n"), MAX_INJECT_CHARS) + `
83
100
  </alexandria-contexto>`;
84
101
  const written = emitContext("prompt", injected);
85
- if (written > 0) logInjection(vault, {
86
- kind: cached ? "solution-cache" : "inject",
87
- injectedChars: injected.length,
88
- promptChars: prompt.length
89
- });
102
+ if (written > 0) {
103
+ const rels = relevant.filter((r) => !already.has(r.note.rel)).map((r) => r.note.rel);
104
+ logInjection(vault, {
105
+ kind: cached ? "solution-cache" : "inject",
106
+ injectedChars: injected.length,
107
+ promptChars: prompt.length,
108
+ session,
109
+ rels,
110
+ dedupSkippedChars: skipped || void 0
111
+ });
112
+ if (dedupe) rememberInjected(vault.cache, session, rels);
113
+ }
90
114
  for (const r of relevant) {
91
115
  if (r.note.type === "lesson" || r.note.type === "solution") {
92
116
  try {
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ runHook
4
+ } from "../chunk-WVZQGLRI.js";
5
+ import {
6
+ PDF_TOKENS_PER_PAGE,
7
+ formatOf
8
+ } from "../chunk-I5H4BN3F.js";
9
+ import {
10
+ resolveVault,
11
+ toggleEnabled,
12
+ vaultExists
13
+ } from "../chunk-YICWI3U3.js";
14
+
15
+ // src/hooks/on-read.ts
16
+ import fs from "fs";
17
+ import path from "path";
18
+ var MIN_BYTES = 20 * 1024;
19
+ var INTERCEPT = /* @__PURE__ */ new Set(["pdf", "docx", "xlsx", "csv"]);
20
+ var MAX_SESSIONS = 20;
21
+ function shouldIntercept(cacheDir, sessionId, file) {
22
+ const store = path.join(cacheDir, "read-intercepts.json");
23
+ let data = {};
24
+ try {
25
+ data = JSON.parse(fs.readFileSync(store, "utf8"));
26
+ } catch {
27
+ }
28
+ const seen = data[sessionId] ?? [];
29
+ if (seen.includes(file)) return false;
30
+ data[sessionId] = [...seen, file];
31
+ const keys = Object.keys(data);
32
+ for (const k of keys.slice(0, Math.max(0, keys.length - MAX_SESSIONS))) delete data[k];
33
+ try {
34
+ fs.mkdirSync(cacheDir, { recursive: true });
35
+ fs.writeFileSync(store, JSON.stringify(data));
36
+ } catch {
37
+ return false;
38
+ }
39
+ return true;
40
+ }
41
+ runHook(2e3, async (input) => {
42
+ if (!toggleEnabled("docs.interceptRead")) return;
43
+ const file = input.filePath;
44
+ if (!file || input.toolName && input.toolName !== "Read") return;
45
+ const format = formatOf(file);
46
+ if (!format || !INTERCEPT.has(format)) return;
47
+ let size = 0;
48
+ try {
49
+ size = fs.statSync(file).size;
50
+ } catch {
51
+ return;
52
+ }
53
+ if (size < MIN_BYTES) return;
54
+ const vault = resolveVault({ cwd: input.cwd });
55
+ if (!vaultExists(vault)) return;
56
+ if (!shouldIntercept(vault.cache, input.session_id ?? "sin-sesion", path.resolve(file))) return;
57
+ const cost = format === "pdf" ? `un PDF le\xEDdo directo cuesta ~${PDF_TOKENS_PER_PAGE.toLocaleString("en")} tokens POR P\xC1GINA (imagen + texto)` : `leer el ${format.toUpperCase()} completo cuesta ~${Math.ceil(size / 4).toLocaleString("en")} tokens`;
58
+ process.stdout.write(
59
+ JSON.stringify({
60
+ hookSpecificOutput: {
61
+ hookEventName: "PreToolUse",
62
+ permissionDecision: "deny",
63
+ permissionDecisionReason: `Alexandria: ${cost}. Usa la tool MCP doc_ingest con path "${file}" (devuelve el \xEDndice de secciones, ~200 tokens) y luego doc_read con las secciones o una pregunta. Si de verdad necesitas ver im\xE1genes o gr\xE1ficas del archivo, vuelve a llamar Read: el segundo intento pasa.`
64
+ }
65
+ })
66
+ );
67
+ });
68
+ export {
69
+ shouldIntercept
70
+ };
@@ -1,20 +1,26 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ forgetInjected,
4
+ loadCapsule
5
+ } from "../chunk-ADA25MTF.js";
2
6
  import {
3
7
  emitContext,
4
8
  projectName,
5
9
  runHook,
6
10
  truncate
7
- } from "../chunk-U2U53TU2.js";
11
+ } from "../chunk-WVZQGLRI.js";
12
+ import {
13
+ VaultIndex
14
+ } from "../chunk-44QPE5IM.js";
15
+ import {
16
+ logInjection
17
+ } from "../chunk-X4V6SYYA.js";
8
18
  import {
9
- logInjection,
10
19
  protocolEnabled,
11
20
  resolveVault,
12
21
  toggleEnabled,
13
22
  vaultExists
14
- } from "../chunk-MDGFK6UC.js";
15
- import {
16
- VaultIndex
17
- } from "../chunk-3CB7GRFJ.js";
23
+ } from "../chunk-YICWI3U3.js";
18
24
  import "../chunk-EDYBSJSS.js";
19
25
 
20
26
  // src/hooks/on-session-start.ts
@@ -67,16 +73,21 @@ ${lines.join("\n")}`);
67
73
  `B\xF3veda joven (${distilled} notas destiladas): al descubrir decisiones, m\xF3dulos o vocabulario del dominio, gu\xE1rdalos compactos con vault_save \u2014 tokens gratis en sesiones futuras.`
68
74
  );
69
75
  }
70
- const titles = toggleEnabled("digest.titleIndex") ? notes.filter((n) => n.type !== "prompt").sort((a, b) => (b.hits ?? 1) - (a.hits ?? 1)).slice(0, 25).map((n) => n.title) : [];
76
+ const titles = toggleEnabled("digest.titleIndex") ? notes.filter((n) => n.type !== "prompt" && n.status !== "superseded").sort((a, b) => (b.hits ?? 1) - (a.hits ?? 1)).slice(0, 25).map((n) => n.title) : [];
71
77
  if (titles.length > 0) {
72
78
  parts.push(`## La b\xF3veda ya tiene conocimiento sobre
73
79
  ${titles.join(" \xB7 ")}`);
74
80
  }
75
81
  if (parts.length === 0) return;
76
- const digest = `<alexandria-digest>
82
+ let capsule = "";
83
+ if (input.session_id && (input.source === "compact" || input.source === "resume")) {
84
+ capsule = loadCapsule(vault.cache, input.session_id) ?? "";
85
+ if (input.source === "compact") forgetInjected(vault.cache, input.session_id);
86
+ }
87
+ const digest = (capsule ? capsule + "\n\n" : "") + `<alexandria-digest>
77
88
  B\xF3veda de conocimiento local activa (${notes.length} notas). ANTES de explorar c\xF3digo o re-derivar contexto, usa la herramienta MCP vault_search \u2014 ahorra tokens. Cuando descubras arquitectura o decisiones nuevas, gu\xE1rdalas con vault_save (title: "Mapa - ${proj}").
78
89
 
79
90
  ` + truncate(parts.join("\n\n"), MAX_CHARS) + `
80
91
  </alexandria-digest>`;
81
- if (emitContext("session", digest) > 0) logInjection(vault, { kind: "session-start", injectedChars: digest.length });
92
+ if (emitContext("session", digest) > 0) logInjection(vault, { kind: "session-start", injectedChars: digest.length, session: input.session_id });
82
93
  }, "session");
@@ -1,24 +1,31 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ buildCapsule,
4
+ extractSession,
5
+ forgetInjected,
6
+ saveCapsule
7
+ } from "../chunk-ADA25MTF.js";
2
8
  import {
3
9
  projectName,
4
10
  runHook,
5
11
  truncate
6
- } from "../chunk-U2U53TU2.js";
12
+ } from "../chunk-WVZQGLRI.js";
7
13
  import {
8
14
  autoCleanDue,
9
15
  markCleaned
10
- } from "../chunk-2ESJQAP4.js";
16
+ } from "../chunk-WSVNMMNN.js";
17
+ import {
18
+ VaultIndex,
19
+ appendToNote
20
+ } from "../chunk-44QPE5IM.js";
21
+ import "../chunk-X4V6SYYA.js";
11
22
  import {
12
23
  ensureVaultStructure,
13
24
  lastExchange,
14
25
  resolveVault,
15
26
  toggleEnabled,
16
27
  vaultExists
17
- } from "../chunk-MDGFK6UC.js";
18
- import {
19
- VaultIndex,
20
- appendToNote
21
- } from "../chunk-3CB7GRFJ.js";
28
+ } from "../chunk-YICWI3U3.js";
22
29
  import "../chunk-EDYBSJSS.js";
23
30
 
24
31
  // src/hooks/on-stop.ts
@@ -31,6 +38,18 @@ runHook(25e3, async (input) => {
31
38
  if (!vaultExists(vault)) return;
32
39
  let lastUser = input.prompt?.trim() ?? "";
33
40
  let lastAssistant = input.answer?.trim() ?? "";
41
+ if (input.compact && input.session_id) {
42
+ forgetInjected(vault.cache, input.session_id);
43
+ if (input.transcript_path && fs.existsSync(input.transcript_path)) {
44
+ try {
45
+ const all = fs.readFileSync(input.transcript_path, "utf8").split("\n").filter(Boolean);
46
+ const proj2 = projectName(input.cwd);
47
+ const openPlans = VaultIndex.load(vault).notesByTag("plan").filter((n) => n.status === "active" && n.tags.some((t) => t.toLowerCase() === proj2.toLowerCase())).map((n) => n.title);
48
+ saveCapsule(vault.cache, input.session_id, buildCapsule(extractSession(all), { cwd: input.cwd, openPlans }));
49
+ } catch {
50
+ }
51
+ }
52
+ }
34
53
  if (!lastAssistant && input.transcript_path && fs.existsSync(input.transcript_path)) {
35
54
  const lines = fs.readFileSync(input.transcript_path, "utf8").split("\n").filter(Boolean);
36
55
  const ex = lastExchange(lines.slice(-200));
@@ -1,28 +1,40 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  architectBlock,
4
+ ingestAndOutline,
5
+ isUrl,
6
+ outlineDir,
7
+ outlineFile,
4
8
  pkgVersion,
5
9
  planContext,
6
- planQualityHints
7
- } from "../chunk-JI2L66DF.js";
10
+ planQualityHints,
11
+ readDoc,
12
+ symbolSource
13
+ } from "../chunk-BXVNQVLX.js";
8
14
  import {
9
15
  hybridSearch
10
- } from "../chunk-FPKJVQ2X.js";
16
+ } from "../chunk-47S5I3D3.js";
11
17
  import {
12
18
  searchArchive
13
- } from "../chunk-2ESJQAP4.js";
14
- import {
15
- ensureVaultStructure,
16
- resolveVault,
17
- toggleEnabled
18
- } from "../chunk-MDGFK6UC.js";
19
+ } from "../chunk-WSVNMMNN.js";
19
20
  import {
20
21
  VaultIndex,
21
22
  createNote,
22
23
  setNoteStatus,
23
24
  slugify,
25
+ supersedeNote,
24
26
  upsertNote
25
- } from "../chunk-3CB7GRFJ.js";
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";
26
38
  import "../chunk-EDYBSJSS.js";
27
39
 
28
40
  // src/mcp/server.ts
@@ -85,7 +97,7 @@ server.registerTool(
85
97
  );
86
98
  }
87
99
  const out = results.map(
88
- (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]` : ""}
89
101
  ${r.excerpts.map((e) => " " + e.replace(/\n/g, "\n ").slice(0, 900)).join("\n")}`
90
102
  ).join("\n\n");
91
103
  return text(out);
@@ -94,14 +106,15 @@ ${r.excerpts.map((e) => " " + e.replace(/\n/g, "\n ").slice(0, 900)).join("\
94
106
  server.registerTool(
95
107
  "vault_save",
96
108
  {
97
- 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).',
98
110
  inputSchema: {
99
111
  title: z.string(),
100
112
  content: z.string().describe("Markdown; puede incluir [[wikilinks]] a otras notas"),
101
- 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)")
102
115
  }
103
116
  },
104
- async ({ title, content, tags }) => {
117
+ async ({ title, content, tags, supersedes }) => {
105
118
  ensureVaultStructure(vault);
106
119
  if (!title.startsWith("Mapa - ") && !/\[\[/.test(content)) {
107
120
  const map = findMap(VaultIndex.load(vault));
@@ -122,9 +135,22 @@ Proyecto: [[${map.title}]]`;
122
135
  } else {
123
136
  file = createNote(vault.managed, { title, content, tags: tags ?? [], type: "note" });
124
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
+ }
125
149
  await VaultIndex.load(vault).refresh().catch(() => {
126
150
  });
127
- return text(`Guardado en ${path.relative(vault.root, file)}`);
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
+ );
128
154
  }
129
155
  );
130
156
  server.registerTool(
@@ -170,6 +196,83 @@ server.registerTool(
170
196
  return text(`Conectado: \xAB${a.title}\xBB \u2192 [[${b.title}]]`);
171
197
  }
172
198
  );
199
+ server.registerTool(
200
+ "doc_ingest",
201
+ {
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.",
203
+ inputSchema: {
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")
206
+ }
207
+ },
208
+ async ({ path: p, force }) => {
209
+ try {
210
+ const abs = isUrl(p) || path.isAbsolute(p) ? p : path.resolve(process.cwd(), p);
211
+ const res = await ingestAndOutline(vault, abs, { force });
212
+ return text(res.text);
213
+ } catch (e) {
214
+ return text(`No pude ingerir \xAB${p}\xBB: ${e.message}`);
215
+ }
216
+ }
217
+ );
218
+ server.registerTool(
219
+ "doc_read",
220
+ {
221
+ description: "Lee un documento ya ingerido SIN cargarlo completo: por ids de secci\xF3n (del \xEDndice de doc_ingest) o por pregunta (devuelve las secciones m\xE1s relevantes). Nunca pasa de max_tokens y dice qu\xE9 secciones quedaron fuera para que pidas m\xE1s solo si hace falta.",
222
+ inputSchema: {
223
+ doc: z.string().describe("Ruta del archivo original, t\xEDtulo o parte del nombre"),
224
+ sections: z.array(z.string()).optional().describe('Ids de secci\xF3n, ej. ["s2","s5"]'),
225
+ query: z.string().optional().describe("Pregunta: devuelve las secciones que la responden"),
226
+ max_tokens: z.number().int().min(200).max(2e4).optional().describe("Presupuesto de tokens (default 1500)")
227
+ }
228
+ },
229
+ async ({ doc, sections, query, max_tokens }) => text(await readDoc(vault, doc, { sections, query, maxTokens: max_tokens }))
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
+ );
173
276
  server.registerTool(
174
277
  "plan_create",
175
278
  {
@@ -4,8 +4,8 @@ import {
4
4
  renderGraphHtml,
5
5
  serveGraph,
6
6
  writeStaticGraph
7
- } from "./chunk-4ZSTD3CU.js";
8
- import "./chunk-3CB7GRFJ.js";
7
+ } from "./chunk-SSTG2NOO.js";
8
+ import "./chunk-44QPE5IM.js";
9
9
  import "./chunk-EDYBSJSS.js";
10
10
  export {
11
11
  buildGraphData,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ureck/alexandria",
3
- "version": "1.4.0",
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",
@@ -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"