@narumitw/pi-starship 0.49.0 → 0.49.3

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.
Files changed (84) hide show
  1. package/README.md +6 -4
  2. package/dist/chunks/chunk-CKNSOLSW.ts +10 -0
  3. package/dist/chunks/chunk-CKNSOLSW.ts.map +7 -0
  4. package/dist/chunks/chunk-G2GG2V6Q.ts +218 -0
  5. package/dist/chunks/chunk-G2GG2V6Q.ts.map +7 -0
  6. package/dist/chunks/chunk-Q6DLIM7H.ts +2492 -0
  7. package/dist/chunks/chunk-Q6DLIM7H.ts.map +7 -0
  8. package/dist/chunks/cloud-JBSZWTB6.ts +142 -0
  9. package/dist/chunks/cloud-JBSZWTB6.ts.map +7 -0
  10. package/dist/chunks/commands-BSQZ2R4M.ts +757 -0
  11. package/dist/chunks/commands-BSQZ2R4M.ts.map +7 -0
  12. package/dist/chunks/deployment-ZNYM4B6W.ts +172 -0
  13. package/dist/chunks/deployment-ZNYM4B6W.ts.map +7 -0
  14. package/dist/chunks/development-TNWZ5SRC.ts +132 -0
  15. package/dist/chunks/development-TNWZ5SRC.ts.map +7 -0
  16. package/dist/chunks/execution-QHAP4U33.ts +132 -0
  17. package/dist/chunks/execution-QHAP4U33.ts.map +7 -0
  18. package/dist/chunks/languages-DPWDCH6Q.ts +184 -0
  19. package/dist/chunks/languages-DPWDCH6Q.ts.map +7 -0
  20. package/dist/chunks/package-MXN2YFLX.ts +104 -0
  21. package/dist/chunks/package-MXN2YFLX.ts.map +7 -0
  22. package/dist/pi-starship.ts +1350 -0
  23. package/dist/pi-starship.ts.map +7 -0
  24. package/package.json +10 -6
  25. package/src/index.ts +1 -1
  26. package/src/command-contract.ts +0 -13
  27. package/src/command-inspector.ts +0 -198
  28. package/src/command-preview.ts +0 -206
  29. package/src/commands.ts +0 -575
  30. package/src/config.ts +0 -794
  31. package/src/format/formatter.ts +0 -275
  32. package/src/format/style.ts +0 -278
  33. package/src/modules/activity.ts +0 -38
  34. package/src/modules/brand.ts +0 -13
  35. package/src/modules/cache.ts +0 -23
  36. package/src/modules/catalog.ts +0 -124
  37. package/src/modules/cloud.ts +0 -74
  38. package/src/modules/context.ts +0 -33
  39. package/src/modules/cost.ts +0 -31
  40. package/src/modules/deployment.ts +0 -61
  41. package/src/modules/development.ts +0 -112
  42. package/src/modules/directory.ts +0 -151
  43. package/src/modules/display.ts +0 -14
  44. package/src/modules/execution.ts +0 -84
  45. package/src/modules/extension-status.ts +0 -93
  46. package/src/modules/fill.ts +0 -14
  47. package/src/modules/git/branch.ts +0 -31
  48. package/src/modules/git/commit.ts +0 -29
  49. package/src/modules/git/metrics.ts +0 -26
  50. package/src/modules/git/runtime.ts +0 -415
  51. package/src/modules/git/state.ts +0 -21
  52. package/src/modules/git/status.ts +0 -87
  53. package/src/modules/git/worktree.ts +0 -16
  54. package/src/modules/github-pr.ts +0 -24
  55. package/src/modules/helpers.ts +0 -5
  56. package/src/modules/index.ts +0 -31
  57. package/src/modules/inspection.ts +0 -138
  58. package/src/modules/languages.ts +0 -87
  59. package/src/modules/model.ts +0 -85
  60. package/src/modules/package.ts +0 -17
  61. package/src/modules/provider.ts +0 -13
  62. package/src/modules/render.ts +0 -166
  63. package/src/modules/terminal.ts +0 -60
  64. package/src/modules/thinking.ts +0 -13
  65. package/src/modules/time.ts +0 -20
  66. package/src/modules/tokens.ts +0 -18
  67. package/src/modules/truncation.ts +0 -37
  68. package/src/modules/turn.ts +0 -13
  69. package/src/modules/types.ts +0 -189
  70. package/src/modules/workspace-helpers.ts +0 -10
  71. package/src/pi-starship.ts +0 -609
  72. package/src/runtime/cloud.ts +0 -166
  73. package/src/runtime/command.ts +0 -123
  74. package/src/runtime/deployment.ts +0 -201
  75. package/src/runtime/development.ts +0 -153
  76. package/src/runtime/execution.ts +0 -151
  77. package/src/runtime/github-pr.ts +0 -332
  78. package/src/runtime/helpers.ts +0 -274
  79. package/src/runtime/languages.ts +0 -205
  80. package/src/runtime/package.ts +0 -112
  81. package/src/runtime/refresh-controller.ts +0 -107
  82. package/src/runtime/types.ts +0 -63
  83. package/src/runtime/workspace.ts +0 -147
  84. package/src/usage.ts +0 -53
