pal-code 0.0.16 → 0.0.18

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 (40) hide show
  1. package/README.md +9 -6
  2. package/SYSTEM.md +17 -2
  3. package/package.json +10 -5
  4. package/packages/cli/src/agent-panel.ts +1 -1
  5. package/packages/cli/src/agent-ui.ts +66 -0
  6. package/packages/cli/src/commands/ext-registry.ts +7 -0
  7. package/packages/cli/src/commands.ts +32 -102
  8. package/packages/cli/src/components/assistant-body.ts +4 -3
  9. package/packages/cli/src/components/message-box.ts +2 -2
  10. package/packages/cli/src/components/permission-prompt.ts +3 -3
  11. package/packages/cli/src/components/render-history.ts +13 -12
  12. package/packages/cli/src/components/run-view.ts +109 -33
  13. package/packages/cli/src/components/sidebar.ts +81 -14
  14. package/packages/cli/src/components/status-line.ts +3 -3
  15. package/packages/cli/src/config.ts +6 -129
  16. package/packages/cli/src/index.ts +194 -69
  17. package/packages/cli/src/overlays/key-input.ts +142 -121
  18. package/packages/cli/src/overlays/model-picker.ts +19 -56
  19. package/packages/cli/src/overlays/select.ts +102 -0
  20. package/packages/cli/src/overlays/session-picker.ts +14 -40
  21. package/packages/cli/src/overlays/wizard.ts +107 -42
  22. package/packages/cli/src/prompt/select.ts +181 -0
  23. package/packages/cli/src/slash-commands.ts +105 -0
  24. package/packages/cli/src/state.ts +32 -74
  25. package/packages/cli/src/theme.ts +13 -1
  26. package/packages/cli/src/themes/github-dark.ts +14 -3
  27. package/packages/cli/src/themes/types.ts +26 -2
  28. package/packages/cli/src/themes/vanilla-pi.ts +23 -9
  29. package/packages/cli/src/tui/components/text.ts +102 -0
  30. package/packages/cli/src/tui/render/code-block.ts +325 -0
  31. package/packages/cli/src/{utils → tui/render}/format.ts +31 -24
  32. package/packages/cli/src/{utils → tui/render}/highlight.ts +94 -2
  33. package/packages/cli/src/tui/render/markdown.ts +529 -0
  34. package/packages/cli/src/tui/surface/index.ts +9 -0
  35. package/packages/cli/src/tui/{paint-panel.ts → surface/paint-panel.ts} +1 -1
  36. package/packages/cli/src/tui/theme-types.ts +59 -0
  37. package/packages/cli/src/tui/tty-width.ts +20 -0
  38. package/packages/cli/src/tui/types.ts +53 -0
  39. package/packages/cli/src/turn.ts +0 -292
  40. package/packages/cli/src/utils/code-block.ts +0 -200
package/README.md CHANGED
@@ -50,8 +50,8 @@ bun add -g pal-code
50
50
  pal
