@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,78 +1,68 @@
1
- import { turnInputMethod } from "./runtime-protocol.js";
2
-
3
- export function createTurnController({ request, state, output, refreshGoalState = () => {}, onTurnStart = () => {} }) {
4
- function submit(text, extra = {}) {
5
- const method = turnInputMethod(state.activeTurn);
6
- if (method === "turn.follow_up") {
7
- output.logQueuedInput(text);
8
- void submitQueuedInput(method, text, text);
9
- return;
10
- }
11
- start(text, extra);
12
- }
13
-
14
- function submitSteering(text, originalInput) {
15
- void submitQueuedInput("turn.steer", text, originalInput);
16
- }
17
-
18
- async function submitQueuedInput(method, text, originalInput) {
19
- try {
20
- await request(method, { input: text });
21
- } catch (error) {
22
- handleSubmissionError(error, originalInput);
23
- }
24
- }
25
-
26
- function handleSubmissionError(error, text) {
27
- output.restoreInputText(text);
28
- if (!state.runtimeClosing) {
29
- output.writeError(error instanceof Error ? error.message : String(error));
30
- }
31
- }
32
-
33
- function start(text, extra = {}) {
34
- if (state.runtimeClosing) {
35
- return;
36
- }
37
- state.activeTurn = true;
38
- state.interruptRequested = false;
39
- state.turnTools = { completed: 0, failed: 0 };
40
- onTurnStart();
41
- output.refreshInputState();
42
- void run(text, extra).catch((error) => handleSubmissionError(error, text));
43
- }
44
-
45
- async function run(text, extra = {}) {
46
- try {
47
- await request("turn.start", { input: text, ...extra });
48
- } finally {
49
- void refreshGoalState();
50
- state.activeTurn = false;
51
- state.interruptRequested = false;
52
- output.closeAssistant();
53
- output.refreshInputState();
54
- }
55
- }
56
-
57
- function interrupt() {
58
- state.interruptRequested = true;
59
- output.cancelInput();
60
- output.closeAssistant();
61
- output.logInterrupt();
62
- void request("turn.interrupt").catch(() => {});
63
- }
64
-
65
- function reset() {
66
- state.activeTurn = false;
67
- state.interruptRequested = false;
68
- output.resetTurnTools();
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.1",
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.4.1",
20
- "@rind-ai/runtime-linux-x64": "0.4.1",
21
- "@rind-ai/runtime-darwin-x64": "0.4.1",
22
- "@rind-ai/runtime-darwin-arm64": "0.4.1"
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
- }