@rbalchii/anchor-engine 4.8.0 → 4.8.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 (141) hide show
  1. package/LICENSE +608 -608
  2. package/README.md +177 -1
  3. package/anchor.bat +5 -5
  4. package/docs/AGENT_CONTROLLED_ENGINE.md +581 -0
  5. package/docs/API.md +314 -314
  6. package/docs/DEPLOYMENT.md +448 -448
  7. package/docs/INDEX.md +226 -226
  8. package/docs/MD_FILES_INVENTORY.md +166 -0
  9. package/docs/STAR_Whitepaper_Executive.md +216 -216
  10. package/docs/TROUBLESHOOTING.md +535 -535
  11. package/docs/arxiv/BIBLIOGRAPHY.bib +145 -145
  12. package/docs/arxiv/RELATED_WORK.tex +38 -38
  13. package/docs/arxiv/compile.bat +48 -48
  14. package/docs/arxiv/joss_response.md +32 -32
  15. package/docs/arxiv/prepare-submission.bat +46 -46
  16. package/docs/arxiv/review.md +127 -127
  17. package/docs/arxiv/star-whitepaper.tex +656 -656
  18. package/docs/code-patterns.md +289 -289
  19. package/docs/daily/TODAY_SUMMARY.md +245 -0
  20. package/docs/guides/BUILDING.md +64 -0
  21. package/docs/guides/INSTALL_NPM.md +160 -0
  22. package/docs/guides/NPM_PUBLISH_SUMMARY.md +231 -0
  23. package/docs/paper.md +124 -0
  24. package/docs/project/PROJECT_STATE_ASSESSMENT.md +312 -0
  25. package/docs/reviews/code-review-v4.8.1-decision-record.md +165 -0
  26. package/docs/testing/TESTING.md +213 -0
  27. package/docs/testing/TESTING_FRAMEWORK_COMPLETE.md +271 -0
  28. package/docs/testing/search-test-report.md +76 -0
  29. package/docs/whitepaper.md +445 -445
  30. package/engine/dist/commands/distill.js +21 -21
  31. package/engine/dist/config/index.d.ts +7 -0
  32. package/engine/dist/config/index.d.ts.map +1 -1
  33. package/engine/dist/config/index.js +22 -0
  34. package/engine/dist/config/index.js.map +1 -1
  35. package/engine/dist/config/paths.d.ts +1 -1
  36. package/engine/dist/config/paths.js +3 -3
  37. package/engine/dist/config/paths.js.map +1 -1
  38. package/engine/dist/core/db.js +131 -131
  39. package/engine/dist/mcp/server.d.ts +44 -0
  40. package/engine/dist/mcp/server.d.ts.map +1 -0
  41. package/engine/dist/mcp/server.js +427 -0
  42. package/engine/dist/mcp/server.js.map +1 -0
  43. package/engine/dist/native/index.d.ts +20 -21
  44. package/engine/dist/native/index.d.ts.map +1 -1
  45. package/engine/dist/profiling/atomization-profiling.js +3 -3
  46. package/engine/dist/profiling/bottleneck-identification.js +35 -35
  47. package/engine/dist/profiling/content-sanitization-profiling.js +86 -86
  48. package/engine/dist/routes/monitoring.js +8 -8
  49. package/engine/dist/routes/v1/admin.js +8 -8
  50. package/engine/dist/routes/v1/atoms.js +15 -15
  51. package/engine/dist/routes/v1/ingest.d.ts.map +1 -1
  52. package/engine/dist/routes/v1/ingest.js +39 -0
  53. package/engine/dist/routes/v1/ingest.js.map +1 -1
  54. package/engine/dist/routes/v1/system.d.ts.map +1 -1
  55. package/engine/dist/routes/v1/system.js +305 -6
  56. package/engine/dist/routes/v1/system.js.map +1 -1
  57. package/engine/dist/routes/v1/tags.js +2 -2
  58. package/engine/dist/services/backup/backup-restore.js +23 -23
  59. package/engine/dist/services/backup/backup.js +14 -14
  60. package/engine/dist/services/distillation/radial-distiller.d.ts +1 -0
  61. package/engine/dist/services/distillation/radial-distiller.d.ts.map +1 -1
  62. package/engine/dist/services/distillation/radial-distiller.js +23 -16
  63. package/engine/dist/services/distillation/radial-distiller.js.map +1 -1
  64. package/engine/dist/services/ingest/github-ingest-service.js +18 -18
  65. package/engine/dist/services/ingest/ingest-atomic.js +79 -79
  66. package/engine/dist/services/ingest/ingest.d.ts.map +1 -1
  67. package/engine/dist/services/ingest/ingest.js +28 -25
  68. package/engine/dist/services/ingest/ingest.js.map +1 -1
  69. package/engine/dist/services/ingest/watchdog.d.ts.map +1 -1
  70. package/engine/dist/services/ingest/watchdog.js +14 -24
  71. package/engine/dist/services/ingest/watchdog.js.map +1 -1
  72. package/engine/dist/services/llm/reader.js +9 -9
  73. package/engine/dist/services/mirror/mirror.js +5 -5
  74. package/engine/dist/services/mirror/mirror.js.map +1 -1
  75. package/engine/dist/services/research/researcher.js +8 -8
  76. package/engine/dist/services/scribe/scribe.js +27 -27
  77. package/engine/dist/services/search/context-inflator.js +34 -34
  78. package/engine/dist/services/search/explore.js +20 -20
  79. package/engine/dist/services/search/physics-tag-walker.js +208 -208
  80. package/engine/dist/services/search/query-parser.js +5 -5
  81. package/engine/dist/services/search/search-utils.js +3 -3
  82. package/engine/dist/services/search/search.js +36 -36
  83. package/engine/dist/services/search/sovereign-system-prompt.js +22 -22
  84. package/engine/dist/services/semantic/semantic-ingestion-service.js +47 -47
  85. package/engine/dist/services/semantic/semantic-search.js +21 -21
  86. package/engine/dist/services/synonyms/auto-synonym-generator.js +35 -35
  87. package/engine/dist/services/system-status.d.ts +34 -0
  88. package/engine/dist/services/system-status.d.ts.map +1 -1
  89. package/engine/dist/services/system-status.js +57 -1
  90. package/engine/dist/services/system-status.js.map +1 -1
  91. package/engine/dist/services/tags/discovery.js +5 -5
  92. package/engine/dist/services/tags/infector.js +6 -6
  93. package/engine/dist/services/tags/tag-auditor.js +51 -51
  94. package/engine/dist/services/taxonomy/taxonomy-manager.js +6 -6
  95. package/engine/dist/utils/tag-cleanup.js +5 -5
  96. package/engine/dist/utils/tag-modulation.js +1 -1
  97. package/engine/dist/utils/tag-modulation.js.map +1 -1
  98. package/engine/package.json +1 -2
  99. package/mcp-server/README.md +404 -0
  100. package/mcp-server/dist/index.d.ts +16 -0
  101. package/mcp-server/dist/index.d.ts.map +1 -0
  102. package/mcp-server/dist/index.js +709 -0
  103. package/mcp-server/dist/index.js.map +1 -0
  104. package/mcp-server/package.json +34 -0
  105. package/package.json +10 -2
  106. package/docs/archive/GIT_BACKUP_VERIFICATION.md +0 -297
  107. package/docs/archive/adoption-guide.md +0 -264
  108. package/docs/archive/adoption-preparation.md +0 -179
  109. package/docs/archive/agent-harness-integration.md +0 -227
  110. package/docs/archive/api-reference.md +0 -106
  111. package/docs/archive/api_flows_diagram.md +0 -118
  112. package/docs/archive/architecture.md +0 -410
  113. package/docs/archive/architecture_diagram.md +0 -174
  114. package/docs/archive/broader-adoption-preparation.md +0 -175
  115. package/docs/archive/browser-paradigm-architecture.md +0 -163
  116. package/docs/archive/chat-integration.md +0 -124
  117. package/docs/archive/community-adoption-materials.md +0 -103
  118. package/docs/archive/community-adoption.md +0 -147
  119. package/docs/archive/comparison-with-siloed-solutions.md +0 -192
  120. package/docs/archive/comprehensive-docs.md +0 -156
  121. package/docs/archive/data_flow_diagram.md +0 -251
  122. package/docs/archive/enhancement-implementation-summary.md +0 -146
  123. package/docs/archive/evolution-summary.md +0 -141
  124. package/docs/archive/ingestion_pipeline_diagram.md +0 -198
  125. package/docs/archive/native-module-profiling-results.md +0 -135
  126. package/docs/archive/positioning-document.md +0 -158
  127. package/docs/archive/positioning.md +0 -175
  128. package/docs/archive/query-builder-documentation.md +0 -218
  129. package/docs/archive/quick-reference.md +0 -40
  130. package/docs/archive/quickstart.md +0 -63
  131. package/docs/archive/relationship-narrative-discovery.md +0 -141
  132. package/docs/archive/search-logic-improvement-plan.md +0 -336
  133. package/docs/archive/search_architecture_diagram.md +0 -212
  134. package/docs/archive/semantic-architecture-guide.md +0 -97
  135. package/docs/archive/sequence-diagrams.md +0 -128
  136. package/docs/archive/system_components_diagram.md +0 -296
  137. package/docs/archive/test-framework-integration.md +0 -109
  138. package/docs/archive/testing-framework-documentation.md +0 -397
  139. package/docs/archive/testing-framework-summary.md +0 -121
  140. package/docs/archive/testing-framework.md +0 -377
  141. package/docs/archive/ui-architecture.md +0 -75
