@porast1/mcp-cognitive 1.1.0 → 2.1.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 (105) hide show
  1. package/AGENT_INSTRUCTIONS.md +28 -41
  2. package/README.md +79 -37
  3. package/dist/adapters/weaviate-v3.adapter.d.ts.map +1 -1
  4. package/dist/adapters/weaviate-v3.adapter.js +6 -3
  5. package/dist/adapters/weaviate-v3.adapter.js.map +1 -1
  6. package/dist/cli/sync-ddd-docs.d.ts +17 -0
  7. package/dist/cli/sync-ddd-docs.d.ts.map +1 -1
  8. package/dist/cli/sync-ddd-docs.js +47 -75
  9. package/dist/cli/sync-ddd-docs.js.map +1 -1
  10. package/dist/server.js +1 -1
  11. package/dist/tools/admin.tool.d.ts +53 -0
  12. package/dist/tools/admin.tool.d.ts.map +1 -0
  13. package/dist/tools/admin.tool.js +447 -0
  14. package/dist/tools/admin.tool.js.map +1 -0
  15. package/dist/tools/analyze.tool.d.ts +44 -0
  16. package/dist/tools/analyze.tool.d.ts.map +1 -0
  17. package/dist/tools/analyze.tool.js +263 -0
  18. package/dist/tools/analyze.tool.js.map +1 -0
  19. package/dist/tools/index.d.ts +9 -3
  20. package/dist/tools/index.d.ts.map +1 -1
  21. package/dist/tools/index.js +15 -111
  22. package/dist/tools/index.js.map +1 -1
  23. package/dist/tools/recall.tool.d.ts +20 -1
  24. package/dist/tools/recall.tool.d.ts.map +1 -1
  25. package/dist/tools/recall.tool.js +187 -51
  26. package/dist/tools/recall.tool.js.map +1 -1
  27. package/dist/tools/store.tool.d.ts +23 -8
  28. package/dist/tools/store.tool.d.ts.map +1 -1
  29. package/dist/tools/store.tool.js +185 -36
  30. package/dist/tools/store.tool.js.map +1 -1
  31. package/dist/tools/sync.tool.d.ts +28 -0
  32. package/dist/tools/sync.tool.d.ts.map +1 -0
  33. package/dist/tools/sync.tool.js +484 -0
  34. package/dist/tools/sync.tool.js.map +1 -0
  35. package/dist/types.d.ts +24 -1
  36. package/dist/types.d.ts.map +1 -1
  37. package/dist/utils/sync-engine.d.ts +60 -0
  38. package/dist/utils/sync-engine.d.ts.map +1 -0
  39. package/dist/utils/sync-engine.js +342 -0
  40. package/dist/utils/sync-engine.js.map +1 -0
  41. package/package.json +1 -1
  42. package/dist/tools/audit.tool.d.ts +0 -8
  43. package/dist/tools/audit.tool.d.ts.map +0 -1
  44. package/dist/tools/audit.tool.js +0 -75
  45. package/dist/tools/audit.tool.js.map +0 -1
  46. package/dist/tools/compact.tool.d.ts +0 -16
  47. package/dist/tools/compact.tool.d.ts.map +0 -1
  48. package/dist/tools/compact.tool.js +0 -85
  49. package/dist/tools/compact.tool.js.map +0 -1
  50. package/dist/tools/correlate.tool.d.ts +0 -25
  51. package/dist/tools/correlate.tool.d.ts.map +0 -1
  52. package/dist/tools/correlate.tool.js +0 -87
  53. package/dist/tools/correlate.tool.js.map +0 -1
  54. package/dist/tools/forget.tool.d.ts +0 -11
  55. package/dist/tools/forget.tool.d.ts.map +0 -1
  56. package/dist/tools/forget.tool.js +0 -27
  57. package/dist/tools/forget.tool.js.map +0 -1
  58. package/dist/tools/health.tool.d.ts +0 -8
  59. package/dist/tools/health.tool.d.ts.map +0 -1
  60. package/dist/tools/health.tool.js +0 -51
  61. package/dist/tools/health.tool.js.map +0 -1
  62. package/dist/tools/reason.tool.d.ts +0 -15
  63. package/dist/tools/reason.tool.d.ts.map +0 -1
  64. package/dist/tools/reason.tool.js +0 -157
  65. package/dist/tools/reason.tool.js.map +0 -1
  66. package/dist/tools/search-code-artifacts.tool.d.ts +0 -15
  67. package/dist/tools/search-code-artifacts.tool.d.ts.map +0 -1
  68. package/dist/tools/search-code-artifacts.tool.js +0 -55
  69. package/dist/tools/search-code-artifacts.tool.js.map +0 -1
  70. package/dist/tools/search-documents.tool.d.ts +0 -14
  71. package/dist/tools/search-documents.tool.d.ts.map +0 -1
  72. package/dist/tools/search-documents.tool.js +0 -48
  73. package/dist/tools/search-documents.tool.js.map +0 -1
  74. package/dist/tools/search-test-artifacts.tool.d.ts +0 -14
  75. package/dist/tools/search-test-artifacts.tool.d.ts.map +0 -1
  76. package/dist/tools/search-test-artifacts.tool.js +0 -50
  77. package/dist/tools/search-test-artifacts.tool.js.map +0 -1
  78. package/dist/tools/stats.tool.d.ts +0 -10
  79. package/dist/tools/stats.tool.d.ts.map +0 -1
  80. package/dist/tools/stats.tool.js +0 -110
  81. package/dist/tools/stats.tool.js.map +0 -1
  82. package/dist/tools/store-code-artifact.tool.d.ts +0 -18
  83. package/dist/tools/store-code-artifact.tool.d.ts.map +0 -1
  84. package/dist/tools/store-code-artifact.tool.js +0 -57
  85. package/dist/tools/store-code-artifact.tool.js.map +0 -1
  86. package/dist/tools/store-document.tool.d.ts +0 -16
  87. package/dist/tools/store-document.tool.d.ts.map +0 -1
  88. package/dist/tools/store-document.tool.js +0 -56
  89. package/dist/tools/store-document.tool.js.map +0 -1
  90. package/dist/tools/store-test-artifact.tool.d.ts +0 -17
  91. package/dist/tools/store-test-artifact.tool.d.ts.map +0 -1
  92. package/dist/tools/store-test-artifact.tool.js +0 -56
  93. package/dist/tools/store-test-artifact.tool.js.map +0 -1
  94. package/dist/tools/timeline.tool.d.ts +0 -29
  95. package/dist/tools/timeline.tool.d.ts.map +0 -1
  96. package/dist/tools/timeline.tool.js +0 -83
  97. package/dist/tools/timeline.tool.js.map +0 -1
  98. package/dist/tools/update.tool.d.ts +0 -27
  99. package/dist/tools/update.tool.d.ts.map +0 -1
  100. package/dist/tools/update.tool.js +0 -101
  101. package/dist/tools/update.tool.js.map +0 -1
  102. package/dist/tools/verify.tool.d.ts +0 -10
  103. package/dist/tools/verify.tool.d.ts.map +0 -1
  104. package/dist/tools/verify.tool.js +0 -60
  105. package/dist/tools/verify.tool.js.map +0 -1
