@heyhuynhgiabuu/pi-pretty 0.6.23 → 0.6.25

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 (54) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +51 -1
  3. package/dist/autocomplete.js +1 -4
  4. package/dist/autocomplete.js.map +1 -1
  5. package/dist/config.d.ts +19 -0
  6. package/dist/config.d.ts.map +1 -1
  7. package/dist/config.js +141 -118
  8. package/dist/config.js.map +1 -1
  9. package/dist/fff-helpers.js +2 -7
  10. package/dist/fff-helpers.js.map +1 -1
  11. package/dist/fff.js +16 -23
  12. package/dist/fff.js.map +1 -1
  13. package/dist/find-glob.js +2 -6
  14. package/dist/find-glob.js.map +1 -1
  15. package/dist/helpers.js +11 -21
  16. package/dist/helpers.js.map +1 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +182 -59
  19. package/dist/index.js.map +1 -1
  20. package/dist/notices.js +1 -4
  21. package/dist/notices.js.map +1 -1
  22. package/dist/render.js +78 -96
  23. package/dist/render.js.map +1 -1
  24. package/dist/session-color.d.ts +30 -0
  25. package/dist/session-color.d.ts.map +1 -0
  26. package/dist/session-color.js +170 -0
  27. package/dist/session-color.js.map +1 -0
  28. package/dist/tools/bash.js +26 -29
  29. package/dist/tools/bash.js.map +1 -1
  30. package/dist/tools/find.js +31 -34
  31. package/dist/tools/find.js.map +1 -1
  32. package/dist/tools/grep.js +22 -25
  33. package/dist/tools/grep.js.map +1 -1
  34. package/dist/tools/labels.js +1 -4
  35. package/dist/tools/labels.js.map +1 -1
  36. package/dist/tools/ls.js +18 -21
  37. package/dist/tools/ls.js.map +1 -1
  38. package/dist/tools/metrics.js +4 -7
  39. package/dist/tools/metrics.js.map +1 -1
  40. package/dist/tools/read.js +35 -38
  41. package/dist/tools/read.js.map +1 -1
  42. package/dist/tui-text.js +5 -9
  43. package/dist/tui-text.js.map +1 -1
  44. package/dist/types.js +1 -2
  45. package/dist/types.js.map +1 -1
  46. package/dist/working-indicator.d.ts +184 -0
  47. package/dist/working-indicator.d.ts.map +1 -0
  48. package/dist/working-indicator.js +524 -0
  49. package/dist/working-indicator.js.map +1 -0
  50. package/package.json +7 -6
  51. package/src/config.ts +48 -0
  52. package/src/index.ts +177 -2
  53. package/src/session-color.ts +172 -0
  54. package/src/working-indicator.ts +691 -0
