opencode-acp 1.14.22-pr.325.39 → 1.14.22-pr.326.41

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
@@ -7327,6 +7327,10 @@ function buildCompressibleRanges(messages, state, protectedTools = [], protected
7327
7327
  };
7328
7328
  }
7329
7329
  var EFFECTIVE_MIN_COMPRESSIBLE_TOKENS = 1250;
7330
+ function resolveEffectiveFloor(config) {
7331
+ const minChars = config.compress?.minCompressRange ?? 5e3;
7332
+ return minChars > 0 ? Math.floor(minChars / 4) : 0;
7333
+ }
7330
7334
  function filterRecommendedRanges(compressible, _protectedRanges, options) {
7331
7335
  const { logger } = options;
7332
7336
  const log = logger?.debug.bind(logger);
@@ -7334,9 +7338,10 @@ function filterRecommendedRanges(compressible, _protectedRanges, options) {
7334
7338
  log?.("filterRecommendedRanges: no compressible ranges, returning empty");
7335
7339
  return [];
7336
7340
  }
7341
+ const floor = options.minEffectiveTokens ?? EFFECTIVE_MIN_COMPRESSIBLE_TOKENS;
7337
7342
  const kept = compressible.filter((r) => {
7338
7343
  const effective = r.effectiveTokens ?? r.tokens;
7339
- return effective >= EFFECTIVE_MIN_COMPRESSIBLE_TOKENS;
7344
+ return effective > 0 && effective >= floor;
7340
7345
  });
7341
7346
  const result = kept.map(
7342
7347
  (r, i) => i === kept.length - 1 ? { ...r, dangerous: true } : r
@@ -7344,7 +7349,11 @@ function filterRecommendedRanges(compressible, _protectedRanges, options) {
7344
7349
  log?.("filterRecommendedRanges: effective-token floor applied", {
7345
7350
  inputRanges: compressible.length,
7346
7351
  outputRanges: result.length,
7347
- dropped: compressible.filter((r) => (r.effectiveTokens ?? r.tokens) < EFFECTIVE_MIN_COMPRESSIBLE_TOKENS).map((r) => `${r.startRef}\u2013${r.endRef} (${r.effectiveTokens ?? r.tokens} eff tokens)`)
7352
+ floor,
7353
+ dropped: compressible.filter((r) => {
7354
+ const effective = r.effectiveTokens ?? r.tokens;
7355
+ return effective <= 0 || effective < floor;
7356
+ }).map((r) => `${r.startRef}\u2013${r.endRef} (${r.effectiveTokens ?? r.tokens} eff tokens)`)
7348
7357
  });
7349
7358
  return result;
7350
7359
  }
@@ -7661,15 +7670,18 @@ var injectCompressNudges = (state, config, logger, messages, prompts, compressio
7661
7670
  const recommendedRanges = filterRecommendedRanges(
7662
7671
  unprotectedCompressible,
7663
7672
  contextRanges.protected,
7664
- { logger }
7673
+ { logger, minEffectiveTokens: resolveEffectiveFloor(config) }
7665
7674
  );
7666
7675
  const hasRecommendations = recommendedRanges.length > 0;
7667
7676
  const allProtected = contextRanges.compressible.length === 0 && contextRanges.protected.length > 0;
7668
7677
  const allInProtectedZone = protectedRefs.size > 0 && unprotectedCompressible.length === 0;
7669
7678
  const allBelowMin = contextRanges.compressible.length > 0 && recommendedRanges.length === 0;
7670
7679
  const nothingToCompress = allProtected || allInProtectedZone || allBelowMin;
7671
- const shouldInjectNudge = nudgeAllowed && (!nothingToCompress || emergencyOverride);
7672
- let shouldInject = shouldInjectNudge;
7680
+ const emergencyNoTargets = emergencyOverride && nothingToCompress;
7681
+ const noticeCadenceMet = state.nudges.lastNudgeShownTokens === void 0 || growthSinceBaseline !== void 0 && growthSinceBaseline >= growthFloor;
7682
+ const shouldInjectNudge = nudgeAllowed && !nothingToCompress;
7683
+ const shouldInjectNotice = emergencyNoTargets && noticeCadenceMet;
7684
+ let shouldInject = shouldInjectNudge || shouldInjectNotice;
7673
7685
  if (shouldInjectNudge) {
7674
7686
  applyAnchoredNudges(state, config, messages, prompts, compressionPriorities, currentTokens, modelContextLimit, suffixMessage);
7675
7687
  }
@@ -7803,8 +7815,18 @@ ${formatCompressibleRanges(recommendedRanges, contextRanges.protected)}`;
7803
7815
  Use \`acp_status({scope:"uncompressed"})\` to re-fetch compressible ranges after compressing, or \`acp_status\` for compressed block details.`;
7804
7816
  appendToLastTextPart(suffixMessage, breakdown);
7805
7817
  }
7806
- if (effectiveTipsVariant === "maxLimit") {
7818
+ if (effectiveTipsVariant === "maxLimit" && !emergencyNoTargets) {
7807
7819
  tipsText = "\n\n\u26A0\uFE0F Context limit reached \u2014 compress now. Prioritize consumed tool outputs.\n\n" + HOW_TO_COMPRESS_RULES + '\n\n{ "topic": "...", "content": [{ "startId": "<ID>", "endId": "<ID>", "summary": "..." }] }\n\nOnly use IDs from visible messages above. Compress older work first.';
7820
+ } else if (shouldInjectNotice) {
7821
+ const emergencyPct = currentTokens !== void 0 && modelContextLimit !== void 0 && modelContextLimit > 0 ? Math.round(currentTokens / modelContextLimit * 100) : void 0;
7822
+ tipsText = `
7823
+
7824
+ \u{1F6A8} Context is critically full${emergencyPct !== void 0 ? ` (${emergencyPct}% of limit)` : ""} and there is nothing left that can be safely compressed.
7825
+ Do NOT retry compress on the same ranges \u2014 they will keep failing.
7826
+ Recommended actions:
7827
+ 1. Use OpenCode's built-in /compact to compact the whole session
7828
+ 2. Or start a new session (this session's compression summaries remain available)
7829
+ 3. Or ask the user to relax protected-tool / preserve-recent settings`;
7808
7830
  }
7809
7831
  state.nudges.lastNudgeShownTokens = currentTokens;
7810
7832
  {
@@ -9057,7 +9079,7 @@ import { writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
9057
9079
  import { join as join3 } from "path";
9058
9080
  import { existsSync as existsSync3 } from "fs";
9059
9081
  import { homedir as homedir3 } from "os";
9060
- var LOG_VERSION = true ? "1.14.22-pr.325.39" : "dev";
9082
+ var LOG_VERSION = true ? "1.14.22-pr.326.41" : "dev";
9061
9083
  var Logger = class {
9062
9084
  logDir;
9063
9085
  enabled;