@vincemakes/kiso-code 0.1.39 → 0.1.40

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.
Files changed (2) hide show
  1. package/dist/chat.js +19 -1
  2. package/package.json +8 -8
package/dist/chat.js CHANGED
@@ -172,6 +172,13 @@ function toRenderInput(ev) {
172
172
  export async function consumeRun(session, run, input, turnNo, faux, liveInput, statusCb) {
173
173
  let last;
174
174
  let usage = { in: null, out: null, cache: null, known: false };
175
+ // R-C item 4: the per-turn cache miss — the overlap with the previous
176
+ // prompt that SHOULD have been cached but was re-sent uncached:
177
+ // missed = min(prevIn, in) − cacheRead. Below the 1024-token floor
178
+ // (Anthropic's minimum cacheable block) it is noise — not surfaced.
179
+ const CACHE_MISS_FLOOR = 1024;
180
+ let prevIn = null;
181
+ let missed = null;
175
182
  // v3 §02: the recap line derives ENTIRELY from the local event stream
176
183
  // (zero tokens) — wall seconds, tool/edit counts, usage, ctx left.
177
184
  const turnStart = Date.now();
@@ -260,10 +267,18 @@ export async function consumeRun(session, run, input, turnNo, faux, liveInput, s
260
267
  case "text_end":
261
268
  body.textEnd();
262
269
  break;
263
- case "usage":
270
+ case "usage": {
264
271
  usage = { in: ev.inputTokens, out: ev.outputTokens, cache: ev.cacheRead, known: ev.known };
272
+ // R-C item 4: min(prevIn, in) is the part that could have been
273
+ // cached; what cacheRead did NOT cover is the miss.
274
+ if (usage.in !== null && usage.cache !== null && prevIn !== null) {
275
+ const m = Math.min(prevIn, usage.in) - usage.cache;
276
+ missed = m > CACHE_MISS_FLOOR ? m : null;
277
+ }
278
+ prevIn = usage.in;
265
279
  statusCb?.(usage, estimateCtxRatio(session));
266
280
  break;
281
+ }
267
282
  case "uncertain_pending":
268
283
  // ruling #12 (ADR-0038): the ⚠ line is pure INFORMATION now — the
269
284
  // approval chain guards retries, and the human question belongs
@@ -305,6 +320,9 @@ export async function consumeRun(session, run, input, turnNo, faux, liveInput, s
305
320
  tools: toolCount,
306
321
  edits: editCount,
307
322
  usage,
323
+ // R-C item 4: only an above-floor miss is surfaced —
324
+ // the recap gains "· miss N" on the cache segment.
325
+ ...(missed !== null ? { missed } : {}),
308
326
  ctxLeftPct: Number.isFinite(ratio) ? (1 - ratio) * 100 : null,
309
327
  // W19: under plan the recap becomes the way-forward row
310
328
  // (the /mode hints are the mode's exits).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vincemakes/kiso-code",
3
- "version": "0.1.39",
3
+ "version": "0.1.40",
4
4
  "description": "kiso CLI — the coding-agent reference product: kiso chat / kiso resume / kiso sessions.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -18,13 +18,13 @@
18
18
  "test": "vitest run"
19
19
  },
20
20
  "dependencies": {
21
- "@vincemakes/kiso-core": "0.1.30",
22
- "@vincemakes/kiso-evals": "0.1.31",
23
- "@vincemakes/kiso-provider-anthropic": "0.1.31",
24
- "@vincemakes/kiso-provider-openai": "0.1.31",
25
- "@vincemakes/kiso-runtime": "0.1.31",
26
- "@vincemakes/kiso-tools-node": "0.1.31",
27
- "@vincemakes/kiso-tui": "0.1.39"
21
+ "@vincemakes/kiso-core": "0.1.31",
22
+ "@vincemakes/kiso-evals": "0.1.32",
23
+ "@vincemakes/kiso-provider-anthropic": "0.1.32",
24
+ "@vincemakes/kiso-provider-openai": "0.1.32",
25
+ "@vincemakes/kiso-runtime": "0.1.32",
26
+ "@vincemakes/kiso-tools-node": "0.1.32",
27
+ "@vincemakes/kiso-tui": "0.1.40"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/node": "^26.1.2",