@@ -0,0 +1,184 @@
1
+ /**
2
+ * omp-style shimmer working indicator (widget takeover).
3
+ *
4
+ * Ports the shimmer sweep from oh-my-pi's `modes/theme/shimmer.ts`: the sweep
5
+ * is discretized into one pre-rendered frame per band position, cycled at
6
+ * 1000/30 ms so the band travels 30 cells/second — omp's exact speed.
7
+ *
8
+ * Why a widget: the host `Loader` extends `Text` with a hardcoded paddingX=1,
9
+ * and `setWorkingIndicator({ frames })` cannot change host component layout.
10
+ * To render the row flush-left we hide the host loader
11
+ * (`setWorkingVisible(false)`) and install our own zero-padding component via
12
+ * `setWidget(..., "aboveEditor")`, animating it with a 33ms interval.
13
+ *
14
+ * Frame layout: `<dim spinner> <shimmer text> <dim interrupt hint>`, one full
15
+ * sweep per phrase — `texts` rotates through phrases chapter by chapter with
16
+ * a continuous spinner phase.
17
+ */
18
+ import { type ThinkingIndicatorConfig, type WorkingIndicatorConfig } from "./config.js";
19
+ /** One cell per frame at 33ms = omp's 30 cells/second band speed. */
20
+ export declare const WORKING_INTERVAL_MS: number;
21
+ export type WorkingIndicatorMode = "shimmer" | "kitt" | "static";
22
+ /** Tier colors as config values: a pi theme color name or a `#rrggbb` hex. */
23
+ export interface WorkingIndicatorPalette {
24
+ low: string;
25
+ mid: string;
26
+ high: string;
27
+ }
28
+ export interface WorkingIndicatorSettings {
29
+ enabled: boolean;
30
+ /** Phrases rotated chapter-by-chapter across the sweep. */
31
+ texts: string[];
32
+ mode: WorkingIndicatorMode;
33
+ palette: WorkingIndicatorPalette;
34
+ bold: boolean;
35
+ hint: boolean;
36
+ /** Tint mid/high tiers (and dim the spinner) with a per-session accent color. */
37
+ sessionAccent: boolean;
38
+ /** True when the user explicitly configured `mid`/`high` — accent then stays off. */
39
+ tiersCustomized?: boolean;
40
+ }
41
+ export declare const WORKING_INDICATOR_DEFAULTS: WorkingIndicatorSettings;
42
+ /**
43
+ * Resolve final settings from `pi-pretty.json`'s flat `workingIndicator` object
44
+ * and env overrides. Precedence: env var > config > default; empty or invalid
45
+ * env values mean unset (matching pi-pretty's config conventions).
46
+ */
47
+ export declare function resolveWorkingIndicatorSettings(config: WorkingIndicatorConfig | undefined, env?: NodeJS.ProcessEnv): WorkingIndicatorSettings;
48
+ /** Tier colors as raw ANSI open sequences. */
49
+ export interface ResolvedPalette {
50
+ low: string;
51
+ mid: string;
52
+ high: string;
53
+ }
54
+ interface ThemeAnsiSource {
55
+ /** Narrowed tier names; pi's Theme (ThemeColor) satisfies this structurally. */
56
+ getFgAnsi?: (name: "dim" | "muted" | "accent" | "thinkingText") => string;
57
+ }
58
+ /**
59
+ * Resolve tier colors to ANSI open sequences. `#rrggbb` wins, then the active
60
+ * pi theme (`getFgAnsi`), then pi-pretty's built-in constants.
61
+ */
62
+ export declare function resolvePaletteAnsi(palette: WorkingIndicatorPalette, theme?: ThemeAnsiSource): ResolvedPalette;
63
+ export interface WorkingFrameOptions {
64
+ mode: WorkingIndicatorMode;
65
+ /** Resolved ANSI open sequences per tier. */
66
+ ansi: ResolvedPalette;
67
+ bold?: boolean;
68
+ spinner?: boolean;
69
+ /** Spinner glyph color; defaults to `ansi.low` (omp tints it with the dim accent). */
70
+ spinnerColor?: string;
71
+ /** Wrap every frame in italic (pi's hidden-thinking label is italic). */
72
+ italic?: boolean;
73
+ /** Pre-colored suffix (e.g. the dim interrupt hint) appended to every frame. */
74
+ hint?: string;
75
+ intervalMs?: number;
76
+ }
77
+ /**
78
+ * Build the frame list for the working row: one full sweep per phrase, in
79
+ * order, with the spinner phase running continuously across chapter
80
+ * boundaries. Same-tier runs share one ANSI pair (omp's run coalescing).
81
+ */
82
+ export declare function buildWorkingFrames(texts: string[], options: WorkingFrameOptions): {
83
+ frames: string[];
84
+ intervalMs: number;
85
+ };
86
+ /** Slice of the pi-tui TUI instance the widget needs. */
87
+ export interface WidgetTuiLike {
88
+ requestRender(): void;
89
+ }
90
+ /**
91
+ * Zero-padding working-row component. The host renders whatever `render()`
92
+ * returns with no margins, so the row sits flush-left — the thing the frames
93
+ * API could not do.
94
+ */
95
+ export declare class WorkingWidget {
96
+ #private;
97
+ setFrames(frames: string[], intervalMs: number): void;
98
+ attach(tui: WidgetTuiLike): void;
99
+ start(): void;
100
+ stop(): void;
101
+ /** Flush-left single line; invisible (no lines) while stopped. */
102
+ render(width: number): string[];
103
+ invalidate(): void;
104
+ dispose(): void;
105
+ }
106
+ export interface ThinkingIndicatorSettings {
107
+ enabled: boolean;
108
+ }
109
+ export declare const THINKING_INDICATOR_DEFAULTS: ThinkingIndicatorSettings;
110
+ /**
111
+ * Resolve thinking-label shimmer settings from `pi-pretty.json`'s
112
+ * `thinkingIndicator` object and env overrides (env > config > default).
113
+ */
114
+ export declare function resolveThinkingIndicatorSettings(config: ThinkingIndicatorConfig | undefined, env?: NodeJS.ProcessEnv): ThinkingIndicatorSettings;
115
+ export interface ThinkingUiLike {
116
+ theme?: WorkingThemeLike;
117
+ setHiddenThinkingLabel(label?: string): void;
118
+ }
119
+ export interface ThinkingLabelAnimator {
120
+ /** Apply the next shimmer frame to the hidden-thinking label. */
121
+ tick(): void;
122
+ /** Restore pi's default static label. */
123
+ restore(): void;
124
+ /** Pre-rendered label frames (exposed for diagnostics). */
125
+ readonly frames: readonly string[];
126
+ }
127
+ /**
128
+ * True while a streaming assistant message is currently emitting a thinking
129
+ * block (its last content block). Used to gate label ticks to the thinking
130
+ * phase — once text or tool calls stream, the label is frozen back to pi's
131
+ * default instead of rebuilding the transcript for a row nobody watches.
132
+ */
133
+ export declare function thinkingBlockActive(message: unknown): boolean;
134
+ /**
135
+ * Animate pi's hidden-thinking label ("Thinking...") with the same shimmer as
136
+ * the working row. Pi renders the label as static italic `thinkingText` text;
137
+ * the only extension lever is `setHiddenThinkingLabel(label)`, which rebuilds
138
+ * chat children — the streaming component already rebuilds per delta, so the
139
+ * animator is driven at a throttled cadence (100ms) from index.ts while the
140
+ * agent streams and thinking blocks are hidden.
141
+ *
142
+ * Tiers: low = theme `thinkingText` (pi's own label look), mid/high = session
143
+ * accent when enabled; every frame is italic like pi's label; no spinner.
144
+ */
145
+ export declare function createThinkingLabelAnimator(ui: ThinkingUiLike, workSettings: WorkingIndicatorSettings, sessionName?: string, thinking?: ThinkingIndicatorSettings): ThinkingLabelAnimator;
146
+ /** Structural slice of pi's Theme needed for the hint, palette, and thinking label. */
147
+ export interface WorkingThemeLike {
148
+ /** Narrowed to the only color the hint needs; pi's ThemeColor satisfies it. */
149
+ fg?: (name: "dim", text: string) => string;
150
+ getFgAnsi?: (name: "dim" | "muted" | "accent" | "thinkingText") => string;
151
+ }
152
+ export interface WorkingUiLike {
153
+ theme?: WorkingThemeLike;
154
+ setWorkingVisible(visible: boolean): void;
155
+ setWidget(key: string, factory: ((tui: WidgetTuiLike, theme: unknown) => WorkingWidget) | undefined, options?: {
156
+ placement?: "aboveEditor" | "belowEditor";
157
+ }): void;
158
+ }
159
+ export interface KeybindingsLike {
160
+ getKeys(name: string): string[];
161
+ }
162
+ export interface WorkingIndicatorController {
163
+ /** Streaming began — show and animate the row. */
164
+ start(): void;
165
+ /** Streaming ended — hide the row and pause the animation. */
166
+ stop(): void;
167
+ /** Remove the widget and stop the animation. */
168
+ dispose(): void;
169
+ /** Pre-rendered frames (exposed for diagnostics). */
170
+ readonly frames: readonly string[];
171
+ }
172
+ /**
173
+ * Take over pi's working row with our own flush-left shimmer widget.
174
+ *
175
+ * Installs a zero-padding component above the editor and hides the host
176
+ * loader; returns a controller the host lifecycle drives (`start` on
177
+ * agent_start, `stop` on agent_end). No-op (host defaults untouched) when
178
+ * disabled or the phrase list is empty.
179
+ */
180
+ export declare function installWorkingIndicator(ui: WorkingUiLike, settings: WorkingIndicatorSettings, deps?: {
181
+ getKeybindings?: () => KeybindingsLike | undefined | Promise<KeybindingsLike | undefined>;
182
+ }, sessionName?: string): Promise<WorkingIndicatorController>;
183
+ export {};
184
+ //# sourceMappingURL=working-indicator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"working-indicator.d.ts","sourceRoot":"","sources":["../src/working-indicator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAA6B,KAAK,uBAAuB,EAAE,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAWnH,qEAAqE;AACrE,eAAO,MAAM,mBAAmB,QAAwB,CAAC;AAgBzD,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEjE,8EAA8E;AAC9E,MAAM,WAAW,uBAAuB;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,wBAAwB;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,2DAA2D;IAC3D,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,oBAAoB,CAAC;IAC3B,OAAO,EAAE,uBAAuB,CAAC;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd,iFAAiF;IACjF,aAAa,EAAE,OAAO,CAAC;IACvB,qFAAqF;IACrF,eAAe,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,eAAO,MAAM,0BAA0B,EAAE,wBASxC,CAAC;AA8CF;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC9C,MAAM,EAAE,sBAAsB,GAAG,SAAS,EAC1C,GAAG,GAAE,MAAM,CAAC,UAAwB,GAClC,wBAAwB,CAwB1B;AAID,8CAA8C;AAC9C,MAAM,WAAW,eAAe;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,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