pi-goal-x 0.6.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.
- package/LICENSE +21 -0
- package/README.md +307 -0
- package/docs/agent-flow-design.md +432 -0
- package/docs/agentic-runtime-prd.md +764 -0
- package/docs/architecture.md +239 -0
- package/docs/goal-ts-refactor-test-strategy.md +82 -0
- package/docs/pi-autoresearch-survey.md +45 -0
- package/extensions/goal-auditor.ts +341 -0
- package/extensions/goal-compaction.ts +124 -0
- package/extensions/goal-core.ts +77 -0
- package/extensions/goal-draft.ts +148 -0
- package/extensions/goal-ledger.ts +319 -0
- package/extensions/goal-policy.ts +152 -0
- package/extensions/goal-pool.ts +94 -0
- package/extensions/goal-questionnaire.ts +533 -0
- package/extensions/goal-record.ts +171 -0
- package/extensions/goal-tool-names.ts +69 -0
- package/extensions/goal.ts +2610 -0
- package/extensions/prompts/goal-prompts.ts +166 -0
- package/extensions/storage/goal-files.ts +267 -0
- package/extensions/widgets/goal-notifications.ts +9 -0
- package/extensions/widgets/goal-widget.ts +219 -0
- package/package.json +57 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# pi-goal Architecture
|
|
2
|
+
|
|
3
|
+
This document describes the shipped `pi-goal` extension as it exists now. It focuses on implemented behavior.
|
|
4
|
+
|
|
5
|
+
## Runtime shape
|
|
6
|
+
|
|
7
|
+
`extensions/goal.ts` is the orchestration layer. It owns pi integration points:
|
|
8
|
+
|
|
9
|
+
- slash commands;
|
|
10
|
+
- tool registration;
|
|
11
|
+
- session events;
|
|
12
|
+
- auto-continue timers;
|
|
13
|
+
- usage accounting;
|
|
14
|
+
- coordination with extracted prompt, storage, policy, questionnaire, goal-pool, and widget modules.
|
|
15
|
+
|
|
16
|
+
The runtime is a focused-goal view over a project goal pool:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
let goalsById: Map<string, GoalRecord>;
|
|
20
|
+
let focusedGoalId: string | null;
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`goalsById` is reconstructed from `.pi/goals/active_goal_*.md` plus compatible legacy session entries. `focusedGoalId` is reconstructed from branch-local `pi-goal-focus` session entries. The focused id is not serialized into goal markdown.
|
|
24
|
+
|
|
25
|
+
Reusable logic is split into smaller modules:
|
|
26
|
+
|
|
27
|
+
| Module | Responsibility |
|
|
28
|
+
|---|---|
|
|
29
|
+
| `goal-record.ts` | Goal record types, creation, cloning, usage normalization, persisted-record migration |
|
|
30
|
+
| `goal-pool.ts` | Open-goal pool helpers, focus resolution, list output, selector labels, unfocused summaries |
|
|
31
|
+
| `goal-core.ts` | Compact display formatting, status labels, objective title cleanup |
|
|
32
|
+
| `goal-draft.ts` | Lightweight confirmation prompt, plain-text draft confirmation report, proposal validation, drafting-stage tool gate |
|
|
33
|
+
| `goal-policy.ts` | Lifecycle policy, abort/pause/resume/complete validation, compaction policy, full result reports |
|
|
34
|
+
| `goal-auditor.ts` | Independent pi auditor agent prompt/config/decision parsing and completion audit execution |
|
|
35
|
+
| `goal-questionnaire.ts` | Built-in questionnaire types, normalization, answer formatting, TUI question runner, proposal confirmation dialog, question-tool registration |
|
|
36
|
+
| `goal-tool-names.ts` | Published tool-name constants, active-tool lists, post-stop allowlist, goal work-tool list, question-like tool detection |
|
|
37
|
+
| `prompts/goal-prompts.ts` | Active-goal, continuation, tweak-drafting, and stale-checkpoint prompt builders |
|
|
38
|
+
| `storage/goal-files.ts` | Goal path safety, serialization/parsing, active-file scanning, active-file writes, archive writes, prompt-body merge from disk |
|
|
39
|
+
| `widgets/goal-widget.ts` | Above-editor Goal Beacon component, blocker/status rendering, `+N open` and unfocused rendering |
|
|
40
|
+
| `widgets/goal-notifications.ts` | Widget-style notification text for goal lifecycle toasts |
|
|
41
|
+
|
|
42
|
+
## Lifecycle
|
|
43
|
+
|
|
44
|
+
```text
|
|
45
|
+
/user command
|
|
46
|
+
├─ /goals or /sisyphus
|
|
47
|
+
│ └─ confirmationIntent = {focus, originalTopic, startedAt}
|
|
48
|
+
│ ├─ agent clarifies, researches, or grills only when needed
|
|
49
|
+
│ ├─ targeted reconnaissance is prompt-guided, not hard-blocked
|
|
50
|
+
│ └─ propose_goal_draft validates focus/objective and asks user to confirm
|
|
51
|
+
│ ├─ Continue Chatting: keep clarifying without creating a goal
|
|
52
|
+
│ └─ Confirm: create active goal, write .pi/goals file, focus it, print full objective
|
|
53
|
+
│
|
|
54
|
+
├─ /goals-set or /sisyphus-set
|
|
55
|
+
│ └─ direct user command creates active goal, writes .pi/goals file, focuses it, and starts execution
|
|
56
|
+
│
|
|
57
|
+
├─ focused active goal
|
|
58
|
+
│ ├─ autoContinue queues checkpoint turns
|
|
59
|
+
│ ├─ pause_goal pauses on real blockers
|
|
60
|
+
│ ├─ abort_goal aborts/archives obsolete or impossible goals
|
|
61
|
+
│ └─ update_goal starts independent auditor; <approved/> archives and prints full completion report
|
|
62
|
+
│
|
|
63
|
+
├─ paused goal
|
|
64
|
+
│ ├─ /goal-resume restarts autoContinue
|
|
65
|
+
│ ├─ update_goal can complete from existing evidence
|
|
66
|
+
│ └─ abort_goal can archive without resuming
|
|
67
|
+
│
|
|
68
|
+
├─ multiple open goals
|
|
69
|
+
│ ├─ /goal-list shows the project goal pool
|
|
70
|
+
│ ├─ /goal-focus chooses the session focus
|
|
71
|
+
│ └─ unfocused sessions guide the user to choose instead of letting the agent decide
|
|
72
|
+
│
|
|
73
|
+
└─ /goal-clear or /goal-abort archives the focused goal or cancels drafting
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Goal pool and session focus
|
|
77
|
+
|
|
78
|
+
The disk layout already supports multiple active files. The extension now treats those files as the durable project-level open goal pool:
|
|
79
|
+
|
|
80
|
+
```text
|
|
81
|
+
.pi/goals/active_goal_<timestamp>_<id>.md
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`readActiveGoalPool(ctx)` scans that directory, ignores invalid files and symlinks, parses each safe active file, sanitizes metadata paths, drops completed records, and returns a deterministic `Map<goalId, GoalRecord>`.
|
|
85
|
+
|
|
86
|
+
Session focus is separate. Focus changes append a custom session entry:
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
{
|
|
90
|
+
version: 1,
|
|
91
|
+
focusedGoalId: string | null,
|
|
92
|
+
reason: "created" | "selected" | "resumed" | "completed" | "cleared" | "aborted" | "migrated"
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Because this is stored with `pi.appendEntry("pi-goal-focus", ...)`, it is session/branch-local and is not sent to the LLM. On `session_start` and `session_tree`, `loadState(ctx)` scans `ctx.sessionManager.getBranch()` for the latest focus entry, scans active goal files, and resolves focus as follows:
|
|
97
|
+
|
|
98
|
+
1. Use a valid focused id from the latest focus entry.
|
|
99
|
+
2. If the latest focus entry explicitly has `focusedGoalId: null`, or points at a missing/stale goal, remain unfocused.
|
|
100
|
+
3. If no focus entry exists, merge a compatible legacy `pi-goal-state { version: 3, goal }` goal and focus it. If disk already has the same id, the disk record wins and the legacy session record only supplies focus.
|
|
101
|
+
4. If no focus entry exists and exactly one open goal exists, auto-focus it for compatibility.
|
|
102
|
+
5. If multiple open goals exist and no valid focus exists, remain unfocused until `/goal-focus`, `/goal-resume`, `/goal-clear`, `/goal-abort`, `/goal-pause`, or `/goal-tweak` asks the user to choose.
|
|
103
|
+
|
|
104
|
+
Focus is human-owned. No agent tool can switch focus. Lifecycle tools operate only on the focused goal.
|
|
105
|
+
|
|
106
|
+
## Goal styles
|
|
107
|
+
|
|
108
|
+
### Regular goal
|
|
109
|
+
|
|
110
|
+
Regular goals are open-ended objectives. The agent decides the next concrete action each checkpoint turn, then completes only after the objective is actually satisfied.
|
|
111
|
+
|
|
112
|
+
### Sisyphus goal
|
|
113
|
+
|
|
114
|
+
Sisyphus is a light variant of the same goal lifecycle. It does not have a separate execution state machine or step counter. The only differences are prompt/criteria level:
|
|
115
|
+
|
|
116
|
+
- drafting asks for a patient ordered-execution style when relevant;
|
|
117
|
+
- continuations remind the agent not to rush, skip, or invent preflight steps;
|
|
118
|
+
- completion still uses `update_goal(status="complete")`, with the stricter expectation that the whole ordered objective is actually satisfied.
|
|
119
|
+
|
|
120
|
+
The legacy `step_complete` tool remains registered as a hidden compatibility no-op for old transcripts, but it is not exposed as an active work tool and is not required for completion.
|
|
121
|
+
|
|
122
|
+
## Drafting and confirmation
|
|
123
|
+
|
|
124
|
+
Drafting is now a lightweight user-intent confirmation conversation. For `/goals` and `/sisyphus`, the runtime stores only a thin session-local `confirmationIntent` with the requested focus, original topic, and start time. The agent may ask a focused question when the topic is vague, perform targeted read-only research when it improves the goal contract, grill assumptions or ordered steps, or proceed directly to `propose_goal_draft` when the request is already concrete.
|
|
125
|
+
|
|
126
|
+
`propose_goal_draft` enforces:
|
|
127
|
+
|
|
128
|
+
- a confirmation intent must be active;
|
|
129
|
+
- objective must be non-empty;
|
|
130
|
+
- `sisyphus` must match the command the user invoked.
|
|
131
|
+
|
|
132
|
+
A deprecated optional `draftId` parameter is accepted for compatibility but ignored; normal goal confirmation no longer depends on hidden prompt identity. Confirming a draft creates a new active goal and focuses it, leaving other active files untouched. Confirmation UI errors fail closed: the goal is not created and confirmation remains active. After confirmation, normal work tools are available for execution immediately.
|
|
133
|
+
|
|
134
|
+
## Command focus behavior
|
|
135
|
+
|
|
136
|
+
- `/goals` and `/sisyphus` start discussion-based confirmation before creating a new focused goal.
|
|
137
|
+
- `/goals-set` and `/sisyphus-set` directly create and focus a new open goal from the supplied objective.
|
|
138
|
+
- `/goal-list` prints all open goals with id, status, mode, usage, objective title, path, and a focus marker.
|
|
139
|
+
- `/goal-focus` uses `ctx.ui.select` when multiple goals are open and updates only session focus.
|
|
140
|
+
- `/goal-status` and `/goal` show the focused goal plus an `other open goals` hint.
|
|
141
|
+
- `/goal-resume` resumes the focused paused goal; when unfocused with multiple open goals, it asks the user to choose. Choosing an already active goal only focuses it.
|
|
142
|
+
- `/goal-clear` and `/goal-abort` archive only the focused/selected goal and never clear the whole pool at once.
|
|
143
|
+
- During goal confirmation, `/goal-clear` and `/goal-abort` only cancel the confirmation flow; they do not archive an unrelated focused goal unless the user invokes a lifecycle command after confirmation is cancelled.
|
|
144
|
+
- `/goal-tweak` revises only the focused active or paused goal; when unfocused with open goals, it asks the user to choose one.
|
|
145
|
+
- `/goal-pause` also asks the user to choose when the session is unfocused and open goals exist.
|
|
146
|
+
- `/goal-settings` opens extension settings. The current settings screen contains `auditor`, where provider/model/thinking_level are edited via free-text inputs.
|
|
147
|
+
|
|
148
|
+
When `propose_goal_draft` asks for confirmation, the UI shows a full plain-text draft report rather than a Markdown preview. On confirmation, the result prints the full finalized objective in the conversation. The same objective is also written to the active goal file.
|
|
149
|
+
|
|
150
|
+
## Tool visibility
|
|
151
|
+
|
|
152
|
+
Tool visibility is recomputed whenever state changes. Built-in work tools remain registered in the base prompt so they can be used after a confirmed draft; lifecycle-specific gates decide whether a call is allowed.
|
|
153
|
+
|
|
154
|
+
- Goal confirmation keeps `propose_goal_draft` stable and exposes `goal_question`, `goal_questionnaire`, and `get_goal` when structured clarification helps; workhorse tools are prompt-guided rather than hidden by a hard whitelist.
|
|
155
|
+
- Tweak drafting exposes question tools, `get_goal`, and `apply_goal_tweak`.
|
|
156
|
+
- Active goals expose `get_goal`, `update_goal`, `pause_goal`, and `abort_goal`.
|
|
157
|
+
- Paused goals expose `get_goal`, `update_goal`, and `abort_goal`, so the agent can complete or abandon a paused goal without resuming substantive work.
|
|
158
|
+
- Unfocused sessions with open goals expose no lifecycle mutation tools; prompts and status guide the user to `/goal-focus`.
|
|
159
|
+
- `step_complete` is hidden legacy compatibility.
|
|
160
|
+
- `create_goal` remains hidden and direct calls are rejected; normal creation goes through `propose_goal_draft`.
|
|
161
|
+
|
|
162
|
+
The `tool_call` interceptor blocks:
|
|
163
|
+
|
|
164
|
+
- non-`get_goal` tools after a stop tool has fired in the same turn.
|
|
165
|
+
|
|
166
|
+
## Disk format
|
|
167
|
+
|
|
168
|
+
Active and archived goal files live under `.pi/goals/`. Multiple active files may exist simultaneously.
|
|
169
|
+
|
|
170
|
+
```text
|
|
171
|
+
.pi/goals/active_goal_<timestamp>_<id>.md
|
|
172
|
+
.pi/goals/archived/goal_<timestamp>_<id>.md
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Each file has extension-owned metadata and a user-editable `# Goal Prompt` section. Before focused commands, tools, and lifecycle hooks act, the runtime re-reads the focused active file and reconciles lifecycle state from disk. External pause/archive/delete/status changes therefore win over stale memory and deleted active files are not resurrected. Prompt-body edits are still picked up from `# Goal Prompt`; session focus is never written to these files.
|
|
176
|
+
|
|
177
|
+
Path safety checks reject absolute paths, traversal, NUL bytes, symlinks, and paths outside the goal directories.
|
|
178
|
+
|
|
179
|
+
## Auto-continue and stop conditions
|
|
180
|
+
|
|
181
|
+
When `autoContinue` is on, the extension queues continuation prompts after agent turns for the focused goal only. The loop stops or pauses when:
|
|
182
|
+
|
|
183
|
+
- the agent calls `update_goal(status="complete")`;
|
|
184
|
+
- the agent calls `pause_goal`;
|
|
185
|
+
- the agent calls `abort_goal`;
|
|
186
|
+
- the user invokes `/goal-pause`, `/goal-clear`, or `/goal-abort`;
|
|
187
|
+
- the user aborts the turn;
|
|
188
|
+
- a turn ends without meaningful goal-work tool activity.
|
|
189
|
+
|
|
190
|
+
Continuation prompts include a goal id so stale prompts can be detected and neutralized. If focus changes or the goal is archived before a queued checkpoint runs, the checkpoint becomes stale and cannot drive task work.
|
|
191
|
+
|
|
192
|
+
`get_goal`, question tools, and draft proposal tools are not meaningful progress for the empty-turn gate. Only lifecycle mutations and actual workhorse tools mark a turn as goal work for continuation purposes.
|
|
193
|
+
|
|
194
|
+
## Completion output
|
|
195
|
+
|
|
196
|
+
Completion is intentionally verbose in the tool result and guarded by an independent auditor agent. `update_goal(status="complete")` is valid for active and paused goals; paused goals do not need to be resumed just to record completion when existing evidence is sufficient.
|
|
197
|
+
|
|
198
|
+
Before archiving, the tool starts a separate in-memory pi session with a focused auditor prompt. The auditor receives the objective, executor completion summary, and goal metadata, can inspect the workspace with `read`, `grep`, `find`, `ls`, and `bash`, and must end with exactly one marker:
|
|
199
|
+
|
|
200
|
+
- `<approved/>` allows archiving;
|
|
201
|
+
- `<disapproved/>`, no marker, an error, or abort rejects completion and leaves the goal open.
|
|
202
|
+
|
|
203
|
+
The auditor uses the current/default model unless `.pi/goal-auditor.json` or `PI_GOAL_AUDITOR_PROVIDER`, `PI_GOAL_AUDITOR_MODEL`, and `PI_GOAL_AUDITOR_THINKING_LEVEL` override provider/model/thinking. `/goal-settings` opens a small UI menu with an `auditor` item; inside it, `provider`, `model`, and `thinking_level` each open a free-text input and save back to `.pi/goal-auditor.json`.
|
|
204
|
+
|
|
205
|
+
The user sees:
|
|
206
|
+
|
|
207
|
+
- a `Goal complete.` header;
|
|
208
|
+
- the executor's optional completion summary/evidence;
|
|
209
|
+
- the auditor's approval report;
|
|
210
|
+
- the full current goal details.
|
|
211
|
+
|
|
212
|
+
This mirrors creation: the finalized goal is visible when created, and the final report is visible when completed. The gate is intentionally semantic rather than paperwork-based: scaffold-only, alpha, generated-template, proxy-metric, build-only, or weakly verified completions should be disapproved by the auditor.
|
|
213
|
+
|
|
214
|
+
## Tests
|
|
215
|
+
|
|
216
|
+
Fast local tests live in `tests/` and run with:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
npm test
|
|
220
|
+
npm run check
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
They cover:
|
|
224
|
+
|
|
225
|
+
- parsing and display helpers;
|
|
226
|
+
- lightweight confirmation prompt and proposal gates;
|
|
227
|
+
- questionnaire normalization and answer formatting;
|
|
228
|
+
- tool-name constants and question-like detection;
|
|
229
|
+
- lifecycle policy, including abort and paused-goal completion;
|
|
230
|
+
- auditor config/prompt/marker parsing, including disapproval winning over approval;
|
|
231
|
+
- goal-pool and focus resolution helpers;
|
|
232
|
+
- active goal file scanning;
|
|
233
|
+
- unfocused prompt guidance;
|
|
234
|
+
- focused/unfocused widget rendering;
|
|
235
|
+
- Sisyphus prompt-style behavior;
|
|
236
|
+
- auto-continue empty-turn guard behavior;
|
|
237
|
+
- full creation/completion report formatting.
|
|
238
|
+
|
|
239
|
+
The `experiments/` harness provides end-to-end coverage with real pi sessions and model calls.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Refactor and Test Baseline
|
|
2
|
+
|
|
3
|
+
This document records the current safety net for the `pi-goal` componentization work.
|
|
4
|
+
|
|
5
|
+
## Commands
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm test
|
|
9
|
+
npm run check
|
|
10
|
+
npm pack --dry-run
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Unit test coverage
|
|
14
|
+
|
|
15
|
+
The fast local suite uses Node's built-in `node:test` runner and currently covers the core modules across:
|
|
16
|
+
|
|
17
|
+
- `tests/goal-core.test.ts`
|
|
18
|
+
- `tests/goal-draft.test.ts`
|
|
19
|
+
- `tests/goal-policy.test.ts`
|
|
20
|
+
- `tests/goal-questionnaire.test.ts`
|
|
21
|
+
- `tests/goal-tool-names.test.ts`
|
|
22
|
+
- `tests/goal-record.test.ts`
|
|
23
|
+
- `tests/goal-files.test.ts`
|
|
24
|
+
- `tests/goal-pool.test.ts`
|
|
25
|
+
- `tests/goal-prompts.test.ts`
|
|
26
|
+
- `tests/goal-notifications.test.ts`
|
|
27
|
+
- `tests/goal-widget.test.ts`
|
|
28
|
+
|
|
29
|
+
## Extracted modules
|
|
30
|
+
|
|
31
|
+
`extensions/goal.ts` remains the orchestration layer. The following logic has been extracted and covered by tests:
|
|
32
|
+
|
|
33
|
+
| Module | Covered behavior |
|
|
34
|
+
|---|---|
|
|
35
|
+
| `extensions/goal-record.ts` | Goal creation, normalization/migration, usage cloning, persisted record shape |
|
|
36
|
+
| `extensions/goal-pool.ts` | Open-goal pool creation, deterministic ordering, explicit-null/stale focus resolution, disk-wins legacy migration, disk lifecycle reconciliation helpers, list and selector labels, unfocused summaries |
|
|
37
|
+
| `extensions/goal-core.ts` | Compact duration/token/status display, objective-title cleanup |
|
|
38
|
+
| `extensions/goal-draft.ts` | Lightweight confirmation prompt, draft summary, safe objective escaping, focus/mode gate, Sisyphus prompt-style guidance, drafting tool gate, multi-open draft creation allowance |
|
|
39
|
+
| `extensions/goal-policy.ts` | Creation/completion-from-active-or-paused, abort/pause/resume/clear policy, multi-open creation slot allowance, compaction reminder, full creation/completion reports |
|
|
40
|
+
| `extensions/goal-auditor.ts` | Independent pi auditor agent config parsing, prompt construction, approval marker parsing, and completion audit execution |
|
|
41
|
+
| `extensions/goal-questionnaire.ts` | Question normalization, duplicate id handling, option filtering, recommended-index validation, answer formatting, confirm/cancel mapping, `goal_question` and `goal_questionnaire` registration |
|
|
42
|
+
| `extensions/goal-tool-names.ts` | Published tool constants, active/paused/drafting tool lists, goal work-tool list, progress-tool list for empty-turn gating, post-stop allowlist, question-like tool detection |
|
|
43
|
+
| `extensions/prompts/goal-prompts.ts` | Active-goal, continuation, tweak-drafting, stale-checkpoint, and unfocused multi-open prompt text |
|
|
44
|
+
| `extensions/storage/goal-files.ts` | Safe goal paths, serialize/parse round trip, prompt-body disk edits, active-goal scans, active/archive writes |
|
|
45
|
+
| `extensions/widgets/goal-widget.ts` | Goal Beacon rendering, Sisyphus style label, status/path lines, blocker/suggested-action display, `+N open` and unfocused guidance |
|
|
46
|
+
| `extensions/widgets/goal-notifications.ts` | Widget-style notification text for goal lifecycle toasts |
|
|
47
|
+
|
|
48
|
+
## Refactor rule
|
|
49
|
+
|
|
50
|
+
1. Add or update tests before moving behavior.
|
|
51
|
+
2. Extract pure helpers or narrow adapter boundaries first.
|
|
52
|
+
3. Keep published tool names, slash commands, file formats, and UI semantics stable unless the user explicitly asks for a new public affordance such as `/goal-abort` or `abort_goal`.
|
|
53
|
+
4. Run `npm test` and `npm run check` after each slice.
|
|
54
|
+
5. Run `npm pack --dry-run` before release or packaging changes.
|
|
55
|
+
|
|
56
|
+
## Remaining runtime-sensitive areas
|
|
57
|
+
|
|
58
|
+
The following remain intentionally in `goal.ts` until a stronger mock `ExtensionAPI` / `ExtensionContext` harness exists:
|
|
59
|
+
|
|
60
|
+
- pi command registration;
|
|
61
|
+
- tool registration beyond the questionnaire pair;
|
|
62
|
+
- session event hooks;
|
|
63
|
+
- timers and auto-continue scheduling;
|
|
64
|
+
- live TUI widget rendering.
|
|
65
|
+
|
|
66
|
+
These areas are protected by TypeScript, focused unit helpers, and the end-to-end experiment harness rather than isolated component tests.
|
|
67
|
+
|
|
68
|
+
## Multi-goal focus test notes
|
|
69
|
+
|
|
70
|
+
The current suite specifically covers the multi-open goal architecture through pure helpers and storage seams:
|
|
71
|
+
|
|
72
|
+
- focus entry normalization in `tests/goal-record.test.ts`;
|
|
73
|
+
- active goal file scanning and invalid/symlink filtering in `tests/goal-files.test.ts`;
|
|
74
|
+
- goal pool sorting, focus resolution, explicit no-focus/stale focus behavior, disk-wins legacy fallback, disk lifecycle merge, list output, and selector labels in `tests/goal-pool.test.ts`;
|
|
75
|
+
- multi-open draft creation allowance, missing confirmation intent rejection, deprecated `draftId` compatibility, concrete-topic direct proposal guidance, and lightweight confirmation prompt text in `tests/goal-draft.test.ts`;
|
|
76
|
+
- no-focus prompt guidance in `tests/goal-prompts.test.ts`;
|
|
77
|
+
- continuation and compaction policy in `tests/goal-policy.test.ts`;
|
|
78
|
+
- auditor marker/config/prompt behavior in `tests/goal-auditor.test.ts`;
|
|
79
|
+
- drafting-phase lifecycle-tool suspension and progress-tool exclusion of `get_goal`, question tools, and draft proposal tools in `tests/goal-tool-names.test.ts`;
|
|
80
|
+
- focused widget `+N open` and unfocused `/goal-focus` guidance in `tests/goal-widget.test.ts`.
|
|
81
|
+
|
|
82
|
+
Release is intentionally separate from implementation validation. The local validation gate is `npm test`, `npm run check`, `npm pack --dry-run`, and `git diff --check`; `npm version`, `npm publish`, `git push`, and `pi update` only happen on explicit release request.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Implemented Borrowed Patterns
|
|
2
|
+
|
|
3
|
+
This document records external patterns that are actually implemented in `pi-goal` today.
|
|
4
|
+
|
|
5
|
+
## From pi-codex-goal
|
|
6
|
+
|
|
7
|
+
`pi-goal` uses several goal-loop stability patterns inspired by `pi-codex-goal`:
|
|
8
|
+
|
|
9
|
+
- **Goal-id continuation markers**: continuation prompts include a goal id so stale prompts can be detected.
|
|
10
|
+
- **Context interceptor**: stale continuation context is neutralized instead of letting an old goal keep driving the agent.
|
|
11
|
+
- **Abort pause**: user abort / Ctrl-C pauses the active goal rather than leaving it in a misleading active state.
|
|
12
|
+
- **Disk-backed active goal file**: the current objective is materialized on disk and can be audited outside the chat.
|
|
13
|
+
|
|
14
|
+
## From pi-autoresearch
|
|
15
|
+
|
|
16
|
+
`pi-goal` uses several autonomous-loop safety patterns inspired by `pi-autoresearch`:
|
|
17
|
+
|
|
18
|
+
- **Empty-turn gate**: auto-continue does not advance when the agent did no meaningful goal-work tool activity.
|
|
19
|
+
- **Post-compaction reminder**: after compaction, the next agent turn is reminded to re-read the objective and continue from actual artifacts/state.
|
|
20
|
+
|
|
21
|
+
## pi-goal-specific work
|
|
22
|
+
|
|
23
|
+
The current extension also adds behavior specific to goal drafting and lifecycle safety:
|
|
24
|
+
|
|
25
|
+
- **Intent-before-run**: `/goals` and `/sisyphus` start a drafting discussion instead of immediate execution.
|
|
26
|
+
- **Direct set shortcut**: `/goals-set` and `/sisyphus-set` immediately create a goal when the user already knows the final objective.
|
|
27
|
+
- **Confirm-before-commit for discussions**: `propose_goal_draft` is the normal discussion-based creation path; `create_goal` stays hidden.
|
|
28
|
+
- **Sisyphus as style**: `/sisyphus` and `/sisyphus-set` use the same lifecycle and tools as regular goals; they only change drafting/continuation wording and completion expectations.
|
|
29
|
+
- **Full draft confirmation and creation output**: draft confirmation uses a plain-text report, and after confirmation the finalized objective is printed directly into the conversation.
|
|
30
|
+
- **Full completion output**: completion prints a report directly into the conversation, including optional evidence and full goal details.
|
|
31
|
+
- **Built-in question tools**: `goal_question` and `goal_questionnaire` provide package-local user-dialogue tools with `goal_` prefixes.
|
|
32
|
+
- **Centralized tool names**: published tool names and allowlists live in `goal-tool-names.ts`.
|
|
33
|
+
- **Questionnaire componentization**: normalization, answer formatting, proposal confirmation, and question-tool registration live in `goal-questionnaire.ts`.
|
|
34
|
+
- **Widget module split**: the above-editor Goal Beacon and widget-style notification text live under `extensions/widgets/`.
|
|
35
|
+
- **Record/prompt/storage split**: goal record normalization, prompt construction, and disk serialization now live in separate tested modules instead of the orchestration file.
|
|
36
|
+
|
|
37
|
+
## Current validation
|
|
38
|
+
|
|
39
|
+
Run locally:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm test
|
|
43
|
+
npm run check
|
|
44
|
+
npm pack --dry-run
|
|
45
|
+
```
|