billion-context-pi 0.1.51 → 0.1.52

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.
package/dist/index.js CHANGED
@@ -2488,6 +2488,8 @@ function decideNudge(input) {
2488
2488
  const t1Eff = tiers[1]?.pending ?? 0;
2489
2489
  const t2Pen = tiers[2]?.pending ?? 0;
2490
2490
  const t3Pen = tiers[3]?.pending ?? 0;
2491
+ const t2Count = tiers[2]?.targetBlocks.length ?? 0;
2492
+ const t3Count = tiers[3]?.targetBlocks.length ?? 0;
2491
2493
  if (pressure) {
2492
2494
  const candidates = [1];
2493
2495
  if (config.tiers.enabled) {
@@ -2511,19 +2513,19 @@ function decideNudge(input) {
2511
2513
  if (t1Eff >= nudgeGrowthTokens) {
2512
2514
  injectedTier = 1;
2513
2515
  injectedReason = `T1 effective ${t1Eff} >= ${nudgeGrowthTokens}, growth ${growthSinceReference}, usage ${Math.round(usage * 100)}%`;
2514
- } else if (config.tiers.enabled && t2Pen >= tier2Threshold && t2Pen > t1Eff) {
2516
+ } else if (config.tiers.enabled && (t2Count >= config.tiers.tier2Trigger || t2Pen >= tier2Threshold && t2Pen > t1Eff)) {
2515
2517
  const lastShown = state.nudge.lastShownByTier[2] ?? 0;
2516
2518
  const cadenceMet = lastShown === 0 || tokenCount - lastShown >= growthFloor;
2517
2519
  if (cadenceMet) {
2518
2520
  injectedTier = 2;
2519
- injectedReason = `T2 distill ready: ${tiers[2].targetBlocks.length} tier-1 blocks (${t2Pen} tokens) >= ${tier2Threshold} (1.5x) and > T1 effective ${t1Eff}, usage ${Math.round(usage * 100)}%`;
2521
+ injectedReason = t2Count >= config.tiers.tier2Trigger ? `T2 distill ready: ${t2Count} tier-1 blocks >= tier2Trigger ${config.tiers.tier2Trigger} (${t2Pen} tokens), usage ${Math.round(usage * 100)}%` : `T2 distill ready: ${tiers[2].targetBlocks.length} tier-1 blocks (${t2Pen} tokens) >= ${tier2Threshold} (1.5x) and > T1 effective ${t1Eff}, usage ${Math.round(usage * 100)}%`;
2520
2522
  }
2521
- } else if (config.tiers.enabled && t3Pen >= tier2Threshold && t3Pen > t2Pen && t3Pen > t1Eff) {
2523
+ } else if (config.tiers.enabled && (t3Count >= config.tiers.tier3Trigger || t3Pen >= tier2Threshold && t3Pen > t2Pen && t3Pen > t1Eff)) {
2522
2524
  const lastShown = state.nudge.lastShownByTier[3] ?? 0;
2523
2525
  const cadenceMet = lastShown === 0 || tokenCount - lastShown >= growthFloor;
2524
2526
  if (cadenceMet) {
2525
2527
  injectedTier = 3;
2526
- injectedReason = `T3 condense ready: ${tiers[3].targetBlocks.length} tier-2 blocks (${t3Pen} tokens) >= ${tier2Threshold} (1.5x) and > T2 ${t2Pen} and > T1 effective ${t1Eff}, usage ${Math.round(usage * 100)}%`;
2528
+ injectedReason = t3Count >= config.tiers.tier3Trigger ? `T3 condense ready: ${t3Count} tier-2 blocks >= tier3Trigger ${config.tiers.tier3Trigger} (${t3Pen} tokens), usage ${Math.round(usage * 100)}%` : `T3 condense ready: ${tiers[3].targetBlocks.length} tier-2 blocks (${t3Pen} tokens) >= ${tier2Threshold} (1.5x) and > T2 ${t2Pen} and > T1 effective ${t1Eff}, usage ${Math.round(usage * 100)}%`;
2527
2529
  }
2528
2530
  }
2529
2531
  }
@@ -2537,10 +2539,13 @@ function decideNudge(input) {
2537
2539
  } else {
2538
2540
  const tiersList = [1, 2, 3];
2539
2541
  const eligible = tiersList.filter((t) => config.tiers.enabled || t === 1);
2542
+ const countReady = (t) => t === 2 ? t2Count >= config.tiers.tier2Trigger : t === 3 ? t3Count >= config.tiers.tier3Trigger : false;
2540
2543
  const ready = eligible.filter((t) => (tiers[t]?.pending ?? 0) >= nudgeGrowthTokens).map((t) => `T${t} ${tiers[t].pending}`);
2541
- const readyHint = ready.length > 0 ? `, ready: ${ready.join(", ")}` : "";
2544
+ const readyCount = eligible.filter((t) => (tiers[t]?.pending ?? 0) < nudgeGrowthTokens && countReady(t)).map((t) => `T${t} ${t === 2 ? t2Count : t3Count} blocks (count)`);
2545
+ const readyAll = [...ready, ...readyCount];
2546
+ const readyHint = readyAll.length > 0 ? `, ready: ${readyAll.join(", ")}` : "";
2542
2547
  const blocked = eligible.filter(
2543
- (t) => (tiers[t]?.pending ?? 0) >= nudgeGrowthTokens && (state.nudge.lastShownByTier[t] ?? 0) > 0 && tokenCount - (state.nudge.lastShownByTier[t] ?? 0) < growthFloor
2548
+ (t) => ((tiers[t]?.pending ?? 0) >= nudgeGrowthTokens || countReady(t)) && (state.nudge.lastShownByTier[t] ?? 0) > 0 && tokenCount - (state.nudge.lastShownByTier[t] ?? 0) < growthFloor
2544
2549
  ).map((t) => `T${t} (cadence)`);
2545
2550
  const blockedHint = blocked.length > 0 ? `, blocked: ${blocked.join(", ")}` : "";
2546
2551
  const maxPending = Math.max(
@@ -11560,7 +11565,7 @@ async function statusReport(runtime, ctx) {
11560
11565
  const modelId = ctx.model?.id ?? "default";
11561
11566
  const sentTokens = estimateTokens(coreMessages, coveredIds, imageTokens) + systemPromptTokens;
11562
11567
  const turn = runtime.core.processTurn({ messages: coreMessages, state, config, tokenCount: calibrateTokens(sentTokens, runtime.density.densityFor(modelId)) });
11563
- const versionStr = "0.1.51" ? `billion-context-pi@${"0.1.51"}` : void 0;
11568
+ const versionStr = "0.1.52" ? `billion-context-pi@${"0.1.52"}` : void 0;
11564
11569
  let text = buildStatusPanel({
11565
11570
  version: versionStr,
11566
11571
  tokenCount: sessionTokens,
@@ -11923,7 +11928,7 @@ async function autoInstallLatest(latest, extDirOverride) {
11923
11928
  "--no-fund",
11924
11929
  "--no-save"
11925
11930
  ];
11926
- const prevVersion = (await readPackageJson(join8(extDir, "package.json")))?.version ?? "0.1.51";
11931
+ const prevVersion = (await readPackageJson(join8(extDir, "package.json")))?.version ?? "0.1.52";
11927
11932
  const { code, stderr } = await runNpmImpl(installArgs(latest), { cwd: npmDir, timeout: 6e4 });
11928
11933
  if (code !== 0) {
11929
11934
  logWarn("update", {
@@ -11936,7 +11941,7 @@ async function autoInstallLatest(latest, extDirOverride) {
11936
11941
  }
11937
11942
  const verify = await verifyInstall(npmDir, latest);
11938
11943
  if (!verify.ok) {
11939
- const rollbackTo = SEMVER_RE.test(prevVersion) ? prevVersion : "0.1.51";
11944
+ const rollbackTo = SEMVER_RE.test(prevVersion) ? prevVersion : "0.1.52";
11940
11945
  logWarn("update", { event: "auto-install-verify-failed", latest, reason: verify.reason, rollbackTo });
11941
11946
  const rb = await runNpmImpl(installArgs(rollbackTo), { cwd: npmDir, timeout: 6e4 });
11942
11947
  logInfo("update", { event: "rollback", from: latest, to: rollbackTo, ok: rb.code === 0 });
@@ -11997,7 +12002,7 @@ async function checkForUpdate(autoUpdate, notify) {
11997
12002
  const runtimeVersion = await getRuntimeVersion();
11998
12003
  const latest = await fetchLatestVersion();
11999
12004
  if (!latest) return;
12000
- const current = runtimeVersion ?? "0.1.51";
12005
+ const current = runtimeVersion ?? "0.1.52";
12001
12006
  const hasUpdate = isNewer(latest, current);
12002
12007
  debug.event("update-check", {
12003
12008
  current,
@@ -12076,7 +12081,7 @@ function wireSessionLifecycle(pi, runtime) {
12076
12081
  const sid = ctx.sessionManager.getSessionId();
12077
12082
  runtime.clearSessionTracking(sid);
12078
12083
  const modelInfo = ctx.model;
12079
- logInfo("session", { event: "start", sid, cwd: ctx.cwd, debug: runtime.adapter.debug ?? null, version: true ? "0.1.51" : null, model: modelInfo?.id ?? null, modelApi: modelInfo?.api ?? null, contextWindow: modelInfo?.contextWindow ?? null });
12084
+ logInfo("session", { event: "start", sid, cwd: ctx.cwd, debug: runtime.adapter.debug ?? null, version: true ? "0.1.52" : null, model: modelInfo?.id ?? null, modelApi: modelInfo?.api ?? null, contextWindow: modelInfo?.contextWindow ?? null });
12080
12085
  try {
12081
12086
  await runtime.reloadConfig(ctx.cwd);
12082
12087
  setDelegateDisplayUsage(resolveDelegate(runtime.adapter).displayUsage);