@tduyng/pi-goal 0.0.2 → 0.0.3
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 +44 -56
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,102 +1,90 @@
|
|
|
1
1
|
# @tduyng/pi-goal
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Give the agent an objective once, then stop typing "continue". Goals survive reload and tree navigation, count what they spend, and pause on their own when the work repeats or the budget runs out.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## What it costs
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Nothing until a goal exists. `create_goal`, `update_goal`, and `get_goal` are deferred tools: they are not declared to the model, and they enter the active set only while a goal is active or you ask to create one. A session that never touches a goal pays no tokens for this package.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
The standing orders live in the system prompt and are byte-stable, so they ride in the prompt cache rather than invalidating it. Live counters such as elapsed time and tokens used travel in the continuation message at the request tail, which is not cached anyway.
|
|
10
|
+
|
|
11
|
+
## /goal
|
|
12
|
+
|
|
13
|
+
```text
|
|
10
14
|
/goal refactor the auth module to use JWT refresh tokens
|
|
11
15
|
/goal with token budget 50000 migrate the database schema
|
|
12
16
|
```
|
|
13
17
|
|
|
14
|
-
Subcommands:
|
|
18
|
+
Subcommands:
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
| Command | Effect |
|
|
21
|
+
| --- | --- |
|
|
22
|
+
| `/goal edit` | Open the objective in an editor |
|
|
23
|
+
| `/goal budget <tokens\|off>` | Set, raise, or remove the token budget |
|
|
24
|
+
| `/goal check <command\|off>` | The command that must exit 0 before the goal can complete |
|
|
25
|
+
| `/goal pause` | Stop queueing continuations |
|
|
26
|
+
| `/goal resume` | Start them again |
|
|
27
|
+
| `/goal clear` | Drop the goal |
|
|
17
28
|
|
|
18
|
-
|
|
19
|
-
- `get_goal`: returns the current goal's status, token and time usage, remaining budget, and thread ID.
|
|
20
|
-
- `update_goal`: mark the goal `complete` or `blocked` after verifying the required conditions. Pass `notes` (max 3,000 characters) to replace the progress notes. `complete` runs the goal's check first and is refused unless it exits 0. The model should not mark a goal complete merely because the budget is nearly exhausted or because it is stopping work.
|
|
29
|
+
Raising the budget past current spend resumes a budget-limited goal.
|
|
21
30
|
|
|
22
|
-
|
|
31
|
+
## The tools
|
|
23
32
|
|
|
24
|
-
|
|
33
|
+
`create_goal` is for when you explicitly ask for a goal: an objective of up to 4,000 characters, an optional token budget, an optional check. It fails if an unfinished goal exists, replaces a complete one, and adds an advisory when no budget is set, because unbounded spend is worth saying out loud.
|
|
25
34
|
|
|
26
|
-
|
|
35
|
+
`get_goal` returns status, token and time usage, remaining budget, and the thread id.
|
|
27
36
|
|
|
28
|
-
|
|
37
|
+
`update_goal` marks the goal `complete` or `blocked`. `notes` replaces the progress notes, up to 3,000 characters. Completion runs the goal's check first and is refused unless the command exits 0, so the model cannot call a goal done over a red test.
|
|
29
38
|
|
|
30
|
-
|
|
39
|
+
## Continuation
|
|
31
40
|
|
|
32
|
-
|
|
41
|
+
After a successful run the extension queues one continuation prompt, so the model keeps working without input. One continuation fires per turn: if `/loop` also queued a prompt, `hasPendingMessages()` makes exactly one of them win.
|
|
33
42
|
|
|
34
|
-
|
|
43
|
+
Runaway detection pauses a goal when the same tool-free output repeats 3 times in a row. Any tool call resets the streak.
|
|
35
44
|
|
|
36
|
-
|
|
45
|
+
A stagnation nudge arrives after 5 goal turns with no successful `edit` or `write` result. The continuation message names the count and asks for the next concrete change, or for the blocked audit when a blocker keeps repeating. It never pauses the goal. Your own input resets the count.
|
|
37
46
|
|
|
38
|
-
|
|
47
|
+
There is no fixed cap. A goal queues continuations until it completes, is paused, or hits its budget, and `/goal clear` is how you stop one that is going nowhere.
|
|
39
48
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
### Token counting
|
|
43
|
-
|
|
44
|
-
Only `input` and `output` tokens count toward the goal budget. `cacheRead` and `cacheWrite` are excluded because providers report them as separate fields.
|
|
49
|
+
Only `input` and `output` tokens count toward the budget. `cacheRead` and `cacheWrite` are excluded, because providers report them as separate fields.
|
|
45
50
|
|
|
46
51
|
## Completion check and notes
|
|
47
52
|
|
|
48
|
-
`create_goal` with `check`, or `/goal check <command>`, sets a
|
|
53
|
+
`create_goal` with `check`, or `/goal check <command>`, sets a command such as `bun test`. The check runs before `update_goal` can complete the goal, and a failing check keeps it active and returns the output to the model.
|
|
49
54
|
|
|
50
|
-
The progress notes hold what is done, what failed and what is next. They are sent again in the next continuation after a compaction or a resume. A note written in
|
|
55
|
+
The progress notes hold what is done, what failed, and what is next. They are sent again in the next continuation after a compaction or a resume. A note written in this turn is already in this turn's context, so it is not repeated.
|
|
51
56
|
|
|
52
57
|
## Status bar
|
|
53
58
|
|
|
54
|
-
|
|
59
|
+
Elapsed time, tokens used, and budget while the goal runs. The other states read `Goal paused`, `Goal blocked`, `Goal hit usage limits`, `Goal budget reached`, and `Goal complete`.
|
|
55
60
|
|
|
56
|
-
## /loop
|
|
61
|
+
## /loop
|
|
57
62
|
|
|
58
|
-
Repeat a prompt on
|
|
63
|
+
Repeat a prompt on an interval, or after each run settles:
|
|
59
64
|
|
|
60
|
-
```
|
|
65
|
+
```text
|
|
61
66
|
/loop 5m check for failing CI jobs
|
|
62
67
|
/loop review recent work and fix unfinished items
|
|
63
68
|
/loop stop
|
|
64
69
|
```
|
|
65
70
|
|
|
66
|
-
Starting a loop fires the first prompt immediately.
|
|
67
|
-
|
|
68
|
-
Interval format: a number followed by a unit. Supported units: `ms`, `s`, `m`, `h`, `d`. Bare numbers without a unit are not supported to avoid silent misinterpretation.
|
|
69
|
-
|
|
70
|
-
Self-paced mode fires 250ms after `agent_settled`, once pi's own retries and compactions have finished. The default prompt when none is provided: "Run a maintenance check: review recent work and address anything stale, broken, or left half-finished."
|
|
71
|
-
|
|
72
|
-
Subcommands: `stop` (also `cancel`, `clear`, `off`), or bare `/loop` to show status. The status bar shows the pace label (e.g. `Loop every 5m (3)`) and iteration count.
|
|
73
|
-
|
|
74
|
-
## Design
|
|
75
|
-
|
|
76
|
-
The extension persists state as custom session entries, without an external database. Resuming a saved session restores its goal. Interval loops re-arm on resume, firing immediately if their interval has elapsed. The extension does not create goals automatically from ordinary tasks and does not reimplement timeout or retry logic that pi already handles.
|
|
71
|
+
Starting a loop fires the first prompt immediately. Interval format is a number plus one of `ms`, `s`, `m`, `h`, `d`. A bare number is refused rather than guessed at.
|
|
77
72
|
|
|
78
|
-
|
|
73
|
+
Self-paced mode fires 250ms after `agent_settled`, once pi's own retries and compactions are done. With no prompt it runs a maintenance check: review recent work and address anything stale, broken, or half-finished. The status bar shows the pace and the iteration count, for example `Loop every 5m (3)`.
|
|
79
74
|
|
|
80
|
-
|
|
81
|
-
the run picks up instead of waiting for the user to type. A turn that ended on a user message,
|
|
82
|
-
a tool result, or a tool call that never ran counts as cut off. A turn the user aborted, or one
|
|
83
|
-
that ended in an error, does not: the first was their own stop, and the second is what pi-goal
|
|
84
|
-
already pauses on. The resume counts as an automatic continuation, and only an interactive
|
|
85
|
-
session resumes, because a headless run has no editor to send a message from. A resume pi
|
|
86
|
-
refuses, because it is already replaying the interrupted turn, says nothing: the goal continues
|
|
87
|
-
from that turn's own settle.
|
|
75
|
+
Loop state is session-scoped and the timer dies with the pi process. For runs that must survive a restart, use `pi -p "<prompt>"` from an OS scheduler.
|
|
88
76
|
|
|
89
|
-
|
|
77
|
+
## Resume and limits
|
|
90
78
|
|
|
91
|
-
|
|
79
|
+
State is stored as custom session entries, with no external database. Resuming a session restores its goal, and an interval loop re-arms and fires at once if its interval has passed. The extension never creates a goal from an ordinary task.
|
|
92
80
|
|
|
93
|
-
|
|
81
|
+
A goal that was mid-turn when the process died gets one continuation when you reopen the session, so the run picks up instead of waiting for you. A turn that ended on a user message, a tool result, or a tool call that never ran counts as cut off. A turn you aborted or one that ended in an error does not: the first was your own stop and the second is what the goal already pauses on. Only an interactive session resumes, because a headless run has no editor to send a message from.
|
|
94
82
|
|
|
95
|
-
|
|
83
|
+
For blocked status the same condition must repeat for at least 3 consecutive goal turns, and resuming a blocked goal resets that count.
|
|
96
84
|
|
|
97
|
-
|
|
85
|
+
A goal that hit its token budget is resumed with the budget raised to usage plus 50,000 tokens, and the status bar says so.
|
|
98
86
|
|
|
99
|
-
|
|
87
|
+
`promptRequestsGoal` needs an action verb (create, set, start, new, add, track, pursue, manage, establish) plus a goal noun, or the phrase "long-running". A bare "goal" does not switch the tools on.
|
|
100
88
|
|
|
101
89
|
## Install
|
|
102
90
|
|
|
@@ -106,4 +94,4 @@ pi install npm:@tduyng/pi-goal
|
|
|
106
94
|
|
|
107
95
|
Local checkout: `pi install /path/to/dotfiles/pi/agent/extensions/pi-goal`
|
|
108
96
|
|
|
109
|
-
No configuration
|
|
97
|
+
No configuration required.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tduyng/pi-goal",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Long-running objectives that survive reload and tree navigation, plus a timed or self-paced loop
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "Long-running objectives that survive reload and tree navigation, plus a timed or self-paced loop. Zero tokens until a goal exists.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi",
|
|
7
7
|
"pi-package",
|