amalfa 1.0.2 → 1.0.3

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.
Files changed (42) hide show
  1. package/package.json +1 -1
  2. package/src/cli.ts +1 -1
  3. package/docs/AGENT-METADATA-PATTERNS.md +0 -1021
  4. package/docs/AGENT_PROTOCOLS.md +0 -28
  5. package/docs/ARCHITECTURAL_OVERVIEW.md +0 -123
  6. package/docs/BENTO_BOXING_DEPRECATION.md +0 -281
  7. package/docs/Bun-SQLite.html +0 -464
  8. package/docs/COMMIT_GUIDELINES.md +0 -367
  9. package/docs/CONFIG_E2E_VALIDATION.md +0 -147
  10. package/docs/CONFIG_UNIFICATION.md +0 -187
  11. package/docs/CONFIG_VALIDATION.md +0 -103
  12. package/docs/DEVELOPER_ONBOARDING.md +0 -36
  13. package/docs/Graph and Vector Database Best Practices.md +0 -214
  14. package/docs/LEGACY_DEPRECATION.md +0 -174
  15. package/docs/MCP_SETUP.md +0 -317
  16. package/docs/PERFORMANCE_BASELINES.md +0 -88
  17. package/docs/QUICK_START_MCP.md +0 -168
  18. package/docs/REPOSITORY_CLEANUP_SUMMARY.md +0 -261
  19. package/docs/SESSION-2026-01-06-METADATA-PATTERNS.md +0 -346
  20. package/docs/SETUP.md +0 -464
  21. package/docs/SETUP_COMPLETE.md +0 -464
  22. package/docs/VISION-AGENT-LEARNING.md +0 -1242
  23. package/docs/_current-config-status.md +0 -93
  24. package/docs/edge-generation-methods.md +0 -57
  25. package/docs/elevator-pitch.md +0 -118
  26. package/docs/graph-and-vector-database-playbook.html +0 -480
  27. package/docs/hardened-sqlite.md +0 -85
  28. package/docs/headless-knowledge-management.md +0 -79
  29. package/docs/john-kaye-flux-prompt.md +0 -46
  30. package/docs/keyboard-shortcuts.md +0 -80
  31. package/docs/opinion-proceed-pattern.md +0 -29
  32. package/docs/polyvis-nodes-edges-schema.md +0 -77
  33. package/docs/protocols/lab-protocol.md +0 -30
  34. package/docs/reaction-iquest-loop-coder.md +0 -46
  35. package/docs/services.md +0 -60
  36. package/docs/sqlite-wal-readonly-trap.md +0 -228
  37. package/docs/strategy/css-architecture.md +0 -40
  38. package/docs/test-document-cycle.md +0 -83
  39. package/docs/test_lifecycle_E2E.md +0 -4
  40. package/docs/the-bicameral-graph.md +0 -83
  41. package/docs/user-guide.md +0 -70
  42. package/docs/vision-helper.md +0 -53
