opencode-acp 1.16.0-pr.365.125 → 1.16.0-pr.374.126

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
@@ -2159,56 +2159,6 @@ var messageHasCompressAttempt = (message) => {
2159
2159
  const parts = Array.isArray(message.parts) ? message.parts : [];
2160
2160
  return parts.some((part) => part.type === "tool" && part.tool === "compress");
2161
2161
  };
2162
- var isCaptureOnlyCompress = (message) => {
2163
- if (!isMessageWithInfo(message)) {
2164
- return false;
2165
- }
2166
- if (message.info.role !== "assistant") {
2167
- return false;
2168
- }
2169
- const parts = Array.isArray(message.parts) ? message.parts : [];
2170
- let sawBoundary = false;
2171
- for (const part of parts) {
2172
- if (!(part.type === "tool" && part.tool === "compress")) {
2173
- continue;
2174
- }
2175
- for (const startId of extractCompressBoundaryIds(part.state?.input)) {
2176
- sawBoundary = true;
2177
- if (/^b\d+$/i.test(startId)) {
2178
- return false;
2179
- }
2180
- }
2181
- }
2182
- return sawBoundary;
2183
- };
2184
- function extractCompressBoundaryIds(rawInput) {
2185
- let content = [];
2186
- if (typeof rawInput === "string") {
2187
- try {
2188
- const parsed = JSON.parse(rawInput);
2189
- const c = parsed?.content;
2190
- content = Array.isArray(c) ? c : [];
2191
- } catch {
2192
- return [];
2193
- }
2194
- } else if (rawInput && typeof rawInput === "object") {
2195
- const c = rawInput.content;
2196
- content = Array.isArray(c) ? c : [];
2197
- }
2198
- const ids = [];
2199
- for (const entry of content) {
2200
- if (!entry || typeof entry !== "object") {
2201
- continue;
2202
- }
2203
- const { startId, endId } = entry;
2204
- for (const sid of [startId, endId]) {
2205
- if (typeof sid === "string" && sid.trim() !== "") {
2206
- ids.push(sid.trim());
2207
- }
2208
- }
2209
- }
2210
- return ids;
2211
- }
2212
2162
  var isIgnoredUserMessage = (message) => {
2213
2163
  if (!isMessageWithInfo(message)) {
2214
2164
  return false;
@@ -6981,6 +6931,7 @@ function estimateContextComposition(messages, state, protectedTools = [], protec
6981
6931
  let summaryTokens = 0;
6982
6932
  let messageTokens = 0;
6983
6933
  let protectedTokens = 0;
6934
+ let reasoningTokens = 0;
6984
6935
  const perMessage = [];
6985
6936
  const perTool = [];
6986
6937
  const perCode = [];
@@ -7034,6 +6985,10 @@ function estimateContextComposition(messages, state, protectedTools = [], protec
7034
6985
  summaryTokens += summaryPartTokens;
7035
6986
  toolTypeMap.set(toolName, (toolTypeMap.get(toolName) || 0) + toolPartTokens);
7036
6987
  if (!msgToolName) msgToolName = toolName;
6988
+ } else if (part.type === "reasoning" && typeof part.text === "string") {
6989
+ const tokens = Math.round(part.text.length / 4);
6990
+ msgTotal += tokens;
6991
+ reasoningTokens += tokens;
7037
6992
  }
7038
6993
  }
7039
6994
  if (isProtected && !isSummary) {
@@ -7061,7 +7016,8 @@ function estimateContextComposition(messages, state, protectedTools = [], protec
7061
7016
  textTokens: Math.max(0, messageTokens - codeTokens),
7062
7017
  systemTokens,
7063
7018
  protectedTokens,
7064
- total: systemTokens + toolTokens + summaryTokens + messageTokens,
7019
+ reasoningTokens,
7020
+ total: systemTokens + toolTokens + summaryTokens + messageTokens + reasoningTokens,
7065
7021
  largestRanges: perMessage.slice(0, 15),
7066
7022
  largestToolRanges: perTool.slice(0, 15),
7067
7023
  largestCodeRanges: perCode.slice(0, 5),
@@ -7943,11 +7899,8 @@ var injectCompressNudges = (state, config, logger, messages, prompts, compressio
7943
7899
  state.nudges.iterationNudgeAnchors.clear();
7944
7900
  state.nudges.lastNudgeShownTokens = void 0;
7945
7901
  state.nudges.lastToolOutputNudgeTokens = void 0;
7946
- const captureOnly = isCaptureOnlyCompress(lastCompressMsg);
7947
- if (!captureOnly) {
7948
- state.nudges.lastTier2NudgeTokens = currentTokens;
7949
- state.nudges.lastTier3NudgeTokens = currentTokens;
7950
- }
7902
+ state.nudges.lastTier2NudgeTokens = currentTokens;
7903
+ state.nudges.lastTier3NudgeTokens = currentTokens;
7951
7904
  const currentTurnHasSuccessfulCompress = messages.slice(currentTurnStart).some((m) => m.info.role === "assistant" && messageHasCompress(m));
7952
7905
  if (currentTurnHasSuccessfulCompress && wasNudgeTriggered && !state.nudges.compressBaselineSet) {
7953
7906
  const baseline = state.nudges.lastPerMessageNudgeTokens;
@@ -8259,7 +8212,7 @@ This is an efficiency nudge to compress early and keep context lean \u2014 not a
8259
8212
  ${COMPRESS_PHILOSOPHY}` : "";
8260
8213
  const sysPart = composition.systemTokens > 0 ? `${fmt(composition.systemTokens)} system (${pct2(composition.systemTokens)}%) | ` : "";
8261
8214
  let breakdown = `${efficiencyNote}
8262
- Breakdown: ${sysPart}${fmt(composition.toolTokens)} tool (${pct2(composition.toolTokens)}%) | ${fmt(composition.summaryTokens)} summaries (${pct2(composition.summaryTokens)}%) | ${fmt(composition.codeTokens)} code (${pct2(composition.codeTokens)}%) | ${fmt(plainTextTokens)} text (${pct2(plainTextTokens)}%)${growthStr}`;
8215
+ Breakdown: ${sysPart}${fmt(composition.toolTokens)} tool (${pct2(composition.toolTokens)}%) | ${fmt(composition.summaryTokens)} summaries (${pct2(composition.summaryTokens)}%) | ${fmt(composition.codeTokens)} code (${pct2(composition.codeTokens)}%) | ${fmt(plainTextTokens)} text (${pct2(plainTextTokens)}%) | ${fmt(composition.reasoningTokens)} reasoning (${pct2(composition.reasoningTokens)}%)${growthStr}`;
8263
8216
  const compressibleTokens = composition.total - composition.systemTokens - composition.protectedTokens - composition.summaryTokens;
8264
8217
  if (composition.protectedTokens > 0) {
8265
8218
  breakdown += `
@@ -9147,6 +9100,7 @@ function collectVisibleMessages(rawMessages, ctx) {
9147
9100
  const ref = byRawId.get(msgId);
9148
9101
  if (!ref) return;
9149
9102
  let tokens = 0;
9103
+ let reasoning = 0;
9150
9104
  let toolName = "";
9151
9105
  for (const part of msg.parts || []) {
9152
9106
  if (part.type === "text" && typeof part.text === "string") {
@@ -9157,10 +9111,12 @@ function collectVisibleMessages(rawMessages, ctx) {
9157
9111
  if (!toolName) {
9158
9112
  toolName = part?.tool || "unknown";
9159
9113
  }
9114
+ } else if (part.type === "reasoning" && typeof part.text === "string") {
9115
+ reasoning += Math.round(part.text.length / 4);
9160
9116
  }
9161
9117
  }
9162
- if (tokens > 0) {
9163
- result.push({ ref, tokens, tool: toolName || "text", index: idx });
9118
+ if (tokens > 0 || reasoning > 0) {
9119
+ result.push({ ref, tokens, tool: toolName || "text", index: idx, reasoning });
9164
9120
  }
9165
9121
  });
9166
9122
  return {
@@ -9182,14 +9138,16 @@ function renderOverview(visibleMessages, summaryTokens, systemTokens, blocks, fe
9182
9138
  } else {
9183
9139
  const totalTool = visibleMessages.filter((m) => m.tool !== "text" && m.tool !== "step-finish").reduce((s, m) => s + m.tokens, 0);
9184
9140
  const totalText = visibleMessages.filter((m) => m.tool === "text").reduce((s, m) => s + m.tokens, 0);
9185
- const total = systemTokens + totalTool + totalText + summaryTokens;
9141
+ const totalReasoning = visibleMessages.reduce((s, m) => s + m.reasoning, 0);
9142
+ const total = systemTokens + totalTool + totalText + summaryTokens + totalReasoning;
9186
9143
  const sysPct = pct(systemTokens, total);
9187
9144
  const toolPct = pct(totalTool, total);
9188
9145
  const textPct = pct(totalText, total);
9189
9146
  const summaryPct = pct(summaryTokens, total);
9147
+ const reasoningPct = pct(totalReasoning, total);
9190
9148
  lines.push("CONTEXT BREAKDOWN");
9191
9149
  lines.push(
9192
- ` ${formatTokens(systemTokens)} system (${sysPct}%) | ${formatTokens(totalTool)} tool (${toolPct}%) | ${formatTokens(totalText)} text (${textPct}%) | ${formatTokens(summaryTokens)} summaries (${summaryPct}%)`
9150
+ ` ${formatTokens(systemTokens)} system (${sysPct}%) | ${formatTokens(totalTool)} tool (${toolPct}%) | ${formatTokens(totalText)} text (${textPct}%) | ${formatTokens(summaryTokens)} summaries (${summaryPct}%) | ${formatTokens(totalReasoning)} reasoning (${reasoningPct}%)`
9193
9151
  );
9194
9152
  const topTypes = Array.from(toolTypeMap.entries()).map(([tool6, tokens]) => ({ tool: tool6, tokens })).sort((a, b) => b.tokens - a.tokens).slice(0, 3);
9195
9153
  if (topTypes.length > 0) {
@@ -9300,22 +9258,23 @@ function renderUncompressedDrilldown(visibleMessages, toolFilter, sort, limit) {
9300
9258
  if (toolFilter) {
9301
9259
  filtered = filtered.filter((m) => m.tool === toolFilter);
9302
9260
  }
9261
+ const sizeOf = (m) => m.tokens + m.reasoning;
9303
9262
  if (sort === "time") {
9304
9263
  filtered.sort((a, b) => a.index - b.index);
9305
9264
  } else if (sort === "tool") {
9306
- filtered.sort((a, b) => a.tool.localeCompare(b.tool) || b.tokens - a.tokens);
9265
+ filtered.sort((a, b) => a.tool.localeCompare(b.tool) || sizeOf(b) - sizeOf(a));
9307
9266
  } else {
9308
- filtered.sort((a, b) => b.tokens - a.tokens);
9267
+ filtered.sort((a, b) => sizeOf(b) - sizeOf(a));
9309
9268
  }
9310
- const totalTokens = filtered.reduce((s, m) => s + m.tokens, 0);
9311
- const allTokens = visibleMessages.reduce((s, m) => s + m.tokens, 0);
9269
+ const totalTokens = filtered.reduce((s, m) => s + sizeOf(m), 0);
9270
+ const allTokens = visibleMessages.reduce((s, m) => s + sizeOf(m), 0);
9312
9271
  const header = toolFilter ? `UNCOMPRESSED \u2014 ${toolFilter}: ${formatTokens(totalTokens)} | ${filtered.length} msgs | ${pct(totalTokens, allTokens)}% of visible` : `UNCOMPRESSED \u2014 ${formatTokens(totalTokens)} | ${filtered.length} msgs`;
9313
9272
  lines.push(header);
9314
9273
  lines.push(`Sorted by ${sort}`);
9315
9274
  lines.push("");
9316
9275
  const shown = filtered.slice(0, limit);
9317
9276
  for (const m of shown) {
9318
- lines.push(` ${m.ref} (${formatTokens(m.tokens)}) ${m.tool}`);
9277
+ lines.push(` ${m.ref} (${formatTokens(sizeOf(m))}) ${m.tool}`);
9319
9278
  }
9320
9279
  if (filtered.length > shown.length) {
9321
9280
  lines.push("");
@@ -9583,7 +9542,7 @@ import { writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
9583
9542
  import { join as join4 } from "path";
9584
9543
  import { existsSync as existsSync4 } from "fs";
9585
9544
  import { homedir as homedir3 } from "os";
9586
- var LOG_VERSION = true ? "1.16.0-pr.365.125" : "dev";
9545
+ var LOG_VERSION = true ? "1.16.0-pr.374.126" : "dev";
9587
9546
  var LEVEL_RANK = {
9588
9547
  debug: 10,
9589
9548
  info: 20,
@@ -9879,13 +9838,14 @@ CONTEXT BREAKDOWN
9879
9838
 
9880
9839
  When context usage passes a threshold, the system appends a breakdown showing where your context tokens are spent:
9881
9840
 
9882
- Breakdown: 5.2K system (21%) | 12.3K tool (40%) | 3.1K summaries (10%) | 8.5K code (28%) | 6.5K text (22%)
9841
+ Breakdown: 4.2K system (21%) | 8.0K tool (40%) | 2.0K summaries (10%) | 2.6K code (13%) | 2.2K text (11%) | 1.0K reasoning (5%)
9883
9842
 
9884
9843
  - "system" = system prompt tokens (AGENTS.md, tool definitions \u2014 not compressible)
9885
9844
  - "tool" = tool call outputs (largest category \u2014 compress first when consumed)
9886
9845
  - "summaries" = existing compression block summaries (already compressed; do not re-compress standalone)
9887
9846
  - "code" = messages containing code blocks
9888
9847
  - "text" = plain text messages
9848
+ - "reasoning" = model thinking blocks (counted to match real API usage; freed when their message is compressed)
9889
9849
 
9890
9850
  Below the breakdown, the system lists compressible ranges grouped by conversation turn. All listed ranges should be compressed to summary format \u2014 the only exceptions are protected content, content the current step is actively using, or critical content you cannot reconstruct. Compress the largest ranges first when the current step no longer needs them.
9891
9851
 
@@ -12074,7 +12034,7 @@ var server = (async (ctx) => {
12074
12034
  }
12075
12035
  const logger = new Logger(config.debug, config.debug ? "debug" : config.logLevel);
12076
12036
  logger.info("ACP plugin initialized", {
12077
- version: true ? "1.16.0-pr.365.125" : "dev",
12037
+ version: true ? "1.16.0-pr.374.126" : "dev",
12078
12038
  workspace: ctx.directory,
12079
12039
  logLevel: logger.level,
12080
12040
  debug: config.debug,