@brainfile/cli 0.16.1 → 0.17.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 (93) hide show
  1. package/.brainfile/brainfile.md.v1.bak +171 -0
  2. package/.brainfile/logs/task-1.md +206 -0
  3. package/.brainfile/logs/task-2.md +482 -0
  4. package/.brainfile/logs/task-3.md +314 -0
  5. package/.github/workflows/release.yml +35 -0
  6. package/README.md +3 -5
  7. package/dist/cli.js +29 -53
  8. package/dist/cli.js.map +1 -1
  9. package/dist/commands/add.d.ts +2 -0
  10. package/dist/commands/add.d.ts.map +1 -1
  11. package/dist/commands/add.js +16 -2
  12. package/dist/commands/add.js.map +1 -1
  13. package/dist/commands/complete.d.ts +5 -7
  14. package/dist/commands/complete.d.ts.map +1 -1
  15. package/dist/commands/complete.js +76 -127
  16. package/dist/commands/complete.js.map +1 -1
  17. package/dist/commands/contract.d.ts +46 -2
  18. package/dist/commands/contract.d.ts.map +1 -1
  19. package/dist/commands/contract.js +499 -2
  20. package/dist/commands/contract.js.map +1 -1
  21. package/dist/commands/mcp.d.ts.map +1 -1
  22. package/dist/commands/mcp.js +1037 -1763
  23. package/dist/commands/mcp.js.map +1 -1
  24. package/dist/commands/migrate.d.ts +0 -2
  25. package/dist/commands/migrate.d.ts.map +1 -1
  26. package/dist/commands/migrate.js +23 -89
  27. package/dist/commands/migrate.js.map +1 -1
  28. package/dist/commands/move.js.map +1 -1
  29. package/dist/commands/schema.d.ts.map +1 -1
  30. package/dist/commands/schema.js +6 -1
  31. package/dist/commands/schema.js.map +1 -1
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +4 -1
  35. package/dist/index.js.map +1 -1
  36. package/dist/lib/contractRunner.d.ts.map +1 -1
  37. package/dist/lib/contractRunner.js +76 -49
  38. package/dist/lib/contractRunner.js.map +1 -1
  39. package/dist/mcp/tools/contract.d.ts +25 -0
  40. package/dist/mcp/tools/contract.d.ts.map +1 -0
  41. package/dist/mcp/tools/contract.js +33 -0
  42. package/dist/mcp/tools/contract.js.map +1 -0
  43. package/dist/utils/config.d.ts.map +1 -1
  44. package/dist/utils/config.js +22 -9
  45. package/dist/utils/config.js.map +1 -1
  46. package/dist/utils/contractSpec.d.ts +2 -0
  47. package/dist/utils/contractSpec.d.ts.map +1 -1
  48. package/dist/utils/contractSpec.js +5 -1
  49. package/dist/utils/contractSpec.js.map +1 -1
  50. package/dist/utils/hook-settings.d.ts.map +1 -1
  51. package/dist/utils/hook-settings.js +5 -1
  52. package/dist/utils/hook-settings.js.map +1 -1
  53. package/dist/validation/command-lint.d.ts +11 -0
  54. package/dist/validation/command-lint.d.ts.map +1 -0
  55. package/dist/validation/command-lint.js +88 -0
  56. package/dist/validation/command-lint.js.map +1 -0
  57. package/package.json +2 -2
  58. package/dist/commands/context.d.ts +0 -19
  59. package/dist/commands/context.d.ts.map +0 -1
  60. package/dist/commands/context.js +0 -103
  61. package/dist/commands/context.js.map +0 -1
  62. package/dist/commands/history.d.ts +0 -18
  63. package/dist/commands/history.d.ts.map +0 -1
  64. package/dist/commands/history.js +0 -92
  65. package/dist/commands/history.js.map +0 -1
  66. package/dist/commands/ledger-rebuild.d.ts +0 -17
  67. package/dist/commands/ledger-rebuild.d.ts.map +0 -1
  68. package/dist/commands/ledger-rebuild.js +0 -287
  69. package/dist/commands/ledger-rebuild.js.map +0 -1
  70. package/dist/commands/ledger.d.ts +0 -20
  71. package/dist/commands/ledger.d.ts.map +0 -1
  72. package/dist/commands/ledger.js +0 -111
  73. package/dist/commands/ledger.js.map +0 -1
  74. package/dist/commands/migrate-ledger.d.ts +0 -17
  75. package/dist/commands/migrate-ledger.d.ts.map +0 -1
  76. package/dist/commands/migrate-ledger.js +0 -127
  77. package/dist/commands/migrate-ledger.js.map +0 -1
  78. package/dist/commands/stats.d.ts +0 -20
  79. package/dist/commands/stats.d.ts.map +0 -1
  80. package/dist/commands/stats.js +0 -151
  81. package/dist/commands/stats.js.map +0 -1
  82. package/dist/tui/components/ArchivePanel.d.ts +0 -16
  83. package/dist/tui/components/ArchivePanel.d.ts.map +0 -1
  84. package/dist/tui/components/ArchivePanel.js +0 -115
  85. package/dist/tui/components/ArchivePanel.js.map +0 -1
  86. package/dist/utils/date-helpers.d.ts +0 -20
  87. package/dist/utils/date-helpers.d.ts.map +0 -1
  88. package/dist/utils/date-helpers.js +0 -54
  89. package/dist/utils/date-helpers.js.map +0 -1
  90. package/dist/utils/v2-tasks.d.ts +0 -121
  91. package/dist/utils/v2-tasks.d.ts.map +0 -1
  92. package/dist/utils/v2-tasks.js +0 -384
  93. package/dist/utils/v2-tasks.js.map +0 -1
