pi-goal-x 0.22.0 → 0.24.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 (39) hide show
  1. package/README.md +289 -387
  2. package/docs/.pi/goals/archived/goal_2026080600262071_msglt8us-fsjgtu.md +157 -0
  3. package/docs/.pi/goals/archived/goal_2026080611065364_mshc1y08-b6pnc1.md +76 -0
  4. package/docs/.pi/goals/goal_events.jsonl +40 -0
  5. package/docs/pi-goal-x-unified-dashboard-plan.md +1667 -0
  6. package/docs/unified-dashboard.md +266 -0
  7. package/extensions/goal-activity.ts +162 -0
  8. package/extensions/goal-auditor.ts +21 -20
  9. package/extensions/goal-commands.ts +31 -11
  10. package/extensions/goal-completion.ts +17 -1
  11. package/extensions/goal-core-tools.ts +32 -6
  12. package/extensions/goal-draft.ts +50 -71
  13. package/extensions/goal-drafting.ts +94 -18
  14. package/extensions/goal-events.ts +53 -7
  15. package/extensions/goal-format.ts +62 -3
  16. package/extensions/goal-ledger.ts +146 -7
  17. package/extensions/goal-policy.ts +61 -24
  18. package/extensions/goal-record.ts +35 -1
  19. package/extensions/goal-service.ts +240 -14
  20. package/extensions/goal-settings.ts +92 -4
  21. package/extensions/goal-state.ts +170 -39
  22. package/extensions/goal-status.ts +185 -0
  23. package/extensions/goal-task-confirmation.ts +5 -8
  24. package/extensions/goal-task-count.ts +59 -0
  25. package/extensions/goal-task-derive.ts +46 -0
  26. package/extensions/goal-task-tools.ts +48 -8
  27. package/extensions/goal-widget.ts +107 -5
  28. package/extensions/goal.ts +2 -0
  29. package/extensions/prompts/goal-prompts.ts +96 -39
  30. package/extensions/storage/goal-files.ts +112 -7
  31. package/extensions/storage/goal-lock.ts +7 -1
  32. package/extensions/widgets/auditor-dashboard-model.ts +174 -0
  33. package/extensions/widgets/dialog-scaffold.ts +26 -0
  34. package/extensions/widgets/goal-dashboard-model.ts +495 -0
  35. package/extensions/widgets/goal-dashboard-renderer.ts +622 -0
  36. package/extensions/widgets/goal-escape-dialog.ts +5 -9
  37. package/extensions/widgets/goal-widget.ts +273 -203
  38. package/extensions/widgets/task-list-overlay.ts +58 -39
  39. package/package.json +5 -2
package/README.md CHANGED
@@ -1,457 +1,359 @@
1
1
  # pi-goal-x
2
2
 
