@brainfile/cli 0.13.3 → 0.15.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 (154) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +129 -354
  3. package/dist/cli.js +91 -5
  4. package/dist/cli.js.map +1 -1
  5. package/dist/commands/add.d.ts +3 -0
  6. package/dist/commands/add.d.ts.map +1 -1
  7. package/dist/commands/add.js +163 -3
  8. package/dist/commands/add.js.map +1 -1
  9. package/dist/commands/adr.d.ts +22 -0
  10. package/dist/commands/adr.d.ts.map +1 -0
  11. package/dist/commands/adr.js +182 -0
  12. package/dist/commands/adr.js.map +1 -0
  13. package/dist/commands/archive.d.ts.map +1 -1
  14. package/dist/commands/archive.js +147 -0
  15. package/dist/commands/archive.js.map +1 -1
  16. package/dist/commands/complete.d.ts +30 -0
  17. package/dist/commands/complete.d.ts.map +1 -0
  18. package/dist/commands/complete.js +254 -0
  19. package/dist/commands/complete.js.map +1 -0
  20. package/dist/commands/contract.d.ts.map +1 -1
  21. package/dist/commands/contract.js +2 -0
  22. package/dist/commands/contract.js.map +1 -1
  23. package/dist/commands/delete.d.ts.map +1 -1
  24. package/dist/commands/delete.js +29 -1
  25. package/dist/commands/delete.js.map +1 -1
  26. package/dist/commands/init.d.ts.map +1 -1
  27. package/dist/commands/init.js +38 -19
  28. package/dist/commands/init.js.map +1 -1
  29. package/dist/commands/list.d.ts +1 -0
  30. package/dist/commands/list.d.ts.map +1 -1
  31. package/dist/commands/list.js +35 -12
  32. package/dist/commands/list.js.map +1 -1
  33. package/dist/commands/log.d.ts +52 -0
  34. package/dist/commands/log.d.ts.map +1 -0
  35. package/dist/commands/log.js +246 -0
  36. package/dist/commands/log.js.map +1 -0
  37. package/dist/commands/mcp.d.ts.map +1 -1
  38. package/dist/commands/mcp.js +864 -44
  39. package/dist/commands/mcp.js.map +1 -1
  40. package/dist/commands/migrate.d.ts +4 -3
  41. package/dist/commands/migrate.d.ts.map +1 -1
  42. package/dist/commands/migrate.js +225 -33
  43. package/dist/commands/migrate.js.map +1 -1
  44. package/dist/commands/move.d.ts.map +1 -1
  45. package/dist/commands/move.js +90 -0
  46. package/dist/commands/move.js.map +1 -1
  47. package/dist/commands/patch.d.ts.map +1 -1
  48. package/dist/commands/patch.js +85 -13
  49. package/dist/commands/patch.js.map +1 -1
  50. package/dist/commands/search.d.ts +33 -0
  51. package/dist/commands/search.d.ts.map +1 -0
  52. package/dist/commands/search.js +209 -0
  53. package/dist/commands/search.js.map +1 -0
  54. package/dist/commands/show.d.ts.map +1 -1
  55. package/dist/commands/show.js +75 -1
  56. package/dist/commands/show.js.map +1 -1
  57. package/dist/commands/subtask.d.ts.map +1 -1
  58. package/dist/commands/subtask.js +72 -5
  59. package/dist/commands/subtask.js.map +1 -1
  60. package/dist/commands/tui.d.ts.map +1 -1
  61. package/dist/commands/tui.js +10 -0
  62. package/dist/commands/tui.js.map +1 -1
  63. package/dist/commands/types.d.ts +40 -0
  64. package/dist/commands/types.d.ts.map +1 -0
  65. package/dist/commands/types.js +242 -0
  66. package/dist/commands/types.js.map +1 -0
  67. package/dist/index.d.ts +1 -0
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +3 -1
  70. package/dist/index.js.map +1 -1
  71. package/dist/lib/contractRunner.d.ts.map +1 -1
  72. package/dist/lib/contractRunner.js +177 -12
  73. package/dist/lib/contractRunner.js.map +1 -1
  74. package/dist/schemas/board.json +105 -18
  75. package/dist/tui/BrainfileTUI.d.ts.map +1 -1
  76. package/dist/tui/BrainfileTUI.js +23 -20
  77. package/dist/tui/BrainfileTUI.js.map +1 -1
  78. package/dist/tui/actions.d.ts +5 -5
  79. package/dist/tui/actions.d.ts.map +1 -1
  80. package/dist/tui/actions.js +335 -47
  81. package/dist/tui/actions.js.map +1 -1
  82. package/dist/tui/components/ArchivePanel.js +1 -1
  83. package/dist/tui/components/ArchivePanel.js.map +1 -1
  84. package/dist/tui/components/ColumnTabs.d.ts.map +1 -1
  85. package/dist/tui/components/ColumnTabs.js +6 -2
  86. package/dist/tui/components/ColumnTabs.js.map +1 -1
  87. package/dist/tui/components/HelpOverlay.js +3 -3
  88. package/dist/tui/components/HelpOverlay.js.map +1 -1
  89. package/dist/tui/components/LogsPanel.d.ts +16 -0
  90. package/dist/tui/components/LogsPanel.d.ts.map +1 -0
  91. package/dist/tui/components/LogsPanel.js +115 -0
  92. package/dist/tui/components/LogsPanel.js.map +1 -0
  93. package/dist/tui/components/MainPanelTabs.d.ts +2 -2
  94. package/dist/tui/components/MainPanelTabs.d.ts.map +1 -1
  95. package/dist/tui/components/MainPanelTabs.js +3 -3
  96. package/dist/tui/components/MainPanelTabs.js.map +1 -1
  97. package/dist/tui/components/StackedTaskList.d.ts +2 -1
  98. package/dist/tui/components/StackedTaskList.d.ts.map +1 -1
  99. package/dist/tui/components/StackedTaskList.js +9 -9
  100. package/dist/tui/components/StackedTaskList.js.map +1 -1
  101. package/dist/tui/components/TaskCard.d.ts +2 -1
  102. package/dist/tui/components/TaskCard.d.ts.map +1 -1
  103. package/dist/tui/components/TaskCard.js +41 -5
  104. package/dist/tui/components/TaskCard.js.map +1 -1
  105. package/dist/tui/components/TaskCardMeasure.d.ts +2 -16
  106. package/dist/tui/components/TaskCardMeasure.d.ts.map +1 -1
  107. package/dist/tui/components/TaskCardMeasure.js +30 -25
  108. package/dist/tui/components/TaskCardMeasure.js.map +1 -1
  109. package/dist/tui/components/TaskDetail.d.ts +2 -3
  110. package/dist/tui/components/TaskDetail.d.ts.map +1 -1
  111. package/dist/tui/components/TaskDetail.js +35 -12
  112. package/dist/tui/components/TaskDetail.js.map +1 -1
  113. package/dist/tui/components/TaskList.d.ts +2 -1
  114. package/dist/tui/components/TaskList.d.ts.map +1 -1
  115. package/dist/tui/components/TaskList.js +5 -5
  116. package/dist/tui/components/TaskList.js.map +1 -1
  117. package/dist/tui/components/index.d.ts +2 -2
  118. package/dist/tui/components/index.d.ts.map +1 -1
  119. package/dist/tui/components/index.js +3 -3
  120. package/dist/tui/components/index.js.map +1 -1
  121. package/dist/tui/hooks/useBrainfileLoader.d.ts.map +1 -1
  122. package/dist/tui/hooks/useBrainfileLoader.js +97 -31
  123. package/dist/tui/hooks/useBrainfileLoader.js.map +1 -1
  124. package/dist/tui/hooks/useKeyboardNavigation.d.ts.map +1 -1
  125. package/dist/tui/hooks/useKeyboardNavigation.js +47 -47
  126. package/dist/tui/hooks/useKeyboardNavigation.js.map +1 -1
  127. package/dist/tui/types.d.ts +7 -7
  128. package/dist/tui/types.d.ts.map +1 -1
  129. package/dist/utils/board-types.d.ts +13 -0
  130. package/dist/utils/board-types.d.ts.map +1 -0
  131. package/dist/utils/board-types.js +7 -0
  132. package/dist/utils/board-types.js.map +1 -0
  133. package/dist/utils/dot-brainfile.d.ts +9 -0
  134. package/dist/utils/dot-brainfile.d.ts.map +1 -0
  135. package/dist/utils/dot-brainfile.js +74 -0
  136. package/dist/utils/dot-brainfile.js.map +1 -0
  137. package/dist/utils/strict-validation.d.ts +8 -0
  138. package/dist/utils/strict-validation.d.ts.map +1 -0
  139. package/dist/utils/strict-validation.js +41 -0
  140. package/dist/utils/strict-validation.js.map +1 -0
  141. package/dist/utils/v2-detect.d.ts +28 -0
  142. package/dist/utils/v2-detect.d.ts.map +1 -0
  143. package/dist/utils/v2-detect.js +112 -0
  144. package/dist/utils/v2-detect.js.map +1 -0
  145. package/dist/utils/v2-tasks.d.ts +121 -0
  146. package/dist/utils/v2-tasks.d.ts.map +1 -0
  147. package/dist/utils/v2-tasks.js +384 -0
  148. package/dist/utils/v2-tasks.js.map +1 -0
  149. package/dist/utils/workspace-format.d.ts +25 -0
  150. package/dist/utils/workspace-format.d.ts.map +1 -0
  151. package/dist/utils/workspace-format.js +106 -0
  152. package/dist/utils/workspace-format.js.map +1 -0
  153. package/package.json +3 -3
  154. package/state.json +3 -0
