gnosys 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +102 -920
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -14,20 +14,14 @@
14
14
 
15
15
  ---
16
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
17
  ### Gnosys — One Brain. Zero Context Bloat.
20
18
 
21
19
  **Gnosys** gives AI agents persistent memory that survives across sessions, projects, and machines.
22
20
 
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.
21
+ 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. In v4.0, the **Web Knowledge Base** turns any website into a searchable knowledge base for serverless chatbots — pre-computed JSON index, zero runtime dependencies. Process tracing builds call chains from source code. Dream Mode consolidates knowledge during idle time. One-command export regenerates a full Obsidian vault.
24
22
 
25
23
  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
24
 
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
25
  No vector DBs. No black boxes. No external services. Just SQLite, Markdown, and Obsidian — the way knowledge should be.
32
26
 
33
27
  ---
@@ -40,94 +34,22 @@ Gnosys takes a different approach: the central brain is a single SQLite database
40
34
 
41
35
  **What makes it different:**
42
36
 
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.
37
+ - **Sandbox-first** — persistent background process + helper library. Agents call `gnosys.add()` / `gnosys.recall()` like regular code. No MCP overhead, near-zero context cost.
44
38
  - **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.
39
+ - **Federated search** — tier-boosted search across project (1.5x) > user (1.0x) > global (0.7x) scopes with recency and reinforcement boosts.
40
+ - **Web Knowledge Base** — `gnosys web build` turns any website into a searchable knowledge base for serverless chatbots. Powers [Sir Chats-A-Lot](https://sir-chats-a-lot.com).
50
41
  - **Dream Mode** — idle-time consolidation: confidence decay, self-critique, summary generation, relationship discovery. Never deletes — only suggests reviews.
51
42
  - **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
43
  - **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.
44
+ - **Multi-project** — MCP roots + per-tool `projectRoot` routing + central project registry. Multiple Cursor windows, zero conflicts.
45
+ - **Process tracing** — `gnosys trace <dir>` builds call chains from source code with `leads_to`, `follows_from`, and `requires` relationships.
46
+ - **Reflection API** — `gnosys.reflect(outcome)` updates confidence and consolidates memories based on real-world outcomes.
47
+ - **Bulk import** — CSV, JSON, JSONL. Import entire datasets in seconds.
56
48
  - **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.
49
+ - **MCP-compatible** — also runs as a full MCP server that drops into Cursor, Claude Desktop, Claude Code, Cowork, Codex, or any MCP client.
64
50
  - **Zero infrastructure** — no external databases, no Docker (unless you want it), no cloud services. Just `npm install`.
65
51
 
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.
52
+ > For the complete CLI reference and detailed guides, see the **[User Guide](https://gnosys.ai/guide.html)**.
131
53
 
132
54
  ---
133
55
 
@@ -155,7 +77,7 @@ gnosys search "PostgreSQL"
155
77
  gnosys helper generate
156
78
  ```
157
79
 
158
- ### Agent / Helper Library (v3.0)
80
+ ### Agent / Helper Library
159
81
 
160
82
  ```ts
161
83
  import { gnosys } from "./gnosys-helper"; // generated once, reused forever
@@ -272,9 +194,25 @@ Add to `gnosys.json`:
272
194
  }
273
195
  ```
274
196
 
275
- ### GEO Integration
197
+ ### The `/knowledge/` Directory
198
+
199
+ `gnosys web build` generates a `/knowledge/` directory containing:
200
+
201
+ - **Markdown files** — one per page, with YAML frontmatter (title, category, tags, relevance keywords, source URL, content hash)
202
+ - **`gnosys-index.json`** — pre-computed TF-IDF inverted index for sub-5ms in-memory search
203
+ - All files commit to git and deploy with your app — the knowledge base and the site are always in sync
276
204
 
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.
205
+ This directory is the bridge between your website content and any AI system. [Sir Chats-A-Lot](https://sir-chats-a-lot.com) uses it to power website chatbots with zero infrastructure.
206
+
207
+ ### Generative Engine Optimization (GEO)
208
+
209
+ The `/knowledge/` markdown files double as a structured content layer for AI crawlers and LLM-powered search engines. To make your knowledge base discoverable:
210
+
211
+ 1. Add a [`llms.txt`](https://llmstxt.org/) file to your site root pointing to the knowledge directory
212
+ 2. Reference individual markdown files in your `llms.txt` for fine-grained content exposure
213
+ 3. YAML frontmatter provides structured metadata (title, category, tags) that LLMs can parse directly
214
+
215
+ This improves your site's visibility in AI-powered search results and enables LLMs to cite your content accurately.
278
216
 
279
217
  ### SQLite vs Web Mode
280
218
 
@@ -290,45 +228,6 @@ The `/knowledge/` directory of markdown files can be served to AI crawlers. YAML
290
228
 
291
229
  ---
292
230
 
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
231
  ## MCP Server Setup
333
232
 
334
233
  ### Claude Desktop
@@ -382,7 +281,9 @@ command = ["gnosys", "serve"]
382
281
  ANTHROPIC_API_KEY = "your-key-here"
383
282
  ```
384
283
 
385
- ### MCP Tools
284
+ ---
285
+
286
+ ## MCP Tools
386
287
 
387
288
  | Tool | Description |
388
289
  |------|-------------|
@@ -421,7 +322,7 @@ ANTHROPIC_API_KEY = "your-key-here"
421
322
  | `gnosys_stores` | Show active stores, MCP roots, and detected project stores |
422
323
  | `gnosys_tags` | List tag registry |
423
324
  | `gnosys_tags_add` | Add a new tag to the registry |
424
- | **v3.0: Centralized Brain** | |
325
+ | **Centralized Brain** | |
425
326
  | `gnosys_projects` | List all registered projects in the central DB |
426
327
  | `gnosys_backup` | Create a point-in-time backup of the central DB |
427
328
  | `gnosys_restore` | Restore the central DB from a backup |
@@ -430,94 +331,22 @@ ANTHROPIC_API_KEY = "your-key-here"
430
331
  | `gnosys_preference_get` | Get one or all preferences |
431
332
  | `gnosys_preference_delete` | Delete a preference |
432
333
  | `gnosys_sync` | Regenerate agent rules file from preferences + conventions |
433
- | `gnosys_federated_search` | Tier-boosted search across project user global scopes |
334
+ | `gnosys_federated_search` | Tier-boosted search across project > user > global scopes |
434
335
  | `gnosys_detect_ambiguity` | Check if a query matches multiple projects |
435
336
  | `gnosys_briefing` | Generate project briefing (categories, activity, tags, summary) |
436
337
  | `gnosys_working_set` | Get recently modified memories for the current project |
437
338
 
438
339
  ---
439
340
 
440
- ## How It Works
341
+ ## Key Features
441
342
 
442
- ### Central Brain (v3.0)
343
+ ### Central Brain
443
344
 
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:
345
+ All memories live in a single `~/.gnosys/gnosys.db` with `project_id` and `scope` columns. Every write is dual-written to both SQLite and a human-readable `.md` file. Sub-10ms reads, WAL mode for concurrent access. See the [User Guide](https://gnosys.ai/guide.html) for the full schema and memory format.
445
346
 
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.
347
+ ### LLM Providers
464
348
 
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
349
+ Five providers behind a single interface switch between cloud and local with one command:
521
350
 
522
351
  | Provider | Type | Default Model | API Key Env Var |
523
352
  |----------|------|---------------|-----------------|
@@ -527,21 +356,14 @@ gnosys doctor
527
356
  | **OpenAI** | Cloud | gpt-4o-mini | `OPENAI_API_KEY` |
528
357
  | **LM Studio** | Local | default | — (runs locally) |
529
358
 
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:
359
+ Route tasks to different providers a cheap model for structuring, a powerful model for synthesis:
535
360
 
536
361
  ```json
537
362
  {
538
363
  "llm": {
539
364
  "defaultProvider": "anthropic",
540
365
  "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" }
366
+ "ollama": { "model": "llama3.2", "baseUrl": "http://localhost:11434" }
545
367
  },
546
368
  "taskModels": {
547
369
  "structuring": { "provider": "ollama", "model": "llama3.2" },
@@ -550,32 +372,29 @@ Use different models for different tasks — a cheap/fast model for structuring
550
372
  }
551
373
  ```
552
374
 
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
- ---
375
+ ### Dream Mode
556
376
 
557
- ## Using with Obsidian
377
+ Idle-time consolidation inspired by biological memory: confidence decay, self-critique, summary generation, and relationship discovery. Runs automatically when the sandbox is idle, or manually with `gnosys dream`. Never deletes — only flags for review. See the [User Guide](https://gnosys.ai/guide.html) for configuration and scheduling.
558
378
 
559
- The primary store is the central `~/.gnosys/gnosys.db`. Use the **Obsidian Export Bridge** to generate a full Obsidian vault from the database:
379
+ ### Federated Search
560
380
 
561
- ```bash
562
- # Export to an Obsidian-compatible vault
563
- gnosys export --to ~/vaults/my-project
381
+ All search commands support `--federated` to search across project (1.5x boost), user (1.0x), and global (0.7x) scopes in the central DB. Recency adds a 1.3x boost, reinforcement count adds up to 25%. Results include `scope` and `boosts` fields so agents know where each memory came from. See the [User Guide](https://gnosys.ai/guide.html) for details.
564
382
 
565
- # Overwrite an existing export
566
- gnosys export --to ~/vaults/my-project --overwrite
383
+ ### Process Tracing
567
384
 
568
- # Export everything including summaries, reviews, and graph data
569
- gnosys export --to ~/vaults/my-project --all
570
- ```
385
+ `gnosys trace ./src` scans TypeScript/JavaScript files, extracts function declarations and call sites, then stores each as a procedural "how" memory with `leads_to`, `follows_from`, and `requires` relationships. `gnosys traverse <id>` walks relationship chains via BFS with depth limiting and type filtering. See the [User Guide](https://gnosys.ai/guide.html) for details.
571
386
 
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.
387
+ ### Obsidian Export
573
388
 
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.
389
+ The primary store is the central `gnosys.db`. Use the Obsidian Export Bridge to generate a full vault:
575
390
 
576
- ---
391
+ ```bash
392
+ gnosys export --to ~/vaults/my-project
393
+ gnosys export --to ~/vaults/my-project --overwrite
394
+ gnosys export --to ~/vaults/my-project --all # summaries, reviews, graph data
395
+ ```
577
396
 
578
- ## Bulk Import
397
+ ### Bulk Import
579
398
 
580
399
  Import any structured dataset into atomic memories:
581
400
 
@@ -592,419 +411,12 @@ gnosys import data.csv --format csv \
592
411
  # JSONL (one record per line)
593
412
  gnosys import events.jsonl --format jsonl \
594
413
  --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
414
  ```
645
415
 
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
416
  ---
1003
417
 
1004
418
  ## Comparison
1005
419
 
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
420
  | Aspect | Plain Markdown | RAG (Vector DB) | Knowledge Graph | **Gnosys** |
1009
421
  |--------|---------------|-----------------|-----------------|-----------|
1010
422
  | **Examples** | CLAUDE.md, .cursorrules | Mem0, LangChain Memory | Graphiti/Zep, Mem0 Graph | — |
@@ -1014,206 +426,40 @@ Agent memory is a spectrum — from a single markdown file to full knowledge gra
1014
426
  | **Keyword search** | Manual / grep | BM25 layer (some) | BM25 layer (some) | FTS5 (built-in) |
1015
427
  | **Semantic search** | None | Vector similarity | Graph + vectors | Vector + FTS5 hybrid (RRF) |
1016
428
  | **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 |
429
+ | **Scale comfort zone** | ~5K memories | 100K+ | 100K+ | 100K+ (unified SQLite + archive tier) |
430
+ | **Setup time** | < 5 min | 30 min - 2 hours | 4 - 8 hours | 15 - 30 min |
1021
431
  | **Infrastructure** | None | Vector DB + embeddings API | Graph DB + LLM | SQLite (embedded) |
1022
432
  | **Human editability** | Excellent | Poor (re-embed) | Moderate | Excellent |
1023
433
  | **MCP integration** | Via skill files | Custom server | Mem0 ships MCP | MCP server (included) |
1024
434
  | **Obsidian compatible** | Partially | No | No | Yes (full vault) |
1025
- | **Cost** | Free | $0500+/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 |
435
+ | **Cost** | Free | $0-500+/mo (cloud DB + embeddings) | $250+/mo (Mem0 Pro) or self-host | Free (MIT) |
1027
436
  | **Offline capable** | Yes | Self-hosted only | Self-hosted only | Yes (Ollama/LM Studio) |
1028
437
 
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
438
+ ---
1106
439
 
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`.
440
+ ## CLI Reference
1108
441
 
1109
- **Claude Desktop** Same MCP config. The resource appears in the model context on every message.
442
+ All commands support `--json` for programmatic output. See the [User Guide](https://gnosys.ai/guide.html) for full details.
1110
443
 
1111
- **Claude Code / Cowork** Configure via `.mcp.json` or the MCP settings. The `gnosys://recall` resource is injected into every assistant turn.
444
+ **Memory operations:** `add`, `add-structured`, `commit-context`, `read`, `update`, `reinforce`, `bootstrap`, `import`
1112
445
 
1113
- No per-turn tool calls, no manual invocation — just configure the MCP server once and memories flow into every conversation automatically.
446
+ **Search:** `discover`, `search`, `hybrid-search`, `semantic-search`, `ask`, `recall`, `fsearch`
1114
447
 
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.
448
+ **Views & analysis:** `list`, `lens`, `stale`, `timeline`, `stats`, `links`, `graph`, `tags`, `tags-add`, `audit`
1116
449
 
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.
450
+ **History:** `history`, `rollback`
1118
451
 
1119
- ```bash
1120
- gnosys audit --days 7 --operation recall --json
1121
- ```
452
+ **Maintenance:** `maintain`, `dearchive`, `dream`, `reindex`, `reindex-graph`
1122
453
 
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.
454
+ **Export & config:** `export`, `config show`, `config set`, `dashboard`, `doctor`, `stores`
1124
455
 
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.
456
+ **Centralized brain:** `projects`, `backup`, `restore`, `migrate`, `pref set/get/delete`, `sync`, `ambiguity`, `briefing`, `working-set`
1126
457
 
1127
- ---
458
+ **Sandbox:** `sandbox start/stop/status`, `helper generate`
1128
459
 
1129
- ## CLI Reference
460
+ **Web knowledge base:** `web init`, `web ingest`, `web build-index`, `web build`, `web add`, `web remove`, `web status`
1130
461
 
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
- ```
462
+ **Server:** `serve`, `serve --with-maintenance`
1217
463
 
1218
464
  ---
1219
465
 
@@ -1222,76 +468,61 @@ gnosys working-set # Show implicit working set (recent memories)
1222
468
  ```bash
1223
469
  npm install # Install dependencies
1224
470
  npm run build # Compile TypeScript
1225
- npm test # Run test suite (495 tests)
471
+ npm test # Run test suite (558 tests)
1226
472
  npm run test:watch # Run tests in watch mode
1227
473
  npm run test:coverage # Run tests with v8 coverage report
1228
474
  npm run dev # Run MCP server in dev mode (tsx)
1229
475
  ```
1230
476
 
1231
- ### Test Suite
477
+ 558 tests across 35+ files. CI runs on Node 20 + 22 with multi-project scenario testing, network-share simulation, and TypeScript strict checking.
1232
478
 
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.
479
+ ---
1244
480
 
1245
- ### Architecture
481
+ ## Architecture
1246
482
 
1247
483
  ```
1248
484
  src/
1249
- index.ts # MCP server — 47+ tools + gnosys://recall resource
485
+ index.ts # MCP server — 50+ tools + gnosys://recall resource
1250
486
  cli.ts # CLI — full command suite with --json output
1251
487
  lib/
1252
- db.ts # GnosysDB — central SQLite (6-table schema, project_id + scope)
488
+ db.ts # Central SQLite (6-table schema, project_id + scope)
1253
489
  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
490
+ dbWrite.ts # Dual-write helpers (sync .md <-> gnosys.db)
491
+ migrate.ts # Migration: v1.x -> v2.0 -> central DB
1256
492
  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
493
+ export.ts # Obsidian Export Bridge (gnosys.db -> vault)
494
+ federated.ts # Federated search, ambiguity detection, briefings
495
+ preferences.ts # User preferences as scoped memories
496
+ rulesGen.ts # Agent rules generation (GNOSYS:START/END blocks)
1262
497
  store.ts # Core: read/write/update memory files (.md)
1263
498
  search.ts # FTS5 search and discovery
1264
499
  embeddings.ts # Lazy semantic embeddings (all-MiniLM-L6-v2)
1265
500
  hybridSearch.ts # Hybrid search with RRF fusion
1266
501
  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)
502
+ llm.ts # LLM abstraction (5 providers)
503
+ maintenance.ts # Auto-maintenance: decay, dedup, archiving
504
+ archive.ts # Two-tier memory: active <-> archive
505
+ recall.ts # Ultra-fast recall for agent orchestrators
506
+ audit.ts # Structured audit logging
507
+ graph.ts # Persistent wikilink graph
508
+ trace.ts # Process tracing + reflection
1278
509
  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
510
+ resolver.ts # Layered multi-store resolution + MCP roots
511
+ import.ts # Bulk import engine (CSV, JSON, JSONL)
512
+ staticSearch.ts # Zero-dep web search runtime (gnosys/web)
513
+ webIndex.ts # Build-time inverted index generator
514
+ webIngest.ts # Site crawler (sitemap -> markdown)
515
+ sandbox/
516
+ server.ts # Unix socket server + Dream Mode scheduler
517
+ client.ts # Client for agent connections
518
+ manager.ts # Process lifecycle management
1288
519
  ```
1289
520
 
1290
521
  ---
1291
522
 
1292
523
  ## Benchmarks
1293
524
 
1294
- Real numbers from our demo vault (120 memories — 100 USDA foods + 20 NVD CVEs):
525
+ Real numbers from a 120-memory test vault:
1295
526
 
1296
527
  | Metric | Result |
1297
528
  |--------|--------|
@@ -1304,57 +535,9 @@ Real numbers from our demo vault (120 memories — 100 USDA foods + 20 NVD CVEs)
1304
535
  | Graph reindex (120 memories) | <1s |
1305
536
  | Storage per memory | ~1 KB `.md` file |
1306
537
  | 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.
538
+ | Test suite | 558 tests, 0 errors |
1356
539
 
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.
540
+ All benchmarks on Apple M-series hardware, Node.js 20+. Structured imports bypass LLM entirely.
1358
541
 
1359
542
  ---
1360
543
 
@@ -1365,7 +548,6 @@ Gnosys is open source (MIT) and actively developed. Here's how to get involved:
1365
548
  **Get started fast:**
1366
549
  - **Cursor template:** Add Gnosys to any Cursor project with one MCP config line (see [MCP Server Setup](#mcp-server-setup))
1367
550
  - **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
551
 
1370
552
  **Contribute:**
1371
553
  - [GitHub Discussions](https://github.com/proticom/gnosys/discussions) — share ideas, ask questions, show what you've built
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gnosys",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "Gnosys — Persistent Memory for AI Agents. Sandbox-first runtime, central SQLite brain, federated search, Dream Mode, Web Knowledge Base, Obsidian export.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",