miii-cli 0.2.5 → 0.2.6
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 +2 -2
- package/dist/tui/hooks/useRunLoop.js +11 -2
- package/dist/tui/printer.js +33 -2
- package/dist/tui/thinking.js +25 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
│ model: qwen2.5-coder:7b │
|
|
9
9
|
├──────────────────────────────────────────────────────────────────────┤
|
|
10
10
|
│ ✦ cross-referencing vibes… 12s │
|
|
11
|
-
│ ⚙ running patch_file…
|
|
12
|
-
│ ⚙ running run_tests…
|
|
11
|
+
│ ⚙ running patch_file… │
|
|
12
|
+
│ ⚙ running run_tests… │
|
|
13
13
|
├──────────────────────────────────────────────────────────────────────┤
|
|
14
14
|
│ ❯ █ │
|
|
15
15
|
│ @ file / command enter send ctrl+c exit │
|
|
@@ -6,6 +6,7 @@ import { shouldCompact, compactContext } from '../../tasks/compactor.js';
|
|
|
6
6
|
import * as printer from '../printer.js';
|
|
7
7
|
const MAX_TOOL_DEPTH = 6;
|
|
8
8
|
const FILE_EDIT_TOOLS = new Set(['edit_file', 'create_file', 'patch_file', 'delete_file']);
|
|
9
|
+
const SHOW_RESULT_TOOLS = new Set(['run_tests', 'git_commit']);
|
|
9
10
|
export function useRunLoop(config, currentModelRef, pushHistory) {
|
|
10
11
|
const [status, setStatus] = useState('idle');
|
|
11
12
|
const [tick, setTick] = useState(0);
|
|
@@ -39,17 +40,22 @@ export function useRunLoop(config, currentModelRef, pushHistory) {
|
|
|
39
40
|
signal: abortRef.current.signal,
|
|
40
41
|
async onDone(fullText) {
|
|
41
42
|
const pendingTools = [];
|
|
43
|
+
const textParts = [];
|
|
42
44
|
const parser = new StreamParser();
|
|
43
45
|
for (const item of [...parser.feed(fullText), ...parser.flush()]) {
|
|
44
46
|
if (item.type === 'tool_call')
|
|
45
47
|
pendingTools.push({ name: item.toolName, args: item.toolArgs });
|
|
48
|
+
else
|
|
49
|
+
textParts.push(item.content);
|
|
46
50
|
}
|
|
47
51
|
if (!pendingTools.length) {
|
|
48
52
|
const bare = extractBareToolCall(fullText);
|
|
49
53
|
if (bare)
|
|
50
54
|
pendingTools.push({ name: bare.name, args: bare.args });
|
|
51
55
|
}
|
|
52
|
-
|
|
56
|
+
const displayText = textParts.join('').trim();
|
|
57
|
+
if (displayText)
|
|
58
|
+
printer.assistantMsg(displayText);
|
|
53
59
|
pushHistoryRef.current({ role: 'assistant', content: fullText });
|
|
54
60
|
if (!pendingTools.length) {
|
|
55
61
|
const hasFencedCode = /```[\w]*\n[\s\S]{50,}?\n```/.test(fullText);
|
|
@@ -72,8 +78,10 @@ export function useRunLoop(config, currentModelRef, pushHistory) {
|
|
|
72
78
|
setCurrentTool(tc.name);
|
|
73
79
|
if (tool) {
|
|
74
80
|
try {
|
|
81
|
+
printer.toolCallStart(tc.name, tc.args);
|
|
75
82
|
const result = await tool.execute(tc.args);
|
|
76
|
-
|
|
83
|
+
if (SHOW_RESULT_TOOLS.has(tc.name))
|
|
84
|
+
printer.toolMsg(tc.name, result);
|
|
77
85
|
next.push({ role: 'user', content: `Tool ${tc.name} result:\n${result}` });
|
|
78
86
|
}
|
|
79
87
|
catch (e) {
|
|
@@ -98,6 +106,7 @@ export function useRunLoop(config, currentModelRef, pushHistory) {
|
|
|
98
106
|
if (testTool) {
|
|
99
107
|
setCurrentTool('run_tests');
|
|
100
108
|
try {
|
|
109
|
+
printer.toolCallStart('run_tests', {});
|
|
101
110
|
const testResult = await testTool.execute({});
|
|
102
111
|
if (testResult && !testResult.startsWith('(no test script') && !testResult.startsWith('(no package.json')) {
|
|
103
112
|
printer.toolMsg('run_tests', testResult);
|
package/dist/tui/printer.js
CHANGED
|
@@ -24,9 +24,18 @@ function stripMarkdown(s) {
|
|
|
24
24
|
function formatContent(text) {
|
|
25
25
|
const lines = text.split('\n');
|
|
26
26
|
let inCode = false;
|
|
27
|
+
let inToolCall = false;
|
|
27
28
|
const out = [];
|
|
28
29
|
for (const line of lines) {
|
|
29
|
-
if (line.startsWith('<tool_call>')
|
|
30
|
+
if (line.startsWith('<tool_call>')) {
|
|
31
|
+
inToolCall = true;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (line.startsWith('</tool_call>')) {
|
|
35
|
+
inToolCall = false;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (inToolCall)
|
|
30
39
|
continue;
|
|
31
40
|
if (line.startsWith('```')) {
|
|
32
41
|
inCode = !inCode;
|
|
@@ -41,6 +50,23 @@ function formatContent(text) {
|
|
|
41
50
|
}
|
|
42
51
|
return out.join('\n');
|
|
43
52
|
}
|
|
53
|
+
function truncate(s, n) {
|
|
54
|
+
return s.length > n ? s.slice(0, n) + '…' : s;
|
|
55
|
+
}
|
|
56
|
+
function toolArgSummary(args) {
|
|
57
|
+
if (args.message)
|
|
58
|
+
return `"${truncate(String(args.message), 60)}"`;
|
|
59
|
+
if (args.path)
|
|
60
|
+
return String(args.path);
|
|
61
|
+
if (args.command)
|
|
62
|
+
return truncate(String(args.command), 60);
|
|
63
|
+
if (args.query)
|
|
64
|
+
return `"${truncate(String(args.query), 60)}"`;
|
|
65
|
+
if (args.from)
|
|
66
|
+
return `${args.from} → ${args.to}`;
|
|
67
|
+
const first = Object.values(args)[0];
|
|
68
|
+
return first ? truncate(String(first), 60) : '';
|
|
69
|
+
}
|
|
44
70
|
export function welcome(provider, model, cwd, version, updateAvailable, linked) {
|
|
45
71
|
const cols = Math.min(process.stdout.columns ?? 80, 100);
|
|
46
72
|
const innerW = cols - 2;
|
|
@@ -101,12 +127,17 @@ export function userMsg(text) {
|
|
|
101
127
|
export function assistantMsg(text) {
|
|
102
128
|
console.log(`\n${bold(green('miii'))}\n${formatContent(text)}`);
|
|
103
129
|
}
|
|
130
|
+
export function toolCallStart(name, args) {
|
|
131
|
+
const summary = toolArgSummary(args);
|
|
132
|
+
process.stdout.write(` ${gray('⎿')} ${cyan(name)}${summary ? gray('(' + summary + ')') : ''}\n`);
|
|
133
|
+
}
|
|
104
134
|
export function toolMsg(name, result) {
|
|
105
135
|
const preview = result.length > 250 ? result.slice(0, 250) + '…' : result;
|
|
106
136
|
const body = preview.trim()
|
|
107
137
|
? preview.split('\n').map(l => gray(' ' + l)).join('\n')
|
|
108
138
|
: '';
|
|
109
|
-
|
|
139
|
+
if (body)
|
|
140
|
+
console.log(body);
|
|
110
141
|
}
|
|
111
142
|
export function systemMsg(text) {
|
|
112
143
|
console.log(gray(`─ ${text}`));
|
package/dist/tui/thinking.js
CHANGED
|
@@ -24,5 +24,30 @@ export const THINKING_PHRASES = [
|
|
|
24
24
|
'applying artificial to the intelligence…',
|
|
25
25
|
'phoning a friend who also doesn\'t know…',
|
|
26
26
|
'checking if this is even my problem to solve…',
|
|
27
|
+
'rebooting common sense… this may take a while…',
|
|
28
|
+
'performing a very convincing impression of thinking…',
|
|
29
|
+
'searching for wisdom in all the wrong places…',
|
|
30
|
+
'warming up the neurons (both of them)…',
|
|
31
|
+
'confidently striding toward the wrong answer…',
|
|
32
|
+
'consulting my gut. it says maybe…',
|
|
33
|
+
'loading… just kidding, still loading…',
|
|
34
|
+
'asking the universe. universe has not replied…',
|
|
35
|
+
'vigorously nodding while understanding nothing…',
|
|
36
|
+
'doing math on my fingers (ran out of fingers)…',
|
|
37
|
+
'the confidence is fake. the effort is real. probably…',
|
|
38
|
+
'entering a fugue state. for your benefit…',
|
|
39
|
+
'mining the depths of mediocrity…',
|
|
40
|
+
'compiling a list of plausible nonsense…',
|
|
41
|
+
'this would be faster if I knew what I was doing…',
|
|
42
|
+
'buffering at the speed of thought…',
|
|
43
|
+
'holding three contradictory opinions simultaneously…',
|
|
44
|
+
'interpolating between guesses…',
|
|
45
|
+
'rewinding the context window with a pencil…',
|
|
46
|
+
'waiting for a sign. any sign…',
|
|
47
|
+
'tracing the error back to its origin: me…',
|
|
48
|
+
'the logic checks out if you squint…',
|
|
49
|
+
'reasoning from first principles I just invented…',
|
|
50
|
+
'generating tokens and praying for coherence…',
|
|
51
|
+
'one sec — dropped all my thoughts, picking them up…',
|
|
27
52
|
];
|
|
28
53
|
export const SPARKLE = ['✦', '✧', '✶', '✷', '✸', '✹'];
|