gentle-shell-bridge 0.0.0-stage → 0.3.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/.codegraph/.gitignore +5 -0
- package/PRD.md +144 -0
- package/README.md +745 -2
- package/docs/architecture.md +981 -0
- package/docs/contract.md +1266 -0
- package/docs/state.md +251 -0
- package/examples/bash-card.ts +1694 -0
- package/gentle-shell-bridge-0.3.0.tgz +0 -0
- package/odd/tasks/palette-sections.md +30 -0
- package/odd/tasks/plugin-keymap.md +32 -0
- package/odd/tasks/plugin-surface-contract.md +55 -0
- package/package.json +35 -4
- package/src/api.ts +492 -0
- package/src/arm.ts +83 -0
- package/src/bus.ts +558 -0
- package/src/capture.ts +886 -0
- package/src/card-style-line.ts +112 -0
- package/src/card-style-rows.ts +390 -0
- package/src/card-style-transform.ts +862 -0
- package/src/card-style-wiring.ts +472 -0
- package/src/card-styles.ts +159 -0
- package/src/config.ts +71 -0
- package/src/extension.ts +271 -0
- package/src/hook.ts +310 -0
- package/src/index.ts +71 -0
- package/src/notices.ts +137 -0
- package/src/plugin-lines.ts +865 -0
- package/src/plugin-surface.ts +218 -0
- package/src/presence.ts +259 -0
- package/src/repaint.ts +351 -0
- package/src/row-labels.ts +146 -0
- package/src/row-names.ts +273 -0
- package/src/row-origin.ts +144 -0
- package/src/rows.ts +248 -0
- package/src/section-panel.ts +378 -0
- package/src/section-pointer.ts +164 -0
- package/src/sections-rows.ts +128 -0
- package/src/sidebar-render.ts +535 -0
- package/src/sidebar.ts +919 -0
- package/src/status.ts +1161 -0
- package/src/store.ts +279 -0
- package/src/tool-design-adoption.ts +263 -0
- package/src/tool-design-rows.ts +246 -0
- package/src/tool-design-wiring.ts +428 -0
- package/src/tool-designs.ts +402 -0
- package/src/transform-pipeline.ts +351 -0
- package/src/types.ts +442 -0
- package/src/visibility.ts +154 -0
- package/test/api.test.ts +395 -0
- package/test/apply-on-move.test.ts +477 -0
- package/test/arm.test.ts +220 -0
- package/test/bridge-ready.test.ts +309 -0
- package/test/bus.test.ts +165 -0
- package/test/button-rows.test.ts +409 -0
- package/test/capture.test.ts +356 -0
- package/test/card-style-rows.test.ts +510 -0
- package/test/card-style-transform.test.ts +379 -0
- package/test/card-style-wiring.test.ts +258 -0
- package/test/card-styles-e2e.test.ts +491 -0
- package/test/card-styles.test.ts +324 -0
- package/test/card-transcript-path.test.ts +178 -0
- package/test/config.test.ts +93 -0
- package/test/e2e.test.ts +443 -0
- package/test/example-bash-identity.test.ts +372 -0
- package/test/example-bash-matrix.test.ts +856 -0
- package/test/example-designs.test.ts +734 -0
- package/test/example-neon-transform.test.ts +283 -0
- package/test/example-plain-style.test.ts +1268 -0
- package/test/extension.test.ts +160 -0
- package/test/fake-events.ts +58 -0
- package/test/fake-host.ts +211 -0
- package/test/fake-sidebar.ts +516 -0
- package/test/fake-transcript.ts +486 -0
- package/test/frame-telemetry.test.ts +417 -0
- package/test/hook.test.ts +196 -0
- package/test/manifest.test.ts +105 -0
- package/test/new-category.test.ts +979 -0
- package/test/notices.test.ts +328 -0
- package/test/plugin-integration-lines.test.ts +979 -0
- package/test/plugin-surface.test.ts +152 -0
- package/test/presence.test.ts +459 -0
- package/test/rail-surfaces.test.ts +457 -0
- package/test/rail-width.test.ts +423 -0
- package/test/regression.test.ts +483 -0
- package/test/repaint-api.test.ts +200 -0
- package/test/reserved-categories.test.ts +361 -0
- package/test/row-labels.test.ts +284 -0
- package/test/row-names.test.ts +473 -0
- package/test/row-origin.test.ts +395 -0
- package/test/section-interaction.test.ts +364 -0
- package/test/section-panel.test.ts +403 -0
- package/test/sections-rows.test.ts +291 -0
- package/test/sidebar-backend.test.ts +471 -0
- package/test/sidebar-e2e.test.ts +331 -0
- package/test/sidebar-hover.test.ts +276 -0
- package/test/sidebar-independent.test.ts +349 -0
- package/test/sidebar-render.test.ts +281 -0
- package/test/sidebar-sections.test.ts +245 -0
- package/test/status-card-styles.test.ts +201 -0
- package/test/status-section-frame.test.ts +181 -0
- package/test/status-sections.test.ts +243 -0
- package/test/status.test.ts +209 -0
- package/test/store.test.ts +192 -0
- package/test/surface-repaint-cost.test.ts +520 -0
- package/test/tool-design-chain.test.ts +483 -0
- package/test/tool-design-cost.test.ts +473 -0
- package/test/tool-design-rows.test.ts +359 -0
- package/test/tool-designs.test.ts +745 -0
- package/test/transform-pipeline.test.ts +465 -0
- package/test/transforms-bus.test.ts +233 -0
- package/test/verifier-width-regressions.test.ts +164 -0
- package/tsconfig.json +18 -0
package/PRD.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# PRD — gentle-shell-bridge
|
|
2
|
+
|
|
3
|
+
## Problem
|
|
4
|
+
|
|
5
|
+
gentle-shell renders `/gentle:customize` from an array it builds itself and never exposes:
|
|
6
|
+
the `ctx.ui.custom` factory constructs a `VisualCustomizeView` and returns a six-method
|
|
7
|
+
adapter, so the rows exist only inside closures
|
|
8
|
+
(`extensions/gentle-shell.ts:3550`, `:3554-3561`). Any plugin that wants a settings line
|
|
9
|
+
therefore reaches for the only reachable moment — the factory call — and patches the host
|
|
10
|
+
to get at the rows.
|
|
11
|
+
|
|
12
|
+
That works once. It does not compose. Two independent wrappers each swap
|
|
13
|
+
`Array.prototype.map` around the same factory: the inner wrapper installs its patch last
|
|
14
|
+
and wins the capture, the outer wrapper captures nothing and degrades to a warning. With
|
|
15
|
+
the naive approach only one plugin's rows ever appear, and neither plugin can tell the
|
|
16
|
+
difference until someone looks at the menu. This is the collision the bridge exists to
|
|
17
|
+
remove, and it is observed behaviour, not a hypothesis: the first prototype using
|
|
18
|
+
duck-typing on the returned component silently injected nothing because the view is sealed
|
|
19
|
+
behind the adapter.
|
|
20
|
+
|
|
21
|
+
## Users
|
|
22
|
+
|
|
23
|
+
- **Plugin authors** (loon, and any future gentle-shell plugin) who want a settings row
|
|
24
|
+
without owning an interception layer, a rebind lifecycle, or a conflict policy.
|
|
25
|
+
- **gentle-shell users** who want every installed plugin's settings in the one menu they
|
|
26
|
+
already open, with no plugin silently missing.
|
|
27
|
+
|
|
28
|
+
## Goals
|
|
29
|
+
|
|
30
|
+
1. One interception layer per process, shared by every plugin.
|
|
31
|
+
2. A small, typed contract: publish a provider, get rows; dispose to remove them.
|
|
32
|
+
3. Rows that reflect live state, so the `●` marker never lies.
|
|
33
|
+
4. No silent failure: every absent row has a reportable reason.
|
|
34
|
+
5. One place to repair when gentle-shell's internals change.
|
|
35
|
+
|
|
36
|
+
## Non-goals
|
|
37
|
+
|
|
38
|
+
- Not a theme pack, banner engine or card renderer; it adds rows to existing categories.
|
|
39
|
+
- Not a UI framework: no widgets, layout engine, or rendering of its own.
|
|
40
|
+
- Not a configuration service for gentle-shell; gentle-shell keeps its own files.
|
|
41
|
+
- Not an upstream replacement: if Pi or gentle-shell ships a row-provider hook, the bridge
|
|
42
|
+
should shrink to a thin adapter over it rather than compete.
|
|
43
|
+
|
|
44
|
+
## Requirements
|
|
45
|
+
|
|
46
|
+
| ID | Requirement | Contract | Status |
|
|
47
|
+
| --- | --- | --- | --- |
|
|
48
|
+
| R1 | `registerRows(provider)` accepts providers and returns a disposer that removes exactly that provider's rows. | `registerRows`, provider shape | Implemented; unit tests plus the end-to-end suite |
|
|
49
|
+
| R2 | Providers are evaluated lazily when the menu is built, in subscription order, with a context carrying at least the active theme and the resolved config home. | Provider `rows(ctx)`, ordering | Implemented; `ctx` carries the factory's theme and the resolved config home, tested |
|
|
50
|
+
| R3 | The bridge supports every row kind gentle-shell's renderer understands: `category`, `label`, `choice`, `preview`, `visible`, `keyhint`, `action`. | Row kinds | Implemented as typed pass-through fields; exercised against the fake host, not the real renderer |
|
|
51
|
+
| R4 | A toggle is expressed as consecutive rows sharing `choice.setting`, and works with the renderer's own `●`/`○` and arrow/Enter handling. | Toggle recipe | Implemented; the end-to-end suite shows the `●` moving after `action()` on a fake host |
|
|
52
|
+
| R5 | Arm-time state is idempotent: repeated `session_start`, rebinds and double loads never double-wrap or double-inject. | Idempotency | Implemented; tested across two `session_start` events and a double entry load |
|
|
53
|
+
| R6 | A throwing provider loses its rows, is reported, and never breaks the menu or other providers. | Failure isolation | Implemented; tested per provider, with the failure reported by `/bridge-status` |
|
|
54
|
+
| R7 | A diagnostics command reports providers, active backend, last capture outcome and last failures. | `/bridge-status` | Implemented as `/bridge-status`; formatter and entry tested, including store problems and duplicate settings from the last menu build |
|
|
55
|
+
| R8 | Composition is stateless; persistence is the plugin's, with an optional namespaced store helper. | `createStore`, [docs/state.md](docs/state.md) | Implemented; `createStore` tested against temporary directories. One documented exception: a sidebar section's visibility is bridge-owned (see R12) |
|
|
56
|
+
| R9 | `registerSection(section)` adds a card to gentle-shell's sidebar and returns a disposer that removes it, with no extra step from the plugin. | `registerSection`, section shape | Implemented; end-to-end over the public API against the fake rail, never in a real TUI |
|
|
57
|
+
| R10 | Each registered section automatically contributes two consecutive rows to `Sections` (a readable label derived from its title or an explicit `rowLabel`, plus `shown`/`hidden`), reading and persisting the same value the rail renders; the id stays internal and never appears in a row. | Automatic toggle rows | Implemented; the menu, the persistence file and the next rail frame are asserted together — against the fake host and fake rail — including the label derivation and the collision rule |
|
|
58
|
+
| R11 | A hidden section is neither rendered nor built (`lines()`/`meta()` not called); a throwing section loses only its own body and is reported. | S7 failure isolation | Implemented; pinned with call counters and `/bridge-status` section failures, against the fake host |
|
|
59
|
+
| R12 | Section visibility persists in the bridge's own store, not the host's `visual-customization.json`, which rejects unknown keys. | `bridge-sections.json`, [docs/state.md](docs/state.md) | Implemented; the document shape is asserted byte-for-byte, and the reason for the separate file is recorded |
|
|
60
|
+
| R13 | `registerCardStyle(style)` accepts `{ id, label, frame: { top, line, bottom }, preview?, order? }`, validates id/label/frame before storing, replaces in place on the same id, and returns a disposer that removes exactly that style. | `registerCardStyle`, frame contract | Implemented; validation, ordering, replacement and disposal are unit-tested, and the published-API path is exercised end to end |
|
|
61
|
+
| R14 | A registered style joins the host's own `Card style` line (spliced in place, one coalesced line, the host's values untouched), with a `Bridge → card style` fallback line only when the host's line is not reachable; the selection is bridge-owned state, pressing a host value returns to native rendering, and a disposed style degrades to `native`/`missing`. | `bridge-card-style.json`, [docs/contract.md](docs/contract.md) §12 | Implemented; one bullet at a time, the way back, the fallback line and the missing-selection degrade are pinned against the fake host and reported by `/bridge-status` |
|
|
62
|
+
| R15 | When a registered style is selected, the bridge repaints the conversation frames the host already drew — detection, title/hint extraction, one style at a time, width clipping, and a pass-through for `native`, for a missing selection and for any throw — and reports the frame outcome. | [docs/architecture.md](docs/architecture.md) §14 | Implemented; proven against a fake conversation built from real `shell-card.ts` output, plus the end-to-end suite through the public API. A downstream post-processor can override the frame, which `/bridge-status` states |
|
|
63
|
+
| R16 | `registerTransform(transform)` accepts `{ id, order?, transform(lines, ctx) }`, validates the id and the function before storing, replaces in place on the same id and returns a disposer that removes exactly that transform; the conversation wrapper runs the card-style repaint first and then every transform in order, each receiving the previous output, clipping the result to the host width, isolating a throw or a non-lines return to that transform, and returning the host's own array when nothing changed; `/bridge-status` lists the pipeline in order with the last frame's outcome per transform. | `registerTransform`, [docs/contract.md](docs/contract.md) §13 | Implemented; ordering, replacement, disposal, identity, clipping, throw isolation and the status block are unit-tested, and the worked example's toggle is proven to restyle cards already on screen, with past and new cards byte-identical |
|
|
64
|
+
|
|
65
|
+
Sixteen requirements are implemented and covered by the 367-test `node --test` suite, 26 of them
|
|
66
|
+
end to end through the public API and the real extension entry. What is proven and what is not:
|
|
67
|
+
|
|
68
|
+
- **Proven against a fake host.** The row side drives a fake menu host that models
|
|
69
|
+
`gentle-shell.ts:3550-3562`: injection, ordering, toggles, failure isolation and the
|
|
70
|
+
diagnostics lines.
|
|
71
|
+
- **Proven against a fake conversation.** The card-style side drives a fake transcript built from
|
|
72
|
+
real `gentle-shell/lib/shell-card.ts` output at a fixed width, plus a fake `tui` that models Pi's
|
|
73
|
+
documented tree: detection, repaint, clipping, the pass-through paths, the disposal degrade, the
|
|
74
|
+
host line splice, the fallback line and the generation guard. The transform pipeline drives the
|
|
75
|
+
same conversation through the real wrapper: ordering, identity, clipping, per-transform throw
|
|
76
|
+
isolation and the `/bridge-status` block — plus the worked example's `Bash rendering` toggle, end
|
|
77
|
+
to end, where a card drawn before the switch and one drawn after it come out byte-identical.
|
|
78
|
+
- **Proven against a fake rail.** The sidebar side drives a fake terminal that models
|
|
79
|
+
`lib/shell-sidebar.ts`'s state symbol and `parts` map plus the layout's card frame
|
|
80
|
+
(`lib/shell-sidebar-layout.ts:35-44,392-410`): section cards, ordering, the `Sections` rows,
|
|
81
|
+
the store file, hiding and failure isolation.
|
|
82
|
+
- **Not proven in a running TUI.** Neither surface has been re-run inside a real Pi +
|
|
83
|
+
gentle-shell session through the package. In particular the sidebar's `tui` is acquired
|
|
84
|
+
through `ctx.ui.setWidget`, and whether a widget whose component renders no rows leaves the
|
|
85
|
+
editor area visually untouched is **unconfirmed**. R7's hook branch has never met a host
|
|
86
|
+
that exposes the registry it looks for.
|
|
87
|
+
- The capture technique itself is proven in the real TUI by the reference probe, not by these
|
|
88
|
+
tests.
|
|
89
|
+
- **The card-style repaint has not been seen in a live TUI.** It depends on the host's `float`
|
|
90
|
+
grammar and on Pi's component tree; both are cited, neither is observed at runtime here, and a
|
|
91
|
+
downstream post-processor can erase the frame — reported, not prevented.
|
|
92
|
+
|
|
93
|
+
## Success criteria
|
|
94
|
+
|
|
95
|
+
- Two independent providers coexist in one menu, each with its own rows and no lost
|
|
96
|
+
capture.
|
|
97
|
+
- A toggle persists through `action()`, the menu re-renders, and the `●` moves to the
|
|
98
|
+
applied value.
|
|
99
|
+
- No silent failure: an uncaptured menu, a broken provider or a duplicate `setting` is
|
|
100
|
+
visible in `/bridge-status`.
|
|
101
|
+
- When gentle-shell changes its menu construction, exactly one module needs repair.
|
|
102
|
+
- A plugin can add a card style with one call: the value appears on the host's own `Card style`
|
|
103
|
+
line, selecting it repaints every card the host drew, and selecting a host value or losing the
|
|
104
|
+
plugin returns the conversation to the host's rendering.
|
|
105
|
+
- A plugin can apply a rendering choice to the WHOLE conversation with one call: the choice reaches
|
|
106
|
+
cards drawn before the switch, not only the next one, and the worked example proves that a bash
|
|
107
|
+
card drawn before and one drawn after are byte-identical.
|
|
108
|
+
- The reference probe's observed result reproduces through the package against the fake host
|
|
109
|
+
that models the real call chain: a `Cards` category showing the injected line
|
|
110
|
+
`Card bash ● activity ○ output`. It has not yet been re-run in the real TUI through the
|
|
111
|
+
package.
|
|
112
|
+
|
|
113
|
+
## Risks and open questions
|
|
114
|
+
|
|
115
|
+
- **Upstream hook availability.** If Pi or gentle-shell adds a supported row-provider
|
|
116
|
+
registry, the capture backend becomes dead weight; the contract should stay stable
|
|
117
|
+
across that switch. A hook backend now exists (`src/hook.ts`) and prefers a recognized
|
|
118
|
+
registry over patching, but no host has been observed emitting
|
|
119
|
+
`Symbol.for("gentle-pi.customize-row-providers")` — that branch is implemented and
|
|
120
|
+
unverified.
|
|
121
|
+
- **Namespace policy.** Requiring namespaced `setting` names (`"Loon → Banner source"`)
|
|
122
|
+
avoids accidental merges but depends on authors complying; the bridge can warn on
|
|
123
|
+
duplicates but cannot rename rows without breaking identity.
|
|
124
|
+
- **Whether the store belongs in the package at all.** It is the only piece that writes to
|
|
125
|
+
disk and the only piece a plugin could implement itself. Shipping it is a convenience
|
|
126
|
+
bet, recorded with its alternatives in [docs/state.md](docs/state.md).
|
|
127
|
+
- **Diagnostics spelling.** Settled in code: the command is `/bridge-status`. Pi has no
|
|
128
|
+
built-in `/status`, and gentle-shell's commands live under the `gentle:` prefix, so a bare
|
|
129
|
+
`bridge-status` collides with neither. It has not yet been typed into a real host.
|
|
130
|
+
- **Compatibility drift.** The capture depends on one constructor line and one adapter
|
|
131
|
+
shape; every gentle-shell upgrade is a potential silent break until an upstream hook
|
|
132
|
+
exists. The sidebar surface depends on the same class of internals: the state symbol, the
|
|
133
|
+
`parts` map and the hard-coded rail key order.
|
|
134
|
+
- **The sidebar widget's visual footprint is unconfirmed.** Pi exposes no `tui` getter, so the
|
|
135
|
+
bridge acquires one through `ctx.ui.setWidget` and returns a component that paints nothing.
|
|
136
|
+
Whether that component leaves the editor area untouched has not been observed; if it does
|
|
137
|
+
not, the fix is the widget's rendering, not the contract.
|
|
138
|
+
- **Sections cannot be interleaved with the native cards.** The host builds its status
|
|
139
|
+
sections inside a closure, so "after every native section" is the honest contract; a user
|
|
140
|
+
request to slot a section between `CHANGES` and `STATS` cannot be met without an upstream
|
|
141
|
+
change.
|
|
142
|
+
- **Bridge-owned visibility is new state.** It is one namespaced file the bridge writes; a
|
|
143
|
+
future host that opens `VISUAL_SECTION_KEYS` would make it redundant and it should then be
|
|
144
|
+
migrated rather than duplicated.
|