amalfa 0.0.0-reserved → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/.biomeignore +19 -0
  2. package/:memory: +0 -0
  3. package/:memory:-shm +0 -0
  4. package/:memory:-wal +0 -0
  5. package/CHANGELOG.md.old +43 -0
  6. package/LICENSE +21 -0
  7. package/README.md +359 -13
  8. package/README.old.md +112 -0
  9. package/ROADMAP.md +316 -0
  10. package/TEST_PLAN.md +561 -0
  11. package/agents.config.json +11 -0
  12. package/amalfa.config.example.ts +102 -0
  13. package/biome.json +49 -0
  14. package/bun.lock +371 -0
  15. package/docs/AGENT_PROTOCOLS.md +28 -0
  16. package/docs/ARCHITECTURAL_OVERVIEW.md +123 -0
  17. package/docs/BENTO_BOXING_DEPRECATION.md +281 -0
  18. package/docs/Bun-SQLite.html +464 -0
  19. package/docs/COMMIT_GUIDELINES.md +367 -0
  20. package/docs/DEVELOPER_ONBOARDING.md +36 -0
  21. package/docs/Graph and Vector Database Best Practices.md +214 -0
  22. package/docs/PERFORMANCE_BASELINES.md +88 -0
  23. package/docs/REPOSITORY_CLEANUP_SUMMARY.md +261 -0
  24. package/docs/edge-generation-methods.md +57 -0
  25. package/docs/elevator-pitch.md +118 -0
  26. package/docs/graph-and-vector-database-playbook.html +480 -0
  27. package/docs/hardened-sqlite.md +85 -0
  28. package/docs/headless-knowledge-management.md +79 -0
  29. package/docs/john-kaye-flux-prompt.md +46 -0
  30. package/docs/keyboard-shortcuts.md +80 -0
  31. package/docs/opinion-proceed-pattern.md +29 -0
  32. package/docs/polyvis-nodes-edges-schema.md +77 -0
  33. package/docs/protocols/lab-protocol.md +30 -0
  34. package/docs/reaction-iquest-loop-coder.md +46 -0
  35. package/docs/services.md +60 -0
  36. package/docs/sqlite-wal-readonly-trap.md +228 -0
  37. package/docs/strategy/css-architecture.md +40 -0
  38. package/docs/test-document-cycle.md +83 -0
  39. package/docs/test_lifecycle_E2E.md +4 -0
  40. package/docs/the-bicameral-graph.md +83 -0
  41. package/docs/user-guide.md +70 -0
  42. package/docs/vision-helper.md +53 -0
  43. package/drizzle/0000_minor_iron_fist.sql +19 -0
  44. package/drizzle/meta/0000_snapshot.json +139 -0
  45. package/drizzle/meta/_journal.json +13 -0
  46. package/example_usage.ts +39 -0
  47. package/experiment.sh +35 -0
  48. package/hello +2 -0
  49. package/index.html +52 -0
  50. package/knowledge/excalibur.md +12 -0
  51. package/package.json +60 -15
  52. package/plans/experience-graph-integration.md +60 -0
  53. package/prompts/gemini-king-mode-prompt.md +46 -0
  54. package/public/docs/MCP_TOOLS.md +372 -0
  55. package/schemas/README.md +20 -0
  56. package/schemas/cda.schema.json +84 -0
  57. package/schemas/conceptual-lexicon.schema.json +75 -0
  58. package/scratchpads/dummy-debrief-boxed.md +39 -0
  59. package/scratchpads/dummy-debrief.md +27 -0
  60. package/scratchpads/scratchpad-design.md +50 -0
  61. package/scratchpads/scratchpad-scrolling.md +20 -0
  62. package/scratchpads/scratchpad-toc-disappearance.md +23 -0
  63. package/scratchpads/scratchpad-toc.md +28 -0
  64. package/scratchpads/test_gardener.md +7 -0
  65. package/src/EnlightenedTriad.ts +146 -0
  66. package/src/JIT_Triad.ts +137 -0
  67. package/src/cli.ts +364 -0
  68. package/src/config/constants.ts +7 -0
  69. package/src/config/defaults.ts +99 -0
  70. package/src/core/BentoNormalizer.ts +113 -0
  71. package/src/core/EdgeWeaver.ts +145 -0
  72. package/src/core/FractureLogic.ts +22 -0
  73. package/src/core/Harvester.ts +73 -0
  74. package/src/core/LLMClient.ts +93 -0
  75. package/src/core/LouvainGate.ts +67 -0
  76. package/src/core/MarkdownMasker.ts +49 -0
  77. package/src/core/README.md +11 -0
  78. package/src/core/SemanticMatcher.ts +89 -0
  79. package/src/core/SemanticWeaver.ts +96 -0
  80. package/src/core/TagEngine.ts +56 -0
  81. package/src/core/TimelineWeaver.ts +61 -0
  82. package/src/core/VectorEngine.ts +232 -0
  83. package/src/daemon/index.ts +225 -0
  84. package/src/data/experience/test_doc_1.md +2 -0
  85. package/src/data/experience/test_doc_2.md +2 -0
  86. package/src/db/schema.ts +46 -0
  87. package/src/demo-triad.ts +45 -0
  88. package/src/gardeners/AutoTagger.ts +116 -0
  89. package/src/gardeners/BaseGardener.ts +55 -0
  90. package/src/llm/EnlightenedProvider.ts +95 -0
  91. package/src/mcp/README.md +6 -0
  92. package/src/mcp/index.ts +341 -0
  93. package/src/pipeline/AmalfaIngestor.ts +272 -0
  94. package/src/pipeline/HarvesterPipeline.ts +101 -0
  95. package/src/pipeline/Ingestor.ts +555 -0
  96. package/src/pipeline/PreFlightAnalyzer.ts +434 -0
  97. package/src/pipeline/README.md +7 -0
  98. package/src/pipeline/SemanticHarvester.ts +222 -0
  99. package/src/resonance/DatabaseFactory.ts +100 -0
  100. package/src/resonance/README.md +148 -0
  101. package/src/resonance/cli/README.md +7 -0
  102. package/src/resonance/cli/ingest.ts +41 -0
  103. package/src/resonance/cli/migrate.ts +54 -0
  104. package/src/resonance/config.ts +40 -0
  105. package/src/resonance/daemon.ts +236 -0
  106. package/src/resonance/db.ts +424 -0
  107. package/src/resonance/pipeline/README.md +7 -0
  108. package/src/resonance/pipeline/extract.ts +89 -0
  109. package/src/resonance/pipeline/transform_docs.ts +60 -0
  110. package/src/resonance/schema.ts +156 -0
  111. package/src/resonance/services/embedder.ts +131 -0
  112. package/src/resonance/services/simpleTokenizer.ts +119 -0
  113. package/src/resonance/services/stats.ts +327 -0
  114. package/src/resonance/services/tokenizer.ts +159 -0
  115. package/src/resonance/transform/cda.ts +393 -0
  116. package/src/resonance/types/enriched-cda.ts +112 -0
  117. package/src/services/README.md +56 -0
  118. package/src/services/llama.ts +59 -0
  119. package/src/services/llamauv.ts +56 -0
  120. package/src/services/olmo3.ts +58 -0
  121. package/src/services/phi.ts +52 -0
  122. package/src/types/artifact.ts +12 -0
  123. package/src/utils/EnvironmentVerifier.ts +67 -0
  124. package/src/utils/Logger.ts +21 -0
  125. package/src/utils/ServiceLifecycle.ts +207 -0
  126. package/src/utils/ZombieDefense.ts +244 -0
  127. package/src/utils/validator.ts +264 -0
  128. package/substack/substack-playbook-1.md +95 -0
  129. package/substack/substack-playbook-2.md +78 -0
  130. package/tasks/ui-investigation.md +26 -0
  131. package/test-db +0 -0
  132. package/test-db-shm +0 -0
  133. package/test-db-wal +0 -0
  134. package/tests/canary/verify_pinch_check.ts +44 -0
  135. package/tests/fixtures/ingest_test.md +12 -0
  136. package/tests/fixtures/ingest_test_boxed.md +13 -0
  137. package/tests/fixtures/safety_test.md +45 -0
  138. package/tests/fixtures/safety_test_boxed.md +49 -0
  139. package/tests/fixtures/tagged_output.md +49 -0
  140. package/tests/fixtures/tagged_test.md +49 -0
  141. package/tests/mcp-server-settings.json +8 -0
  142. package/tsconfig.json +46 -0
  143. package/verify-embedder.ts +54 -0
