@ureck/alexandria 1.2.0 → 1.3.1

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 CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  Alexandria automatically captures your AI prompts and sessions, searches that knowledge **before** spending tokens, and connects everything in an Obsidian-style graph. **100% local**: no database, no API keys, no telemetry, no cost.
12
12
 
13
- Works with the most popular agents via MCP: **Claude Code · Cursor · OpenCode · Windsurf · Cline · Codex CLI · Gemini CLI · VS Code (Copilot) · OpenClaw · Hermes Agent**.
13
+ Works with the most popular agents via MCP: **Claude Code · Cursor · OpenCode · Devin CLI · Cline · Codex CLI · Gemini CLI · VS Code (Copilot) · OpenClaw · Hermes Agent · Windsurf (legacy)**.
14
14
 
15
15
  ## Why?
16
16
 
@@ -34,7 +34,7 @@ It lives in the MCP tools themselves — their names and descriptions carry the
34
34
  | MCP tool | What the agent does with it | Token payoff |
35
35
  |---|---|---|
36
36
  | `plan_create(title, goal, dod, tasks, design?)` | Plans like an **architect**: clarifies vague goals first, optionally records the architecture (`design` → a `## Design` section), and the response surfaces **similar past plans + relevant lessons** plus quality hints (verifiable DoD, small tasks) — suggestions, never a gate | No wandering; open plans are re-injected next session so work is resumed, not repeated |
37
- | `task_verify(plan, task, passed, verify_command)` | **Runs** `verify_command` (e.g. `npm test`) and takes the verdict from the real exit code — not from the agent's word. Flags a **discrepancy** if the agent claimed otherwise; without a command the note is tagged `self-reported` and `ale audit` calls it out | "✅ 12/12 passed" (5 tokens) instead of a 500-line log; on failure it automatically surfaces **past lessons** that match |
37
+ | `task_verify(plan, task, passed, verify_command, cwd?)` | **Runs** `verify_command` (e.g. `npm test`) and takes the verdict from the real exit code — not from the agent's word. Flags a **discrepancy** if the agent claimed otherwise; without a command the note is tagged `self-reported` and `ale audit` calls it out | "✅ 12/12 passed" (5 tokens) instead of a 500-line log; on failure it automatically surfaces **past lessons** that match |
38
38
  | `lesson_extract(title, lesson, links)` | Distills the root cause + fix after solving something non-obvious | ~200 tokens today replace ~20,000 tokens of re-debugging next month |
39
39
 
40
40
  Lessons and solutions get a ranking boost in search, so the most valuable knowledge always surfaces first. The protocol is **on by default**; toggle it anytime:
@@ -63,7 +63,7 @@ Verify:
63
63
 
64
64
  ```bash
65
65
  $ ale --version
66
- 1.2.0
66
+ 1.3.1
67
67
  ```
68
68
 
69
69
  ## Getting started
@@ -142,7 +142,7 @@ ale init --off architect.enrich,digest.map # disable from the start
142
142
  ale config set tokens.solutionCache false # scriptable, one by one
