acp-kernel 0.0.46-pr.165.20 → 0.0.46-pr.171.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.
@@ -33,6 +33,8 @@ export interface ResolvedRange {
33
33
  boundaryKind: BoundaryKind;
34
34
  protectedGaps: number[];
35
35
  snappedBoundaries: string[];
36
+ refStart: number | null;
37
+ refEnd: number | null;
36
38
  }
37
39
  export declare function resolveBoundaries(input: ResolveBoundariesInput): ResolvedRange;
38
40
  /**
@@ -43,7 +45,7 @@ export declare function resolveBoundaries(input: ResolveBoundariesInput): Resolv
43
45
  * promoted (dog/billion-context-pi#195).
44
46
  */
45
47
  export declare function visibleBlockAnchor(block: CompressionBlock, indexByMessageId: Map<string, number>): number | null;
46
- export declare function blockVisibleInRange(block: CompressionBlock, indexByMessageId: Map<string, number>, startIndex: number, endIndex: number): boolean;
48
+ export declare function blockVisibleInRange(block: CompressionBlock, indexByMessageId: Map<string, number>, startIndex: number, endIndex: number, byRaw?: Record<string, string>, refStart?: number | null, refEnd?: number | null): boolean;
47
49
  export declare function earliestIndexOfIds(ids: string[], indexByMessageId: Map<string, number>): number | null;
48
50
  export declare function toResolvedBoundary(range: ResolvedRange): ResolvedBoundary;
49
51
  //# sourceMappingURL=boundaries.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"boundaries.d.ts","sourceRoot":"","sources":["../src/boundaries.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,CAAC;AAE/C,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CACb;AAKD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,IA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AAE,cAAc,CAAC;CAC7B;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,EAAE,CAAC;IACJ,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,EAAE,gBAAgB,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACnC;AA2BD,wBAAgB,UAAU,CAAC,KAAK,GAAE,KAAU,GAAG,eAAe,CA+T7D;AA85BD,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -117,6 +117,10 @@ function prune(messages, state, options = {}) {
117
117
  const firstUserIndex = messages.findIndex(
118
118
  (message) => message.role === "user"
119
119
  );
120
+ const firstNonSystemIndex = messages.findIndex(
121
+ (message) => message.role !== "system"
122
+ );
123
+ const summaryClampIndex = firstNonSystemIndex >= 0 ? firstNonSystemIndex : 0;
120
124
  const indexById = /* @__PURE__ */ new Map();
121
125
  const summaryIndexById = /* @__PURE__ */ new Map();
122
126
  messages.forEach((message, index) => {
@@ -124,7 +128,12 @@ function prune(messages, state, options = {}) {
124
128
  if (isRenderedSummaryMessage(message))
125
129
  summaryIndexById.set(message.id, index);
126
130
  });
127
- const anchors = inject ? collectSummaryAnchors(state, indexById, summaryIndexById) : [];
131
+ const anchors = inject ? collectSummaryAnchors(
132
+ state,
133
+ indexById,
134
+ summaryIndexById,
135
+ summaryClampIndex
136
+ ) : [];
128
137
  return stripOrphanedReasoning(
129
138
  stripOrphanedToolResults(
130
139
  stripOrphanedToolCalls(
@@ -133,7 +142,7 @@ function prune(messages, state, options = {}) {
133
142
  )
134
143
  );
135
144
  }
136
- function collectSummaryAnchors(state, indexById, summaryIndexById) {
145
+ function collectSummaryAnchors(state, indexById, summaryIndexById, clampIndex) {
137
146
  const anchors = [];
138
147
  for (const block of activeBlocks(state)) {
139
148
  const existingIndex = summaryIndexById.get(summaryMessageId(block.blockId));
@@ -142,7 +151,8 @@ function collectSummaryAnchors(state, indexById, summaryIndexById) {
142
151
  blockId: block.blockId,
143
152
  summary: block.summary,
144
153
  topic: block.topic,
145
- insertAt: existingIndex
154
+ insertAt: Math.min(existingIndex, clampIndex),
155
+ orderKey: existingIndex
146
156
  });
147
157
  continue;
148
158
  }
@@ -153,14 +163,16 @@ function collectSummaryAnchors(state, indexById, summaryIndexById) {
153
163
  earliest = index;
154
164
  }
155
165
  }
166
+ const original = earliest ?? 0;
156
167
  anchors.push({
157
168
  blockId: block.blockId,
158
169
  summary: block.summary,
159
170
  topic: block.topic,
160
- insertAt: earliest ?? 0
171
+ insertAt: Math.min(original, clampIndex),
172
+ orderKey: original
161
173
  });
162
174
  }
163
- anchors.sort((left, right) => left.insertAt - right.insertAt);
175
+ anchors.sort((left, right) => left.orderKey - right.orderKey);
164
176
  return anchors;
165
177
  }
