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

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,6 +2159,56 @@ 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
+ }
2162
2212
  var isIgnoredUserMessage = (message) => {
2163
2213
  if (!isMessageWithInfo(message)) {
2164
2214
  return false;
@@ -7034,10 +7084,13 @@ function buildCompressibleRanges(messages, state, protectedTools = [], protected
7034
7084
  if (!ref) continue;
7035
7085
  const rn = parseInt(ref.slice(1), 10);
7036
7086
  if ((protectedTools.length > 0 || protectedFilePatterns.length > 0) && messageContainsProtectedTool(msg, protectedTools, protectedFilePatterns)) {
7037
- const tokens2 = Math.round(countMessageCharacters(msg) / 4);
7087
+ let tokens2 = 0;
7038
7088
  const tools = /* @__PURE__ */ new Set();
7039
7089
  for (const part of msg.parts || []) {
7040
- if (part.type !== "text" && part.type !== "reasoning") {
7090
+ if (part.type === "text" && typeof part.text === "string") {
7091
+ tokens2 += Math.round(part.text.length / 4);
7092
+ } else if (part.type !== "text" && part.type !== "reasoning") {
7093
+ tokens2 += Math.round(JSON.stringify(part).length / 4);
7041
7094
  const toolName = part?.tool;
7042
7095
  const callID = part?.callID;
7043
7096
  if (toolName && callID) {
@@ -7058,13 +7111,15 @@ function buildCompressibleRanges(messages, state, protectedTools = [], protected
7058
7111
  protectedMsgInfo.push({ ref, refNum: rn, tokens: tokens2, tools: [...tools] });
7059
7112
  continue;
7060
7113
  }
7061
- const tokens = Math.round(countMessageCharacters(msg) / 4);
7114
+ let tokens = 0;
7062
7115
  let isTool = false;
7063
7116
  let hasMeaningfulPart = false;
7064
7117
  for (const part of msg.parts || []) {
7065
7118
  if (part.type === "text" && typeof part.text === "string") {
7119
+ tokens += Math.round(part.text.length / 4);
7066
7120
  if (part.text.trim().length > 0) hasMeaningfulPart = true;
7067
7121
  } else if (part.type !== "text" && part.type !== "reasoning") {
7122
+ tokens += Math.round(JSON.stringify(part).length / 4);
7068
7123
  isTool = true;
7069
7124
  hasMeaningfulPart = true;
7070
7125
  }
@@ -7888,8 +7943,11 @@ var injectCompressNudges = (state, config, logger, messages, prompts, compressio
7888
7943
  state.nudges.iterationNudgeAnchors.clear();
7889
7944
  state.nudges.lastNudgeShownTokens = void 0;
7890
7945
  state.nudges.lastToolOutputNudgeTokens = void 0;
7891
- state.nudges.lastTier2NudgeTokens = currentTokens;
7892
- state.nudges.lastTier3NudgeTokens = currentTokens;
7946
+ const captureOnly = isCaptureOnlyCompress(lastCompressMsg);
7947
+ if (!captureOnly) {
7948
+ state.nudges.lastTier2NudgeTokens = currentTokens;
7949
+ state.nudges.lastTier3NudgeTokens = currentTokens;
7950
+ }
7893
7951
  const currentTurnHasSuccessfulCompress = messages.slice(currentTurnStart).some((m) => m.info.role === "assistant" && messageHasCompress(m));
7894
7952
  if (currentTurnHasSuccessfulCompress && wasNudgeTriggered && !state.nudges.compressBaselineSet) {
7895
7953
  const baseline = state.nudges.lastPerMessageNudgeTokens;
@@ -9525,7 +9583,7 @@ import { writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
9525
9583
  import { join as join4 } from "path";
9526
9584
  import { existsSync as existsSync4 } from "fs";
9527
9585
  import { homedir as homedir3 } from "os";
9528
- var LOG_VERSION = true ? "1.16.0-pr.360.124" : "dev";
9586
+ var LOG_VERSION = true ? "1.16.0-pr.365.125" : "dev";
9529
9587
  var LEVEL_RANK = {
9530
9588
  debug: 10,
9531
9589
  info: 20,
@@ -12016,7 +12074,7 @@ var server = (async (ctx) => {
12016
12074
  }
12017
12075
  const logger = new Logger(config.debug, config.debug ? "debug" : config.logLevel);
12018
12076
  logger.info("ACP plugin initialized", {
12019
- version: true ? "1.16.0-pr.360.124" : "dev",
12077
+ version: true ? "1.16.0-pr.365.125" : "dev",
12020
12078
  workspace: ctx.directory,
12021
12079
  logLevel: logger.level,
12022
12080
  debug: config.debug,