@rind-ai/cli 0.4.1 → 0.6.1
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/rind.js +5 -5
- package/lib/assistant-renderer.js +179 -265
- package/lib/choice-menu-state.js +46 -46
- package/lib/cli-input-actions.js +548 -0
- package/lib/cli-output-controller.js +460 -0
- package/lib/cli-runtime-controller.js +350 -0
- package/lib/cli-state-store.js +32 -0
- package/lib/cli-state.js +41 -0
- package/lib/command-controller.js +159 -126
- package/lib/compact-context-state.js +22 -22
- package/lib/components/assistant-message.js +169 -0
- package/lib/components/composer-area.js +25 -0
- package/lib/components/dynamic-block.js +20 -0
- package/lib/components/monitor-stack.js +35 -0
- package/lib/components/text-block.js +47 -0
- package/lib/components/tool-block.js +122 -0
- package/lib/composer-terminal.js +224 -203
- package/lib/event-controller.js +243 -242
- package/lib/frontend-cli-implementation.js +656 -1111
- package/lib/input-controller.js +75 -94
- package/lib/input-errors.js +3 -3
- package/lib/interrupt-state.js +9 -9
- package/lib/line-editor.js +541 -541
- package/lib/local-slash-commands.js +217 -0
- package/lib/markdown-lines.js +103 -0
- package/lib/model-menu-state.js +50 -50
- package/lib/one-shot-progress.js +145 -0
- package/lib/one-shot.js +228 -0
- package/lib/question-menu-state.js +61 -0
- package/lib/rendering.js +1295 -1037
- package/lib/runtime-client.js +241 -193
- package/lib/runtime-env.js +21 -21
- package/lib/runtime-protocol.js +122 -15
- package/lib/slash-command-mode.js +16 -27
- package/lib/slash-menu-state.js +59 -59
- package/lib/{background-controller.js → task-monitor-controller.js} +411 -289
- package/lib/terminal-key.js +97 -97
- package/lib/text-width.js +335 -151
- package/lib/theme-menu-state.js +31 -0
- package/lib/theme.js +134 -0
- package/lib/tool-display.js +680 -0
- package/lib/tui/component.js +55 -0
- package/lib/tui/cursor.js +29 -0
- package/lib/tui/input-buffer.js +172 -0
- package/lib/tui/tui.js +591 -0
- package/lib/turn-controller.js +68 -78
- package/package.json +28 -28
- package/lib/assistant-stream-buffer.js +0 -25
- package/lib/terminal-ui.js +0 -581
package/lib/input-controller.js
CHANGED
|
@@ -1,94 +1,75 @@
|
|
|
1
|
-
export function createInputController({
|
|
2
|
-
terminalUi = null,
|
|
3
|
-
state = {},
|
|
4
|
-
askInput,
|
|
5
|
-
onSubmit = () => {},
|
|
6
|
-
onCommand = async () => false,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
await
|
|
27
|
-
if (state.runtimeClosing) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function close() {
|
|
77
|
-
cancel();
|
|
78
|
-
terminalUi?.stop();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
start,
|
|
83
|
-
promptLoop,
|
|
84
|
-
ask,
|
|
85
|
-
pause,
|
|
86
|
-
resume,
|
|
87
|
-
cancel,
|
|
88
|
-
redraw,
|
|
89
|
-
close,
|
|
90
|
-
handleInput: onInput,
|
|
91
|
-
handlePaste: onPaste,
|
|
92
|
-
handleSigint: onSigint,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
1
|
+
export function createInputController({
|
|
2
|
+
terminalUi = null,
|
|
3
|
+
state = {},
|
|
4
|
+
askInput,
|
|
5
|
+
onSubmit = () => {},
|
|
6
|
+
onCommand = async () => false,
|
|
7
|
+
onPaste = () => {},
|
|
8
|
+
onInput = () => {},
|
|
9
|
+
cancelInput = () => {},
|
|
10
|
+
prompt = () => "",
|
|
11
|
+
placeholder = () => "",
|
|
12
|
+
}) {
|
|
13
|
+
const promptResumeWaiters = [];
|
|
14
|
+
|
|
15
|
+
function start() {
|
|
16
|
+
terminalUi?.start();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function promptLoop() {
|
|
20
|
+
while (!state.runtimeClosing) {
|
|
21
|
+
await waitForResume();
|
|
22
|
+
if (state.runtimeClosing) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
// Keep the prompt callback intact so TTY redraws reflect live runtime state.
|
|
26
|
+
const text = (await askInput(prompt, placeholder())).trim();
|
|
27
|
+
if (state.runtimeClosing) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (!text) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (await onCommand(text)) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
onSubmit(text);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function pause() {
|
|
41
|
+
state.promptPaused = true;
|
|
42
|
+
cancelInput();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function resume() {
|
|
46
|
+
state.promptPaused = false;
|
|
47
|
+
while (promptResumeWaiters.length) {
|
|
48
|
+
promptResumeWaiters.shift()();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function waitForResume() {
|
|
53
|
+
if (!state.promptPaused) {
|
|
54
|
+
return Promise.resolve();
|
|
55
|
+
}
|
|
56
|
+
return new Promise((resolve) => promptResumeWaiters.push(resolve));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function cancel() {
|
|
60
|
+
cancelInput();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function close() {
|
|
64
|
+
cancel();
|
|
65
|
+
terminalUi?.stop();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
start,
|
|
70
|
+
promptLoop,
|
|
71
|
+
pause,
|
|
72
|
+
resume,
|
|
73
|
+
close,
|
|
74
|
+
};
|
|
75
|
+
}
|
package/lib/input-errors.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export function isInputClosed(error) {
|
|
2
|
-
return error instanceof Error && ["Input closed", "readline was closed"].includes(error.message);
|
|
3
|
-
}
|
|
1
|
+
export function isInputClosed(error) {
|
|
2
|
+
return error instanceof Error && ["Input closed", "readline was closed"].includes(error.message);
|
|
3
|
+
}
|
package/lib/interrupt-state.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export function sigintAction({ activeTurn, interruptRequested, runtimeClosing = false }) {
|
|
2
|
-
if (runtimeClosing) {
|
|
3
|
-
return "force-shutdown";
|
|
4
|
-
}
|
|
5
|
-
if (!activeTurn) {
|
|
6
|
-
return "shutdown";
|
|
7
|
-
}
|
|
8
|
-
return interruptRequested ? "force-shutdown" : "interrupt";
|
|
9
|
-
}
|
|
1
|
+
export function sigintAction({ activeTurn, interruptRequested, runtimeClosing = false }) {
|
|
2
|
+
if (runtimeClosing) {
|
|
3
|
+
return "force-shutdown";
|
|
4
|
+
}
|
|
5
|
+
if (!activeTurn) {
|
|
6
|
+
return "shutdown";
|
|
7
|
+
}
|
|
8
|
+
return interruptRequested ? "force-shutdown" : "interrupt";
|
|
9
|
+
}
|