@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.
- package/AGENT_INSTRUCTIONS.md +28 -41
- package/README.md +79 -37
- package/dist/adapters/weaviate-v3.adapter.d.ts.map +1 -1
- package/dist/adapters/weaviate-v3.adapter.js +6 -3
- package/dist/adapters/weaviate-v3.adapter.js.map +1 -1
- package/dist/cli/sync-ddd-docs.d.ts +17 -0
- package/dist/cli/sync-ddd-docs.d.ts.map +1 -1
- package/dist/cli/sync-ddd-docs.js +47 -75
- package/dist/cli/sync-ddd-docs.js.map +1 -1
- package/dist/server.js +1 -1
- package/dist/tools/admin.tool.d.ts +53 -0
- package/dist/tools/admin.tool.d.ts.map +1 -0
- package/dist/tools/admin.tool.js +447 -0
- package/dist/tools/admin.tool.js.map +1 -0
- package/dist/tools/analyze.tool.d.ts +44 -0
- package/dist/tools/analyze.tool.d.ts.map +1 -0
- package/dist/tools/analyze.tool.js +263 -0
- package/dist/tools/analyze.tool.js.map +1 -0
- package/dist/tools/index.d.ts +9 -3
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +15 -111
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/recall.tool.d.ts +20 -1
- package/dist/tools/recall.tool.d.ts.map +1 -1
- package/dist/tools/recall.tool.js +187 -51
- package/dist/tools/recall.tool.js.map +1 -1
- package/dist/tools/store.tool.d.ts +23 -8
- package/dist/tools/store.tool.d.ts.map +1 -1
- package/dist/tools/store.tool.js +185 -36
- package/dist/tools/store.tool.js.map +1 -1
- package/dist/tools/sync.tool.d.ts +28 -0
- package/dist/tools/sync.tool.d.ts.map +1 -0
- package/dist/tools/sync.tool.js +484 -0
- package/dist/tools/sync.tool.js.map +1 -0
- package/dist/types.d.ts +24 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/sync-engine.d.ts +60 -0
- package/dist/utils/sync-engine.d.ts.map +1 -0
- package/dist/utils/sync-engine.js +342 -0
- package/dist/utils/sync-engine.js.map +1 -0
- package/package.json +1 -1
- package/dist/tools/audit.tool.d.ts +0 -8
- package/dist/tools/audit.tool.d.ts.map +0 -1
- package/dist/tools/audit.tool.js +0 -75
- package/dist/tools/audit.tool.js.map +0 -1
- package/dist/tools/compact.tool.d.ts +0 -16
- package/dist/tools/compact.tool.d.ts.map +0 -1
- package/dist/tools/compact.tool.js +0 -85
- package/dist/tools/compact.tool.js.map +0 -1
- package/dist/tools/correlate.tool.d.ts +0 -25
- package/dist/tools/correlate.tool.d.ts.map +0 -1
- package/dist/tools/correlate.tool.js +0 -87
- package/dist/tools/correlate.tool.js.map +0 -1
- package/dist/tools/forget.tool.d.ts +0 -11
- package/dist/tools/forget.tool.d.ts.map +0 -1
- package/dist/tools/forget.tool.js +0 -27
- package/dist/tools/forget.tool.js.map +0 -1
- package/dist/tools/health.tool.d.ts +0 -8
- package/dist/tools/health.tool.d.ts.map +0 -1
- package/dist/tools/health.tool.js +0 -51
- package/dist/tools/health.tool.js.map +0 -1
- package/dist/tools/reason.tool.d.ts +0 -15
- package/dist/tools/reason.tool.d.ts.map +0 -1
- package/dist/tools/reason.tool.js +0 -157
- package/dist/tools/reason.tool.js.map +0 -1
- package/dist/tools/search-code-artifacts.tool.d.ts +0 -15
- package/dist/tools/search-code-artifacts.tool.d.ts.map +0 -1
- package/dist/tools/search-code-artifacts.tool.js +0 -55
- package/dist/tools/search-code-artifacts.tool.js.map +0 -1
- package/dist/tools/search-documents.tool.d.ts +0 -14
- package/dist/tools/search-documents.tool.d.ts.map +0 -1
- package/dist/tools/search-documents.tool.js +0 -48
- package/dist/tools/search-documents.tool.js.map +0 -1
- package/dist/tools/search-test-artifacts.tool.d.ts +0 -14
- package/dist/tools/search-test-artifacts.tool.d.ts.map +0 -1
- package/dist/tools/search-test-artifacts.tool.js +0 -50
- package/dist/tools/search-test-artifacts.tool.js.map +0 -1
- package/dist/tools/stats.tool.d.ts +0 -10
- package/dist/tools/stats.tool.d.ts.map +0 -1
- package/dist/tools/stats.tool.js +0 -110
- package/dist/tools/stats.tool.js.map +0 -1
- package/dist/tools/store-code-artifact.tool.d.ts +0 -18
- package/dist/tools/store-code-artifact.tool.d.ts.map +0 -1
- package/dist/tools/store-code-artifact.tool.js +0 -57
- package/dist/tools/store-code-artifact.tool.js.map +0 -1
- package/dist/tools/store-document.tool.d.ts +0 -16
- package/dist/tools/store-document.tool.d.ts.map +0 -1
- package/dist/tools/store-document.tool.js +0 -56
- package/dist/tools/store-document.tool.js.map +0 -1
- package/dist/tools/store-test-artifact.tool.d.ts +0 -17
- package/dist/tools/store-test-artifact.tool.d.ts.map +0 -1
- package/dist/tools/store-test-artifact.tool.js +0 -56
- package/dist/tools/store-test-artifact.tool.js.map +0 -1
- package/dist/tools/timeline.tool.d.ts +0 -29
- package/dist/tools/timeline.tool.d.ts.map +0 -1
- package/dist/tools/timeline.tool.js +0 -83
- package/dist/tools/timeline.tool.js.map +0 -1
- package/dist/tools/update.tool.d.ts +0 -27
- package/dist/tools/update.tool.d.ts.map +0 -1
- package/dist/tools/update.tool.js +0 -101
- package/dist/tools/update.tool.js.map +0 -1
- package/dist/tools/verify.tool.d.ts +0 -10
- package/dist/tools/verify.tool.d.ts.map +0 -1
- package/dist/tools/verify.tool.js +0 -60
- package/dist/tools/verify.tool.js.map +0 -1
package/AGENT_INSTRUCTIONS.md
CHANGED
|
@@ -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 (
|
|
14
|
-
|
|
15
|
-
####
|
|
16
|
-
|
|
17
|
-
| Tool | When to use
|
|
18
|
-
| ------------------ |
|
|
19
|
-
| `cognitive_recall` | **At task start** —
|
|
20
|
-
| `cognitive_store` | After discovering an insight
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
| `
|
|
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
|
|
65
|
-
6. **
|
|
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
|
|
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
|
-
- **
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
|
111
|
-
|
|
112
|
-
| `
|
|
113
|
-
| `
|
|
114
|
-
| `
|
|
115
|
-
| `
|
|
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
|
-
|
|
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
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
|
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
|
-
###
|
|
168
|
+
### `cognitive_admin` — Maintenance & infrastructure
|
|
126
169
|
|
|
127
|
-
|
|
|
128
|
-
|
|
129
|
-
|
|
|
130
|
-
| `
|
|
131
|
-
|
|
|
132
|
-
| `
|
|
133
|
-
| `
|
|
134
|
-
| `
|
|
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
|
|
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
|
|
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
|
|
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;
|
|
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;AAqFrB,MAAM,WAAW,gBAAgB;I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AAI,CAAC;YAMvD,OAAO;YA4BP,kBAAkB;IAuBhC,KAAK,IAAI,IAAI;IAOP,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAwCxD,cAAc,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IA4CnE,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC;IA0HrC,qDAAqD;IACrD,OAAO,CAAC,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
|
|
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
|
|
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
|
|
1396
|
+
checksum,
|
|
1394
1397
|
lastSynced: now,
|
|
1395
1398
|
}),
|
|
1396
1399
|
});
|