package/CHANGELOG.md CHANGED
@@ -7,6 +7,56 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.15.1] - 2026-02-19
11
+
12
+ ### Added
13
+ - **Workspace format probe for migration readiness**
14
+ - New shared detector classifies workspaces as `v2`, `legacy-root`, `legacy-dotbrainfile`, `mixed`, or `empty`
15
+ - Used consistently by init/migrate/hint flows to avoid command drift
16
+ - **Soft migration warnings in TUI read path**
17
+ - Launching `brainfile tui` in legacy/mixed workspaces now shows a non-blocking upgrade hint
18
+
19
+ ### Changed
20
+ - **`brainfile migrate` is now the primary v2 upgrade path**
21
+ - Migration now handles legacy root and legacy `.brainfile/brainfile.md` layouts in one command
22
+ - Mixed workspaces are handled safely (including backup of stray legacy root files)
23
+ - Existing `board/`/`logs/` partial states are recognized and migrated more robustly
24
+ - **Migration guidance text now points to `brainfile migrate` (without `--v2`)**
25
+ - Updated CLI hints and relevant command errors/messages
26
+
27
+ ### Fixed
28
+ - **`brainfile init` legacy detection behavior**
29
+ - `init` now refuses to initialize over detected legacy/mixed layouts and suggests running `brainfile migrate`
30
+ - Already-v2 workspaces are treated idempotently (no destructive re-init path)
31
+ - **List/TUI migration nudges**
32
+ - `brainfile list` and `brainfile tui` now provide soft warnings when legacy layout is detected, improving discoverability for required migration
33
+
34
+ ## [0.14.0] - 2026-02-18
35
+
36
+ ### Added
37
+ - **Per-task file architecture (v2)** - Tasks are now individual `.md` files instead of embedded YAML
38
+ - `brainfile init` creates v2 structure: `brainfile.md` (config), `tasks/`, `logs/`, `state.json`
39
+ - `brainfile migrate --v2` converts v1 boards to v2 per-task files (creates `.v1.bak` backup)
40
+ - All existing commands auto-detect v1 vs v2 and handle both transparently
41
+ - **`brainfile complete`** - Move task from `tasks/` to `logs/` with `completedAt` timestamp
42
+ - Strips `column` and `position` fields from completed task
43
+ - `complete_task` MCP tool for parity
44
+ - **`brainfile log`** - View and manage task history
45
+ - `brainfile log -t <id>` - View a completed task's log
46
+ - `brainfile log --search <query>` - Search across all completed task logs
47
+ - `brainfile log --recent` - List recently completed tasks
48
+ - `brainfile log note -t <id> "<message>"` - Append timestamped entry to any task's `## Log` section
49
+ - `search_logs` and `append_log` MCP tools for parity
50
+ - **`brainfile search`** - Search across active tasks and completed logs with relevance scoring
51
+ - `search_tasks` MCP tool updated for v2
52
+
53
+ ### Changed
54
+ - **All MCP tools have v2 support** - 29 tools detect v1/v2 and handle per-task files correctly
55
+ - Uses `@brainfile/core` as single source of truth for all task I/O operations
56
+ - CLI is a thin wrapper over core (no duplicated parsing/serialization logic)
57
+ - **`brainfile init` defaults to v2** - Creates per-task file directory structure
58
+ - Upgraded to @brainfile/core@^0.11.0
59
+
10
60
  ## [0.13.3] - 2026-01-01
