@kvali/cli 0.6.5 → 0.6.7
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.6.
|
|
3
|
+
"version": "0.6.7",
|
|
4
4
|
"description": "Live progress for Claude Code: plan progress, the current step and its time, what the agent is doing right now, and tokens, in a pane beside the chat.",
|
|
5
5
|
"author": { "name": "Giorgi Khiladze" },
|
|
6
6
|
"homepage": "https://github.com/webGrandpa/kvali",
|
|
@@ -15,6 +15,23 @@ export const ASKS_PERSON: Record<string, string> = {
|
|
|
15
15
|
ExitPlanMode: 'A plan is waiting for your approval',
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
/** What a `tool.check` verdict says stands behind an ask. */
|
|
19
|
+
export type AskVerdict = { plugin?: string; hook?: string; rule?: string; setting?: string; ceiling?: string }
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Whether the engine's `ask` for a tool call is put to the person. A hook's ask (`plugin`) always
|
|
23
|
+
* is. The engine's own asks go to the permission mode's decider: in `dontAsk` they are refused, in
|
|
24
|
+
* `auto` a classifier approves or blocks them, except those auto mode still shows the person: a
|
|
25
|
+
* settings hook's (`hook`), an explicit ask rule's (`rule`), an option's own check (`setting`) and
|
|
26
|
+
* a connector tool the organization keeps at `ask`. A mode not known yet counts as one that asks.
|
|
27
|
+
*/
|
|
28
|
+
export function asksPerson(verdict: AskVerdict, mode: string | undefined): boolean {
|
|
29
|
+
if (verdict.plugin) return true
|
|
30
|
+
if (mode === 'dontAsk') return false
|
|
31
|
+
if (mode !== 'auto') return true
|
|
32
|
+
return Boolean(verdict.hook || verdict.rule || verdict.setting) || verdict.ceiling === 'ask'
|
|
33
|
+
}
|
|
34
|
+
|
|
18
35
|
export const EMPTY_PLAN: KvPlan = { tasks: [], durations: [], fileDurations: [] }
|
|
19
36
|
export const EMPTY_USAGE: KvUsage = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, isWholeSession: false }
|
|
20
37
|
export const IDLE: KvLive = { phase: 'idle', since: 0 }
|
|
@@ -4,6 +4,7 @@ import type { EngineInterface, Register } from 'claude-code'
|
|
|
4
4
|
import type { KvAction, KvLive, KvPhase, KvPlan, KvTask } from '../types'
|
|
5
5
|
import {
|
|
6
6
|
ASKS_PERSON,
|
|
7
|
+
asksPerson,
|
|
7
8
|
EMPTY_PLAN,
|
|
8
9
|
EMPTY_USAGE,
|
|
9
10
|
IDLE,
|
|
@@ -68,6 +69,8 @@ type Running = {
|
|
|
68
69
|
/** The same question for a phone push: no command text leaves the computer. */
|
|
69
70
|
askPush?: string
|
|
70
71
|
askedAt?: number
|
|
72
|
+
/** The engine asked about this call and auto mode's classifier answers: the person only if a prompt follows. */
|
|
73
|
+
review?: true
|
|
71
74
|
}
|
|
72
75
|
type StreamPhase = 'requesting' | 'thinking' | 'writing' | 'tool-input'
|
|
73
76
|
|
|
@@ -124,6 +127,8 @@ type Runtime = {
|
|
|
124
127
|
budgetLeft: number | undefined
|
|
125
128
|
/** Ask Claude for a plan while there is none (`autoPlan` in ~/.kvali/config.json). */
|
|
126
129
|
autoPlan: boolean
|
|
130
|
+
/** The session's permission mode, as the last classic event carried it: who answers an ask. */
|
|
131
|
+
mode: string | undefined
|
|
127
132
|
}
|
|
128
133
|
|
|
129
134
|
const fresh = (): Runtime => ({
|
|
@@ -164,8 +169,16 @@ const fresh = (): Runtime => ({
|
|
|
164
169
|
budgetAt: -Infinity,
|
|
165
170
|
budgetLeft: undefined,
|
|
166
171
|
autoPlan: true,
|
|
172
|
+
mode: undefined,
|
|
167
173
|
})
|
|
168
174
|
|
|
175
|
+
/** Marks a call as waiting for the person's permission. */
|
|
176
|
+
function markAsk(r: Running, now: number): void {
|
|
177
|
+
r.asks = `allow ${r.label}${r.detail ? ` (${r.detail})` : ''}?`
|
|
178
|
+
r.askPush = `allow ${r.label}?`
|
|
179
|
+
r.askedAt = now
|
|
180
|
+
}
|
|
181
|
+
|
|
169
182
|
/**
|
|
170
183
|
* What happens right now, from the engine's events. It lives with the module: a reload
|
|
171
184
|
* starts it over and the engine's next event fills it in again.
|
|
@@ -560,21 +573,41 @@ export const register: Register = on => {
|
|
|
560
573
|
return ran
|
|
561
574
|
}).catch(($, e, next) => next(e)) // an observer: if it fails, the call goes on as if it were not here
|
|
562
575
|
|
|
563
|
-
// A permission prompt: the engine asks the person before the tool runs.
|
|
576
|
+
// A permission prompt: the engine asks the person before the tool runs. Where someone else
|
|
577
|
+
// answers (auto mode's classifier, a host) the call is only under review: a prompt may follow.
|
|
564
578
|
on('tool.check', async ($, e, next) => {
|
|
565
579
|
const verdict = await next(e)
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
r.askedAt = await $.clock.now()
|
|
572
|
-
quiet(refresh($))
|
|
573
|
-
}
|
|
574
|
-
}
|
|
580
|
+
const r = verdict.decision === 'ask' && e.tool_use_id ? rt.running.get(e.tool_use_id) : undefined
|
|
581
|
+
if (r && e.approver === 'person' && asksPerson(verdict, rt.mode)) {
|
|
582
|
+
markAsk(r, await $.clock.now())
|
|
583
|
+
quiet(refresh($))
|
|
584
|
+
} else if (r) r.review = true
|
|
575
585
|
return verdict
|
|
576
586
|
}).catch(($, e, next) => next(e))
|
|
577
587
|
|
|
588
|
+
// The session's permission mode rides on the classic events: each prompt, each finished tool.
|
|
589
|
+
on('classic.UserPromptSubmit', ($, e, next) => {
|
|
590
|
+
if (e.permission_mode) rt.mode = e.permission_mode
|
|
591
|
+
return next(e)
|
|
592
|
+
}).catch(($, e, next) => next(e))
|
|
593
|
+
on('classic.PostToolUse', ($, e, next) => {
|
|
594
|
+
if (e.permission_mode) rt.mode = e.permission_mode
|
|
595
|
+
return next(e)
|
|
596
|
+
}).catch(($, e, next) => next(e))
|
|
597
|
+
|
|
598
|
+
// The engine shows a permission prompt: a call under review was put to the person after all
|
|
599
|
+
// (auto mode's classifier blocked three in a row, say), so it waits for them now.
|
|
600
|
+
on('classic.Notification', async ($, e, next) => {
|
|
601
|
+
if (e.permission_mode) rt.mode = e.permission_mode
|
|
602
|
+
const calls = [...rt.running.values()]
|
|
603
|
+
const r = e.notification_type === 'permission_prompt' && !calls.some(x => x.asks) ? calls.filter(x => x.review).pop() : undefined
|
|
604
|
+
if (r) {
|
|
605
|
+
markAsk(r, await $.clock.now())
|
|
606
|
+
quiet(refresh($))
|
|
607
|
+
}
|
|
608
|
+
return next(e)
|
|
609
|
+
}).catch(($, e, next) => next(e))
|
|
610
|
+
|
|
578
611
|
on('session.compact', async ($, e, next) => {
|
|
579
612
|
rt.running.set('kvali:compact', { label: 'Compacting the conversation', startedAt: await $.clock.now() })
|
|
580
613
|
quiet(refresh($))
|
package/dist/kvali.mjs
CHANGED
|
@@ -1098,6 +1098,7 @@ var ClaudeCodeAdapter = class {
|
|
|
1098
1098
|
phaseAt: 0,
|
|
1099
1099
|
turns: 0,
|
|
1100
1100
|
turnSteps: 0,
|
|
1101
|
+
turnOpen: false,
|
|
1101
1102
|
subagents: /* @__PURE__ */ new Map(),
|
|
1102
1103
|
timer: new TaskTimer(),
|
|
1103
1104
|
recent: [],
|
|
@@ -1211,8 +1212,15 @@ var ClaudeCodeAdapter = class {
|
|
|
1211
1212
|
st.phase = "error";
|
|
1212
1213
|
st.phaseAt = ts;
|
|
1213
1214
|
st.errorText = firstLine(contentText(m.content) || "API error", 120);
|
|
1215
|
+
this.endTurn(st, ts, void 0);
|
|
1214
1216
|
return;
|
|
1215
1217
|
}
|
|
1218
|
+
const msgId = typeof m.id === "string" ? m.id : void 0;
|
|
1219
|
+
if (!st.turnOpen && !(msgId && msgId === st.turnEndedBy)) {
|
|
1220
|
+
st.turnOpen = true;
|
|
1221
|
+
st.turnSteps = 0;
|
|
1222
|
+
st.turnStartedAt = st.promptAt !== void 0 && st.promptAt >= (st.turnEndedAt ?? 0) ? st.promptAt : ts;
|
|
1223
|
+
}
|
|
1216
1224
|
let sawToolUse = false;
|
|
1217
1225
|
for (const block of Array.isArray(m.content) ? m.content : []) {
|
|
1218
1226
|
if (!block || typeof block !== "object") continue;
|
|
@@ -1230,9 +1238,15 @@ var ClaudeCodeAdapter = class {
|
|
|
1230
1238
|
else if (stop === "end_turn" || stop === "stop_sequence" || stop === "max_tokens" || stop === "refusal") {
|
|
1231
1239
|
st.phase = "idle";
|
|
1232
1240
|
st.open.clear();
|
|
1241
|
+
this.endTurn(st, ts, msgId);
|
|
1233
1242
|
} else st.phase = "working";
|
|
1234
1243
|
st.phaseAt = ts;
|
|
1235
1244
|
}
|
|
1245
|
+
endTurn(st, ts, by) {
|
|
1246
|
+
st.turnOpen = false;
|
|
1247
|
+
st.turnEndedAt = ts;
|
|
1248
|
+
st.turnEndedBy = by;
|
|
1249
|
+
}
|
|
1236
1250
|
onToolUse(st, block, ts) {
|
|
1237
1251
|
const name = String(block.name ?? "tool");
|
|
1238
1252
|
const input = block.input && typeof block.input === "object" ? block.input : {};
|
|
@@ -1308,8 +1322,10 @@ var ClaudeCodeAdapter = class {
|
|
|
1308
1322
|
st.phase = "interrupted";
|
|
1309
1323
|
st.phaseAt = ts;
|
|
1310
1324
|
st.open.clear();
|
|
1325
|
+
this.endTurn(st, ts, void 0);
|
|
1311
1326
|
return;
|
|
1312
1327
|
}
|
|
1328
|
+
st.promptAt = ts;
|
|
1313
1329
|
const isCommand = raw.includes("<command-name>") || raw.includes("<local-command-");
|
|
1314
1330
|
const text = stripInjectedTags(raw);
|
|
1315
1331
|
if (!text) return;
|
|
@@ -1319,6 +1335,8 @@ var ClaudeCodeAdapter = class {
|
|
|
1319
1335
|
st.turns += 1;
|
|
1320
1336
|
st.turnSteps = 0;
|
|
1321
1337
|
st.turnStartedAt = ts;
|
|
1338
|
+
st.turnOpen = true;
|
|
1339
|
+
st.turnEndedBy = void 0;
|
|
1322
1340
|
}
|
|
1323
1341
|
if (!isCommand) {
|
|
1324
1342
|
st.phase = "working";
|
|
@@ -5143,7 +5161,7 @@ function qrTerminal(text, color = true) {
|
|
|
5143
5161
|
}
|
|
5144
5162
|
|
|
5145
5163
|
// src/index.ts
|
|
5146
|
-
var VERSION = "0.6.
|
|
5164
|
+
var VERSION = "0.6.7";
|
|
5147
5165
|
function parse(argv) {
|
|
5148
5166
|
const opts = {
|
|
5149
5167
|
json: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kvali/cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
4
4
|
"description": "Live progress, tokens and phone alerts for AI coding agents (Claude Code, Codex, Gemini CLI, Antigravity), in your terminal.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Giorgi Khiladze (https://github.com/webGrandpa)",
|