@kvali/cli 0.7.2 → 0.7.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kvali",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "Live progress for Claude Code: plan progress, the current step and the time left, what the agent is doing right now, tokens and your plan limits, in a pane beside the chat.",
|
|
5
5
|
"author": { "name": "Giorgi Khiladze" },
|
|
6
6
|
"homepage": "https://github.com/webGrandpa/kvali",
|
|
@@ -60,7 +60,8 @@ export function typicalMs(plan: KvPlan): number | undefined {
|
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* How long the rest of the plan should take at its own pace: the typical step for each step
|
|
63
|
-
* left, less the time already spent on the current one. Undefined until a step has finished
|
|
63
|
+
* left, less the time already spent on the current one. Undefined until a step has finished,
|
|
64
|
+
* and while the current step runs past twice its usual time.
|
|
64
65
|
*/
|
|
65
66
|
export function planEtaMs(plan: KvPlan, now: number): number | undefined {
|
|
66
67
|
const typical = typicalMs(plan)
|
|
@@ -69,7 +70,10 @@ export function planEtaMs(plan: KvPlan, now: number): number | undefined {
|
|
|
69
70
|
const left = p.total - p.done
|
|
70
71
|
if (!p.total || left <= 0) return undefined
|
|
71
72
|
const spent = p.current && plan.step ? Math.max(0, now - plan.step.startedAt) : 0
|
|
72
|
-
|
|
73
|
+
// A step past twice its usual time is one the earlier steps say nothing about: no estimate.
|
|
74
|
+
// One just past its usual time is not done yet: a quarter of a step still counts.
|
|
75
|
+
if (spent > 2 * typical) return undefined
|
|
76
|
+
return Math.max(typical - spent, typical / 4) + (left - 1) * typical
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
/** One usage window as Claude Code reports it (`session.measure`, `$.session.usage()`). */
|
|
@@ -156,6 +160,12 @@ export function sortTasks(tasks: KvTask[]): KvTask[] {
|
|
|
156
160
|
* Applies a plan tool call to the task list. `input` is the call's arguments,
|
|
157
161
|
* `result` the tool's structured result (TaskCreate answers the new id).
|
|
158
162
|
*/
|
|
163
|
+
/** The id of the task a TaskCreate made, from its result. */
|
|
164
|
+
export function createdTaskId(result: unknown): string | undefined {
|
|
165
|
+
const id = (result as { task?: { id?: unknown } } | undefined)?.task?.id
|
|
166
|
+
return id === undefined || id === null ? undefined : String(id)
|
|
167
|
+
}
|
|
168
|
+
|
|
159
169
|
export function applyPlanTool(tasks: readonly KvTask[], tool: string, input: Record<string, unknown>, result: unknown): KvTask[] {
|
|
160
170
|
if (tool === 'TodoWrite' && Array.isArray(input.todos)) {
|
|
161
171
|
return (input.todos as Record<string, unknown>[]).map((t, i) => ({
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
STALL_MS,
|
|
15
15
|
advance,
|
|
16
16
|
applyPlanTool,
|
|
17
|
+
createdTaskId,
|
|
17
18
|
baseName,
|
|
18
19
|
autoPlanEnabled,
|
|
19
20
|
ntfyBody,
|
|
@@ -162,6 +163,14 @@ type Runtime = {
|
|
|
162
163
|
background: Map<string, { label: string; startedAt: number }>
|
|
163
164
|
/** Agents whose run's end was heard: the engine's list may call one running a moment longer. */
|
|
164
165
|
finished: Set<string>
|
|
166
|
+
/**
|
|
167
|
+
* Tasks subagents made for their own work. Their plans are theirs, not the session's: a
|
|
168
|
+
* subagent's TodoWrite would otherwise replace the session's plan, and a task list the
|
|
169
|
+
* engine shares with them would add their steps to it.
|
|
170
|
+
*/
|
|
171
|
+
foreignTasks: Set<string>
|
|
172
|
+
/** Teammates of an agent team: the task list they share with the session is the team's plan. */
|
|
173
|
+
teammates: Set<string>
|
|
165
174
|
/**
|
|
166
175
|
* A task whose answer handed work to background agents: its end (the phone, the toast) waits
|
|
167
176
|
* for theirs and for the turn their reports start. `idleSince`: all done, and nothing woke it.
|
|
@@ -222,6 +231,8 @@ const fresh = (): Runtime => ({
|
|
|
222
231
|
mode: undefined,
|
|
223
232
|
background: new Map(),
|
|
224
233
|
finished: new Set(),
|
|
234
|
+
foreignTasks: new Set(),
|
|
235
|
+
teammates: new Set(),
|
|
225
236
|
held: undefined,
|
|
226
237
|
limits: undefined,
|
|
227
238
|
limitSamples: {},
|
|
@@ -446,7 +457,7 @@ async function taskFiles($: Engine): Promise<{ tasks: KvTask[]; times: Map<strin
|
|
|
446
457
|
continue
|
|
447
458
|
}
|
|
448
459
|
const t = parseTaskFile(text, f.name.slice(0, -5))
|
|
449
|
-
if (!t) continue
|
|
460
|
+
if (!t || rt.foreignTasks.has(t.id)) continue
|
|
450
461
|
tasks.push(t)
|
|
451
462
|
times.set(t.id, f.mtimeMs)
|
|
452
463
|
}
|
|
@@ -781,7 +792,14 @@ export const register: Register = on => {
|
|
|
781
792
|
noteCall(rt.loops, loopKey(e.tool, describeTool(e.tool, input, rt.cwd)), describeTool(e.tool, input, rt.cwd), ran.isError === true ? resultText(ran.result) : undefined, end, totalTokens(await read($, usage)))
|
|
782
793
|
}
|
|
783
794
|
if (!isPlan) await update($, recent, list => endAction(list, id, end, ran.deny !== undefined || ran.isError === true))
|
|
784
|
-
else if (
|
|
795
|
+
else if (e.agentId && (e.tool === 'TodoWrite' || !rt.teammates.has(e.agentId))) {
|
|
796
|
+
// A subagent's plan is its own: the session's progress bar follows the main loop (and an
|
|
797
|
+
// agent team's shared list). Its tasks are left out of the list, should the engine share it.
|
|
798
|
+
if (e.tool === 'TaskCreate' && ran.deny === undefined && !ran.isError) {
|
|
799
|
+
const made = createdTaskId(ran.result)
|
|
800
|
+
if (made !== undefined) rt.foreignTasks.add(made)
|
|
801
|
+
}
|
|
802
|
+
} else if (ran.deny === undefined && !ran.isError && e.tool !== 'TaskList' && e.tool !== 'TaskGet') {
|
|
785
803
|
const files = e.tool === 'TodoWrite' ? undefined : await taskFiles($)
|
|
786
804
|
const current = await read($, plan)
|
|
787
805
|
const tasks = files?.tasks ?? applyPlanTool(current.tasks, e.tool, input, ran.result)
|
|
@@ -869,6 +887,7 @@ export const register: Register = on => {
|
|
|
869
887
|
on('agent.spawn', async ($, e, next) => {
|
|
870
888
|
const r = await next(e)
|
|
871
889
|
try {
|
|
890
|
+
if (e.isTeammate && r.agentId) rt.teammates.add(r.agentId)
|
|
872
891
|
if (e.background && !e.parentAgentId && !e.isTeammate && !e.workflow && r.agentId) {
|
|
873
892
|
rt.background.set(r.agentId, { label: e.description, startedAt: await $.clock.now() })
|
|
874
893
|
quiet(refresh($))
|
package/dist/kvali.mjs
CHANGED
|
@@ -80,7 +80,11 @@ function planEta(s, now) {
|
|
|
80
80
|
const left = p2.total - p2.done;
|
|
81
81
|
if (p2.total === 0 || left <= 0) return void 0;
|
|
82
82
|
const spent = s.current ? Math.max(0, now - s.current.startedAt) : 0;
|
|
83
|
-
return
|
|
83
|
+
return restOfPlan(typical, spent, left);
|
|
84
|
+
}
|
|
85
|
+
function restOfPlan(typical, spent, left) {
|
|
86
|
+
if (spent > 2 * typical) return void 0;
|
|
87
|
+
return Math.max(typical - spent, typical / 4) + (left - 1) * typical;
|
|
84
88
|
}
|
|
85
89
|
function fmtClock(ms) {
|
|
86
90
|
return new Date(ms).toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit" });
|
|
@@ -1592,6 +1596,8 @@ var ClaudeCodeAdapter = class {
|
|
|
1592
1596
|
maxContext: 0,
|
|
1593
1597
|
tasks: /* @__PURE__ */ new Map(),
|
|
1594
1598
|
pendingCreates: /* @__PURE__ */ new Map(),
|
|
1599
|
+
foreignCreates: /* @__PURE__ */ new Set(),
|
|
1600
|
+
foreignTasks: /* @__PURE__ */ new Set(),
|
|
1595
1601
|
open: /* @__PURE__ */ new Map(),
|
|
1596
1602
|
phase: "idle",
|
|
1597
1603
|
phaseAt: 0,
|
|
@@ -1612,7 +1618,18 @@ var ClaudeCodeAdapter = class {
|
|
|
1612
1618
|
const o = rec;
|
|
1613
1619
|
const ts = parseTime(o.timestamp);
|
|
1614
1620
|
if (tokensOnly) {
|
|
1615
|
-
if (o.type === "assistant" && o.message)
|
|
1621
|
+
if (o.type === "assistant" && o.message) {
|
|
1622
|
+
this.countUsage(st, o, ts, ctx, false);
|
|
1623
|
+
for (const b of Array.isArray(o.message.content) ? o.message.content : []) {
|
|
1624
|
+
if (b?.type === "tool_use" && b.name === "TaskCreate" && typeof b.id === "string") st.foreignCreates.add(b.id);
|
|
1625
|
+
}
|
|
1626
|
+
} else if (o.type === "user" && Array.isArray(o.message?.content) && st.foreignCreates.size) {
|
|
1627
|
+
for (const b of o.message.content) {
|
|
1628
|
+
if (b?.type !== "tool_result" || !st.foreignCreates.delete(b.tool_use_id)) continue;
|
|
1629
|
+
const id = o.toolUseResult?.task?.id ?? /Task #?(\w+) created/i.exec(contentText(b.content))?.[1];
|
|
1630
|
+
if (id !== void 0 && id !== null) st.foreignTasks.add(String(id));
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1616
1633
|
return;
|
|
1617
1634
|
}
|
|
1618
1635
|
if (ts !== void 0) {
|
|
@@ -1977,7 +1994,8 @@ var ClaudeCodeAdapter = class {
|
|
|
1977
1994
|
}
|
|
1978
1995
|
}
|
|
1979
1996
|
resolveTasks(st) {
|
|
1980
|
-
|
|
1997
|
+
const own = st.taskDir?.tasks.filter((t) => !st.foreignTasks.has(t.id)) ?? [];
|
|
1998
|
+
if (own.length > 0) return own;
|
|
1981
1999
|
if (st.tasks.size > 0) {
|
|
1982
2000
|
return [...st.tasks.values()].sort((a, b) => Number(a.id) - Number(b.id) || a.id.localeCompare(b.id));
|
|
1983
2001
|
}
|
|
@@ -8526,7 +8544,7 @@ function qrTerminal(text, color = true) {
|
|
|
8526
8544
|
}
|
|
8527
8545
|
|
|
8528
8546
|
// src/index.ts
|
|
8529
|
-
var VERSION = "0.7.
|
|
8547
|
+
var VERSION = "0.7.3";
|
|
8530
8548
|
function parse(argv) {
|
|
8531
8549
|
const opts = {
|
|
8532
8550
|
json: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kvali/cli",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "Live progress, time left, tokens, plan limits and phone alerts for AI coding agents (Claude Code, Codex, Gemini CLI, Antigravity, Copilot, Cline, Roo Code, Kilo Code, OpenCode), in your terminal.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Giorgi Khiladze (https://github.com/webGrandpa)",
|