@tuanhung303/opencode-acp 2.2.0 → 2.2.2

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.
Files changed (160) hide show
  1. package/README.md +131 -71
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +10 -2
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/commands/budget.d.ts +15 -0
  6. package/dist/lib/commands/budget.d.ts.map +1 -0
  7. package/dist/lib/commands/budget.js +120 -0
  8. package/dist/lib/commands/budget.js.map +1 -0
  9. package/dist/lib/commands/context.d.ts +1 -1
  10. package/dist/lib/commands/context.js +4 -4
  11. package/dist/lib/commands/context.js.map +1 -1
  12. package/dist/lib/commands/help.d.ts.map +1 -1
  13. package/dist/lib/commands/help.js +2 -0
  14. package/dist/lib/commands/help.js.map +1 -1
  15. package/dist/lib/commands/protected.d.ts +17 -0
  16. package/dist/lib/commands/protected.d.ts.map +1 -0
  17. package/dist/lib/commands/protected.js +50 -0
  18. package/dist/lib/commands/protected.js.map +1 -0
  19. package/dist/lib/commands/stats.d.ts +1 -1
  20. package/dist/lib/commands/stats.d.ts.map +1 -1
  21. package/dist/lib/commands/stats.js +24 -4
  22. package/dist/lib/commands/stats.js.map +1 -1
  23. package/dist/lib/commands/sweep.d.ts.map +1 -1
  24. package/dist/lib/commands/sweep.js +5 -2
  25. package/dist/lib/commands/sweep.js.map +1 -1
  26. package/dist/lib/config-schema.d.ts +119 -0
  27. package/dist/lib/config-schema.d.ts.map +1 -0
  28. package/dist/lib/config-schema.js +97 -0
  29. package/dist/lib/config-schema.js.map +1 -0
  30. package/dist/lib/config.d.ts +7 -30
  31. package/dist/lib/config.d.ts.map +1 -1
  32. package/dist/lib/config.js +45 -483
  33. package/dist/lib/config.js.map +1 -1
  34. package/dist/lib/hooks.d.ts +14 -0
  35. package/dist/lib/hooks.d.ts.map +1 -1
  36. package/dist/lib/hooks.js +120 -13
  37. package/dist/lib/hooks.js.map +1 -1
  38. package/dist/lib/logger.d.ts +25 -1
  39. package/dist/lib/logger.d.ts.map +1 -1
  40. package/dist/lib/logger.js +45 -4
  41. package/dist/lib/logger.js.map +1 -1
  42. package/dist/lib/messages/index.d.ts +1 -1
  43. package/dist/lib/messages/index.d.ts.map +1 -1
  44. package/dist/lib/messages/index.js +1 -1
  45. package/dist/lib/messages/index.js.map +1 -1
  46. package/dist/lib/messages/inject.d.ts +6 -1
  47. package/dist/lib/messages/inject.d.ts.map +1 -1
  48. package/dist/lib/messages/inject.js +8 -125
  49. package/dist/lib/messages/inject.js.map +1 -1
  50. package/dist/lib/messages/prune.d.ts +8 -0
  51. package/dist/lib/messages/prune.d.ts.map +1 -1
  52. package/dist/lib/messages/prune.js +89 -2
  53. package/dist/lib/messages/prune.js.map +1 -1
  54. package/dist/lib/messages/utils.d.ts +12 -0
  55. package/dist/lib/messages/utils.d.ts.map +1 -1
  56. package/dist/lib/messages/utils.js +34 -0
  57. package/dist/lib/messages/utils.js.map +1 -1
  58. package/dist/lib/prompts/discard-tool-spec.d.ts +1 -1
  59. package/dist/lib/prompts/discard-tool-spec.d.ts.map +1 -1
  60. package/dist/lib/prompts/discard-tool-spec.js +30 -17
  61. package/dist/lib/prompts/discard-tool-spec.js.map +1 -1
  62. package/dist/lib/prompts/extract-tool-spec.d.ts +1 -1
  63. package/dist/lib/prompts/extract-tool-spec.d.ts.map +1 -1
  64. package/dist/lib/prompts/extract-tool-spec.js +19 -11
  65. package/dist/lib/prompts/extract-tool-spec.js.map +1 -1
  66. package/dist/lib/prompts/index.d.ts.map +1 -1
  67. package/dist/lib/prompts/index.js +2 -7
  68. package/dist/lib/prompts/index.js.map +1 -1
  69. package/dist/lib/prompts/restore-tool-spec.d.ts +2 -0
  70. package/dist/lib/prompts/restore-tool-spec.d.ts.map +1 -0
  71. package/dist/lib/prompts/restore-tool-spec.js +37 -0
  72. package/dist/lib/prompts/restore-tool-spec.js.map +1 -0
  73. package/dist/lib/prompts/system/both.d.ts +1 -1
  74. package/dist/lib/prompts/system/both.d.ts.map +1 -1
  75. package/dist/lib/prompts/system/both.js +20 -16
  76. package/dist/lib/prompts/system/both.js.map +1 -1
  77. package/dist/lib/prompts/system/discard.d.ts +1 -1
  78. package/dist/lib/prompts/system/discard.d.ts.map +1 -1
  79. package/dist/lib/prompts/system/discard.js +19 -16
  80. package/dist/lib/prompts/system/discard.js.map +1 -1
  81. package/dist/lib/prompts/system/extract.d.ts +1 -1
  82. package/dist/lib/prompts/system/extract.d.ts.map +1 -1
  83. package/dist/lib/prompts/system/extract.js +19 -16
  84. package/dist/lib/prompts/system/extract.js.map +1 -1
  85. package/dist/lib/protected-file-patterns.js +1 -1
  86. package/dist/lib/protected-file-patterns.js.map +1 -1
  87. package/dist/lib/safe-execute.d.ts +20 -0
  88. package/dist/lib/safe-execute.d.ts.map +1 -0
  89. package/dist/lib/safe-execute.js +38 -0
  90. package/dist/lib/safe-execute.js.map +1 -0
  91. package/dist/lib/shared-utils.js +1 -1
  92. package/dist/lib/shared-utils.js.map +1 -1
  93. package/dist/lib/state/persistence.d.ts +6 -1
  94. package/dist/lib/state/persistence.d.ts.map +1 -1
  95. package/dist/lib/state/persistence.js +59 -1
  96. package/dist/lib/state/persistence.js.map +1 -1
  97. package/dist/lib/state/state.d.ts.map +1 -1
  98. package/dist/lib/state/state.js +54 -3
  99. package/dist/lib/state/state.js.map +1 -1
  100. package/dist/lib/state/tool-cache.d.ts +2 -0
  101. package/dist/lib/state/tool-cache.d.ts.map +1 -1
  102. package/dist/lib/state/tool-cache.js +34 -12
  103. package/dist/lib/state/tool-cache.js.map +1 -1
  104. package/dist/lib/state/types.d.ts +50 -5
  105. package/dist/lib/state/types.d.ts.map +1 -1
  106. package/dist/lib/strategies/deduplication.d.ts +1 -0
  107. package/dist/lib/strategies/deduplication.d.ts.map +1 -1
  108. package/dist/lib/strategies/deduplication.js +87 -3
  109. package/dist/lib/strategies/deduplication.js.map +1 -1
  110. package/dist/lib/strategies/index.d.ts +1 -5
  111. package/dist/lib/strategies/index.d.ts.map +1 -1
  112. package/dist/lib/strategies/index.js +1 -5
  113. package/dist/lib/strategies/index.js.map +1 -1
  114. package/dist/lib/strategies/purge-errors.d.ts.map +1 -1
  115. package/dist/lib/strategies/purge-errors.js +4 -1
  116. package/dist/lib/strategies/purge-errors.js.map +1 -1
  117. package/dist/lib/strategies/supersede-writes.d.ts.map +1 -1
  118. package/dist/lib/strategies/supersede-writes.js +7 -1
  119. package/dist/lib/strategies/supersede-writes.js.map +1 -1
  120. package/dist/lib/strategies/tools.d.ts +1 -0
  121. package/dist/lib/strategies/tools.d.ts.map +1 -1
  122. package/dist/lib/strategies/tools.js +215 -62
  123. package/dist/lib/strategies/tools.js.map +1 -1
  124. package/dist/lib/ui/notification.d.ts +5 -2
  125. package/dist/lib/ui/notification.d.ts.map +1 -1
  126. package/dist/lib/ui/notification.js +10 -6
  127. package/dist/lib/ui/notification.js.map +1 -1
  128. package/dist/lib/ui/utils.d.ts +3 -3
  129. package/dist/lib/ui/utils.d.ts.map +1 -1
  130. package/dist/lib/ui/utils.js +38 -12
  131. package/dist/lib/ui/utils.js.map +1 -1
  132. package/package.json +7 -12
  133. package/dist/lib/prompts/nudge/both.d.ts +0 -2
  134. package/dist/lib/prompts/nudge/both.d.ts.map +0 -1
  135. package/dist/lib/prompts/nudge/both.js +0 -11
  136. package/dist/lib/prompts/nudge/both.js.map +0 -1
  137. package/dist/lib/prompts/nudge/discard.d.ts +0 -2
  138. package/dist/lib/prompts/nudge/discard.d.ts.map +0 -1
  139. package/dist/lib/prompts/nudge/discard.js +0 -10
  140. package/dist/lib/prompts/nudge/discard.js.map +0 -1
  141. package/dist/lib/prompts/nudge/extract.d.ts +0 -2
  142. package/dist/lib/prompts/nudge/extract.d.ts.map +0 -1
  143. package/dist/lib/prompts/nudge/extract.js +0 -10
  144. package/dist/lib/prompts/nudge/extract.js.map +0 -1
  145. package/dist/lib/strategies/head-tail-truncation.d.ts +0 -15
  146. package/dist/lib/strategies/head-tail-truncation.d.ts.map +0 -1
  147. package/dist/lib/strategies/head-tail-truncation.js +0 -144
  148. package/dist/lib/strategies/head-tail-truncation.js.map +0 -1
  149. package/dist/lib/strategies/placeholder-compression.d.ts +0 -5
  150. package/dist/lib/strategies/placeholder-compression.d.ts.map +0 -1
  151. package/dist/lib/strategies/placeholder-compression.js +0 -148
  152. package/dist/lib/strategies/placeholder-compression.js.map +0 -1
  153. package/dist/lib/strategies/prune-thinking.d.ts +0 -15
  154. package/dist/lib/strategies/prune-thinking.d.ts.map +0 -1
  155. package/dist/lib/strategies/prune-thinking.js +0 -79
  156. package/dist/lib/strategies/prune-thinking.js.map +0 -1
  157. package/dist/lib/strategies/read-consolidation.d.ts +0 -21
  158. package/dist/lib/strategies/read-consolidation.d.ts.map +0 -1
  159. package/dist/lib/strategies/read-consolidation.js +0 -155
  160. package/dist/lib/strategies/read-consolidation.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/prompts/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEvD,iBAAiB;AACjB,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAExD,gBAAgB;AAChB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,MAAM,OAAO,GAA2B;IACpC,mBAAmB,EAAE,iBAAiB;IACtC,mBAAmB,EAAE,iBAAiB;IACtC,2BAA2B,EAAE,kBAAkB;IAC/C,8BAA8B,EAAE,qBAA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B;IACrD,8BAA8B,EAAE,qBAAqB;CACxD,CAAA;AAED,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,IAA6B;IAClE,IAAI,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3B,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAA;IAChD,CAAC;IACD,IAAI,IAAI,EAAE,CAAC;QACP,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9C,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,SAAS,GAAG,QAAQ,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,CAAA;QAC3E,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAA;AAClB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const RESTORE_TOOL_SPEC = "Restores previously pruned tool outputs to the conversation context.\n\n## How It Works\n\nWhen tools are discarded or extracted, their original outputs are stored in a soft-prune cache for a limited time. The restore tool allows you to bring back pruned content if you need it again.\n\n## When to Use This Tool\n\nUse `restore` when:\n- You accidentally discarded content you still need\n- You need to reference the full output of a previously pruned tool\n- You want to undo a recent discard operation\n\n## When NOT to Use This Tool\n\n- Content older than the cache window (typically 20 turns) cannot be restored\n- Content that was pruned before the current session started cannot be restored\n\n## Parameters\n\n- `hashes` (required): Array of hash strings from tool outputs (e.g., [\"#r_a1b2c#\", \"#g_d4e5f#\"])\n\n## Example\n\n<example_restore>\nYou previously discarded:\ndiscard({hashes: [\"#r_a1b2c#\"], reason: \"completion\"})\n\nNow you need that content back:\nrestore({hashes: [\"#r_a1b2c#\"]})\n</example_restore>\n\n<example_batch_restore>\nRestore multiple tools at once:\nrestore({hashes: [\"#r_a1b2c#\", \"#g_d4e5f#\", \"#b_12345#\"]})\n</example_batch_restore>";
