pi-goal-x 0.18.6 → 0.18.8

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.
package/README.md CHANGED
@@ -1,97 +1,26 @@
1
1
  # pi-goal-x
2
2
 
3
- > **Fork of [@capyup/pi-goal](https://github.com/capyup/pi-goal)** — this repository extends the upstream with quality-of-life features for the completion auditor, lifecycle reliability improvements, mid-flight objective updates, deferred archival, and drafting UX refinements. Upstream changes can be merged from the original repository.
4
-
5
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.
6
4
 
7
5
  The extension is designed around one rule: **the user owns intent; the agent executes only after the goal is explicit and confirmed**.
8
6
 
9
- ## What's different from upstream
10
-
11
- All core features of [@capyup/pi-goal](https://github.com/capyup/pi-goal) are preserved. The following changes are specific to pi-goal-x:
12
-
13
- ### Verification contract system
14
-
15
- - **Per-goal verification contracts** — when drafting a goal, include a `Verification contract:` section with plain-text requirements (e.g. "Run npm test (0 failures), grep for remaining STP references"). The contract is extracted, stored on the goal record, and enforced by the `complete_goal` tool — the call is rejected unless the agent provides a non-empty `verificationSummary` matching the contract.
16
- - **Per-task verification contracts** — `propose_task_list` supports an optional `verificationContract` per task. If set, `complete_task` requires a non-empty `verificationSummary`.
17
- - **Both prompt and tool enforcement** — prompts include a VERIFICATION CONTRACT section instructing the agent; tool validators reject calls that violate the contract.
18
- - **Backward compatible** — goals/tasks without a `Verification contract:` section work exactly as before. No contract = no enforcement.
19
- - **Auditor integration** — the independent completion auditor receives both the `verificationContract` and `verificationSummary` and cross-checks claims against real artifacts.
20
- - **`complete_goal` `testResults` removed** — replaced with `verificationSummary`. The old structured test results interface is gone.
21
-
22
- ### Unified goal + task acceptance
23
-
24
- - **Single-dialog confirmation** — `propose_goal_draft` now accepts an optional `tasks` array parameter. The confirmation dialog shows the goal objective AND the proposed task list together in a single rich TUI view with box-drawing panel (`┌─ TASKS ───┐`), section headers, and hierarchical indentation for subtasks.
25
- - **Atomic creation** — one confirmation (single enter press) creates the goal AND its task list together. No need for separate `propose_goal_draft` + `propose_task_list` calls.
26
- - **Backward compatible** — existing separate `propose_task_list` flow continues to work unchanged. Goals without tasks work as before.
27
-
28
- ### Task list & sub-task system
29
-
30
- - **Structured task breakdown** — the agent can propose a task list via `propose_task_list` (standalone) or `propose_goal_draft` with `tasks` (unified). Both show a Confirm / Continue Chatting dialog. Once confirmed, tasks are displayed in prompts, the widget, serialized to disk, and included in auditor review.
31
- - **Recursive subtasks** — tasks can have nested sub-tasks via `subtasks?: GoalTask[]` (full recursive type). Subtask depth is controlled globally by `subtaskDepth` in `.pi/pi-goal-x-settings.json` (default: 1 level). Too-deep subtrees are rejected at proposal.
32
- - **Lightweight subtasks** — each task has an optional `lightweightSubtasks?: boolean` flag. When true, the parent can complete regardless of subtask status. When false/absent (full subtasks), all subtasks must be individually complete before the parent can close.
33
- - **Per-task completion** — `complete_task` marks individual tasks done with optional evidence/verificationSummary, and `skip_task` marks tasks as skipped with a required reason. Neither stops the turn, so the agent can continue uninterrupted.
34
- - **Recursive lookup** — `findTaskInTree` and `updateTaskInTree` search and update tasks at any depth. Subtask IDs are valid targets for `complete_task` and `skip_task`.
35
- - **Subtask gate** — parent tasks with full subtasks require all sub-items to be completed or skipped before the parent can close, enforced by recursive `checkSubtasksComplete`.
36
- - **Duplicate ID validation** — `validateTaskListProposal` recursively checks all task IDs across the entire tree, preventing collisions between parent/subtask or sibling subtasks.
37
- - **Agent workflow guidance** — prompts include a `[TASK WORKFLOW]` section directing agents to use tasks as progress trackers, completing subtasks immediately when work finishes (not batch-marking at the end).
38
- - **Hierarchical display** — task lists with subtasks render with indentation in prompts (`taskListBlock`, `goalPrompt`, `continuationPrompt`) and in the TUI widget (recursive count, BFS next-pending).
39
- - **Optional `taskList`** — goals without a task list work exactly as before. The feature is entirely opt-in.
40
- - **Soft `complete_goal` gate** — when `blockCompletion: true` is set, `complete_goal` surfaces a warning if pending tasks remain (prompt-level only; the agent can still complete).
41
-
42
- ### Goal objective is immutable
43
-
44
- - The goal objective is immutable — the agent **must not** modify it autonomously. Objective changes are only possible through `propose_goal_tweak`, which presents the user with a Confirm / Continue Chatting dialog matching the `propose_goal_draft` confirmation pattern. This prevents the agent from silently changing the goal contract.
45
- - **`propose_goal_tweak`** is the sole mechanism for updating the objective, available exclusively during a `/goal-tweak` drafting flow. If the user's requirements change, they must run `/goal-tweak` to initiate the revision flow.
46
-
47
- ### Deferred archival
48
-
49
- - **No more premature archiving**: previously, `update_goal` archived the goal file inline within the tool handler before the agent could see the audit result (or skip notification). Archival is now deferred until `turn_end` — after the agent has received the audit/skip result in the conversation. The goal remains visible in the active pool through the entire completion flow.
50
- - **Cleaner lifecycle**: completed goals are archived by the `turn_end` lifecycle hook, not by the tool handler. The `accountProgress` guard skips disk reconciliation for completed goals.
51
-
52
- ### E2e test infrastructure
53
-
54
- - **Deterministic fork tests using `--mode json`**: the e2e suite spawns a real `pi --fork --mode json` session, parses structured `tool_execution_start`/`tool_execution_end` JSON events for field-level assertions — no free-text AI output parsing. Uses `--append-system-prompt` + `--tools` to force deterministic tool calls.
55
- - **Full coverage**: 310 tests total — function-level integration tests, mock-pi handler tests, file-validity checks, real `pi --fork --mode json` E2E tests, propose_goal_tweak unit/integration/e2e tests, task list policy/round-trip/render tests (including subtasks), and verification contract tests.
56
-
57
- ### Completion auditor
58
-
59
- - **Live progress widget** — when the auditor runs, the TUI shows a spinner, a progress bar (`[████░░░░] 40%`), step labels (`Inspecting files...`, `Verifying success criteria...`), the current tool being executed, and recent output lines. No more wondering if anything is happening.
60
- - **Per-goal auditor toggle** — during goal confirmation, press `a` to toggle the auditor on/off for that goal. The toggle uses a ●/○ indicator between the goal summary and confirm options. The default position comes from settings; the per-goal override persists within the session.
61
- - **Escape to skip** — press Escape during an audit to abort it and complete the goal immediately. The skip is recorded in the ledger as `audit_skipped` with reason `user_aborted` and auditor model metadata.
62
- - **Disable the auditor entirely** — set `disabled: true` in `.pi/pi-goal-x-settings.json` (or toggle it via `/goal-settings`). The agent can still bypass with user confirmation by passing `confirmBypassAuditor: true` to `complete_goal`.
63
- - **Skipped audits are recorded** — every skip (whether disabled or Escape-aborted) is logged to the ledger with the reason, provider, model, and thinking level for full traceability.
64
- - **Robust abort detection** — the auditor detects aborts both from exceptions *and* from `session.prompt()` returning after an abort signal, preventing stuck goals or ghost states.
65
- - **Cleaner lifecycle** — `AbortSignal` is properly wired to `session.abort()`, animation timers are cleaned up, and the unsubscribe path is always executed. No more having to kill the session.
66
- - **Completion report includes full auditor output** — the auditor's full report is included in the goal completion conversation message upon approval, not just a verdict.
67
- - **Session factory injection** — `runGoalCompletionAuditor` accepts an optional `createSession` parameter for testability, enabling mock auditor sessions in tests.
68
- - **Structured test evidence** — the executor can pass `testResults` (exit code, suite name, output, timestamp) via `complete_goal({testResults})`. The auditor receives a `<test_evidence>` block and is instructed to check it before re-running test suites, skipping redundant re-runs.
69
-
70
- ### Drafting & UX
71
-
72
- - **Normalized proposal-refinement language** — consistent terminology ("keep refining through normal proposal cycles") across all drafting prompts and tools.
73
- - **`PI_GOAL_AUTO_CONFIRM=0` opt-out** — explicitly set the env var to `0` to disable auto-confirm even in headless contexts (useful for benchmarking).
74
-
75
- ### Testing
76
-
77
- - **Comprehensive abort/skip coverage** — unit tests for `audit_skipped` ledger events, disabled auditor config, Esc-to-skip widget behaviour, post-prompt abort detection, and the `confirmBypassAuditor` parameter.
7
+ ## Features
78
8
 
79
- ## What it provides
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.
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 agent must provide matching evidence before `complete_goal` or `complete_task` will succeed.
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.
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`.
80
22
 
81
- - **Two goal styles**: regular goals for open-ended work, and Sisyphus goals for patient ordered execution.
82
- - **Intent-before-run flow**: `/goals` and `/sisyphus` start a discussion where the agent can clarify, research, and grill before any work begins.
83
- - **Direct set flow**: `/goals-set` and `/sisyphus-set` immediately create and start a goal from the supplied objective.
84
- - **Confirm-before-commit for discussions**: the agent must call `propose_goal_draft`; the user confirms or keeps chatting.
85
- - **Full goal visibility**: after confirmation, the final objective is printed back into the conversation in full.
86
- - **Multiple open goals**: `.pi/goals/` may hold several active goal files at once; each pi session focuses exactly one goal at a time.
87
- - **Session-local focus**: the focused goal id is stored as a branch-local session entry, not in goal markdown metadata.
88
- - **Auto-continue loop**: confirmed goals can continue across turns until completion, pause, abort, user interruption, or the empty-turn guard.
89
- - **Schema gates**: unsafe lifecycle transitions are rejected by tool validators, not just prompts.
90
- - **Sisyphus as a light variant**: Sisyphus shares the normal lifecycle/tools and differs only in prompt style and completion standard.
91
- - **Pause/resume/abort/clear lifecycle**: goals can be paused by the user, paused by the agent when blocked, resumed, completed from pause, aborted, or archived.
92
- - **Disk-backed state**: active and archived goals are stored under `.pi/goals/`.
93
- - **Lightweight built-in questionnaire tools**: `goal_question` and `goal_questionnaire` let the agent ask structured drafting questions without depending on another package.
94
- - **Above-editor status widget**: pi shows the current goal, status, progress, and active file path while work is running.
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.
95
24
 
96
25
  ## Install
97
26
 
@@ -128,7 +57,7 @@ Flow:
128
57
  3. pi shows a full plain-text confirmation report.
129
58
  4. If confirmed, the full finalized goal is printed into the conversation and written to `.pi/goals/`.
130
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`.
131
- 6. The agent works only on the focused goal until it calls `update_goal(status="complete")`, pauses, aborts, produces an empty/non-progress turn, or the user interrupts.
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.
132
61
 
133
62
  ### Sisyphus goal
134
63
 
@@ -212,7 +141,7 @@ While goal confirmation or tweak drafting is active, old goal execution is suspe
212
141
 
213
142
  ## Completion behavior
214
143
 
215
- Completion is also explicit and is checked by an independent pi auditor agent. The executor calls `update_goal` with its completion claim:
144
+ Completion is also explicit and is checked by an independent pi auditor agent. The executor calls `complete_goal` with its completion claim:
216
145
 
217
146
  ```json
218
147
  {
@@ -221,7 +150,7 @@ Completion is also explicit and is checked by an independent pi auditor agent. T
221
150
  }
222
151
  ```
223
152
 
224
- Before archiving the goal, `update_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:
153
+ 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:
225
154
 
226
155
  - `<approved/>` archives the goal as complete.
227
156
  - `<disapproved/>`, no marker, an error, or an abort rejects completion and leaves the goal open.
@@ -3309,6 +3309,7 @@ promptGuidelines: [
3309
3309
  // Per-turn flag resets (#4 + C9 fix).
3310
3310
  goalWorkToolCalledThisTurn = false;
3311
3311
  turnStoppedFor = null;
3312
+ syncGoalTools();
3312
3313
  beginAccounting();
3313
3314
  updateUI(ctx);
3314
3315
  });
@@ -3340,9 +3341,6 @@ promptGuidelines: [
3340
3341
  if (isMeaningfulProgressToolCall(event.toolName, asRecord(event)?.args)) {
3341
3342
  if (state.goal?.id) activeGetGoalTurnsByGoalId.delete(state.goal.id);
3342
3343
  goalWorkToolCalledThisTurn = true;
3343
- } else if (state.goal?.status === "active" && state.goal.autoContinue && event.toolName !== "get_goal") {
3344
- // A non-progress tool should not create an infinite retry chain.
3345
- turnStoppedFor = state.goal.id;
3346
3344
  }
3347
3345
  return;
3348
3346
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-goal-x",
3
- "version": "0.18.6",
3
+ "version": "0.18.8",
4
4
  "description": "Goal mode extension for pi: persistent long-running objectives, /goal-set drafting, Sisyphus prompt style, autoContinue, and an above-editor status overlay. Fork of @capyup/pi-goal.",
5
5
  "license": "MIT",
6
6
  "author": "pi-goal-x contributors",