clarity-ai 5.1.0 → 6.1.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/bin/clarity.js CHANGED
@@ -5,6 +5,9 @@ import { App } from '../src/app.js';
5
5
  import { hasKey } from '../src/config/keys.js';
6
6
  import { createInterface } from 'readline';
7
7
 
8
+ // Full terminal reset: clear screen, reset cursor, reset scrollback
9
+ process.stdout.write('\x1Bc\x1b[2J\x1b[0f\x1b[?25h');
10
+
8
11
  async function main() {
9
12
  const provider = process.env.CLARITY_PROVIDER || 'groq';
10
13
 
@@ -18,13 +21,32 @@ async function main() {
18
21
  });
19
22
  const { setKey } = await import('../src/config/keys.js');
20
23
  setKey(provider, key);
24
+ // Re-clear after key prompt
25
+ process.stdout.write('\x1Bc\x1b[2J\x1b[0f');
21
26
  }
22
27
 
23
28
  const config = { provider, model: process.env.CLARITY_MODEL || 'groq/llama-3.3-70b-versatile' };
24
- render(React.createElement(App, { config }), { fullscreen: true });
29
+
30
+ const { waitUntilExit } = render(React.createElement(App, { config }), { fullscreen: true });
31
+
32
+ // Cleanup handlers
33
+ function cleanup() {
34
+ process.stdout.write('\x1Bc\x1b[?25h\x1b[0m');
35
+ process.exit(0);
36
+ }
37
+
38
+ process.on('SIGINT', cleanup);
39
+ process.on('SIGTERM', cleanup);
40
+ process.on('exit', () => {
41
+ process.stdout.write('\x1Bc\x1b[?25h\x1b[0m');
42
+ });
43
+
44
+ await waitUntilExit;
45
+ cleanup();
25
46
  }
26
47
 
27
48
  main().catch(err => {
49
+ process.stdout.write('\x1Bc\x1b[?25h\x1b[0m');
28
50
  console.error('\n\x1b[31mFatal error:\x1b[0m', err.message);
29
51
  process.exit(1);
30
52
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "clarity-ai",
3
- "version": "5.1.0",
4
- "description": "Premium OpenCode-style terminal AI agent — streaming, tools, multiline composer, virtual scroll, code blocks",
3
+ "version": "6.1.0",
4
+ "description": "Premium OpenCode-style terminal AI agent — 24-bit TrueColor theme, 8s timeout recovery, virtual scroll, inline tool trees, collapsible thought cards",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "clarity": "bin/clarity.js"
@@ -15,11 +15,17 @@
15
15
  "dependencies": {
16
16
  "ink": "^5",
17
17
  "react": "^18",
18
- "ink-text-input": "^6.0.0",
19
18
  "ink-spinner": "^5",
20
19
  "ink-big-text": "^2",
21
20
  "ink-gradient": "^3",
22
21
  "marked": "^12",
23
- "cli-highlight": "^2"
22
+ "cli-highlight": "^2",
23
+ "chalk": "^5",
24
+ "ansi-escapes": "^7",
25
+ "cli-cursor": "^5",
26
+ "wrap-ansi": "^9",
27
+ "strip-ansi": "^7",
28
+ "string-width": "^7",
29
+ "picocolors": "^1"
24
30
  }
25
31
  }
package/src/app.js CHANGED
@@ -1,4 +1,4 @@
1
- import React, { useState, useCallback } from 'react';
1
+ import React, { useState, useCallback, useRef, useEffect } from 'react';
2
2
  import { Box } from 'ink';
3
3
  import { Banner } from './components/Banner.js';
4
4
  import { MessageList } from './components/MessageList.js';
@@ -6,6 +6,7 @@ import { Composer } from './components/Composer.js';
6
6
  import { CommandPicker } from './components/CommandPicker.js';
7
7
  import { ModelPicker } from './components/ModelPicker.js';
8
8
  import { createChatState, handleSend, handleCommand } from './chat.js';
9
+ import { theme } from './config/theme.js';
9
10
  const { createElement: h } = React;
10
11
 
11
12
  export function App({ config }) {
@@ -18,16 +19,24 @@ export function App({ config }) {
18
19
  const [showModels, setShowModels] = useState(false);
19
20
  const [showBanner, setShowBanner] = useState(true);
20
21
 
22
+ // Use refs to avoid stale closures in callbacks
23
+ const stateRef = useRef(state);
24
+ const modelRef = useRef(model);
25
+ const providerRef = useRef(provider);
26
+ stateRef.current = state;
27
+ modelRef.current = model;
28
+ providerRef.current = provider;
29
+
21
30
  const onSubmit = useCallback(async (input) => {
22
31
  if (input.startsWith('/')) {
23
32
  if (input === '/model' || input === '/models') { setShowModels(true); return; }
24
33
  if (input === '/help') { setShowCommands(true); return; }
25
- await handleCommand(input, state, setState, setModel, setProvider, model, provider);
34
+ await handleCommand(input, stateRef.current, setState, setModel, setProvider, modelRef.current, providerRef.current);
26
35
  return;
27
36
  }
28
37
  if (showBanner) setShowBanner(false);
29
- await handleSend(state, setState, input, model, provider, setStreamContent);
30
- }, [state, model, provider, showBanner]);
38
+ await handleSend(stateRef.current, setState, input, modelRef.current, providerRef.current, setStreamContent);
39
+ }, [showBanner]);
31
40
 
32
41
  function handleCommandSelect(cmdName) {
33
42
  setShowCommands(false);
@@ -45,20 +54,26 @@ export function App({ config }) {
45
54
  }));
