Skip to content

Commit aee70b1

Browse files
committed
Audit and correct package documentation
1 parent fb117e3 commit aee70b1

10 files changed

Lines changed: 89 additions & 56 deletions

File tree

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ First-class [Sprites](https://sprites.dev) environments for the [Pi coding agent
99

1010
## Install
1111

12-
Until the first npm release, install directly from GitHub:
12+
`pi-sprites` is not published to npm. Until the first npm release, install it
13+
directly from GitHub (the repository must be public or your Git client must
14+
already have access):
1315

1416
```bash
1517
pi install git:github.com/superfly/pi-sprites
@@ -24,6 +26,7 @@ pi install npm:pi-sprites
2426
For development from this checkout:
2527

2628
```bash
29+
npm ci
2730
pi -e ./extensions/core.ts \
2831
-e ./extensions/checkpoints.ts \
2932
-e ./extensions/services.ts \
@@ -85,7 +88,7 @@ See the [extension guide](./docs/README.md) for prerequisites, configuration, co
8588

8689
## Project configuration
8790

88-
Copy [`templates/sprites.json`](./templates/sprites.json) to `.pi/sprites.json` and adjust it for the project. Project configuration overrides `~/.pi/agent/sprites.json`; ignored `.pi/sprites.local.json` overrides both.
91+
Copy [`templates/sprites.json`](./templates/sprites.json) to `.pi/sprites.json` and adjust it for the project. Project configuration overrides `~/.pi/agent/sprites.json`; a machine-local `.pi/sprites.local.json` overrides both. Add the local file to the project's `.gitignore` before putting machine-specific or sensitive values in it.
8992

9093
The major sections are:
9194

@@ -104,11 +107,11 @@ With the default `toolActivation: "auto"`, commands remain available but the eig
104107

105108
## Checkpoints
106109

107-
The default `risky` mode creates one safety checkpoint before the first write, edit, destructive shell command, or mutating Sprite management tool in a Pi turn. `turn` applies the same once-per-turn checkpoint to any mutation; `off` disables automatic checkpoints.
110+
The default `risky` mode creates one safety checkpoint before the first write, edit, recognized destructive shell command, or service, policy, or RPC-host model tool in a Pi turn. Those three model tools are conservatively treated as risky even for read-only actions. `turn` applies the same once-per-turn checkpoint before any tool call; `off` disables automatic checkpoints.
108111

109112
Restore remains command-only and requires confirmation. Checkpoints contain the filesystem, installed packages, configuration, and on-disk databases. They do not contain running processes, memory, or open connections.
110113

111-
Checkpoint deletion and filesystem diffs are intentionally not implemented until the public Sprites SDK exposes stable APIs for them. The package does not reach through SDK internals or assume a private checkpoint mount layout.
114+
Checkpoint deletion and filesystem diffs are intentionally not implemented because the installed public JavaScript SDK does not expose stable APIs for them. The package does not reach through SDK internals or assume a private checkpoint mount layout.
112115

113116
## Services and networking
114117

@@ -153,17 +156,17 @@ This installs Pi as a Sprite service and exposes it locally through a TCP proxy.
153156
- `POST /rpc`
154157
- `GET /events` as server-sent events
155158

156-
The service has no public HTTP port by default. When `rpcHost.httpPort` is configured, the secret named by `rpcHost.secretEnv` must be present; requests must send it as `Authorization: Bearer ...`.
159+
The service is not routed through the Sprite URL by default. When `rpcHost.httpPort` is configured, the secret named by `rpcHost.secretEnv` must be present and requests must send it as `Authorization: Bearer ...`. Configuring the service port does not change the Sprite URL's own `sprite` (authenticated) or `public` access setting.
157160

158161
## Safety defaults
159162

160163
- Sprite destruction and checkpoint restore are command-only and confirmed.
161164
- CI and workers are retained unless cleanup is explicitly configured.
162165
- The RPC host is local-proxy-only unless configured otherwise.
163166
- Public URL access is never enabled automatically.
164-
- Provider credentials are not copied into Sprites.
167+
- Local provider credentials are not copied into Sprites automatically.
165168
- Project setup commands run only from a trusted project's configuration.
166-
- New, resumed, and forked Pi sessions reset selection, proxies, and last-checkpoint state.
169+
- New, resumed, and forked Pi sessions reset transient selection to configured defaults and clear proxies and last-checkpoint state.
167170

168171
Pi packages execute with the user's full permissions. Review package source before installation, just as you would any other Pi extension.
169172

docs/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Testing guides:
2121

2222
## How Pi treats these files
2323

24-
Pi packages have runtime resource types for extensions, skills, prompts, and themes. There is no separate documentation resource type. These Markdown files are shipped in the npm package and linked from the top-level README, but are deliberately absent from the `pi` manifest. Pi therefore does not load them as prompts or place them in model context.
24+
Pi packages have runtime resource types for extensions, skills, prompts, and themes. There is no separate documentation resource type. These Markdown files are shipped with the package and linked from the top-level README, but are deliberately absent from the `pi` manifest. Pi therefore does not load them as prompts or place them in model context. See Pi's [package documentation](https://pi.dev/docs/latest/packages) for the resource and filtering model.
2525

2626
Commands beginning with `/sprite-` are always available when their extension is loaded and are initiated by the user. Tools named `sprite_*` are callable by the model. With the default `toolActivation: "auto"`, those model tools become active only after a Sprite is selected or when Pi itself is running inside a Sprite. See [Core remote environment](./core.md#model-tool-activation) for the other activation modes.
2727

@@ -30,19 +30,19 @@ Commands beginning with `/sprite-` are always available when their extension is
3030
- Node.js 24 or later.
3131
- A Sprites token in `SPRITES_TOKEN`, `SPRITE_TOKEN`, or the variable named by `tokenEnv`.
3232
- A selected or configured Sprite for extensions that operate on the current environment. Checkpoints can also use `sprite-env` when Pi itself runs inside a Sprite. Bootstrap, CI, and workers can provision explicitly named Sprites without changing the user's selection.
33-
- Project trust before `.pi/sprites.json` or `.pi/sprites.local.json` is honored. Global `~/.pi/agent/sprites.json` remains available outside a trusted project.
33+
- Project trust before `.pi/sprites.json` or `.pi/sprites.local.json` is honored. Global `~/.pi/agent/sprites.json` remains available outside a trusted project. Add `.pi/sprites.local.json` to the consuming project's `.gitignore` before using it for local-only values.
3434

3535
Start with the configuration template at [`templates/sprites.json`](../templates/sprites.json).
3636

3737
## Filtering extensions
3838

39-
Pi package filters can narrow the extension list. For example, this project setting keeps only core routing and checkpoints:
39+
Pi package filters can narrow the extension list. For example, this entry in the project's `.pi/settings.json` keeps only core routing and checkpoints for the current Git installation:
4040

4141
```json
4242
{
4343
"packages": [
4444
{
45-
"source": "npm:pi-sprites",
45+
"source": "git:github.com/superfly/pi-sprites",
4646
"extensions": [
4747
"+extensions/core.ts",
4848
"+extensions/checkpoints.ts"

docs/automated-testing.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,16 @@ export SPRITES_TOKEN='...'
9797
pi -p --no-session \
9898
-e ./extensions/core.ts -e ./extensions/checkpoints.ts \
9999
-e ./extensions/services.ts -e ./extensions/policy.ts \
100-
"Create a Sprite named agent-smoke, write /workspace/agent-smoke/ok.txt, \
101-
read it back, create a checkpoint, then destroy the Sprite."
100+
"Create a Sprite named agent-smoke, select /workspace/agent-smoke as its \
101+
working directory, write ok.txt, read it back, create a checkpoint, and \
102+
report the Sprite name for manual cleanup."
102103
```
103104

104105
This is the closest match to "an agent does the testing," but it is
105106
non-deterministic (results depend on the model). Use it for exploratory or
106107
acceptance-style checks, and Approach A for deterministic regression gating.
108+
Destruction is intentionally unavailable to model tools; clean up afterward in
109+
an interactive Pi session with `/sprite-destroy agent-smoke` and confirm it.
107110

108111
## Approach C — Drive a durable Pi over RPC
109112

@@ -115,8 +118,9 @@ host and talk to it over HTTP:
115118
/sprite-rpc proxy
116119
```
117120

118-
Then `POST /rpc` with JSON-line requests, subscribe to `GET /events`, and poll
119-
`GET /health`. See [rpc-host.md](./rpc-host.md). This is useful when the tester is
121+
Then send one JSON command object in each `POST /rpc` HTTP body, subscribe to
122+
`GET /events`, and poll `GET /health`. The host handles JSONL framing toward the
123+
Pi child process. See [rpc-host.md](./rpc-host.md). This is useful when the tester is
120124
itself an autonomous agent that needs a persistent session rather than one-shot
121125
prompts.
122126

docs/checkpoints.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ A selected Sprite is required unless Pi itself is running inside a Sprite, where
3131
Modes are:
3232

3333
- `off`: no automatic checkpoints.
34-
- `risky` (default): once per turn, before the first write, edit, recognized destructive shell command, or mutating service, policy, or RPC-host tool call.
35-
- `turn`: once per turn before the first mutating tool call.
34+
- `risky` (default): once per turn, before the first write, edit, recognized destructive shell command, or service, policy, or RPC-host model-tool call. Those three model tools are conservatively treated as risky for every action, including inspection.
35+
- `turn`: once per turn before the first tool call, whether or not that tool is expected to mutate state.
3636

3737
If a required automatic checkpoint fails, the mutation is blocked rather than allowed to continue without a recovery point.
3838

@@ -44,6 +44,6 @@ Bootstrap, CI, and worker tool calls do not checkpoint the user's selected Sprit
4444

4545
## Limitations
4646

47-
Checkpoint deletion and filesystem diff are not implemented. Those operations currently require SDK internals or an unstable on-disk layout; `pi-sprites` waits for stable public SDK APIs instead.
47+
Checkpoint deletion and filesystem diff are not implemented. The installed public JavaScript SDK does not expose those operations, and implementing them would require a hand-written API call or an unstable on-disk layout. `pi-sprites` avoids both.
4848

4949
Restoring may terminate active processes and sessions. Services should restart according to the Sprite service manager, but arbitrary foreground processes will not be recreated.

docs/core.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ After `/sprite-use` or `/sprite-new`, these normal Pi operations target `remoteC
1010
- interactive `!` shell commands
1111
- the working-directory line added to the agent's system prompt
1212

13-
`/sprite-local` returns those operations to the machine running Pi. Selection and open proxies reset when a Pi session starts, ends, resumes, forks, or is replaced.
13+
`/sprite-local` returns those operations to the machine running Pi. When a Pi session starts, resumes, forks, or is replaced, transient selection resets and configuration is reapplied; a configured `sprite` may therefore become selected again. Open proxies and last-checkpoint state are cleared between sessions.
1414

1515
## Commands
1616

@@ -74,7 +74,7 @@ The setting does not disable Pi's normal filesystem tools; it only changes wheth
7474
}
7575
```
7676

77-
- `mode`: `auto`, `local`, or `remote`. `auto` uses remote routing when a Sprite is selected.
77+
- `mode`: `local` always keeps native tools on the Pi host; `remote` routes them when a Sprite is selected, including when Pi itself runs inside a Sprite; `auto` routes to a selected Sprite only when Pi is running outside one.
7878
- `sprite`: initial configured Sprite name.
7979
- `remoteCwd`: workspace directory inside the Sprite; otherwise `/workspace/<local-project-name>`.
8080
- `baseURL`: optional Sprites API endpoint override.

docs/manual-test-plan.md

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,24 @@ logic. This plan covers the interactive experience those tests cannot.
2121
```bash
2222
export SPRITES_TOKEN='...'
2323
```
24-
- This checkout installed, and a scratch Git project to point bootstrap/CI at.
24+
- This checkout with `npm ci` completed, and a scratch Git project whose
25+
`origin` is reachable from a Sprite without copying local credentials. Its
26+
configured CI commands should be safe to run.
2527
- A throwaway Sprite name to avoid touching real work, e.g. `pi-sprites-test`.
2628

27-
Launch Pi with all extensions from this checkout:
29+
From the scratch project, set the checkout path and launch Pi with all
30+
extensions:
2831

2932
```bash
30-
pi -e ./extensions/core.ts \
31-
-e ./extensions/checkpoints.ts \
32-
-e ./extensions/services.ts \
33-
-e ./extensions/policy.ts \
34-
-e ./extensions/bootstrap.ts \
35-
-e ./extensions/ci.ts \
36-
-e ./extensions/workers.ts \
37-
-e ./extensions/rpc-host.ts
33+
PI_SPRITES_CHECKOUT=/absolute/path/to/pi-sprites
34+
pi -e "$PI_SPRITES_CHECKOUT/extensions/core.ts" \
35+
-e "$PI_SPRITES_CHECKOUT/extensions/checkpoints.ts" \
36+
-e "$PI_SPRITES_CHECKOUT/extensions/services.ts" \
37+
-e "$PI_SPRITES_CHECKOUT/extensions/policy.ts" \
38+
-e "$PI_SPRITES_CHECKOUT/extensions/bootstrap.ts" \
39+
-e "$PI_SPRITES_CHECKOUT/extensions/ci.ts" \
40+
-e "$PI_SPRITES_CHECKOUT/extensions/workers.ts" \
41+
-e "$PI_SPRITES_CHECKOUT/extensions/rpc-host.ts"
3842
```
3943

4044
Cleanup is at the end. Nothing here enables public URLs or copies credentials.
@@ -45,14 +49,15 @@ Cleanup is at the end. Nothing here enables public URLs or copies credentials.
4549

4650
| Step | Action | Expect |
4751
|---|---|---|
48-
| 1.1 | `/sprite status` | Reports local mode, no Sprite selected. |
52+
| 1.1 | `/sprite status` | Reports the current mode. With no global `sprite` configured, this is local mode with no selection. |
4953
| 1.2 | `/sprite list` | Lists your Sprites (or empty). Confirms auth works. |
50-
| 1.3 | `/sprite new pi-sprites-test` | Creates and selects the Sprite. |
51-
| 1.4 | `!pwd` | Runs in the **remote** Sprite, prints `remoteCwd` (`/workspace/pi-sprites-test`). |
52-
| 1.5 | `write` a file `hello.txt` with some text | File is created remotely. |
53-
| 1.6 | `read hello.txt` / `ls` | Shows the remote file. Confirms `read`/`write`/`ls` are routed. |
54-
| 1.7 | `/sprite-local` then `!pwd` | Returns to your **local** machine's cwd. |
55-
| 1.8 | `/sprite-use pi-sprites-test` then `ls` | Back on the remote workspace, file still present. |
54+
| 1.3 | `/sprite new pi-sprites-test` | Creates and selects the Sprite. Its initial `remoteCwd` is derived from the local project unless configured. |
55+
| 1.4 | `/sprite-use pi-sprites-test /workspace/pi-sprites-test` | Selects an explicit test working directory. |
56+
| 1.5 | `!mkdir -p /workspace/pi-sprites-test` then `!pwd` | Creates the workspace and prints `/workspace/pi-sprites-test` from the **remote** Sprite. |
57+
| 1.6 | Ask Pi to write a file `hello.txt` with some text | The `write` tool creates the file remotely. |
58+
| 1.7 | Ask Pi to read `hello.txt` and list the directory | The `read` and `ls` tools show the remote file. |
59+
| 1.8 | `/sprite-local` then `!pwd` | Returns to your **local** machine's cwd. |
60+
| 1.9 | `/sprite-use pi-sprites-test /workspace/pi-sprites-test` then ask Pi to list the directory | Back in the remote workspace, the file is still present. |
5661

5762
**Pass criteria:** native tools transparently switch between local and remote,
5863
and selection survives within the session.
@@ -79,7 +84,7 @@ asks for confirmation; the model cannot restore.
7984

8085
| Step | Action | Expect |
8186
|---|---|---|
82-
| 3.1 | `/sprite-service create web npm run dev` (or any simple command that stays up) | Service definition created in `remoteCwd`. |
87+
| 3.1 | `/sprite-service create web python3 -m http.server 3000` | Creates a long-running service in `remoteCwd` without relying on project-specific scripts. |
8388
| 3.2 | `/sprite-services` | Lists services with status. |
8489
| 3.3 | `/sprite-service logs web 200` | Streams recent logs. |
8590
| 3.4 | `/sprite-service restart web` | Restarts cleanly. |
@@ -108,15 +113,16 @@ confirms; empty rules == unrestricted (not deny-all).
108113

109114
## 5. Bootstrap: reproducible environment
110115

111-
Point config at a real repo first. Create `.pi/sprites.json` (see
112-
`templates/sprites.json`) and set `bootstrap.repository`, `branch`, and safe,
113-
repeatable `commands`. **Trust the project** in Pi so config is honored.
116+
Point config at the scratch repo first. Create `.pi/sprites.json` (see
117+
`templates/sprites.json`), set `remoteCwd` to `/workspace/pi-sprites-test`, and
118+
set `bootstrap.repository`, `branch`, and safe, repeatable `commands`.
119+
**Trust the project** in Pi so config is honored.
114120

115121
| Step | Action | Expect |
116122
|---|---|---|
117123
| 5.1 | `/sprite-bootstrap pi-sprites-test` | Reuses the Sprite, clones repo if no `.git`, checks out branch, runs trusted commands, applies policy, creates services, checkpoints. |
118124
| 5.2 | Re-run `/sprite-bootstrap pi-sprites-test` | Idempotent: reuses checkout, only creates missing services, reapplies policy. |
119-
| 5.3 | `/sprite-use pi-sprites-test /workspace/<project>` | Point native tools at the bootstrapped tree. |
125+
| 5.3 | `/sprite-use pi-sprites-test /workspace/pi-sprites-test` | Point native tools at the configured bootstrapped tree. |
120126
| 5.4 | `/sprite-services` and `/sprite-checkpoints` | Show the reconciled services and known-good checkpoint. |
121127

122128
**Pass criteria:** bootstrap converges, is safe to repeat, refuses commands
@@ -161,12 +167,13 @@ uncommitted changes; your selection is untouched.
161167
| 8.2 | `/sprite-rpc status` | Reports service state and internal port. |
162168
| 8.3 | `/sprite-rpc proxy` | Session-scoped local TCP proxy. |
163169
| 8.4 | `curl localhost:43120/health` | Returns healthy. |
164-
| 8.5 | `curl -XPOST localhost:43120/rpc -d '{...}'` | Round-trips a JSON-line RPC request. |
170+
| 8.5 | `curl -sS -H 'Content-Type: application/json' -d '{"type":"get_state"}' http://localhost:43120/rpc` | Sends one JSON command over HTTP and returns its correlated Pi RPC response. |
165171
| 8.6 | `/sprite-rpc remove`, confirm | Deletes the service (session data remains). |
166172

167173
**Pass criteria:** host installs as a service, is reachable only via local proxy
168174
by default, and removal confirms. (Only test `httpPort` + bearer secret if you
169-
explicitly want public HTTP routing.)
175+
explicitly want routing through the Sprite URL. Making that URL public is a
176+
separate platform setting and is not part of this plan.)
170177

