billion-context-pi 0.1.30 → 0.1.31

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
@@ -2537,6 +2537,15 @@ function patchRefTag(original, core) {
2537
2537
  if (!tag) return original;
2538
2538
  const base = original;
2539
2539
  if (base.role === "assistant") return original;
2540
+ const tagCore = tag.replace(/\s+$/, "");
2541
+ let bodyStart = tagCore.length;
2542
+ if (core.text && core.text.charAt(bodyStart) === "\n") bodyStart += 1;
2543
+ const coreBody = core.text ? core.text.slice(bodyStart) : "";
2544
+ const originalBody = extractText(base.content);
2545
+ const trimEnd = (s) => s.replace(/\s+$/, "");
2546
+ if (coreBody && trimEnd(coreBody) !== trimEnd(originalBody)) {
2547
+ return rebuildBodyFromCore(original, coreBody, tag);
2548
+ }
2540
2549
  const rawBlocks = Array.isArray(base.content) ? base.content : typeof base.content === "string" ? [{ type: "text", text: base.content }] : [];
2541
2550
  const peeled = peelRefTagBlocks(rawBlocks);
2542
2551
  const newBlocks = [...peeled];
@@ -2560,6 +2569,23 @@ ${tag}` : tag };
2560
2569
  content: [...peeled, { type: "text", text: tag }]
2561
2570
  };
2562
2571
  }
2572
+ function rebuildBodyFromCore(original, coreBody, tag) {
2573
+ const base = original;
2574
+ const text = `${coreBody.replace(/\s+$/, "")}
2575
+
2576
+ ${tag}`;
2577
+ if (typeof base.content === "string") {
2578
+ return { ...original, content: text };
2579
+ }
2580
+ if (Array.isArray(base.content)) {
2581
+ const nonText = base.content.filter((b) => b.type !== "text");
2582
+ return {
2583
+ ...original,
2584
+ content: [...nonText, { type: "text", text }]
2585
+ };
2586
+ }
2587
+ return { ...original, content: [{ type: "text", text }] };
2588
+ }
2563
2589
  function peelRefTagBlocks(blocks) {
2564
2590
  const out = [];
2565
2591
  for (const block of blocks) {
@@ -8718,7 +8744,7 @@ async function statusReport(runtime, ctx) {
8718
8744
  const activeBlocksList = state.blocks.filter((b) => b.active);
8719
8745
  const totalBlocksList = state.blocks;
8720
8746
  const lines = [];
8721
- const versionStr = "0.1.30" ? `billion-context-pi@${"0.1.30"}` : "";
8747
+ const versionStr = "0.1.31" ? `billion-context-pi@${"0.1.31"}` : "";
8722
8748
  lines.push("\u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E");
8723
8749
  lines.push("\u2502 ACP Context Analysis \u2502");
8724
8750
  lines.push("\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F");
@@ -9084,7 +9110,7 @@ async function checkForUpdate(autoUpdate, notify) {
9084
9110
  const data = await res.json();
9085
9111
  const latest = data.version;
9086
9112
  if (!latest) return;
9087
- const current = runtimeVersion ?? "0.1.30";
9113
+ const current = runtimeVersion ?? "0.1.31";
9088
9114
  const hasUpdate = isNewer(latest, current);
9089
9115
  debug.event("update-check", {
9090
9116
  current,
@@ -9323,7 +9349,7 @@ function wireSessionLifecycle(pi, runtime) {
9323
9349
  runtime.store.invalidate();
9324
9350
  runtime.clearNudgeTracking();
9325
9351
  const sid = ctx.sessionManager.getSessionId();
9326
- logInfo("session", { event: "start", sid, cwd: ctx.cwd, debug: runtime.adapter.debug ?? null, version: true ? "0.1.30" : null });
9352
+ logInfo("session", { event: "start", sid, cwd: ctx.cwd, debug: runtime.adapter.debug ?? null, version: true ? "0.1.31" : null });
9327
9353
  try {
9328
9354
  const user = await loadUserConfig(ctx.cwd);
9329
9355
  runtime.setAdapter(applyUserConfig(runtime.adapter, user));