11
61
 
12
62
  ### Added
package/README.md CHANGED
@@ -1,450 +1,225 @@
1
- <p align="center">
2
- <img src="https://raw.githubusercontent.com/brainfile/cli/main/logo.png" alt="Brainfile Logo" width="128" height="128">
3
- </p>
4
-
5
1
  # @brainfile/cli
6
2
 
7
- **Task management for your terminal.** A full kanban board that lives in a markdown file.
8
-
9
- - Modern, borderless TUI optimized for information density
10
- - Vim-style navigation with intuitive keybindings
11
- - CLI commands for scripting and automation
12
- - MCP server for AI assistant integration
13
-
14
- ## Installation
3
+ **The official CLI for Brainfile.** Manage tasks, contracts, and ADRs directly from your terminal.
15
4
 
16
- ```bash
17
- npm install -g @brainfile/cli
18
- ```
5
+ Designed for developers who want a local-first, file-based task management system that plays nicely with AI agents.
19
6
 
20
- Verify installation:
7
+ ## Install
21
8
 
22
9
  ```bash
23
- brainfile --version
10
+ npm i -g @brainfile/cli
24
11
  ```
25
12
 
26
13
  ## Quick Start
27
14
 
28
- ```bash
29
- # Initialize a new brainfile
30
- brainfile init
31
-
32
- # Launch interactive TUI
33
- brainfile
34
-
35
- # Or use CLI commands
36
- brainfile list # List all tasks
37
- brainfile add --title "My task" --column todo # Add a task
38
- brainfile move --task task-1 --column done # Move a task
39
- ```
40
-
41
- ## Commands
42
-
43
- ### Terminal UI (TUI)
44
-
45
- Launch an interactive task board:
15
+ Initialize a new brainfile in your project root:
46
16
 
