pi-odd-worktree 3.15.1 → 3.16.1
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 +70 -212
- 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/session-auto-name-wiring.test.js +39 -0
- 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,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The diagnostics channel Pi actually owns: `ctx.ui.notify`, never stdout/stderr.
|
|
3
|
+
*
|
|
4
|
+
* Pi renders its diagnostics inside the TUI (its startup report lists `[Ext]`, `[Skill warnings]`,
|
|
5
|
+
* …). An extension that writes to the console instead puts that text in the terminal *around*
|
|
6
|
+
* Pi's startup, before the TUI takes the screen, where it is easy to miss and impossible to read
|
|
7
|
+
* after the fact. So this module is the only place a bridge problem is reported out of band:
|
|
8
|
+
*
|
|
9
|
+
* - a message produced while a context exists is shown with `ctx.ui.notify(message, level)`;
|
|
10
|
+
* - a message produced before any context exists (module load) is buffered
|
|
11
|
+
* here and flushed ONCE on the first `session_start` that has a UI;
|
|
12
|
+
* - every message stays in the buffer afterwards, so a delivered notice is never shown twice and
|
|
13
|
+
* the same problem reported again is recognised instead of duplicated.
|
|
14
|
+
*
|
|
15
|
+
* The buffer is process-global for the same reason the bus is (`./bus.ts`): Pi loads every
|
|
16
|
+
* extension through its own loader with `moduleCache: false`, so module scope is per-copy. It is
|
|
17
|
+
* bounded, so a plugin that reports the same problem on every call cannot grow it without limit,
|
|
18
|
+
* and identical `message` + `level` pairs are recorded once — a repeated warning is the same fact.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** The levels Pi's `notify` accepts. Every bridge notice is a problem report: default `warning`. */
|
|
22
|
+
export type NoticeLevel = "info" | "warning" | "error";
|
|
23
|
+
|
|
24
|
+
export interface NoticeEntry {
|
|
25
|
+
message: string;
|
|
26
|
+
level: NoticeLevel;
|
|
27
|
+
/** `true` once `notify` accepted it; a delivered notice is never delivered twice. */
|
|
28
|
+
emitted: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface NoticeSnapshot {
|
|
32
|
+
entries: NoticeEntry[];
|
|
33
|
+
/** Messages the bound had to evict before they were ever reported, so the loss stays visible. */
|
|
34
|
+
dropped: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface NoticeState {
|
|
38
|
+
entries: NoticeEntry[];
|
|
39
|
+
dropped: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** How many notices are kept. */
|
|
43
|
+
export const MAX_NOTICES = 20;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Stable process-global slot. `v1` is part of the key for the same reason as the API symbol: a
|
|
47
|
+
* future shape change takes a new key instead of mutating this one.
|
|
48
|
+
*/
|
|
49
|
+
const NOTICES_KEY: symbol = Symbol.for("gentle-shell-bridge/notices/v1");
|
|
50
|
+
|
|
51
|
+
function noticesHost(): Record<symbol, NoticeState | undefined> {
|
|
52
|
+
// SAFETY: this module is the only writer of the slot, and `noticeState()` re-checks the shape
|
|
53
|
+
// before trusting a value left by another copy or an older load.
|
|
54
|
+
return globalThis as unknown as Record<symbol, NoticeState | undefined>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The process-global notice state, created on first use; a foreign value is replaced. */
|
|
58
|
+
function noticeState(): NoticeState {
|
|
59
|
+
const host = noticesHost();
|
|
60
|
+
const existing = host[NOTICES_KEY];
|
|
61
|
+
if (existing !== undefined && Array.isArray(existing.entries)) {
|
|
62
|
+
if (typeof existing.dropped !== "number") existing.dropped = 0;
|
|
63
|
+
return existing;
|
|
64
|
+
}
|
|
65
|
+
const created: NoticeState = { entries: [], dropped: 0 };
|
|
66
|
+
host[NOTICES_KEY] = created;
|
|
67
|
+
return created;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Record one message for the TUI.
|
|
72
|
+
*
|
|
73
|
+
* Identical `message` + `level` pairs are recorded once. When the bound is reached the oldest
|
|
74
|
+
* already-delivered entry is evicted first, so a message the user has not been shown yet is not
|
|
75
|
+
* the one that goes; only when every entry is still pending is one dropped (and counted).
|
|
76
|
+
*/
|
|
77
|
+
export function recordNotice(message: string, level: NoticeLevel = "warning"): void {
|
|
78
|
+
const text = message.trim();
|
|
79
|
+
if (text === "") return;
|
|
80
|
+
const state = noticeState();
|
|
81
|
+
if (state.entries.some((entry) => entry.message === text && entry.level === level)) return;
|
|
82
|
+
|
|
83
|
+
if (state.entries.length >= MAX_NOTICES) {
|
|
84
|
+
const delivered = state.entries.findIndex((entry) => entry.emitted);
|
|
85
|
+
if (delivered >= 0) state.entries.splice(delivered, 1);
|
|
86
|
+
else {
|
|
87
|
+
state.entries.shift();
|
|
88
|
+
state.dropped += 1;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
state.entries.push({ message: text, level, emitted: false });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Deliver every pending notice through `ui.notify`, once.
|
|
96
|
+
*
|
|
97
|
+
* A context without a `notify` (or without a UI at all) delivers nothing and marks nothing, so the
|
|
98
|
+
* message waits for the next `session_start` that can show it. A `notify` that throws leaves that
|
|
99
|
+
* message pending and keeps the rest of the list intact — a broken UI must not lose diagnostics.
|
|
100
|
+
* Returns how many notices this call delivered.
|
|
101
|
+
*/
|
|
102
|
+
export function flushNotices(ui: unknown): number {
|
|
103
|
+
if (typeof ui !== "object" || ui === null) return 0;
|
|
104
|
+
const notify = (ui as { notify?: unknown }).notify;
|
|
105
|
+
if (typeof notify !== "function") return 0;
|
|
106
|
+
|
|
107
|
+
let delivered = 0;
|
|
108
|
+
for (const entry of noticeState().entries) {
|
|
109
|
+
if (entry.emitted) continue;
|
|
110
|
+
try {
|
|
111
|
+
// `this` matters: Pi's notify is a method on the UI context.
|
|
112
|
+
(notify as (message: string, level?: NoticeLevel) => void).call(ui, entry.message, entry.level);
|
|
113
|
+
entry.emitted = true;
|
|
114
|
+
delivered += 1;
|
|
115
|
+
} catch {
|
|
116
|
+
// Leave it pending: the next session_start retries it.
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return delivered;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** A copy of the buffer; callers can never mutate the live state. */
|
|
123
|
+
export function snapshotNotices(): NoticeSnapshot {
|
|
124
|
+
const state = noticeState();
|
|
125
|
+
return {
|
|
126
|
+
entries: state.entries.map((entry) => ({ ...entry })),
|
|
127
|
+
dropped: state.dropped,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Test-only seam: forget every buffered notice. The extension never calls this; a delivered
|
|
133
|
+
* message is kept for the life of the process.
|
|
134
|
+
*/
|
|
135
|
+
export function resetNoticesForTests(): void {
|
|
136
|
+
delete noticesHost()[NOTICES_KEY];
|
|
137
|
+
}
|