herdr-omp-lens 0.0.0-stage → 1.0.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 +52 -0
- package/LICENSE +21 -0
- package/README.md +223 -2
- package/docs/architecture.md +131 -0
- package/docs/assets/multisession.gif +0 -0
- package/docs/assets/overview.gif +0 -0
- package/docs/assets/scroll.gif +0 -0
- package/package.json +56 -4
- package/src/extension/api.ts +67 -0
- package/src/extension/bridge.ts +403 -0
- package/src/extension/history/index.ts +36 -0
- package/src/extension/history/merge.ts +40 -0
- package/src/extension/history/scan.ts +390 -0
- package/src/extension/history-stub.ts +30 -0
- package/src/extension/index.ts +282 -0
- package/src/extension/observe/index.ts +135 -0
- package/src/extension/observe/schemas.ts +120 -0
- package/src/extension/resolve.ts +14 -0
- package/src/extension/roster.ts +275 -0
- package/src/extension/topology.ts +704 -0
- package/src/herdr/adapter.ts +251 -0
- package/src/herdr/context.ts +46 -0
- package/src/herdr/guards.ts +62 -0
- package/src/herdr/lifecycle.ts +313 -0
- package/src/herdr/transport.ts +358 -0
- package/src/herdr/types.ts +76 -0
- package/src/index.ts +63 -0
- package/src/protocol/codec.ts +135 -0
- package/src/protocol/types.ts +84 -0
- package/src/viewer/cli.ts +532 -0
- package/src/viewer/client.ts +228 -0
- package/src/viewer/render.ts +189 -0
- package/src/viewer/state.ts +218 -0
- package/src/viewer/transcript.ts +275 -0
- package/src/viewer/tui.ts +679 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to herdr-omp-lens are documented here. Format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/); the project adheres to
|
|
5
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [1.0.0] — 2026-11-26
|
|
8
|
+
|
|
9
|
+
First public release — **"The Window"**: read-only observation of OMP's native subagents from
|
|
10
|
+
inside Herdr, rendered with OMP's own TUI components.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Native observation** of the current session's direct `task` workers via the
|
|
15
|
+
`task:subagent:{event,progress,lifecycle}` bus; direct-only scope, unknown-status passthrough.
|
|
16
|
+
- **Local unix-socket NDJSON bridge** — per-session `0700` dir, `0600` socket, versioned handshake,
|
|
17
|
+
coalesced deltas (≤150 ms), bounded buffers; `control.*` frames rejected at the boundary.
|
|
18
|
+
- **One `OMP subagents` tab per OMP session** in the caller workspace, opened `--no-focus` on first
|
|
19
|
+
delegation; close → next subtask reopens exactly one; survivor rebind after OMP restart (D2).
|
|
20
|
+
Multi-session ownership via session-suffixed labels + viewer argv0 token (`lens:<suffix>:<pid>`),
|
|
21
|
+
never hijacking another live session's tab.
|
|
22
|
+
- **Worker split** — `/lens split <workerId>` opens a no-focus worker-scoped view; closing it never
|
|
23
|
+
touches the worker.
|
|
24
|
+
- **OMP-look two-column viewer** built on `@oh-my-pi/pi-tui` (pinned to the installed OMP version):
|
|
25
|
+
`agent` painter roster, `kv` detail grid, live transcript via `omp render`. Fixed full-viewport
|
|
26
|
+
frame — statusLineBg header/footer bars, borderMuted T-junction rules, disclosure section headers,
|
|
27
|
+
accent `❯` + selectedBg selection, footer locked to the bottom row, resize-aware.
|
|
28
|
+
- **Persistent finished rows** — completed workers stay listed after OMP reaps them; `e` collapses
|
|
29
|
+
on demand; non-terminal reaps demote to `[not-live]` history; bounded retention (100).
|
|
30
|
+
- **Transcript scrolling** — `J`/`K` line, `PgDn`/`PgUp` page, `g` top, `G` live-follow, and the
|
|
31
|
+
**mouse wheel** (SGR 64/65); `↑ N earlier lines` / `↓ N more lines` indicators; view-local only.
|
|
32
|
+
- **History after restart** — persisted transcripts marked `[not-live]`, never implying live execution.
|
|
33
|
+
- **Degraded mode (D1)** — absent bus → one warn notice + artifact-scan discovery; Herdr/bridge death
|
|
34
|
+
never blocks an OMP turn.
|
|
35
|
+
- **Showcase recordings** — real asciinema→agg captures of the actual viewer (`docs/assets/`),
|
|
36
|
+
reproducible via `scripts/showcase/driver.ts`.
|
|
37
|
+
|
|
38
|
+
### Quality
|
|
39
|
+
|
|
40
|
+
- 501 tests / 0 fail across 36 files; `tsc --noEmit` and `biome check` clean.
|
|
41
|
+
- Tamper-proven safety invariants (no duplicate workers, worker survives viewer close, no focus
|
|
42
|
+
theft, read-only keyboard map, no `control.*`).
|
|
43
|
+
- Isolated-session E2E in disposable Herdr workspaces; daily workspaces proven untouched.
|
|
44
|
+
- Evidence pack: `docs/analysis/dod-v1-report.md` (19 pass / 2 manual-evidence / 0 fail).
|
|
45
|
+
|
|
46
|
+
### Known limitations
|
|
47
|
+
|
|
48
|
+
See the [README §Limitations](README.md#limitations) and the DoD report — history counters are not
|
|
49
|
+
reconstructable; `queued`/`idle`/`parked` have no reachable trigger on the pinned build;
|
|
50
|
+
pre-activation workers are not observed; Herdr-server-restart layout restore is a v2 horizon item.
|
|
51
|
+
|
|
52
|
+
[1.0.0]: https://github.com/fabzter/herdr-omp-lens/releases/tag/v1.0.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fabrizio Hernandez
|
|
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,224 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# 🪟 herdr-omp-lens
|
|
4
|
+
|
|
5
|
+
**A window into OMP's native subagents — from inside Herdr.**
|
|
6
|
+
|
|
7
|
+
[](https://github.com/fabzter/herdr-omp-lens/releases)
|
|
8
|
+
[](docs/analysis/dod-v1-report.md)
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
[](https://omp.sh)
|
|
11
|
+
[](https://herdr.dev)
|
|
12
|
+
|
|
13
|
+
When you delegate work in [OMP](https://omp.sh), it spins up native subagents — headless workers
|
|
14
|
+
doing research, edits, and reviews in the background. They live inside one terminal pane.
|
|
15
|
+
If you work in [Herdr](https://herdr.dev), you already think in tabs and panes.
|
|
16
|
+
|
|
17
|
+
**herdr-omp-lens gives those workers a second screen**: a tab in your workspace showing who's
|
|
18
|
+
working, what they're doing, and what they found — rendered with **OMP's own TUI components**.
|
|
19
|
+
No duplicate agents. No focus theft. Nothing leaves your machine.
|
|
20
|
+
|
|
21
|
+
OMP stays the boss. It owns the workers and their results. This is just a window.
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## ✨ What you get
|
|
30
|
+
|
|
31
|
+
- **One tab per OMP session.** Run several OMP sessions in one workspace — each gets its own
|
|
32
|
+
`OMP subagents` tab (additional ones suffixed `· <id>`), never a shared or hijacked view.
|
|
33
|
+
Opens with `--no-focus` on the first delegation; close it and the *next* subtask reopens exactly one.
|
|
34
|
+
- **OMP's own look.** The roster is painted by OMP's actual TUI component (`@oh-my-pi/pi-tui`'s
|
|
35
|
+
`agent` painter, pinned to your installed OMP version); the selected worker's detail and live
|
|
36
|
+
transcript (`omp render`) fill the right column. Fixed full-viewport frame: the footer stays
|
|
37
|
+
locked at the bottom, always.
|
|
38
|
+
- **Finished workers stay visible.** Completed workers remain listed — OMP-hub style — even after
|
|
39
|
+
OMP reaps them. `e` collapses them on demand. Both columns stay open at all times.
|
|
40
|
+
- **Scroll everything.** `J`/`K`, `PgUp`/`PgDn`, `g`/`G` — or just the **mouse wheel** — scroll the
|
|
41
|
+
transcript; `↑ N earlier lines` / `↓ N more lines` keep you oriented; `G` returns to live-follow.
|
|
42
|
+
- **History that knows it's history.** After an OMP restart, saved transcripts are still there,
|
|
43
|
+
labelled `[not-live]` — the viewer never implies execution that isn't happening.
|
|
44
|
+
- **Read-only by construction.** No key, click, or frame can steer, revive, or cancel a worker.
|
|
45
|
+
The bridge rejects every `control.*` frame at the handshake boundary.
|
|
46
|
+
- **Fail-soft — degraded mode (D1).** If the native bus is unavailable, one warn notice and
|
|
47
|
+
artifact-scan discovery. If Herdr or the bridge dies mid-turn, your OMP turn completes normally.
|
|
48
|
+
|
|
49
|
+
### Scroll the transcript — keys or wheel
|
|
50
|
+
|
|
51
|
+

|
|
52
|
+
|
|
53
|
+
### Two OMP sessions, two tabs, zero hijack
|
|
54
|
+
|
|
55
|
+

|
|
56
|
+
|
|
57
|
+
## 📦 Install
|
|
58
|
+
|
|
59
|
+
**Requirements:** OMP 19.2.1 (the design pin — re-pinned 19.0.1 → 19.1.1 per OI-1 → 19.2.1 per
|
|
60
|
+
OI-4, owner decisions 2026-11-25), Herdr 0.9.5, and [Bun](https://bun.sh) on `PATH`. The extension activates only inside a Herdr-managed pane
|
|
61
|
+
(`HERDR_ENV=1`); outside Herdr it is a complete no-op.
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
# one-liner (no clone needed)
|
|
65
|
+
omp plugin install github:fabzter/herdr-omp-lens#v1.0.0
|
|
66
|
+
|
|
67
|
+
# or from a clone of this repo
|
|
68
|
+
omp plugin link /path/to/herdr-omp-lens
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Also available via the [fabzter-plugins marketplace](.omp-plugin/marketplace.json):
|
|
72
|
+
`omp plugin marketplace add fabzter/herdr-omp-lens` then
|
|
73
|
+
`omp plugin install herdr-omp-lens@fabzter-plugins`.
|
|
74
|
+
|
|
75
|
+
> **Inside a Herdr pane, strip `HERDR_*` for the install command** — the installer otherwise waits
|
|
76
|
+
> on handles a running extension keeps open (install-time only; runtime is unaffected):
|
|
77
|
+
>
|
|
78
|
+
> ```sh
|
|
79
|
+
> env -u HERDR_ENV -u HERDR_PANE_ID -u HERDR_TAB_ID -u HERDR_WORKSPACE_ID \
|
|
80
|
+
> -u HERDR_SOCKET_PATH -u HERDR_BIN_PATH \
|
|
81
|
+
> omp plugin link /path/to/herdr-omp-lens
|
|
82
|
+
> ```
|
|
83
|
+
>
|
|
84
|
+
> To keep a daily profile untouched, link into a disposable profile instead:
|
|
85
|
+
> `omp --profile=<name> plugin link <path>` (the `--profile` flag comes *before* the subcommand).
|
|
86
|
+
|
|
87
|
+
Then **restart your OMP session** and delegate a task — the `OMP subagents` tab opens by itself.
|
|
88
|
+
|
|
89
|
+
## 🚀 Use
|
|
90
|
+
|
|
91
|
+
Delegate anything in OMP (`task` tool). The overview opens on the first spawn.
|
|
92
|
+
|
|
93
|
+
| Command | Effect |
|
|
94
|
+
| --- | --- |
|
|
95
|
+
| `/lens` | Open the overview (no-op if already open; never moves focus). |
|
|
96
|
+
| `/lens split <workerId>` | Open a no-focus, worker-scoped split for that worker. Closing it never touches the worker. |
|
|
97
|
+
|
|
98
|
+
### Keyboard (read-only by construction)
|
|
99
|
+
|
|
100
|
+
| Key | Action |
|
|
101
|
+
| --- | --- |
|
|
102
|
+
| `j` / `k` or `↑` / `↓` | Select an agent |
|
|
103
|
+
| `J` / `K` | Scroll transcript down / up |
|
|
104
|
+
| `PgDn` / `PgUp` | Scroll a page |
|
|
105
|
+
| `g` / `G` | Transcript top / back to live-follow |
|
|
106
|
+
| **mouse wheel** | Scroll transcript (Herdr forwards it) |
|
|
107
|
+
| `e` / `Enter` / `Space` | Collapse / expand the finished section |
|
|
108
|
+
| `t` | Toggle thinking display (hidden by default) |
|
|
109
|
+
| `r` | Refresh |
|
|
110
|
+
| `q` / `Ctrl-C` | Quit the viewer (never the worker) |
|
|
111
|
+
|
|
112
|
+
There is no key that sends anything to a worker.
|
|
113
|
+
|
|
114
|
+
**Scope:** v1 shows the **direct** `task` workers of the **current** OMP session. Nested children
|
|
115
|
+
and other sessions' workers are excluded by design; workers started before the extension activated
|
|
116
|
+
are not retroactively observed (see [limitations](#-limitations)).
|
|
117
|
+
|
|
118
|
+
## 🔍 How it works
|
|
119
|
+
|
|
120
|
+
An in-process OMP extension subscribes to `task:subagent:{event,progress,lifecycle}` through
|
|
121
|
+
`pi.events`, keeps a direct-worker roster, and publishes it over a **local unix-socket NDJSON
|
|
122
|
+
bridge** (per-session `0700` dir, socket `0600`, unlinked on exit). A small viewer CLI — launched
|
|
123
|
+
into the Herdr tab through a guarded, no-focus adapter — connects, receives a `hello` snapshot plus
|
|
124
|
+
deltas, and renders with OMP's own `pi-tui` components. Nothing is spawned by the viewer; nothing
|
|
125
|
+
leaves the machine.
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
OMP session ──pi.events──▶ extension ──unix socket──▶ viewer (Herdr pane)
|
|
129
|
+
owns workers roster + bridge pi-tui render, read-only
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
See [`docs/architecture.md`](docs/architecture.md) for the component map, data flow, invariants and
|
|
133
|
+
degraded-mode behavior, and the [SDD](docs/superpowers/specs/2026-11-19-herdr-omp-lens-design.md)
|
|
134
|
+
for the full design.
|
|
135
|
+
|
|
136
|
+
## ✅ Quality
|
|
137
|
+
|
|
138
|
+
- **501 tests / 0 fail** across 36 files; `tsc --noEmit` and `biome check` clean.
|
|
139
|
+
- **Tamper-proven invariants**: no duplicate workers, worker survives viewer close, no focus theft,
|
|
140
|
+
no `control.*` frames, read-only keyboard map — each guard test fails on a deliberate sabotage.
|
|
141
|
+
- **Isolated-session E2E** in disposable Herdr workspaces; daily workspaces proven byte-identical
|
|
142
|
+
before/after every run.
|
|
143
|
+
- Evidence pack: [DoD-v1 report](docs/analysis/dod-v1-report.md) ·
|
|
144
|
+
[E2E evidence](docs/analysis/e2e-evidence.md) ·
|
|
145
|
+
[clean-profile install](docs/analysis/clean-profile-install.md).
|
|
146
|
+
|
|
147
|
+
Regenerate the evidence report with `bun scripts/gen-dod-report.ts`.
|
|
148
|
+
|
|
149
|
+
### Verified commands
|
|
150
|
+
|
|
151
|
+
Every command below was executed on 2026-11-26 at commit `a994629` (OMP 19.2.1 / Herdr 0.9.5) and
|
|
152
|
+
its output is quoted verbatim:
|
|
153
|
+
|
|
154
|
+
```console
|
|
155
|
+
$ bun test
|
|
156
|
+
501 pass
|
|
157
|
+
0 fail
|
|
158
|
+
1832 expect() calls
|
|
159
|
+
Ran 501 tests across 36 files. [3.82s]
|
|
160
|
+
|
|
161
|
+
$ bun run typecheck # tsc --noEmit — clean, no output
|
|
162
|
+
|
|
163
|
+
$ bun run lint
|
|
164
|
+
$ biome check src tests
|
|
165
|
+
Checked 68 files in 24ms. No fixes applied.
|
|
166
|
+
|
|
167
|
+
$ bash scripts/run-e2e.sh # safe mode — disposable round-trip, dailies untouched
|
|
168
|
+
checks : 7 pass, 0 fail, 0 manual, 5 skipped, 5 notes
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Limitations
|
|
172
|
+
|
|
173
|
+
Recorded known limitations — each a deliberate v1 boundary or an honest gap with a named capture:
|
|
174
|
+
|
|
175
|
+
1. **History counters are not reconstructable.** Persisted JSONL carries roster fields and terminal
|
|
176
|
+
status, not the live `counters` stream; historical rows show counters absent, labelled *not live*.
|
|
177
|
+
2. **`queued` / `idle` / `parked` transitions** are mapped verbatim if OMP emits them, but no
|
|
178
|
+
reachable trigger was found on the pinned build (see
|
|
179
|
+
[caveat closure](docs/analysis/phase-0-caveat-closure.md)).
|
|
180
|
+
3. **Pre-activation workers** are not observed — there is no registry snapshot for extensions.
|
|
181
|
+
4. **Herdr-server-restart layout restore** is a v2 horizon item; an *OMP* restart reuses and rebinds
|
|
182
|
+
the surviving tab.
|
|
183
|
+
5. **TUI `detached` variance** is unconsumed (harmless but unverified).
|
|
184
|
+
|
|
185
|
+
Full list with evidence: [DoD report §Known limitations](docs/analysis/dod-v1-report.md).
|
|
186
|
+
|
|
187
|
+
## 🗺️ Roadmap
|
|
188
|
+
|
|
189
|
+
- **v1 — "The Window" (this release):** read-only observation, OMP-look two-column frame,
|
|
190
|
+
persistent finished rows, transcript scroll (keys + wheel), one tab per session.
|
|
191
|
+
- **v2 — "The Console" (horizon):** safe interactive control — steer, follow up, revive, stop —
|
|
192
|
+
routed back to the session that owns the worker.
|
|
193
|
+
|
|
194
|
+
## 📚 Documentation
|
|
195
|
+
|
|
196
|
+
- [Architecture notes](docs/architecture.md) — components, data flow, invariants, degraded mode.
|
|
197
|
+
- [Software Design Document](docs/superpowers/specs/2026-11-19-herdr-omp-lens-design.md) — source of truth.
|
|
198
|
+
- [DoD-v1 evidence report](docs/analysis/dod-v1-report.md) — requirement matrix and sign-off block.
|
|
199
|
+
- [Isolated-session E2E evidence](docs/analysis/e2e-evidence.md) — runs, findings, live witnesses.
|
|
200
|
+
- [Clean-profile install + version discipline](docs/analysis/clean-profile-install.md).
|
|
201
|
+
- [Phase 0 caveat closure](docs/analysis/phase-0-caveat-closure.md) — what the bus really emits.
|
|
202
|
+
- [Seam research](docs/analysis/research-seams.md) · [ADR-0001](docs/adr/0001-observation-seam.md).
|
|
203
|
+
- [Contributing](CONTRIBUTING.md) — dev setup, tests, review gates.
|
|
204
|
+
|
|
205
|
+
## 🎬 Showcase recordings
|
|
206
|
+
|
|
207
|
+
The GIFs above are **real recordings of the actual viewer** (asciinema → agg), reproducible from
|
|
208
|
+
this repo: `bun scripts/showcase/driver.ts <overview|scroll>` drives the real `runViewer` against a
|
|
209
|
+
scripted local bridge with demo data; the multi-session capture runs two real OMP agents in a
|
|
210
|
+
disposable Herdr workspace. Sources: [`scripts/showcase/`](scripts/showcase/),
|
|
211
|
+
[`docs/assets/`](docs/assets/) (`.cast` + `.gif`).
|
|
212
|
+
|
|
213
|
+
## License
|
|
214
|
+
|
|
215
|
+
[MIT](LICENSE) © 2026 Fabrizio Hernandez.
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
<div align="center">
|
|
220
|
+
|
|
221
|
+
Built with care for people who live in their terminal.
|
|
222
|
+
Be kind to your workers; they're doing their best. 🪟
|
|
223
|
+
|
|
224
|
+
</div>
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# herdr-omp-lens — architecture notes (v1 + v1.1, shipped)
|
|
2
|
+
|
|
3
|
+
This document describes the **shipped** v1 architecture: an in-process OMP extension that observes
|
|
4
|
+
the native `task` subagents of the current session and publishes them over a local-only bridge to a
|
|
5
|
+
read-only viewer CLI running in Herdr panes. Authoritative requirements live in the
|
|
6
|
+
[SDD](superpowers/specs/2026-11-19-herdr-omp-lens-design.md); this note mirrors what the code does,
|
|
7
|
+
not the draft.
|
|
8
|
+
|
|
9
|
+
## Component map
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
OMP interactive session (the agent that owns the workers)
|
|
13
|
+
└─ src/extension/ in-process extension, bound via package.json `omp.extensions`
|
|
14
|
+
gate callerContext() — activates only under HERDR_ENV=1 with all caller ids
|
|
15
|
+
observe/ pi.events.on(task:subagent:{event,progress,lifecycle}) + pi.on(before_subagent_spawn)
|
|
16
|
+
roster direct-worker reducer (status map, notices, counters from the nested progress envelope)
|
|
17
|
+
history/ bounded fs scan of ~/.omp/agent/sessions/<encoded-cwd>/ (read-only, no lease, no history://)
|
|
18
|
+
bridge per-session unix socket (0700 dir, 0600 sock), NDJSON, hello + deltas + notices
|
|
19
|
+
topology overview tab + worker splits through the guarded Herdr adapter (no-focus only)
|
|
20
|
+
resolve resolveViewerCommand() → `bun <pkg>/src/viewer/cli.ts` (never process.cwd())
|
|
21
|
+
├─ src/herdr/ the single Herdr boundary
|
|
22
|
+
context HERDR_* env → CallerContext
|
|
23
|
+
transport unix-socket NDJSON RPC + events.subscribe stream (timeouts, circuit break)
|
|
24
|
+
adapter typed methods only; every create/split passes focus:false; env passthrough
|
|
25
|
+
guards runtime denylist + param guards (no layout.apply tab_id, no agent start, no focus:true)
|
|
26
|
+
lifecycle transparent resubscribe on events_lost → onEventsLost reconcile hook
|
|
27
|
+
├─ src/protocol/ versioned NDJSON codec (PROTOCOL_VERSION=1)
|
|
28
|
+
types/codec strict Zod shapes; client boundary accepts ONLY the viewer handshake (control.* rejected)
|
|
29
|
+
└─ src/viewer/ read-only renderer, runs as an ordinary Herdr pane
|
|
30
|
+
cli env/argv resolution, keymap (select + view-local transcript scroll, SGR wheel), main loop
|
|
31
|
+
client connects, handshakes, applies hello + deltas (never writes after the handshake)
|
|
32
|
+
state/render roster + persistent finished section (v1.2: retained after reap, ≤100) + history (not-live) + banners
|
|
33
|
+
tui v1.1 two-column OMP-look screen: pi-tui `agent` painter roster (left) + inspector/transcript (right);
|
|
34
|
+
exact-version pin to the installed OMP; stacks <100 cols; LENS_PLAIN/--plain → legacy render
|
|
35
|
+
transcript `omp render <sessionFile> --plain` via a filtered temp copy (thinking hidden by default)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Data flow
|
|
39
|
+
|
|
40
|
+
1. **Gate.** `lensExtension(pi)` is a complete no-op unless `HERDR_ENV=1` and the caller context vars
|
|
41
|
+
are all present — no commands, hooks, sockets, or Herdr calls happen otherwise.
|
|
42
|
+
2. **Observe.** `before_subagent_spawn` opens the direct-worker id set; the three
|
|
43
|
+
`task:subagent:*` channels feed a synchronous reducer (status transitions, counters, activity,
|
|
44
|
+
sessionFile). Handlers enqueue work and return — no `await` inside a bus or command handler.
|
|
45
|
+
3. **Publish.** The bridge binds a unix socket in a per-session `0700` directory (`0600` socket),
|
|
46
|
+
authenticates with the versioned `{v:1, role:"viewer", session}` handshake, then streams `hello`
|
|
47
|
+
(roster + history) followed by `worker.upsert` / `worker.removed` / `transcript.ref` / `notice`.
|
|
48
|
+
Progress bursts coalesce to at most one delta per ≤150 ms window (latest-wins).
|
|
49
|
+
4. **Present.** The topology manager subscribes to the lifecycle event stream **before** the first
|
|
50
|
+
`tab.create`, opens exactly one `--no-focus` `OMP subagents` tab, and runs the viewer in its root
|
|
51
|
+
pane with `env = {LENS_SOCKET_PATH, LENS_SESSION, [LENS_WORKER_ID]}`. `LENS_SOCKET_PATH` is the
|
|
52
|
+
*bridge* socket, never the caller's `HERDR_SOCKET_PATH`.
|
|
53
|
+
5. **Render.** The viewer paints roster, inspector, and the selected worker's transcript. On a TTY
|
|
54
|
+
(v1.1) it renders OMP's own look through `@oh-my-pi/pi-tui`'s `agent` painter — two columns
|
|
55
|
+
(roster left, detail right), stacked under 100 columns; a dynamic import falls back to the plain
|
|
56
|
+
single-column renderer when pi-tui is absent or `LENS_PLAIN=1`/`--plain` is set. Both columns
|
|
57
|
+
render at all times (v1.2, owner UX decision 2026-11-25): finished workers stay listed after
|
|
58
|
+
`worker.removed` (finished rows retained; non-terminal reaps demote to *not-live* history;
|
|
59
|
+
retention ≤100). The only bytes the viewer ever sends are its handshake.
|
|
60
|
+
|
|
61
|
+
## Topology lifecycle
|
|
62
|
+
|
|
63
|
+
- **Auto-open** on the first `worker.spawned` signal (single-flight: concurrent spawns open exactly
|
|
64
|
+
one tab) and on startup when the history scan is non-empty (`onHistoryPresent`, D2).
|
|
65
|
+
- **Reopen** after a manual close on the *next* spawn — one tab, deduplicated against an
|
|
66
|
+
authoritative `session.snapshot` read so concurrent events can't double-create.
|
|
67
|
+
- **One tab per OMP session (v1.4).** The first session keeps the plain `OMP subagents` label (the
|
|
68
|
+
D2 restart anchor); additional live sessions get `OMP subagents · <suffix>` (suffix = the session
|
|
69
|
+
id's random tail — UUIDv7 heads collide). A session rebinds only its OWN tab; the plain anchor is
|
|
70
|
+
adoptable only when its viewer's owner pid is dead (restart orphan). Ownership is read from the
|
|
71
|
+
viewer's argv0 token `lens:<suffix>:<pid>` via `pane.process_info` — a live foreign owner is never
|
|
72
|
+
hijacked.
|
|
73
|
+
- **`/lens`** opens the overview; **`/lens split <workerId>`** opens a no-focus worker-scoped split
|
|
74
|
+
(one per worker; repeats reuse the live pane). Both are read-only and never touch the worker.
|
|
75
|
+
- **Survivor rebind (D2).** After an OMP restart a surviving `OMP subagents` pane is rebound to the
|
|
76
|
+
*new* bridge socket — the viewer reconnects to the new session and history shows *not-live*; no
|
|
77
|
+
duplicate tab is created.
|
|
78
|
+
- **Authoritative reconcile.** `pane.closed`/`pane.exited` are hints; state clears only when an
|
|
79
|
+
authoritative `getPane`/`snapshot` misses. `pane.moved` rewrites owned ids so a later close hits
|
|
80
|
+
the new id. `events_lost` triggers the adapter's transparent resubscribe plus one
|
|
81
|
+
`onEventsLost` → `snapshot()` reconcile — never a second subscription.
|
|
82
|
+
|
|
83
|
+
## Invariants (enforced by tests, tamper-proven)
|
|
84
|
+
|
|
85
|
+
- **Read-only v1.** No `control.*` frame is accepted; the viewer has no control affordance.
|
|
86
|
+
- **No worker duplication.** View operations never emit `before_subagent_spawn`; the roster is only
|
|
87
|
+
fed by native bus frames.
|
|
88
|
+
- **Worker ≠ view.** Closing the overview or a split emits topology signals only — never
|
|
89
|
+
`worker.removed`, never an OMP side effect.
|
|
90
|
+
- **No focus theft.** Every adapter create/split carries `focus:false`; `layout.apply` with
|
|
91
|
+
`tab_id`, `agent start`, `report_agent`, and `focus:true` are runtime-denied at the transport
|
|
92
|
+
boundary (two layers: source scan + runtime guard).
|
|
93
|
+
- **No focus or agent claims.** Owned panes report only `pane.report_metadata` with the required
|
|
94
|
+
`source` field.
|
|
95
|
+
- **Local-only.** The bridge binds unix sockets only — `0600` in a `0700` per-session dir, unlinked
|
|
96
|
+
on `close()`/SIGINT/SIGTERM; no TCP listener is ever bound.
|
|
97
|
+
- **Fire-and-forget.** Every `pi.on`/`pi.events.on` handler and command is synchronous; a throwing
|
|
98
|
+
downstream (dead bridge, dead Herdr) becomes one `notice`, never a thrown escape into an OMP turn.
|
|
99
|
+
`session_shutdown` tears the lens down asynchronously and idempotently.
|
|
100
|
+
|
|
101
|
+
## Degraded mode (D1)
|
|
102
|
+
|
|
103
|
+
- `pi.events` absent → the bus subscribes nothing, `before_subagent_spawn` still attaches, and after
|
|
104
|
+
the bridge starts exactly **one** `notice{level:"warn"}` is broadcast. Discovery relaxes to the
|
|
105
|
+
bounded artifact scan (live roster/counter promises FR-02/04/10 are explicitly relaxed).
|
|
106
|
+
- Herdr adapter/socket failure → the topology manager goes `degraded` with one `notice`, signals
|
|
107
|
+
still flow, and it recovers through the `events_lost` reconcile path; refused fails fast, a stalled
|
|
108
|
+
socket trips the per-call timeouts (2 s connect / 5 s RPC) and circuit-breaks.
|
|
109
|
+
- Missing/corrupt history → that entry is skipped with a per-file warning; the scan still succeeds
|
|
110
|
+
and the viewer gets one deduplicated warn notice.
|
|
111
|
+
|
|
112
|
+
## History
|
|
113
|
+
|
|
114
|
+
`src/extension/history/` scans `~/.omp/agent/sessions/<encoded-cwd>/<ts>_<session-id>/*.jsonl` for
|
|
115
|
+
the current cwd only: newest ≤20 session dirs, ≤100 workers, mtime-keyed cache, bounded tail-read for
|
|
116
|
+
the terminal marker. Every emitted snapshot is `historical:true`, merged into `hello.history` with
|
|
117
|
+
**live-wins** dedupe. The scan performs no writes, no spawns, no sockets, no `history://` reads —
|
|
118
|
+
`omp render` is the only transcript path.
|
|
119
|
+
|
|
120
|
+
## Testing shape
|
|
121
|
+
|
|
122
|
+
- `tests/protocol|viewer|herdr|extension` — unit tests for codec, state/render, adapter, roster,
|
|
123
|
+
observe wiring, topology (mocked adapter).
|
|
124
|
+
- `tests/guards` — safety-invariant tamper tests, each proven red on a deliberate sabotage
|
|
125
|
+
(`tests/guards/sabotage.md`), plus source-scan + runtime denylist guards and deterministic perf
|
|
126
|
+
bounds (100-frame burst → 1 coalesced upsert; 50k frames → flat heap, bounded lines).
|
|
127
|
+
- `tests/harness/isolated-session` + `tests/e2e/isolated-session.e2e.ts` + `scripts/run-e2e.sh` —
|
|
128
|
+
disposable named Herdr-session E2E (safe default; `RUN_E2E_LIVE=1` for the full lifecycle).
|
|
129
|
+
- `bun scripts/gen-dod-report.ts` — regenerates [`analysis/dod-v1-report.md`](analysis/dod-v1-report.md):
|
|
130
|
+
maps every FR-01..15 + NFR-01..06 to a test or a named manual capture, plus the doc-vs-shipped
|
|
131
|
+
checklist.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "herdr-omp-lens",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"omp": {
|
|
7
|
+
"extensions": [
|
|
8
|
+
"./src/extension/index.ts"
|
|
9
|
+
]
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "bun test",
|
|
13
|
+
"typecheck": "tsc --noEmit",
|
|
14
|
+
"lint": "biome check src tests"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@oh-my-pi/pi-tui": "19.2.1",
|
|
18
|
+
"@oh-my-pi/pi-wire": "19.2.1",
|
|
19
|
+
"zod": "^4.1.13"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@biomejs/biome": "^2.3.5",
|
|
23
|
+
"bun-types": "^1.3.3",
|
|
24
|
+
"typescript": "^5.9.3"
|
|
25
|
+
},
|
|
26
|
+
"description": "A window into OMP's native subagents, from inside Herdr \u2014 read-only, OMP's own TUI look, one tab per session.",
|
|
27
|
+
"keywords": [
|
|
28
|
+
"omp",
|
|
29
|
+
"omp-plugin",
|
|
30
|
+
"omp-extension",
|
|
31
|
+
"oh-my-pi",
|
|
32
|
+
"herdr",
|
|
33
|
+
"subagents",
|
|
34
|
+
"tui",
|
|
35
|
+
"terminal",
|
|
36
|
+
"viewer"
|
|
37
|
+
],
|
|
38
|
+
"homepage": "https://github.com/fabzter/herdr-omp-lens#readme",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://github.com/fabzter/herdr-omp-lens.git"
|
|
42
|
+
},
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/fabzter/herdr-omp-lens/issues"
|
|
45
|
+
},
|
|
46
|
+
"author": "Fabrizio Hernandez",
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
},
|
|
50
|
+
"files": [
|
|
51
|
+
"src",
|
|
52
|
+
"README.md",
|
|
53
|
+
"LICENSE",
|
|
54
|
+
"CHANGELOG.md",
|
|
55
|
+
"docs/architecture.md",
|
|
56
|
+
"docs/assets/*.gif"
|
|
57
|
+
]
|
|
58
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural subset of the OMP extension API (`ExtensionAPI` from
|
|
3
|
+
* `@oh-my-pi/pi-coding-agent`). Declared locally — per the P1 ruling the
|
|
4
|
+
* package stays dependency-light and OMP's real `pi` object satisfies this
|
|
5
|
+
* type structurally at runtime.
|
|
6
|
+
*
|
|
7
|
+
* All handlers MUST enqueue work synchronously and return immediately
|
|
8
|
+
* (fire-and-forget): never awaiting I/O inside a handler is what guarantees
|
|
9
|
+
* an OMP turn is never blocked (FR-12 / F-15).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Structural subset of the OMP handler ctx the lens reads: session identity
|
|
14
|
+
* only (`ctx.sessionManager.getSessionId()` — RC-4's LENS_SESSION source).
|
|
15
|
+
* OMP's real `ExtensionContext`/`ExtensionCommandContext` satisfies this
|
|
16
|
+
* structurally; all members optional so partial test doubles type-check.
|
|
17
|
+
*/
|
|
18
|
+
export interface LensContext {
|
|
19
|
+
sessionManager?: {
|
|
20
|
+
getSessionId?(): string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Handler for a `/`-command invocation; receives the raw argument tail plus
|
|
26
|
+
* the OMP handler ctx (session identity lives there — see LensContext).
|
|
27
|
+
*/
|
|
28
|
+
export type LensCommandHandler = (args: string, ctx?: LensContext) => void;
|
|
29
|
+
|
|
30
|
+
/** Slash-command registration passed to `pi.registerCommand`. */
|
|
31
|
+
export interface LensCommandDefinition {
|
|
32
|
+
description: string;
|
|
33
|
+
handler: LensCommandHandler;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** OMP lifecycle hook handler (`pi.on`). Fire-and-forget. */
|
|
37
|
+
export type LensHookHandler = (event: unknown, ctx?: LensContext) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Undocumented event-bus surface (`pi.events`): carries the
|
|
40
|
+
* `task:subagent:{lifecycle,progress,event}` channels observed in Phase 0.
|
|
41
|
+
* Subscriptions are fire-and-forget.
|
|
42
|
+
*/
|
|
43
|
+
export interface LensEventBus {
|
|
44
|
+
on(channel: string, handler: (payload: unknown) => void): void;
|
|
45
|
+
/**
|
|
46
|
+
* Detach a channel handler when the host bus exposes removal. Optional:
|
|
47
|
+
* the bus surface is undocumented (Phase 0), so consumers also guard
|
|
48
|
+
* handlers with a stopped flag for a deterministic `stop()`.
|
|
49
|
+
*/
|
|
50
|
+
off?(channel: string, handler: (payload: unknown) => void): void;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The subset of `ExtensionAPI` the lens extension touches. */
|
|
54
|
+
export interface LensExtensionApi {
|
|
55
|
+
/** Register a `/name` slash command. */
|
|
56
|
+
registerCommand(name: string, definition: LensCommandDefinition): void;
|
|
57
|
+
/** Subscribe to an OMP lifecycle hook (e.g. `before_subagent_spawn`). */
|
|
58
|
+
on(event: string, handler: LensHookHandler): void;
|
|
59
|
+
/** Detach a hook handler when the host exposes removal (best-effort). */
|
|
60
|
+
off?(event: string, handler: LensHookHandler): void;
|
|
61
|
+
/**
|
|
62
|
+
* Event bus for `task:subagent:*` channels. Optional: the surface is
|
|
63
|
+
* undocumented (Phase 0), so consumers feature-detect and degrade to a
|
|
64
|
+
* `notice` when absent (P2-R8) instead of throwing.
|
|
65
|
+
*/
|
|
66
|
+
events?: LensEventBus;
|
|
67
|
+
}
|