47
17
  ```bash
48
- brainfile # Auto-detect (prefers .brainfile/brainfile.md)
49
- brainfile ./path/to/file.md # Open specific file
50
- ```
51
-
52
- **Task Card Layout:**
53
- ```
54
- ▌ CRIT Implement user authentication flow
55
- [1/5] · Nov 30 · #auth #security task-39
56
-
57
- HIGH Dashboard performance optimization
58
- [0/4] · Dec 4 · #performance #frontend task-40
18
+ brainfile init
59
19
  ```
60
20
 
61
- - `▌` indicator shows selected task
62
- - Priority badge (CRIT/HIGH/MED/LOW) leads each row
63
- - `[X/Y]` shows subtask progress
64
- - Due dates with urgency coloring (red if overdue, yellow if soon)
65
- - Tags and task ID complete the metadata row
66
-
67
- **Panel Navigation:**
68
- | Key | Action |
69
- |-----|--------|
70
- | `1` | Switch to Tasks panel |
71
- | `2` | Switch to Rules panel |
72
- | `3` | Switch to Archive panel |
73
- | `?` | Show help |
74
- | `q` | Quit |
75
-
76
- **Tasks Panel:**
77
- | Key | Action |
78
- |-----|--------|
79
- | `TAB` / `Shift+TAB` | Navigate columns |
80
- | `j`/`k` or `↑`/`↓` | Navigate tasks |
81
- | `h`/`l` or `←`/`→` | Switch columns |
82
- | `g`/`G` | Jump to top/bottom |
83
- | `Enter` | Expand/collapse task |
84
- | `/` | Search tasks |
85
- | `r` | Refresh |
86
-
87
- **Search Filters:**
88
- | Filter | Example | Description |
89
- |--------|---------|-------------|
90
- | Priority | `p:high` | Filter by priority |
91
- | Tag | `#bug` or `t:feature` | Filter by tag |
92
- | Assignee | `@john` | Filter by assignee |
93
- | Due date | `due:week` | `overdue`, `today`, `week`, `month` |
94
-
95
- Combine filters with text: `p:high #bug login issue`
96
-
97
- **Task Management:**
98
- | Key | Action |
99
- |-----|--------|
100
- | `e` | Edit task in $EDITOR |
101
- | `m` | Move task to column |
102
- | `d` | Delete task |
103
- | `n` | Quick add new task |
104
- | `N` | New task in $EDITOR |
105
- | `p` | Cycle priority |
106
- | `t` | Toggle subtask |
107
- | `A` | Archive task |
108
- | `y` | Copy task ID |
109
-
110
- **Rules Panel:**
111
- | Key | Action |
112
- |-----|--------|
113
- | `TAB` / `Shift+TAB` | Switch rule type |
114
- | `h`/`l` | Switch rule type (always/never/prefer/context) |
115
- | `j`/`k` | Navigate rules |
116
- | `n` | Add new rule |
117
- | `e` | Edit selected rule |
118
- | `d` | Delete selected rule |
119
-
120
- **Archive Panel:**
121
- | Key | Action |
122
- |-----|--------|
123
- | `j`/`k` | Navigate archived tasks |
124
- | `Enter` | Expand/collapse task |
125
- | `R` | Restore task to column |
126
- | `d` | Permanently delete task |
127
- | `r` | Refresh archive |
21
+ This creates the standard v2 structure:
22
+ - `.brainfile/brainfile.md` (Configuration, rules, definitions)
23
+ - `.brainfile/board/` (Active tasks)
24
+ - `.brainfile/logs/` (Completed tasks)
128
25
 
