clarity-ai 6.2.0 → 6.2.2

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,19 +5,20 @@ import { App } from '../src/app.js';
5
5
  import { hasKey } from '../src/config/keys.js';
6
6
  import { createInterface } from 'readline';
7
7
 
8
- process.stdout.write('\x1b[2J\x1b[0f');
9
-
10
- // Force stdin into flowing mode BEFORE any I/O that might pause it.
11
- // Without this, Ink's useInput never activates, the event loop
12
- // has no handles, and the process exits immediately.
8
+ // Keep stdin flowing so Ink's useInput hooks can register.
9
+ // This must happen before any async I/O that might pause stdin.
13
10
  process.stdin.resume();
14
11
  process.stdin.setEncoding('utf8');
15
12
 
13
+ // Do NOT clear the screen here. Ink's { fullscreen: true } switch to
14
+ // the alternate screen buffer on mount, which implicitly clears the
15
+ // visible area. A manual \x1b[2J before render() would clear the
16
+ // main buffer — that's destructive and shows as a flash on Termux.
17
+
16
18
  async function main() {
17
19
  const provider = process.env.CLARITY_PROVIDER || 'groq';
18
20
 
19
21
  if (!hasKey(provider)) {
20
- // Save raw state before readline hijacks stdin
21
22
  const rl = createInterface({ input: process.stdin, output: process.stdout });
22
23
  const key = await new Promise(resolve => {
23
24
  rl.question('\n\x1b[33m No ' + provider + ' API key found.\x1b[0m\n Enter your ' + provider + ' key: ', (answer) => {
@@ -27,29 +28,28 @@ async function main() {
27
28
  });
28
29
  const { setKey } = await import('../src/config/keys.js');
29
30
  setKey(provider, key);
30
- process.stdout.write('\x1b[2J\x1b[0f');
31
- // Re-resume stdin — readline.close() can leave it paused
31
+ // readline.close() can leave stdin paused — restore it for Ink
32
32
  process.stdin.resume();
33
33
  }
34
34
 
35
35
  const config = { provider, model: process.env.CLARITY_MODEL || 'groq/llama-3.3-70b-versatile' };
36
36
 
37
- // Mount Ink. fullscreen:true tells Ink to own stdin/output.
38
- // Keep the render ref so we can wait for graceful exit.
37
+ // Let Ink own the screen. fullscreen:true switches to alt buffer,
38
+ // clears it, and renders the React tree incrementally from there.
39
39
  const { waitUntilExit, clear } = render(React.createElement(App, { config }), {
40
40
  fullscreen: true,
41
41
  patchConsole: false,
42
42
  });
43
43
 
44
- // Keep the event loop alive even if Ink's reconciler settles.
45
- // On some Termux/Node combos, waitUntilExit can fire early when
46
- // no async updates are pending this interval prevents that.
44
+ // On some Termux/Node versions Ink's reconciler can settle early
45
+ // when no async updates are queued. This interval keeps the event
46
+ // loop alive so the process doesn't exit.
47
47
  const keepAlive = setInterval(() => {}, 2 ** 31 - 1);
48
48
 
49
49
  function cleanup() {
50
50
  clearInterval(keepAlive);
51
- clear();
52
- process.stdout.write('\x1b[?25h\x1b[0m');
51
+ clear(); // Ink unmount — exits alt buffer
52
+ process.stdout.write('\x1b[?25h\x1b[0m'); // show cursor, reset attrs
53
53
  process.exit(0);
54
54
  }
55
55
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clarity-ai",
3
- "version": "6.2.0",
3
+ "version": "6.2.2",
4
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": {
@@ -16,8 +16,6 @@
16
16
  "ink": "^5",
17
17
  "react": "^18",
18
18
  "ink-spinner": "^5",
19
- "ink-big-text": "^2",
20
- "ink-gradient": "^3",
21
19
  "marked": "^12",
22
20
  "cli-highlight": "^2",
23
21
  "chalk": "^5",
package/src/app.js CHANGED
@@ -1,6 +1,5 @@
1
- import React, { useState, useCallback, useRef, useEffect } from 'react';
1
+ import React, { useState, useCallback, useRef } from 'react';
2
2
  import { Box } from 'ink';
3
- import { Banner } from './components/Banner.js';
4
3
  import { MessageList } from './components/MessageList.js';
5
4
  import { Composer } from './components/Composer.js';
6
5
  import { CommandPicker } from './components/CommandPicker.js';
@@ -17,9 +16,7 @@ export function App({ config }) {
17
16
  const [provider, setProvider] = useState(config.provider || 'groq');
18
17
  const [showCommands, setShowCommands] = useState(false);
19
18
  const [showModels, setShowModels] = useState(false);
20
- const [showBanner, setShowBanner] = useState(true);
21
19
 
22
- // Use refs to avoid stale closures in callbacks
23
20
  const stateRef = useRef(state);
24
21
  const modelRef = useRef(model);
25
22
  const providerRef = useRef(provider);
@@ -34,9 +31,8 @@ export function App({ config }) {
34
31
  await handleCommand(input, stateRef.current, setState, setModel, setProvider, modelRef.current, providerRef.current);
35
32
  return;
36
33
  }
37
- if (showBanner) setShowBanner(false);
38
34
  await handleSend(stateRef.current, setState, input, modelRef.current, providerRef.current, setStreamContent);
39
- }, [showBanner]);
35
+ }, []);
40
36
 
41
37
  function handleCommandSelect(cmdName) {
42
38
  setShowCommands(false);
@@ -44,8 +40,7 @@ export function App({ config }) {
44
40
  }
45
41
 
46
42
  function handleModelSelect(modelId) {
47
- const p = modelId.split('/')[0];
48
- setProvider(p);
43
+ setProvider(modelId.split('/')[0]);
49
44
  setModel(modelId.replace(/^[^/]+\//, ''));
50
45
  setShowModels(false);
51
46
  setState(s => ({
@@ -54,42 +49,31 @@ export function App({ config }) {
54
49
  }));
55
50
  }
56
51
 
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
- )
52
+ return h(Box, { flexDirection: 'column', backgroundColor: theme.bg, minHeight: '100%' },
53
+ h(Box, { flexGrow: 1, flexDirection: 'column', minHeight: 0 },
54
+ h(MessageList, {
55
+ messages: state.messages,
56
+ thinking: state.thinking,
57
+ streamContent,
58
+ agentStatus: state.agentStatus,
59
+ toolExecutions: state.toolExecutions,
60
+ })
73
61
  ),
74
- showCommands
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 },
77
- h(CommandPicker, {
78
- query: '',
79
- onSelect: handleCommandSelect,
80
- onClose: () => setShowCommands(false),
81
- })
82
- )
83
- )
84
- : null,
85
- showModels
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 },
88
- h(ModelPicker, {
89
- onSelect: handleModelSelect,
90
- onClose: () => setShowModels(false),
91
- })
92
- )
62
+ showCommands || showModels
63
+ ? h(Box, { flexDirection: 'column', marginBottom: 1, backgroundColor: theme.surfaceAlt, borderStyle: 'round', borderColor: theme.borderLight },
64
+ showCommands
65
+ ? h(CommandPicker, {
66
+ query: '',
67
+ onSelect: handleCommandSelect,
68
+ onClose: () => setShowCommands(false),
69
+ })
70
+ : null,
71
+ showModels
72
+ ? h(ModelPicker, {
73
+ onSelect: handleModelSelect,
74
+ onClose: () => setShowModels(false),
75
+ })
76
+ : null
93
77
  )
94
78
  : null,
95
79
  h(Composer, {
package/src/chat.js CHANGED
@@ -5,7 +5,11 @@ const sleep = ms => new Promise(r => setTimeout(r, ms));
5
5
 
6
6
  export function createChatState() {
7
7
  return {
8
- messages: [],
8
+ messages: [{
9
+ id: 'welcome',
10
+ role: 'system',
11
+ content: 'CLARITY AI ready \u00B7 Ctrl+P commands \u00B7 /help',
12
+ }],
9
13
  thinking: false,
10
14
  streamContent: '',
11
15
  awaitingKey: false,
@@ -1,23 +0,0 @@
1
- import React from 'react';
2
- import { Box, Text } from 'ink';
3
- import Gradient from 'ink-gradient';
4
- import BigText from 'ink-big-text';
5
- const { createElement: h } = React;
6
-
7
- export function Banner() {
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))),
22
- );
23
- }