@@ -0,0 +1,171 @@
1
+ ---
2
+ schema: https://brainfile.md/v1/board.json
3
+ title: Brainfile CLI TUI Test Data
4
+ type: board
5
+ agent:
6
+ instructions:
7
+ - Modify only the YAML frontmatter
8
+ - Preserve all IDs
9
+ - Keep ordering
10
+ - Make minimal changes
11
+ columns:
12
+ - id: todo
13
+ title: To Do
14
+ tasks:
15
+ - id: task-100
16
+ title: "[Long Description] Task with very long description to test wrapping"
17
+ description: This is a very long description that should wrap across multiple keyboard lines. It is designed to test the layout engine's ability to handle multi-line content gracefully without breaking the visual hierarchy or causing overlap with subsequent tasks. We want to ensure that the truncation happens correctly after 3 lines as specified in the design doc.
18
+ priority: high
19
+ tags:
20
+ - test
21
+ - layout
22
+ - id: task-101
23
+ title: "[No Desc] Simple task with no description"
24
+ priority: medium
25
+ tags:
26
+ - test
27
+ - id: task-102
28
+ title: "[Subtasks] Task with subtasks (Mixed status)"
29
+ description: Task with some completed and some incomplete subtasks
30
+ priority: high
31
+ subtasks:
32
+ - id: task-102-1
33
+ title: Completed subtask
34
+ completed: true
35
+ - id: task-102-2
36
+ title: Incomplete subtask
37
+ completed: false
38
+ - id: task-102-3
39
+ title: Another incomplete subtask
40
+ completed: false
41
+ - id: task-103
42
+ title: "[Subtasks Only] Task with ONLY subtasks (No Description)"
43
+ priority: low
44
+ subtasks:
45
+ - id: task-103-1
46
+ title: Subtask 1
47
+ completed: true
48
+ - id: task-103-2
49
+ title: Subtask 2
50
+ completed: false
51
+ - id: task-104
52
+ title: "[Related] Task with related files"
53
+ description: Task showing related files display
54
+ relatedFiles:
55
+ - src/tui/components/TaskCard.tsx
56
+ - src/tui/components/TaskList.tsx
57
+ - src/tui/theme.ts
58
+ - src/utils/very-long-file-name-that-should-be-truncated-correctly.ts
59
+ - id: task-105
60
+ title: "[All Features] Complex task with everything"
61
+ description: This task has priority, tags, due date, subtasks, and related files.
62
+ priority: critical
63
+ tags:
64
+ - feature
65
+ - complex
66
+ dueDate: "2025-12-31"
67
+ subtasks:
68
+ - id: task-105-1
69
+ title: Subtask A
70
+ completed: true
71
+ relatedFiles:
72
+ - README.md
73
+ - id: task-303
74
+ title: "Phase 1: Enable contract badges in TUI"
75
+ description: |-
76
+ Enable the existing contract badge functionality in task lists. The code already exists but the prop is not being passed.
77
+
78
+ **Changes needed:**
79
+ - TaskList.tsx: Pass showContractBadge={true} to TaskCard
80
+ - StackedTaskList.tsx: Pass showContractBadge={true} to TaskCard
81
+
82
+ **Expected behavior:**
83
+ Tasks with contracts show inline badge: [C:ready], [C:in_progress], [C:done], [C:failed]
84
+
85
+ **Testing:**
86
+ - Verify badges appear in collapsed task view
87
+ - Verify badges are color-coded correctly
88
+ - Test with tasks that have no contracts (should not show badge)
89
+ priority: high
90
+ tags:
91
+ - tui
92
+ - contracts
93
+ - ux
94
+ assignee: codex
95
+ relatedFiles:
96
+ - cli/src/tui/components/TaskList.tsx
97
+ - cli/src/tui/components/StackedTaskList.tsx
98
+ - id: task-304
99
+ title: Revamp CLI help screens and command documentation
100
+ priority: high
101
+ tags:
102
+ - cli
103
+ - ux
104
+ - documentation
105
+ assignee: codex
106
+ - id: spacing-test
107
+ title: Spacing Test
108
+ tasks:
109
+ - id: task-201
110
+ title: Spacing Task 1
111
+ - id: task-202
112
+ title: Spacing Task 2
113
+ - id: task-203
114
+ title: Spacing Task 3
115
+ - id: task-204
116
+ title: Spacing Task 4
117
+ - id: task-205
118
+ title: Spacing Task 5
119
+ - id: task-206
120
+ title: Spacing Task 6
121
+ - id: task-207
122
+ title: Spacing Task 7
123
+ - id: task-208
124
+ title: Spacing Task 8
125
+ - id: task-209
126
+ title: Spacing Task 9
127
+ - id: task-210
128
+ title: Spacing Task 10
129
+ - id: done
130
+ title: Done
131
+ tasks:
132
+ - id: task-301
133
+ title: Completed Task
134
+ priority: low
135
+ - id: task-302
136
+ title: Research PM-to-worker flow improvements in CLI
137
+ description: |-
138
+ Research the CLI codebase (TUI and commands) to identify improvements for the PM → worker contract workflow experience.
139
+
140
+ **Research Questions:**
141
+ 1. How does the current contract workflow work in TUI vs CLI commands?
142
+ 2. What friction points exist in the pickup → deliver → validate cycle?
143
+ 3. What visual/UX improvements could make contracts more discoverable and actionable?
144
+ 4. How can we improve the PM experience when creating and managing contracts?
145
+ 5. What best practices from other CLI tools could we adopt?
146
+
147
+ **Focus Areas:**
148
+ - TUI contract display and interaction
149
+ - CLI command ergonomics (pickup, deliver, validate)
150
+ - Contract creation workflow (currently manual YAML editing)
151
+ - Visual indicators for contract status
152
+ - Agent handoff experience
153
+ - Validation feedback and error handling
154
+
155
+ **Deliverables:**
156
+ - Current state analysis
157
+ - Pain points identified
158
+ - Proposed improvements (prioritized)
159
+ - Implementation recommendations
160
+ priority: high
161
+ tags:
162
+ - research
163
+ - cli
164
+ - tui
165
+ - ux
166
+ assignee: "@research"
167
+ relatedFiles:
168
+ - cli/src/tui/index.ts
169
+ - cli/src/commands/contract.ts
170
+ - cli/src/lib/contractRunner.ts
171
+ ---
@@ -0,0 +1,206 @@
1
+ ---
2
+ id: task-1
3
+ title: Implement `contract graph` — DAG-aware batch contract attachment
4
+ description: |-
5
+ Add the ability to attach contracts to multiple tasks in a single atomic operation with dependency edges (`dependsOn`). This enables agents to define a full execution graph in one call instead of attaching contracts one-by-one.
6
+
7
+ ## Motivation
8
+
9
+ The current orchestration workflow is:
10
+ 1. Think/refine → create tasks (no contracts)
11
+ 2. Attach contracts one at a time → tedious, race-prone with supervisor
12
+
13
+ With `contract graph`, step 2 becomes a single atomic call that wires the full DAG.
14
+
15
+ ## CLI usage
16
+
17
+ ```bash
18
+ brainfile contract graph \
19
+ --task research-1 --deliverable "file:docs/findings.md" \
20
+ --task impl-1 --deliverable "file:src/bridge.ts" --depends-on research-1 \
21
+ --task test-1 --deliverable "test:src/tests/bridge.test.ts" --depends-on impl-1 \
22
+ --ready
23
+ ```
24
+
25
+ ## MCP usage
26
+
27
+ ```json
28
+ {
29
+ "tool": "contract",
30
+ "action": "graph",
31
+ "tasks": [
32
+ { "task": "research-1", "deliverables": [{ "type": "file", "path": "docs/findings.md" }] },
33
+ { "task": "impl-1", "deliverables": [{ "type": "file", "path": "src/bridge.ts" }], "dependsOn": ["research-1"] },
34
+ { "task": "test-1", "deliverables": [{ "type": "test", "path": "src/tests/bridge.test.ts" }], "dependsOn": ["impl-1"] }
35
+ ],
36
+ "activate": true
37
+ }
38
+ ```
39
+
40
+ ## Key behaviors
41
+
42
+ - **Atomic**: nothing written until full graph is validated (no partial state)
43
+ - **Cycle detection**: reject graphs with circular dependencies before writing
44
+ - **Missing ref detection**: reject if `dependsOn` references a task ID that doesn't exist on the board
45
+ - **Array-only input**: even a single contract is `tasks: [{ ... }]` — no singular shorthand, nudges agents toward batch usage
46
+ - **`--ready` / `activate: true`**: flip all contracts to ready after writing (default: draft)
47
+ - **Backward compatible**: existing `contract attach` for single tasks still works unchanged
48
+
49
+ ## Supervisor integration
50
+
51
+ The supervisor tick already has `dependenciesMet()` — extend it to check `task.dependsOn` in addition to `parentId`. Auto-activate drafts whose dependencies are all `done` (new behavior, opt-in via board config or flag).
52
+
53
+ ## Visualization
54
+
55
+ `brainfile contract graph --show` prints the DAG as an ASCII tree/graph for the current board. The TUI could render this as well.
56
+ priority: high
57
+ tags:
58
+ - orchestration
59
+ - contracts
60
+ - dag
61
+ - mcp
62
+ relatedFiles:
63
+ - core/src/types/base.ts
64
+ - core/src/taskOperations.ts
65
+ - cli/src/commands/contract.ts
66
+ - cli/src/mcp/tools/contract.ts
67
+ - supervisor/src/loop/tick.ts
68
+ subtasks:
69
+ - id: task-1-1
70
+ title: "Add `dependsOn: string[]` field to Task type in core (types/base.ts)"
71
+ completed: true
72
+ - id: task-1-2
73
+ title: Parse/serialize `dependsOn` in core task operations and templates
74
+ completed: true
75
+ - id: task-1-3
76
+ title: Cycle detection utility in core (topological sort, reject cycles)
77
+ completed: true
78
+ - id: task-1-4
79
+ title: Add `contract graph` CLI command with multi-task `--task`/`--depends-on` flag parsing
80
+ completed: true
81
+ - id: task-1-5
82
+ title: Add `graph` action to MCP `contract` tool with array-only input
83
+ completed: true
84
+ - id: task-1-6
85
+ title: Extend supervisor `dependenciesMet()` to check `task.dependsOn` alongside `parentId`
86
+ completed: true
87
+ - id: task-1-7
88
+ title: "Auto-activation: supervisor flips draft→ready when all dependsOn tasks are done"
89
+ completed: true
90
+ - id: task-1-8
91
+ title: Add `contract graph --show` ASCII visualization
92
+ completed: true
93
+ - id: task-1-9
94
+ title: "Tests: core cycle detection, CLI graph command, MCP graph action, supervisor dependency resolution"
95
+ completed: true
96
+ createdAt: "2026-03-05T21:42:19.284Z"
97
+ contract:
98
+ status: done
99
+ deliverables:
100
+ - type: file
101
+ path: core/src/types/base.ts
102
+ description: Add dependsOn string[] field to Task interface
103
+ - type: file
104
+ path: core/src/taskOperations.ts
105
+ description: Parse/serialize dependsOn in task CRUD operations
106
+ - type: file
107
+ path: core/src/graph.ts
108
+ description: DAG cycle detection utility (topological sort)
109
+ - type: file
110
+ path: cli/src/commands/contract.ts
111
+ description: contract graph CLI command with multi-task flag parsing
112
+ - type: file
113
+ path: cli/src/mcp/tools/contract.ts
114
+ description: graph action on MCP contract tool (array-only input)
115
+ - type: file
116
+ path: supervisor/src/loop/tick.ts
117
+ description: Extend dependenciesMet() to check task.dependsOn
118
+ - type: test
119
+ path: core/src/__tests__/graph.test.ts
120
+ description: Cycle detection and topological sort tests
121
+ - type: test
122
+ path: cli/src/__tests__/contract-graph.test.ts
123
+ description: CLI graph command and MCP action tests
124
+ validation:
125
+ commands:
126
+ - cd core && npm test
127
+ - cd cli && npm test
128
+ constraints:
129
+ - dependsOn is optional — existing tasks without it are unaffected
130
+ - Array-only input on MCP graph action — no singular shorthand
131
+ - Atomic writes — validate full DAG before writing any contracts
132
+ - Do not break existing contract attach/pickup/deliver/validate flows
133
+ - Cycle detection must reject and return clear error listing the cycle path
134
+ - Auto-activation (draft→ready when deps done) lives in supervisor tick only, not CLI
135
+ metrics:
136
+ reworkCount: 1
137
+ pickedUpAt: "2026-03-06T00:59:24.778Z"
138
+ deliveredAt: "2026-03-06T01:04:44.348Z"
139
+ duration: 319570
140
+ deliverablePaths:
141
+ - core/src/types/base.ts
142
+ - core/src/taskOperations.ts
143
+ - core/src/graph.ts
144
+ - cli/src/commands/contract.ts
145
+ - cli/src/mcp/tools/contract.ts
146
+ - supervisor/src/loop/tick.ts
147
+ - core/src/__tests__/graph.test.ts
148
+ - cli/src/__tests__/contract-graph.test.ts
149
+ feedback: "sh: 1: cd: can't cd to core"
150
+ updatedAt: "2026-03-06T01:40:18.386Z"
151
+ assignee: implement
152
+ completedAt: "2026-03-06T01:40:18.386Z"
153
+ ---
154
+
155
+ ## Description
156
+ Add the ability to attach contracts to multiple tasks in a single atomic operation with dependency edges (`dependsOn`). This enables agents to define a full execution graph in one call instead of attaching contracts one-by-one.
157
+
158
+ ## Motivation
159
+
160
+ The current orchestration workflow is:
161
+ 1. Think/refine → create tasks (no contracts)
162
+ 2. Attach contracts one at a time → tedious, race-prone with supervisor
163
+
164
+ With `contract graph`, step 2 becomes a single atomic call that wires the full DAG.
165
+
166
+ ## CLI usage
167
+
168
+ ```bash
169
+ brainfile contract graph \
170
+ --task research-1 --deliverable "file:docs/findings.md" \
171
+ --task impl-1 --deliverable "file:src/bridge.ts" --depends-on research-1 \
172
+ --task test-1 --deliverable "test:src/tests/bridge.test.ts" --depends-on impl-1 \
173
+ --ready
174
+ ```
175
+
176
+ ## MCP usage
177
+
178
+ ```json
179
+ {
180
+ "tool": "contract",
181
+ "action": "graph",
182
+ "tasks": [
183
+ { "task": "research-1", "deliverables": [{ "type": "file", "path": "docs/findings.md" }] },
184
+ { "task": "impl-1", "deliverables": [{ "type": "file", "path": "src/bridge.ts" }], "dependsOn": ["research-1"] },
185
+ { "task": "test-1", "deliverables": [{ "type": "test", "path": "src/tests/bridge.test.ts" }], "dependsOn": ["impl-1"] }
186
+ ],
187
+ "activate": true
188
+ }
189
+ ```
190
+
191
+ ## Key behaviors
192
+
193
+ - **Atomic**: nothing written until full graph is validated (no partial state)
194
+ - **Cycle detection**: reject graphs with circular dependencies before writing
195
+ - **Missing ref detection**: reject if `dependsOn` references a task ID that doesn't exist on the board
196
+ - **Array-only input**: even a single contract is `tasks: [{ ... }]` — no singular shorthand, nudges agents toward batch usage
197
+ - **`--ready` / `activate: true`**: flip all contracts to ready after writing (default: draft)
198
+ - **Backward compatible**: existing `contract attach` for single tasks still works unchanged
199
+
200
+ ## Supervisor integration
201
+
202
+ The supervisor tick already has `dependenciesMet()` — extend it to check `task.dependsOn` in addition to `parentId`. Auto-activate drafts whose dependencies are all `done` (new behavior, opt-in via board config or flag).
203
+
204
+ ## Visualization
205
+
206
+ `brainfile contract graph --show` prints the DAG as an ASCII tree/graph for the current board. The TUI could render this as well.