143
143
  ```
144
144
 
145
- The six toggles: Protocol manifest (~6% of the session digest), Architect enrichment in `plan_create` (~+90 tokens/plan), solution cache (up to ~500 tokens/prompt), per-prompt semantic search (the **main saving mechanism** — up to ~1500 tokens/prompt, disabling it defeats the point), project map in the digest (up to ~1000 tokens), title index (~200 tokens). All on by default; nothing changes unless you touch them.
145
+ The toggles: Protocol manifest (~6% of the session digest), Architect enrichment in `plan_create` (~+90 tokens/plan), solution cache (up to ~500 tokens/prompt), per-prompt semantic search (the **main saving mechanism** — up to ~1500 tokens/prompt, disabling it defeats the point), project map in the digest (up to ~1000 tokens), title index (~200 tokens), and background index rebuild at session close (costs no tokens). All on by default; nothing changes unless you touch them.
146
146
 
147
147
  ### Deep project context (`ale scan`)
148
148
 
@@ -252,7 +252,8 @@ ale agents cursor,gemini # just these
252
252
  | Claude Code | `.mcp.json` / `claude mcp add` + hooks | ✓ |
253
253
  | Cursor | `~/.cursor/mcp.json` / `.cursor/mcp.json` | ✓ |
254
254
  | OpenCode | `opencode.json` | ✓ |
255
- | Windsurf | `~/.codeium/windsurf/mcp_config.json` | — |
255
+ | Devin CLI (Cognition) | `.devin/mcp_config.local.json` | ✓ |
256
+ | Windsurf (legacy) | `~/.codeium/windsurf/mcp_config.json` | — |
256
257
  | Cline | `cline_mcp_settings.json` (VS Code) | — |
257
258
  | Codex CLI | `~/.codex/config.toml` | — |
258
259
  | Gemini CLI | `~/.gemini/settings.json` / `.gemini/settings.json` | ✓ |
package/dist/cli.js CHANGED
@@ -455,13 +455,34 @@ var AGENTS = [
455
455
  },
456
456
  {
457
457
  id: "windsurf",
458
- name: "Windsurf",
458
+ name: "Windsurf (legacy \u2192 Devin)",
459
459
  supportsProject: false,
460
460
  detect: () => fs3.existsSync(home(".codeium", "windsurf")),
461
461
  register() {
462
462
  return mergeMcpServers(home(".codeium", "windsurf", "mcp_config.json"));
463
463
  }
464
464
  },
465
+ {
466
+ id: "devin",
467
+ name: "Devin CLI (Cognition)",
468
+ supportsProject: true,
469
+ // El CLI vive en ~/.local/bin/devin y guarda config MCP por proyecto en .devin/
470
+ detect: () => fs3.existsSync(home(".devin")) || fs3.existsSync(home(".local", "bin", "devin")),
471
+ register(scope, projectDir) {
472
+ const dir = scope === "project" ? projectDir : home();
473
+ const file = path3.join(dir, ".devin", "mcp_config.local.json");
474
+ try {
475
+ const cfg = readJsonSafe(file);
476
+ const servers = cfg["mcpServers"] ?? {};
477
+ servers["alexandria"] = { ...serverCmd(), transport: "stdio" };
478
+ cfg["mcpServers"] = servers;
479
+ writeJson(file, cfg);
480
+ return { ok: true, file };
481
+ } catch (e) {
482
+ return { ok: false, file, detail: e.message };
483
+ }
484
+ }
485
+ },
465
486
  {
466
487
  id: "cline",
467
488
  name: "Cline (VS Code)",
@@ -684,7 +705,8 @@ var PERSONAL_CONFIG_FILES = [
684
705
  ".cursor/mcp.json",
685
706
  "opencode.json",
686
707
  ".vscode/mcp.json",
687
- ".gemini/settings.json"
708
+ ".gemini/settings.json",
709
+ ".devin/mcp_config.local.json"
688
710
  ];
689
711
  function ensureGitignore(projectDir, vaultRoot) {
690
712
  if (!fs4.existsSync(path4.join(projectDir, ".git"))) return null;
@@ -29,6 +29,26 @@ import { execSync } from "child_process";
29
29
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
30
30
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
31
31
  import { z } from "zod";
32
+
33
+ // src/core/hints.ts
34
+ var NOT_FOUND = /no such file|not found|cannot find|ENOENT|does not exist/i;
35
+ var RELATIVE_PATH = /(?:^|\s)(?!-)(?!\/)[\w.-]*\.\w+|(?:^|\s)\.{1,2}\//;
36
+ function pathHint(cmd, cwdArg, runDir, evidence) {
37
+ if (!cmd) return "";
38
+ if (!NOT_FOUND.test(evidence)) return "";
39
+ if (!RELATIVE_PATH.test(cmd)) return "";
40
+ const asked = cwdArg?.trim();
41
+ const suggested = asked || "<carpeta-del-proyecto>";
42
+ const clientDropped = Boolean(asked) && asked !== runDir;
43
+ return `
44
+
45
+ \u{1F4A1} El comando se ejecut\xF3 en: ${runDir}` + (clientDropped ? ` \u2014 tu \`cwd\` NO lleg\xF3 (algunos clientes MCP descartan par\xE1metros nuevos hasta reiniciar la sesi\xF3n).` : ` \u2014 probablemente NO es la carpeta de tu proyecto.`) + `
46
+ Ruta relativa + directorio equivocado = "no such file". Dos salidas:
47
+ 1) comando autocontenido (funciona en CUALQUIER cliente): \`cd ${suggested} && ${cmd}\`
48
+ 2) rutas absolutas en el comando.`;
49
+ }
50
+
51
+ // src/mcp/server.ts
32
52
  var vault = resolveVault({ cwd: process.cwd() });