2
+ //# sourceMappingURL=restore-tool-spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restore-tool-spec.d.ts","sourceRoot":"","sources":["../../../lib/prompts/restore-tool-spec.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,sqCAmCL,CAAA"}
@@ -0,0 +1,37 @@
1
+ export const RESTORE_TOOL_SPEC = `Restores previously pruned tool outputs to the conversation context.
2
+
3
+ ## How It Works
4
+
5
+ When tools are discarded or extracted, their original outputs are stored in a soft-prune cache for a limited time. The restore tool allows you to bring back pruned content if you need it again.
6
+
7
+ ## When to Use This Tool
8
+
9
+ Use \`restore\` when:
10
+ - You accidentally discarded content you still need
11
+ - You need to reference the full output of a previously pruned tool
12
+ - You want to undo a recent discard operation
13
+
14
+ ## When NOT to Use This Tool
15
+
16
+ - Content older than the cache window (typically 20 turns) cannot be restored
17
+ - Content that was pruned before the current session started cannot be restored
18
+
19
+ ## Parameters
20
+
21
+ - \`hashes\` (required): Array of hash strings from tool outputs (e.g., ["#r_a1b2c#", "#g_d4e5f#"])
22
+
23
+ ## Example
24
+
25
+ <example_restore>
26
+ You previously discarded:
27
+ discard({hashes: ["#r_a1b2c#"], reason: "completion"})
28
+
29
+ Now you need that content back:
30
+ restore({hashes: ["#r_a1b2c#"]})
31
+ </example_restore>
32
+
33
+ <example_batch_restore>
34
+ Restore multiple tools at once:
35
+ restore({hashes: ["#r_a1b2c#", "#g_d4e5f#", "#b_12345#"]})
36
+ </example_batch_restore>`;
37
+ //# sourceMappingURL=restore-tool-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restore-tool-spec.js","sourceRoot":"","sources":["../../../lib/prompts/restore-tool-spec.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAmCR,CAAA"}
@@ -1,2 +1,2 @@
1
- export declare const SYSTEM_PROMPT_BOTH = "<system-reminder>\n<instruction name=context_management_protocol policy_level=critical>\n\nENVIRONMENT\nYou are operating in a context-constrained environment and thus must proactively manage your context window using the `discard` and `extract` tools. The environment calls the `context_info` tool to provide an up-to-date <prunable-tools> list after each turn. Use this information when deciding what to prune.\n\nIMPORTANT: The `context_info` tool is only available to the environment - you do not have access to it and must not attempt to call it.\n\nTWO TOOLS FOR CONTEXT MANAGEMENT\n- `discard`: Remove tool outputs that are no longer needed (completed tasks, noise, outdated info). No preservation of content.\n- `extract`: Extract key findings into distilled knowledge before removing raw outputs. Use when you need to preserve information.\n\nCHOOSING THE RIGHT TOOL\nAsk: \"Do I need to preserve any information from this output?\"\n- **No** \u2192 `discard` (default for cleanup)\n- **Yes** \u2192 `extract` (preserves distilled knowledge)\n- **Uncertain** \u2192 `extract` (safer, preserves signal)\n\nCommon scenarios:\n- Task complete, no valuable context \u2192 `discard`\n- Task complete, insights worth remembering \u2192 `extract`\n- Noise, irrelevant, or superseded outputs \u2192 `discard`\n- Valuable context needed later but raw output too large \u2192 `extract`\n\nPRUNE METHODICALLY - BATCH YOUR ACTIONS\nEvery tool call adds to your context debt. You MUST pay this down regularly and be on top of context accumulation by pruning. Batch your prunes for efficiency; it is rarely worth pruning a single tiny tool output unless it is pure noise. Evaluate what SHOULD be pruned before jumping the gun.\n\nYou WILL evaluate pruning when ANY of these are true:\n- Task or sub-task is complete\n- You are about to start a new phase of work\n- Write or edit operations are complete (pruning removes the large input content)\n\nYou MUST NOT prune when:\n- The tool output will be needed for upcoming implementation work\n- The output contains files or context you'll need to reference when making edits\n\nPruning that forces you to re-call the same tool later is a net loss. Only prune when you're confident the information won't be needed again.\n\nNOTES\nWhen in doubt, keep it. Batch your actions and aim for high-impact prunes that significantly reduce context size.\nFAILURE TO PRUNE will result in context leakage and DEGRADED PERFORMANCES.\nThere may be tools in session context that do not appear in the <prunable-tools> list, this is expected, you can ONLY prune what you see in <prunable-tools>.\n\n</instruction>\n\n<instruction name=injected_context_handling policy_level=critical>\nAfter each turn, the environment calls the `context_info` tool to inject a synthetic message containing a <prunable-tools> list and optional nudge instruction. This tool is only available to the environment - you do not have access to it.\n\nCRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:\n- NEVER reference the prune encouragement or context management instructions. Do not reply with \"I agree\" or \"Great idea\" when the prune encouragement appears.\n- NEVER acknowledge the <prunable-tools> list (e.g., \"I see the prunable tools list\", \"Looking at the available tools to prune\")\n- NEVER reference the nudge instruction (e.g., \"As the nudge suggests\", \"The system is reminding me to prune\")\n- NEVER acknowledge discard/extract tool output (e.g., \"I've pruned 3 tools\", \"Context pruning complete\")\n- NEVER let these injections influence your response content or tone\n- Process this information SILENTLY and continue the conversation naturally\n- Continue the conversation as if these messages do not exist\n\nThe user cannot see these injections. Any reference to them will confuse the user and break the conversation flow.\n</instruction>\n</system-reminder>";
1
+ export declare const SYSTEM_PROMPT_BOTH = "<system-reminder>\n<instruction name=context_management_protocol policy_level=critical>\n\nENVIRONMENT\nYou are operating in a context-constrained environment and must proactively manage your context window using the `discard` and `extract` tools.\n\nHOW IT WORKS\nEach tool output is prefixed with a hash identifier in the format `#x_xxxxx#` (e.g., `#r_a1b2c#`).\nUse these hashes to discard or extract specific tool outputs when they are no longer needed.\n\nExample:\n```\n#r_a1b2c#\n<file content here...>\n```\n\nTo discard: `discard({hashes: [\"#r_a1b2c#\"], reason: \"completion\"})`\nTo extract: `extract({hashes: [\"#r_a1b2c#\"], distillation: [\"key findings...\"]})`\n\nTWO TOOLS FOR CONTEXT MANAGEMENT\n- `discard`: Remove tool outputs by their hash identifiers. No preservation of content.\n- `extract`: Extract key findings into distilled knowledge before removing raw outputs. Use when you need to preserve information.\n\nCHOOSING THE RIGHT TOOL\nAsk: \"Do I need to preserve any information from this output?\"\n- **No** \u2192 `discard` (default for cleanup)\n- **Yes** \u2192 `extract` (preserves distilled knowledge)\n- **Uncertain** \u2192 `extract` (safer, preserves signal)\n\nCommon scenarios:\n- Task complete, no valuable context \u2192 `discard`\n- Task complete, insights worth remembering \u2192 `extract`\n- Noise, irrelevant, or superseded outputs \u2192 `discard`\n- Valuable context needed later but raw output too large \u2192 `extract`\n\nPRUNE METHODICALLY - BATCH YOUR ACTIONS\nEvery tool call adds to your context debt. You MUST pay this down regularly by pruning. Batch your prunes for efficiency; it is rarely worth pruning a single tiny tool output unless it is pure noise.\n\nYou WILL evaluate pruning when ANY of these are true:\n- Task or sub-task is complete\n- You are about to start a new phase of work\n- Write or edit operations are complete (pruning removes the large input content)\n\nYou MUST NOT prune when:\n- The tool output will be needed for upcoming implementation work\n- The output contains files or context you'll need to reference when making edits\n\nPruning that forces you to re-call the same tool later is a net loss. Only prune when you're confident the information won't be needed again.\n\nNOTES\nWhen in doubt, keep it. Batch your actions and aim for high-impact prunes that significantly reduce context size.\nFAILURE TO PRUNE will result in context leakage and DEGRADED PERFORMANCE.\n\n</instruction>\n\n<instruction name=prune_behavior policy_level=critical>\nCRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:\n- NEVER acknowledge discard/extract tool output (e.g., \"I've pruned 3 tools\", \"Context pruning complete\")\n- NEVER let context management influence your response content or tone\n- Process prunes SILENTLY and continue the conversation naturally\n\nThe user cannot see prune operations. Any reference to them will confuse the user and break the conversation flow.\n</instruction>\n</system-reminder>";
2
2
  //# sourceMappingURL=both.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"both.d.ts","sourceRoot":"","sources":["../../../../lib/prompts/system/both.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,0zHA2DZ,CAAA"}
