@titan-design/brain 0.2.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,169 @@
1
+ # @titan-design/brain
2
+
3
+ Developer second brain — hybrid RAG search (BM25 + vector embeddings), LLM-powered memory extraction, project management with AI orchestration, and temporal intelligence.
4
+
5
+ ## Features
6
+
7
+ - **Hybrid Search** — BM25 + vector with RRF/score fusion, optional cross-encoder reranking
8
+ - **Memory Engine** — LLM-extracted facts with version chaining, temporal validity, auto-forgetting
9
+ - **Project Management** — Full PM module: projects, workstreams, tasks, dependencies, waves, dispatch
10
+ - **AI Orchestration** — Agent routing, claim tokens, worktree isolation, verification, cost tracking
11
+ - **Inbox Pipeline** — Zero-friction capture from CLI, file import, RSS feeds
12
+ - **Module System** — Extensible plugin architecture with namespace isolation
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ npm install @titan-design/brain
18
+ ```
19
+
20
+ Requires Node >= 22.
21
+
22
+ ## Quick Start
23
+
24
+ ```bash
25
+ brain init # Initialize workspace
26
+ brain index # Index notes
27
+ brain search "query" # Hybrid BM25 + vector search
28
+ brain quick "thought" # Capture to inbox
29
+ brain extract --all # Extract memories (requires Ollama)
30
+ ```
31
+
32
+ ## PM Module Quick Start
33
+
34
+ ```bash
35
+ brain pm init "My Project" --prefix MY
36
+ brain pm use MY
37
+ brain pm workstream add "Core Features" --project MY
38
+ brain pm task add "First task" --project MY --workstream 1 --category implementation
39
+ brain pm waves
40
+ brain pm briefing
41
+ ```
42
+
43
+ See [PM Quick Start](docs/pm-module/quickstart.md) for the full 5-minute guide.
44
+
45
+ ## Commands
46
+
47
+ ### Core
48
+
49
+ | Command | Description |
50
+ |---------|-------------|
51
+ | `brain init` | Initialize workspace and database |
52
+ | `brain index` | Index all markdown notes |
53
+ | `brain search "query"` | Hybrid BM25 + vector search |
54
+ | `brain add <file>` | Add a note from file or stdin |
55
+ | `brain quick "text"` | Zero-friction capture to inbox |
56
+ | `brain inbox` | View/manage inbox items |
57
+ | `brain ingest` | Bulk-import files to inbox |
58
+ | `brain feed` | Manage RSS feed subscriptions |
59
+ | `brain extract` | Extract memories from notes (Ollama) |
60
+ | `brain memories` | List, history, and stats for memories |
61
+ | `brain context <id>` | Show context for a note (relations + memories) |
62
+ | `brain lineage <id>` | Show memory version lineage |
63
+ | `brain profile` | Generate agent context profile |
64
+ | `brain tidy` | LLM-powered note cleanup suggestions |
65
+ | `brain doctor` | System health checks (`--fix` for auto-repair) |
66
+ | `brain install-hooks` | Set up launchd/systemd scheduled processing |
67
+ | `brain status` | Database stats |
68
+ | `brain stale` | Notes needing review |
69
+ | `brain graph <id>` | Show note relations |
70
+ | `brain template <type>` | Output frontmatter template |
71
+ | `brain archive` | Archive expired notes |
72
+ | `brain config` | View/set configuration |
73
+
74
+ ### Project Management (`brain pm`)
75
+
76
+ | Command | Description |
77
+ |---------|-------------|
78
+ | `brain pm init <name> --prefix <P>` | Initialize a new project |
79
+ | `brain pm use <prefix>` | Set active project context |
80
+ | `brain pm list` | List all projects |
81
+ | `brain pm status [prefix]` | Show project status |
82
+ | `brain pm workstream add <name>` | Add a workstream |
83
+ | `brain pm task add <name>` | Create a task |
84
+ | `brain pm task list` | List tasks (filterable by status, workstream) |
85
+ | `brain pm task done <id>` | Mark task done |
86
+ | `brain pm next` | Show eligible tasks (all deps satisfied) |
87
+ | `brain pm waves` | Topological wave grouping of remaining tasks |
88
+ | `brain pm dispatch <id>` | Assemble context bundle for a task |
89
+ | `brain pm complete <id>` | Mark done, run impact analysis |
90
+ | `brain pm briefing` | Session briefing with project state overview |
91
+ | `brain pm audit summary` | Activity log, cost tracking |
92
+ | `brain pm check [--deep]` | Consistency check (structural + semantic analysis) |
93
+ | `brain pm setup` | Configure PM module (paths, hooks) |
94
+ | `brain pm install-hooks` | Install PM hooks and skills (orchestrator + sanity-check) |
95
+
96
+ ## Architecture
97
+
98
+ ```
99
+ src/
100
+ cli.ts — Entry point, Commander program
101
+ types.ts — TypeScript interfaces and constants
102
+ utils.ts — Shared utilities
103
+ commands/ — 22 core CLI commands
104
+ modules/
105
+ types.ts — Module system interfaces
106
+ registry.ts — ModuleRegistry class
107
+ context.ts — Module context factory
108
+ loader.ts — Module discovery and loading
109
+ validation.ts — Frontmatter schema validation
110
+ pm/ — Project management module
111
+ commands/ — 15 command groups (incl. check)
112
+ data/ — CRUD operations and queries
113
+ engine/ — Dependency waves, dispatch, state machine, claims, consistency
114
+ services/
115
+ brain-db.ts — Database facade
116
+ brain-service.ts — Resource lifecycle (withBrain/withDb)
117
+ repos/ — Domain repositories (note, memory, capture)
118
+ config.ts — Configuration loading
119
+ search.ts — Hybrid search orchestration
120
+ memory-extractor.ts — LLM fact extraction and reconciliation
121
+ indexing.ts — Index pipeline
122
+ reranker.ts — Cross-encoder reranking
123
+ adapters/ — Embedder backends (local/ollama/remote)
124
+ ```
125
+
126
+ **Storage:** SQLite via better-sqlite3 with FTS5 full-text search and sqlite-vec for vector search.
127
+
128
+ ## How It Works
129
+
130
+ Brain indexes markdown files with YAML frontmatter into a SQLite database. It combines three layers:
131
+
132
+ **Search** — Hybrid BM25 full-text search (FTS5) + vector similarity (sqlite-vec) with reciprocal rank fusion. Optional cross-encoder reranking via `--rerank`.
133
+
134
+ **Memory extraction** — Ollama LLM extracts discrete facts from notes, reconciled against existing memories (ADD/UPDATE/DELETE). Memories are versioned with parent chains, temporal validity (`valid_at`/`invalid_at`), and automatic forgetting (`forget_after`).
135
+
136
+ **Capture pipeline** — Zero-friction ingestion from CLI quick capture, file import, and RSS feed subscriptions. Items flow through an inbox queue before being indexed.
137
+
138
+ ### Embedding Backends
139
+
140
+ - **Local** — `@huggingface/transformers` (default, no external dependencies)
141
+ - **Ollama** — local Ollama server
142
+ - **Remote** — configurable API endpoint
143
+
144
+ ### Note Tiers
145
+
146
+ - `slow` — permanent knowledge (decisions, patterns, research) with review intervals
147
+ - `fast` — ephemeral (meetings, session logs) with expiry dates
148
+
149
+ ## Testing
150
+
151
+ ```bash
152
+ npm test # 1,095 tests (Vitest)
153
+ npm run typecheck # TypeScript checking
154
+ npm run lint # ESLint
155
+ npm run build # Production build (tsup)
156
+ npx tsx src/cli.ts # Run CLI in development
157
+ ```
158
+
159
+ ## Documentation
160
+
161
+ - [PM Quick Start](docs/pm-module/quickstart.md)
162
+ - [PM User Guide](docs/pm-module/guide.md)
163
+ - [PM Architecture](docs/pm-module/architecture.md)
164
+ - [PM Command Reference](docs/pm-module/commands.md)
165
+ - [Demo Workflow](docs/pm-module/demo.md)
166
+
167
+ ## License
168
+
169
+ MIT