opencode-acp 1.16.0-pr.350.123 → 1.16.0-pr.360.128

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
@@ -2226,6 +2226,56 @@ var messageHasCompressAttempt = (message) => {
2226
2226
  const parts = Array.isArray(message.parts) ? message.parts : [];
2227
2227
  return parts.some((part) => part.type === "tool" && part.tool === "compress");
2228
2228
  };
2229
+ var isCaptureOnlyCompress = (message) => {
2230
+ if (!isMessageWithInfo(message)) {
2231
+ return false;
2232
+ }
2233
+ if (message.info.role !== "assistant") {
2234
+ return false;
2235
+ }
2236
+ const parts = Array.isArray(message.parts) ? message.parts : [];
2237
+ let sawBoundary = false;
2238
+ for (const part of parts) {
2239
+ if (!(part.type === "tool" && part.tool === "compress")) {
2240
+ continue;
2241
+ }
2242
+ for (const startId of extractCompressBoundaryIds(part.state?.input)) {
2243
+ sawBoundary = true;
2244
+ if (/^b\d+$/i.test(startId)) {
2245
+ return false;
2246
+ }
2247
+ }
2248
+ }
2249
+ return sawBoundary;
2250
+ };
2251
+ function extractCompressBoundaryIds(rawInput) {
2252
+ let content = [];
2253
+ if (typeof rawInput === "string") {
2254
+ try {
2255
+ const parsed = JSON.parse(rawInput);
2256
+ const c = parsed?.content;
2257
+ content = Array.isArray(c) ? c : [];
2258
+ } catch {
2259
+ return [];
2260
+ }
2261
+ } else if (rawInput && typeof rawInput === "object") {
2262
+ const c = rawInput.content;
2263
+ content = Array.isArray(c) ? c : [];
2264
+ }
2265
+ const ids = [];
2266
+ for (const entry of content) {
2267
+ if (!entry || typeof entry !== "object") {
2268
+ continue;
2269
+ }
2270
+ const { startId, endId } = entry;
2271
+ for (const sid of [startId, endId]) {
2272
+ if (typeof sid === "string" && sid.trim() !== "") {
2273
+ ids.push(sid.trim());
2274
+ }
2275
+ }
2276
+ }
2277
+ return ids;
2278
+ }
2229
2279
  var isIgnoredUserMessage = (message) => {
2230
2280
  if (!isMessageWithInfo(message)) {
2231
2281
  return false;
@@ -7133,13 +7183,10 @@ function buildCompressibleRanges(messages, state, protectedTools = [], protected
7133
7183
  if (!ref) continue;
7134
7184
  const rn = parseInt(ref.slice(1), 10);
7135
7185
  if ((protectedTools.length > 0 || protectedFilePatterns.length > 0) && messageContainsProtectedTool(msg, protectedTools, protectedFilePatterns)) {
7136
- let tokens2 = 0;
7186
+ const tokens2 = Math.round(countMessageCharacters(msg) / 4);
7137
7187
  const tools = /* @__PURE__ */ new Set();
7138
7188
  for (const part of msg.parts || []) {
7139
- if (part.type === "text" && typeof part.text === "string") {
7140
- tokens2 += Math.round(part.text.length / 4);
7141
- } else if (part.type !== "text" && part.type !== "reasoning") {
7142
- tokens2 += Math.round(JSON.stringify(part).length / 4);
7189
+ if (part.type !== "text" && part.type !== "reasoning") {
7143
7190
  const toolName = part?.tool;
7144
7191
  const callID = part?.callID;
7145
7192
  if (toolName && callID) {
@@ -7160,15 +7207,13 @@ function buildCompressibleRanges(messages, state, protectedTools = [], protected
7160
7207
  protectedMsgInfo.push({ ref, refNum: rn, tokens: tokens2, tools: [...tools] });
7161
7208
  continue;
7162
7209
  }
7163
- let tokens = 0;
7210
+ const tokens = Math.round(countMessageCharacters(msg) / 4);
7164
7211
  let isTool = false;
7165
7212
  let hasMeaningfulPart = false;
7166
7213
  for (const part of msg.parts || []) {
7167
7214
  if (part.type === "text" && typeof part.text === "string") {
7168
- tokens += Math.round(part.text.length / 4);
7169
7215
  if (part.text.trim().length > 0) hasMeaningfulPart = true;
7170
7216
  } else if (part.type !== "text" && part.type !== "reasoning") {
7171
- tokens += Math.round(JSON.stringify(part).length / 4);
7172
7217
  isTool = true;
7173
7218
  hasMeaningfulPart = true;
7174
7219
  }
@@ -7992,8 +8037,11 @@ var injectCompressNudges = (state, config, logger, messages, prompts, compressio
7992
8037
  state.nudges.iterationNudgeAnchors.clear();
7993
8038
  state.nudges.lastNudgeShownTokens = void 0;
7994
8039
  state.nudges.lastToolOutputNudgeTokens = void 0;
7995
- state.nudges.lastTier2NudgeTokens = currentTokens;
7996
- state.nudges.lastTier3NudgeTokens = currentTokens;
8040
+ const captureOnly = isCaptureOnlyCompress(lastCompressMsg);
8041
+ if (!captureOnly) {
8042
+ state.nudges.lastTier2NudgeTokens = currentTokens;
8043
+ state.nudges.lastTier3NudgeTokens = currentTokens;
8044
+ }
7997
8045
  const currentTurnHasSuccessfulCompress = messages.slice(currentTurnStart).some((m) => m.info.role === "assistant" && messageHasCompress(m));
7998
8046
  if (currentTurnHasSuccessfulCompress && wasNudgeTriggered && !state.nudges.compressBaselineSet) {
7999
8047
  const baseline = state.nudges.lastPerMessageNudgeTokens;
@@ -9631,7 +9679,7 @@ import { writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
9631
9679
  import { join as join4 } from "path";
9632
9680
  import { existsSync as existsSync4 } from "fs";
9633
9681
  import { homedir as homedir3 } from "os";
9634
- var LOG_VERSION = true ? "1.16.0-pr.350.123" : "dev";
9682
+ var LOG_VERSION = true ? "1.16.0-pr.360.128" : "dev";
9635
9683
  var LEVEL_RANK = {
9636
9684
  debug: 10,
9637
9685
  info: 20,
@@ -11966,7 +12014,7 @@ function createCommandExecuteHandler(client, registry4, logger, config, workingD
11966
12014
  const sub = input.arguments?.trim().toLowerCase();
11967
12015
  if (sub === "stats" || sub === "status" || sub === "") {
11968
12016
  await handleStatsCommand(commandCtx);
11969
- throw new Error("__DCP_CONTEXT_HANDLED__");
12017
+ return;
11970
12018
  }
11971
12019
  if (sub === "export" || sub.startsWith("export ")) {
11972
12020
  const exportArgs = input.arguments?.trim().slice("export".length).trim() || "";
@@ -11978,7 +12026,6 @@ function createCommandExecuteHandler(client, registry4, logger, config, workingD
11978
12026
  throw new Error("__DCP_CONTEXT_HANDLED__");
11979
12027
  }
11980
12028
  await handleContextCommand(commandCtx);
11981
- throw new Error("__DCP_CONTEXT_HANDLED__");
11982
12029
  }
11983
12030
  };
11984
12031
  }
@@ -12326,7 +12373,7 @@ var server = (async (ctx) => {
12326
12373
  }
12327
12374
  const logger = new Logger(config.debug, config.debug ? "debug" : config.logLevel);
12328
12375
  logger.info("ACP plugin initialized", {
12329
- version: true ? "1.16.0-pr.350.123" : "dev",
12376
+ version: true ? "1.16.0-pr.360.128" : "dev",
12330
12377
  workspace: ctx.directory,
12331
12378
  logLevel: logger.level,
12332
12379
  debug: config.debug,