package/docs/MCP_SETUP.md DELETED
@@ -1,317 +0,0 @@
1
- # AMALFA MCP Server Setup
2
-
3
- **Guide to configuring AMALFA as an MCP server for Claude Desktop, Cursor, Windsurf, and other MCP clients.**
4
-
5
- ---
6
-
7
- ## Prerequisites
8
-
9
- 1. **Bun installed** (`v1.0+`)
10
- 2. **AMALFA repository cloned** and dependencies installed:
11
- ```bash
12
- git clone https://github.com/pjsvis/amalfa.git
13
- cd amalfa
14
- bun install
15
- ```
16
- 3. **Database initialized** (see Data Preparation below)
17
-
18
- ---
19
-
20
- ## Step 1: Prepare Your Data
21
-
22
- Before starting the MCP server, you need to:
23
-
24
- 1. **Configure sources** in `amalfa.config.json`:
25
- ```json
26
- {
27
- "sources": ["./docs", "./playbooks"],
28
- "database": ".amalfa/resonance.db",
29
- "embeddings": {
30
- "model": "BAAI/bge-small-en-v1.5",
31
- "dimensions": 384
32
- }
33
- }
34
- ```
35
-
36
- 2. **Ingest your markdown documents**:
37
- ```bash
38
- bun run scripts/cli/ingest.ts
39
- ```
40
-
41
- This will:
42
- - Parse all markdown files from your source directories
43
- - Generate embeddings (first run downloads the model to `.amalfa/cache/`)
44
- - Create the SQLite database at `.amalfa/resonance.db`
45
-
46
- ---
47
-
48
- ## Step 2: Generate MCP Configuration
49
-
50
- Run the setup script to generate your machine-specific config:
51
-
52
- ```bash
53
- bun run scripts/setup_mcp.ts
54
- ```
55
-
56
- This will output configuration JSON like:
57
-
58
- ```json
59
- {
60
- "mcpServers": {
61
- "amalfa": {
62
- "command": "bun",
63
- "args": [
64
- "run",
65
- "/absolute/path/to/amalfa/src/mcp/index.ts"
66
- ],
67
- "env": {
68
- "PATH": "..."
69
- }
70
- }
71
- }
72
- }
73
- ```
74
-
75
- **Important:** The path is absolute and machine-specific. If you move the amalfa folder, run this script again.
76
-
77
- ---
78
-
79
- ## Step 3: Configure Your MCP Client
80
-
81
- ### Claude Desktop (macOS)
82
-
83
- 1. **Open Claude Desktop config**:
84
- ```bash
85
- open ~/Library/Application\ Support/Claude/claude_desktop_config.json
86
- ```
87
-
88
- Or create it if it doesn't exist:
89
- ```bash
90
- mkdir -p ~/Library/Application\ Support/Claude
91
- touch ~/Library/Application\ Support/Claude/claude_desktop_config.json
92
- ```
93
-
94
- 2. **Add the AMALFA server** to the `mcpServers` section:
95
- ```json
96
- {
97
- "mcpServers": {
98
- "amalfa": {
99
- "command": "bun",
100
- "args": [
101
- "run",
102
- "/Users/yourusername/path/to/amalfa/src/mcp/index.ts"
103
- ],
104
- "env": {
105
- "PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
106
- }
107
- }
108
- }
109
- }
110
- ```
111
-
112
- **Note:** Use the exact JSON output from Step 2.
113
-
114
- 3. **Restart Claude Desktop**
115
-
116
- 4. **Verify connection**: In Claude Desktop, check the MCP icon/status—you should see "amalfa" listed as a connected server.
117
-
118
- ### Cursor / Windsurf
119
-
120
- Check your IDE's MCP configuration documentation. The setup is similar—add the JSON block to the appropriate config file.
121
-
122
- ---
123
-
124
- ## Step 4: Test the Connection
125
-
126
- ### From Claude Desktop
127
-
128
- Ask Claude:
129
-
130
- ```
131
- Search my knowledge base for "embeddings"
132
- ```
133
-
134
- Claude should use the `search_documents` tool and return results from your markdown files.
135
-
136
- ### From Command Line (Debug Mode)
137
-
138
- You can test the MCP server directly:
139
-
140
- ```bash
141
- bun run src/mcp/index.ts
142
- ```
143
-
144
- This starts the server in stdio mode. It will log to `.mcp.log`.
145
-
146
- Check the logs:
147
- ```bash
148
- tail -f .amalfa/.mcp.log
149
- ```
150
-
151
- ---
152
-
153
- ## Available MCP Tools
154
-
155
- Once connected, your AI agent can use these tools:
156
-
157
- ### 1. `search_documents`
158
- **Description:** Semantic search over your knowledge base
159
- **Parameters:**
160
- - `query` (string, required): Search query
161
- - `limit` (number, optional): Max results (default: 20)
162
-
163
- **Example:**
164
- ```
165
- Search for documents about "vector embeddings"
166
- ```
167
-
168
- ### 2. `read_node_content`
169
- **Description:** Read full markdown content of a specific document
170
- **Parameters:**
171
- - `id` (string, required): Document ID from search results
172
-
173
- **Example:**
174
- ```
175
- Read the full content of document "docs/embeddings.md"
176
- ```
177
-
178
- ### 3. `explore_links`
179
- **Description:** Find related documents (graph traversal)
180
- **Parameters:**
181
- - `id` (string, required): Starting document ID
182
- - `relation` (string, optional): Relationship type
183
-
184
- **Example:**
185
- ```
186
- Show me documents related to "playbooks/vector-search.md"
187
- ```
188
-
189
- ### 4. `list_directory_structure`
190
- **Description:** List all documents in the knowledge base
191
- **Parameters:** None
192
-
193
- **Example:**
194
- ```
195
- List all documents in my knowledge base
196
- ```
197
-
198
- ### 5. `inject_tags` (Experimental)
199
- **Description:** Add semantic tags to a document
200
- **Parameters:**
201
- - `file_path` (string, required): Path to markdown file
202
- - `tags` (array, required): List of tags to add
203
-
204
- ---
205
-
206
- ## Troubleshooting
207
-
208
- ### "Server not connecting"
209
-
210
- 1. **Check Bun is in PATH**:
211
- ```bash
212
- which bun
213
- ```
214
-
215
- 2. **Verify database exists**:
216
- ```bash
217
- ls -la .amalfa/resonance.db
218
- ```
219
-
220
- If missing, run ingestion again:
221
- ```bash
222
- bun run scripts/cli/ingest.ts
223
- ```
224
-
225
- 3. **Check server logs**:
226
- ```bash
227
- tail -n 50 .amalfa/.mcp.log
228
- ```
229
-
230
- ### "No results from search"
231
-
232
- 1. **Verify database has data**:
233
- ```bash
234
- sqlite3 .amalfa/resonance.db "SELECT COUNT(*) FROM nodes;"
235
- ```
236
-
237
- Should return a number > 0.
238
-
239
- 2. **Check embeddings**:
240
- ```bash
241
- sqlite3 .amalfa/resonance.db "SELECT COUNT(*) FROM node_embeddings;"
242
- ```
243
-
244
- 3. **Re-run ingestion** if counts are 0:
245
- ```bash
246
- bun run scripts/cli/ingest.ts
247
- ```
248
-
249
- ### "Error: ENOENT: no such file or directory"
250
-
251
- The absolute path in your config is incorrect. Re-run:
252
- ```bash
253
- bun run scripts/setup_mcp.ts
254
- ```
255
-
256
- And update your MCP client config with the new path.
257
-
258
- ---
259
-
260
- ## Advanced Configuration
261
-
262
- ### Custom Database Path
263
-
264
- Edit `amalfa.config.json`:
265
- ```json
266
- {
267
- "database": ".amalfa/my-custom.db"
268
- }
269
- ```
270
-
271
- Then re-ingest and restart the MCP server.
272
-
273
- ### Multiple Source Directories
274
-
275
- ```json
276
- {
277
- "sources": [
278
- "./docs",
279
- "./playbooks",
280
- "../other-project/docs"
281
- ]
282
- }
283
- ```
284
-
285
- ### Environment Variables
286
-
287
- You can override config with environment variables in your MCP client config:
288
-
289
- ```json
290
- {
291
- "mcpServers": {
292
- "amalfa": {
293
- "command": "bun",
294
- "args": ["run", "/path/to/amalfa/src/mcp/index.ts"],
295
- "env": {
296
- "AMALFA_DB": ".amalfa/custom.db",
297
- "PATH": "..."
298
- }
299
- }
300
- }
301
- }
302
- ```
303
-
304
- ---
305
-
306
- ## Next Steps
307
-
308
- - **[User Guide](./user-guide.md)** - Learn how to structure your markdown for best results
309
- - **[VISION-AGENT-LEARNING.md](./VISION-AGENT-LEARNING.md)** - Understand the brief-debrief-playbook pattern
310
- - **[Configuration Status](./docs/_current-config-status.md)** - Configuration reference
311
-
312
- ---
313
-
314
- ## Support
315
-
316
- - **Issues:** https://github.com/pjsvis/amalfa/issues
317
- - **Discussions:** https://github.com/pjsvis/amalfa/discussions
@@ -1,88 +0,0 @@
1
- # Performance Baselines & Benchmarks
2
-
3
- > **Last Updated:** 2025-12-16
4
- > **Device:** Apple Silicon (M-series)
5
- > **Node/Bun:** Bun v1.3.4+
6
-
7
- ## 1. Memory Footprint (Daemon)
8
- The Daemon run-time consists of the `Core Kernel`, `VectorEngine (WASM)`, and `Data Graph`.
9
-
10
- | Component | RAM Usage (RSS) | Scaling Nature | Notes |
11
- | :--- | :--- | :--- | :--- |
12
- | **AI Model (fastembed)** | **~252 MB** | 🛑 **Fixed** | Unavoidable one-time cost for local embedding. |
13
- | **Daemon Runtime** | **~60 MB** | 🛑 **Fixed** | Bun runtime + SQLite + Kernel overhead. |
14
- | **Graph Structure** | **~14 kB / node** | 🟢 **Variable** | Graphology in-memory graph representation. |
15
- | **Raw Data** | **~9 kB / node** | 🟢 **Variable** | Text content and metadata objects. |
16
- | **Vectors** | **~2 kB / node** | 🟢 **Variable** | Float32Arrays and normalized buffers. |
17
-
18
- ### Total Daemon Footprint
19
- - **Empty State**: ~310 MB
20
- - **Current State (429 nodes)**: ~320 MB
21
- - **PROJECTED (10k nodes)**: ~560 MB
22
-
23
- ## 2. Storage Footprint (Disk)
24
- Benchmarks from `public/resonance.db`.
25
-
26
- | Metric | Size / Count | Notes |
27
- | :--- | :--- | :--- |
28
- | **DB File Size** | 6.09 MB | SQLite WAL mode enabled. |
29
- | **Vector Data** | 1.42 MB | Blob storage. |
30
- | **Text Content** | 1.00 MB | Raw text in `content` column. |
31
- | **Node Count** | 429 | Including Experience & Persona domains. |
32
-
33
- ## 3. How to Measure
34
- ### Memory
35
- 1. Ensure `graphology` is installed (temporarily): `bun add graphology`.
36
- 2. Uncomment the graphology section in `scripts/profile_memory.ts`.
37
- 3. Run: `bun run scripts/profile_memory.ts`.
38
- 4. Revert: `bun remove graphology`.
39
-
40
- ### Disk / DB Stats
41
- 1. Run: `bun run scripts/assess_db_weight.ts`.
42
-
43
- ## 4. Ingestion Baselines (Comparison)
44
-
45
- > **Baseline Source:** `_misc/ingestion-baseline.json` (2025-12-11)
46
-
47
- | Metric | Baseline (Dec 11) | Current (Dec 16) | Delta | Notes |
48
- | :--- | :--- | :--- | :--- | :--- |
49
- | **Persona Nodes** | 185 | 185 | **0** | Stable. Core lexicon. |
50
- | **Experience Nodes** | 128 | 244 | **+116** | Significant growth (new sessions/debriefs). |
51
- | **Total Nodes** | 313 | 429 | **+116** | ~37% Growth. |
52
- | **Total Edges** | 498 | 631 | **+133** | ~27% Growth. |
53
- | **Total Vectors** | 289 | 242 | **-47** | 📉 **Intentional Optimization** |
54
-
55
- ### Insights
56
- - **Vector Efficiency**: Despite node growth (+37%), vector count dropped (-16%). This reflects the **"Narrative Vector Strategy"**, where only high-value content (Concepts, Playbooks) is vectorized, while structural nodes (Logs, raw fragments) are skipped.
57
- - **Graph Connectivity**: Edge growth (+27%) tracks closely with node growth, maintaining decent density.
58
-
59
- ## 5. Speed Benchmarks (Dec 16)
60
-
61
- > **Environment**: Apple Silicon (M-series) | Bun v1.3.4
62
-
63
- | Operation | Latency | Notes |
64
- | :--- | :--- | :--- |
65
- | **Model Load (Cold)** | **~192 ms** | One-time initialization cost. |
66
- | **Vector Search** | **~71 ms** | Avg of 10 runs (Top-5 search). |
67
- | **SQL Insert (Raw)** | **~0.001 ms/row** | Batch prepared statement (Buffered). |
68
- | **SQL Insert (ORM)** | **~0.012 ms/row** | Drizzle ORM overhead (~12x slower than raw). |
69
-
70
- ## 6. Vector Inclusion Rules (Audit)
71
-
72
- > **Policy:** "Everything in the folders noted in the settings file should be in the vector store."
73
-
74
- **Audit Results (Dec 16):**
75
-
76
- | Domain | Source | Status | Notes |
77
- | :--- | :--- | :--- | :--- |
78
- | **Experience** | `debriefs/` | ✅ **100% Vectorized** | Narrative content. |
79
- | **Experience** | `playbooks/` | ✅ **100% Vectorized** | Procedural knowledge. |
80
- | **Experience** | `briefs/` | ✅ **100% Vectorized** | Context setting. |
81
- | **Experience** | `docs/` | ✅ **100% Vectorized** | Project documentation. |
82
- | **Persona** | `lexicon.json` | ⚪ **Excluded** | *Optimization*: Concepts matched via Keywords/Graph. |
83
- | **Persona** | `cda.json` | ⚪ **Excluded** | *Optimization*: Directives matched via Keywords/Graph. |
84
- | **Experience** | `test-artifacts` | ⚪ **Excluded** | *Transient*: `test-doc-1` & `test-doc-2` (from test scripts). |
85
-
86
- **Conclusion:**
87
- The logic complies with the rule. All folder-based narrative content is vectorized. File-based structured data (Persona) is excluded to save memory, as it is efficiently retrievable via exact graph traversal. The only un-vectorized `document` nodes are confirmed test artifacts.
88
-
@@ -1,168 +0,0 @@
1
- # AMALFA MCP Quick Start
2
-
3
- **Get AMALFA running with Claude Desktop in 5 minutes.**
4
-
5
- ---
6
-
7
- ## Current Status
8
-
9
- ✅ **Database exists**: `.amalfa/resonance.db` (2.4 MB)
10
- ✅ **Dependencies installed**: `node_modules/` present
11
- ✅ **MCP server ready**: `src/mcp/index.ts`
12
-
13
- ---
14
-
15
- ## Quick Setup (Claude Desktop)
16
-
17
- ### 1. Generate your configuration
18
-
19
- ```bash
20
- cd /Users/petersmith/Documents/GitHub/amalfa
21
- bun run scripts/setup_mcp.ts
22
- ```
23
-
24
- Copy the JSON output (will look like this):
25
-
26
- ```json
27
- {
28
- "mcpServers": {
29
- "amalfa": {
30
- "command": "bun",
31
- "args": [
32
- "run",
33
- "/Users/petersmith/Documents/GitHub/amalfa/src/mcp/index.ts"
34
- ],
35
- "env": {
36
- "PATH": "..."
37
- }
38
- }
39
- }
40
- }
41
- ```
42
-
43
- ### 2. Add to Claude Desktop
44
-
45
- **Open config file:**
46
- ```bash
47
- open ~/Library/Application\ Support/Claude/claude_desktop_config.json
48
- ```
49
-
50
- **Paste the JSON** from step 1. If the file already has content, merge the `amalfa` entry into the existing `mcpServers` object.
51
-
52
- **Example final config:**
53
- ```json
54
- {
55
- "mcpServers": {
56
- "amalfa": {
57
- "command": "bun",
58
- "args": [
59
- "run",
60
- "/Users/petersmith/Documents/GitHub/amalfa/src/mcp/index.ts"
61
- ],
62
- "env": {
63
- "PATH": "/usr/local/bin:/usr/bin:/bin"
64
- }
65
- }
66
- }
67
- }
68
- ```
69
-
70
- ### 3. Restart Claude Desktop
71
-
72
- Quit and relaunch Claude Desktop completely (Cmd+Q, then reopen).
73
-
74
- ### 4. Test it
75
-
76
- In Claude Desktop, ask:
77
-
78
- ```
79
- Search my knowledge base for "embeddings"
80
- ```
81
-
82
- Claude should invoke the `search_documents` tool and return results from your markdown files.
83
-
84
- ---
85
-
86
- ## What's in Your Database?
87
-
88
- Check what's indexed:
89
-
90
- ```bash
91
- sqlite3 .amalfa/resonance.db "SELECT COUNT(*) FROM nodes;"
92
- sqlite3 .amalfa/resonance.db "SELECT COUNT(*) FROM node_embeddings;"
93
- sqlite3 .amalfa/resonance.db "SELECT id, type FROM nodes LIMIT 10;"
94
- ```
95
-
96
- ---
97
-
98
- ## Troubleshooting
99
-
100
- ### "Server not connecting"
101
-
102
- 1. **Verify Bun path in Claude config** matches your system:
103
- ```bash
104
- which bun
105
- ```
106
-
107
- 2. **Check server logs**:
108
- ```bash
109
- tail -f .amalfa/.mcp.log
110
- ```
111
-
112
- 3. **Test manually**:
113
- ```bash
114
- bun run src/mcp/index.ts
115
- ```
116
- Press Ctrl+C to stop. Check for errors in the startup output.
117
-
118
- ### "No results from search"
119
-
120
- **Option A: Re-ingest from current config**
121
-
122
- Your `amalfa.config.json` currently points to:
123
- ```json
124
- {
125
- "sources": ["../polyvis/docs", "../polyvis/playbooks"]
126
- }
127
- ```
128
-
129
- If you want to index **local** amalfa docs instead:
130
-
131
- 1. **Edit** `amalfa.config.json`:
132
- ```json
133
- {
134
- "sources": ["./docs", "./playbooks"],
135
- "database": ".amalfa/resonance.db"
136
- }
137
- ```
138
-
139
- 2. **Re-ingest**:
140
- ```bash
141
- bun run scripts/cli/ingest.ts
142
- ```
143
-
144
- **Option B: Keep polyvis sources**
145
-
146
- If you want to keep searching polyvis content, ensure `../polyvis` exists and contains the docs/playbooks folders.
147
-
148
- ---
149
-
150
- ## Next Steps
151
-
152
- - **[Full MCP Setup Guide](./MCP_SETUP.md)** - Advanced configuration, troubleshooting
153
- - **[User Guide](./user-guide.md)** - How to structure markdown for best results
154
- - **[Configuration Status](./docs/_current-config-status.md)** - All config files explained
155
-
156
- ---
157
-
158
- ## Available Tools
159
-
160
- Once connected, Claude can use:
161
-
162
- - `search_documents` - Semantic search
163
- - `read_node_content` - Read full markdown file
164
- - `explore_links` - Graph traversal
165
- - `list_directory_structure` - List all documents
166
- - `inject_tags` - Add tags (experimental)
167
-
168
- See [MCP_SETUP.md](./MCP_SETUP.md) for details.