51
51
  ```
52
52
 
53
- On first launch, pal-code runs a short setup wizard. Pick a provider and paste an API
54
- key (or press Enter for a keyless provider like OpenCode Zen).
53
+ On first launch, pal-code runs a short setup wizard. Pick a provider (OpenCode Zen
54
+ included) and paste an API key.
55
55
 
56
56
  ## Features
57
57
 
@@ -60,8 +60,8 @@ key (or press Enter for a keyless provider like OpenCode Zen).
60
60
  - **Tool use** — read/write/edit files, run shell commands, grep/glob/ast-grep
61
61
  search, repo maps, `verify`, and `delegate` sub-agents.
62
62
  - **BYOK provider registry** with key-shape detection, live `/models` fetching,
63
- curated fallback model lists, and retry/backoff with quota-vs-rate-limit-aware
64
- fallback switching.
63
+ curated fallback model lists, and retry/backoff. Model rotation on failure is
64
+ opt-in (`/rotation`), with quota-vs-rate-limit-aware switching.
65
65
  - **Safety & context** — `.pal.json` ignore patterns, file-size limits, file
66
66
  snapshots for `/undo`, context compaction, and secret-redacting debug logs.
67
67
  - **Sessions** — SQLite-backed (`bun:sqlite`) with resume via `/sessions` or
@@ -96,11 +96,13 @@ MCP config is stored in `~/.pal/mcp.json` (user-level) or `./mcp.json` (project-
96
96
  API keys are resolved from (in order):
97
97
 
98
98
  1. Environment variables — `DEEPSEEK_API_KEY`, `GEMINI_API_KEY`,
99
- `OPENROUTER_API_KEY`, `ZEN_API_KEY`, `OPENAI_API_KEY`, `GROQ_API_KEY`,
99
+ `OPENROUTER_API_KEY`, `OPENCODE_API_KEY`, `OPENAI_API_KEY`, `GROQ_API_KEY`,
100
100
  `XAI_API_KEY`, `MISTRAL_API_KEY`.
101
101
  2. `~/.pal/config.json` — `{ "keys": { "<provider>": "<key>" } }`.
102
102
 
103
- Keyless providers are opted into by setting `"keyless": "<provider-id>"`.
103
+ Custom providers in `~/.pal/providers.json` can opt into keyless access with
104
+ `keyOptional: true`; set `"keyless": "<provider-id>"` to select one. A real key
105
+ saved for that provider always takes precedence and clears the keyless flag.
104
106
 
105
107
  Non-key settings can also live in `~/.pal/config.json` — for example
106
108
  `"model"`, `"systemPrompt"`, `"extensions"`, and `"contextLimit"`. A
@@ -130,6 +132,7 @@ All user data lives in `~/.pal/`:
130
132
  | `/model NAME` | Set a model directly |
131
133
  | `/key` | Set an API key interactively |
132
134
  | `/keys` | Show configured keys |
135
+ | `/rotation [on\|off]` | Toggle automatic model switching on failure |
133
136
  | `/sessions` / `/resume ID` | List / resume sessions |
134
137
  | `/snapshots` / `/undo [id]` | Restore a pre-edit file |
135
138
  | `/compact` | Compress conversation context |
package/SYSTEM.md CHANGED
@@ -89,8 +89,11 @@ runWithFallback → decides which model, retries, backoff (core)
89
89
  └─ runAgent → drives that model to completion (core)
90
90
  ```
91
91
 
92
- - **Same provider first** (same rate-limit pool), then other configured
93
- providers — the candidate list is built from each provider's live `/models`,
92
+ - **Rotation is opt-in** (`rotate`; `/rotation on`). By default the selected
93
+ model is retried and the turn reports the failure — it never switches models
94
+ silently.
95
+ - **When enabled** — same provider first (same rate-limit pool), then other
96
+ configured providers. Candidates come from each provider's live `/models`,
94
97
  never from invented names.
95
98
  - **Quota exhausted** → switch immediately (retrying only burns RPM).
96
99
  - **Rate limited** → exponential backoff, `maxRetries` attempts, then switch.
@@ -139,6 +142,18 @@ bun test # run the test suite
139
142
  bunx tsc --noEmit # typecheck
