pi-goal-x 0.21.0 → 0.23.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 (44) hide show
  1. package/README.md +261 -123
  2. package/docs/agent-flow-design.md +268 -398
  3. package/docs/agentic-runtime-prd.md +9 -0
  4. package/docs/architecture.md +229 -155
  5. package/docs/goal-ts-refactor-test-strategy.md +6 -0
  6. package/docs/pi-autoresearch-survey.md +5 -0
  7. package/extensions/auditor-selector.ts +72 -0
  8. package/extensions/goal-accounting.ts +92 -0
  9. package/extensions/goal-auditor.ts +44 -48
  10. package/extensions/goal-commands.ts +570 -0
  11. package/extensions/goal-compaction.ts +4 -1
  12. package/extensions/goal-completion.ts +408 -0
  13. package/extensions/goal-contract.ts +58 -0
  14. package/extensions/goal-core-tools.ts +313 -0
  15. package/extensions/goal-core.ts +3 -2
  16. package/extensions/goal-draft.ts +6 -74
  17. package/extensions/goal-drafting.ts +370 -0
  18. package/extensions/goal-events.ts +427 -0
  19. package/extensions/goal-format.ts +296 -0
  20. package/extensions/goal-ledger.ts +177 -20
  21. package/extensions/goal-policy.ts +61 -117
  22. package/extensions/goal-pool.ts +1 -1
  23. package/extensions/goal-questionnaire.ts +33 -155
  24. package/extensions/goal-record.ts +66 -10
  25. package/extensions/goal-runtime.ts +205 -0
  26. package/extensions/goal-service.ts +739 -0
  27. package/extensions/goal-settings.ts +92 -4
  28. package/extensions/goal-state.ts +945 -0
  29. package/extensions/goal-task-confirmation.ts +169 -0
  30. package/extensions/goal-task-count.ts +59 -0
  31. package/extensions/goal-task-derive.ts +46 -0
  32. package/extensions/goal-task-tools.ts +510 -0
  33. package/extensions/goal-tool-names.ts +43 -49
  34. package/extensions/goal-tools.ts +16 -0
  35. package/extensions/goal-widget.ts +418 -0
  36. package/extensions/goal.ts +22 -3744
  37. package/extensions/prompts/goal-prompts.ts +153 -185
  38. package/extensions/storage/goal-files.ts +112 -7
  39. package/extensions/storage/goal-lock.ts +124 -0
  40. package/extensions/widgets/dialog-scaffold.ts +26 -0
  41. package/extensions/widgets/goal-escape-dialog.ts +10 -10
  42. package/extensions/widgets/goal-widget.ts +140 -7
  43. package/extensions/widgets/task-list-overlay.ts +58 -39
  44. package/package.json +22 -6
package/README.md CHANGED
@@ -1,26 +1,26 @@
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, and schema-gated tools for drafting, executing, pausing, resuming, and completing work.
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.
4
4
 
5
5
  The extension is designed around one rule: **the user owns intent; the agent executes only after the goal is explicit and confirmed**.
6
6
 
7
7
  ## Features
8
8
 
9
9
  - **Two goal styles** — Regular goals for open-ended research and implementation. Sisyphus goals for patient ordered execution, one step at a time.
10
- - **Simple goal creation** — Use `/goals` to discuss and confirm a draft. Use `/goals-set` to skip discussion and start immediately.
11
- - **Full lifecycle** — Pause blocked goals, resume when unblocked, abort obsolete work, complete when done. Auto-continue keeps the agent working across turns until completion, interruption, or the empty-turn guard.
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
12
  - **Multiple open goals** — Keep several goals in `.pi/goals/`. Each session focuses one at a time; switch with `/goal-focus`.
13
13
  - **Above-editor status widget** — See the current goal, status, file path, and progress at a glance while the agent works.
14
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 agent must provide matching evidence before `complete_goal` or `complete_task` will succeed.
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
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
- - **Schema-gated tools** — Agents see only the tools relevant to the current lifecycle phase: drafting, active, paused, or tweaking. Lifecycle tools like `pause_goal`, `complete_task`, and `abort_goal` appear and disappear automatically.
18
- - **Immutable objective** — The agent cannot silently change your goal. Objective updates require a `/goal-tweak` drafting flow with explicit user confirmation.
19
- - **Built-in questionnaire tools** — During drafting, agents can ask structured questions through `goal_question` and `goal_questionnaire` without depending on external packages.
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
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** — Tune the auditor model, disable the task system or contracts, and set subtask depth through `/goal-settings` or `.pi/pi-goal-x-settings.json`.
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
22
 
