gnosys 4.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 (188) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1387 -0
  3. package/dist/cli.d.ts +7 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +3753 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/index.d.ts +8 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +2267 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/lib/archive.d.ts +95 -0
  12. package/dist/lib/archive.d.ts.map +1 -0
  13. package/dist/lib/archive.js +311 -0
  14. package/dist/lib/archive.js.map +1 -0
  15. package/dist/lib/ask.d.ts +77 -0
  16. package/dist/lib/ask.d.ts.map +1 -0
  17. package/dist/lib/ask.js +316 -0
  18. package/dist/lib/ask.js.map +1 -0
  19. package/dist/lib/audit.d.ts +47 -0
  20. package/dist/lib/audit.d.ts.map +1 -0
  21. package/dist/lib/audit.js +136 -0
  22. package/dist/lib/audit.js.map +1 -0
  23. package/dist/lib/bootstrap.d.ts +56 -0
  24. package/dist/lib/bootstrap.d.ts.map +1 -0
  25. package/dist/lib/bootstrap.js +163 -0
  26. package/dist/lib/bootstrap.js.map +1 -0
  27. package/dist/lib/config.d.ts +239 -0
  28. package/dist/lib/config.d.ts.map +1 -0
  29. package/dist/lib/config.js +371 -0
  30. package/dist/lib/config.js.map +1 -0
  31. package/dist/lib/dashboard.d.ts +81 -0
  32. package/dist/lib/dashboard.d.ts.map +1 -0
  33. package/dist/lib/dashboard.js +314 -0
  34. package/dist/lib/dashboard.js.map +1 -0
  35. package/dist/lib/db.d.ts +182 -0
  36. package/dist/lib/db.d.ts.map +1 -0
  37. package/dist/lib/db.js +620 -0
  38. package/dist/lib/db.js.map +1 -0
  39. package/dist/lib/dbSearch.d.ts +65 -0
  40. package/dist/lib/dbSearch.d.ts.map +1 -0
  41. package/dist/lib/dbSearch.js +239 -0
  42. package/dist/lib/dbSearch.js.map +1 -0
  43. package/dist/lib/dbWrite.d.ts +56 -0
  44. package/dist/lib/dbWrite.d.ts.map +1 -0
  45. package/dist/lib/dbWrite.js +171 -0
  46. package/dist/lib/dbWrite.js.map +1 -0
  47. package/dist/lib/dream.d.ts +170 -0
  48. package/dist/lib/dream.d.ts.map +1 -0
  49. package/dist/lib/dream.js +706 -0
  50. package/dist/lib/dream.js.map +1 -0
  51. package/dist/lib/embeddings.d.ts +84 -0
  52. package/dist/lib/embeddings.d.ts.map +1 -0
  53. package/dist/lib/embeddings.js +226 -0
  54. package/dist/lib/embeddings.js.map +1 -0
  55. package/dist/lib/export.d.ts +92 -0
  56. package/dist/lib/export.d.ts.map +1 -0
  57. package/dist/lib/export.js +362 -0
  58. package/dist/lib/export.js.map +1 -0
  59. package/dist/lib/federated.d.ts +113 -0
  60. package/dist/lib/federated.d.ts.map +1 -0
  61. package/dist/lib/federated.js +346 -0
  62. package/dist/lib/federated.js.map +1 -0
  63. package/dist/lib/graph.d.ts +50 -0
  64. package/dist/lib/graph.d.ts.map +1 -0
  65. package/dist/lib/graph.js +118 -0
  66. package/dist/lib/graph.js.map +1 -0
  67. package/dist/lib/history.d.ts +39 -0
  68. package/dist/lib/history.d.ts.map +1 -0
  69. package/dist/lib/history.js +112 -0
  70. package/dist/lib/history.js.map +1 -0
  71. package/dist/lib/hybridSearch.d.ts +80 -0
  72. package/dist/lib/hybridSearch.d.ts.map +1 -0
  73. package/dist/lib/hybridSearch.js +296 -0
  74. package/dist/lib/hybridSearch.js.map +1 -0
  75. package/dist/lib/import.d.ts +52 -0
  76. package/dist/lib/import.d.ts.map +1 -0
  77. package/dist/lib/import.js +365 -0
  78. package/dist/lib/import.js.map +1 -0
  79. package/dist/lib/ingest.d.ts +51 -0
  80. package/dist/lib/ingest.d.ts.map +1 -0
  81. package/dist/lib/ingest.js +144 -0
  82. package/dist/lib/ingest.js.map +1 -0
  83. package/dist/lib/lensing.d.ts +35 -0
  84. package/dist/lib/lensing.d.ts.map +1 -0
  85. package/dist/lib/lensing.js +85 -0
  86. package/dist/lib/lensing.js.map +1 -0
  87. package/dist/lib/llm.d.ts +84 -0
  88. package/dist/lib/llm.d.ts.map +1 -0
  89. package/dist/lib/llm.js +386 -0
  90. package/dist/lib/llm.js.map +1 -0
  91. package/dist/lib/lock.d.ts +28 -0
  92. package/dist/lib/lock.d.ts.map +1 -0
  93. package/dist/lib/lock.js +145 -0
  94. package/dist/lib/lock.js.map +1 -0
  95. package/dist/lib/maintenance.d.ts +124 -0
  96. package/dist/lib/maintenance.d.ts.map +1 -0
  97. package/dist/lib/maintenance.js +587 -0
  98. package/dist/lib/maintenance.js.map +1 -0
  99. package/dist/lib/migrate.d.ts +19 -0
  100. package/dist/lib/migrate.d.ts.map +1 -0
  101. package/dist/lib/migrate.js +260 -0
  102. package/dist/lib/migrate.js.map +1 -0
  103. package/dist/lib/preferences.d.ts +49 -0
  104. package/dist/lib/preferences.d.ts.map +1 -0
  105. package/dist/lib/preferences.js +149 -0
  106. package/dist/lib/preferences.js.map +1 -0
  107. package/dist/lib/projectIdentity.d.ts +66 -0
  108. package/dist/lib/projectIdentity.d.ts.map +1 -0
  109. package/dist/lib/projectIdentity.js +148 -0
  110. package/dist/lib/projectIdentity.js.map +1 -0
  111. package/dist/lib/recall.d.ts +82 -0
  112. package/dist/lib/recall.d.ts.map +1 -0
  113. package/dist/lib/recall.js +289 -0
  114. package/dist/lib/recall.js.map +1 -0
  115. package/dist/lib/resolver.d.ts +116 -0
  116. package/dist/lib/resolver.d.ts.map +1 -0
  117. package/dist/lib/resolver.js +372 -0
  118. package/dist/lib/resolver.js.map +1 -0
  119. package/dist/lib/retry.d.ts +24 -0
  120. package/dist/lib/retry.d.ts.map +1 -0
  121. package/dist/lib/retry.js +60 -0
  122. package/dist/lib/retry.js.map +1 -0
  123. package/dist/lib/rulesGen.d.ts +51 -0
  124. package/dist/lib/rulesGen.d.ts.map +1 -0
  125. package/dist/lib/rulesGen.js +167 -0
  126. package/dist/lib/rulesGen.js.map +1 -0
  127. package/dist/lib/search.d.ts +51 -0
  128. package/dist/lib/search.d.ts.map +1 -0
  129. package/dist/lib/search.js +190 -0
  130. package/dist/lib/search.js.map +1 -0
  131. package/dist/lib/staticSearch.d.ts +70 -0
  132. package/dist/lib/staticSearch.d.ts.map +1 -0
  133. package/dist/lib/staticSearch.js +162 -0
  134. package/dist/lib/staticSearch.js.map +1 -0
  135. package/dist/lib/store.d.ts +79 -0
  136. package/dist/lib/store.d.ts.map +1 -0
  137. package/dist/lib/store.js +227 -0
  138. package/dist/lib/store.js.map +1 -0
  139. package/dist/lib/structuredIngest.d.ts +37 -0
  140. package/dist/lib/structuredIngest.d.ts.map +1 -0
  141. package/dist/lib/structuredIngest.js +208 -0
  142. package/dist/lib/structuredIngest.js.map +1 -0
  143. package/dist/lib/tags.d.ts +26 -0
  144. package/dist/lib/tags.d.ts.map +1 -0
  145. package/dist/lib/tags.js +109 -0
  146. package/dist/lib/tags.js.map +1 -0
  147. package/dist/lib/timeline.d.ts +34 -0
  148. package/dist/lib/timeline.d.ts.map +1 -0
  149. package/dist/lib/timeline.js +116 -0
  150. package/dist/lib/timeline.js.map +1 -0
  151. package/dist/lib/trace.d.ts +42 -0
  152. package/dist/lib/trace.d.ts.map +1 -0
  153. package/dist/lib/trace.js +338 -0
  154. package/dist/lib/trace.js.map +1 -0
  155. package/dist/lib/webIndex.d.ts +28 -0
  156. package/dist/lib/webIndex.d.ts.map +1 -0
  157. package/dist/lib/webIndex.js +208 -0
  158. package/dist/lib/webIndex.js.map +1 -0
  159. package/dist/lib/webIngest.d.ts +51 -0
  160. package/dist/lib/webIngest.d.ts.map +1 -0
  161. package/dist/lib/webIngest.js +533 -0
  162. package/dist/lib/webIngest.js.map +1 -0
  163. package/dist/lib/wikilinks.d.ts +63 -0
  164. package/dist/lib/wikilinks.d.ts.map +1 -0
  165. package/dist/lib/wikilinks.js +146 -0
  166. package/dist/lib/wikilinks.js.map +1 -0
  167. package/dist/sandbox/client.d.ts +82 -0
  168. package/dist/sandbox/client.d.ts.map +1 -0
  169. package/dist/sandbox/client.js +128 -0
  170. package/dist/sandbox/client.js.map +1 -0
  171. package/dist/sandbox/helper-template.d.ts +14 -0
  172. package/dist/sandbox/helper-template.d.ts.map +1 -0
  173. package/dist/sandbox/helper-template.js +285 -0
  174. package/dist/sandbox/helper-template.js.map +1 -0
  175. package/dist/sandbox/index.d.ts +10 -0
  176. package/dist/sandbox/index.d.ts.map +1 -0
  177. package/dist/sandbox/index.js +10 -0
  178. package/dist/sandbox/index.js.map +1 -0
  179. package/dist/sandbox/manager.d.ts +40 -0
  180. package/dist/sandbox/manager.d.ts.map +1 -0
  181. package/dist/sandbox/manager.js +220 -0
  182. package/dist/sandbox/manager.js.map +1 -0
  183. package/dist/sandbox/server.d.ts +44 -0
  184. package/dist/sandbox/server.d.ts.map +1 -0
  185. package/dist/sandbox/server.js +661 -0
  186. package/dist/sandbox/server.js.map +1 -0
  187. package/package.json +103 -0
  188. package/prompts/synthesize.md +21 -0
