amalfa 0.0.0-reserved → 1.0.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.
Files changed (139) 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/LICENSE +21 -0
  6. package/README.md +343 -13
  7. package/README.old.md +112 -0
  8. package/agents.config.json +11 -0
  9. package/amalfa.config.example.ts +100 -0
  10. package/biome.json +49 -0
  11. package/bun.lock +371 -0
  12. package/docs/AGENT_PROTOCOLS.md +28 -0
  13. package/docs/ARCHITECTURAL_OVERVIEW.md +123 -0
  14. package/docs/BENTO_BOXING_DEPRECATION.md +281 -0
  15. package/docs/Bun-SQLite.html +464 -0
  16. package/docs/COMMIT_GUIDELINES.md +367 -0
  17. package/docs/DEVELOPER_ONBOARDING.md +36 -0
  18. package/docs/Graph and Vector Database Best Practices.md +214 -0
  19. package/docs/PERFORMANCE_BASELINES.md +88 -0
  20. package/docs/REPOSITORY_CLEANUP_SUMMARY.md +261 -0
  21. package/docs/edge-generation-methods.md +57 -0
  22. package/docs/elevator-pitch.md +118 -0
  23. package/docs/graph-and-vector-database-playbook.html +480 -0
  24. package/docs/hardened-sqlite.md +85 -0
  25. package/docs/headless-knowledge-management.md +79 -0
  26. package/docs/john-kaye-flux-prompt.md +46 -0
  27. package/docs/keyboard-shortcuts.md +80 -0
  28. package/docs/opinion-proceed-pattern.md +29 -0
  29. package/docs/polyvis-nodes-edges-schema.md +77 -0
  30. package/docs/protocols/lab-protocol.md +30 -0
  31. package/docs/reaction-iquest-loop-coder.md +46 -0
  32. package/docs/services.md +60 -0
  33. package/docs/sqlite-wal-readonly-trap.md +228 -0
  34. package/docs/strategy/css-architecture.md +40 -0
  35. package/docs/test-document-cycle.md +83 -0
  36. package/docs/test_lifecycle_E2E.md +4 -0
  37. package/docs/the-bicameral-graph.md +83 -0
  38. package/docs/user-guide.md +70 -0
  39. package/docs/vision-helper.md +53 -0
  40. package/drizzle/0000_minor_iron_fist.sql +19 -0
  41. package/drizzle/meta/0000_snapshot.json +139 -0
  42. package/drizzle/meta/_journal.json +13 -0
  43. package/example_usage.ts +39 -0
  44. package/experiment.sh +35 -0
  45. package/hello +2 -0
  46. package/index.html +52 -0
  47. package/knowledge/excalibur.md +12 -0
  48. package/package.json +60 -15
  49. package/plans/experience-graph-integration.md +60 -0
  50. package/prompts/gemini-king-mode-prompt.md +46 -0
  51. package/public/docs/MCP_TOOLS.md +372 -0
  52. package/schemas/README.md +20 -0
  53. package/schemas/cda.schema.json +84 -0
  54. package/schemas/conceptual-lexicon.schema.json +75 -0
  55. package/scratchpads/dummy-debrief-boxed.md +39 -0
  56. package/scratchpads/dummy-debrief.md +27 -0
  57. package/scratchpads/scratchpad-design.md +50 -0
  58. package/scratchpads/scratchpad-scrolling.md +20 -0
  59. package/scratchpads/scratchpad-toc-disappearance.md +23 -0
  60. package/scratchpads/scratchpad-toc.md +28 -0
  61. package/scratchpads/test_gardener.md +7 -0
  62. package/src/EnlightenedTriad.ts +146 -0
  63. package/src/JIT_Triad.ts +137 -0
  64. package/src/cli.ts +318 -0
  65. package/src/config/constants.ts +7 -0
  66. package/src/config/defaults.ts +81 -0
  67. package/src/core/BentoNormalizer.ts +113 -0
  68. package/src/core/EdgeWeaver.ts +145 -0
  69. package/src/core/FractureLogic.ts +22 -0
  70. package/src/core/Harvester.ts +73 -0
  71. package/src/core/LLMClient.ts +93 -0
  72. package/src/core/LouvainGate.ts +67 -0
  73. package/src/core/MarkdownMasker.ts +49 -0
  74. package/src/core/README.md +11 -0
  75. package/src/core/SemanticMatcher.ts +89 -0
  76. package/src/core/SemanticWeaver.ts +96 -0
  77. package/src/core/TagEngine.ts +56 -0
  78. package/src/core/TimelineWeaver.ts +61 -0
  79. package/src/core/VectorEngine.ts +232 -0
  80. package/src/daemon/index.ts +221 -0
  81. package/src/data/experience/test_doc_1.md +2 -0
  82. package/src/data/experience/test_doc_2.md +2 -0
  83. package/src/db/schema.ts +46 -0
  84. package/src/demo-triad.ts +45 -0
  85. package/src/gardeners/AutoTagger.ts +116 -0
  86. package/src/gardeners/BaseGardener.ts +55 -0
  87. package/src/llm/EnlightenedProvider.ts +95 -0
  88. package/src/mcp/README.md +6 -0
  89. package/src/mcp/index.ts +341 -0
  90. package/src/pipeline/AmalfaIngestor.ts +262 -0
  91. package/src/pipeline/HarvesterPipeline.ts +101 -0
  92. package/src/pipeline/Ingestor.ts +555 -0
  93. package/src/pipeline/README.md +7 -0
  94. package/src/pipeline/SemanticHarvester.ts +222 -0
  95. package/src/resonance/DatabaseFactory.ts +100 -0
  96. package/src/resonance/README.md +148 -0
  97. package/src/resonance/cli/README.md +7 -0
  98. package/src/resonance/cli/ingest.ts +41 -0
  99. package/src/resonance/cli/migrate.ts +54 -0
  100. package/src/resonance/config.ts +40 -0
  101. package/src/resonance/daemon.ts +236 -0
  102. package/src/resonance/db.ts +422 -0
  103. package/src/resonance/pipeline/README.md +7 -0
  104. package/src/resonance/pipeline/extract.ts +89 -0
  105. package/src/resonance/pipeline/transform_docs.ts +60 -0
  106. package/src/resonance/schema.ts +138 -0
  107. package/src/resonance/services/embedder.ts +131 -0
  108. package/src/resonance/services/simpleTokenizer.ts +119 -0
  109. package/src/resonance/services/stats.ts +327 -0
  110. package/src/resonance/services/tokenizer.ts +159 -0
  111. package/src/resonance/transform/cda.ts +393 -0
  112. package/src/resonance/types/enriched-cda.ts +112 -0
  113. package/src/services/README.md +56 -0
  114. package/src/services/llama.ts +59 -0
  115. package/src/services/llamauv.ts +56 -0
  116. package/src/services/olmo3.ts +58 -0
  117. package/src/services/phi.ts +52 -0
  118. package/src/types/artifact.ts +12 -0
  119. package/src/utils/EnvironmentVerifier.ts +67 -0
  120. package/src/utils/Logger.ts +21 -0
  121. package/src/utils/ServiceLifecycle.ts +207 -0
  122. package/src/utils/ZombieDefense.ts +244 -0
  123. package/src/utils/validator.ts +264 -0
  124. package/substack/substack-playbook-1.md +95 -0
  125. package/substack/substack-playbook-2.md +78 -0
  126. package/tasks/ui-investigation.md +26 -0
  127. package/test-db +0 -0
  128. package/test-db-shm +0 -0
  129. package/test-db-wal +0 -0
  130. package/tests/canary/verify_pinch_check.ts +44 -0
  131. package/tests/fixtures/ingest_test.md +12 -0
  132. package/tests/fixtures/ingest_test_boxed.md +13 -0
  133. package/tests/fixtures/safety_test.md +45 -0
  134. package/tests/fixtures/safety_test_boxed.md +49 -0
  135. package/tests/fixtures/tagged_output.md +49 -0
  136. package/tests/fixtures/tagged_test.md +49 -0
  137. package/tests/mcp-server-settings.json +8 -0
  138. package/tsconfig.json +46 -0
  139. 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
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,355 @@
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
+ "source": "./docs",
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
+ Or use TypeScript:
69
+
70
+ ```typescript
71
+ // amalfa.config.ts
72
+ export default {
73
+ source: "./docs",
74
+ database: ".amalfa/resonance.db",
75
+ // ... rest of config
76
+ };
77
+ ```
78
+
79
+ ### Claude Desktop Integration
80
+
81
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
82
+
83
+ ```json
84
+ {
85
+ "mcpServers": {
86
+ "amalfa": {
87
+ "command": "amalfa",
88
+ "args": ["serve"]
89
+ }
90
+ }
91
+ }
92
+ ```
93
+
94
+ Restart Claude Desktop, and you'll see AMALFA tools available in the conversation.
95
+
96
+ ## CLI Commands
97
+
98
+ ### `amalfa init`
99
+
100
+ Initialize knowledge graph from markdown files.
101
+
102
+ ```bash
103
+ amalfa init
104
+ ```
105
+
106
+ **What it does:**
107
+ - Scans your source directory for `.md` files
108
+ - Generates vector embeddings (384 dimensions)
109
+ - Extracts WikiLinks (`[[links]]`) and semantic tags
110
+ - Creates edges between related documents
111
+ - Stores everything in SQLite with WAL mode
112
+
113
+ **Output:**
114
+ ```
115
+ 📚 Starting ingestion from: ./docs
116
+ 📁 Found 127 markdown files
117
+ 100% (127/127)
118
+ ✅ Initialization complete!
119
+
120
+ 📊 Summary:
121
+ Files processed: 127
122
+ Nodes created: 127
123
+ Edges created: 243
124
+ Embeddings: 127
125
+ Duration: 8.42s
126
+ ```
127
+
128
+ ### `amalfa daemon <action>`
129
+
130
+ Manage the file watcher daemon.
131
+
132
+ ```bash
133
+ amalfa daemon start # Start watching for changes
134
+ amalfa daemon stop # Stop the daemon
135
+ amalfa daemon status # Check if running
136
+ amalfa daemon restart # Restart daemon
137
+ ```
138
+
139
+ **Features:**
140
+ - Watches source directory recursively
141
+ - Debounced updates (1s default)
142
+ - Hash-based change detection (only processes modified files)
143
+ - Retry logic with exponential backoff
144
+ - Native macOS notifications
145
+
146
+ ### `amalfa serve`
147
+
148
+ Start MCP server for Claude Desktop (stdio transport).
149
+
150
+ ```bash
151
+ amalfa serve
152
+ ```
153
+
154
+ **Available Tools:**
155
+ - `search_knowledge`: Semantic search across all documents
156
+ - `get_node`: Retrieve specific document by ID
157
+ - `get_neighbors`: Find related documents (graph traversal)
158
+
159
+ See [docs/MCP_TOOLS.md](docs/MCP_TOOLS.md) for detailed tool schemas.
160
+
161
+ ### `amalfa stats`
162
+
163
+ View knowledge graph statistics.
164
+
165
+ ```bash
166
+ amalfa stats
167
+ ```
168
+
169
+ ### `amalfa doctor`
170
+
171
+ Health check and diagnostics.
172
+
173
+ ```bash
174
+ amalfa doctor
175
+ ```
176
+
177
+ ## Architecture
178
+
179
+ ### Philosophy: Markdown is Truth
180
+
181
+ AMALFA implements the **"Hollow Nodes"** pattern:
182
+
183
+ - **Markdown files** = Source of truth (version controlled, human-readable)
184
+ - **SQLite database** = Ephemeral cache (can be regenerated anytime)
185
+
186
+ This means:
187
+ - ✅ You can delete `.amalfa/` and rebuild with `amalfa init`
188
+ - ✅ Your markdown files remain the canonical source
189
+ - ✅ Database changes are never written back to files
190
+ - ✅ No lock-in, no vendor formats
191
+
192
+ ### Technology Stack
193
+
194
+ - **Runtime**: Bun (fast, modern JavaScript runtime)
195
+ - **Database**: SQLite with WAL mode
196
+ - **Embeddings**: FastEmbed (local, no API calls)
197
+ - **Vectors**: 384-dimensional (BAAI/bge-small-en-v1.5)
198
+ - **Search**: Pure dot product (cosine similarity)
199
+ - **Protocol**: Model Context Protocol (MCP)
200
+
201
+ ### File Structure
202
+
203
+ ```
204
+ your-project/
205
+ ├── docs/ # Your markdown files
206
+ │ ├── README.md
207
+ │ ├── architecture.md
208
+ │ └── ...
209
+ ├── .amalfa/ # AMALFA data (gitignored)
210
+ │ └── resonance.db # SQLite database (2-5 MB typical)
211
+ ├── amalfa.config.json # Configuration (optional)
212
+ └── .amalfa-daemon.pid # Daemon process ID (if running)
213
+ ```
214
+
215
+ ## Features
216
+
217
+ ### Vector Search (FAFCAS Protocol)
218
+
219
+ Fast, accurate search without a vector database:
220
+
221
+ - L2-normalized embeddings (unit vectors)
222
+ - Pure dot product = cosine similarity
223
+ - 85%+ accuracy at <10ms per query
224
+ - No chunking needed (markdown files are already chunk-sized)
225
+
226
+ ### Edge Weaving
227
+
228
+ Automatic relationship detection:
229
+
230
+ - **WikiLinks**: `[[Document Name]]` creates `CITES` edges
231
+ - **Tags**: `[tag: Concept]` creates `TAGGED_AS` edges
232
+ - **Metadata**: `<!-- tags: [RELATION: Target] -->` for explicit edges
233
+ - **Louvain Gate**: Prevents graph pollution (community detection)
234
+
235
+ ### Incremental Updates
236
+
237
+ The daemon watches for changes and only re-processes modified files:
238
+
239
+ - MD5 hash tracking
240
+ - Batch transactions (50 files)
241
+ - Debounced (1s default)
242
+ - Automatic retry on failure (3 attempts, exponential backoff)
243
+
244
+ ## Use Cases
245
+
246
+ ### Personal Knowledge Base
247
+
248
+ ```bash
249
+ # Your notes directory
250
+ cd ~/Documents/notes
251
+ amalfa init
252
+ amalfa daemon start
253
+
254
+ # Now ask Claude: "What did I write about X?"
255
+ # Claude uses AMALFA to search your notes
256
+ ```
257
+
258
+ ### Project Documentation
259
+
260
+ ```bash
261
+ # Your project's docs
262
+ cd ~/Code/my-project
263
+ amalfa init
264
+
265
+ # Ask Claude: "Explain the architecture"
266
+ # Claude searches ./docs and provides context
267
+ ```
268
+
269
+ ### Research & Zettelkasten
270
+
271
+ ```bash
272
+ # Zettelkasten notes
273
+ cd ~/Zettelkasten
274
+ amalfa init
275
+
276
+ # Ask Claude: "Find connections between concept A and B"
277
+ # Claude traverses the knowledge graph
278
+ ```
279
+
280
+ ## Troubleshooting
281
+
282
+ ### Daemon won't start
283
+
284
+ Check logs:
285
+ ```bash
286
+ tail -f .amalfa-daemon.log
287
+ ```
288
+
289
+ Common issues:
290
+ - Source directory doesn't exist
291
+ - Database permissions
292
+ - Port conflicts (if running multiple instances)
293
+
294
+ ### Database corruption
295
+
296
+ Rebuild from markdown:
297
+ ```bash
298
+ rm -rf .amalfa/
299
+ amalfa init
300
+ ```
301
+
302
+ Your markdown files are the source of truth, so this is always safe.
303
+
304
+ ### Slow initialization
305
+
306
+ Large repositories (1000+ files) may take 2-5 minutes on first run. Subsequent updates are fast (hash checking prevents re-processing).
307
+
308
+ ## Development
309
+
310
+ ```bash
311
+ # Clone repository
312
+ git clone https://github.com/pjsvis/amalfa.git
313
+ cd amalfa
314
+
315
+ # Install dependencies
316
+ bun install
317
+
318
+ # Run CLI locally
319
+ bun run src/cli.ts help
320
+
321
+ # Run tests
322
+ bun test
323
+
324
+ # Type checking
325
+ bun run tsc --noEmit
326
+ ```
327
+
328
+ ## Roadmap
329
+
330
+ - [ ] v1.1: Web UI for graph visualization
331
+ - [ ] v1.2: Multi-language embedding models
332
+ - [ ] v1.3: PDF/DOCX support
333
+ - [ ] v2.0: Distributed sync (private P2P)
334
+
335
+ ## Contributing
336
+
337
+ Contributions welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md).
338
+
339
+ ## License
340
+
341
+ MIT License - see [LICENSE](LICENSE) for details.
342
+
343
+ ## Credits
344
+
345
+ Built with:
346
+ - [Bun](https://bun.sh) - Fast JavaScript runtime
347
+ - [FastEmbed](https://github.com/qdrant/fastembed) - Local embeddings
348
+ - [Model Context Protocol](https://modelcontextprotocol.io) - AI agent integration
23
349
 
24
350
  ---
25
351
 
26
- _This is a placeholder package to reserve the name. v1.0.0 coming soon._
352
+ **AMALFA** = **A Memory Layer For Agents**
353
+
354
+ Give your AI agents a memory. Keep your privacy. Own your data.
355
+
356
+ **[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.
@@ -0,0 +1,11 @@
1
+ {
2
+ "nanocoder": {
3
+ "providers": [
4
+ {
5
+ "name": "ollama",
6
+ "models": ["llama3.1:8b"],
7
+ "baseUrl": "http://localhost:11434/v1"
8
+ }
9
+ ]
10
+ }
11
+ }
@@ -0,0 +1,100 @@
1
+ /**
2
+ * AMALFA Configuration Example
3
+ *
4
+ * Copy this file to your project root as:
5
+ * - amalfa.config.ts (TypeScript)
6
+ * - amalfa.config.js (JavaScript)
7
+ * - amalfa.config.json (JSON)
8
+ */
9
+
10
+ export default {
11
+ /**
12
+ * Source directory containing markdown files
13
+ * Relative to project root
14
+ *
15
+ * Examples:
16
+ * - "./docs" - Standard documentation folder
17
+ * - "./notes" - Personal notes
18
+ * - "./content" - Content management
19
+ * - "." - Current directory (scans all .md files)
20
+ */
21
+ source: "./docs",
22
+
23
+ /**
24
+ * Database file location
25
+ * Relative to project root
26
+ *
27
+ * The .amalfa directory is gitignored by default.
28
+ * The database can be regenerated from markdown at any time.
29
+ */
30
+ database: ".amalfa/resonance.db",
31
+
32
+ /**
33
+ * Embedding configuration
34
+ */
35
+ embeddings: {
36
+ /**
37
+ * Embedding model to use
38
+ *
39
+ * Options:
40
+ * - "BAAI/bge-small-en-v1.5" (default) - Best balance (384 dims)
41
+ * - "sentence-transformers/all-MiniLM-L6-v2" - Faster (384 dims)
42
+ * - "BAAI/bge-base-en-v1.5" - More accurate (768 dims, slower)
43
+ *
44
+ * Models are downloaded on first use to .resonance/cache/
45
+ */
46
+ model: "BAAI/bge-small-en-v1.5",
47
+
48
+ /**
49
+ * Vector dimensions
50
+ * Must match the model's output size
51
+ *
52
+ * Common dimensions:
53
+ * - 384: Most small models
54
+ * - 768: Most base models
55
+ * - 1024: Large models
56
+ */
57
+ dimensions: 384,
58
+ },
59
+
60
+ /**
61
+ * File watcher configuration
62
+ */
63
+ watch: {
64
+ /**
65
+ * Enable file watching
66
+ * Used by 'amalfa daemon' command
67
+ */
68
+ enabled: true,
69
+
70
+ /**
71
+ * Debounce delay in milliseconds
72
+ *
73
+ * How long to wait after the last file change before
74
+ * triggering re-ingestion. This prevents excessive
75
+ * processing during rapid file edits.
76
+ *
77
+ * Recommended:
78
+ * - 1000ms (1 second) - Default, good for most cases
79
+ * - 500ms - More responsive, slightly higher CPU
80
+ * - 2000ms - Less responsive, lower CPU
81
+ */
82
+ debounce: 1000,
83
+ },
84
+
85
+ /**
86
+ * Patterns to exclude from ingestion
87
+ *
88
+ * Files/directories matching these patterns are ignored.
89
+ * Patterns are checked with String.includes(), not glob.
90
+ *
91
+ * Common exclusions:
92
+ * - "node_modules" - JavaScript dependencies
93
+ * - ".git" - Git internals
94
+ * - ".amalfa" - AMALFA data directory
95
+ * - "vendor" - PHP dependencies
96
+ * - "target" - Rust build artifacts
97
+ * - "dist" - Build output
98
+ */
99
+ excludePatterns: ["node_modules", ".git", ".amalfa"],
100
+ };
package/biome.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "$schema": "https://biomejs.dev/schemas/2.3.8/schema.json",
3
+ "vcs": {
4
+ "enabled": true,
5
+ "clientKind": "git",
6
+ "useIgnoreFile": true
7
+ },
8
+ "files": {
9
+ "ignoreUnknown": false,
10
+ "includes": [
11
+ "src/**",
12
+ "scripts/**",
13
+ "tests/**",
14
+ "*.ts",
15
+ "*.js",
16
+ "*.json",
17
+ "*.css"
18
+ ]
19
+ },
20
+ "formatter": {
21
+ "enabled": true,
22
+ "indentStyle": "tab"
23
+ },
24
+ "linter": {
25
+ "enabled": true,
26
+ "rules": {
27
+ "recommended": true
28
+ }
29
+ },
30
+ "javascript": {
31
+ "formatter": {
32
+ "quoteStyle": "double"
33
+ }
34
+ },
35
+ "css": {
36
+ "parser": {
37
+ "cssModules": true,
38
+ "tailwindDirectives": true
39
+ }
40
+ },
41
+ "assist": {
42
+ "enabled": true,
43
+ "actions": {
44
+ "source": {
45
+ "organizeImports": "on"
46
+ }
47
+ }
48
+ }
49
+ }