23
- > **Fork of [@capyup/pi-goal](https://github.com/capyup/pi-goal)** — pi-goal-x preserves all upstream features and adds: verification contracts (per-goal and per-task), unified goal+task acceptance in a single confirmation dialog, recursive task lists with subtasks, an immutable objective enforced by tools, deferred archival with cleaner lifecycle hooks, an improved completion auditor with configurable model and progress widget, drafting UX refinements, and lifecycle reliability fixes.
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.
24
24
 
25
25
  ## Install
26
26
 
@@ -47,17 +47,21 @@ pi -e .
47
47
  ### Regular goal
48
48
 
49
49
  ```text
50
- /goals add structured logging to the auth module
50
+ /goal add structured logging to the auth module
51
51
  ```
52
52
 
53
53
  Flow:
54
54
 
55
- 1. The agent clarifies, researches, or grills only when the goal contract needs it.
56
- 2. The agent calls `propose_goal_draft` with a concrete objective once the contract is clear.
57
- 3. pi shows a full plain-text confirmation report.
58
- 4. If confirmed, the full finalized goal is printed into the conversation and written to `.pi/goals/`.
59
- 5. The new goal becomes this session's focus. Existing open goals remain in `.pi/goals/` and can be selected later with `/goal-focus`.
60
- 6. The agent works only on the focused goal until it calls `complete_goal`, pauses, aborts, produces an empty/non-progress turn, or the user interrupts.
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.
61
65
 
62
66
  ### Sisyphus goal
63
67
 
@@ -67,34 +71,64 @@ Flow:
67
71
 
68
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.
69
73
 
70
- If the objective is already final and should start immediately, use:
71
-
72
- ```text
73
- /goals-set add structured logging to the auth module
74
- /sisyphus-set Refactor auth flow exactly as ordered: 1) extract token validation. 2) wire it into login. 3) update tests.
75
- ```
74
+ If the objective is already final, use `/goal-direct <objective>` or
75
+ `/sisyphus-direct <objective>` to create it immediately without drafting.
76
76
 
77
77
  ## User commands
78
78
 
79
+ The curated fourteen-command palette (each lifecycle action is independently
80
+ registered so tab completion is self-explanatory):
81
+
79
82
  ```text
80
- /goals <topic> Discuss/research/grill a regular goal, then confirm a draft
81
- /sisyphus <topic> Discuss/grill a Sisyphus-style goal, then confirm a draft
82
- /goals-set <objective> Immediately create and start a regular goal
83
- /sisyphus-set <objective> Immediately create and start a Sisyphus-style goal
84
- /goal-status Show focused goal state
85
- /goal-list List all open goals in .pi/goals/
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)
86
89
  /goal-focus Choose this session's focused goal
87
90
  /goal-unfocus Stop this session's goal work without modifying the shared goal
88
- /goal-tweak <change> Draft a revision to the focused active/paused goal
91
+ /goal-tweak <change> Guide a confirmed refinement of the focused objective and task plan
89
92
  /goal-pause Pause the focused active goal
90
- /goal-resume Resume a paused goal
93
+ /goal-resume Resume a paused or blocked goal
91
94
  /goal-settings Configure pi-goal settings, including auditor model settings
92
- /goal-abort Abort/archive the focused goal or cancel drafting
93
- /goal-clear Archive the focused goal or cancel drafting
95
+ /goal-clear Archive the focused goal after confirmation
96
+ /goal-cancel Cancel the in-progress guided draft without creating a goal
94
97
  ```
95
98
 
96
99
  Pressing `Esc` or aborting an active run pauses the goal so it does not remain falsely active.
97
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
+
98
132
  ## Multiple open goals and focus
99
133
 
100
134
  `pi-goal` separates durable goals from session focus:
@@ -105,69 +139,103 @@ Pressing `Esc` or aborting an active run pauses the goal so it does not remain f
105
139
  - **Branch-local focus**: because focus is reconstructed from the current session branch, `/tree` navigation can restore a different focus for a different branch.
106
140
  - **One continuation chain**: auto-continue only schedules work for the focused goal in the current session.
107
141
 
108
- Creating a goal with `/goals`, `/sisyphus`, `/goals-set`, or `/sisyphus-set` no longer 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-abort`, `/goal-pause`, and `/goal-tweak` ask the user to choose a goal instead of acting on all of them.
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.
109
143
 
110
144
  ## Agent tools
111
145
 
112
- The extension exposes tools only when they make sense for the current lifecycle phase.
113
-
114
- | Tool | Visible when | Purpose |
115
- |---|---|---|
116
- | `goal_question` | drafting / tweak drafting | Ask one focused user question |
117
- | `goal_questionnaire` | drafting / tweak drafting | Ask multiple structured questions |
118
- | `get_goal` | always | Read the focused goal state; mentions other open goals when present |
119
- | `propose_goal_draft` | drafting only (goal creation) | Submit a concrete draft for user confirmation |
120
- | `propose_goal_tweak` | tweak drafting only | Submit a revision to an existing goal (shows Confirm / Continue Chatting dialog) |
121
- | `complete_goal` | focused active or paused goal | Mark the focused goal complete — supply a `verificationSummary` covering all contract items. When the auditor is disabled, supply `confirmBypassAuditor: true` after user confirmation to bypass the audit |
122
- | `pause_goal` | focused active goal | Pause the focused goal because of a real blocker |
123
- | `abort_goal` | focused active or paused goal | Abort/archive an obsolete, impossible, unsafe, or user-cancelled focused goal |
124
- | `propose_task_list` | active or paused goal | Propose a structured task list for user confirmation (stops the turn) |
125
- | `complete_task` | active or paused goal | Mark a task complete with optional `verificationSummary`. If the task has a `verificationContract`, the summary is required (does not stop turn) |
126
- | `skip_task` | active or paused goal | Mark a task skipped with a required reason (does not stop turn) |
127
- | `propose_goal_tweak` | tweak drafting only | Submit a revision to the focused goal (shows Confirm / Continue Chatting dialog) |
128
- | `step_complete` | hidden / legacy | Compatibility no-op; Sisyphus no longer requires a step counter |
129
- | `create_goal` | hidden | Direct calls are rejected; normal creation goes through `propose_goal_draft` |
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.
130
152
 
131
- ## Drafting behavior
132
-
133
- `/goals` and `/sisyphus` start a lightweight intent discussion, not a heavy runtime sub-state. The agent clarifies, researches, and grills only when needed, may proceed directly for fully specified requests, and then calls `propose_goal_draft` to show the user a Confirm / Continue Chatting dialog. `goal_question` and `goal_questionnaire` are available when structured input helps, but plain conversation is acceptable.
134
-
135
- `/goals-set` and `/sisyphus-set` skip the discussion and confirmation dialog. They directly create and focus an active goal from the supplied objective so execution can begin immediately.
136
-
137
- The agent may do minimal read-only reconnaissance when it directly improves the goal contract, but should not begin substantive implementation before confirmation. The strict runtime starts after the user confirms the draft and an active goal is created.
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). |
138
160
 
139
- When a draft is proposed, the confirmation UI shows a full plain-text report with draft details, the original topic, and the proposed goal. If the confirmation UI throws in interactive mode, creation fails closed and confirmation remains active; it never auto-creates a goal. When a draft is confirmed, the tool result includes the full final objective, not a one-line summary, and normal work tools (`write`, `read`, `bash`, `edit`) are available for execution. This makes the confirmed contract visible in the conversation as well as on disk.
161
+ During a user-started draft, these replace the execution tools:
140
162
 
141
- While goal confirmation or tweak drafting is active, old goal execution is suspended: active-goal prompts, accounting, and auto-continue checkpoints do not run for the previously focused goal.
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.
142
192
 
143
193
  ## Completion behavior
144
194
 
145
- Completion is also explicit and is checked by an independent pi auditor agent. The executor calls `complete_goal` with its completion claim:
195
+ Completion is explicit and checked by an independent pi auditor agent. The
196
+ model calls `update_goal` with the terminal outcome:
146
197
 
147
198
  ```json
148
- {
149
- "status": "complete",
150
- "completionSummary": "What was completed and what evidence proves it."
151
- }
199
+ { "status": "complete", "completion_summary": "optional untrusted claim" }
152
200
  ```
153
201
 
154
- Before archiving the goal, `complete_goal` starts a separate pi agent in an isolated in-memory session. The auditor receives the objective, the executor's completion claim, and current goal metadata, then can inspect the workspace with read-only-oriented tools (`read`, `grep`, `find`, `ls`, and `bash`). It must end its report with exactly one marker:
155
-
156
- - `<approved/>` archives the goal as complete.
157
- - `<disapproved/>`, no marker, an error, or an abort rejects completion and leaves the goal open.
158
-
159
- The auditor is semantic, not a paperwork checklist: it should reject scaffold-only, alpha, generated-template, proxy-metric, build-only, or weakly verified completions when the real user outcome is not satisfied.
160
-
161
- By default the auditor uses the current/default pi model. Configure it via `.pi/pi-goal-x-settings.json`, or interactively with `/goal-settings` (see [Configuration](#configuration)).
162
-
163
- The completion result prints a full report into the conversation:
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`).
164
208
 