166
178
  function rebuildMessages(messages, covered, firstUserIndex, anchors) {
@@ -445,6 +457,9 @@ function resolveBoundaries(input) {
445
457
  if (startIndex > endIndex) {
446
458
  [startIndex, endIndex] = [endIndex, startIndex];
447
459
  }
460
+ const bothMessageRefs = start.kind === "message" && end.kind === "message";
461
+ const refStart = bothMessageRefs ? Math.min(start.numericId, end.numericId) : null;
462
+ const refEnd = bothMessageRefs ? Math.max(start.numericId, end.numericId) : null;
448
463
  const messageIds = [];
449
464
  for (let index = startIndex; index <= endIndex; index++) {
450
465
  const message = input.messages[index];
@@ -455,7 +470,15 @@ function resolveBoundaries(input) {
455
470
  const nestedBlockIds = [];
456
471
  const nestedSeen = /* @__PURE__ */ new Set();
457
472
  for (const block of activeBlocks(input.state)) {
458
- if (blockVisibleInRange(block, indexByMessageId, startIndex, endIndex)) {
473
+ if (blockVisibleInRange(
474
+ block,
475
+ indexByMessageId,
476
+ startIndex,
477
+ endIndex,
478
+ input.state.messageRefs.byRaw,
479
+ refStart,
480
+ refEnd
481
+ )) {
459
482
  if (!nestedSeen.has(block.blockId)) {
460
483
  nestedSeen.add(block.blockId);
461
484
  nestedBlockIds.push(block.blockId);
@@ -470,7 +493,9 @@ function resolveBoundaries(input) {
470
493
  nestedBlockIds,
471
494
  boundaryKind,
472
495
  protectedGaps,
473
- snappedBoundaries
496
+ snappedBoundaries,
497
+ refStart,
498
+ refEnd
474
499
  };
475
500
  }
476
501
  function resolveAnchorIndex(boundary, state, indexByMessageId, endpoint) {
@@ -579,7 +604,7 @@ function visibleBlockAnchor(block, indexByMessageId) {
579
604
  if (summaryIndex !== void 0) return summaryIndex;
580
605
  return earliestIndexOfIds(block.effectiveMessageIds, indexByMessageId);
581
606
  }
582
- function blockVisibleInRange(block, indexByMessageId, startIndex, endIndex) {
607
+ function blockVisibleInRange(block, indexByMessageId, startIndex, endIndex, byRaw = {}, refStart = null, refEnd = null) {
583
608
  const summaryIndex = indexByMessageId.get(summaryMessageId(block.blockId));
584
609
  if (summaryIndex !== void 0 && summaryIndex >= startIndex && summaryIndex <= endIndex) {
585
610
  return true;
@@ -588,7 +613,22 @@ function blockVisibleInRange(block, indexByMessageId, startIndex, endIndex) {
588
613
  block.effectiveMessageIds,
589
614
  indexByMessageId
590
615
  );
591
- return rawIndex !== null && rawIndex >= startIndex && rawIndex <= endIndex;
616
+ if (rawIndex !== null && rawIndex >= startIndex && rawIndex <= endIndex) {
617
+ return true;
618
+ }
619
+ if (rawIndex === null && refStart !== null && refEnd !== null) {
620
+ for (const id of block.effectiveMessageIds) {
621
+ const ref = byRaw[id];
622
+ if (ref === void 0) continue;
623
+ const num = refNumber(ref);
624
+ if (num !== null && num >= refStart && num <= refEnd) return true;
625
+ }
626
+ }
627
+ return false;
628
+ }
629
+ function refNumber(ref) {
630
+ const match = MESSAGE_REF_PATTERN.exec(ref);
631
+ return match ? Number(match[1]) : null;
592
632
  }
593
633
  function earliestIndexOfIds(ids, indexByMessageId) {
594
634
  let earliest = null;
@@ -2274,7 +2314,15 @@ function applySingleRange(input) {
2274
2314
  const nestedSeen = new Set(resolved.nestedBlockIds);
2275
2315
  for (const block2 of activeBlocks(input.state)) {
2276
2316
  if (nestedSeen.has(block2.blockId)) continue;
2277
- if (blockVisibleInRange(block2, indexByMessageId, adjustedStart, adjustedEnd)) {
2317
+ if (blockVisibleInRange(
2318
+ block2,
2319
+ indexByMessageId,
2320
+ adjustedStart,
2321
+ adjustedEnd,
2322
+ input.state.messageRefs.byRaw,
2323
+ resolved.refStart,
2324
+ resolved.refEnd
2325
+ )) {
2278
2326
  nestedSeen.add(block2.blockId);
2279
2327
  resolved.nestedBlockIds.push(block2.blockId);
2280
2328
  }
@@ -2914,7 +2962,7 @@ function collectVisible(messages, state, countTokens) {
2914
2962
  if (!ref) return;
2915
2963
  const tokens = countTokens(message.text ?? "");
2916
2964
  const tool = message.toolName ?? "text";
2917
- if (tokens > 0) visible.push({ ref, tokens, tool, index, isUser: message.role === "user" });
2965
+ if (tokens > 0) visible.push({ ref, tokens, tool, index });
2918
2966
  });
2919
2967
  return { visible, summaryTokens };
2920
2968
  }
@@ -2933,7 +2981,7 @@ function buildStatusReport(state, messages, countTokens, options = {}) {
2933
2981
  if (view === "messages") {
2934
2982
  return renderMessageDrilldown(visible, toolFilter, sort, limit);
2935
2983
  }
2936
- return renderUncompressedRanges(visible, sort, limit);
2984
+ return renderUncompressedRanges(visible);
2937
2985
  }
2938
2986
  return renderOverview(visible, summaryTokens, activeBlocks2, state, countTokens, limit);
2939
2987
  }
@@ -2988,7 +3036,7 @@ function renderOverview(visible, summaryTokens, blocks, state, countTokens, limi
2988
3036
  );
2989
3037
  return lines.join("\n");
2990
3038
  }
2991
- function renderUncompressedRanges(visible, sort, limit) {
3039
+ function renderUncompressedRanges(visible) {
2992
3040
  const lines = [];
2993
3041
  const totalTokens = visible.reduce((s, m) => s + m.tokens, 0);
2994
3042
  lines.push(`UNCOMPRESSED \u2014 ${formatTokens2(totalTokens)} | ${visible.length} visible messages`);
@@ -3005,9 +3053,7 @@ function renderUncompressedRanges(visible, sort, limit) {
3005
3053
  for (const m of visible) {
3006
3054
  const num = refNum2(m.ref);
3007
3055
  const last = merged[merged.length - 1];
3008
- const contiguous = !!last && num === last.startNum + last.count;
3009
- const turnBoundary = !!last && m.isUser && last.count >= 3;
3010
- if (contiguous && !turnBoundary) {
3056
+ if (last && num === last.startNum + last.count) {
3011
3057
  last.endRef = m.ref;
3012
3058
  last.count += 1;
3013
3059
  last.tokens += m.tokens;
@@ -3015,16 +3061,12 @@ function renderUncompressedRanges(visible, sort, limit) {
3015
3061
  merged.push({ startRef: m.ref, endRef: m.ref, startNum: num, count: 1, tokens: m.tokens, tool: m.tool });
3016
3062
  }
3017
3063
  }
3018
- if (sort !== "time") merged.sort((a, b) => b.tokens - a.tokens || a.startNum - b.startNum);
3019
- lines.push(`Sorted by ${sort === "time" ? "time" : "size"}`);
3020
- lines.push("");
3021
- const shown = merged.slice(0, limit);
3022
- for (const r of shown) {
3064
+ for (const r of merged.slice(0, 30)) {
3023
3065
  const range = r.count === 1 ? r.startRef : `${r.startRef}\u2013${r.endRef}`;
3024
3066
  lines.push(` ${range} (${r.count} msgs, ${formatTokens2(r.tokens)}${r.count > 1 ? ` (${Math.round(r.tokens / r.count)}/msg)` : ""}) ${r.tool}`);
3025
3067
  }
3026
- if (merged.length > shown.length) {
3027
- lines.push(` ... and ${merged.length - shown.length} more ranges`);
3068
+ if (merged.length > 30) {
3069
+ lines.push(` ... and ${merged.length - 30} more ranges`);
3028
3070
  }
3029
3071
  return lines.join("\n");
3030
3072
  }