@ruvnet/open-claude-code 2.0.1 → 2.1.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.
- package/README.md +113 -0
- package/package.json +20 -2
- package/src/config/env.mjs +0 -2
- package/src/config/settings.mjs +24 -130
- package/src/core/session.mjs +4 -145
- package/src/core/system-prompt.mjs +43 -47
- package/src/index.mjs +21 -31
- package/src/permissions/checker.mjs +8 -79
- package/src/tools/bash.mjs +3 -40
- package/src/ui/app.mjs +286 -0
- package/src/ui/commands.mjs +83 -70
- package/src/ui/components.mjs +219 -0
- package/src/ui/ink-app.mjs +13 -52
- package/src/ui/markdown.mjs +278 -0
- package/src/ui/repl.mjs +10 -25
- package/test/test.mjs +0 -800
package/src/ui/repl.mjs
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* REPL — interactive read-eval-print loop for open-claude-code.
|
|
3
3
|
*
|
|
4
|
-
* Supports all 39
|
|
5
|
-
* streaming output with spinner
|
|
4
|
+
* Supports all 39 slash commands, skill invocation, enhanced UI,
|
|
5
|
+
* and streaming output with spinner and token display.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import readline from 'readline';
|
|
9
9
|
import { executeCommand, getCompletions, COMMANDS } from './commands.mjs';
|
|
10
|
-
import { Spinner, highlightCode, renderStatusBar, renderToolProgress
|
|
10
|
+
import { Spinner, highlightCode, renderStatusBar, renderToolProgress } from './ink-app.mjs';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Start the interactive REPL.
|
|
14
14
|
* @param {object} loop - agent loop instance (from createAgentLoop)
|
|
15
15
|
* @param {object} settings - loaded settings
|
|
16
|
-
* @param {object} [permissions] - permission checker to wire readline into
|
|
17
16
|
*/
|
|
18
|
-
export async function startRepl(loop, settings
|
|
17
|
+
export async function startRepl(loop, settings) {
|
|
19
18
|
const rl = readline.createInterface({
|
|
20
19
|
input: process.stdin,
|
|
21
20
|
output: process.stdout,
|
|
@@ -29,11 +28,6 @@ export async function startRepl(loop, settings, permissions) {
|
|
|
29
28
|
},
|
|
30
29
|
});
|
|
31
30
|
|
|
32
|
-
// Wire readline into permission checker for interactive prompts
|
|
33
|
-
if (permissions && typeof permissions === 'object') {
|
|
34
|
-
permissions.rl = rl;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
31
|
console.log('\x1b[1mopen-claude-code v2\x1b[0m — type your prompt or /help');
|
|
38
32
|
console.log('\x1b[2mModel: %s | Tools: %d\x1b[0m', loop.state.model || 'default', loop.state.tools?.list?.()?.length || 0);
|
|
39
33
|
console.log('');
|
|
@@ -64,9 +58,9 @@ export async function startRepl(loop, settings, permissions) {
|
|
|
64
58
|
}
|
|
65
59
|
}
|
|
66
60
|
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
console.log(
|
|
61
|
+
const { response, exit } = executeCommand(trimmed, loop.state);
|
|
62
|
+
if (exit) { rl.close(); return; }
|
|
63
|
+
console.log(response);
|
|
70
64
|
askPrompt();
|
|
71
65
|
return;
|
|
72
66
|
}
|
|
@@ -86,7 +80,7 @@ export async function startRepl(loop, settings, permissions) {
|
|
|
86
80
|
}
|
|
87
81
|
console.log('');
|
|
88
82
|
|
|
89
|
-
// Show
|
|
83
|
+
// Show status bar if enabled
|
|
90
84
|
if (settings.showTokenUsage !== false) {
|
|
91
85
|
process.stderr.write(renderStatusBar(loop.state) + '\n');
|
|
92
86
|
}
|
|
@@ -116,12 +110,7 @@ function renderEvent(event) {
|
|
|
116
110
|
break;
|
|
117
111
|
case 'thinking':
|
|
118
112
|
if (process.env.SHOW_THINKING) {
|
|
119
|
-
process.stdout.write(`\x1b[
|
|
120
|
-
}
|
|
121
|
-
break;
|
|
122
|
-
case 'thinking_complete':
|
|
123
|
-
if (process.env.SHOW_THINKING) {
|
|
124
|
-
process.stderr.write(`\x1b[90m[thinking complete]\x1b[0m\n`);
|
|
113
|
+
process.stdout.write(`\x1b[2m${event.text}\x1b[0m`);
|
|
125
114
|
}
|
|
126
115
|
break;
|
|
127
116
|
case 'tool_progress':
|
|
@@ -135,11 +124,7 @@ function renderEvent(event) {
|
|
|
135
124
|
break;
|
|
136
125
|
case 'assistant':
|
|
137
126
|
if (event.content) {
|
|
138
|
-
|
|
139
|
-
let text = event.content;
|
|
140
|
-
text = highlightCode(text);
|
|
141
|
-
text = renderMarkdown(text);
|
|
142
|
-
process.stdout.write(text);
|
|
127
|
+
process.stdout.write(highlightCode(event.content));
|
|
143
128
|
}
|
|
144
129
|
break;
|
|
145
130
|
case 'compaction':
|