@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/slash-menu-state.js
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
export function createSlashMenuState(commands) {
|
|
2
|
-
let text = "";
|
|
3
|
-
let selected = 0;
|
|
4
|
-
let dismissed = false;
|
|
5
|
-
return {
|
|
6
|
-
input() {
|
|
7
|
-
return text;
|
|
8
|
-
},
|
|
9
|
-
matches() {
|
|
10
|
-
return dismissed ? [] : matchingCommands(commands, text);
|
|
11
|
-
},
|
|
12
|
-
selectedIndex() {
|
|
13
|
-
return selected;
|
|
14
|
-
},
|
|
15
|
-
selectedCommand() {
|
|
16
|
-
return this.matches()[selected] || null;
|
|
17
|
-
},
|
|
18
|
-
handleKey(chunk, key = {}) {
|
|
19
|
-
if (key.name === "escape") {
|
|
20
|
-
dismissed = true;
|
|
21
|
-
selected = 0;
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
const matches = this.matches();
|
|
25
|
-
if (matches.length && key.name === "up") {
|
|
26
|
-
selected = selected <= 0 ? matches.length - 1 : selected - 1;
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
if (matches.length && key.name === "down") {
|
|
30
|
-
selected = selected >= matches.length - 1 ? 0 : selected + 1;
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
if (chunk && !key.ctrl && !key.meta && String(chunk) >= " ") {
|
|
34
|
-
text += String(chunk);
|
|
35
|
-
selected = 0;
|
|
36
|
-
dismissed = false;
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
return false;
|
|
40
|
-
},
|
|
41
|
-
setInput(value) {
|
|
42
|
-
const nextText = String(value || "");
|
|
43
|
-
if (nextText !== text) {
|
|
44
|
-
selected = 0;
|
|
45
|
-
dismissed = false;
|
|
46
|
-
}
|
|
47
|
-
text = nextText;
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function matchingCommands(commands, line) {
|
|
53
|
-
const text = String(line || "");
|
|
54
|
-
if (!text.startsWith("/") || /\s/.test(text)) {
|
|
55
|
-
return [];
|
|
56
|
-
}
|
|
57
|
-
const token = text.slice(1).toLowerCase();
|
|
58
|
-
return commands.filter((command) => command.name.startsWith(token));
|
|
59
|
-
}
|
|
1
|
+
export function createSlashMenuState(commands) {
|
|
2
|
+
let text = "";
|
|
3
|
+
let selected = 0;
|
|
4
|
+
let dismissed = false;
|
|
5
|
+
return {
|
|
6
|
+
input() {
|
|
7
|
+
return text;
|
|
8
|
+
},
|
|
9
|
+
matches() {
|
|
10
|
+
return dismissed ? [] : matchingCommands(commands, text);
|
|
11
|
+
},
|
|
12
|
+
selectedIndex() {
|
|
13
|
+
return selected;
|
|
14
|
+
},
|
|
15
|
+
selectedCommand() {
|
|
16
|
+
return this.matches()[selected] || null;
|
|
17
|
+
},
|
|
18
|
+
handleKey(chunk, key = {}) {
|
|
19
|
+
if (key.name === "escape") {
|
|
20
|
+
dismissed = true;
|
|
21
|
+
selected = 0;
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
const matches = this.matches();
|
|
25
|
+
if (matches.length && key.name === "up") {
|
|
26
|
+
selected = selected <= 0 ? matches.length - 1 : selected - 1;
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
if (matches.length && key.name === "down") {
|
|
30
|
+
selected = selected >= matches.length - 1 ? 0 : selected + 1;
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
if (chunk && !key.ctrl && !key.meta && String(chunk) >= " ") {
|
|
34
|
+
text += String(chunk);
|
|
35
|
+
selected = 0;
|
|
36
|
+
dismissed = false;
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
},
|
|
41
|
+
setInput(value) {
|
|
42
|
+
const nextText = String(value || "");
|
|
43
|
+
if (nextText !== text) {
|
|
44
|
+
selected = 0;
|
|
45
|
+
dismissed = false;
|
|
46
|
+
}
|
|
47
|
+
text = nextText;
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function matchingCommands(commands, line) {
|
|
53
|
+
const text = String(line || "");
|
|
54
|
+
if (!text.startsWith("/") || /\s/.test(text)) {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
const token = text.slice(1).toLowerCase();
|
|
58
|
+
return commands.filter((command) => command.name.startsWith(token));
|
|
59
|
+
}
|