@@ -1,206 +0,0 @@
1
- import { stripVTControlCharacters } from "node:util";
2
- import type { ExtensionCommandContext, KeybindingsManager } from "@earendil-works/pi-coding-agent";
3
- import { Key, matchesKey, truncateToWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
4
-
5
- const RESERVED_HOST_ROWS = 3;
6
-
7
- export interface PreviewMenuItem<Value extends string> {
8
- value: Value;
9
- label: string;
10
- }
11
-
12
- export type PreviewMenuResult<Value extends string> =
13
- | { kind: "selected"; value: Value }
14
- | { kind: "cancelled" }
15
- | { kind: "closed" };
16
-
17
- export async function showPreviewActionMenu<Value extends string>(
18
- ctx: ExtensionCommandContext,
19
- title: string,
20
- body: (width: number) => readonly string[],
21
- items: readonly PreviewMenuItem<Value>[],
22
- signal?: AbortSignal,
23
- ): Promise<PreviewMenuResult<Value> | undefined> {
24
- if (signal?.aborted) return { kind: "closed" };
25
- return ctx.ui.custom<PreviewMenuResult<Value> | undefined>((tui, theme, keybindings, done) => {
26
- let selectedIndex = 0;
27
- let scrollOffset = 0;
28
- let lastMaximumScroll = 0;
29
- let lastViewportSize = 1;
30
- let disposed = false;
31
- let deferredAbort: ReturnType<typeof setImmediate> | undefined;
32
- const closeForAbort = () => {
33
- if (disposed) return;
34
- if (deferredAbort) clearImmediate(deferredAbort);
35
- deferredAbort = undefined;
36
- done({ kind: "closed" });
37
- };
38
- signal?.addEventListener("abort", closeForAbort, { once: true });
39
- if (signal?.aborted) deferredAbort = setImmediate(closeForAbort);
40
-
41
- const requestRender = () => {
42
- if (!disposed) tui.requestRender();
43
- };
44
- const moveSelection = (delta: number) => {
45
- if (items.length === 0) return;
46
- selectedIndex = (selectedIndex + delta + items.length) % items.length;
47
- requestRender();
48
- };
49
- const movePreview = (offset: number) => {
50
- scrollOffset = Math.max(0, Math.min(offset, lastMaximumScroll));
51
- requestRender();
52
- };
53
-
54
- return {
55
- render(width: number): string[] {
56
- const safeWidth = Math.max(1, width);
57
- const terminalRows = Number.isFinite(tui.terminal.rows)
58
- ? Math.floor(tui.terminal.rows)
59
- : 24;
60
- const availableRows = Math.max(1, terminalRows - RESERVED_HOST_ROWS);
61
- const bodyLines = body(safeWidth).flatMap((line) =>
62
- line ? wrapTextWithAnsi(line, safeWidth) : [""],
63
- );
64
- const layout = allocateLayout(availableRows, items.length, bodyLines.length);
65
- lastViewportSize = layout.previewRows;
66
- lastMaximumScroll = Math.max(0, bodyLines.length - layout.previewRows);
67
- scrollOffset = Math.max(0, Math.min(scrollOffset, lastMaximumScroll));
68
- const actionStart = actionWindowStart(selectedIndex, items.length, layout.actionRows);
69
- const actionLines = items
70
- .slice(actionStart, actionStart + layout.actionRows)
71
- .map((item, index) => {
72
- const absoluteIndex = actionStart + index;
73
- const prefix = absoluteIndex === selectedIndex ? "→ " : " ";
74
- return theme.fg(
75
- absoluteIndex === selectedIndex ? "accent" : "text",
76
- `${prefix}${safeDisplayText(item.label)}`,
77
- );
78
- });
79
- const position = layout.positionRows
80
- ? [theme.fg("dim", previewPosition(scrollOffset, layout.previewRows, bodyLines.length))]
81
- : [];
82
- const lines = [
83
- ...(layout.titleRows ? [theme.fg("accent", theme.bold(safeDisplayText(title)))] : []),
84
- ...bodyLines.slice(scrollOffset, scrollOffset + layout.previewRows),
85
- ...position,
86
- ...actionLines,
87
- ...(layout.hintRows ? [theme.fg("dim", previewHint(keybindings))] : []),
88
- ];
89
- return lines.map((line) => truncateToWidth(line, safeWidth, ""));
90
- },
91
- invalidate() {},
92
- handleInput(data: string) {
93
- if (disposed) return;
94
- if (matchesKey(data, Key.ctrl("c"))) {
95
- done({ kind: "closed" });
96
- } else if (keybindings.matches(data, "tui.select.cancel")) {
97
- done({ kind: "cancelled" });
98
- } else if (keybindings.matches(data, "tui.select.up")) {
99
- moveSelection(-1);
100
- } else if (keybindings.matches(data, "tui.select.down")) {
101
- moveSelection(1);
102
- } else if (keybindings.matches(data, "tui.select.pageUp")) {
103
- movePreview(scrollOffset - lastViewportSize);
104
- } else if (keybindings.matches(data, "tui.select.pageDown")) {
105
- movePreview(scrollOffset + lastViewportSize);
106
- } else if (matchesKey(data, Key.home)) {
107
- movePreview(0);
108
- } else if (matchesKey(data, Key.end)) {
109
- movePreview(lastMaximumScroll);
110
- } else if (keybindings.matches(data, "tui.select.confirm")) {
111
- const item = items[selectedIndex];
112
- if (item) done({ kind: "selected", value: item.value });
113
- }
114
- },
115
- dispose() {
116
- if (disposed) return;
117
- disposed = true;
118
- if (deferredAbort) clearImmediate(deferredAbort);
119
- deferredAbort = undefined;
120
- signal?.removeEventListener("abort", closeForAbort);
121
- },
122
- };
123
- });
124
- }
125
-
126
- interface PreviewLayout {
127
- titleRows: number;
128
- previewRows: number;
129
- positionRows: number;
130
- actionRows: number;
131
- hintRows: number;
132
- }
133
-
134
- function allocateLayout(
135
- availableRows: number,
136
- actionCount: number,
137
- bodyLineCount: number,
138
- ): PreviewLayout {
139
- if (availableRows === 1) {
140
- return { titleRows: 0, previewRows: 0, positionRows: 0, actionRows: 1, hintRows: 0 };
141
- }
142
- const titleRows = availableRows >= 3 ? 1 : 0;
143
- const hintRows = availableRows >= 3 ? 1 : 0;
144
- const minimumPreviewRows = bodyLineCount > 0 && availableRows >= 4 ? 1 : 0;
145
- const availableActionRows = Math.max(
146
- 1,
147
- availableRows - titleRows - hintRows - minimumPreviewRows,
148
- );
149
- const actionRows = Math.min(Math.max(1, actionCount), availableActionRows);
150
- let previewRows = Math.max(0, availableRows - titleRows - hintRows - actionRows);
151
- const positionRows = previewRows >= 2 && bodyLineCount > previewRows ? 1 : 0;
152
- previewRows -= positionRows;
153
- return { titleRows, previewRows, positionRows, actionRows, hintRows };
154
- }
155
-
156
- function actionWindowStart(selectedIndex: number, itemCount: number, viewportSize: number): number {
157
- if (itemCount <= viewportSize) return 0;
158
- return Math.max(0, Math.min(selectedIndex, itemCount - viewportSize));
159
- }
160
-
161
- function previewPosition(offset: number, viewportSize: number, lineCount: number): string {
162
- if (lineCount === 0) return "0/0";
163
- return `${offset + 1}-${Math.min(lineCount, offset + viewportSize)}/${lineCount}`;
164
- }
165
-
166
- function previewHint(keybindings: Pick<KeybindingsManager, "getKeys">): string {
167
- const up = bindingText(keybindings, "tui.select.up");
168
- const down = bindingText(keybindings, "tui.select.down");
169
- const confirm = bindingText(keybindings, "tui.select.confirm");
170
- const cancel = bindingText(keybindings, "tui.select.cancel", "ctrl+c");
171
- const pageUp = bindingText(keybindings, "tui.select.pageUp");
172
- const pageDown = bindingText(keybindings, "tui.select.pageDown");
173
- return [
174
- ...(up || down ? [`${[up, down].filter(Boolean).join("/")} navigate`] : []),
175
- ...(confirm ? [`${confirm} select`] : []),
176
- ...(cancel ? [`${cancel} discard`] : []),
177
- "ctrl+c close",
178
- ...(pageUp || pageDown ? [`${[pageUp, pageDown].filter(Boolean).join("/")} preview`] : []),
179
- ].join(" • ");
180
- }
181
-
182
- function bindingText(
183
- keybindings: Pick<KeybindingsManager, "getKeys">,
184
- binding: Parameters<KeybindingsManager["getKeys"]>[0],
185
- excluded?: string,
186
- ): string {
187
- return keybindings
188
- .getKeys(binding)
189
- .filter((key) => key !== excluded)
190
- .map((key) => {
191
- if (key === "up") return "↑";
192
- if (key === "down") return "↓";
193
- if (key === "escape") return "esc";
194
- if (key === "return") return "enter";
195
- return safeDisplayText(key);
196
- })
197
- .join("/");
198
- }
199
-
200
- function safeDisplayText(value: string): string {
201
- return Array.from(stripVTControlCharacters(value), (character) => {
202
- const codePoint = character.codePointAt(0) ?? 0;
203
- const control = codePoint <= 0x1f || (codePoint >= 0x7f && codePoint <= 0x9f);
204
- return control ? "" : character;
205
- }).join("");
206
- }