dsh-code 0.6.1 → 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.
Files changed (56) hide show
  1. package/README.en.md +20 -6
  2. package/README.md +20 -6
  3. package/lib/index.mjs +3952 -1315
  4. package/lib/startup.mjs +21 -9
  5. package/lib/theme-BEi4i_aN.mjs +624 -0
  6. package/lib/types/app.d.ts +108 -4
  7. package/lib/types/history.d.ts +15 -4
  8. package/lib/types/index.d.ts +49 -0
  9. package/lib/types/kernel-panels.d.ts +28 -0
  10. package/lib/types/mentions.d.ts +29 -12
  11. package/lib/types/models.d.ts +66 -0
  12. package/lib/types/permissions.d.ts +37 -0
  13. package/lib/types/presets.d.ts +2 -0
  14. package/lib/types/provider-settings.d.ts +144 -0
  15. package/lib/types/questions.d.ts +2 -0
  16. package/lib/types/render/animations.d.ts +177 -2
  17. package/lib/types/render/lines.d.ts +6 -0
  18. package/lib/types/render/markdown.d.ts +3 -3
  19. package/lib/types/render/projection.d.ts +123 -3
  20. package/lib/types/render/status.d.ts +35 -24
  21. package/lib/types/render/text.d.ts +14 -7
  22. package/lib/types/render/tool-detail.d.ts +3 -1
  23. package/lib/types/render/tool-preview.d.ts +4 -1
  24. package/lib/types/session-directory.d.ts +15 -0
  25. package/lib/types/startup.d.ts +12 -4
  26. package/lib/types/store.d.ts +13 -2
  27. package/lib/types/theme-panel.d.ts +24 -0
  28. package/lib/types/theme.d.ts +158 -2
  29. package/lib/types/version.d.ts +5 -0
  30. package/package.json +1 -1
  31. package/src/app.ts +1283 -206
  32. package/src/approval.ts +11 -2
  33. package/src/history.ts +20 -5
  34. package/src/index.ts +1207 -905
  35. package/src/kernel-panels.ts +518 -419
  36. package/src/mentions.ts +57 -27
  37. package/src/models.ts +200 -66
  38. package/src/permissions.ts +85 -0
  39. package/src/presets.ts +12 -0
  40. package/src/provider-settings.ts +520 -0
  41. package/src/questions.ts +15 -5
  42. package/src/render/animations.ts +373 -2
  43. package/src/render/lines.ts +21 -6
  44. package/src/render/markdown.ts +302 -4
  45. package/src/render/projection.ts +1419 -659
  46. package/src/render/status.ts +650 -603
  47. package/src/render/text.ts +28 -9
  48. package/src/render/tool-detail.ts +81 -40
  49. package/src/render/tool-preview.ts +18 -2
  50. package/src/session-directory.ts +44 -5
  51. package/src/skills.ts +8 -4
  52. package/src/startup.ts +119 -109
  53. package/src/store.ts +26 -8
  54. package/src/theme-panel.ts +72 -0
  55. package/src/theme.ts +206 -70
  56. package/src/version.ts +16 -0
@@ -3,12 +3,22 @@
3
3
  * the StateDot "ongoing" pixel chase (3×3 ring, 125ms flat-hold brightness
4
4
  * steps, 1s cycle) becomes the single-cell stepped pulse below and the
5
5
  * full-ring clockwise braille chase in {@link BUSY_CHASE_FRAMES}, and the
6
- * streaming caret blink is the Claude-Code convention. Pure functions only —
7
- * the Ink layer owns timers and colors.
6
+ * streaming caret blink is the Claude-Code convention.
7
+ *
8
+ * The DeepSeek model-switch easter egg ports Codex's effort-ignition "Wave"
9
+ * style (`codex-rs/tui/src/bottom_pane/effort_ignition_styles.rs`): switching
10
+ * INTO an official DeepSeek route sweeps a blue wave across the composer's
11
+ * input row — one column per cell, `backgroundColor` = the sampled wave
12
+ * color — then, on the deepseek (Ultra-equivalent) tier, drops the `· ✦ ✧`
13
+ * sparkle sequence into the rightmost blank cell before fading. The prompt
14
+ * marker keeps the tier accent afterwards (persistent, like Codex's prompt
15
+ * charge). Pure functions only — the Ink layer owns timers and colors.
8
16
  *
