@blackbelt-technology/pi-dashboard-extension 0.7.0 → 0.8.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/.pi/skills/browser/SKILL.md +28 -14
- package/.pi/skills/browser/UPSTREAM.md +10 -1
- package/.pi/skills/browser/references/electron.agent.md +57 -0
- package/.pi/skills/browser/references/own-browser.md +299 -0
- package/.pi/skills/browser/references/web.agent.md +323 -0
- package/.pi/skills/browser/scripts/check-panerelay.sh +157 -0
- package/.pi/skills/doctor/SKILL.md +3 -9
- package/.pi/skills/doctor/_lib/checks.ts +14 -68
- package/.pi/skills/doctor/_lib/derive-tokens.ts +1 -0
- package/.pi/skills/doctor/modules/apple-tools.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/apple-tools.md +51 -0
- package/.pi/skills/doctor/modules/oauth-redirect-base.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/oauth-redirect-base.md +71 -0
- package/.pi/skills/doctor/modules/pi-resolution.knowledge.hash +1 -1
- package/.pi/skills/doctor/modules/pi-resolution.md +21 -1
- package/.pi/skills/pi-dashboard/references/api-reference.agent.md +69 -0
- package/.pi/skills/project-init/SKILL.md +1 -7
- package/.pi/skills/project-init/dox-doctrine.md +42 -0
- package/.pi/skills/project-init/profiles/docs/profile.json +1 -1
- package/README.md +19 -0
- package/agents/DoxTriage.md +80 -0
- package/package.json +22 -11
- package/src/agent-settled.ts +27 -9
- package/src/auto-session-namer.ts +486 -70
- package/src/autostart-guard.ts +99 -0
- package/src/autostart-lock.ts +258 -0
- package/src/bridge-context.ts +86 -5
- package/src/bridge-ticket-client.ts +105 -0
- package/src/bridge.ts +917 -213
- package/src/command-handler.ts +332 -57
- package/src/connect-target.ts +130 -0
- package/src/connection.ts +371 -7
- package/src/endpoint-resolution.ts +221 -0
- package/src/flow-event-wiring.ts +125 -3
- package/src/followup-buffer.ts +217 -0
- package/src/instance-verification.ts +125 -0
- package/src/local-token-header.ts +44 -0
- package/src/model-refresh.ts +95 -0
- package/src/notify-proxy.ts +33 -0
- package/src/pi-env.d.ts +4 -0
- package/src/pi-retry-settings.ts +91 -0
- package/src/provider-register.ts +86 -21
- package/src/remote-registration-gate.ts +102 -0
- package/src/retry-tracker.ts +265 -86
- package/src/role-manager.ts +20 -0
- package/src/role-model-tools.ts +38 -3
- package/src/server-auto-start.ts +144 -2
- package/src/server-pin-store.ts +92 -0
- package/src/session-move.ts +275 -0
- package/src/session-sync.ts +24 -5
- package/src/subagent-forward-sites.ts +69 -0
- package/src/subagent-frame-buffer.ts +24 -3
- package/src/subagent-frame-strip.ts +109 -0
- package/src/subagent-tick-throttle.ts +250 -0
- package/src/transcript-backfill.ts +151 -0
- package/src/transcript-request-guard.ts +76 -0
- package/src/transport-diagnostics.ts +76 -0
- package/src/turn-actionability.ts +20 -0
- package/src/ui-stale-guard.ts +58 -0
- package/.pi/skills/doctor/AGENTS.md +0 -27
- package/src/AGENTS.md +0 -57
- package/src/__tests__/abort-latch.test.ts +0 -97
- package/src/__tests__/agent-settled.test.ts +0 -82
- package/src/__tests__/artifact-roots.test.ts +0 -83
- package/src/__tests__/ask-user-attachments.test.ts +0 -106
- package/src/__tests__/ask-user-schema-discriminator.test.ts +0 -141
- package/src/__tests__/ask-user-tool.test.ts +0 -571
- package/src/__tests__/auto-session-namer.test.ts +0 -339
- package/src/__tests__/bridge-default-model-apply.test.ts +0 -242
- package/src/__tests__/bridge-default-model-gate.test.ts +0 -50
- package/src/__tests__/bridge-entry-id-pi-070.test.ts +0 -174
- package/src/__tests__/bridge-followup-chat-order.test.ts +0 -215
- package/src/__tests__/bridge-followup-multi-entry.test.ts +0 -202
- package/src/__tests__/bridge-followup-mutation.test.ts +0 -217
- package/src/__tests__/bridge-followup-queue-drain.test.ts +0 -266
- package/src/__tests__/bridge-hasui-flip.test.ts +0 -109
- package/src/__tests__/bridge-no-queue-mutation.test.ts +0 -112
- package/src/__tests__/bridge-plugin-emit-event.test.ts +0 -44
- package/src/__tests__/bridge-queue-update-forward.test.ts +0 -77
- package/src/__tests__/bridge-resume-disconnect.test.ts +0 -333
- package/src/__tests__/bridge-shadow-queue-gate.test.ts +0 -299
- package/src/__tests__/bridge-shutdown-reset.test.ts +0 -159
- package/src/__tests__/bridge-slash-command-routing.test.ts +0 -458
- package/src/__tests__/bridge-stop-after-turn.test.ts +0 -72
- package/src/__tests__/bridge-system-followup.test.ts +0 -163
- package/src/__tests__/bridge-thinking-level-select.test.ts +0 -68
- package/src/__tests__/browser-skill-registered.test.ts +0 -84
- package/src/__tests__/build-provider-catalogue.test.ts +0 -210
- package/src/__tests__/command-handler.test.ts +0 -1180
- package/src/__tests__/commit-draft.test.ts +0 -100
- package/src/__tests__/connection-dropped-frames.test.ts +0 -78
- package/src/__tests__/connection-suppress-auto-start.test.ts +0 -97
- package/src/__tests__/connection.test.ts +0 -344
- package/src/__tests__/credentials-updated.test.ts +0 -26
- package/src/__tests__/custom-provider-apikey-roundtrip.test.ts +0 -128
- package/src/__tests__/cwd-missing-probe.test.ts +0 -82
- package/src/__tests__/dashboard-commands-shipped.test.ts +0 -53
- package/src/__tests__/dashboard-context-injector.test.ts +0 -190
- package/src/__tests__/dashboard-default-adapter.test.ts +0 -77
- package/src/__tests__/dev-build.test.ts +0 -79
- package/src/__tests__/doctor/checks.test.ts +0 -121
- package/src/__tests__/doctor/modules.test.ts +0 -64
- package/src/__tests__/doctor/provenance-hash.test.ts +0 -94
- package/src/__tests__/doctor/router.test.ts +0 -143
- package/src/__tests__/empty-actionable-guard-config.test.ts +0 -32
- package/src/__tests__/empty-actionable-guard.test.ts +0 -73
- package/src/__tests__/enrich-model-metadata.test.ts +0 -222
- package/src/__tests__/event-forwarder.test.ts +0 -119
- package/src/__tests__/extension-slash-command-detection.test.ts +0 -143
- package/src/__tests__/filter-enabled-models.test.ts +0 -151
- package/src/__tests__/fixtures/turn-actionability-fixtures.ts +0 -69
- package/src/__tests__/fork-entryid-timing.test.ts +0 -88
- package/src/__tests__/git-info-status.test.ts +0 -73
- package/src/__tests__/git-link-builder.test.ts +0 -102
- package/src/__tests__/git-poll.test.ts +0 -69
- package/src/__tests__/markdown-image-inliner.test.ts +0 -392
- package/src/__tests__/model-resolve.test.ts +0 -379
- package/src/__tests__/multiselect-dashboard-routing.test.ts +0 -203
- package/src/__tests__/multiselect-list.test.ts +0 -137
- package/src/__tests__/multiselect-polyfill.test.ts +0 -92
- package/src/__tests__/no-session-replacement-calls.test.ts +0 -99
- package/src/__tests__/no-tui-multiselect-arm-regression.test.ts +0 -81
- package/src/__tests__/openspec-activity-detector.test.ts +0 -337
- package/src/__tests__/openspec-cli-shim.test.ts +0 -145
- package/src/__tests__/openspec-poller.test.ts +0 -124
- package/src/__tests__/pi-version-tracker.test.ts +0 -109
- package/src/__tests__/process-metrics.test.ts +0 -47
- package/src/__tests__/process-scanner-kill.test.ts +0 -61
- package/src/__tests__/process-scanner.test.ts +0 -292
- package/src/__tests__/project-init-detect-stack.test.ts +0 -61
- package/src/__tests__/project-init-dox-kb-config.test.ts +0 -53
- package/src/__tests__/project-init-profiles.test.ts +0 -84
- package/src/__tests__/project-init-scaffold.test.ts +0 -139
- package/src/__tests__/project-init-seed-doctrine.test.ts +0 -100
- package/src/__tests__/project-trust.test.ts +0 -92
- package/src/__tests__/prompt-bus-wiring.test.ts +0 -791
- package/src/__tests__/prompt-bus.test.ts +0 -513
- package/src/__tests__/prompt-expander.test.ts +0 -398
- package/src/__tests__/provider-register-native-models.test.ts +0 -182
- package/src/__tests__/provider-register-reload.test.ts +0 -498
- package/src/__tests__/provider-register-thinking-levels.test.ts +0 -104
- package/src/__tests__/retry-tracker.test.ts +0 -152
- package/src/__tests__/role-manager.test.ts +0 -585
- package/src/__tests__/role-model-tools-registry-readiness.test.ts +0 -114
- package/src/__tests__/role-model-tools.test.ts +0 -229
- package/src/__tests__/search-files-completeness.test.ts +0 -111
- package/src/__tests__/search-files-ranking.test.ts +0 -168
- package/src/__tests__/server-auto-start.test.ts +0 -375
- package/src/__tests__/server-launcher-launch.test.ts +0 -96
- package/src/__tests__/server-launcher.test.ts +0 -101
- package/src/__tests__/server-probe.test.ts +0 -25
- package/src/__tests__/session-switch.test.ts +0 -139
- package/src/__tests__/session-sync.test.ts +0 -243
- package/src/__tests__/single-derivation-guard.test.ts +0 -39
- package/src/__tests__/source-detector.test.ts +0 -88
- package/src/__tests__/stats-extractor.test.ts +0 -92
- package/src/__tests__/subagent-frame-buffer.test.ts +0 -239
- package/src/__tests__/tool-result-image-inliner.test.ts +0 -206
- package/src/__tests__/tui-prompt-adapter.test.ts +0 -213
- package/src/__tests__/turn-actionability.test.ts +0 -86
- package/src/__tests__/ui-decorators.test.ts +0 -309
- package/src/__tests__/ui-modules.test.ts +0 -293
- package/src/__tests__/vcs-info.test.ts +0 -265
- package/src/__tests__/visibility-intent.test.ts +0 -43
- package/src/__tests__/watchdog.test.ts +0 -161
- package/src/abort-latch.ts.AGENTS.md +0 -3
- package/src/agent-settled.ts.AGENTS.md +0 -3
- package/src/artifact-roots.ts.AGENTS.md +0 -3
- package/src/ask-user-attachments.ts.AGENTS.md +0 -3
- package/src/ask-user-tool.ts.AGENTS.md +0 -3
- package/src/auto-session-namer.ts.AGENTS.md +0 -3
- package/src/bridge-context.ts.AGENTS.md +0 -3
- package/src/bridge-default-model-gate.ts.AGENTS.md +0 -3
- package/src/bridge.ts.AGENTS.md +0 -3
- package/src/command-handler.ts.AGENTS.md +0 -3
- package/src/commit-draft-agent.ts.AGENTS.md +0 -3
- package/src/commit-draft.ts.AGENTS.md +0 -3
- package/src/connection.ts.AGENTS.md +0 -3
- package/src/dashboard-context-injector.ts.AGENTS.md +0 -3
- package/src/dashboard-default-adapter.ts.AGENTS.md +0 -3
- package/src/dev-build.ts.AGENTS.md +0 -3
- package/src/empty-actionable-guard-config.ts.AGENTS.md +0 -3
- package/src/empty-actionable-guard.ts.AGENTS.md +0 -3
- package/src/event-forwarder.ts.AGENTS.md +0 -3
- package/src/flow-event-wiring.ts.AGENTS.md +0 -3
- package/src/git-link-builder.ts.AGENTS.md +0 -3
- package/src/git-poll.ts.AGENTS.md +0 -3
- package/src/hasui-flip.ts.AGENTS.md +0 -3
- package/src/markdown-image-inliner.ts.AGENTS.md +0 -3
- package/src/model-tracker.ts.AGENTS.md +0 -3
- package/src/multiselect-decode.ts.AGENTS.md +0 -3
- package/src/multiselect-list.ts.AGENTS.md +0 -3
- package/src/multiselect-polyfill.ts.AGENTS.md +0 -3
- package/src/openspec-cli-shim.ts.AGENTS.md +0 -7
- package/src/process-metrics.ts.AGENTS.md +0 -3
- package/src/process-scanner.ts.AGENTS.md +0 -3
- package/src/project-init/AGENTS.md +0 -12
- package/src/project-trust.ts.AGENTS.md +0 -3
- package/src/prompt-bus.ts.AGENTS.md +0 -3
- package/src/prompt-expander.ts.AGENTS.md +0 -3
- package/src/provider-register.ts.AGENTS.md +0 -3
- package/src/retry-tracker.ts.AGENTS.md +0 -3
- package/src/role-manager.ts.AGENTS.md +0 -3
- package/src/role-model-tools.ts.AGENTS.md +0 -3
- package/src/server-auto-start.ts.AGENTS.md +0 -3
- package/src/server-launcher.ts.AGENTS.md +0 -3
- package/src/session-sync.ts.AGENTS.md +0 -3
- package/src/slash-dispatch.ts.AGENTS.md +0 -3
- package/src/source-detector.ts.AGENTS.md +0 -3
- package/src/subagent-frame-buffer.ts.AGENTS.md +0 -3
- package/src/tool-result-image-inliner.ts.AGENTS.md +0 -3
- package/src/tui-prompt-adapter.ts.AGENTS.md +0 -3
- package/src/turn-actionability.ts.AGENTS.md +0 -3
- package/src/ui-modules.ts.AGENTS.md +0 -3
- package/src/vcs-info.ts.AGENTS.md +0 -3
- package/src/visibility-intent.ts.AGENTS.md +0 -3
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from "vitest";
|
|
2
|
-
import { MultiSelectList } from "../multiselect-list.js";
|
|
3
|
-
|
|
4
|
-
function make(options: string[] = ["A", "B", "C"], title = "Pick", message?: string) {
|
|
5
|
-
const list = new MultiSelectList(title, options, message);
|
|
6
|
-
const onConfirm = vi.fn();
|
|
7
|
-
const onCancel = vi.fn();
|
|
8
|
-
list.onConfirm = onConfirm;
|
|
9
|
-
list.onCancel = onCancel;
|
|
10
|
-
return { list, onConfirm, onCancel };
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
describe("MultiSelectList", () => {
|
|
14
|
-
describe("keybindings", () => {
|
|
15
|
-
it("space toggles the checked state of the current item and nothing else", () => {
|
|
16
|
-
const { list, onConfirm } = make();
|
|
17
|
-
list.handleInput(" "); // toggle index 0 → A checked
|
|
18
|
-
list.handleInput("\r");
|
|
19
|
-
expect(onConfirm).toHaveBeenCalledWith(["A"]);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("arrow down moves cursor and space toggles the new current item", () => {
|
|
23
|
-
const { list, onConfirm } = make();
|
|
24
|
-
list.handleInput("\u001b[B"); // cursor → 1 (B)
|
|
25
|
-
list.handleInput(" "); // B checked
|
|
26
|
-
list.handleInput("\r");
|
|
27
|
-
expect(onConfirm).toHaveBeenCalledWith(["B"]);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("j / k navigation works like arrows", () => {
|
|
31
|
-
const { list, onConfirm } = make();
|
|
32
|
-
list.handleInput("j"); // cursor → 1
|
|
33
|
-
list.handleInput("j"); // cursor → 2
|
|
34
|
-
list.handleInput(" "); // C checked
|
|
35
|
-
list.handleInput("k"); // cursor → 1
|
|
36
|
-
list.handleInput(" "); // B checked
|
|
37
|
-
list.handleInput("\r");
|
|
38
|
-
// selected values returned in ORIGINAL order
|
|
39
|
-
expect(onConfirm).toHaveBeenCalledWith(["B", "C"]);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("enter with nothing checked confirms with []", () => {
|
|
43
|
-
const { list, onConfirm } = make();
|
|
44
|
-
list.handleInput("\r");
|
|
45
|
-
expect(onConfirm).toHaveBeenCalledWith([]);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("escape cancels; no confirm is fired", () => {
|
|
49
|
-
const { list, onConfirm, onCancel } = make();
|
|
50
|
-
list.handleInput(" "); // check A
|
|
51
|
-
list.handleInput("\u001b");
|
|
52
|
-
expect(onCancel).toHaveBeenCalledTimes(1);
|
|
53
|
-
expect(onConfirm).not.toHaveBeenCalled();
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("pressing 'a' does NOT bulk-toggle (no select-all in TUI)", () => {
|
|
57
|
-
const { list, onConfirm } = make();
|
|
58
|
-
list.handleInput("a");
|
|
59
|
-
list.handleInput("\r");
|
|
60
|
-
expect(onConfirm).toHaveBeenCalledWith([]);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("cursor does not go below 0", () => {
|
|
64
|
-
const { list } = make();
|
|
65
|
-
list.handleInput("k");
|
|
66
|
-
list.handleInput("k");
|
|
67
|
-
expect(list.getCursor()).toBe(0);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it("cursor does not go past last item", () => {
|
|
71
|
-
const { list } = make(["A", "B"]);
|
|
72
|
-
list.handleInput("j");
|
|
73
|
-
list.handleInput("j");
|
|
74
|
-
list.handleInput("j");
|
|
75
|
-
expect(list.getCursor()).toBe(1);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("toggling twice returns item to unchecked", () => {
|
|
79
|
-
const { list, onConfirm } = make();
|
|
80
|
-
list.handleInput(" ");
|
|
81
|
-
list.handleInput(" ");
|
|
82
|
-
list.handleInput("\r");
|
|
83
|
-
expect(onConfirm).toHaveBeenCalledWith([]);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it("selected order follows original option order, not toggle order", () => {
|
|
87
|
-
const { list, onConfirm } = make(["A", "B", "C", "D"]);
|
|
88
|
-
// toggle D first, then A, then C
|
|
89
|
-
list.handleInput("j");
|
|
90
|
-
list.handleInput("j");
|
|
91
|
-
list.handleInput("j");
|
|
92
|
-
list.handleInput(" "); // D
|
|
93
|
-
list.handleInput("k");
|
|
94
|
-
list.handleInput("k");
|
|
95
|
-
list.handleInput("k");
|
|
96
|
-
list.handleInput(" "); // A
|
|
97
|
-
list.handleInput("j");
|
|
98
|
-
list.handleInput("j");
|
|
99
|
-
list.handleInput(" "); // C
|
|
100
|
-
list.handleInput("\r");
|
|
101
|
-
expect(onConfirm).toHaveBeenCalledWith(["A", "C", "D"]);
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
describe("render", () => {
|
|
106
|
-
it("includes footer hint", () => {
|
|
107
|
-
const { list } = make();
|
|
108
|
-
const lines = list.render(80);
|
|
109
|
-
expect(lines.some((l) => l.includes("space toggle"))).toBe(true);
|
|
110
|
-
expect(lines.some((l) => l.includes("enter confirm"))).toBe(true);
|
|
111
|
-
expect(lines.some((l) => l.includes("esc cancel"))).toBe(true);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("renders [ ] for unchecked and [x] for checked items", () => {
|
|
115
|
-
const { list } = make();
|
|
116
|
-
list.handleInput(" "); // check A
|
|
117
|
-
const lines = list.render(80);
|
|
118
|
-
expect(lines.some((l) => l.includes("[x] A"))).toBe(true);
|
|
119
|
-
expect(lines.some((l) => l.includes("[ ] B"))).toBe(true);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it("renders cursor marker on current item", () => {
|
|
123
|
-
const { list } = make();
|
|
124
|
-
list.handleInput("j"); // cursor → 1
|
|
125
|
-
const lines = list.render(80);
|
|
126
|
-
// Cursor line should start with "▸ " somewhere
|
|
127
|
-
expect(lines.some((l) => l.startsWith("▸ ") && l.includes("B"))).toBe(true);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it("includes title and message when provided", () => {
|
|
131
|
-
const { list } = make(["A", "B"], "Pick one or more", "Some context");
|
|
132
|
-
const lines = list.render(80);
|
|
133
|
-
expect(lines.some((l) => l.includes("Pick one or more"))).toBe(true);
|
|
134
|
-
expect(lines.some((l) => l.includes("Some context"))).toBe(true);
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
});
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for `polyfillMultiselect`'s fallback chain. After the
|
|
3
|
-
* fix-multiselect-auto-cancel-on-dashboard change, the polyfill prefers a
|
|
4
|
-
* bridge-patched `ctx.ui.multiselect` (the PromptBus path that surfaces in
|
|
5
|
-
* the dashboard browser) and falls back to the legacy `ctx.ui.custom` +
|
|
6
|
-
* `MultiSelectList` overlay only when the patch is absent (older pi
|
|
7
|
-
* versions or non-bridge embeddings).
|
|
8
|
-
*
|
|
9
|
-
* See change: fix-multiselect-auto-cancel-on-dashboard.
|
|
10
|
-
*/
|
|
11
|
-
import { describe, it, expect, vi } from "vitest";
|
|
12
|
-
import { polyfillMultiselect } from "../multiselect-polyfill.js";
|
|
13
|
-
|
|
14
|
-
describe("polyfillMultiselect — fallback chain", () => {
|
|
15
|
-
it("delegates to ctx.ui.multiselect when present (primary, bus-routed path)", async () => {
|
|
16
|
-
const multiselectFn = vi.fn().mockResolvedValue(["a"]);
|
|
17
|
-
const customFn = vi.fn();
|
|
18
|
-
const ctx = {
|
|
19
|
-
ui: {
|
|
20
|
-
multiselect: multiselectFn,
|
|
21
|
-
custom: customFn,
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const result = await polyfillMultiselect(ctx as any, "Pick", ["a", "b"]);
|
|
26
|
-
|
|
27
|
-
expect(result).toEqual(["a"]);
|
|
28
|
-
expect(multiselectFn).toHaveBeenCalledTimes(1);
|
|
29
|
-
expect(multiselectFn).toHaveBeenCalledWith("Pick", ["a", "b"], undefined);
|
|
30
|
-
expect(customFn).not.toHaveBeenCalled();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("forwards opts.message to ctx.ui.multiselect when present", async () => {
|
|
34
|
-
const multiselectFn = vi.fn().mockResolvedValue([]);
|
|
35
|
-
const ctx = { ui: { multiselect: multiselectFn, custom: vi.fn() } };
|
|
36
|
-
|
|
37
|
-
await polyfillMultiselect(ctx as any, "Pick", ["a"], { message: "ctx" });
|
|
38
|
-
|
|
39
|
-
expect(multiselectFn).toHaveBeenCalledWith("Pick", ["a"], { message: "ctx" });
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("propagates undefined (cancellation) through the primary path", async () => {
|
|
43
|
-
const multiselectFn = vi.fn().mockResolvedValue(undefined);
|
|
44
|
-
const ctx = { ui: { multiselect: multiselectFn, custom: vi.fn() } };
|
|
45
|
-
|
|
46
|
-
await expect(polyfillMultiselect(ctx as any, "t", ["a"])).resolves.toBeUndefined();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("falls back to ctx.ui.custom when ctx.ui.multiselect is absent (TUI path)", async () => {
|
|
50
|
-
let capturedDone: ((r: string[] | undefined) => void) | undefined;
|
|
51
|
-
const customFn = vi.fn().mockImplementation((factory: any) => {
|
|
52
|
-
return new Promise<string[] | undefined>((resolve) => {
|
|
53
|
-
const done = (r: string[] | undefined) => resolve(r);
|
|
54
|
-
capturedDone = done;
|
|
55
|
-
const component = factory({}, {}, {}, done);
|
|
56
|
-
// Simulate user confirming after the factory wires the component.
|
|
57
|
-
component?.onConfirm?.(["b"]);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
const ctx = { ui: { custom: customFn } };
|
|
61
|
-
|
|
62
|
-
const result = await polyfillMultiselect(ctx as any, "Pick", ["a", "b"]);
|
|
63
|
-
|
|
64
|
-
expect(result).toEqual(["b"]);
|
|
65
|
-
expect(customFn).toHaveBeenCalledTimes(1);
|
|
66
|
-
expect(capturedDone).toBeTypeOf("function");
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("falls back to ctx.ui.custom and resolves undefined on cancel", async () => {
|
|
70
|
-
const customFn = vi.fn().mockImplementation((factory: any) => {
|
|
71
|
-
return new Promise<string[] | undefined>((resolve) => {
|
|
72
|
-
const component = factory({}, {}, {}, (r: any) => resolve(r));
|
|
73
|
-
component?.onCancel?.();
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
const ctx = { ui: { custom: customFn } };
|
|
77
|
-
|
|
78
|
-
await expect(polyfillMultiselect(ctx as any, "Pick", ["a"])).resolves.toBeUndefined();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("does NOT fall back to ctx.ui.custom when ctx.ui.multiselect resolves to []", async () => {
|
|
82
|
-
// Empty selection is a valid answer — must NOT trigger the legacy fallback.
|
|
83
|
-
const multiselectFn = vi.fn().mockResolvedValue([]);
|
|
84
|
-
const customFn = vi.fn();
|
|
85
|
-
const ctx = { ui: { multiselect: multiselectFn, custom: customFn } };
|
|
86
|
-
|
|
87
|
-
const result = await polyfillMultiselect(ctx as any, "t", ["a"]);
|
|
88
|
-
|
|
89
|
-
expect(result).toEqual([]);
|
|
90
|
-
expect(customFn).not.toHaveBeenCalled();
|
|
91
|
-
});
|
|
92
|
-
});
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Repo-level invariant: the bridge MUST NOT call pi's session-replacement
|
|
3
|
-
* APIs (`pi.newSession(...)`, `ctx.fork(...)`, `ctx.switchSession(...)`)
|
|
4
|
-
* from any code under `packages/extension/src/`.
|
|
5
|
-
*
|
|
6
|
-
* Rationale: pi 0.69.0+ invalidates captured pre-replacement `pi`/`ctx`/
|
|
7
|
-
* session-bound objects on next access after these calls. The bridge
|
|
8
|
-
* holds long-lived caches (`cachedCtx`, `cachedModelRegistry`,
|
|
9
|
-
* `cachedHasUI` in `bridge.ts`; `modelRegistry` in `provider-register.ts`)
|
|
10
|
-
* that depend on pi being the ONLY originator of session replacement, so
|
|
11
|
-
* we can re-capture inside the resulting `session_start` handler keyed on
|
|
12
|
-
* `event.reason ∈ {"new","fork","resume"}`.
|
|
13
|
-
*
|
|
14
|
-
* If this test fails: do NOT add the call. Either drive the user-facing
|
|
15
|
-
* action through the dashboard server (which prompts the user, who
|
|
16
|
-
* triggers replacement via pi's UI), or wrap your post-switch work in
|
|
17
|
-
* the `withSession` callback that pi 0.69+ exposes on each replacement
|
|
18
|
-
* API and capture the freshly-emitted ReplacedSessionContext there.
|
|
19
|
-
*
|
|
20
|
-
* See change: pi-zero-seventy-compat.
|
|
21
|
-
*/
|
|
22
|
-
import { describe, it, expect } from "vitest";
|
|
23
|
-
import fs from "node:fs/promises";
|
|
24
|
-
import path from "node:path";
|
|
25
|
-
import url from "node:url";
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Each pattern matches `<receiver>.<method>(` allowing for whitespace and
|
|
29
|
-
* tolerating common variations like `await pi.newSession(...)`. Prefixed
|
|
30
|
-
* with a non-word boundary so we don't flag method names embedded in
|
|
31
|
-
* longer identifiers.
|
|
32
|
-
*/
|
|
33
|
-
const PATTERNS: ReadonlyArray<{ name: string; re: RegExp }> = [
|
|
34
|
-
{ name: "pi.newSession", re: /(?:^|[^.\w])pi\.newSession\s*\(/ },
|
|
35
|
-
{ name: "ctx.fork", re: /(?:^|[^.\w])ctx\.fork\s*\(/ },
|
|
36
|
-
{ name: "ctx.switchSession", re: /(?:^|[^.\w])ctx\.switchSession\s*\(/ },
|
|
37
|
-
];
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Per-line opt-out marker. Use only for documented exceptions (e.g. a
|
|
41
|
-
* future migration cell that intentionally drives a replacement and
|
|
42
|
-
* fully re-binds via `withSession`):
|
|
43
|
-
* await pi.newSession({ withSession: ... }); // ban:session-replacement-ok
|
|
44
|
-
*/
|
|
45
|
-
const OPT_OUT_MARKER = "ban:session-replacement-ok";
|
|
46
|
-
|
|
47
|
-
async function* walk(dir: string): AsyncGenerator<string> {
|
|
48
|
-
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
49
|
-
for (const entry of entries) {
|
|
50
|
-
const full = path.join(dir, entry.name);
|
|
51
|
-
if (entry.isDirectory()) {
|
|
52
|
-
if (entry.name === "node_modules" || entry.name === "dist" || entry.name === "__tests__") continue;
|
|
53
|
-
yield* walk(full);
|
|
54
|
-
} else if (entry.isFile() && /\.(ts|tsx|mts|cts)$/.test(entry.name)) {
|
|
55
|
-
yield full;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
describe("no session-replacement API calls in packages/extension/src/", () => {
|
|
61
|
-
it("bridge code never invokes pi.newSession / ctx.fork / ctx.switchSession", async () => {
|
|
62
|
-
const here = path.dirname(url.fileURLToPath(import.meta.url));
|
|
63
|
-
const srcDir = path.resolve(here, "..");
|
|
64
|
-
const repoRoot = path.resolve(here, "..", "..", "..", "..");
|
|
65
|
-
|
|
66
|
-
const violations: Array<{ file: string; line: number; pattern: string; text: string }> = [];
|
|
67
|
-
|
|
68
|
-
for await (const file of walk(srcDir)) {
|
|
69
|
-
const content = await fs.readFile(file, "utf-8");
|
|
70
|
-
const lines = content.split(/\r?\n/);
|
|
71
|
-
lines.forEach((line, idx) => {
|
|
72
|
-
if (line.includes(OPT_OUT_MARKER)) return;
|
|
73
|
-
for (const { name, re } of PATTERNS) {
|
|
74
|
-
if (re.test(line)) {
|
|
75
|
-
violations.push({
|
|
76
|
-
file: path.relative(repoRoot, file),
|
|
77
|
-
line: idx + 1,
|
|
78
|
-
pattern: name,
|
|
79
|
-
text: line.trim(),
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (violations.length > 0) {
|
|
87
|
-
const msg =
|
|
88
|
-
`Bridge code MUST NOT call pi session-replacement APIs.\n` +
|
|
89
|
-
`pi 0.69.0+ invalidates captured pre-replacement pi/ctx after these calls;\n` +
|
|
90
|
-
`the bridge relies on pi being the sole originator of replacement so it can\n` +
|
|
91
|
-
`re-capture state inside the resulting session_start handler.\n\n` +
|
|
92
|
-
`Offenders (${violations.length}):\n` +
|
|
93
|
-
violations
|
|
94
|
-
.map((v) => ` ${v.file}:${v.line} [${v.pattern}] ${v.text}`)
|
|
95
|
-
.join("\n");
|
|
96
|
-
expect(violations, msg).toEqual([]);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
});
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Repo-level invariant: `packages/extension/src/bridge.ts` MUST NOT
|
|
3
|
-
* contain the co-occurrence of two substrings:
|
|
4
|
-
*
|
|
5
|
-
* 1. `originals.custom`
|
|
6
|
-
* 2. `prompt.type === "multiselect"`
|
|
7
|
-
*
|
|
8
|
-
* If both appear in the same file, a contributor has (re)introduced the
|
|
9
|
-
* TUI PromptBus-adapter multiselect arm that was removed by change
|
|
10
|
-
* `fix-multiselect-tui-arm-self-cancel`. The arm is forbidden because
|
|
11
|
-
* pi 0.70's RPC mode (the only mode dashboard headless sessions run
|
|
12
|
-
* under) defines `ExtensionUIContext.custom` as an unconditional no-op
|
|
13
|
-
* (`async custom() { return undefined; }`, see
|
|
14
|
-
* `~/.nvm/.../@earendil-works/pi-coding-agent/dist/modes/rpc/rpc-mode.js`
|
|
15
|
-
* lines 150-153). Awaiting that primitive resolves to `undefined`
|
|
16
|
-
* synchronously, and the TUI arm's `bus.respond({ cancelled: true,
|
|
17
|
-
* source: "tui" })` triggers the PromptBus's first-response-wins
|
|
18
|
-
* dismissal — which auto-cancels the dashboard's already-rendered
|
|
19
|
-
* `MultiselectRenderer` within ~1 event-loop tick.
|
|
20
|
-
*
|
|
21
|
-
* The bus-routed `(ctx.ui as any).multiselect = (...) => bus.request(...)`
|
|
22
|
-
* patch site uses the substring `type: "multiselect"` (object-literal
|
|
23
|
-
* shape), not `prompt.type === "multiselect"` (equality-check shape),
|
|
24
|
-
* so it is unaffected by this lint.
|
|
25
|
-
*
|
|
26
|
-
* To remove a legitimate `originals.custom` reference (e.g. for a
|
|
27
|
-
* future use that does not include multiselect prompt routing), keep
|
|
28
|
-
* one substring and ensure the other does not co-occur.
|
|
29
|
-
*
|
|
30
|
-
* See change: fix-multiselect-tui-arm-self-cancel.
|
|
31
|
-
*/
|
|
32
|
-
import { describe, it, expect } from "vitest";
|
|
33
|
-
import fs from "node:fs/promises";
|
|
34
|
-
import path from "node:path";
|
|
35
|
-
import url from "node:url";
|
|
36
|
-
|
|
37
|
-
const FORBIDDEN_A = "originals.custom";
|
|
38
|
-
const FORBIDDEN_B = 'prompt.type === "multiselect"';
|
|
39
|
-
|
|
40
|
-
function findLineNumbers(src: string, needle: string): number[] {
|
|
41
|
-
const lines = src.split(/\r?\n/);
|
|
42
|
-
const hits: number[] = [];
|
|
43
|
-
lines.forEach((line, idx) => {
|
|
44
|
-
if (line.includes(needle)) hits.push(idx + 1);
|
|
45
|
-
});
|
|
46
|
-
return hits;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
describe("no TUI multiselect arm regression in bridge.ts", () => {
|
|
50
|
-
it("bridge.ts MUST NOT contain both `originals.custom` and `prompt.type === \"multiselect\"`", async () => {
|
|
51
|
-
const here = path.dirname(url.fileURLToPath(import.meta.url));
|
|
52
|
-
const bridgePath = path.resolve(here, "..", "bridge.ts");
|
|
53
|
-
const src = await fs.readFile(bridgePath, "utf-8");
|
|
54
|
-
|
|
55
|
-
const hasA = src.includes(FORBIDDEN_A);
|
|
56
|
-
const hasB = src.includes(FORBIDDEN_B);
|
|
57
|
-
|
|
58
|
-
if (hasA && hasB) {
|
|
59
|
-
const linesA = findLineNumbers(src, FORBIDDEN_A);
|
|
60
|
-
const linesB = findLineNumbers(src, FORBIDDEN_B);
|
|
61
|
-
const msg =
|
|
62
|
-
`Forbidden co-occurrence in ${path.relative(process.cwd(), bridgePath)}:\n` +
|
|
63
|
-
` - "${FORBIDDEN_A}" found on line(s): ${linesA.join(", ")}\n` +
|
|
64
|
-
` - "${FORBIDDEN_B}" found on line(s): ${linesB.join(", ")}\n` +
|
|
65
|
-
`\n` +
|
|
66
|
-
`This pattern was removed by change "fix-multiselect-tui-arm-self-cancel".\n` +
|
|
67
|
-
`pi 0.70 RPC mode's ctx.ui.custom is a no-op, so a TUI multiselect\n` +
|
|
68
|
-
`arm that awaits originals.custom auto-cancels the dashboard-rendered\n` +
|
|
69
|
-
`dialog within ~1 event-loop tick. The bus-routed ctx.ui.multiselect\n` +
|
|
70
|
-
`patch + DashboardDefaultAdapter handle multiselect end-to-end without\n` +
|
|
71
|
-
`any TUI arm participation. See:\n` +
|
|
72
|
-
` openspec/changes/archive/<date>-fix-multiselect-tui-arm-self-cancel/\n` +
|
|
73
|
-
`(or openspec/changes/fix-multiselect-tui-arm-self-cancel/ if not yet archived).`;
|
|
74
|
-
expect.fail(msg);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Guardrail: at least one of the two substrings absent (we already
|
|
78
|
-
// assert above that both-present is illegal). Either-alone is fine.
|
|
79
|
-
expect(hasA && hasB).toBe(false);
|
|
80
|
-
});
|
|
81
|
-
});
|