@gajae-code/tui 0.9.6 → 0.10.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/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.10.0] - 2026-07-12
6
+ ### Fixed
7
+
8
+ - Unified TUI wrapping, truncation, and visible-width measurements on the native grapheme-width engine, preventing Hangul tone marks from causing Korean/CJK layout width drift (#1979).
9
+
10
+ - Preserved durable transcript semantic anchors at their screen rows when completion removes transient content, including CJK/emoji/ANSI reflow, prefix eviction, provider replacement, explicit exclusion of synthetic/IRC/pinned rows, and supported SSH, tmux, Termux, and Windows terminal paths (#1969).
11
+
12
+ ### Added
13
+
14
+ - Added transparent Sixel and Kitty real-pixel encoders plus animated 16x16 frame art for the Gajae composer pet.
15
+ - Added an opt-in IRC sidebar split (`alt+i`, remappable): a responsive 70:30 vertical right-hand split that renders Discord-style IRC message blocks through a shared inline/sidebar formatter, with unbounded session backfill and tail-aligned panes. Kitty terminals render inline images inside the split via a cursor-neutral graphics fallback; cursor-advancing protocols (iTerm2, raw Sixel) keep the textual placeholder (#2018).
16
+
5
17
  ## [0.9.4] - 2026-07-09
6
18
 
7
19
  ### Fixed
@@ -0,0 +1,127 @@
1
+ /**
2
+ * ┌─ GAJAE PET SPRITE SPEC ────────────────────────────────────────────────┐
3
+ * The pet is a 16×16 pixel sprite drawn beside the composer. Everything here is
4
+ * data: no PNGs, no assets — each frame is 16 strings of 16 chars, encoded to a
5
+ * sixel or kitty escape at runtime. Author a new frame by drawing a grid.
6
+ *
7
+ * GRID RULES
8
+ * - Exactly 16 rows × 16 columns. Only PALETTE keys below are valid chars.
9
+ * - `.` = transparent. Keep the outer columns transparent so the sprite sits
10
+ * snug beside the input box (the widget reserves +1 column of slack).
11
+ *
12
+ * PALETTE (char → role) — see PALETTE for exact RGB:
13
+ * .=transparent K=dark outline R=body red r=red highlight
14
+ * V=visor screen G=visor glow(green) H=satgat straw h=satgat brim
15
+ * b=belly tan A=antenna
16
+ *
17
+ * FRAME CATALOG (GajaePixelFrameName → PIXEL_GRIDS):
18
+ * base idle rest; also the dance "drop/settle" beat
19
+ * gazeL eyes glance left ┐ idle loop (see gajae-pet-widget IDLE_LOOP)
20
+ * gazeR eyes glance right │
21
+ * flicker visor blink ┘
22
+ * flex both claws up + `^^`; dance accent + random idle flex burst
23
+ * danceL left claw up + `><` + feet step left ┐ work loop (PARA_PARA_STEPS)
24
+ * danceR right claw up + `^^` + feet step right ┘
25
+ *
26
+ * RENDERING: buildGajaePixelFrames({ protocol, cellWidthPx, cellHeightPx,
27
+ * targetRows: 2 }) scales the art to 2 terminal rows and encodes each frame
28
+ * once. Kitty uses a native `Y=` sub-cell drop (set by the widget) to sit on the
29
+ * composer border; sixel uses transparent top padding.
30
+ *
31
+ * BEHAVIOR (timing, positioning, on/off) lives in
32
+ * packages/coding-agent/src/modes/components/gajae-pet-widget.ts.
33
+ *
34
+ * ADD A FRAME: draw the grid → add its name to GajaePixelFrameName → register it in
35
+ * PIXEL_GRIDS → reference it from an idle/work loop or a skin burst.
36
+ *
37
+ * ADD A PET (skin): append one entry to PET_SKINS below — { id, label, description,
38
+ * palette, burst }. The id flows into PetSkinId/PetMode automatically, the settings
39
+ * enum, `/pet` command and both selectors derive their options from PET_SKINS, and the
40
+ * widget reads `burst` to animate — no other file needs editing. Recolor with a palette
41
+ * spread (see BLUE_PALETTE); add frames only for poses the catalog lacks.
42
+ * └────────────────────────────────────────────────────────────────────────┘
43
+ */
44
+ type Rgb = readonly [number, number, number];
45
+ export type Palette = Record<string, Rgb | null>;
46
+ export declare const PET_SKIN_IDS: readonly ["red", "blue"];
47
+ export type PetSkinId = (typeof PET_SKIN_IDS)[number];
48
+ /** Every pet mode: "off" plus each skin id, in menu order. */
49
+ export declare const PET_MODE_IDS: readonly ["off", "red", "blue"];
50
+ export type PetMode = (typeof PET_MODE_IDS)[number];
51
+ /** Narrow an arbitrary string to a PetMode. */
52
+ export declare function isPetMode(value: string): value is PetMode;
53
+ /** Logical pixel-pet frame names shared by the overlay state machine. */
54
+ export type GajaePixelFrameName = "base" | "gazeL" | "gazeR" | "flicker" | "flex" | "danceL" | "danceR" | "cry1" | "cry2" | "cry3";
55
+ /** Para-para work dance beats: the working loop and each skin's burst "work-in" intro. */
56
+ export declare const PARA_PARA_STEPS: ReadonlyArray<readonly [GajaePixelFrameName, number]>;
57
+ /**
58
+ * A skin's idle burst: a short intro sequence, then an optional looping tail. It drives
59
+ * BOTH the random live show-off AND the selector's preview demo, so give every skin a
60
+ * real animation (reuse PARA_PARA_STEPS for a work-in intro) rather than one held frame.
61
+ */
62
+ export interface PetBurst {
63
+ /** Frames played once, in order, at the start of the burst. */
64
+ intro: ReadonlyArray<readonly [GajaePixelFrameName, number]>;
65
+ /** Frames cycled every `stepMs` for `ms` after the intro (a held or looping finish). */
66
+ tail?: {
67
+ frames: readonly GajaePixelFrameName[];
68
+ stepMs: number;
69
+ ms: number;
70
+ };
71
+ }
72
+ /** Everything that defines a pet skin: identity, UI copy, colors and behavior. */
73
+ export interface PetSkin {
74
+ id: PetSkinId;
75
+ /** Selector/settings label, e.g. "RedGajae". */
76
+ label: string;
77
+ /** One-line selector/settings description. */
78
+ description: string;
79
+ palette: Palette;
80
+ /** Idle burst animation played between quiet idle loops. */
81
+ burst: PetBurst;
82
+ }
83
+ /** Skin registry — the single source for palettes, behavior and selector/command copy. */
84
+ export declare const PET_SKINS: Record<PetSkinId, PetSkin>;
85
+ /** Total burst duration (intro beats plus the looping tail). */
86
+ export declare function petBurstDurationMs(burst: PetBurst): number;
87
+ /** The frame to show `elapsed` ms into a burst (`now` cycles the looping tail). */
88
+ export declare function petBurstFrame(burst: PetBurst, elapsed: number, now: number): GajaePixelFrameName;
89
+ /** Test-only access to logical art; production rendering still uses encoded frames. */
90
+ export declare const __gajaePetTestHooks: {
91
+ getPixelGrid(name: GajaePixelFrameName): string[];
92
+ };
93
+ /** Encode a grid as a transparent SIXEL image, optionally bottom-aligned by top padding. */
94
+ export declare function encodeGridSixel(grid: string[], scale: number, topPaddingPx?: number, palette?: Palette): string;
95
+ /** Encode a bottom-aligned grid as kitty raw RGBA at `scale`. */
96
+ export declare function encodeGridKitty(grid: string[], scale: number, imageId: number, cols: number, rows: number, topPaddingPx?: number, cellYOffsetPx?: number, leftPaddingPx?: number, rightPaddingPx?: number, palette?: Palette): string;
97
+ export interface GajaePixelFrames {
98
+ /** escape payload per logical frame (drawn at the current cursor cell) */
99
+ frames: Record<GajaePixelFrameName, string>;
100
+ /** protocol the frames were encoded for */
101
+ protocol: "sixel" | "kitty";
102
+ widthPx: number;
103
+ heightPx: number;
104
+ columns: number;
105
+ rows: number;
106
+ /** terminal rows touched by the encoded raster, including pixel offset */
107
+ rasterRows: number;
108
+ }
109
+ /**
110
+ * Build overlay pixel frames exactly `targetRows` terminal rows tall when the
111
+ * terminal cells permit it. Nearest-neighbor sampling preserves the 16x16 art
112
+ * while allowing fractional scale factors such as 36px / 16px.
113
+ */
114
+ export declare function buildGajaePixelFrames(options: {
115
+ protocol: "sixel" | "kitty";
116
+ cellWidthPx: number;
117
+ cellHeightPx: number;
118
+ targetRows?: number;
119
+ /** Transparent pixel offset above sixel art for sub-cell vertical placement. */
120
+ sixelTopPaddingPx?: number;
121
+ /** Native sub-cell `Y=` pixel offset that drops the kitty sprite within its first cell. */
122
+ kittyCellYOffsetPx?: number;
123
+ kittyImageId?: number;
124
+ /** Color skin for the sprite palette (default "red"). */
125
+ skin?: PetSkinId;
126
+ }): GajaePixelFrames;
127
+ export {};
@@ -1,5 +1,6 @@
1
1
  import type { SymbolTheme } from "../symbols";
2
2
  import type { Component } from "../tui";
3
+ import { type ViewportAnchorSpan } from "../utils";
3
4
  /** Test-only clock seam for streaming throttle tests. */
4
5
  export declare function __setMarkdownNowForTest(now: (() => number) | undefined): void;
5
6
  /** Test/diagnostic seam: number of synchronous highlight invocations since the last reset. */
@@ -70,6 +71,14 @@ export declare class Markdown implements Component {
70
71
  dispose(): void;
71
72
  invalidate(): void;
72
73
  render(width: number): string[];
74
+ renderWithViewportAnchorSource(width: number, source: {
75
+ id: string;
76
+ }): {
77
+ lines: string[];
78
+ anchors: Array<({
79
+ id: string;
80
+ } & ViewportAnchorSpan) | null>;
81
+ };
73
82
  }
74
83
  /**
75
84
  * Render inline markdown (bold, italic, code, links, strikethrough) to a styled string.
@@ -1,4 +1,5 @@
1
1
  import type { Component } from "../tui";
2
+ import { type ViewportAnchorSpan } from "../utils";
2
3
  /**
3
4
  * Text component - displays multi-line text with word wrapping
4
5
  */
@@ -10,4 +11,12 @@ export declare class Text implements Component {
10
11
  setCustomBgFn(customBgFn?: (text: string) => string): void;
11
12
  invalidate(): void;
12
13
  render(width: number): string[];
14
+ renderWithViewportAnchorSource(width: number, source: {
15
+ id: string;
16
+ }): {
17
+ lines: string[];
18
+ anchors: Array<({
19
+ id: string;
20
+ } & ViewportAnchorSpan) | null>;
21
+ };
13
22
  }
@@ -3,6 +3,7 @@ export * from "./autocomplete";
3
3
  export * from "./components/box";
4
4
  export * from "./components/cancellable-loader";
5
5
  export * from "./components/editor";
6
+ export * from "./components/gajae-pet";
6
7
  export * from "./components/image";
7
8
  export * from "./components/input";
8
9
  export * from "./components/loader";
@@ -22,6 +22,27 @@ export declare class TerminalInfo {
22
22
  sendNotification(message: string): void;
23
23
  }
24
24
  export declare function isNotificationSuppressed(): boolean;
25
+ export interface TerminalGraphicsFallbackOptions {
26
+ /**
27
+ * Permit cursor-neutral image escapes (kitty `a=p,C=1` placements) to render
28
+ * inside this fallback scope. Cursor-advancing protocols (iTerm2/SIXEL)
29
+ * remain suppressed. A nested scope without this option revokes the
30
+ * permission for its own subtree.
31
+ */
32
+ allowCursorNeutralImages?: boolean;
33
+ }
34
+ /**
35
+ * Synchronously suppress terminal graphics while rendering a text-only surface.
36
+ * Nested scopes remain active until the outermost scope exits.
37
+ */
38
+ export declare function withTerminalGraphicsFallback<T>(fn: () => T, options?: TerminalGraphicsFallbackOptions): T;
39
+ /** Returns whether terminal graphics are currently suppressed by a render scope. */
40
+ export declare function isTerminalGraphicsFallbackActive(): boolean;
41
+ /**
42
+ * Returns whether cursor-neutral image escapes may render despite an active
43
+ * graphics-fallback scope. True only when every active fallback scope opted in.
44
+ */
45
+ export declare function isCursorNeutralImagePermittedInFallback(): boolean;
25
46
  /**
26
47
  * Returns true when running in Windows Terminal with known SIXEL support.
27
48
  *
@@ -57,6 +57,32 @@ export declare function isFocusable(component: Component | null): component is C
57
57
  */
58
58
  export declare const CURSOR_MARKER = "\u001B_pi:c\u0007";
59
59
  export { visibleWidth };
60
+ /** Durable source identifier for a semantically anchored viewport row. */
61
+ export type ViewportAnchorId = string;
62
+ export interface ViewportAnchorRow {
63
+ id: ViewportAnchorId;
64
+ graphemeStart: number;
65
+ graphemeEnd: number;
66
+ cellStart: number;
67
+ cellEnd: number;
68
+ }
69
+ export interface ViewportAnchorRender {
70
+ lines: string[];
71
+ anchors: Array<ViewportAnchorRow | null>;
72
+ }
73
+ export interface ViewportAnchorProvider extends Component {
74
+ renderWithViewportAnchors(width: number): ViewportAnchorRender;
75
+ }
76
+ export interface ViewportAnchorSource {
77
+ id: ViewportAnchorId;
78
+ }
79
+ export interface ViewportAnchorSourceRenderer extends Component {
80
+ renderWithViewportAnchorSource(width: number, source: ViewportAnchorSource): ViewportAnchorRender;
81
+ }
82
+ export declare function isViewportAnchorProvider(component: Component): component is ViewportAnchorProvider;
83
+ export declare function isViewportAnchorSourceRenderer(component: Component): component is ViewportAnchorSourceRenderer;
84
+ export declare function renderComponentWithViewportAnchors(component: Component, width: number): ViewportAnchorRender;
85
+ export declare function renderComponentWithViewportAnchorSource(component: Component, width: number, source: ViewportAnchorSource): ViewportAnchorRender;
60
86
  /**
61
87
  * Anchor position for overlays
62
88
  */
@@ -125,7 +151,7 @@ export interface OverlayHandle {
125
151
  /**
126
152
  * Container - a component that contains other components
127
153
  */
128
- export declare class Container implements Component {
154
+ export declare class Container implements ViewportAnchorProvider {
129
155
  #private;
130
156
  children: Component[];
131
157
  addChild(component: Component): void;
@@ -135,9 +161,12 @@ export declare class Container implements Component {
135
161
  clear(): void;
136
162
  /** Remove all children without disposing them (for detach-then-readd reuse). */
137
163
  detachAll(): void;
164
+ /** Registers a direct child as eligible for semantic viewport anchoring. */
165
+ setViewportAnchorSource(component: Component, source: ViewportAnchorSource | null): void;
138
166
  dispose(): void;
139
167
  invalidate(): void;
140
168
  render(width: number): string[];
169
+ renderWithViewportAnchors(width: number): ViewportAnchorRender;
141
170
  }
142
171
  type TuiRenderCounterSnapshot = {
143
172
  debugRedrawEnvReads: number;
@@ -174,6 +203,12 @@ export declare class TUI extends Container {
174
203
  setClearOnShrink(enabled: boolean): void;
175
204
  setFocus(component: Component | null): void;
176
205
  setBottomPinnedComponent(component: Component | null): void;
206
+ /** Register the direct child whose rows are eligible for semantic viewport anchoring. */
207
+ setViewportAnchorComponent(component: Component | null): void;
208
+ /** Clear manual viewport ownership before replacing the transcript identity namespace. */
209
+ resetViewportAnchorIntent(): void;
210
+ /** Allow one semantic-neighbor reconciliation after a definitive same-transcript rebuild. */
211
+ prepareViewportAnchorForTranscriptRebuild(): void;
177
212
  scrollViewportPages(direction: -1 | 1): boolean;
178
213
  followLiveViewport(): boolean;
179
214
  /**
@@ -212,4 +247,11 @@ export declare class TUI extends Container {
212
247
  normalizationLimit: number;
213
248
  truncationLimit: number;
214
249
  };
250
+ /**
251
+ * Register an emitter whose escape payload is appended to every render
252
+ * write (inside its own synchronized-output block, cursor saved/restored).
253
+ * Used for absolute-positioned overlays such as pixel-image pets that live
254
+ * outside the line-based component model. Return null to emit nothing.
255
+ */
256
+ setPostRenderEmitter(emitter: (() => string | null) | undefined): void;
215
257
  }
@@ -29,6 +29,29 @@ export declare function padding(n: number): string;
29
29
  * Get the shared grapheme segmenter instance.
30
30
  */
31
31
  export declare function getSegmenter(): Intl.Segmenter;
32
+ export interface ViewportAnchorSpan {
33
+ graphemeStart: number;
34
+ graphemeEnd: number;
35
+ cellStart: number;
36
+ cellEnd: number;
37
+ }
38
+ export interface ViewportAnchorAnnotation {
39
+ text: string;
40
+ nextGrapheme: number;
41
+ nextCell: number;
42
+ token: string;
43
+ }
44
+ export declare const VIEWPORT_ANCHOR_PREFIX = "\u001B_AGJC_ANCHOR:";
45
+ /**
46
+ * Tag every visible grapheme with an APC marker that survives ANSI-aware
47
+ * wrapping. The marker contains source grapheme and monotonic cell offsets.
48
+ */
49
+ export declare function annotateViewportAnchorGraphemes(text: string, startGrapheme?: number, startCell?: number, token?: `${string}-${string}-${string}-${string}-${string}`): ViewportAnchorAnnotation;
50
+ /** Remove viewport anchor markers and return the exact marked span for each row. */
51
+ export declare function extractViewportAnchorRows(lines: readonly string[], token: string): {
52
+ lines: string[];
53
+ spans: Array<ViewportAnchorSpan | null>;
54
+ };
32
55
  export declare function visibleWidthRaw(str: string): number;
33
56
  /**
34
57
  * Calculate the visible width of a string in terminal columns.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@gajae-code/tui",
4
- "version": "0.9.6",
4
+ "version": "0.10.0",
5
5
  "description": "Terminal User Interface library with differential rendering for efficient text-based applications",
6
6
  "homepage": "https://gajae-code.com",
7
7
  "author": "Yeachan-Heo and Gajae Code Contributors",
@@ -27,7 +27,7 @@
27
27
  "types": "./dist/types/index.d.ts",
28
28
  "scripts": {
29
29
  "check": "biome check . && bun run check:types",
30
- "check:types": "tsgo -p tsconfig.json --noEmit",
30
+ "check:types": "tsc -p tsconfig.json --noEmit",
31
31
  "lint": "biome lint .",
32
32
  "test": "bun test test/*.test.ts",
33
33
  "test:perf": "PI_TUI_PERF_GATES=1 bun test test/perf-gates.test.ts",
@@ -35,8 +35,8 @@
35
35
  "fmt": "biome format --write ."
36
36
  },
37
37
  "dependencies": {
38
- "@gajae-code/natives": "0.9.6",
39
- "@gajae-code/utils": "0.9.6",
38
+ "@gajae-code/natives": "0.10.0",
39
+ "@gajae-code/utils": "0.10.0",
40
40
  "lru-cache": "11.3.6",
41
41
  "marked": "^18.0.3"
42
42
  },