kovence-cli 1.0.1 → 1.0.3
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/package.json +2 -2
- package/providers.js +40 -3
- package/src/agent/turn.js +8 -0
- package/src/cli/sinks.js +27 -6
- package/tui.js +16 -5
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kovence-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Kovence CLI — Fast zero-dependency multi-step AI coding-agent CLI harness",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"homepage": "https://
|
|
6
|
+
"homepage": "https://kovence-cli.kovence.com",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/MillatSakib/kovence-cli.git"
|
package/providers.js
CHANGED
|
@@ -378,6 +378,43 @@ async function streamProviderTurn({
|
|
|
378
378
|
}
|
|
379
379
|
};
|
|
380
380
|
|
|
381
|
+
let lastProgressUpdate = 0;
|
|
382
|
+
const updateToolProgress = () => {
|
|
383
|
+
if (firstTokenAt === null) firstTokenAt = Date.now();
|
|
384
|
+
if (printedHeader) return;
|
|
385
|
+
const now = Date.now();
|
|
386
|
+
if (now - lastProgressUpdate < 80) return;
|
|
387
|
+
lastProgressUpdate = now;
|
|
388
|
+
|
|
389
|
+
const activeEntry = [...toolMap.values()].pop();
|
|
390
|
+
const toolName = activeEntry?.function?.name || "";
|
|
391
|
+
const args = activeEntry?.function?.arguments || "";
|
|
392
|
+
const isWrite = /write_file|edit_file|multi_edit|apply_patch/.test(toolName);
|
|
393
|
+
const isRead = /read_file|glob_files|grep_files|file_search|list_directory/.test(toolName);
|
|
394
|
+
|
|
395
|
+
let target = "";
|
|
396
|
+
const m = args.match(/"(?:path|target|file)":\s*"([^"]+)"/);
|
|
397
|
+
if (m) {
|
|
398
|
+
const p = m[1];
|
|
399
|
+
target = p.length > 25 ? `...${p.slice(-22)}` : p;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const charCount = args.length;
|
|
403
|
+
const charSuffix = charCount > 100 ? ` (${Math.round(charCount / 100) / 10}k chars)` : "";
|
|
404
|
+
|
|
405
|
+
let label = "Thinking...";
|
|
406
|
+
if (isWrite) {
|
|
407
|
+
label = target ? `Writing ${target}${charSuffix}...` : `Writing code${charSuffix}...`;
|
|
408
|
+
} else if (isRead) {
|
|
409
|
+
label = target ? `Reading ${target}...` : `Reading codebase...`;
|
|
410
|
+
} else if (toolName) {
|
|
411
|
+
label = target ? `${toolName}(${target})...` : `Preparing ${toolName}...`;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
streamUi.setLabel?.(label);
|
|
415
|
+
sink.setBusy?.(label);
|
|
416
|
+
};
|
|
417
|
+
|
|
381
418
|
const mergeOpenAITools = (deltas) => {
|
|
382
419
|
for (const d of deltas) {
|
|
383
420
|
const idx = d.index ?? 0;
|
|
@@ -423,23 +460,23 @@ async function streamProviderTurn({
|
|
|
423
460
|
};
|
|
424
461
|
}
|
|
425
462
|
} else if (json.type === "content_block_start" && json.content_block?.type === "tool_use") {
|
|
426
|
-
markFirstToken(false);
|
|
427
463
|
const idx = json.index ?? toolMap.size;
|
|
428
464
|
toolMap.set(idx, {
|
|
429
465
|
id: json.content_block.id || `call_${idx}`,
|
|
430
466
|
type: "function",
|
|
431
467
|
function: { name: json.content_block.name || "", arguments: "" },
|
|
432
468
|
});
|
|
469
|
+
updateToolProgress();
|
|
433
470
|
} else if (json.type === "content_block_delta") {
|
|
434
471
|
if (json.delta?.type === "text_delta" && json.delta.text) {
|
|
435
472
|
markFirstToken(true);
|
|
436
473
|
streamUi.write(json.delta.text);
|
|
437
474
|
fullText += json.delta.text;
|
|
438
475
|
} else if (json.delta?.type === "input_json_delta" && json.delta.partial_json) {
|
|
439
|
-
markFirstToken(false);
|
|
440
476
|
const idx = json.index ?? 0;
|
|
441
477
|
const entry = toolMap.get(idx);
|
|
442
478
|
if (entry) entry.function.arguments += json.delta.partial_json;
|
|
479
|
+
updateToolProgress();
|
|
443
480
|
}
|
|
444
481
|
}
|
|
445
482
|
return;
|
|
@@ -450,8 +487,8 @@ async function streamProviderTurn({
|
|
|
450
487
|
if (choice?.finish_reason) finishReason = choice.finish_reason;
|
|
451
488
|
const delta = choice?.delta;
|
|
452
489
|
if (delta?.tool_calls?.length) {
|
|
453
|
-
markFirstToken(false);
|
|
454
490
|
mergeOpenAITools(delta.tool_calls);
|
|
491
|
+
updateToolProgress();
|
|
455
492
|
}
|
|
456
493
|
const token = delta?.content ?? json.response ?? "";
|
|
457
494
|
if (token) {
|
package/src/agent/turn.js
CHANGED
|
@@ -453,6 +453,14 @@ async function runToolCalls(state, toolCalls, sink) {
|
|
|
453
453
|
if (name === "download_file") {
|
|
454
454
|
state.isDownloading = true;
|
|
455
455
|
sink.setBusy("Downloading (commands paused)...");
|
|
456
|
+
} else if (name === "write_file" || name === "edit_file" || name === "multi_edit") {
|
|
457
|
+
const target = parsedArgs.path ? parsedArgs.path.split("/").pop() : "";
|
|
458
|
+
sink.setBusy(`Writing ${target || "file"}...`);
|
|
459
|
+
} else if (name === "read_file" || name === "glob_files" || name === "grep_files") {
|
|
460
|
+
const target = parsedArgs.path ? parsedArgs.path.split("/").pop() : "";
|
|
461
|
+
sink.setBusy(`Reading ${target || "code"}...`);
|
|
462
|
+
} else {
|
|
463
|
+
sink.setBusy(`Running ${name}...`);
|
|
456
464
|
}
|
|
457
465
|
try {
|
|
458
466
|
const out = await executeTool(
|
package/src/cli/sinks.js
CHANGED
|
@@ -51,17 +51,21 @@ function createPlainSink(interactive, { headless = false, jsonMode = false } = {
|
|
|
51
51
|
const dots = [" ", ". ", ".. ", "..."];
|
|
52
52
|
let tick = 0;
|
|
53
53
|
let stopped = false;
|
|
54
|
+
let currentLabel = label;
|
|
54
55
|
const render = () => {
|
|
55
56
|
const symbol = frames[tick % frames.length];
|
|
56
57
|
const blink = dots[Math.floor(tick / 2) % dots.length];
|
|
57
58
|
process.stdout.write(
|
|
58
|
-
`\r\x1b[K${C.cyan}${prefix}${C.reset}${C.yellow}${symbol} ${
|
|
59
|
+
`\r\x1b[K${C.cyan}${prefix}${C.reset}${C.yellow}${symbol} ${currentLabel}${blink}${C.reset}`
|
|
59
60
|
);
|
|
60
61
|
tick++;
|
|
61
62
|
};
|
|
62
63
|
render();
|
|
63
64
|
const timer = setInterval(render, 100);
|
|
64
65
|
return {
|
|
66
|
+
setLabel(newLabel) {
|
|
67
|
+
if (newLabel) currentLabel = newLabel;
|
|
68
|
+
},
|
|
65
69
|
stop(keepPrefix = true) {
|
|
66
70
|
if (stopped) return;
|
|
67
71
|
stopped = true;
|
|
@@ -164,26 +168,35 @@ function createTuiSink(tui, state) {
|
|
|
164
168
|
process.stdout.write("\x07");
|
|
165
169
|
}
|
|
166
170
|
},
|
|
167
|
-
startThinking(_prefix = "Kovence: ",
|
|
171
|
+
startThinking(_prefix = "Kovence: ", initialLabel = "Thinking") {
|
|
168
172
|
const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
169
173
|
const dots = [" ", ". ", ".. ", "..."];
|
|
170
174
|
let tick = 0;
|
|
171
175
|
let stopped = false;
|
|
172
|
-
|
|
176
|
+
let currentLabel = initialLabel;
|
|
177
|
+
const block = tui.addBlock("thinking", `⠋ ${currentLabel} `);
|
|
173
178
|
const timer = setInterval(() => {
|
|
174
179
|
tick++;
|
|
175
180
|
const symbol = frames[tick % frames.length];
|
|
176
181
|
const blink = dots[Math.floor(tick / 2) % dots.length];
|
|
177
|
-
tui.updateBlock(block, `${symbol} ${
|
|
182
|
+
tui.updateBlock(block, `${symbol} ${currentLabel}${blink}`);
|
|
178
183
|
}, 100);
|
|
179
184
|
|
|
180
185
|
return {
|
|
186
|
+
setLabel(newLabel) {
|
|
187
|
+
if (stopped || !newLabel) return;
|
|
188
|
+
currentLabel = newLabel;
|
|
189
|
+
const symbol = frames[tick % frames.length];
|
|
190
|
+
const blink = dots[Math.floor(tick / 2) % dots.length];
|
|
191
|
+
tui.updateBlock(block, `${symbol} ${currentLabel}${blink}`);
|
|
192
|
+
},
|
|
181
193
|
stop(keepForStream = true) {
|
|
182
194
|
if (stopped) return;
|
|
183
195
|
stopped = true;
|
|
184
196
|
clearInterval(timer);
|
|
185
197
|
if (keepForStream) {
|
|
186
198
|
block.kind = "assistant";
|
|
199
|
+
block._streaming = true;
|
|
187
200
|
tui.updateBlock(block, "");
|
|
188
201
|
} else {
|
|
189
202
|
const idx = tui.blocks.indexOf(block);
|
|
@@ -194,7 +207,13 @@ function createTuiSink(tui, state) {
|
|
|
194
207
|
write(tok) {
|
|
195
208
|
tui.appendBlock(block, tok);
|
|
196
209
|
},
|
|
197
|
-
end() {
|
|
210
|
+
end() {
|
|
211
|
+
if (block._streaming) {
|
|
212
|
+
block._streaming = false;
|
|
213
|
+
block._cache = null;
|
|
214
|
+
tui.scheduleRender();
|
|
215
|
+
}
|
|
216
|
+
},
|
|
198
217
|
};
|
|
199
218
|
},
|
|
200
219
|
confirm: (label) => tui.askModal(label, false),
|
|
@@ -252,11 +271,13 @@ function createTuiSink(tui, state) {
|
|
|
252
271
|
};
|
|
253
272
|
},
|
|
254
273
|
startToolCall(label, { collapsible = true, expanded = false } = {}) {
|
|
274
|
+
const isWrite = /write_file|edit_file|multi_edit|apply_patch/.test(label);
|
|
275
|
+
const isRead = /read_file|glob_files|grep_files/.test(label);
|
|
255
276
|
const block = tui.addBlock("tool", label, {
|
|
256
277
|
collapsible,
|
|
257
278
|
expanded,
|
|
258
279
|
details: [],
|
|
259
|
-
statusLine: "running...",
|
|
280
|
+
statusLine: isWrite ? "writing..." : isRead ? "reading..." : "running...",
|
|
260
281
|
});
|
|
261
282
|
const details = [];
|
|
262
283
|
let lastUpdateAt = 0;
|
package/tui.js
CHANGED
|
@@ -38,7 +38,7 @@ function styleInlineMarkdown(line, ansi) {
|
|
|
38
38
|
.replace(/\*\*([^*]+)\*\*/g, `${ansi.bold}${ansi.amber}$1${ansi.reset}${ansi.white}`);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
function formatAssistantLines(text, innerW, ansi) {
|
|
41
|
+
function formatAssistantLines(text, innerW, ansi, isStreaming = false) {
|
|
42
42
|
const out = [];
|
|
43
43
|
const rawLines = String(text || "").split(/\r?\n/);
|
|
44
44
|
let inCode = false;
|
|
@@ -74,6 +74,15 @@ function formatAssistantLines(text, innerW, ansi) {
|
|
|
74
74
|
out.push(` ${ansi.orange}┃ ${ansi.white}${styleInlineMarkdown(wl, ansi)}${ansi.reset}`);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
+
|
|
78
|
+
if (isStreaming) {
|
|
79
|
+
if (inCode) {
|
|
80
|
+
out.push(` ${ansi.gray}│ ${ansi.amber}${ansi.dim}writing... ▌${ansi.reset}`);
|
|
81
|
+
} else if (!text || text.endsWith("\n")) {
|
|
82
|
+
out.push(` ${ansi.orange}┃ ${ansi.amber}${ansi.dim}writing... ▌${ansi.reset}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
77
86
|
return out;
|
|
78
87
|
}
|
|
79
88
|
|
|
@@ -684,7 +693,7 @@ class KovenceTUI {
|
|
|
684
693
|
blockLines.push("");
|
|
685
694
|
} else if (b.kind === "assistant") {
|
|
686
695
|
blockLines.push(` ${ansi.orange}${ansi.bold}◆ KOVENCE CLI${ansi.reset}`);
|
|
687
|
-
blockLines.push(...formatAssistantLines(b.text, innerW, ansi));
|
|
696
|
+
blockLines.push(...formatAssistantLines(b.text, innerW, ansi, Boolean(b._streaming)));
|
|
688
697
|
} else if (b.kind === "thinking") {
|
|
689
698
|
blockLines.push(` ${ansi.orange}${ansi.bold}◆ KOVENCE CLI${ansi.reset}`);
|
|
690
699
|
for (const wl of wrapped) {
|
|
@@ -951,15 +960,17 @@ class KovenceTUI {
|
|
|
951
960
|
for (let i = 0; i < visCompLines.length; i++) {
|
|
952
961
|
const pfx = i === 0 && compStart === 0 ? promptPrefix : prefixSpace;
|
|
953
962
|
const txt = visCompLines[i];
|
|
963
|
+
const isBusy = Boolean(this.status.isBusy || this.status.busyLabel);
|
|
964
|
+
const defaultPh = "Type message · Shift+Enter newline · / commands...";
|
|
965
|
+
const phText = isBusy && this.status.busyLabel ? `⏳ ${this.status.busyLabel}` : defaultPh;
|
|
954
966
|
const showPh =
|
|
955
967
|
i === 0 &&
|
|
956
968
|
compStart === 0 &&
|
|
957
969
|
!this.modal &&
|
|
958
970
|
!this.input &&
|
|
959
971
|
this.status.showTips !== false &&
|
|
960
|
-
cols >= 2 + displayWidth(pfx) +
|
|
961
|
-
const
|
|
962
|
-
const placeholder = showPh ? `${ansi.gray}${phText}${ansi.reset}` : "";
|
|
972
|
+
cols >= 2 + displayWidth(pfx) + displayWidth(phText);
|
|
973
|
+
const placeholder = showPh ? `${isBusy ? ansi.amber : ansi.gray}${phText}${ansi.reset}` : "";
|
|
963
974
|
const phLen = showPh ? displayWidth(phText) : 0;
|
|
964
975
|
const linePlainLen = 2 + displayWidth(pfx) + displayWidth(txt);
|
|
965
976
|
const padComposer = Math.max(0, cols - linePlainLen - phLen);
|