@ureck/alexandria 0.5.0 → 0.5.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 +3 -3
- package/dist/{chunk-BCLBZ7NX.js → chunk-3ETM6PKR.js} +1 -1
- package/dist/{chunk-MLA3KZPZ.js → chunk-7G3NPKDO.js} +4 -1
- package/dist/{chunk-KHTYRYDR.js → chunk-IQM5S5N4.js} +8 -8
- package/dist/{chunk-RLVCH6CZ.js → chunk-UTXUGXDB.js} +1 -1
- package/dist/cli.js +91 -16
- package/dist/hooks/on-prompt.js +2 -2
- package/dist/hooks/on-session-start.js +1 -1
- package/dist/mcp/server.js +3 -3
- package/dist/{viewer-57T7UOFE.js → viewer-G3N57646.js} +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ Verify:
|
|
|
61
61
|
|
|
62
62
|
```bash
|
|
63
63
|
$ ale --version
|
|
64
|
-
0.5.
|
|
64
|
+
0.5.1
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
## Getting started
|
|
@@ -251,7 +251,7 @@ AI agent session
|
|
|
251
251
|
|
|
252
252
|
| Command | What it does |
|
|
253
253
|
|---|---|
|
|
254
|
-
| `ale init [--project] [--path <dir>] [--agents <ids>] [--auto\|--manual] [--no-protocol]` | Installs everything: vault
|
|
254
|
+
| `ale init [--project] [--path <dir>] [--agents <ids>] [--auto\|--manual] [--no-protocol] [--portable]` | Installs everything: vault, hooks, MCP, .gitignore, project scan, CLAUDE.md. `--portable` writes an npx-based MCP command safe to commit for teams |
|
|
255
255
|
| `ale agents [ids] [--project]` | List agents / register the MCP server |
|
|
256
256
|
| `ale search <query> [-k n] [--expand]` | Hybrid search; `--expand` pulls graph neighbors |
|
|
257
257
|
| `ale add <title> [-c text] [--file <path>] [-t tags]` | Save a note (inline, from file, or stdin) |
|
|
@@ -274,7 +274,7 @@ AI agent session
|
|
|
274
274
|
- **Everything runs on your machine**: the embedding model is downloaded once (Hugging Face) and then works offline. Your notes never leave your disk. No telemetry.
|
|
275
275
|
- **No API keys, no accounts, no cost.**
|
|
276
276
|
- Dependency scanners (Socket, etc.) flag *network/shell/env access* in the dependency tree: those come from the ML runtime (`onnxruntime`/`transformers.js`, which needs filesystem access and the one-time model download) and the official MCP SDK — not from Alexandria's code. The published package runs no install scripts of its own.
|
|
277
|
-
- Generated configs (`.mcp.json`,
|
|
277
|
+
- Generated per-project configs (`.mcp.json`, `.vault.json`, etc.) point at your machine's install path, so `ale init --project` automatically gitignores them (and untracks any already committed) — they never leak to a shared repo. For a team that *wants* a shared MCP config, run `ale init --project --portable`, which writes an npx-based command that works on any machine.
|
|
278
278
|
|
|
279
279
|
## Support the project ☕
|
|
280
280
|
|
|
@@ -80,6 +80,9 @@ var VaultIndex = class _VaultIndex {
|
|
|
80
80
|
const rel = path.relative(this.vault.root, abs).split(path.sep).join("/");
|
|
81
81
|
onDisk.set(rel, { abs, mtime: fs.statSync(abs).mtimeMs });
|
|
82
82
|
}
|
|
83
|
+
if (withEmbeddings && this.emb === null && this.meta.chunks.length > 0) {
|
|
84
|
+
force = true;
|
|
85
|
+
}
|
|
83
86
|
const changed = [];
|
|
84
87
|
for (const [rel, info] of onDisk) {
|
|
85
88
|
if (force || this.meta.mtimes[rel] !== info.mtime) changed.push(rel);
|
|
@@ -168,7 +171,7 @@ ${c.text}`),
|
|
|
168
171
|
this.rebuildLinks();
|
|
169
172
|
this.save();
|
|
170
173
|
try {
|
|
171
|
-
const { writeStaticGraph } = await import("./viewer-
|
|
174
|
+
const { writeStaticGraph } = await import("./viewer-G3N57646.js");
|
|
172
175
|
writeStaticGraph(this);
|
|
173
176
|
} catch {
|
|
174
177
|
}
|
|
@@ -73,7 +73,10 @@ function hooksRegistered(settingsPath) {
|
|
|
73
73
|
return false;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function serverCommand(portable) {
|
|
77
|
+
return portable ? { command: "npx", args: ["-y", "@ureck/alexandria", "alexandria", "serve-mcp"] } : { command: "node", args: [path.join(distDir(), "mcp", "server.js")] };
|
|
78
|
+
}
|
|
79
|
+
function registerMcpProject(projectDir, portable = false) {
|
|
77
80
|
const file = path.join(projectDir, ".mcp.json");
|
|
78
81
|
let cfg = {};
|
|
79
82
|
try {
|
|
@@ -84,17 +87,14 @@ function registerMcpProject(projectDir) {
|
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
cfg.mcpServers ??= {};
|
|
87
|
-
cfg.mcpServers["alexandria"] =
|
|
88
|
-
command: "node",
|
|
89
|
-
args: [path.join(distDir(), "mcp", "server.js")]
|
|
90
|
-
};
|
|
90
|
+
cfg.mcpServers["alexandria"] = serverCommand(portable);
|
|
91
91
|
fs.writeFileSync(file, JSON.stringify(cfg, null, 2) + "\n");
|
|
92
92
|
return file;
|
|
93
93
|
}
|
|
94
|
-
function registerMcpGlobal() {
|
|
95
|
-
const
|
|
94
|
+
function registerMcpGlobal(portable = false) {
|
|
95
|
+
const { command, args } = serverCommand(portable);
|
|
96
96
|
try {
|
|
97
|
-
execFileSync("claude", ["mcp", "add", "--scope", "user", "alexandria", "--",
|
|
97
|
+
execFileSync("claude", ["mcp", "add", "--scope", "user", "alexandria", "--", command, ...args], {
|
|
98
98
|
stdio: "pipe",
|
|
99
99
|
timeout: 15e3
|
|
100
100
|
});
|
package/dist/cli.js
CHANGED
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
registerMcpGlobal,
|
|
14
14
|
registerMcpProject,
|
|
15
15
|
unregisterHooks
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-IQM5S5N4.js";
|
|
17
17
|
import {
|
|
18
18
|
hybridSearch
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-3ETM6PKR.js";
|
|
20
20
|
import {
|
|
21
21
|
defaultVaultPath,
|
|
22
22
|
ensureVaultStructure,
|
|
@@ -30,10 +30,10 @@ import {
|
|
|
30
30
|
} from "./chunk-DYCARGQR.js";
|
|
31
31
|
import {
|
|
32
32
|
serveGraph
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-UTXUGXDB.js";
|
|
34
34
|
import {
|
|
35
35
|
VaultIndex
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-7G3NPKDO.js";
|
|
37
37
|
import {
|
|
38
38
|
createNote,
|
|
39
39
|
slugify,
|
|
@@ -438,27 +438,57 @@ async function showBanner(animate) {
|
|
|
438
438
|
import fs3 from "fs";
|
|
439
439
|
import os3 from "os";
|
|
440
440
|
import path3 from "path";
|
|
441
|
+
import { execFileSync as execFileSync3 } from "child_process";
|
|
442
|
+
var PERSONAL_CONFIG_FILES = [
|
|
443
|
+
".vault.json",
|
|
444
|
+
".mcp.json",
|
|
445
|
+
".cursor/mcp.json",
|
|
446
|
+
"opencode.json",
|
|
447
|
+
".vscode/mcp.json",
|
|
448
|
+
".gemini/settings.json"
|
|
449
|
+
];
|
|
441
450
|
function ensureGitignore(projectDir, vaultRoot) {
|
|
442
451
|
if (!fs3.existsSync(path3.join(projectDir, ".git"))) return null;
|
|
452
|
+
const entries = [];
|
|
443
453
|
const rel = path3.relative(projectDir, vaultRoot);
|
|
444
|
-
if (rel.startsWith(".."))
|
|
454
|
+
if (!rel.startsWith("..")) entries.push(`${rel.split(path3.sep).join("/")}/`);
|
|
455
|
+
entries.push(...PERSONAL_CONFIG_FILES);
|
|
445
456
|
const file = path3.join(projectDir, ".gitignore");
|
|
446
|
-
const entries = [`${rel.split(path3.sep).join("/")}/`];
|
|
447
457
|
let text = "";
|
|
448
458
|
try {
|
|
449
459
|
text = fs3.readFileSync(file, "utf8");
|
|
450
460
|
} catch {
|
|
451
461
|
}
|
|
452
|
-
const
|
|
462
|
+
const has = (e) => text.split("\n").some((l) => l.trim() === e || l.trim() === e.replace(/\/$/, ""));
|
|
463
|
+
const missing = entries.filter((e) => !has(e));
|
|
453
464
|
if (missing.length === 0) return null;
|
|
454
465
|
const block = `${text.trimEnd()}
|
|
455
466
|
|
|
456
|
-
# Alexandria (conocimiento personal
|
|
467
|
+
# Alexandria (conocimiento y config personal \u2014 no del repo)
|
|
457
468
|
${missing.join("\n")}
|
|
458
469
|
`;
|
|
459
470
|
fs3.writeFileSync(file, text.trim() ? block : block.trimStart());
|
|
460
471
|
return file;
|
|
461
472
|
}
|
|
473
|
+
function untrackPersonalConfigs(projectDir) {
|
|
474
|
+
if (!fs3.existsSync(path3.join(projectDir, ".git"))) return [];
|
|
475
|
+
const untracked = [];
|
|
476
|
+
for (const f of PERSONAL_CONFIG_FILES) {
|
|
477
|
+
if (!fs3.existsSync(path3.join(projectDir, f))) continue;
|
|
478
|
+
try {
|
|
479
|
+
const tracked = execFileSync3("git", ["ls-files", "--error-unmatch", f], {
|
|
480
|
+
cwd: projectDir,
|
|
481
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
482
|
+
});
|
|
483
|
+
if (tracked.toString().trim()) {
|
|
484
|
+
execFileSync3("git", ["rm", "--cached", "--quiet", f], { cwd: projectDir, stdio: "ignore" });
|
|
485
|
+
untracked.push(f);
|
|
486
|
+
}
|
|
487
|
+
} catch {
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
return untracked;
|
|
491
|
+
}
|
|
462
492
|
var CLAUDE_MD_START = "<!-- alexandria:start -->";
|
|
463
493
|
var CLAUDE_MD_END = "<!-- alexandria:end -->";
|
|
464
494
|
function configureClaudeMd(scope, projectDir) {
|
|
@@ -487,6 +517,24 @@ function configureClaudeMd(scope, projectDir) {
|
|
|
487
517
|
fs3.writeFileSync(file, text);
|
|
488
518
|
return file;
|
|
489
519
|
}
|
|
520
|
+
function removeClaudeMd(scope, projectDir) {
|
|
521
|
+
const file = scope === "project" ? path3.join(projectDir, "CLAUDE.md") : path3.join(os3.homedir(), ".claude", "CLAUDE.md");
|
|
522
|
+
let text;
|
|
523
|
+
try {
|
|
524
|
+
text = fs3.readFileSync(file, "utf8");
|
|
525
|
+
} catch {
|
|
526
|
+
return null;
|
|
527
|
+
}
|
|
528
|
+
if (!text.includes(CLAUDE_MD_START)) return null;
|
|
529
|
+
const re = new RegExp(`\\n*${CLAUDE_MD_START}[\\s\\S]*?${CLAUDE_MD_END}\\n*`);
|
|
530
|
+
const cleaned = text.replace(re, "\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
531
|
+
if (cleaned === "") {
|
|
532
|
+
fs3.rmSync(file, { force: true });
|
|
533
|
+
} else {
|
|
534
|
+
fs3.writeFileSync(file, cleaned + "\n");
|
|
535
|
+
}
|
|
536
|
+
return file;
|
|
537
|
+
}
|
|
490
538
|
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", ".next", "dist", "build", ".vault", ".claude", "coverage", "Alexandria", "KnowledgeVault"]);
|
|
491
539
|
function scanProject(vault, projectDir) {
|
|
492
540
|
const name = path3.basename(projectDir);
|
|
@@ -544,15 +592,15 @@ ${readme.split("\n").slice(0, 15).join("\n")}`);
|
|
|
544
592
|
}
|
|
545
593
|
|
|
546
594
|
// src/cli.ts
|
|
547
|
-
function registerAgentsMcp(agents, scope, cwd) {
|
|
595
|
+
function registerAgentsMcp(agents, scope, cwd, portable = false) {
|
|
548
596
|
for (const agent of agents) {
|
|
549
597
|
if (agent.id === "claude") {
|
|
550
598
|
if (scope === "project") {
|
|
551
|
-
const file = registerMcpProject(cwd);
|
|
599
|
+
const file = registerMcpProject(cwd, portable);
|
|
552
600
|
console.log(pc.green(`\u2713 MCP \u2192 Claude Code (${file})`));
|
|
553
601
|
continue;
|
|
554
602
|
}
|
|
555
|
-
if (registerMcpGlobal()) {
|
|
603
|
+
if (registerMcpGlobal(portable)) {
|
|
556
604
|
console.log(pc.green("\u2713 MCP \u2192 Claude Code (scope user, v\xEDa claude mcp add)"));
|
|
557
605
|
continue;
|
|
558
606
|
}
|
|
@@ -599,7 +647,7 @@ async function ensureReady(vault = getVault()) {
|
|
|
599
647
|
program.command("init").description("Crea/conecta la b\xF3veda e instala TODO: modelo, hooks (Claude Code) y MCP en tus agentes de IA (una sola vez, persiste entre sesiones)").option("--project", "registrar para este proyecto (cwd): .vault.json + .claude/settings.json + .mcp.json").option("--global", "registrar para todas las sesiones del usuario (default)").option(
|
|
600
648
|
"--path <dir>",
|
|
601
649
|
"ruta del vault Obsidian (existente o nuevo). Default: ./Alexandria con --project, ~/Alexandria en global"
|
|
602
|
-
).option("--auto", "configurar el uso autom\xE1tico en CLAUDE.md sin preguntar").option("--manual", "no tocar CLAUDE.md (config\xFAralo t\xFA)").option("--no-protocol", "instalar sin el Protocolo Alexandria (solo b\xF3veda cl\xE1sica)").option("--skills", "al final, recomendar e instalar skills seg\xFAn el contenido").option(
|
|
650
|
+
).option("--auto", "configurar el uso autom\xE1tico en CLAUDE.md sin preguntar").option("--manual", "no tocar CLAUDE.md (config\xFAralo t\xFA)").option("--no-protocol", "instalar sin el Protocolo Alexandria (solo b\xF3veda cl\xE1sica)").option("--portable", "MCP con comando npx (commiteable en repos de equipo) en vez de ruta local").option("--skills", "al final, recomendar e instalar skills seg\xFAn el contenido").option(
|
|
603
651
|
"--agents <ids>",
|
|
604
652
|
`agentes de IA donde registrar el MCP: "all", "detected" o csv de ${AGENTS.map((a) => a.id).join(",")} (default: claude + detectados)`
|
|
605
653
|
).action(async (opts) => {
|
|
@@ -625,13 +673,20 @@ program.command("init").description("Crea/conecta la b\xF3veda e instala TODO: m
|
|
|
625
673
|
console.log(pc.dim(" SessionStart (digest) \xB7 UserPromptSubmit (contexto+captura) \xB7 Stop/PreCompact (sesiones)"));
|
|
626
674
|
const scope = isProject ? "project" : "global";
|
|
627
675
|
const chosen = opts.agents ? resolveAgents(opts.agents) : [...AGENTS.filter((a) => a.id === "claude" || a.detect())];
|
|
628
|
-
registerAgentsMcp(chosen, scope, cwd);
|
|
676
|
+
registerAgentsMcp(chosen, scope, cwd, opts.portable);
|
|
677
|
+
if (opts.portable) console.log(pc.dim(" MCP portable (npx) \u2014 apto para commitear en repos de equipo"));
|
|
629
678
|
const skipped = AGENTS.filter((a) => !chosen.includes(a));
|
|
630
679
|
if (skipped.length > 0) {
|
|
631
680
|
console.log(pc.dim(` Otros agentes disponibles: ${skipped.map((a) => a.id).join(", ")} \u2192 ale agents <ids>`));
|
|
632
681
|
}
|
|
633
682
|
if (isProject) {
|
|
634
683
|
const gi = ensureGitignore(cwd, vault.root);
|
|
684
|
+
if (!opts.portable) {
|
|
685
|
+
const untracked = untrackPersonalConfigs(cwd);
|
|
686
|
+
if (untracked.length > 0) {
|
|
687
|
+
console.log(pc.green(`\u2713 Configs personales sacados del \xEDndice de git: ${untracked.join(", ")}`));
|
|
688
|
+
}
|
|
689
|
+
}
|
|
635
690
|
if (gi) console.log(pc.green(`\u2713 B\xF3veda agregada a ${gi}`));
|
|
636
691
|
}
|
|
637
692
|
let auto = opts.auto ? true : opts.manual ? false : void 0;
|
|
@@ -947,11 +1002,31 @@ program.command("doctor").description("Verifica y repara la instalaci\xF3n (mode
|
|
|
947
1002
|
console.log(`${pc.green("\u2713")} \xCDndice al d\xEDa (${res.changed} reindexadas, ${Object.keys(idx.meta.notes).length} notas)
|
|
948
1003
|
`);
|
|
949
1004
|
});
|
|
950
|
-
program.command("uninstall").description("
|
|
951
|
-
const
|
|
1005
|
+
program.command("uninstall").description("Reversi\xF3n limpia: quita hooks, bloque de CLAUDE.md y MCP del proyecto (no borra la b\xF3veda ni las notas)").option("--project", "quitar del proyecto (cwd)").action((opts) => {
|
|
1006
|
+
const cwd = process.cwd();
|
|
1007
|
+
const scope = opts.project ? "project" : "global";
|
|
1008
|
+
const settings = opts.project ? projectSettingsPath(cwd) : globalSettingsPath();
|
|
952
1009
|
unregisterHooks(settings);
|
|
953
1010
|
console.log(pc.green(`\u2713 Hooks de alexandria eliminados de ${settings}`));
|
|
954
|
-
|
|
1011
|
+
const claudeMd = removeClaudeMd(scope, cwd);
|
|
1012
|
+
if (claudeMd) console.log(pc.green(`\u2713 Bloque de Alexandria removido de ${claudeMd}`));
|
|
1013
|
+
if (opts.project) {
|
|
1014
|
+
const mcpFile = path4.join(cwd, ".mcp.json");
|
|
1015
|
+
try {
|
|
1016
|
+
const cfg = JSON.parse(fs4.readFileSync(mcpFile, "utf8"));
|
|
1017
|
+
if (cfg.mcpServers?.alexandria) {
|
|
1018
|
+
delete cfg.mcpServers.alexandria;
|
|
1019
|
+
if (Object.keys(cfg.mcpServers).length === 0) delete cfg.mcpServers;
|
|
1020
|
+
if (Object.keys(cfg).length === 0) fs4.rmSync(mcpFile, { force: true });
|
|
1021
|
+
else fs4.writeFileSync(mcpFile, JSON.stringify(cfg, null, 2) + "\n");
|
|
1022
|
+
console.log(pc.green("\u2713 MCP removido de .mcp.json"));
|
|
1023
|
+
}
|
|
1024
|
+
} catch {
|
|
1025
|
+
}
|
|
1026
|
+
console.log(pc.dim(' Otros agentes (Cursor/OpenCode/\u2026): quita "alexandria" de su config si lo registraste.'));
|
|
1027
|
+
} else {
|
|
1028
|
+
console.log(pc.dim(" MCP global: qu\xEDtalo con `claude mcp remove alexandria`. Tus notas quedan intactas."));
|
|
1029
|
+
}
|
|
955
1030
|
});
|
|
956
1031
|
program.command("serve-mcp").description("Correr el servidor MCP por stdio (lo usa Claude Code internamente)").action(async () => {
|
|
957
1032
|
await import("./mcp/server.js");
|
package/dist/hooks/on-prompt.js
CHANGED
|
@@ -9,12 +9,12 @@ import {
|
|
|
9
9
|
} from "../chunk-DEDAOKAV.js";
|
|
10
10
|
import {
|
|
11
11
|
hybridSearch
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-3ETM6PKR.js";
|
|
13
13
|
import {
|
|
14
14
|
resolveVault,
|
|
15
15
|
vaultExists
|
|
16
16
|
} from "../chunk-DYCARGQR.js";
|
|
17
|
-
import "../chunk-
|
|
17
|
+
import "../chunk-7G3NPKDO.js";
|
|
18
18
|
import {
|
|
19
19
|
createNote,
|
|
20
20
|
touchNote
|
package/dist/mcp/server.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
pkgVersion
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-IQM5S5N4.js";
|
|
5
5
|
import {
|
|
6
6
|
hybridSearch
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-3ETM6PKR.js";
|
|
8
8
|
import {
|
|
9
9
|
ensureVaultStructure,
|
|
10
10
|
resolveVault
|
|
11
11
|
} from "../chunk-DYCARGQR.js";
|
|
12
12
|
import {
|
|
13
13
|
VaultIndex
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-7G3NPKDO.js";
|
|
15
15
|
import {
|
|
16
16
|
createNote,
|
|
17
17
|
setNoteStatus,
|
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
renderGraphHtml,
|
|
5
5
|
serveGraph,
|
|
6
6
|
writeStaticGraph
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-UTXUGXDB.js";
|
|
8
|
+
import "./chunk-7G3NPKDO.js";
|
|
9
9
|
import "./chunk-XWR74BQ2.js";
|
|
10
10
|
import "./chunk-EDYBSJSS.js";
|
|
11
11
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ureck/alexandria",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.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",
|