46
55
  }
47
56
 
48
- return h(Box, { flexDirection: 'column', height: '100%' },
49
- h(Box, { flexGrow: 1, flexDirection: 'column' },
50
- showBanner ? h(Banner) : null,
51
- h(MessageList, {
52
- messages: state.messages,
53
- thinking: state.thinking,
54
- streamContent,
55
- agentStatus: state.agentStatus,
56
- toolExecutions: state.toolExecutions,
57
- })
57
+ const termHeight = process.stdout.rows || 30;
58
+
59
+ return h(Box, { flexDirection: 'column', backgroundColor: theme.bg },
60
+ h(Box, { flexGrow: 1, flexShrink: 1, flexDirection: 'column', minHeight: 0 },
61
+ showBanner
62
+ ? h(Banner)
63
+ : null,
64
+ h(Box, { flexGrow: 1, flexShrink: 1, minHeight: 0 },
65
+ h(MessageList, {
66
+ messages: state.messages,
67
+ thinking: state.thinking,
68
+ streamContent,
69
+ agentStatus: state.agentStatus,
70
+ toolExecutions: state.toolExecutions,
71
+ })
72
+ )
58
73
  ),
59
74
  showCommands
60
- ? h(Box, { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, justifyContent: 'center' },
61
- h(Box, { backgroundColor: '#0A0A0A', borderStyle: 'round', borderColor: '#333', paddingX: 2, paddingY: 1 },
75
+ ? h(Box, { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, justifyContent: 'center', alignItems: 'center' },
76
+ h(Box, { backgroundColor: theme.bg, borderStyle: 'round', borderColor: theme.borderLight, paddingX: 2, paddingY: 1 },
62
77
  h(CommandPicker, {
63
78
  query: '',
64
79
  onSelect: handleCommandSelect,
@@ -68,8 +83,8 @@ export function App({ config }) {
68
83
  )
69
84
  : null,
70
85
  showModels
71
- ? h(Box, { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, justifyContent: 'center' },
72
- h(Box, { backgroundColor: '#0A0A0A', borderStyle: 'round', borderColor: '#333', paddingX: 2, paddingY: 1 },
86
+ ? h(Box, { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, justifyContent: 'center', alignItems: 'center' },
87
+ h(Box, { backgroundColor: theme.bg, borderStyle: 'round', borderColor: theme.borderLight, paddingX: 2, paddingY: 1 },
73
88
  h(ModelPicker, {
74
89
  onSelect: handleModelSelect,
75
90
  onClose: () => setShowModels(false),
package/src/chat.js CHANGED
@@ -87,6 +87,7 @@ async function processStream(provider, model, history, agentMode, setState, onSt
87
87
  let buffer = '';
88
88
  let toolCallsData = null;
89
89
  let thoughtTime = Date.now();
90
+ let timedOut = false;
90
91
 
91
92
  try {
92
93
  for await (const event of stream) {
@@ -95,12 +96,13 @@ async function processStream(provider, model, history, agentMode, setState, onSt
95
96
  onStreamContent(buffer);
96
97
  setState(s => ({ ...s, agentStatus: 'Writing response...' }));
97
98
  } else if (event.type === 'tool_calls') {
98
- toolCallsData = event.calls;
99
+ if (!timedOut) toolCallsData = event.calls;
99
100
  } else if (event.type === 'done') {
100
101
  } else if (event.type === 'timeout') {
102
+ timedOut = true;
101
103
  setState(s => ({
102
- ...s, agentStatus: 'Stream stalled, completing...',
103
- messages: [...s.messages, { id: nextId(), role: 'system', content: 'Stream timeoutresponse may be incomplete' }],
104
+ ...s, agentStatus: 'Stalled recovering...',
105
+ messages: [...s.messages, { id: nextId(), role: 'system', content: 'Response timed out showing partial result.' }],
104
106
  }));
105
107
  } else if (event.type === 'error') {
106
108
  setState(s => ({ ...s, thinking: false, streamContent: '', agentStatus: '', toolExecutions: [], thoughtTimer: null }));
@@ -136,6 +138,12 @@ async function processStream(provider, model, history, agentMode, setState, onSt
136
138
  onStreamContent('');
137
139
  }
138
140
 
141
+ if (timedOut) {
142
+ setState(s => ({ ...s, thinking: false, toolExecutions: [], thoughtTimer: null }));
143
+ onStreamContent('');
144
+ return;
145
+ }
146
+
139
147
  if (toolCallsData && toolCallsData.length > 0 && agentMode) {
140
148
  const execs = toolCallsData.map(tc => ({
141
149
  execId: nextExecId(),
@@ -1,13 +1,23 @@
1
1
  import React from 'react';
2
- import { Box } from 'ink';
3
- import BigText from 'ink-big-text';
2
+ import { Box, Text } from 'ink';
4
3
  import Gradient from 'ink-gradient';
4
+ import BigText from 'ink-big-text';
5
5
  const { createElement: h } = React;
6
6
 
7
7
  export function Banner() {
8
- return h(Box, { justifyContent: 'center', marginBottom: 0 },
9
- h(Gradient, { name: 'cristal' },
10
- h(BigText, { text: 'CLARITY', font: 'block' })
11
- )
8
+ return h(Box, { flexDirection: 'column', alignItems: 'center', marginTop: 1, marginBottom: 1 },
9
+ h(Gradient, { name: 'summer' },
10
+ h(BigText, { text: 'CLARITY', font: 'chrome', letterSpacing: 1 })
11
+ ),
12
+ h(Box, { flexDirection: 'row', gap: 1 },
13
+ h(Text, { color: '#FF6B6B' }, '\u25C9'),
14
+ h(Text, { color: '#555' }, 'premium terminal AI'),
15
+ h(Text, { color: '#555' }, '\u00B7'),
16
+ h(Text, { color: '#00FF88' }, 'agent mode'),
17
+ h(Text, { color: '#555' }, '\u00B7'),
18
+ h(Text, { color: '#00D4FF' }, 'Ctrl+P commands'),
19
+ h(Text, { color: '#FF6B6B' }, '\u25C9'),
20
+ ),
21
+ h(Text, { color: '#2A2A2A' }, '\u2501'.repeat(Math.min(process.stdout.columns || 80, 60))),
12
22
  );
13
23
  }
@@ -1,5 +1,6 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import { Box, Text } from 'ink';
3
+ import { theme } from '../config/theme.js';
3
4
  const { createElement: h } = React;
4
5
 
5
6
  const LANG_COLORS = {
@@ -11,26 +12,24 @@ const LANG_COLORS = {
11
12
  json: '#292929', yaml: '#CB171E', md: '#083FA1', sql: '#E38C00',
12
13
  };
13
14
 
14
- export function CodeBlock({ code, language, termWidth }) {
15
+ export function CodeBlock({ code, language }) {
15
16
  const lang = language || 'code';
16
17
  const lines = useMemo(() => String(code).split('\n'), [code]);
17
18
  const langColor = LANG_COLORS[lang] || '#555';
18
- const lineNumWidth = String(lines.length).length;
19
+ const lnW = String(lines.length).length;
19
20
 
20
- return h(Box, { flexDirection: 'column', marginY: 1, marginLeft: 2 },
21
- h(Box, { flexDirection: 'row' },
22
- h(Box, { backgroundColor: '#1C1C1C', paddingX: 1 },
23
- h(Text, { color: langColor, bold: true }, ' ' + lang + ' '),
24
- h(Text, { color: '#555' }, String(lines.length).padStart(3) + ' lines '),
25
- )
21
+ return h(Box, { flexDirection: 'column', marginY: 1, marginLeft: 0 },
22
+ h(Box, { flexDirection: 'row', backgroundColor: theme.codeBg },
23
+ h(Text, { color: langColor, bold: true, backgroundColor: '#1C1C1C' }, ' ' + lang + ' '),
24
+ h(Text, { color: theme.textMuted, backgroundColor: '#1C1C1C' }, String(lines.length) + ' lines '),
26
25
  ),
27
- h(Box, { flexDirection: 'column', backgroundColor: '#0D1117', paddingY: 0 },
26
+ h(Box, { flexDirection: 'column', backgroundColor: theme.codeBg },
28
27
  lines.map((line, i) =>
29
- h(Box, { key: i, flexDirection: 'row' },
30
- h(Text, { color: '#555', backgroundColor: '#0D1117' },
31
- ' ' + String(i + 1).padStart(lineNumWidth) + ' '
28
+ h(Box, { key: i, flexDirection: 'row', backgroundColor: theme.codeBg },
29
+ h(Text, { color: theme.textMuted, backgroundColor: theme.codeBg },
30
+ ' ' + String(i + 1).padStart(lnW) + ' '
32
31
  ),
33
- h(Text, { color: '#C9D1D9', backgroundColor: '#0D1117', wrap: 'truncate-end' },
32
+ h(Text, { color: '#C9D1D9', backgroundColor: theme.codeBg, wrap: 'truncate-end' },
34
33
  line || ' '
35
34
  )
36
35
  )
@@ -1,5 +1,6 @@
1
1
  import React, { useState } from 'react';
2
2
  import { Box, Text, useInput } from 'ink';
3
+ import { theme } from '../config/theme.js';
3
4
  const { createElement: h } = React;
4
5
 
5
6
  const COMMANDS = [
@@ -15,32 +16,50 @@ const COMMANDS = [
15
16
  ];
16
17
 
17
18
  export function CommandPicker({ query, onSelect, onClose }) {
19
+ const [search, setSearch] = useState('');
20
+ const [idx, setIdx] = useState(0);
21
+
18
22
  const filtered = COMMANDS.filter(c =>
19
- c.name.includes(query) || c.desc.toLowerCase().includes(query.toLowerCase())
23
+ c.name.includes(search) || c.desc.toLowerCase().includes(search.toLowerCase())
20
24
  );
21
- const [idx, setIdx] = useState(0);
22
25
 
23
26
  useInput((input, key) => {
24
27
  if (key.upArrow) setIdx(i => Math.max(0, i - 1));
25
28
  if (key.downArrow) setIdx(i => Math.min(filtered.length - 1, i + 1));
26
- if (key.return) onSelect(filtered[idx].name);
29
+ if (key.return) onSelect(filtered[idx]?.name || '');
27
30
  if (key.escape) onClose();
31
+ if (key.backspace) setSearch(s => s.slice(0, -1));
32
+ else if (input && !key.ctrl && !key.meta) setSearch(s => s + input);
28
33
  });
29
34
 
30
- return h(Box, { flexDirection: 'column', paddingX: 1, borderStyle: 'round', borderColor: '#333' },
31
- h(Text, { color: '#00D4FF', bold: true }, ' Commands'),
32
- h(Text, { color: '#333' }, ''),
35
+ const tw = process.stdout.columns || 80;
36
+ const boxWidth = Math.min(tw - 4, 50);
37
+
38
+ return h(Box, { flexDirection: 'column', width: boxWidth },
39
+ h(Box, { flexDirection: 'row', marginBottom: 1, gap: 1 },
40
+ h(Text, { color: theme.textMuted }, '\u2315'),
41
+ h(Text, { color: search ? theme.text : theme.textMuted }, search || 'type to filter...'),
42
+ ),
33
43
  filtered.map((cmd, i) =>
34
- h(Box, { key: cmd.name, flexDirection: 'row', gap: 2 },
44
+ h(Box, {
45
+ key: cmd.name,
46
+ flexDirection: 'row',
47
+ backgroundColor: i === idx ? theme.selectionBg : undefined,
48
+ width: boxWidth,
49
+ },
35
50
  h(Text, {
36
- color: i === idx ? '#FF6B6B' : '#F0F0F0',
51
+ color: i === idx ? theme.selectionText : theme.text,
37
52
  bold: i === idx,
38
- backgroundColor: i === idx ? '#2A2A2A' : undefined,
39
- }, ' ' + cmd.name),
40
- h(Text, { color: '#555' }, cmd.desc)
53
+ backgroundColor: i === idx ? theme.selectionBg : undefined,
54
+ wrap: 'truncate-end',
55
+ }, ' ' + cmd.name.padEnd(16)),
56
+ h(Text, {
57
+ color: i === idx ? theme.selectionText : theme.textDim,
58
+ backgroundColor: i === idx ? theme.selectionBg : undefined,
59
+ wrap: 'truncate-end',
60
+ }, cmd.desc)
41
61
  )
42
62
  ),
43
- h(Text, { color: '#333' }, ''),
44
- h(Text, { color: '#555' }, ' \u2191\u2193 navigate \u23CE select Esc close')
63
+ h(Text, { color: theme.textMuted }, ' \u2191\u2193 nav \u23CE select Esc close')
45
64
  );
46
65
  }
@@ -1,152 +1,93 @@
1
- import React, { useState, useRef, useCallback } from 'react';
1
+ import React, { useState, useRef } from 'react';
2
2
  import { Box, Text, useInput } from 'ink';
3
+ import { theme } from '../config/theme.js';
3
4
  const { createElement: h } = React;
4
- const w = () => process.stdout.columns || 80;
5
5
 
6
6
  export function Composer({ provider, model, agentMode, thinking, onSlash, onSubmit }) {
7
7
  const [lines, setLines] = useState(['']);
8
8
  const [cursorLine, setCursorLine] = useState(0);
9
9
  const [cursorCol, setCursorCol] = useState(0);
10
- const inputRef = useRef({ lines: [''], line: 0, col: 0 });
10
+ const buf = useRef({ lines: [''], line: 0, col: 0 });
11
11
  const displayName = provider + '/' + model;
12
12
 
13
13
  useInput((input, key) => {
14
- if (thinking) return;
15
- const state = inputRef.current;
14
+ const s = buf.current;
16
15
 
17
- if (key.return && !key.shift) {
18
- const text = state.lines.join('\n');
19
- setLines(['']);
20
- state.lines = [''];
21
- state.line = 0;
22
- state.col = 0;
23
- setCursorLine(0);
24
- setCursorCol(0);
16
+ if (key.return && !key.shift && !thinking) {
17
+ const text = s.lines.join('\n');
18
+ s.lines = ['']; s.line = 0; s.col = 0;
19
+ setLines(['']); setCursorLine(0); setCursorCol(0);
25
20
  if (text.trim()) onSubmit(text);
26
21
  return;
27
22
  }
28
23
 
29
24
  if (key.return && key.shift) {
30
- state.lines.splice(state.line + 1, 0,
31
- state.lines[state.line].slice(state.col)
32
- );
33
- state.lines[state.line] = state.lines[state.line].slice(0, state.col);
34
- state.line++;
35
- state.col = 0;
36
- setLines([...state.lines]);
37
- setCursorLine(state.line);
38
- setCursorCol(state.col);
25
+ const rest = s.lines[s.line].slice(s.col);
26
+ s.lines[s.line] = s.lines[s.line].slice(0, s.col);
27
+ s.lines.splice(s.line + 1, 0, rest);
28
+ s.line++; s.col = 0;
29
+ setLines([...s.lines]); setCursorLine(s.line); setCursorCol(0);
39
30
  return;
40
31
  }
41
32
 
42
33
  if (key.backspace || key.delete) {
43
- if (state.col > 0) {
44
- state.lines[state.line] =
45
- state.lines[state.line].slice(0, state.col - 1) +
46
- state.lines[state.line].slice(state.col);
47
- state.col--;
48
- } else if (state.line > 0) {
49
- state.col = state.lines[state.line - 1].length;
50
- state.lines[state.line - 1] += state.lines[state.line];
51
- state.lines.splice(state.line, 1);
52
- state.line--;
34
+ if (s.col > 0) {
35
+ s.lines[s.line] = s.lines[s.line].slice(0, s.col - 1) + s.lines[s.line].slice(s.col);
36
+ s.col--;
37
+ } else if (s.line > 0) {
38
+ s.col = s.lines[s.line - 1].length;
39
+ s.lines[s.line - 1] += s.lines[s.line];
40
+ s.lines.splice(s.line, 1);
41
+ s.line--;
53
42
  }
54
- setLines([...state.lines]);
55
- setCursorLine(state.line);
56
- setCursorCol(state.col);
43
+ setLines([...s.lines]); setCursorLine(s.line); setCursorCol(s.col);
57
44
  return;
58
45
  }
59
46
 
60
- if (key.upArrow) {
61
- if (state.line > 0) {
62
- state.line--;
63
- state.col = Math.min(state.col, state.lines[state.line].length);
64
- setCursorLine(state.line);
65
- setCursorCol(state.col);
66
- }
67
- return;
68
- }
69
-
70
- if (key.downArrow) {
71
- if (state.line < state.lines.length - 1) {
72
- state.line++;
73
- state.col = Math.min(state.col, state.lines[state.line].length);
74
- setCursorLine(state.line);
75
- setCursorCol(state.col);
76
- }
77
- return;
78
- }
79
-
80
- if (key.leftArrow) {
81
- if (state.col > 0) {
82
- state.col--;
83
- } else if (state.line > 0) {
84
- state.line--;
85
- state.col = state.lines[state.line].length;
86
- }
87
- setCursorLine(state.line);
88
- setCursorCol(state.col);
89
- return;
90
- }
91
-
92
- if (key.rightArrow) {
93
- if (state.col < state.lines[state.line].length) {
94
- state.col++;
95
- } else if (state.line < state.lines.length - 1) {
96
- state.line++;
97
- state.col = 0;
98
- }
99
- setCursorLine(state.line);
100
- setCursorCol(state.col);
101
- return;
102
- }
47
+ if (key.upArrow && s.line > 0) { s.line--; s.col = Math.min(s.col, s.lines[s.line].length); setCursorLine(s.line); setCursorCol(s.col); return; }
48
+ if (key.downArrow && s.line < s.lines.length - 1) { s.line++; s.col = Math.min(s.col, s.lines[s.line].length); setCursorLine(s.line); setCursorCol(s.col); return; }
49
+ if (key.leftArrow) { if (s.col > 0) s.col--; else if (s.line > 0) { s.line--; s.col = s.lines[s.line].length; } setCursorLine(s.line); setCursorCol(s.col); return; }
50
+ if (key.rightArrow) { if (s.col < s.lines[s.line].length) s.col++; else if (s.line < s.lines.length - 1) { s.line++; s.col = 0; } setCursorLine(s.line); setCursorCol(s.col); return; }
103
51
 
104
52
  if (input && input.length === 1 && !key.ctrl && !key.meta) {
105
- if (input === '/' && state.lines.length === 1 && state.lines[0] === '') {
106
- onSlash?.();
107
- return;
108
- }
109
- state.lines[state.line] =
110
- state.lines[state.line].slice(0, state.col) +
111
- input +
112
- state.lines[state.line].slice(state.col);
113
- state.col++;
114
- setLines([...state.lines]);
115
- setCursorLine(state.line);
116
- setCursorCol(state.col);
53
+ if (input === '/' && s.lines.length === 1 && s.lines[0] === '') { onSlash?.(); return; }
54
+ s.lines[s.line] = s.lines[s.line].slice(0, s.col) + input + s.lines[s.line].slice(s.col);
55
+ s.col++;
56
+ setLines([...s.lines]); setCursorLine(s.line); setCursorCol(s.col);
117
57
  }
118
58
  });
119
59
 
120
- const currentText = lines.join('\n');
121
- const dispLines = currentText ? currentText.split('\n') : [''];
60
+ const dispLines = lines.join('\n') ? lines : [''];
122
61
  const height = Math.min(dispLines.length, 5);
123
- const blankLines = height - dispLines.length;
124
62
 
125
- return h(Box, { flexDirection: 'column', flexShrink: 0 },
126
- h(Box, { flexDirection: 'column', backgroundColor: '#0A0A0A', borderStyle: 'round', borderColor: '#2D2D2D' },
63
+ return h(Box, { flexDirection: 'column', flexShrink: 0, borderStyle: 'round', borderColor: theme.border },
64
+ h(Box, { flexDirection: 'column' },
127
65
  dispLines.slice(0, height).map((line, i) =>
128
- h(Box, { key: i, flexDirection: 'row' },
129
- h(Text, { color: '#00D4FF' }, i === cursorLine ? '\u276F' : ' '),
130
- h(Text, { color: '#F0F0F0' }, ' ' + (line || ' ')),
66
+ h(Box, { key: i, flexDirection: 'row', backgroundColor: theme.surface },
67
+ h(Text, { color: theme.accent, backgroundColor: theme.surface },
68
+ i === cursorLine ? '\u276F' : ' '
69
+ ),
70
+ h(Text, { color: theme.text, backgroundColor: theme.surface, wrap: 'wrap' },
71
+ ' ' + (line || ' ')
72
+ ),
131
73
  i === cursorLine
132
- ? h(Text, { color: '#00D4FF' }, '\u258C')
133
- : null
134
- )
135
- ),
136
- Array.from({ length: blankLines }).map((_, i) =>
137
- h(Box, { key: 'b' + i, flexDirection: 'row' },
138
- h(Text, { color: '#2D2D2D' }, ' '),
139
- h(Text, { color: '#555' }, ' ')
74
+ ? h(Text, { color: theme.info, backgroundColor: theme.surface }, '\u258C')
75
+ : h(Text, { backgroundColor: theme.surface }, ' ')
140
76
  )
141
- ),
142
- h(Box, { flexDirection: 'row', gap: 1, marginTop: 0 },
143
- h(Text, { color: '#555' }, '\u2502'),
144
- h(Text, { color: '#888' }, displayName),
145
- h(Text, { color: '#333' }, '\u00B7'),
146
- h(Text, { color: agentMode ? '#00FF88' : '#555' }, agentMode ? 'agent:ON' : 'agent:OFF'),
147
- h(Text, { color: '#333' }, '\u00B7 Ctrl+P commands'),
148
- h(Text, { color: '#888' }, thinking ? '\u25CF thinking...' : ''),
149
77
  )
78
+ ),
79
+ h(Box, { flexDirection: 'row', gap: 1, paddingX: 1, backgroundColor: theme.surfaceAlt },
80
+ h(Text, { color: theme.textMuted }, '\u2502'),
81
+ h(Text, { color: theme.info }, '\u25C9 ' + displayName),
82
+ h(Text, { color: theme.textMuted }, '\u00B7'),
83
+ h(Text, { color: agentMode ? theme.success : theme.textMuted },
84
+ agentMode ? '\u25C9 agent' : '\u25CB agent'
85
+ ),
86
+ h(Text, { color: theme.textMuted }, '\u00B7'),
87
+ h(Text, { color: theme.textDim }, 'Ctrl+P'),
88
+ thinking
89
+ ? h(Text, { color: theme.warning }, ' \u25CF thinking')
90
+ : null,
150
91
  )
151
92
  );
152
93
  }
@@ -1,11 +1,14 @@
1
1
  import React from 'react';
2
2
  import { Box, Text } from 'ink';
3
3
  import Spinner from 'ink-spinner';
4
+ import { theme } from '../config/theme.js';
4
5
  const { createElement: h } = React;
5
6
 
6
7
  export function LoadingIndicator({ label }) {
7
- return h(Box, { paddingLeft: 2, marginBottom: 1 },
8
- h(Text, { color: 'cyan' }, h(Spinner, { type: 'dots' })),
9
- h(Text, { color: 'gray' }, ' ' + (label || 'Thinking'))
8
+ return h(Box, { flexDirection: 'row', marginLeft: 0, marginY: 1, backgroundColor: theme.surface },
9
+ h(Text, { color: theme.info, backgroundColor: theme.surface }, '\u25B6'),
10
+ h(Text, { color: theme.info, backgroundColor: theme.surface }, ' '),
11
+ h(Text, { color: theme.info, backgroundColor: theme.surface }, h(Spinner, { type: 'dots' })),
12
+ h(Text, { color: theme.textDim, backgroundColor: theme.surface }, ' ' + (label || 'Thinking'))
10
13
  );
11
14
  }