@ureck/alexandria 0.4.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 -173
- package/dist/{chunk-ADHRHLX7.js → chunk-BCLBZ7NX.js} +17 -4
- package/dist/{chunk-KB6KYZFQ.js → chunk-DYCARGQR.js} +19 -1
- package/dist/{chunk-ZW7XY3EN.js → chunk-MLA3KZPZ.js} +3 -2
- package/dist/{chunk-WPNU64MA.js → chunk-RLVCH6CZ.js} +8 -4
- package/dist/{chunk-JPHL2JHE.js → chunk-XWR74BQ2.js} +26 -4
- package/dist/cli.js +94 -10
- package/dist/hooks/on-prompt.js +5 -5
- package/dist/hooks/on-session-start.js +12 -3
- package/dist/hooks/on-stop.js +2 -2
- package/dist/mcp/server.js +132 -4
- package/dist/{viewer-FRJYOK3S.js → viewer-57T7UOFE.js} +3 -3
- package/package.json +1 -1
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/Alexandria (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
|
-
> `ale init --project` también agrega la bóveda a tu `.gitignore` automáticamente, escanea el proyecto (stack, estructura, comandos → mapa inicial) y te ofrece configurar en `CLAUDE.md` que Claude use Alexandria por default en cada sesión (`--auto` / `--manual` para decidir sin pregunta).
|
|
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
|
+
|
|
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"
|
|
126
|
+
|
|
127
|
+
# With [[wikilinks]] to connect knowledge
|
|
128
|
+
ale add "Vercel deploy" -c "Region cdg1, see [[Prisma setup]]" -t deploy
|
|
129
|
+
```
|
|
122
130
|
|
|
123
|
-
|
|
124
|
-
cat DECISIONES.md | ale add "Decisiones de arquitectura Q3"
|
|
131
|
+
(Automatic capture via hooks already does this in every Claude Code session — `add` is for extra knowledge.)
|
|
125
132
|
|
|
126
|
-
|
|
127
|
-
|
|
133
|
+
### Create a plan from a file
|
|
134
|
+
|
|
135
|
+
Instead of typing a whole plan into the terminal, keep it as markdown in your repo:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
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
|
|
128
141
|
```
|
|
129
142
|
|
|
130
|
-
(
|
|
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`.
|
|
131
144
|
|
|
132
|
-
###
|
|
145
|
+
### View the knowledge graph
|
|
133
146
|
|
|
134
|
-
**
|
|
147
|
+
**The graph maintains itself** — every vault change (automatic capture, `ale add`, reindex) regenerates `<vault>/grafo.html`. Double-click it anytime.
|
|
135
148
|
|
|
136
149
|
```bash
|
|
137
|
-
ale graph
|
|
138
|
-
ale graph --out
|
|
150
|
+
ale graph # LIVE viewer in your browser: auto-refreshes every 3s
|
|
151
|
+
ale graph --out other.html # static copy elsewhere (optional)
|
|
139
152
|
```
|
|
140
153
|
|
|
141
|
-
|
|
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.
|
|
142
155
|
|
|
143
|
-
**
|
|
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.
|
|
144
157
|
|
|
145
|
-
###
|
|
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,85 +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>] [--auto\|--manual]` |
|
|
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
|
-
| `ale --
|
|
257
|
-
|
|
258
|
-
`
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
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).
|
|
275
|
-
|
|
276
|
-
- 🐛 **Issues y sugerencias**: [github.com/UreckChan/alexandria/issues](https://github.com/UreckChan/alexandria/issues)
|
|
277
|
-
- 📦 **Releases**: cada versión de npm tiene su tag aquí
|
|
278
|
-
|
|
279
|
-
## Apoya el proyecto ☕
|
|
280
|
-
|
|
281
|
-
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:
|
|
282
282
|
|
|
283
283
|
**[☕ buymeacoffee.com/ureck](https://buymeacoffee.com/ureck)**
|
|
284
284
|
|
|
285
|
-
|
|
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);
|
|
@@ -78,7 +78,22 @@ function ensureVaultStructure(v) {
|
|
|
78
78
|
}
|
|
79
79
|
function writeGlobalConfig(vaultPath) {
|
|
80
80
|
fs.mkdirSync(configDir(), { recursive: true });
|
|
81
|
-
|
|
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";
|
|
82
97
|
}
|
|
83
98
|
function writeProjectConfig(projectDir, vaultPath) {
|
|
84
99
|
const file = path.join(projectDir, ".vault.json");
|
|
@@ -95,5 +110,8 @@ export {
|
|
|
95
110
|
vaultExists,
|
|
96
111
|
ensureVaultStructure,
|
|
97
112
|
writeGlobalConfig,
|
|
113
|
+
getConfigKey,
|
|
114
|
+
setConfigKey,
|
|
115
|
+
protocolEnabled,
|
|
98
116
|
writeProjectConfig
|
|
99
117
|
};
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
ensureAlias,
|
|
4
4
|
listMarkdownFiles,
|
|
5
5
|
parseNote
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-XWR74BQ2.js";
|
|
7
7
|
import {
|
|
8
8
|
DIM,
|
|
9
9
|
MODEL_ID,
|
|
@@ -115,6 +115,7 @@ var VaultIndex = class _VaultIndex {
|
|
|
115
115
|
rel,
|
|
116
116
|
title: note.title,
|
|
117
117
|
type: note.type,
|
|
118
|
+
status: note.status,
|
|
118
119
|
tags: note.tags,
|
|
119
120
|
created: note.created,
|
|
120
121
|
hits: note.hits,
|
|
@@ -167,7 +168,7 @@ ${c.text}`),
|
|
|
167
168
|
this.rebuildLinks();
|
|
168
169
|
this.save();
|
|
169
170
|
try {
|
|
170
|
-
const { writeStaticGraph } = await import("./viewer-
|
|
171
|
+
const { writeStaticGraph } = await import("./viewer-57T7UOFE.js");
|
|
171
172
|
writeStaticGraph(this);
|
|
172
173
|
} catch {
|
|
173
174
|
}
|
|
@@ -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
|
|
|
6
6
|
// src/graph/viewer.ts
|
|
7
7
|
import fs from "fs";
|
|
@@ -65,8 +65,12 @@ function renderGraphHtml(data, live) {
|
|
|
65
65
|
<div class="leg" id="leg">
|
|
66
66
|
<label><input type="checkbox" data-type="note" checked><b style="background:#7aa2f7"></b>nota</label>
|
|
67
67
|
<label><input type="checkbox" data-type="map" checked><b style="background:#f7768e"></b>mapa</label>
|
|
68
|
+
<label><input type="checkbox" data-type="plan" checked><b style="background:#bb9af7"></b>plan</label>
|
|
69
|
+
<label><input type="checkbox" data-type="verification" checked><b style="background:#2ac3de"></b>verificaci\xF3n</label>
|
|
70
|
+
<label><input type="checkbox" data-type="lesson" checked><b style="background:#ffc777"></b>lecci\xF3n</label>
|
|
71
|
+
<label><input type="checkbox" data-type="solution" checked><b style="background:#73daca"></b>soluci\xF3n</label>
|
|
68
72
|
<label><input type="checkbox" data-type="session" checked><b style="background:#9ece6a"></b>sesi\xF3n</label>
|
|
69
|
-
<label><input type="checkbox" data-type="prompt"><b style="background:#
|
|
73
|
+
<label><input type="checkbox" data-type="prompt"><b style="background:#565f89"></b>prompt</label>
|
|
70
74
|
</div>
|
|
71
75
|
<div id="hint">filtros por tipo (prompts ocultos por default \u2014 ruido) \xB7 arrastra \xB7 rueda = zoom<br>hover = conexiones \xB7 click = detalle \xB7 \u2014 s\xF3lida = [[wikilink]] \xB7 \u2025 punteada = sem\xE1ntica</div>
|
|
72
76
|
</div>
|
|
@@ -79,7 +83,7 @@ function renderGraphHtml(data, live) {
|
|
|
79
83
|
'use strict';
|
|
80
84
|
const LIVE = ${live};
|
|
81
85
|
let DATA = ${JSON.stringify(data)};
|
|
82
|
-
const COLORS = { note:'#7aa2f7', session:'#9ece6a', prompt:'#
|
|
86
|
+
const COLORS = { note:'#7aa2f7', session:'#9ece6a', prompt:'#565f89', map:'#f7768e', plan:'#bb9af7', verification:'#2ac3de', lesson:'#ffc777', solution:'#73daca', task:'#7dcfff' };
|
|
83
87
|
const cv = document.getElementById('c'), ctx = cv.getContext('2d');
|
|
84
88
|
const DPR = Math.min(devicePixelRatio || 1, 2);
|
|
85
89
|
let W, H;
|
|
@@ -91,7 +95,7 @@ let nodes = [], byId = new Map(), edges = [];
|
|
|
91
95
|
let zoom = 1, panX = 0, panY = 0, dragNode = null, hot = true, heat = 300;
|
|
92
96
|
let didFit = false, hover = null, filter = '';
|
|
93
97
|
// filtros por tipo (estilo Obsidian) \u2014 prompts ocultos por default: son ruido visual
|
|
94
|
-
const typeOn = { note: true, map: true, session: true, prompt: false };
|
|
98
|
+
const typeOn = { note: true, map: true, session: true, prompt: false, plan: true, verification: true, lesson: true, solution: true, task: true };
|
|
95
99
|
document.querySelectorAll('#leg input').forEach(cb => cb.addEventListener('change', e => {
|
|
96
100
|
typeOn[e.target.dataset.type] = e.target.checked; heat = Math.max(heat, 30); hot = true;
|
|
97
101
|
}));
|
|
@@ -4,6 +4,17 @@
|
|
|
4
4
|
import fs from "fs";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import matter from "gray-matter";
|
|
7
|
+
var NOTE_TYPES = [
|
|
8
|
+
"note",
|
|
9
|
+
"prompt",
|
|
10
|
+
"session",
|
|
11
|
+
"map",
|
|
12
|
+
"plan",
|
|
13
|
+
"task",
|
|
14
|
+
"verification",
|
|
15
|
+
"lesson",
|
|
16
|
+
"solution"
|
|
17
|
+
];
|
|
7
18
|
var SKIP_DIRS = /* @__PURE__ */ new Set([".obsidian", ".vault", ".trash", ".git", "node_modules"]);
|
|
8
19
|
function extractWikilinks(content) {
|
|
9
20
|
const out = /* @__PURE__ */ new Set();
|
|
@@ -42,12 +53,14 @@ function parseNote(root, absPath) {
|
|
|
42
53
|
const { data, content } = matter(raw);
|
|
43
54
|
const rel = path.relative(root, absPath).split(path.sep).join("/");
|
|
44
55
|
const title = typeof data.title === "string" && data.title || path.basename(absPath, ".md");
|
|
45
|
-
const type =
|
|
56
|
+
const type = NOTE_TYPES.includes(data.type) ? data.type : "note";
|
|
57
|
+
const status = ["active", "completed", "failed"].includes(data.status) ? data.status : void 0;
|
|
46
58
|
const tags = Array.isArray(data.tags) ? data.tags.map(String) : [];
|
|
47
59
|
return {
|
|
48
60
|
rel,
|
|
49
61
|
title,
|
|
50
62
|
type,
|
|
63
|
+
status,
|
|
51
64
|
tags,
|
|
52
65
|
created: data.created ? String(data.created) : void 0,
|
|
53
66
|
hits: typeof data.hits === "number" ? data.hits : 1,
|
|
@@ -63,6 +76,7 @@ function frontmatter(n) {
|
|
|
63
76
|
// del frontmatter — sin esto su graph view muestra los enlaces como rotos
|
|
64
77
|
`aliases: [${JSON.stringify(n.title)}]`,
|
|
65
78
|
`type: ${n.type}`,
|
|
79
|
+
...n.status ? [`status: ${n.status}`] : [],
|
|
66
80
|
`tags: [${n.tags.map((t) => JSON.stringify(t)).join(", ")}]`,
|
|
67
81
|
`created: ${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
68
82
|
`hits: ${n.hits ?? 1}`,
|
|
@@ -93,10 +107,17 @@ function createNote(managed, n) {
|
|
|
93
107
|
while (fs.existsSync(file)) file = path.join(dir, `${base}-${i++}.md`);
|
|
94
108
|
fs.writeFileSync(
|
|
95
109
|
file,
|
|
96
|
-
frontmatter({ title: n.title, type: n.type ?? "note", tags: n.tags ?? [] }) + n.content.trim() + "\n"
|
|
110
|
+
frontmatter({ title: n.title, type: n.type ?? "note", tags: n.tags ?? [], status: n.status }) + n.content.trim() + "\n"
|
|
97
111
|
);
|
|
98
112
|
return file;
|
|
99
113
|
}
|
|
114
|
+
function setNoteStatus(absPath, status) {
|
|
115
|
+
const raw = fs.readFileSync(absPath, "utf8");
|
|
116
|
+
const { data, content } = matter(raw);
|
|
117
|
+
data.status = status;
|
|
118
|
+
data.updated = (/* @__PURE__ */ new Date()).toISOString();
|
|
119
|
+
fs.writeFileSync(absPath, matter.stringify(content, data));
|
|
120
|
+
}
|
|
100
121
|
function touchNote(absPath) {
|
|
101
122
|
const raw = fs.readFileSync(absPath, "utf8");
|
|
102
123
|
const { data, content } = matter(raw);
|
|
@@ -116,7 +137,7 @@ function upsertNote(managed, n) {
|
|
|
116
137
|
} else {
|
|
117
138
|
fs.writeFileSync(
|
|
118
139
|
file,
|
|
119
|
-
frontmatter({ title: n.title, type: n.type ?? "note", tags: n.tags ?? [] }) + n.content.trim() + "\n"
|
|
140
|
+
frontmatter({ title: n.title, type: n.type ?? "note", tags: n.tags ?? [], status: n.status }) + n.content.trim() + "\n"
|
|
120
141
|
);
|
|
121
142
|
}
|
|
122
143
|
return file;
|
|
@@ -130,7 +151,7 @@ function appendToNote(managed, n) {
|
|
|
130
151
|
} else {
|
|
131
152
|
fs.writeFileSync(
|
|
132
153
|
file,
|
|
133
|
-
frontmatter({ title: n.title, type: n.type ?? "session", tags: n.tags ?? [] }) + n.content.trim() + "\n"
|
|
154
|
+
frontmatter({ title: n.title, type: n.type ?? "session", tags: n.tags ?? [], status: n.status }) + n.content.trim() + "\n"
|
|
134
155
|
);
|
|
135
156
|
}
|
|
136
157
|
return file;
|
|
@@ -142,6 +163,7 @@ export {
|
|
|
142
163
|
parseNote,
|
|
143
164
|
ensureAlias,
|
|
144
165
|
createNote,
|
|
166
|
+
setNoteStatus,
|
|
145
167
|
touchNote,
|
|
146
168
|
upsertNote,
|
|
147
169
|
appendToNote
|
package/dist/cli.js
CHANGED
|
@@ -16,27 +16,29 @@ import {
|
|
|
16
16
|
} from "./chunk-KHTYRYDR.js";
|
|
17
17
|
import {
|
|
18
18
|
hybridSearch
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-BCLBZ7NX.js";
|
|
20
20
|
import {
|
|
21
21
|
defaultVaultPath,
|
|
22
22
|
ensureVaultStructure,
|
|
23
|
+
getConfigKey,
|
|
23
24
|
globalConfigPath,
|
|
24
25
|
resolveVault,
|
|
26
|
+
setConfigKey,
|
|
25
27
|
vaultExists,
|
|
26
28
|
writeGlobalConfig,
|
|
27
29
|
writeProjectConfig
|
|
28
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-DYCARGQR.js";
|
|
29
31
|
import {
|
|
30
32
|
serveGraph
|
|
31
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-RLVCH6CZ.js";
|
|
32
34
|
import {
|
|
33
35
|
VaultIndex
|
|
34
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-MLA3KZPZ.js";
|
|
35
37
|
import {
|
|
36
38
|
createNote,
|
|
37
39
|
slugify,
|
|
38
40
|
upsertNote
|
|
39
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-XWR74BQ2.js";
|
|
40
42
|
import {
|
|
41
43
|
MODEL_ID,
|
|
42
44
|
getEmbedder,
|
|
@@ -463,10 +465,11 @@ function configureClaudeMd(scope, projectDir) {
|
|
|
463
465
|
const file = scope === "project" ? path3.join(projectDir, "CLAUDE.md") : path3.join(os3.homedir(), ".claude", "CLAUDE.md");
|
|
464
466
|
const block = [
|
|
465
467
|
CLAUDE_MD_START,
|
|
466
|
-
"## Alexandria \u2014 b\xF3veda de conocimiento (uso por default)",
|
|
468
|
+
"## Alexandria \u2014 b\xF3veda de conocimiento y Protocolo (uso por default)",
|
|
467
469
|
"- ANTES de explorar c\xF3digo o re-derivar contexto: busca con la tool MCP `vault_search`; si la b\xF3veda ya lo sabe, \xFAsalo.",
|
|
468
|
-
"-
|
|
469
|
-
"-
|
|
470
|
+
"- El Protocolo Alexandria es palanca, no l\xEDmite: tareas simples se responden directo, sin ceremonia. En tareas no triviales: `plan_create` (objetivo + Definition of Done) \u2192 ejecutar con toda tu capacidad \u2192 `task_verify` con evidencia real (la evidencia elimina errores, no frena) \u2192 si algo falla, `vault_search` por lecciones previas antes de re-debuggear \u2192 `lesson_extract` al resolver algo no obvio. Soluciones cacheadas se validan contra el c\xF3digo actual antes de reutilizarse.",
|
|
471
|
+
"- Al descubrir arquitectura o decisiones: `vault_save` (con `[[wikilinks]]`; el t\xEDtulo `Mapa - <proyecto>` actualiza el mapa que se inyecta al iniciar sesi\xF3n).",
|
|
472
|
+
"- `vault_related` trae conocimiento conectado sin releer archivos.",
|
|
470
473
|
CLAUDE_MD_END
|
|
471
474
|
].join("\n");
|
|
472
475
|
fs3.mkdirSync(path3.dirname(file), { recursive: true });
|
|
@@ -596,7 +599,7 @@ async function ensureReady(vault = getVault()) {
|
|
|
596
599
|
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(
|
|
597
600
|
"--path <dir>",
|
|
598
601
|
"ruta del vault Obsidian (existente o nuevo). Default: ./Alexandria con --project, ~/Alexandria en global"
|
|
599
|
-
).option("--auto", "configurar el uso autom\xE1tico en CLAUDE.md sin preguntar").option("--manual", "no tocar CLAUDE.md (config\xFAralo t\xFA)").option("--skills", "al final, recomendar e instalar skills seg\xFAn el contenido").option(
|
|
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(
|
|
600
603
|
"--agents <ids>",
|
|
601
604
|
`agentes de IA donde registrar el MCP: "all", "detected" o csv de ${AGENTS.map((a) => a.id).join(",")} (default: claude + detectados)`
|
|
602
605
|
).action(async (opts) => {
|
|
@@ -648,6 +651,10 @@ program.command("init").description("Crea/conecta la b\xF3veda e instala TODO: m
|
|
|
648
651
|
} else {
|
|
649
652
|
console.log(pc.dim(" Sin auto-configuraci\xF3n (act\xEDvala luego con: ale init --auto)"));
|
|
650
653
|
}
|
|
654
|
+
setConfigKey("protocol", opts.protocol !== false);
|
|
655
|
+
console.log(
|
|
656
|
+
opts.protocol !== false ? pc.green("\u2713 Protocolo Alexandria activo (plan_create \xB7 task_verify \xB7 lesson_extract) \u2014 ap\xE1galo con: ale config set protocol false") : pc.dim(" Protocolo desactivado (b\xF3veda cl\xE1sica) \u2014 act\xEDvalo con: ale config set protocol true")
|
|
657
|
+
);
|
|
651
658
|
if (isProject) {
|
|
652
659
|
const map = scanProject(vault, cwd);
|
|
653
660
|
if (map) console.log(pc.green(`\u2713 Proyecto escaneado \u2192 ${path4.relative(vault.root, map)} (mapa inicial)`));
|
|
@@ -661,6 +668,72 @@ program.command("init").description("Crea/conecta la b\xF3veda e instala TODO: m
|
|
|
661
668
|
console.log(pc.dim(' Prueba: ale search "algo" \xB7 ale graph \xB7 ale stats \xB7 ale agents\n'));
|
|
662
669
|
if (opts.skills) await runSkills({ yes: false, project: isProject });
|
|
663
670
|
});
|
|
671
|
+
program.command("plan").description("Crear un plan del Protocolo desde un archivo .md/.txt (en vez de escribirlo en la terminal)").argument("<file>", 'archivo con el plan (los checkboxes "- [ ]" se toman como Definition of Done)').option("--title <t>", "t\xEDtulo del plan (default: nombre del archivo o primer heading)").action(async (file, opts) => {
|
|
672
|
+
const { vault } = await ensureReady();
|
|
673
|
+
const abs = path4.resolve(file);
|
|
674
|
+
const raw = fs4.readFileSync(abs, "utf8");
|
|
675
|
+
const heading = raw.match(/^#\s+(.+)$/m)?.[1]?.trim();
|
|
676
|
+
const title = opts.title ?? heading ?? path4.basename(abs).replace(/\.(md|txt)$/i, "");
|
|
677
|
+
const dod = [...raw.matchAll(/^[-*]\s*\[[ x]\]\s*(.+)$/gim)].map((m) => m[1].trim());
|
|
678
|
+
const noteFile = createNote(vault.managed, {
|
|
679
|
+
title: title.startsWith("Plan - ") ? title : `Plan - ${title}`,
|
|
680
|
+
type: "plan",
|
|
681
|
+
status: "active",
|
|
682
|
+
tags: ["plan"],
|
|
683
|
+
content: raw.trim()
|
|
684
|
+
});
|
|
685
|
+
await VaultIndex.load(vault).refresh();
|
|
686
|
+
console.log(pc.green(`\u2713 Plan creado: ${path4.relative(vault.root, noteFile)}`));
|
|
687
|
+
console.log(pc.dim(` DoD detectada: ${dod.length} criterios${dod.length ? " \u2014 " + dod.slice(0, 3).join(" \xB7 ") + (dod.length > 3 ? " \u2026" : "") : ' (agrega checkboxes "- [ ]" para criterios verificables)'}`));
|
|
688
|
+
console.log(pc.dim(" El agente lo ver\xE1 como plan abierto al iniciar sesi\xF3n y lo retomar\xE1 con task_verify."));
|
|
689
|
+
});
|
|
690
|
+
program.command("audit").description("Auditor\xEDa del Protocolo: planes sin DoD, planes abiertos, fallos sin lecci\xF3n, notas sueltas").action(async () => {
|
|
691
|
+
const { vault, idx } = await ensureReady();
|
|
692
|
+
const notes = Object.values(idx.meta.notes).filter((n) => !n.rel.split("/").includes("archive"));
|
|
693
|
+
const plans = notes.filter((n) => n.type === "plan");
|
|
694
|
+
const linked = new Set(idx.meta.links.flatMap((l) => [l.from, l.to]));
|
|
695
|
+
console.log(pc.bold("\n\u{1F3DB}\uFE0F Auditor\xEDa del Protocolo Alexandria\n"));
|
|
696
|
+
const openPlans = plans.filter((p) => p.status === "active");
|
|
697
|
+
console.log(` Planes: ${plans.length} (${pc.yellow(`${openPlans.length} abiertos`)}, ${plans.filter((p) => p.status === "completed").length} completados, ${plans.filter((p) => p.status === "failed").length} fallidos)`);
|
|
698
|
+
for (const p of openPlans.slice(0, 8)) console.log(pc.dim(` \u25CB ${p.title}`));
|
|
699
|
+
const chunksByNote = /* @__PURE__ */ new Map();
|
|
700
|
+
for (const c of idx.meta.chunks) chunksByNote.set(c.note, (chunksByNote.get(c.note) ?? "") + "\n" + c.text);
|
|
701
|
+
const noDod = plans.filter((p) => !/\[[ x]\]/i.test(chunksByNote.get(p.rel) ?? ""));
|
|
702
|
+
if (noDod.length > 0) {
|
|
703
|
+
console.log(pc.yellow(` \u26A0 Planes sin Definition of Done: ${noDod.length}`));
|
|
704
|
+
for (const p of noDod.slice(0, 5)) console.log(pc.dim(` - ${p.title}`));
|
|
705
|
+
}
|
|
706
|
+
const fails = notes.filter((n) => n.type === "verification" && n.status === "failed");
|
|
707
|
+
const lessons = notes.filter((n) => n.type === "lesson");
|
|
708
|
+
console.log(` Verificaciones: ${notes.filter((n) => n.type === "verification").length} (${pc.red(`${fails.length} fallos`)}) \xB7 Lecciones: ${pc.green(String(lessons.length))}`);
|
|
709
|
+
if (fails.length > lessons.length) {
|
|
710
|
+
console.log(pc.yellow(` \u26A0 Hay m\xE1s fallos (${fails.length}) que lecciones (${lessons.length}) \u2014 fallos resueltos sin destilar aprendizaje.`));
|
|
711
|
+
}
|
|
712
|
+
const loose = notes.filter((n) => n.type !== "prompt" && n.type !== "session" && !linked.has(n.rel));
|
|
713
|
+
if (loose.length > 0) {
|
|
714
|
+
console.log(pc.yellow(` \u26A0 Notas sin conexiones (invisibles para vault_related): ${loose.length}`));
|
|
715
|
+
for (const n of loose.slice(0, 5)) console.log(pc.dim(` - ${n.title} \u2192 con\xE9ctala con vault_link o [[wikilinks]]`));
|
|
716
|
+
}
|
|
717
|
+
if (noDod.length === 0 && loose.length === 0 && fails.length <= lessons.length) {
|
|
718
|
+
console.log(pc.green("\n \u2713 B\xF3veda sana: planes con DoD, conocimiento conectado, fallos con lecci\xF3n."));
|
|
719
|
+
}
|
|
720
|
+
console.log();
|
|
721
|
+
});
|
|
722
|
+
program.command("config").description("Configuraci\xF3n de Alexandria (ej. protocol true/false)").argument("<accion>", "get | set").argument("<clave>", "ej. protocol").argument("[valor]", "para set: true/false o texto").action((accion, clave, valor) => {
|
|
723
|
+
const key = clave.replace(/^protocol\.enabled$/, "protocol");
|
|
724
|
+
if (accion === "get") {
|
|
725
|
+
const v = getConfigKey(key);
|
|
726
|
+
console.log(v === void 0 ? pc.dim(`${key} sin definir (default: ${key === "protocol" ? "true" : "\u2014"})`) : `${key} = ${JSON.stringify(v)}`);
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
if (accion === "set") {
|
|
730
|
+
const parsed = valor === "true" ? true : valor === "false" ? false : valor;
|
|
731
|
+
setConfigKey(key, parsed);
|
|
732
|
+
console.log(pc.green(`\u2713 ${key} = ${JSON.stringify(parsed)}`));
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
console.log(pc.yellow("Acci\xF3n inv\xE1lida: usa get o set"));
|
|
736
|
+
});
|
|
664
737
|
program.command("consolidate").description("Archiva prompts viejos sin reuso: salen del grafo y de la inyecci\xF3n, pero NUNCA se pierden \u2014 siguen buscables (contexto infinito)").option("--days <n>", "antig\xFCedad m\xEDnima en d\xEDas", "45").option("--dry", "solo mostrar qu\xE9 se archivar\xEDa").action(async (opts) => {
|
|
665
738
|
const { vault, idx } = await ensureReady();
|
|
666
739
|
const cutoff = Date.now() - (parseInt(opts.days, 10) || 45) * 864e5;
|
|
@@ -712,9 +785,12 @@ program.command("agents").description("Lista los agentes de IA soportados y regi
|
|
|
712
785
|
registerAgentsMcp(chosen, opts.project ? "project" : "global", process.cwd());
|
|
713
786
|
console.log(pc.dim("\n Reinicia el agente (o recarga sus MCP) para que tome el servidor.\n"));
|
|
714
787
|
});
|
|
715
|
-
program.command("add").description("Guardar una nota manualmente").argument("<title>", "t\xEDtulo").option("-c, --content <text>", "contenido markdown (o se lee de stdin)").option("-t, --tags <tags>", "tags separados por coma").action(async (title, opts) => {
|
|
788
|
+
program.command("add").description("Guardar una nota manualmente").argument("<title>", "t\xEDtulo").option("-c, --content <text>", "contenido markdown (o se lee de stdin)").option("-f, --file <path>", "leer el contenido desde un archivo .md/.txt del proyecto").option("-t, --tags <tags>", "tags separados por coma").action(async (title, opts) => {
|
|
716
789
|
const { vault } = await ensureReady();
|
|
717
790
|
let content = opts.content;
|
|
791
|
+
if (!content && opts.file) {
|
|
792
|
+
content = fs4.readFileSync(path4.resolve(opts.file), "utf8");
|
|
793
|
+
}
|
|
718
794
|
if (!content && !process.stdin.isTTY) {
|
|
719
795
|
content = fs4.readFileSync(0, "utf8");
|
|
720
796
|
}
|
|
@@ -789,6 +865,14 @@ program.command("stats").description("Estado de la b\xF3veda y tokens ahorrados"
|
|
|
789
865
|
console.log(` Notas: ${notes.length} ${pc.dim(JSON.stringify(byType))}`);
|
|
790
866
|
console.log(` Chunks indexados: ${idx.meta.chunks.length} \xB7 Conexiones: ${idx.meta.links.length}`);
|
|
791
867
|
console.log(` B\xFAsqueda sem\xE1ntica: ${idx.emb ? pc.green("activa") : pc.yellow("keyword-only (corre ale reindex con internet)")}`);
|
|
868
|
+
console.log(pc.bold("\n\u{1F3DB}\uFE0F Protocolo"));
|
|
869
|
+
const plans = notes.filter((n) => n.type === "plan");
|
|
870
|
+
const verifs = notes.filter((n) => n.type === "verification");
|
|
871
|
+
const lessons = notes.filter((n) => n.type === "lesson");
|
|
872
|
+
const reused = lessons.filter((n) => (n.hits ?? 1) > 1).length;
|
|
873
|
+
const passed = verifs.filter((n) => n.status === "completed").length;
|
|
874
|
+
console.log(` Planes: ${plans.length} (${plans.filter((p) => p.status === "active").length} abiertos) \xB7 Verificaciones: ${verifs.length}${verifs.length ? ` (${Math.round(passed / verifs.length * 100)}% \u2713)` : ""}`);
|
|
875
|
+
console.log(` Lecciones: ${lessons.length} (${reused} reutilizadas \u2014 cada reuso = debug que no se repiti\xF3)`);
|
|
792
876
|
console.log(pc.bold("\n\u{1F4B0} Ahorro estimado"));
|
|
793
877
|
console.log(` Inyecciones de contexto: ${s.injections} (${s.solutionCacheHits} con soluci\xF3n cacheada)`);
|
|
794
878
|
console.log(` Tokens inyectados: ~${s.injectedTokens.toLocaleString()}`);
|
package/dist/hooks/on-prompt.js
CHANGED
|
@@ -9,16 +9,16 @@ import {
|
|
|
9
9
|
} from "../chunk-DEDAOKAV.js";
|
|
10
10
|
import {
|
|
11
11
|
hybridSearch
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-BCLBZ7NX.js";
|
|
13
13
|
import {
|
|
14
14
|
resolveVault,
|
|
15
15
|
vaultExists
|
|
16
|
-
} from "../chunk-
|
|
17
|
-
import "../chunk-
|
|
16
|
+
} from "../chunk-DYCARGQR.js";
|
|
17
|
+
import "../chunk-MLA3KZPZ.js";
|
|
18
18
|
import {
|
|
19
19
|
createNote,
|
|
20
20
|
touchNote
|
|
21
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-XWR74BQ2.js";
|
|
22
22
|
import "../chunk-EDYBSJSS.js";
|
|
23
23
|
|
|
24
24
|
// src/hooks/on-prompt.ts
|
|
@@ -53,7 +53,7 @@ runHook(25e3, async (input) => {
|
|
|
53
53
|
const lines = [];
|
|
54
54
|
if (cached) {
|
|
55
55
|
lines.push(
|
|
56
|
-
`\u26A1 Ya resolviste algo casi id\xE9ntico antes (\xAB${cached.note.title}\xBB).
|
|
56
|
+
`\u26A1 Ya resolviste algo casi id\xE9ntico antes (\xAB${cached.note.title}\xBB). Parte de esa soluci\xF3n en vez de re-derivarla \u2014 valida que siga aplicando si el c\xF3digo cambi\xF3:
|
|
57
57
|
${truncate(cached.excerpts.join("\n"), 2e3)}`
|
|
58
58
|
);
|
|
59
59
|
}
|
|
@@ -8,13 +8,14 @@ import {
|
|
|
8
8
|
truncate
|
|
9
9
|
} from "../chunk-DEDAOKAV.js";
|
|
10
10
|
import {
|
|
11
|
+
protocolEnabled,
|
|
11
12
|
resolveVault,
|
|
12
13
|
vaultExists
|
|
13
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-DYCARGQR.js";
|
|
14
15
|
import {
|
|
15
16
|
VaultIndex
|
|
16
|
-
} from "../chunk-
|
|
17
|
-
import "../chunk-
|
|
17
|
+
} from "../chunk-MLA3KZPZ.js";
|
|
18
|
+
import "../chunk-XWR74BQ2.js";
|
|
18
19
|
import "../chunk-EDYBSJSS.js";
|
|
19
20
|
|
|
20
21
|
// src/hooks/on-session-start.ts
|
|
@@ -31,6 +32,14 @@ runHook(15e3, async (input) => {
|
|
|
31
32
|
if (notes.length === 0) return;
|
|
32
33
|
const proj = projectName(input.cwd);
|
|
33
34
|
const parts = [];
|
|
35
|
+
if (protocolEnabled()) {
|
|
36
|
+
const openPlans = notes.filter((n) => n.type === "plan" && n.status === "active");
|
|
37
|
+
parts.push(
|
|
38
|
+
`## Protocolo Alexandria (activo)
|
|
39
|
+
El protocolo es PALANCA, no l\xEDmite: \xFAsalo para rendir m\xE1s con menos tokens, nunca como burocracia. Tareas simples \u2192 responde directo, sin ceremonia. Tareas no triviales \u2192 ciclo con las tools MCP: 1) plan_create (objetivo + Definition of Done) \u2192 2) ejecuta con toda tu capacidad \u2192 3) task_verify con evidencia real (tests/build \u2014 la evidencia elimina errores, no te frena) \u2192 si algo falla, vault_search por lecciones ANTES de re-debuggear (conocimiento previo = tokens gratis) \u2192 4) lesson_extract si resolviste algo no obvio. Reutiliza lo cacheado con criterio: valida que siga aplicando si el c\xF3digo cambi\xF3.` + (openPlans.length > 0 ? `
|
|
40
|
+
**Planes abiertos:** ${openPlans.map((p) => p.title).join(" \xB7 ")} \u2014 ret\xF3malos, no dupliques.` : "")
|
|
41
|
+
);
|
|
42
|
+
}
|
|
34
43
|
const map = notes.find(
|
|
35
44
|
(n) => (n.type === "map" || n.title.toLowerCase().startsWith("mapa - ")) && n.title.toLowerCase().includes(proj.toLowerCase())
|
|
36
45
|
);
|
package/dist/hooks/on-stop.js
CHANGED
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
ensureVaultStructure,
|
|
9
9
|
resolveVault,
|
|
10
10
|
vaultExists
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-DYCARGQR.js";
|
|
12
12
|
import {
|
|
13
13
|
appendToNote
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-XWR74BQ2.js";
|
|
15
15
|
|
|
16
16
|
// src/hooks/on-stop.ts
|
|
17
17
|
import fs from "fs";
|
package/dist/mcp/server.js
CHANGED
|
@@ -4,19 +4,20 @@ import {
|
|
|
4
4
|
} from "../chunk-KHTYRYDR.js";
|
|
5
5
|
import {
|
|
6
6
|
hybridSearch
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-BCLBZ7NX.js";
|
|
8
8
|
import {
|
|
9
9
|
ensureVaultStructure,
|
|
10
10
|
resolveVault
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-DYCARGQR.js";
|
|
12
12
|
import {
|
|
13
13
|
VaultIndex
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-MLA3KZPZ.js";
|
|
15
15
|
import {
|
|
16
16
|
createNote,
|
|
17
|
+
setNoteStatus,
|
|
17
18
|
slugify,
|
|
18
19
|
upsertNote
|
|
19
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-XWR74BQ2.js";
|
|
20
21
|
import "../chunk-EDYBSJSS.js";
|
|
21
22
|
|
|
22
23
|
// src/mcp/server.ts
|
|
@@ -28,6 +29,15 @@ import { z } from "zod";
|
|
|
28
29
|
var vault = resolveVault({ cwd: process.cwd() });
|
|
29
30
|
var server = new McpServer({ name: "alexandria", version: pkgVersion() });
|
|
30
31
|
var text = (t) => ({ content: [{ type: "text", text: t }] });
|
|
32
|
+
function findMap(idx) {
|
|
33
|
+
return Object.values(idx.meta.notes).find((n) => n.type === "map" || n.title.startsWith("Mapa - "));
|
|
34
|
+
}
|
|
35
|
+
function findByTitle(idx, t) {
|
|
36
|
+
const lower = t.toLowerCase();
|
|
37
|
+
return Object.values(idx.meta.notes).find(
|
|
38
|
+
(n) => n.title.toLowerCase() === lower || n.rel.toLowerCase() === lower
|
|
39
|
+
);
|
|
40
|
+
}
|
|
31
41
|
server.tool(
|
|
32
42
|
"vault_search",
|
|
33
43
|
"Busca conocimiento en la b\xF3veda local (b\xFAsqueda sem\xE1ntica + keyword). \xDAsala ANTES de explorar c\xF3digo o re-derivar contexto: si la b\xF3veda ya lo sabe, ahorras tokens.",
|
|
@@ -118,4 +128,122 @@ server.tool(
|
|
|
118
128
|
return text(`Conectado: \xAB${a.title}\xBB \u2192 [[${b.title}]]`);
|
|
119
129
|
}
|
|
120
130
|
);
|
|
131
|
+
server.tool(
|
|
132
|
+
"plan_create",
|
|
133
|
+
'PROTOCOLO paso 1 (solo tareas NO triviales \u2014 las simples resp\xF3ndelas directo, sin ceremonia): crea el plan con Definition of Done (criterios verificables de "terminado") y tareas numeradas. Verifica cada tarea con task_verify. El plan enfoca tu capacidad, no la limita; y deja huella reutilizable.',
|
|
134
|
+
{
|
|
135
|
+
title: z.string().describe('Nombre corto del objetivo, ej. "Login con Google"'),
|
|
136
|
+
goal: z.string().describe("Qu\xE9 se quiere lograr, en una o dos frases"),
|
|
137
|
+
dod: z.array(z.string()).describe("Definition of Done: criterios verificables de \xE9xito"),
|
|
138
|
+
tasks: z.array(z.string()).describe("Tareas numeradas, chicas y verificables")
|
|
139
|
+
},
|
|
140
|
+
async ({ title, goal, dod, tasks }) => {
|
|
141
|
+
ensureVaultStructure(vault);
|
|
142
|
+
const idx = VaultIndex.load(vault);
|
|
143
|
+
const map = findMap(idx);
|
|
144
|
+
const content = [
|
|
145
|
+
`## Objetivo
|
|
146
|
+
${goal}`,
|
|
147
|
+
`## Definition of Done
|
|
148
|
+
${dod.map((d) => `- [ ] ${d}`).join("\n")}`,
|
|
149
|
+
`## Tareas
|
|
150
|
+
${tasks.map((t, i) => `${i + 1}. ${t}`).join("\n")}`,
|
|
151
|
+
map ? `Proyecto: [[${map.title}]]` : ""
|
|
152
|
+
].join("\n\n");
|
|
153
|
+
const file = createNote(vault.managed, {
|
|
154
|
+
title: `Plan - ${title}`,
|
|
155
|
+
type: "plan",
|
|
156
|
+
status: "active",
|
|
157
|
+
tags: ["plan"],
|
|
158
|
+
dir: "notes",
|
|
159
|
+
content
|
|
160
|
+
});
|
|
161
|
+
await VaultIndex.load(vault).refresh().catch(() => {
|
|
162
|
+
});
|
|
163
|
+
return text(
|
|
164
|
+
`Plan guardado en ${path.relative(vault.root, file)}. Ejecuta las tareas UNA por una; tras cada una llama task_verify con evidencia real (salida de tests/build). Al terminar todo, llama lesson_extract.`
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
server.tool(
|
|
169
|
+
"task_verify",
|
|
170
|
+
"PROTOCOLO paso 2: registra el resultado VERIFICADO de una tarea con evidencia real (salida de tests, build, curl \u2014 no lo des por hecho sin correrlo). Guarda el veredicto compacto; si fall\xF3, busca lecciones previas con vault_search antes de improvisar.",
|
|
171
|
+
{
|
|
172
|
+
plan: z.string().describe('T\xEDtulo del plan al que pertenece (ej. "Plan - Login con Google")'),
|
|
173
|
+
task: z.string().describe("Qu\xE9 tarea se verific\xF3"),
|
|
174
|
+
passed: z.boolean().describe("true si la evidencia confirma que funciona"),
|
|
175
|
+
evidence: z.string().describe('Evidencia compacta: "npm test \u2192 12/12 passed", c\xF3digo de error, etc.'),
|
|
176
|
+
completes_plan: z.boolean().optional().describe("true si esta era la \xFAltima tarea y el plan queda completado")
|
|
177
|
+
},
|
|
178
|
+
async ({ plan, task, passed, evidence, completes_plan }) => {
|
|
179
|
+
ensureVaultStructure(vault);
|
|
180
|
+
const idx = VaultIndex.load(vault);
|
|
181
|
+
const planNote = findByTitle(idx, plan);
|
|
182
|
+
const file = createNote(vault.managed, {
|
|
183
|
+
title: `${passed ? "OK" : "FALLO"} - ${task.slice(0, 60)}`,
|
|
184
|
+
type: "verification",
|
|
185
|
+
status: passed ? "completed" : "failed",
|
|
186
|
+
tags: ["verificacion"],
|
|
187
|
+
dir: "notes",
|
|
188
|
+
content: `**Tarea:** ${task}
|
|
189
|
+
|
|
190
|
+
**Veredicto:** ${passed ? "\u2705 pas\xF3" : "\u274C fall\xF3"}
|
|
191
|
+
|
|
192
|
+
**Evidencia:**
|
|
193
|
+
\`\`\`
|
|
194
|
+
${evidence.slice(0, 1500)}
|
|
195
|
+
\`\`\`
|
|
196
|
+
|
|
197
|
+
${planNote ? `Plan: [[${planNote.title}]]` : ""}`
|
|
198
|
+
});
|
|
199
|
+
if (completes_plan && planNote) {
|
|
200
|
+
try {
|
|
201
|
+
setNoteStatus(path.join(vault.root, planNote.rel), passed ? "completed" : "failed");
|
|
202
|
+
} catch {
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
await VaultIndex.load(vault).refresh().catch(() => {
|
|
206
|
+
});
|
|
207
|
+
if (!passed) {
|
|
208
|
+
const lessons = await hybridSearch(vault, `${task} ${evidence.slice(0, 200)}`, 3);
|
|
209
|
+
const useful = lessons.filter((l) => l.note.type === "lesson" || l.note.type === "solution");
|
|
210
|
+
if (useful.length > 0) {
|
|
211
|
+
return text(
|
|
212
|
+
`Fallo registrado (${path.relative(vault.root, file)}). LECCIONES PREVIAS que podr\xEDan aplicar \u2014 \xFAsalas antes de improvisar:
|
|
213
|
+
` + useful.map((l) => `- \xAB${l.note.title}\xBB: ${l.excerpts[0]?.slice(0, 300) ?? ""}`).join("\n")
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
return text(`Fallo registrado. Sin lecciones previas para esto \u2014 cuando lo resuelvas, guarda la lecci\xF3n con lesson_extract.`);
|
|
217
|
+
}
|
|
218
|
+
return text(`Verificaci\xF3n guardada${completes_plan ? " y plan marcado como completado" : ""}. ${completes_plan ? "Cierra con lesson_extract si hubo aprendizaje." : "Siguiente tarea."}`);
|
|
219
|
+
}
|
|
220
|
+
);
|
|
221
|
+
server.tool(
|
|
222
|
+
"lesson_extract",
|
|
223
|
+
"PROTOCOLO paso 3: al resolver un error o terminar un plan, destila LA lecci\xF3n (qu\xE9 fall\xF3/funcion\xF3 y c\xF3mo evitarlo/repetirlo). 200 tokens hoy ahorran 20,000 de re-debug ma\xF1ana. Se inyecta autom\xE1ticamente cuando el problema reaparezca.",
|
|
224
|
+
{
|
|
225
|
+
title: z.string().describe('Lecci\xF3n en una frase, ej. "GOOGLE_CLIENT_SECRET debe ir en .env"'),
|
|
226
|
+
lesson: z.string().describe("Qu\xE9 pas\xF3, causa ra\xEDz, y c\xF3mo aplicarla la pr\xF3xima vez"),
|
|
227
|
+
links: z.array(z.string()).optional().describe("T\xEDtulos de notas relacionadas (plan, feature, etc.)")
|
|
228
|
+
},
|
|
229
|
+
async ({ title, lesson, links }) => {
|
|
230
|
+
ensureVaultStructure(vault);
|
|
231
|
+
const idx = VaultIndex.load(vault);
|
|
232
|
+
const map = findMap(idx);
|
|
233
|
+
const wikilinks = (links ?? []).map((l) => findByTitle(idx, l)).filter((n) => Boolean(n)).map((n) => `[[${n.title}]]`);
|
|
234
|
+
if (map) wikilinks.push(`[[${map.title}]]`);
|
|
235
|
+
const file = createNote(vault.managed, {
|
|
236
|
+
title: `Lecci\xF3n - ${title.slice(0, 70)}`,
|
|
237
|
+
type: "lesson",
|
|
238
|
+
tags: ["leccion"],
|
|
239
|
+
dir: "notes",
|
|
240
|
+
content: `${lesson}
|
|
241
|
+
|
|
242
|
+
${wikilinks.length ? `Relacionado: ${[...new Set(wikilinks)].join(" \xB7 ")}` : ""}`
|
|
243
|
+
});
|
|
244
|
+
await VaultIndex.load(vault).refresh().catch(() => {
|
|
245
|
+
});
|
|
246
|
+
return text(`Lecci\xF3n guardada en ${path.relative(vault.root, file)} \u2014 se inyectar\xE1 autom\xE1ticamente cuando el tema reaparezca.`);
|
|
247
|
+
}
|
|
248
|
+
);
|
|
121
249
|
await server.connect(new StdioServerTransport());
|
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
renderGraphHtml,
|
|
5
5
|
serveGraph,
|
|
6
6
|
writeStaticGraph
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-RLVCH6CZ.js";
|
|
8
|
+
import "./chunk-MLA3KZPZ.js";
|
|
9
|
+
import "./chunk-XWR74BQ2.js";
|
|
10
10
|
import "./chunk-EDYBSJSS.js";
|
|
11
11
|
export {
|
|
12
12
|
buildGraphData,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ureck/alexandria",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
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",
|