3
- `pi-goal-x` is a long-running goal extension for [pi](https://github.com/earendil-works/pi-coding-agent). It gives the agent a durable objective, a visible lifecycle, five schema-gated model tools, structured tasks, and independently audited completion.
3
+ `pi-goal-x` is a goal-management extension for [pi](https://github.com/earendil-works/pi-coding-agent).
4
4
 
5
- The extension is designed around one rule: **the user owns intent; the agent executes only after the goal is explicit and confirmed**.
5
+ It gives the agent a persistent objective, a structured plan, visible progress, and an independent completion review. Goals remain available across sessions, so the agent can continue working with the same objective and progress record.
6
6
 
7
7
  ## Features
8
8
 
9
- - **Two goal styles** — Regular goals for open-ended research and implementation. Sisyphus goals for patient ordered execution, one step at a time.
10
- - **Guided goal creation** — `/goal [seed]` and `/sisyphus [seed]` let the agent clarify intent, use a questionnaire when useful, propose the full goal and a task tree, and wait for explicit confirmation. `/goal-direct <objective>` and `/sisyphus-direct <objective>` are the fast bypass.
11
- - **Full lifecycle** — Pause, resume, clear, and complete through user commands and the five model tools. Auto-continue keeps the agent working across turns until completion, interruption, or the empty-turn guard.
12
- - **Multiple open goals** — Keep several goals in `.pi/goals/`. Each session focuses one at a time; switch with `/goal-focus`.
13
- - **Above-editor status widget** — See the current goal, status, file path, and progress at a glance while the agent works.
14
- - **Structured task lists with subtasks** — Break goals into trackable tasks. Agents can mark individual tasks or subtasks complete without stopping the turn. Subtask IDs are validated for uniqueness and depth.
15
- - **Verification contracts** — Attach plain-text requirements to a goal or task (e.g. "Run npm test, zero failures"). The independent auditor verifies them from actual evidence; per-task contracts require evidence on `update_goal_task`.
16
- - **Independent completion auditor** — When a goal is marked complete, a separate pi agent inspects the workspace, verifies every success criterion, and approves or rejects before the goal is archived. You can press Escape during an audit to abort it. Configure the auditor model via `/goal-settings`.
17
- - **Compact execution surface** — Normal work uses five goal tools (`create_goal`, `get_goal`, `update_goal`, `set_goal_tasks`, `update_goal_task`), or three when tasks are disabled. A user-started draft temporarily exposes only `goal_question`, `goal_questionnaire`, and `propose_goal_draft`; confirmation restores the execution profile without touching ordinary Pi work tools.
18
- - **Immutable objective** — The agent cannot silently change your goal. Objective updates happen through user-owned `/goal-tweak`.
19
- - **User-owned lifecycle** — Pause, resume, clear, focus, and settings are immediate user commands; the model reports complete, blocked, or (with a reason) paused outcomes.
20
- - **Disk-backed state** — Active and archived goals persist in `.pi/goals/`. Goal state survives session compaction, workspace switches, and context churn.
21
- - **Configurable settings** — Every persisted setting (task/contract toggles, subtask depth, auditor provider/model/thinking, auto-select, disable) is selectable and operable through `/goal-settings`; the file `.pi/pi-goal-x-settings.json` remains the durable store.
22
-
23
- > **Fork of [@capyup/pi-goal](https://github.com/capyup/pi-goal)** — pi-goal-x is now maintained independently. It adds verification contracts, recursive task lists, multiple durable goals with session-local focus, an immutable objective, deferred archival, a configurable completion auditor, token budgets, compaction recovery, and a live progress widget.
9
+ ### Regular goals
10
+
11
+ Regular goals describe an outcome for the agent to achieve. The agent can investigate the work, choose an appropriate sequence, create tasks, and adapt its plan as it progresses.
12
+
13
+ Regular goals work well for research, implementation, debugging, documentation, and other work where the desired result is clear and the execution path can be determined during the task.
14
+
15
+ ### Sisyphus goals
16
+
17
+ Sisyphus goals describe work that should be completed in a specific order. The agent follows the listed sequence one step at a time and preserves dependencies between steps.
18
+
19
+ Sisyphus goals work well for migrations, staged refactors, release procedures, data-processing workflows, and other tasks where each step prepares the way for the next.
20
+
21
+ ### Guided goal creation
22
+
23
+ The `/goal` and `/sisyphus` commands start a guided drafting process. The agent can ask focused questions, clarify the objective, and propose a task plan for confirmation.
24
+
25
+ The proposal is written to the conversation as a durable summary (objective, plan, verification, automatic continuation, auditor state); confirming it creates and focuses the goal and starts working automatically.
26
+
27
+ ### Direct goal creation
28
+
29
+ The `/goal-direct` and `/sisyphus-direct` commands create a goal immediately from a complete objective.
30
+
31
+ ### Persistent progress
32
+
33
+ Open goals are stored in `.pi/goals/`. Their objectives, tasks, status, and progress remain available across sessions and context changes.
34
+
35
+ ### Multiple open goals
36
+
37
+ A project can contain several open goals. Each session focuses on one goal at a time, and you can switch between them with `/goal-focus`.
38
+
39
+ ### Tasks and subtasks
40
+
41
+ Goals can include structured tasks and subtasks. The agent updates their status and records completion evidence as work progresses.
42
+
43
+ ### Verification contracts
44
+
45
+ Goals and tasks can include plain-text completion requirements, such as:
46
+
47
+ ```text
48
+ Run npm test with zero failures.
49
+ ```
50
+
51
+ The completion auditor checks these requirements against evidence from the workspace.
52
+
53
+ ### Independent completion review
54
+
55
+ When the agent reports a goal as complete, a separate pi agent reviews the objective, tasks, verification requirements, and workspace.
56
+
57
+ Approved goals are archived as complete. Goals requiring additional work remain open with review feedback.
58
+
59
+ ### Visible status
60
+
61
+ An above-editor widget shows the focused goal: its status, focus state, other open goals, time and token usage, task progress, the current task, and the goal file path.
62
+
63
+ Press `Ctrl+Shift+T` to expand the widget into the full unified dashboard — the complete task tree with the current task highlighted, the current task's verification contract and evidence, the goal-level verification contract, and a recent-activity feed derived from the durable goal ledger. Press `Esc` or `Ctrl+Shift+T` again to collapse it.
64
+
65
+ During an independent completion audit the widget shows a structured audit dashboard (five review stages and a progress bar); after the audit it shows the approval or changes-required result, then returns to the normal view.
66
+
67
+ ### Goal controls
68
+
69
+ Slash commands let you pause, resume, revise, select, unfocus, and archive goals.
70
+
71
+ ### Configurable behaviour
72
+
73
+ The settings menu controls task support, verification contracts, subtask depth, goal selection, and the completion auditor.
24
74
 
25
75
  ## Install
26
76
 
27
- From npm:
77
+ Install from npm:
28
78
 
29
79
  ```bash
30
80
  pi install npm:pi-goal-x
31
81
  ```
32
82
 
33
- From a local checkout:
83
+ Install from a local checkout:
34
84
 
35
85
  ```bash
36
86
  pi install .
37
87
  ```
38
88
 
39
- Try once without installing:
89
+ Run it once from a local checkout:
40
90
 
41
91
  ```bash
42
92
  pi -e .
43
93
  ```
44
94
 
45
- ## Quick start
95
+ ## Choose a goal style
96
+
97
+ Use a **regular goal** when you have a clear outcome and want the agent to determine how to reach it.
46
98
 
47
- ### Regular goal
99
+ For example:
48
100
 
49
101
  ```text
50
- /goal add structured logging to the auth module
102
+ /goal Add account deletion to the application, including the user interface, data cleanup, documentation, and tests.
51
103
  ```
52
104
 
53
- Flow:
105
+ The agent can decide how to investigate the application, divide the work, and order the implementation.
54
106
 
55
- 1. `/goal <seed>` begins a guided draft. The agent may ask focused questions
56
- or show a short questionnaire, and decides whether a task tree is useful.
57
- 2. The agent calls `propose_goal_draft` with the full objective and any task
58
- tree. The confirmation dialog presents both; Confirm creates them
59
- atomically, while Continue Chatting keeps the draft open for refinement.
60
- 3. The confirmed goal becomes this session's focus. Existing open goals remain
61
- in `.pi/goals/` and can be selected later with `/goal-focus`.
62
- 4. The agent works only on the focused goal until it requests completion via
63
- `update_goal`, reports a blocker, produces an empty/non-progress turn, or the
64
- user interrupts.
107
+ Use a **Sisyphus goal** when you already know the required sequence and want the agent to follow it step by step.
65
108
 
66
- ### Sisyphus goal
109
+ For example:
67
110
 
68
111
  ```text
69
- /sisyphus Refactor the auth flow: 1) extract token validation. 2) wire it into login. 3) update tests.
112
+ /sisyphus Migrate authentication in this order:
113
+ 1. Add the new token validator.
114
+ 2. Update login to use it.
115
+ 3. Update session refresh to use it.
116
+ 4. Remove the old validator.
117
+ 5. Run the authentication test suite.
70
118
  ```
71
119
 
72
- Sisyphus mode is for patient ordered execution. It uses the same lifecycle and tools as a regular goal; the difference is the prompt style and completion standard: preserve the user's order, do not rush, do not invent preflight/reconnaissance steps, and stop to ask when blocked.
120
+ The agent completes the migration in the stated order, preserving the dependency between each stage.
73
121
 
74
- If the objective is already final, use `/goal-direct <objective>` or
75
- `/sisyphus-direct <objective>` to create it immediately without drafting.
122
+ ## Create a guided goal
123
+
124
+ Start a guided regular goal:
125
+
126
+ ```text
127
+ /goal add structured logging to the authentication module
128
+ ```
76
129
 
77
- ## User commands
130
+ The agent can ask questions and propose a complete objective and task plan. Confirm the proposal to create the goal and begin work.
78
131
 
79
- The curated fourteen-command palette (each lifecycle action is independently
80
- registered so tab completion is self-explanatory):
132
+ Start a guided Sisyphus goal:
81
133
 
82
134
  ```text
83
- /goal [seed] Start a regular guided draft; bare form asks what to accomplish.
84
- /sisyphus [seed] Start a guided Sisyphus draft with ordered-work constraints.
85
- /goal-direct <objective> Create and focus a regular goal immediately, without drafting.
86
- /sisyphus-direct <objective> Create and focus a Sisyphus goal immediately, without drafting.
87
- /goal-list List all open goals in .pi/goals/ and the current focus
88
- /goal-status Show the focused goal and how many other goals are open (read-only)
89
- /goal-focus Choose this session's focused goal
90
- /goal-unfocus Stop this session's goal work without modifying the shared goal
91
- /goal-tweak <change> Guide a confirmed refinement of the focused objective and task plan
92
- /goal-pause Pause the focused active goal
93
- /goal-resume Resume a paused or blocked goal
94
- /goal-settings Configure pi-goal settings, including auditor model settings
95
- /goal-clear Archive the focused goal after confirmation
96
- /goal-cancel Cancel the in-progress guided draft without creating a goal
135
+ /sisyphus prepare and perform the customer-data migration
97
136
  ```
98
137
 
99
- Pressing `Esc` or aborting an active run pauses the goal so it does not remain falsely active.
100
-
101
- ### Command migration
102
-
103
- | Legacy command | New command |
104
- |---|---|
105
- | `/goal-status` | restored as the read-only focused-status command |
106
- | `/goals-set <x>` | `/goal-direct <x>` |
107
- | `/sisyphus-set <x>` | `/sisyphus-direct <x>` |
108
- | `/goal-abort` | `/goal-clear` |
109
- | `/goals <topic>` | `/goal <topic>` guided draft |
110
-
111
- `/goal-tweak`, `/goal-pause`, `/goal-resume`, `/goal-clear`, `/goal-list`,
112
- `/goal-focus`, `/goal-unfocus`, and `/goal-settings` are retained unchanged.
113
-
114
- ### Tool migration
115
-
116
- | Legacy tool (removed) | Replacement |
117
- |---|---|
118
- | `complete_goal` | `update_goal({status: "complete"})` — audited from actual evidence, no verification-summary field |
119
- | `pause_goal` | `/goal-pause` (user-owned); `update_goal({status: "paused"})` with a required reason for an immediate agent pause; `update_goal({status: "blocked"})` only after the same blocker recurs on three consecutive turns |
120
- | `abort_goal` | `/goal-clear` (user-owned abandonment) |
121
- | `propose_goal_draft` | Used only in the temporary guided draft entered by `/goal`, `/sisyphus`, or `/goal-tweak` |
122
- | `propose_goal_tweak` | `/goal-tweak <change>` (a guided, user-confirmed revision) |
123
- | `propose_task_list` | `set_goal_tasks` (structural, with confirmation) |
124
- | `complete_task` / `skip_task` | `update_goal_task` (`complete`/`skipped`/`pending` on one task) |
125
- | `step_complete` | Sisyphus completion is checked against the objective's numbered steps; no separate tool |
126
- | `goal_question` / `goal_questionnaire` | Temporary guided-drafting tools; unavailable during normal execution |
127
-
128
- Old goal-file and ledger readers (`readActiveGoalPool`, `readGoalLedger`,
129
- `mergeGoalPromptFromDisk`, `latestAuditorResultForGoal`, `normalizeGoalRecord`)
130
- remain so existing `.pi/goals/` files and ledgers stay readable.
131
-
132
- ## Multiple open goals and focus
133
-
134
- `pi-goal` separates durable goals from session focus:
135
-
136
- - **Goal pool**: every open goal is an `active_goal_*.md` file under `.pi/goals/`.
137
- - **Focused goal**: the current pi session has one focused goal id stored in a `pi-goal-focus` custom session entry.
138
- - **No focus in markdown**: goal files describe the goal itself; they do not record which session is focused on them.
139
- - **Branch-local focus**: because focus is reconstructed from the current session branch, `/tree` navigation can restore a different focus for a different branch.
140
- - **One continuation chain**: auto-continue only schedules work for the focused goal in the current session.
141
-
142
- Confirming a `/goal` or `/sisyphus` draft, or using either `-direct` command, never clears other open goals; it creates a new active goal file and focuses it. Use `/goal-list` to inspect open goals, `/goal-focus` to switch the session focus, and `/goal-unfocus` to detach the current session without pausing, modifying, archiving, or recording a project-ledger focus change for the shared goal. Unfocus also aborts in-flight work and audits owned by that session; asynchronous lifecycle results are discarded if focus changed while they were pending. If the latest focus entry explicitly clears focus, or points at a missing/stale goal, a remaining single open goal is not auto-focused and resume does not prompt to replace that explicit choice. By default (`autoSelectSingleGoal: false`) sessions start unfocused so focus stays session-scoped — useful when multiple sessions share the same `.pi/goals/` directory. Set `autoSelectSingleGoal: true` to restore the old behavior where a single open goal is auto-focused when no focus entry exists at all. If multiple open goals exist and the session has no valid focus, `/goal-resume`, `/goal-clear`, `/goal-pause`, and `/goal-tweak` ask the user to choose a goal instead of acting on all of them.
143
-
144
- ## Agent tools
145
-
146
- Normal execution uses a fixed five-tool profile (three core tools when tasks
147
- are disabled). It is installed at session start and after a `disableTasks`
148
- setting change; focus, status, budget, completion, audit, and compaction do
149
- not change it. The only exception is a user-started draft: it temporarily
150
- replaces the goal tools with `goal_question`, `goal_questionnaire`, and
151
- `propose_goal_draft`, then restores execution tools on confirmation or exit.
152
-
153
- | Tool | Purpose |
154
- |---|---|
155
- | `create_goal` | Create and focus a new goal after an explicit user request (objective 1–4000 chars, optional `mode` regular/sisyphus and `token_budget`). Never infer a goal from an ordinary task. |
156
- | `get_goal` | Read-only complete focused goal snapshot: objective, status, mode, usage, budget + remaining, task summary, verification contract, blocker details, paths, other-open count. |
157
- | `update_goal` | Report a run outcome: `complete` (runs the independent auditor, which verifies from actual evidence; an optional `completion_summary` is an untrusted claim, never evidence), `blocked` (distinct agent-blocked state, only after the same blocker recurs on three consecutive turns), or `paused` (immediate agent pause with a required `reason` and optional `suggested_action`). |
158
- | `set_goal_tasks` | Create or structurally replace the task tree (flat parent-linked input, confirmation dialog, matching ids keep status/evidence). |
159
- | `update_goal_task` | Update one task without stopping the turn: complete (evidence for contracted tasks), skipped (reason), pending (reopens skipped). |
160
-
161
- During a user-started draft, these replace the execution tools:
162
-
163
- | Tool | Purpose |
164
- |---|---|
165
- | `goal_question` | Ask one focused structured clarification question. |
166
- | `goal_questionnaire` | Ask a small multi-question questionnaire. |
167
- | `propose_goal_draft` | Present the complete objective and the agent-selected flat task tree for Confirm, Continue Chatting, or Cancel. |
168
-
169
- Plus ordinary Pi work tools, which the extension never adds, removes, or
170
- force-enables: the user's host-tool selection is preserved. Lifecycle actions
171
- the model does not own (pause, resume, clear, focus, tweak, settings) are
172
- user-owned slash commands. When `disableTasks` is enabled, only the three core
173
- tools are advertised.
174
-
175
- ## Goal creation
176
-
177
- `/goal [seed]` and `/sisyphus [seed]` begin a goal-specific drafting state.
178
- The agent can clarify intent in conversation, use `goal_question` or
179
- `goal_questionnaire` when structured answers help, and choose a task tree
180
- when the work naturally decomposes. `propose_goal_draft` displays the full
181
- goal and task proposal for explicit Confirm or Continue Chatting. Only Confirm
182
- persists and focuses the goal. `/goal-direct <objective>` and
183
- `/sisyphus-direct <objective>` are the explicit no-drafting alternatives.
184
- During a draft `create_goal` is not advertised; it remains the normal
185
- execution-surface tool for an explicit user request outside drafting.
186
-
187
- The model may do minimal read-only reconnaissance before creating a goal, but
188
- should not begin substantive implementation before the goal exists. When a
189
- goal is created, the tool result includes the full final objective and the
190
- normal work tools (`write`, `read`, `bash`, `edit`) are available for
191
- execution.
192
-
193
- ## Completion behavior
194
-
195
- Completion is explicit and checked by an independent pi auditor agent. The
196
- model calls `update_goal` with the terminal outcome:
197
-
198
- ```json
199
- { "status": "complete", "completion_summary": "optional untrusted claim" }
138
+ The agent can help define the ordered steps and present them for confirmation.
139
+
140
+ ## Create a goal directly
141
+
142
+ Use `/goal-direct` when the objective already describes a complete outcome:
143
+
144
+ ```text
145
+ /goal-direct Add a health-check endpoint that verifies database connectivity, returns the service status as JSON, documents the endpoint, and includes passing tests.
200
146
  ```
201
147
 
202
- There is no paperwork field: the auditor derives the requirements from the
203
- objective and any verification contract, and inspects the actual workspace
204
- evidence (including the task tree and its evidence). An optional
205
- `completion_summary` reaches the auditor as an UNTRUSTED claim — it is never
206
- evidence and cannot make a disapproved goal complete. `update_goal` accepts
207
- `complete`, `blocked`, or `paused` (with a required `reason`).
208
-
209
- Before archiving the goal, completion starts a separate pi agent in an isolated
210
- in-memory session. The auditor receives the objective, mode, verification
211
- contract, task tree and task evidence, current usage/budget, and the workspace
212
- path with read-only-oriented tools (`read`, `grep`, `find`, `ls`, `bash`). It
213
- must end its report with exactly one marker:
214
-
215
- - `<approved/>` archives the goal as complete.
216
- - `<disapproved/>`, no marker, an error, or an abort rejects completion and
217
- leaves the goal open with the auditor feedback recorded.
218
-
219
- The auditor is semantic, not a paperwork checklist: it should reject
220
- scaffold-only, alpha, generated-template, proxy-metric, build-only, or weakly
221
- verified completions when the real user outcome is not satisfied.
222
-
223
- By default the auditor uses the current/default pi model. Configure it via
224
- `.pi/pi-goal-x-settings.json`, or interactively with `/goal-settings`.
225
-
226
- `blocked` records a distinct agent-blocked state and stops continuation. To
227
- align with Codex behavior, the tool description and continuation prompt require
228
- the same blocker to recur on three consecutive goal turns before the model
229
- reports blocked; there is no separate attempt counter. A user pause
230
- (`/goal-pause`, Esc) remains an immediate, distinct state, and the agent can
231
- pause immediately with `update_goal({status: "paused"})` plus a reason. The
232
- model cannot abort a goal — obsolete or abandoned goals are cleared by the user
233
- through `/goal-clear`.
234
-
235
- Sisyphus goals use the same lifecycle tools as regular goals; the difference is
236
- the prompt/criteria execution standard. A paused goal can also be completed
237
- directly when the agent already has enough evidence that every requirement is
238
- satisfied.
239
-
240
- ## Schema gates
241
-
242
- The shipped gates are intentionally small and mechanical.
243
-
244
- | Gate | Prevents |
245
- |---|---|
246
- | Objective bound | `create_goal` / `/goal` objectives outside 1–4000 characters |
247
- | Explicit request | The model inferring a goal from an ordinary task (prompt policy) |
248
- | Completion auditor gate | Archiving completion unless an independent pi auditor agent returns `<approved/>` |
249
- | Blocked-from-active | `update_goal(blocked)` on a non-active goal |
250
- | Task schema gates | set_goal_tasks flat-input validation (ids, parents, acyclic, ≤50, depth, lightweight placement); update_goal_task evidence/reason/status rules |
251
- | Post-stop block | Continuing to call tools after `update_goal` / `set_goal_tasks` / a user lifecycle command stops the turn |
252
- | Empty-turn guard | Pure chat loops that would keep auto-continuing without meaningful goal work |
253
- | Abort pause | Active goals staying active after user abort / Ctrl-C |
254
- | Disk reconciliation | External pause/archive/delete/status changes being ignored or overwritten by stale memory |
255
- | Post-compaction reminder | Losing the active objective after session compaction |
256
- | Budget transition | Accounted usage crossing the token budget firing more than once |
257
-
258
- ## Files
148
+ This creates and focuses the regular goal immediately.
149
+
150
+ Use `/sisyphus-direct` when the objective already contains the complete ordered process:
259
151
 
260
152
  ```text
261
- .pi/goals/active_goal_<timestamp>_<id>.md
262
- .pi/goals/archived/goal_<timestamp>_<id>.md
153
+ /sisyphus-direct Upgrade the payment integration in this order:
154
+ 1. Add support for the new API version.
155
+ 2. Update payment creation.
156
+ 3. Update refund handling.
157
+ 4. Migrate the test fixtures.
158
+ 5. Run the payment test suite.
159
+ 6. Remove the old API integration.
263
160
  ```
264
161
 
265
- Multiple `active_goal_*.md` files may exist simultaneously. This is the project-level open goal pool. The selected/focused goal is intentionally not stored in these files; focus lives in session custom state.
162
+ This creates and focuses the ordered goal immediately.
163
+
164
+ ## Manage goals
165
+
166
+ List open goals:
266
167
 
267
- Each file contains:
168
+ ```text
169
+ /goal-list
170
+ ```
268
171
 
269
- 1. extension-owned JSON metadata;
270
- 2. a user-editable `# Goal Prompt` section;
271
- 3. progress/status information.
172
+ Show the focused goal:
173
+
174
+ ```text
175
+ /goal-status
176
+ ```
272
177
 
273
- Before commands, tools, and lifecycle hooks act on a focused goal, the runtime reconciles the focused record against the active goal file on disk. External archive/delete/status changes therefore win over stale in-memory state and cannot resurrect deleted active files. Prompt-body edits are still picked up from the `# Goal Prompt` section; focus is never stored in goal markdown.
178
+ Select an open goal for the current session:
274
179
 
275
- Goal paths are constrained to `.pi/goals/` and `.pi/goals/archived/`; absolute paths, traversal, NUL bytes, symlinks, and unsafe metadata paths are rejected.
180
+ ```text
181
+ /goal-focus
182
+ ```
276
183
 
277
- ## Configuration
184
+ Remove the current session’s focus while keeping the goal open:
278
185
 
279
- All settings live in a single file: **`.pi/pi-goal-x-settings.json`**
280
-
281
- All eight persisted fields are selectable and operable through
282
- `/goal-settings`: booleans toggle directly, `provider`/`model` edit and clear,
283
- `thinkingLevel` accepts every level and rejects unknown values, and
284
- `subtaskDepth` validates the full input string (whole positive safe integers
285
- only). The file remains the durable store and env-var overrides take
286
- precedence.
287
-
288
- ```json
289
- {
290
- "disableTasks": false,
291
- "disableContracts": false,
292
- "subtaskDepth": 1,
293
- "autoSelectSingleGoal": false,
294
- "provider": "fireworks",
295
- "model": "accounts/fireworks/models/deepseek-v4-flash",
296
- "thinkingLevel": "high",
297
- "disabled": false
298
- }
186
+ ```text
187
+ /goal-unfocus
299
188
  ```
300
189
 
301
- | Field | Default | `/goal-settings` | Purpose |
302
- |---|---:|:---:|---|
303
- | `disableTasks` | `false` | Yes | Suppress task list features entirely when `true` |
304
- | `disableContracts` | `false` | Yes | Suppress verification contract enforcement when `true` |
305
- | `subtaskDepth` | `1` | Yes | Maximum nesting depth for subtasks (whole positive integers only) |
306
- | `autoSelectSingleGoal` | `false` | Yes | When `true`, auto-focus the single open goal when a session has no focus entry (default keeps goals session-scoped) |
307
- | `provider` | system default | Yes | Provider name for the auditor agent |
308
- | `model` | system default | Yes | Model name for the auditor agent |
309
- | `thinkingLevel` | system default | Yes | Thinking level: `off`, `minimal`, `low`, `medium`, `high`, `xhigh` |
310
- | `disabled` | `false` | Yes | When `true`, skips the completion audit: `update_goal({status:"complete"})` records an `audit_skipped` event and completes through the normal deferred-completion path. |
311
-
312
- **Env var overrides:**
313
- - `PI_GOAL_DISABLE_TASKS=1` — disable task features (takes precedence over file)
314
- - `PI_GOAL_DISABLE_CONTRACTS=1` — disable contract enforcement (takes precedence over file)
315
- - `PI_GOAL_SETTINGS_FILE=custom-path.json` — alternative settings file path (relative to cwd or absolute)
316
-
317
- ## Environment variables
318
-
319
- | Variable | Default | Purpose |
320
- |---|---:|---|
321
- | `PI_GOAL_AUTO_CONFIRM` | unset | When `1`, auto-confirms task-list proposals in headless/test contexts |
322
- | `PI_GOAL_DISABLE_TASKS` | — | When `1`, disable task features (overrides settings file) |
323
- | `PI_GOAL_DISABLE_CONTRACTS` | — | When `1`, disable contract enforcement (overrides settings file) |
324
- | `PI_GOAL_SETTINGS_FILE` | `.pi/pi-goal-x-settings.json` | Alternative settings file path (relative to cwd or absolute) |
325
-
326
- ## Development
190
+ Revise the focused objective and task plan:
327
191
 
328
- ```bash
329
- npm install
330
- npm test
331
- npm run check
332
- npm pack --dry-run
192
+ ```text
193
+ /goal-tweak <change>
333
194
  ```
334
195
 
335
- The unit and integration commands discover `*.test.ts` files automatically and
336
- run them in one Node process. Test-only adapters provide the small runtime SDK
337
- surface the handlers exercise, avoiding initialization of unrelated Pi model
338
- providers and TUI media modules. `npm run test:all` runs all 510 cases in one
339
- startup; `npm run test:selfcheck` asserts the discovered test entries match the
340
- pinned manifest. The fast runner requires Node 22.15 or newer (for synchronous
341
- module hooks); on older supported development environments, use `test:serial`.
342
- The suite covers records/storage,
343
- lifecycle policy, the service/runtime/accounting split, the five tool handlers,
344
- the fourteen commands, tasks/contracts, auditing, drafting, compaction,
345
- prompts, widgets, and the experiment harness.
346
- Use `npm run test:serial` as the real-SDK, process-isolated compatibility path.
347
- The handler-level
348
- integration suite (`npm run test:integration`, part of `test:all`) drives the
349
- actual registered tools with an auditor fixture; the legacy `tests/e2e/run.ts`
350
- real-model runner is manual and opt-in.
351
-
352
- The experiment harness under `experiments/` runs full pi sessions against real
353
- model calls and mechanical rubrics. C20-C26 are the release evaluation set;
354
- B1-B2 and C1-C19 have also been migrated to the five-tool interface. Experiments are
355
- opt-in because they incur model usage.
196
+ Pause or resume the focused goal:
356
197
 
357
- ```bash
358
- cd experiments
359
- bash harness/run.sh C1-vague-goal-set --count 3 --grade --no-smoke
198
+ ```text
199
+ /goal-pause
200
+ /goal-resume
201
+ ```
202
+
203
+ Archive the focused goal:
204
+
205
+ ```text
206
+ /goal-clear
207
+ ```
208
+
209
+ Cancel an unconfirmed guided draft:
210
+
211
+ ```text
212
+ /goal-cancel
213
+ ```
214
+
215
+ Open the settings menu:
216
+
217
+ ```text
218
+ /goal-settings
219
+ ```
220
+
221
+ Pressing `Esc` during active work pauses the goal.
222
+
223
+ ## Tasks and verification
224
+
225
+ The agent can divide a goal into tasks and subtasks and update them as work progresses. The current task is tracked explicitly (persisted as the goal's execution focus) and highlighted in the dashboard; starting a task with `update_goal_task(status="start")` sets it, and completing or skipping it clears it.
226
+
227
+ Verification contracts describe the evidence required for completion. They can apply to the entire goal or to an individual task.
228
+
229
+ Examples include:
230
+
231
+ ```text
232
+ Run npm test with zero failures.
233
+ ```
234
+
235
+ ```text
236
+ Confirm the new command appears in the help menu.
237
+ ```
238
+
239
+ ```text
240
+ Verify that the generated report contains every required section.
241
+ ```
242
+
243
+ ## Unified dashboard
244
+
245
+ `pi-goal-x` renders one dashboard component in two modes; the above-editor widget, `/goal-status`, and the completion flow all derive from the same presentation model, so they can never disagree about the data.
246
+
247
+ ### Compact mode
248
+
249
+ Always visible above the editor while a goal is focused:
250
+
251
+ ```text
252
+ ╭─ pi-goal-x ─ Add CSV export to reports ─────── 12m47s · 18.2K tok ─╮
253
+ │ ● In progress · Focused: yes · Other goals: 2 │
254
+ │ Tasks [██████░░░░] 3/5 · 60% │
255
+ ├─ Tasks ────────────────────────────────────────────────────────────┤
256
+ │ ✓ t1 Review reports page and data source │
257
+ │ ✓ t2 Implement filtered CSV export │
258
+ │ ▸ t3 Add the download button │
259
+ │ · t4 Add documentation │
260
+ │ … +1 more task │
261
+ │ Current t3 · Add the download button │
262
+ │ Subtasks [███████░░░] 2/3 · 67% │
263
+ │ Verify Run npm test with zero failures. │
264
+ │ File .pi/goals/active_goal_... │
265
+ ╰─ Ctrl+Shift+T: expand tasks ───────────────────────────────────────╯
266
+ ```
267
+
268
+ ### Expanded mode
269
+
270
+ `Ctrl+Shift+T` expands the same component: full task tree (✓ complete, ▸ current, ~ skipped, · pending), the current-task block with its contract and evidence, goal-level verification, and recent activity.
271
+
272
+ ```text
273
+ ├─ Progress ──────────────────────────────────────────────────────────┤
274
+ │ [██████░░░░] 3/5 tasks · 60% │
275
+ ├─ Tasks ─────────────────────────────────────────────────────────────┤
276
+ │ ✓ t1 Review reports page and data source │
277
+ │ ✓ t2 Implement filtered CSV export │
278
+ │ ▸ t3 Add the download button │
279
+ │ ✓ t3.1 Add loading state │
280
+ │ · t3.3 Add error handling │
281
+ │ · t4 Add documentation │
282
+ ├─ Current task ──────────────────────────────────────────────────────┤
283
+ │ t3 · Add the download button │
284
+ │ Subtasks [███████░░░] 2/3 · 67% │
285
+ │ Contract: The button downloads a CSV using the active filters. │
286
+ ├─ Verification ──────────────────────────────────────────────────────┤
287
+ │ Run npm test with zero failures. │
288
+ └─ Esc/Ctrl+Shift+T: collapse ────────────────────────────────────────┘
289
+ ```
290
+
291
+ Every rendered line is width-aware: the dashboard adapts to wide, medium, narrow, and very-narrow terminals and never overflows the available width. It follows a pastel theme palette with a monochrome fallback: a light steel-gray-blue outer frame (`mdLink`) with gray interior rules, pastel-amber task rows with colour-coded markers and ids (✓ complete green, ▸ current teal, ~ skipped gray, · pending amber), accent-tinted progress and brand, and status symbols in their state color.
292
+
293
+ The task list is a scrollable **window** that by default is anchored to the most recently completed task — recent completions stay visible instead of the earliest tasks. The expanded dashboard is modal and scrolls with the plain `↑/↓`, `PgUp/PgDn`, and `Home/End` keys; the compact widget keeps the editor's arrows untouched and scrolls with the free `Ctrl+Shift+↑/↓` chords (pi leaves those unbound). A new completion re-anchors the window.
294
+
295
+ See [`docs/unified-dashboard.md`](docs/unified-dashboard.md) for the full layout specification, status states, scrolling behavior, and migration behavior.
296
+
297
+ ## Completion review
298
+
299
+ When the agent reports a goal as complete, `pi-goal-x` starts an independent completion review.
300
+
301
+ The auditor examines:
302
+
303
+ * The objective
304
+ * The task plan and recorded evidence
305
+ * Verification contracts
306
+ * The current workspace
307
+
308
+ An approved goal is archived as complete, and the archive path is reported. Review feedback is added to any goal that requires further work, and the dashboard shows the changes-required result before returning to the normal view.
309
+
310
+ Press `Esc` to stop an active audit (completing without audit is recorded explicitly and never presented as independently approved).
311
+
312
+ ## Goal storage
313
+
314
+ Open goals are stored in:
315
+
316
+ ```text
317
+ .pi/goals/
360
318
  ```
361
319
 
362
- ## Package contents
320
+ Completed and cleared goals are stored in:
321
+
322
+ ```text
323
+ .pi/goals/archived/
324
+ ```
325
+
326
+ Each session can focus on one goal while the project keeps other goals open.
327
+
328
+ ## Commands
329
+
330
+ ```text
331
+ /goal [seed] Start a guided regular goal
332
+ /sisyphus [seed] Start a guided ordered goal
333
+ /goal-direct <objective> Create a regular goal immediately
334
+ /sisyphus-direct <objective> Create an ordered goal immediately
335
+ /goal-list List open goals
336
+ /goal-status Show the focused goal (unified dashboard)
337
+ /goal-status verbose Show the focused goal with full diagnostic detail
338
+ /goal-focus Select an open goal
339
+ /goal-unfocus Remove the session’s focus
340
+ /goal-tweak <change> Revise the focused goal
341
+ /goal-pause Pause the focused goal
342
+ /goal-resume Resume a paused or blocked goal
343
+ /goal-settings Open the settings menu
344
+ /goal-clear Archive the focused goal
345
+ /goal-cancel Cancel the current draft
346
+ ```
347
+
348
+ ## Configuration
363
349
 
364
- The npm package ships only the runtime extension, docs, and package metadata. The extension is split into small modules:
350
+ Settings are stored in:
365
351
 
366
352
  ```text
367
- extensions/goal.ts thin installer for renderers, commands, tools, and events
368
- extensions/goal-state.ts shared GoalCore state and service/runtime wiring
369
- extensions/goal-tools.ts tool registration composition (core + task installers)
370
- extensions/goal-core-tools.ts create_goal / get_goal / update_goal executors, and the blocked and agent-pause flows
371
- extensions/goal-completion.ts completion transaction (audit orchestration + commit)
372
- extensions/goal-task-tools.ts set_goal_tasks / update_goal_task executors, flat conversion, merge, counts
373
- extensions/goal-task-confirmation.ts task-only result boundary ({decision}) with neutral Confirm task list / Keep current tasks labels
374
- extensions/goal-commands.ts fourteen slash-command handlers
375
- extensions/goal-events.ts lifecycle event handlers
376
- extensions/goal-service.ts ordered goal mutation boundary (incl. typed updateTask transaction)
377
- extensions/goal-runtime.ts continuation, stale-checkpoint, and turn-stop state
378
- extensions/goal-accounting.ts idempotent usage accounting and budget helpers
379
- extensions/goal-format.ts result formatting and message introspection
380
- extensions/goal-record.ts goal record types, normalization, creation helpers
381
- extensions/goal-contract.ts verification-contract extraction and objective prompt-safety
382
- extensions/goal-pool.ts open-goal pool, focus resolution, list/selector text helpers
383
- extensions/goal-core.ts display helpers
384
- extensions/goal-policy.ts lifecycle, completion, task, and compaction policy
385
- extensions/goal-auditor.ts independent pi auditor agent for completion approval, config, and progress tracking
386
- extensions/goal-ledger.ts event append, read, validation, sanitization, and reconstruction (task_reopened)
387
- extensions/goal-draft.ts drafting prompt/confirmation text helpers and Sisyphus sufficiency guidance
388
- extensions/goal-drafting.ts guided drafting orchestration (durable draft sessions, questionnaire tools, propose_goal_draft)
389
- extensions/goal-questionnaire.ts structured question/answer UI used by the drafting tools and confirmation dialogs
390
- extensions/goal-tool-names.ts the five published names, fixed profiles, work/progress sets, post-stop allowlist
391
- extensions/prompts/goal-prompts.ts active, continuation, stale, unfocused, and budget prompts
392
- extensions/storage/goal-files.ts goal file paths, serialization, parsing, archive IO
393
- extensions/widgets/goal-widget.ts above-editor goal beacon component
394
- extensions/widgets/goal-notifications.ts widget-style notification text
353
+ .pi/pi-goal-x-settings.json
395
354
  ```
396
355
 
397
- ## Design principles
398
-
399
- - **User owns mutable intent**: the user controls objective changes, pause/resume, clear, focus, settings, and cancellation; the agent may create only on explicit request and may report complete, blocked, or paused (with a reason) outcomes.
400
- - **Guided creation with an explicit direct bypass**: `/goal` and `/sisyphus` always run the guided draft (clarify, propose, confirm); `/goal-direct` and `/sisyphus-direct` are the explicit no-drafting paths.
401
- - **Schema beats prompt walls**: recurring failure modes are handled by validators and tool-call interceptors.
402
- - **Visible contracts**: created goals and completion reports are printed fully into the conversation.
403
- - **Small stable target surface**: three core model tools plus two task tools; lifecycle validity belongs in handlers, not phase-specific tool rebuilding.
404
- - **Disk-backed continuity**: goal state survives context churn and can be audited from `.pi/goals/`.
405
- - **Human-owned focus**: the agent may work on the focused goal, but only user commands/UI selection switch focus.
406
-
407
- ## Hardening
408
-
409
- The 2026-08-04 hardening pass
410
- ([`specs/2026-08-04-goal-simplification-hardening`](specs/2026-08-04-goal-simplification-hardening/PRODUCT.md))
411
- is implemented and validated: persisted lifecycle status is
412
- authoritative (paused stays paused, including legacy `autoContinue: true`
413
- records), disabled-auditor completion works and records `audit_skipped`, the
414
- three/five tool profile is fixed and host tools are never touched, task
415
- operations are disk-fresh transactions with structural-clearing merge
416
- semantics, `token_budget` is a positive safe integer, reopening a task writes
417
- `task_reopened`, and ledger failures surface through an observable diagnostic.
418
-
419
- ### Runtime follow-up (current branch)
420
-
421
- The 2026-08-04 follow-up
422
- ([`specs/2026-08-04-goal-runtime-follow-up`](specs/2026-08-04-goal-runtime-follow-up/PRODUCT.md))
423
- landed the remaining work:
424
-
425
- - The settings menu is fully operable (all eight persisted fields, exact
426
- `subtaskDepth` validation, correct repeated task toggles).
427
- - `/goal-clear` asks for confirmation (cancel is a byte-for-byte no-op);
428
- task-list confirmation uses neutral labels; an aborted audit produces one
429
- canonical ledger event and continue-working leaves the goal active.
430
- - Completion commits are failure-checked transactions.
431
- - Cross-process mutations are serialized with persisted revisions and
432
- per-goal locks (typed conflicts, no blind overwrites).
433
- - **Guided drafting is restored as a first-class workflow** (a product
434
- correction reversing the interim removal): `/goal`, `/sisyphus`, and
435
- `/goal-tweak`
436
- run a transient draft with `goal_question`, `goal_questionnaire`, and
437
- `propose_goal_draft` (Confirm / Continue / Cancel); durable draft sessions
438
- survive compaction; `/goal-cancel` and `/goal-status` complete the
439
- fourteen-command palette; per-draft auditor selection persists on create
440
- and tweak; the agent can pause with a reason, abandonment stays
441
- user-owned via `/goal-clear`, and `completion_summary` is an untrusted
442
- auditor claim.
443
- - The experiment harness enforces `SUPPORTED_CASES.json`, uses the selected
444
- model in the smoke check, and runs on portable timeouts; the test runner
445
- has a self-check; the Pi SDK family is upgraded to 0.83 with both
446
- dependency audits clean.
447
-
448
- ## Relationship to pi-goal
449
-
450
- pi-goal-x started as a fork of [@capyup/pi-goal](https://github.com/capyup/pi-goal), but it is maintained as an independent project with a single `origin` remote at `github.com/tmonk/pi-goal-x`. Bug reports, feature requests, and contributions target this repository directly.
451
-
452
- ## Release policy
453
-
454
- This repository can be validated locally with tests and packaging checks. Publishing a new npm version, pushing tags, and running `pi update` are explicit release steps and are not part of ordinary implementation goals unless requested.
356
+ Use `/goal-settings` to configure task lists, verification contracts, subtask depth, automatic goal selection, and completion auditing.
455
357
 
456
358
  ## License
457
359