@rbalchii/anchor-engine 4.7.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 +513 -317
  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 +104 -105
  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
@@ -0,0 +1,404 @@
1
+ # Anchor Engine MCP Server
2
+
3
+ Model Context Protocol (MCP) server for Anchor Engine. Exposes your knowledge graph to any MCP-compatible AI client (Claude, Cursor, Qwen Code, etc.).
4
+
5
+ ## Features
6
+
7
+ ### Read Operations (Always Available)
8
+ - **🔍 Semantic Search** - Query your memory with `anchor_query`
9
+ - **🧪 Radial Distillation** - Compress knowledge into source-of-truth files
10
+ - **🌐 Graph Exploration** - BFS traversal with `anchor_illuminate`
11
+ - **📄 Token-Efficient Reading** - Read files by line ranges
12
+ - **📊 Real-time Stats** - Monitor your knowledge graph
13
+
14
+ ### Write Operations (Opt-In, Disabled by Default)
15
+ - **📝 Text Ingestion** - Add raw text content with `anchor_ingest_text`
16
+ - **📁 File Ingestion** - Ingest files from filesystem with `anchor_ingest_file`
17
+ - **🪣 Bucket Selection** - Choose `inbox` (sovereign) or `external-inbox` (external)
18
+ - **🔐 Security Toggle** - Enable/disable write operations via settings
19
+
20
+ ---
21
+
22
+ ## What's New in v4.8.0
23
+
24
+ ### Write Operations (NEW!)
25
+
26
+ The MCP server now supports **ingesting content** into Anchor Engine, not just querying it. This allows AI agents to add knowledge to your memory graph.
27
+
28
+ **Two New Tools:**
29
+
30
+ 1. **`anchor_ingest_text`** - Add raw text content
31
+ - Perfect for: Meeting notes, thoughts, code snippets, emails
32
+ - Deterministic atomization (no LLM processing)
33
+ - Bucket selection: `inbox` (sovereign) or `external-inbox` (external)
34
+
35
+ 2. **`anchor_ingest_file`** - Ingest files from filesystem
36
+ - Perfect for: Documents, articles, downloaded content
37
+ - Reads file and ingests in one operation
38
+ - Defaults to `external-inbox` for safety
39
+
40
+ **Security First:**
41
+ - Write operations are **disabled by default**
42
+ - Must explicitly enable in `user_settings.json`
43
+ - Defaults to `external-inbox` (lower trust) for safety
44
+ - Clear guidance on when to use `inbox` vs `external-inbox`
45
+
46
+ **Example Usage:**
47
+ ```typescript
48
+ // AI agent adds meeting notes
49
+ anchor_ingest_text({
50
+ content: "Meeting summary...",
51
+ filename: "meeting-2026-03-18.md",
52
+ bucket: "inbox" // You created this content
53
+ })
54
+
55
+ // AI agent ingests downloaded article
56
+ anchor_ingest_file({
57
+ path: "~/downloads/article.html",
58
+ bucket: "external-inbox" // External content
59
+ })
60
+ ```
61
+
62
+ **Enable Write Operations:**
63
+ ```json
64
+ {
65
+ "mcp": {
66
+ "allow_write_operations": true,
67
+ "default_bucket_for_writes": "external-inbox"
68
+ }
69
+ }
70
+ ```
71
+
72
+ ⚠️ **Only enable write operations if you trust the AI agent.** The default `external-inbox` bucket ensures untrusted data gets lower retrieval priority until you review it.
73
+
74
+ ---
75
+
76
+ ## Installation
77
+
78
+ ```bash
79
+ # From the anchor-engine-node directory
80
+ cd mcp-server
81
+ pnpm install
82
+ pnpm build
83
+ ```
84
+
85
+ ## Configuration
86
+
87
+ ### For Claude Desktop
88
+
89
+ Add to `~/.config/claude/claude_desktop_config.json`:
90
+
91
+ ```json
92
+ {
93
+ "mcpServers": {
94
+ "anchor": {
95
+ "command": "node",
96
+ "args": ["/path/to/anchor-engine-node/mcp-server/dist/index.js"],
97
+ "env": {
98
+ "ANCHOR_API_URL": "http://localhost:3160"
99
+ }
100
+ }
101
+ }
102
+ }
103
+ ```
104
+
105
+ ### For Cursor
106
+
107
+ Add to `~/.cursor/mcp.json`:
108
+
109
+ ```json
110
+ {
111
+ "mcpServers": {
112
+ "anchor": {
113
+ "command": "node",
114
+ "args": ["/path/to/anchor-engine-node/mcp-server/dist/index.js"],
115
+ "env": {
116
+ "ANCHOR_API_URL": "http://localhost:3160"
117
+ }
118
+ }
119
+ }
120
+ }
121
+ ```
122
+
123
+ ### For Qwen Code / Quinn CLI
124
+
125
+ Add to your Qwen config (usually `~/.config/qwen/mcp.json` or similar):
126
+
127
+ ```json
128
+ {
129
+ "mcpServers": {
130
+ "anchor": {
131
+ "type": "stdio",
132
+ "command": "node",
133
+ "args": ["/data/data/com.termux/files/home/projects/anchor-engine-node/mcp-server/dist/index.js"],
134
+ "env": {
135
+ "ANCHOR_API_URL": "http://localhost:3160"
136
+ }
137
+ }
138
+ }
139
+ }
140
+ ```
141
+
142
+ Or in your `.qwen/settings.json`:
143
+
144
+ ```json
145
+ {
146
+ "mcp": {
147
+ "servers": [
148
+ {
149
+ "name": "anchor",
150
+ "command": "node /data/data/com.termux/files/home/projects/anchor-engine-node/mcp-server/dist/index.js",
151
+ "env": {
152
+ "ANCHOR_API_URL": "http://localhost:3160"
153
+ }
154
+ }
155
+ ]
156
+ }
157
+ }
158
+ ```
159
+
160
+ ## Available Tools
161
+
162
+ ### `anchor_query`
163
+
164
+ Search your knowledge graph.
165
+
166
+ ```json
167
+ {
168
+ "query": "machine learning patterns",
169
+ "max_results": 10,
170
+ "strategy": "standard"
171
+ }
172
+ ```
173
+
174
+ ### `anchor_distill`
175
+
176
+ Create a compressed knowledge file.
177
+
178
+ ```json
179
+ {
180
+ "seed": "neural networks",
181
+ "radius": 3,
182
+ "max_nodes": 500
183
+ }
184
+ ```
185
+
186
+ ### `anchor_illuminate`
187
+
188
+ Explore connected concepts.
189
+
190
+ ```json
191
+ {
192
+ "seed": "transformer architecture",
193
+ "depth": 3
194
+ }
195
+ ```
196
+
197
+ ### `anchor_read_file`
198
+
199
+ Read files efficiently with line ranges.
200
+
201
+ ```json
202
+ {
203
+ "path": "inbox/distilled/distilled_2026-03-11.yaml",
204
+ "start_line": 0,
205
+ "end_line": 100
206
+ }
207
+ ```
208
+
209
+ ### `anchor_list_compounds`
210
+
211
+ List available source files.
212
+
213
+ ```json
214
+ {
215
+ "limit": 20
216
+ }
217
+ ```
218
+
219
+ ### `anchor_get_stats`
220
+
221
+ Get system statistics.
222
+
223
+ ```json
224
+ {}
225
+ ```
226
+
227
+ ### `anchor_ingest_text` (NEW in v4.8.0)
228
+
229
+ Ingest raw text content into Anchor Engine memory. Content is atomized deterministically (no LLM processing).
230
+
231
+ **Use Cases:**
232
+ - Meeting notes you wrote
233
+ - Personal thoughts and reflections
234
+ - Code snippets you created
235
+ - Email drafts
236
+ - Any sovereign content (content you created)
237
+
238
+ **Parameters:**
239
+ - `content` (required): Raw text content to ingest
240
+ - `filename` (required): Filename for the content (e.g., `meeting-notes.md`)
241
+ - `bucket` (optional): Destination bucket
242
+ - `"inbox"` - Sovereign data (you created it) → 3.0x retrieval boost
243
+ - `"external-inbox"` - External data (scraped/imported) → 1.0x boost
244
+ - **Default:** `"external-inbox"` (safer)
245
+ - `tags` (optional): Tags to apply (auto-extracted if not provided)
246
+
247
+ **Example:**
248
+ ```json
249
+ {
250
+ "content": "Meeting notes from today...\n\nAction items:\n1. Review PR #123\n2. Update documentation",
251
+ "filename": "meeting-2026-03-18.md",
252
+ "bucket": "inbox",
253
+ "tags": ["meetings", "action-items"]
254
+ }
255
+ ```
256
+
257
+ **Response:**
258
+ ```
259
+ ✅ Text ingested successfully!
260
+
261
+ 👑 Bucket: inbox - Sovereign data (3.0x retrieval boost)
262
+ 📄 Filename: meeting-2026-03-18.md
263
+ 📊 Size: 1,234 characters
264
+ 🏷️ Tags: meetings, action-items
265
+
266
+ 💡 Content will be atomized deterministically (no LLM processing).
267
+ Use anchor_query to search for this content after ingestion.
268
+ ```
269
+
270
+ ⚠️ **Note:** Write operations must be enabled in `user_settings.json`:
271
+ ```json
272
+ {
273
+ "mcp": {
274
+ "allow_write_operations": true,
275
+ "default_bucket_for_writes": "external-inbox"
276
+ }
277
+ }
278
+ ```
279
+
280
+ ---
281
+
282
+ ### `anchor_ingest_file` (NEW in v4.8.0)
283
+
284
+ Ingest a file from filesystem into Anchor Engine. Content is atomized deterministically.
285
+
286
+ **Use Cases:**
287
+ - Documents you wrote
288
+ - Code files from your projects
289
+ - Downloaded articles (use `external-inbox`)
290
+ - Research papers (use `external-inbox`)
291
+
292
+ **Parameters:**
293
+ - `path` (required): Absolute or relative path to file
294
+ - `bucket` (optional): Destination bucket
295
+ - `"inbox"` - Files you created
296
+ - `"external-inbox"` - External files (downloads, scrapes)
297
+ - **Default:** `"external-inbox"` (safer)
298
+ - `delete_original` (optional): Delete original file after ingestion (default: `false`)
299
+
300
+ **Example:**
301
+ ```json
302
+ {
303
+ "path": "~/notes/meeting-2026-03-18.md",
304
+ "bucket": "inbox"
305
+ }
306
+ ```
307
+
308
+ **Response:**
309
+ ```
310
+ ✅ File ingested successfully!
311
+
312
+ 👑 Bucket: inbox - Sovereign data (3.0x retrieval boost)
313
+ 📄 Filename: meeting-2026-03-18.md
314
+ 📊 Size: 1,234 characters
315
+ 📁 Source: /home/user/notes/meeting-2026-03-18.md
316
+
317
+ 💡 Content will be atomized deterministically (no LLM processing).
318
+ Use anchor_query to search for this content after ingestion.
319
+ ```
320
+
321
+ ⚠️ **Note:** Write operations must be enabled in `user_settings.json` (see above).
322
+
323
+ ---
324
+
325
+ ## 🪣 Bucket Selection Guide
326
+
327
+ **When to use `inbox`:**
328
+ - ✅ Content you created (notes, thoughts, code, emails)
329
+ - ✅ Files you wrote
330
+ - ✅ Personal knowledge
331
+ - ✅ Sovereign data (high trust, 3.0x retrieval boost)
332
+
333
+ **When to use `external-inbox`:**
334
+ - ✅ Web scrapes
335
+ - ✅ Downloaded articles
336
+ - ✅ Imported documents
337
+ - ✅ Third-party content
338
+ - ✅ External knowledge (lower trust, 1.0x boost)
339
+
340
+ **Default Behavior:** If not specified, defaults to `external-inbox` for safety. This ensures untrusted data doesn't pollute your sovereign knowledge graph until you review it.
341
+
342
+ ---
343
+
344
+ ## 🔒 Security Configuration
345
+
346
+ MCP is **disabled by default**. Enable it in `user_settings.json`:
347
+
348
+ ```json
349
+ {
350
+ "mcp": {
351
+ "enabled": true,
352
+ "require_api_key": true,
353
+ "api_key": "your-secure-key-here",
354
+ "rate_limit_requests_per_minute": 60,
355
+ "max_query_results": 50,
356
+ "restrict_to_localhost": true,
357
+ "allowed_operations": ["query", "read_file", "get_stats"],
358
+ "blocked_operations": []
359
+ }
360
+ }
361
+ ```
362
+
363
+ ### Security Features
364
+
365
+ - **Toggle**: Enable/disable MCP entirely
366
+ - **Rate limiting**: Configurable requests per minute
367
+ - **Operation filtering**: Allow/block specific operations
368
+ - **Result limits**: Cap max results returned
369
+ - **Localhost restriction**: Only accept local connections
370
+
371
+ ### Recommended Security Setup
372
+
373
+ For client data protection:
374
+
375
+ ```json
376
+ {
377
+ "mcp": {
378
+ "enabled": false, // Only enable when needed
379
+ "require_api_key": true,
380
+ "api_key": "<generate-random-key>",
381
+ "rate_limit_requests_per_minute": 30,
382
+ "max_query_results": 20,
383
+ "allowed_operations": ["query", "get_stats"], // Restrict dangerous ops
384
+ "blocked_operations": ["distill", "illuminate"]
385
+ }
386
+ }
387
+ ```
388
+
389
+ ## Token-Efficient Workflow
390
+
391
+ 1. **Distill** your corpus: `anchor_distill` with a seed query
392
+ 2. **Get** the output file path from results
393
+ 3. **Read** the file in chunks: `anchor_read_file` with line ranges
394
+ 4. **Search** recursively within chunks
395
+
396
+ This mimics Kimi's recursive search and saves massive token budgets!
397
+
398
+ ## Environment Variables
399
+
400
+ - `ANCHOR_API_URL` - Anchor Engine API endpoint (default: `http://localhost:3160`)
401
+
402
+ ## License
403
+
404
+ MIT
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Anchor Engine MCP Server
4
+ *
5
+ * Exposes Anchor's search, distill, and exploration capabilities
6
+ * to any MCP-compatible client (Claude, Cursor, Qwen Code, etc.)
7
+ *
8
+ * Tools:
9
+ * - anchor_query: Semantic search over the memory graph
10
+ * - anchor_distill: Run radial distillation on corpus
11
+ * - anchor_illuminate: BFS graph traversal
12
+ * - anchor_read_file: Read files with line ranges (token-efficient)
13
+ * - anchor_list_compounds: List available compounds
14
+ */
15
+ export {};
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG"}