9
17
  * @module @deepseek-ai/dsh-code/render/animations
10
18
  */
11
19
 
20
+ import type { RgbTriple } from '../theme.ts'
21
+
12
22
  /** Single-cell stepped pulse: flat holds mirroring the web's 125ms keyframes. */
13
23
  export const PULSE_FRAMES = ['█', '█', '▆', '▃', '▁', '▃', '▆', '█'] as const
14
24
 
@@ -33,3 +43,364 @@ export function busyChaseFrame(tick: number): string {
33
43
  export function caretVisible(tick: number): boolean {
34
44
  return tick % 2 === 0
35
45
  }
46
+
47
+ /**
48
+ * The one-shot DeepSeek model-switch easter egg: when the status bar model
49
+ * label switches to an official DeepSeek route, the composer's input row
50
+ * plays Codex's effort-ignition "Wave" — a blue crest sweeping the content
51
+ * row column by column (background tint ≤ 0.55 under the draft), plus the
52
+ * Ultra-style `· ✦ ✧` sparkles on the deepseek tier — and the prompt marker
53
+ * keeps the tier accent afterwards. The Ink layer owns the timer and reads
54
+ * the ACTIVE palette anchors (`getPalette`); everything below is pure
55
+ * interpolation over the colors it is given.
56
+ */
57
+
58
+ /** Frame cadence of the DeepSeek wave: Codex's IGNITION_FRAME_TICK (33ms ≈ 30fps). */
59
+ export const DEEPSEEK_WAVE_TICK_MS = 33
60
+
61
+ /**
62
+ * The two DeepSeek wave tiers. The concept maps Codex's reasoning tiers to
63
+ * model ids: `flash` runs the Max parameters, `deepseek` (pro models) runs
64
+ * the Ultra parameters (dual band + tail sparkles on the Wave style).
65
+ */
66
+ export type DeepseekWaveTier = 'flash' | 'deepseek'
67
+
68
+ /**
69
+ * The three ignition styles — Codex `IgnitionStyle`: a traveling crest
70
+ * (Wave), a drifting multi-hue band (Aurora), and an expanding ring (Pulse).
71
+ * One style is picked at random per trigger and never repeats the previous.
72
+ */
73
+ export type DeepseekWaveStyle = 'wave' | 'aurora' | 'pulse'
74
+
75
+ /** All styles in canonical order, for random selection and tests. */
76
+ export const DEEPSEEK_WAVE_STYLES: readonly DeepseekWaveStyle[] = ['wave', 'aurora', 'pulse']
77
+
78
+ /** Wave half-width in columns — Codex WAVE_HALF_WIDTH (9). */
79
+ export const WAVE_HALF_WIDTH = 9
80
+
81
+ /** Pulse ring half-width in columns — Codex PULSE_HALF_WIDTH (4.5). */
82
+ export const PULSE_HALF_WIDTH = 4.5
83
+
84
+ /** Sparkle start and frame cadence — Codex SPARK_START / SPARK_FRAME. */
85
+ export const SPARK_START_MS = 900
86
+ export const SPARK_FRAME_MS = 100
87
+
88
+ /** Sparkle glyphs in frame order — Codex SPARK_GLYPHS (`· ✦ ✧`). */
89
+ export const SPARK_GLYPHS = ['·', '✦', '✧'] as const
90
+
91
+ /**
92
+ * Band tables — Codex `bands(style, tier)`. Each entry is a triple whose
93
+ * meaning depends on the style: Wave/Pulse use `(launch, travel, strength)`;
94
+ * Aurora uses `(speed, phase, hueIndex)`.
95
+ */
96
+ export type DeepseekWaveBand = readonly [number, number, number]
97
+ export const DEEPSEEK_WAVE_BANDS: Readonly<Record<DeepseekWaveStyle, Readonly<Record<DeepseekWaveTier, readonly DeepseekWaveBand[]>>>> = {
98
+ wave: {
99
+ // Wave-Max: one band sweeping 0.10s..0.85s.
100
+ flash: [[0.10, 0.75, 1.0]],
101
+ // Wave-Ultra: two offset bands for a richer crest.
102
+ deepseek: [[0.10, 0.70, 1.0], [0.35, 0.55, 1.0]],
103
+ },
104
+ aurora: {
105
+ // Aurora-Max: two drifting bands (hues 0 and 1).
106
+ flash: [[0.35, 0.15, 0.0], [-0.50, 0.60, 1.0]],
107
+ // Aurora-Ultra: a third band adds hue 2.
108
+ deepseek: [[0.35, 0.15, 0.0], [-0.50, 0.60, 1.0], [0.75, 0.35, 2.0]],
109
+ },
110
+ pulse: {
111
+ // Pulse-Max: one expanding ring.
112
+ flash: [[0.10, 0.60, 1.0]],
113
+ // Pulse-Ultra: two rings (inner weaker, outer stronger).
114
+ deepseek: [[0.10, 0.55, 0.8], [0.45, 0.55, 1.1]],
115
+ },
116
+ }
117
+
118
+ /** Extra display time applied to every Codex ignition style. */
119
+ export const DEEPSEEK_WAVE_DURATION_EXTENSION_MS = 200
120
+
121
+ /** Original Codex duration used as the animation's sampling timeline. */
122
+ function deepseekWaveBaseDuration(tier: DeepseekWaveTier, style: DeepseekWaveStyle): number {
123
+ switch (style) {
124
+ case 'aurora': return tier === 'flash' ? 1300 : 1600
125
+ case 'pulse': return tier === 'flash' ? 900 : 1250
126
+ case 'wave': return tier === 'flash' ? 1000 : 1300
127
+ }
128
+ }
129
+
130
+ /**
131
+ * Total visible duration: the Codex ignition duration plus 200ms so its motion
132
+ * remains readable in a busy terminal.
133
+ * @param tier - the active wave tier.
134
+ * @param style - the active ignition style.
135
+ * @returns the duration in milliseconds.
136
+ */
137
+ export function deepseekWaveDuration(tier: DeepseekWaveTier, style: DeepseekWaveStyle = 'wave'): number {
138
+ return deepseekWaveBaseDuration(tier, style) + DEEPSEEK_WAVE_DURATION_EXTENSION_MS
139
+ }
140
+
141
+ /** Map the extended display timeline back onto the original Codex samples. */
142
+ function deepseekWaveSampleElapsedMs(tick: number, tier: DeepseekWaveTier, style: DeepseekWaveStyle): number {
143
+ const base = deepseekWaveBaseDuration(tier, style)
144
+ return tick * DEEPSEEK_WAVE_TICK_MS * base / deepseekWaveDuration(tier, style)
145
+ }
146
+
147
+ /**
148
+ * Pick one ignition style at random, never repeating the previous one —
149
+ * Codex `IgnitionStyle::random`. Falls back to the remaining styles.
150
+ * @param previous - the style of the last trigger, if any.
151
+ * @returns a style different from `previous`.
152
+ */
153
+ export function deepseekWaveStyleRandom(previous: DeepseekWaveStyle | undefined): DeepseekWaveStyle {
154
+ const candidates = DEEPSEEK_WAVE_STYLES.filter(style => style !== previous)
155
+ return candidates[Math.floor(Math.random() * candidates.length)] ?? 'wave'
156
+ }
157
+
158
+ /**
159
+ * Blank-cell background the wave tint blends toward — fixed approximations
160
+ * of the terminal's default background, mirroring Codex's
161
+ * `user_message_bg_rgb` (which derives a near-black / near-white bubble tint
162
+ * from the terminal background). The Ink layer picks the active theme's one.
163
+ */
164
+ export const WAVE_BASE_DARK: RgbTriple = [16, 18, 24]
165
+ export const WAVE_BASE_LIGHT: RgbTriple = [242, 244, 248]
166
+
167
+ /**
168
+ * Tier for a `provider/model` label: a model id containing `flash` runs the
169
+ * single-band flash tier; everything else (pro/reasoner/chat) runs the
170
+ * dual-band deepseek tier. Mirrors Codex's Max→Ultra mapping.
171
+ * @param model - the `provider/model` label of the applied model.
172
+ * @returns the wave tier for that model.
173
+ */
174
+ export function deepseekWaveTier(model: string): DeepseekWaveTier {
175
+ return model.toLowerCase().includes('flash') ? 'flash' : 'deepseek'
176
+ }
177
+
178
+ /**
179
+ * Cosine window — Codex `crest`: 1 exactly under the wave center, 0 from
180
+ * one half-width away.
181
+ * @param distance - distance from the crest center in half-widths.
182
+ * @returns the crest strength in 0..1.
183
+ */
184
+ export function crest(distance: number): number {
185
+ if (distance >= 1) return 0
186
+ return 0.5 * (1 + Math.cos(Math.PI * distance))
187
+ }
188
+
189
+ /**
190
+ * Cubic ease-in-out — Codex `ease_in_out`: flat at both ends, steepest in
191
+ * the middle, so the crest accelerates and eases instead of sliding linearly.
192
+ * @param progress - raw progress (clamped to 0..1).
193
+ * @returns the eased progress in 0..1.
194
+ */
195
+ export function easeInOut(progress: number): number {
196
+ const p = Math.min(1, Math.max(0, progress))
197
+ if (p < 0.5) return 4 * p * p * p
198
+ const inverse = -2 * p + 2
199
+ return 1 - (inverse * inverse * inverse) / 2
200
+ }
201
+
202
+ /**
203
+ * Fade-in/fade-out envelope — Codex `envelope`: linear ramp over `fadeIn`
204
+ * at the start and `fadeOut` at the end, plateau at 1 between, 0 outside the
205
+ * total. The Wave style keeps the envelope at 1 (Codex paints Wave without
206
+ * an envelope); exported for the Aurora-style fades and for tests.
207
+ * @param elapsed - seconds since the animation started.
208
+ * @param total - total duration in seconds.
209
+ * @param fadeIn - seconds of fade-in.
210
+ * @param fadeOut - seconds of fade-out.
211
+ * @returns the envelope value in 0..1.
212
+ */
213
+ export function envelope(elapsed: number, total: number, fadeIn: number, fadeOut: number): number {
214
+ if (elapsed <= 0 || elapsed >= total) return 0
215
+ const rise = elapsed / Math.max(fadeIn, Number.EPSILON)
216
+ const fall = (total - elapsed) / Math.max(fadeOut, Number.EPSILON)
217
+ return Math.min(Math.max(Math.min(rise, fall), 0), 1)
218
+ }
219
+
220
+ /**
221
+ * One band's contribution at a column — Codex `band_sample`, all three
222
+ * branches: Wave sweeps an eased crest across the row; Aurora drifts a
223
+ * sinusoidal center carrying a hue index; Pulse expands a ring from the row
224
+ * center with cubic ease and decaying strength.
225
+ * @param style - the ignition style.
226
+ * @param band - the band triple (meaning depends on the style).
227
+ * @param elapsed - seconds since the animation started.
228
+ * @param column - column index in the content row (0..width-1).
229
+ * @param width - content-row width in columns.
230
+ * @returns `[hueIndex, strength]`.
231
+ */
232
+ function bandSample(
233
+ style: DeepseekWaveStyle,
234
+ band: DeepseekWaveBand,
235
+ elapsed: number,
236
+ column: number,
237
+ width: number,
238
+ ): [number, number] {
239
+ const [first, second, third] = band
240
+ switch (style) {
241
+ case 'wave': {
242
+ const progress = (elapsed - first) / second
243
+ if (progress < 0 || progress > 1) return [0, 0]
244
+ const center = easeInOut(progress) * (width + 2 * WAVE_HALF_WIDTH) - WAVE_HALF_WIDTH
245
+ return [0, crest(Math.abs(column - center) / WAVE_HALF_WIDTH)]
246
+ }
247
+ case 'aurora': {
248
+ const center = (0.5 + 0.38 * Math.sin(Math.PI * 2 * (first * elapsed + second))) * width
249
+ const halfWidth = Math.max(width * 0.22, 4)
250
+ return [Math.trunc(third), crest(Math.abs(column - center) / halfWidth)]
251
+ }
252
+ case 'pulse': {
253
+ const progress = (elapsed - first) / second
254
+ if (progress < 0 || progress > 1) return [0, 0]
255
+ const inverse = 1 - progress
256
+ const radius = (1 - inverse * inverse * inverse) * (width / 2 + 2 * PULSE_HALF_WIDTH)
257
+ const distance = Math.abs(column - width / 2)
258
+ return [0, crest(Math.abs(distance - radius) / PULSE_HALF_WIDTH) * third * (1 - 0.6 * progress)]
259
+ }
260
+ }
261
+ }
262
+
263
+ /** Linear RGB blend — Codex `blend`: `fg * alpha + bg * (1 - alpha)`. */
264
+ function blendRgb(fg: RgbTriple, bg: RgbTriple, alpha: number): RgbTriple {
265
+ return [
266
+ Math.round(fg[0] * alpha + bg[0] * (1 - alpha)),
267
+ Math.round(fg[1] * alpha + bg[1] * (1 - alpha)),
268
+ Math.round(fg[2] * alpha + bg[2] * (1 - alpha)),
269
+ ]
270
+ }
271
+
272
+ /**
273
+ * The background color for one composer-row column at a tick — Codex
274
+ * `paint_bands` + `Canvas::tint` for all three styles. Bands overlap with a
275
+ * max for Wave/Pulse and a SUM for Aurora (Codex differs by style), the
276
+ * weighted hues mix per column (Wave/Pulse always end on hue 0), the tint
277
+ * blends the mixed hue toward the blank-cell base at the style's alpha cap,
278
+ * and Aurora applies its own fade envelope. Returns `null` when the column
279
+ * should stay transparent, so the row returns to no `backgroundColor` on
280
+ * both ends.
281
+ * @param tick - wave frame (0, 1, … at DEEPSEEK_WAVE_TICK_MS).
282
+ * @param column - column index in the content row (0..width-1).
283
+ * @param width - content-row width in columns.
284
+ * @param tier - the wave tier (flash = Max, deepseek = Ultra parameters).
285
+ * @param style - the ignition style.
286
+ * @param hues - the tier's three hues.
287
+ * @param base - the blank-cell base color the tint blends toward.
288
+ * @returns the blended RGB background, or null for transparent.
289
+ */
290
+ export function deepseekWaveColumnBg(
291
+ tick: number,
292
+ column: number,
293
+ width: number,
294
+ tier: DeepseekWaveTier,
295
+ style: DeepseekWaveStyle,
296
+ hues: readonly [RgbTriple, RgbTriple, RgbTriple],
297
+ base: RgbTriple,
298
+ ): RgbTriple | null {
299
+ const total = deepseekWaveBaseDuration(tier, style) / 1000
300
+ const elapsed = deepseekWaveSampleElapsedMs(tick, tier, style) / 1000
301
+ const fade = style === 'aurora' ? envelope(elapsed, total, 0.25, 0.40) : 1
302
+ const weights = [0, 0, 0]
303
+ for (const band of DEEPSEEK_WAVE_BANDS[style][tier]) {
304
+ const [hue, strength] = bandSample(style, band, elapsed, column, width)
305
+ weights[hue] = style === 'aurora' ? weights[hue]! + strength : Math.max(weights[hue]!, strength)
306
+ }
307
+ const weight = weights[0]! + weights[1]! + weights[2]!
308
+ if (weight <= 0.01) return null
309
+ let red = 0
310
+ let green = 0
311
+ let blue = 0
312
+ for (let index = 0; index < 3; index += 1) {
313
+ red += weights[index]! * hues[index]![0]
314
+ green += weights[index]! * hues[index]![1]
315
+ blue += weights[index]! * hues[index]![2]
316
+ }
317
+ const mixed: RgbTriple = [
318
+ Math.round(red / weight),
319
+ Math.round(green / weight),
320
+ Math.round(blue / weight),
321
+ ]
322
+ const alpha = style === 'aurora' ? Math.min(weight * 0.40, 0.50) * fade : weight * 0.55
323
+ if (alpha < 0.02) return null
324
+ return blendRgb(mixed, base, alpha)
325
+ }
326
+
327
+ /**
328
+ * The sparkle glyph for a tick — Codex `spark_frame`, sampled on the same
329
+ * proportionally slowed DeepSeek Wave timeline as the composer background.
330
+ * The Ink layer still must skip occupied cells.
331
+ * @param tick - wave frame at DEEPSEEK_WAVE_TICK_MS.
332
+ * @returns the sparkle glyph, or null outside the stretched tail window.
333
+ */
334
+ export function deepseekWaveSpark(tick: number): string | null {
335
+ const elapsed = deepseekWaveSampleElapsedMs(tick, 'deepseek', 'wave')
336
+ if (elapsed < SPARK_START_MS) return null
337
+ const frame = Math.floor((elapsed - SPARK_START_MS) / SPARK_FRAME_MS)
338
+ return SPARK_GLYPHS[frame] ?? null
339
+ }
340
+
341
+ /**
342
+ * The composer BORDER color at a tick: the frame breathes with the wave —
343
+ * the palette's static dim blends toward the tier accent as the crest is
344
+ * alive and back, so the frame glows up while the wave sweeps and settles to
345
+ * dim on both ends (first==last frame==dim, no hard jump).
346
+ * @param tick - wave frame at DEEPSEEK_WAVE_TICK_MS.
347
+ * @param tier - the wave tier.
348
+ * @param hues - the tier's three hues; the border blends toward hues[0].
349
+ * @param dim - the palette's static dim RGB (the resting border color).
350
+ * @returns the blended border RGB.
351
+ */
352
+ export function deepseekWaveBorderColor(
353
+ tick: number,
354
+ tier: DeepseekWaveTier,
355
+ style: DeepseekWaveStyle,
356
+ hues: readonly [RgbTriple, RgbTriple, RgbTriple],
357
+ dim: RgbTriple,
358
+ ): RgbTriple {
359
+ const total = deepseekWaveBaseDuration(tier, style) / 1000
360
+ const elapsed = deepseekWaveSampleElapsedMs(tick, tier, style) / 1000
361
+ // The border stays visibly on the tier accent for the whole sweep (a
362
+ // floor keeps it glowing, not just cresting mid-wave): it ramps in as the
363
+ // first band launches and relaxes after the last crest passes.
364
+ const glow = envelope(elapsed, total, total * 0.25, total * 0.4)
365
+ return blendRgb(hues[0], dim, 0.25 + glow * 0.6)
366
+ }
367
+
368
+ /**
369
+ * Whether the `deepseek` wordmark rides the wave at this tick: it fades in
370
+ * shortly after the first crest launches and out before the wave settles,
371
+ * so the brand name surfaces through the sweep's middle. The Ink layer
372
+ * places it in the row's blank mid-section (never over real draft text).
373
+ * @param tick - wave frame at DEEPSEEK_WAVE_TICK_MS.
374
+ * @param tier - the wave tier.
375
+ * @returns true while the wordmark should be visible.
376
+ */
377
+ export function deepseekWaveWordVisible(tick: number, tier: DeepseekWaveTier, style: DeepseekWaveStyle = 'wave'): boolean {
378
+ const total = deepseekWaveBaseDuration(tier, style) / 1000
379
+ const elapsed = deepseekWaveSampleElapsedMs(tick, tier, style) / 1000
380
+ return envelope(elapsed, total, total * 0.2, total * 0.35) > 0.25
381
+ }
382
+
383
+ /**
384
+ * The per-character color for the `deepseek` wordmark: the tier's hues
385
+ * cycled per character (d→hue0, e→hue1, e→hue2, …), a brand-gradient text.
386
+ * @param index - character index in the wordmark.
387
+ * @param hues - the tier's three hues.
388
+ * @returns the hue for that character.
389
+ */
390
+ export function deepseekWaveWordHue(index: number, hues: readonly [RgbTriple, RgbTriple, RgbTriple]): RgbTriple {
391
+ return hues[index % hues.length]!
392
+ }
393
+
394
+ /**
395
+ * True when a `provider/model` status label addresses the official DeepSeek
396
+ * route: either segment contains `deepseek` (case-insensitive), covering the
397
+ * `deepseek-official` provider route and its `deepseek-*` model ids.
398
+ * @param label - the status bar model label (`provider/model`).
399
+ * @returns whether the label names an official DeepSeek model.
400
+ */
401
+ export function isOfficialDeepSeekLabel(label: string): boolean {
402
+ const slash = label.indexOf('/')
403
+ const provider = slash < 0 ? label : label.slice(0, slash)
404
+ const model = slash < 0 ? '' : label.slice(slash + 1)
405
+ return provider.toLowerCase().includes('deepseek') || model.toLowerCase().includes('deepseek')
406
+ }
@@ -83,6 +83,26 @@ export function markdownLines(text: string, columns: number): readonly StyledLin
83
83
  ))