129
- ---
26
+ The board comes pre-configured with `To Do` and `In Progress` columns.
130
27
 
131
- ### list
28
+ ### Migrating older layouts
132
29
 
133
- List all tasks with optional filtering:
30
+ If your repo still has a legacy `brainfile.md` layout, run:
134
31
 
135
32
  ```bash
136
- brainfile list
137
- brainfile list --column "In Progress"
138
- brainfile list --tag bug
33
+ brainfile migrate
139
34
  ```
140
35
 
141
- **Options:**
142
- - `-f, --file <path>` - Brainfile path (default: `brainfile.md`)
143
- - `-c, --column <name>` - Filter by column
144
- - `-t, --tag <name>` - Filter by tag
145
-
146
- ---
36
+ This upgrades your workspace to v2 (`.brainfile/brainfile.md` + `board/` + `logs/`).
147
37
 
148
- ### show
38
+ ## Core Workflow
149
39
 
150
- Show full details of a single task:
40
+ ### Add Tasks
41
+ Create new tasks with rich metadata.
151
42
 
152
43
  ```bash
153
- brainfile show --task task-1
154
- brainfile show -t task-1 --file ./brainfile.md
155
- ```
44
+ # Basic task
45
+ brainfile add --title "Implement login" --column todo
156
46
 
157
- **Options:**
158
- - `-f, --file <path>` - Brainfile path (default: `brainfile.md`)
159
- - `-t, --task <id>` - Task ID (required)
47
+ # Full featured task
48
+ brainfile add \
49
+ --title "Refactor database layer" \
50
+ --type task \
51
+ --column todo \
52
+ --priority high \
53
+ --assignee @josh \
54
+ --tags "refactor,db" \
55
+ --parent epic-123
160
56
 
161
- ---
57
+ # Create a parent with children in one shot
58
+ brainfile add -c todo -t "Auth overhaul" \
59
+ --child "OAuth flow" --child "Session hardening"
60
+ ```
162
61
 
163
- ### add
62
+ **Key Flags:**
63
+ - `--title, -t`: Task summary
64
+ - `--type`: `task`, `epic`, or `adr` (default: `task`)
65
+ - `--column, -c`: Target column ID
66
+ - `--parent`: Parent task/epic ID
67
+ - `--child`: Create child task(s) under the new parent (repeatable)
68
+ - `--priority, -p`: `low`, `medium`, `high`, `critical`
69
+ - `--tags`: Comma-separated list
164
70
 
165
- Create a new task:
71
+ ### List Tasks
72
+ View your board from the command line.
166
73
 
167
74
  ```bash
