acp-kernel 0.0.55-pr.209.60 → 0.0.56-pr.210.62

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
@@ -284,6 +284,10 @@ function syncBlocks(messages, state) {
284
284
  block.active = false;
285
285
  continue;
286
286
  }
287
+ if (block.expanded) {
288
+ block.active = false;
289
+ continue;
290
+ }
287
291
  block.active = true;
288
292
  const stillPresent = block.effectiveMessageIds.some((id) => presentIds.has(id)) || presentIds.has(summaryMessageId(block.blockId));
289
293
  if (!stillPresent) {
@@ -1648,6 +1652,10 @@ function adjustBoundariesForReasoningPairs(startIndex, endIndex, messages) {
1648
1652
  }
1649
1653
 
1650
1654
  // src/recommend.ts
1655
+ function refNum(ref) {
1656
+ const n = parseInt(ref.slice(1), 10);
1657
+ return Number.isNaN(n) ? -1 : n;
1658
+ }
1651
1659
  function estimateTextTokens(text) {
1652
1660
  return Math.ceil(text.length / 4);
1653
1661
  }
@@ -1700,50 +1708,42 @@ function buildCompressibleRanges(messages, state, config, protectedZoneRefs, cou
1700
1708
  const compressibleMsgs = [];
1701
1709
  const protectedMsgs = [];
1702
1710
  const protectedCallIds = collectProtectedToolCallIds(messages, config);
1703
- let skipSinceCompressible = false;
1704
- let skipSinceProtected = false;
1705
1711
  for (const msg of messages) {
1712
+ if (isSyntheticOrPruned(msg, state)) continue;
1706
1713
  const ref = state.messageRefs.byRaw[msg.id];
1707
1714
  if (!ref || ref === "BLOCKED") continue;
1708
- if (isSyntheticOrPruned(msg, state)) {
1709
- skipSinceCompressible = true;
1710
- skipSinceProtected = true;
1711
- continue;
1712
- }
1715
+ const rn = refNum(ref);
1713
1716
  if (isMessageProtectedWithPairing(msg, config, protectedCallIds)) {
1714
1717
  protectedMsgs.push({
1715
1718
  ref,
1716
- gapBefore: skipSinceProtected,
1719
+ refNum: rn,
1717
1720
  tokens: countTokens(msg.text ?? ""),
1718
1721
  tools: msg.toolName ? [msg.toolName] : []
1719
1722
  });
1720
- skipSinceProtected = false;
1721
- skipSinceCompressible = true;
1722
1723
  continue;
1723
1724
  }
1724
1725
  if (protectedZoneRefs?.has(ref)) {
1725
- skipSinceCompressible = true;
1726
- skipSinceProtected = true;
1727
1726
  continue;
1728
1727
  }
1729
1728
  compressibleMsgs.push({
1730
1729
  ref,
1731
- gapBefore: skipSinceCompressible,
1730
+ refNum: rn,
1732
1731
  tokens: countTokens(msg.text ?? ""),
1733
1732
  chars: (msg.text ?? "").length,
1734
1733
  isTool: isToolMessage(msg),
1735
1734
  isUser: msg.role === "user"
1736
1735
  });
1737
- skipSinceCompressible = false;
1738
- skipSinceProtected = true;
1739
1736
  }
1740
1737
  const compressible = [];
1741
1738
  let cur = null;
1739
+ let prevRefNum = -2;
1742
1740
  for (const info of compressibleMsgs) {
1743
- if (cur && (info.isUser && cur.count >= 3 || info.gapBefore)) {
1741
+ const hasGap = info.refNum > prevRefNum + 1;
1742
+ if (cur && (info.isUser && cur.count >= 3 || hasGap)) {
1744
1743
  compressible.push(cur);
1745
1744
  cur = null;
1746
1745
  }
1746
+ prevRefNum = info.refNum;
1747
1747
  if (!cur) {
1748
1748
  cur = {
1749
1749
  startRef: info.ref,
@@ -1770,11 +1770,14 @@ function buildCompressibleRanges(messages, state, config, protectedZoneRefs, cou
1770
1770
  if (cur) compressible.push(cur);
1771
1771
  const protectedRanges = [];
1772
1772
  let pcur = null;
1773
+ let pPrevRefNum = -2;
1773
1774
  for (const info of protectedMsgs) {
1774
- if (pcur && info.gapBefore) {
1775
+ const hasGap = info.refNum > pPrevRefNum + 1;
1776
+ if (pcur && hasGap) {
1775
1777
  protectedRanges.push(pcur);
1776
1778
  pcur = null;
1777
1779
  }
1780
+ pPrevRefNum = info.refNum;
1778
1781
  if (!pcur) {
1779
1782
  pcur = {
1780
1783
  startRef: info.ref,
@@ -3044,7 +3047,7 @@ function renderUncompressedRanges(visible) {
3044
3047
  lines.push(" (no uncompressed messages)");
3045
3048
  return lines.join("\n");
3046
3049
  }
3047
- const refNum = (ref) => {
3050
+ const refNum2 = (ref) => {
3048
3051
  const m = ref.match(/\d+/);
3049
3052
  return m ? parseInt(m[0], 10) : 0;
3050
3053
  };
@@ -3061,7 +3064,7 @@ function renderUncompressedRanges(visible) {
3061
3064
  };
3062
3065
  const merged = [];
3063
3066
  for (const m of visible) {
3064
- const num = refNum(m.ref);
3067
+ const num = refNum2(m.ref);
3065
3068
  const last = merged[merged.length - 1];
3066
3069
  if (last && num === last.startNum + last.count) {
3067
3070
  last.endRef = m.ref;