package/README.md CHANGED
@@ -67,7 +67,25 @@ open http://localhost:3160
67
67
 
68
68
  That's it! You now have a sovereign memory system for your LLM.
69
69
 
70
- **Full installation guide:** [INSTALL_NPM.md](INSTALL_NPM.md)
70
+ ### Data Directory Structure
71
+
72
+ All user data is stored in the `local-data/` directory:
73
+
74
+ - **`local-data/inbox/`** - Your sovereign content (internal provenance, 3.0x boost)
75
+ - Files you create or write directly
76
+ - Higher priority in search results
77
+
78
+ - **`local-data/external-inbox/`** - External content (external provenance, 1.0x boost)
79
+ - Web scrapes, news articles, RSS feeds
80
+ - Content from external sources
81
+
82
+ - **`local-data/mirrored_brain/`** - Auto-generated mirror of ingested content
83
+ - Cleaned, processed versions of your files
84
+ - Stripped of noise, timestamps, and PII
85
+
86
+ **Note:** The `local-data/` directory is gitignored by default to protect your data and privacy.
87
+
88
+ **Full installation guide:** [docs/guides/INSTALL_NPM.md](docs/guides/INSTALL_NPM.md)
71
89
 
72
90
  ---
73
91
 
@@ -176,6 +194,164 @@ curl -X POST http://localhost:3160/v1/memory/search \
176
194
 
