@quantmind-br/pi-goal-x 0.0.0-stage → 0.35.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.
Files changed (79) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +131 -2
  3. package/assets/badge-dark.svg +18 -0
  4. package/assets/badge-light.svg +18 -0
  5. package/docs/advanced-usage.md +106 -0
  6. package/docs/agent-flow-design.md +306 -0
  7. package/docs/agentic-runtime-prd.md +773 -0
  8. package/docs/architecture.md +368 -0
  9. package/docs/controls.md +140 -0
  10. package/docs/pi-autoresearch-survey.md +50 -0
  11. package/docs/pi-goal-x-unified-dashboard-plan.md +1667 -0
  12. package/docs/prompt-caching.md +31 -0
  13. package/docs/unified-dashboard.md +286 -0
  14. package/extensions/auditor-selector.ts +74 -0
  15. package/extensions/goal-accounting.ts +107 -0
  16. package/extensions/goal-activity.ts +202 -0
  17. package/extensions/goal-auditor.ts +480 -0
  18. package/extensions/goal-commands.ts +866 -0
  19. package/extensions/goal-compaction.ts +197 -0
  20. package/extensions/goal-completion.ts +173 -0
  21. package/extensions/goal-context.ts +12 -0
  22. package/extensions/goal-contract.ts +58 -0
  23. package/extensions/goal-controls.ts +202 -0
  24. package/extensions/goal-core-tools.ts +549 -0
  25. package/extensions/goal-core.ts +78 -0
  26. package/extensions/goal-detail.ts +65 -0
  27. package/extensions/goal-dialog-controls.ts +31 -0
  28. package/extensions/goal-draft.ts +244 -0
  29. package/extensions/goal-drafting.ts +535 -0
  30. package/extensions/goal-events.ts +692 -0
  31. package/extensions/goal-format.ts +376 -0
  32. package/extensions/goal-interruption.ts +53 -0
  33. package/extensions/goal-ledger-index.ts +68 -0
  34. package/extensions/goal-ledger.ts +1007 -0
  35. package/extensions/goal-live-retention.ts +219 -0
  36. package/extensions/goal-oracle.ts +346 -0
  37. package/extensions/goal-policy.ts +370 -0
  38. package/extensions/goal-pool.ts +103 -0
  39. package/extensions/goal-prompt-cache.ts +80 -0
  40. package/extensions/goal-questionnaire.ts +1073 -0
  41. package/extensions/goal-record.ts +388 -0
  42. package/extensions/goal-recovery.ts +256 -0
  43. package/extensions/goal-runtime.ts +277 -0
  44. package/extensions/goal-scheduler-state.ts +100 -0
  45. package/extensions/goal-scheduler.ts +436 -0
  46. package/extensions/goal-service.ts +843 -0
  47. package/extensions/goal-session-health.ts +130 -0
  48. package/extensions/goal-session-safety.ts +65 -0
  49. package/extensions/goal-settings.ts +1370 -0
  50. package/extensions/goal-state.ts +1069 -0
  51. package/extensions/goal-status.ts +305 -0
  52. package/extensions/goal-task-confirmation.ts +174 -0
  53. package/extensions/goal-task-count.ts +59 -0
  54. package/extensions/goal-task-derive.ts +46 -0
  55. package/extensions/goal-task-index.ts +57 -0
  56. package/extensions/goal-task-tools.ts +595 -0
  57. package/extensions/goal-tool-inputs.ts +102 -0
  58. package/extensions/goal-tool-names.ts +73 -0
  59. package/extensions/goal-tools.ts +16 -0
  60. package/extensions/goal-widget.ts +455 -0
  61. package/extensions/goal.ts +42 -0
  62. package/extensions/network-error-backoff.ts +55 -0
  63. package/extensions/prompts/goal-prompts.ts +321 -0
  64. package/extensions/storage/atomic-rename.ts +52 -0
  65. package/extensions/storage/goal-files.ts +695 -0
  66. package/extensions/storage/goal-lock.ts +131 -0
  67. package/extensions/storage/goal-root.ts +95 -0
  68. package/extensions/widgets/auditor-dashboard-model.ts +174 -0
  69. package/extensions/widgets/dialog-scaffold.ts +26 -0
  70. package/extensions/widgets/goal-controls-dialog.ts +329 -0
  71. package/extensions/widgets/goal-dashboard-model.ts +530 -0
  72. package/extensions/widgets/goal-dashboard-renderer.ts +674 -0
  73. package/extensions/widgets/goal-escape-dialog.ts +148 -0
  74. package/extensions/widgets/goal-notifications.ts +9 -0
  75. package/extensions/widgets/goal-widget.ts +723 -0
  76. package/extensions/widgets/task-list-overlay.ts +409 -0
  77. package/extensions/widgets/text-cache.ts +30 -0
  78. package/package.json +117 -4
  79. package/scripts/recover-session-checkpoints.mjs +289 -0
