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
@@ -10,21 +10,8 @@
10
10
  // Imports
11
11
  // ═══════════════════════════════════════════════════════════════════════════════
12
12
 
13
- import {
14
- ProcessTerminal,
15
- TuiMainScreen,
16
- Editor,
17
- Text,
18
- Container,
19
- Spacer,
20
- matchesKey,
21
- Key,
22
- CombinedAutocompleteProvider,
23
- setKeybindings,
24
- KeybindingsManager,
25
- TUI_KEYBINDINGS,
26
- detectCapabilities,
27
- } from '@earendil-works/pi-tui';
13
+ import {Text} from './tui/components/text.js';
14
+ import {ProcessTerminal, TuiMainScreen, Editor, Container, Spacer, matchesKey, Key, CombinedAutocompleteProvider, setKeybindings, KeybindingsManager, TUI_KEYBINDINGS, detectCapabilities} from '@earendil-works/pi-tui';
28
15
  import type {Component, TUI} from '@earendil-works/pi-tui';
29
16
  import {
30
17
  c,
@@ -43,7 +30,7 @@ import {
43
30
  sanitizeTitle,
44
31
  formatMessageTimestamp,
45
32
  subagentStatusText,
46
- } from './utils/format.js';
33
+ } from '././tui/render/format.js';
47
34
  import {MessageBox} from './components/message-box.js';
48
35
  import {renderHistory} from './components/render-history.js';
49
36
  import {AssistantBody} from './components/assistant-body.js';