168
- brainfile add --title "Implement auth" --column todo
169
- brainfile add --title "Fix bug" --priority high --tags "bug,urgent"
170
- brainfile add --title "Review PR" --assignee john --due-date 2025-02-01
75
+ brainfile list # View all active tasks
76
+ brainfile list --column todo # Filter by column
77
+ brainfile list --tag bug # Filter by tag
78
+ brainfile list --parent epic-123 # See all children of an epic
79
+ brainfile list --contract ready # See tasks with contracts waiting for pickup
171
80
  ```
172
81
 
173
- **Options:**
174
- - `-t, --title <text>` - Task title (required)
175
- - `-c, --column <name>` - Target column (default: `todo`)
176
- - `-d, --description <text>` - Task description
177
- - `-p, --priority <level>` - `low`, `medium`, `high`, or `critical`
178
- - `--tags <list>` - Comma-separated tags
179
- - `--assignee <name>` - Assignee name
180
- - `--due-date <date>` - Due date (YYYY-MM-DD)
181
- - `--subtasks <list>` - Comma-separated subtask titles
182
-
183
- ---
184
-
185
- ### move
186
-
187
- Move a task to a different column:
82
+ ### Manage Tasks
83
+ Manipulate tasks as you work.
188
84
 
189
85
  ```bash
190
- brainfile move --task task-1 --column "In Progress"
191
- brainfile move --task task-5 --column done
192
- ```
86
+ # View details
87
+ brainfile show -t task-10
193
88
 
194
- **Options:**
195
- - `-t, --task <id>` - Task ID (required)
196
- - `-c, --column <name>` - Target column (required)
89
+ # Move to another column
90
+ brainfile move -t task-10 -c in-progress
197
91
 
198
- ---
92
+ # Update fields
93
+ brainfile patch -t task-10 --priority critical --tags "frontend,urgent"
199
94
 
200
- ### patch
95
+ # Clear fields
96
+ brainfile patch -t task-10 --clear-tags --clear-assignee
201
97
 
202
- Update specific fields of a task:
203
-
204
- ```bash
205
- brainfile patch --task task-1 --priority critical
206
- brainfile patch --task task-1 --title "Updated title" --tags "new,tags"
207
- brainfile patch --task task-1 --clear-assignee # Remove assignee
98
+ # Delete (permanently)
99
+ brainfile delete -t task-10
208
100
  ```
209
101
 
210
- **Options:**
211
- - `-t, --task <id>` - Task ID (required)
212
- - `--title <text>` - New title
213
- - `--description <text>` - New description
214
- - `--priority <level>` - New priority
215
- - `--tags <list>` - New tags (comma-separated)
216
- - `--assignee <name>` - New assignee
217
- - `--due-date <date>` - New due date
218
- - `--clear-description` - Remove description
219
- - `--clear-priority` - Remove priority
220
- - `--clear-tags` - Remove tags
221
- - `--clear-assignee` - Remove assignee
222
- - `--clear-due-date` - Remove due date
223
-
224
- ---
225
-
226
- ### delete
227
-
228
- Permanently delete a task:
102
+ ### Complete
103
+ When a task is done, move it to the archive.
229
104
 
230
105
  ```bash
231
- brainfile delete --task task-1 --force
106
+ brainfile complete -t task-10
232
107
  ```
108
+ This moves the file from `.brainfile/board/` to `.brainfile/logs/`, preserving its history forever.
233
109
 
234
- **Options:**
235
- - `-t, --task <id>` - Task ID (required)
236
- - `--force` - Confirm deletion (required)
237
-
238
- ---
110
+ ## Types
239
111
 
240
- ### archive
241
-
242
- Move a task to the archive:
112
+ Brainfile supports different document types.
243
113
 
244
114
  ```bash
245
- brainfile archive --task task-1
115
+ brainfile types list # See available types (task, epic, adr)
116
+ brainfile types add # (Coming soon: define custom types)
246
117
  ```
247
118
 
248
- ---
119
+ ## Contracts: Working with AI Agents
249
120
 
250
- ### restore
121
+ Contracts allow you to define explicit deliverables and validation rules for AI agents.
251
122
 
252
- Restore a task from the archive:
123
+ ### 1. Create a Contract
124
+ Add a task with a contract definition.
253
125
 
254
126
  ```bash
255
- brainfile restore --task task-1 --column todo
127
+ brainfile add -c todo -t "Optimize image loader" \
128
+ --with-contract \
129
+ --deliverable "file:src/utils/loader.ts:Optimized implementation" \
130
+ --validation "npm test -- loader" \
131
+ --constraint "Must use lazy loading"
256
132
  ```
257
133
 
258
- **Options:**
259
- - `-t, --task <id>` - Task ID (required)
260
- - `-c, --column <name>` - Target column (required)
261
-
262
- ---
263
-
264
- ### subtask
265
-
266
- Manage subtasks:
134
+ ### 2. Pickup (Agent)
135
+ The agent claims the task.
267
136
 
268
137
  ```bash
