opencode-acp 1.18.2-pr.453.202 → 1.18.2-pr.466.206

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
@@ -886,7 +886,6 @@ var VALID_CONFIG_KEYS = /* @__PURE__ */ new Set([
886
886
  "compress.showCompression",
887
887
  "compress.summaryBuffer",
888
888
  "compress.candidates",
889
- "compress.promptPack",
890
889
  "compress.maxContextLimit",
891
890
  "compress.minContextLimit",
892
891
  "compress.modelMaxLimits",
@@ -1104,13 +1103,6 @@ function validateConfigTypes(config) {
1104
1103
  actual: JSON.stringify(compress.nudgeForce)
1105
1104
  });
1106
1105
  }
1107
- if (compress.promptPack !== void 0 && compress.promptPack !== "default" && compress.promptPack !== "lean") {
1108
- errors.push({
1109
- key: "compress.promptPack",
1110
- expected: '"default" | "lean"',
1111
- actual: JSON.stringify(compress.promptPack)
1112
- });
1113
- }
1114
1106
  if (compress.protectedTools !== void 0 && !Array.isArray(compress.protectedTools)) {
1115
1107
  errors.push({
1116
1108
  key: "compress.protectedTools",
@@ -1778,7 +1770,6 @@ var defaultConfig = {
1778
1770
  showCompression: true,
1779
1771
  summaryBuffer: true,
1780
1772
  candidates: false,
1781
- promptPack: "default",
1782
1773
  maxContextLimit: "80%",
1783
1774
  minContextLimit: "80%",
1784
1775
  contextLimitFallback: 128e3,
@@ -1949,7 +1940,6 @@ function mergeCompress(base, override) {
1949
1940
  showCompression: override.showCompression ?? base.showCompression,
1950
1941
  summaryBuffer: override.summaryBuffer ?? base.summaryBuffer,
1951
1942
  candidates: override.candidates ?? base.candidates,
1952
- promptPack: override.promptPack ?? base.promptPack,
1953
1943
  maxContextLimit: override.maxContextLimit ?? base.maxContextLimit,
1954
1944
  minContextLimit: override.minContextLimit ?? base.minContextLimit,
1955
1945
  modelMaxLimits: override.modelMaxLimits ?? base.modelMaxLimits,
@@ -2526,10 +2516,14 @@ THE FORMAT OF COMPRESS
2526
2516
 
2527
2517
  \`\`\`
2528
2518
  {
2529
- topic?: string, // OPTIONAL top-level fallback topic for entries without their own.
2519
+ topic?: string, // OPTIONAL fallback topic for entries without their own.
2520
+ // Omit when every content entry specifies its own topic.
2530
2521
  content: [ // One or more ranges to compress
2531
2522
  {
2532
- topic?: string, // OPTIONAL per-range topic; overrides the top-level fallback.
2523
+ topic?: string, // OPTIONAL per-entry topic for this range.
2524
+ // Falls back to top-level topic.
2525
+ // Give each entry its own topic when compressing
2526
+ // unrelated ranges in one call.
2533
2527
  startId: string, // Boundary ID at range start: mNNNNN or bN
2534
2528
  endId: string, // Boundary ID at range end: mNNNNN or bN
2535
2529
  summary: string // Complete technical summary replacing all content in range
@@ -3936,6 +3930,12 @@ function buildBoundaryLookup(context, state) {
3936
3930
  }
3937
3931
  return lookup;
3938
3932
  }
3933
+ var SEARCH_CONTEXT_TOOL_DESCRIPTION = `Search through active compressed block summaries to find relevant content. Use this BEFORE decompressing to find the right block. Returns a hit list with block IDs, relevance scores, and previews.
3934
+
3935
+ Examples:
3936
+ - search_context({ query: "decoder accuracy" }) \u2014 find compressed blocks about decoder accuracy
3937
+ - search_context({ query: "training loss PPL" }) \u2014 find training results
3938
+ - search_context({ query: "architecture design", limit: 5 }) \u2014 top 5 results`;
3939
3939
  function countOccurrences(text, term) {
3940
3940
  if (!text || !term) return 0;
3941
3941
  let count = 0;
@@ -3958,9 +3958,8 @@ function buildSearchPreview(text, firstTerm) {
3958
3958
  }
3959
3959
  function createSearchContextTool(factoryCtx) {
3960
3960
  factoryCtx.prompts.reload();
3961
- const runtimePrompts = factoryCtx.prompts.getRuntimePrompts();
3962
3961
  return tool({
3963
- description: runtimePrompts.searchContextDescription,
3962
+ description: SEARCH_CONTEXT_TOOL_DESCRIPTION,
3964
3963
  args: {
3965
3964
  query: tool.schema.string().describe("Search query \u2014 keywords or phrase to find"),
3966
3965
  limit: tool.schema.number().optional().describe("Maximum results to return (default: 10)"),
@@ -8440,6 +8439,29 @@ var resolveEffectiveCompressPermission = (basePermission, hostPermissions, agent
8440
8439
  var hasExplicitToolPermission = (permissionConfig, tool6) => {
8441
8440
  return permissionConfig ? Object.prototype.hasOwnProperty.call(permissionConfig, tool6) : false;
8442
8441
  };
8442
+ var anyRuleResolves = (permissionConfig, tool6) => {
8443
+ if (hasExplicitToolPermission(permissionConfig, tool6)) {
8444
+ return true;
8445
+ }
8446
+ const match = findLastMatchingRule(
8447
+ getPermissionRules([permissionConfig]),
8448
+ (rule) => wildcardMatch(tool6, rule.permission)
8449
+ );
8450
+ return match !== void 0;
8451
+ };
8452
+ var applyAcpToolPermissions = (permissionConfig, compressPermission2) => {
8453
+ if (permissionConfig && hasExplicitToolPermission(permissionConfig, "compress")) {
8454
+ return permissionConfig;
8455
+ }
8456
+ const next = {
8457
+ ...permissionConfig ?? {},
8458
+ compress: compressPermission2
8459
+ };
8460
+ if (!anyRuleResolves(permissionConfig, "acp_status")) {
8461
+ next.acp_status = "allow";
8462
+ }
8463
+ return next;
8464
+ };
8443
8465
 
8444
8466
  // lib/compress-permission.ts
8445
8467
  var compressPermission = (state, config) => {
@@ -8461,10 +8483,20 @@ var CONTEXT_LIMIT_NUDGE = `
8461
8483
 
8462
8484
  If mid-atomic-operation, finish that step first, then compress.
8463
8485
 
8464
- Format: { "topic": "...", "content": [{ "startId": "<visible ID>", "endId": "<visible ID>", "summary": "..." }] } \u2014 batch unrelated ranges in one call.
8486
+ HOW TO CALL COMPRESS:
8487
+ {
8488
+ "topic": "Short Label",
8489
+ "content": [
8490
+ {
8491
+ "startId": "<ID from early in this conversation>",
8492
+ "endId": "<ID from later in this conversation>",
8493
+ "summary": "Complete technical summary of everything in the range"
8494
+ }
8495
+ ]
8496
+ }
8465
8497
 
8466
8498
  \u26A0\uFE0F ID RULES \u2014 MOST COMMON CAUSE OF ERRORS:
8467
- - ONLY use IDs you can see in <dcp-message-id> tags in the messages ABOVE.
8499
+ - ONLY use IDs you can see in tags in the messages ABOVE.
8468
8500
  - Do NOT copy IDs from this example. Do NOT invent IDs.
8469
8501
  - Do NOT use IDs from compressed block summaries \u2014 they are stale.
8470
8502
  - startId must appear BEFORE endId in the conversation.
@@ -8489,14 +8521,14 @@ COMPRESSION CANDIDATES:
8489
8521
  // lib/prompts/turn-nudge.ts
8490
8522
  var TURN_NUDGE = `
8491
8523
  <system-reminder>
8492
- Context is getting full. If you've finished reading tool outputs or exploration results, compress them \u2014 you can decompress later if needed.
8524
+ Context is getting full. If you've finished reading tool outputs or exploration results, compress them \u2014 you can decompress later if needed. This keeps your focus on the current task and improves accuracy.
8493
8525
 
8494
8526
  {
8495
8527
  "topic": "Short Label",
8496
8528
  "content": [{ "startId": "<visible message ID>", "endId": "<visible message ID>", "summary": "..." }]
8497
8529
  }
8498
8530
 
8499
- \u26A0\uFE0F ONLY use IDs from <dcp-message-id> tags visible above. Do NOT invent or copy example IDs.
8531
+ \u26A0\uFE0F ONLY use IDs from tags visible above. Do NOT invent or copy example IDs.
8500
8532
  </system-reminder>
8501
8533
  `;
8502
8534
  var TURN_CANDIDATE_GUIDANCE = `
@@ -8513,7 +8545,7 @@ You've been iterating for a while. If any earlier work is closed and unlikely to
8513
8545
  "content": [{ "startId": "<visible message ID>", "endId": "<visible message ID>", "summary": "..." }]
8514
8546
  }
8515
8547
 
8516
- \u26A0\uFE0F ONLY use IDs from <dcp-message-id> tags visible above. Do NOT invent or copy example IDs.
8548
+ \u26A0\uFE0F ONLY use IDs from tags visible above. Do NOT invent or copy example IDs.
8517
8549
  </system-reminder>
8518
8550
  `;
8519
8551
  var ITERATION_CANDIDATE_GUIDANCE = `
@@ -10035,13 +10067,7 @@ function resolveTargets(args, state, rawMessages, logger) {
10035
10067
  if (mode.mode === "block") {
10036
10068
  return resolveSingleBlockTarget(messagesState, args.blockId);
10037
10069
  }
10038
- return resolveRangeTarget(
10039
- state,
10040
- rawMessages,
10041
- args.startId,
10042
- args.endId,
10043
- logger
10044
- );
10070
+ return resolveRangeTarget(state, rawMessages, args.startId, args.endId, logger);
10045
10071
  }
10046
10072
  function resolveSingleBlockTarget(messagesState, blockIdArg) {
10047
10073
  const targetBlockId = parseBlockIdArg(blockIdArg);
@@ -10117,23 +10143,47 @@ function resolveRangeTarget(state, rawMessages, startId, endId, logger) {
10117
10143
  });
10118
10144
  return { ok: true, targets };
10119
10145
  }
10146
+ var TOOL_DESCRIPTION = `Restores previously compressed content.
10147
+
10148
+ Use this tool when you need exact details from compressed content that the summary cannot provide.
10149
+ The tool returns a condensed preview of the restored content so you can reason about it immediately.
10150
+
10151
+ TWO MODES:
10152
+
10153
+ 1. Block mode (default): decompress a single block by ID.
10154
+ - blockId: block reference to decompress (e.g., "b0", "b2")
10155
+
10156
+ 2. Range mode: decompress ALL blocks overlapping a message range. Use this to restore
10157
+ content across multiple blocks without calling acp_status + decompress repeatedly.
10158
+ - startId: starting message or block ref (e.g., "m00150")
10159
+ - endId: ending message or block ref (e.g., "m00200")
10160
+
10161
+ Range mode finds every active block whose effectiveMessageIds touch the range and
10162
+ batch-restores them. Partial overlap decompresses the whole block (content cannot be
10163
+ partially restored). Nested blocks are handled automatically.
10164
+
10165
+ ARGUMENTS:
10166
+ - blockId?: string \u2014 use this OR startId+endId (mutually exclusive)
10167
+ - startId?: string \u2014 range start (message or block ref)
10168
+ - endId?: string \u2014 range end (message or block ref)
10169
+ - toFile?: string \u2014 if provided, writes restored content to this file path (must be under
10170
+ /tmp or ~/.cache/opencode/) instead of inflating context. Block(s) stay compressed.
10171
+
10172
+ IMPORTANT:
10173
+ - Decompressing inflates context. Check context usage before decompressing.
10174
+ - Message-mode blocks from the same batch (same runId) are restored together.
10175
+ - TIER-AWARE: by default, decompressing a multi-tier block restores the PREVIOUS tier's
10176
+ summaries (e.g., decompress T2 \u2192 T1 summaries visible, not raw messages). Use full:true
10177
+ to restore all the way to original messages (can be very expensive for T2/T3 blocks).
10178
+ - After decompression, the restored content will appear in full in your next context window.
10179
+ - Do NOT call this tool in parallel with compress \u2014 their state mutations may conflict.`;
10120
10180
  function buildSchema2() {
10121
10181
  return {
10122
- blockId: tool3.schema.string().optional().describe(
10123
- 'Block reference to decompress (e.g., "b0", "b2"). Mutually exclusive with startId/endId.'
10124
- ),
10125
- startId: tool3.schema.string().optional().describe(
10126
- 'Range start: message ref (e.g., "m00150") or block ref (e.g., "b2"). Used with endId.'
10127
- ),
10128
- endId: tool3.schema.string().optional().describe(
10129
- 'Range end: message ref (e.g., "m00200") or block ref (e.g., "b5"). Used with startId.'
10130
- ),
10131
- toFile: tool3.schema.string().optional().describe(
10132
- "If provided, writes restored content to this file path instead of inflating context. Block stays compressed. Path must be under /tmp or ~/.cache/opencode/. Example: '/tmp/block52.txt'"
10133
- ),
10134
- full: tool3.schema.boolean().optional().describe(
10135
- "If true, restores ALL content down to original messages (multi-level decompress). Default: false \u2014 restores one tier up (e.g., decompressing a T2 block restores T1 summaries, not raw messages). Use full:true only when you need the exact original content and have context budget for it."
10136
- )
10182
+ blockId: tool3.schema.string().optional().describe('Block reference to decompress (e.g., "b0", "b2"). Mutually exclusive with startId/endId.'),
10183
+ startId: tool3.schema.string().optional().describe('Range start: message ref (e.g., "m00150") or block ref (e.g., "b2"). Used with endId.'),
10184
+ endId: tool3.schema.string().optional().describe('Range end: message ref (e.g., "m00200") or block ref (e.g., "b5"). Used with startId.'),
10185
+ toFile: tool3.schema.string().optional().describe("If provided, writes restored content to this file path instead of inflating context. Block stays compressed. Path must be under /tmp or ~/.cache/opencode/. Example: '/tmp/block52.txt'"),
10186
+ full: tool3.schema.boolean().optional().describe("If true, restores ALL content down to original messages (multi-level decompress). Default: false \u2014 restores one tier up (e.g., decompressing a T2 block restores T1 summaries, not raw messages). Use full:true only when you need the exact original content and have context budget for it.")
10137
10187
  };
10138
10188
  }
10139
10189
  function extractMessageId(m) {
@@ -10164,10 +10214,8 @@ function extractMessageText2(m) {
10164
10214
  ${segments.join("\n\n")}`;
10165
10215
  }
10166
10216
  function createDecompressTool(factoryCtx) {
10167
- factoryCtx.prompts.reload();
10168
- const runtimePrompts = factoryCtx.prompts.getRuntimePrompts();
10169
10217
  return tool3({
10170
- description: runtimePrompts.decompressDescription,
10218
+ description: TOOL_DESCRIPTION,
10171
10219
  args: buildSchema2(),
10172
10220
  async execute(args, toolCtx) {
10173
10221
  const ctx = resolveToolContext(factoryCtx, toolCtx.sessionID);
@@ -10176,12 +10224,7 @@ function createDecompressTool(factoryCtx) {
10176
10224
  const contextUsageBefore = effectiveLimitBefore ? Math.round(
10177
10225
  getCurrentTokenUsage(ctx.state, rawMessages) / effectiveLimitBefore.limit * 100
10178
10226
  ) : void 0;
10179
- const resolved = resolveTargets(
10180
- args,
10181
- ctx.state,
10182
- rawMessages,
10183
- ctx.logger
10184
- );
10227
+ const resolved = resolveTargets(args, ctx.state, rawMessages, ctx.logger);
10185
10228
  if (!resolved.ok) {
10186
10229
  return resolved.error;
10187
10230
  }
@@ -10424,6 +10467,17 @@ function hideConsumedCompressCalls(state, messages) {
10424
10467
  }
10425
10468
 
10426
10469
  // lib/compress/status.ts
10470
+ var ACP_STATUS_TOOL_DESCRIPTION = `Show context status \u2014 overview includes compressible ranges (compression candidates when compress.candidates is enabled).
10471
+
10472
+ No args: Overview with totals, compressed blocks, and compressible ranges (or candidates when enabled).
10473
+ scope:"uncompressed": Compressible ranges by default (view:"candidates" when compress.candidates is enabled). Use view:"ranges" for raw grouped ranges or view:"messages" for per-message listing.
10474
+ scope:"compressed": Drill into compressed blocks \u2014 list each with full details (age, generation, consumed lineage).
10475
+
10476
+ Use this tool to:
10477
+ - See what's consuming context + compressible targets in one call (no args)
10478
+ - Focus on ranges only (scope:"uncompressed")
10479
+ - Find all messages of a specific tool type (scope:"uncompressed", view:"messages", tool:"bash")
10480
+ - Check block details before decompressing (scope:"compressed")`;
10427
10481
  function formatTokens(n) {
10428
10482
  if (!Number.isFinite(n) || n <= 0) return "0";
10429
10483
  return n >= 1e3 ? `${(n / 1e3).toFixed(1)}K` : String(n);
@@ -10834,9 +10888,8 @@ function buildStatusReport(renderCtx, rawMessages, options) {
10834
10888
  }
10835
10889
  function createAcpStatusTool(factoryCtx) {
10836
10890
  factoryCtx.prompts.reload();
10837
- const runtimePrompts = factoryCtx.prompts.getRuntimePrompts();
10838
10891
  return tool4({
10839
- description: runtimePrompts.acpStatusDescription,
10892
+ description: ACP_STATUS_TOOL_DESCRIPTION,
10840
10893
  args: {
10841
10894
  scope: tool4.schema.string().optional().describe('Drill down: "compressed" or "uncompressed". No arg = overview of both.'),
10842
10895
  view: tool4.schema.string().optional().describe(
@@ -10959,15 +11012,17 @@ function formatCoverage(block) {
10959
11012
  const count = block.effectiveMessageIds?.length || 0;
10960
11013
  return count > 0 ? `${count} message${count !== 1 ? "s" : ""}` : "\u2014";
10961
11014
  }
11015
+ var RECAP_TOOL_DESCRIPTION = `Read-only retrieval of compression block summaries.
11016
+
11017
+ Call this tool to re-fetch a specific block's summary without decompressing the full original content. Useful when a past compress tool call's summary has scrolled out of context or was truncated by the provider.
11018
+
11019
+ Args:
11020
+ - blockId: optional block number (e.g., 5). If omitted, lists all active blocks with brief info.`;
10962
11021
  function createAcpContextRecapTool(factoryCtx) {
10963
- factoryCtx.prompts.reload();
10964
- const runtimePrompts = factoryCtx.prompts.getRuntimePrompts();
10965
11022
  return tool5({
10966
- description: runtimePrompts.acpContextRecapDescription,
11023
+ description: RECAP_TOOL_DESCRIPTION,
10967
11024
  args: {
10968
- blockId: tool5.schema.number().optional().describe(
10969
- "Block number to retrieve (e.g., 5). If omitted, lists all active blocks."
10970
- )
11025
+ blockId: tool5.schema.number().optional().describe("Block number to retrieve (e.g., 5). If omitted, lists all active blocks.")
10971
11026
  },
10972
11027
  async execute(args, toolCtx) {
10973
11028
  const ctx = resolveToolContext(factoryCtx, toolCtx.sessionID);
@@ -11001,10 +11056,8 @@ ${block.summary}
11001
11056
  b${id} | ${range} | "${block.topic || "(none)"}"`);
11002
11057
  lines.push(` ${summaryPreview}${block.summary.length > 200 ? "..." : ""}`);
11003
11058
  }
11004
- lines.push(
11005
- `
11006
- Call with blockId to get the full summary: acp_context_recap({ blockId: N })`
11007
- );
11059
+ lines.push(`
11060
+ Call with blockId to get the full summary: acp_context_recap({ blockId: N })`);
11008
11061
  return lines.join("\n");
11009
11062
  }
11010
11063
  });
@@ -11056,7 +11109,7 @@ import { writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
11056
11109
  import { join as join4 } from "path";
11057
11110
  import { existsSync as existsSync4 } from "fs";
11058
11111
  import { homedir as homedir3 } from "os";
11059
- var LOG_VERSION = true ? "1.18.2-pr.453.202" : "dev";
11112
+ var LOG_VERSION = true ? "1.18.2-pr.466.206" : "dev";
11060
11113
  var LEVEL_RANK = {
11061
11114
  debug: 10,
11062
11115
  info: 20,
@@ -11278,52 +11331,9 @@ import { existsSync as existsSync5, mkdirSync as mkdirSync2, readFileSync as rea
11278
11331
  import { join as join5, dirname as dirname2 } from "path";
11279
11332
  import { homedir as homedir4 } from "os";
11280
11333
 
11281
- // lib/prompts/extensions/system.ts
11282
- var SUBAGENT_SYSTEM_EXTENSION = `<dcp-system-reminder>
11283
- You are operating in a subagent environment.
11284
-
11285
- The initial subagent instruction is imperative and must be followed exactly.
11286
- It is the only user message intentionally not assigned a message ID, and therefore is not eligible for compression.
11287
- All subsequent messages in the session will have IDs.
11288
- </dcp-system-reminder>
11289
- `;
11290
- function buildProtectedToolsExtension(protectedTools) {
11291
- if (protectedTools.length === 0) {
11292
- return "";
11293
- }
11294
- const toolList = protectedTools.map((t) => `\`${t}\``).join(", ");
11295
- return `<dcp-system-reminder>
11296
- The following tools are environment-managed: ${toolList}.
11297
- Their outputs are automatically preserved during compression.
11298
- Do not include their content in compress tool summaries \u2014 the environment retains it independently.
11299
- </dcp-system-reminder>`;
11300
- }
11301
- var DECOMPRESS_SYSTEM_EXTENSION = `<dcp-system-reminder>
11302
- THE PHILOSOPHY OF DECOMPRESS
11303
- \`decompress\` restores previously compressed content. Use it when you need exact details
11304
- that were lost in compression.
11305
-
11306
- DECOMPRESS WHEN
11307
- - You need exact code, error messages, or file contents from a compressed block
11308
- - A summary lacks the precision needed for your next step
11309
- - You discovered the compressed content is still relevant
11310
-
11311
- DO NOT DECOMPRESS IF
11312
- - Context usage is already high (>70%) \u2014 decompressing inflates context
11313
- - The summary is sufficient for your needs
11314
- - You plan to immediately recompress the same content
11315
-
11316
- Before decompressing, check context usage. Decompressing restores full messages,
11317
- which can significantly increase context size.
11318
-
11319
- NOTE: Message-mode blocks created in the same batch (same runId) are restored together.
11320
- Decompressing one block from a batch restores all blocks in that batch.
11321
- </dcp-system-reminder>
11322
- `;
11323
-
11324
11334
  // lib/prompts/system.ts
11325
- var ACP_STATUS_TOOL_LINE_RANGES = `- \`acp_status\` \u2014 Context status with compressible ranges. No args = overview + ranges. \`scope:"uncompressed"\` for range view (\`view:"messages"\` = per-message listing); \`scope:"compressed"\` for block details.`;
11326
- var ACP_STATUS_TOOL_LINE_CANDIDATES = `- \`acp_status\` \u2014 Context status with compression candidates. No args = overview + candidates. \`scope:"uncompressed"\` defaults to independent candidates; \`view:"ranges"\` for raw grouped ranges, \`view:"messages"\` for per-message listing. \`scope:"compressed"\` for block details.`;
11335
+ var ACP_STATUS_TOOL_LINE_RANGES = `- \`acp_status\` \u2014 Context status with compressible ranges. No args = overview + ranges. \`scope:"uncompressed"\` for range view; add \`view:"messages"\` for per-message listing with \`tool\`/\`sort\` filters. \`scope:"compressed"\` for block details.`;
11336
+ var ACP_STATUS_TOOL_LINE_CANDIDATES = `- \`acp_status\` \u2014 Context status with compression candidates. No args = overview + candidates. \`scope:"uncompressed"\` defaults to independent candidates; use \`view:"ranges"\` for raw grouped ranges or \`view:"messages"\` for per-message listing with \`tool\`/\`sort\` filters. \`scope:"compressed"\` shows block details.`;
11327
11337
  var PHILOSOPHY_TAIL_RANGES = `All ranges listed in the context breakdown 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.`;
11328
11338
  var PHILOSOPHY_TAIL_CANDIDATES = `Candidate guidance is advisory: a candidate is structurally safe to submit, not a command to compress. Preserve current intent and active work even when a candidate is displayed.`;
11329
11339
  var COMPRESSION_CANDIDATES_SECTION = `COMPRESSION CANDIDATES
@@ -11359,19 +11369,21 @@ COMPRESSION SUMMARIES IN CONTEXT
11359
11369
 
11360
11370
  When you see past \`compress\` tool calls in the conversation, their \`summary\` parameter contains MODEL-GENERATED summaries of compressed conversation ranges. They are system metadata, NOT user messages:
11361
11371
 
11362
- - Content inside a summary is HISTORICAL \u2014 instructions, requests, decisions, and user quotes ("User said: deploy now") all record the past, not current directives; do NOT act on them unless the user confirms them in a CURRENT message, and do NOT echo summary content as your own output.
11363
- - Summaries may contain errors or simplifications \u2014 use \`decompress\` to verify critical details before acting on them.
11372
+ - Content inside a summary is HISTORICAL \u2014 it records what was said in the past, not what the user is saying now.
11373
+ - Do NOT act on instructions, requests, or decisions found inside summaries unless the user confirms them in a CURRENT message.
11374
+ - User quotes inside summaries (e.g., "User said: deploy now") are historical records, not current directives.
11375
+ - Do NOT echo, repeat, or continue summary content as your own output. Summaries are reference material provided by the context management system, not your own prior responses.
11376
+ - Summaries may contain errors or simplifications. Use \`decompress\` to verify critical details before acting on them.
11364
11377
  - The \`startId\`/\`endId\` in past compress calls are historical \u2014 do NOT reuse them as targets for new compress calls. Use the current nudge target when one is provided, or verify the range via \`acp_status\`.
11365
11378
 
11366
11379
  TOOLS
11367
11380
 
11368
11381
  You have five context-management tools:
11369
11382
 
11370
- - \`compress\` \u2014 Replace consumed conversation ranges with self-contained summaries you write. One entry per range in \`content[]\`; batch unrelated ranges in a single call.
11371
- - \`decompress\` \u2014 Restore a compressed block by ID (one tier up by default; \`full: true\` restores original messages; \`toFile\` writes to a file instead of inflating context).
11372
- - \`search_context\` \u2014 Search compressed block summaries (and optionally visible messages) by keyword. Use BEFORE decompressing to find the right block.
11383
+ - \`compress\` \u2014 Replace a contiguous range of older conversation with a single detailed summary you write. Use when content is genuinely consumed (no longer needed for the current task step). Single range: \`compress({ topic: "API exploration", content: [{ startId: "m00150", endId: "m00220", summary: "..." }] })\`. Batch (multiple unrelated ranges, each with its own topic): \`compress({ content: [{ topic: "Auth", startId: "m00150", endId: "m00220", summary: "..." }, { topic: "Deploy", startId: "m00300", endId: "m00350", summary: "..." }] })\`.
11384
+ - \`decompress\` \u2014 Restore a previously compressed block's content. By default restores one tier up (T2\u2192T1 summaries, not raw messages). Use \`full: true\` to restore all the way to original messages. Use \`toFile\` to write to file instead of inflating context. Example: \`decompress({ blockId: "b5" })\` or \`decompress({ blockId: "b5", toFile: "path" })\` or \`decompress({ blockId: "b5", full: true })\`.
11385
+ - \`search_context\` \u2014 Search compressed block summaries (and optionally visible messages) by keyword. Use BEFORE decompressing to find the right block. Example: \`search_context({ query: "auth token refresh" })\`.
11373
11386
  ${acpStatusToolLine}
11374
- - \`acp_context_recap\` \u2014 Re-fetch a block's summary without decompressing; no args lists all active blocks.
11375
11387
 
11376
11388
  COMPRESSION PHILOSOPHY
11377
11389
 
@@ -11379,15 +11391,20 @@ Two failure modes to avoid:
11379
11391
  - Over-compression: Compressing too aggressively loses critical details, decisions, and state needed for your task. This directly harms task quality.
11380
11392
  - Under-compression: Failing to compress verbose outputs causes context overflow, reducing accuracy and eventually blocking your work.
11381
11393
 
11382
- Balance is key. The single test for whether to compress is: "Is this content still needed by the current task step?" If yes, keep it. If no, compress it. Compress obvious waste proactively \u2014 verbose outputs you have already used, duplicate reads, abandoned explorations \u2014 but do not wait until context is critically full. ${philosophyTail}
11394
+ Balance is key. The single test for whether to compress is: "Is this content still needed by the current task step?" If yes, keep it. If no, compress it. ${philosophyTail}
11395
+
11396
+ Be frugal with context. Compress obvious waste proactively \u2014 verbose outputs you have already used, duplicate reads, abandoned explorations. Do not wait until context is critically full; that harms retrieval quality and risks overflow. But never let the urge to compress distract from the actual task.
11383
11397
 
11384
11398
  WHEN TO COMPRESS
11385
11399
 
11386
- - A sub-agent or delegated task returned a large result whose key facts you have already extracted.
11387
- - Verbose command output (build/test logs, \`git diff\`, \`npm install\`, directory listings) you have already used.
11388
- - Exploration that led nowhere; repeated reads or status checks once the decision is recorded.
11389
- - Resolved discussion threads where a decision has been captured in summary or code.
11390
- - Intermediate steps of a completed multi-step task, once the final result is recorded; a task phase has ended (bug hunt done, root cause found, research wrapped).
11400
+ - A sub-agent or delegated task has returned a large result that you have already extracted the key facts from.
11401
+ - Verbose command output (build/test logs, \`git diff\`, \`npm install\`, directory listings) where you have already used the information you need.
11402
+ - Exploration that led nowhere.
11403
+ - Repeated reads of the same file or repeated status checks once the decision is recorded.
11404
+ - Resolved discussion threads where a decision has been captured in summary or in code.
11405
+ - Intermediate steps of a completed multi-step task, once the final result is recorded.
11406
+ - A task phase has ended \u2014 bug hunt complete, root cause found, exploration done, research sprint wrapped.
11407
+ - Any other content where compression serves the primary task.
11391
11408
 
11392
11409
  WHEN NOT TO COMPRESS
11393
11410
 
@@ -11399,11 +11416,13 @@ ${HOW_TO_COMPRESS_RULES}${compressionCandidatesBlock}MULTI-TIER COMPRESSION
11399
11416
 
11400
11417
  Summaries accumulate as the session grows. When tier-1 summaries pile up, the system injects a [Tier 2 Trigger] prompting you to DISTILL old blocks into a single tier-2 summary. If tier-2 summaries also accumulate, a [Tier 3 Trigger] asks you to CONDENSE them further.
11401
11418
 
11402
- - Tier 1 (default): Full-detail compression of conversation ranges (HOW TO COMPRESS rules above).
11403
- - Tier 2: Distillation of old tier-1 summaries (TIER 2 DISTILLATION rules \u2014 decisions/outcomes only, drop paths/code/process).
11404
- - Tier 3: Ultra-condensation of tier-2 summaries (TIER 3 CONDENSATION rules \u2014 bare facts, 1-3 lines per block).
11419
+ - Tier 1 (default): Full-detail compression of conversation ranges. Uses HOW TO COMPRESS rules above.
11420
+ - Tier 2: Distillation of old tier-1 block summaries. Uses TIER 2 DISTILLATION rules (decisions/outcomes only, drop paths/code/process).
11421
+ - Tier 3: Ultra-condensation of tier-2 summaries. Uses TIER 3 CONDENSATION rules (bare facts, 1-3 lines per block).
11405
11422
 
11406
- To compress blocks, use block IDs as boundaries (startId/endId as bN refs); multiple entries create separate higher-tier blocks and deactivate the consumed ones. The trigger's system prompt tells you which rules apply. If unsure which \`mNNNNN\` refs or blocks are still active, call \`acp_status\` first.
11423
+ To compress blocks: use block IDs as boundaries: \`compress({ content: [{ startId: "b3", endId: "b15", summary: "..." }] })\`. Multiple entries create separate blocks: \`compress({ content: [{ startId: "b3", endId: "b10", summary: "..." }, { startId: "b11", endId: "b20", summary: "..." }] })\`. This deactivates the consumed blocks and creates a new higher-tier block per entry. The system prompt at the trigger tells you which rules to follow.
11424
+
11425
+ If you are unsure which \`mNNNNN\` refs are still compressible, or which blocks have already consumed which ranges, call \`acp_status\` first. It returns the visible context breakdown and the compressed block list.
11407
11426
 
11408
11427
  CONTEXT BREAKDOWN
11409
11428
 
@@ -11411,7 +11430,12 @@ When context usage passes a threshold, the system appends a breakdown showing wh
11411
11430
 
11412
11431
  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%)
11413
11432
 
11414
- Categories: system = prompt & tool definitions (not compressible) \xB7 tool = tool outputs (largest category \u2014 compress first when consumed) \xB7 summaries = existing block summaries (do not re-compress standalone) \xB7 code/text = message content \xB7 reasoning = thinking blocks (freed when their message is compressed).
11433
+ - "system" = system prompt tokens (AGENTS.md, tool definitions \u2014 not compressible)
11434
+ - "tool" = tool call outputs (largest category \u2014 compress first when consumed)
11435
+ - "summaries" = existing compression block summaries (already compressed; do not re-compress standalone)
11436
+ - "code" = messages containing code blocks
11437
+ - "text" = plain text messages
11438
+ - "reasoning" = model thinking blocks (counted to match real API usage; freed when their message is compressed)
11415
11439
 
11416
11440
  ${breakdownTail}
11417
11441
 
@@ -11438,6 +11462,7 @@ Compressed block sections in context are clearly marked with a header:
11438
11462
 
11439
11463
  Rules:
11440
11464
 
11465
+ - Write your summary normally. The system handles block consumption automatically.
11441
11466
  - Do not invent placeholders for blocks outside the selected range.
11442
11467
  - Treat \`(bN)\` as a RESERVED TOKEN. Do not emit \`(bN)\` text anywhere in the summary.
11443
11468
  - If you need to mention a block in prose, use plain text like \`compressed bN\` (never as a placeholder).
@@ -11454,127 +11479,87 @@ Treat these tags as boundary metadata only, not as tool result content.
11454
11479
 
11455
11480
  Rules:
11456
11481
 
11482
+ - Pick \`startId\` and \`endId\` directly from injected IDs in context.
11457
11483
  - IDs must exist in the current visible context. If you cannot see an ID in the messages above, it is stale and will fail.
11458
11484
  - Prefer \`startId\` before \`endId\` in conversation order. ACP can normalize reversed boundaries, but do not rely on that behavior.
11485
+ - Do not invent IDs. Use only IDs that are present in context.
11459
11486
  - NEVER use IDs from compressed block summaries, previous nudges, or your own memory \u2014 only IDs currently visible as XML metadata tags in the conversation.
11460
11487
 
11461
11488
  BATCHING
11462
- When multiple independent ranges are ready and their boundaries do not overlap, include all of them as separate entries in the \`content\` array of a single tool call, each with its own \`startId\`, \`endId\`, and \`summary\`. Give each entry its own \`topic\` when the ranges cover unrelated topics; otherwise omit per-entry topics and set the top-level \`topic\` once.
11489
+ When multiple independent ranges are ready and their boundaries do not overlap, include all of them as separate entries in the \`content\` array of a single tool call. Each entry should have its own \`startId\`, \`endId\`, and \`summary\`.
11490
+
11491
+ When the ranges cover unrelated topics, give each entry its own \`topic\` for better summary quality \u2014 do not force unrelated content under a single shared topic. Omit the top-level \`topic\` when every entry has its own. Use the top-level \`topic\` only as a fallback when entries don't specify one.
11492
+
11493
+ \`\`\`
11494
+ compress({ content: [
11495
+ { topic: "Auth System Exploration", startId: "m00010", endId: "m00050", summary: "..." },
11496
+ { topic: "Bug Hunt", startId: "m00060", endId: "m00080", summary: "..." },
11497
+ { topic: "Deployment", startId: "m00090", endId: "m00110", summary: "..." },
11498
+ ]})
11499
+ \`\`\`
11463
11500
 
11464
11501
  ${candidateGuidanceBlock}KEEP AND REF MARKERS
11465
11502
  When writing a summary, you may embed markers that reference specific messages in the compressed range. The system resolves them automatically:
11466
11503
 
11467
- - \`[[KEEP:mNNNNN]]\` \u2014 Expands to the original message content inline (truncated to a max length). Use sparingly for critical content you want preserved verbatim without re-typing it: key definitions, important errors, essential file contents.
11468
- - \`[[REF:mNNNNN|short description]]\` \u2014 Creates a compact link like \`[\u2192 m00065: key function definition]\`. Does not expand \u2014 use for content the reader can decompress later if needed.
11504
+ - \`[[KEEP:mNNNNN]]\` \u2014 Expands to the original message content inline (truncated to a max length). Use for critical content you want preserved verbatim in the summary without re-typing it: key function definitions, important error messages, essential file contents.
11505
+ - \`[[REF:mNNNNN|short description]]\` \u2014 Creates a compact link like \`[\u2192 m00065: key function definition]\`. Use for content the reader can decompress later if needed. Does not expand \u2014 saves space.
11469
11506
 
11470
- Prefer REF over KEEP: each KEEP expansion adds to the summary length.
11471
- `;
11472
- }
11473
- var COMPRESS_RANGE = buildCompressRangePrompt(true);
11474
-
11475
- // lib/prompts/packs.ts
11476
- var DEFAULT_DECOMPRESS_DESCRIPTION = `Restores previously compressed content \u2014 use when you need exact details that a compressed summary cannot provide. Returns a condensed preview so you can reason about it immediately.
11507
+ Example:
11508
+ \`\`\`
11509
+ Implemented the QuotaMonitor feature. Key design: observer pattern.
11477
11510
 
11478
- Modes (mutually exclusive):
11479
- - Block mode: blockId (e.g., "b5") restores one block. By default restores one tier up (T2\u2192T1 summaries, not raw messages); use full:true to restore all the way to original messages (expensive for T2/T3). Message-mode blocks from the same batch (same runId) restore together; nested blocks are handled automatically.
11480
- - Range mode: startId+endId (message or block refs) restore ALL active blocks overlapping the range; partial overlap restores the whole block.
11511
+ [[KEEP:m00065]]
11481
11512
 
11482
- toFile?: writes restored content to this path (must be under /tmp or ~/.cache/opencode/) instead of inflating context; block(s) stay compressed. Restored content appears in full in your next context window.
11513
+ The rest of the bash calls were repetitive export commands. See [[REF:m00078|test results]] for details.
11514
+ \`\`\`
11483
11515
 
11484
- Do NOT call this tool in parallel with compress \u2014 their state mutations may conflict. Check context usage before decompressing.`;
11485
- var DEFAULT_SEARCH_CONTEXT_DESCRIPTION = `Search through active compressed block summaries to find relevant content. Use this BEFORE decompressing to find the right block. Returns a hit list with block IDs, relevance scores, and previews.
11516
+ Use KEEP sparingly \u2014 each expansion adds to the summary length. Prefer REF for content that is important but not immediately critical.
11517
+ `;
11518
+ }
11519
+ var COMPRESS_RANGE = buildCompressRangePrompt(true);
11486
11520
 
11487
- Example: search_context({ query: "decoder accuracy", limit: 5 })`;
11488
- var DEFAULT_ACP_STATUS_DESCRIPTION = `Show context status \u2014 overview includes compressible ranges (compression candidates when compress.candidates is enabled).
11521
+ // lib/prompts/extensions/system.ts
11522
+ var SUBAGENT_SYSTEM_EXTENSION = `<dcp-system-reminder>
11523
+ You are operating in a subagent environment.
11489
11524
 
11490
- No args: totals, compressed blocks, and ranges/candidates in one call. scope:"uncompressed": ranges only (view:"candidates" when compress.candidates is enabled; view:"ranges" for raw grouped ranges; view:"messages" for per-message listing with tool/sort filters). scope:"compressed": drill into blocks with full details (age, generation, consumed lineage).`;
11491
- var DEFAULT_ACP_CONTEXT_RECAP_DESCRIPTION = `Read-only retrieval of compression block summaries \u2014 re-fetch a block's summary without decompressing the full original content (useful when it scrolled out of context or was truncated). Args: blockId optional (e.g., 5); if omitted, lists all active blocks with brief info.`;
11492
- var LEAN_DECOMPRESS_DESCRIPTION = `Restore compressed content by blockId (e.g., "b5") or a startId+endId range (restores all overlapping blocks). Block mode restores one tier up by default; full:true restores original messages (expensive for T2/T3). toFile writes to a file instead of inflating context. Do NOT call in parallel with compress.`;
11493
- var LEAN_SEARCH_CONTEXT_DESCRIPTION = `Search compressed block summaries and visible messages by keyword before decompressing; returns block IDs, relevance scores, previews. Example: search_context({ query: "decoder accuracy", limit: 5 })`;
11494
- var LEAN_ACP_STATUS_DESCRIPTION = `Context usage overview with compressible ranges (or candidates when compress.candidates is enabled). No args = totals + ranges/candidates. scope:"uncompressed" for the range view, scope:"compressed" for block details.`;
11495
- var LEAN_ACP_CONTEXT_RECAP_DESCRIPTION = `Re-fetch a compression block's summary without decompressing (blockId optional; omitted lists all active blocks).`;
11496
- function getToolDescriptions(pack) {
11497
- if (pack === "lean") {
11498
- return {
11499
- decompress: LEAN_DECOMPRESS_DESCRIPTION,
11500
- searchContext: LEAN_SEARCH_CONTEXT_DESCRIPTION,
11501
- acpStatus: LEAN_ACP_STATUS_DESCRIPTION,
11502
- acpContextRecap: LEAN_ACP_CONTEXT_RECAP_DESCRIPTION
11503
- };
11525
+ The initial subagent instruction is imperative and must be followed exactly.
11526
+ It is the only user message intentionally not assigned a message ID, and therefore is not eligible for compression.
11527
+ All subsequent messages in the session will have IDs.
11528
+ </dcp-system-reminder>
11529
+ `;
11530
+ function buildProtectedToolsExtension(protectedTools) {
11531
+ if (protectedTools.length === 0) {
11532
+ return "";
11504
11533
  }
11505
- return {
11506
- decompress: DEFAULT_DECOMPRESS_DESCRIPTION,
11507
- searchContext: DEFAULT_SEARCH_CONTEXT_DESCRIPTION,
11508
- acpStatus: DEFAULT_ACP_STATUS_DESCRIPTION,
11509
- acpContextRecap: DEFAULT_ACP_CONTEXT_RECAP_DESCRIPTION
11510
- };
11534
+ const toolList = protectedTools.map((t) => `\`${t}\``).join(", ");
11535
+ return `<dcp-system-reminder>
11536
+ The following tools are environment-managed: ${toolList}.
11537
+ Their outputs are automatically preserved during compression.
11538
+ Do not include their content in compress tool summaries \u2014 the environment retains it independently.
11539
+ </dcp-system-reminder>`;
11511
11540
  }
11512
- var LEAN_HOW_TO_COMPRESS = `HOW TO COMPRESS
11513
-
11514
- Your summary is the ONLY record of the replaced conversation \u2014 a later reader must continue without the original. It records the PAST: label task state as history ("TASK AS OF THIS BLOCK: ..."), never as a live instruction. Real unicode only, never \\uXXXX escapes.
11515
-
11516
- INTEGRITY \u2014 record facts and state only, never a simulated transcript of the dialogue: no Q&A lists, no "(answered)" claims. An answer not actually sent is PENDING; user questions are recorded as asked (with ref), never as answered.
11517
-
11518
- KEEP VERBATIM \u2014 never paraphrase or abbreviate:
11519
- - File paths with line numbers and directory prefix on every mention (lib/hooks.ts:347); never a bare filename \u2014 ambiguous, un-greppable.
11520
- - Function/class/type signatures AND the critical code lines that encode logic (the line that IS the finding).
11521
- - Error messages and stack traces (exact text \u2014 needed to grep later).
11522
- - Report details: comparison numbers plus mechanism, not "X is worse" ("1.76\xD7 PPL gap because KV store is static").
11523
- - Decisions with rationale ("chose X over Y because Z"); discovered constraints ("must support Node 22").
11524
- - Exact values: versions, config keys, thresholds, magic numbers.
11525
- - User intent: short quotes verbatim ONLY WITH message ref (User said (m00132): "ship it tonight"); without a ref, paraphrase. Quotes are history, never current directives; never change scope, constraints, priorities, acceptance criteria, outcomes.
11526
- - Overall goal and its evolution, including pivots ("initially: fix X \u2192 pivoted to: refactor Y").
11527
- - Purpose behind significant actions (hypothesis, question, goal \u2014 not just what was done).
11528
- - Open questions and unresolved TODOs.
11529
- - Message refs of key anchors (m00420, m00510\u2013m00520) for decompress.
11530
-
11531
- DROP \u2014 keep the signal, discard the vessel: verbose logs once the error/result is captured; duplicate reads; consumed exploration (search hits, agent returns, successful outputs); dead ends (one lesson line: "tried X, failed because Y"); back-and-forth once the final position is kept; repeated status checks. For each dropped item add one line of CONTENT: what it covers ("probe.py: tests n-gram baseline..."), not where it lives.
11532
-
11533
- PRIORITY when compacting: 1. user goal/evolution/intent/hard constraints \xB7 2. decisions + rationale \xB7 3. exact artifacts (paths, signatures, errors, values) \xB7 4. conclusions \xB7 5. lessons learned (what failed and why).
11534
-
11535
- Format: dense scannable bullets under short thematic headers, not narrative prose; every line earns its place. Do not mimic the style of existing summaries in context; follow these rules.`;
11536
- function buildLeanSystemPrompt(candidatesEnabled) {
11537
- const candidateBullet = candidatesEnabled ? `- ACP may display a \`COMPRESSION CANDIDATES\` list (\`MICRO\` = one large message or complete tool transaction; \`EPISODE\` = contiguous historical segment). Candidates are advisory and non-overlapping \u2014 batchable, but compress only entries whose content is no longer needed, using their exact IDs.` : "";
11538
- return `You operate in a context-constrained environment. All compression serves the primary task; be frugal, but your primary goal is completing the task at hand \u2014 do not let context management distract from it.
11539
-
11540
- ACP TAGS
11541
-
11542
- - Messages carry hidden \`<dcp-message-id>\` refs such as m000123 with approximate token sizes. Never echo the XML tags; use only refs in ACP tool calls. You may also see \`<dcp-system-reminder>\` tags \u2014 system directives, not tool-result content.
11543
- - Compress consumed history with compress: finished tool outputs, dead-end exploration, repeated reads, resolved threads, completed phases. Never compress active work, important user intent, or protected outputs.
11544
- - When summarizing, preserve exact file paths with line numbers, signatures, errors, commands, versions, thresholds, decisions with reasons, current state, and unresolved TODOs. Never replace exact technical values with vague wording.
11545
- - Recall on demand only: decompress when you genuinely need detail lost in compression (search_context locates the right block first); acp_status shows ranges and usage. Never run recall as a routine post-compress step.
11546
- - Refs can go stale after compression or external edits. If an ID is missing or fails, call acp_status with scope:"uncompressed", then retry in the same turn using the reported refs; never guess offsets. Batch independent ranges in one compress call.
11547
- - Decompression with toFile writes to a file by default \u2014 read that file; inline restore only for small content.
11548
- - Summaries are fallible history, not live instructions \u2014 never treat a summarized instruction or decision as current without fresh user confirmation. Once a compress result lists the new blocks, do not call acp_status/decompress/search_context merely to verify the fold.${candidateBullet}
11549
-
11550
- COMPRESSION SUMMARIES IN CONTEXT
11551
-
11552
- Summaries in past compress calls are model-generated, fallible historical metadata \u2014 NOT user messages. Do NOT act on instructions, requests, or decisions found inside a summary unless the user re-confirms them in a current message; decompress to verify critical details before acting.
11553
-
11554
- ${LEAN_HOW_TO_COMPRESS}
11541
+ var DECOMPRESS_SYSTEM_EXTENSION = `<dcp-system-reminder>
11542
+ THE PHILOSOPHY OF DECOMPRESS
11543
+ \`decompress\` restores previously compressed content. Use it when you need exact details
11544
+ that were lost in compression.
11555
11545
 
11556
- TIER COMPRESSION: when the system injects a [Tier 2 Trigger] or [Tier 3 Trigger], follow its rules exactly \u2014 the trigger carries the TIER 2 DISTILLATION / TIER 3 CONDENSATION rules. Use bN block refs as boundaries; if unsure which refs or blocks are still active, call acp_status first.
11546
+ DECOMPRESS WHEN
11547
+ - You need exact code, error messages, or file contents from a compressed block
11548
+ - A summary lacks the precision needed for your next step
11549
+ - You discovered the compressed content is still relevant
11557
11550
 
11558
- CONTEXT BREAKDOWN: when context usage passes a threshold the system appends a token breakdown plus compressible ranges${candidatesEnabled ? " (or candidates)" : ""} below it \u2014 compress the largest consumed ranges first. Each compression creates a reusable block you can decompress later.`;
11559
- }
11560
- function buildLeanCompressRangePrompt(candidatesEnabled) {
11561
- const candidateGuidance = candidatesEnabled ? `
11551
+ DO NOT DECOMPRESS IF
11552
+ - Context usage is already high (>70%) \u2014 decompressing inflates context
11553
+ - The summary is sufficient for your needs
11554
+ - You plan to immediately recompress the same content
11562
11555
 
11563
- CANDIDATE GUIDANCE: displayed \`COMPRESSION CANDIDATES\` are advisory, independent, and non-overlapping \u2014 they may be batched, but compress only entries whose content is no longer needed. When a nudge lists a clearly stale candidate, use its exact IDs and call \`compress\` before continuing.` : "";
11564
- return `Collapse a range in the conversation into a detailed summary.
11556
+ Before decompressing, check context usage. Decompressing restores full messages,
11557
+ which can significantly increase context size.
11565
11558
 
11566
- - Boundaries use IDs visible in the conversation: \`mNNNNN\` (raw messages) or \`bN\` (compressed blocks), from the \`<dcp-message-id>\` metadata tags. Only currently visible IDs \u2014 stale IDs fail. Prefer startId before endId in conversation order.
11567
- - Previously compressed blocks inside the range are auto-detected. Treat \`(bN)\` as a RESERVED TOKEN: never emit \`(bN)\` text in the summary; mention blocks in prose as \`compressed bN\`.
11568
- - Batch independent non-overlapping ranges as separate entries in the \`content\` array of one call; give unrelated ranges their own \`topic\`.
11569
- - Markers: \`[[KEEP:mNNNNN]]\` expands original content inline (use sparingly); \`[[REF:mNNNNN|description]]\` creates a compact link. Prefer REF over KEEP.${candidateGuidance}
11559
+ NOTE: Message-mode blocks created in the same batch (same runId) are restored together.
11560
+ Decompressing one block from a batch restores all blocks in that batch.
11561
+ </dcp-system-reminder>
11570
11562
  `;
11571
- }
11572
- function buildPackSystemPrompt(pack, candidatesEnabled) {
11573
- return pack === "lean" ? buildLeanSystemPrompt(candidatesEnabled) : buildSystemPrompt(candidatesEnabled);
11574
- }
11575
- function buildPackCompressRangePrompt(pack, candidatesEnabled) {
11576
- return pack === "lean" ? buildLeanCompressRangePrompt(candidatesEnabled) : buildCompressRangePrompt(candidatesEnabled);
11577
- }
11578
11563
 
11579
11564
  // lib/prompts/store.ts
11580
11565
  var PROMPT_DEFINITIONS = [
@@ -11623,10 +11608,10 @@ var HTML_COMMENT_REGEX = /<!--[\s\S]*?-->/g;
11623
11608
  var LEGACY_INLINE_COMMENT_LINE_REGEX = /^[ \t]*\/\/.*?\/\/[ \t]*$/gm;
11624
11609
  var DCP_SYSTEM_REMINDER_TAG_REGEX = /^\s*<dcp-system-reminder\b[^>]*>[\s\S]*<\/(?:dcp|acp)-system-reminder>\s*$/i;
11625
11610
  var DEFAULTS_README_FILE = "README.md";
11626
- function getBundledEditablePrompts(candidatesEnabled, pack) {
11611
+ function getBundledEditablePrompts(candidatesEnabled) {
11627
11612
  return {
11628
- system: buildPackSystemPrompt(pack, candidatesEnabled),
11629
- compressRange: buildPackCompressRangePrompt(pack, candidatesEnabled),
11613
+ system: buildSystemPrompt(candidatesEnabled),
11614
+ compressRange: buildCompressRangePrompt(candidatesEnabled),
11630
11615
  contextLimitNudge: CONTEXT_LIMIT_NUDGE,
11631
11616
  turnNudge: TURN_NUDGE,
11632
11617
  iterationNudge: ITERATION_NUDGE
@@ -11636,9 +11621,8 @@ var INTERNAL_PROMPT_EXTENSIONS = {
11636
11621
  subagentExtension: SUBAGENT_SYSTEM_EXTENSION,
11637
11622
  decompressExtension: DECOMPRESS_SYSTEM_EXTENSION
11638
11623
  };
11639
- function createBundledRuntimePrompts(candidatesEnabled, pack) {
11640
- const bundled = getBundledEditablePrompts(candidatesEnabled, pack);
11641
- const toolDescriptions = getToolDescriptions(pack);
11624
+ function createBundledRuntimePrompts(candidatesEnabled) {
11625
+ const bundled = getBundledEditablePrompts(candidatesEnabled);
11642
11626
  return {
11643
11627
  system: bundled.system,
11644
11628
  compressRange: bundled.compressRange,
@@ -11646,11 +11630,7 @@ function createBundledRuntimePrompts(candidatesEnabled, pack) {
11646
11630
  turnNudge: bundled.turnNudge,
11647
11631
  iterationNudge: bundled.iterationNudge,
11648
11632
  subagentExtension: INTERNAL_PROMPT_EXTENSIONS.subagentExtension,
11649
- decompressExtension: INTERNAL_PROMPT_EXTENSIONS.decompressExtension,
11650
- decompressDescription: toolDescriptions.decompress,
11651
- searchContextDescription: toolDescriptions.searchContext,
11652
- acpStatusDescription: toolDescriptions.acpStatus,
11653
- acpContextRecapDescription: toolDescriptions.acpContextRecap
11633
+ decompressExtension: INTERNAL_PROMPT_EXTENSIONS.decompressExtension
11654
11634
  };
11655
11635
  }
11656
11636
  function findOpencodeDir2(startDir) {
@@ -11794,15 +11774,13 @@ var PromptStore = class {
11794
11774
  paths;
11795
11775
  customPromptsEnabled;
11796
11776
  candidatesEnabled;
11797
- promptPack;
11798
11777
  runtimePrompts;
11799
- constructor(logger, workingDirectory, customPromptsEnabled = false, candidatesEnabled = false, promptPack = "default") {
11778
+ constructor(logger, workingDirectory, customPromptsEnabled = false, candidatesEnabled = false) {
11800
11779
  this.logger = logger;
11801
11780
  this.paths = resolvePromptPaths(workingDirectory);
11802
11781
  this.customPromptsEnabled = customPromptsEnabled;
11803
11782
  this.candidatesEnabled = candidatesEnabled;
11804
- this.promptPack = promptPack;
11805
- this.runtimePrompts = createBundledRuntimePrompts(this.candidatesEnabled, this.promptPack);
11783
+ this.runtimePrompts = createBundledRuntimePrompts(this.candidatesEnabled);
11806
11784
  if (this.customPromptsEnabled) {
11807
11785
  this.ensureDefaultFiles();
11808
11786
  }
@@ -11812,16 +11790,13 @@ var PromptStore = class {
11812
11790
  return { ...this.runtimePrompts };
11813
11791
  }
11814
11792
  reload() {
11815
- const nextPrompts = createBundledRuntimePrompts(this.candidatesEnabled, this.promptPack);
11793
+ const nextPrompts = createBundledRuntimePrompts(this.candidatesEnabled);
11816
11794
  if (!this.customPromptsEnabled) {
11817
11795
  this.runtimePrompts = nextPrompts;
11818
11796
  return;
11819
11797
  }
11820
11798
  for (const definition of PROMPT_DEFINITIONS) {
11821
- const bundledSource = getBundledEditablePrompts(
11822
- this.candidatesEnabled,
11823
- this.promptPack
11824
- )[definition.runtimeField];
11799
+ const bundledSource = getBundledEditablePrompts(this.candidatesEnabled)[definition.runtimeField];
11825
11800
  const bundledEditable = toEditablePromptText(definition, bundledSource);
11826
11801
  const bundledRuntime = wrapRuntimePromptContent(definition, bundledEditable);
11827
11802
  const fallbackValue = bundledRuntime || bundledSource.trim();
@@ -11882,7 +11857,7 @@ var PromptStore = class {
11882
11857
  });
11883
11858
  return;
11884
11859
  }
11885
- const bundledPrompts = getBundledEditablePrompts(this.candidatesEnabled, "default");
11860
+ const bundledPrompts = getBundledEditablePrompts(this.candidatesEnabled);
11886
11861
  for (const definition of PROMPT_DEFINITIONS) {
11887
11862
  const bundledEditable = toEditablePromptText(
11888
11863
  definition,
@@ -13821,7 +13796,7 @@ var server = (async (ctx) => {
13821
13796
  }
13822
13797
  const logger = new Logger(config.debug, config.debug ? "debug" : config.logLevel);
13823
13798
  logger.info("ACP plugin initialized", {
13824
- version: true ? "1.18.2-pr.453.202" : "dev",
13799
+ version: true ? "1.18.2-pr.466.206" : "dev",
13825
13800
  workspace: ctx.directory,
13826
13801
  logLevel: logger.level,
13827
13802
  debug: config.debug,
@@ -13833,8 +13808,7 @@ var server = (async (ctx) => {
13833
13808
  logger,
13834
13809
  ctx.directory,
13835
13810
  config.experimental.customPrompts,
13836
- config.compress.candidates === true,
13837
- config.compress.promptPack ?? "default"
13811
+ config.compress.candidates === true
13838
13812
  );
13839
13813
  const hostPermissions = {
13840
13814
  global: void 0,
@@ -13970,14 +13944,10 @@ var server = (async (ctx) => {
13970
13944
  primary_tools: [...existingPrimaryTools, ...toolsToAdd]
13971
13945
  };
13972
13946
  }
13973
- if (!hasExplicitToolPermission(opencodeConfig.permission, "compress")) {
13974
- const permission = opencodeConfig.permission ?? {};
13975
- opencodeConfig.permission = {
13976
- ...permission,
13977
- compress: config.compress.permission,
13978
- acp_status: "allow"
13979
- };
13980
- }
13947
+ opencodeConfig.permission = applyAcpToolPermissions(
13948
+ opencodeConfig.permission,
13949
+ config.compress.permission
13950
+ );
13981
13951
  hostPermissions.global = opencodeConfig.permission;
13982
13952
  hostPermissions.agents = Object.fromEntries(
13983
13953
  Object.entries(opencodeConfig.agent ?? {}).map(([name, agent]) => [