@titan-design/brain 0.3.0 → 0.5.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 CHANGED
@@ -1,6 +1,15 @@
1
- # Brain
1
+ # @titan-design/brain
2
2
 
3
- Personal knowledge base and memory engine with hybrid RAG search (BM25 + vector embeddings), LLM-powered memory extraction, and temporal intelligence.
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
4
13
 
5
14
  ## Install
6
15
 
@@ -15,13 +24,28 @@ Requires Node >= 22.
15
24
  ```bash
16
25
  brain init # Initialize workspace
17
26
  brain index # Index notes
18
- brain search "query" # Hybrid search
27
+ brain search "query" # Hybrid BM25 + vector search
19
28
  brain quick "thought" # Capture to inbox
20
29
  brain extract --all # Extract memories (requires Ollama)
21
30
  ```
22
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
+
23
45
  ## Commands
24
46
 
47
+ ### Core
48
+
25
49
  | Command | Description |
26
50
  |---------|-------------|
27
51
  | `brain init` | Initialize workspace and database |
@@ -35,6 +59,7 @@ brain extract --all # Extract memories (requires Ollama)
35
59
  | `brain extract` | Extract memories from notes (Ollama) |
36
60
  | `brain memories` | List, history, and stats for memories |
37
61
  | `brain context <id>` | Show context for a note (relations + memories) |
62
+ | `brain lineage <id>` | Show memory version lineage |
38
63
  | `brain profile` | Generate agent context profile |
39
64
  | `brain tidy` | LLM-powered note cleanup suggestions |
40
65
  | `brain doctor` | System health checks (`--fix` for auto-repair) |
@@ -46,13 +71,67 @@ brain extract --all # Extract memories (requires Ollama)
46
71
  | `brain archive` | Archive expired notes |
47
72
  | `brain config` | View/set configuration |
48
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
+
49
128
  ## How It Works
50
129
 
51
130
  Brain indexes markdown files with YAML frontmatter into a SQLite database. It combines three layers:
52
131
 
53
132
  **Search** — Hybrid BM25 full-text search (FTS5) + vector similarity (sqlite-vec) with reciprocal rank fusion. Optional cross-encoder reranking via `--rerank`.
54
133
 
55
- **Memory extraction** — Ollama LLM extracts discrete facts from notes, then reconciles them against existing memories (ADD/UPDATE/DELETE). Memories are versioned with parent chains, temporal validity (`valid_at`/`invalid_at`), and automatic forgetting (`forget_after`).
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`).
56
135
 
57
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.
58
137
 
@@ -67,46 +146,23 @@ Brain indexes markdown files with YAML frontmatter into a SQLite database. It co
67
146
  - `slow` — permanent knowledge (decisions, patterns, research) with review intervals
68
147
  - `fast` — ephemeral (meetings, session logs) with expiry dates
69
148
 
70
- ## Architecture
149
+ ## Testing
71
150
 
72
- ```
73
- src/
74
- cli.ts — Entry point, Commander program
75
- types.ts — All TypeScript interfaces
76
- utils.ts — Shared utilities
77
- commands/ CLI commands (22 commands)
78
- services/
79
- brain-db.ts — Database facade (delegates to repos)
80
- brain-service.ts — Resource management (withBrain/withDb)
81
- repos/
82
- note-repo.ts — Notes, files, chunks, relations, FTS, search queries
83
- memory-repo.ts — Memory entries, history, vectors
84
- capture-repo.ts — Inbox items, feed records
85
- config.ts — Configuration loading
86
- file-scanner.ts — File change detection
87
- markdown-parser.ts — Frontmatter + heading-aware chunking
88
- search.ts — Hybrid search orchestration
89
- graph.ts — Note relation traversal
90
- indexing.ts — Index pipeline
91
- memory-extractor.ts — LLM fact extraction and reconciliation
92
- ollama.ts — Ollama client and health checks
93
- health.ts — System health check service
94
- reranker.ts — Cross-encoder reranking
95
- adapters/ — Embedder backends (local/ollama/remote)
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
96
157
  ```
97
158
 
98
- **Storage:** SQLite via better-sqlite3 with FTS5 and sqlite-vec
159
+ ## Documentation
99
160
 
100
- ## Development
101
-
102
- ```bash
103
- npm install
104
- npm test # Vitest (380 tests)
105
- npm run build # tsup → dist/cli.js
106
- npm run typecheck # tsc --noEmit
107
- npm run lint # ESLint
108
- npx tsx src/cli.ts # Run CLI in dev
109
- ```
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)
110
166
 
111
167
  ## License
112
168
 
@@ -0,0 +1,14 @@
1
+ import {
2
+ LocalEmbedder,
3
+ OllamaEmbedder,
4
+ RemoteEmbedder,
5
+ createEmbedder,
6
+ getEmbedderInfo
7
+ } from "./chunk-BDNH2E2O.js";
8
+ export {
9
+ LocalEmbedder,
10
+ OllamaEmbedder,
11
+ RemoteEmbedder,
12
+ createEmbedder,
13
+ getEmbedderInfo
14
+ };
@@ -0,0 +1,11 @@
1
+ import {
2
+ withBrain,
3
+ withDb
4
+ } from "./chunk-QL2GPXP6.js";
5
+ import "./chunk-BDNH2E2O.js";
6
+ import "./chunk-4SD4JRLS.js";
7
+ import "./chunk-PO3GJPIC.js";
8
+ export {
9
+ withBrain,
10
+ withDb
11
+ };