177
195
  ---
178
196
 
197
+ ## 🧠 MCP Server – Memory for Your AI Agent
198
+
199
+ Anchor Engine can act as an **MCP (Model Context Protocol) server**, giving any MCP‑compatible agent persistent, deterministic memory.
200
+
201
+ ### Install
202
+
203
+ ```bash
204
+ # Install globally for CLI access
205
+ npm install -g @rbalchii/anchor-engine
206
+
207
+ # Or use npx directly
208
+ npx @rbalchii/anchor-engine
209
+ ```
210
+
211
+ ### Start the MCP Server
212
+
213
+ ```bash
214
+ # Option 1: Use the dedicated MCP binary
215
+ anchor-mcp
216
+
217
+ # Option 2: Start via main CLI
218
+ anchor mcp
219
+
220
+ # Option 3: Run directly with npx
221
+ npx anchor-mcp
222
+ ```
223
+
224
+ The server runs in **stdio mode**, communicating directly with your AI agent.
225
+
226
+ ### Available Tools
227
+
228
+ | Tool | Description |
229
+ |------|-------------|
230
+ | `anchor_query` | Search memory with token budget and provenance tracking |
231
+ | `anchor_distill` | Create checkpoint summaries from sessions |
232
+ | `anchor_illuminate` | BFS graph traversal for exploration |
233
+ | `anchor_read_file` | Read files by line ranges (token-efficient) |
234
+ | `anchor_list_compounds` | List available source files |
235
+ | `anchor_get_stats` | Check engine health and database stats |
236
+ | `anchor_ingest_text` | Add raw text content (opt-in, disabled by default) |
237
+ | `anchor_ingest_file` | Ingest files from filesystem (opt-in) |
238
+
239
+ ### Configuration
240
+
241
+ Create a `user_settings.json` in your project root:
242
+
243
+ ```json
244
+ {
245
+ "server": {
246
+ "port": 3160,
247
+ "api_key": "your-secret-key"
248
+ },
249
+ "mcp": {
250
+ "allow_write_operations": false,
251
+ "default_bucket_for_writes": "external-inbox",
252
+ "rate_limit_requests_per_minute": 60,
253
+ "max_query_results": 50
254
+ }
255
+ }
256
+ ```
257
+
258
+ Or set environment variables:
259
+ ```bash
260
+ export ANCHOR_API_URL="http://localhost:3160"
261
+ export ANCHOR_API_KEY="your-secret-key"
262
+ ```
263
+
264
+ ### Agent Examples
265
+
266
+ #### Claude Desktop
267
+
268
+ Add to `claude_desktop_config.json`:
269
+
270
+ ```json
271
+ {
272
+ "mcpServers": {
273
+ "anchor": {
274
+ "command": "npx",
275
+ "args": ["@rbalchii/anchor-engine", "mcp"]
276
+ }
277
+ }
278
+ }
279
+ ```
280
+
281
+ Or if installed globally:
282
+ ```json
283
+ {
284
+ "mcpServers": {
285
+ "anchor": {
286
+ "command": "anchor-mcp"
287
+ }
288
+ }
289
+ }
290
+ ```
291
+
292
+ #### Qwen Code
293
+
294
+ Qwen Code automatically detects MCP servers. Just run:
295
+ ```bash
296
+ anchor-mcp
297
+ ```
298
+
299
+ Then use tools in chat:
300
+ ```
301
+ /anchor_query query="What did we decide about authentication?"
302
+ ```
303
+
304
+ #### Cursor
305
+
306
+ Add to Cursor MCP settings:
307
+ ```json
308
+ {
309
+ "command": "anchor-mcp",
310
+ "env": {
311
+ "ANCHOR_API_URL": "http://localhost:3160"
312
+ }
313
+ }
314
+ ```
315
+
316
+ ### Quick-Start Demo (2 Minutes)
317
+
318
+ ```bash
319
+ # 1. Start the MCP server
320
+ anchor-mcp &
321
+
322
+ # 2. Ingest some text (via API for demo)
323
+ curl -X POST http://localhost:3160/v1/research/upload-raw \
324
+ -H "Content-Type: application/json" \
325
+ -d '{
326
+ "content": "The STAR algorithm uses physics-based scoring with temporal decay.",
327
+ "filename": "star-notes.md",
328
+ "bucket": "inbox"
329
+ }'
330
+
331
+ # 3. Search for it
332
+ curl -X POST http://localhost:3160/v1/memory/search \
333
+ -H "Content-Type: application/json" \
334
+ -d '{
335
+ "query": "STAR algorithm physics scoring",
336
+ "token_budget": 1024
337
+ }'
338
+
339
+ # 4. Or use MCP tools in your AI agent
340
+ # In Claude/Qwen: "/anchor_query query=STAR algorithm"
341
+ ```
342
+
343
+ ### Security
344
+
345
+ - **Write operations disabled by default** – Must explicitly enable in settings
346
+ - **Rate limiting** – Configurable requests per minute
347
+ - **API key authentication** – Optional but recommended
348
+ - **Localhost restriction** – Only accept local connections by default
349
+ - **Bucket safety** – Defaults to `external-inbox` for untrusted content
350
+
351
+ See full documentation: **[mcp-server/README.md](mcp-server/README.md)**
352
+
353
+ ---
354
+
179
355
  ## 🏛️ Our Philosophy: AI Memory Should Work Like Your Brain
180
356
 
181
357
  Human memory is remarkably efficient. It runs on ~20 watts, forgets irrelevant details, and over time clarifies core truths rather than drowning in noise. It doesn't store raw experiences—it stores *patterns*, *relationships*, and *meaning*.
package/anchor.bat CHANGED
@@ -1,5 +1,5 @@
1
- @echo off
2
- echo Launching Anchor Console...
3
- cd engine
4
- npx ts-node tools/anchor.ts
5
- pause
1
+ @echo off
2
+ echo Launching Anchor Console...
3
+ cd engine
4
+ npx ts-node tools/anchor.ts
5
+ pause