84
84
  }
85
85
 
86
+ /**
87
+ * Codex-style reasoning rows: the marker occupies the reply gutter and every
88
+ * wrapped or explicit continuation starts with the same two-column indent, so
89
+ * reasoning content and assistant Markdown share one left edge.
90
+ */
91
+ export function reasoningLines(text: string, columns: number): readonly StyledLine[] {
92
+ const width = Math.max(1, Math.floor(columns))
93
+ if (width < 3) return textLines(text, width, 'dimItalic')
94
+ const contentWidth = width - 2
95
+ const content = displayText(text).replaceAll('\t', ' ').replaceAll('\r', '')
96
+ .split('\n')
97
+ .flatMap(line => styledLines([lineSegment(line, 'dimItalic')], contentWidth))
98
+ return content.map((line, index) => ({
99
+ segments: [
100
+ lineSegment(index === 0 ? '✻ ' : ' ', 'dimItalic'),
101
+ ...line.segments,
102
+ ],
103
+ }))
104
+ }
105
+
86
106
  /** Expanded structured tool detail as scrollable, width-safe rows. */
87
107
  function toolDetailLines(detail: ToolDetail, columns: number): readonly StyledLine[] {
88
108
  switch (detail.kind) {
@@ -151,12 +171,7 @@ export function transcriptEntryLines(entry: TranscriptEntry, columns: number): r
151
171
  lineSegment(entry.text, 'plain'),
152
172
  ], width)
153
173
  case 'assistant': {
154
- const reasoning = entry.reasoning === ''
155
- ? []
156
- : styledLines([
157
- lineSegment(' ✻ ', 'dimItalic'),
158
- lineSegment(entry.reasoning, 'dimItalic'),
159
- ], width)
174
+ const reasoning = entry.reasoning === '' ? [] : reasoningLines(entry.reasoning, width)
160
175
  // Every reply row carries the composer's two-column gutter, so reply
161
176
  // text aligns with the input cursor (Codex LIVE_PREFIX alignment); the
162
177
  // wrap budget shrinks by the same amount so no line double-wraps.