gentle-shell-bridge 0.3.0 → 0.3.2
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/LICENSE +202 -0
- package/README.md +91 -722
- package/docs/contract.md +92 -35
- package/package.json +13 -1
- package/src/api.ts +1 -1
- package/.codegraph/.gitignore +0 -5
- package/PRD.md +0 -144
- package/examples/bash-card.ts +0 -1694
- package/gentle-shell-bridge-0.3.0.tgz +0 -0
- package/odd/tasks/palette-sections.md +0 -30
- package/odd/tasks/plugin-keymap.md +0 -32
- package/odd/tasks/plugin-surface-contract.md +0 -55
- package/test/api.test.ts +0 -395
- package/test/apply-on-move.test.ts +0 -477
- package/test/arm.test.ts +0 -220
- package/test/bridge-ready.test.ts +0 -309
- package/test/bus.test.ts +0 -165
- package/test/button-rows.test.ts +0 -409
- package/test/capture.test.ts +0 -356
- package/test/card-style-rows.test.ts +0 -510
- package/test/card-style-transform.test.ts +0 -379
- package/test/card-style-wiring.test.ts +0 -258
- package/test/card-styles-e2e.test.ts +0 -491
- package/test/card-styles.test.ts +0 -324
- package/test/card-transcript-path.test.ts +0 -178
- package/test/config.test.ts +0 -93
- package/test/e2e.test.ts +0 -443
- package/test/example-bash-identity.test.ts +0 -372
- package/test/example-bash-matrix.test.ts +0 -856
- package/test/example-designs.test.ts +0 -734
- package/test/example-neon-transform.test.ts +0 -283
- package/test/example-plain-style.test.ts +0 -1268
- package/test/extension.test.ts +0 -160
- package/test/fake-events.ts +0 -58
- package/test/fake-host.ts +0 -211
- package/test/fake-sidebar.ts +0 -516
- package/test/fake-transcript.ts +0 -486
- package/test/frame-telemetry.test.ts +0 -417
- package/test/hook.test.ts +0 -196
- package/test/manifest.test.ts +0 -105
- package/test/new-category.test.ts +0 -979
- package/test/notices.test.ts +0 -328
- package/test/plugin-integration-lines.test.ts +0 -979
- package/test/plugin-surface.test.ts +0 -152
- package/test/presence.test.ts +0 -459
- package/test/rail-surfaces.test.ts +0 -457
- package/test/rail-width.test.ts +0 -423
- package/test/regression.test.ts +0 -483
- package/test/repaint-api.test.ts +0 -200
- package/test/reserved-categories.test.ts +0 -361
- package/test/row-labels.test.ts +0 -284
- package/test/row-names.test.ts +0 -473
- package/test/row-origin.test.ts +0 -395
- package/test/section-interaction.test.ts +0 -364
- package/test/section-panel.test.ts +0 -403
- package/test/sections-rows.test.ts +0 -291
- package/test/sidebar-backend.test.ts +0 -471
- package/test/sidebar-e2e.test.ts +0 -331
- package/test/sidebar-hover.test.ts +0 -276
- package/test/sidebar-independent.test.ts +0 -349
- package/test/sidebar-render.test.ts +0 -281
- package/test/sidebar-sections.test.ts +0 -245
- package/test/status-card-styles.test.ts +0 -201
- package/test/status-section-frame.test.ts +0 -181
- package/test/status-sections.test.ts +0 -243
- package/test/status.test.ts +0 -209
- package/test/store.test.ts +0 -192
- package/test/surface-repaint-cost.test.ts +0 -520
- package/test/tool-design-chain.test.ts +0 -483
- package/test/tool-design-cost.test.ts +0 -473
- package/test/tool-design-rows.test.ts +0 -359
- package/test/tool-designs.test.ts +0 -745
- package/test/transform-pipeline.test.ts +0 -465
- package/test/transforms-bus.test.ts +0 -233
- package/test/verifier-width-regressions.test.ts +0 -164
- package/tsconfig.json +0 -18
package/docs/contract.md
CHANGED
|
@@ -7,7 +7,7 @@ What a plugin can rely on. The mechanism behind it is in
|
|
|
7
7
|
|
|
8
8
|
```ts
|
|
9
9
|
const dispose: () => void = registerRows(provider);
|
|
10
|
-
```
|
|
10
|
+
```text
|
|
11
11
|
|
|
12
12
|
Registers a row provider with the process-global bridge and returns a disposer
|
|
13
13
|
unsubscribing exactly that provider — no other provider's rows and no bridge state are
|
|
@@ -35,7 +35,7 @@ interface RowProvider {
|
|
|
35
35
|
name?: string; // optional: this plugin's INTEGRATIONS row (§8)
|
|
36
36
|
rows(ctx: RowContext): CustomizeRow[]; // evaluated lazily, per menu build
|
|
37
37
|
}
|
|
38
|
-
```
|
|
38
|
+
```text
|
|
39
39
|
|
|
40
40
|
- `rows()` runs each time the menu is built, never at registration. That is what makes
|
|
41
41
|
`current()` honest: the plugin reads its live state at build time, so the bullet matches
|
|
@@ -91,7 +91,7 @@ const toggle = (value: string) => ({
|
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
rows: () => [toggle("activity"), toggle("output")], // one rendered line
|
|
94
|
-
```
|
|
94
|
+
```text
|
|
95
95
|
|
|
96
96
|
The renderer draws one line, `Name ● current ○ other`, and handles the keys itself: ←/→ moves
|
|
97
97
|
the cursor inside the line and applies a value only when that row does not defer, Enter applies
|
|
@@ -151,7 +151,7 @@ Bash design OK a row name: the host's own vocabulary
|
|
|
151
151
|
Bash card → Bash rendering BAD arrow and a repeated qualifier: reads as a breadcrumb
|
|
152
152
|
Bash card: rendering BAD colon
|
|
153
153
|
Section: bash-card.status BAD prefix plus a dotted id
|
|
154
|
-
```
|
|
154
|
+
```text
|
|
155
155
|
|
|
156
156
|
The bridge enforces the shape instead of trusting authors; it is never a silent rewrite:
|
|
157
157
|
|
|
@@ -304,7 +304,7 @@ told once, on Pi's cross-extension bus.
|
|
|
304
304
|
Object.freeze({
|
|
305
305
|
schema: "gentle-shell-bridge/api", // identity, so a foreign payload is never mistaken for ours
|
|
306
306
|
version: 1, // the major; a breaking change is a NEW symbol key
|
|
307
|
-
VERSION: "0.3.
|
|
307
|
+
VERSION: "0.3.2", // the publishing release; informational only
|
|
308
308
|
registerRows,
|
|
309
309
|
registerSection,
|
|
310
310
|
registerCardStyle, // since 0.2.0; optional on an older published object
|
|
@@ -313,7 +313,7 @@ Object.freeze({
|
|
|
313
313
|
requestRepaint, // since 0.3.0; optional on an older published object
|
|
314
314
|
createStore,
|
|
315
315
|
});
|
|
316
|
-
```
|
|
316
|
+
```text
|
|
317
317
|
|
|
318
318
|
Publication is **first wins**: a compatible object already in the slot is kept and never replaced,
|
|
319
319
|
and the slot is never reset. A consumer gates on the schema string, `version === 1` and the three
|
|
@@ -359,7 +359,7 @@ pi.on("session_start", (_event, ctx) => {
|
|
|
359
359
|
);
|
|
360
360
|
}
|
|
361
361
|
});
|
|
362
|
-
```
|
|
362
|
+
```text
|
|
363
363
|
|
|
364
364
|
Or import the package and call `onBridgeApi(handler, pi.events)`, which does both forms for you: the
|
|
365
365
|
handler runs immediately when the object is already published (and no listener is taken), otherwise
|
|
@@ -374,7 +374,7 @@ const register = (api: BridgeApi): void => {
|
|
|
374
374
|
|
|
375
375
|
// Works in both orders: this package loaded first, or the plugin did.
|
|
376
376
|
const dispose = onBridgeApi(register, pi.events);
|
|
377
|
-
```
|
|
377
|
+
```text
|
|
378
378
|
|
|
379
379
|
`bridgeApi()` never waits, defers or retries: it answers about the slot as it is right now.
|
|
380
380
|
|
|
@@ -387,7 +387,7 @@ When this package publishes its object, it emits one event on Pi's cross-extensi
|
|
|
387
387
|
pi.events.on("gentle-shell-bridge:ready", (payload) => {
|
|
388
388
|
// { schema: "gentle-shell-bridge/api", version: 1, VERSION: "0.3.0" }
|
|
389
389
|
});
|
|
390
|
-
```
|
|
390
|
+
```text
|
|
391
391
|
|
|
392
392
|
- **Name:** `gentle-shell-bridge:ready`. Payload: `{ schema, version, VERSION }` — the same identity,
|
|
393
393
|
major and release the published object carries, frozen. Informational only: the payload says
|
|
@@ -432,7 +432,7 @@ const dispose = api.registerRows({
|
|
|
432
432
|
category: "Cards",
|
|
433
433
|
rows: () => [toggle("activity"), toggle("output")], // consecutive rows → one line
|
|
434
434
|
});
|
|
435
|
-
```
|
|
435
|
+
```text
|
|
436
436
|
|
|
437
437
|
Nothing may sit between the two values or the renderer draws two lines. `current()` is evaluated
|
|
438
438
|
when the menu is built, `action()` runs before the host's own repaint, and `preview()` replaces the
|
|
@@ -454,7 +454,7 @@ const dispose = api.registerSection({
|
|
|
454
454
|
defaultVisible: true, // absent means true
|
|
455
455
|
order: 10, // optional integer
|
|
456
456
|
});
|
|
457
|
-
```
|
|
457
|
+
```text
|
|
458
458
|
|
|
459
459
|
The bridge generates the `Sections` rows for it: two consecutive rows sharing one label,
|
|
460
460
|
values `shown` / `hidden`, with a live `current()` and a persist-first `action()`. The label — not
|
|
@@ -472,7 +472,7 @@ or writes that file.
|
|
|
472
472
|
const store = api.createStore("loon");
|
|
473
473
|
store.set("bannerSource", "activity");
|
|
474
474
|
const value = store.get("bannerSource", "activity"); // caller's fallback when absent or unreadable
|
|
475
|
-
```
|
|
475
|
+
```text
|
|
476
476
|
|
|
477
477
|
The document is `{ "schemaVersion": 1, "values": { … } }` at
|
|
478
478
|
`<gentle config home>/gentle-shell-bridge/<pluginId>.json`. `values` is an envelope, so a plugin
|
|
@@ -548,7 +548,7 @@ const dispose: () => void = registerSection({
|
|
|
548
548
|
defaultVisible: true, // absent means true
|
|
549
549
|
order: 10, // optional integer
|
|
550
550
|
});
|
|
551
|
-
```
|
|
551
|
+
```text
|
|
552
552
|
|
|
553
553
|
- `id` — registering an existing id **replaces** the previous section in place; a second
|
|
554
554
|
card never appears. It is the toggle's identity (replacement, disposer and the persisted
|
|
@@ -582,7 +582,7 @@ A row is a plain **string** or a structured **row object**:
|
|
|
582
582
|
|
|
583
583
|
```ts
|
|
584
584
|
{ label: string; meta?: string; glyph?: string; tone?: Tone; onClick?: () => void }
|
|
585
|
-
```
|
|
585
|
+
```text
|
|
586
586
|
|
|
587
587
|
- a plain string is drawn **byte for byte**: the author's characters, clipped to the width, no
|
|
588
588
|
indent, no padding, no styling. Every section written before structured rows existed looks
|
|
@@ -626,7 +626,7 @@ child, and the conversation gets `columns - 53`. One decision IS made from a par
|
|
|
626
626
|
|
|
627
627
|
```text
|
|
628
628
|
const active = railLines.length > 0 && railLines.every((line) => visibleWidth(line) <= contentWidth);
|
|
629
|
-
```
|
|
629
|
+
```text
|
|
630
630
|
(`lib/shell-sidebar-layout.ts:410`) — a single rail row wider than the content width drops the whole
|
|
631
631
|
rail, and the conversation then takes every column: the layout's widths changed because of what a
|
|
632
632
|
part returned.
|
|
@@ -706,7 +706,7 @@ label the user reads, never an id and never a prefix:
|
|
|
706
706
|
```text
|
|
707
707
|
stats ● shown ○ hidden ← the host's own row
|
|
708
708
|
music ● shown ○ hidden ← a plugin's section (id "loon.music", title "MUSIC")
|
|
709
|
-
```
|
|
709
|
+
```text
|
|
710
710
|
|
|
711
711
|
For every registered section the bridge emits **two consecutive rows** in category `Sections`,
|
|
712
712
|
sharing one label as their `choice.setting` (the host prints the setting as the line's name) with
|
|
@@ -752,7 +752,7 @@ one namespaced file:
|
|
|
752
752
|
"collapsed": { "loon.music": true }
|
|
753
753
|
}
|
|
754
754
|
}
|
|
755
|
-
```
|
|
755
|
+
```text
|
|
756
756
|
|
|
757
757
|
`sections` maps a section id to `true` (shown) / `false` (hidden); a missing id falls back to
|
|
758
758
|
`defaultVisible`. `collapsed` maps a section id to `true` (folded) / `false` (open); a missing id is
|
|
@@ -781,7 +781,7 @@ const dispose: () => void = registerCardStyle({
|
|
|
781
781
|
frame: { top, line, bottom }, // the three functions below; nothing else is called
|
|
782
782
|
preview: () => ({ title: "Cute", sample: "○ cute ╭─ welcome ─╮" }), // optional, literal
|
|
783
783
|
});
|
|
784
|
-
```
|
|
784
|
+
```text
|
|
785
785
|
|
|
786
786
|
The id never appears in a row: the host's line reads `Card style ○ neon ● float ○ cute`, and the
|
|
787
787
|
style's own row is labelled `cute` (or the author's `rowLabel`), exactly like a host row's visible
|
|
@@ -794,7 +794,7 @@ text. `label` stays the line's value — the text the host renders and the uniqu
|
|
|
794
794
|
top(ctx: { width: number; title?: string; hint?: string }): string;
|
|
795
795
|
line(ctx: { text: string; width: number; first: boolean }): string;
|
|
796
796
|
bottom(ctx: { width: number }): string;
|
|
797
|
-
```
|
|
797
|
+
```text
|
|
798
798
|
|
|
799
799
|
`width` is the width the host rendered at. `title` is the heading the host printed, without its
|
|
800
800
|
glyph and without the right-aligned hint; `hint` is that hint when its style runs prove it is one
|
|
@@ -812,7 +812,7 @@ setting, so the user sees ONE line in the host's own position:
|
|
|
812
812
|
|
|
813
813
|
```text
|
|
814
814
|
Card style ○ neon ● float ○ cute
|
|
815
|
-
```
|
|
815
|
+
```text
|
|
816
816
|
|
|
817
817
|
The host's own rows keep the host's `current()` and `action()`, wrapped in exactly two ways:
|
|
818
818
|
`current()` reports `false` while a registered style is selected (one bullet at a time), and
|
|
@@ -868,7 +868,7 @@ The selection is the bridge's state, not the plugin's:
|
|
|
868
868
|
|
|
869
869
|
```json
|
|
870
870
|
{ "schemaVersion": 1, "values": { "cardStyle": "loon.cute" } }
|
|
871
|
-
```
|
|
871
|
+
```text
|
|
872
872
|
|
|
873
873
|
`cardStyle` is a style id or `native`. A missing file, an unreadable one, an unknown
|
|
874
874
|
`schemaVersion` or a non-string value reads as `native`. A stored id whose style was disposed
|
|
@@ -928,7 +928,7 @@ const dispose: () => void = registerTransform({
|
|
|
928
928
|
return rows;
|
|
929
929
|
},
|
|
930
930
|
});
|
|
931
|
-
```
|
|
931
|
+
```text
|
|
932
932
|
|
|
933
933
|
### What the transform receives
|
|
934
934
|
|
|
@@ -1009,7 +1009,7 @@ keeps its report byte for byte:
|
|
|
1009
1009
|
transforms: 2 registered
|
|
1010
1010
|
- loon.bash-cards (order 10): applied, 13 lines, 4 candidates, 1 recognised, 1 rewritten, shapes: float 1
|
|
1011
1011
|
- loon.strict (registration order): failed (definitions are missing), 13 lines, 0 candidates, 0 recognised, 0 rewritten
|
|
1012
|
-
```
|
|
1012
|
+
```text
|
|
1013
1013
|
|
|
1014
1014
|
`applied` means the frame changed, `skipped` means the transform was called and left the rows as they
|
|
1015
1015
|
were, `failed` carries its message, and `not run` means it was registered after the last frame. The
|
|
@@ -1034,7 +1034,7 @@ api.registerToolDesign({
|
|
|
1034
1034
|
return lines.map((line) => rewriteTheMarkOnly(line));
|
|
1035
1035
|
},
|
|
1036
1036
|
});
|
|
1037
|
-
```
|
|
1037
|
+
```text
|
|
1038
1038
|
|
|
1039
1039
|
### The convention: lines in, lines out
|
|
1040
1040
|
|
|
@@ -1199,21 +1199,78 @@ The bridge registers exactly ONE `pi.registerToolRenderer` resolver for the whol
|
|
|
1199
1199
|
out to these designs. That is why two plugins contributing designs for the same tool do not stack
|
|
1200
1200
|
wrappers, and why a plugin must never call `pi.registerToolRenderer` itself for a design.
|
|
1201
1201
|
|
|
1202
|
+
## 15. Plugin keymaps and the command palette
|
|
1203
|
+
|
|
1204
|
+
The bridge publishes what plugins contributed; the **host reads it per build**. The direction is the
|
|
1205
|
+
design: there is no registration handshake, no startup cache and no lifecycle in the host, so a
|
|
1206
|
+
registration made during `session_start` is visible at the next menu or palette open, in any load
|
|
1207
|
+
order.
|
|
1208
|
+
|
|
1209
|
+
```text
|
|
1210
|
+
Symbol.for("gentle-shell-bridge/plugin-surface/v1") → { schema: 1, keymaps(), commands() }
|
|
1211
|
+
```text
|
|
1212
|
+
|
|
1213
|
+
Both getters answer with a **copy**, never the live array, so a host that keeps one cannot mutate
|
|
1214
|
+
what the bridge owns.
|
|
1215
|
+
|
|
1216
|
+
### `registerKeymap(registration): () => void`
|
|
1217
|
+
|
|
1218
|
+
One action for the host's Keymaps page: `{ id, label, env?, defaultKey?, command? }`.
|
|
1219
|
+
|
|
1220
|
+
- `id` and `label` must be non-empty strings; `env`, `defaultKey` and `command` are optional but,
|
|
1221
|
+
when present, must be non-empty strings too. Validation happens here, where the plugin author sees
|
|
1222
|
+
the error.
|
|
1223
|
+
- An `id` starting with `command:` is refused: those name palette command bindings, not plugin
|
|
1224
|
+
actions.
|
|
1225
|
+
- The same `id` registered twice **replaces in place and is reported**, like every other
|
|
1226
|
+
registration in this package. A silent takeover would be one plugin stealing another's row.
|
|
1227
|
+
- The disposer removes exactly the entry it created. A replaced entry is a different object, so
|
|
1228
|
+
disposing the old registration never deletes its successor.
|
|
1229
|
+
- A contributed id can never shadow a built-in action or a `command:<name>` binding: the host keeps
|
|
1230
|
+
its own ids.
|
|
1231
|
+
|
|
1232
|
+
### `registerCommands(contribution | contribution[]): () => void`
|
|
1233
|
+
|
|
1234
|
+
One palette item, or several: `{ id, label, command, section? }`.
|
|
1235
|
+
|
|
1236
|
+
- An item joins the section it names, after that section's own entries, or opens a section of its
|
|
1237
|
+
own after the host's catalog. Without `section` it lands in the shared `Plugins` page.
|
|
1238
|
+
- The host lists an item only while its command is registered, so a missing extension leaves no
|
|
1239
|
+
dead row, and an own section that would be left empty does not appear at all.
|
|
1240
|
+
- An `id` twice **in one call** is refused whole: the batch would silently keep only the last one.
|
|
1241
|
+
Across calls it replaces in place and is reported, exactly like keymaps.
|
|
1242
|
+
|
|
1243
|
+
### `resolveKeymap(id): { key?; unavailable? }`
|
|
1244
|
+
|
|
1245
|
+
The key an id currently uses, answered by the shell that owns the file, the environment override
|
|
1246
|
+
and the defaults — environment variable, then saved binding, then default. It never throws: no
|
|
1247
|
+
shell, an older shell or a throwing getter is an `unavailable` reason the caller reports.
|
|
1248
|
+
|
|
1249
|
+
The plugin then binds the key itself with `pi.registerShortcut`. The bridge never binds for a
|
|
1250
|
+
plugin, and the shell never binds a plugin's key. That split is what keeps one implementation of the
|
|
1251
|
+
precedence: the row and the real binding cannot disagree.
|
|
1252
|
+
|
|
1253
|
+
**A keymap change applies after `/reload`.** Pi reads extension shortcuts at startup and on reload,
|
|
1254
|
+
for native actions and contributed ones alike, and it exposes no way to re-register a shortcut while
|
|
1255
|
+
running. The Keymaps page says so, and its last row offers the reload.
|
|
1256
|
+
|
|
1202
1257
|
## Limits
|
|
1203
1258
|
|
|
1204
1259
|
- `registerRows`, `registerSection`, `registerCardStyle`, `registerTransform`,
|
|
1205
|
-
`registerToolDesign`, `
|
|
1260
|
+
`registerToolDesign`, `registerKeymap`, `registerCommands`, `resolveKeymap`, `requestRepaint`,
|
|
1261
|
+
`createStore`, `bridgeApi`, `isBridgeApi`, `onBridgeApi`
|
|
1206
1262
|
and the `gentle-shell-bridge:ready` event are the contract; anything a plugin does inside `action()` beyond
|
|
1207
1263
|
calling inline helpers is the plugin's own business.
|
|
1208
|
-
- **`Keymaps`
|
|
1209
|
-
anything is stored, with an error naming the category and why
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
`
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1264
|
+
- **`Keymaps` stays reserved for row providers.** A provider registered with `category: "Keymaps"` is
|
|
1265
|
+
refused before anything is stored, with an error naming the category and why; the refusal is a rejected
|
|
1266
|
+
registration in the plugin's INTEGRATIONS line and in `/bridge-status`. A single row whose own
|
|
1267
|
+
`category` is `Keymaps` is dropped and reported the same way, and its siblings still render. The
|
|
1268
|
+
comparison is trimmed and case-insensitive: ` keymaps ` and `KEYMAPS` are the same page; `Keymap` and
|
|
1269
|
+
`Key maps` are ordinary categories. `Profiles` and `Reset` are not reserved: a plugin row there renders
|
|
1270
|
+
as an ordinary line. A refusal of one row is listed under `row rejections` but is not counted in the
|
|
1271
|
+
plugin's INTEGRATIONS line (a build cannot reach it; only the registration refusal does). The reason
|
|
1272
|
+
is unchanged and now has a supported alternative: that page captures keys and claims a footer, so a
|
|
1273
|
+
plain row would be advertised as assignable and could never honour it — a plugin uses §15 instead.
|
|
1217
1274
|
- **A new category becomes a page.** The host computes its page list once, in the view's constructor
|
|
1218
1275
|
(`lib/visual-customize-view.ts:387`), so the rows must be in the array before that `map` runs; see
|
|
1219
1276
|
[architecture.md](architecture.md) "A brand-new page". The cost is stated there. The one residual
|
|
@@ -1261,6 +1318,6 @@ wrappers, and why a plugin must never call `pi.registerToolRenderer` itself for
|
|
|
1261
1318
|
simply false) and keeps working.
|
|
1262
1319
|
- A transform is a per-frame pass, so a slow transform is a slow frame; the bridge isolates its
|
|
1263
1320
|
failures and clips its width, and can bound nothing else. It sees lines, never tool metadata.
|
|
1264
|
-
- The API is released (`0.3.
|
|
1321
|
+
- The API is released (`0.3.2`). The `v1` symbol is the compatibility boundary: a breaking
|
|
1265
1322
|
change takes a new key instead of mutating this one (§9). The `gentle-shell-bridge:ready` event is
|
|
1266
1323
|
additive: a plugin that never subscribes loses nothing but the late-load case.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gentle-shell-bridge",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Shared provider bus for gentle-shell's /gentle:customize settings rows: plugins register rows, the bridge owns the single interception layer.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -10,6 +10,18 @@
|
|
|
10
10
|
"gentle-ai",
|
|
11
11
|
"extension"
|
|
12
12
|
],
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/jonasotoaguilar/gentle-shell-bridge.git"
|
|
16
|
+
},
|
|
17
|
+
"license": "Apache-2.0",
|
|
18
|
+
"files": [
|
|
19
|
+
"src",
|
|
20
|
+
"docs/contract.md",
|
|
21
|
+
"docs/state.md",
|
|
22
|
+
"docs/architecture.md",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
13
25
|
"pi": {
|
|
14
26
|
"extensions": [
|
|
15
27
|
"./src/extension.ts"
|
package/src/api.ts
CHANGED
|
@@ -67,7 +67,7 @@ import { createStore } from "./store.ts";
|
|
|
67
67
|
import { registerToolDesign } from "./tool-designs.ts";
|
|
68
68
|
|
|
69
69
|
/** The release that published the object; informational, never the compatibility check. */
|
|
70
|
-
export const VERSION = "0.3.
|
|
70
|
+
export const VERSION = "0.3.2";
|
|
71
71
|
|
|
72
72
|
/** Identity of the object, so a foreign payload at the symbol is never mistaken for ours. */
|
|
73
73
|
export const API_SCHEMA = "gentle-shell-bridge/api";
|
package/.codegraph/.gitignore
DELETED
package/PRD.md
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
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.
|