165
- - `Goal complete.`
166
- - optional completion summary / evidence supplied by the executor
167
- - the auditor's approval report
168
- - full current goal details, including objective, status, usage, mode, and file path
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:
169
214
 
170
- Sisyphus goals use the same completion tool as regular goals. The stricter part is the prompt/criteria standard: the agent should only call completion after the whole ordered objective is actually satisfied and likely to survive independent auditing. A paused goal can also be completed directly when the agent already has enough evidence that every requirement is satisfied; it does not need a resume just to call `complete_goal`.
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.
171
239
 
172
240
  ## Schema gates
173
241
 
@@ -175,17 +243,17 @@ The shipped gates are intentionally small and mechanical.
175
243
 
176
244
  | Gate | Prevents |
177
245
  |---|---|
178
- | Focus consistency | `/goals` accidentally becoming Sisyphus, or `/sisyphus` becoming regular mode |
179
- | Confirm-before-commit | The agent silently creating or replacing a discussion-based goal |
180
- | Direct set intent | `/goals-set` and `/sisyphus-set` are explicit user shortcuts that bypass draft confirmation |
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) |
181
248
  | Completion auditor gate | Archiving completion unless an independent pi auditor agent returns `<approved/>` |
182
- | Abort gate | Aborting missing, stale, completed, or reasonless goals |
183
- | Direct-create rejection | Hidden `create_goal` calls creating goals without the confirmation flow |
184
- | Post-stop block | Continuing to call tools after `pause_goal`, `abort_goal`, `complete_goal`, or `propose_goal_tweak` stops the turn |
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 |
185
252
  | Empty-turn guard | Pure chat loops that would keep auto-continuing without meaningful goal work |
