backbrain 1.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kaustubh Deshpande
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,497 @@
1
+ # Backbrain (formerly flux-cap)
2
+
3
+ > Backbrain: keep a running memory of your work, searchable from the CLI and readable by your AI.
4
+
5
+ *Backbrain was previously called flux-cap. The CLI `flux` still works as an alias, but `bb` is now the primary command.*
6
+
7
+ ---
8
+
9
+ ### How this was built
10
+
11
+ Backbrain is a personal project built incrementally over several weeks — not generated in one shot. The search algorithm (`searchV2Helper`) was designed from first principles: Fuse.js scores are inverted and weighted, recency uses exponential decay (`e^(-days/7)`), and git context gets a dynamic boost multiplier when you have uncommitted changes. The TUI was built twice — once in Ink, once in Rezi — to compare performance and ergonomics firsthand.
12
+
13
+ The commit history tells the story better than this paragraph.
14
+
15
+ ---
16
+
17
+ [![npm version](https://img.shields.io/npm/v/@dev_desh/flux-cap)](https://www.npmjs.com/package/@dev_desh/flux-cap)
18
+ [![npm downloads](https://img.shields.io/npm/dm/@dev_desh/flux-cap)](https://www.npmjs.com/package/@dev_desh/flux-cap)
19
+ [![license](https://img.shields.io/npm/l/@dev_desh/flux-cap)](LICENSE)
20
+
21
+ **Now at v1.1.0** — with Search 2.0 multi-signal ranking, interactive TUI, and MCP integration for AI assistants.
22
+
23
+ ### What's new:
24
+ - **v1.1.0:** Backbrain MCP support for AI integration!
25
+ - **v1.0.0:** First stable release with Rezi TUI
26
+ - **v0.10.0:** Rezi-based lazygit-style TUI (`bb u`)
27
+ - **v0.9.0:** Ink-powered interactive search TUI
28
+ - **v0.8.0:** Search 2.0 — multi-signal ranking with git context awareness
29
+
30
+ ## What is Backbrain?
31
+
32
+ Backbrain is a git-aware developer journal that keeps a running memory of your work. It's designed for developers who context-switch frequently and need to maintain mental state across interruptions.
33
+
34
+ ### Key Features:
35
+ - **Terminal-first CLI** - Capture thoughts without leaving your terminal
36
+ - **Smart Search** - Multi-signal ranking with git context awareness
37
+ - **Interactive TUI** - Real-time search with professional interface
38
+ - **AI Integration** - MCP server for seamless AI assistant access (Cursor, Claude, Zed)
39
+ - **Git-aware** - Automatically tracks branch context and uncommitted changes
40
+ - **Local & Private** - All data stored locally in human-readable JSON
41
+
42
+ ## Installation
43
+
44
+ Install Backbrain globally using your preferred package manager:
45
+
46
+ ```bash
47
+ # Using npm
48
+ npm install -g @dev_desh/flux-cap
49
+
50
+ # Using pnpm
51
+ pnpm install -g @dev_desh/flux-cap
52
+
53
+ # Using bun
54
+ bun install -g @dev_desh/flux-cap
55
+ ```
56
+
57
+ ## Quick Start
58
+
59
+ ### 1. Initialize Backbrain in your project root folder
60
+ ```bash
61
+ bb init
62
+ ```
63
+ *Interactive setup will ask about your privacy preferences*
64
+
65
+ ### 2. Start capturing notes with tags
66
+ ```bash
67
+ # Basic notes
68
+ bb note "remember to add error handling to auth module"
69
+ bb note "bug in user validation - check line 42"
70
+
71
+ # Tagged notes for better organization
72
+ bb note -i "add dark mode toggle" # Ideas
73
+ bb note -n "team meeting at 3pm tomorrow" # Notes
74
+ bb note -t "refactor payment processing logic" # Tasks
75
+ bb note -b "payment flow fails on Safari" # Bugs
76
+ bb note -l "https://docs.example.com/api" # Links
77
+ ```
78
+
79
+ ### 3. Search your notes with intelligent ranking
80
+
81
+ Backbrain features **Search 2.0** - intelligent, context-aware search that prioritizes:
82
+ - **Recent notes** (exponential decay scoring)
83
+ - **Same git branch** as your current work
84
+ - **Same working directory** context
85
+ - **Exact tag matches** for specific searches
86
+
87
+ ```bash
88
+ # Smart context-aware search
89
+ bb search auth # Prioritizes recent + current branch matches
90
+ bb s payment # Quick alias
91
+ bb search "authentication bug" # Multi-word search
92
+
93
+ # Coming soon: Convenience commands
94
+ bb recent # Last 10 notes
95
+ bb here # Current branch + directory
96
+ bb notes # All note-tagged entries
97
+ ```
98
+
99
+ ## Interactive TUI
100
+
101
+ Backbrain includes a terminal user interface for interactive searching:
102
+
103
+ ![TUI Interface](https://github.com/kaustubh285/flux-cap/blob/main/images/v0.10-rezi-interactive.png)
104
+
105
+ ### Features
106
+ - **Real-time Search**: Results update as you type
107
+ - **Search 2.0 Integration**: Same scoring system as CLI search
108
+ - **Professional Layout**: Fixed table format matching CLI output
109
+ - **Context Tags**: Visual indicators for recent, same-branch, same-dir
110
+ - **Stable Interface**: Fixed height prevents layout jumps
111
+ - **Slash Commands**: Type `/exit` to quit cleanly
112
+
113
+ ### Usage
114
+ ```bash
115
+ # Start interactive search
116
+ bb u
117
+
118
+ # Search and navigate
119
+ # Type query -> See results instantly
120
+ # /exit -> Quit cleanly
121
+ ```
122
+
123
+ ## AI Integration
124
+
125
+ Backbrain now integrates with AI assistants via MCP (Model Context Protocol):
126
+
127
+ ![MCP Integration](https://github.com/kaustubh285/flux-cap/blob/main/images/mcp-integration.png)
128
+
129
+ ### What This Gives You:
130
+ - **Shared Memory**: AI agents can access your notes as context
131
+ - **Smart Captures**: AI suggests capturing important conversation insights
132
+ - **Context Awareness**: AI knows your past work when helping with current tasks
133
+ - **Seamless Workflow**: No context switching between CLI and AI chat
134
+
135
+ ### Setup:
136
+ Add Backbrain MCP integration to your AI assistant config:
137
+
138
+ ```json
139
+ {
140
+ "mcpServers": {
141
+ "backbrain": {
142
+ "command": "bb",
143
+ "args": ["mcp-server"],
144
+ "env": {}
145
+ }
146
+ }
147
+ }
148
+ ```
149
+
150
+ Add it to:
151
+ - **Cursor**: `~/.cursor/mcp.json`
152
+ - **Zed**: `~/.config/zed/settings.json` (add to 'language_models' section)
153
+ - **Claude Desktop**: `~/Library/Application Support/Claude/claude_desktop_config.json`
154
+
155
+ ## Screenshots
156
+
157
+ ### CLI Search
158
+ ![CLI Search](https://github.com/kaustubh285/flux-cap/blob/main/images/v0.8-search-v2-demo.png)
159
+
160
+ ### Interactive TUI
161
+ ![TUI Interface](https://github.com/kaustubh285/flux-cap/blob/main/images/v0.10-rezi-interactive.png)
162
+
163
+ ### TUI Demo
164
+ ![TUI Demo](https://github.com/kaustubh285/flux-cap/blob/main/images/v0.10-rezi-interactive.gif)
165
+
166
+ ## Commands
167
+
168
+ | Command | Description | Example |
169
+ |---------|-------------|---------|
170
+ | `bb init` | Initialize Backbrain with privacy setup | `bb init` |
171
+ | `bb note <message...>` | Capture a note | `bb note "fix the bug in auth.ts"` |
172
+ | `bb note -i <message...>` | Capture an idea | `bb note -i "add keyboard shortcuts"` |
173
+ | `bb note -n <message...>` | Capture a note | `bb note -n "meeting notes from standup"` |
174
+ | `bb note -t <message...>` | Capture a task | `bb note -t "refactor user authentication"` |
175
+ | `bb note -b <message...>` | Capture a bug | `bb note -b "tsconfig mismatch"` |
176
+ | `bb note -l <message...>` | Capture a link | `bb note -l "https://github.com/user/repo"` |
177
+ | `bb note -m` | Multiline input mode | `bb note -m` |
178
+ | `bb search [query...]` | Search notes with smart ranking | `bb search "authentication"` |
179
+ | `bb s [query...]` | Search alias | `bb s "auth"` |
180
+ | `bb u` | Open interactive TUI | `bb u` |
181
+ | `bb config [field] [value]` | View or update configuration | `bb config search.resultLimit 20` |
182
+ | `bb reset` | Complete reset (deletes all data) | `bb reset` |
183
+
184
+ ### Legacy Commands (Deprecated)
185
+ | Command | Status | Replacement |
186
+ |---------|--------|-------------|
187
+ | `flux dump` | Deprecated | Use `bb note` |
188
+ | `flux d` | Deprecated | Use `bb note` |
189
+ | `flux search` | Works | Use `bb search` |
190
+ | `flux` | Works as alias | Use `bb` |
191
+
192
+ ## Tag System
193
+
194
+ ### Built-in Tags
195
+ Backbrain comes with built-in tag shortcuts:
196
+ - **`-i, --ideas`** - For capturing ideas and inspiration
197
+ - **`-n, --notes`** - For general notes and reminders
198
+ - **`-t, --tasks`** - For tasks and todos
199
+ - **`-b, --bugs`** - For bugs and issues
200
+ - **`-l, --links`** - For URLs and references
201
+
202
+ ### Custom Tags
203
+ Extend your tagging system by adding custom tags:
204
+ ```bash
205
+ # Built-in shortcuts
206
+ bb note -i "idea message"
207
+ bb note -n "note message"
208
+ bb note -t "task message"
209
+
210
+ # Custom tags
211
+ bb note --tag meeting "standup notes"
212
+ bb note --tag bug "found an issue"
213
+ bb note --tag research "performance analysis"
214
+ ```
215
+
216
+ ### Tag Examples
217
+ ```bash
218
+ # Ideas for future features
219
+ bb note -i "add real-time collaboration to the editor"
220
+ bb note -i "implement auto-save every 30 seconds"
221
+
222
+ # Meeting notes and reminders
223
+ bb note -n "team decided to use TypeScript for new components"
224
+ bb note -n "remember to update documentation before release"
225
+
226
+ # Task tracking
227
+ bb note -t "fix memory leak in image processor"
228
+ bb note -t "write unit tests for authentication module"
229
+
230
+ # Bug reports
231
+ bb note -b "payment flow fails on mobile Safari"
232
+ bb note -b "memory leak in file upload component"
233
+
234
+ # Combine with multiline for detailed entries
235
+ bb note -t -m # Opens editor for detailed task description
236
+ ```
237
+
238
+ ## Use Cases
239
+
240
+ ### Context Switching
241
+ ```bash
242
+ # Before switching tasks
243
+ bb note -t "was working on user auth, next: add validation to login form"
244
+
245
+ # After interruption
246
+ bb search "auth" # Quickly find where you left off
247
+ bb search "tasks" # Find your pending tasks
248
+ ```
249
+
250
+ ### Bug Tracking & Ideas
251
+ ```bash
252
+ # Track bugs and investigations
253
+ bb note -b "weird bug in payment flow - users can't checkout"
254
+ bb note -n "bug seems related to session timeout - check Redis config"
255
+
256
+ # Capture ideas as they come
257
+ bb note -i "add keyboard shortcuts to dashboard"
258
+ bb note -i "maybe use React.memo for performance optimization"
259
+
260
+ # Later...
261
+ bb search "payment bug"
262
+ bb search "ideas"
263
+ ```
264
+
265
+ ### Meeting Notes & Task Management
266
+ ```bash
267
+ # Capture meeting outcomes
268
+ bb note -n "team standup: focus on performance this sprint"
269
+ bb note -t "implement caching layer for API responses"
270
+
271
+ # Track follow-up tasks
272
+ bb note -t "review Sarah's PR for authentication changes"
273
+ bb note -t "update deployment documentation"
274
+ ```
275
+
276
+ ### AI-Enhanced Workflow
277
+ ```bash
278
+ # While working with AI assistant
279
+ # AI can automatically capture insights:
280
+ # - Important code snippets discussed
281
+ # - Solutions to complex problems
282
+ # - Follow-up tasks identified
283
+ # - Links to documentation referenced
284
+
285
+ # AI can also search your notes for context:
286
+ # "What was I working on with authentication?"
287
+ # AI searches your notes and provides relevant context
288
+ ```
289
+
290
+ ## Configuration
291
+
292
+ Backbrain stores configuration in `.flux/config.json`. You can customize:
293
+
294
+ ### Privacy Settings
295
+ ```json
296
+ {
297
+ "privacy": {
298
+ "hideWorkingDir": false, // Hide file paths
299
+ "hideBranchName": false, // Hide git branch names
300
+ "hideUncommittedChanges": false // Hide git status
301
+ }
302
+ }
303
+ ```
304
+
305
+ ### Search Configuration
306
+ ```json
307
+ {
308
+ "search": {
309
+ "searchFields": ["message", "branch", "workingDir", "tags"],
310
+ "resultLimit": 10,
311
+ "fuseOptions": {
312
+ "threshold": 0.3, // 0.0 = exact match, 1.0 = match anything
313
+ "includeScore": true
314
+ }
315
+ }
316
+ }
317
+ ```
318
+
319
+ ### Tag Configuration
320
+ ```json
321
+ {
322
+ "tags": ["meeting", "review", "research", "urgent"] // Your custom tags
323
+ }
324
+ ```
325
+
326
+ ### Other Options
327
+ ```json
328
+ {
329
+ "defaultFocusDuration": 1500, // 25 minutes in seconds
330
+ "todoKeywords": ["TODO", "FIXME", "BUG", "OPTIMIZE", "HACK"],
331
+ "sorted": true, // Sort entries chronologically
332
+ "theme": "minimal"
333
+ }
334
+ ```
335
+
336
+ ## Data Structure
337
+
338
+ ```
339
+ .flux/
340
+ ├── config.json # Your configuration
341
+ ├── dumps/ # Notes organized by month
342
+ │ ├── 2026-02.json
343
+ │ └── 2026-03.json
344
+ └── sessions/ # Future: Focus session tracking
345
+ ```
346
+
347
+ ### Note Entry Format
348
+ ```json
349
+ {
350
+ "id": "019c5419-671b-7000-9600-5d9b4c563579",
351
+ "timestamp": "2026-02-12T23:04:36.891Z",
352
+ "message": "fix auth validation bug",
353
+ "tags": ["tasks"],
354
+ "workingDir": "/Users/you/project",
355
+ "branch": "feature/auth-fix",
356
+ "hasUncommittedChanges": true
357
+ }
358
+ ```
359
+
360
+ ## Features
361
+
362
+ ### Note System with Smart Tags
363
+ - Instantly capture thoughts without breaking flow: `bb note "fix auth validation bug"`
364
+ - **Tag system** for better organization: `-i` for ideas, `-n` for notes, `-t` for tasks
365
+ - Git-aware context tracking (branch, working directory, uncommitted changes)
366
+ - Monthly file organization for easy browsing
367
+ - Privacy-first design - you control what gets tracked
368
+
369
+ ### Intelligent Search 2.0 🚀
370
+ - **Multi-signal ranking**: Combines fuzzy matching, recency, and git context
371
+ - **Smart defaults**: Recent notes + current branch automatically ranked higher
372
+ - **Context-aware**: Prioritizes notes from your current branch and directory
373
+ - **Debug mode**: `--debug` flag shows detailed scoring breakdown
374
+ - **Flexible filtering**: `--all`, `--since`, `--branch` flags override smart defaults
375
+ - **Fast & local**: No external APIs, blazing fast search results
376
+
377
+ ### Interactive Search
378
+ ```bash
379
+ bb u # Open interactive TUI search
380
+ ```
381
+
382
+ ### Privacy Controls
383
+ - Choose what information to track during setup
384
+ - Hide working directory paths, branch names, or git status
385
+ - All data stored locally in human-readable JSON
386
+ - Edit or delete your data anytime
387
+
388
+ ### Git Integration
389
+ - Automatic branch context detection
390
+ - Uncommitted changes tracking
391
+ - .gitignore management
392
+ - Works in non-git directories too
393
+
394
+ ### Parent Directory Support
395
+ - Initialize Backbrain once in your project root and use it from any subdirectory
396
+ - Automatically discovers `.flux` configuration by traversing up the directory tree
397
+ - No need to initialize in every subfolder - works project-wide
398
+ - Seamlessly handles monorepos and complex project structures
399
+
400
+ ### AI Assistant Integration
401
+ - **MCP Server**: Direct integration with Cursor, Zed, Claude Desktop
402
+ - **Smart Captures**: AI can suggest and create notes from conversations
403
+ - **Context Sharing**: AI has access to your note history for better assistance
404
+ - **Seamless Workflow**: No manual copy-paste between tools
405
+
406
+ ## Development
407
+
408
+ Want to contribute or run locally?
409
+
410
+ ```bash
411
+ # Clone and setup
412
+ git clone https://github.com/kaustubh285/flux-cap
413
+ cd flux-cap
414
+ bun install
415
+
416
+ # Run in development mode
417
+ bun run dev <command>
418
+
419
+ # Build and test locally
420
+ bun run build
421
+ npm link
422
+ ```
423
+
424
+ Built with:
425
+ - **Bun** - Fast JavaScript runtime
426
+ - **TypeScript** - Type safety
427
+ - **Commander.js** - CLI parsing
428
+ - **Fuse.js** - Fuzzy search
429
+ - **Rezi** - Terminal UI components
430
+ - **MCP SDK** - AI assistant integration
431
+
432
+ ### Project Structure
433
+ ```
434
+ src/
435
+ ├── commands/ # Command implementations
436
+ │ ├── dump.command.ts # Note capture (legacy naming)
437
+ │ ├── search.command.ts
438
+ │ ├── ui.command.ts
439
+ │ └── init.command.ts
440
+ ├── utils/ # Shared utilities
441
+ │ ├── privacy.ts # Git integration
442
+ │ ├── fuse.instance.ts # Search configuration
443
+ │ └── lib.ts # File operations
444
+ ├── mcp-server.ts # MCP integration
445
+ └── types/ # TypeScript definitions
446
+ ```
447
+
448
+ ## Roadmap
449
+
450
+ ### ✅ Shipped
451
+ - [x] Search 2.0 multi-signal ranking (fuzzy + recency + git context)
452
+ - [x] Interactive TUI with real-time search
453
+ - [x] MCP integration for AI assistants
454
+ - [x] Custom tag support (`--tag`)
455
+ - [x] Parent directory `.flux` discovery
456
+ - [x] Backwards compatibility with `flux` command
457
+
458
+ ### Phase 2 (v1.2)
459
+ - [ ] Convenience commands (`bb recent`, `bb here`, `bb notes`)
460
+ - [ ] Enhanced MCP tools for AI context
461
+ - [ ] Search result pagination and filtering
462
+ - [ ] Export formats for AI tools
463
+
464
+ ### Phase 3 (Future)
465
+ - [ ] Advanced git context switching
466
+ - [ ] Session restoration and time tracking
467
+ - [ ] Cross-IDE AI integration improvements
468
+ - [ ] Tag analytics and insights
469
+
470
+ ### Phase 4 (Maybe)
471
+ - [ ] AI-powered note analysis and suggestions
472
+ - [ ] Team collaboration features
473
+ - [ ] Cross-machine sync (optional)
474
+ - [ ] Smart tag suggestions based on content
475
+
476
+ ## Contributing
477
+
478
+ This is currently a personal learning project, but feedback and suggestions are welcome!
479
+
480
+ ## Migration from flux-cap
481
+
482
+ If you were using the old `flux-cap` commands:
483
+
484
+ - **`flux dump`** → **`bb note`** (recommended)
485
+ - **`flux d`** → **`bb note`** (recommended)
486
+ - **`flux search`** → **`bb search`** (or keep using `flux search`)
487
+ - **`flux u`** → **`bb u`** (or keep using `flux u`)
488
+
489
+ The old `flux` commands still work but are deprecated. We recommend switching to `bb` for the best experience.
490
+
491
+ ## License
492
+
493
+ MIT
494
+
495
+ ---
496
+
497
+ *Keep a running memory of your work with Backbrain.*