@rind-ai/cli 0.4.1 → 0.6.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/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 +1309 -1060
- 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 +0 -11
- 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 +675 -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/turn-controller.js
CHANGED
|
@@ -1,78 +1,68 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export function createTurnController({ request, state, output, refreshGoalState = () => {}, onTurnStart = () => {} }) {
|
|
4
|
-
function submit(text, extra = {}) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
state.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
output.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
submit,
|
|
73
|
-
submitSteering,
|
|
74
|
-
interrupt,
|
|
75
|
-
isActive: () => state.activeTurn,
|
|
76
|
-
reset,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
1
|
+
import { runtimeMethods } from "./runtime-protocol.js";
|
|
2
|
+
|
|
3
|
+
export function createTurnController({ request, state, output, refreshGoalState = () => {}, onTurnStart = () => {} }) {
|
|
4
|
+
function submit(text, extra = {}) {
|
|
5
|
+
if (state.activeTurn) {
|
|
6
|
+
void submitQueuedInput(runtimeMethods.sessionSteer, text, text, "steering");
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
start(text, extra);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function submitFollowUp(text, originalInput = text) {
|
|
13
|
+
void submitQueuedInput(runtimeMethods.sessionFollowUp, text, originalInput, "follow_up");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function submitQueuedInput(method, text, originalInput, mode) {
|
|
17
|
+
try {
|
|
18
|
+
const result = await request(method, { input: text });
|
|
19
|
+
output.queueInput?.(text, mode, result);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
handleSubmissionError(error, originalInput);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function handleSubmissionError(error, text) {
|
|
26
|
+
output.restoreInputText(text);
|
|
27
|
+
if (!state.runtimeClosing) {
|
|
28
|
+
output.writeError(error instanceof Error ? error.message : String(error));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function start(text, extra = {}) {
|
|
33
|
+
if (state.runtimeClosing) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
state.activeTurn = true;
|
|
37
|
+
state.interruptRequested = false;
|
|
38
|
+
onTurnStart();
|
|
39
|
+
output.refreshInputState();
|
|
40
|
+
void run(text, extra).catch((error) => handleSubmissionError(error, text));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function run(text, extra = {}) {
|
|
44
|
+
try {
|
|
45
|
+
await request(runtimeMethods.sessionPrompt, { input: text, ...extra });
|
|
46
|
+
} finally {
|
|
47
|
+
void refreshGoalState();
|
|
48
|
+
state.activeTurn = false;
|
|
49
|
+
state.interruptRequested = false;
|
|
50
|
+
output.closeAssistant();
|
|
51
|
+
output.refreshInputState();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function interrupt() {
|
|
56
|
+
state.interruptRequested = true;
|
|
57
|
+
output.cancelInput();
|
|
58
|
+
output.closeAssistant();
|
|
59
|
+
output.logInterrupt();
|
|
60
|
+
void request(runtimeMethods.sessionCancel).catch(() => {});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
submit,
|
|
65
|
+
submitFollowUp,
|
|
66
|
+
interrupt,
|
|
67
|
+
};
|
|
68
|
+
}
|
package/package.json
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@rind-ai/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Rind command-line client",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"repository": "https://github.com/Azzurroooo/rind.git",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"bin": {
|
|
9
|
-
"rind": "bin/rind.js"
|
|
10
|
-
},
|
|
11
|
-
"files": [
|
|
12
|
-
"bin",
|
|
13
|
-
"lib"
|
|
14
|
-
],
|
|
15
|
-
"engines": {
|
|
16
|
-
"node": ">=18"
|
|
17
|
-
},
|
|
18
|
-
"optionalDependencies": {
|
|
19
|
-
"@rind-ai/runtime-win32-x64": "0.
|
|
20
|
-
"@rind-ai/runtime-linux-x64": "0.
|
|
21
|
-
"@rind-ai/runtime-darwin-x64": "0.
|
|
22
|
-
"@rind-ai/runtime-darwin-arm64": "0.
|
|
23
|
-
},
|
|
24
|
-
"publishConfig": {
|
|
25
|
-
"access": "public",
|
|
26
|
-
"registry": "https://registry.npmjs.org"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@rind-ai/cli",
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "Rind command-line client",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "https://github.com/Azzurroooo/rind.git",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"bin": {
|
|
9
|
+
"rind": "bin/rind.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin",
|
|
13
|
+
"lib"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=18"
|
|
17
|
+
},
|
|
18
|
+
"optionalDependencies": {
|
|
19
|
+
"@rind-ai/runtime-win32-x64": "0.6.0",
|
|
20
|
+
"@rind-ai/runtime-linux-x64": "0.6.0",
|
|
21
|
+
"@rind-ai/runtime-darwin-x64": "0.6.0",
|
|
22
|
+
"@rind-ai/runtime-darwin-arm64": "0.6.0"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public",
|
|
26
|
+
"registry": "https://registry.npmjs.org"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export function createAssistantStreamBuffer() {
|
|
2
|
-
let pending = "";
|
|
3
|
-
|
|
4
|
-
return {
|
|
5
|
-
push(text, holdPartialLine = false) {
|
|
6
|
-
const output = pending + String(text || "");
|
|
7
|
-
if (!holdPartialLine || output.endsWith("\n")) {
|
|
8
|
-
pending = "";
|
|
9
|
-
return output;
|
|
10
|
-
}
|
|
11
|
-
const splitAt = output.lastIndexOf("\n");
|
|
12
|
-
if (splitAt === -1) {
|
|
13
|
-
pending = output;
|
|
14
|
-
return "";
|
|
15
|
-
}
|
|
16
|
-
pending = output.slice(splitAt + 1);
|
|
17
|
-
return output.slice(0, splitAt + 1);
|
|
18
|
-
},
|
|
19
|
-
flush() {
|
|
20
|
-
const output = pending;
|
|
21
|
-
pending = "";
|
|
22
|
-
return output;
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
}
|