@kvali/cli 0.6.5 → 0.6.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kvali",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kvali/cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
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)",
|