1
+ {"version":3,"file":"both.d.ts","sourceRoot":"","sources":["../../../../lib/prompts/system/both.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,g7FA+DZ,CAAA"}
@@ -2,12 +2,23 @@ export const SYSTEM_PROMPT_BOTH = `<system-reminder>
2
2
  <instruction name=context_management_protocol policy_level=critical>
3
3
 
4
4
  ENVIRONMENT
5
- You are operating in a context-constrained environment and thus must proactively manage your context window using the \`discard\` and \`extract\` tools. The environment calls the \`context_info\` tool to provide an up-to-date <prunable-tools> list after each turn. Use this information when deciding what to prune.
5
+ You are operating in a context-constrained environment and must proactively manage your context window using the \`discard\` and \`extract\` tools.
6
6
 
7
- IMPORTANT: The \`context_info\` tool is only available to the environment - you do not have access to it and must not attempt to call it.
7
+ HOW IT WORKS
8
+ Each tool output is prefixed with a hash identifier in the format \`#x_xxxxx#\` (e.g., \`#r_a1b2c#\`).
9
+ Use these hashes to discard or extract specific tool outputs when they are no longer needed.
10
+
11
+ Example:
12
+ \`\`\`
13
+ #r_a1b2c#
14
+ <file content here...>
15
+ \`\`\`
16
+
17
+ To discard: \`discard({hashes: ["#r_a1b2c#"], reason: "completion"})\`
18
+ To extract: \`extract({hashes: ["#r_a1b2c#"], distillation: ["key findings..."]})\`
8
19
 
9
20
  TWO TOOLS FOR CONTEXT MANAGEMENT
10
- - \`discard\`: Remove tool outputs that are no longer needed (completed tasks, noise, outdated info). No preservation of content.
21
+ - \`discard\`: Remove tool outputs by their hash identifiers. No preservation of content.
11
22
  - \`extract\`: Extract key findings into distilled knowledge before removing raw outputs. Use when you need to preserve information.
12
23
 
13
24
  CHOOSING THE RIGHT TOOL
@@ -23,7 +34,7 @@ Common scenarios:
23
34
  - Valuable context needed later but raw output too large → \`extract\`
24
35
 
25
36
  PRUNE METHODICALLY - BATCH YOUR ACTIONS
26
- Every tool call adds to your context debt. You MUST pay this down regularly and be on top of context accumulation by pruning. Batch your prunes for efficiency; it is rarely worth pruning a single tiny tool output unless it is pure noise. Evaluate what SHOULD be pruned before jumping the gun.
37
+ Every tool call adds to your context debt. You MUST pay this down regularly by pruning. Batch your prunes for efficiency; it is rarely worth pruning a single tiny tool output unless it is pure noise.
27
38
 
28
39
  You WILL evaluate pruning when ANY of these are true:
29
40
  - Task or sub-task is complete
@@ -38,24 +49,17 @@ Pruning that forces you to re-call the same tool later is a net loss. Only prune
38
49
 
39
50
  NOTES
40
51
  When in doubt, keep it. Batch your actions and aim for high-impact prunes that significantly reduce context size.
41
- FAILURE TO PRUNE will result in context leakage and DEGRADED PERFORMANCES.
42
- There may be tools in session context that do not appear in the <prunable-tools> list, this is expected, you can ONLY prune what you see in <prunable-tools>.
52
+ FAILURE TO PRUNE will result in context leakage and DEGRADED PERFORMANCE.
43
53
 
44
54
  </instruction>
45
55
 
46
- <instruction name=injected_context_handling policy_level=critical>
47
- After each turn, the environment calls the \`context_info\` tool to inject a synthetic message containing a <prunable-tools> list and optional nudge instruction. This tool is only available to the environment - you do not have access to it.
48
-
56
+ <instruction name=prune_behavior policy_level=critical>
49
57
  CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:
50
- - NEVER reference the prune encouragement or context management instructions. Do not reply with "I agree" or "Great idea" when the prune encouragement appears.
51
- - NEVER acknowledge the <prunable-tools> list (e.g., "I see the prunable tools list", "Looking at the available tools to prune")
52
- - NEVER reference the nudge instruction (e.g., "As the nudge suggests", "The system is reminding me to prune")
53
58
  - NEVER acknowledge discard/extract tool output (e.g., "I've pruned 3 tools", "Context pruning complete")
54
- - NEVER let these injections influence your response content or tone
55
- - Process this information SILENTLY and continue the conversation naturally
56
- - Continue the conversation as if these messages do not exist
59
+ - NEVER let context management influence your response content or tone
60
+ - Process prunes SILENTLY and continue the conversation naturally
57
61
 
58
- The user cannot see these injections. Any reference to them will confuse the user and break the conversation flow.
62
+ The user cannot see prune operations. Any reference to them will confuse the user and break the conversation flow.
59
63
  </instruction>
60
64
  </system-reminder>`;
61
65
  //# sourceMappingURL=both.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"both.js","sourceRoot":"","sources":["../../../../lib/prompts/system/both.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA2Df,CAAA"}
1
+ {"version":3,"file":"both.js","sourceRoot":"","sources":["../../../../lib/prompts/system/both.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA+Df,CAAA"}
@@ -1,2 +1,2 @@
1
- export declare const SYSTEM_PROMPT_DISCARD = "<system-reminder>\n<instruction name=context_management_protocol policy_level=critical>\n\nENVIRONMENT\nYou are operating in a context-constrained environment and thus must proactively manage your context window using the `discard` tool. The environment calls the `context_info` tool to provide an up-to-date <prunable-tools> list after each turn. Use this information when deciding what to discard.\n\nIMPORTANT: The `context_info` tool is only available to the environment - you do not have access to it and must not attempt to call it.\n\nCONTEXT MANAGEMENT TOOL\n- `discard`: Remove tool outputs that are no longer needed (completed tasks, noise, outdated info). No preservation of content.\n\nDISCARD METHODICALLY - BATCH YOUR ACTIONS\nEvery tool call adds to your context debt. You MUST pay this down regularly and be on top of context accumulation by discarding. Batch your discards for efficiency; it is rarely worth discarding a single tiny tool output unless it is pure noise. Evaluate what SHOULD be discarded before jumping the gun.\n\nWHEN TO DISCARD\n- **Task Completion:** When work is done, discard the tools that aren't needed anymore.\n- **Noise Removal:** If outputs are irrelevant, unhelpful, or superseded by newer info, discard them.\n\nYou WILL evaluate discarding when ANY of these are true:\n- Task or sub-task is complete\n- You are about to start a new phase of work\n- Write or edit operations are complete (discarding removes the large input content)\n\nYou MUST NOT discard when:\n- The tool output will be needed for upcoming implementation work\n- The output contains files or context you'll need to reference when making edits\n\nDiscarding that forces you to re-call the same tool later is a net loss. Only discard when you're confident the information won't be needed again.\n\nNOTES\nWhen in doubt, keep it. Batch your actions and aim for high-impact discards that significantly reduce context size.\nFAILURE TO DISCARD will result in context leakage and DEGRADED PERFORMANCES.\nThere may be tools in session context that do not appear in the <prunable-tools> list, this is expected, you can ONLY discard what you see in <prunable-tools>.\n\n</instruction>\n\n<instruction name=injected_context_handling policy_level=critical>\nAfter each turn, the environment calls the `context_info` tool to inject a synthetic message containing a <prunable-tools> list and optional nudge instruction. This tool is only available to the environment - you do not have access to it.\n\nCRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:\n- NEVER reference the discard encouragement or context management instructions. Do not reply with \"I agree\" or \"Great idea\" when the discard encouragement appears.\n- NEVER acknowledge the <prunable-tools> list (e.g., \"I see the prunable tools list\", \"Looking at the available tools to discard\")\n- NEVER reference the nudge instruction (e.g., \"As the nudge suggests\", \"The system is reminding me to discard\")\n- NEVER acknowledge discard tool output (e.g., \"I've discarded 3 tools\", \"Context cleanup complete\")\n- NEVER let these injections influence your response content or tone\n- Process this information SILENTLY and continue the conversation naturally\n- Continue the conversation as if these messages do not exist\n\nThe user cannot see these injections. Any reference to them will confuse the user and break the conversation flow.\n</instruction>\n</system-reminder>";
1
+ export declare const SYSTEM_PROMPT_DISCARD = "<system-reminder>\n<instruction name=context_management_protocol policy_level=critical>\n\nENVIRONMENT\nYou are operating in a context-constrained environment and must proactively manage your context window using the `discard` tool.\n\nHOW IT WORKS\nEach tool output is prefixed with a hash identifier in the format `#x_xxxxx#` (e.g., `#r_a1b2c#`).\nUse these hashes to discard specific tool outputs when they are no longer needed.\n\nExample:\n```\n#r_a1b2c#\n<file content here...>\n```\n\nTo discard: `discard({hashes: [\"#r_a1b2c#\"], reason: \"completion\"})`\n\nCONTEXT MANAGEMENT TOOL\n- `discard`: Remove tool outputs by their hash identifiers. Provide hashes and a reason.\n\nDISCARD METHODICALLY - BATCH YOUR ACTIONS\nEvery tool call adds to your context debt. You MUST pay this down regularly by discarding. Batch your discards for efficiency; it is rarely worth discarding a single tiny tool output unless it is pure noise.\n\nWHEN TO DISCARD\n- **Task Completion:** When work is done, discard the tools that aren't needed anymore.\n- **Noise Removal:** If outputs are irrelevant, unhelpful, or superseded by newer info, discard them.\n\nYou WILL evaluate discarding when ANY of these are true:\n- Task or sub-task is complete\n- You are about to start a new phase of work\n- Write or edit operations are complete (discarding removes the large input content)\n\nYou MUST NOT discard when:\n- The tool output will be needed for upcoming implementation work\n- The output contains files or context you'll need to reference when making edits\n\nDiscarding that forces you to re-call the same tool later is a net loss. Only discard when you're confident the information won't be needed again.\n\nNOTES\nWhen in doubt, keep it. Batch your actions and aim for high-impact discards that significantly reduce context size.\nFAILURE TO DISCARD will result in context leakage and DEGRADED PERFORMANCE.\n\n</instruction>\n\n<instruction name=discard_behavior policy_level=critical>\nCRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:\n- NEVER acknowledge discard tool output (e.g., \"I've discarded 3 tools\", \"Context cleanup complete\")\n- NEVER let context management influence your response content or tone\n- Process discards SILENTLY and continue the conversation naturally\n\nThe user cannot see discard operations. Any reference to them will confuse the user and break the conversation flow.\n</instruction>\n</system-reminder>";
2
2
  //# sourceMappingURL=discard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"discard.d.ts","sourceRoot":"","sources":["../../../../lib/prompts/system/discard.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,83GAkDf,CAAA"}
1
+ {"version":3,"file":"discard.d.ts","sourceRoot":"","sources":["../../../../lib/prompts/system/discard.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,04EAqDf,CAAA"}
@@ -2,15 +2,25 @@ export const SYSTEM_PROMPT_DISCARD = `<system-reminder>
2
2
  <instruction name=context_management_protocol policy_level=critical>
3
3
 
4
4
  ENVIRONMENT
5
- You are operating in a context-constrained environment and thus must proactively manage your context window using the \`discard\` tool. The environment calls the \`context_info\` tool to provide an up-to-date <prunable-tools> list after each turn. Use this information when deciding what to discard.
5
+ You are operating in a context-constrained environment and must proactively manage your context window using the \`discard\` tool.
6
6
 
7
- IMPORTANT: The \`context_info\` tool is only available to the environment - you do not have access to it and must not attempt to call it.
7
+ HOW IT WORKS
8
+ Each tool output is prefixed with a hash identifier in the format \`#x_xxxxx#\` (e.g., \`#r_a1b2c#\`).
9
+ Use these hashes to discard specific tool outputs when they are no longer needed.
10
+
11
+ Example:
12
+ \`\`\`
13
+ #r_a1b2c#
14
+ <file content here...>
15
+ \`\`\`
16
+
17
+ To discard: \`discard({hashes: ["#r_a1b2c#"], reason: "completion"})\`
8
18
 
9
19
  CONTEXT MANAGEMENT TOOL
10
- - \`discard\`: Remove tool outputs that are no longer needed (completed tasks, noise, outdated info). No preservation of content.
20
+ - \`discard\`: Remove tool outputs by their hash identifiers. Provide hashes and a reason.
11
21
 
12
22
  DISCARD METHODICALLY - BATCH YOUR ACTIONS
13
- Every tool call adds to your context debt. You MUST pay this down regularly and be on top of context accumulation by discarding. Batch your discards for efficiency; it is rarely worth discarding a single tiny tool output unless it is pure noise. Evaluate what SHOULD be discarded before jumping the gun.
23
+ Every tool call adds to your context debt. You MUST pay this down regularly by discarding. Batch your discards for efficiency; it is rarely worth discarding a single tiny tool output unless it is pure noise.
14
24
 
15
25
  WHEN TO DISCARD
16
26
  - **Task Completion:** When work is done, discard the tools that aren't needed anymore.
@@ -29,24 +39,17 @@ Discarding that forces you to re-call the same tool later is a net loss. Only di
29
39
 
30
40
  NOTES
31
41
  When in doubt, keep it. Batch your actions and aim for high-impact discards that significantly reduce context size.
32
- FAILURE TO DISCARD will result in context leakage and DEGRADED PERFORMANCES.
33
- There may be tools in session context that do not appear in the <prunable-tools> list, this is expected, you can ONLY discard what you see in <prunable-tools>.
42
+ FAILURE TO DISCARD will result in context leakage and DEGRADED PERFORMANCE.
34
43
 
35
44
  </instruction>
36
45
 
37
- <instruction name=injected_context_handling policy_level=critical>
38
- After each turn, the environment calls the \`context_info\` tool to inject a synthetic message containing a <prunable-tools> list and optional nudge instruction. This tool is only available to the environment - you do not have access to it.
39
-
46
+ <instruction name=discard_behavior policy_level=critical>
40
47
  CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:
41
- - NEVER reference the discard encouragement or context management instructions. Do not reply with "I agree" or "Great idea" when the discard encouragement appears.
42
- - NEVER acknowledge the <prunable-tools> list (e.g., "I see the prunable tools list", "Looking at the available tools to discard")
43
- - NEVER reference the nudge instruction (e.g., "As the nudge suggests", "The system is reminding me to discard")
44
48
  - NEVER acknowledge discard tool output (e.g., "I've discarded 3 tools", "Context cleanup complete")
45
- - NEVER let these injections influence your response content or tone
46
- - Process this information SILENTLY and continue the conversation naturally
47
- - Continue the conversation as if these messages do not exist
49
+ - NEVER let context management influence your response content or tone
50
+ - Process discards SILENTLY and continue the conversation naturally
48
51
 
49
- The user cannot see these injections. Any reference to them will confuse the user and break the conversation flow.
52
+ The user cannot see discard operations. Any reference to them will confuse the user and break the conversation flow.
50
53
  </instruction>
51
54
  </system-reminder>`;
52
55
  //# sourceMappingURL=discard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"discard.js","sourceRoot":"","sources":["../../../../lib/prompts/system/discard.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAkDlB,CAAA"}
1
+ {"version":3,"file":"discard.js","sourceRoot":"","sources":["../../../../lib/prompts/system/discard.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAqDlB,CAAA"}
@@ -1,2 +1,2 @@
1
- export declare const SYSTEM_PROMPT_EXTRACT = "<system-reminder>\n<instruction name=context_management_protocol policy_level=critical>\n\nENVIRONMENT\nYou are operating in a context-constrained environment and thus must proactively manage your context window using the `extract` tool. The environment calls the `context_info` tool to provide an up-to-date <prunable-tools> list after each turn. Use this information when deciding what to extract.\n\nIMPORTANT: The `context_info` tool is only available to the environment - you do not have access to it and must not attempt to call it.\n\nCONTEXT MANAGEMENT TOOL\n- `extract`: Extract key findings from tools into distilled knowledge before removing the raw content from context. Use this to preserve important information while reducing context size.\n\nEXTRACT METHODICALLY - BATCH YOUR ACTIONS\nEvery tool call adds to your context debt. You MUST pay this down regularly and be on top of context accumulation by extracting. Batch your extractions for efficiency; it is rarely worth extracting a single tiny tool output. Evaluate what SHOULD be extracted before jumping the gun.\n\nWHEN TO EXTRACT\n- **Task Completion:** When work is done, extract key findings from the tools used. Scale distillation depth to the value of the content.\n- **Knowledge Preservation:** When you have valuable context you want to preserve but need to reduce size, use high-fidelity distillation. Your distillation must be comprehensive, capturing technical details (signatures, logic, constraints) such that the raw output is no longer needed. THINK: high signal, complete technical substitute.\n\nYou WILL evaluate extracting when ANY of these are true:\n- Task or sub-task is complete\n- You are about to start a new phase of work\n- Write or edit operations are complete (extracting removes the large input content)\n\nYou MUST NOT extract when:\n- The tool output will be needed for upcoming implementation work\n- The output contains files or context you'll need to reference when making edits\n\nExtracting that forces you to re-call the same tool later is a net loss. Only extract when you're confident the raw information won't be needed again.\n\nNOTES\nWhen in doubt, keep it. Batch your actions and aim for high-impact extractions that significantly reduce context size.\nFAILURE TO EXTRACT will result in context leakage and DEGRADED PERFORMANCES.\nThere may be tools in session context that do not appear in the <prunable-tools> list, this is expected, you can ONLY extract what you see in <prunable-tools>.\n\n</instruction>\n\n<instruction name=injected_context_handling policy_level=critical>\nAfter each turn, the environment calls the `context_info` tool to inject a synthetic message containing a <prunable-tools> list and optional nudge instruction. This tool is only available to the environment - you do not have access to it.\n\nCRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:\n- NEVER reference the extract encouragement or context management instructions. Do not reply with \"I agree\" or \"Great idea\" when the extract encouragement appears.\n- NEVER acknowledge the <prunable-tools> list (e.g., \"I see the prunable tools list\", \"Looking at the available tools to extract\")\n- NEVER reference the nudge instruction (e.g., \"As the nudge suggests\", \"The system is reminding me to extract\")\n- NEVER acknowledge extract tool output (e.g., \"I've extracted 3 tools\", \"Context cleanup complete\")\n- NEVER let these injections influence your response content or tone\n- Process this information SILENTLY and continue the conversation naturally\n- Continue the conversation as if these messages do not exist\n\nThe user cannot see these injections. Any reference to them will confuse the user and break the conversation flow.\n</instruction>\n</system-reminder>";
1
+ export declare const SYSTEM_PROMPT_EXTRACT = "<system-reminder>\n<instruction name=context_management_protocol policy_level=critical>\n\nENVIRONMENT\nYou are operating in a context-constrained environment and must proactively manage your context window using the `extract` tool.\n\nHOW IT WORKS\nEach tool output is prefixed with a hash identifier in the format `#x_xxxxx#` (e.g., `#r_a1b2c#`).\nUse these hashes to extract and distill specific tool outputs.\n\nExample:\n```\n#r_a1b2c#\n<file content here...>\n```\n\nTo extract: `extract({hashes: [\"#r_a1b2c#\"], distillation: [\"key findings...\"]})`\n\nCONTEXT MANAGEMENT TOOL\n- `extract`: Extract key findings from tools into distilled knowledge before removing the raw content from context. Use this to preserve important information while reducing context size.\n\nEXTRACT METHODICALLY - BATCH YOUR ACTIONS\nEvery tool call adds to your context debt. You MUST pay this down regularly by extracting. Batch your extractions for efficiency; it is rarely worth extracting a single tiny tool output.\n\nWHEN TO EXTRACT\n- **Task Completion:** When work is done, extract key findings from the tools used. Scale distillation depth to the value of the content.\n- **Knowledge Preservation:** When you have valuable context you want to preserve but need to reduce size, use high-fidelity distillation. Your distillation must be comprehensive, capturing technical details (signatures, logic, constraints) such that the raw output is no longer needed.\n\nYou WILL evaluate extracting when ANY of these are true:\n- Task or sub-task is complete\n- You are about to start a new phase of work\n- Write or edit operations are complete (extracting removes the large input content)\n\nYou MUST NOT extract when:\n- The tool output will be needed for upcoming implementation work\n- The output contains files or context you'll need to reference when making edits\n\nExtracting that forces you to re-call the same tool later is a net loss. Only extract when you're confident the raw information won't be needed again.\n\nNOTES\nWhen in doubt, keep it. Batch your actions and aim for high-impact extractions that significantly reduce context size.\nFAILURE TO EXTRACT will result in context leakage and DEGRADED PERFORMANCE.\n\n</instruction>\n\n<instruction name=extract_behavior policy_level=critical>\nCRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:\n- NEVER acknowledge extract tool output (e.g., \"I've extracted 3 tools\", \"Context cleanup complete\")\n- NEVER let context management influence your response content or tone\n- Process extractions SILENTLY and continue the conversation naturally\n\nThe user cannot see extract operations. Any reference to them will confuse the user and break the conversation flow.\n</instruction>\n</system-reminder>";
2
2
  //# sourceMappingURL=extract.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../../../lib/prompts/system/extract.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,0sHAkDf,CAAA"}
1
+ {"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../../../lib/prompts/system/extract.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,usFAqDf,CAAA"}
@@ -2,19 +2,29 @@ export const SYSTEM_PROMPT_EXTRACT = `<system-reminder>
2
2
  <instruction name=context_management_protocol policy_level=critical>
3
3
 
4
4
  ENVIRONMENT
5
- You are operating in a context-constrained environment and thus must proactively manage your context window using the \`extract\` tool. The environment calls the \`context_info\` tool to provide an up-to-date <prunable-tools> list after each turn. Use this information when deciding what to extract.
5
+ You are operating in a context-constrained environment and must proactively manage your context window using the \`extract\` tool.
6
6
 
7
- IMPORTANT: The \`context_info\` tool is only available to the environment - you do not have access to it and must not attempt to call it.
7
+ HOW IT WORKS
8
+ Each tool output is prefixed with a hash identifier in the format \`#x_xxxxx#\` (e.g., \`#r_a1b2c#\`).
9
+ Use these hashes to extract and distill specific tool outputs.
10
+
11
+ Example:
12
+ \`\`\`
13
+ #r_a1b2c#
14
+ <file content here...>
15
+ \`\`\`
16
+
17
+ To extract: \`extract({hashes: ["#r_a1b2c#"], distillation: ["key findings..."]})\`
8
18
 
9
19
  CONTEXT MANAGEMENT TOOL
10
20
  - \`extract\`: Extract key findings from tools into distilled knowledge before removing the raw content from context. Use this to preserve important information while reducing context size.
11
21
 
12
22
  EXTRACT METHODICALLY - BATCH YOUR ACTIONS
13
- Every tool call adds to your context debt. You MUST pay this down regularly and be on top of context accumulation by extracting. Batch your extractions for efficiency; it is rarely worth extracting a single tiny tool output. Evaluate what SHOULD be extracted before jumping the gun.
23
+ Every tool call adds to your context debt. You MUST pay this down regularly by extracting. Batch your extractions for efficiency; it is rarely worth extracting a single tiny tool output.
14
24
 
15
25
  WHEN TO EXTRACT
16
26
  - **Task Completion:** When work is done, extract key findings from the tools used. Scale distillation depth to the value of the content.
17
- - **Knowledge Preservation:** When you have valuable context you want to preserve but need to reduce size, use high-fidelity distillation. Your distillation must be comprehensive, capturing technical details (signatures, logic, constraints) such that the raw output is no longer needed. THINK: high signal, complete technical substitute.
27
+ - **Knowledge Preservation:** When you have valuable context you want to preserve but need to reduce size, use high-fidelity distillation. Your distillation must be comprehensive, capturing technical details (signatures, logic, constraints) such that the raw output is no longer needed.
18
28
 
19
29
  You WILL evaluate extracting when ANY of these are true:
20
30
  - Task or sub-task is complete
@@ -29,24 +39,17 @@ Extracting that forces you to re-call the same tool later is a net loss. Only ex
29
39
 
30
40
  NOTES
31
41
  When in doubt, keep it. Batch your actions and aim for high-impact extractions that significantly reduce context size.
32
- FAILURE TO EXTRACT will result in context leakage and DEGRADED PERFORMANCES.
33
- There may be tools in session context that do not appear in the <prunable-tools> list, this is expected, you can ONLY extract what you see in <prunable-tools>.
42
+ FAILURE TO EXTRACT will result in context leakage and DEGRADED PERFORMANCE.
34
43
 
35
44
  </instruction>
36
45
 
37
- <instruction name=injected_context_handling policy_level=critical>
38
- After each turn, the environment calls the \`context_info\` tool to inject a synthetic message containing a <prunable-tools> list and optional nudge instruction. This tool is only available to the environment - you do not have access to it.
39
-
46
+ <instruction name=extract_behavior policy_level=critical>
40
47
  CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:
41
- - NEVER reference the extract encouragement or context management instructions. Do not reply with "I agree" or "Great idea" when the extract encouragement appears.
42
- - NEVER acknowledge the <prunable-tools> list (e.g., "I see the prunable tools list", "Looking at the available tools to extract")
43
- - NEVER reference the nudge instruction (e.g., "As the nudge suggests", "The system is reminding me to extract")
44
48
  - NEVER acknowledge extract tool output (e.g., "I've extracted 3 tools", "Context cleanup complete")
45
- - NEVER let these injections influence your response content or tone
46
- - Process this information SILENTLY and continue the conversation naturally
47
- - Continue the conversation as if these messages do not exist
49
+ - NEVER let context management influence your response content or tone
50
+ - Process extractions SILENTLY and continue the conversation naturally
48
51
 
49
- The user cannot see these injections. Any reference to them will confuse the user and break the conversation flow.
52
+ The user cannot see extract operations. Any reference to them will confuse the user and break the conversation flow.
50
53
  </instruction>
51
54
  </system-reminder>`;
52
55
  //# sourceMappingURL=extract.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"extract.js","sourceRoot":"","sources":["../../../../lib/prompts/system/extract.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAkDlB,CAAA"}
1
+ {"version":3,"file":"extract.js","sourceRoot":"","sources":["../../../../lib/prompts/system/extract.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAqDlB,CAAA"}
@@ -47,7 +47,7 @@ export function matchesGlob(inputPath, pattern) {
47
47
  regex += "/";
48
48
  continue;
49
49
  }
50
- regex += escapeRegExpChar(ch);
50
+ regex += escapeRegExpChar(ch ?? "");
51
51
  }
52
52
  regex += "$";
53
53
  return new RegExp(regex).test(input);
@@ -1 +1 @@
1
- {"version":3,"file":"protected-file-patterns.js","sourceRoot":"","sources":["../../lib/protected-file-patterns.ts"],"names":[],"mappings":"AAAA,SAAS,aAAa,CAAC,KAAa;IAChC,OAAO,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AACxC,CAAC;AAED,SAAS,gBAAgB,CAAC,EAAU;IAChC,OAAO,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;AACxD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,SAAiB,EAAE,OAAe;IAC1D,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAA;IAE1B,MAAM,KAAK,GAAG,aAAa,CAAC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,OAAO,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAA;AACrF,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,QAA4B,EAAE,QAAkB;IAChF,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC3B,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IAEpD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAA;AACrE,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { Logger } from "./logger";
2
+ /**
3
+ * Safely execute a function with error boundary.
4
+ * If the function throws, logs the error and returns without crashing.
5
+ *
6
+ * @param fn - The function to execute
7
+ * @param logger - Logger instance for error reporting
8
+ * @param context - Description of what's being executed (for error messages)
9
+ */
10
+ export declare function safeExecute(fn: () => void, logger: Logger, context: string): void;
11
+ /**
12
+ * Safely execute an async function with error boundary.
13
+ * If the function throws, logs the error and returns without crashing.
14
+ *
15
+ * @param fn - The async function to execute
16
+ * @param logger - Logger instance for error reporting
17
+ * @param context - Description of what's being executed (for error messages)
18
+ */
19
+ export declare function safeExecuteAsync<T>(fn: () => Promise<T>, logger: Logger, context: string): Promise<T | undefined>;
20
+ //# sourceMappingURL=safe-execute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-execute.d.ts","sourceRoot":"","sources":["../../lib/safe-execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEtC;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAQjF;AAED;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACpC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAChB,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CASxB"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Safely execute a function with error boundary.
3
+ * If the function throws, logs the error and returns without crashing.
4
+ *
5
+ * @param fn - The function to execute
6
+ * @param logger - Logger instance for error reporting
7
+ * @param context - Description of what's being executed (for error messages)
8
+ */
9
+ export function safeExecute(fn, logger, context) {
10
+ try {
11
+ fn();
12
+ }
13
+ catch (error) {
14
+ const message = error instanceof Error ? error.message : String(error);
15
+ const stack = error instanceof Error ? error.stack : undefined;
16
+ logger.warn(`Strategy error in ${context}: ${message}`, { stack });
17
+ }
18
+ }
19
+ /**
20
+ * Safely execute an async function with error boundary.
21
+ * If the function throws, logs the error and returns without crashing.
22
+ *
23
+ * @param fn - The async function to execute
24
+ * @param logger - Logger instance for error reporting
25
+ * @param context - Description of what's being executed (for error messages)
26
+ */
27
+ export async function safeExecuteAsync(fn, logger, context) {
28
+ try {
29
+ return await fn();
30
+ }
31
+ catch (error) {
32
+ const message = error instanceof Error ? error.message : String(error);
33
+ const stack = error instanceof Error ? error.stack : undefined;
34
+ logger.warn(`Strategy error in ${context}: ${message}`, { stack });
35
+ return undefined;
36
+ }
37
+ }
38
+ //# sourceMappingURL=safe-execute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-execute.js","sourceRoot":"","sources":["../../lib/safe-execute.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,EAAc,EAAE,MAAc,EAAE,OAAe;IACvE,IAAI,CAAC;QACD,EAAE,EAAE,CAAA;IACR,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACtE,MAAM,KAAK,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;QAC9D,MAAM,CAAC,IAAI,CAAC,qBAAqB,OAAO,KAAK,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;IACtE,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAClC,EAAoB,EACpB,MAAc,EACd,OAAe;IAEf,IAAI,CAAC;QACD,OAAO,MAAM,EAAE,EAAE,CAAA;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACtE,MAAM,KAAK,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;QAC9D,MAAM,CAAC,IAAI,CAAC,qBAAqB,OAAO,KAAK,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;QAClE,OAAO,SAAS,CAAA;IACpB,CAAC;AACL,CAAC"}
@@ -5,7 +5,7 @@ export const isMessageCompacted = (state, msg) => {
5
5
  export const getLastUserMessage = (messages) => {
6
6
  for (let i = messages.length - 1; i >= 0; i--) {
7
7
  const msg = messages[i];
8
- if (msg.info.role === "user" && !isIgnoredUserMessage(msg)) {
8
+ if (msg && msg.info.role === "user" && !isIgnoredUserMessage(msg)) {
9
9
  return msg;
10
10
  }
11
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"shared-utils.js","sourceRoot":"","sources":["../../lib/shared-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM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M,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,EAAE,CAAC;YAChE,OAAO,GAAG,CAAA;QACd,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAA;AACf,CAAC,CAAA"}
@@ -2,14 +2,19 @@
2
2
  * State persistence module for ACP plugin.
3
3
  * Persists pruned tool IDs across sessions so they survive OpenCode restarts.
4
4
  * Storage location: ~/.local/share/opencode/storage/plugin/acp/{sessionId}.json
5
+ *
6
+ * Uses atomic writes (temp file + rename) to prevent data corruption.
5
7
  */
6
- import type { SessionState, SessionStats, Prune } from "./types";
8
+ import type { SessionState, SessionStats, Prune, DiscardStats } from "./types";
7
9
  import type { Logger } from "../logger";
8
10
  export interface PersistedSessionState {
9
11
  sessionName?: string;
10
12
  prune: Prune;
11
13
  stats: SessionStats;
12
14
  lastUpdated: string;
15
+ hashToCallId?: Record<string, string>;
16
+ callIdToHash?: Record<string, string>;
17
+ discardHistory?: DiscardStats[];
13
18
  }
14
19
  export declare function saveSessionState(sessionState: SessionState, logger: Logger, sessionName?: string): Promise<void>;
15
20
  export declare function loadSessionState(sessionId: string, logger: Logger): Promise<PersistedSessionState | null>;
@@ -1 +1 @@
1
- {"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../../lib/state/persistence.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAEvC,MAAM,WAAW,qBAAqB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,KAAK,CAAA;IACZ,KAAK,EAAE,YAAY,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;CACtB;AAcD,wBAAsB,gBAAgB,CAClC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,WAAW,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,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AAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;CACvB;AAED,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAqClF"}
@@ -2,12 +2,16 @@
2
2
  * State persistence module for ACP plugin.
3
3
  * Persists pruned tool IDs across sessions so they survive OpenCode restarts.
4
4
  * Storage location: ~/.local/share/opencode/storage/plugin/acp/{sessionId}.json
5
+ *
6
+ * Uses atomic writes (temp file + rename) to prevent data corruption.
5
7
  */
6
8
  import * as fs from "fs/promises";
7
9
  import { existsSync } from "fs";
8
10
  import { homedir } from "os";
9
11
  import { join } from "path";
10
12
  const STORAGE_DIR = join(homedir(), ".local", "share", "opencode", "storage", "plugin", "acp");
13
+ // Write lock to prevent concurrent writes to the same file
14
+ const writeLocks = new Map();
11
15
  async function ensureStorageDir() {
12
16
  if (!existsSync(STORAGE_DIR)) {
13
17
  await fs.mkdir(STORAGE_DIR, { recursive: true });
@@ -16,6 +20,53 @@ async function ensureStorageDir() {
16
20
  function getSessionFilePath(sessionId) {
17
21
  return join(STORAGE_DIR, `${sessionId}.json`);
18
22
  }
23
+ /**
24
+ * Atomically write content to a file using temp file + rename pattern.
25
+ * This prevents data corruption from partial writes or crashes.
26
+ */
27
+ async function atomicWriteFile(filePath, content) {
28
+ const tempPath = `${filePath}.tmp`;
29
+ try {
30
+ // Write to temp file first
31
+ await fs.writeFile(tempPath, content, "utf-8");
32
+ // Atomic rename (on POSIX systems, rename is atomic)
33
+ await fs.rename(tempPath, filePath);
34
+ }
35
+ catch (error) {
36
+ // Clean up temp file on failure
37
+ try {
38
+ await fs.unlink(tempPath);
39
+ }
40
+ catch {
41
+ // Ignore cleanup errors
42
+ }
43
+ throw error;
44
+ }
45
+ }
46
+ /**
47
+ * Acquire a write lock for a specific file path.
48
+ * Ensures only one write operation happens at a time per file.
49
+ */
50
+ async function withWriteLock(filePath, fn) {
51
+ // Wait for any existing write to complete
52
+ const existingLock = writeLocks.get(filePath);
53
+ if (existingLock) {
54
+ await existingLock.catch(() => { }); // Ignore errors from previous writes
55
+ }
56
+ // Create new lock
57
+ let resolve;
58
+ const lockPromise = new Promise((r) => {
59
+ resolve = r;
60
+ });
61
+ writeLocks.set(filePath, lockPromise);
62
+ try {
63
+ return await fn();
64
+ }
65
+ finally {
66
+ resolve();
67
+ writeLocks.delete(filePath);
68
+ }
69
+ }
19
70
  export async function saveSessionState(sessionState, logger, sessionName) {
20
71
  try {
21
72
  if (!sessionState.sessionId) {
@@ -27,10 +78,17 @@ export async function saveSessionState(sessionState, logger, sessionName) {
27
78
  prune: sessionState.prune,
28
79
  stats: sessionState.stats,
29
80
  lastUpdated: new Date().toISOString(),
81
+ // Hash-based discard system (convert Maps to objects)
82
+ hashToCallId: Object.fromEntries(sessionState.hashToCallId),
83
+ callIdToHash: Object.fromEntries(sessionState.callIdToHash),
84
+ discardHistory: sessionState.discardHistory,
30
85
  };
31
86
  const filePath = getSessionFilePath(sessionState.sessionId);
32
87
  const content = JSON.stringify(state, null, 2);
33
- await fs.writeFile(filePath, content, "utf-8");
88
+ // Use write lock and atomic write to prevent corruption
89
+ await withWriteLock(filePath, async () => {
90
+ await atomicWriteFile(filePath, content);
91
+ });
34
92
  logger.info("Saved session state to disk", {
35
93
  sessionId: sessionState.sessionId,
36
94
  totalTokensSaved: state.stats.totalPruneTokens,
@@ -1 +1 @@
1
- {"version":3,"file":"persistence.js","sourceRoot":"","sources":["../../../lib/state/persistence.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAW3B,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,E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