186
253
  | Abort pause | Active goals staying active after user abort / Ctrl-C |
187
254
  | Disk reconciliation | External pause/archive/delete/status changes being ignored or overwritten by stale memory |
188
255
  | Post-compaction reminder | Losing the active objective after session compaction |
256
+ | Budget transition | Accounted usage crossing the token budget firing more than once |
189
257
 
190
258
  ## Files
191
259
 
@@ -210,7 +278,12 @@ Goal paths are constrained to `.pi/goals/` and `.pi/goals/archived/`; absolute p
210
278
 
211
279
  All settings live in a single file: **`.pi/pi-goal-x-settings.json`**
212
280
 
213
- Configured interactively via `/goal-settings`, or edited directly:
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.
214
287
 
215
288
  ```json
216
289
  {
@@ -225,16 +298,16 @@ Configured interactively via `/goal-settings`, or edited directly:
225
298
  }
226
299
  ```
227
300
 
228
- | Field | Default | Purpose |
229
- |---|---:|---|
230
- | `disableTasks` | `false` | Suppress task list features entirely when `true` |
231
- | `disableContracts` | `false` | Suppress verification contract enforcement when `true` |
232
- | `subtaskDepth` | `1` | Maximum nesting depth for subtasks |
233
- | `autoSelectSingleGoal` | `false` | When `true`, auto-focus the single open goal when a session has no focus entry (default keeps goals session-scoped) |
234
- | `provider` | system default | Provider name for the auditor agent |
235
- | `model` | system default | Model name for the auditor agent |
236
- | `thinkingLevel` | system default | Thinking level: `off`, `minimal`, `low`, `medium`, `high`, `xhigh` |
237
- | `disabled` | `false` | When `true`, skip the completion audit entirely |
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. |
238
311
 
239
312
  **Env var overrides:**
240
313
  - `PI_GOAL_DISABLE_TASKS=1` — disable task features (takes precedence over file)
@@ -245,7 +318,7 @@ Configured interactively via `/goal-settings`, or edited directly:
245
318
 