269
- brainfile subtask --task task-1 --add "New subtask"
270
- brainfile subtask --task task-1 --toggle task-1-1
271
- brainfile subtask --task task-1 --update task-1-1 --title "Updated"
272
- brainfile subtask --task task-1 --delete task-1-2
138
+ brainfile contract pickup -t task-45
273
139
  ```
140
+ Status changes to `in_progress`. Metrics tracking begins.
274
141
 
275
- **Options:**
276
- - `-t, --task <id>` - Parent task ID (required)
277
- - `--add <title>` - Add a new subtask
278
- - `--toggle <id>` - Toggle subtask completion
279
- - `--update <id>` - Update subtask (use with `--title`)
280
- - `--delete <id>` - Delete a subtask
281
- - `--title <text>` - New title (for `--update`)
282
-
283
- ---
284
-
285
- ### lint
286
-
287
- Validate and auto-fix brainfile syntax:
142
+ ### 3. Deliver (Agent)
143
+ The agent marks work as ready for review.
288
144
 
289
145
  ```bash
290
- brainfile lint # Check for issues
291
- brainfile lint --fix # Auto-fix issues
292
- brainfile lint --check # Exit with error code (for CI)
146
+ brainfile contract deliver -t task-45
293
147
  ```
148
+ Status changes to `delivered`.
294
149
 
295
- **What it checks:**
296
- - YAML syntax errors
297
- - Unquoted strings with colons (auto-fixable)
298
- - Duplicate column IDs
299
- - Missing required fields
300
-
301
- ---
302
-
303
- ### template
304
-
305
- Create tasks from templates:
150
+ ### 4. Validate (User)
151
+ Run the validation commands automatically.
306
152
 
307
153
  ```bash
308
- brainfile template --list
309
- brainfile template --use bug-report --title "Login fails"
310
- brainfile template --use feature-request --title "Dark mode"
154
+ brainfile contract validate -t task-45
311
155
  ```
156
+ - **Pass**: Task is marked `done`.
157
+ - **Fail**: Task status reverts to `ready` (or `failed`) for rework.
312
158
 
313
- **Built-in Templates:**
314
- - `bug-report` - Bug tracking with triage steps
315
- - `feature-request` - Feature proposals
316
- - `refactor` - Code refactoring tasks
159
+ ## ADR Promotion
317
160
 
318
- ---
161
+ Architecture Decision Records (ADRs) are first-class citizens. You can promote an accepted ADR to a global rule that agents must follow.
319
162
 
320
- ### hooks
163
+ ```bash
164
+ # 1. Create an ADR
165
+ brainfile add -t "Use Postgres for all user data" --type adr -c proposed
321
166
 
322
- Integrate with AI coding assistants:
167
+ # 2. Accept it (move to accepted column)
168
+ brainfile move -t adr-1 -c accepted
323
169
 
324
- ```bash
325
- brainfile hooks install claude-code
326
- brainfile hooks install cursor --scope project
327
- brainfile hooks install cline
328
- brainfile hooks list
329
- brainfile hooks uninstall claude-code --scope all
170
+ # 3. Promote to a rule
171
+ brainfile adr promote -t adr-1 --category always
330
172
  ```
331
173
 
332
- **Supported Assistants:**
333
- - Claude Code
334
- - Cursor
335
- - Cline
174
+ **Categories:**
175
+ - `always`: Strict rules (e.g., "Always use TypeScript")
176
+ - `never`: Prohibitions (e.g., "Never commit secrets")
177
+ - `prefer`: Guidelines (e.g., "Prefer functional components")
178
+ - `context`: informational context
336
179
 
337
- Hooks provide automatic reminders to update task status during AI-assisted development.
180
+ Promoted rules are added to `.brainfile/brainfile.md` and injected into agent prompts.
338
181
 
339
- ---
182
+ ## TUI (Terminal UI)
340
183
 
341
- ### mcp
342
-
343
- Start an MCP (Model Context Protocol) server for AI assistant integration:
184
+ Launch the interactive board:
344
185
 
