@kolohelios/dipping-bird 0.0.0-stage → 0.1.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 +9 -0
- package/LICENSE +11 -0
- package/LICENSE-APACHE +201 -0
- package/LICENSE-MIT +21 -0
- package/README.md +121 -2
- package/architecture-decision-record.md +49 -0
- package/architecture.md +62 -0
- package/extensions/core.ts +199 -0
- package/extensions/index.ts +389 -0
- package/package.json +83 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.1.0]
|
|
4
|
+
|
|
5
|
+
- Prepare the jj-only continuation extension as a portable Pi package.
|
|
6
|
+
- Preserve opt-in startup, bounded continuation, paused restoration, and
|
|
7
|
+
evidence-bearing completion reports.
|
|
8
|
+
- Reject negative persisted start times and prevent settled or expired initial
|
|
9
|
+
preflights from arming the loop.
|
package/LICENSE
ADDED
package/LICENSE-APACHE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Jon Edwards
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/LICENSE-MIT
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jon Edwards
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,122 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Dipping Bird
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An opt-in Pi extension that keeps an authorized task moving until the agent
|
|
4
|
+
reports completion, a blocker, or a pause. Works in **jj workspaces**; plain Git
|
|
5
|
+
repositories are not supported.
|
|
6
|
+
|
|
7
|
+
This is a community package, not an official Pi-maintained extension. The first
|
|
8
|
+
release is being prepared in this public repository; the npm package is not published yet.
|
|
9
|
+
|
|
10
|
+
## Use
|
|
11
|
+
|
|
12
|
+
Tested with Pi 1.5.2. Requires Node.js 22.19+ and `jj` on Pi's PATH.
|
|
13
|
+
From a local checkout:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
pi install ./
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
In Pi:
|
|
20
|
+
|
|
21
|
+
```text
|
|
22
|
+
/reload
|
|
23
|
+
/bird start Finish the current task against its existing acceptance criteria.
|
|
24
|
+
/bird status
|
|
25
|
+
/bird stop
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`/bird start` uses the current conversation's task on first start; after that it
|
|
29
|
+
resumes the saved goal with the **remaining original limits**. Supplying a new
|
|
30
|
+
goal explicitly starts a new supervision window, not a new permission grant.
|
|
31
|
+
|
|
32
|
+
## Limits and safety
|
|
33
|
+
|
|
34
|
+
- At most **60 automatic continuations** or **two elapsed hours**, checked
|
|
35
|
+
between runs. An in-flight tool is not forcibly preempted by these caps.
|
|
36
|
+
- Pins the real working directory and eight-character jj change ID. Identity
|
|
37
|
+
checks use read-only `jj --ignore-working-copy log`, with a five-second timeout.
|
|
38
|
+
Bird never switches directories or changes VCS state.
|
|
39
|
+
- Escape/aborted runs pause active supervision. Use `/bird stop` to cancel a
|
|
40
|
+
start still waiting for jj; Pi's idle Escape handling does not cancel commands.
|
|
41
|
+
Plain `stop` or `pause` input also pauses Bird.
|
|
42
|
+
- Reload, resume, fork, and tree navigation restore saved state **paused**.
|
|
43
|
+
Compaction preserves the current supervision window.
|
|
44
|
+
- `bird_checkpoint` lets the model report `continue`, `blocked`, `pause`, or
|
|
45
|
+
`complete`. Completion requires evidence references and means **completion
|
|
46
|
+
reported for review**, not independent certification.
|
|
47
|
+
- Bird controls its own continuations, not other extensions or manual prompts.
|
|
48
|
+
It does not enforce permissions on tools or verify evidence contents.
|
|
49
|
+
|
|
50
|
+
Starting Bird can incur additional model costs. It grants no new file, network,
|
|
51
|
+
credential, deployment, or publication authority. Existing approval gates remain
|
|
52
|
+
in force. The continuation prompt also forbids Git use, creating changes/commits/
|
|
53
|
+
workspaces/PRs, and spawning helper agents while Bird supervises the task.
|
|
54
|
+
|
|
55
|
+
## Privacy
|
|
56
|
+
|
|
57
|
+
Bird makes no direct network/model calls, reads no credentials, and starts no
|
|
58
|
+
background services or timers. It stores its goal, workspace/change pin, limits,
|
|
59
|
+
and checkpoint summaries/references as custom entries in Pi's session history.
|
|
60
|
+
Do not put secrets or raw sensitive output in goals or checkpoints. Control
|
|
61
|
+
characters are normalized; that is **not** secret redaction.
|
|
62
|
+
|
|
63
|
+
## Development
|
|
64
|
+
|
|
65
|
+
Use the locked Nix dev shell (Linux or Apple Silicon macOS, not Intel macOS),
|
|
66
|
+
or let direnv load `.envrc`:
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
nix develop
|
|
70
|
+
just install
|
|
71
|
+
just typecheck
|
|
72
|
+
just lint
|
|
73
|
+
just format-check
|
|
74
|
+
just test
|
|
75
|
+
just build
|
|
76
|
+
just validate
|
|
77
|
+
just compat
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Tests use Node's test runner. Core/state and lifecycle tests use a fake Pi host;
|
|
81
|
+
loader/package smoke tests use the real pinned Pi SDK without model requests.
|
|
82
|
+
The coverage gate measures all extension source, including unimported files.
|
|
83
|
+
`just build` packs the release into `dist/`, installs it offline without peer or
|
|
84
|
+
dev dependencies, and verifies its manifest, contents, and Pi discovery. Only
|
|
85
|
+
`extensions/index.ts` is registered; the helper module is not a second extension.
|
|
86
|
+
|
|
87
|
+
`just validate` also runs Shaka's repository preflight/whitespace checks and
|
|
88
|
+
Nix checks. Shaka is pinned from FlakeHub in `flake.lock`. Its current
|
|
89
|
+
`shaka build` command is a stub and it has no TypeScript project kind, so the
|
|
90
|
+
actual package assembly is an explicit npm recipe—not a claimed Shaka build.
|
|
91
|
+
`repo-checks` initializes colocated jj metadata if needed for Shaka's tracked-file
|
|
92
|
+
checks. No branch, remote, or source checkout is switched.
|
|
93
|
+
|
|
94
|
+
GitHub Actions runs the same validation on Linux (Node 22 and 24) and macOS
|
|
95
|
+
(Node 24), with Nix binary caching and lockfile-keyed npm download caching.
|
|
96
|
+
It uploads coverage reports and verified tarballs; it never publishes to npm.
|
|
97
|
+
|
|
98
|
+
## Main branch protection
|
|
99
|
+
|
|
100
|
+
`.shaka/repo.cue` declares the desired merge policy and requires `Gate` plus all
|
|
101
|
+
three explicitly named matrix checks, up-to-date with `main`. Force pushes and
|
|
102
|
+
deletion of `main` are forbidden. Tests keep workflow names, Shaka policy, and
|
|
103
|
+
`.github/main-ruleset.json` aligned.
|
|
104
|
+
|
|
105
|
+
The native ruleset additionally requires a PR, resolved review conversations,
|
|
106
|
+
and rebase-only merges, with no bypass actors. It requires no approving review
|
|
107
|
+
because a single maintainer cannot approve their own PR. This still forbids
|
|
108
|
+
direct pushes once the ruleset is active.
|
|
109
|
+
|
|
110
|
+
**These files are desired policy, not live enforcement.** Before PR delivery,
|
|
111
|
+
confirm the remote owner/host, enable protection, and verify the actual main
|
|
112
|
+
rules and hosted CI checks. Live settings may drift independently of these files.
|
|
113
|
+
Shaka cannot currently represent the PR requirement; its branch-protection
|
|
114
|
+
`--fix` path clears required PR reviews. Do not use it as the complete setup
|
|
115
|
+
operation or overwrite stronger existing settings.
|
|
116
|
+
|
|
117
|
+
See [architecture](architecture.md) and [decisions](architecture-decision-record.md)
|
|
118
|
+
for lifecycle and tooling details.
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
Licensed under [MIT](LICENSE-MIT) OR [Apache-2.0](LICENSE-APACHE), at your option.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Dipping Bird architecture decisions
|
|
2
|
+
|
|
3
|
+
## Offer MIT or Apache-2.0 at the recipient's option
|
|
4
|
+
|
|
5
|
+
Use SPDX `MIT OR Apache-2.0` and ship both full license texts. The Apache text
|
|
6
|
+
comes from the [Apache Foundation](https://www.apache.org/licenses/LICENSE-2.0.txt),
|
|
7
|
+
with the copyright placeholder filled in. Package checks pin the normalized text
|
|
8
|
+
hashes so accidental clause edits cannot retain the same SPDX claim unnoticed.
|
|
9
|
+
|
|
10
|
+
## Declare main protection separately from applying it
|
|
11
|
+
|
|
12
|
+
Shaka's desired policy requires every matrix check and the aggregate `Gate`,
|
|
13
|
+
strictly up-to-date, and rejects force pushes and deletion. Native ruleset JSON
|
|
14
|
+
adds PR-only changes, resolved conversations, rebase merges, and no bypass
|
|
15
|
+
actors. No approving review is mandatory for a single-maintainer repository.
|
|
16
|
+
Tests compare these requirements with the actual workflow names.
|
|
17
|
+
|
|
18
|
+
Shaka's current branch-protection fixer clears required PR reviews and cannot
|
|
19
|
+
express the complete policy. Live configuration therefore needs separate,
|
|
20
|
+
authorized application and verification at the confirmed destination, preserving
|
|
21
|
+
any stronger existing protection. Local configuration alone is not enforcement.
|
|
22
|
+
|
|
23
|
+
## Keep the first release jj-only
|
|
24
|
+
|
|
25
|
+
The installed extension pins a jj change as well as the canonical working
|
|
26
|
+
directory. The extracted package preserves that contract rather than inventing
|
|
27
|
+
a Git equivalent during release preparation. This excludes plain Git workspaces
|
|
28
|
+
but keeps resume and drift behavior predictable.
|
|
29
|
+
|
|
30
|
+
## Separate supervision from permission and certification
|
|
31
|
+
|
|
32
|
+
Continuation requests can spend more model tokens but must not broaden task
|
|
33
|
+
authority. Bird therefore keeps permission boundaries in its prompt, treats
|
|
34
|
+
completion as a report for review, and restores paused state. It does not inspect
|
|
35
|
+
evidence artifacts or implement a tool permission gate. Stronger enforcement
|
|
36
|
+
would require a separate design and cannot be implied by installation.
|
|
37
|
+
|
|
38
|
+
## Use Shaka's real gates without pretending it builds TypeScript
|
|
39
|
+
|
|
40
|
+
The pinned Shaka binary provides repository preflight and whitespace checks.
|
|
41
|
+
Upstream has no TypeScript project kind, and `shaka build` is currently a stub.
|
|
42
|
+
The root Justfile therefore runs mandatory language checks, coverage, and package
|
|
43
|
+
assembly explicitly, alongside Shaka's repository checks. The hand-authored CI
|
|
44
|
+
workflow is accounted for in `.shaka/repo.cue` rather than masquerading as a
|
|
45
|
+
generated Rust project.
|
|
46
|
+
|
|
47
|
+
This costs a small language-specific build recipe. It avoids changing upstream
|
|
48
|
+
Shaka or silently accepting a no-op build as release verification. Both Nix tools
|
|
49
|
+
and npm dependencies are locked, and the workflow pins action revisions.
|
package/architecture.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Dipping Bird architecture
|
|
2
|
+
|
|
3
|
+
## Purpose and boundaries
|
|
4
|
+
|
|
5
|
+
Bird requests additional work in the current Pi session after a user explicitly
|
|
6
|
+
starts supervision. It does not run another agent, execute task tools, verify
|
|
7
|
+
acceptance evidence, or authorize operations. The user reviews completion.
|
|
8
|
+
|
|
9
|
+
## Components
|
|
10
|
+
|
|
11
|
+
```mermaid
|
|
12
|
+
flowchart LR
|
|
13
|
+
U[User: /bird] --> S[Pi lifecycle adapter]
|
|
14
|
+
S --> C[Pure state transitions]
|
|
15
|
+
S --> J[Read-only jj identity]
|
|
16
|
+
S --> H[Pi session entries]
|
|
17
|
+
C --> S
|
|
18
|
+
S --> P[Pi continuation boundary]
|
|
19
|
+
P --> A[Current agent]
|
|
20
|
+
A --> T[bird_checkpoint]
|
|
21
|
+
T --> S
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
- `extensions/core.ts` owns immutable state transitions, input bounds, prompt
|
|
25
|
+
text, budget checks, and parsing persisted state.
|
|
26
|
+
- `extensions/index.ts` registers `/bird`, `bird_checkpoint`, and Pi lifecycle
|
|
27
|
+
handlers. Its revision counter discards stale asynchronous identity results.
|
|
28
|
+
- Pi owns message scheduling, tool permissions, model calls, and persistence.
|
|
29
|
+
The manifest exposes only `extensions/index.ts` as an extension entry point.
|
|
30
|
+
|
|
31
|
+
## State and lifecycle
|
|
32
|
+
|
|
33
|
+
The `dipping-bird-v1` custom entry contains the goal, canonical directory, jj
|
|
34
|
+
change pin, original start time, continuation count, checkpoint, and mode.
|
|
35
|
+
Restoration reads only the active session branch and always yields paused state.
|
|
36
|
+
Malformed latest state clears earlier state rather than falling back to an older
|
|
37
|
+
armed window. Checkpoints are session data, not independent proof.
|
|
38
|
+
|
|
39
|
+
A start queues a nonce-bearing user prompt while Bird remains paused. Only the
|
|
40
|
+
exact prompt with a verified pin and remaining budget can arm at `agent_start`.
|
|
41
|
+
Stop, lifecycle replacement, and final settlement invalidate pending lookups.
|
|
42
|
+
`agent_before_settle` appends its proposal after earlier extensions' entries;
|
|
43
|
+
it does not duplicate work when another continuation or message is pending.
|
|
44
|
+
|
|
45
|
+
`running`, `paused`, `blocked`, and `review` are the persisted modes. `review`
|
|
46
|
+
means completion reported. Blocked, paused, and review states require an explicit
|
|
47
|
+
user restart before Bird supervises further work. Compaction keeps the current
|
|
48
|
+
window; reload and tree navigation do not re-arm it.
|
|
49
|
+
|
|
50
|
+
## Operation
|
|
51
|
+
|
|
52
|
+
See [the README](README.md#limits-and-safety) for limits and operator commands.
|
|
53
|
+
Identity lookup fails closed on timeout, process failure, malformed output, or
|
|
54
|
+
pin drift. Elapsed limits are checked between runs and again when queued initial
|
|
55
|
+
work arms, not by an interrupting timer. Bird cannot preempt an in-flight tool
|
|
56
|
+
when its elapsed cap expires.
|
|
57
|
+
|
|
58
|
+
Builds ship TypeScript source. Pi supplies the peer imports. The package smoke
|
|
59
|
+
check installs the real tarball without peers or development dependencies and
|
|
60
|
+
loads it with the pinned SDK in an isolated agent directory. CI uses the same
|
|
61
|
+
validation recipes as local development. CI results and live protection must
|
|
62
|
+
be observed separately from the configuration committed here.
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
export const MAX_CONTINUATIONS = 60;
|
|
2
|
+
export const MAX_ELAPSED_MS = 2 * 60 * 60 * 1000;
|
|
3
|
+
export const STATE_KEY = "dipping-bird-v1";
|
|
4
|
+
|
|
5
|
+
export type Mode = "running" | "paused" | "blocked" | "review";
|
|
6
|
+
export type Verdict = "continue" | "blocked" | "complete" | "pause";
|
|
7
|
+
export type State = Readonly<{
|
|
8
|
+
version: 1;
|
|
9
|
+
mode: Mode;
|
|
10
|
+
goal: string;
|
|
11
|
+
cwd: string;
|
|
12
|
+
change: string;
|
|
13
|
+
startedAt: number;
|
|
14
|
+
continuations: number;
|
|
15
|
+
summary: string;
|
|
16
|
+
evidence: readonly string[];
|
|
17
|
+
}>;
|
|
18
|
+
|
|
19
|
+
export const clean = (text: string): string =>
|
|
20
|
+
text.replace(/\p{Cc}/gu, " ").trim();
|
|
21
|
+
|
|
22
|
+
export function start(
|
|
23
|
+
goal: string,
|
|
24
|
+
cwd: string,
|
|
25
|
+
change: string,
|
|
26
|
+
now: number,
|
|
27
|
+
): State {
|
|
28
|
+
const normalized = clean(goal);
|
|
29
|
+
if (
|
|
30
|
+
!normalized ||
|
|
31
|
+
normalized.length > 4000 ||
|
|
32
|
+
!cwd ||
|
|
33
|
+
!Number.isFinite(now) ||
|
|
34
|
+
now < 0 ||
|
|
35
|
+
!/^[a-z]{8}$/.test(change)
|
|
36
|
+
) {
|
|
37
|
+
throw new Error("A bounded goal and jj change identity are required.");
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
version: 1,
|
|
41
|
+
mode: "running",
|
|
42
|
+
goal: normalized,
|
|
43
|
+
cwd,
|
|
44
|
+
change,
|
|
45
|
+
startedAt: now,
|
|
46
|
+
continuations: 0,
|
|
47
|
+
summary: "Started explicitly by the user.",
|
|
48
|
+
evidence: [],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function pause(state: State, summary: string): State {
|
|
53
|
+
return { ...state, mode: "paused", summary: clean(summary) };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function checkpoint(
|
|
57
|
+
state: State,
|
|
58
|
+
verdict: Verdict,
|
|
59
|
+
summary: string,
|
|
60
|
+
evidence: readonly string[],
|
|
61
|
+
): State {
|
|
62
|
+
if (state.mode !== "running")
|
|
63
|
+
throw new Error("Bird is not running; use /bird start.");
|
|
64
|
+
const detail = clean(summary);
|
|
65
|
+
const refs = evidence.map(clean);
|
|
66
|
+
if (
|
|
67
|
+
!detail ||
|
|
68
|
+
detail.length > 2000 ||
|
|
69
|
+
refs.length > 32 ||
|
|
70
|
+
refs.some((ref) => !ref || ref.length > 1000)
|
|
71
|
+
) {
|
|
72
|
+
throw new Error(
|
|
73
|
+
"Provide a bounded summary and nonempty evidence references.",
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
if (verdict === "complete" && refs.length === 0) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
"Completion requires references covering every acceptance criterion.",
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
...state,
|
|
83
|
+
mode:
|
|
84
|
+
verdict === "complete"
|
|
85
|
+
? "review"
|
|
86
|
+
: verdict === "blocked"
|
|
87
|
+
? "blocked"
|
|
88
|
+
: verdict === "pause"
|
|
89
|
+
? "paused"
|
|
90
|
+
: "running",
|
|
91
|
+
summary: detail,
|
|
92
|
+
evidence: refs,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function hasBudget(state: State, now: number): boolean {
|
|
97
|
+
return (
|
|
98
|
+
Number.isFinite(now) &&
|
|
99
|
+
now >= state.startedAt &&
|
|
100
|
+
now - state.startedAt < MAX_ELAPSED_MS &&
|
|
101
|
+
state.continuations < MAX_CONTINUATIONS
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function advance(
|
|
106
|
+
state: State,
|
|
107
|
+
now: number,
|
|
108
|
+
outcome: string,
|
|
109
|
+
sameIdentity: boolean,
|
|
110
|
+
): State {
|
|
111
|
+
if (state.mode !== "running") return state;
|
|
112
|
+
if (outcome !== "completed")
|
|
113
|
+
return pause(state, `Run ${outcome}; automatic continuation stopped.`);
|
|
114
|
+
if (!sameIdentity)
|
|
115
|
+
return pause(
|
|
116
|
+
state,
|
|
117
|
+
"Working directory or jj change differs from the start pin.",
|
|
118
|
+
);
|
|
119
|
+
if (!hasBudget(state, now))
|
|
120
|
+
return pause(
|
|
121
|
+
state,
|
|
122
|
+
state.continuations >= MAX_CONTINUATIONS
|
|
123
|
+
? "60 automatic continuations reached."
|
|
124
|
+
: "Two-hour continuation limit reached (checked between runs).",
|
|
125
|
+
);
|
|
126
|
+
return { ...state, continuations: state.continuations + 1 };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function restore(raw: unknown): State | undefined {
|
|
130
|
+
if (typeof raw !== "object" || raw === null) return undefined;
|
|
131
|
+
if (
|
|
132
|
+
!("version" in raw) ||
|
|
133
|
+
raw.version !== 1 ||
|
|
134
|
+
!("mode" in raw) ||
|
|
135
|
+
!["running", "paused", "blocked", "review"].some(
|
|
136
|
+
(mode) => mode === raw.mode,
|
|
137
|
+
)
|
|
138
|
+
)
|
|
139
|
+
return undefined;
|
|
140
|
+
if (
|
|
141
|
+
!("goal" in raw) ||
|
|
142
|
+
typeof raw.goal !== "string" ||
|
|
143
|
+
!clean(raw.goal) ||
|
|
144
|
+
raw.goal.length > 4000 ||
|
|
145
|
+
!("cwd" in raw) ||
|
|
146
|
+
typeof raw.cwd !== "string" ||
|
|
147
|
+
!raw.cwd ||
|
|
148
|
+
!("change" in raw) ||
|
|
149
|
+
typeof raw.change !== "string" ||
|
|
150
|
+
!/^[a-z]{8}$/.test(raw.change) ||
|
|
151
|
+
!("startedAt" in raw) ||
|
|
152
|
+
typeof raw.startedAt !== "number" ||
|
|
153
|
+
!Number.isFinite(raw.startedAt) ||
|
|
154
|
+
raw.startedAt < 0 ||
|
|
155
|
+
!("continuations" in raw) ||
|
|
156
|
+
typeof raw.continuations !== "number" ||
|
|
157
|
+
!Number.isInteger(raw.continuations) ||
|
|
158
|
+
raw.continuations < 0 ||
|
|
159
|
+
raw.continuations > MAX_CONTINUATIONS ||
|
|
160
|
+
!("summary" in raw) ||
|
|
161
|
+
typeof raw.summary !== "string" ||
|
|
162
|
+
raw.summary.length > 2000 ||
|
|
163
|
+
!("evidence" in raw) ||
|
|
164
|
+
!Array.isArray(raw.evidence)
|
|
165
|
+
)
|
|
166
|
+
return undefined;
|
|
167
|
+
const evidence: unknown[] = raw.evidence;
|
|
168
|
+
if (
|
|
169
|
+
evidence.length > 32 ||
|
|
170
|
+
!evidence.every(
|
|
171
|
+
(ref): ref is string =>
|
|
172
|
+
typeof ref === "string" && !!clean(ref) && ref.length <= 1000,
|
|
173
|
+
)
|
|
174
|
+
)
|
|
175
|
+
return undefined;
|
|
176
|
+
return {
|
|
177
|
+
version: 1,
|
|
178
|
+
mode: "paused",
|
|
179
|
+
goal: clean(raw.goal),
|
|
180
|
+
cwd: raw.cwd,
|
|
181
|
+
change: raw.change,
|
|
182
|
+
startedAt: raw.startedAt,
|
|
183
|
+
continuations: raw.continuations,
|
|
184
|
+
summary:
|
|
185
|
+
"Restored paused; /bird start explicitly resumes with the remaining limits.",
|
|
186
|
+
evidence: evidence.map(clean),
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export function prompt(state: State): string {
|
|
191
|
+
return `[BIRD: acceptance-driven continuation, ${state.continuations}/${MAX_CONTINUATIONS} automatic continuations]
|
|
192
|
+
Goal: ${state.goal}
|
|
193
|
+
Stay in the pinned working directory and jj change ${state.change}. Do not use Git, create a change/commit/workspace/PR, spawn helper agents, or change the task's constraints.
|
|
194
|
+
Work through authorized investigation, implementation, tests, and validation without asking the user to say 'keep going'. Use the existing acceptance criteria/specs, not a new planning document. A passing offline suite or partial fixture is not delivery.
|
|
195
|
+
Before ending, call bird_checkpoint: pause when the user cancels or asks to pause; continue for actionable authorized work; blocked only for a genuine external prerequisite/permission/decision, giving one consolidated actionable request; complete only when EVERY applicable acceptance criterion has evidence, including required native end-to-end and owner/vendor acceptance. Completion is a report for review, not certification by Bird.
|
|
196
|
+
Never invent approvals, renew/reset/borrow live allocations, replay uncertain operations, refresh/login/read caches as agent, expand privileges, delete unexpected resources, weaken checks, or expose sensitive data. A continuation prompt authorizes no new I/O or file modification. Follow existing write-approval and task-specific boundaries. When authority is exhausted, report blocked once rather than repeat prompts or run another diagnostic.
|
|
197
|
+
Checkpoint references must contain only safe paths to evidence/artifacts, hashes, test results and sanitized summaries: no credentials, claims, licensed rows, private principal/root values, raw native errors or exception chains.
|
|
198
|
+
Last checkpoint: ${state.summary}`;
|
|
199
|
+
}
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { realpathSync } from "node:fs";
|
|
3
|
+
import { Type } from "typebox";
|
|
4
|
+
import type {
|
|
5
|
+
ExtensionAPI,
|
|
6
|
+
ExtensionContext,
|
|
7
|
+
} from "@earendil-works/pi-coding-agent";
|
|
8
|
+
import {
|
|
9
|
+
advance,
|
|
10
|
+
checkpoint,
|
|
11
|
+
hasBudget,
|
|
12
|
+
MAX_CONTINUATIONS,
|
|
13
|
+
MAX_ELAPSED_MS,
|
|
14
|
+
pause,
|
|
15
|
+
prompt,
|
|
16
|
+
restore,
|
|
17
|
+
start,
|
|
18
|
+
STATE_KEY,
|
|
19
|
+
type State,
|
|
20
|
+
} from "./core.ts";
|
|
21
|
+
|
|
22
|
+
const DEFAULT_GOAL =
|
|
23
|
+
"Finish the current conversation's task against its existing acceptance criteria and specs. Require evidence for every applicable criterion, native acceptance where required, and resolution of owner/vendor holds. Do not substitute offline test counts, more planning, or harness scaffolding for delivery.";
|
|
24
|
+
|
|
25
|
+
export default function dippingBird(pi: ExtensionAPI): void {
|
|
26
|
+
let state: State | undefined;
|
|
27
|
+
let revision = 0;
|
|
28
|
+
const issuedStarts = new Set<string>();
|
|
29
|
+
let pendingStart:
|
|
30
|
+
{ state: State; prompt: string; ready: boolean } | undefined;
|
|
31
|
+
|
|
32
|
+
const show = (ctx: ExtensionContext): void => {
|
|
33
|
+
ctx.ui.setStatus(
|
|
34
|
+
"dipping-bird",
|
|
35
|
+
state
|
|
36
|
+
? `bird: ${state.mode === "review" ? "completion reported" : state.mode} ${state.continuations}/${MAX_CONTINUATIONS}`
|
|
37
|
+
: undefined,
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
const save = (ctx: ExtensionContext, next: State): void => {
|
|
41
|
+
if (state !== next) revision++;
|
|
42
|
+
state = next;
|
|
43
|
+
pi.appendEntry(STATE_KEY, next);
|
|
44
|
+
show(ctx);
|
|
45
|
+
};
|
|
46
|
+
const identity = async (
|
|
47
|
+
ctx: ExtensionContext,
|
|
48
|
+
): Promise<{ cwd: string; change: string }> => {
|
|
49
|
+
const cwd = realpathSync(ctx.cwd);
|
|
50
|
+
const result = await pi.exec(
|
|
51
|
+
"jj",
|
|
52
|
+
[
|
|
53
|
+
"--ignore-working-copy",
|
|
54
|
+
"log",
|
|
55
|
+
"-r",
|
|
56
|
+
"@",
|
|
57
|
+
"--no-graph",
|
|
58
|
+
"-T",
|
|
59
|
+
"change_id.short(8)",
|
|
60
|
+
],
|
|
61
|
+
{ cwd, timeout: 5000 },
|
|
62
|
+
);
|
|
63
|
+
const change = result.stdout.trim();
|
|
64
|
+
if (result.code !== 0 || result.killed || !/^[a-z]{8}$/.test(change)) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
"Cannot verify the selected jj change; Bird remains paused.",
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
return { cwd, change };
|
|
70
|
+
};
|
|
71
|
+
const sameIdentity = async (
|
|
72
|
+
ctx: ExtensionContext,
|
|
73
|
+
pin: State,
|
|
74
|
+
): Promise<boolean> => {
|
|
75
|
+
try {
|
|
76
|
+
const current = await identity(ctx);
|
|
77
|
+
return current.cwd === pin.cwd && current.change === pin.change;
|
|
78
|
+
} catch {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const recover = (ctx: ExtensionContext): void => {
|
|
83
|
+
pendingStart = undefined;
|
|
84
|
+
revision++;
|
|
85
|
+
state = undefined;
|
|
86
|
+
for (const entry of ctx.sessionManager.getBranch()) {
|
|
87
|
+
if (entry.type === "custom" && entry.customType === STATE_KEY)
|
|
88
|
+
state = restore(entry.data);
|
|
89
|
+
}
|
|
90
|
+
if (state) save(ctx, state);
|
|
91
|
+
else show(ctx);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
pi.registerCommand("bird", {
|
|
95
|
+
description:
|
|
96
|
+
"Acceptance-driven continuation: /bird start [goal], /bird stop, /bird status",
|
|
97
|
+
handler: async (args, ctx) => {
|
|
98
|
+
const [action, ...words] = args.trim().split(/\s+/);
|
|
99
|
+
if (action === "status" || !action) {
|
|
100
|
+
const remaining = state
|
|
101
|
+
? Math.max(
|
|
102
|
+
0,
|
|
103
|
+
Math.ceil(
|
|
104
|
+
(MAX_ELAPSED_MS - (Date.now() - state.startedAt)) / 60000,
|
|
105
|
+
),
|
|
106
|
+
)
|
|
107
|
+
: 0;
|
|
108
|
+
ctx.ui.notify(
|
|
109
|
+
state
|
|
110
|
+
? `Bird: ${state.mode === "review" ? "completion reported — inspect evidence; not independently certified" : state.mode}\nJJ change: ${state.change}; continuations ${state.continuations}/${MAX_CONTINUATIONS}; ${remaining} minutes left, checked between runs.\nGoal: ${state.goal}\nCheckpoint: ${state.summary}\nEvidence: ${state.evidence.join("; ") || "none"}`
|
|
111
|
+
: "Bird is not started. Use /bird start to supervise this task.",
|
|
112
|
+
"info",
|
|
113
|
+
);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (action === "stop") {
|
|
117
|
+
pendingStart = undefined;
|
|
118
|
+
revision++;
|
|
119
|
+
if (state) save(ctx, pause(state, "Stopped explicitly by the user."));
|
|
120
|
+
ctx.abort();
|
|
121
|
+
ctx.ui.notify(
|
|
122
|
+
"Bird stopped. Any delayed start will be aborted.",
|
|
123
|
+
"info",
|
|
124
|
+
);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (action !== "start") {
|
|
128
|
+
ctx.ui.notify("Usage: /bird start [goal] | stop | status", "warning");
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (!ctx.isIdle()) {
|
|
132
|
+
ctx.ui.notify(
|
|
133
|
+
"Wait for the current run or press Escape before starting Bird.",
|
|
134
|
+
"warning",
|
|
135
|
+
);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
pendingStart = undefined;
|
|
139
|
+
const ticket = ++revision;
|
|
140
|
+
try {
|
|
141
|
+
const pin = await identity(ctx);
|
|
142
|
+
if (revision !== ticket) return;
|
|
143
|
+
const goal = words.join(" ").trim();
|
|
144
|
+
if (state && !goal) {
|
|
145
|
+
if (state.mode === "running") {
|
|
146
|
+
ctx.ui.notify("Bird is already running.", "info");
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
if (pin.cwd !== state.cwd || pin.change !== state.change)
|
|
150
|
+
throw new Error("Pin differs; resuming is refused.");
|
|
151
|
+
if (!hasBudget(state, Date.now())) {
|
|
152
|
+
ctx.ui.notify(
|
|
153
|
+
"Supervision cap reached. /bird start <goal> explicitly begins a new model-work window, never a new live-I/O authorization.",
|
|
154
|
+
"warning",
|
|
155
|
+
);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
save(ctx, {
|
|
159
|
+
...state,
|
|
160
|
+
mode: "running",
|
|
161
|
+
summary:
|
|
162
|
+
"Resumed explicitly with remaining limits; no permissions renewed.",
|
|
163
|
+
});
|
|
164
|
+
} else {
|
|
165
|
+
save(
|
|
166
|
+
ctx,
|
|
167
|
+
start(goal || DEFAULT_GOAL, pin.cwd, pin.change, Date.now()),
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
if (state) {
|
|
171
|
+
const next = state;
|
|
172
|
+
const initialPrompt = `[BIRD START ${randomUUID()}]\n${prompt(next)}`;
|
|
173
|
+
save(ctx, pause(next, "Awaiting initial run; Bird remains paused."));
|
|
174
|
+
pendingStart = { state: next, prompt: initialPrompt, ready: false };
|
|
175
|
+
issuedStarts.add(initialPrompt);
|
|
176
|
+
try {
|
|
177
|
+
pi.sendUserMessage(initialPrompt);
|
|
178
|
+
} catch {
|
|
179
|
+
issuedStarts.delete(initialPrompt);
|
|
180
|
+
pendingStart = undefined;
|
|
181
|
+
save(ctx, pause(next, "Initial prompt could not be queued."));
|
|
182
|
+
ctx.ui.notify(
|
|
183
|
+
"Bird paused: initial prompt could not be queued.",
|
|
184
|
+
"warning",
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
} catch {
|
|
189
|
+
if (revision !== ticket) return;
|
|
190
|
+
if (state)
|
|
191
|
+
save(
|
|
192
|
+
ctx,
|
|
193
|
+
pause(state, "Could not verify start/resume identity or goal."),
|
|
194
|
+
);
|
|
195
|
+
ctx.ui.notify(
|
|
196
|
+
"Bird did not start: identity, goal or resume pin could not be verified.",
|
|
197
|
+
"warning",
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
pi.registerTool({
|
|
204
|
+
name: "bird_checkpoint",
|
|
205
|
+
label: "Bird checkpoint",
|
|
206
|
+
description:
|
|
207
|
+
"While Bird is active, report actionable continuation, one genuine external blocker, user-requested pause/cancellation, or completion with evidence references covering ALL acceptance criteria. Never use test counts alone as completion or put sensitive/raw output in the checkpoint. This tool does not authorize work or independently certify completion.",
|
|
208
|
+
exposure: "model-only",
|
|
209
|
+
parameters: Type.Object(
|
|
210
|
+
{
|
|
211
|
+
status: Type.Union([
|
|
212
|
+
Type.Literal("continue"),
|
|
213
|
+
Type.Literal("blocked"),
|
|
214
|
+
Type.Literal("complete"),
|
|
215
|
+
Type.Literal("pause"),
|
|
216
|
+
]),
|
|
217
|
+
summary: Type.String({ minLength: 1, maxLength: 2000 }),
|
|
218
|
+
evidence: Type.Array(Type.String({ minLength: 1, maxLength: 1000 }), {
|
|
219
|
+
maxItems: 32,
|
|
220
|
+
}),
|
|
221
|
+
},
|
|
222
|
+
{ additionalProperties: false },
|
|
223
|
+
),
|
|
224
|
+
async execute(_id, params, signal, _update, ctx) {
|
|
225
|
+
if (signal?.aborted) throw new Error("Checkpoint cancelled.");
|
|
226
|
+
if (!state || state.mode !== "running")
|
|
227
|
+
throw new Error(
|
|
228
|
+
"Bird is not running. Only the user can start it with /bird start.",
|
|
229
|
+
);
|
|
230
|
+
const pin = state;
|
|
231
|
+
const ticket = revision;
|
|
232
|
+
const matches = await sameIdentity(ctx, pin);
|
|
233
|
+
if (signal?.aborted) throw new Error("Checkpoint cancelled.");
|
|
234
|
+
if (revision !== ticket)
|
|
235
|
+
throw new Error("Bird changed while checking; checkpoint refused.");
|
|
236
|
+
if (!matches) {
|
|
237
|
+
save(ctx, pause(pin, "Identity drift; checkpoint refused."));
|
|
238
|
+
throw new Error("Bird pin differs; no checkpoint accepted.");
|
|
239
|
+
}
|
|
240
|
+
const next = checkpoint(
|
|
241
|
+
state,
|
|
242
|
+
params.status,
|
|
243
|
+
params.summary,
|
|
244
|
+
params.evidence,
|
|
245
|
+
);
|
|
246
|
+
save(ctx, next);
|
|
247
|
+
const text =
|
|
248
|
+
next.mode === "review"
|
|
249
|
+
? `Completion reported, not independently certified by Bird. Review criterion-by-criterion evidence: ${next.evidence.join("; ")}`
|
|
250
|
+
: `Bird ${next.mode}: ${next.summary}`;
|
|
251
|
+
return {
|
|
252
|
+
content: [{ type: "text", text }],
|
|
253
|
+
details: {
|
|
254
|
+
mode: next.mode,
|
|
255
|
+
summary: next.summary,
|
|
256
|
+
evidence: next.evidence,
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
},
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
pi.on("session_start", (_event, ctx) => recover(ctx));
|
|
263
|
+
pi.on("session_tree", (_event, ctx) => recover(ctx));
|
|
264
|
+
pi.on("session_compact", (_event, ctx) => {
|
|
265
|
+
if (state) save(ctx, state);
|
|
266
|
+
});
|
|
267
|
+
pi.on("session_shutdown", (_event, ctx) => {
|
|
268
|
+
pendingStart = undefined;
|
|
269
|
+
revision++;
|
|
270
|
+
if (state?.mode === "running")
|
|
271
|
+
save(
|
|
272
|
+
ctx,
|
|
273
|
+
pause(state, "Session ended/reloaded; explicitly restart Bird."),
|
|
274
|
+
);
|
|
275
|
+
});
|
|
276
|
+
pi.on("input", (event, ctx) => {
|
|
277
|
+
if (event.source === "extension") return;
|
|
278
|
+
pendingStart = undefined;
|
|
279
|
+
revision++;
|
|
280
|
+
if (["stop", "pause"].includes(event.text.trim().toLowerCase())) {
|
|
281
|
+
if (state) save(ctx, pause(state, "User requested a stop/pause."));
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
pi.on("before_agent_start", async (event, ctx) => {
|
|
285
|
+
const birdStart =
|
|
286
|
+
event.messageType === "user" && issuedStarts.delete(event.prompt);
|
|
287
|
+
const pending = pendingStart;
|
|
288
|
+
if (pending) {
|
|
289
|
+
pendingStart = undefined;
|
|
290
|
+
const ticket = revision;
|
|
291
|
+
if (
|
|
292
|
+
event.messageType === "user" &&
|
|
293
|
+
event.prompt === pending.prompt &&
|
|
294
|
+
(await sameIdentity(ctx, pending.state)) &&
|
|
295
|
+
revision === ticket &&
|
|
296
|
+
hasBudget(pending.state, Date.now())
|
|
297
|
+
) {
|
|
298
|
+
pendingStart = { ...pending, ready: true };
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
// Preflight can outlive stop; abort again once Pi owns the run.
|
|
302
|
+
if (birdStart && !pendingStart?.ready) {
|
|
303
|
+
ctx.abort();
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
if (state?.mode !== "running") return;
|
|
307
|
+
const pin = state;
|
|
308
|
+
const ticket = revision;
|
|
309
|
+
const matches = await sameIdentity(ctx, pin);
|
|
310
|
+
if (revision !== ticket) return;
|
|
311
|
+
if (!matches) {
|
|
312
|
+
save(ctx, pause(pin, "Working directory or jj change drifted."));
|
|
313
|
+
return {
|
|
314
|
+
message: {
|
|
315
|
+
customType: "bird-paused",
|
|
316
|
+
content:
|
|
317
|
+
"Bird paused on workspace/change drift. Do not continue automatically outside the selected scope.",
|
|
318
|
+
display: true,
|
|
319
|
+
},
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
return {
|
|
323
|
+
message: {
|
|
324
|
+
customType: "bird-context",
|
|
325
|
+
content: prompt(state),
|
|
326
|
+
display: false,
|
|
327
|
+
},
|
|
328
|
+
};
|
|
329
|
+
});
|
|
330
|
+
pi.on("agent_start", (_event, ctx) => {
|
|
331
|
+
if (!pendingStart?.ready) return;
|
|
332
|
+
const next = pendingStart.state;
|
|
333
|
+
pendingStart = undefined;
|
|
334
|
+
if (!hasBudget(next, Date.now())) {
|
|
335
|
+
save(
|
|
336
|
+
ctx,
|
|
337
|
+
pause(next, "Supervision window expired before the initial run."),
|
|
338
|
+
);
|
|
339
|
+
ctx.abort();
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
save(ctx, next);
|
|
343
|
+
});
|
|
344
|
+
pi.on("agent_settled", (event, ctx) => {
|
|
345
|
+
pendingStart = undefined;
|
|
346
|
+
revision++;
|
|
347
|
+
if (!event.aborted) return;
|
|
348
|
+
if (state?.mode === "running")
|
|
349
|
+
save(ctx, pause(state, "Run aborted; explicitly restart Bird."));
|
|
350
|
+
});
|
|
351
|
+
pi.on("agent_before_settle", async (event, ctx) => {
|
|
352
|
+
if (state?.mode !== "running") return;
|
|
353
|
+
if (
|
|
354
|
+
event.outcome === "completed" &&
|
|
355
|
+
(event.continue || ctx.hasPendingMessages())
|
|
356
|
+
)
|
|
357
|
+
return;
|
|
358
|
+
const pin = state;
|
|
359
|
+
const ticket = revision;
|
|
360
|
+
const matches = await sameIdentity(ctx, pin);
|
|
361
|
+
if (revision !== ticket) return;
|
|
362
|
+
const next = advance(pin, Date.now(), event.outcome, matches);
|
|
363
|
+
revision++;
|
|
364
|
+
state = next;
|
|
365
|
+
show(ctx);
|
|
366
|
+
if (next.mode !== "running") {
|
|
367
|
+
if (ctx.hasUI) ctx.ui.notify(`Bird paused: ${next.summary}`, "warning");
|
|
368
|
+
return {
|
|
369
|
+
entries: [
|
|
370
|
+
...event.entries,
|
|
371
|
+
{ type: "custom", customType: STATE_KEY, data: next },
|
|
372
|
+
],
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
return {
|
|
376
|
+
entries: [
|
|
377
|
+
...event.entries,
|
|
378
|
+
{ type: "custom", customType: STATE_KEY, data: next },
|
|
379
|
+
{
|
|
380
|
+
type: "custom_message",
|
|
381
|
+
customType: "bird-continue",
|
|
382
|
+
content: prompt(next),
|
|
383
|
+
display: false,
|
|
384
|
+
},
|
|
385
|
+
],
|
|
386
|
+
continue: true,
|
|
387
|
+
};
|
|
388
|
+
});
|
|
389
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,85 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolohelios/dipping-bird",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Opt-in, bounded, evidence-driven continuation for the Pi coding agent (jj workspaces).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT OR Apache-2.0",
|
|
7
|
+
"author": "Jon Edwards <jkedwards@me.com>",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/kolohelios/dipping-bird.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/kolohelios/dipping-bird#readme",
|
|
13
|
+
"bugs": "https://github.com/kolohelios/dipping-bird/issues",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"pi-package",
|
|
16
|
+
"pi-extension",
|
|
17
|
+
"continuation",
|
|
18
|
+
"jujutsu"
|
|
19
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=22.19.0"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"extensions/*.ts",
|
|
25
|
+
"README.md",
|
|
26
|
+
"CHANGELOG.md",
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"LICENSE-MIT",
|
|
29
|
+
"LICENSE-APACHE",
|
|
30
|
+
"architecture.md",
|
|
31
|
+
"architecture-decision-record.md"
|
|
32
|
+
],
|
|
33
|
+
"pi": {
|
|
34
|
+
"extensions": [
|
|
35
|
+
"./extensions/index.ts"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
40
|
+
"typebox": "*"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@earendil-works/pi-coding-agent": "1.5.2",
|
|
44
|
+
"@eslint/js": "10.0.1",
|
|
45
|
+
"@types/node": "24.19.2",
|
|
46
|
+
"c8": "9.1.0",
|
|
47
|
+
"eslint": "10.15.0",
|
|
48
|
+
"globals": "17.4.0",
|
|
49
|
+
"prettier": "3.10.1",
|
|
50
|
+
"typebox": "1.4.7",
|
|
51
|
+
"typescript": "6.0.3",
|
|
52
|
+
"typescript-eslint": "8.73.0",
|
|
53
|
+
"yaml": "2.9.1"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"typecheck": "tsc --noEmit",
|
|
57
|
+
"lint": "eslint extensions test",
|
|
58
|
+
"format:check": "prettier --check .",
|
|
59
|
+
"format": "prettier --write .",
|
|
60
|
+
"test": "node --test test/*.test.mjs",
|
|
61
|
+
"build": "node --test test/package.test.mjs",
|
|
62
|
+
"coverage": "c8 node --test test/*.test.mjs"
|
|
63
|
+
},
|
|
64
|
+
"c8": {
|
|
65
|
+
"all": true,
|
|
66
|
+
"include": [
|
|
67
|
+
"extensions/**/*.ts"
|
|
68
|
+
],
|
|
69
|
+
"extension": [
|
|
70
|
+
".ts"
|
|
71
|
+
],
|
|
72
|
+
"check-coverage": true,
|
|
73
|
+
"per-file": true,
|
|
74
|
+
"statements": 90,
|
|
75
|
+
"branches": 90,
|
|
76
|
+
"functions": 90,
|
|
77
|
+
"lines": 90,
|
|
78
|
+
"reporter": [
|
|
79
|
+
"text",
|
|
80
|
+
"html",
|
|
81
|
+
"lcov",
|
|
82
|
+
"json-summary"
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
}
|