pi-odd-worktree 3.15.1 → 3.16.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/README.md +48 -25
- package/extensions/odd-worktree-tools.ts +64 -211
- package/lib/shell-api/api.ts +523 -0
- package/lib/shell-api/arm.ts +83 -0
- package/lib/shell-api/bus.ts +1389 -0
- package/lib/shell-api/capture.ts +1340 -0
- package/lib/shell-api/card-style-line.ts +112 -0
- package/lib/shell-api/card-style-rows.ts +390 -0
- package/lib/shell-api/card-style-transform.ts +862 -0
- package/lib/shell-api/card-style-wiring.ts +477 -0
- package/lib/shell-api/card-styles.ts +153 -0
- package/lib/shell-api/config.ts +71 -0
- package/lib/shell-api/extension.ts +247 -0
- package/lib/shell-api/hook.ts +322 -0
- package/lib/shell-api/index.ts +88 -0
- package/lib/shell-api/message-design-adoption.ts +549 -0
- package/lib/shell-api/message-design-rows.ts +313 -0
- package/lib/shell-api/message-design-wiring.ts +369 -0
- package/lib/shell-api/message-designs.ts +746 -0
- package/lib/shell-api/notices.ts +137 -0
- package/lib/shell-api/plugin-lines.ts +877 -0
- package/lib/shell-api/presence.ts +258 -0
- package/lib/shell-api/repaint.ts +351 -0
- package/lib/shell-api/row-labels.ts +146 -0
- package/lib/shell-api/row-names.ts +273 -0
- package/lib/shell-api/row-origin.ts +144 -0
- package/lib/shell-api/rows.ts +591 -0
- package/lib/shell-api/section-panel.ts +378 -0
- package/lib/shell-api/section-pointer.ts +164 -0
- package/lib/shell-api/sections-preview.ts +275 -0
- package/lib/shell-api/sections-rows.ts +133 -0
- package/lib/shell-api/sidebar-render.ts +705 -0
- package/lib/shell-api/sidebar.ts +1126 -0
- package/lib/shell-api/store.ts +279 -0
- package/lib/shell-api/tool-design-adoption.ts +263 -0
- package/lib/shell-api/tool-design-rows.ts +307 -0
- package/lib/shell-api/tool-design-wiring.ts +481 -0
- package/lib/shell-api/tool-designs.ts +1411 -0
- package/lib/shell-api/transform-pipeline.ts +351 -0
- package/lib/shell-api/types.ts +803 -0
- package/lib/shell-api/visibility.ts +154 -0
- package/package.json +3 -2
- package/tools/files-bridge.test.js +81 -66
- package/tools/fixtures/load-extension.js +40 -18
- package/tools/issues-command.test.js +4 -7
- package/tools/issues-section.test.js +71 -81
- package/tools/odd-rail-wiring.test.js +16 -10
- package/tools/package-surface.test.js +42 -13
- package/tools/prs-command.test.js +11 -6
- package/tools/shell-api/api.test.ts +484 -0
- package/tools/shell-api/apply-on-move.test.ts +529 -0
- package/tools/shell-api/arm.test.ts +220 -0
- package/tools/shell-api/bridge-ready.test.ts +309 -0
- package/tools/shell-api/bus.test.ts +194 -0
- package/tools/shell-api/button-rows.test.ts +435 -0
- package/tools/shell-api/capture.test.ts +583 -0
- package/tools/shell-api/card-style-rows.test.ts +493 -0
- package/tools/shell-api/card-style-transform.test.ts +379 -0
- package/tools/shell-api/card-style-wiring.test.ts +258 -0
- package/tools/shell-api/card-styles-e2e.test.ts +502 -0
- package/tools/shell-api/card-styles.test.ts +324 -0
- package/tools/shell-api/card-transcript-path.test.ts +178 -0
- package/tools/shell-api/compatibility-regression.test.mjs +64 -0
- package/tools/shell-api/config.test.ts +93 -0
- package/tools/shell-api/docs-coverage.test.ts +82 -0
- package/tools/shell-api/e2e.test.ts +562 -0
- package/tools/shell-api/example-bash-identity.test.ts +372 -0
- package/tools/shell-api/example-bash-matrix.test.ts +856 -0
- package/tools/shell-api/example-designs.test.ts +737 -0
- package/tools/shell-api/example-neon-transform.test.ts +283 -0
- package/tools/shell-api/example-plain-style.test.ts +1225 -0
- package/tools/shell-api/extension.test.ts +157 -0
- package/tools/shell-api/fake-events.ts +58 -0
- package/tools/shell-api/fake-host.ts +211 -0
- package/tools/shell-api/fake-sidebar.ts +516 -0
- package/tools/shell-api/fake-transcript.ts +486 -0
- package/tools/shell-api/frame-telemetry.test.ts +317 -0
- package/tools/shell-api/hook.test.ts +196 -0
- package/tools/shell-api/manifest.test.ts +47 -0
- package/tools/shell-api/message-design-adoption.test.ts +611 -0
- package/tools/shell-api/message-design-follows.test.ts +361 -0
- package/tools/shell-api/message-design-pi-release.test.mjs +157 -0
- package/tools/shell-api/message-design-regressions.test.mjs +162 -0
- package/tools/shell-api/message-design-rows.test.ts +266 -0
- package/tools/shell-api/message-design-wiring.test.ts +362 -0
- package/tools/shell-api/message-designs.test.ts +339 -0
- package/tools/shell-api/new-category.test.ts +1101 -0
- package/tools/shell-api/notices.test.ts +292 -0
- package/tools/shell-api/plugin-integration-lines.test.ts +827 -0
- package/tools/shell-api/presence.test.ts +396 -0
- package/tools/shell-api/rail-part-hits.test.ts +281 -0
- package/tools/shell-api/rail-surfaces.test.ts +402 -0
- package/tools/shell-api/rail-width.test.ts +406 -0
- package/tools/shell-api/regression.test.ts +434 -0
- package/tools/shell-api/repaint-api.test.ts +200 -0
- package/tools/shell-api/reserved-categories.test.ts +250 -0
- package/tools/shell-api/row-labels.test.ts +261 -0
- package/tools/shell-api/row-names.test.ts +407 -0
- package/tools/shell-api/row-origin.test.ts +395 -0
- package/tools/shell-api/row-placement-regression.test.ts +797 -0
- package/tools/shell-api/row-placement.test.ts +410 -0
- package/tools/shell-api/section-interaction.test.ts +364 -0
- package/tools/shell-api/section-panel.test.ts +430 -0
- package/tools/shell-api/section-placement-rail.test.ts +390 -0
- package/tools/shell-api/section-placement.test.ts +386 -0
- package/tools/shell-api/sections-preview.test.ts +312 -0
- package/tools/shell-api/sections-rows.test.ts +293 -0
- package/tools/shell-api/sidebar-backend.test.ts +477 -0
- package/tools/shell-api/sidebar-e2e.test.ts +317 -0
- package/tools/shell-api/sidebar-hover.test.ts +276 -0
- package/tools/shell-api/sidebar-independent.test.ts +291 -0
- package/tools/shell-api/sidebar-render.test.ts +281 -0
- package/tools/shell-api/sidebar-sections.test.ts +247 -0
- package/tools/shell-api/store.test.ts +192 -0
- package/tools/shell-api/surface-repaint-cost.test.ts +520 -0
- package/tools/shell-api/tool-design-card-style.test.ts +308 -0
- package/tools/shell-api/tool-design-chain.test.ts +471 -0
- package/tools/shell-api/tool-design-cost.test.ts +591 -0
- package/tools/shell-api/tool-design-rows.test.ts +627 -0
- package/tools/shell-api/tool-design-scopes-audit.test.ts +212 -0
- package/tools/shell-api/tool-designs.test.ts +2412 -0
- package/tools/shell-api/transform-pipeline.test.ts +376 -0
- package/tools/shell-api/transforms-bus.test.ts +233 -0
- package/tools/shell-api/verifier-width-regressions.test.ts +147 -0
- package/tools/shell-api-rpc.test.js +189 -0
- package/tools/user-prompt-card.test.js +8 -9
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The verifier's width findings, pinned (W2-T2–W2-T4, A-T5, C-T2/C-T3 adjacent).
|
|
3
|
+
*
|
|
4
|
+
* Each expectation below is the value pi-tui's own `visibleWidth` produces for that string
|
|
5
|
+
* (`@earendil-works/pi-tui/dist/utils.js:126-268`, measured with the installed host copy), so this
|
|
6
|
+
* file is a differential fixture with pinned numbers instead of a second implementation:
|
|
7
|
+
*
|
|
8
|
+
* - a cluster is charged the way `graphemeWidth` charges it: zero for a cluster of marks, two only
|
|
9
|
+
* when `couldBeEmoji` AND `\p{RGI_Emoji}` both hold (so `©` is ONE column, `©️` is two), the base
|
|
10
|
+
* code point's East Asian width otherwise, plus every trailing halfwidth/fullwidth form and the
|
|
11
|
+
* Thai/Lao AM vowels;
|
|
12
|
+
* - a row that already fits is byte-identical, escapes included, even at width zero;
|
|
13
|
+
* - a cut never splits a grapheme cluster, even when an SGR sequence sits inside it.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import assert from "node:assert/strict";
|
|
17
|
+
import test from "node:test";
|
|
18
|
+
|
|
19
|
+
import { registerTransform, resetTransformsForTests } from "../../lib/shell-api/bus.ts";
|
|
20
|
+
import { clipToWidth, hostColumns } from "../../lib/shell-api/card-style-transform.ts";
|
|
21
|
+
import { applyTransforms, resetTransformPipelineForTests } from "../../lib/shell-api/transform-pipeline.ts";
|
|
22
|
+
|
|
23
|
+
test.beforeEach(() => {
|
|
24
|
+
resetTransformsForTests();
|
|
25
|
+
resetTransformPipelineForTests();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// ---------------------------------------------------------------------------------------------
|
|
29
|
+
// The host's measure, cluster by cluster
|
|
30
|
+
// ---------------------------------------------------------------------------------------------
|
|
31
|
+
|
|
32
|
+
test("a symbol that is not an RGI emoji is one column; a qualified or keycap emoji is two", () => {
|
|
33
|
+
for (const symbol of ["©", "®", "™", "☺"]) {
|
|
34
|
+
assert.equal(hostColumns(symbol), 1, `${symbol} is not an RGI emoji: the host charges one column`);
|
|
35
|
+
}
|
|
36
|
+
assert.equal(hostColumns("©️"), 2, "the emoji presentation selector makes it an RGI emoji");
|
|
37
|
+
assert.equal(hostColumns("1️⃣"), 2, "a keycap sequence is one two-column cluster");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("a trailing halfwidth/fullwidth form is charged its own column", () => {
|
|
41
|
+
assert.equal(hostColumns("ガ"), 2, "halfwidth KA plus the voiced sound mark");
|
|
42
|
+
assert.equal(hostColumns("ガギ"), 4, "two voiced halfwidth kana are four columns");
|
|
43
|
+
assert.equal(hostColumns("ア"), 1, "a bare halfwidth kana is one column");
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("a cluster of marks charges nothing, and a leading mark rides its base", () => {
|
|
47
|
+
assert.equal(hostColumns("्"), 0, "a lone Devanagari virama occupies no cell");
|
|
48
|
+
assert.equal(hostColumns("़क"), 1, "the leading nukta is stripped before measuring क");
|
|
49
|
+
assert.equal(hostColumns("क्"), 1);
|
|
50
|
+
assert.equal(hostColumns("e\u0301"), 1, "a combining acute rides its base");
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test("a Devanagari spacing mark occupies its own cell, as the host allocates one", () => {
|
|
54
|
+
assert.equal(hostColumns("ि"), 1, "U+093F is a Spacing_Mark: the host charges it one column");
|
|
55
|
+
assert.equal(hostColumns("ा"), 1, "U+093E is a Spacing_Mark too");
|
|
56
|
+
assert.equal(hostColumns("नमस्ते"), 4, "the host's own number for नमस्ते (pi-tui 1.5.x)");
|
|
57
|
+
assert.equal(hostColumns("हिन्दी"), 5, "the host's own number for हिन्दी");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// ---------------------------------------------------------------------------------------------
|
|
61
|
+
// W2-3: a consonant that follows a mark is charged, so it cannot overflow a narrower frame
|
|
62
|
+
// ---------------------------------------------------------------------------------------------
|
|
63
|
+
|
|
64
|
+
test("an Indic conjunct that follows a mark is two columns, and is never cut into one column", () => {
|
|
65
|
+
// pi-tui 1.5.x charges the base (क) plus the visible consonant after the virama (ष): 2 columns.
|
|
66
|
+
// Charging the cluster as its base alone made a "one column" frame hold two.
|
|
67
|
+
assert.equal(hostColumns("क्ष"), 2, "the host charges the conjunct two columns");
|
|
68
|
+
assert.equal(hostColumns("क्ष"), 2, "with or without the joiner");
|
|
69
|
+
assert.equal(hostColumns("क्षा"), 3, "the trailing spacing mark adds its own cell");
|
|
70
|
+
|
|
71
|
+
assert.equal(
|
|
72
|
+
clipToWidth("क्षx", 1),
|
|
73
|
+
"",
|
|
74
|
+
"a two-column cluster cannot be emitted in a one-column frame",
|
|
75
|
+
);
|
|
76
|
+
assert.equal(clipToWidth("क्षx", 2), "क्ष", "at two columns the whole cluster fits");
|
|
77
|
+
assert.equal(hostColumns(clipToWidth("क्षx", 2)), 2, "and the result measures exactly two");
|
|
78
|
+
for (const width of [0, 1, 2, 3]) {
|
|
79
|
+
assert.ok(
|
|
80
|
+
hostColumns(clipToWidth("क्षx", width)) <= width,
|
|
81
|
+
`the cut at ${width} never exceeds the frame`,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test("the pipeline clips an overflowing Indic conjunct instead of emitting it", () => {
|
|
87
|
+
registerTransform({ id: "indic", transform: () => ["क्षx"] });
|
|
88
|
+
|
|
89
|
+
assert.deepEqual(applyTransforms(["host"], 1), [""], "nothing wider than the frame reaches the host");
|
|
90
|
+
assert.deepEqual(applyTransforms(["host"], 2), ["क्ष"]);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test("a Thai/Lao AM vowel adds a column, and an ignorable symbol adds none", () => {
|
|
94
|
+
assert.equal(hostColumns("กำ"), 2, "the trailing AM vowel is charged one extra column");
|
|
95
|
+
assert.equal(hostColumns("ເກຳ"), 3, "the same rule for Lao");
|
|
96
|
+
assert.equal(hostColumns("\u00ad"), 0, "a soft hyphen is default-ignorable: no columns");
|
|
97
|
+
assert.equal(hostColumns("👨👩👧👦"), 2, "a ZWJ family is one two-column cluster");
|
|
98
|
+
assert.equal(hostColumns("👍🏽"), 2, "a skin-tone modifier rides its base");
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// ---------------------------------------------------------------------------------------------
|
|
102
|
+
// Fitting rows are byte-identical, at every width — including zero
|
|
103
|
+
// ---------------------------------------------------------------------------------------------
|
|
104
|
+
|
|
105
|
+
test("a row that fits at width zero keeps its bytes, escapes included", () => {
|
|
106
|
+
const sgr = "\u001b[31m";
|
|
107
|
+
const link = "\u001b]8;;http://example.com\u0007\u001b]8;;\u0007";
|
|
108
|
+
const background = "\u001b[48;5;236m\u001b[0m";
|
|
109
|
+
|
|
110
|
+
assert.equal(clipToWidth(sgr, 0), sgr, "an SGR-only row has no columns and must survive");
|
|
111
|
+
assert.equal(clipToWidth(link, 0), link, "an empty hyperlink is the same empty hyperlink");
|
|
112
|
+
assert.equal(clipToWidth(background, 0), background);
|
|
113
|
+
assert.equal(clipToWidth("\u001b[31m\u001b[39m", 0), "\u001b[31m\u001b[39m");
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test("a row with no columns is passed through, and a row with columns is emptied, at width zero", () => {
|
|
117
|
+
assert.equal(clipToWidth("", 0), "");
|
|
118
|
+
assert.equal(clipToWidth("A", 0), "", "a visible column cannot be drawn in zero columns");
|
|
119
|
+
assert.equal(clipToWidth("\u001b[31mA", 0), "", "the paint alone is not a row fit to draw");
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test("the pipeline returns an ANSI-only row untouched at width zero", () => {
|
|
123
|
+
registerTransform({ id: "ansi-only", transform: () => ["\u001b[31m", "A"] });
|
|
124
|
+
|
|
125
|
+
assert.deepEqual(applyTransforms(["host"], 0), ["\u001b[31m", ""], "only the visible column is cut");
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// ---------------------------------------------------------------------------------------------
|
|
129
|
+
// The cut never splits a cluster, even with SGR interleaved
|
|
130
|
+
// ---------------------------------------------------------------------------------------------
|
|
131
|
+
|
|
132
|
+
test("an SGR inside a grapheme cluster does not split it, and the kept paint is reset", () => {
|
|
133
|
+
const row = "👨\u001b[31m👩👧👦AB";
|
|
134
|
+
assert.equal(hostColumns(row), 4, "the host measures the family as one cluster plus A and B");
|
|
135
|
+
|
|
136
|
+
const clipped = clipToWidth(row, 2);
|
|
137
|
+
|
|
138
|
+
assert.equal(clipped, "👨\u001b[31m👩👧👦\u001b[0m", "the whole family is kept, then the paint is reset");
|
|
139
|
+
assert.equal(clipped.split("\u200d").length - 1, 3, "every joiner of the family survived the cut");
|
|
140
|
+
assert.equal(hostColumns(clipped), 2, "and it measures the host's width exactly");
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test("the pipeline applies that cut to what a transform returns", () => {
|
|
144
|
+
registerTransform({ id: "family", transform: () => ["👨\u001b[31m👩👧👦AB"] });
|
|
145
|
+
|
|
146
|
+
assert.deepEqual(applyTransforms(["host"], 2), ["👨\u001b[31m👩👧👦\u001b[0m"]);
|
|
147
|
+
});
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// native-bridge T5: the real-host check. It drives a real `pi --mode rpc` with ONLY this package
|
|
3
|
+
// loaded, so it proves what the fixture-stubbed suite cannot: odd-worktree's own shell API
|
|
4
|
+
// publishes the slot, arms, and a third party can extend it. It needs the host binary and a
|
|
5
|
+
// type-stripping Node, so it is opt-in:
|
|
6
|
+
// NATIVE_BRIDGE_PI="$(command -v pi)" node --test tools/shell-api-rpc.test.js
|
|
7
|
+
const assert = require('node:assert/strict');
|
|
8
|
+
const { spawnSync } = require('node:child_process');
|
|
9
|
+
const { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } = require('node:fs');
|
|
10
|
+
const { tmpdir } = require('node:os');
|
|
11
|
+
const { join, resolve } = require('node:path');
|
|
12
|
+
const test = require('node:test');
|
|
13
|
+
|
|
14
|
+
const pi = process.env.NATIVE_BRIDGE_PI;
|
|
15
|
+
const entry = resolve(__dirname, '../extensions/odd-worktree-tools.ts');
|
|
16
|
+
const slot = 'Symbol.for("gentle-shell-bridge/api/v1")';
|
|
17
|
+
const get = { type: 'get_commands', id: '1' };
|
|
18
|
+
|
|
19
|
+
function rpc(t, before, after, commands) {
|
|
20
|
+
const dir = mkdtempSync(join(tmpdir(), 'odd-shell-api-rpc-'));
|
|
21
|
+
t.after(() => rmSync(dir, { recursive: true, force: true }));
|
|
22
|
+
const home = join(dir, 'home');
|
|
23
|
+
const tmp = join(dir, 'tmp');
|
|
24
|
+
const ad = join(dir, 'agent');
|
|
25
|
+
for (const path of [home, tmp, ad]) mkdirSync(path);
|
|
26
|
+
const probe = join(dir, 'probe.ts');
|
|
27
|
+
const report = join(dir, 'probe-report.json');
|
|
28
|
+
writeFileSync(probe, before || after);
|
|
29
|
+
const flags = before ? ['-e', probe, '-e', entry] : ['-e', entry, '-e', probe];
|
|
30
|
+
const result = spawnSync('bash', [
|
|
31
|
+
'-c', 'set -o pipefail; (cat; sleep 6) | timeout 25 "$@"', 'rpc',
|
|
32
|
+
pi, '--agent-dir', ad, '--no-session', '-ne', '-ns', '-np', ...flags, '--mode', 'rpc',
|
|
33
|
+
], {
|
|
34
|
+
cwd: dir, encoding: 'utf8', timeout: 28000,
|
|
35
|
+
input: commands.map((x) => JSON.stringify(x) + '\n').join(''),
|
|
36
|
+
env: {
|
|
37
|
+
PATH: process.env.PATH,
|
|
38
|
+
HOME: home,
|
|
39
|
+
TMPDIR: tmp,
|
|
40
|
+
NO_UPDATE_NOTIFIER: '1',
|
|
41
|
+
PROBE_REPORT: report,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
assert.ifError(result.error);
|
|
45
|
+
assert.equal(result.status, 0, result.stderr);
|
|
46
|
+
const records = result.stdout
|
|
47
|
+
.split('\n')
|
|
48
|
+
.filter((line) => line.startsWith('{'))
|
|
49
|
+
.map((line) => JSON.parse(line));
|
|
50
|
+
const report_ = () => JSON.parse(readFileSync(report, 'utf8'));
|
|
51
|
+
return { records, report: report_ };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
test('only this package: six commands, the slot published, and a third party extends it', { skip: !pi }, (t) => {
|
|
55
|
+
const { records, report } = rpc(t, null, `
|
|
56
|
+
import { writeFileSync } from "node:fs";
|
|
57
|
+
|
|
58
|
+
export default function (pi) {
|
|
59
|
+
pi.registerCommand("gentle:customize", { handler() {} });
|
|
60
|
+
pi.on("session_start", () => {
|
|
61
|
+
const api = globalThis[${slot}];
|
|
62
|
+
const answer = {
|
|
63
|
+
schema: api?.schema,
|
|
64
|
+
version: api?.version,
|
|
65
|
+
VERSION: api?.VERSION,
|
|
66
|
+
members: api === undefined ? [] : Object.keys(api).sort(),
|
|
67
|
+
};
|
|
68
|
+
// A third party registers exactly as the contract says, and the registration answers with
|
|
69
|
+
// its own disposer. The slot publishes registries, not readers, so this is the whole
|
|
70
|
+
// observable answer for a caller.
|
|
71
|
+
const disposer = api?.registerRows({ id: "probe.rows", category: "Probe", rows: () => [] });
|
|
72
|
+
answer.disposer = typeof disposer;
|
|
73
|
+
writeFileSync(process.env.PROBE_REPORT, JSON.stringify(answer));
|
|
74
|
+
});
|
|
75
|
+
}`, [get]);
|
|
76
|
+
const names = records.find((x) => x.id === '1').data.commands.map((c) => c.name);
|
|
77
|
+
for (const name of ['warp', 'odd', 'files', 'issues', 'prs', 'identity']) {
|
|
78
|
+
assert.equal(names.filter((candidate) => candidate === name).length, 1, name);
|
|
79
|
+
}
|
|
80
|
+
assert.equal(names.includes('bridge-status'), false, 'the status command is gone');
|
|
81
|
+
const answer = report();
|
|
82
|
+
assert.equal(answer.schema, 'gentle-shell-bridge/api');
|
|
83
|
+
assert.equal(answer.version, 1);
|
|
84
|
+
assert.equal(answer.VERSION, '0.16.2', 'the release consumers gate on');
|
|
85
|
+
assert.deepEqual(answer.members, [
|
|
86
|
+
'VERSION',
|
|
87
|
+
'createStore',
|
|
88
|
+
'registerCardStyle',
|
|
89
|
+
'registerMessageDesign',
|
|
90
|
+
'registerRows',
|
|
91
|
+
'registerSection',
|
|
92
|
+
'registerToolDesign',
|
|
93
|
+
'registerTransform',
|
|
94
|
+
'requestRepaint',
|
|
95
|
+
'resolveToolDesignSelection',
|
|
96
|
+
'schema',
|
|
97
|
+
'version',
|
|
98
|
+
]);
|
|
99
|
+
assert.equal(answer.disposer, 'function', 'a registration answers with its disposer');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('a first-loaded plugin sees the API, adds a section and removes it again', { skip: !pi }, (t) => {
|
|
103
|
+
const { report } = rpc(t, `
|
|
104
|
+
import { writeFileSync } from "node:fs";
|
|
105
|
+
|
|
106
|
+
export default function (pi) {
|
|
107
|
+
pi.registerCommand("gentle:customize", { handler() {} });
|
|
108
|
+
let ready = 0;
|
|
109
|
+
pi.events.on("gentle-shell-bridge:ready", () => { ready += 1; });
|
|
110
|
+
pi.on("session_start", () => {
|
|
111
|
+
const api = globalThis[${slot}];
|
|
112
|
+
const ids = () =>
|
|
113
|
+
globalThis[Symbol.for("gentle-shell-bridge.providers")].sections
|
|
114
|
+
.map((entry) => entry.section.id)
|
|
115
|
+
.sort();
|
|
116
|
+
const own = ids();
|
|
117
|
+
const dispose = api.registerSection({
|
|
118
|
+
id: "verification.section",
|
|
119
|
+
title: "Verification",
|
|
120
|
+
lines: () => ["probe"],
|
|
121
|
+
});
|
|
122
|
+
const added = ids();
|
|
123
|
+
dispose();
|
|
124
|
+
dispose();
|
|
125
|
+
writeFileSync(process.env.PROBE_REPORT, JSON.stringify({
|
|
126
|
+
own, added, after: ids(), ready,
|
|
127
|
+
identity: [api.schema, api.version, api.VERSION],
|
|
128
|
+
}));
|
|
129
|
+
});
|
|
130
|
+
}`, null, [get]);
|
|
131
|
+
const saw = report();
|
|
132
|
+
const own = ['odd-worktree.issues', 'odd-worktree.odd-rail'];
|
|
133
|
+
assert.deepEqual(saw.own, own, 'this package\'s two sections are there before the probe registers');
|
|
134
|
+
assert.deepEqual(saw.added, [...own, 'verification.section'], 'a third party adds its own');
|
|
135
|
+
assert.deepEqual(saw.after, own, 'and its disposer removes exactly that one, twice safely');
|
|
136
|
+
assert.equal(saw.ready, 1, 'the ready announcement reaches a plugin loaded first');
|
|
137
|
+
assert.deepEqual(saw.identity, ['gentle-shell-bridge/api', 1, '0.16.2']);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test('an incompatible object on the slot leaves this package\'s surface unregistered and says so once', { skip: !pi }, (t) => {
|
|
141
|
+
const { records } = rpc(t, `
|
|
142
|
+
globalThis[${slot}] = { schema: "other-bridge/api", version: 2 };
|
|
143
|
+
export default function (pi) {
|
|
144
|
+
pi.registerCommand("gentle:customize", { handler() {} });
|
|
145
|
+
}
|
|
146
|
+
`, null, [get]);
|
|
147
|
+
const names = records.find((x) => x.id === '1').data.commands.map((c) => c.name);
|
|
148
|
+
for (const name of ['warp', 'odd', 'files', 'identity', 'issues', 'prs']) {
|
|
149
|
+
assert.equal(names.includes(name), false, `/${name} is not registered`);
|
|
150
|
+
}
|
|
151
|
+
const warnings = records.filter((x) => x.method === 'notify' && x.notifyType === 'warning');
|
|
152
|
+
const foreign = warnings.filter((x) => x.message.startsWith('odd-worktree:'));
|
|
153
|
+
assert.equal(foreign.length, 1, 'one notice, in this package\'s own words');
|
|
154
|
+
assert.match(foreign[0].message, /other-bridge\/api/, 'it names the schema the slot really holds');
|
|
155
|
+
assert.match(foreign[0].message, /"2"/, 'and its version');
|
|
156
|
+
assert.match(foreign[0].message, /sidebar sections/, 'and what is off');
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
for (const schema of ['third-party/v2', 'gentle-shell-bridge/api']) {
|
|
160
|
+
test(`foreign slot ${schema}: one warning, no commands, no row of this package, and no load failure`, { skip: !pi }, (t) => {
|
|
161
|
+
const { records, report } = rpc(t, `
|
|
162
|
+
import { writeFileSync } from "node:fs";
|
|
163
|
+
const key = ${slot};
|
|
164
|
+
const foreign = {
|
|
165
|
+
schema: ${JSON.stringify(schema)},
|
|
166
|
+
get version() { throw new Error("unreadable version"); },
|
|
167
|
+
};
|
|
168
|
+
globalThis[key] = foreign;
|
|
169
|
+
export default function (pi) {
|
|
170
|
+
pi.registerCommand("gentle:customize", { handler() {} });
|
|
171
|
+
pi.on("session_start", () => setImmediate(() => {
|
|
172
|
+
const bus = globalThis[Symbol.for("gentle-shell-bridge.providers")];
|
|
173
|
+
writeFileSync(process.env.PROBE_REPORT, JSON.stringify({
|
|
174
|
+
preserved: globalThis[key] === foreign,
|
|
175
|
+
providers: ((bus && bus.entries) || []).map((entry) => entry.provider.id),
|
|
176
|
+
}));
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
179
|
+
`, null, [get]);
|
|
180
|
+
const commands = records.find((x) => x.id === '1').data.commands;
|
|
181
|
+
assert.deepEqual(commands.filter((x) => x.source === 'extension').map((x) => x.name), ['gentle:customize']);
|
|
182
|
+
const warnings = records.filter((x) => x.method === 'notify' && x.notifyType === 'warning' && x.message.startsWith('odd-worktree:'));
|
|
183
|
+
assert.equal(warnings.length, 1, 'one notice, in this package\'s own words');
|
|
184
|
+
assert.ok(warnings[0].message.includes(`schema "${schema}", version "unreadable"`));
|
|
185
|
+
const saw = report();
|
|
186
|
+
assert.equal(saw.preserved, true, 'the foreign object is never replaced');
|
|
187
|
+
assert.deepEqual(saw.providers.filter((id) => id.startsWith('odd-worktree.')), [], 'none of this package\'s own rows');
|
|
188
|
+
});
|
|
189
|
+
}
|
|
@@ -901,10 +901,11 @@ test('S7: factory load does not arm a host import before session_start', async (
|
|
|
901
901
|
}
|
|
902
902
|
});
|
|
903
903
|
|
|
904
|
-
test('S7:
|
|
905
|
-
// The gate observer is
|
|
906
|
-
//
|
|
907
|
-
//
|
|
904
|
+
test('S7 (T2): with no bridge on the slot nothing is registered, and a silent publication never arms an install', async () => {
|
|
905
|
+
// The gate observer is gone (native-bridge T2): the shell API publishes at module load, the
|
|
906
|
+
// factory reads the slot ONCE, and a load that found it empty keeps no observer to be woken by.
|
|
907
|
+
// What S7 still guarantees is the other half: a load that DID find the bridge owns the shutdown
|
|
908
|
+
// that unwraps the card, which is what the first test above proves.
|
|
908
909
|
const previousBridge = globalThis[BRIDGE_API_SLOT];
|
|
909
910
|
delete globalThis[BRIDGE_API_SLOT];
|
|
910
911
|
class Host {
|
|
@@ -916,14 +917,12 @@ test('S7: silent publication on a host without a bus acquires a shutdown owner',
|
|
|
916
917
|
const { hooks } = await loadExtensionModule(() => ({ UserMessageComponent: Host }));
|
|
917
918
|
const emit = extensionSession(hooks);
|
|
918
919
|
try {
|
|
919
|
-
assert.deepEqual(hooks
|
|
920
|
-
// A SILENT publication: nothing announces it,
|
|
920
|
+
assert.deepEqual(hooks, [], 'a load with no bridge registers no hook at all');
|
|
921
|
+
// A SILENT publication: nothing announces it, and nothing is listening for it either.
|
|
921
922
|
globalThis[BRIDGE_API_SLOT] = fixture.defaultBridge().api;
|
|
922
923
|
await emit('session_start');
|
|
923
924
|
await drain();
|
|
924
|
-
assert.
|
|
925
|
-
await emit('session_shutdown');
|
|
926
|
-
assert.equal(Host.prototype.render, native, 'and it owns the shutdown that unwraps it');
|
|
925
|
+
assert.equal(Host.prototype.render, native, 'nothing installs: no session boundary was owned');
|
|
927
926
|
} finally {
|
|
928
927
|
await emit('session_shutdown');
|
|
929
928
|
if (previousBridge === undefined) delete globalThis[BRIDGE_API_SLOT];
|