140
143
  ```
141
144
 
145
+ ### List selection
146
+
147
+ Any flow that asks the user to pick from a list uses a filterable arrow-key
148
+ selector, never a numbered text prompt:
149
+
150
+ - Inside the TUI: `packages/cli/src/overlays/select.ts` (`showSelectOverlay`,
151
+ built on pi-tui's `SelectList`).
152
+ - Before the TUI exists: `packages/cli/src/prompt/select.ts` (`promptSelect`,
153
+ raw stdin + ANSI, no pi-tui).
154
+
155
+ Piped/non-TTY runs fall back to numbered input.
156
+
142
157
  ## See also
143
158
 
144
159
  - [`README.md`](./README.md) — what pal is, install, commands
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pal-code",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "A terminal coding agent with BYOK, tool use, and extensions",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -31,7 +31,7 @@
31
31
  "dev": "cd packages/cli && bun src/index.ts",
32
32
  "test": "bun test",
33
33
  "eval": "bun run evals/run.ts",
34
- "typecheck": "bunx tsc --noEmit",
34
+ "typecheck": "bunx tsc --noEmit && bun run --cwd packages/ui web:typecheck",
35
35
  "lint": "biome check .",
36
36
  "lint:fix": "biome check --write .",
37
37
  "format": "biome format --write .",
@@ -42,11 +42,14 @@
42
42
  "build:linux-x64": "bun build --compile packages/cli/src/index.ts --target=bun-linux-x64 --outfile dist/pal-linux-x64",
43
43
  "build:linux-arm64": "bun build --compile packages/cli/src/index.ts --target=bun-linux-arm64 --outfile dist/pal-linux-arm64",
44
44
  "build:windows-x64": "bun build --compile packages/cli/src/index.ts --target=bun-windows-x64 --outfile dist/pal-windows-x64.exe",
45
- "publish:all": "npm run publish:core && npm publish && npm run publish:web-search && npm run publish:agents && npm run publish:mcp",
45
+ "publish:all": "npm run publish:core && npm publish && npm run publish:web-search && npm run publish:agents && npm run publish:mcp && npm run publish:jev && npm run publish:memory && npm run publish:workflow",
46
46
  "publish:core": "cd packages/core && npm publish",
47
47
  "publish:web-search": "cd packages/web-search && npm publish",
48
48
  "publish:agents": "cd packages/agents && npm publish",
49
49
  "publish:mcp": "cd packages/mcp && npm publish",
50
+ "publish:jev": "cd packages/jev && npm publish",
51
+ "publish:memory": "cd packages/memory && npm publish",
52
+ "publish:workflow": "cd packages/workflow && npm publish",
50
53
  "prepublishOnly": "node scripts/sync-version.js"
51
54
  },
52
55
  "keywords": [
@@ -62,8 +65,10 @@
62
65
  "gemini"
63
66
  ],
64
67
  "dependencies": {
65
- "@pal-code/core": "0.0.16",
66
- "@earendil-works/pi-tui": "^0.85.1"
68
+ "@pal-code/core": "0.0.18",
69
+ "@earendil-works/pi-tui": "^0.85.1",
70
+ "get-east-asian-width": "1.6.0",
71
+ "marked": "^18.1.3"
67
72
  },
68
73
  "devDependencies": {
69
74
  "@biomejs/biome": "^2.5.13",
@@ -5,7 +5,7 @@
5
5
  * (delegate-start, delegate-done) that are hidden from the main transcript.
6
6
  */
7
7
 
8
- import {Text} from '@earendil-works/pi-tui';
8
+ import {Text} from './tui/components/text.js';
9
9
  import type {TUI, Container, Component} from '@earendil-works/pi-tui';
10
10
  import {c} from './theme.js';
11
11
  import {state} from './state.js';
@@ -0,0 +1,66 @@
1
+ /**
2
+ * TUI adapter for core's `AgentUi` port. This is the only place the turn
3
+ * orchestrator touches RunView and the sidebar-facing app state.
4
+ */
5
+
6
+ import type {AgentUi, Approval} from '@pal-code/core';
7
+ import type {Container, TUI} from '@earendil-works/pi-tui';
8
+
9
+ import {RunView} from './components/run-view.js';
10
+ import {state} from './state.js';
11
+ import {checkToolPermission} from './utils/permissions.js';
12
+
13
+ export function createTuiAgentUi(tui: TUI, container: Container): AgentUi {
14
+ let run: RunView | null = null;
15
+
16
+ return {
17
+ startRun(model) {
18
+ run = new RunView(container, tui, model);
19
+ state.activeRun = run;
20
+ },
21
+ setModel(model) {
22
+ run?.setModel(model);
23
+ },
24
+ beginRound(round, max) {
25
+ run?.beginRound(round, max);
26
+ },
27
+ text(delta) {
28
+ run?.streamText(delta);
29
+ },
30
+ thinking(delta) {
31
+ run?.streamThinking(delta);
32
+ },
33
+ toolStart(id, name, argsSummary) {
34
+ run?.addTool(id, name, argsSummary);
35
+ },
36
+ toolEnd(id, ok, content) {
37
+ run?.endTool(id, ok, content);
38
+ },
39
+ notice(text) {
40
+ run?.notice(text);
41
+ },
42
+ aborted() {
43
+ run?.aborted();
44
+ },
45
+ extensions(extensions) {
46
+ state.extensions = extensions;
47
+ },
48
+ mcpServers(servers) {
49
+ state.mcpServers = servers;
50
+ },
51
+ primary(name) {
52
+ state.currentAgentRole = name;
53
+ },
54
+ ready() {
55
+ state.refreshSidebar();
56
+ state.refreshStatusLine();
57
+ state.refreshRoleIndicator();
58
+ },
59
+ };
60
+ }
61
+
62
+ /** Route core's approval request through the TUI permission gate. */
63
+ export const approveTool: Approval = async (toolName, args) => {
64
+ const decision = await checkToolPermission(toolName, args);
65
+ return decision.allowed ? 'allow' : 'deny';
66
+ };
@@ -40,6 +40,13 @@ export const REGISTRY: ExtRegistryEntry[] = [
40
40
  package: '@pal-code/mcp',
41
41
  tags: ['mcp', 'model context protocol', 'server', 'bridge', 'integrations'],
42
42
  },
43
+ {
44
+ name: 'Memory',
45
+ description:
46
+ 'Repo knowledge the agent reads before re-exploring: schemas, playbooks, past runs',
47
+ package: '@pal-code/memory',
48
+ tags: ['memory', 'knowledge', 'schema', 'playbook', 'context', 'notes', 'handoff'],
49
+ },
43
50
  ];
44
51
 
45
52
  /** ANSI codes used when rendering the browse list (omit for plain text). */
@@ -5,26 +5,46 @@
5
5
  * and requests a render. No engine logic lives here.
6
6
  */
7
7
 
8
- import {Text} from '@earendil-works/pi-tui';
8
+ import {Text} from './tui/components/text.js';
9
9
  import type {TUI, Container} from '@earendil-works/pi-tui';
10
10
 
11
11
  import {c} from './theme.js';
12
12
  import {formatTokens, formatCost} from './utils/cost.js';
13
13
  import {isDebugEnabled} from '@pal-code/core';
14
+ import {visibleCommands} from './slash-commands.js';
14
15
 
15
16
  export function cmdHelp(container: Container, tui: TUI): void {
17
+ const commands = visibleCommands(isDebugEnabled());
18
+ const labels = commands.map((cmd) => `/${cmd.name}${cmd.usage ? ` ${cmd.usage}` : ''}`);
19
+ const labelWidth = Math.max(...labels.map((label) => label.length)) + 2;
20
+ const detailWidth =
21
+ Math.max(
22
+ 0,
23
+ ...commands.flatMap((cmd) =>
24
+ (cmd.details ?? []).map((detail) => `/${cmd.name} ${detail.usage}`.length),
25
+ ),
26
+ ) + 2;
27
+
16
28
  container.addChild(new Text('', 0, 0));
17
29
  container.addChild(new Text(` ${c.bold}Available commands:${c.reset}`, 1, 0));
18
- container.addChild(new Text(` ${c.cyan}/help${c.reset} Show this help message`, 1, 0));
19
- container.addChild(new Text(` ${c.cyan}/exit${c.reset} Save session and quit`, 1, 0));
20
- container.addChild(new Text(` ${c.cyan}/new${c.reset} Start a new session`, 1, 0));
21
- container.addChild(new Text(` ${c.cyan}/sessions${c.reset} List recent sessions`, 1, 0));
22
- container.addChild(
23
- new Text(` ${c.cyan}/undo${c.reset} Restore the file from your last edit`, 1, 0),
24
- );
25
- container.addChild(
26
- new Text(` ${c.cyan}/snapshots${c.reset} List recent file snapshots`, 1, 0),
27
- );
30
+ for (const [i, cmd] of commands.entries()) {
31
+ container.addChild(
32
+ new Text(` ${c.cyan}${labels[i].padEnd(labelWidth)}${c.reset}${cmd.description}`, 1, 0),
33
+ );
34
+ for (const detail of cmd.details ?? []) {
35
+ const prefix = `/${cmd.name} ${detail.usage}`;
36
+ container.addChild(
37
+ new Text(
38
+ ` ${c.cyan}${prefix.padEnd(detailWidth)}${c.reset}${detail.description}`,
39
+ 1,
40
+ 0,
41
+ ),
42
+ );
43
+ }
44
+ }
45
+
46
+ container.addChild(new Text('', 0, 0));
47
+ container.addChild(new Text(` ${c.bold}Keys:${c.reset}`, 1, 0));
28
48
  container.addChild(
29
49
  new Text(` ${c.cyan}ctrl+b${c.reset} Toggle background agent panel`, 1, 0),
30
50
  );
@@ -32,97 +52,7 @@ export function cmdHelp(container: Container, tui: TUI): void {
32
52
  container.addChild(
33
53
  new Text(` ${c.cyan}esc${c.reset} Interrupt the running turn`, 1, 0),
34
54
  );
35
- container.addChild(new Text(` ${c.cyan}/resume ID${c.reset} Load a previous session`, 1, 0));
36
- container.addChild(
37
- new Text(` ${c.cyan}/cost${c.reset} Show token usage and estimated cost`, 1, 0),
38
- );
39
- container.addChild(
40
- new Text(
41
- ` ${c.cyan}/model${c.reset} Open model selector (arrow keys + type to filter)`,
42
- 1,
43
- 0,
44
- ),
45
- );
46
- container.addChild(new Text(` ${c.cyan}/model NAME${c.reset} Set model directly`, 1, 0));
47
- container.addChild(
48
- new Text(` ${c.cyan}/key${c.reset} Set API key interactively`, 1, 0),
49
- );
50
- container.addChild(
51
- new Text(
52
- ` ${c.cyan}/export${c.reset} [file] Export config to JSON (secrets excluded)`,
53
- 1,
54
- 0,
55
- ),
56
- );
57
- container.addChild(
58
- new Text(` ${c.cyan}/import${c.reset} <file> Merge an export (local API keys kept)`, 1, 0),
59
- );
60
- container.addChild(
61
- new Text(` ${c.cyan}/roles${c.reset} List agent roles (agents extension)`, 1, 0),
62
- );
63
- container.addChild(
64
- new Text(
65
- ` ${c.cyan}/plan${c.reset} [task] Enter read-only plan mode (Tab also cycles)`,
66
- 1,
67
- 0,
68
- ),
69
- );
70
- container.addChild(
71
- new Text(` ${c.cyan}/execute${c.reset} Leave plan mode and implement`, 1, 0),
72
- );
73
- container.addChild(
74
- new Text(` ${c.cyan}/ext add${c.reset} <pkg> Install an extension from npm`, 1, 0),
75
- );
76
- container.addChild(
77
- new Text(` ${c.cyan}/ext remove${c.reset} <pkg> Remove an extension`, 1, 0),
78
- );
79
- container.addChild(
80
- new Text(
81
- ` ${c.cyan}/ext search${c.reset} <q> Search the npm registry for extensions`,
82
- 1,
83
- 0,
84
- ),
85
- );
86
- container.addChild(
87
- new Text(` ${c.cyan}/ext list${c.reset} List loaded extensions`, 1, 0),
88
- );
89
- container.addChild(
90
- new Text(` ${c.cyan}/ext browse${c.reset} Browse curated extensions`, 1, 0),
91
- );
92
- container.addChild(
93
- new Text(` ${c.cyan}/mcp add${c.reset} <name> <cmd> [args] Add a local MCP server`, 1, 0),
94
- );
95
- container.addChild(
96
- new Text(` ${c.cyan}/mcp add-remote${c.reset} <name> <url> Add a remote MCP server`, 1, 0),
97
- );
98
- container.addChild(
99
- new Text(` ${c.cyan}/mcp remove${c.reset} <name> Remove an MCP server`, 1, 0),
100
- );
101
- container.addChild(new Text(` ${c.cyan}/mcp list${c.reset} List MCP servers`, 1, 0));
102
- container.addChild(
103
- new Text(` ${c.cyan}/mcp browse${c.reset} Browse curated MCP servers`, 1, 0),
104
- );
105
- container.addChild(
106
- new Text(` ${c.cyan}/mcp search${c.reset} <q> Search curated MCP servers`, 1, 0),
107
- );
108
- container.addChild(
109
- new Text(` ${c.cyan}/permission${c.reset} Show permission rules and whitelist`, 1, 0),
110
- );
111
- container.addChild(
112
- new Text(
113
- ` ${c.cyan}/copy${c.reset} [code] Copy last reply (or code block) to clipboard`,
114
- 1,
115
- 0,
116
- ),
117
- );
118
- if (isDebugEnabled()) {
119
- container.addChild(
120
- new Text(` ${c.cyan}/reload${c.reset} Hot-reload extensions (dev)`, 1, 0),
121
- );
122
- container.addChild(
123
- new Text(` ${c.cyan}/restart${c.reset} Restart pal (saves session first)`, 1, 0),
124
- );
125
- }
55
+
126
56
  container.addChild(new Text('', 0, 0));
127
57
  container.addChild(new Text(` ${c.bold}Scroll transcript:${c.reset}`, 1, 0));
128
58
  container.addChild(
@@ -13,7 +13,8 @@
13
13
  * through `setHovered`/`setSuccess`, never sampled from input devices.
14
14
  */
15
15
 
16
- import {Markdown, type Component} from '@earendil-works/pi-tui';
16
+ import {Markdown} from '../tui/render/markdown.js';
17
+ import type {Component} from '../tui/types.js';
17
18
 
18
19
  import {markdownTheme} from '../theme.js';
19
20
  import {
@@ -22,8 +23,8 @@ import {
22
23
  COPY_LABEL,
23
24
  parseCodeSegments,
24
25
  SUCCESS_LABEL,
25
- } from '../utils/code-block.js';
26
- import type {CodeSegment} from '../utils/code-block.js';
26
+ } from '../tui/render/code-block.js';
27
+ import type {CodeSegment} from '../tui/render/code-block.js';
27
28
 
28
29
  type BodySegment =
29
30
  | {readonly kind: 'text'; readonly md: Markdown}
@@ -6,9 +6,9 @@
6
6
  * messages instead of leaving them at their submit-time width.
7
7
  */
8
8
 
9
- import type {Component} from '@earendil-works/pi-tui';
9
+ import type {Component} from '../tui/types.js';
10
10
 
11
- import {userMessageBox} from '../utils/format.js';
11
+ import {userMessageBox} from '../tui/render/format.js';
12
12
  import type {AgentRole} from '../state.js';
13
13
 
14
14
  export class MessageBox implements Component {
@@ -10,8 +10,8 @@
10
10
  * the permission; this component is purely visual.
11
11
  */
12
12
 
13
- import {visibleWidth} from '@earendil-works/pi-tui';
14
- import type {Component} from '@earendil-works/pi-tui';
13
+ import {visibleWidth} from '../tui/tty-width.js';
14
+ import type {Component} from '../tui/types.js';
15
15
 
16
16
  import {c, surface} from '../theme.js';
17
17
  import {state} from '../state.js';
@@ -22,7 +22,7 @@ const ANSI_RE = new RegExp('\x1b\\[[0-9;]*m', 'g');
22
22
  /** Repeat a character `n` times. */
23
23
  const rep = (ch: string, n: number): string => ch.repeat(Math.max(0, n));
24
24
 
25
- /** Visible width of a string (delegates to pi-tui's ANSI-aware helper). */
25
+ /** Visible width of a string in terminal columns. */
26
26
  const vw = (s: string): number => visibleWidth(s);
27
27
 
28
28
  export class PermissionPrompt implements Component {
@@ -10,13 +10,15 @@
10
10
  * than replaying hundreds of blocks at once.
11
11
  */
12
12
 
13
- import {type Container, Text} from '@earendil-works/pi-tui';
13
+ import {Text} from '../tui/components/text.js';
14
+ import {type Container} from '@earendil-works/pi-tui';
14
15
  import type {StoredMessage, CompactionRecord} from '@pal-code/core';
15
16
 
16
- import {c} from '../theme.js';
17
+ import {c, surface} from '../theme.js';
17
18
  import {AssistantBody} from './assistant-body.js';
18
19
  import {MessageBox} from './message-box.js';
19
- import {formatMessageTimestamp} from '../utils/format.js';
20
+ import {toolRowText, formatThinkingBlock} from './run-view.js';
21
+ import {formatMessageTimestamp} from '../tui/render/format.js';
20
22
  import type {AgentRole} from '../state.js';
21
23
 
22
24
  /** How many of the most recent messages to render initially. */
@@ -85,23 +87,22 @@ function renderMessage(container: Container, m: StoredMessage): void {
85
87
  const icon = m.meta.toolStatus === 'error' ? `${c.red}✗${c.reset}` : `${c.green}✓${c.reset}`;
86
88
  const name = m.meta.toolName ?? 'tool';
87
89
  const firstLine = (m.content || '').split('\n').find((l) => l.trim()) ?? '';
88
- container.addChild(
89
- new Text(
90
- ` ${icon} ${c.dim}${name}${c.reset} ${c.dim}→ ${truncate(firstLine.trim(), 80)}${c.reset}`,
91
- 1,
92
- 0,
93
- ),
94
- );
90
+ const preview = firstLine.trim();
91
+ const tail = preview ? ` ${surface.runView.preview}→ ${truncate(preview, 80)}${c.reset}` : '';
92
+ container.addChild(new Text(`${toolRowText(icon, '', name, '')}${tail}`, 1, 0));
95
93
  return;
96
94
  }
97
95
 
98
- // assistant (with or without tool calls) — prose plus boxed code fences
96
+ // assistant (with or without tool calls) — dim thinking first, then prose plus boxed code fences
97
+ if (m.meta.thinking) {
98
+ container.addChild(new Text(formatThinkingBlock(m.meta.thinking, m.meta.thinkingMs ?? 0), 1, 0));
99
+ }
99
100
  if (m.content && m.content.trim()) {
100
101
  container.addChild(new AssistantBody(m.content));
101
102
  }
102
103
  if (m.toolCalls?.length) {
103
104
  for (const tc of m.toolCalls) {
104
- container.addChild(new Text(` ${c.cyan}⛭${c.reset} ${c.dim}${tc.name}${c.reset}`, 1, 0));
105
+ container.addChild(new Text(toolRowText(`${c.cyan}⛭${c.reset}`, '', tc.name, ''), 1, 0));
105
106
  }
106
107
  }
107
108
  }