@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,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
+ }