clarity-ai 6.2.1 → 6.2.3
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 +24 -22
- package/package.json +1 -3
- package/src/components/Banner.js +0 -23
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
|
-
|
|
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 } switches
|
|
14
|
+
// to the alternate screen buffer on mount, which implicitly clears
|
|
15
|
+
// the visible area. Any manual \x1b[2J before render() would clear
|
|
16
|
+
// the main buffer — destructive, 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,37 +28,38 @@ async function main() {
|
|
|
27
28
|
});
|
|
28
29
|
const { setKey } = await import('../src/config/keys.js');
|
|
29
30
|
setKey(provider, key);
|
|
30
|
-
|
|
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
|
|
38
|
-
//
|
|
39
|
-
|
|
37
|
+
// Mount Ink. fullscreen:true enters the alternate screen buffer.
|
|
38
|
+
// We DO NOT await waitUntilExit; on some Termux/Node combos it
|
|
39
|
+
// resolves before the first frame renders. Instead we keep the
|
|
40
|
+
// process alive with a never-resolving promise and exit only via
|
|
41
|
+
// signal handlers or process.exit from inside the app.
|
|
42
|
+
const { clear } = render(React.createElement(App, { config }), {
|
|
40
43
|
fullscreen: true,
|
|
41
44
|
patchConsole: false,
|
|
42
45
|
});
|
|
43
46
|
|
|
44
|
-
// Keep the event loop alive
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
const keepAlive = setInterval(() => {}, 2 ** 31 - 1);
|
|
47
|
+
// Keep the event loop alive — Ink's reconciler settles
|
|
48
|
+
// synchronously when no async state updates are queued.
|
|
49
|
+
setInterval(() => {}, 2 ** 31 - 1);
|
|
48
50
|
|
|
51
|
+
// Signal handlers are the ONLY way to exit.
|
|
49
52
|
function cleanup() {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
process.stdout.write('\x1b[?25h\x1b[0m');
|
|
53
|
+
try { clear(); } catch {} // Ink unmount — exit alt buffer, restore TTY
|
|
54
|
+
process.stdout.write('\x1b[?25h\x1b[0m'); // show cursor, reset attrs
|
|
53
55
|
process.exit(0);
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
process.on('SIGINT', cleanup);
|
|
57
|
-
process.on('SIGTERM', cleanup);
|
|
58
|
+
process.on('SIGINT', () => cleanup());
|
|
59
|
+
process.on('SIGTERM', () => cleanup());
|
|
58
60
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
// Never-resolving promise — we stay alive until a signal fires cleanup.
|
|
62
|
+
await new Promise(() => {});
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
main().catch(err => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clarity-ai",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.3",
|
|
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/components/Banner.js
DELETED
|
@@ -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
|
-
}
|