@@ -0,0 +1,1667 @@
1
+ # pi-goal-x Unified Dashboard and Goal Lifecycle Implementation Plan
2
+
3
+ ## Delivery model
4
+
5
+ All work described in this document will be delivered in **one pull request**.
6
+
7
+ The pull request will include the data-model changes, runtime changes, unified dashboard, merged task view, goal-status redesign, audit presentation, migration handling, tests, documentation, and changelog updates. The work should be committed in reviewable internal commits, but it must land as a single coherent feature.
8
+
9
+ ---
10
+
11
+ ## 1. Objective
12
+
13
+ Upgrade `pi-goal-x` into a polished, complete goal-execution experience for long-running work.
14
+
15
+ The finished system must support the full lifecycle:
16
+
17
+ 1. Guided goal creation.
18
+ 2. Explicit confirmation.
19
+ 3. Immediate automatic execution.
20
+ 4. Persistent progress visibility.
21
+ 5. Structured task and subtask tracking.
22
+ 6. A clearly identified current task.
23
+ 7. Visible verification requirements.
24
+ 8. Human-readable recent activity.
25
+ 9. Independent completion auditing.
26
+ 10. Clear approval or rejection.
27
+ 11. Reliable archival with a permanent record.
28
+
29
+ At any point, the user should be able to understand:
30
+
31
+ - What goal is focused.
32
+ - What state the goal is in.
33
+ - What the agent is doing now.
34
+ - What has already been completed.
35
+ - What remains.
36
+ - Which task and subtask are current.
37
+ - What evidence is required.
38
+ - How much active time and token usage has accumulated.
39
+ - Whether other goals remain open.
40
+ - Whether completion is being audited.
41
+ - Whether the audit passed or failed.
42
+ - Where the durable goal record is stored.
43
+
44
+ The design must work well in narrow and wide terminals, preserve compatibility with existing goal files, and avoid unnecessary terminal redraws that disrupt scrollback.
45
+
46
+ ---
47
+
48
+ ## 2. Design principles
49
+
50
+ ### 2.1 One source of truth
51
+
52
+ The dashboard, `/goal-status`, completion summaries, and tests must all derive from the same presentation model.
53
+
54
+ There must not be separate formatting logic that gradually diverges between:
55
+
56
+ - The above-editor widget.
57
+ - The goal-status command.
58
+ - The task overlay.
59
+ - Audit progress.
60
+ - Completion messages.
61
+
62
+ ### 2.2 Persist meaningful execution state
63
+
64
+ Anything important enough to show as factual progress must be derived from persisted state or the durable ledger.
65
+
66
+ Do not fabricate display-only state for:
67
+
68
+ - Current task.
69
+ - Task completion.
70
+ - Verification status.
71
+ - Audit result.
72
+ - Archive location.
73
+ - Recent activity.
74
+
75
+ ### 2.3 Progressive disclosure
76
+
77
+ The default dashboard should be visually rich but compact.
78
+
79
+ More detail should be available by expanding the same dashboard rather than opening an unrelated interface.
80
+
81
+ The dashboard should have two presentation modes:
82
+
83
+ - **Compact mode:** persistent summary above the editor.
84
+ - **Expanded mode:** integrated task tree, current-task details, verification, evidence, and recent activity.
85
+
86
+ ### 2.4 Terminal-first visual quality
87
+
88
+ The UI should be as polished as the host TUI permits:
89
+
90
+ - Balanced spacing.
91
+ - Clear visual hierarchy.
92
+ - Semantic color.
93
+ - Consistent borders.
94
+ - Stable alignment.
95
+ - Width-aware truncation.
96
+ - Useful progress bars.
97
+ - No line overflow.
98
+ - No dependence on color alone.
99
+
100
+ ### 2.5 Minimal redraw churn
101
+
102
+ Normal goal rendering must not introduce a once-per-second redraw loop.
103
+
104
+ Elapsed time should refresh on meaningful events such as:
105
+
106
+ - Turn start.
107
+ - Turn end.
108
+ - Tool progress.
109
+ - Task updates.
110
+ - Goal updates.
111
+ - Focus changes.
112
+ - Explicit status requests.
113
+ - Audit progress.
114
+
115
+ The audit may retain a short-lived animation timer because it is a temporary foreground process.
116
+
117
+ ---
118
+
119
+ ## 3. Required user experience
120
+
121
+ ## 3.1 Guided goal creation
122
+
123
+ Running:
124
+
125
+ ```text
126
+ /goal <initial request>
127
+ ```
128
+
129
+ must begin a guided drafting session.
130
+
131
+ The agent should:
132
+
133
+ - Identify material ambiguity.
134
+ - Ask only the questions required to make the goal executable.
135
+ - Offer recommended answers where appropriate.
136
+ - Allow custom answers.
137
+ - Build a complete objective.
138
+ - Propose a useful task plan when the work naturally decomposes.
139
+ - Define or extract a verification contract.
140
+ - Present the complete proposal for confirmation.
141
+
142
+ The confirmation experience must show:
143
+
144
+ - Goal type.
145
+ - Normalized objective.
146
+ - Constraints and boundaries.
147
+ - Automatic-continuation state.
148
+ - Auditor state.
149
+ - Proposed task hierarchy.
150
+ - Verification requirements.
151
+ - Token budget when configured.
152
+
153
+ The user must be able to:
154
+
155
+ - Confirm and begin.
156
+ - Continue refining.
157
+ - Cancel without creating a goal.
158
+
159
+ No persistent goal may be created before confirmation succeeds.
160
+
161
+ ## 3.2 Direct creation
162
+
163
+ The direct commands must continue to work:
164
+
165
+ ```text
166
+ /goal-direct <complete objective>
167
+ /sisyphus-direct <ordered objective>
168
+ ```
169
+
170
+ Direct creation should:
171
+
172
+ - Validate the objective.
173
+ - Extract verification requirements.
174
+ - Create the goal.
175
+ - Focus it for the current session.
176
+ - Persist it.
177
+ - Start accounting.
178
+ - Begin automatic continuation when enabled.
179
+
180
+ ## 3.3 Immediate automatic execution
181
+
182
+ After confirmation or direct creation:
183
+
184
+ - The goal becomes focused.
185
+ - The active goal file is written.
186
+ - Accounting begins.
187
+ - The agent starts the first execution turn automatically.
188
+ - Productive turns continue until the goal pauses, blocks, reaches a budget, or enters completion review.
189
+
190
+ Automatic continuation must stop when:
191
+
192
+ - The user pauses the goal.
193
+ - The agent reports a blocker.
194
+ - The goal is unfocused.
195
+ - The goal reaches its token budget.
196
+ - A stale continuation is detected.
197
+ - The current turn performed no meaningful work.
198
+ - The user interrupts execution.
199
+ - Completion review begins.
200
+ - The goal is completed.
201
+
202
+ ---
203
+
204
+ ## 4. Unified dashboard
205
+
206
+ The current goal widget and task overlay will be merged into one unified dashboard component.
207
+
208
+ The separate task overlay should no longer be a parallel UI with separate formatting and navigation logic. Its useful behavior should move into the dashboard's expanded mode.
209
+
210
+ The existing task shortcut may be retained, but it should toggle the dashboard between compact and expanded task views.
211
+
212
+ Suggested behavior:
213
+
214
+ ```text
215
+ Ctrl+Shift+T Toggle expanded goal dashboard
216
+ ```
217
+
218
+ If the host keybinding system supports a clearer default, use that instead, but keep the action discoverable in help and the dashboard footer.
219
+
220
+ ## 4.1 Compact mode
221
+
222
+ Compact mode is always visible above the editor while a goal is focused.
223
+
224
+ Wide-terminal example:
225
+
226
+ ```text
227
+ ┌─ pi-goal-x ─ Add CSV export to reports ─────────────── 12m47s · 18.2K tok ─┐
228
+ │ ● In progress Focused: yes Other goals: 2 │
229
+ │ Tasks [██████░░░░] 3/5 · 60% │
230
+ │ Current t3 · Add the download button │
231
+ │ Subtasks [███████░░░] 2/3 · 67% │
232
+ │ Verify Run npm test with zero failures. │
233
+ │ File .pi/goals/active_goal_... │
234
+ └─ Enter/Ctrl+Shift+T: expand tasks ──────────────────────────────────────────┘
235
+ ```
236
+
237
+ The exact shortcut hint should match the implemented interaction.
238
+
239
+ ## 4.2 Expanded mode
240
+
241
+ Expanded mode replaces the separate task overlay and uses the same dashboard component.
242
+
243
+ It should show:
244
+
245
+ - Goal header.
246
+ - Goal status.
247
+ - Focus state.
248
+ - Time and token usage.
249
+ - Active or archived path.
250
+ - Overall task progress.
251
+ - Full task tree.
252
+ - Current task highlight.
253
+ - Current task verification contract.
254
+ - Current task evidence.
255
+ - Current task subtasks.
256
+ - Recent completed tasks.
257
+ - Recent activity.
258
+ - Goal-level verification contract.
259
+ - Other open goals.
260
+ - Useful keyboard hints.
261
+
262
+ Example:
263
+
264
+ ```text
265
+ ┌─ pi-goal-x ─ Add CSV export to reports ─────────────── 12m47s · 18.2K tok ─┐
266
+ │ Status: ● In progress Focused: yes Other goals: 2 │
267
+ │ File: .pi/goals/active_goal_... │
268
+ ├─ Progress ──────────────────────────────────────────────────────────────────┤
269
+ │ [██████░░░░] 3/5 tasks · 60% │
270
+ ├─ Tasks ─────────────────────────────────────────────────────────────────────┤
271
+ │ ✓ t1 Review reports page and data source │
272
+ │ ✓ t2 Implement filtered CSV export │
273
+ │ ▸ t3 Add the download button │
274
+ │ ✓ t3.1 Add loading state │
275
+ │ ✓ t3.2 Generate timestamped filename │
276
+ │ ▸ t3.3 Add error handling │
277
+ │ · t4 Add documentation │
278
+ │ · t5 Add and run tests │
279
+ ├─ Current task ──────────────────────────────────────────────────────────────┤
280
+ │ t3 · Add the download button │
281
+ │ Subtasks: [███████░░░] 2/3 · 67% │
282
+ │ Contract: The button downloads a CSV using the active filters. │
283
+ │ Evidence: Loading state and filename behavior implemented. │
284
+ ├─ Verification ──────────────────────────────────────────────────────────────┤
285
+ │ Run npm test with zero failures. │
286
+ ├─ Recent activity ───────────────────────────────────────────────────────────┤
287
+ │ ✓ Completed filtered CSV serialization │
288
+ │ ✓ Added loading and filename behavior │
289
+ │ ▸ Started download error handling │
290
+ └─ Esc/Ctrl+Shift+T: collapse ────────────────────────────────────────────────┘
291
+ ```
292
+
293
+ ## 4.3 Unfocused state
294
+
295
+ When open goals exist but none is focused:
296
+
297
+ ```text
298
+ ┌─ pi-goal-x ─ Goal focus required ───────────────────────────────────────────┐
299
+ │ 3 open goals are available. │
300
+ │ Run /goal-focus to choose the goal for this session. │
301
+ └─────────────────────────────────────────────────────────────────────────────┘
302
+ ```
303
+
304
+ ## 4.4 Paused state
305
+
306
+ Paused goals should clearly show:
307
+
308
+ - Paused status.
309
+ - Who paused the goal.
310
+ - Pause reason.
311
+ - Suggested next action.
312
+ - Resume command.
313
+
314
+ ## 4.5 Blocked state
315
+
316
+ Blocked goals should prominently show:
317
+
318
+ - Blocker.
319
+ - Suggested user action.
320
+ - Current task.
321
+ - Last useful progress.
322
+ - Resume or tweak command.
323
+
324
+ ## 4.6 Budget-limited state
325
+
326
+ Budget-limited goals should show:
327
+
328
+ - Used and configured token budget.
329
+ - Percentage used.
330
+ - Goal status.
331
+ - Current task.
332
+ - Suggested next action.
333
+
334
+ ## 4.7 Complete state
335
+
336
+ Before archival completes:
337
+
338
+ ```text
339
+ ┌─ pi-goal-x ─ Goal complete ─────────────────────────────────────────────────┐
340
+ │ ✓ All required work is complete. │
341
+ │ Waiting for final archival. │
342
+ └─────────────────────────────────────────────────────────────────────────────┘
343
+ ```
344
+
345
+ After archival, the persistent dashboard should clear or focus the next goal according to existing settings.
346
+
347
+ ---
348
+
349
+ ## 5. Visual design specification
350
+
351
+ ## 5.1 Border system
352
+
353
+ Use a consistent box-drawing system:
354
+
355
+ - `┌ ┐ └ ┘` for outer borders.
356
+ - `├ ┤` for section separators.
357
+ - `─` for horizontal rules.
358
+ - `│` for vertical edges.
359
+
360
+ The renderer must be capable of falling back to a simpler ASCII border if the host or environment cannot render box-drawing characters reliably.
361
+
362
+ ## 5.2 Status symbols
363
+
364
+ Use symbols consistently:
365
+
366
+ - `●` running.
367
+ - `○` idle.
368
+ - `◐` paused.
369
+ - `⊘` blocked.
370
+ - `⛽` budget limited.
371
+ - `✓` complete.
372
+ - `◌` active audit stage.
373
+ - `·` pending.
374
+ - `✗` failed.
375
+ - `▸` current task or current subtask.
376
+
377
+ Status labels must remain explicit so the interface is understandable without symbols.
378
+
379
+ ## 5.3 Progress bars
380
+
381
+ Use a fixed logical scale with width selected by available terminal space.
382
+
383
+ Examples:
384
+
385
+ ```text
386
+ [██████░░░░] 3/5 · 60%
387
+ [███████░░░] 2/3 · 67%
388
+ ```
389
+
390
+ Progress bars must:
391
+
392
+ - Clamp values to valid bounds.
393
+ - Handle zero tasks.
394
+ - Handle all-complete state.
395
+ - Avoid misleading percentages.
396
+ - Use semantic color where available.
397
+ - Remain readable without color.
398
+
399
+ ## 5.4 Spacing and hierarchy
400
+
401
+ The dashboard should use:
402
+
403
+ - One-line title/header.
404
+ - Clear section separators.
405
+ - Consistent label widths where practical.
406
+ - One blank line only where it materially improves readability.
407
+ - Indentation for task hierarchy.
408
+ - Strong emphasis on the current task.
409
+ - Muted treatment for paths and secondary metadata.
410
+
411
+ ## 5.5 Responsive layouts
412
+
413
+ Define explicit rendering modes.
414
+
415
+ ### Wide: 100 columns and above
416
+
417
+ - Full border.
418
+ - Multiple fields on one line.
419
+ - Full task titles.
420
+ - Wider progress bars.
421
+ - Current-task details.
422
+ - Rich footer hints.
423
+
424
+ ### Medium: 70–99 columns
425
+
426
+ - Full border.
427
+ - Mostly one field per line.
428
+ - Shorter progress bars.
429
+ - Truncated paths and contracts.
430
+ - Compact current-task block.
431
+
432
+ ### Narrow: 50–69 columns
433
+
434
+ - Compact border.
435
+ - Short labels.
436
+ - Reduced metadata.
437
+ - One task line at a time.
438
+ - Current task and progress remain visible.
439
+
440
+ ### Very narrow: below 50 columns
441
+
442
+ Render only the essential summary:
443
+
444
+ ```text
445
+ ┌ Goal · In progress ───────┐
446
+ │ CSV export │
447
+ │ Tasks 3/5 · 60% │
448
+ │ ▸ Add download button │
449
+ │ Verify: npm test passes │
450
+ └───────────────────────────┘
451
+ ```
452
+
453
+ The renderer must never emit a line wider than the available terminal width.
454
+
455
+ ## 5.6 ANSI and Unicode safety
456
+
457
+ All truncation and alignment must use visible-width-aware helpers.
458
+
459
+ Test with:
460
+
461
+ - ANSI colors.
462
+ - Unicode task titles.
463
+ - Double-width characters.
464
+ - Long paths.
465
+ - Long contracts.
466
+ - Long evidence.
467
+ - Long auditor names.
468
+
469
+ ---
470
+
471
+ ## 6. Shared dashboard view model
472
+
473
+ Create:
474
+
475
+ ```text
476
+ extensions/widgets/goal-dashboard-model.ts
477
+ ```
478
+
479
+ This module must contain pure data derivation only. It should not import TUI rendering components.
480
+
481
+ Suggested model:
482
+
483
+ ```ts
484
+ export interface GoalDashboardModel {
485
+ goalId: string;
486
+ title: string;
487
+
488
+ status: {
489
+ code:
490
+ | "running"
491
+ | "idle"
492
+ | "paused"
493
+ | "blocked"
494
+ | "budget_limited"
495
+ | "complete";
496
+ label: string;
497
+ reason?: string;
498
+ suggestedAction?: string;
499
+ };
500
+
501
+ focused: boolean;
502
+ filePath?: string;
503
+
504
+ usage: {
505
+ activeSeconds: number;
506
+ elapsedLabel: string;
507
+ tokens: number;
508
+ tokenLabel: string;
509
+ };
510
+
511
+ budget?: {
512
+ used: number;
513
+ total: number;
514
+ percentage: number;
515
+ remaining: number;
516
+ };
517
+
518
+ taskProgress?: {
519
+ completed: number;
520
+ total: number;
521
+ percentage: number;
522
+ };
523
+
524
+ taskTree: DashboardTaskNode[];
525
+
526
+ currentTask?: {
527
+ id: string;
528
+ title: string;
529
+ depth: number;
530
+ completedSubtasks: number;
531
+ totalSubtasks: number;
532
+ subtaskPercentage: number;
533
+ verificationContract?: string;
534
+ evidence?: string;
535
+ };
536
+
537
+ goalVerificationContract?: string;
538
+ otherOpenGoals: number;
539
+ recentActivity: GoalActivityItem[];
540
+ }
541
+
542
+ export interface DashboardTaskNode {
543
+ id: string;
544
+ title: string;
545
+ status: "pending" | "complete" | "skipped";
546
+ depth: number;
547
+ isCurrent: boolean;
548
+ verificationContract?: string;
549
+ evidence?: string;
550
+ }
551
+ ```
552
+
553
+ Add pure helpers:
554
+
555
+ ```ts
556
+ deriveGoalDashboardModel(...)
557
+ deriveGoalStatus(...)
558
+ deriveTopLevelTaskProgress(...)
559
+ flattenTaskTree(...)
560
+ deriveCurrentTask(...)
561
+ deriveCurrentTaskSubtaskProgress(...)
562
+ deriveGoalActivity(...)
563
+ formatDashboardDuration(...)
564
+ formatCompactTokens(...)
565
+ formatBudget(...)
566
+ ```
567
+
568
+ Use this model for:
569
+
570
+ - Persistent compact dashboard.
571
+ - Expanded dashboard.
572
+ - `/goal-status`.
573
+ - Audit transition back to normal display.
574
+ - Golden tests.
575
+ - Documentation examples.
576
+
577
+ ---
578
+
579
+ ## 7. Data model changes
580
+
581
+ ## 7.1 Persist current task
582
+
583
+ Extend `GoalRecord`:
584
+
585
+ ```ts
586
+ export interface GoalRecord {
587
+ // Existing fields...
588
+ currentTaskId?: string;
589
+ }
590
+ ```
591
+
592
+ Keep it optional for compatibility.
593
+
594
+ Do not add `in_progress` to `TaskStatus`.
595
+
596
+ Task status should remain:
597
+
598
+ ```ts
599
+ type TaskStatus = "pending" | "complete" | "skipped";
600
+ ```
601
+
602
+ `currentTaskId` describes execution focus, while task status describes completion state.
603
+
604
+ ## 7.2 Persist current subtask
605
+
606
+ A separate `currentSubtaskId` is not required if every task and subtask already has a globally unique ID.
607
+
608
+ `currentTaskId` may point to any node in the task tree.
609
+
610
+ The dashboard should derive:
611
+
612
+ - The current node.
613
+ - Its parent task when applicable.
614
+ - Its sibling/subtask progress.
615
+ - Its depth.
616
+
617
+ ## 7.3 Add task-start ledger event
618
+
619
+ Add:
620
+
621
+ ```ts
622
+ interface TaskStartedEvent {
623
+ type: "task_started";
624
+ goalId: string;
625
+ taskId: string;
626
+ at: string;
627
+ }
628
+ ```
629
+
630
+ Use existing completion and skip events for terminal states.
631
+
632
+ ## 7.4 Normalization rules
633
+
634
+ When loading a goal:
635
+
636
+ - Accept `currentTaskId` only when it references an existing pending task.
637
+ - Clear it when the task is complete.
638
+ - Clear it when the task is skipped.
639
+ - Clear it when the task no longer exists.
640
+ - Leave it absent for historical files.
641
+ - Do not rewrite old files solely because the field is absent.
642
+
643
+ For display only, if no persisted current task exists, the dashboard may fall back to the first pending task. The fallback must be visually or internally marked as inferred so it is not persisted accidentally.
644
+
645
+ ## 7.5 Task-list replacement rules
646
+
647
+ When a task list is replaced or restructured:
648
+
649
+ - Preserve matching task statuses and evidence.
650
+ - Preserve `currentTaskId` only if the same ID remains pending.
651
+ - Otherwise clear it.
652
+ - Recompute dashboard state immediately.
653
+
654
+ ---
655
+
656
+ ## 8. Task tool changes
657
+
658
+ Extend `update_goal_task` to support explicit task execution focus.
659
+
660
+ Suggested input:
661
+
662
+ ```ts
663
+ {
664
+ task_id: string;
665
+ action: "start" | "complete" | "skip";
666
+ evidence?: string;
667
+ reason?: string;
668
+ }
669
+ ```
670
+
671
+ ## 8.1 Start
672
+
673
+ Validation:
674
+
675
+ - A focused goal exists.
676
+ - The goal is active or valid for task editing.
677
+ - The task exists.
678
+ - The task is pending.
679
+
680
+ Effect:
681
+
682
+ - Set `currentTaskId`.
683
+ - Append `task_started`.
684
+ - Persist the goal.
685
+ - Refresh the dashboard.
686
+ - Include the task contract in the next continuation prompt.
687
+
688
+ ## 8.2 Complete
689
+
690
+ Validation:
691
+
692
+ - The task exists.
693
+ - Required subtasks are complete unless lightweight rules permit otherwise.
694
+ - Required evidence is present.
695
+ - The task is not already complete or skipped.
696
+
697
+ Effect:
698
+
699
+ - Set status to complete.
700
+ - Save completion timestamp.
701
+ - Save evidence.
702
+ - Clear `currentTaskId` if it matches.
703
+ - Append `task_completed`.
704
+ - Optionally infer the next pending task for display.
705
+ - Refresh the dashboard.
706
+
707
+ ## 8.3 Skip
708
+
709
+ Validation:
710
+
711
+ - The task exists.
712
+ - A reason is supplied when required.
713
+ - The task is not already terminal.
714
+
715
+ Effect:
716
+
717
+ - Set status to skipped.
718
+ - Save timestamp and reason.
719
+ - Clear `currentTaskId` if it matches.
720
+ - Append `task_skipped`.
721
+ - Refresh the dashboard.
722
+
723
+ ---
724
+
725
+ ## 9. Task progress semantics
726
+
727
+ ## 9.1 Overall task progress
728
+
729
+ The main dashboard progress should count top-level tasks.
730
+
731
+ This keeps the main percentage aligned with major milestones.
732
+
733
+ A top-level task counts as done when it is:
734
+
735
+ - Complete.
736
+ - Skipped.
737
+
738
+ ## 9.2 Expanded task tree
739
+
740
+ Expanded mode should show every task and subtask recursively.
741
+
742
+ Each task row should show:
743
+
744
+ - Completion marker.
745
+ - Current-task marker.
746
+ - ID.
747
+ - Title.
748
+ - Optional verification indicator.
749
+ - Optional evidence indicator.
750
+
751
+ Suggested markers:
752
+
753
+ ```text
754
+ ✓ complete
755
+ ~ skipped
756
+ ▸ current
757
+ · pending
758
+ ```
759
+
760
+ ## 9.3 Current-task subtask progress
761
+
762
+ For the current task:
763
+
764
+ - If it has direct children, show progress across those children.
765
+ - If the current task is itself a subtask, show progress among its siblings or omit the ratio if that would be confusing.
766
+ - Use one documented rule consistently.
767
+
768
+ Preferred rule:
769
+
770
+ - For a parent task, show direct-child completion.
771
+ - For a leaf task, omit subtask progress.
772
+
773
+ ## 9.4 All tasks complete
774
+
775
+ When all top-level tasks are done:
776
+
777
+ ```text
778
+ Tasks [██████████] 5/5 · 100%
779
+ Current: All tasks complete
780
+ ```
781
+
782
+ The expanded dashboard should retain the completed task tree until audit or archival begins.
783
+
784
+ ## 9.5 Tasks disabled
785
+
786
+ When tasks are disabled:
787
+
788
+ - Omit task sections.
789
+ - Keep goal status, verification, usage, path, and focus.
790
+ - Do not show empty separators.
791
+
792
+ ---
793
+
794
+ ## 10. Merging the existing task overlay
795
+
796
+ The useful behavior currently associated with the task overlay should be moved into the dashboard.
797
+
798
+ This includes:
799
+
800
+ - Recursive task rendering.
801
+ - Current selection.
802
+ - Task detail.
803
+ - Evidence.
804
+ - Verification contracts.
805
+ - Keyboard navigation where useful.
806
+ - Width-safe rendering.
807
+ - Task counts.
808
+ - Nested indentation.
809
+
810
+ Implementation direction:
811
+
812
+ 1. Move reusable tree derivation into `goal-dashboard-model.ts`.
813
+ 2. Move reusable task-row rendering into the dashboard renderer.
814
+ 3. Add a dashboard expansion state to `GoalWidgetComponent`.
815
+ 4. Route the task-overlay shortcut to `toggleExpanded()`.
816
+ 5. Remove separate overlay registration after parity is achieved.
817
+ 6. Retain compatibility helpers only where tests or external imports require them.
818
+ 7. Update documentation and help text to describe one dashboard, not two interfaces.
819
+
820
+ The expanded dashboard should remain a passive status surface unless the current overlay already provides safe, well-tested navigation. Do not add task mutation directly to the dashboard in this change unless it can be done without confusing focus or input behavior.
821
+
822
+ ---
823
+
824
+ ## 11. Verification visibility
825
+
826
+ ## 11.1 Goal-level verification
827
+
828
+ Show the goal-level verification contract in:
829
+
830
+ - Compact dashboard.
831
+ - Expanded dashboard.
832
+ - `/goal-status`.
833
+ - Completion review.
834
+ - Archive record.
835
+
836
+ Compact mode may show a truncated first line.
837
+
838
+ Expanded mode should show the complete contract, wrapped safely.
839
+
840
+ ## 11.2 Task-level verification
841
+
842
+ Show the current task's verification contract in the current-task section.
843
+
844
+ The full task tree may show a small indicator for tasks with contracts, with the full contract shown when the task is current or selected.
845
+
846
+ ## 11.3 Detailed summary
847
+
848
+ Update `detailedSummary` to include:
849
+
850
+ ```text
851
+ Verification: <contract>
852
+ ```
853
+
854
+ where a contract exists.
855
+
856
+ ---
857
+
858
+ ## 12. Human-readable activity feed
859
+
860
+ Create:
861
+
862
+ ```text
863
+ extensions/goal-activity.ts
864
+ ```
865
+
866
+ Suggested model:
867
+
868
+ ```ts
869
+ export interface GoalActivityItem {
870
+ at: string;
871
+ kind:
872
+ | "goal"
873
+ | "task"
874
+ | "verification"
875
+ | "audit"
876
+ | "archive";
877
+ text: string;
878
+ }
879
+ ```
880
+
881
+ Map durable events to readable activity:
882
+
883
+ ```text
884
+ goal_created
885
+ → Created and focused the goal.
886
+
887
+ task_started
888
+ → Started “Add download button.”
889
+
890
+ task_completed
891
+ → Completed “Implement CSV export.”
892
+
893
+ task_skipped
894
+ → Skipped “Legacy fallback” — out of scope.
895
+
896
+ goal_tweaked
897
+ → Updated the goal objective and task plan.
898
+
899
+ audit_started
900
+ → Started independent completion review.
901
+
902
+ audit_approved
903
+ → Independent auditor approved completion.
904
+
905
+ audit_rejected
906
+ → Completion review requested additional work.
907
+
908
+ goal_archived
909
+ → Archived the completed goal.
910
+ ```
911
+
912
+ Rules:
913
+
914
+ - Prefer task title over task ID.
915
+ - Include evidence only when concise.
916
+ - Exclude low-value checkpoint noise.
917
+ - Deduplicate repeated lifecycle events.
918
+ - Default to the latest three to five useful entries.
919
+ - Preserve full history for verbose status and archived records.
920
+
921
+ ---
922
+
923
+ ## 13. `/goal-status` redesign
924
+
925
+ `/goal-status` should render the same unified dashboard model as the above-editor widget.
926
+
927
+ It should be visually polished, not a plain diagnostic dump.
928
+
929
+ ## 13.1 Standard mode
930
+
931
+ Standard output should contain:
932
+
933
+ 1. A static text rendering of the compact dashboard.
934
+ 2. Current-task details.
935
+ 3. Recent activity.
936
+ 4. Last audit result when available.
937
+
938
+ Example:
939
+
940
+ ```text
941
+ ┌─ pi-goal-x ─ Add CSV export to reports ─────────────── 12m47s · 18.2K tok ─┐
942
+ │ ● In progress Focused: yes Other goals: 2 │
943
+ │ Tasks [██████░░░░] 3/5 · 60% │
944
+ │ Current t3 · Add the download button │
945
+ │ Subtasks [███████░░░] 2/3 · 67% │
946
+ │ Verify Run npm test with zero failures. │
947
+ │ File .pi/goals/active_goal_... │
948
+ ├─ Recent activity ───────────────────────────────────────────────────────────┤
949
+ │ ✓ Completed filtered CSV serialization │
950
+ │ ✓ Added loading and filename behavior │
951
+ │ ▸ Started download error handling │
952
+ └─────────────────────────────────────────────────────────────────────────────┘
953
+ ```
954
+
955
+ The command output should not include effective settings by default.
956
+
957
+ ## 13.2 Verbose mode
958
+
959
+ Add:
960
+
961
+ ```text
962
+ /goal-status verbose
963
+ ```
964
+
965
+ Verbose output may include:
966
+
967
+ - Goal ID.
968
+ - Revision.
969
+ - Full objective.
970
+ - Complete task tree.
971
+ - Full task evidence.
972
+ - Full verification contracts.
973
+ - Recent ledger history.
974
+ - Effective settings and provenance.
975
+ - Token budget detail.
976
+ - Pause or blocker detail.
977
+ - Active and archived paths.
978
+ - Last audit report.
979
+
980
+ ## 13.3 Expanded dashboard parity
981
+
982
+ The standard `/goal-status` output should closely match the expanded dashboard's information hierarchy.
983
+
984
+ The two surfaces may differ in interaction, but not in data or terminology.
985
+
986
+ ---
987
+
988
+ ## 14. Guided drafting improvements
989
+
990
+ Preserve the existing questionnaire capabilities:
991
+
992
+ - Single or multiple questions.
993
+ - Recommended answers.
994
+ - Custom answers.
995
+ - Tab navigation.
996
+ - Auditor toggle.
997
+ - Continue refining.
998
+ - Cancel.
999
+ - Terminal-height safety.
1000
+
1001
+ Add a durable proposal summary to the terminal transcript:
1002
+
1003
+ ```text
1004
+ Proposed objective:
1005
+ Add CSV export to the reports page using active filters and visible-column
1006
+ order, with documentation and passing tests.
1007
+
1008
+ Proposed plan:
1009
+ 1. Review the reports page and data source.
1010
+ 2. Implement filtered CSV export.
1011
+ 3. Add the download control.
1012
+ 4. Add documentation.
1013
+ 5. Add and run tests.
1014
+
1015
+ Verification:
1016
+ Run npm test with zero failures.
1017
+
1018
+ Automatic continuation: enabled
1019
+ Independent auditor: enabled
1020
+ ```
1021
+
1022
+ After confirmation:
1023
+
1024
+ ```text
1025
+ ✓ Goal created and focused.
1026
+ Continuing automatically with the confirmed plan.
1027
+ ```
1028
+
1029
+ Expanded detail may include:
1030
+
1031
+ - Goal ID.
1032
+ - Active file path.
1033
+ - Task count.
1034
+ - Verification contract.
1035
+ - Auditor configuration.
1036
+ - Token budget.
1037
+
1038
+ Capture questionnaire answers before clearing draft state so the confirmed goal report can include them reliably.
1039
+
1040
+ ---
1041
+
1042
+ ## 15. Structured audit dashboard
1043
+
1044
+ The audit view should use the same visual system as the goal dashboard.
1045
+
1046
+ ## 15.1 Audit model
1047
+
1048
+ Extend auditor progress with structured checks:
1049
+
1050
+ ```ts
1051
+ export type AuditCheckState =
1052
+ | "pending"
1053
+ | "running"
1054
+ | "passed"
1055
+ | "failed";
1056
+
1057
+ export interface AuditCheck {
1058
+ id:
1059
+ | "objective"
1060
+ | "verification"
1061
+ | "tasks"
1062
+ | "workspace"
1063
+ | "decision";
1064
+ label: string;
1065
+ state: AuditCheckState;
1066
+ detail?: string;
1067
+ }
1068
+
1069
+ export interface AuditorDashboardModel {
1070
+ auditorLabel: string;
1071
+ elapsedMs: number;
1072
+ percentage?: number;
1073
+ checks: AuditCheck[];
1074
+ currentTool?: string;
1075
+ currentToolArgs?: string;
1076
+ recentOutput: string[];
1077
+ }
1078
+ ```
1079
+
1080
+ ## 15.2 Audit stages
1081
+
1082
+ The auditor should report:
1083
+
1084
+ 1. Objective and success criteria.
1085
+ 2. Verification contracts.
1086
+ 3. Tasks and evidence.
1087
+ 4. Workspace inspection.
1088
+ 5. Final decision.
1089
+
1090
+ ## 15.3 Audit rendering
1091
+
1092
+ Example:
1093
+
1094
+ ```text
1095
+ ┌─ Independent completion audit ─ provider/model ─────────────────── 2m18s ─┐
1096
+ │ ✓ Objective and success criteria │
1097
+ │ ✓ Verification contracts │
1098
+ │ ✓ Tasks and recorded evidence │
1099
+ │ ◌ Workspace inspection │
1100
+ │ · Final decision │
1101
+ │ [███████░░░] 72% │
1102
+ └─ Esc: stop audit ───────────────────────────────────────────────────────────┘
1103
+ ```
1104
+
1105
+ Raw tools and recent output should appear only:
1106
+
1107
+ - In expanded audit mode.
1108
+ - In debug mode.
1109
+ - When an unexpected audit failure needs diagnostic detail.
1110
+
1111
+ ## 15.4 Audit result
1112
+
1113
+ Approval:
1114
+
1115
+ ```text
1116
+ ┌─ Audit result ─ APPROVED ───────────────────────────────────────────────────┐
1117
+ │ ✓ Objective satisfied. │
1118
+ │ ✓ Verification requirements satisfied. │
1119
+ │ ✓ Required tasks and evidence accepted. │
1120
+ └─────────────────────────────────────────────────────────────────────────────┘
1121
+ ```
1122
+
1123
+ Rejection:
1124
+
1125
+ ```text
1126
+ ┌─ Audit result ─ CHANGES REQUIRED ───────────────────────────────────────────┐
1127
+ │ ✗ Tests were not run after the final implementation change. │
1128
+ │ ✗ Task “Update documentation” has no completion evidence. │
1129
+ └─────────────────────────────────────────────────────────────────────────────┘
1130
+ ```
1131
+
1132
+ On rejection:
1133
+
1134
+ - Keep the goal open.
1135
+ - Persist the report.
1136
+ - Add findings to the next continuation.
1137
+ - Restore the normal dashboard.
1138
+ - Show the required next work clearly.
1139
+
1140
+ ---
1141
+
1142
+ ## 16. Completion and archival flow
1143
+
1144
+ ## 16.1 Completion request
1145
+
1146
+ When the agent requests completion:
1147
+
1148
+ - Reconcile the goal from disk.
1149
+ - Validate lifecycle state.
1150
+ - Validate task-completion rules.
1151
+ - Account remaining usage.
1152
+ - Append `completion_requested`.
1153
+ - Launch the auditor.
1154
+
1155
+ ## 16.2 Auditor disabled
1156
+
1157
+ When auditing is disabled:
1158
+
1159
+ - Record `audit_skipped`.
1160
+ - State why it was skipped.
1161
+ - Use the same completion transaction.
1162
+ - Do not present the result as independently approved.
1163
+
1164
+ ## 16.3 User abort during audit
1165
+
1166
+ Preserve the existing Escape flow.
1167
+
1168
+ The user should be able to:
1169
+
1170
+ - Continue working.
1171
+ - Complete without audit.
1172
+
1173
+ Completing without audit must:
1174
+
1175
+ - Record the bypass explicitly.
1176
+ - Never be labeled approved.
1177
+ - Continue through normal archival.
1178
+
1179
+ ## 16.4 Approval
1180
+
1181
+ On approval:
1182
+
1183
+ - Persist the audit report.
1184
+ - Mark the goal complete.
1185
+ - Stop continuation.
1186
+ - Allow the final executor summary.
1187
+ - Archive at the correct deferred lifecycle point.
1188
+
1189
+ ## 16.5 Rejection
1190
+
1191
+ On rejection:
1192
+
1193
+ - Persist the audit report.
1194
+ - Keep the goal open.
1195
+ - Surface actionable findings.
1196
+ - Resume normal work state.
1197
+ - Allow the agent to continue correcting the implementation.
1198
+
1199
+ ## 16.6 Archive transaction
1200
+
1201
+ The archive operation should:
1202
+
1203
+ 1. Acquire the goal lock.
1204
+ 2. Confirm the expected revision.
1205
+ 3. Write the completed archived record.
1206
+ 4. Retire the active record.
1207
+ 5. Append `goal_archived`.
1208
+ 6. Update memory.
1209
+ 7. Clear or change focus according to settings.
1210
+ 8. Emit the actual archive path.
1211
+
1212
+ Success message:
1213
+
1214
+ ```text
1215
+ Goal archived.
1216
+ File: .pi/goals/archived/goal_...
1217
+ ```
1218
+
1219
+ Failure behavior:
1220
+
1221
+ - Do not claim success.
1222
+ - Keep the complete record recoverable.
1223
+ - Report the remaining active or temporary path.
1224
+ - Write a diagnostic ledger event when possible.
1225
+
1226
+ ---
1227
+
1228
+ ## 17. Repository changes
1229
+
1230
+ ## 17.1 New files
1231
+
1232
+ ```text
1233
+ extensions/widgets/goal-dashboard-model.ts
1234
+ extensions/widgets/goal-dashboard-renderer.ts
1235
+ extensions/goal-activity.ts
1236
+ tests/goal-dashboard-model.test.ts
1237
+ tests/goal-activity.test.ts
1238
+ tests/goal-dashboard-golden.test.ts
1239
+ tests/e2e/goal-lifecycle-dashboard.test.ts
1240
+ docs/unified-dashboard.md
1241
+ ```
1242
+
1243
+ `goal-dashboard-renderer.ts` may be folded into `goal-widget.ts` if keeping a separate renderer does not improve clarity. The important requirement is to keep pure model derivation separate from TUI integration.
1244
+
1245
+ ## 17.2 Primary modified files
1246
+
1247
+ ```text
1248
+ extensions/goal-record.ts
1249
+ extensions/goal-ledger.ts
1250
+ extensions/goal-task-tools.ts
1251
+ extensions/goal-format.ts
1252
+ extensions/goal-state.ts
1253
+ extensions/goal-drafting.ts
1254
+ extensions/goal-questionnaire.ts
1255
+ extensions/goal-completion.ts
1256
+ extensions/goal-auditor.ts
1257
+ extensions/goal-commands.ts
1258
+ extensions/widgets/goal-widget.ts
1259
+ extensions/widgets/task-list-overlay.ts
1260
+ extensions/storage/goal-files.ts
1261
+ README.md
1262
+ CHANGELOG.md
1263
+ tests/.test-manifest.json
1264
+ ```
1265
+
1266
+ ## 17.3 Supporting changes as required
1267
+
1268
+ ```text
1269
+ extensions/goal-policy.ts
1270
+ extensions/goal-prompts.ts
1271
+ extensions/goal-core-tools.ts
1272
+ extensions/goal-service.ts
1273
+ extensions/goal-events.ts
1274
+ tests/tui-test-utils.ts
1275
+ ```
1276
+
1277
+ ---
1278
+
1279
+ ## 18. Implementation sequence inside the single PR
1280
+
1281
+ The pull request should be developed in this order to keep the branch continuously testable.
1282
+
1283
+ ### 18.1 Presentation foundation
1284
+
1285
+ - Add the dashboard model.
1286
+ - Add task-tree flattening.
1287
+ - Add progress derivation.
1288
+ - Add status derivation.
1289
+ - Add activity derivation.
1290
+ - Add model tests.
1291
+
1292
+ ### 18.2 Current-task persistence
1293
+
1294
+ - Add `currentTaskId`.
1295
+ - Add normalization.
1296
+ - Add task-start events.
1297
+ - Extend task tools.
1298
+ - Add migration and lifecycle tests.
1299
+
1300
+ ### 18.3 Unified dashboard component
1301
+
1302
+ - Add compact rendering.
1303
+ - Add expanded rendering.
1304
+ - Merge task-overlay behavior.
1305
+ - Add expansion state.
1306
+ - Add responsive layouts.
1307
+ - Add width and golden tests.
1308
+
1309
+ ### 18.4 Goal-status integration
1310
+
1311
+ - Render from the same dashboard model.
1312
+ - Add standard and verbose modes.
1313
+ - Remove default settings noise.
1314
+ - Add activity and last-audit sections.
1315
+
1316
+ ### 18.5 Drafting polish
1317
+
1318
+ - Add durable proposal summaries.
1319
+ - Improve confirmation output.
1320
+ - Preserve questionnaire answer summaries.
1321
+
1322
+ ### 18.6 Audit integration
1323
+
1324
+ - Add structured audit stages.
1325
+ - Add audit dashboard rendering.
1326
+ - Add approval and rejection result cards.
1327
+ - Preserve Escape and bypass behavior.
1328
+
1329
+ ### 18.7 Completion and archival polish
1330
+
1331
+ - Add explicit archive-success output.
1332
+ - Add archive-failure handling.
1333
+ - Add the complete end-to-end lifecycle test.
1334
+
1335
+ ### 18.8 Documentation and final verification
1336
+
1337
+ - Update README.
1338
+ - Add unified dashboard documentation.
1339
+ - Update command help.
1340
+ - Add migration notes.
1341
+ - Update changelog.
1342
+ - Run all checks.
1343
+
1344
+ ---
1345
+
1346
+ ## 19. Testing strategy
1347
+
1348
+ ## 19.1 Dashboard model tests
1349
+
1350
+ Cover:
1351
+
1352
+ - Active goal without tasks.
1353
+ - Active goal with partial tasks.
1354
+ - All tasks complete.
1355
+ - Current top-level task.
1356
+ - Current nested task.
1357
+ - Current parent with subtasks.
1358
+ - Current leaf task.
1359
+ - Invalid `currentTaskId`.
1360
+ - Removed current task.
1361
+ - Skipped tasks.
1362
+ - Disabled tasks.
1363
+ - Goal verification.
1364
+ - Task verification.
1365
+ - Multiple open goals.
1366
+ - Token budget.
1367
+ - Paused state.
1368
+ - Blocked state.
1369
+ - Budget-limited state.
1370
+ - Complete state.
1371
+
1372
+ ## 19.2 Task lifecycle tests
1373
+
1374
+ Verify:
1375
+
1376
+ - `start` sets `currentTaskId`.
1377
+ - Starting another task replaces it.
1378
+ - Completing the current task clears it.
1379
+ - Skipping the current task clears it.
1380
+ - Structural task changes preserve a valid current ID.
1381
+ - Structural task changes clear an invalid ID.
1382
+ - Existing status, timestamps, and evidence remain intact.
1383
+
1384
+ ## 19.3 Activity tests
1385
+
1386
+ Verify:
1387
+
1388
+ - Ledger events map to readable text.
1389
+ - Task titles replace IDs.
1390
+ - Checkpoint noise is excluded.
1391
+ - Evidence is truncated safely.
1392
+ - Events are correctly ordered.
1393
+ - Duplicate events are merged.
1394
+ - Default output is capped.
1395
+ - Full history remains available.
1396
+
1397
+ ## 19.4 Dashboard golden tests
1398
+
1399
+ Render compact and expanded dashboards at:
1400
+
1401
+ ```text
1402
+ 40 columns
1403
+ 50 columns
1404
+ 60 columns
1405
+ 80 columns
1406
+ 100 columns
1407
+ 140 columns
1408
+ ```
1409
+
1410
+ Cover:
1411
+
1412
+ - Running goal.
1413
+ - Running goal with tasks.
1414
+ - Current task with subtasks.
1415
+ - Long objective.
1416
+ - Long file path.
1417
+ - Long verification contract.
1418
+ - Unicode content.
1419
+ - Paused goal.
1420
+ - Blocked goal.
1421
+ - Budget-limited goal.
1422
+ - Complete goal.
1423
+ - Unfocused state.
1424
+ - Audit running.
1425
+ - Audit approved.
1426
+ - Audit rejected.
1427
+
1428
+ For every rendered line:
1429
+
1430
+ ```ts
1431
+ assert.ok(visibleWidth(line) <= width);
1432
+ ```
1433
+
1434
+ ## 19.5 Dashboard interaction tests
1435
+
1436
+ Verify:
1437
+
1438
+ - Compact mode is the default.
1439
+ - Task shortcut expands the dashboard.
1440
+ - The same shortcut or Escape collapses it.
1441
+ - Expanded mode does not corrupt editor input.
1442
+ - Goal state updates are visible in both modes.
1443
+ - Audit mode temporarily replaces the normal view.
1444
+ - Normal mode returns after rejection or audit completion.
1445
+ - Separate task-overlay registration is removed.
1446
+
1447
+ ## 19.6 Drafting tests
1448
+
1449
+ Verify:
1450
+
1451
+ - Questions precede proposals when needed.
1452
+ - Recommended answers work.
1453
+ - Custom answers work.
1454
+ - Proposal includes objective, tasks, verification, continuation, and auditor state.
1455
+ - Continue refining does not create a goal.
1456
+ - Cancel does not create a goal.
1457
+ - Confirm creates exactly one goal.
1458
+ - The goal is focused.
1459
+ - Questionnaire answers appear in the creation report.
1460
+ - Draft state survives compaction.
1461
+ - Stale tweak drafts are safely discarded.
1462
+
1463
+ ## 19.7 Audit tests
1464
+
1465
+ Verify each transition:
1466
+
1467
+ ```text
1468
+ objective: pending → running → passed
1469
+ verification: pending → running → passed
1470
+ tasks: pending → running → passed
1471
+ workspace: pending → running → passed
1472
+ decision: pending → running → passed or failed
1473
+ ```
1474
+
1475
+ Also verify:
1476
+
1477
+ - Auditor identity is shown.
1478
+ - Percentage is clamped.
1479
+ - Expanded diagnostics retain tool details.
1480
+ - Escape behavior works.
1481
+ - Rejection keeps the goal open.
1482
+ - Approval enters deferred completion.
1483
+ - The normal dashboard returns correctly.
1484
+
1485
+ ## 19.8 Persistence and migration tests
1486
+
1487
+ Legacy goal files must:
1488
+
1489
+ - Load without `currentTaskId`.
1490
+ - Preserve task state.
1491
+ - Preserve usage.
1492
+ - Preserve verification.
1493
+ - Preserve lifecycle status.
1494
+ - Archive correctly.
1495
+
1496
+ New goal files must:
1497
+
1498
+ - Persist `currentTaskId`.
1499
+ - Remove stale IDs during normalization.
1500
+ - Survive restart.
1501
+ - Survive session refocus.
1502
+ - Preserve revision safety.
1503
+
1504
+ ## 19.9 End-to-end lifecycle test
1505
+
1506
+ Create a deterministic lifecycle scenario:
1507
+
1508
+ 1. Start a guided goal.
1509
+ 2. Answer clarification questions.
1510
+ 3. Confirm a five-task plan.
1511
+ 4. Verify goal creation, focus, persistence, and automatic continuation.
1512
+ 5. Start the first task.
1513
+ 6. Complete three of five top-level tasks.
1514
+ 7. Verify the compact dashboard shows:
1515
+ - `3/5`.
1516
+ - `60%`.
1517
+ - Current task.
1518
+ - Subtask progress.
1519
+ - Verification contract.
1520
+ 8. Expand the dashboard.
1521
+ 9. Verify the complete task tree and current-task block.
1522
+ 10. Complete all tasks.
1523
+ 11. Request completion.
1524
+ 12. Simulate all audit stages.
1525
+ 13. Approve.
1526
+ 14. Verify deferred completion.
1527
+ 15. Verify archive creation.
1528
+ 16. Verify the final archive path.
1529
+ 17. Reload and verify the goal is no longer active.
1530
+
1531
+ ## 19.10 Full regression suite
1532
+
1533
+ All existing tests must remain green, including coverage for:
1534
+
1535
+ - Accounting.
1536
+ - Automatic continuation.
1537
+ - Auditor selection.
1538
+ - Drafting.
1539
+ - Escape handling.
1540
+ - Goal focus.
1541
+ - Mutation boundaries.
1542
+ - Overflow.
1543
+ - Task rendering.
1544
+ - Deferred archival.
1545
+ - Session growth.
1546
+ - Tool visibility.
1547
+ - Width safety.
1548
+
1549
+ Required commands:
1550
+
1551
+ ```text
1552
+ npm run check
1553
+ npm test
1554
+ npm run test:integration
1555
+ npm run test:all
1556
+ ```
1557
+
1558
+ Run any project benchmark or self-check commands required by the repository before merge.
1559
+
1560
+ ---
1561
+
1562
+ ## 20. Backward compatibility
1563
+
1564
+ The change must preserve:
1565
+
1566
+ - Existing goal-file formats.
1567
+ - Existing archived goals.
1568
+ - Existing settings.
1569
+ - Existing slash commands.
1570
+ - Existing direct-goal behavior.
1571
+ - Existing Sisyphus behavior.
1572
+ - Existing auditor configuration.
1573
+ - Existing task evidence.
1574
+ - Existing focus behavior.
1575
+
1576
+ Compatibility rules:
1577
+
1578
+ - New persisted fields are optional.
1579
+ - Historical records normalize safely.
1580
+ - Existing task IDs remain authoritative.
1581
+ - Existing command names do not change.
1582
+ - Existing task-overlay shortcut may be retained, but it now expands the unified dashboard.
1583
+ - Headless behavior remains functional without TUI rendering.
1584
+ - Audit-disabled behavior remains explicit and distinguishable from approval.
1585
+
1586
+ ---
1587
+
1588
+ ## 21. Documentation updates
1589
+
1590
+ Update the README to explain:
1591
+
1592
+ - Guided goal creation.
1593
+ - Immediate automatic continuation.
1594
+ - The unified dashboard.
1595
+ - Compact and expanded modes.
1596
+ - Current-task tracking.
1597
+ - Task-tree integration.
1598
+ - Verification visibility.
1599
+ - Recent activity.
1600
+ - Independent auditing.
1601
+ - Approval, rejection, and archival.
1602
+ - Keyboard shortcuts.
1603
+ - Standard and verbose goal-status modes.
1604
+
1605
+ Add:
1606
+
1607
+ ```text
1608
+ docs/unified-dashboard.md
1609
+ ```
1610
+
1611
+ The document should include:
1612
+
1613
+ - Layout examples for wide and narrow terminals.
1614
+ - Status-state examples.
1615
+ - Expanded task view.
1616
+ - Audit view.
1617
+ - Keybindings.
1618
+ - Accessibility and width behavior.
1619
+ - Migration behavior.
1620
+
1621
+ Update `CHANGELOG.md` with:
1622
+
1623
+ - Unified dashboard.
1624
+ - Merged task overlay.
1625
+ - Persisted current-task state.
1626
+ - Improved goal-status.
1627
+ - Structured audit progress.
1628
+ - Archive-result improvements.
1629
+
1630
+ ---
1631
+
1632
+ ## 22. Acceptance criteria
1633
+
1634
+ The single pull request is complete when all of the following are true:
1635
+
1636
+ - `/goal` supports clarification and explicit confirmation.
1637
+ - No guided goal is created before confirmation.
1638
+ - Confirmed goals are immediately focused and started.
1639
+ - Automatic continuation works without repetitive user prompts.
1640
+ - A polished dashboard is visible for focused goals.
1641
+ - The dashboard has compact and expanded modes.
1642
+ - The existing task overlay is merged into the dashboard.
1643
+ - The expanded dashboard shows the complete task tree.
1644
+ - The current task is persisted and clearly highlighted.
1645
+ - Current-task subtask progress is visible.
1646
+ - Task and goal verification contracts are visible.
1647
+ - Time, token usage, focus, path, and other open goals are visible.
1648
+ - Progress is derived from persisted goal state.
1649
+ - Recent activity is derived from the durable ledger.
1650
+ - `/goal-status` uses the same presentation model.
1651
+ - `/goal-status` is visually polished.
1652
+ - `/goal-status verbose` contains diagnostic detail.
1653
+ - Completion launches an independent auditor.
1654
+ - Audit progress uses a structured checklist.
1655
+ - Auditor identity and elapsed time are visible.
1656
+ - Audit rejection leaves the goal open with actionable feedback.
1657
+ - Audit approval proceeds through deferred archival.
1658
+ - Successful archival reports the real archive path.
1659
+ - Failed archival is never reported as successful.
1660
+ - Legacy goal files continue to work.
1661
+ - Compact and expanded layouts fit narrow and wide terminals.
1662
+ - No rendered line exceeds terminal width.
1663
+ - Normal goal rendering does not disrupt scrollback with continuous redraws.
1664
+ - Separate task-overlay registration is removed after feature parity.
1665
+ - All existing tests pass.
1666
+ - New model, lifecycle, rendering, migration, audit, interaction, and end-to-end tests pass.
1667
+ - README, dashboard documentation, and changelog are updated.