@loka1/pi-orchestra 0.0.0-stage → 0.6.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 ADDED
@@ -0,0 +1,313 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.6.0] - 2026-12-02
11
+
12
+ ### Added
13
+
14
+ - **`widget` mode: `auto` (default), `always`, `off`.** In `auto` the always-on
15
+ widget body is mounted only while a worker is starting, running, waiting on a
16
+ question or orphaned, and is unmounted as soon as the last one settles — the
17
+ one-line status bar stays. `off` removes the widget *and* the status line;
18
+ `always` keeps the old "mounted whenever there is a run" behaviour.
19
+ - **`/orchestra hide` and `/orchestra show [auto|always|off]`.** The choice is
20
+ stored per project (`state.json` → `ui.widget`) and wins over the config key, so
21
+ a new session in that directory stays quiet without editing any file.
22
+ - **`/orchestra reset` (alias `clean`).** Asks for confirmation, stops the
23
+ session's workers, copies `state.json` to `state.<ts>.bak.json` and clears runs,
24
+ tasks, dispatches and gates. Logs, prompts and mail stay on disk for `prune`.
25
+ The tool action `reset` now shares the same code path.
26
+ - **`staleRunHours` (default `12`).** A run whose workers are all terminal (an
27
+ `orphaned` process is not terminal) and whose last activity is older than the
28
+ window stops being the current run, so a fresh session starts with no run and
29
+ new work creates a new one instead of appending to yesterday's. `0` restores the
30
+ previous behaviour.
31
+ - `state.ui` in `state.json`: `widget` (the hide/show preference) and
32
+ `pinnedRunId` (set by `/orchestra use`, so reopening an old run on purpose does
33
+ not get hidden again).
34
+ - `/orchestra status` in a session with no current run points at the earlier runs
35
+ that are kept on disk.
36
+
37
+ ### Changed
38
+
39
+ - **The widget no longer shows another session's work.** `refreshUI` renders the
40
+ current run only: with no run (a new directory, or only stale/older runs) the
41
+ status line and the widget are both cleared instead of counting every dispatch
42
+ in the store. The widget's animation timer keeps its 500 ms dirty-check.
43
+ - `/orchestra use <run>` (and `o` in the browser) pins the run it switches to, and
44
+ creating a new run releases the pin.
45
+ - The staleness window also applies to `runOf()`, so `task_create` / `worker_start`
46
+ in a new session never attach to a finished run from days ago.
47
+
48
+ ### Fixed
49
+
50
+ - A run that ended days ago no longer reappears on screen in a new session — the
51
+ cause was `activeRun()` always falling back to the newest run, plus terminal
52
+ `timeout` rows that the widget never collapsed, so it could not unmount.
53
+ - `state.ui` survives a reset: hiding the widget is a choice about the terminal,
54
+ not about the data. The `use` pin does not survive it.
55
+
56
+ ## [0.5.0] - 2026-11-30
57
+
58
+ ### Added
59
+
60
+ - **Published to npm.** `@loka1/pi-orchestra@0.5.0` is on the registry
61
+ (`pi install npm:@loka1/pi-orchestra`), with `repository`/`homepage`/`bugs`
62
+ metadata linking it back to this repo and the docs site. Tagged releases publish
63
+ themselves: the release workflow uses `NPM_TOKEN` with `--provenance` and falls
64
+ back to OIDC trusted publishing when no token is set.
65
+ - **Docs site.** `wiki/` is built into a GitHub Pages site
66
+ (<https://loka1.github.io/pi-orchestra/>) by `docs.yml` on every change:
67
+ `scripts/wiki-site.mjs` rewrites GitHub-wiki `[[Page]]` links to plain markdown
68
+ and turns `Home.md` into the landing page. The GitHub wiki mirror still exists,
69
+ but GitHub only creates `<repo>.wiki.git` after a page is saved once in the web
70
+ UI, so the site is the surface that always publishes.
71
+
72
+ - **Joined worker chat.** `/orchestra join <dispatch>` (or `j` in the browser)
73
+ opens one worker's conversation full-screen and lets you type into it: a steer
74
+ while it runs, a follow-up turn once it has settled. Header shows status, model,
75
+ turns, spend vs budget; `ctrl+t` toggles thinking, `ctrl+o` expands tool output,
76
+ `ctrl+e` opens the editor, `esc` returns to the browser and `ctrl+g` to your own
77
+ session. `/stop`, `/retry`, `/resume`, `/diff`, `/open`, `/back`, `/exit` and
78
+ `/help` work from the composer.
79
+ - `action=chat dispatch=<id> [includeThinking=true]` and `/orchestra chat <id>`
80
+ render the same conversation as text, for print/RPC modes.
81
+ - `extensions/lib/chat.ts` maps the worker event stream into conversation blocks
82
+ (brief, assistant, thinking, tool, result, error), folding the dispatch
83
+ preamble down to its task.
84
+ - **`/orchestra runs` and `/orchestra use <run>`.** List runs newest-first (the
85
+ active one is marked) and switch the active run from the prompt, matching the
86
+ `run_list` / `run_use` tool actions.
87
+ - **`/orchestra` argument completion.** Tab after `/orchestra` completes the
88
+ subcommand (with a one-line description), and a second tab completes live
89
+ dispatch, task, run and template ids where a command takes one.
90
+ - **`timeoutMode`.** `"idle"` restarts the worker's wall-clock timer on every
91
+ event, so a busy worker is never stopped mid-job — only silence for `timeoutMs`
92
+ is. `timeoutMs: 0` removes the limit, and `worker_start timeoutMs=` /
93
+ `timeoutMode=` override it per dispatch (repairs and resumes inherit it).
94
+
95
+ ### Changed
96
+
97
+ - The coordinator is told to **end its turn** after `worker_start` instead of
98
+ blocking in `orchestra_wait`: it is woken on settle or question, so the user can
99
+ keep working in the same session. `wait` stays for "nothing else can proceed".
100
+ - `j` joins the highlighted worker in the browser; `k`/`j` no longer move the
101
+ cursor (arrows, page keys, `Home`/`End` and `g`/`G` do).
102
+
103
+ ### Fixed
104
+
105
+ - **A stopped worker no longer reports as settled.** `worker_stop` set the status
106
+ and the stop reason after killing the process, so the exit handler's finalize
107
+ ran first and the wake-up said "settled" for a deliberate stop. The reason is
108
+ now recorded before the abort, and the report and glyph treat a `stopReason:
109
+ "user"` dispatch as `stopped` even if the race is lost.
110
+ - **Page, home/end and top/bottom keys now work in the browser.** Page keys were
111
+ forwarded to `SelectList` and only matched the default binding, `home`/`end`
112
+ were documented but never implemented, and terminals sending modifier variants
113
+ (`\x1b[5;2~`, `\x1b[6;5~`) did nothing. Both the list and the detail pane now
114
+ accept `PgUp`/`PgDn` in every common encoding, `Home`/`End`, `g`/`G` and
115
+ `ctrl+d`/`ctrl+u`.
116
+
117
+ ## [0.4.0] - 2026-11-30
118
+
119
+ The review-and-recovery release: a run can now be inspected, repaired and
120
+ cleaned up without leaving the session.
121
+
122
+ ### Added
123
+
124
+ - **Diff review.** Every dispatch records the git commit it started from;
125
+ `action=diff dispatch=<id>` and `D` in the browser show the base, stat,
126
+ untracked files and patch of what that worker changed.
127
+ - **Markdown run report.** `action=report` (and `/orchestra report`) writes
128
+ `exports/<runId>.md`: goal, task table, each report, failures with errors,
129
+ diff stats, cost totals and the regression line.
130
+ - **Cost regression.** Runs keep the template they came from, and metrics/report
131
+ compare against the previous run of the same template or name: cost, turns,
132
+ tool calls and wall time deltas.
133
+ - **Automatic retries.** `retries`/`retryBackoffMs` (config and `worker_start`)
134
+ queue a repair dispatch on failure with exponential backoff, attempt tracking
135
+ and no retry for deliberate stops, resumed sessions or exhausted budgets.
136
+ - **Orphan recovery.** A coordinator restart probes the pid: live processes
137
+ become `⚡ orphaned` (stoppable with `worker_stop` via SIGTERM, resumable) and
138
+ only dead ones are `lost`.
139
+ - **Budget pause.** `budgetAction: "ask"` pauses a run at its ceiling instead of
140
+ killing workers; `action=budget budgetUsd=<n>` raises it and resumes.
141
+ - **Retention.** `action=prune days=<n> dryRun=<bool>` deletes archived runs and
142
+ orphaned logs/prompts/mail/exports by age, never touching live state.
143
+ - **Structured filters.** `status:`, `agent:`, `kind:`, `run:`, `id:`, `task:`,
144
+ `model:`, `cost:` and `turns:` terms with comparisons, shared by the browser
145
+ search, `task_list`/`worker_list` and `/orchestra find`.
146
+
147
+ ### Changed
148
+
149
+ - `task_create`/`task_update` validate dependencies: unknown ids, self-deps and
150
+ cycles are refused with the path, and a cycle already on disk is shown as
151
+ `⊘ blocked · dependency cycle: A -> C -> B -> A` until fixed.
152
+ - `task_update` can now replace `deps` as well as set a status.
153
+
154
+ ## [0.3.0] - 2026-11-30
155
+
156
+ The toolbox release: a run can now be bounded, repaired, searched and audited
157
+ without leaving the session.
158
+
159
+ ### Added
160
+
161
+ - **Budgets.** `budgetUsdPerWorker`, `budgetUsdPerRun`, `budgetMsPerWorker`,
162
+ `budgetGraceMs`, overridable per dispatch (`worker_start budgetUsd=/budgetMs=`)
163
+ and per run (`run_create budgetUsd=`). Cost is checked on every event; a run
164
+ over its ceiling stops its workers and refuses new ones. A time budget asks the
165
+ worker to wrap up first and only then stops it, unlike the hard `timeoutMs`.
166
+ - **Stall watchdog.** `stallMs` (default 10 min) flags a worker that produced no
167
+ events — distinct from a timeout — as `⚠ stalled 12m` in the widget and status
168
+ line, with a message; `stallAction: "abort"` stops it.
169
+ - **`worker_resume`.** With `sessionMode: "session"`, a dispatch keeps its pi
170
+ session id and can be reopened later on the same session (linked with
171
+ `resumedFrom`, continuation prompt only). `/orchestra resume <id> [msg]`.
172
+ - **Repair dispatch.** `worker_start retryOf=<id>` reuses the failed attempt's
173
+ spec, agent, tools and model, and leads the prompt with its status, error, last
174
+ tool and report. `/orchestra retry <id>`.
175
+ - **Broadcast.** `orchestra_send dispatch="*"` and `/orchestra broadcast <msg>`
176
+ deliver one message to every live worker and report per-worker results.
177
+ - **Transcript search.** `action=search filter=…` and `/orchestra grep <text>` over
178
+ every `.pi/orchestra/logs/*.jsonl`, with dispatch, line numbers and redacted text.
179
+ - **Metrics and export.** `action=metrics` / the run detail pane show cost, turns,
180
+ tool calls, tokens, duration and a spend sparkline per worker; `action=export`
181
+ writes `.pi/orchestra/exports/<runId>.jsonl` (run header, worker rows, timeline
182
+ points with cumulative cost and turns).
183
+ - **Browser: bulk and sort.** `space` marks rows, `x`/`r`/`c` act on the mark set
184
+ (stop, retry, copy ids into the editor), `s`/`t` sort by cost/time, and `d` opens
185
+ the full transcript.
186
+
187
+ ### Changed
188
+
189
+ - The detail pane tails live: a log pager opens at the end, follows new events and
190
+ stops following as soon as you scroll (`f` toggles).
191
+ - Stopping a worker from the browser and `worker_stop` share one path, so the task
192
+ returns to `pending` and its budget timers are cleared either way.
193
+ - `worker_show` reports the last event time, `⚠ stalled since …` and the budgets.
194
+
195
+ ## [0.2.1] - 2026-11-30
196
+
197
+ ### Fixed
198
+
199
+ - **Workers no longer change model behind your back.** With `workerIsolation`, a
200
+ provider contributed by an extension package (e.g. `commandcode`) was not
201
+ registered in the worker, and the bare `--model deepseek/deepseek-v4.1-flash`
202
+ was read as `provider/id`, silently running `(deepseek) deepseek-v4-pro`.
203
+
204
+ ### Fixed (CI)
205
+
206
+ - The **Sync wiki** workflow no longer fails when the wiki has not been initialised
207
+ or `WIKI_TOKEN` is missing. It validates every page first (H1 title, linked from
208
+ `Home`, `[[links]]` resolve), then warns and skips the push. GitHub only creates
209
+ `<repo>.wiki.git` after the first page is saved in the web UI, so the old job
210
+ failed with `repository not found` until then.
211
+
212
+ ### Changed
213
+
214
+ - Workers are started with an explicit `--provider <name> --model <id>` pair,
215
+ resolved from `worker_start` params → agent frontmatter/`agents` override →
216
+ the coordinator's model. The provider is looked up in the coordinator's
217
+ catalogue, preferring its own provider when an id exists on several.
218
+ - Isolated workers load the extension that registers their provider, found
219
+ among the packages already installed in pi (`settings.json` → `packages`).
220
+ Nothing new to install; `providerExtensions` covers what discovery cannot see.
221
+ - Before spawning, the worker's own model list is probed
222
+ (`pi … --list-models <provider>/<id>`, one spawn per model, cached). When the
223
+ model is missing the worker falls back to the **coordinator's** model and
224
+ records `modelNote` instead of running a fuzzy match.
225
+ - `worker_start` accepts `provider`; agent frontmatter accepts `provider`;
226
+ `agents.<name>` overrides accept `provider`. The start banner, `worker_show`,
227
+ transcripts, reports and the browser print `(provider) model`.
228
+
229
+ ## [0.2.0] - 2026-11-30
230
+
231
+ ### Added
232
+
233
+ - **`/orchestra browse`** — an interactive list of tasks, workers and runs:
234
+ fuzzy search, `tab` to switch scope, `enter` for a detail view with the
235
+ worker report and transcript tail, `m` to message, `x` to stop, `f` to
236
+ follow, `o` to switch the active run. `/orchestra` opens it in TUI mode;
237
+ print and RPC modes print the same data as text.
238
+ - **`/orchestra open <id>`** and **`/orchestra find <query>`** for scripted use.
239
+ - `task_list` and `worker_list` take `filter`, `limit` (default 20) and
240
+ `offset`, and end with `showing 1–20 of 24 — offset=20` instead of dumping
241
+ every row into the model's context.
242
+ - `widgetMaxLines` (default 8) and `widgetShowSettled` (default false) config
243
+ keys.
244
+
245
+ ### Changed
246
+
247
+ - **The widget is a component now**, so it knows the viewport width: rows are
248
+ truncated with `…` instead of being clipped by pi, they are ordered by
249
+ urgency (`question` → `running` → `timeout`/`failed` → `ready` → settled)
250
+ and capped with `+N more · /orchestra browse`. Settled rows collapse into a
251
+ counter.
252
+ - Timeouts render as `⏱ timeout 15m` with their age instead of looking like a
253
+ generic failure, and the widget reports how many workers timed out.
254
+ - Task status now defers to its dispatch, on write and again when state is
255
+ reloaded. A task whose worker settled can no longer keep a `✗` glyph, and a
256
+ stopped worker returns its task to `pending` deterministically.
257
+
258
+ ### Fixed
259
+
260
+ - Widget rows were emitted in creation order with no width awareness, so long
261
+ titles were cut mid-word and pi printed `... (widget truncated)`.
262
+ - `statusLine`/widget counters disagreed with the worker rows after a restart
263
+ (e.g. `0 running` while two tasks showed `◌` ready).
264
+
265
+ ## [0.1.1] - 2026-11-29
266
+
267
+ ### Changed
268
+
269
+ - **Docs and examples now configure the reviewer agent with
270
+ `deepseek/deepseek-v4.1-flash` at `thinking: high`** (provider `commandcode`),
271
+ read-only tools (`read`, `grep`, `find`, `ls`, `bash`), in line with the
272
+ recommended review setup.
273
+ - Documented that model ids should use pi's `defaultModel` form, and that under
274
+ `workerIsolation` the bare id is the right choice because workers do not load
275
+ provider extensions.
276
+
277
+ ### Fixed
278
+
279
+ - The release workflow no longer references `secrets` in a step `if`, which made
280
+ GitHub reject the workflow file before running any job.
281
+
282
+ ## [0.1.0] - 2026-11-29
283
+
284
+ ### Added
285
+
286
+ - **Orchestration without an external runtime.** One pi session coordinates
287
+ other pi sessions. No daemon, no socket, no database file to manage.
288
+ - **Runs, tasks and dispatches.** Tasks carry `deps`; readiness (`pending` →
289
+ `ready` → `blocked`) is recomputed when a worker finishes, so a fan-out graph
290
+ can be drained task by task.
291
+ - **Worker processes over RPC.** Each dispatch is a real `pi --mode rpc` process
292
+ with its own context window, tools, model, thinking level and JSONL event log.
293
+ Events are parsed strictly by LF and correlated by request id.
294
+ - **Wake-ups instead of polling.** `agent_settled` in a worker turns into a
295
+ coordinator message with the final report and usage. `orchestra_wait` blocks,
296
+ and returns early when a worker is blocked on a question.
297
+ - **Questions and gates.** `orchestra_ask` in a worker blocks on a file in
298
+ `.pi/orchestra/mail/<dispatch>/`; `orchestra_answer` writes the reply and the
299
+ worker resumes. Pending questions are tracked as gates in state.
300
+ - **Steering and follow-up work.** `orchestra_send` steers a running worker or
301
+ continues a settled one, reopening its task.
302
+ - **Live UI.** Footer status line, task/worker widget, `/orchestra` subcommands
303
+ (`status`, `tasks`, `workers`, `read`, `watch`, `unwatch`, `stop`,
304
+ `questions`, `config`), and message renderers for worker reports and questions.
305
+ - **Isolated workers by default** (`workerIsolation`): `--no-extensions` plus
306
+ this extension only, so no MCP servers, no interactive gates and no recursive
307
+ dispatch. Interactive dialogs are auto-cancelled when isolation is off.
308
+ - **Agent definitions** shared with pi's subagent convention
309
+ (`~/.pi/agent/agents/*.md`, `.pi/agents/*.md`) and per-agent overrides in
310
+ config.
311
+ - **Durable state** in `.pi/orchestra/state.json` (atomic writes, git-ignored
312
+ automatically), one transcript log per dispatch, and a `reset` action that
313
+ archives the previous state instead of deleting it.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 loka1
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.