package/.biomeignore ADDED
@@ -0,0 +1,19 @@
1
+ **/*-bak.html
2
+ **/*.bak
3
+ public/layout-test.html
4
+ public/test
5
+ public/js
6
+ public/css/app.css
7
+ node_modules
8
+ dist
9
+ .DS_Store
10
+ **/*.py
11
+ **/*.c
12
+ **/*.cpp
13
+ **/*.h
14
+ **/*.hpp
15
+ **/*.sh
16
+ **/*.txt
17
+ docs
18
+ examples
19
+ experiments
package/:memory: ADDED
Binary file
package/:memory:-shm ADDED
Binary file
package/:memory:-wal ADDED
File without changes
@@ -0,0 +1,43 @@
1
+ # Changelog
2
+
3
+ All notable changes to the **PolyVis** project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased] - 2025-12-31
9
+ ### Added
10
+ - **UI:** Implemented "Terminal Brutalist" design system (High-Contrast / Low-Noise).
11
+ - **UI:** Added "Vision Helper" (`window.__AGENT_THEME__`) for programmatic theme detection by agents.
12
+ - **UI:** Added "Style Auditor" (`window.runStyleAudit()`) for runtime CSS integrity checks.
13
+ - **UI:** Added "Hollow" vs "Full" node visualization states in `sigma.js` renderer.
14
+ - **UI:** Added "Agent Activity" indicator color (`--ansi-orange` / `#FF8C00`).
15
+ - **Arch:** Added "FAFCAS" Protocol (Feature Alignment / Frequency Correction / Amplitude Scaling) for normalized embeddings.
16
+ - **Docs:** Added `CHANGELOG.md` as a primary context source.
17
+
18
+ ### Changed
19
+ - **UI:** Replaced generic color palette with strict **ANSI Standard** variables (`basecoat-css`).
20
+ - **UI:** Enforced `border-radius: 0px` global reset.
21
+ - **UI:** Refactored Home Page to "Vertical Monolith" layout (5:8 Aspect Ratio).
22
+ - **UI:** Updated Navbar Brand to use `--ansi-cyan` (System Identity).
23
+ - **UI:** Implemented "Semantic Inversion" for hover states (High Contrast).
24
+ - **Arch:** Initiated migration from `fastembed` to `model2vec` (Pending Benchmark results).
25
+ - **Arch:** Deprecated "Context Engineering" in favor of "Constraint Stacking" for Agent prompts.
26
+
27
+ ### Fixed
28
+ - **Code:** Resolved all Biome linting issues (`noExplicitAny`, `noStaticOnlyClass`).
29
+ - **Code:** Eliminated strict TypeScript errors across the codebase.
30
+ - **Code:** Refactored static-only classes to `export const` objects for better tree-shaking and simplicity.
31
+ - **Code:** Strong typing for Database Query results (removed `any` casting).
32
+
33
+ ### Removed
34
+ - **UI:** Removed all shadows, gradients, and non-monospace fonts.
35
+ - **UI:** Removed "Soft" interaction states (transitions/fades) in favor of "Hard" inversions.
36
+
37
+ ## [1.0.0] - 2025-12-29
38
+ ### Added
39
+ - **Core:** Initial release of the "Hollow Node" architecture.
40
+ - **Runtime:** Validated **Bun** + **SQLite** (`bun:sqlite`) substrate.
41
+ - **Visor:** Canvas-based Graph rendering via `sigma.js`.
42
+ - **Agent:** MCP Server implementation with `search_documents` and `read_node` tools.
43
+ - **Pipeline:** "Semantic Harvester" python bridge for initial ingestion.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Polyvis Project Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,25 +2,371 @@
2
2
 
3
3
  **A Memory Layer For Agents**
4
4
 
5
- 🚧 **Coming Soon** 🚧
5
+ A local-first knowledge graph engine that transforms your markdown files into a searchable memory layer for AI agents. Built for privacy, speed, and zero API costs.
6
6
 
7
- AMALFA is an MCP (Model Context Protocol) server that gives AI agents access to your project's knowledge graph.
7
+ [![NPM Version](https://img.shields.io/npm/v/amalfa)](https://www.npmjs.com/package/amalfa)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
9
 
9
- ## Planned Features
10
+ ## Why AMALFA?
10
11
 
11
- - 🔍 Vector search over markdown documentation
12
- - 📊 Graph traversal (relationships between docs)
13
- - 🧠 Works with Claude Desktop, Cursor, Windsurf
14
- - ⚡ Built with Bun + SQLite + FastEmbed
15
- - 🔒 Local-first, privacy-focused
12
+ AI agents need memory. AMALFA provides:
16
13
 
17
- ## Status
14
+ - **🔒 Privacy-first**: Your data never leaves your machine
15
+ - **⚡️ Fast**: SQLite + vector embeddings for sub-second search
16
+ - **💰 Zero cost**: No API calls, no subscriptions
17
+ - **📝 Markdown native**: Your notes are the source of truth
18
+ - **🔄 Real-time**: File watcher keeps your knowledge graph up-to-date
19
+ - **🤖 Agent-ready**: MCP protocol integration with Claude Desktop
18
20
 
19
- Currently in development. Watch this space!
21
+ ## Quick Start
20
22
 
21
- **GitHub:** [Coming Soon]
22
- **Author:** @polyvis
23
+ ### Installation
24
+
25
+ ```bash
26
+ # Install globally
27
+ bun add -g amalfa
28
+
29
+ # Or use with bunx
30
+ bunx amalfa --help
31
+ ```
32
+
33
+ ### Initialize Your Knowledge Graph
34
+
35
+ ```bash
36
+ # 1. Navigate to your project with markdown files
37
+ cd ~/Documents/my-notes
38
+
39
+ # 2. Initialize AMALFA (creates .amalfa/resonance.db)
40
+ amalfa init
41
+
42
+ # 3. Start the file watcher (optional)
43
+ amalfa daemon start
44
+
45
+ # 4. Connect to Claude Desktop (see Configuration below)
46
+ ```
47
+
48
+ ## Configuration
49
+
50
+ Create `amalfa.config.json` in your project root:
51
+
52
+ ```json
53
+ {
54
+ "sources": ["./docs", "./notes"],
55
+ "database": ".amalfa/resonance.db",
56
+ "embeddings": {
57
+ "model": "BAAI/bge-small-en-v1.5",
58
+ "dimensions": 384
59
+ },
60
+ "watch": {
61
+ "enabled": true,
62
+ "debounce": 1000
63
+ },
64
+ "excludePatterns": ["node_modules", ".git", ".amalfa"]
65
+ }
66
+ ```
67
+
68
+ **New in v1.0.1:** Multi-source support! Use `sources` array to scan multiple directories. Single `source` string still works (auto-migrates).
69
+
70
+ Or use TypeScript:
71
+
72
+ ```typescript
73
+ // amalfa.config.ts
74
+ export default {
75
+ source: "./docs",
76
+ database: ".amalfa/resonance.db",
77
+ // ... rest of config
78
+ };
79
+ ```
80
+
81
+ ### Claude Desktop Integration
82
+
83
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
84
+
85
+ ```json
86
+ {
87
+ "mcpServers": {
88
+ "amalfa": {
89
+ "command": "amalfa",
90
+ "args": ["serve"]
91
+ }
92
+ }
93
+ }
94
+ ```
95
+
96
+ Restart Claude Desktop, and you'll see AMALFA tools available in the conversation.
97
+
98
+ ## CLI Commands
99
+
100
+ ### `amalfa init [--force]`
101
+
102
+ Initialize knowledge graph from markdown files with pre-flight validation.
103
+
104
+ ```bash
105
+ amalfa init # With validation
106
+ amalfa init --force # Override warnings (use with caution)
107
+ ```
108
+
109
+ **What it does:**
110
+ - **Pre-flight validation** (v1.0.1): Checks for large files, symlinks, circular references
111
+ - Scans your source directories for `.md` files
112
+ - Generates vector embeddings (384 dimensions)
113
+ - Extracts WikiLinks (`[[links]]`) and semantic tags
114
+ - Creates edges between related documents
115
+ - Stores metadata in SQLite (content in filesystem - "hollow nodes")
116
+
117
+ **Pre-Flight Protection** (v1.0.1):
118
+ - Blocks files >10MB (prevents memory issues)
119
+ - Detects symlink loops (prevents infinite recursion)
120
+ - Warns about small files (<50 bytes) and large corpora (10K+ files)
121
+ - Generates `.amalfa-pre-flight.log` with actionable recommendations
122
+ - Use `--force` to override warnings (errors still block)
123
+
124
+ **Output:**
125
+ ```
126
+ 📚 Starting ingestion from: ./docs
127
+ 📁 Found 127 markdown files
128
+ 100% (127/127)
129
+ ✅ Initialization complete!
130
+
131
+ 📊 Summary:
132
+ Files processed: 127
133
+ Nodes created: 127
134
+ Edges created: 243
135
+ Embeddings: 127
136
+ Duration: 8.42s
137
+ ```
138
+
139
+ ### `amalfa daemon <action>`
140
+
141
+ Manage the file watcher daemon.
142
+
143
+ ```bash
144
+ amalfa daemon start # Start watching for changes
145
+ amalfa daemon stop # Stop the daemon
146
+ amalfa daemon status # Check if running
147
+ amalfa daemon restart # Restart daemon
148
+ ```
149
+
150
+ **Features:**
151
+ - Watches source directory recursively
152
+ - Debounced updates (1s default)
153
+ - Hash-based change detection (only processes modified files)
154
+ - Retry logic with exponential backoff
155
+ - Native macOS notifications
156
+
157
+ ### `amalfa serve`
158
+
159
+ Start MCP server for Claude Desktop (stdio transport).
160
+
161
+ ```bash
162
+ amalfa serve
163
+ ```
164
+
165
+ **Available Tools:**
166
+ - `search_knowledge`: Semantic search across all documents
167
+ - `get_node`: Retrieve specific document by ID
168
+ - `get_neighbors`: Find related documents (graph traversal)
169
+
170
+ See [docs/MCP_TOOLS.md](docs/MCP_TOOLS.md) for detailed tool schemas.
171
+
172
+ ### `amalfa stats`
173
+
174
+ View knowledge graph statistics.
175
+
176
+ ```bash
177
+ amalfa stats
178
+ ```
179
+
180
+ ### `amalfa doctor`
181
+
182
+ Health check and diagnostics.
183
+
184
+ ```bash
185
+ amalfa doctor
186
+ ```
187
+
188
+ ## Architecture
189
+
190
+ ### Philosophy: Markdown is Truth
191
+
192
+ AMALFA implements the **"Hollow Nodes"** pattern:
193
+
194
+ - **Markdown files** = Source of truth (version controlled, human-readable)
195
+ - **SQLite database** = Ephemeral cache (can be regenerated anytime)
196
+
197
+ **v1.0.1 Enhancement:** Schema v6 fully implements hollow nodes - content is never stored in the database, only metadata and embeddings. This reduces database size dramatically (~350MB saved for 70K documents) and maintains the filesystem as the single source of truth.
198
+
199
+ This means:
200
+ - ✅ You can delete `.amalfa/` and rebuild with `amalfa init`
201
+ - ✅ Your markdown files remain the canonical source
202
+ - ✅ Database changes are never written back to files
203
+ - ✅ No lock-in, no vendor formats
204
+ - ✅ Smaller databases, faster writes (v1.0.1)
205
+
206
+ ### Technology Stack
207
+
208
+ - **Runtime**: Bun (fast, modern JavaScript runtime)
209
+ - **Database**: SQLite with WAL mode
210
+ - **Embeddings**: FastEmbed (local, no API calls)
211
+ - **Vectors**: 384-dimensional (BAAI/bge-small-en-v1.5)
212
+ - **Search**: Pure dot product (cosine similarity)
213
+ - **Protocol**: Model Context Protocol (MCP)
214
+
215
+ ### File Structure
216
+
217
+ ```
218
+ your-project/
219
+ ├── docs/ # Your markdown files
220
+ │ ├── README.md
221
+ │ ├── architecture.md
222
+ │ └── ...
223
+ ├── .amalfa/ # AMALFA data (gitignored)
224
+ │ └── resonance.db # SQLite database (schema v6 - hollow nodes)
225
+ ├── amalfa.config.json # Configuration (optional)
226
+ ├── .amalfa-daemon.pid # Daemon process ID (if running)
227
+ ├── .amalfa-daemon.log # Daemon logs
228
+ └── .amalfa-pre-flight.log # Validation report (generated by init)
229
+ ```
230
+
231
+ ## Features
232
+
233
+ ### Vector Search (FAFCAS Protocol)
234
+
235
+ Fast, accurate search without a vector database:
236
+
237
+ - L2-normalized embeddings (unit vectors)
238
+ - Pure dot product = cosine similarity
239
+ - 85%+ accuracy at <10ms per query
240
+ - No chunking needed (markdown files are already chunk-sized)
241
+
242
+ ### Edge Weaving
243
+
244
+ Automatic relationship detection:
245
+
246
+ - **WikiLinks**: `[[Document Name]]` creates `CITES` edges
247
+ - **Tags**: `[tag: Concept]` creates `TAGGED_AS` edges
248
+ - **Metadata**: `<!-- tags: [RELATION: Target] -->` for explicit edges
249
+ - **Louvain Gate**: Prevents graph pollution (community detection)
250
+
251
+ ### Incremental Updates
252
+
253
+ The daemon watches for changes and only re-processes modified files:
254
+
255
+ - MD5 hash tracking
256
+ - Batch transactions (50 files)
257
+ - Debounced (1s default)
258
+ - Automatic retry on failure (3 attempts, exponential backoff)
259
+
260
+ ## Use Cases
261
+
262
+ ### Personal Knowledge Base
263
+
264
+ ```bash
265
+ # Your notes directory
266
+ cd ~/Documents/notes
267
+ amalfa init
268
+ amalfa daemon start
269
+
270
+ # Now ask Claude: "What did I write about X?"
271
+ # Claude uses AMALFA to search your notes
272
+ ```
273
+
274
+ ### Project Documentation
275
+
276
+ ```bash
277
+ # Your project's docs
278
+ cd ~/Code/my-project
279
+ amalfa init
280
+
281
+ # Ask Claude: "Explain the architecture"
282
+ # Claude searches ./docs and provides context
283
+ ```
284
+
285
+ ### Research & Zettelkasten
286
+
287
+ ```bash
288
+ # Zettelkasten notes
289
+ cd ~/Zettelkasten
290
+ amalfa init
291
+
292
+ # Ask Claude: "Find connections between concept A and B"
293
+ # Claude traverses the knowledge graph
294
+ ```
295
+
296
+ ## Troubleshooting
297
+
298
+ ### Daemon won't start
299
+
300
+ Check logs:
301
+ ```bash
302
+ tail -f .amalfa-daemon.log
303
+ ```
304
+
305
+ Common issues:
306
+ - Source directory doesn't exist
307
+ - Database permissions
308
+ - Port conflicts (if running multiple instances)
309
+
310
+ ### Database corruption
311
+
312
+ Rebuild from markdown:
313
+ ```bash
314
+ rm -rf .amalfa/
315
+ amalfa init
316
+ ```
317
+
318
+ Your markdown files are the source of truth, so this is always safe.
319
+
320
+ ### Slow initialization
321
+
322
+ Large repositories (1000+ files) may take 2-5 minutes on first run. Subsequent updates are fast (hash checking prevents re-processing).
323
+
324
+ ## Development
325
+
326
+ ```bash
327
+ # Clone repository
328
+ git clone https://github.com/pjsvis/amalfa.git
329
+ cd amalfa
330
+
331
+ # Install dependencies
332
+ bun install
333
+
334
+ # Run CLI locally
335
+ bun run src/cli.ts help
336
+
337
+ # Run tests
338
+ bun test
339
+
340
+ # Type checking
341
+ bun run tsc --noEmit
342
+ ```
343
+
344
+ ## Roadmap
345
+
346
+ - [ ] v1.1: Web UI for graph visualization
347
+ - [ ] v1.2: Multi-language embedding models
348
+ - [ ] v1.3: PDF/DOCX support
349
+ - [ ] v2.0: Distributed sync (private P2P)
350
+
351
+ ## Contributing
352
+
353
+ Contributions welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md).
354
+
355
+ ## License
356
+
357
+ MIT License - see [LICENSE](LICENSE) for details.
358
+
359
+ ## Credits
360
+
361
+ Built with:
362
+ - [Bun](https://bun.sh) - Fast JavaScript runtime
363
+ - [FastEmbed](https://github.com/qdrant/fastembed) - Local embeddings
364
+ - [Model Context Protocol](https://modelcontextprotocol.io) - AI agent integration
23
365
 
24
366
  ---
25
367
 
26
- _This is a placeholder package to reserve the name. v1.0.0 coming soon._
368
+ **AMALFA** = **A Memory Layer For Agents**
369
+
370
+ Give your AI agents a memory. Keep your privacy. Own your data.
371
+
372
+ **[GitHub](https://github.com/pjsvis/amalfa)** • **[NPM](https://www.npmjs.com/package/amalfa)** • **[Issues](https://github.com/pjsvis/amalfa/issues)**
package/README.old.md ADDED
@@ -0,0 +1,112 @@
1
+ # Polyvis: A Neuro-Symbolic Graph Visualizer
2
+
3
+ Polyvis is a lightweight, frontend-only web application for exploring and visualizing neuro-symbolic knowledge graphs. It renders conceptual relationships from a pre-built SQLite database, allowing users to navigate a "Neuro-Map" of interconnected ideas, principles, and directives.
4
+
5
+ The application is built with HTML, CSS, and [Alpine.js](https://alpinejs.dev/), and uses [Bun](https://bun.sh/) as its JavaScript runtime and toolkit. The graph visualization is powered by [viz.js](https://github.com/mdaines/viz.js) and [Sigma.js](https://www.sigmajs.org/), and the in-browser database is handled by [sql.js](https://sql.js.org/).
6
+
7
+ ## Features
8
+
9
+ - **Interactive Graph Visualization:** Explore the knowledge graph by searching for terms.
10
+ - **Data-Driven Suggestions:** The search box provides a curated list of high-value terms guaranteed to produce rich, interesting graphs.
11
+ - **In-Browser Database:** The entire graph dataset is loaded into the browser via sql.js, requiring no active backend server for querying.
12
+ - **Alpine.js Reactivity:** Uses [Alpine.js](https://alpinejs.dev/) for a lightweight, reactive UI without a complex build step.
13
+ - **Zero-Build Frontend:** Built with vanilla web technologies and Alpine.js for maximum simplicity and performance.
14
+ - **Themable UI:** All design tokens (colors, dimensions) are centralized in `src/css/layers/theme.css` ("The Control Panel") for easy customization.
15
+ - **Semantic Styling:** No magic numbers. All styles use semantic variables (e.g., `--surface-panel`, `--border-base`) for consistent theming.
16
+ - **Efficient Search:** Two-tier search architecture (vector embeddings + grep) - no FTS or chunking needed.
17
+
18
+ ## Search Architecture
19
+
20
+ Polyvis uses a **two-tier search system** that eliminates the need for full-text search (FTS) or document chunking:
21
+
22
+ ### 1. Vector Search (Semantic)
23
+ - **Purpose:** Semantic similarity, concept discovery
24
+ - **Accuracy:** 85% average best match across diverse queries
25
+ - **Speed:** <10ms per query
26
+ - **Use case:** "Find documents about CSS patterns" or "Show me graph weaving logic"
27
+
28
+ ### 2. Grep/Ripgrep (Literal)
29
+ - **Purpose:** Exact phrase matches, symbol lookup
30
+ - **Accuracy:** 100% (literal text matching)
31
+ - **Speed:** <1ms
32
+ - **Use case:** "Find exact phrase 'function fooBar'" or "Where is BentoBoxer imported?"
33
+
34
+ ### Why No Chunking?
35
+
36
+ **Document corpus characteristics:**
37
+ - 80% of documents are <5KB (~1,000 words) - already "chunk-sized"
38
+ - Average document: 2.7KB (~550 words)
39
+ - Largest document: 47KB (~9,500 words) - still within LLM context windows
40
+
41
+ **Results without chunking:**
42
+ - Vector search achieves 85% accuracy on whole documents
43
+ - Documents are well-structured markdown with clear headers
44
+ - Natural granularity matches search needs
45
+
46
+ **Future strategy:** If large documents (>20KB) become problematic, split them into multiple markdown files at natural boundaries (H1/H2 headers) and commit to version control. This keeps source files as the source of truth, maintains git-friendly diffs, and requires no runtime infrastructure.
47
+
48
+ **See:** `docs/BENTO_BOXING_DEPRECATION.md` for full analysis and decision rationale.
49
+
50
+ ## Design System (The Control Center)
51
+ The application's visual design is strictly controlled by **`src/css/layers/theme.css`**. This file acts as a configuration panel for:
52
+ - **Dimensions:** Sidebar widths, header heights.
53
+ - **Colors:** Semantic mappings (e.g., `--surface-1`, `--brand`).
54
+ - **Spacing:** Global padding and gaps.
55
+
56
+ **Protocol:** Always check and tweak `theme.css` before modifying component styles.
57
+
58
+ ## Prerequisites
59
+
60
+ - [Bun.js](https://bun.sh/docs/installation) (v1.0 or later) - **MANDATORY**
61
+ - A local web server for development (e.g., `bun x http-server`)
62
+
63
+ ## Getting Started
64
+
65
+ Follow these steps to set up and run the project locally.
66
+
67
+ ### 1. Installation
68
+
69
+ There are no external dependencies to install for the application itself, as it relies on vanilla JavaScript and CDN-hosted libraries.
70
+
71
+ ### 2. Development Workflow
72
+
73
+ For detailed instructions on CSS development, database building, and running the app, please refer to the **[Development Workflow Playbook](playbooks/development-workflow-playbook.md)**.
74
+
75
+ **Quick Start:**
76
+ 1. **Dev Mode:** `bun run dev` (Starts server & CSS watcher)
77
+ 2. **Build DB:** `bun run scripts/build_db.ts`
78
+
79
+ ## Project Structure
80
+
81
+ ### 3. Detailed Documentation
82
+ For a deep dive on the codebase organization, please see **[Project Structure](docs/webdocs/project-structure.md)**.
83
+
84
+ ## Project Structure (High Level)
85
+
86
+ ```
87
+ ├── public/ # Web Root (HTML, Static Data)
88
+ │ ├── explorer/ # Sigma.js Graph Explorer
89
+ │ └── resonance.db # SQLite Database (generated locally)
90
+
91
+ ├── src/ # Application Source Code
92
+ │ ├── core/ # The Bento Box Kernel (Normalizer, Weaver)
93
+ │ ├── config/ # Shared Configuration
94
+ │ └── db/ # Database Schemas
95
+
96
+ ├── scripts/ # Data Pipeline & Tooling
97
+ │ ├── pipeline/ # ETL Scripts (Sync, Load)
98
+ │ ├── cli/ # Command Line Tools (Harvest)
99
+ │ └── verify/ # Integrity Checks
100
+
101
+ ├── docs/ # Project Documentation
102
+ ├── playbooks/ # Operational Protocols
103
+ ├── polyvis.settings.json # Central Configuration
104
+ └── README.md # This file
105
+ ```
106
+
107
+ ## Contributing
108
+ ## Contribution Guidelines
109
+ Please review `AGENTS.md` for our operational protocols, specifically:
110
+ - **EVP (Empirical Verification Protocol):** Use the browser to verify, don't guess.
111
+ - **GEP (Granular Execution Protocol):** One step at a time.
112
+ Please feel free to open issues or submit pull requests.