246
319
  | Variable | Default | Purpose |
247
320
  |---|---:|---|
248
- | `PI_GOAL_AUTO_CONFIRM` | unset | When `1`, auto-confirms drafts in headless/test contexts |
321
+ | `PI_GOAL_AUTO_CONFIRM` | unset | When `1`, auto-confirms task-list proposals in headless/test contexts |
249
322
  | `PI_GOAL_DISABLE_TASKS` | — | When `1`, disable task features (overrides settings file) |
250
323
  | `PI_GOAL_DISABLE_CONTRACTS` | — | When `1`, disable contract enforcement (overrides settings file) |
251
324
  | `PI_GOAL_SETTINGS_FILE` | `.pi/pi-goal-x-settings.json` | Alternative settings file path (relative to cwd or absolute) |
@@ -259,9 +332,27 @@ npm run check
259
332
  npm pack --dry-run
260
333
  ```
261
334
 
262
- The fast unit suite uses Node's built-in test runner and covers core parsing, drafting gates, lifecycle policy, abort policy, questionnaire formatting, centralized tool names, Sisyphus prompt-style behavior, completion reporting, and display helpers.
263
-
264
- The experiment harness under `experiments/` runs full pi sessions against real model calls and mechanical rubrics.
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.
265
356
 
266
357
  ```bash
267
358
  cd experiments
@@ -273,17 +364,31 @@ bash harness/run.sh C1-vague-goal-set --count 3 --grade --no-smoke
273
364
  The npm package ships only the runtime extension, docs, and package metadata. The extension is split into small modules:
274
365
 
275
366
  ```text
276
- extensions/goal.ts orchestration, commands, tools, events, timers
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
277
380
  extensions/goal-record.ts goal record types, normalization, creation helpers
381
+ extensions/goal-contract.ts verification-contract extraction and objective prompt-safety
278
382
  extensions/goal-pool.ts open-goal pool, focus resolution, list/selector text helpers
279
383
  extensions/goal-core.ts display helpers
280
- extensions/goal-draft.ts lightweight confirmation prompt, proposal validation, drafting tool gate
281
- extensions/goal-policy.ts lifecycle, pause/resume/complete, and Sisyphus policy
384
+ extensions/goal-policy.ts lifecycle, completion, task, and compaction policy
282
385
  extensions/goal-auditor.ts independent pi auditor agent for completion approval, config, and progress tracking
283
- extensions/goal-ledger.ts event append, read, validation, sanitization, and reconstruction
284
- extensions/goal-questionnaire.ts built-in question UI and question tool registration
285
- extensions/goal-tool-names.ts centralized published tool names and allowlists
286
- extensions/prompts/goal-prompts.ts active, continuation, tweak, and stale prompts
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
287
392
  extensions/storage/goal-files.ts goal file paths, serialization, parsing, archive IO
288
393
  extensions/widgets/goal-widget.ts above-editor goal beacon component
289
394
  extensions/widgets/goal-notifications.ts widget-style notification text
@@ -291,25 +396,58 @@ extensions/widgets/goal-notifications.ts widget-style notification text
291
396
 
292
397
  ## Design principles
293
398
 
294
- - **User owns intent**: only the user starts, replaces, resumes, clears, or confirms goals; the agent may only pause, complete, or abort through schema-gated lifecycle tools with evidence/reason.
295
- - **One commit path**: normal goal creation goes through drafting and confirmation.
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.
296
401
  - **Schema beats prompt walls**: recurring failure modes are handled by validators and tool-call interceptors.
297
- - **Visible contracts**: confirmed goals and completion reports are printed fully into the conversation.
298
- - **Lifecycle-shaped tool surface**: the agent sees only tools appropriate to the current phase.
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.
299
404
  - **Disk-backed continuity**: goal state survives context churn and can be audited from `.pi/goals/`.
300
405
  - **Human-owned focus**: the agent may work on the focused goal, but only user commands/UI selection switch focus.
301
406
 
302
- ## Upstream
303
-
304
- This repository is a downstream fork of [@capyup/pi-goal](https://github.com/capyup/pi-goal). To sync with upstream changes:
305
-
306
- ```bash
307
- git fetch upstream
308
- git merge upstream/main
309
- # resolve conflicts, test, commit
310
- ```
311
-
312
- The `upstream` remote should point to `https://github.com/capyup/pi-goal.git`.
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.
313
451
 
314
452
  ## Release policy
315
453