345
186
  ```bash
346
- brainfile mcp
347
- brainfile mcp --file ./project/brainfile.md
187
+ brainfile # No arguments launches the TUI
188
+ brainfile tui # Explicit subcommand also works
348
189
  ```
349
190
 
350
- The MCP server exposes all brainfile operations as tools that AI assistants can use directly.
351
-
352
- **Available MCP Tools:**
353
- | Tool | Description |
354
- |------|-------------|
355
- | `list_tasks` | List tasks with optional filtering |
356
- | `add_task` | Create a new task |
357
- | `move_task` | Move task between columns |
358
- | `patch_task` | Update task fields |
359
- | `delete_task` | Permanently delete a task |
360
- | `archive_task` | Archive a task |
361
- | `restore_task` | Restore from archive |
362
- | `add_subtask` | Add a subtask |
363
- | `delete_subtask` | Delete a subtask |
364
- | `toggle_subtask` | Toggle subtask completion |
365
- | `update_subtask` | Update subtask title |
191
+ ### Panels
192
+ - **Board (`1`)**: Kanban view of active tasks.
193
+ - **Logs (`2`)**: List of completed tasks.
194
+ - **Rules (`3`)**: Active rules and configuration.
366
195
 
367
- **Configuration for Claude Code:**
196
+ ### Keyboard Shortcuts
197
+ | Key | Action |
198
+ |-----|--------|
199
+ | `tab` | Next column |
200
+ | `j` / `k` | Down / Up |
201
+ | `enter` | View task details |
202
+ | `n` | New task |
203
+ | `m` | Move task |
204
+ | `e` | Edit task (in $EDITOR) |
205
+ | `/` | Search |
206
+ | `q` | Quit |
368
207
 
369
- Add to your MCP settings (`.mcp.json` or Claude Code config):
208
+ ## AI Integration
370
209
 
371
- ```json
372
- {
373
- "mcpServers": {
374
- "brainfile": {
375
- "command": "npx",
376
- "args": ["@brainfile/cli", "mcp"]
377
- }
378
- }
379
- }
380
- ```
210
+ The CLI includes an MCP (Model Context Protocol) server.
381
211
 
382
- Or with a specific file:
212
+ Add to your `claude_desktop_config.json`:
383
213
 
384
214
  ```json
385
215
  {
386
216
  "mcpServers": {
387
217
  "brainfile": {
388
218
  "command": "npx",
389
- "args": ["@brainfile/cli", "mcp", "-f", "path/to/brainfile.md"]
219
+ "args": ["@brainfile/cli", "mcp"]
390
220
  }
391
221
  }
392
222
  }
393
223
  ```
394
224
 
395
- ---
396
-
397
- ### init
398
-
399
- Create a new brainfile:
400
-
401
- ```bash
402
- brainfile init
403
- brainfile init --file ./project/tasks.md # Custom location (optional)
404
- brainfile init --force # Overwrite existing
405
- ```
406
-
407
- ### migrate
408
-
409
- Move a legacy root `brainfile.md` into the preferred `.brainfile/` directory:
410
-
411
- ```bash
412
- brainfile migrate
413
- brainfile migrate --force
414
- ```
415
-
416
- ## Output Colors
417
-
418
- The CLI uses colors to highlight information:
419
-
420
- | Element | Color |
421
- |---------|-------|
422
- | Task IDs | Gray |
423
- | Titles | White |
424
- | Critical Priority | Red (bold) |
425
- | High Priority | Red |
426
- | Medium Priority | Yellow |
427
- | Low Priority | Blue |
428
- | Tags | Cyan |
429
- | Completed | Green |
430
-
431
- ## Package Information
432
-
433
- - **npm**: https://www.npmjs.com/package/@brainfile/cli
434
- - **GitHub**: https://github.com/brainfile/cli
435
- - **Core Library**: [@brainfile/core](https://www.npmjs.com/package/@brainfile/core)
436
- - **Protocol**: https://brainfile.md
437
-
438
- ## Development
439
-
440
- ```bash
441
- git clone https://github.com/brainfile/cli.git
442
- cd cli
443
- npm install
444
- npm run build
445
- npm test
446
- ```
447
-
448
- ## License
449
-
450
- MIT
225
+ This gives Claude (and other MCP clients) full access to read your board, create tasks, and manage contracts.