@ureck/alexandria 0.3.0 → 0.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 +173 -172
- package/dist/{chunk-FID2RAOH.js → chunk-BCLBZ7NX.js} +17 -4
- package/dist/chunk-DYCARGQR.js +117 -0
- package/dist/{chunk-VN7QOAG2.js → chunk-MLA3KZPZ.js} +6 -4
- package/dist/{chunk-I2ZBQUZD.js → chunk-RLVCH6CZ.js} +33 -13
- package/dist/chunk-XWR74BQ2.js +170 -0
- package/dist/cli.js +270 -18
- package/dist/hooks/on-prompt.js +17 -8
- package/dist/hooks/on-session-start.js +14 -4
- package/dist/hooks/on-stop.js +4 -2
- package/dist/mcp/server.js +144 -5
- package/dist/{viewer-LD4RTZE7.js → viewer-57T7UOFE.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-CF2GLMR3.js +0 -241
package/README.md
CHANGED
|
@@ -1,26 +1,49 @@
|
|
|
1
1
|
# 🏛️ Alexandria
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> A local knowledge vault for your AI agents — saves tokens, remembers across sessions, and turns every model into a disciplined engineer.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@ureck/alexandria)
|
|
6
6
|
[](./LICENSE)
|
|
7
|
-
[](https://buymeacoffee.com/ureck)
|
|
8
8
|
|
|
9
|
-
Alexandria
|
|
9
|
+
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.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Works with the most popular agents via MCP: **Claude Code · Cursor · OpenCode · Windsurf · Cline · Codex CLI · Gemini CLI · VS Code (Copilot) · OpenClaw · Hermes Agent**.
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Why?
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Every new AI session starts from zero: it re-explores your code, re-derives decisions you already made, re-spends the same tokens. Alexandria breaks that cycle:
|
|
16
16
|
|
|
17
|
-
- **
|
|
18
|
-
- **
|
|
19
|
-
- **
|
|
20
|
-
- **
|
|
21
|
-
- **
|
|
17
|
+
- **Saves tokens**: every prompt triggers a local semantic search (<100ms) that injects only the relevant fragments — instead of re-reading whole files.
|
|
18
|
+
- **Zero re-analysis between sessions**: on session start, the agent receives the project map and all accumulated knowledge.
|
|
19
|
+
- **Solution memory**: if a nearly identical prompt was already solved, the previous solution is injected — the agent doesn't re-derive it.
|
|
20
|
+
- **Infinite context, nothing is ever lost**: old noise gets archived, never deleted — everything stays searchable forever.
|
|
21
|
+
- **It's a valid Obsidian vault**: plain markdown with `[[wikilinks]]`. Open it in Obsidian anytime.
|
|
22
|
+
- **Cross-platform**: Windows, macOS, Linux · Node, Bun or Deno. Pure JS — no native dependencies to break your install.
|
|
22
23
|
|
|
23
|
-
##
|
|
24
|
+
## The Alexandria Protocol
|
|
25
|
+
|
|
26
|
+
Beyond memory, Alexandria ships a lightweight engineering protocol that turns **any** MCP-capable model into a senior agent that plans, verifies with evidence, and learns:
|
|
27
|
+
|
|
28
|
+
> **Plan → Execute one task → Verify with evidence → (on failure: reuse past lessons) → Extract the lesson**
|
|
29
|
+
|
|
30
|
+
It lives in the MCP tools themselves — their names and descriptions carry the instructions — so it works identically across every agent, with or without hooks:
|
|
31
|
+
|
|
32
|
+
| MCP tool | What the agent does with it | Token payoff |
|
|
33
|
+
|---|---|---|
|
|
34
|
+
| `plan_create(title, goal, dod, tasks)` | Writes a plan note with a **Definition of Done** and numbered tasks before touching code | No wandering; open plans are re-injected next session so work is resumed, not repeated |
|
|
35
|
+
| `task_verify(plan, task, passed, evidence)` | Records the real verdict of each task (test/build output, compacted) | "✅ 12/12 passed" (5 tokens) instead of a 500-line log; on failure it automatically surfaces **past lessons** that match |
|
|
36
|
+
| `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 |
|
|
37
|
+
|
|
38
|
+
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:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
ale config set protocol false # classic vault only
|
|
42
|
+
ale config set protocol true # back on
|
|
43
|
+
ale init --no-protocol # install without it
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Install
|
|
24
47
|
|
|
25
48
|
```bash
|
|
26
49
|
# npm (Node ≥ 20)
|
|
@@ -31,168 +54,162 @@ bun add -g @ureck/alexandria
|
|
|
31
54
|
|
|
32
55
|
# deno
|
|
33
56
|
deno install -grA -n ale npm:@ureck/alexandria/ale
|
|
34
|
-
# (
|
|
57
|
+
# (if Deno complains about "minimum dependency date", add --minimum-dependency-age=0)
|
|
35
58
|
```
|
|
36
59
|
|
|
37
|
-
|
|
60
|
+
Verify:
|
|
38
61
|
|
|
39
62
|
```bash
|
|
40
63
|
$ ale --version
|
|
41
|
-
0.
|
|
64
|
+
0.5.0
|
|
42
65
|
```
|
|
43
66
|
|
|
44
|
-
##
|
|
67
|
+
## Getting started
|
|
45
68
|
|
|
46
|
-
|
|
69
|
+
One command installs everything (embedding model ~130MB downloaded once, hooks, MCP registration, index):
|
|
47
70
|
|
|
48
71
|
```bash
|
|
49
|
-
# Global —
|
|
72
|
+
# Global — one shared vault for all your sessions (~/Alexandria)
|
|
50
73
|
ale init
|
|
51
74
|
|
|
52
|
-
#
|
|
53
|
-
cd
|
|
75
|
+
# Per project — vault INSIDE the repo (./Alexandria)
|
|
76
|
+
cd my-project
|
|
54
77
|
ale init --project
|
|
55
78
|
|
|
56
|
-
#
|
|
57
|
-
ale init --path ~/Documents/
|
|
79
|
+
# Point at an existing Obsidian vault
|
|
80
|
+
ale init --path ~/Documents/MyObsidianVault
|
|
58
81
|
|
|
59
|
-
#
|
|
60
|
-
ale init --agents all #
|
|
61
|
-
ale init --agents claude,cursor,opencode #
|
|
62
|
-
# (
|
|
82
|
+
# Choose which agents get the MCP server
|
|
83
|
+
ale init --agents all # every supported agent
|
|
84
|
+
ale init --agents claude,cursor,opencode # just these
|
|
85
|
+
# (without --agents: Claude Code + whatever is detected on your machine)
|
|
63
86
|
```
|
|
64
87
|
|
|
65
|
-
|
|
66
|
-
|
|
88
|
+
`ale init --project` also, automatically:
|
|
89
|
+
- adds the vault to your `.gitignore` (personal knowledge, not repo code),
|
|
90
|
+
- **scans the project** (stack from package.json, npm scripts, folder structure, README excerpt) into an initial `Map - <project>` note — context from the very first session,
|
|
91
|
+
- asks *"Configure Claude to use Alexandria automatically?"* and writes the usage rules into `CLAUDE.md` (`--auto` / `--manual` to skip the question).
|
|
67
92
|
|
|
68
|
-
|
|
69
|
-
▄▀█ █░░ █▀▀ ▀▄▀ ▄▀█ █▄░█ █▀▄ █▀█ █ ▄▀█
|
|
70
|
-
█▀█ █▄▄ ██▄ █░█ █▀█ █░▀█ █▄▀ █▀▄ █ █▀█
|
|
71
|
-
🏛 Bóveda de conocimiento local · creada por Ureck
|
|
72
|
-
|
|
73
|
-
Instalación por proyecto
|
|
74
|
-
|
|
75
|
-
✓ Bóveda en /Users/tu/mi-proyecto/KnowledgeVault (vault Obsidian válido)
|
|
76
|
-
✓ Config del proyecto: /Users/tu/mi-proyecto/.vault.json
|
|
77
|
-
✓ Hooks registrados en /Users/tu/mi-proyecto/.claude/settings.json
|
|
78
|
-
SessionStart (digest) · UserPromptSubmit (contexto+captura) · Stop/PreCompact (sesiones)
|
|
79
|
-
✓ MCP → Claude Code (/Users/tu/mi-proyecto/.mcp.json)
|
|
80
|
-
↓ Descargando modelo de embeddings (una sola vez)…
|
|
81
|
-
✓ Modelo listo (búsqueda semántica activada)
|
|
82
|
-
✓ Índice: 0 notas, 0 conexiones
|
|
83
|
-
|
|
84
|
-
✅ Listo. Abre una sesión de tu agente y todo funciona solo — nada que reconectar nunca.
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
</details>
|
|
88
|
-
|
|
89
|
-
Después de `init` no hay nada que reconectar, nunca. Importante: los hooks cargan **al arrancar** una sesión — abre una sesión *nueva* de tu agente en esa carpeta (una que ya estaba abierta no los verá). Desde ahí, cada prompt busca en la bóveda antes de gastar tokens y cada cierre de sesión guarda lo aprendido.
|
|
90
|
-
|
|
91
|
-
> 💡 **Tip**: si la bóveda vive dentro de un repo git, agrega `KnowledgeVault/` a tu `.gitignore` — los digests de sesión son conocimiento personal tuyo, no del repo.
|
|
93
|
+
After `init` there is nothing to reconnect, ever. Important: hooks load **when a session starts** — open a *new* agent session in that folder (an already-open one won't see them).
|
|
92
94
|
|
|
93
|
-
##
|
|
95
|
+
## Daily usage — examples
|
|
94
96
|
|
|
95
|
-
###
|
|
96
|
-
|
|
97
|
-
Busca por **significado**, no por palabras exactas:
|
|
97
|
+
### Search by meaning, not keywords
|
|
98
98
|
|
|
99
99
|
```bash
|
|
100
|
-
$ ale search
|
|
100
|
+
$ ale search how do I publish my app to the google store
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
flutter build appbundle.
|
|
102
|
+
Flutter release deployment (Alexandria/notes/2026-07-09-deploy.md, note) ● high relevance
|
|
103
|
+
To publish on Play Store: keystore outside git, key.properties,
|
|
104
|
+
flutter build appbundle. Always sign with the production key.
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
The query shares zero keywords with the note ("google store" → "Play Store"). More:
|
|
108
108
|
|
|
109
109
|
```bash
|
|
110
|
-
ale search error
|
|
111
|
-
ale search "
|
|
112
|
-
ale search
|
|
110
|
+
ale search cors error in the api # finds your fix from months ago
|
|
111
|
+
ale search "architecture decision" -k 10
|
|
112
|
+
ale search auth --expand # also pulls notes CONNECTED to the results (graph)
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
The `● high/medium/low relevance` label is relative to the best hit — trust it over the raw number.
|
|
116
116
|
|
|
117
|
-
###
|
|
117
|
+
### Save notes manually
|
|
118
118
|
|
|
119
119
|
```bash
|
|
120
|
-
#
|
|
121
|
-
ale add "
|
|
120
|
+
# Quick note
|
|
121
|
+
ale add "Prisma setup" -c "Singleton in src/lib/prisma.ts using globalThis" -t "prisma,db"
|
|
122
122
|
|
|
123
|
-
#
|
|
124
|
-
|
|
123
|
+
# From a file in your project (or a pipe)
|
|
124
|
+
ale add "Q3 architecture decisions" --file DECISIONS.md
|
|
125
|
+
cat DECISIONS.md | ale add "Q3 architecture decisions"
|
|
125
126
|
|
|
126
|
-
#
|
|
127
|
-
ale add "
|
|
127
|
+
# With [[wikilinks]] to connect knowledge
|
|
128
|
+
ale add "Vercel deploy" -c "Region cdg1, see [[Prisma setup]]" -t deploy
|
|
128
129
|
```
|
|
129
130
|
|
|
130
|
-
(
|
|
131
|
+
(Automatic capture via hooks already does this in every Claude Code session — `add` is for extra knowledge.)
|
|
131
132
|
|
|
132
|
-
###
|
|
133
|
+
### Create a plan from a file
|
|
133
134
|
|
|
134
|
-
|
|
135
|
+
Instead of typing a whole plan into the terminal, keep it as markdown in your repo:
|
|
135
136
|
|
|
136
137
|
```bash
|
|
137
|
-
ale
|
|
138
|
-
|
|
138
|
+
$ ale plan PLAN-migration.md
|
|
139
|
+
✓ Plan created: notes/2026-07-11-plan-migrate-to-postgres-17.md
|
|
140
|
+
DoD detected: 3 criteria — backup verified · migrations run clean · app responds on staging
|
|
139
141
|
```
|
|
140
142
|
|
|
141
|
-
|
|
143
|
+
Checkbox lines (`- [ ] ...`) become the Definition of Done. The agent sees it as an **open plan** at the start of the next session and resumes it with `task_verify`.
|
|
142
144
|
|
|
143
|
-
|
|
145
|
+
### View the knowledge graph
|
|
144
146
|
|
|
145
|
-
|
|
147
|
+
**The graph maintains itself** — every vault change (automatic capture, `ale add`, reindex) regenerates `<vault>/grafo.html`. Double-click it anytime.
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
ale graph # LIVE viewer in your browser: auto-refreshes every 3s
|
|
151
|
+
ale graph --out other.html # static copy elsewhere (optional)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Nodes = notes (size = connections, color = type: 🟪 plans, 🟦 verifications, 🟨 lessons, 🟩 sessions…), solid lines = `[[wikilinks]]`, dashed = semantic similarity. Auto-fit, hover highlights neighbors, click shows details, Obsidian-style **type filters** (prompts hidden by default — they're visual noise). The graph shines from ~20-30 notes on — it's cumulative by design.
|
|
155
|
+
|
|
156
|
+
**In Obsidian**: open the vault folder as a vault and use the native graph view — notes carry `aliases` in their frontmatter so Obsidian resolves the `[[wikilinks]]`. Old notes are migrated automatically on the next reindex. Note: `grafo.html` is for your browser; Obsidian doesn't render HTML.
|
|
157
|
+
|
|
158
|
+
### Measure what it saves you
|
|
146
159
|
|
|
147
160
|
```bash
|
|
148
161
|
$ ale stats
|
|
149
162
|
|
|
150
|
-
🧠
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
163
|
+
🧠 Vault: /Users/you/Alexandria (global)
|
|
164
|
+
Notes: 142 {"note":80,"prompt":38,"session":22,"map":2}
|
|
165
|
+
Indexed chunks: 385 · Connections: 91
|
|
166
|
+
Semantic search: active
|
|
154
167
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
168
|
+
🏛️ Protocol
|
|
169
|
+
Plans: 6 (1 open) · Verifications: 14 (86% ✓)
|
|
170
|
+
Lessons: 9 (4 reused — each reuse = a debug session that never happened)
|
|
171
|
+
|
|
172
|
+
💰 Estimated savings
|
|
173
|
+
Context injections: 57 (12 with cached solution)
|
|
174
|
+
Injected tokens: ~21,300
|
|
175
|
+
Tokens saved (vs re-exploring): ~191,700
|
|
159
176
|
```
|
|
160
177
|
|
|
161
|
-
###
|
|
178
|
+
### Audit your vault's health
|
|
162
179
|
|
|
163
180
|
```bash
|
|
164
|
-
$ ale
|
|
165
|
-
|
|
166
|
-
📦 Skills recomendadas según tu bóveda:
|
|
167
|
-
pdf-report-gen [local] — detecté 14 menciones de pdf, membrete en la bóveda
|
|
168
|
-
auth-standard [local] — detecté 9 menciones de auth, login, jwt en la bóveda
|
|
181
|
+
$ ale audit
|
|
169
182
|
|
|
170
|
-
|
|
183
|
+
🏛️ Alexandria Protocol audit
|
|
184
|
+
Plans: 2 (2 open, 0 completed, 0 failed)
|
|
185
|
+
Verifications: 1 (1 failures) · Lessons: 1
|
|
186
|
+
⚠ Notes without connections (invisible to vault_related): 1
|
|
187
|
+
- Plan - Migrate to Postgres 17 → connect it with vault_link or [[wikilinks]]
|
|
171
188
|
```
|
|
172
189
|
|
|
173
|
-
|
|
190
|
+
Flags plans without a Definition of Done, failures without lessons, and orphan notes.
|
|
174
191
|
|
|
175
|
-
###
|
|
192
|
+
### Maintenance (you rarely need it)
|
|
176
193
|
|
|
177
194
|
```bash
|
|
178
|
-
ale doctor
|
|
179
|
-
ale reindex
|
|
180
|
-
ale
|
|
181
|
-
|
|
195
|
+
ale doctor # checks & repairs: model, hooks, MCP, index
|
|
196
|
+
ale reindex [--force] # incremental by default
|
|
197
|
+
ale consolidate [--days 45] # ARCHIVES old unused prompts to Alexandria/archive/
|
|
198
|
+
# — out of the graph and injection, still searchable: nothing is ever lost
|
|
199
|
+
ale uninstall # removes hooks; your notes stay untouched
|
|
182
200
|
```
|
|
183
201
|
|
|
184
|
-
|
|
202
|
+
Every command self-repairs before running: missing model → downloads it; stale index → updates it.
|
|
185
203
|
|
|
186
|
-
##
|
|
204
|
+
## Supported agents
|
|
187
205
|
|
|
188
206
|
```bash
|
|
189
|
-
ale agents #
|
|
190
|
-
ale agents all #
|
|
191
|
-
ale agents cursor,gemini #
|
|
192
|
-
ale agents detected # solo los detectados
|
|
207
|
+
ale agents # list with auto-detection (● = found on your machine)
|
|
208
|
+
ale agents all # register the MCP server in all of them
|
|
209
|
+
ale agents cursor,gemini # just these
|
|
193
210
|
```
|
|
194
211
|
|
|
195
|
-
|
|
|
212
|
+
| Agent | Config written | Per-project |
|
|
196
213
|
|---|---|---|
|
|
197
214
|
| Claude Code | `.mcp.json` / `claude mcp add` + hooks | ✓ |
|
|
198
215
|
| Cursor | `~/.cursor/mcp.json` / `.cursor/mcp.json` | ✓ |
|
|
@@ -201,84 +218,68 @@ ale agents detected # solo los detectados
|
|
|
201
218
|
| Cline | `cline_mcp_settings.json` (VS Code) | — |
|
|
202
219
|
| Codex CLI | `~/.codex/config.toml` | — |
|
|
203
220
|
| Gemini CLI | `~/.gemini/settings.json` / `.gemini/settings.json` | ✓ |
|
|
204
|
-
| VS Code (Copilot) | `mcp.json` (
|
|
221
|
+
| VS Code (Copilot) | `mcp.json` (profile) / `.vscode/mcp.json` | ✓ |
|
|
205
222
|
| OpenClaw | `~/.openclaw/openclaw.json` | — |
|
|
206
223
|
| Hermes Agent (Nous) | `hermes mcp add` / `~/.hermes/config.yaml` | — |
|
|
207
224
|
|
|
208
|
-
|
|
225
|
+
Registrations are **idempotent merges** — your other MCP servers are never touched.
|
|
209
226
|
|
|
210
|
-
**
|
|
227
|
+
**Note**: automatic capture via hooks (session digest, per-prompt injection, session save on close) is Claude Code-only — other agents don't have a hook system. There, knowledge flows through the MCP tools, which the agent uses on its own (the protocol instructions travel inside the tool descriptions).
|
|
211
228
|
|
|
212
|
-
##
|
|
229
|
+
## How it works
|
|
213
230
|
|
|
214
231
|
```
|
|
215
|
-
|
|
232
|
+
AI agent session
|
|
216
233
|
│
|
|
217
|
-
├─ SessionStart ──►
|
|
218
|
-
├─
|
|
219
|
-
│ └─ prompt
|
|
220
|
-
├─ MCP tools ─────► vault_search · vault_save · vault_related · vault_link
|
|
221
|
-
|
|
234
|
+
├─ SessionStart ──► injects digest: protocol manifest + project map + open plans (hooks, Claude Code)
|
|
235
|
+
├─ Every prompt ──► local hybrid search → injects only what's relevant (hooks, Claude Code)
|
|
236
|
+
│ └─ near-identical prompt already solved → injects the solution (cache)
|
|
237
|
+
├─ MCP tools ─────► vault_search · vault_save · vault_related · vault_link (all agents)
|
|
238
|
+
│ plan_create · task_verify · lesson_extract (the Protocol)
|
|
239
|
+
└─ Stop/PreCompact► saves the session outcome into the vault (hooks, Claude Code)
|
|
222
240
|
│
|
|
223
|
-
<
|
|
224
|
-
<
|
|
241
|
+
<Obsidian vault>/Alexandria/*.md ← markdown, [[wikilinks]]
|
|
242
|
+
<vault>/.vault/ ← index (regenerable)
|
|
225
243
|
```
|
|
226
244
|
|
|
227
|
-
- **
|
|
228
|
-
-
|
|
229
|
-
- **
|
|
230
|
-
- **
|
|
245
|
+
- **Hybrid search**: local embeddings (transformers.js, multilingual e5-small) + BM25, combined with RRF, boosted by recency, usage, and note type (lessons/solutions rank highest).
|
|
246
|
+
- **Incremental index**: only re-processes notes whose mtime changed. The graph is never rebuilt from scratch.
|
|
247
|
+
- **Deduplication**: near-identical prompts don't create new notes — they add `hits` (and climb the ranking).
|
|
248
|
+
- **About scores**: the e5 model compresses cosines (~0.76–0.86 even for unrelated topics); the *ranking* is what's reliable, hence the relevance label.
|
|
231
249
|
|
|
232
|
-
##
|
|
250
|
+
## Command reference
|
|
233
251
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
- `vault_search(query, k)` — busca conocimiento antes de explorar código.
|
|
237
|
-
- `vault_save(title, content, tags)` — guarda decisiones/arquitectura. `title: "Mapa - <proyecto>"` actualiza el mapa que se inyecta al inicio de cada sesión de Claude Code.
|
|
238
|
-
- `vault_related(title)` — vecinos en el grafo (wikilinks + semánticos) sin releer archivos.
|
|
239
|
-
- `vault_link(from, to)` — conecta dos notas con `[[wikilink]]`.
|
|
240
|
-
|
|
241
|
-
## Comandos — referencia
|
|
242
|
-
|
|
243
|
-
| Comando | Qué hace |
|
|
252
|
+
| Command | What it does |
|
|
244
253
|
|---|---|
|
|
245
|
-
| `ale init [--project] [--path <dir>] [--agents <ids>] [--
|
|
246
|
-
| `ale agents [ids] [--project]` |
|
|
247
|
-
| `ale search <query> [-k n] [--expand]` |
|
|
248
|
-
| `ale add <
|
|
249
|
-
| `ale
|
|
250
|
-
| `ale
|
|
251
|
-
| `ale
|
|
252
|
-
| `ale
|
|
253
|
-
| `ale
|
|
254
|
-
| `ale
|
|
255
|
-
| `ale --
|
|
256
|
-
|
|
257
|
-
`
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
El código fuente se mantiene en un repositorio privado; este repositorio público contiene el compilado distribuido en npm (el mismo contenido del paquete, auditable).
|
|
274
|
-
|
|
275
|
-
- 🐛 **Issues y sugerencias**: [github.com/UreckChan/alexandria/issues](https://github.com/UreckChan/alexandria/issues)
|
|
276
|
-
- 📦 **Releases**: cada versión de npm tiene su tag aquí
|
|
277
|
-
|
|
278
|
-
## Apoya el proyecto ☕
|
|
279
|
-
|
|
280
|
-
Alexandria es gratis y open source. Si te ahorra tokens (y dinero), puedes invitarme un café:
|
|
254
|
+
| `ale init [--project] [--path <dir>] [--agents <ids>] [--auto\|--manual] [--no-protocol]` | Installs everything: vault (default `./Alexandria` / `~/Alexandria`), hooks, MCP, .gitignore, project scan, CLAUDE.md |
|
|
255
|
+
| `ale agents [ids] [--project]` | List agents / register the MCP server |
|
|
256
|
+
| `ale search <query> [-k n] [--expand]` | Hybrid search; `--expand` pulls graph neighbors |
|
|
257
|
+
| `ale add <title> [-c text] [--file <path>] [-t tags]` | Save a note (inline, from file, or stdin) |
|
|
258
|
+
| `ale plan <file> [--title t]` | Create a Protocol plan from a .md/.txt file (checkboxes → Definition of Done) |
|
|
259
|
+
| `ale graph [--out file.html] [--no-open]` | Live local graph viewer |
|
|
260
|
+
| `ale audit` | Protocol health: plans without DoD, failures without lessons, orphan notes |
|
|
261
|
+
| `ale stats` | Notes, connections, protocol metrics, estimated tokens saved |
|
|
262
|
+
| `ale config <get\|set> <key> [value]` | Configuration (e.g. `protocol` true/false) |
|
|
263
|
+
| `ale skills [-y] [--project]` | Recommends & installs Claude skills based on your patterns |
|
|
264
|
+
| `ale reindex [--force]` | Reindex (incremental by default) |
|
|
265
|
+
| `ale consolidate [--days n] [--dry]` | Archive old unused prompts — never deletes |
|
|
266
|
+
| `ale doctor [--project]` | Check & repair: model, hooks, MCP, index |
|
|
267
|
+
| `ale uninstall [--project]` | Remove hooks (notes stay untouched) |
|
|
268
|
+
| `ale --vault <path> <cmd>` | Run any command against another vault |
|
|
269
|
+
|
|
270
|
+
`alexandria` works as an alias of `ale`.
|
|
271
|
+
|
|
272
|
+
## Privacy & security
|
|
273
|
+
|
|
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
|
+
- **No API keys, no accounts, no cost.**
|
|
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`, hooks) point at your machine's install path. If you share a repo with a team, switch the `command` to `npx -y @ureck/alexandria alexandria serve-mcp` for portability.
|
|
278
|
+
|
|
279
|
+
## Support the project ☕
|
|
280
|
+
|
|
281
|
+
Alexandria is free and open source. If it saves you tokens (and money), you can buy me a coffee:
|
|
281
282
|
|
|
282
283
|
**[☕ buymeacoffee.com/ureck](https://buymeacoffee.com/ureck)**
|
|
283
284
|
|
|
284
|
-
|
|
285
|
+
Built with 🏛 by **[Ureck](https://buymeacoffee.com/ureck)** — MIT License.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
VaultIndex
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MLA3KZPZ.js";
|
|
5
5
|
import {
|
|
6
6
|
dot,
|
|
7
7
|
embed,
|
|
@@ -35,12 +35,25 @@ function buildMini(idx) {
|
|
|
35
35
|
);
|
|
36
36
|
return mini;
|
|
37
37
|
}
|
|
38
|
+
var TYPE_BOOST = {
|
|
39
|
+
lesson: 1.35,
|
|
40
|
+
solution: 1.35,
|
|
41
|
+
map: 1.25,
|
|
42
|
+
plan: 1.15,
|
|
43
|
+
verification: 1.1,
|
|
44
|
+
note: 1,
|
|
45
|
+
task: 1,
|
|
46
|
+
session: 0.9,
|
|
47
|
+
prompt: 0.8
|
|
48
|
+
};
|
|
38
49
|
function recencyBoost(note) {
|
|
39
|
-
if (!note
|
|
50
|
+
if (!note) return 1;
|
|
51
|
+
const typeBoost = TYPE_BOOST[note.type] ?? 1;
|
|
52
|
+
if (!note.created) return typeBoost;
|
|
40
53
|
const age = (Date.now() - Date.parse(note.created)) / 864e5;
|
|
41
|
-
if (Number.isNaN(age)) return
|
|
54
|
+
if (Number.isNaN(age)) return typeBoost;
|
|
42
55
|
const hits = Math.min(note.hits ?? 1, 10);
|
|
43
|
-
return 1 + 0.15 * Math.exp(-Math.max(age, 0) / 45) + 0.02 * hits;
|
|
56
|
+
return typeBoost * (1 + 0.15 * Math.exp(-Math.max(age, 0) / 45) + 0.02 * hits);
|
|
44
57
|
}
|
|
45
58
|
async function hybridSearch(vault, query, k = 6, opts = {}) {
|
|
46
59
|
const idx = VaultIndex.load(vault);
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/core/vault.ts
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import os from "os";
|
|
6
|
+
import path from "path";
|
|
7
|
+
var MANAGED_DIR = "Alexandria";
|
|
8
|
+
function configDir() {
|
|
9
|
+
if (process.platform === "win32" && process.env.APPDATA) {
|
|
10
|
+
return path.join(process.env.APPDATA, "alexandria");
|
|
11
|
+
}
|
|
12
|
+
return path.join(os.homedir(), ".config", "alexandria");
|
|
13
|
+
}
|
|
14
|
+
function globalConfigPath() {
|
|
15
|
+
return path.join(configDir(), "config.json");
|
|
16
|
+
}
|
|
17
|
+
function defaultVaultPath() {
|
|
18
|
+
const legacy = path.join(os.homedir(), "KnowledgeVault");
|
|
19
|
+
if (fs.existsSync(legacy)) return legacy;
|
|
20
|
+
return path.join(os.homedir(), "Alexandria");
|
|
21
|
+
}
|
|
22
|
+
function readJson(file) {
|
|
23
|
+
try {
|
|
24
|
+
return JSON.parse(fs.readFileSync(file, "utf8"));
|
|
25
|
+
} catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function findProjectConfig(from) {
|
|
30
|
+
let dir = path.resolve(from);
|
|
31
|
+
for (; ; ) {
|
|
32
|
+
const candidate = path.join(dir, ".vault.json");
|
|
33
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
34
|
+
const parent = path.dirname(dir);
|
|
35
|
+
if (parent === dir) return null;
|
|
36
|
+
dir = parent;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function build(root, source, projectConfig) {
|
|
40
|
+
const managed = path.basename(root).toLowerCase() === MANAGED_DIR.toLowerCase() ? root : path.join(root, MANAGED_DIR);
|
|
41
|
+
return {
|
|
42
|
+
root,
|
|
43
|
+
managed,
|
|
44
|
+
cache: path.join(root, ".vault"),
|
|
45
|
+
source,
|
|
46
|
+
projectConfig
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function resolveVault(opts = {}) {
|
|
50
|
+
if (opts.flag) return build(path.resolve(opts.flag), "flag");
|
|
51
|
+
const cwd = opts.cwd ?? process.cwd();
|
|
52
|
+
const projectFile = findProjectConfig(cwd);
|
|
53
|
+
if (projectFile) {
|
|
54
|
+
const cfg = readJson(projectFile);
|
|
55
|
+
if (cfg?.vaultPath) {
|
|
56
|
+
const base = path.dirname(projectFile);
|
|
57
|
+
return build(path.resolve(base, cfg.vaultPath), "project", projectFile);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const globalCfg = readJson(globalConfigPath());
|
|
61
|
+
if (globalCfg?.vaultPath) return build(globalCfg.vaultPath, "global");
|
|
62
|
+
return build(defaultVaultPath(), "default");
|
|
63
|
+
}
|
|
64
|
+
function vaultExists(v) {
|
|
65
|
+
return fs.existsSync(v.managed) || fs.existsSync(v.cache);
|
|
66
|
+
}
|
|
67
|
+
function ensureVaultStructure(v) {
|
|
68
|
+
for (const dir of [
|
|
69
|
+
v.root,
|
|
70
|
+
v.managed,
|
|
71
|
+
path.join(v.managed, "notes"),
|
|
72
|
+
path.join(v.managed, "prompts"),
|
|
73
|
+
path.join(v.managed, "sessions"),
|
|
74
|
+
v.cache
|
|
75
|
+
]) {
|
|
76
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function writeGlobalConfig(vaultPath) {
|
|
80
|
+
fs.mkdirSync(configDir(), { recursive: true });
|
|
81
|
+
const current = readJson(globalConfigPath()) ?? {};
|
|
82
|
+
fs.writeFileSync(globalConfigPath(), JSON.stringify({ ...current, vaultPath }, null, 2) + "\n");
|
|
83
|
+
}
|
|
84
|
+
function getConfigKey(key) {
|
|
85
|
+
const cfg = readJson(globalConfigPath()) ?? {};
|
|
86
|
+
return cfg[key];
|
|
87
|
+
}
|
|
88
|
+
function setConfigKey(key, value) {
|
|
89
|
+
fs.mkdirSync(configDir(), { recursive: true });
|
|
90
|
+
const cfg = readJson(globalConfigPath()) ?? {};
|
|
91
|
+
cfg[key] = value;
|
|
92
|
+
fs.writeFileSync(globalConfigPath(), JSON.stringify(cfg, null, 2) + "\n");
|
|
93
|
+
}
|
|
94
|
+
function protocolEnabled() {
|
|
95
|
+
const v = getConfigKey("protocol");
|
|
96
|
+
return v !== false && v !== "false";
|
|
97
|
+
}
|
|
98
|
+
function writeProjectConfig(projectDir, vaultPath) {
|
|
99
|
+
const file = path.join(projectDir, ".vault.json");
|
|
100
|
+
const rel = path.relative(projectDir, vaultPath) || ".";
|
|
101
|
+
const stored = rel.startsWith("..") ? vaultPath : rel;
|
|
102
|
+
fs.writeFileSync(file, JSON.stringify({ vaultPath: stored }, null, 2) + "\n");
|
|
103
|
+
return file;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export {
|
|
107
|
+
globalConfigPath,
|
|
108
|
+
defaultVaultPath,
|
|
109
|
+
resolveVault,
|
|
110
|
+
vaultExists,
|
|
111
|
+
ensureVaultStructure,
|
|
112
|
+
writeGlobalConfig,
|
|
113
|
+
getConfigKey,
|
|
114
|
+
setConfigKey,
|
|
115
|
+
protocolEnabled,
|
|
116
|
+
writeProjectConfig
|
|
117
|
+
};
|