@@ -10,45 +10,32 @@
10
10
  The project uses an MCP server (`mcp-cognitive`) backed by Weaviate hybrid search for persistent AI knowledge.
11
11
  Facts survive between sessions — recall them before searching the codebase.
12
12
 
13
- ### Tool Inventory (18 tools)
14
-
15
- #### CRUD Core Knowledge
16
-
17
- | Tool | When to use | Key params |
18
- | ------------------ | --------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
19
- | `cognitive_recall` | **At task start** — before codebase research. Search facts by semantic query, filter by module/tags/type. | `query?` (optional — omit for filter-only), `module?`, `modules?` (multi-module parallel), `tags?`, `types?`, `agent?`, `limit?` |
20
- | `cognitive_store` | After discovering an insight worth remembering. Use `dryRun=true` first to check for duplicates. | `fact`, `type` (invariant/policy/convention/observation/ephemeral), `module`, `citations?`, `tags?`, `confidence?`, `dryRun?` |
21
- | `cognitive_update` | To patch an existing fact in-place (confidence, tags, citations). Preserves ID and history. | `id` (UUID), `confidence?`, `type?`, `module?`, `tags?`, `addTags?`, `removeTags?`, `citations?` |
22
- | `cognitive_forget` | To archive outdated/incorrect facts (soft-delete with reason). | `id` (UUID), `reason` |
23
-
24
- #### Search & Discovery
25
-
26
- | Tool | When to use | Key params |
27
- | --------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
28
- | `cognitive_search_documents` | Find indexed docs (DDD, architecture, guides). | `query`, `docType?`, `module?`, `project?` |
29
- | `cognitive_search_code_artifacts` | Find indexed code by semantic meaning or keyword. | `query`, `module?`, `layer?`, `artifactType?` |
30
- | `cognitive_search_test_artifacts` | Find indexed tests by description or module. | `query`, `module?`, `testType?` |
31
- | `cognitive_correlate` | Cross-collection traceability: docs ↔ code ↔ tests. Gap detection. | `sourceId` or `sourceQuery`, `sourceCollection`, `targetCollections?`, `module?` |
32
-
33
- #### Indexing
34
-
35
- | Tool | When to use | Key params |
36
- | ------------------------------- | ----------------------------------------------------- | ------------------------------------------------------------ |
37
- | `cognitive_store_document` | Index a markdown doc chunk (auto-dedup via checksum). | `content`, `filePath`, `docType`, `project`, `checksum` |
38
- | `cognitive_store_code_artifact` | Index a TypeScript file with metadata. | `content`, `filePath`, `project`, `artifactType`, `checksum` |
39
- | `cognitive_store_test_artifact` | Index a test file with describe/it blocks. | `content`, `filePath`, `project`, `testType`, `checksum` |
40
-
41
- #### Analysis & Maintenance
42
-
43
- | Tool | When to use | Key params |
44
- | -------------------- | ---------------------------------------------------------------------------------------- | -------------------------------------------------- |
45
- | `cognitive_reason` | Need a synthesized answer, not raw facts. Groups by module/type, detects contradictions. | `question`, `modules?`, `depth?` (shallow/deep) |
46
- | `cognitive_timeline` | Review what was learned during a period. Chronological, grouped by day. | `since?`, `until?`, `module?`, `status?`, `order?` |
47
- | `cognitive_stats` | Quick overview before deciding what to do. Counts, top tags, activity. | `module?` |
48
- | `cognitive_verify` | After refactors — check if citation file paths still exist. | `factId?` (omit = verify all) |
49
- | `cognitive_audit` | Periodic quality check. Finds stale facts, broken citations, duplicates. Expensive. | _(no params)_ |
50
- | `cognitive_compact` | Merge duplicate facts. Preview first, then execute. | `mode` (preview/execute), `factIdA?`, `factIdB?` |
51
- | `cognitive_health` | Check Weaviate infrastructure is running. | _(no params)_ |
13
+ ### Tool Inventory (v2 — 5 unified tools)
14
+
15
+ #### Core Tools (daily use)
16
+
17
+ | Tool | When to use | Key params |
18
+ | ------------------ | ----------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
19
+ | `cognitive_recall` | **At task start** — search facts, docs, code, tests. Hybrid semantic + keyword, cross-encoder. | `query?`, `scope?` (all/facts/docs/code/tests), `module?`, `modules?`, `types?`, `tags?`, `agent?`, `docType?`, `layer?`, `testType?` |
20
+ | `cognitive_store` | After discovering an insight. Create, update, or archive facts with a single tool. | **Create:** `fact`, `type`, `module`, `citations?`, `tags?`, `dryRun?`. **Update:** `id` + fields. **Archive:** `id`, `archive: true`, `reason` |
21
+
22
+ #### Sync Tool (batch operations)
23
+
24
+ | Tool | When to use | Key params |
25
+ | ----------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------- |
26
+ | `cognitive_sync` | Sync docs/code/tests from `.cognitive/sync.json`. Or sync a single file. | `project`, `scope?` (all/docs/code/tests), `filePath?`, `dryRun?` |
27
+
28
+ #### Analysis Tool (periodic use)
29
+
30
+ | Tool | When to use | Key params |
31
+ | ------------------- | -------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
32
+ | `cognitive_analyze` | Cross-collection correlation (docs↔code↔tests) or structured reasoning. | **correlate:** `action: "correlate"`, `sourceCollection`, `sourceQuery`/`sourceId`. **reason:** `action: "reason"`, `question`, `depth?` |
33
+
34
+ #### Admin Tool (maintenance)
35
+
36
+ | Tool | When to use | Key params |
37
+ | ----------------- | ------------------------------------------------------------ | --------------------------------------------------------- |
38
+ | `cognitive_admin` | Infrastructure health, stats, audit, compact, verify, timeline | `action` (health/stats/audit/compact/verify/timeline) + action-specific params |
52
39
 