package/README.md ADDED
@@ -0,0 +1,1387 @@
1
+ <p align="center">
2
+ <img src="docs/logo.svg" alt="Gnosys" width="200">
3
+ </p>
4
+
5
+ <p align="center">
6
+ <a href="https://www.npmjs.com/package/gnosys"><img src="https://img.shields.io/npm/v/gnosys.svg" alt="npm version"></a>
7
+ <a href="https://github.com/proticom/gnosys/actions"><img src="https://github.com/proticom/gnosys/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
8
+ <img src="https://img.shields.io/badge/tests-558%20passing-brightgreen" alt="tests">
9
+ <img src="https://img.shields.io/badge/coverage-lib%2040%25%20|%20sandbox%2045%25-yellow" alt="coverage">
10
+ <a href="https://gnosys.ai"><img src="https://img.shields.io/badge/docs-gnosys.ai-C04C4C" alt="docs"></a>
11
+ <a href="https://gnosys.ai/guide.html"><img src="https://img.shields.io/badge/user%20guide-gnosys.ai%2Fguide-555560" alt="user guide"></a>
12
+ <a href="https://github.com/proticom/gnosys/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/gnosys.svg" alt="license"></a>
13
+ </p>
14
+
15
+ ---
16
+
17
+ > **Migrating from `gnosys-mcp`?** The package has been renamed to `gnosys`. Install with `npm install -g gnosys`. All previous versions under `gnosys-mcp` are deprecated.
18
+
19
+ ### Gnosys — One Brain. Zero Context Bloat.
20
+
21
+ **Gnosys** gives AI agents persistent memory that survives across sessions, projects, and machines.
22
+
23
+ In v3.0, Gnosys is **sandbox-first**: a persistent background process holds the database connection while agents import a tiny helper library and call memory operations like normal code — no MCP schemas, no round-trips, near-zero context cost. The central brain at `~/.gnosys/gnosys.db` unifies all projects, user preferences, and global knowledge. Federated search ranks results across scopes with tier boosting and recency awareness. Preferences drive automatic agent rules generation. Dream Mode consolidates knowledge during idle time. One-command export regenerates a full Obsidian vault.
24
+
25
+ It also runs as a CLI and a complete MCP server that drops straight into Cursor, Claude Desktop, Claude Code, Cowork, Codex, or any MCP client.
26
+
27
+ **Beyond agents**: Gnosys turns any structured dataset into a connected, versioned knowledge graph.
28
+ • NVD/CVE Database: 200k+ vulnerabilities auto-linked to packages, exploits, patches, and supersession history. Ask "which of our dependencies have active unpatched criticals?"
29
+ • USDA FoodData Central: ~8k foods atomized with wikilinks to nutrients and substitutions. Ask "high-protein, low-sodium, high-potassium alternatives to X?"
30
+
31
+ No vector DBs. No black boxes. No external services. Just SQLite, Markdown, and Obsidian — the way knowledge should be.
32
+
33
+ ---
34
+
35
+ ## Why Gnosys?
36
+
37
+ Most "memory for LLMs" solutions use vector databases, embeddings, or proprietary services. They're opaque — you can't see what the model remembers, can't edit it, can't version it, can't share it.
38
+
39
+ Gnosys takes a different approach: the central brain is a single SQLite database (`~/.gnosys/gnosys.db`) with sub-10ms reads, while every memory is also dual-written as a plain Markdown file with YAML frontmatter. The Markdown layer is a human-readable safety net and Obsidian export path — you can read it, edit it, grep it, and back it up with the tools you already use.
40
+
41
+ **What makes it different:**
42
+
43
+ - **Sandbox-first (v3.0)** — persistent background process + helper library. Agents call `gnosys.add()` / `gnosys.recall()` like regular code. No MCP overhead, near-zero context cost.
44
+ - **Centralized brain** — single `~/.gnosys/gnosys.db` unifies all projects with `project_id` + `scope` columns. No more per-project silos.
45
+ - **Federated search** — tier-boosted search across project (1.5x) → user (1.0x) → global (0.7x) scopes with recency and reinforcement boosts.
46
+ - **Preferences as memories** — user preferences stored as scoped memories, driving automatic agent rules generation via `gnosys sync`.
47
+ - **Project briefings** — instant project status: categories, recent activity, top tags, summary. Dream Mode pre-computes these.
48
+ - **Ambiguity detection** — when a query hits multiple projects, Gnosys lists all candidates instead of guessing wrong.
49
+ - **Agent-first SQLite** — sub-10ms reads/writes. Markdown files kept as a dual-write safety net.
50
+ - **Dream Mode** — idle-time consolidation: confidence decay, self-critique, summary generation, relationship discovery. Never deletes — only suggests reviews.
51
+ - **Transparent** — every memory has a human-readable `.md` file alongside the database. Export to Obsidian vault with one command.
52
+ - **Multi-project** — MCP roots + per-tool `projectRoot` routing + central project registry. Multiple Cursor windows, zero conflicts.
53
+ - **Freeform Ask** — natural-language questions, synthesized answers with Obsidian wikilink citations.
54
+ - **Hybrid Search** — FTS5 keyword + semantic embeddings via Reciprocal Rank Fusion (RRF).
55
+ - **Dual-write** — every memory writes to both SQLite and a human-readable `.md` file. The Markdown layer is a safety net and export path, not the primary store.
56
+ - **Obsidian-native** — `gnosys export` generates a full vault with YAML frontmatter, `[[wikilinks]]`, summaries, and graph data.
57
+ - **MCP-compatible** — also runs as a full MCP server that drops into Cursor, Claude Desktop, Claude Code, Cowork, Codex, or any MCP client with one config line.
58
+ - **Bulk import** — CSV, JSON, JSONL. Import entire datasets (USDA, NVD, your internal docs) in seconds.
59
+ - **Backup & restore** — `gnosys backup` + `gnosys restore` for the central DB. Point-in-time recovery.
60
+ - **Reflection API** — `gnosys.reflect(outcome)` updates confidence, adds relationships, and consolidates memories based on real-world outcomes.
61
+ - **Process tracing** — `gnosys trace <dir>` builds call chains from source code and stores them as procedural "how" memories with `leads_to`, `follows_from`, and `requires` relationships.
62
+ - **Relationship traversal** — `gnosys.traverse(id)` walks relationship chains via BFS with depth limiting and type filtering.
63
+ - **Web Knowledge Base (v4.0)** — `gnosys web build` turns any website into a searchable knowledge base for serverless chatbots. Pre-computed JSON index, zero-dependency runtime via `gnosys/web`, works on Vercel/Netlify/Cloudflare Pages without SQLite.
64
+ - **Zero infrastructure** — no external databases, no Docker (unless you want it), no cloud services. Just `npm install`.
65
+
66
+ ---
67
+
68
+ ## Real-World Use Cases
69
+
70
+ ### USDA FoodData Central — 100 foods imported in 0.6s
71
+
72
+ ![USDA import: 100 Foundation Foods with nutrient data, wikilinks to food categories](docs/screenshots/usda-import-result.png)
73
+
74
+ ```bash
75
+ gnosys import usda-foods.json \
76
+ --format json \
77
+ --mapping '{"title":"title","category":"category","content":"content","tags":"tags","relevance":"relevance"}' \
78
+ --mode structured --skip-existing
79
+ ```
80
+
81
+ Each food lands in the central `~/.gnosys/gnosys.db` as an atomic memory with nutrient data and `[[wikilinks]]` to food categories. A dual-write `.md` copy is kept for safety and Obsidian export:
82
+
83
+ ```yaml
84
+ ---
85
+ title: "Almond butter, creamy"
86
+ category: usda-foods
87
+ tags:
88
+ domain: [food, nutrition, usda]
89
+ relevance: "almond butter creamy food nutrition usda fdc nutrient diet dietary protein"
90
+ ---
91
+ # Almond butter, creamy
92
+
93
+ **Food Category:** [[General]]
94
+
95
+ ## Key Nutrients (per 100g)
96
+ - Protein (g): 20.4 G
97
+ - Total Fat (g): 55.7 G
98
+ - Calcium (mg): 264 MG
99
+ - Potassium (mg): 699 MG
100
+ ```
101
+
102
+ ### NVD/CVE Database — 20 vulnerabilities with CVSS scores and affected products
103
+
104
+ ![NVD import: CVEs with CVSS scores, severity tags, wikilinks to affected products](docs/screenshots/nvd-import-result.png)
105
+
106
+ ```bash
107
+ gnosys import nvd-cves.json \
108
+ --format json \
109
+ --mapping '{"title":"title","category":"category","content":"content","tags":"tags","relevance":"relevance"}' \
110
+ --mode structured --skip-existing
111
+ ```
112
+
113
+ Each CVE lands in the central DB and links to affected packages via wikilinks:
114
+
115
+ ```yaml
116
+ ---
117
+ title: CVE-1999-0095
118
+ tags:
119
+ domain: [cve, vulnerability, security, high]
120
+ relevance: "cve-1999-0095 cve vulnerability security nvd patch exploit high eric_allman sendmail"
121
+ ---
122
+ # CVE-1999-0095
123
+
124
+ The debug command in Sendmail is enabled, allowing attackers to execute commands as root.
125
+
126
+ **CVSS Score:** 10.0 (HIGH)
127
+ **Affected:** [[eric_allman/sendmail]]
128
+ ```
129
+
130
+ See [DEMO.md](DEMO.md) for the full step-by-step walkthrough.
131
+
132
+ ---
133
+
134
+ ## Quick Start
135
+
136
+ ```bash
137
+ # Install
138
+ npm install -g gnosys
139
+
140
+ # Initialize a project
141
+ cd your-project
142
+ gnosys init
143
+
144
+ # Start the sandbox (background process — runs once, stays alive)
145
+ gnosys sandbox start
146
+
147
+ # Add memories via CLI
148
+ gnosys add "We chose PostgreSQL over MySQL for its JSON support and mature ecosystem"
149
+
150
+ # Search memories
151
+ gnosys recall "database selection"
152
+ gnosys search "PostgreSQL"
153
+
154
+ # Generate a helper library for agent integration
155
+ gnosys helper generate
156
+ ```
157
+
158
+ ### Agent / Helper Library (v3.0)
159
+
160
+ ```ts
161
+ import { gnosys } from "./gnosys-helper"; // generated once, reused forever
162
+
163
+ await gnosys.add("We use conventional commits");
164
+ const ctx = await gnosys.recall("auth decisions");
165
+ await gnosys.reinforce("payment logic");
166
+ ```
167
+
168
+ The helper auto-starts the sandbox if it's not running. No MCP required.
169
+
170
+ ---
171
+
172
+ ## Web Knowledge Base
173
+
174
+ Turn any website into a searchable knowledge base for AI chatbots. No database required. Works on Vercel, Netlify, Cloudflare Pages, or any platform that can serve files.
175
+
176
+ ### Quick Start
177
+
178
+ ```bash
179
+ cd your-nextjs-site
180
+ npm install -g gnosys
181
+ gnosys init
182
+ gnosys web init
183
+ # Edit gnosys.json to set your sitemapUrl
184
+ gnosys web build
185
+ # Add to package.json: "postbuild": "gnosys web build"
186
+ ```
187
+
188
+ ### How It Works
189
+
190
+ ```
191
+ DEVELOPMENT TIME (local machine)
192
+ ─────────────────────────────────
193
+ gnosys web init → scaffolds /knowledge/ dir, adds config to gnosys.json
194
+ gnosys web ingest → crawls site → converts to markdown → writes /knowledge/*.md
195
+ gnosys web build-index → reads /knowledge/*.md → produces /knowledge/gnosys-index.json
196
+ gnosys web build → runs ingest + build-index in one shot
197
+
198
+ All files committed to git. Deployed with the app.
199
+
200
+ RUNTIME (serverless / any host)
201
+ ───────────────────────────────
202
+ import { loadIndex, search } from 'gnosys/web'
203
+
204
+ 1. loadIndex('knowledge/gnosys-index.json') → loads pre-computed index into memory
205
+ 2. search(index, userMessage, { limit: 6 }) → returns ranked document references
206
+ 3. Read matched .md files from filesystem → inject content into LLM prompt
207
+ 4. Call Claude/GPT/etc with focused context → respond to user
208
+
209
+ No SQLite. No database. No network calls for search.
210
+ ```
211
+
212
+ ### Integration Example (Next.js)
213
+
214
+ ```typescript
215
+ // app/api/chat/route.ts
216
+ import { loadIndex, search } from 'gnosys/web'
217
+ import { readFileSync } from 'fs'
218
+ import { join } from 'path'
219
+
220
+ const index = loadIndex(join(process.cwd(), 'knowledge', 'gnosys-index.json'))
221
+
222
+ export async function POST(req: Request) {
223
+ const { message } = await req.json()
224
+
225
+ const results = search(index, message, { limit: 6 })
226
+ const context = results.map(r =>
227
+ readFileSync(join(process.cwd(), 'knowledge', r.document.path), 'utf8')
228
+ ).join('\n\n---\n\n')
229
+
230
+ // Pass context to your LLM of choice
231
+ const response = await callLLM({
232
+ system: `Answer using ONLY the provided context.\n\nContext:\n${context}`,
233
+ message
234
+ })
235
+
236
+ return Response.json({ reply: response })
237
+ }
238
+ ```
239
+
240
+ ### Web CLI Commands
241
+
242
+ | Command | Description |
243
+ |---------|-------------|
244
+ | `gnosys web init` | Scaffold knowledge directory and config |
245
+ | `gnosys web ingest` | Crawl source and generate knowledge markdown |
246
+ | `gnosys web build-index` | Generate search index from knowledge files |
247
+ | `gnosys web build` | Run ingest + build-index in one shot |
248
+ | `gnosys web add <url>` | Ingest a single URL |
249
+ | `gnosys web remove <path>` | Remove a knowledge file and rebuild index |
250
+ | `gnosys web status` | Show knowledge base status |
251
+
252
+ ### Configuration
253
+
254
+ Add to `gnosys.json`:
255
+
256
+ ```json
257
+ {
258
+ "web": {
259
+ "source": "sitemap",
260
+ "sitemapUrl": "https://yoursite.com/sitemap.xml",
261
+ "outputDir": "./knowledge",
262
+ "exclude": ["/api", "/admin", "/_next"],
263
+ "categories": {
264
+ "/blog/*": "blog",
265
+ "/services/*": "services",
266
+ "/products/*": "products",
267
+ "/about*": "company"
268
+ },
269
+ "llmEnrich": true,
270
+ "prune": false
271
+ }
272
+ }
273
+ ```
274
+
275
+ ### GEO Integration
276
+
277
+ The `/knowledge/` directory of markdown files can be served to AI crawlers. YAML frontmatter provides structured metadata that LLMs can extract. Add an `llms.txt` entry pointing to your knowledge directory for AI discoverability.
278
+
279
+ ### SQLite vs Web Mode
280
+
281
+ | Aspect | SQLite (default) | Web Knowledge Base |
282
+ |--------|------------------|--------------------|
283
+ | Storage | Central `~/.gnosys/gnosys.db` | Markdown files in repo |
284
+ | Search | FTS5 + optional embeddings | Pre-computed inverted index |
285
+ | Write support | Full CRUD | Read-only (build-time only) |
286
+ | Infrastructure | None (embedded SQLite) | None (files deploy with app) |
287
+ | Best for | Local agents, MCP, CLI | Web chatbots, serverless |
288
+ | Search latency | <10ms | <5ms (in-memory index) |
289
+ | Supports Dream Mode | Yes | No (read-only) |
290
+
291
+ ---
292
+
293
+ ## Installation
294
+
295
+ ### npm (recommended)
296
+
297
+ ```bash
298
+ npm install -g gnosys
299
+ ```
300
+
301
+ ### Docker
302
+
303
+ ```bash
304
+ # Build the image
305
+ docker build -t gnosys .
306
+
307
+ # Initialize a store
308
+ docker run -v $(pwd):/data gnosys init
309
+
310
+ # Import data
311
+ docker run -v $(pwd):/data gnosys import data.json --format json \
312
+ --mapping '{"name":"title","type":"category","notes":"content"}' \
313
+ --mode structured
314
+
315
+ # Start the MCP server
316
+ docker run -v $(pwd):/data gnosys serve
317
+ ```
318
+
319
+ Or with Docker Compose:
320
+
321
+ ```bash
322
+ # Start the MCP server (mounts current directory)
323
+ docker compose up
324
+
325
+ # Run any CLI command
326
+ docker compose run gnosys search "my query"
327
+ docker compose run gnosys import data.json --format json --mapping '...'
328
+ ```
329
+
330
+ ---
331
+
332
+ ## MCP Server Setup
333
+
334
+ ### Claude Desktop
335
+
336
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
337
+
338
+ ```json
339
+ {
340
+ "mcpServers": {
341
+ "gnosys": {
342
+ "command": "gnosys",
343
+ "args": ["serve"],
344
+ "env": { "ANTHROPIC_API_KEY": "your-key-here" }
345
+ }
346
+ }
347
+ }
348
+ ```
349
+
350
+ ### Cursor
351
+
352
+ Add to `.cursor/mcp.json`:
353
+
354
+ ```json
355
+ {
356
+ "mcpServers": {
357
+ "gnosys": {
358
+ "command": "gnosys",
359
+ "args": ["serve"],
360
+ "env": { "ANTHROPIC_API_KEY": "your-key-here" }
361
+ }
362
+ }
363
+ }
364
+ ```
365
+
366
+ ### Claude Code
367
+
368
+ ```bash
369
+ claude mcp add gnosys gnosys serve
370
+ ```
371
+
372
+ ### Codex
373
+
374
+ Add to `.codex/config.toml`:
375
+
376
+ ```toml
377
+ [mcp.gnosys]
378
+ type = "local"
379
+ command = ["gnosys", "serve"]
380
+
381
+ [mcp.gnosys.env]
382
+ ANTHROPIC_API_KEY = "your-key-here"
383
+ ```
384
+
385
+ ### MCP Tools
386
+
387
+ | Tool | Description |
388
+ |------|-------------|
389
+ | `gnosys_discover` | Find relevant memories by keyword (start here) |
390
+ | `gnosys_read` | Read a specific memory |
391
+ | `gnosys_search` | Full-text search across stores |
392
+ | `gnosys_hybrid_search` | Hybrid keyword + semantic search (RRF fusion) |
393
+ | `gnosys_semantic_search` | Semantic similarity search (embeddings) |
394
+ | `gnosys_ask` | Ask a question, get a synthesized answer with citations |
395
+ | `gnosys_reindex` | Rebuild semantic embeddings from all memories |
396
+ | `gnosys_list` | List memories with optional filters |
397
+ | `gnosys_lens` | Filtered views — combine category, tag, status, confidence, date filters |
398
+ | `gnosys_add` | Add a memory (LLM-structured) |
399
+ | `gnosys_add_structured` | Add with explicit fields (no LLM) |
400
+ | `gnosys_update` | Update frontmatter or content |
401
+ | `gnosys_reinforce` | Signal usefulness of a memory |
402
+ | `gnosys_commit_context` | Extract memories from conversation context |
403
+ | `gnosys_bootstrap` | Batch-import existing markdown documents |
404
+ | `gnosys_import` | Bulk import from CSV, JSON, or JSONL |
405
+ | `gnosys_init` | Initialize a new store |
406
+ | `gnosys_stale` | Find memories not modified within N days |
407
+ | `gnosys_history` | Git-backed version history for a memory |
408
+ | `gnosys_rollback` | Rollback a memory to a previous commit |
409
+ | `gnosys_timeline` | Show when memories were created/modified over time |
410
+ | `gnosys_stats` | Summary statistics for the memory store |
411
+ | `gnosys_links` | Show wikilinks and backlinks for a memory |
412
+ | `gnosys_graph` | Full cross-reference graph across all memories |
413
+ | `gnosys_maintain` | Run vault maintenance (decay, dedup, consolidation, archiving) |
414
+ | `gnosys_dearchive` | Force-dearchive memories from archive back to active |
415
+ | `gnosys_dashboard` | System dashboard (memory count, health, archive, graph, LLM status) |
416
+ | `gnosys_reindex_graph` | Build/rebuild the wikilink graph |
417
+ | `gnosys_dream` | Run a Dream Mode cycle (decay, self-critique, summaries, relationships) |
418
+ | `gnosys_export` | Export gnosys.db to an Obsidian-compatible vault |
419
+ | `gnosys_recall` | Fast memory injection for agent orchestrators (sub-50ms) |
420
+ | `gnosys_audit` | View structured audit trail of all memory operations |
421
+ | `gnosys_stores` | Show active stores, MCP roots, and detected project stores |
422
+ | `gnosys_tags` | List tag registry |
423
+ | `gnosys_tags_add` | Add a new tag to the registry |
424
+ | **v3.0: Centralized Brain** | |
425
+ | `gnosys_projects` | List all registered projects in the central DB |
426
+ | `gnosys_backup` | Create a point-in-time backup of the central DB |
427
+ | `gnosys_restore` | Restore the central DB from a backup |
428
+ | `gnosys_migrate_to_central` | Migrate project data into the central DB |
429
+ | `gnosys_preference_set` | Set a user preference (stored as scoped memory) |
430
+ | `gnosys_preference_get` | Get one or all preferences |
431
+ | `gnosys_preference_delete` | Delete a preference |
432
+ | `gnosys_sync` | Regenerate agent rules file from preferences + conventions |
433
+ | `gnosys_federated_search` | Tier-boosted search across project → user → global scopes |
434
+ | `gnosys_detect_ambiguity` | Check if a query matches multiple projects |
435
+ | `gnosys_briefing` | Generate project briefing (categories, activity, tags, summary) |
436
+ | `gnosys_working_set` | Get recently modified memories for the current project |
437
+
438
+ ---
439
+
440
+ ## How It Works
441
+
442
+ ### Central Brain (v3.0)
443
+
444
+ In v3.0, Gnosys uses a **central database** at `~/.gnosys/gnosys.db` as the single source of truth across all projects. Each project also has a local `.gnosys/` directory with a `gnosys.json` identity file:
445
+
446
+ ```
447
+ ~/.gnosys/
448
+ gnosys.db # ← v3.0 central brain (all projects, users, globals)
449
+
450
+ your-project/
451
+ .gnosys/
452
+ gnosys.json # ← v3.0 project identity (projectId, name, settings)
453
+ decisions/ # dual-write .md copies (safety net + Obsidian export)
454
+ use-postgresql.md
455
+ architecture/
456
+ three-layer-design.md
457
+ .config/tags.json # tag registry
458
+ CHANGELOG.md
459
+ ```
460
+
461
+ `gnosys init` creates the project identity, registers the project in the central DB, and auto-detects your IDE (Cursor, Claude Code) for rules file generation.
462
+
463
+ All reads go through SQLite for sub-10ms performance. Writes dual-write to both `.md` files and the database. Run `gnosys migrate --to-central` to migrate existing v2.x project data into the central DB.
464
+
465
+ Each memory is an atomic Markdown file with YAML frontmatter:
466
+
467
+ ```yaml
468
+ ---
469
+ id: deci-001
470
+ title: "Use PostgreSQL for Main Database"
471
+ category: decisions
472
+ tags:
473
+ domain: [database, backend]
474
+ type: [decision]
475
+ relevance: "database selection postgres sql json storage persistence"
476
+ author: human+ai
477
+ authority: declared
478
+ confidence: 0.9
479
+ created: 2026-03-01
480
+ status: active
481
+ supersedes: null
482
+ ---
483
+ # Use PostgreSQL for Main Database
484
+
485
+ We chose PostgreSQL over MySQL and SQLite because...
486
+ ```
487
+
488
+ Key fields:
489
+
490
+ - **relevance** — keyword cloud powering `discover`. Think: what would someone search to find this?
491
+ - **confidence** — 0–1 score. Observations: 0.6. Firm decisions: 0.9.
492
+ - **authority** — who established this? `declared`, `observed`, `imported`, `inferred`.
493
+ - **status** — `active`, `archived`, or `superseded`. Superseded memories link to replacements.
494
+
495
+ ---
496
+
497
+ ## LLM Providers & Configuration
498
+
499
+ Gnosys features a **System of Cognition (SOC)** — five LLM providers behind a single interface. Switch between cloud and local with one command:
500
+
501
+ ```bash
502
+ # Switch providers
503
+ gnosys config set provider anthropic # Cloud (default)
504
+ gnosys config set provider ollama # Local via Ollama
505
+ gnosys config set provider groq # Fast cloud inference
506
+ gnosys config set provider openai # OpenAI-compatible
507
+ gnosys config set provider lmstudio # Local via LM Studio
508
+
509
+ # Route tasks to different providers
510
+ gnosys config set task structuring ollama llama3.2
511
+ gnosys config set task synthesis anthropic claude-sonnet-4-20250514
512
+
513
+ # View the full SOC dashboard
514
+ gnosys dashboard
515
+
516
+ # Check all provider connectivity
517
+ gnosys doctor
518
+ ```
519
+
520
+ ### Supported Providers
521
+
522
+ | Provider | Type | Default Model | API Key Env Var |
523
+ |----------|------|---------------|-----------------|
524
+ | **Anthropic** | Cloud | claude-sonnet-4-20250514 | `ANTHROPIC_API_KEY` |
525
+ | **Ollama** | Local | llama3.2 | — (runs locally) |
526
+ | **Groq** | Cloud | llama-3.3-70b-versatile | `GROQ_API_KEY` |
527
+ | **OpenAI** | Cloud | gpt-4o-mini | `OPENAI_API_KEY` |
528
+ | **LM Studio** | Local | default | — (runs locally) |
529
+
530
+ All providers implement the same `LLMProvider` interface. Cloud providers use API keys (set via env var or `gnosys.json`). Local providers (Ollama, LM Studio) just need the service running.
531
+
532
+ ### Task-Based Model Routing
533
+
534
+ Use different models for different tasks — a cheap/fast model for structuring imports and a powerful model for synthesis:
535
+
536
+ ```json
537
+ {
538
+ "llm": {
539
+ "defaultProvider": "anthropic",
540
+ "anthropic": { "model": "claude-sonnet-4-20250514" },
541
+ "ollama": { "model": "llama3.2", "baseUrl": "http://localhost:11434" },
542
+ "groq": { "model": "llama-3.3-70b-versatile" },
543
+ "openai": { "model": "gpt-4o-mini", "baseUrl": "https://api.openai.com/v1" },
544
+ "lmstudio": { "model": "default", "baseUrl": "http://localhost:1234/v1" }
545
+ },
546
+ "taskModels": {
547
+ "structuring": { "provider": "ollama", "model": "llama3.2" },
548
+ "synthesis": { "provider": "anthropic", "model": "claude-sonnet-4-20250514" }
549
+ }
550
+ }
551
+ ```
552
+
553
+ A default `gnosys.json` is created during `gnosys init`. Validation is handled by Zod — invalid configs produce clear error messages. Legacy `defaultLLMProvider` and `defaultModel` fields are auto-migrated to the new `llm` structure.
554
+
555
+ ---
556
+
557
+ ## Using with Obsidian
558
+
559
+ The primary store is the central `~/.gnosys/gnosys.db`. Use the **Obsidian Export Bridge** to generate a full Obsidian vault from the database:
560
+
561
+ ```bash
562
+ # Export to an Obsidian-compatible vault
563
+ gnosys export --to ~/vaults/my-project
564
+
565
+ # Overwrite an existing export
566
+ gnosys export --to ~/vaults/my-project --overwrite
567
+
568
+ # Export everything including summaries, reviews, and graph data
569
+ gnosys export --to ~/vaults/my-project --all
570
+ ```
571
+
572
+ The export creates: category folders with YAML frontmatter `.md` files, `[[wikilinks]]` from the relationships table, `_summaries/` for Dream Mode category summaries, `_review/` for flagged memories, and `_graph/` for relationship data.
573
+
574
+ You can also browse the dual-write `.md` files directly in the `.gnosys/` directory — they're kept in sync with every write. Open the exported vault in Obsidian for graph view, wikilinks, backlinks, tag search, and visual editing.
575
+
576
+ ---
577
+
578
+ ## Bulk Import
579
+
580
+ Import any structured dataset into atomic memories:
581
+
582
+ ```bash
583
+ # JSON with field mapping
584
+ gnosys import foods.json --format json \
585
+ --mapping '{"description":"title","foodCategory":"category","notes":"content"}' \
586
+ --mode structured
587
+
588
+ # CSV
589
+ gnosys import data.csv --format csv \
590
+ --mapping '{"name":"title","type":"category","notes":"content"}'
591
+
592
+ # JSONL (one record per line)
593
+ gnosys import events.jsonl --format jsonl \
594
+ --mapping '{"event":"title","type":"category","details":"content"}'
595
+
596
+ # With LLM enrichment (generates keyword clouds, better structure)
597
+ gnosys import data.json --mode llm --concurrency 3
598
+
599
+ # Preview without writing
600
+ gnosys import data.json --dry-run
601
+
602
+ # Resume interrupted imports
603
+ gnosys import data.json --skip-existing
604
+
605
+ # Slice a large dataset
606
+ gnosys import large.json --limit 500 --offset 1000
607
+ ```
608
+
609
+ ---
610
+
611
+ ## Freeform Asking
612
+
613
+ Ask natural-language questions and get synthesized answers with citations from the entire vault. Gnosys retrieves relevant memories via hybrid search, then uses your LLM to synthesize a cited response.
614
+
615
+ ```bash
616
+ # First, build the semantic index (downloads ~80 MB model on first run)
617
+ gnosys reindex
618
+
619
+ # Ask a question about your USDA data
620
+ gnosys ask "What are the best high-protein low-sodium food alternatives?"
621
+
622
+ # Ask about CVEs
623
+ gnosys ask "Which vulnerabilities allow remote code execution?"
624
+
625
+ # Use keyword-only mode (no embeddings needed)
626
+ gnosys ask "What do we know about cheddar cheese?" --mode keyword
627
+ ```
628
+
629
+ Answers include Obsidian wikilink citations like `[[almond-butter-creamy.md]]` so you can click through to the source memories. If the initial search doesn't find enough context, a "deep query" follow-up search automatically expands the context.
630
+
631
+ ### Hybrid Search
632
+
633
+ Three search modes available:
634
+
635
+ ```bash
636
+ # Hybrid (default): combines keyword + semantic with RRF fusion
637
+ gnosys hybrid-search "high protein low sodium"
638
+
639
+ # Semantic only: finds conceptually related memories
640
+ gnosys semantic-search "healthy meal alternatives"
641
+
642
+ # Keyword only: classic FTS5 full-text search
643
+ gnosys hybrid-search "cheddar cheese protein" --mode keyword
644
+ ```
645
+
646
+ The embedding model (`all-MiniLM-L6-v2`) is lazy-loaded — it's only downloaded the first time you run `gnosys reindex` or a semantic search. Embeddings are stored as a regeneratable sidecar in SQLite, never the source of truth.
647
+
648
+ ---
649
+
650
+ ## Memory Scopes
651
+
652
+ In v3.0, the central `~/.gnosys/gnosys.db` holds all memories with `project_id` and `scope` columns replacing the old layered-store model:
653
+
654
+ | Scope | Description | Boost |
655
+ |-------|-------------|-------|
656
+ | **project** | Tied to a specific project (via `project_id`) | 1.5x (1.8x for current) |
657
+ | **user** | Cross-project user preferences and knowledge | 1.0x |
658
+ | **global** | Org-wide shared knowledge | 0.7x |
659
+
660
+ Federated search ranks results across all scopes with tier boosting. Legacy env vars (`GNOSYS_STORES`, `GNOSYS_PERSONAL`, `GNOSYS_GLOBAL`) are still supported as read-only fallback stores for backward compatibility.
661
+
662
+ ---
663
+
664
+ ## Reflection API
665
+
666
+ Reflect on real-world outcomes to update memory confidence and build validation chains:
667
+
668
+ ```bash
669
+ # Success — boosts confidence on related memories
670
+ gnosys reflect "JWT auth worked perfectly in production" --memory-ids mem-001,mem-002
671
+
672
+ # Failure — decreases confidence and marks contradictions
673
+ gnosys reflect "bcrypt was too slow, switched to argon2" --memory-ids mem-003 --failure
674
+
675
+ # Auto-discover — searches for related memories when no IDs given
676
+ gnosys reflect "Our three-layer architecture handled 10k users"
677
+ ```
678
+
679
+ In the helper library:
680
+
681
+ ```typescript
682
+ import { gnosys } from "./gnosys-helper";
683
+
684
+ const result = await gnosys.reflect("Deployment succeeded", {
685
+ memory_ids: ["mem-auth-001", "mem-arch-001"],
686
+ success: true,
687
+ notes: "Zero downtime deploy with 10k concurrent users",
688
+ });
689
+ // → { reflection_id, memories_updated, relationships_created, confidence_delta }
690
+ ```
691
+
692
+ Each reflection creates a dedicated memory (category: `reflections`) and links it to related memories via `validates` or `contradicts` relationships. On success, related memories are also cross-linked with `corroborates`.
693
+
694
+ ---
695
+
696
+ ## Process Tracing
697
+
698
+ Trace a codebase to build procedural "how" memories with call-chain relationships:
699
+
700
+ ```bash
701
+ # Trace your project
702
+ gnosys trace ./src
703
+
704
+ # With project association
705
+ gnosys trace ./src --project-id proj-abc123
706
+
707
+ # JSON output
708
+ gnosys trace ./src --json
709
+ ```
710
+
711
+ This scans TypeScript/JavaScript files, extracts function declarations and call sites, then stores each as a procedural memory (category: `how`) with three relationship types:
712
+
713
+ - **leads_to** — function A calls function B
714
+ - **follows_from** — function B is called by function A
715
+ - **requires** — function A imports from module B
716
+
717
+ ---
718
+
719
+ ## Relationship Traversal
720
+
721
+ Walk relationship chains starting from any memory:
722
+
723
+ ```bash
724
+ # Traverse from a memory (default depth: 3)
725
+ gnosys traverse mem-001
726
+
727
+ # Limit depth
728
+ gnosys traverse mem-001 --depth 5
729
+
730
+ # Filter by relationship type
731
+ gnosys traverse mem-001 --rel-types leads_to,requires
732
+ ```
733
+
734
+ In the helper library:
735
+
736
+ ```typescript
737
+ const chain = await gnosys.traverse("mem-001", {
738
+ depth: 3,
739
+ rel_types: ["leads_to", "follows_from"],
740
+ });
741
+ // → { root, depth, nodes: [{ id, title, category, confidence, depth, via_rel, via_from }], total }
742
+ ```
743
+
744
+ Traversal uses BFS and follows both outgoing and incoming edges. The depth is capped at 10 for safety.
745
+
746
+ ---
747
+
748
+ ## Auto Memory Maintenance
749
+
750
+ The vault stays clean and useful forever without manual babysitting. Agents can run for months without the memory turning into a mess.
751
+
752
+ ### How It Works
753
+
754
+ **Confidence Decay:** Every memory's confidence decays exponentially over time based on how recently it was used. The formula: `decayed = base_confidence × e^(-0.005 × days_since_reinforced)`. At this rate, an unreinforced memory loses ~50% confidence after 139 days.
755
+
756
+ **Automatic Reinforcement:** Every time a memory appears in search results, ask synthesis, or import — its `reinforcement_count` increments and `last_reinforced` resets. This happens automatically in `gnosys_ask`, `gnosys_hybrid_search`, and all search-based tools.
757
+
758
+ **Duplicate Detection:** Uses semantic similarity (cosine > 0.85) combined with title word overlap (Jaccard > 0.4) to flag potential duplicates. Both conditions must pass to reduce false positives.
759
+
760
+ **Auto-Consolidation:** When duplicates are confirmed, the LLM merges both memories into a single comprehensive one. Originals are marked `status: superseded` with a pointer to the merged version.
761
+
762
+ ### Running Maintenance
763
+
764
+ ```bash
765
+ # See what would change (safe, no modifications)
766
+ gnosys maintain --dry-run
767
+
768
+ # Apply all changes automatically
769
+ gnosys maintain --auto-apply
770
+
771
+ # Background mode: runs every 6 hours alongside the sandbox
772
+ gnosys serve --with-maintenance
773
+ ```
774
+
775
+ ### Scheduling with cron (Linux/Mac)
776
+
777
+ ```bash
778
+ # Run maintenance daily at 3am
779
+ 0 3 * * * cd /path/to/project && npx gnosys maintain --auto-apply >> /var/log/gnosys-maintain.log 2>&1
780
+ ```
781
+
782
+ ### Scheduling with Task Scheduler (Windows)
783
+
784
+ Create a basic task that runs daily:
785
+ - Program: `npx`
786
+ - Arguments: `gnosys maintain --auto-apply`
787
+ - Start in: `C:\path\to\project`
788
+
789
+ ### MCP Tool
790
+
791
+ The `gnosys_maintain` MCP tool lets agents trigger maintenance programmatically with dry-run and auto-apply options.
792
+
793
+ ### Doctor Health Report
794
+
795
+ `gnosys doctor` now includes a Maintenance Health section showing stale count, average confidence (raw and decayed), reinforcement stats, and never-reinforced memories.
796
+
797
+ ---
798
+
799
+ ## Agent-First SQLite Core
800
+
801
+ Gnosys uses an **agent-first SQLite core**. In v3.0, the central `~/.gnosys/gnosys.db` holds all memories across all projects, with `project_id` and `scope` columns for multi-project isolation. The schema has six tables: `memories`, `memories_fts` (FTS5), `relationships`, `summaries`, `audit_log`, and `projects`.
802
+
803
+ ### Migration
804
+
805
+ Existing v1.x stores upgrade with a single command:
806
+
807
+ ```bash
808
+ # Migrate all .md files + archive.db into gnosys.db
809
+ gnosys migrate
810
+
811
+ # Preview what would be migrated (dry run)
812
+ gnosys migrate --dry-run
813
+ ```
814
+
815
+ Migration is one-shot and safe — your `.md` files remain untouched. After migration, all reads go through SQLite (sub-10ms), and all writes dual-write to both `.md` and `gnosys.db`.
816
+
817
+ ### Schema
818
+
819
+ | Table | Purpose |
820
+ |-------|---------|
821
+ | `memories` | All memory data: frontmatter, content, embeddings, project_id, scope |
822
+ | `memories_fts` | FTS5 full-text index — auto-synced via INSERT/UPDATE/DELETE triggers |
823
+ | `relationships` | Typed edges between memories (wikilinks, Dream Mode discoveries) |
824
+ | `summaries` | Category-level summaries generated by Dream Mode |
825
+ | `audit_log` | Every operation logged with timestamps and trace IDs |
826
+ | `projects` | v3.0: Project identity registry (id, name, working_directory) |
827
+
828
+ The database uses WAL mode for concurrent access — multiple agents can read and write safely from parallel processes.
829
+
830
+ ---
831
+
832
+ ## Dream Mode
833
+
834
+ Dream Mode is Gnosys's idle-time consolidation engine — inspired by how biological memory consolidates during sleep. When your agent goes idle, Dream Mode runs a four-phase cycle:
835
+
836
+ **Phase 1: Confidence Decay** — Applies exponential decay to unreinforced memories. No LLM needed.
837
+
838
+ **Phase 2: Self-Critique** — Rule-based + optional LLM scoring flags low-quality, stale, or contradictory memories for review. **Never deletes** — only stores review suggestions.
839
+
840
+ **Phase 3: Summary Generation** — LLM generates category-level summaries and stores them in the `summaries` table.
841
+
842
+ **Phase 4: Relationship Discovery** — LLM discovers semantic relationships between memories and stores typed edges in the `relationships` table.
843
+
844
+ ### Usage
845
+
846
+ ```bash
847
+ # Run a Dream cycle manually
848
+ gnosys dream
849
+
850
+ # Limit runtime
851
+ gnosys dream --max-runtime 15
852
+
853
+ # Skip specific phases
854
+ gnosys dream --no-summaries --no-relationships
855
+
856
+ # JSON output for automation
857
+ gnosys dream --json
858
+ ```
859
+
860
+ ### Configuration
861
+
862
+ Dream Mode is **off by default**. Enable it in `gnosys.json`:
863
+
864
+ ```json
865
+ {
866
+ "dream": {
867
+ "enabled": true,
868
+ "idleMinutes": 10,
869
+ "maxRuntimeMinutes": 30,
870
+ "provider": "ollama",
871
+ "selfCritique": true,
872
+ "generateSummaries": true,
873
+ "discoverRelationships": true
874
+ }
875
+ }
876
+ ```
877
+
878
+ When enabled and the MCP server is running, Dream Mode automatically triggers after the configured idle period. Any agent activity immediately aborts the dream cycle and resets the idle timer.
879
+
880
+ The `gnosys_dream` MCP tool lets agents trigger dream cycles programmatically.
881
+
882
+ ### Sandbox Protocol (v3.0)
883
+
884
+ The sandbox daemon exposes Dream Mode, preferences, and sync through its IPC protocol. This enables helper libraries and agents to interact with these features without MCP:
885
+
886
+ | Method | Description |
887
+ |---|---|
888
+ | `dream_status` | Returns current Dream Mode state (enabled, idle timer, dreams completed, isDreaming) |
889
+ | `pref_set` | Set a user preference (stored as `scope: user` memory) |
890
+ | `pref_get` | Retrieve a preference by key |
891
+ | `pref_list` | List all user preferences |
892
+ | `pref_delete` | Remove a preference |
893
+ | `pref_search` | Search preferences by query |
894
+ | `sync` | Generate and inject agent rules from preferences + project conventions |
895
+
896
+ Dream Mode integrates with the sandbox: every request resets the idle timer, and the dream scheduler runs automatically when the sandbox is idle. The `sync` method generates a `<!-- GNOSYS:START -->` / `<!-- GNOSYS:END -->` protected block in agent rules files (CLAUDE.md, .cursorrules, etc.) that is safely replaced on each sync without disturbing user-written content.
897
+
898
+ ---
899
+
900
+ ## Federated Search
901
+
902
+ All major search commands (`search`, `discover`, `hybrid-search`, `recall`, `ask`) support federated search with tier boosting. Use `--federated` to search across all scopes in the central DB with automatic ranking:
903
+
904
+ ```bash
905
+ # Federated search with tier boosting (project > user > global)
906
+ gnosys search "auth tokens" --federated
907
+
908
+ # Filter to specific scope(s)
909
+ gnosys search "deploy config" --scope user
910
+ gnosys search "best practices" --scope project,global
911
+
912
+ # Dedicated federated search command with JSON output
913
+ gnosys fsearch "authentication" --json --scope user,project
914
+
915
+ # Federated recall for agents
916
+ gnosys recall "payment logic" --federated --json
917
+
918
+ # Ask with cross-scope context
919
+ gnosys ask "What auth pattern do we use?" --federated
920
+
921
+ # Multi-project scenario: specify project directory
922
+ gnosys search "API design" --federated --directory /path/to/project-b
923
+ ```
924
+
925
+ **Tier boosting** ranks results by scope: project memories get 1.5x boost (1.8x for the current project), user-scoped get 1.0x, and global get 0.7x. Recency (last 24h) adds a 1.3x boost, and reinforcement count adds up to 25%.
926
+
927
+ Results always include `scope` and `boosts` fields so agents know where each memory came from.
928
+
929
+ ---
930
+
931
+ ## Multi-Project Support
932
+
933
+ Gnosys supports multiple projects in parallel — critical for developers using multiple Cursor windows or multi-root workspaces. In v3.0, the central DB's `projects` table acts as a registry, and federated search + ambiguity detection make cross-project workflows safe and predictable.
934
+
935
+ ### How It Works
936
+
937
+ In v3.0, the central `~/.gnosys/gnosys.db` holds all projects, each identified by `project_id`. The sandbox process holds the database connection and routes requests by project. MCP tools accept an optional `projectRoot` parameter for explicit routing, and the CLI auto-detects the current project from `gnosys.json` in the working directory.
938
+
939
+ ```
940
+ # Agent in Window 1 (project-a):
941
+ gnosys_add(input: "...", projectRoot: "/Users/me/project-a")
942
+
943
+ # Agent in Window 2 (project-b) — runs simultaneously, routes correctly:
944
+ gnosys_add(input: "...", projectRoot: "/Users/me/project-b")
945
+ ```
946
+
947
+ ### MCP Roots
948
+
949
+ Gnosys also supports the MCP roots protocol. On connect, the server calls `roots/list` to discover workspace folders and listens for `notifications/roots/list_changed` to track dynamic changes. Store resolution priority: registered stores → MCP roots → `cwd` walkup.
950
+
951
+ ### Debugging
952
+
953
+ Use `gnosys stores` (CLI) or the `gnosys_stores` MCP tool to see all detected stores, MCP roots, and which store is currently active.
954
+
955
+ ---
956
+
957
+ ## Network Share Support
958
+
959
+ Gnosys v3.0 supports pointing the central database at a network share — Dropbox, iCloud Drive, NAS, or any mounted network path. This enables multi-machine access to the same knowledge base.
960
+
961
+ ### Setup
962
+
963
+ ```bash
964
+ # Start the sandbox with a network DB path
965
+ gnosys sandbox start --db-path /Volumes/NAS/gnosys
966
+
967
+ # Or Dropbox
968
+ gnosys sandbox start --db-path ~/Dropbox/gnosys
969
+
970
+ # Or iCloud Drive
971
+ gnosys sandbox start --db-path ~/Library/Mobile\ Documents/com~apple~CloudDocs/gnosys
972
+ ```
973
+
974
+ The sandbox automatically applies network-safe defaults when a custom `--db-path` is provided: 5 connection retries with 1-second delays, and a 10-second SQLite busy timeout for concurrent multi-machine access.
975
+
976
+ ### Multi-Machine Usage
977
+
978
+ Multiple machines can share the same database. SQLite's WAL mode handles concurrent reads safely, and the busy timeout prevents lock contention failures. For best results:
979
+
980
+ - Keep each machine's sandbox running (it holds a connection pool)
981
+ - Ensure the network path is mounted before starting the sandbox
982
+ - If the path becomes unavailable, stop and restart the sandbox after remounting
983
+
984
+ ### Backup & Restore
985
+
986
+ ```bash
987
+ # Backup the central DB (includes DB, helper library, rules, and sandbox log)
988
+ gnosys backup
989
+ gnosys backup --to /backups/gnosys-$(date +%F).db
990
+
991
+ # Restore from a backup
992
+ gnosys restore latest
993
+ gnosys restore --from /backups/gnosys-2026-03-12.db
994
+
995
+ # JSON output for scripting
996
+ gnosys backup --json
997
+ gnosys restore latest --json
998
+ ```
999
+
1000
+ Backups include the full SQLite database, helper library, rules files, and sandbox diagnostics log. The `--to` and `--from` flags support both local and network paths.
1001
+
1002
+ ---
1003
+
1004
+ ## Comparison
1005
+
1006
+ Agent memory is a spectrum — from a single markdown file to full knowledge graphs. Here's an honest look at the trade-offs.
1007
+
1008
+ | Aspect | Plain Markdown | RAG (Vector DB) | Knowledge Graph | **Gnosys** |
1009
+ |--------|---------------|-----------------|-----------------|-----------|
1010
+ | **Examples** | CLAUDE.md, .cursorrules | Mem0, LangChain Memory | Graphiti/Zep, Mem0 Graph | — |
1011
+ | **Storage** | `.md` files | Embeddings in vector DB | Nodes/edges in graph DB | Unified SQLite DB + `.md` dual-write |
1012
+ | **Transparency** | Perfect | Lossy (embeddings) | High (query nodes) | High (SQLite + dual-write `.md` + Obsidian export) |
1013
+ | **Version history** | Git native | None built-in | None built-in | Dual-write `.md` files (optional Git) |
1014
+ | **Keyword search** | Manual / grep | BM25 layer (some) | BM25 layer (some) | FTS5 (built-in) |
1015
+ | **Semantic search** | None | Vector similarity | Graph + vectors | Vector + FTS5 hybrid (RRF) |
1016
+ | **Relationship traversal** | None | None | Multi-hop graph queries | Wikilinks (manual encoding) |
1017
+ | **Automatic extraction** | No | Yes (embeddings) | Yes (entities + edges) | No (explicit structuring) |
1018
+ | **Conflict detection** | No | No | Yes (graph rules) | No |
1019
+ | **Scale comfort zone** | ~5K memories | 100K+ | 100K+ | 100K+ (unified SQLite + optional archive tier) |
1020
+ | **Setup time** | < 5 min | 30 min – 2 hours | 4 – 8 hours | 15 – 30 min |
1021
+ | **Infrastructure** | None | Vector DB + embeddings API | Graph DB + LLM | SQLite (embedded) |
1022
+ | **Human editability** | Excellent | Poor (re-embed) | Moderate | Excellent |
1023
+ | **MCP integration** | Via skill files | Custom server | Mem0 ships MCP | MCP server (included) |
1024
+ | **Obsidian compatible** | Partially | No | No | Yes (full vault) |
1025
+ | **Cost** | Free | $0–500+/mo (cloud DB + embeddings) | $250+/mo (Mem0 Pro) or self-host | Free (MIT) |
1026
+ | **Memory lifecycle** | Manual cleanup | Manual / TTL | Manual / TTL | Auto-archive + auto-dearchive on cite |
1027
+ | **Offline capable** | Yes | Self-hosted only | Self-hosted only | Yes (Ollama/LM Studio) |
1028
+
1029
+ ### Where others genuinely win
1030
+
1031
+ - **Knowledge graphs** (Graphiti, Mem0 Graph) excel at multi-hop reasoning ("Who does Alice report to?") and automatic conflict detection. If your domain has clear entities and relationships — org charts, dependency trees, CRM data — a graph DB is the right tool.
1032
+ - **RAG/vector search** handles fuzzy semantic matching without requiring explicit keyword clouds. You don't need to think about relevance fields — the embeddings handle conceptual similarity automatically.
1033
+ - **Automatic extraction** in both RAG and graph approaches means the system learns from conversations without you explicitly structuring each fact.
1034
+
1035
+ ### Where Gnosys wins
1036
+
1037
+ - **Zero infrastructure**: No vector DB to deploy, no graph DB to manage. SQLite is embedded.
1038
+ - **Full transparency**: Every memory is a readable, editable `.md` file. No opaque embeddings.
1039
+ - **Dual-write transparency**: Every memory has a human-readable `.md` file alongside the central DB. Optional Git versioning for rollback and diff.
1040
+ - **Obsidian native**: Browse, edit, graph view, wikilinks — all with your existing Obsidian setup.
1041
+ - **Hybrid search without a vector DB**: FTS5 keyword search is built-in. Semantic search is optional (local embeddings via Ollama, no API costs).
1042
+ - **Bulk import**: CSV, JSON, JSONL. Turn a dataset into a searchable knowledge base in seconds.
1043
+ - **Cost**: Genuinely free. No cloud service, no API costs if using local LLM providers.
1044
+ - **Two-tier memory**: Active memories stay lightning-fast in SQLite. Old/low-confidence memories are automatically archived — and auto-dearchive when needed by search or ask.
1045
+
1046
+ ### Two-Tier Memory (Active + Archive)
1047
+
1048
+ Gnosys uses a two-tier architecture so your current work stays fast while safely growing to 100k+ memories:
1049
+
1050
+ **Active layer** — `~/.gnosys/gnosys.db` central brain. All reads and writes go here. Dual-write `.md` copies are kept as a safety net.
1051
+
1052
+ **Archive layer** — low-confidence memories within the same `gnosys.db`, marked with `tier: archive`. Searched as a fallback when active results are insufficient.
1053
+
1054
+ The flow is fully automatic and bidirectional:
1055
+ 1. `gnosys maintain --auto-apply` moves stale memories (>90 days unreinforced + confidence below 0.3) from active → archive
1056
+ 2. Every search and ask query checks the archive if active results are insufficient
1057
+ 3. Archived memories that get cited in an answer are automatically restored to active and reinforced
1058
+
1059
+ You can also force-dearchive with `gnosys dearchive "query"` or the `gnosys_dearchive` MCP tool.
1060
+
1061
+ Configure thresholds in `gnosys.json`:
1062
+ ```json
1063
+ {
1064
+ "archive": {
1065
+ "maxActiveDays": 90,
1066
+ "minConfidence": 0.3
1067
+ }
1068
+ }
1069
+ ```
1070
+
1071
+ ### Enterprise Reliability (v1.3.0+)
1072
+
1073
+ Built for long-running agent orchestrators that call Gnosys hundreds of times per session.
1074
+
1075
+ **Automatic Memory Injection** — The `gnosys://recall` MCP Resource is read by hosts (Cursor, Claude Desktop, Claude Code, Cowork) on every single turn. No tool call needed — the host injects relevant memories into the model context automatically. The `gnosys_recall` tool is kept as a fallback for hosts that don't support MCP Resources.
1076
+
1077
+ Sub-50ms, no LLM, no embeddings — pure FTS5 keyword search with relevance scoring. Returns `<gnosys-recall>` blocks with `[[wikilinks]]` or a `<gnosys: no-strong-recall-needed>` heartbeat.
1078
+
1079
+ Two modes: **aggressive** (default) always injects the top 3 memories plus any above the relevance floor. **Filtered** (`aggressive: false`) applies a hard cutoff at `minRelevance`.
1080
+
1081
+ ```bash
1082
+ # CLI — aggressive mode (default)
1083
+ gnosys recall "React state management"
1084
+
1085
+ # Force filtered mode
1086
+ gnosys recall "React state management" --no-aggressive --host
1087
+
1088
+ # Configure recall
1089
+ gnosys config set recall aggressive true
1090
+ gnosys config set recall maxMemories 12
1091
+ gnosys config set recall minRelevance 0.3
1092
+ ```
1093
+
1094
+ Configure in `gnosys.json`:
1095
+ ```json
1096
+ {
1097
+ "recall": {
1098
+ "aggressive": true,
1099
+ "maxMemories": 8,
1100
+ "minRelevance": 0.4
1101
+ }
1102
+ }
1103
+ ```
1104
+
1105
+ #### Setup for Automatic Injection
1106
+
1107
+ **Cursor** — Add to your MCP config. Cursor reads `gnosys://recall` automatically on every turn when it's listed as a resource with `priority: 1`.
1108
+
1109
+ **Claude Desktop** — Same MCP config. The resource appears in the model context on every message.
1110
+
1111
+ **Claude Code / Cowork** — Configure via `.mcp.json` or the MCP settings. The `gnosys://recall` resource is injected into every assistant turn.
1112
+
1113
+ No per-turn tool calls, no manual invocation — just configure the MCP server once and memories flow into every conversation automatically.
1114
+
1115
+ **Concurrency safety** — The central `gnosys.db` uses WAL mode with a 10-second busy timeout for concurrent reads and writes. Write locking with PID tracking prevents corruption when multiple agents write simultaneously. Stale lock detection auto-recovers from crashed processes.
1116
+
1117
+ **Audit trail** — Every memory operation (read, write, recall, ask, maintain, archive, dearchive) is logged to the `audit_log` table in `gnosys.db` with timestamps, durations, and optional traceIds for correlation with your outer orchestrator.
1118
+
1119
+ ```bash
1120
+ gnosys audit --days 7 --operation recall --json
1121
+ ```
1122
+
1123
+ **Deterministic dearchive** — When an LLM-synthesized answer cites archived memories, a three-stage fallback ensures they're always restored: path match → title match → all archive results from context. No memory is left behind even if the LLM output is unpredictable.
1124
+
1125
+ **Performance monitoring** — `gnosys dashboard` now includes enterprise performance benchmarks: recall latency, active search latency, and archive search latency, with warnings if recall exceeds the 50ms target.
1126
+
1127
+ ---
1128
+
1129
+ ## CLI Reference
1130
+
1131
+ ```bash
1132
+ gnosys --help # List all commands
1133
+ gnosys init # Initialize a new store
1134
+ gnosys add "raw input" # Add memory via LLM
1135
+ gnosys add-structured ... # Add memory with explicit fields (--user/--global for scope)
1136
+ gnosys commit-context "..." # Extract memories from conversation
1137
+ gnosys bootstrap <dir> # Batch-import existing markdown files
1138
+ gnosys import <file> ... # Bulk import CSV/JSON/JSONL data
1139
+ gnosys discover "keywords" # Find relevant memories (metadata only)
1140
+ gnosys search "query" # Full-text search with snippets
1141
+ gnosys hybrid-search "q" # Hybrid keyword + semantic search
1142
+ gnosys semantic-search "q" # Semantic similarity search
1143
+ gnosys ask "question" # Ask a question, get cited answer
1144
+ # All search commands support: --federated --scope <project|user|global> --json
1145
+ gnosys read <path> # Read a specific memory
1146
+ gnosys list # List all memories
1147
+ gnosys lens # Filtered views (category, tag, status, date...)
1148
+ gnosys update <path> ... # Update a memory
1149
+ gnosys reinforce <id> ... # Signal memory usefulness
1150
+ gnosys stale # Find stale memories
1151
+ gnosys history <path> # Git-backed version history
1152
+ gnosys rollback <path> <hash> # Rollback to a previous commit
1153
+ gnosys timeline # Knowledge evolution over time
1154
+ gnosys stats # Summary statistics
1155
+ gnosys links <path> # Wikilinks and backlinks for a memory
1156
+ gnosys graph # Full cross-reference graph
1157
+ gnosys tags # List tag registry
1158
+ gnosys tags-add # Add a new tag
1159
+ gnosys reindex # Build/rebuild semantic embeddings
1160
+ gnosys reindex-graph # Build/rebuild wikilink graph
1161
+ gnosys maintain # Run vault maintenance (dry run by default)
1162
+ gnosys maintain --auto-apply # Apply all maintenance + archiving automatically
1163
+ gnosys dearchive "query" # Force-dearchive memories from archive to active
1164
+ gnosys dashboard # Pretty system dashboard
1165
+ gnosys dashboard --json # Dashboard as JSON
1166
+ gnosys config show # Show SOC configuration
1167
+ gnosys config set provider <name> # Set default provider
1168
+ gnosys config set task <task> <provider> <model> # Route task
1169
+ gnosys doctor # Full system health check (all providers)
1170
+ gnosys stores # Show active stores
1171
+ gnosys recall "query" # Always-on recall (aggressive mode by default)
1172
+ gnosys recall "q" --no-aggressive # Force filtered mode (hard cutoff)
1173
+ gnosys recall "q" --host # Output in <gnosys-recall> host format
1174
+ gnosys recall "q" --json # Recall as JSON for programmatic use
1175
+ gnosys recall "q" --federated # Federated recall across all scopes
1176
+ gnosys audit # View audit trail (last 7 days)
1177
+ gnosys audit --days 30 # View last 30 days of operations
1178
+ gnosys audit --operation ask # Filter by operation type
1179
+ gnosys migrate # Migrate v1.x data to unified gnosys.db
1180
+ gnosys migrate --dry-run # Preview migration without changes
1181
+ gnosys dream # Run Dream Mode consolidation cycle
1182
+ gnosys dream --max-runtime 15 # Limit dream runtime to 15 minutes
1183
+ gnosys dream --no-summaries # Skip summary generation phase
1184
+ gnosys export --to <dir> # Export gnosys.db to Obsidian vault
1185
+ gnosys export --to <dir> --all # Include summaries, reviews, and graph
1186
+ gnosys export --to <dir> --overwrite # Overwrite existing export
1187
+ gnosys serve # Start MCP server (stdio)
1188
+ gnosys serve --with-maintenance # MCP server + maintenance every 6h
1189
+
1190
+ # v3.0: Sandbox Runtime
1191
+ gnosys sandbox start # Start the background sandbox daemon
1192
+ gnosys sandbox stop # Stop the sandbox daemon
1193
+ gnosys sandbox status # Show sandbox process status
1194
+ gnosys helper generate # Generate agent helper library
1195
+
1196
+ # v3.0: Network Share Support
1197
+ gnosys sandbox start --db-path /path/to/network/share # Use network DB
1198
+ gnosys backup --to /backups/gnosys-2026-03-12.db # Backup to specific path
1199
+ gnosys restore --from /backups/gnosys-2026-03-12.db # Restore from specific path
1200
+
1201
+ # v3.0: Centralized Brain
1202
+ gnosys projects # List all registered projects
1203
+ gnosys backup # Backup the central DB
1204
+ gnosys restore <file> # Restore central DB from backup
1205
+ gnosys migrate --to-central # Migrate project data to central DB
1206
+ gnosys pref set <key> <val> # Set a user preference
1207
+ gnosys pref get [key] # Get one or all preferences (--json)
1208
+ gnosys pref delete <key> # Delete a preference
1209
+ gnosys sync # Regenerate agent rules from preferences
1210
+ gnosys fsearch "query" # Federated search (project > user > global)
1211
+ gnosys fsearch "q" --scope user # Filter to specific scope(s)
1212
+ gnosys ambiguity "query" # Check for cross-project ambiguity
1213
+ gnosys briefing # Project briefing (categories, activity, tags)
1214
+ gnosys briefing --all # Briefings for all projects
1215
+ gnosys working-set # Show implicit working set (recent memories)
1216
+ ```
1217
+
1218
+ ---
1219
+
1220
+ ## Development
1221
+
1222
+ ```bash
1223
+ npm install # Install dependencies
1224
+ npm run build # Compile TypeScript
1225
+ npm test # Run test suite (495 tests)
1226
+ npm run test:watch # Run tests in watch mode
1227
+ npm run test:coverage # Run tests with v8 coverage report
1228
+ npm run dev # Run MCP server in dev mode (tsx)
1229
+ ```
1230
+
1231
+ ### Test Suite
1232
+
1233
+ 495 tests across 30 files covering the full v3.0 feature set:
1234
+
1235
+ | Phase | Tests | Coverage |
1236
+ |-------|-------|----------|
1237
+ | Core (DB, store, search, FTS5) | 120+ | db.ts 77%, store.ts 94%, search.ts 78% |
1238
+ | Federation + CLI parity | 100+ | federated.ts 85%, preferences.ts 79% |
1239
+ | Sandbox (server, client, helper) | 32 | client.ts 71%, server.ts 53% |
1240
+ | Phase 9d coverage overhaul | 74 | audit.ts 92%, lock.ts 72%, dbWrite.ts 64% |
1241
+ | Phase 9e network share + polish | 21 | db.ts retry, backup/restore, manager, docs |
1242
+
1243
+ CI runs on Node 20 + 22 with multi-project scenario testing, network-share simulation, and TypeScript strict checking. Coverage reports are generated and uploaded as artifacts on every push.
1244
+
1245
+ ### Architecture
1246
+
1247
+ ```
1248
+ src/
1249
+ index.ts # MCP server — 47+ tools + gnosys://recall resource
1250
+ cli.ts # CLI — full command suite with --json output
1251
+ lib/
1252
+ db.ts # GnosysDB — central SQLite (6-table schema, project_id + scope)
1253
+ dbSearch.ts # Adapter bridging GnosysDB to search interfaces
1254
+ dbWrite.ts # Dual-write helpers (sync .md → gnosys.db)
1255
+ migrate.ts # Migration: v1.x → v2.0 → v3.0 central DB
1256
+ dream.ts # Dream Mode engine + idle scheduler
1257
+ export.ts # Obsidian Export Bridge (gnosys.db → vault)
1258
+ federated.ts # v3.0: Federated search, ambiguity detection, briefings, working set
1259
+ preferences.ts # v3.0: User preferences as scoped memories
1260
+ rulesGen.ts # v3.0: Agent rules generation (GNOSYS:START/END blocks)
1261
+ projectIdentity.ts # v3.0: Project identity (gnosys.json) + central registry
1262
+ store.ts # Core: read/write/update memory files (.md)
1263
+ search.ts # FTS5 search and discovery
1264
+ embeddings.ts # Lazy semantic embeddings (all-MiniLM-L6-v2)
1265
+ hybridSearch.ts # Hybrid search with RRF fusion
1266
+ ask.ts # Freeform Q&A with LLM synthesis + citations
1267
+ llm.ts # LLM abstraction — System of Cognition (5 providers)
1268
+ maintenance.ts # Auto-maintenance: decay, dedup, consolidation, archiving
1269
+ archive.ts # Two-tier memory: active ↔ archive (SQLite)
1270
+ recall.ts # Ultra-fast recall hook for agent orchestrators
1271
+ audit.ts # Structured JSONL audit logging
1272
+ lock.ts # File-level write locking + WAL helper
1273
+ dashboard.ts # Aggregated system dashboard + performance monitoring
1274
+ graph.ts # Persistent wikilink graph (graph.json)
1275
+ tags.ts # Tag registry management
1276
+ ingest.ts # LLM-powered structuring (with retry logic)
1277
+ import.ts # Bulk import engine (CSV, JSON, JSONL)
1278
+ config.ts # gnosys.json loader with Zod validation
1279
+ retry.ts # Exponential backoff for LLM calls
1280
+ resolver.ts # Layered multi-store resolution + MCP roots + multi-project
1281
+ lensing.ts # Memory lensing (filtered views)
1282
+ history.ts # Git history and rollback
1283
+ timeline.ts # Knowledge evolution timeline
1284
+ wikilinks.ts # Obsidian wikilink graph
1285
+ bootstrap.ts # Bootstrap from source code
1286
+ prompts/
1287
+ synthesize.md # System prompt template for ask engine
1288
+ ```
1289
+
1290
+ ---
1291
+
1292
+ ## Benchmarks
1293
+
1294
+ Real numbers from our demo vault (120 memories — 100 USDA foods + 20 NVD CVEs):
1295
+
1296
+ | Metric | Result |
1297
+ |--------|--------|
1298
+ | Import 100 records (structured) | 0.6s |
1299
+ | Cold start (first load) | 0.3s |
1300
+ | Keyword search (FTS5) | <10ms |
1301
+ | Hybrid search (keyword + semantic) | ~50ms |
1302
+ | Reindex 120 embeddings | ~8s (first run downloads ~80 MB model) |
1303
+ | Maintenance dry-run (120 memories) | ~2s |
1304
+ | Graph reindex (120 memories) | <1s |
1305
+ | Storage per memory | ~1 KB `.md` file |
1306
+ | Embedding storage (120 memories) | ~0.3 MB |
1307
+ | Test suite | 495 tests, 0 errors |
1308
+
1309
+ All benchmarks on Apple M-series hardware, Node.js 20+. Structured imports bypass LLM entirely. LLM-enriched imports depend on provider latency.
1310
+
1311
+ ---
1312
+
1313
+ ## Migrating from v2.x to v3.0
1314
+
1315
+ v3.0 is a major architectural upgrade. Here's what changed and how to migrate.
1316
+
1317
+ ### What's New in v3.0
1318
+
1319
+ - **Sandbox-first runtime**: persistent background process replaces per-request MCP overhead
1320
+ - **Central brain**: single `~/.gnosys/gnosys.db` replaces per-project databases
1321
+ - **Federated search**: tier-boosted search across project → user → global scopes
1322
+ - **Preferences**: user preferences stored as scoped memories, driving agent rules generation
1323
+ - **Network share**: point the central DB at Dropbox, iCloud, NAS for multi-machine access
1324
+ - **Helper library**: generated TypeScript/JavaScript library for direct agent integration
1325
+
1326
+ ### Migration Steps
1327
+
1328
+ ```bash
1329
+ # 1. Install v3.0 (package renamed from gnosys-mcp to gnosys)
1330
+ npm install -g gnosys
1331
+
1332
+ # 2. Start the sandbox
1333
+ gnosys sandbox start
1334
+
1335
+ # 3. Migrate each project's data to the central DB
1336
+ cd /path/to/project-a
1337
+ gnosys migrate --to-central
1338
+
1339
+ cd /path/to/project-b
1340
+ gnosys migrate --to-central
1341
+
1342
+ # 4. Generate a helper library (optional, for agent integration)
1343
+ gnosys helper generate
1344
+
1345
+ # 5. Verify migration
1346
+ gnosys projects # List all registered projects
1347
+ gnosys briefing --all # Check project data
1348
+ ```
1349
+
1350
+ ### Breaking Changes
1351
+
1352
+ - **Database location**: The primary database is now `~/.gnosys/gnosys.db`, not `<project>/.gnosys/gnosys.db`. Per-project databases still exist as read fallbacks.
1353
+ - **MCP server**: Still works identically. No config changes needed.
1354
+ - **CLI**: All commands work as before. New commands added for sandbox, preferences, federation.
1355
+ - **Import/export**: Unchanged. Imports go to the central DB by default.
1356
+
1357
+ Your `.gnosys/` directories and `.md` files are preserved. v3.0 reads from both the central DB and local stores, so nothing breaks during gradual migration.
1358
+
1359
+ ---
1360
+
1361
+ ## Community & Next Steps
1362
+
1363
+ Gnosys is open source (MIT) and actively developed. Here's how to get involved:
1364
+
1365
+ **Get started fast:**
1366
+ - **Cursor template:** Add Gnosys to any Cursor project with one MCP config line (see [MCP Server Setup](#mcp-server-setup))
1367
+ - **Docker:** `docker build -t gnosys . && docker compose up` for containerized deployment
1368
+ - **Demo vault:** See [DEMO.md](DEMO.md) for a full walkthrough with USDA + NVD data
1369
+
1370
+ **Contribute:**
1371
+ - [GitHub Discussions](https://github.com/proticom/gnosys/discussions) — share ideas, ask questions, show what you've built
1372
+ - [Issues](https://github.com/proticom/gnosys/issues) — bug reports and feature requests
1373
+ - PRs welcome — especially for new import connectors, LLM providers, and Obsidian plugins
1374
+
1375
+ **What's next:**
1376
+ - Real-time multi-machine sync (automatic conflict resolution)
1377
+ - Temporal memory versioning (valid_from / valid_until)
1378
+ - Cross-session "deep dream" overnight consolidation
1379
+ - Graph visualization in the dashboard
1380
+ - Obsidian community plugin for native vault integration
1381
+ - Docker Hub published image for one-line deployment
1382
+
1383
+ ---
1384
+
1385
+ ## License
1386
+
1387
+ MIT — [LICENSE](LICENSE)