@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/terminal-key.js
CHANGED
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
const ARROW_KEYS = {
|
|
2
|
-
A: "up",
|
|
3
|
-
B: "down",
|
|
4
|
-
C: "right",
|
|
5
|
-
D: "left",
|
|
6
|
-
H: "home",
|
|
7
|
-
F: "end",
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export function parseTerminalKey(raw = "") {
|
|
11
|
-
const value = String(raw || "");
|
|
12
|
-
if (!value) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
if (value === "\r" || value === "\x1bOM") {
|
|
16
|
-
return key("enter");
|
|
17
|
-
}
|
|
18
|
-
if (value === "\n") {
|
|
19
|
-
return key("j", 5);
|
|
20
|
-
}
|
|
21
|
-
if (value === "\t") {
|
|
22
|
-
return key("tab");
|
|
23
|
-
}
|
|
24
|
-
if (value === "\b") {
|
|
25
|
-
return key("backspace", process.platform === "win32" && process.env.WT_SESSION ? 5 : 1);
|
|
26
|
-
}
|
|
27
|
-
if (value === "\x7f") {
|
|
28
|
-
return key("backspace");
|
|
29
|
-
}
|
|
30
|
-
if (value === "\x1f") {
|
|
31
|
-
return key("-", 5);
|
|
32
|
-
}
|
|
33
|
-
if (value === "\x1b") {
|
|
34
|
-
return key("escape");
|
|
35
|
-
}
|
|
36
|
-
if (value.length === 1) {
|
|
37
|
-
const code = value.charCodeAt(0);
|
|
38
|
-
if (code >= 1 && code <= 26) {
|
|
39
|
-
return key(String.fromCharCode(96 + code), 5);
|
|
40
|
-
}
|
|
41
|
-
if (code < 32) {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
return { kind: "text", name: "", text: value };
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const modifiedArrow = value.match(/^\x1b\[1;([2-8])([ABCDHF])$/);
|
|
48
|
-
if (modifiedArrow) {
|
|
49
|
-
return key(ARROW_KEYS[modifiedArrow[2]], Number(modifiedArrow[1]));
|
|
50
|
-
}
|
|
51
|
-
const tilde = value.match(/^\x1b\[([0-9]+)(?:;([2-8]))?~$/);
|
|
52
|
-
if (tilde) {
|
|
53
|
-
return Number(tilde[1]) === 3 ? key("delete", Number(tilde[2] || 1)) : null;
|
|
54
|
-
}
|
|
55
|
-
const csiKey = value.match(/^\x1b\[([ABCDHFZ])$/);
|
|
56
|
-
if (csiKey) {
|
|
57
|
-
return csiKey[1] === "Z" ? key("tab", 2) : key(ARROW_KEYS[csiKey[1]]);
|
|
58
|
-
}
|
|
59
|
-
const ss3Key = value.match(/^\x1bO([ABCDHF])$/);
|
|
60
|
-
if (ss3Key) {
|
|
61
|
-
return key(ARROW_KEYS[ss3Key[1]]);
|
|
62
|
-
}
|
|
63
|
-
const csiEnter = value.match(/^\x1b\[13;([2-8])u$/);
|
|
64
|
-
if (csiEnter) {
|
|
65
|
-
return key("enter", Number(csiEnter[1]));
|
|
66
|
-
}
|
|
67
|
-
const csiMinus = value.match(/^\x1b\[45;([2-8])u$/);
|
|
68
|
-
if (csiMinus) {
|
|
69
|
-
return key("-", Number(csiMinus[1]));
|
|
70
|
-
}
|
|
71
|
-
const modifiedEnter = value.match(/^\x1b\[27;([2-8]);13~$/);
|
|
72
|
-
if (modifiedEnter) {
|
|
73
|
-
return key("enter", Number(modifiedEnter[1]));
|
|
74
|
-
}
|
|
75
|
-
if (value === "\x1b\r") {
|
|
76
|
-
return key("enter", 2);
|
|
77
|
-
}
|
|
78
|
-
if (value.startsWith("\x1b") && value.length === 2) {
|
|
79
|
-
return key(value[1] === "\x7f" || value[1] === "\b" ? "backspace" : value[1], 3);
|
|
80
|
-
}
|
|
81
|
-
if (value.startsWith("\x1b")) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
return { kind: "text", name: "", text: value };
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function key(name, modifier = 1) {
|
|
88
|
-
const bits = modifier - 1;
|
|
89
|
-
return {
|
|
90
|
-
kind: "key",
|
|
91
|
-
name,
|
|
92
|
-
shift: Boolean(bits & 1),
|
|
93
|
-
alt: Boolean(bits & 2),
|
|
94
|
-
ctrl: Boolean(bits & 4),
|
|
95
|
-
text: "",
|
|
96
|
-
};
|
|
97
|
-
}
|
|
1
|
+
const ARROW_KEYS = {
|
|
2
|
+
A: "up",
|
|
3
|
+
B: "down",
|
|
4
|
+
C: "right",
|
|
5
|
+
D: "left",
|
|
6
|
+
H: "home",
|
|
7
|
+
F: "end",
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function parseTerminalKey(raw = "") {
|
|
11
|
+
const value = String(raw || "");
|
|
12
|
+
if (!value) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
if (value === "\r" || value === "\x1bOM") {
|
|
16
|
+
return key("enter");
|
|
17
|
+
}
|
|
18
|
+
if (value === "\n") {
|
|
19
|
+
return key("j", 5);
|
|
20
|
+
}
|
|
21
|
+
if (value === "\t") {
|
|
22
|
+
return key("tab");
|
|
23
|
+
}
|
|
24
|
+
if (value === "\b") {
|
|
25
|
+
return key("backspace", process.platform === "win32" && process.env.WT_SESSION ? 5 : 1);
|
|
26
|
+
}
|
|
27
|
+
if (value === "\x7f") {
|
|
28
|
+
return key("backspace");
|
|
29
|
+
}
|
|
30
|
+
if (value === "\x1f") {
|
|
31
|
+
return key("-", 5);
|
|
32
|
+
}
|
|
33
|
+
if (value === "\x1b") {
|
|
34
|
+
return key("escape");
|
|
35
|
+
}
|
|
36
|
+
if (value.length === 1) {
|
|
37
|
+
const code = value.charCodeAt(0);
|
|
38
|
+
if (code >= 1 && code <= 26) {
|
|
39
|
+
return key(String.fromCharCode(96 + code), 5);
|
|
40
|
+
}
|
|
41
|
+
if (code < 32) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return { kind: "text", name: "", text: value };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const modifiedArrow = value.match(/^\x1b\[1;([2-8])([ABCDHF])$/);
|
|
48
|
+
if (modifiedArrow) {
|
|
49
|
+
return key(ARROW_KEYS[modifiedArrow[2]], Number(modifiedArrow[1]));
|
|
50
|
+
}
|
|
51
|
+
const tilde = value.match(/^\x1b\[([0-9]+)(?:;([2-8]))?~$/);
|
|
52
|
+
if (tilde) {
|
|
53
|
+
return Number(tilde[1]) === 3 ? key("delete", Number(tilde[2] || 1)) : null;
|
|
54
|
+
}
|
|
55
|
+
const csiKey = value.match(/^\x1b\[([ABCDHFZ])$/);
|
|
56
|
+
if (csiKey) {
|
|
57
|
+
return csiKey[1] === "Z" ? key("tab", 2) : key(ARROW_KEYS[csiKey[1]]);
|
|
58
|
+
}
|
|
59
|
+
const ss3Key = value.match(/^\x1bO([ABCDHF])$/);
|
|
60
|
+
if (ss3Key) {
|
|
61
|
+
return key(ARROW_KEYS[ss3Key[1]]);
|
|
62
|
+
}
|
|
63
|
+
const csiEnter = value.match(/^\x1b\[13;([2-8])u$/);
|
|
64
|
+
if (csiEnter) {
|
|
65
|
+
return key("enter", Number(csiEnter[1]));
|
|
66
|
+
}
|
|
67
|
+
const csiMinus = value.match(/^\x1b\[45;([2-8])u$/);
|
|
68
|
+
if (csiMinus) {
|
|
69
|
+
return key("-", Number(csiMinus[1]));
|
|
70
|
+
}
|
|
71
|
+
const modifiedEnter = value.match(/^\x1b\[27;([2-8]);13~$/);
|
|
72
|
+
if (modifiedEnter) {
|
|
73
|
+
return key("enter", Number(modifiedEnter[1]));
|
|
74
|
+
}
|
|
75
|
+
if (value === "\x1b\r") {
|
|
76
|
+
return key("enter", 2);
|
|
77
|
+
}
|
|
78
|
+
if (value.startsWith("\x1b") && value.length === 2) {
|
|
79
|
+
return key(value[1] === "\x7f" || value[1] === "\b" ? "backspace" : value[1], 3);
|
|
80
|
+
}
|
|
81
|
+
if (value.startsWith("\x1b")) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
return { kind: "text", name: "", text: value };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function key(name, modifier = 1) {
|
|
88
|
+
const bits = modifier - 1;
|
|
89
|
+
return {
|
|
90
|
+
kind: "key",
|
|
91
|
+
name,
|
|
92
|
+
shift: Boolean(bits & 1),
|
|
93
|
+
alt: Boolean(bits & 2),
|
|
94
|
+
ctrl: Boolean(bits & 4),
|
|
95
|
+
text: "",
|
|
96
|
+
};
|
|
97
|
+
}
|