@vincemakes/kiso-code 0.1.21 → 0.1.22

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 +15 -5
  2. package/package.json +1 -1
package/dist/chat.js CHANGED
@@ -303,7 +303,7 @@ export async function chat(session, faux, input, autoCompact) {
303
303
  // 手感批 C8: the opt-in auto-compact — checked AFTER the
304
304
  // turn ended (the run's terminal is in the log, the ratio
305
305
  // is post-run).
306
- maybeAutoCompact();
306
+ await maybeAutoCompact();
307
307
  resolve();
308
308
  }
309
309
  catch (err) {
@@ -419,15 +419,19 @@ export async function chat(session, faux, input, autoCompact) {
419
419
  // 手感批 C8: the auto-compact check — the /compact FULL path via the
420
420
  // shared dispatch (same notices, same chain ordering, same mid-run
421
421
  // refusal — the isRunning guard here only avoids the refusal's noise).
422
+ // The appended segment is NOT awaited here on purpose: from inside a
423
+ // chain segment, awaiting the append would be circular (the segment
424
+ // chains after THIS segment's promise). The exit path re-awaits the
425
+ // chain once more after the turn — see the final awaits in chat().
422
426
  const maybeAutoCompact = () => {
423
427
  if (autoCompact === undefined)
424
428
  return;
425
429
  if (currentRun !== null)
426
430
  return; // dispatch would refuse — skip the noise
427
431
  const ratio = estimateCtxRatio(session);
428
- if (Number.isFinite(ratio) && ratio >= autoCompact.thresholdRatio) {
429
- dispatch("/compact", dispatchCtx);
430
- }
432
+ if (!Number.isFinite(ratio) || ratio < autoCompact.thresholdRatio)
433
+ return;
434
+ dispatch("/compact", dispatchCtx);
431
435
  };
432
436
  input.onLine((line) => {
433
437
  if (!replReady) {
@@ -449,7 +453,7 @@ export async function chat(session, faux, input, autoCompact) {
449
453
  const last = await consumeRun(session, recoveryRun, input, turnNo, faux, liveInput, statusCb);
450
454
  currentRun = null;
451
455
  failOnFauxExhaustion(last, faux, input);
452
- maybeAutoCompact(); // 手感批 C8: the recovery run ended too — same check
456
+ maybeAutoCompact(); // 手感批 C8: the recovery run ended too — same check (awaited by the exit re-await)
453
457
  }
454
458
  if (cancelled) {
455
459
  input.close();
@@ -470,4 +474,10 @@ export async function chat(session, faux, input, autoCompact) {
470
474
  input.prompt();
471
475
  await input.closed;
472
476
  await chainRef.current; // never exit while a turn is in flight
477
+ // 手感批 C8: the auto-compact may have appended ITS segment inside the
478
+ // turn (the check runs at the turn's end, after the exit-await above
479
+ // already captured the chain) — re-await once so the summarize either
480
+ // runs before the exit or the chain is already settled. One level is
481
+ // enough: the /compact segment appends nothing of its own.
482
+ await chainRef.current;
473
483
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vincemakes/kiso-code",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "kiso CLI — the coding-agent reference product: kiso chat / kiso resume / kiso sessions.",
5
5
  "type": "module",
6
6
  "license": "MIT",