d5i-openpi 0.1.0__tar.gz
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.
- d5i_openpi-0.1.0/.agents/README.md +25 -0
- d5i_openpi-0.1.0/.agents/architecture.md +110 -0
- d5i_openpi-0.1.0/.agents/decisions.md +118 -0
- d5i_openpi-0.1.0/.agents/pi-protocol.md +125 -0
- d5i_openpi-0.1.0/.agents/server-api.md +77 -0
- d5i_openpi-0.1.0/.agents/ui-guidelines.md +64 -0
- d5i_openpi-0.1.0/.github/workflows/ci.yml +24 -0
- d5i_openpi-0.1.0/.github/workflows/release.yml +55 -0
- d5i_openpi-0.1.0/.gitignore +18 -0
- d5i_openpi-0.1.0/.python-version +1 -0
- d5i_openpi-0.1.0/AGENTS.md +33 -0
- d5i_openpi-0.1.0/PKG-INFO +121 -0
- d5i_openpi-0.1.0/README.md +108 -0
- d5i_openpi-0.1.0/docs/plan.md +235 -0
- d5i_openpi-0.1.0/docs/research/openchamber.md +180 -0
- d5i_openpi-0.1.0/pyproject.toml +36 -0
- d5i_openpi-0.1.0/src/openpi/__init__.py +5 -0
- d5i_openpi-0.1.0/src/openpi/cli.py +186 -0
- d5i_openpi-0.1.0/src/openpi/config.py +151 -0
- d5i_openpi-0.1.0/src/openpi/pi/__init__.py +0 -0
- d5i_openpi-0.1.0/src/openpi/pi/doctor.py +74 -0
- d5i_openpi-0.1.0/src/openpi/pi/index.py +109 -0
- d5i_openpi-0.1.0/src/openpi/pi/install.py +78 -0
- d5i_openpi-0.1.0/src/openpi/pi/process.py +99 -0
- d5i_openpi-0.1.0/src/openpi/pi/session.py +190 -0
- d5i_openpi-0.1.0/src/openpi/pi/transcript.py +274 -0
- d5i_openpi-0.1.0/src/openpi/protocol/__init__.py +3 -0
- d5i_openpi-0.1.0/src/openpi/protocol/codec.py +25 -0
- d5i_openpi-0.1.0/src/openpi/protocol/records.py +152 -0
- d5i_openpi-0.1.0/src/openpi/relay.py +247 -0
- d5i_openpi-0.1.0/src/openpi/server/__init__.py +0 -0
- d5i_openpi-0.1.0/src/openpi/server/client.py +286 -0
- d5i_openpi-0.1.0/src/openpi/server/http.py +228 -0
- d5i_openpi-0.1.0/src/openpi/server/hub.py +272 -0
- d5i_openpi-0.1.0/src/openpi/server/serve.py +114 -0
- d5i_openpi-0.1.0/src/openpi/server/tls.py +91 -0
- d5i_openpi-0.1.0/src/openpi/server/web/index.html +425 -0
- d5i_openpi-0.1.0/src/openpi/ui/__init__.py +0 -0
- d5i_openpi-0.1.0/src/openpi/ui/app.py +37 -0
- d5i_openpi-0.1.0/src/openpi/ui/composer.py +205 -0
- d5i_openpi-0.1.0/src/openpi/ui/dialogs.py +84 -0
- d5i_openpi-0.1.0/src/openpi/ui/markdown.py +28 -0
- d5i_openpi-0.1.0/src/openpi/ui/pane.py +203 -0
- d5i_openpi-0.1.0/src/openpi/ui/tasks.py +34 -0
- d5i_openpi-0.1.0/src/openpi/ui/theme.py +60 -0
- d5i_openpi-0.1.0/src/openpi/ui/transcript.py +200 -0
- d5i_openpi-0.1.0/src/openpi/ui/window.py +365 -0
- d5i_openpi-0.1.0/tests/conftest.py +12 -0
- d5i_openpi-0.1.0/tests/fake_pi.py +63 -0
- d5i_openpi-0.1.0/tests/test_client.py +105 -0
- d5i_openpi-0.1.0/tests/test_codec.py +28 -0
- d5i_openpi-0.1.0/tests/test_home.py +37 -0
- d5i_openpi-0.1.0/tests/test_http.py +144 -0
- d5i_openpi-0.1.0/tests/test_hub.py +126 -0
- d5i_openpi-0.1.0/tests/test_index.py +77 -0
- d5i_openpi-0.1.0/tests/test_install.py +28 -0
- d5i_openpi-0.1.0/tests/test_live_pi.py +72 -0
- d5i_openpi-0.1.0/tests/test_process.py +84 -0
- d5i_openpi-0.1.0/tests/test_records.py +93 -0
- d5i_openpi-0.1.0/tests/test_relay.py +85 -0
- d5i_openpi-0.1.0/tests/test_session.py +64 -0
- d5i_openpi-0.1.0/tests/test_tls.py +102 -0
- d5i_openpi-0.1.0/tests/test_tokens.py +123 -0
- d5i_openpi-0.1.0/tests/test_transcript.py +156 -0
- d5i_openpi-0.1.0/tests/test_ui.py +68 -0
- d5i_openpi-0.1.0/uv.lock +393 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# .agents/
|
|
2
|
+
|
|
3
|
+
Durable working notes for agents changing this repo. Read the file that matches your task
|
|
4
|
+
before you edit code.
|
|
5
|
+
|
|
6
|
+
| File | Read it when |
|
|
7
|
+
|---|---|
|
|
8
|
+
| [`pi-protocol.md`](pi-protocol.md) | touching anything that talks to pi: spawn flags, RPC commands, events, framing, session files |
|
|
9
|
+
| [`architecture.md`](architecture.md) | adding modules, changing threading, deciding where state lives |
|
|
10
|
+
| [`ui-guidelines.md`](ui-guidelines.md) | building Qt widgets, streaming text, styling, keyboard handling |
|
|
11
|
+
| [`server-api.md`](server-api.md) | changing the HTTP/SSE surface the web client and `--connect` consume |
|
|
12
|
+
| [`decisions.md`](decisions.md) | wondering why something is the way it is, or wanting to change a settled choice |
|
|
13
|
+
|
|
14
|
+
Ground rules:
|
|
15
|
+
|
|
16
|
+
- `docs/plan.md` is the roadmap. If a change is not in the current milestone, say so instead of
|
|
17
|
+
quietly expanding scope.
|
|
18
|
+
- pi owns sessions, models, settings, and extensions. openpi reads session JSONL and writes
|
|
19
|
+
only through RPC. Never patch `~/.pi/agent/settings.json`.
|
|
20
|
+
- Any claim about pi's protocol comes from the installed docs, not from memory:
|
|
21
|
+
`~/.pi/agent/install/releases/<version>/node_modules/@earendil-works/pi-coding-agent/docs/`.
|
|
22
|
+
- `.agents/skills/` is pi's own discovery path for project skills. Do not put openpi notes
|
|
23
|
+
there — this directory holds markdown only.
|
|
24
|
+
- The cited pi version is whatever `pi --version` reports on this machine; protocol details in
|
|
25
|
+
`pi-protocol.md` were verified against 1.5.2. Re-check `rpc-commands.md` after a pi upgrade.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# openpi architecture
|
|
2
|
+
|
|
3
|
+
A control room for the **pi** coding agent: a PySide6 desktop app and a background web server
|
|
4
|
+
that share one runtime design. pi has no server; openpi drives `pi --mode rpc` child processes
|
|
5
|
+
and reads pi's session files. If anything here contradicts `pi-protocol.md`, the protocol file
|
|
6
|
+
wins — it is sourced from pi's own docs.
|
|
7
|
+
|
|
8
|
+
Topology:
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
browser ──HTTP/SSE──▶ openpi serve ──JSONL──▶ pi --mode rpc (one process per session)
|
|
12
|
+
▲ ▲
|
|
13
|
+
└──relay byte pipe────┘ desktop app ──HTTP/SSE──▶ (--connect) or in-process (default)
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Module map (as built)
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
src/openpi/
|
|
20
|
+
__init__.py exports main
|
|
21
|
+
cli.py click group: GUI (default), `sessions`, `doctor`
|
|
22
|
+
config.py Settings struct, XDG state dir, atomic JSON writes
|
|
23
|
+
protocol/codec.py LF framing helpers
|
|
24
|
+
protocol/records.py msgspec Structs for state, models, stats, commands, UI requests
|
|
25
|
+
pi/process.py PiProcess(QObject): QProcess spawn, LF split from a byte buffer, send
|
|
26
|
+
pi/session.py PiSession: process + State + Transcript + stats/models/commands
|
|
27
|
+
pi/transcript.py pure reducer: pi events/entries -> blocks (user, text, thinking, tool…)
|
|
28
|
+
pi/index.py read-only scan of ~/.pi/agent/sessions for the rail
|
|
29
|
+
pi/doctor.py one-shot RPC probe behind `openpi doctor`
|
|
30
|
+
ui/window.py MainWindow: project rail, session rail, pane stack, status bar
|
|
31
|
+
ui/pane.py SessionPane: header controls, transcript, composer, footer
|
|
32
|
+
ui/transcript.py BlockWidget + TranscriptView (incremental, capped at 200 blocks)
|
|
33
|
+
ui/composer.py input box, send/stop, queue count, `/` command menu
|
|
34
|
+
ui/dialogs.py extension_ui_request dialogs (select/confirm/input/editor)
|
|
35
|
+
ui/theme.py palette + QSS
|
|
36
|
+
ui/markdown.py markdown-it-py -> Qt rich text
|
|
37
|
+
ui/tasks.py thread + signal helper for scans
|
|
38
|
+
server/hub.py SessionHub: owns sessions, snapshots, block patches, cross-thread calls
|
|
39
|
+
server/http.py HTTP + SSE API, token auth, static web client
|
|
40
|
+
server/serve.py `openpi serve`: QCoreApplication + hub + HTTP + optional relay client
|
|
41
|
+
server/client.py RemoteClient + RemoteSession: the desktop as a client of a server
|
|
42
|
+
server/web/index.html browser client (no build step, vanilla JS)
|
|
43
|
+
relay.py `openpi relay` + RelayClient: outbound byte-pipe relay
|
|
44
|
+
tests/ codec, records, index, transcript, process, session, UI, hub, http,
|
|
45
|
+
relay, live contract
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Hard invariants
|
|
49
|
+
|
|
50
|
+
1. **One process per open session.** No shared daemon, no multiplexing. Switching sessions
|
|
51
|
+
never kills anything: every open `PiSession` keeps streaming. That is the product.
|
|
52
|
+
2. **All Qt widget access happens on the GUI thread.** `PiProcess` uses `QProcess`, so records
|
|
53
|
+
arrive as Qt signals on the GUI thread with no reader thread. Keep file scans off the GUI
|
|
54
|
+
thread (`ui/tasks.py`).
|
|
55
|
+
3. **Framing is LF-only.** Split bytes on `b"\n"`, strip one trailing `\r`. Never use text-mode
|
|
56
|
+
readline or treat U+2028 as a boundary.
|
|
57
|
+
4. **stdout is protocol, stderr is logs.** stderr becomes a `failed` signal; never parsed as
|
|
58
|
+
JSON.
|
|
59
|
+
5. **Gate "done" on `agent_settled`, never on prompt acceptance.** `prompt` only reports
|
|
60
|
+
acceptance (`disposition`).
|
|
61
|
+
6. **Transcript is a pure reducer.** `pi/transcript.py` has no Qt import; widgets reconcile by
|
|
62
|
+
block uid. A message is only re-rendered from its final `message_end` payload.
|
|
63
|
+
7. **Never invent a permission gate.** pi does not ask per tool call. Project trust is decided at
|
|
64
|
+
spawn time (`--approve` / `--no-approve`), extension dialogs are rendered as they come.
|
|
65
|
+
8. **Cap the process count.** Opening is lazy; the cap (default 8) is not enforced yet — see
|
|
66
|
+
`docs/plan.md` risks.
|
|
67
|
+
9. **HTTP threads never touch Qt objects.** `SessionHub.call(fn)` posts work to the Qt thread
|
|
68
|
+
and waits; `post(fn)` is fire-and-forget. Event fan-out goes through `queue.Queue` per SSE
|
|
69
|
+
subscriber, pushed from the Qt thread.
|
|
70
|
+
10. **The server owns the transcript.** Clients receive blocks, not raw pi events, so the web
|
|
71
|
+
client never re-implements the reducer. Patches are `{upsert: [...], order?: [...],
|
|
72
|
+
state?/stats?/busy?/queued?}` keyed by block uid. The wire contract is
|
|
73
|
+
`.agents/server-api.md`; `RemoteSession` is the desktop side of it.
|
|
74
|
+
11. **The relay is a byte pipe, not an HTTP proxy.** Instance holds one control socket out;
|
|
75
|
+
every browser connection triggers `GO <id>` and a `DATA` dial-back. Keep it dumb so HTTP,
|
|
76
|
+
SSE, and keep-alive behave normally.
|
|
77
|
+
|
|
78
|
+
## Session lifecycle
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
spawn -> pi --mode rpc [--session <path>] --approve|--no-approve
|
|
82
|
+
-> get_state + get_entries + get_session_stats + models + thinking levels + commands
|
|
83
|
+
-> live events append to the transcript
|
|
84
|
+
close -> close stdin; pi disposes; kill only after a grace period
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
- New session: spawn without `--session`; `--name` or `set_session_name` names it later.
|
|
88
|
+
- Reopen: `--session <path>` runs in the session's own cwd, not the launcher's cwd.
|
|
89
|
+
- Fork/clone/switch go through RPC so the process and its extensions stay alive.
|
|
90
|
+
- Backfill uses `get_entries` (includes pre-compaction history). `get_messages` is the compacted
|
|
91
|
+
model view; openpi uses it only through `get_session_stats`.
|
|
92
|
+
|
|
93
|
+
## Data ownership
|
|
94
|
+
|
|
95
|
+
- pi owns sessions, models, settings, extensions, MCP, skills. openpi never rewrites session
|
|
96
|
+
JSONL, `~/.pi/agent/settings.json`, or model catalogs.
|
|
97
|
+
- openpi owns only its own UI state in `~/.openpi/` (override with `OPENPI_HOME`):
|
|
98
|
+
settings, pairings, the server token, TLS material, and reserved `extensions/`/`skills/`
|
|
99
|
+
dirs — projects, last project, trust decisions, live cap, later window
|
|
100
|
+
geometry. Atomic write (tmp + `os.replace`).
|
|
101
|
+
- Renames go through RPC (`set_session_name`); that is the only session write openpi performs.
|
|
102
|
+
|
|
103
|
+
## Where openpi deliberately differs from openchamber
|
|
104
|
+
|
|
105
|
+
- One server token, no per-device pairing, no push notifications, no mobile app shell.
|
|
106
|
+
- No websocket: SSE + POST is enough for one-way streams and survives dumb proxies.
|
|
107
|
+
- The relay does not end-to-end encrypt frames yet (see decisions #12).
|
|
108
|
+
- No permission mode / classifier: pi has no per-call approval to classify.
|
|
109
|
+
- Notes/todos/plans live in the repo the agent can already read, not a private store.
|
|
110
|
+
- No extension SDK. pi extensions already exist; openpi renders what they ask for.
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Decisions
|
|
2
|
+
|
|
3
|
+
Settled choices with the reason. Add an entry when a choice is made, not while it is being
|
|
4
|
+
discussed. Supersede by editing and marking `superseded by #n`.
|
|
5
|
+
|
|
6
|
+
**1. ~~No server, no HTTP API~~ — superseded by #12 (2026-11-25).**
|
|
7
|
+
The original call was desktop-only. Remote access is now a requirement, so the server exists.
|
|
8
|
+
Kept here so the reversal is visible.
|
|
9
|
+
|
|
10
|
+
**2. One pi process per open session (2026-11-25).**
|
|
11
|
+
Isolation and parallelism come free, and a crash costs one session. Accept the memory cost and
|
|
12
|
+
cap live processes (default 8) rather than multiplexing sessions through one process, which pi
|
|
13
|
+
does not support anyway.
|
|
14
|
+
|
|
15
|
+
**3. `QProcess` instead of a reader thread or `qasync` (2026-11-25).**
|
|
16
|
+
QProcess delivers stdout bytes as Qt signals on the GUI thread, so there is no thread lifetime
|
|
17
|
+
to manage and no async/await leaking into widget code. Keep a `bytearray` buffer and split on LF
|
|
18
|
+
yourself — QProcess gives you chunks, not records.
|
|
19
|
+
|
|
20
|
+
**4. `markdown-it-py` as the only added runtime dependency (2026-11-25).**
|
|
21
|
+
The transcript has to render CommonMark with fenced code. Hand-rolling that is a bug factory.
|
|
22
|
+
No highlighter in v1: monospace plus a copy button is enough.
|
|
23
|
+
|
|
24
|
+
**5. pi owns persistence; openpi reads session files and never writes them (2026-11-25).**
|
|
25
|
+
Display names, forks, and compactions all go through RPC so pi stays the single writer. The
|
|
26
|
+
session index is read-only and re-scanned on file change.
|
|
27
|
+
|
|
28
|
+
**6. No permission layer (2026-11-25).**
|
|
29
|
+
pi has no per-tool approval to gate. Rendering extension dialogs and deciding project trust at
|
|
30
|
+
spawn (`--approve` / `--no-approve`) is the honest maximum. A fake approval gate would train
|
|
31
|
+
users to trust a control that does not exist.
|
|
32
|
+
|
|
33
|
+
**7. UI state under `~/.openpi/` (2026-11-25).**
|
|
34
|
+
Window geometry, project list, drafts, scheduler tasks. Not in `~/.pi`, which belongs to pi and
|
|
35
|
+
is read by other tools. Atomic tmp+rename writes.
|
|
36
|
+
|
|
37
|
+
**8. Use the session header `cwd` for project mapping (2026-11-25).**
|
|
38
|
+
Session directories are mangled paths (`--home-user-repo--`) and can collide after renames or
|
|
39
|
+
for paths with dashes. The header is authoritative.
|
|
40
|
+
|
|
41
|
+
**9. ~~Out of scope: web, mobile, relay~~ — superseded by #12 (2026-11-25).**
|
|
42
|
+
Web, relay, and remote access are in v1. Still out: extension SDK, voice, native mobile apps.
|
|
43
|
+
|
|
44
|
+
**10. Transcript blocks are plain dataclasses; widgets reconcile by uid (2026-11-25).**
|
|
45
|
+
The reducer (`pi/transcript.py`) is Qt-free and tested headless. The view owns one widget per
|
|
46
|
+
block and updates it in place; only `message_end` replaces a message's blocks, so streaming is
|
|
47
|
+
linear work per delta instead of a full re-render.
|
|
48
|
+
|
|
49
|
+
**11. The GUI opens a folder with `--project`, not a bare positional (2026-11-25).**
|
|
50
|
+
A click group with an optional positional argument swallows subcommand names
|
|
51
|
+
(`openpi doctor` became a path). An option keeps `openpi`, `openpi doctor`,
|
|
52
|
+
`openpi sessions` unambiguous.
|
|
53
|
+
|
|
54
|
+
**12. A server with one shared token, not per-device pairing (2026-11-25).**
|
|
55
|
+
`openpi serve` owns the sessions; clients attach over HTTP + SSE. One bearer token (query for
|
|
56
|
+
EventSource, header for POST) is the whole auth model until there is more than one user. Device
|
|
57
|
+
tokens and QR pairing are the upgrade path, not v1.
|
|
58
|
+
|
|
59
|
+
**13. SSE + POST instead of WebSocket (2026-11-25).**
|
|
60
|
+
The data flow is one-way (events down, commands up). SSE works through relays, proxies, and
|
|
61
|
+
`EventSource` with no client library, and POST is trivial to test with curl. WebSocket buys
|
|
62
|
+
nothing here until there are binary attachments or sub-100ms steering.
|
|
63
|
+
|
|
64
|
+
**14. Clients receive blocks, not pi events (2026-11-25).**
|
|
65
|
+
The hub diffs the transcript and sends block upserts plus an order list. The browser renders
|
|
66
|
+
blocks and never re-implements compaction, message merging, or tool-result linking. Cost: the
|
|
67
|
+
patch is computed server-side per change — cheap over ~200 blocks.
|
|
68
|
+
|
|
69
|
+
**15. Relay is a byte pipe (2026-11-25).**
|
|
70
|
+
Browsers speak HTTP to a public port; the relay asks the instance to dial back per connection
|
|
71
|
+
and pipes bytes. No HTTP parsing, no WebSocket on the relay, no open port at home. Consequence:
|
|
72
|
+
the relay can read traffic, so v1 is for self-hosted relays or a trusted network. E2E is an open
|
|
73
|
+
decision (plan §9.1).
|
|
74
|
+
|
|
75
|
+
**16. `openpi doctor` and the live pytest are the protocol contract (2026-11-25).**
|
|
76
|
+
pi's RPC is the only integration surface; a pi upgrade must be caught by `pytest -m live`, not by
|
|
77
|
+
a user's broken transcript.
|
|
78
|
+
|
|
79
|
+
**17. PySide6, not PyQt6 (2026-11-25).**
|
|
80
|
+
PySide6 is the official Qt for Python binding. The code uses only the source-compatible
|
|
81
|
+
surface (scoped enums, `Signal`/`Slot`, `QProcess`), so the two are interchangeable here; the
|
|
82
|
+
binding is chosen once and everything else is bound to it. Any new import must come from
|
|
83
|
+
`PySide6.*`, and `pytest` must stay green after `uv add pyside6`.
|
|
84
|
+
|
|
85
|
+
**18. The desktop is a client when it connects, not a second runtime (2026-11-25).**
|
|
86
|
+
`openpi --connect` reuses `SessionPane`/`TranscriptView`/`dialogs` against a `RemoteSession`
|
|
87
|
+
that mirrors `PiSession`'s signals and methods over SSE + POST. No UI branch per backend: the
|
|
88
|
+
window picks a session factory, the pane does not know which. This finishes the "one runtime,
|
|
89
|
+
several clients" model.
|
|
90
|
+
|
|
91
|
+
**19. Admin token + revocable device tokens, no per-token scopes (2026-11-25).**
|
|
92
|
+
One shared admin token was the top security gap. Now device tokens are issued by id+name and
|
|
93
|
+
revocable from the CLI (`openpi token new|list|revoke`) or the admin HTTP endpoints; the server
|
|
94
|
+
reloads `pairings.json` on change. Tokens are all-or-nothing (any token = shell), which is the
|
|
95
|
+
right first step; per-token scopes stay out until there is a use for them.
|
|
96
|
+
|
|
97
|
+
**20. E2E through the relay is TLS at the instance, trusted by CA pinning (2026-11-25).**
|
|
98
|
+
`openpi serve --tls` serves HTTPS with a self-signed cert; the relay stays a byte pipe, so it
|
|
99
|
+
carries only ciphertext. The desktop client pins the cert with `--tls-ca` (real verification);
|
|
100
|
+
the browser sees a one-time self-signed warning unless the cert is installed. No new framing or
|
|
101
|
+
crypto in the relay itself.
|
|
102
|
+
|
|
103
|
+
**21. Home directory is `~/.openpi/`, not the XDG state dir (2026-11-25).**
|
|
104
|
+
`OPENPI_HOME` overrides the default `~/.openpi`, which holds `settings.json`, `pairings.json`,
|
|
105
|
+
`server-token`, `server.crt`/`server.key`, and reserved `extensions/`/`skills/` dirs. On first
|
|
106
|
+
run, pre-existing state under `~/.local/state/openpi/` is copied in. `ensure_home()` runs from
|
|
107
|
+
the click group on every invocation; `openpi setup` does it explicitly.
|
|
108
|
+
|
|
109
|
+
**22. pi is installed/updated by `openpi setup`, not silently by the server (2026-11-25).**
|
|
110
|
+
`setup` installs pi with its official installer (`pi.dev/install.sh`) and updates it with
|
|
111
|
+
`pi update --self`, falling back to a global npm install. `serve` only checks that pi exists;
|
|
112
|
+
`doctor` reports the installed vs latest version. Auto-updating pi behind a running server is
|
|
113
|
+
too surprising to do unprompted.
|
|
114
|
+
|
|
115
|
+
**23. Releases publish on a version tag; the token is the PyPI secret (2026-11-25).**
|
|
116
|
+
`.github/workflows/release.yml` runs tests, checks the `v*` tag matches `pyproject` version,
|
|
117
|
+
builds with `uv build`, publishes with `uv publish --token "$PYPI_TOKEN"` (org-scoped token for
|
|
118
|
+
`pypi.org/org/D5-Interactive/`), then cuts the GitHub release. `ci.yml` runs tests on push/PR.
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# pi integration facts (authoritative)
|
|
2
|
+
|
|
3
|
+
Source: installed pi 1.5.2 docs at
|
|
4
|
+
`~/.pi/agent/install/releases/1.5.2/node_modules/@earendil-works/pi-coding-agent/docs/`
|
|
5
|
+
(`rpc.md`, `rpc-commands.md`, `json.md`, `rpc-extension-ui.md`, `session-format.md`,
|
|
6
|
+
`message-types.md`, `sessions.md`, `security.md`). Read those before changing the client.
|
|
7
|
+
|
|
8
|
+
## There is no server. Spawn one process per session.
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
pi --mode rpc [--session <path>|--session-id <id>|--continue|--fork <path>] [--name <n>] [--no-session]
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
- RPC mode = long-lived child process, JSONL on stdin/stdout. This is pi's only remote-control API.
|
|
15
|
+
- One process = one session. Parallel sessions/worktrees/multi-run = N processes. No shared daemon.
|
|
16
|
+
- stdout is protocol only; stderr is logs. Never parse stderr as protocol.
|
|
17
|
+
- Close stdin to shut down; pi disposes cleanly. SIGTERM also starts an orderly shutdown.
|
|
18
|
+
|
|
19
|
+
## Framing rules (get these wrong and the client dies)
|
|
20
|
+
|
|
21
|
+
- Split records on **LF only**. JS `readline` also splits on U+2028/U+2029, which are legal
|
|
22
|
+
inside JSON strings — read bytes and split on `b"\n"`, strip a trailing `\r`.
|
|
23
|
+
- Read stdout continuously; a stalled reader blocks pi on backpressure.
|
|
24
|
+
- One JSON object per line. `id` on a command is echoed on its `response`.
|
|
25
|
+
- Command handling is asynchronous: correlate by `id`, never by order.
|
|
26
|
+
|
|
27
|
+
## Commands we need (stdin)
|
|
28
|
+
|
|
29
|
+
| Command | Notes |
|
|
30
|
+
|---|---|
|
|
31
|
+
| `prompt` | `{message, images?, streamingBehavior?}`. `streamingBehavior`: `"steer"` or `"followUp"` required while streaming, else error. Response `data.disposition`: `started`/`queued`/`handled`. Accepted ≠ finished. |
|
|
32
|
+
| `steer` / `follow_up` | Queue separately; `clear_queue` returns their text so Esc can restore the editor. |
|
|
33
|
+
| `abort` | Responds after the session is idle. |
|
|
34
|
+
| `get_state` | model, thinkingLevel, isStreaming, isCompacting, sessionFile, sessionId, sessionName, pendingMessageCount. |
|
|
35
|
+
| `get_messages` | Full conversation (post-compaction view). |
|
|
36
|
+
| `get_entries` | Append-only tree entries; `since: <entryId>` is a durable cursor. Use for history/backfill and branch UI. |
|
|
37
|
+
| `get_tree` | `{tree, leafId}` of `{entry, children, label?}`. |
|
|
38
|
+
| `switch_session` / `new_session` / `fork` / `clone` | All can be cancelled by extension handlers (`data.cancelled`). |
|
|
39
|
+
| `set_model`, `cycle_model`, `get_available_models` | Model object: id, provider, api, baseUrl, reasoning, input, contextWindow, maxTokens, cost. |
|
|
40
|
+
| `set_thinking_level`, `get_available_thinking_levels` | off/minimal/low/medium/high/xhigh/max. |
|
|
41
|
+
| `compact`, `set_auto_compaction`, `set_auto_retry`, `abort_retry` | |
|
|
42
|
+
| `bash`, `abort_bash` | Direct shell in the session; output joins context on the next prompt. Streams `bash_execution_update` with the command's `id`. |
|
|
43
|
+
| `get_session_stats` | tokens, cost, contextUsage {tokens, contextWindow, percent}. |
|
|
44
|
+
| `set_session_name`, `export_html`, `get_last_assistant_text` | |
|
|
45
|
+
| `get_commands` | Skills / prompt templates / extension commands for the `/` menu. TUI-only commands are absent. |
|
|
46
|
+
|
|
47
|
+
## Events (stdout)
|
|
48
|
+
|
|
49
|
+
`agent_start`, `turn_start`, `message_start`, `message_update`, `message_end`, `turn_end`,
|
|
50
|
+
`agent_end`, `agent_settled`, `tool_execution_start|update|end`, `queue_update`,
|
|
51
|
+
`entry_appended`, `session_info_changed`, `thinking_level_changed`,
|
|
52
|
+
`compaction_start|end`, `auto_retry_start|end`, `summarization_retry_*`,
|
|
53
|
+
`bash_execution_update`, `extension_error`.
|
|
54
|
+
|
|
55
|
+
- `message_update` carries **deltas only**: `{usage, assistantMessageEvent}` with types
|
|
56
|
+
`text_start/delta/end`, `thinking_start/delta/end`, `toolcall_start/delta/end`.
|
|
57
|
+
Buffer deltas, then replace with `*_end` content, then replace the whole message with
|
|
58
|
+
`message_end.message`.
|
|
59
|
+
- `agent_end` = one low-level run ended; retries/compaction/queue can still run.
|
|
60
|
+
`agent_settled` = nothing more will happen automatically. **Gate "done" on `agent_settled`.**
|
|
61
|
+
- Ordering: subscribe before sending a prompt, or you can miss a fast completion.
|
|
62
|
+
|
|
63
|
+
## Messages
|
|
64
|
+
|
|
65
|
+
Content blocks: `text`, `image` (base64 + mimeType), `thinking`, `toolCall`
|
|
66
|
+
(`{id, name, arguments}`). Roles: `system`, `user`, `assistant`, `toolResult`,
|
|
67
|
+
`bashExecution`, `custom`, `branchSummary`, `compactionSummary`. Tolerate unknown roles.
|
|
68
|
+
|
|
69
|
+
## Extension UI subprotocol
|
|
70
|
+
|
|
71
|
+
- `extension_ui_request` with `method`:
|
|
72
|
+
- dialogs (block until answered): `select` (options), `confirm` (title+message), `input`
|
|
73
|
+
(placeholder), `editor` (prefill). May carry `timeout`; pi auto-resolves, so the client
|
|
74
|
+
need not track it.
|
|
75
|
+
- fire-and-forget: `notify` (`notifyType`: info|warning|error), `setStatus`, `setWidget`,
|
|
76
|
+
`setTitle`, `set_editor_text`.
|
|
77
|
+
- Answer with `extension_ui_response` `{id, value}` / `{id, confirmed}` / `{id, cancelled:true}`.
|
|
78
|
+
It produces no normal command response.
|
|
79
|
+
- `ctx.mode == "rpc"` and `hasUI == true`; TUI-only extension features (`custom()`, theming,
|
|
80
|
+
header/footer) are no-ops. Extensions written for the TUI degrade, not crash.
|
|
81
|
+
|
|
82
|
+
## Session storage (read-only access for the browser)
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
~/.pi/agent/sessions/--<mangled-cwd>--/<ISO-ts>_<session-id>.jsonl
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Header line `{"type":"session","version":3,"id","timestamp","cwd","parentSession?"}`,
|
|
89
|
+
then entries with `id`/`parentId`/`timestamp`: `message`, `model_change`,
|
|
90
|
+
`thinking_level_change`, `usage`, `compaction`, `context_edit`, `branch_summary`, `custom`,
|
|
91
|
+
`custom_message`, `label`, `session_info` (display name). Entries form a tree; the leaf is
|
|
92
|
+
the active branch. `buildContextEntries` walks leaf→root and honors the latest compaction.
|
|
93
|
+
|
|
94
|
+
Cheap session list = read the first line (cwd/id) + scan for `session_info`/first user text +
|
|
95
|
+
file mtime. Do this off the GUI thread for large histories.
|
|
96
|
+
|
|
97
|
+
## Model picker specifics
|
|
98
|
+
|
|
99
|
+
- `get_available_models` returns hundreds of entries on a configured machine (408 here) and the
|
|
100
|
+
list can differ per cwd because project settings add models. Group by `provider`, filter by
|
|
101
|
+
`input` support when the prompt has images.
|
|
102
|
+
- **Virtual models** exist: an extension can register a model that picks a physical model per
|
|
103
|
+
request (`pi.registerVirtualModel`). The session's selected model may therefore be virtual
|
|
104
|
+
while each assistant message names the physical model that answered. Show both — selection
|
|
105
|
+
from `get_state.model`, dispatch from the last assistant message — or the UI will look wrong.
|
|
106
|
+
- Thinking levels are model-specific (`get_available_thinking_levels`); do not hardcode the
|
|
107
|
+
seven levels from the docs.
|
|
108
|
+
- `sessionFile` is absent when pi runs with `--no-session`; `sessionName` is absent until set.
|
|
109
|
+
|
|
110
|
+
Verified against pi 1.5.2 on this machine: `pi --mode rpc --no-session --no-extensions --no-mcp`
|
|
111
|
+
answered `get_state`, `get_available_models` (408), and `get_available_thinking_levels`
|
|
112
|
+
(`["low","high","max"]` for the configured virtual model `balanced`) over JSONL, then exited 0
|
|
113
|
+
on stdin EOF with empty stderr.
|
|
114
|
+
|
|
115
|
+
## Trust and safety gotchas
|
|
116
|
+
|
|
117
|
+
- **RPC/JSON/print cannot show pi's project-trust prompt.** With `defaultProjectTrust: "ask"`,
|
|
118
|
+
protected project resources (`.pi/settings.json`, `.pi/extensions`, `.pi/skills`,
|
|
119
|
+
`.agents/skills`, …) are silently skipped. openpi must decide and pass `--approve` /
|
|
120
|
+
`--no-approve` per project, and surface that choice in the UI.
|
|
121
|
+
- pi does **not** ask approval per tool call. Any confirm dialog you see comes from an
|
|
122
|
+
extension via `extension_ui_request`. Do not invent a permission gate in the client.
|
|
123
|
+
- `--session`/`--resume` run in the session's own cwd, not the launching cwd. `--fork` uses
|
|
124
|
+
the current directory and creates a new session.
|
|
125
|
+
- Session dir override: `--session-dir`, `PI_CODING_AGENT_SESSION_DIR`, or `sessionDir` setting.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# server API (openpi serve ↔ clients)
|
|
2
|
+
|
|
3
|
+
The contract between `openpi serve`, the browser client, and the desktop client
|
|
4
|
+
(`openpi --connect`). One server owns the sessions; clients attach over HTTP + SSE. If the
|
|
5
|
+
server's Python types drift from this, update this file in the same change.
|
|
6
|
+
|
|
7
|
+
## Auth
|
|
8
|
+
|
|
9
|
+
Two token classes. Sent as an `X-Openpi-Token` header on POST/GET, or as `?token=` for
|
|
10
|
+
EventSource (which cannot set headers).
|
|
11
|
+
|
|
12
|
+
- **Admin token** — `~/.openpi/server-token` (or `$OPENPI_HOME`), printed on start. Opens
|
|
13
|
+
everything and manages pairings.
|
|
14
|
+
- **Device tokens** — issued per device (`openpi token new`), stored in
|
|
15
|
+
`~/.openpi/pairings.json`, revocable. Accepted for all session endpoints, refused
|
|
16
|
+
for the pairing endpoints below. The server reloads them on change, no restart.
|
|
17
|
+
|
|
18
|
+
## Endpoints
|
|
19
|
+
|
|
20
|
+
| Method | Path | Body | Result |
|
|
21
|
+
|---|---|---|---|
|
|
22
|
+
| GET | `/` | — | the browser client (no token needed) |
|
|
23
|
+
| GET | `/api/state` | — | `{cwd, sessions:[{key,cwd,file,title,busy}]}` |
|
|
24
|
+
| POST | `/api/open` | `{cwd?, session?}` | `{key}` — new session, or reopen `session` path |
|
|
25
|
+
| GET | `/api/sessions/{key}/events` | — | SSE stream (see below) |
|
|
26
|
+
| POST | `/api/sessions/{key}/prompt` | `{message, behavior?}` | `{ok}` |
|
|
27
|
+
| POST | `/api/sessions/{key}/steer` | `{message}` | `{ok}` |
|
|
28
|
+
| POST | `/api/sessions/{key}/follow_up` | `{message}` | `{ok}` |
|
|
29
|
+
| POST | `/api/sessions/{key}/abort` | — | `{ok}` |
|
|
30
|
+
| POST | `/api/sessions/{key}/clear_queue` | — | `{ok}` |
|
|
31
|
+
| POST | `/api/sessions/{key}/rename` | `{name}` | `{ok}` |
|
|
32
|
+
| POST | `/api/sessions/{key}/model` | `{provider, id}` | `{ok}` |
|
|
33
|
+
| POST | `/api/sessions/{key}/thinking` | `{level}` | `{ok}` |
|
|
34
|
+
| POST | `/api/sessions/{key}/stats` | — | `{ok}` (forces a stats refresh) |
|
|
35
|
+
| POST | `/api/sessions/{key}/answer` | `{id, value?, confirmed?, cancelled?}` | `{ok}` — answers an extension dialog |
|
|
36
|
+
| POST | `/api/pairings` | `{name?}` (admin) | `{id, name, token}` |
|
|
37
|
+
| GET | `/api/pairings` | — (admin) | `{pairings:[{id,name}]}` (no tokens) |
|
|
38
|
+
| DELETE | `/api/pairings/{id}` | — (admin) | `{ok}` |
|
|
39
|
+
|
|
40
|
+
Errors are `{error: str}` with an HTTP status (400 bad action, 401 bad token, 404 unknown
|
|
41
|
+
session, 503 hub busy).
|
|
42
|
+
|
|
43
|
+
## Event stream (SSE)
|
|
44
|
+
|
|
45
|
+
`text/event-stream`, one JSON object per `data:` line, `: ping` every 15 s, `Connection: close`,
|
|
46
|
+
`X-Accel-Buffering: no`. First event is a `snapshot`, then `patch`es as the transcript/state
|
|
47
|
+
changes, plus `ui` and `notify`.
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
snapshot = {t:"snapshot", key, blocks:[Block], state, stats, busy, queued:[s,f],
|
|
51
|
+
models:[{id,provider,name}], levels:[str], commands:[{name,description}]}
|
|
52
|
+
patch = {t:"patch", key, upsert?:[Block], order?:[uid], state?, stats?, busy?, queued?}
|
|
53
|
+
ui = {t:"ui", key, request:{id,method,title,message,options,placeholder,prefill,timeout}}
|
|
54
|
+
notify = {t:"notify", key, message, kind}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`Block = {uid, kind:user|text|thinking|tool|bash|notice, text, name, args, result, is_error,
|
|
58
|
+
duration_ms, meta}`. `order` is the full block-id list and appears only when it changed; `upsert`
|
|
59
|
+
carries blocks whose content changed or are new. `state = {name, thinking, model:{id,provider,
|
|
60
|
+
name}|null, is_streaming}`; `stats = {cost, context:{tokens,window,percent}|null}`.
|
|
61
|
+
|
|
62
|
+
Clients keep `uid → Block` and an order list, apply `upsert` then `order`, and render. The
|
|
63
|
+
server never sends raw pi events, so the browser does not re-implement compaction or tool-result
|
|
64
|
+
linking.
|
|
65
|
+
|
|
66
|
+
## Invariants
|
|
67
|
+
|
|
68
|
+
- Only `GET /` is unauthenticated. Everything under `/api/` needs an admin or device token.
|
|
69
|
+
- TLS: `openpi serve --tls` serves HTTPS with a self-signed cert (`.agents/pi-protocol.md`
|
|
70
|
+
unrelated; see `server/tls.py`). The desktop client trusts it with `--connect https://… --tls-ca
|
|
71
|
+
server.crt`; the relay pipes ciphertext, so this is the end-to-end encryption path.
|
|
72
|
+
- SSE streams are per-session and start with a full snapshot, so a dropped connection is
|
|
73
|
+
resync-safe on reconnect.
|
|
74
|
+
- All commands are marshalled onto the server's Qt thread; a slow hub returns 503 rather than
|
|
75
|
+
hanging.
|
|
76
|
+
- Extension dialogs are answered by POST `answer` with the `request.id`; pi resolves a timed-out
|
|
77
|
+
dialog itself, so a late answer is ignored server-side.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# UI guidelines (PySide6)
|
|
2
|
+
|
|
3
|
+
## Threading
|
|
4
|
+
|
|
5
|
+
- GUI thread: every widget, every model, every palette lookup.
|
|
6
|
+
- `PiProcess` reads stdout via `QProcess` signals; records are split on LF from a byte buffer.
|
|
7
|
+
Never assume one signal carries one record, and never touch widgets from a worker.
|
|
8
|
+
- File scans, git commands, and diffs go through `QThreadPool` + `QRunnable` with a result
|
|
9
|
+
signal. A synchronous `subprocess.run` on the GUI thread is a bug, even if it feels fast.
|
|
10
|
+
- Writes to pi are small JSON lines from the GUI thread under a `threading.Lock`. If a write
|
|
11
|
+
ever blocks, the lock owner logs and the UI shows a degraded state — do not add a writer
|
|
12
|
+
thread until there is evidence it is needed.
|
|
13
|
+
|
|
14
|
+
## Widget choices
|
|
15
|
+
|
|
16
|
+
| Need | Use | Not |
|
|
17
|
+
|---|---|---|
|
|
18
|
+
| Transcript | `QScrollArea` + a column of widgets, one per message | one giant `QTextBrowser` |
|
|
19
|
+
| Streaming text block | `QLabel`: plain text while streaming, `markdown-it-py` HTML once the block ends | re-parsing markdown per delta |
|
|
20
|
+
| Tool call | `QFrame` with header (name, status, duration) and a collapsible body | dumping JSON into the transcript |
|
|
21
|
+
| Session list | `QListWidget` (fine at this scale); move to `QListView` + model if it grows | a widget per session |
|
|
22
|
+
| Composer | `QPlainTextEdit` with `Ctrl+Enter` to send, `Enter` for newline (configurable) | `QLineEdit` |
|
|
23
|
+
| Diff | `QPlainTextEdit` (read-only) with `QTextCharFormat` per line | QWebEngine |
|
|
24
|
+
|
|
25
|
+
Code and diffs are monospace and horizontally scrollable. A truncation marker with "show full
|
|
26
|
+
output" is better than silently clipping.
|
|
27
|
+
|
|
28
|
+
## Streaming performance
|
|
29
|
+
|
|
30
|
+
The event stream is delta-heavy: one long reply can be thousands of `text_delta` records.
|
|
31
|
+
|
|
32
|
+
1. Coalesce deltas into a buffer; flush to the label at ~10 Hz (a `QTimer`), not per record.
|
|
33
|
+
2. Render with `setPlainText` while streaming, then swap to markdown HTML once on
|
|
34
|
+
`text_end` / `message_end`.
|
|
35
|
+
3. Keep at most ~300 rendered messages; older ones collapse to "n earlier messages" with the
|
|
36
|
+
full history available through the tree view.
|
|
37
|
+
4. Re-rendering the whole transcript on every update is the usual cause of a janky chat window.
|
|
38
|
+
5. Rebuild combo boxes only when their source list changes, never on every state signal.
|
|
39
|
+
|
|
40
|
+
## State and honesty
|
|
41
|
+
|
|
42
|
+
- Every data surface renders `loading`, `ready`, or `error`. Empty is a `ready` state with zero
|
|
43
|
+
items, never the initial state.
|
|
44
|
+
- Session status comes from events (`isStreaming`, `tool_execution_*`, `queue_update`,
|
|
45
|
+
`agent_settled`), never from "last message looks finished".
|
|
46
|
+
- After a disconnect, keep the transcript and mark it stale. Do not clear it.
|
|
47
|
+
|
|
48
|
+
## Styling
|
|
49
|
+
|
|
50
|
+
- One palette module (`ui/theme.py`) exposing roles (background, surface, border, text, muted,
|
|
51
|
+
accent, success, warning, danger, diff-add, diff-del) and a QSS string built from them.
|
|
52
|
+
Widgets use `setObjectName` + QSS classes; no inline `setStyleSheet` per widget.
|
|
53
|
+
- Dark theme first, light theme from the same roles. Respect the system colour scheme when the
|
|
54
|
+
user has not chosen one (`QStyleHints.colorScheme`).
|
|
55
|
+
- Keep line height generous (1.4) and body text at the system font; never hardcode pixel sizes.
|
|
56
|
+
|
|
57
|
+
## Keyboard and accessibility
|
|
58
|
+
|
|
59
|
+
- Every action reachable by keyboard. Palette (`Ctrl+K`) covers anything not on a shortcut.
|
|
60
|
+
- Focus rings visible on the composer, list views, and diff pane. Tab order follows reading
|
|
61
|
+
order.
|
|
62
|
+
- `Esc` in the composer clears the queue and aborts, restoring queued text — mirror pi's TUI
|
|
63
|
+
semantics, and document it in the shortcut sheet.
|
|
64
|
+
- Announce state changes in the status bar text, not only by colour dots.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
- uses: astral-sh/setup-uv@v5
|
|
14
|
+
with:
|
|
15
|
+
python-version: "3.14"
|
|
16
|
+
|
|
17
|
+
- name: Install Qt system libraries (offscreen platform)
|
|
18
|
+
run: |
|
|
19
|
+
sudo apt-get update
|
|
20
|
+
sudo apt-get install -y libegl1 libgl1 libxkbcommon0 libxkbcommon-x11-0 \
|
|
21
|
+
libfontconfig1 libdbus-1-3 libglib2.0-0
|
|
22
|
+
|
|
23
|
+
- run: uv sync
|
|
24
|
+
- run: uv run pytest
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
name: release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ["v*"]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: write
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
test:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: astral-sh/setup-uv@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.14"
|
|
18
|
+
|
|
19
|
+
- name: Install Qt system libraries (offscreen platform)
|
|
20
|
+
run: |
|
|
21
|
+
sudo apt-get update
|
|
22
|
+
sudo apt-get install -y libegl1 libgl1 libxkbcommon0 libxkbcommon-x11-0 \
|
|
23
|
+
libfontconfig1 libdbus-1-3 libglib2.0-0
|
|
24
|
+
|
|
25
|
+
- run: uv sync
|
|
26
|
+
- run: uv run pytest
|
|
27
|
+
|
|
28
|
+
publish:
|
|
29
|
+
needs: test
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v4
|
|
33
|
+
- uses: astral-sh/setup-uv@v5
|
|
34
|
+
with:
|
|
35
|
+
python-version: "3.14"
|
|
36
|
+
|
|
37
|
+
- name: Verify the tag matches the package version
|
|
38
|
+
run: |
|
|
39
|
+
version="$(python3 -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')"
|
|
40
|
+
test "v$version" = "$GITHUB_REF_NAME" \
|
|
41
|
+
|| { echo "tag $GITHUB_REF_NAME does not match pyproject version v$version"; exit 1; }
|
|
42
|
+
|
|
43
|
+
- name: Build distributions
|
|
44
|
+
run: uv build
|
|
45
|
+
|
|
46
|
+
- name: Publish to PyPI (D5-Interactive org)
|
|
47
|
+
# PYPI_TOKEN must be an org-scoped API token for https://pypi.org/org/D5-Interactive/
|
|
48
|
+
env:
|
|
49
|
+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
|
|
50
|
+
run: uv publish --token "$PYPI_TOKEN"
|
|
51
|
+
|
|
52
|
+
- name: Create GitHub release
|
|
53
|
+
env:
|
|
54
|
+
GH_TOKEN: ${{ github.token }}
|
|
55
|
+
run: gh release create "$GITHUB_REF_NAME" dist/* --generate-notes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Python-generated files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[oc]
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
wheels/
|
|
7
|
+
*.egg-info
|
|
8
|
+
|
|
9
|
+
# Virtual environments
|
|
10
|
+
.venv
|
|
11
|
+
|
|
12
|
+
# playwright mcp artifacts
|
|
13
|
+
.playwright-mcp/
|
|
14
|
+
|
|
15
|
+
# OpenCode harness session state
|
|
16
|
+
.opencode/
|
|
17
|
+
|
|
18
|
+
# `.agents/` is intentionally tracked (agent-facing docs) — never add it here.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.14
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# OpenPi — agent instructions
|
|
2
|
+
|
|
3
|
+
Desktop control room for the pi coding agent. PySide6 + click + msgspec, Python 3.14, managed by
|
|
4
|
+
`uv`.
|
|
5
|
+
|
|
6
|
+
Read [`.agents/README.md`](.agents/README.md) first; it routes you to protocol, architecture,
|
|
7
|
+
UI, and decision notes. The roadmap is [`docs/plan.md`](docs/plan.md).
|
|
8
|
+
|
|
9
|
+
## Rules
|
|
10
|
+
|
|
11
|
+
- Use `uv` for everything: `uv sync`, `uv run openpi`, `uv add <pkg>`, `uv run pytest`. Never
|
|
12
|
+
`pip`.
|
|
13
|
+
- Do not start a milestone that is not in the plan without saying so first.
|
|
14
|
+
- pi is the single writer of sessions and settings. openpi talks to it through
|
|
15
|
+
`pi --mode rpc`; read session JSONL, never rewrite it, never edit `~/.pi/agent/*.json`.
|
|
16
|
+
- After changing anything protocol-facing, run the live contract test
|
|
17
|
+
(`uv run pytest -m live`) against the installed pi and note its version.
|
|
18
|
+
- Home is `~/.openpi/` (`OPENPI_HOME` overrides); `openpi setup` installs/updates pi.
|
|
19
|
+
- Releases: `v*` tag matches `pyproject` version; the workflow publishes to PyPI with
|
|
20
|
+
`secrets.PYPI_TOKEN`. Bump the version before tagging.
|
|
21
|
+
- Commits in this repo use the D5-Interactive subject format:
|
|
22
|
+
`[ o7 ]: <1-3 WORD TITLE> | <1-SENTENCE DESCRIPTION> | <CONDENSED CHANGES>`.
|
|
23
|
+
- Tests stay headless: `QT_QPA_PLATFORM=offscreen` is set by the test fixtures.
|
|
24
|
+
|
|
25
|
+
## Layout
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
src/openpi/ application code (see .agents/architecture.md for the module map)
|
|
29
|
+
tests/ pytest, no network, offscreen Qt
|
|
30
|
+
docs/plan.md milestones and acceptance criteria
|
|
31
|
+
docs/research/ OpenChamber research the plan is based on
|
|
32
|
+
.agents/ durable notes for agents
|
|
33
|
+
```
|