@srobroek/pi-autopilot 0.0.0-stage → 1.4.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/CHANGELOG.md +105 -0
- package/LICENSE +202 -0
- package/README.md +414 -2
- package/_kit/prereqs.json +21 -0
- package/_kit/prereqs.ts +374 -0
- package/extensions/autopilot.js +4863 -0
- package/package.json +49 -4
- package/skills/autopilot/SKILL.md +192 -0
- package/skills/autopilot/references/pitfalls.md +31 -0
package/package.json
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@srobroek/pi-autopilot",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"description": "Unattended runs: /autopilot arms a no-questions session with a journal, a 4-minute tick and stop conditions.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pi-package"
|
|
7
|
+
],
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/srobroek/harness-plugins.git",
|
|
12
|
+
"directory": "plugins/autopilot/pi"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"CHANGELOG.md",
|
|
16
|
+
"LICENSE",
|
|
17
|
+
"README.md",
|
|
18
|
+
"_kit",
|
|
19
|
+
"extensions",
|
|
20
|
+
"skills"
|
|
21
|
+
],
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public",
|
|
24
|
+
"provenance": true
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@srobroek/pi-beads-enforcer": "*",
|
|
28
|
+
"@srobroek/pi-parley-rounds": "*",
|
|
29
|
+
"pi-subagents": "*"
|
|
30
|
+
},
|
|
31
|
+
"peerDependenciesMeta": {
|
|
32
|
+
"@srobroek/pi-beads-enforcer": {
|
|
33
|
+
"optional": true
|
|
34
|
+
},
|
|
35
|
+
"@srobroek/pi-parley-rounds": {
|
|
36
|
+
"optional": true
|
|
37
|
+
},
|
|
38
|
+
"pi-subagents": {
|
|
39
|
+
"optional": true
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"pi": {
|
|
43
|
+
"extensions": [
|
|
44
|
+
"./extensions/autopilot.js",
|
|
45
|
+
"./_kit/prereqs.ts"
|
|
46
|
+
],
|
|
47
|
+
"skills": [
|
|
48
|
+
"./skills"
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: autopilot
|
|
3
|
+
description: User-only unattended-run rules for /autopilot; never load it yourself, the /autopilot command loads it.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Autopilot
|
|
7
|
+
|
|
8
|
+
The user started `/autopilot` and left. This skill holds the rules for the run.
|
|
9
|
+
Load it only when an `/autopilot` command, a tick or the compaction notice tells
|
|
10
|
+
you to.
|
|
11
|
+
|
|
12
|
+
## Setup (the only time you ask)
|
|
13
|
+
|
|
14
|
+
1. The command prompt lists the values the command line gave and the values it
|
|
15
|
+
left out. Ask every missing value in ONE `parley_ask` round. Without parley,
|
|
16
|
+
ask them all in one message and end the turn until the user answers.
|
|
17
|
+
Recommend an answer for each value:
|
|
18
|
+
- scope: one of these:
|
|
19
|
+
- an epic id or a bead id
|
|
20
|
+
- a goal in plain words
|
|
21
|
+
- the `bd ready` queue
|
|
22
|
+
- ledger: the beads ledger (`.beads` directory) the run reads and writes.
|
|
23
|
+
Skip it unless the scope's beads live in a ledger other than this session
|
|
24
|
+
directory's; the plugin derives it from the scope's bead ids or the session
|
|
25
|
+
directory, and refuses to arm when it cannot. Pass it as `setup.ledger`.
|
|
26
|
+
- `--full`: decide irreversible items too (recommend no)
|
|
27
|
+
- permissions: `merge` and `deploy` grants (recommend none). pi has no
|
|
28
|
+
`self-review` grant: a merge always needs a GitHub approval.
|
|
29
|
+
- parallel write lanes: any whole number (recommend 3)
|
|
30
|
+
- budget: a duration (`3h`) or a clock time (`18:00`)
|
|
31
|
+
- a free-text stop condition (optional)
|
|
32
|
+
2. Call `autopilot_status` with `action: "arm"` and the answers in `setup`. The
|
|
33
|
+
plugin starts the 4-minute tick itself; there is nothing to create.
|
|
34
|
+
|
|
35
|
+
From here until the run stops, never ask the user anything. While the run is
|
|
36
|
+
armed, the plugin blocks `question` and the `parley_*` tools for this session
|
|
37
|
+
and for every subagent that loads the plugin.
|
|
38
|
+
|
|
39
|
+
## Decision policy
|
|
40
|
+
|
|
41
|
+
- Reversible: pick the most likely option and continue. Log it with
|
|
42
|
+
`autopilot_log` and these fields:
|
|
43
|
+
- `type: "decision"`
|
|
44
|
+
- `chosen` and `alternatives`
|
|
45
|
+
- `reversible: true`
|
|
46
|
+
- `confidence`
|
|
47
|
+
- Irreversible or outward-facing: log a `blocker` with `parked: true`, park the
|
|
48
|
+
item and move on. Outward-facing covers messages to people, releases and
|
|
49
|
+
anything another team sees.
|
|
50
|
+
- With `--full`: decide irreversible items too, within the granted permissions.
|
|
51
|
+
Work beads that are already flagged `human` as well.
|
|
52
|
+
- Without `--full`, `autopilot_log` flags the bead of each blocker or ambiguity
|
|
53
|
+
with the `human` label.
|
|
54
|
+
- Log each finished unit of work as `progress`. A unit of work is one of these:
|
|
55
|
+
- a closed bead
|
|
56
|
+
- a commit
|
|
57
|
+
- an opened PR
|
|
58
|
+
- a lane result
|
|
59
|
+
|
|
60
|
+
Ticks count progress. Six ticks in a row without any progress stop the run.
|
|
61
|
+
On pi the tick cannot see subagents, so a lane result counts only once you
|
|
62
|
+
log it.
|
|
63
|
+
- When an error repeats, give it a short stable `error` signature. The same
|
|
64
|
+
signature twice in a row parks the item.
|
|
65
|
+
|
|
66
|
+
## Permissions
|
|
67
|
+
|
|
68
|
+
These rules say what you may decide to do. They are not approvals. pi has no
|
|
69
|
+
permission prompts, but other extensions open dialogs that wait for a person,
|
|
70
|
+
for example a safety confirmation for a destructive command. Nobody is there to
|
|
71
|
+
answer one: in the terminal it waits, and a session without dialogs usually
|
|
72
|
+
refuses the call. The plugin logs each dialog that opens as a blocker. Before a
|
|
73
|
+
call that you expect to need an approval, log a blocker, park the item and move
|
|
74
|
+
on. Do not retry a refused call in another form to get around the check.
|
|
75
|
+
|
|
76
|
+
Before you spawn a reviewer for a round, call
|
|
77
|
+
`autopilot_export_review({ pr, base, head })` with the PR number and the
|
|
78
|
+
revisions under review, and call it again after each new head. The tool runs
|
|
79
|
+
git itself and writes, under the run's `review/<head>/<manifestHash>/`:
|
|
80
|
+
`round.diff` (the `base...head` diff), `diffstat.txt`, `files/<path>` (each
|
|
81
|
+
changed file at head) and `manifest.json` (the SHA-256 of every file). It
|
|
82
|
+
returns `dir` and `manifestHash`; the plugin keeps the hash by `pr@head`.
|
|
83
|
+
Put both in the reviewer's prompt: "Review the export at `<dir>` (manifest hash
|
|
84
|
+
`<manifestHash>`). Read `manifest.json` first and start your verdict with that
|
|
85
|
+
hash line. Do not run git." A verdict that quotes a different hash, or none,
|
|
86
|
+
does not count: export again and re-run the review. If the tool refuses (a cap,
|
|
87
|
+
a bad revision), narrow the range or log a blocker. Any session that may edit
|
|
88
|
+
can write to the export directory, so only the manifest hash vouches for it.
|
|
89
|
+
|
|
90
|
+
Allowed by default:
|
|
91
|
+
|
|
92
|
+
- commits on branches and worktrees, and pushes of feature branches
|
|
93
|
+
- opening PRs and MRs
|
|
94
|
+
- creating beads, and closing beads you verified
|
|
95
|
+
- adding or bumping dependencies
|
|
96
|
+
- read-only AWS calls
|
|
97
|
+
- evals and probes that leave no resources behind
|
|
98
|
+
|
|
99
|
+
Spikes are throwaway AWS resources. Tag each one `autopilot-run=<run id>` and
|
|
100
|
+
give it a TTL. Before you create a spike, create a teardown child bead that
|
|
101
|
+
blocks its parent. Close that bead only with evidence: a tag query that returns
|
|
102
|
+
0 resources. Sweep the tag before you stop. A leftover resource is a blocker,
|
|
103
|
+
and the run cannot stop as a success while one remains.
|
|
104
|
+
|
|
105
|
+
Never do: a force push, a mirror push, or a push to the default branch.
|
|
106
|
+
|
|
107
|
+
Commands that discard work (`git reset --hard`, `git clean -f`, `git branch -D`,
|
|
108
|
+
`git switch --discard-changes`, deleting a remote branch, `git stash drop`,
|
|
109
|
+
`rm -r`, `bd delete`) are irreversible. Run one only in a `--full` run.
|
|
110
|
+
Otherwise, log it as a blocker and park the item.
|
|
111
|
+
|
|
112
|
+
A merge needs `--allow merge`, a GitHub review in state `APPROVED` on the
|
|
113
|
+
exact head SHA from an account other than the PR author (ask the reviewer to
|
|
114
|
+
submit it with `gh pr review --approve`; a comment verdict does not count), and
|
|
115
|
+
green checks. Merge only through `autopilot_merge({ pr, sha, method })` with
|
|
116
|
+
the SHA the reviewer approved; never run `gh pr merge` in a shell. Without
|
|
117
|
+
`--allow merge` the plugin refuses the merge and logs a blocker. Pass the
|
|
118
|
+
repository's documented merge method (see AGENTS.md, CONTRIBUTING or the
|
|
119
|
+
README; `squash`, `rebase` or `merge`), never a guess: the tool refuses a
|
|
120
|
+
method the repository does not allow. It also refuses when the head moved, the
|
|
121
|
+
approval is for another SHA, a required check is not green, branch protection
|
|
122
|
+
or rulesets cannot be read, or the base branch uses a merge queue: after a
|
|
123
|
+
moved head or a bad approval, re-review the new head; for the rest, log a
|
|
124
|
+
blocker and park the item. Report a merge only when the tool says merged; the
|
|
125
|
+
tool re-reads the PR to confirm it. When the only reviewer is the PR author's
|
|
126
|
+
own account, log a blocker and park the item. A deployment (stack create,
|
|
127
|
+
update or delete) needs `--allow deploy`.
|
|
128
|
+
|
|
129
|
+
## Lanes
|
|
130
|
+
|
|
131
|
+
- Lanes are pi-subagents children: start each with the `subagent` tool. The
|
|
132
|
+
number of write lanes is the count chosen at setup, with no upper limit.
|
|
133
|
+
Read-only agents take no lane. These agents are read-only:
|
|
134
|
+
- `explore` and `researcher`
|
|
135
|
+
- the reviewers
|
|
136
|
+
- `debug`
|
|
137
|
+
- Each writer gets its own Worktrunk worktree. Each lane claims its own bead.
|
|
138
|
+
The lead leaves bead claims to the lanes.
|
|
139
|
+
- The tick sees no subagents on pi: the ping shows `0/<lanes> lanes`, and it
|
|
140
|
+
names no stalled lane. Track your lanes yourself. Nudge a lane that has been
|
|
141
|
+
silent for 12 minutes, restart it once with journal context if it stays
|
|
142
|
+
silent, then park its item.
|
|
143
|
+
|
|
144
|
+
## Ticks
|
|
145
|
+
|
|
146
|
+
Every 4 minutes, while this session is idle, the plugin runs the tick and sends
|
|
147
|
+
a prompt with a ping like:
|
|
148
|
+
|
|
149
|
+
`♥ 14:32 · 0/4 lanes · ready 4 · blocked 2 (+1 unblocked) · parked 1 · 1h12m left`
|
|
150
|
+
|
|
151
|
+
Post the ping line verbatim and act on its actions due. Keep a tick that has no
|
|
152
|
+
actions to that one line. The tick runs inside this pi process: print mode
|
|
153
|
+
(`pi -p`) ends with its prompt and gets no ticks.
|
|
154
|
+
|
|
155
|
+
## Stopping
|
|
156
|
+
|
|
157
|
+
The run stops when any of these happens:
|
|
158
|
+
|
|
159
|
+
- the scope is finished
|
|
160
|
+
- the budget or the clock deadline is reached
|
|
161
|
+
- the free-text condition holds (log a `stop` entry for it)
|
|
162
|
+
- the user runs `/autopilot stop`
|
|
163
|
+
- six ticks pass without progress
|
|
164
|
+
|
|
165
|
+
To stop, call `autopilot_status` with `action: "stop"` and a `reason`. The call
|
|
166
|
+
does these things:
|
|
167
|
+
|
|
168
|
+
- writes `summary.md`
|
|
169
|
+
- creates the `autopilot-handoff` bead
|
|
170
|
+
- disarms the gates
|
|
171
|
+
|
|
172
|
+
Then print the summary and end the turn.
|
|
173
|
+
|
|
174
|
+
## Recovery
|
|
175
|
+
|
|
176
|
+
- After compaction, the plugin queues a notice with a fresh status. Reload this
|
|
177
|
+
skill and continue.
|
|
178
|
+
- `/autopilot resume [run-id]` arms a run again in this session from its latest
|
|
179
|
+
state file and restarts the tick here. Ticks bound to the old session no
|
|
180
|
+
longer count.
|
|
181
|
+
- If a stop reports `phase: "stopping"`, the summary or the handoff bead did not
|
|
182
|
+
land. The next tick retries; call `autopilot_status` with `action: "stop"` to
|
|
183
|
+
retry now. The run is stopped only when both exist.
|
|
184
|
+
- `/autopilot review [run-id]`, in any session, loads the summary and asks one
|
|
185
|
+
question per needs-input item.
|
|
186
|
+
|
|
187
|
+
The run directory is `$(git rev-parse --git-common-dir)/opencode-scratch/autopilot/<run-id>/`.
|
|
188
|
+
It holds `journal.jsonl`, the state files `state.<N>.json` (the highest number
|
|
189
|
+
is the state; `state.json` links to it for reading by hand) and `summary.md`.
|
|
190
|
+
The `autopilot/latest` link points to the newest run.
|
|
191
|
+
|
|
192
|
+
When a call here fails unexpectedly, read [references/pitfalls.md](references/pitfalls.md).
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Autopilot pitfalls
|
|
2
|
+
|
|
3
|
+
## A tick prompt arrives in the middle of a turn
|
|
4
|
+
|
|
5
|
+
**Symptom:** `Autopilot tick. Post this ping verbatim` shows up between tool calls of a running turn.
|
|
6
|
+
**Cause:** an automation `send` goes into the session even while it executes. The tick skips while the host's session record shows a running execution. A turn that starts between that check and the send still gets the prompt.
|
|
7
|
+
**Fix:** post the ping, finish the current step, and keep working.
|
|
8
|
+
|
|
9
|
+
## autopilot_status says the run is in setup
|
|
10
|
+
|
|
11
|
+
**Symptom:** `run is in setup: finish the setup round and call action "arm"`
|
|
12
|
+
**Cause:** the agent skipped the setup round, or the arm call failed validation.
|
|
13
|
+
**Fix:** call `autopilot_status` with `action: "arm"` and the setup answers. Correct any `--for` or `--until-time` value that the call rejects.
|
|
14
|
+
|
|
15
|
+
## A permission request is denied while the run is armed
|
|
16
|
+
|
|
17
|
+
**Symptom:** `autopilot never approves a permission ask while the run is unattended; logged as a blocker`
|
|
18
|
+
**Cause:** the user's permission rules ask about this call, and nobody is there to answer. The plugin denies every `ask` and journals the permission kind and the command or pattern.
|
|
19
|
+
**Fix:** do not retry the call in another form to get around the prompt. Park the item, leave the blocker for the user, and move on to the next item.
|
|
20
|
+
|
|
21
|
+
## autopilot_status reports that it cannot use its run files
|
|
22
|
+
|
|
23
|
+
**Symptom:** `autopilot cannot use its run files: <path>: ...`
|
|
24
|
+
**Cause:** the latest `state.<N>.json`, `journal.jsonl` or `summary.md` exists but is unreadable or corrupt. A corrupt latest state file is never skipped for an older one.
|
|
25
|
+
**Fix:** do not treat the run as finished. Check the file named in the message, log the blocker, and stop the run with `/autopilot stop` once the file is repaired.
|
|
26
|
+
|
|
27
|
+
## autopilot_status reports that the state moved on under the call
|
|
28
|
+
|
|
29
|
+
**Symptom:** `state moved on under this call (...)`, with `stale: true`.
|
|
30
|
+
**Cause:** another writer, such as a second plugin instance or a stalled earlier call, created that state generation first. Nothing was overwritten, and the plugin journaled an `issue`.
|
|
31
|
+
**Fix:** call `autopilot_status` again. It reads the latest state and acts on it.
|