53
40
  ### Workflow Rules
54
41
 
@@ -61,8 +48,8 @@ Facts survive between sessions — recall them before searching the codebase.
61
48
  - `convention` (0.85–0.9) — team conventions, audit every 6 months
62
49
  - `observation` (0.7–0.8) — debugging insights, re-verify in 30 days
63
50
  - `ephemeral` (any) — temporary notes, auto-expire in 7 days
64
- 5. **Update > Supersede** — use `cognitive_update` to patch facts. Only use `store({ supersedes })` when the fact text itself changed fundamentally.
65
- 6. **Forget with reason** — when archiving, always explain why so the knowledge graph stays auditable.
51
+ 5. **Update via `cognitive_store`** — use `cognitive_store({ id: "uuid", ... })` to patch existing facts. Use `supersedes` only when the fact text changed fundamentally.
52
+ 6. **Archive with reason** — use `cognitive_store({ id: "uuid", archive: true, reason: "..." })` so the knowledge graph stays auditable.
66
53
 
67
54
  ### Example: Typical Agent Flow
68
55
 
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Universal [MCP](https://modelcontextprotocol.io/) server that gives AI agents persistent, searchable memory backed by [Weaviate](https://weaviate.io/) hybrid search (BM25 keyword + vector embeddings + cross-encoder reranking).
4
4
 
5
- Store facts, documents, code artifacts, and test artifacts. Query them with semantic search, filter by module/type/tags, reason across knowledge, detect contradictions, and keep the database healthy — all from 18 MCP tools.
5
+ Store facts, documents, code artifacts, and test artifacts. Query them with semantic search, filter by module/type/tags, reason across knowledge, detect contradictions, and keep the database healthy — all from 5 unified MCP tools.
6
6
 
7
7
  ## Why
8
8
 
@@ -12,7 +12,7 @@ LLM agents lose context between sessions.
12
12
  - **Hybrid search** — BM25 keyword matching + transformer vector embeddings + reranking. Not just text search.
13
13
  - **Multi-tenancy** — one Weaviate instance, many projects. Data fully isolated via `WEAVIATE_TENANT`.
14
14
  - **4 collections** — `CognitiveFact`, `DocumentChunk`, `CodeArtifact`, `TestArtifact`. Facts, docs, code, tests.
15
- - **18 MCP tools** — CRUD, search, reasoning, audit, correlation, compaction, timeline, stats.
15
+ - **5 unified MCP tools** — recall, store, sync, analyze, admin. Consolidated from 18 v1 tools for cleaner agent interaction.
16
16
  - **Agent profiles** — tune recall per agent role (architect vs. tester vs. debugger).
17
17
  - **Pattern detection** — auto-detect conventions from git diffs via post-commit hooks.
18
18
  - **Zero vendor lock-in** — port/adapter architecture. Weaviate is the sole adapter today.
@@ -71,7 +71,7 @@ Then add to `.vscode/mcp.json` (or copy from `.cognitive/mcp.jsonc`):
71
71
 
72
72
  ### 4. Done
73
73
 
74
- The MCP server registers 18 tools automatically. Your AI agent can now store and recall knowledge.
74
+ The MCP server registers 5 unified tools automatically. Your AI agent can now store and recall knowledge.
75
75
 
76
76
  ---
77
77
 
@@ -94,45 +94,87 @@ Full reference in [`config/.env.example`](config/.env.example). Key variables:
94
94
 
95
95
  ---
96
96
 
97
- ## Tools Reference
97
+ ## Tools Reference (v2 — 5 unified tools)
98
98
 
99
- ### Core Knowledge (CRUD)
99
+ > **v2.0.0** consolidated 18 v1 tools into 5 unified tools. Old v1 tool names are preserved in `src/tools/v1/` for reference.
100
100
 
101
- | Tool | Description |
102
- | ------------------ | ---------------------------------------------------------------------------------------------------------------- |
103
- | `cognitive_store` | Store a new fact. Supports `dryRun=true` to check for duplicates before writing. |
104
- | `cognitive_recall` | Hybrid search facts. Query is optional (filter-only mode). Supports `modules[]` for multi-module parallel query. |
105
- | `cognitive_update` | Patch a fact in-place (confidence, tags, citations, module, type). Supports incremental `addTags`/`removeTags`. |
106
- | `cognitive_forget` | Archive (soft-delete) a fact with a reason. |
101
+ ### `cognitive_recall` — Unified search across all collections
107
102
 
108
- ### Search & Discovery
103
+ Search facts, documents, code artifacts, and test artifacts with a single tool. Uses hybrid BM25 + vector search with cross-encoder reranking.
109
104
 
110
- | Tool | Description |
111
- | --------------------------------- | ---------------------------------------------------------------------------------- |
112
- | `cognitive_search_documents` | Hybrid search across indexed document chunks (DDD docs, architecture, guides). |
113
- | `cognitive_search_code_artifacts` | Semantic search across indexed TypeScript code (entities, use cases, ports). |
114
- | `cognitive_search_test_artifacts` | Semantic search across indexed tests (unit, integration, E2E). |
115
- | `cognitive_correlate` | Cross-collection correlation: docs code ↔ tests. Gap detection & traceability. |
105
+ | Param | Description |
106
+ |-------|-------------|
107
+ | `query` | Semantic or keyword search query. Optional for `scope: "facts"` (filter-only browsing). |
108
+ | `scope` | `"all"` (default) \| `"facts"` \| `"docs"` \| `"code"` \| `"tests"` |
109
+ | `module` | Filter by bounded context / module |
110
+ | `modules` | Multi-module parallel query (OR logic) |
111
+ | `types` | Filter by fact types (facts scope only) |
112
+ | `tags` | Filter by tags — all must match (facts scope only) |
113
+ | `agent` | Agent name for profile-based filtering |
114
+ | `docType` | `"DDD"`, `"ARCHITECTURE"`, `"GUIDE"`, `"README"` (docs scope only) |
115
+ | `layer` | `"domain"`, `"application"`, `"infrastructure"` (code scope only) |
116
+ | `artifactType` | `"entity"`, `"usecase"`, `"port"`, `"adapter"` (code scope only) |
117
+ | `testType` | `"unit"`, `"integration"`, `"e2e"` (tests scope only) |
118
+ | `limit` | Max results per scope (default: 10) |
116
119
 
117
- ### Indexing
120
+ **Examples:**
121
+ ```
122
+ cognitive_recall({ query: "cross-BC isolation rules" })
123
+ cognitive_recall({ query: "Email value object", scope: "code", module: "identity" })
124
+ cognitive_recall({ scope: "facts", tags: ["architecture"], types: ["invariant"] })
125
+ ```
126
+
127
+ ### `cognitive_store` — Create, update, or archive facts
128
+
129
+ Unified fact management replacing `store`, `update`, and `forget`.
130
+
131
+ | Mode | Params | Description |
132
+ |------|--------|-------------|
133
+ | **Create** | `fact`, `type`, `module`, `citations?`, `tags?`, `confidence?`, `dryRun?` | Store a new fact. Use `dryRun: true` to check for duplicates first. |
134
+ | **Update** | `id`, + any patch fields (`confidence?`, `addTags?`, `removeTags?`, `type?`, `module?`) | Patch existing fact in-place. |
135
+ | **Archive** | `id`, `archive: true`, `reason` | Soft-delete with audit trail. |
136
+
137
+ **Examples:**
138
+ ```
139
+ cognitive_store({ fact: "Domain must be pure TS", type: "invariant", module: "architecture", citations: ["ARCH.md:L97"] })
140
+ cognitive_store({ id: "uuid", confidence: 0.95, addTags: ["verified"] })
141
+ cognitive_store({ id: "uuid", archive: true, reason: "outdated after refactor" })
142
+ ```
118
143
 
119
- | Tool | Description |
120
- | ------------------------------- | ------------------------------------------------------------ |
121
- | `cognitive_store_document` | Index a document chunk with checksum-based change detection. |
122
- | `cognitive_store_code_artifact` | Index a TypeScript code artifact with AST metadata. |
123
- | `cognitive_store_test_artifact` | Index a test file with describe/it block metadata. |
144
+ ### `cognitive_sync` — Batch & single-file synchronization
145
+
146
+ Sync documents, code artifacts, and test artifacts into the knowledge base.
147
+
148
+ | Mode | Params | Description |
149
+ |------|--------|-------------|
150
+ | **Batch** | `project`, `scope?` (`"all"` \| `"docs"` \| `"code"` \| `"tests"`) | Sync all files from `.cognitive/sync.json` config. |
151
+ | **Single-file** | `project`, `filePath` | Auto-detects collection from file extension. |
152
+
153
+ Supports `dryRun: true` for preview. Uses checksum-based change detection — unchanged files are skipped.
154
+
155
+ ### `cognitive_analyze` — Correlate artifacts & reason about knowledge
156
+
157
+ | Action | Params | Description |
158
+ |--------|--------|-------------|
159
+ | **correlate** | `sourceCollection`, `sourceQuery` or `sourceId`, `targetCollections?`, `minScore?` | Find semantically related artifacts across docs/code/tests. Scores: >0.65 = strong, 0.5–0.65 = partial. |
160
+ | **reason** | `question`, `modules?`, `depth?` (`"shallow"` \| `"deep"`) | Synthesize structured answer with contradiction detection. |
161
+
162
+ **Examples:**
163
+ ```
164
+ cognitive_analyze({ action: "correlate", sourceCollection: "DocumentChunk", sourceQuery: "user authentication" })
165
+ cognitive_analyze({ action: "reason", question: "What are the cross-BC isolation rules?" })
166
+ ```
124
167
 
125
- ### Analysis & Maintenance
168
+ ### `cognitive_admin` — Maintenance & infrastructure
126
169
 
127
- | Tool | Description |
128
- | -------------------- | ------------------------------------------------------------------------------------------ |
129
- | `cognitive_reason` | Synthesize a structured answer from facts — groups by module/type, detects contradictions. |
130
- | `cognitive_timeline` | Chronological view with date range filtering and daily grouping. |
131
- | `cognitive_stats` | Quick dashboard: counts by type/module/status, top tags, recent activity. |
132
- | `cognitive_verify` | Check if file:line citations still exist on disk. |
133
- | `cognitive_audit` | Full quality audit: stale facts, broken citations, duplicate candidates. |
134
- | `cognitive_compact` | Find and merge duplicate facts (preview or execute mode). |
135
- | `cognitive_health` | Weaviate infrastructure health: version, nodes, collections, tenants. |
170
+ | Action | Params | Description |
171
+ |--------|--------|-------------|
172
+ | **health** | _(none)_ | Weaviate infrastructure check: nodes, collections, tenants. |
173
+ | **stats** | `module?` | Quick dashboard: counts by type/module/status, top tags, activity. |
174
+ | **audit** | _(none)_ | Deep quality scan: stale facts, broken citations, duplicates, health score. |
175
+ | **compact** | `mode` (`"preview"` \| `"execute"`), `idA?`, `idB?` | Find & merge duplicate facts. Preview first, then execute. |
176
+ | **verify** | `id?` | Check citation integrity (files still exist on disk). Omit `id` to verify all. |
177
+ | **timeline** | `since?`, `until?`, `module?`, `types?`, `status?`, `order?` | Chronological fact view with date filtering and daily grouping. |
136
178
 
137
179
  ---
138
180
 
@@ -248,7 +290,7 @@ cd weaviate-dev-stack
248
290
  ./scripts/create-tenant.sh test-isolation-b
249
291
 
250
292
  # Run tests (uses TEST_TENANT constants, never touches production data)
251
- pnpm test # 162 tests covering all 18 tools + Phase 8 features
293
+ pnpm test # 162 tests covering all 5 unified tools + collections
252
294
  ```
253
295
 
254
296
  **Test Coverage:**
@@ -280,7 +322,7 @@ pnpm test # 162 tests covering all 18 tools + Phase 8 features
280
322
  ┌──────────────────────────────────────────────┐
281
323
  │ MCP Protocol (stdio) │
282
324
  ├──────────────────────────────────────────────┤
283
- │ server.ts — auto-registers 18 tools
325
+ │ server.ts — auto-registers 5 tools
284
326
  ├──────────────────────────────────────────────┤
285
327
  │ tools/*.tool.ts — Zod schema + execute fn │
286
328
  ├──────────────────────────────────────────────┤
@@ -334,7 +376,7 @@ your-project/
334
376
  ├── .vscode/
335
377
  │ └── mcp.json # MCP server config (from config/mcp.jsonc)
336
378
  ├── .env # Environment variables (from config/.env.example)
337
- └── .gitignore # Add: .cognitive/pending-facts.json, .cognitive/facts.sqlite
379
+ └── .gitignore # Add: .cognitive/pending-facts.json
338
380
  ```
339
381
 
340
382
  See [`examples/`](examples/) for pattern & profile templates with detailed documentation.
@@ -1 +1 @@
1
- {"version":3,"file":"weaviate-v3.adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/weaviate-v3.adapter.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,KAAK,EACV,WAAW,EAEX,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,EAEvB,gBAAgB,EAEhB,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EAEtB,IAAI,EACJ,SAAS,EAGT,YAAY,EACZ,MAAM,EAEN,WAAW,EACX,YAAY,EAEZ,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,EACvB,aAAa,EACb,cAAc,EACd,YAAY,EACb,MAAM,aAAa,CAAC;AAoFrB,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,C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WAAW;IAMb,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;YAuF/C,oBAAoB;IAiBlC,OAAO,CAAC,uBAAuB;IA0B/B,OAAO,CAAC,WAAW;CAuBpB"}
@@ -5,6 +5,7 @@ import { getAgentProfile } from '../profiles/agent-profiles.js';
5
5
  import { checkCitations, overallCitationStatus } from '../utils/citation-checker.js';
6
6
  import { checkDecayBatch } from '../utils/decay.js';
7
7
  import { guardReset, guardArchive, guardCompact } from '../utils/safety-guard.js';
8
+ import { computeChecksum } from '../utils/sync-engine.js';
8
9
  // ─── Collection Names ───────────────────────────────────────────────────────
9
10
  const FACT_COLLECTION = 'CognitiveFact';
10
11
  const DOC_COLLECTION = 'DocumentChunk';
@@ -1361,6 +1362,8 @@ export class WeaviateV3Store {
1361
1362
  'lastSynced',
1362
1363
  ];
1363
1364
  async storeDocument(input) {
1365
+ // Auto-calculate checksum if not provided by caller
1366
+ const checksum = input.checksum ?? computeChecksum(input.content);
1364
1367
  // Section included in UUID because a single file can produce multiple chunks (H2 splitting)
1365
1368
  const idSource = input.section
1366
1369
  ? `${input.filePath}:${input.project}:${input.section}`
@@ -1369,13 +1372,13 @@ export class WeaviateV3Store {
1369
1372
  collectionName: DOC_COLLECTION,
1370
1373
  deterministicId: generateUuid5(idSource, 'document'),
1371
1374
  returnProperties: WeaviateV3Store.DOC_RETURN_PROPS,
1372
- checksum: input.checksum,
1375
+ checksum,
1373
1376
  mutableProperties: {
1374
1377
  content: input.content,
1375
1378
  docType: input.docType,
1376
1379
  module: input.module ?? '',
1377
1380
  section: input.section ?? '',
1378
- checksum: input.checksum,
1381
+ checksum,
1379
1382
  },
1380
1383
  identityProperties: {
1381
1384
  filePath: input.filePath,
@@ -1390,7 +1393,7 @@ export class WeaviateV3Store {
1390
1393
  project: input.project,
1391
1394
  module: input.module,
1392
1395
  section: input.section,
1393
- checksum: input.checksum,
1396
+ checksum,
1394
1397
  lastSynced: now,
1395
1398
  }),
1396
1399
  });