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