33
53
  var server = new McpServer({ name: "alexandria", version: pkgVersion() });
34
54
  var text = (t) => ({ content: [{ type: "text", text: t }] });
@@ -186,10 +206,11 @@ server.tool(
186
206
  task: z.string().describe("Qu\xE9 tarea se verific\xF3"),
187
207
  passed: z.boolean().describe("Lo que T\xDA crees que pas\xF3 (se compara contra el resultado real del comando)"),
188
208
  verify_command: z.string().optional().describe('Comando a EJECUTAR para verificar de verdad; exit 0 = pas\xF3. Ej. "npm test", "npm run build". Preferido sobre evidence.'),
209
+ cwd: z.string().optional().describe("Directorio donde correr verify_command. Por defecto se usa el del agente (a menudo la RA\xCDZ del workspace, no tu subproyecto): si tu comando usa rutas relativas, pasa aqu\xED la carpeta del proyecto."),
189
210
  evidence: z.string().optional().describe("Solo si NO hay comando: evidencia textual (queda marcada como auto-reportada, sin verificar)."),
190
211
  completes_plan: z.boolean().optional().describe("true si esta era la \xFAltima tarea y el plan queda completado")
191
212
  },
192
- async ({ plan, task, passed, verify_command, evidence, completes_plan }) => {
213
+ async ({ plan, task, passed, verify_command, cwd, evidence, completes_plan }) => {
193
214
  ensureVaultStructure(vault);
194
215
  const idx = VaultIndex.load(vault);
195
216
  const planNote = findByTitle(idx, plan);
@@ -197,11 +218,12 @@ server.tool(
197
218
  let realEvidence;
198
219
  let verified = false;
199
220
  let discrepancy = "";
221
+ const runDir = cwd?.trim() && fs.existsSync(cwd.trim()) ? cwd.trim() : process.cwd();
200
222
  if (verify_command && verify_command.trim()) {
201
223
  verified = true;
202
224
  try {
203
225
  const out = execSync(verify_command, {
204
- cwd: process.cwd(),
226
+ cwd: runDir,
205
227
  timeout: 18e4,
206
228
  encoding: "utf8",
207
229
  stdio: ["ignore", "pipe", "pipe"],
@@ -209,14 +231,14 @@ server.tool(
209
231
  });
210
232
  realPassed = true;
211
233
  realEvidence = `$ ${verify_command}
212
- (exit 0)
234
+ (cwd: ${runDir}, exit 0)
213
235
  ${tail(out, 1500)}`;
214
236
  } catch (e) {
215
237
  const err = e;
216
238
  realPassed = false;
217
239
  const output = ((err.stdout ?? "") + "\n" + (err.stderr ?? "")).trim() || err.message;
218
240
  realEvidence = `$ ${verify_command}
219
- (exit ${err.status ?? "\u22600"})
241
+ (cwd: ${runDir}, exit ${err.status ?? "\u22600"})
220
242
  ${tail(output, 1500)}`;
221
243
  }
222
244
  if (passed !== realPassed) {
@@ -256,7 +278,7 @@ ${planNote ? `Plan: [[${planNote.title}]]` : ""}`
256
278
  if (!realPassed) {
257
279
  const lessons = await hybridSearch(vault, `${task} ${realEvidence.slice(0, 200)}`, 3);
258
280
  const useful = lessons.filter((l) => l.note.type === "lesson" || l.note.type === "solution");
259
- const head = `Fallo ${verified ? "CONFIRMADO por el comando" : "registrado (auto-reportado)"} (${path.relative(vault.root, file)}).${discrepancy}`;
281
+ const head = `Fallo ${verified ? "CONFIRMADO por el comando" : "registrado (auto-reportado)"} (${path.relative(vault.root, file)}).${discrepancy}` + pathHint(verify_command, cwd, runDir, realEvidence);
260
282
  if (useful.length > 0) {
261
283
  return text(
262
284
  `${head}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ureck/alexandria",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "Alexandria — bóveda de conocimiento local para agentes de IA (Claude Code, Cursor, OpenCode, Windsurf y más): captura automática, búsqueda semántica offline y grafo de conexiones estilo Obsidian. Ahorra tokens inyectando solo el contexto relevante.",
5
5
  "type": "module",
6
6
  "license": "MIT",