171178
---
172179

@@ -182,9 +189,13 @@ selection.
182189

183190
## 10. Session reset behavior
184191

185-
Start a new/resumed/forked Pi session and run `/sprite status`: selection,
186-
proxies, and last-checkpoint state must reset. This guards against a stale
187-
session silently operating on the wrong environment.
192+
Select a Sprite other than the one declared in configuration, then start a new,
193+
resumed, or forked Pi session and run `/sprite status`. The transient selection
194+
must reset to the newly loaded configuration (or to no selection if none is
195+
configured), rather than carrying over the prior session's choice. Proxies are
196+
closed, and `/sprite-undo` must report that Pi has not created a checkpoint in
197+
the new session. This guards against stale state silently targeting the wrong
198+
environment.
188199

189200
---
190201

@@ -206,7 +217,7 @@ no longer shows the test Sprites.
206217
| Extension | Covered by |
207218
|---|---|
208219
| Core | §1, §9, §10 |
209-
| Checkpoints | §2, plus auto checkpoints in §5/§6 |
220+
| Checkpoints | §2, plus bootstrap and CI failure checkpoints in §5/§6 |
210221
| Services | §3, §5.4 |
211222
| Policy | §4, §5.1 |
212223
| Bootstrap | §5, and reused by §6/§7 |

docs/releasing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Future npm releases
22

3-
`pi-sprites` is not currently published to npm, and this repository does not contain an active npm publishing workflow. Users should install directly from GitHub until maintainers announce otherwise.
3+
`pi-sprites` is not currently published to npm, and this repository does not contain an active npm publishing workflow. Until maintainers announce otherwise, install directly from GitHub; while the repository is not public, this requires existing GitHub access.
44

55
```bash
66
pi install git:github.com/superfly/pi-sprites

0 commit comments

Comments
 (0)