@@ -54,6 +41,7 @@ import {PermissionPrompt} from './components/permission-prompt.js';
54
41
  import {
55
42
  dequeueMessage,
56
43
  enqueueMessage,
44
+ nextEscAction,
57
45
  queuedStatusText,
58
46
  resetSessionTokenomics,
59
47
  setSessionTokenomics,
@@ -61,6 +49,7 @@ import {
61
49
  } from './state.js';
62
50
  import {Sidebar} from './components/sidebar.js';
63
51
  import {cmdHelp, cmdCost} from './commands.js';
52
+ import {autocompleteItems} from './slash-commands.js';
64
53
  import {
65
54
  loadUpdateCache,
66
55
  planStartupNotice,
@@ -95,6 +84,10 @@ import {
95
84
  PROVIDERS,
96
85
  loadCustomProviders,
97
86
  providerForModel,
87
+ saveKey,
88
+ getProvider,
89
+ detectProvider,
90
+ clearModelCache,
98
91
  clearTodos,
99
92
  resetShell,
100
93
  compactionBoundary,
@@ -130,7 +123,7 @@ import type {SessionStore as SessionStoreType} from '@pal-code/core';
130
123
  // (see buildModelOptions). Static curated lists live in @pal-code/core PROVIDERS as fallback.
131
124
 
132
125
  // Version synced from version.json via `node scripts/sync-version.js`.
133
- const VERSION = '0.0.16';
126
+ const VERSION = '0.0.18';
134
127
 
135
128
  // ── Canvas sync (OSC 10/11) ──
136
129
  // Raw reply payloads captured after a successful startup query + set, or null
@@ -153,9 +146,16 @@ function restoreCanvas(): void {
153
146
  }
154
147
 
155
148
  import {showModelSelector} from './overlays/model-picker.js';
149
+ import {showSelectOverlay} from './overlays/select.js';
156
150
  import {showKeyInput} from './overlays/key-input.js';
157
151
  import {runSetupWizard} from './overlays/wizard.js';
158
- import {agentLoop, ensureExtensionsLoaded, isReadOnlyPrimary} from './turn.js';
152
+ import {
153
+ ensureExtensionsLoaded,
154
+ isReadOnlyPrimary,
155
+ reloadExtensions,
156
+ runTurn as runAgentTurn,
157
+ } from '@pal-code/core';
158
+ import {approveTool, createTuiAgentUi} from './agent-ui.js';
159
159
 
160
160
  // ═══════════════════════════════════════════════════════════════════════════════
161
161
  // Main
@@ -169,6 +169,15 @@ async function main() {
169
169
  process.exit(0);
170
170
  }
171
171
 
172
+ // The desktop/web frontend is not part of the shipped build: `packages/ui` is
173
+ // private and `dist/` is excluded from the published package, so importing it
174
+ // from an installed copy cannot resolve. Report that in one line rather than
175
+ // surfacing a module-resolution stack trace.
176
+ if (flag === 'ui') {
177
+ console.error('pal ui is not available in this build.');
178
+ process.exit(1);
179
+ }
180
+
172
181
  // Anchor to the project root (where .pal.json lives) so that process.cwd()
173
182
  // reflects the user's project, not wherever the CLI package happens to be.
174
183
  const root = resolveProjectRoot();
@@ -360,11 +369,13 @@ async function main() {
360
369
  editorRow.addChild(roleIndicator); // hidden initially (empty text)
361
370
  editorRow.addChild(editor);
362
371
 
372
+ const agentUi = createTuiAgentUi(tui, messagesContainer);
373
+
363
374
  const sidebar = new Sidebar();
364
375
  // Fixed sidebar width used by both the overlay compositor and the transcript
365
376
  // layout. Both must agree — if the layout reserves N columns but the overlay
366
377
  // paints at M ≠ N, the sidebar overpaints transcript content.
367
- const SIDEBAR_WIDTH = 30;
378
+ const SIDEBAR_WIDTH = 34;
368
379
  const sidebarWidthFor = (w: number): number => {
369
380
  if (w < 70) return 0; // too narrow — hide the sidebar
370
381
  return SIDEBAR_WIDTH;
@@ -784,24 +795,7 @@ async function main() {
784
795
  // ── Autocomplete ──
785
796
  // ── Autocomplete ──
786
797
  editor.setAutocompleteProvider(
787
- new CombinedAutocompleteProvider(
788
- [
789
- {name: 'help', description: 'Show available commands'},
790
- {name: 'exit', description: 'Save session and quit'},
791
- {name: 'clear', description: 'Reset conversation'},
792
- {name: 'new', description: 'Start a new session'},
793
- {name: 'sessions', description: 'List recent sessions'},
794
- {name: 'resume', description: 'Load a previous session'},
795
- {name: 'cost', description: 'Show token usage and cost'},
796
- {name: 'model', description: 'Switch model'},
797
- {name: 'theme', description: 'Switch color theme (vanilla-pi, github-dark)'},
798
- {name: 'ext', description: 'Manage extensions'},
799
- {name: 'export', description: 'Export config to a versionable JSON file'},
800
- {name: 'import', description: 'Import config from an export file'},
801
- {name: 'roles', description: 'List agent roles'},
802
- ],
803
- process.cwd(),
804
- ),
798
+ new CombinedAutocompleteProvider(autocompleteItems(isDebugEnabled()), process.cwd()),
805
799
  );
806
800
 
807
801
  // ── Focus editor ──
@@ -848,8 +842,14 @@ async function main() {
848
842
  // settle). Empty at N=0, so the idle status line stays byte-identical.
849
843
  const queuedText = queuedStatusText(state.pendingMessages.length);
850
844
  const queuedStr = queuedText ? ` ${surface.statusLine.warn}${queuedText}${c.reset}` : '';
845
+ // Only meaningful while a turn is live; once it settles activeAbort is
846
+ // null and the prompt drops on the next repaint without extra wiring.
847
+ const abortStr =
848
+ state.abortArmed && state.activeAbort
849
+ ? ` ${surface.statusLine.warn}Esc again to stop${c.reset}`
850
+ : '';
851
851
  statusLine.setText(
852
- `${modelShort} ${surface.statusLine.dim}${providerName}${agentStr}${subStr}${queuedStr}${c.reset} ${surface.statusLine.dim}/help${c.reset}`,
852
+ `${modelShort} ${surface.statusLine.dim}${providerName}${agentStr}${subStr}${queuedStr}${abortStr}${c.reset} ${surface.statusLine.dim}/help${c.reset}`,
853
853
  );
854
854
  }
855
855
  // A copy flash outranks every other status for its 1500ms window, so a
@@ -861,6 +861,8 @@ async function main() {
861
861
  cachedTokens: state.sessionTokenomics.cachedTokens,
862
862
  cost: state.sessionTokenomics.cost,
863
863
  contextPct,
864
+ ctxTokens,
865
+ contextLimit: config.contextLimit,
864
866
  priced: isPricedModel(config.model),
865
867
  });
866
868
  tui.requestRender();
@@ -896,6 +898,7 @@ async function main() {
896
898
  // Re-read keys + rebuild the live provider after `/key` saves one, so it
897
899
  // takes effect without a restart.
898
900
  state.reloadKeys = () => {
901
+ clearModelCache();
899
902
  allKeys = resolveAllKeys();
900
903
  const {provider: modelDef} = providerForModel(config.model, Object.keys(allKeys));
901
904
  if (!providerAccessible(modelDef, allKeys)) {
@@ -1040,10 +1043,36 @@ async function main() {
1040
1043
  return false;
1041
1044
  }
1042
1045
 
1046
+ // Esc needs a second press to stop a run: the first arms a short window
1047
+ // instead of killing the turn, so a stray Esc mid-thought is harmless. Any
1048
+ // other key disarms, and the window closes itself so a forgotten arm cannot
1049
+ // turn the next Esc into an accidental kill.
1050
+ let abortArmTimer: ReturnType<typeof setTimeout> | null = null;
1051
+ const disarmAbort = (): void => {
1052
+ state.abortArmed = false;
1053
+ if (abortArmTimer) {
1054
+ clearTimeout(abortArmTimer);
1055
+ abortArmTimer = null;
1056
+ }
1057
+ };
1058
+ const armAbort = (): void => {
1059
+ disarmAbort();
1060
+ state.abortArmed = true;
1061
+ abortArmTimer = setTimeout(() => {
1062
+ state.abortArmed = false;
1063
+ abortArmTimer = null;
1064
+ updateStatusLine();
1065
+ }, 5000);
1066
+ };
1067
+
1043
1068
  // ── Exit handler: intercept raw Ctrl+C and Ctrl+D via input listener ──
1044
1069
  // pi-tui maps ctrl+c to "copy selection" and ctrl+d to "delete", so we
1045
1070
  // listen at the raw TUI level. On empty editor, these become exit signals.
1046
1071
  tui.addInputListener((data: string) => {
1072
+ if (state.abortArmed && !matchesKey(data, 'escape')) {
1073
+ disarmAbort();
1074
+ updateStatusLine();
1075
+ }
1047
1076
  if (matchesKey(data, 'ctrl+c') || matchesKey(data, 'ctrl+d')) {
1048
1077
  if (editor.getText().trim().length === 0) {
1049
1078
  saveSession();
@@ -1141,6 +1170,10 @@ async function main() {
1141
1170
  // Restore the editor
1142
1171
  editorRow.addChild(editor);
1143
1172
  tui.setFocus(editor);
1173
+ // Repaint the status line: the resolver already cleared
1174
+ // overlayMode/pendingPermission, but `requestRender` alone would leave
1175
+ // StatusLine's cached "🔒 Awaiting permission..." text on screen.
1176
+ state.refreshStatusLine();
1144
1177
  tui.requestRender();
1145
1178
  };
1146
1179
 
@@ -1178,10 +1211,16 @@ async function main() {
1178
1211
  cycleAgentRole();
1179
1212
  return {consume: true};
1180
1213
  }
1181
- // Esc aborts a running turn (keeps the session). Only active mid-turn —
1182
- // otherwise Esc falls through to the editor (autocomplete dismissal).
1214
+ // Esc stops a running turn (keeps the session) — but only on a confirmed
1215
+ // second press, so an accidental Esc never kills work in flight.
1183
1216
  if (matchesKey(data, 'escape') && state.activeAbort) {
1184
- state.activeAbort.abort();
1217
+ if (nextEscAction(state.abortArmed).abort) {
1218
+ disarmAbort();
1219
+ state.activeAbort.abort();
1220
+ } else {
1221
+ armAbort();
1222
+ }
1223
+ updateStatusLine();
1185
1224
  return {consume: true};
1186
1225
  }
1187
1226
  if (matchesKey(data, 'ctrl+b')) {
@@ -1325,7 +1364,7 @@ async function main() {
1325
1364
  // mode AND runs that task in the same go; `/execute` returns to the
1326
1365
  // orchestrator to implement what was planned.
1327
1366
  if (trimmed === '/plan' || trimmed.startsWith('/plan ')) {
1328
- await ensureExtensionsLoaded(config.extensions);
1367
+ await ensureExtensionsLoaded(config.extensions, agentUi, state.currentAgentRole);
1329
1368
  const arg = trimmed.slice('/plan'.length).trim();
1330
1369
 
1331
1370
  if (arg === 'off') {
@@ -1358,7 +1397,7 @@ async function main() {
1358
1397
  }
1359
1398
  }
1360
1399
  if (trimmed === '/execute' || trimmed.startsWith('/execute ')) {
1361
- await ensureExtensionsLoaded(config.extensions);
1400
+ await ensureExtensionsLoaded(config.extensions, agentUi, state.currentAgentRole);
1362
1401
  const arg = trimmed.slice('/execute'.length).trim();
1363
1402
  switchPrimary(defaultPrimaryName());
1364
1403
  if (arg) {
@@ -1390,8 +1429,11 @@ async function main() {
1390
1429
  if (trimmed === '/reload') {
1391
1430
  // Re-import extensions (cache-bust via timestamp query param).
1392
1431
  // Useful during extension development — no full restart needed.
1393
- const turnModule = await import('./turn.js');
1394
- const toolCount = await turnModule.reloadExtensions(config.extensions);
1432
+ const toolCount = await reloadExtensions(
1433
+ config.extensions,
1434
+ agentUi,
1435
+ state.currentAgentRole,
1436
+ );
1395
1437
  messagesContainer.addChild(
1396
1438
  new Text(`${c.green} Extensions reloaded (${toolCount} tools)${c.reset}`, 1, 0),
1397
1439
  );
@@ -1607,20 +1649,31 @@ async function main() {
1607
1649
  }
1608
1650
  if (trimmed === '/theme') {
1609
1651
  const active = activeTheme();
1610
- const lines = listThemes().map((name) =>
1611
- name === active.name
1612
- ? `${c.green} ● ${name}${c.reset} ${c.dim}(active)${c.reset}`
1613
- : ` ${c.dim}○ ${name}${c.reset}`,
1614
- );
1615
- messagesContainer.addChild(
1616
- new Text(
1617
- `${c.bold}Theme:${c.reset} ${active.displayName} ${c.dim}(${active.name})${c.reset}\n` +
1618
- `${lines.join('\n')}\n${c.dim}Switch with /theme <name>.${c.reset}`,
1619
- 1,
1620
- 0,
1621
- ),
1652
+ showSelectOverlay(
1653
+ {
1654
+ title: 'Select theme',
1655
+ items: listThemes().map((name) => ({
1656
+ value: name,
1657
+ label: name,
1658
+ description: name === active.name ? 'active' : undefined,
1659
+ })),
1660
+ selectedValue: active.name,
1661
+ height: 10,
1662
+ onSelect: (item) => {
1663
+ if (!setTheme(item.value)) return;
1664
+ saveSetting('theme', item.value);
1665
+ messagesContainer.addChild(
1666
+ new Text(`${c.green} ✓ theme: ${item.value} (saved)${c.reset}`, 1, 0),
1667
+ );
1668
+ messagesContainer.invalidate();
1669
+ editorRow.invalidate();
1670
+ state.refreshStatusLine();
1671
+ refreshSidebar();
1672
+ tui.requestRender();
1673
+ },
1674
+ },
1675
+ {container: messagesContainer, editor, editorRow, tui},
1622
1676
  );
1623
- tui.requestRender();
1624
1677
  return;
1625
1678
  }
1626
1679
  if (trimmed.startsWith('/theme ')) {
@@ -1676,6 +1729,32 @@ async function main() {
1676
1729
  tui.requestRender();
1677
1730
  return;
1678
1731
  }
1732
+ if (trimmed === '/rotation' || trimmed.startsWith('/rotation ')) {
1733
+ const arg = trimmed.slice('/rotation'.length).trim().toLowerCase();
1734
+ const explicit =
1735
+ arg === 'on' || arg === 'true' || arg === 'enable' || arg === '1'
1736
+ ? true
1737
+ : arg === 'off' || arg === 'false' || arg === 'disable' || arg === '0'
1738
+ ? false
1739
+ : null;
1740
+ const enabled = explicit ?? !config.modelRotation;
1741
+ config.modelRotation = enabled;
1742
+ saveSetting('modelRotation', enabled);
1743
+ messagesContainer.addChild(
1744
+ new Text(
1745
+ `${c.green} ✓ Model rotation ${enabled ? 'enabled' : 'disabled'}${c.reset} ${c.dim}${
1746
+ enabled
1747
+ ? '— failing turns switch to the next available model/provider.'
1748
+ : `— failing turns stay on ${config.model}.`
1749
+ }${c.reset}`,
1750
+ 1,
1751
+ 0,
1752
+ ),
1753
+ );
1754
+ state.refreshStatusLine();
1755
+ tui.requestRender();
1756
+ return;
1757
+ }
1679
1758
  if (trimmed === '/keys') {
1680
1759
  const keys = resolveAllKeys();
1681
1760
  const lines = PROVIDERS.map((p) => {
@@ -1696,6 +1775,35 @@ async function main() {
1696
1775
  showKeyInput(config, messagesContainer, editor, editorRow, tui);
1697
1776
  return;
1698
1777
  }
1778
+ if (trimmed.startsWith('/key ')) {
1779
+ const rest = trimmed.slice('/key '.length).trim();
1780
+ const [first, ...remaining] = rest.split(/\s+/);
1781
+ const named = getProvider(first);
1782
+ const rawKey = named ? remaining.join(' ') : rest;
1783
+ if (!rawKey) {
1784
+ showKeyInput(config, messagesContainer, editor, editorRow, tui);
1785
+ return;
1786
+ }
1787
+ const def = named ?? detectProvider(rawKey);
1788
+ if (!def) {
1789
+ messagesContainer.addChild(
1790
+ new Text(
1791
+ `${c.red} Could not detect a provider for that key.${c.reset}\n${c.dim} Use /key <provider-id> <key>, e.g. /key zen sk-ot-...${c.reset}`,
1792
+ 1,
1793
+ 0,
1794
+ ),
1795
+ );
1796
+ tui.requestRender();
1797
+ return;
1798
+ }
1799
+ saveKey(def.id, rawKey);
1800
+ if (state.reloadKeys) state.reloadKeys();
1801
+ messagesContainer.addChild(
1802
+ new Text(`${c.green} ✓ ${def.name} key saved — active now${c.reset}`, 1, 0),
1803
+ );
1804
+ tui.requestRender();
1805
+ return;
1806
+ }
1699
1807
  if (trimmed === '/ext' || trimmed.startsWith('/ext ')) {
1700
1808
  const args = trimmed.slice('/ext'.length).trim();
1701
1809
  const parts = args.split(/\s+/);
@@ -1726,8 +1834,14 @@ async function main() {
1726
1834
  } else if (sub === 'list') {
1727
1835
  const extensions = state.extensions;
1728
1836
  const lines = extensions.map((ext) => {
1729
- const status = ext.active ? `${c.green}active${c.reset}` : `${c.red}failed${c.reset}`;
1730
- return ` ${ext.name.padEnd(24)} ${status}`;
1837
+ const status =
1838
+ ext.status === 'active'
1839
+ ? `${c.green}active${c.reset}`
1840
+ : ext.status === 'failed'
1841
+ ? `${c.red}failed${c.reset}`
1842
+ : `${c.dim}inactive${c.reset}`;
1843
+ const detail = ext.reason ? ` ${c.dim}— ${ext.reason}${c.reset}` : '';
1844
+ return ` ${ext.name.padEnd(24)} ${status}${detail}`;
1731
1845
  });
1732
1846
  if (lines.length === 0) {
1733
1847
  const {emptyListMessage} = await import('./commands/ext-registry.js');
@@ -1964,19 +2078,20 @@ async function main() {
1964
2078
  .map((r) => `[messages ${r.fromSeq}-${r.toSeq}]\n${r.summary}`)
1965
2079
  .join('\n\n');
1966
2080
  }
1967
- const result = await agentLoop(
2081
+ const result = await runAgentTurn(
1968
2082
  message,
1969
2083
  messages,
1970
2084
  config,
1971
- tui,
1972
- messagesContainer,
1973
2085
  allKeys,
1974
2086
  createProvider,
2087
+ agentUi,
2088
+ approveTool,
1975
2089
  state.currentAgentRole,
1976
2090
  // Resume from the persisted high-water mark so an already-summarized
1977
2091
  // prefix is neither re-sent nor re-summarized.
1978
2092
  store && currentSessionId ? store.getCompactedUpto(currentSessionId) : 0,
1979
2093
  resumedNote,
2094
+ state.activeAbort?.signal,
1980
2095
  );
1981
2096
  answered = true;
1982
2097
  if (state.activeRun) {
@@ -2006,12 +2121,22 @@ async function main() {
2006
2121
  // `boundary` is a whole-history COUNT; the store speaks in 1-based seqs,
2007
2122
  // and a rolled-back earlier turn can shift them apart, so convert through
2008
2123
  // the same helper the agent uses instead of assuming they're equal.
2009
- if (result.compaction && store && currentSessionId) {
2010
- const from = store.getCompactedUpto(currentSessionId);
2011
- const to = seqToCount(result.compaction.boundary, messages.length);
2012
- if (to > from) {
2013
- store.recordCompaction(currentSessionId, from, to, result.compaction.summary);
2124
+ if (result.compactions.length > 0) {
2125
+ for (const rec of result.compactions) {
2126
+ const from = store && currentSessionId ? store.getCompactedUpto(currentSessionId) : 0;
2127
+ const to = seqToCount(rec.boundary, messages.length);
2128
+ if (store && currentSessionId && to > from) {
2129
+ store.recordCompaction(currentSessionId, from, to, rec.summary);
2130
+ }
2131
+ messagesContainer.addChild(
2132
+ new Text(
2133
+ `${c.green}✓ Context compacted${c.reset} ${c.dim}· ${rec.summarized} messages summarized into a checkpoint (messages ${from + 1}–${to})${c.reset}`,
2134
+ 1,
2135
+ 0,
2136
+ ),
2137
+ );
2014
2138
  }
2139
+ tui.requestRender();
2015
2140
  }
2016
2141
  } catch (err) {
2017
2142
  const msg = err instanceof Error ? err.message : String(err);
@@ -2104,7 +2229,7 @@ async function main() {
2104
2229
  tui.start();
2105
2230
 
2106
2231
  // Load extensions in the background — fast startup, ready before first message.
2107
- ensureExtensionsLoaded(config.extensions).catch(() => {});
2232
+ ensureExtensionsLoaded(config.extensions, agentUi, state.currentAgentRole).catch(() => {});
2108
2233
 
2109
2234
  // Initialize session store AFTER tui starts (bun:sqlite import must not run before pi-tui stdin setup)
2110
2235
  const {SessionStore} = await import('@pal-code/core');