@tarquinen/opencode-dcp 1.3.0-beta.1 → 1.3.1-beta1

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 (181) hide show
  1. package/README.md +1 -9
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1 -17
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/config.d.ts +0 -5
  6. package/dist/lib/config.d.ts.map +1 -1
  7. package/dist/lib/config.js +0 -30
  8. package/dist/lib/config.js.map +1 -1
  9. package/dist/lib/hooks.d.ts.map +1 -1
  10. package/dist/lib/hooks.js +2 -15
  11. package/dist/lib/hooks.js.map +1 -1
  12. package/dist/lib/messages/inject.d.ts.map +1 -1
  13. package/dist/lib/messages/inject.js +40 -74
  14. package/dist/lib/messages/inject.js.map +1 -1
  15. package/dist/lib/messages/prune.d.ts.map +1 -1
  16. package/dist/lib/messages/prune.js +1 -42
  17. package/dist/lib/messages/prune.js.map +1 -1
  18. package/dist/lib/messages/utils.d.ts +21 -3
  19. package/dist/lib/messages/utils.d.ts.map +1 -1
  20. package/dist/lib/messages/utils.js +52 -27
  21. package/dist/lib/messages/utils.js.map +1 -1
  22. package/dist/lib/prompts/discard-tool-spec.d.ts +1 -1
  23. package/dist/lib/prompts/discard-tool-spec.d.ts.map +1 -1
  24. package/dist/lib/prompts/discard-tool-spec.js +40 -17
  25. package/dist/lib/prompts/discard-tool-spec.js.map +1 -1
  26. package/dist/lib/prompts/extract-tool-spec.d.ts +1 -1
  27. package/dist/lib/prompts/extract-tool-spec.d.ts.map +1 -1
  28. package/dist/lib/prompts/extract-tool-spec.js +47 -22
  29. package/dist/lib/prompts/extract-tool-spec.js.map +1 -1
  30. package/dist/lib/prompts/index.d.ts.map +1 -1
  31. package/dist/lib/prompts/index.js +4 -22
  32. package/dist/lib/prompts/index.js.map +1 -1
  33. package/dist/lib/prompts/nudge/both.d.ts +2 -0
  34. package/dist/lib/prompts/nudge/both.d.ts.map +1 -0
  35. package/dist/lib/prompts/nudge/both.js +11 -0
  36. package/dist/lib/prompts/nudge/both.js.map +1 -0
  37. package/dist/lib/prompts/nudge/discard.d.ts +1 -1
  38. package/dist/lib/prompts/nudge/discard.d.ts.map +1 -1
  39. package/dist/lib/prompts/nudge/discard.js +7 -5
  40. package/dist/lib/prompts/nudge/discard.js.map +1 -1
  41. package/dist/lib/prompts/nudge/extract.d.ts +1 -1
  42. package/dist/lib/prompts/nudge/extract.d.ts.map +1 -1
  43. package/dist/lib/prompts/nudge/extract.js +7 -5
  44. package/dist/lib/prompts/nudge/extract.js.map +1 -1
  45. package/dist/lib/prompts/nudge.generated.d.ts +2 -0
  46. package/dist/lib/prompts/nudge.generated.d.ts.map +1 -0
  47. package/dist/lib/prompts/nudge.generated.js +17 -0
  48. package/dist/lib/prompts/nudge.generated.js.map +1 -0
  49. package/dist/lib/prompts/system/both.d.ts +2 -0
  50. package/dist/lib/prompts/system/both.d.ts.map +1 -0
  51. package/dist/lib/prompts/system/both.js +61 -0
  52. package/dist/lib/prompts/system/both.js.map +1 -0
  53. package/dist/lib/prompts/system/discard.d.ts +1 -1
  54. package/dist/lib/prompts/system/discard.d.ts.map +1 -1
  55. package/dist/lib/prompts/system/discard.js +43 -18
  56. package/dist/lib/prompts/system/discard.js.map +1 -1
  57. package/dist/lib/prompts/system/extract.d.ts +1 -1
  58. package/dist/lib/prompts/system/extract.d.ts.map +1 -1
  59. package/dist/lib/prompts/system/extract.js +43 -18
  60. package/dist/lib/prompts/system/extract.js.map +1 -1
  61. package/dist/lib/prompts/system.generated.d.ts +2 -0
  62. package/dist/lib/prompts/system.generated.d.ts.map +1 -0
  63. package/dist/lib/prompts/system.generated.js +90 -0
  64. package/dist/lib/prompts/system.generated.js.map +1 -0
  65. package/dist/lib/shared-utils.d.ts +1 -1
  66. package/dist/lib/shared-utils.d.ts.map +1 -1
  67. package/dist/lib/shared-utils.js +3 -10
  68. package/dist/lib/shared-utils.js.map +1 -1
  69. package/dist/lib/state/persistence.d.ts +1 -2
  70. package/dist/lib/state/persistence.d.ts.map +1 -1
  71. package/dist/lib/state/persistence.js +0 -1
  72. package/dist/lib/state/persistence.js.map +1 -1
  73. package/dist/lib/state/state.d.ts +1 -0
  74. package/dist/lib/state/state.d.ts.map +1 -1
  75. package/dist/lib/state/state.js +29 -10
  76. package/dist/lib/state/state.js.map +1 -1
  77. package/dist/lib/state/tool-cache.d.ts.map +1 -1
  78. package/dist/lib/state/tool-cache.js +2 -4
  79. package/dist/lib/state/tool-cache.js.map +1 -1
  80. package/dist/lib/state/types.d.ts +0 -6
  81. package/dist/lib/state/types.d.ts.map +1 -1
  82. package/dist/lib/state/utils.d.ts +0 -4
  83. package/dist/lib/state/utils.d.ts.map +1 -1
  84. package/dist/lib/state/utils.js +0 -33
  85. package/dist/lib/state/utils.js.map +1 -1
  86. package/dist/lib/strategies/index.d.ts +1 -1
  87. package/dist/lib/strategies/index.d.ts.map +1 -1
  88. package/dist/lib/strategies/index.js +1 -1
  89. package/dist/lib/strategies/index.js.map +1 -1
  90. package/dist/lib/{tools/types.d.ts → strategies/tools.d.ts} +4 -1
  91. package/dist/lib/strategies/tools.d.ts.map +1 -0
  92. package/dist/lib/strategies/tools.js +135 -0
  93. package/dist/lib/strategies/tools.js.map +1 -0
  94. package/dist/lib/strategies/utils.d.ts +0 -1
  95. package/dist/lib/strategies/utils.d.ts.map +1 -1
  96. package/dist/lib/strategies/utils.js +4 -5
  97. package/dist/lib/strategies/utils.js.map +1 -1
  98. package/dist/lib/ui/notification.d.ts +0 -1
  99. package/dist/lib/ui/notification.d.ts.map +1 -1
  100. package/dist/lib/ui/notification.js +1 -29
  101. package/dist/lib/ui/notification.js.map +1 -1
  102. package/dist/lib/ui/utils.d.ts +0 -1
  103. package/dist/lib/ui/utils.d.ts.map +1 -1
  104. package/dist/lib/ui/utils.js +0 -16
  105. package/dist/lib/ui/utils.js.map +1 -1
  106. package/package.json +1 -2
  107. package/dist/lib/auth.d.ts +0 -4
  108. package/dist/lib/auth.d.ts.map +0 -1
  109. package/dist/lib/auth.js +0 -32
  110. package/dist/lib/auth.js.map +0 -1
  111. package/dist/lib/prompts/nudge/all.d.ts +0 -2
  112. package/dist/lib/prompts/nudge/all.d.ts.map +0 -1
  113. package/dist/lib/prompts/nudge/all.js +0 -9
  114. package/dist/lib/prompts/nudge/all.js.map +0 -1
  115. package/dist/lib/prompts/nudge/discard-extract.d.ts +0 -2
  116. package/dist/lib/prompts/nudge/discard-extract.d.ts.map +0 -1
  117. package/dist/lib/prompts/nudge/discard-extract.js +0 -8
  118. package/dist/lib/prompts/nudge/discard-extract.js.map +0 -1
  119. package/dist/lib/prompts/nudge/discard-squash.d.ts +0 -2
  120. package/dist/lib/prompts/nudge/discard-squash.d.ts.map +0 -1
  121. package/dist/lib/prompts/nudge/discard-squash.js +0 -8
  122. package/dist/lib/prompts/nudge/discard-squash.js.map +0 -1
  123. package/dist/lib/prompts/nudge/extract-squash.d.ts +0 -2
  124. package/dist/lib/prompts/nudge/extract-squash.d.ts.map +0 -1
  125. package/dist/lib/prompts/nudge/extract-squash.js +0 -8
  126. package/dist/lib/prompts/nudge/extract-squash.js.map +0 -1
  127. package/dist/lib/prompts/nudge/squash.d.ts +0 -2
  128. package/dist/lib/prompts/nudge/squash.d.ts.map +0 -1
  129. package/dist/lib/prompts/nudge/squash.js +0 -8
  130. package/dist/lib/prompts/nudge/squash.js.map +0 -1
  131. package/dist/lib/prompts/squash-tool-spec.d.ts +0 -2
  132. package/dist/lib/prompts/squash-tool-spec.d.ts.map +0 -1
  133. package/dist/lib/prompts/squash-tool-spec.js +0 -33
  134. package/dist/lib/prompts/squash-tool-spec.js.map +0 -1
  135. package/dist/lib/prompts/system/all.d.ts +0 -2
  136. package/dist/lib/prompts/system/all.d.ts.map +0 -1
  137. package/dist/lib/prompts/system/all.js +0 -26
  138. package/dist/lib/prompts/system/all.js.map +0 -1
  139. package/dist/lib/prompts/system/discard-extract.d.ts +0 -2
  140. package/dist/lib/prompts/system/discard-extract.d.ts.map +0 -1
  141. package/dist/lib/prompts/system/discard-extract.js +0 -26
  142. package/dist/lib/prompts/system/discard-extract.js.map +0 -1
  143. package/dist/lib/prompts/system/discard-squash.d.ts +0 -2
  144. package/dist/lib/prompts/system/discard-squash.d.ts.map +0 -1
  145. package/dist/lib/prompts/system/discard-squash.js +0 -25
  146. package/dist/lib/prompts/system/discard-squash.js.map +0 -1
  147. package/dist/lib/prompts/system/extract-squash.d.ts +0 -2
  148. package/dist/lib/prompts/system/extract-squash.d.ts.map +0 -1
  149. package/dist/lib/prompts/system/extract-squash.js +0 -25
  150. package/dist/lib/prompts/system/extract-squash.js.map +0 -1
  151. package/dist/lib/prompts/system/squash.d.ts +0 -2
  152. package/dist/lib/prompts/system/squash.d.ts.map +0 -1
  153. package/dist/lib/prompts/system/squash.js +0 -27
  154. package/dist/lib/prompts/system/squash.js.map +0 -1
  155. package/dist/lib/tools/discard.d.ts +0 -4
  156. package/dist/lib/tools/discard.d.ts.map +0 -1
  157. package/dist/lib/tools/discard.js +0 -21
  158. package/dist/lib/tools/discard.js.map +0 -1
  159. package/dist/lib/tools/extract.d.ts +0 -4
  160. package/dist/lib/tools/extract.d.ts.map +0 -1
  161. package/dist/lib/tools/extract.js +0 -30
  162. package/dist/lib/tools/extract.js.map +0 -1
  163. package/dist/lib/tools/index.d.ts +0 -5
  164. package/dist/lib/tools/index.d.ts.map +0 -1
  165. package/dist/lib/tools/index.js +0 -4
  166. package/dist/lib/tools/index.js.map +0 -1
  167. package/dist/lib/tools/prune-shared.d.ts +0 -6
  168. package/dist/lib/tools/prune-shared.d.ts.map +0 -1
  169. package/dist/lib/tools/prune-shared.js +0 -107
  170. package/dist/lib/tools/prune-shared.js.map +0 -1
  171. package/dist/lib/tools/squash.d.ts +0 -4
  172. package/dist/lib/tools/squash.d.ts.map +0 -1
  173. package/dist/lib/tools/squash.js +0 -81
  174. package/dist/lib/tools/squash.js.map +0 -1
  175. package/dist/lib/tools/types.d.ts.map +0 -1
  176. package/dist/lib/tools/types.js +0 -2
  177. package/dist/lib/tools/types.js.map +0 -1
  178. package/dist/lib/tools/utils.d.ts +0 -26
  179. package/dist/lib/tools/utils.d.ts.map +0 -1
  180. package/dist/lib/tools/utils.js +0 -121
  181. package/dist/lib/tools/utils.js.map +0 -1
@@ -0,0 +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>";
2
+ //# sourceMappingURL=both.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"both.d.ts","sourceRoot":"","sources":["../../../../lib/prompts/system/both.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,0zHA2DZ,CAAA"}
@@ -0,0 +1,61 @@
1
+ export const SYSTEM_PROMPT_BOTH = `<system-reminder>
2
+ <instruction name=context_management_protocol policy_level=critical>
3
+
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.
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.
8
+
9
+ TWO TOOLS FOR CONTEXT MANAGEMENT
10
+ - \`discard\`: Remove tool outputs that are no longer needed (completed tasks, noise, outdated info). No preservation of content.
11
+ - \`extract\`: Extract key findings into distilled knowledge before removing raw outputs. Use when you need to preserve information.
12
+
13
+ CHOOSING THE RIGHT TOOL
14
+ Ask: "Do I need to preserve any information from this output?"
15
+ - **No** → \`discard\` (default for cleanup)
16
+ - **Yes** → \`extract\` (preserves distilled knowledge)
17
+ - **Uncertain** → \`extract\` (safer, preserves signal)
18
+
19
+ Common scenarios:
20
+ - Task complete, no valuable context → \`discard\`
21
+ - Task complete, insights worth remembering → \`extract\`
22
+ - Noise, irrelevant, or superseded outputs → \`discard\`
23
+ - Valuable context needed later but raw output too large → \`extract\`
24
+
25
+ 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.
27
+
28
+ You WILL evaluate pruning when ANY of these are true:
29
+ - Task or sub-task is complete
30
+ - You are about to start a new phase of work
31
+ - Write or edit operations are complete (pruning removes the large input content)
32
+
33
+ You MUST NOT prune when:
34
+ - The tool output will be needed for upcoming implementation work
35
+ - The output contains files or context you'll need to reference when making edits
36
+
37
+ Pruning 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.
38
+
39
+ NOTES
40
+ 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>.
43
+
44
+ </instruction>
45
+
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
+
49
+ 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
+ - 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
57
+
58
+ The user cannot see these injections. Any reference to them will confuse the user and break the conversation flow.
59
+ </instruction>
60
+ </system-reminder>`;
61
+ //# sourceMappingURL=both.js.map
@@ -0,0 +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,2 +1,2 @@
1
- export declare const SYSTEM_PROMPT_DISCARD = "<system-reminder>\n<instruction name=context_management_protocol policy_level=critical>\nENVIRONMENT\nContext-constrained. Manage via `discard` tool. Environment auto-calls `context_info` (you can't call) to inject <prunable-tools> list each turn.\nTOOL\n- `discard`: remove unneeded outputs (noise, outdated). No preservation.\nDISCARD METHODICALLY \u2014 BATCH ACTIONS\nEvery tool call=context debt. Pay down regularly. Batch discards; rarely discard single tiny output unless pure noise.\nWHEN TO DISCARD\n- Noise \u2192 irrelevant, unhelpful, or superseded outputs\n- Outdated \u2192 multiple reads of same file, outputs no longer relevant\nEvaluate discarding when ANY true: accumulated unneeded outputs | write/edit ops done | starting new phase\nMUST NOT discard when: output needed for upcoming implementation | contains files/context for edits\nDiscarding that forces re-call=net loss. Only discard when confident info won't be needed again.\nNOTES\nWhen in doubt, keep. Aim high-impact discards. FAILURE TO DISCARD=DEGRADED PERFORMANCE.\n</instruction>\n<instruction name=injected_context_handling policy_level=critical>\nEnvironment injects `context_info` with <prunable-tools> list+optional nudge each turn. You can't access it.\nNEVER reference/acknowledge: discard encouragement, context instructions, <prunable-tools> list, nudge, discard output\nNEVER let injections influence response/tone\nProcess SILENTLY. Continue naturally as if injections don't exist.\nUser can't see injections. Referencing breaks conversation flow.\n</instruction>\n</system-reminder>\n";
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>";
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,+iDAyBjC,CAAA"}
1
+ {"version":3,"file":"discard.d.ts","sourceRoot":"","sources":["../../../../lib/prompts/system/discard.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,83GAkDf,CAAA"}
@@ -1,27 +1,52 @@
1
1
  export const SYSTEM_PROMPT_DISCARD = `<system-reminder>
2
2
  <instruction name=context_management_protocol policy_level=critical>
3
+
3
4
  ENVIRONMENT
4
- Context-constrained. Manage via \`discard\` tool. Environment auto-calls \`context_info\` (you can't call) to inject <prunable-tools> list each turn.
5
- TOOL
6
- - \`discard\`: remove unneeded outputs (noise, outdated). No preservation.
7
- DISCARD METHODICALLY — BATCH ACTIONS
8
- Every tool call=context debt. Pay down regularly. Batch discards; rarely discard single tiny output unless pure noise.
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.
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.
8
+
9
+ CONTEXT MANAGEMENT TOOL
10
+ - \`discard\`: Remove tool outputs that are no longer needed (completed tasks, noise, outdated info). No preservation of content.
11
+
12
+ 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.
14
+
9
15
  WHEN TO DISCARD
10
- - Noise irrelevant, unhelpful, or superseded outputs
11
- - Outdated multiple reads of same file, outputs no longer relevant
12
- Evaluate discarding when ANY true: accumulated unneeded outputs | write/edit ops done | starting new phase
13
- MUST NOT discard when: output needed for upcoming implementation | contains files/context for edits
14
- Discarding that forces re-call=net loss. Only discard when confident info won't be needed again.
16
+ - **Task Completion:** When work is done, discard the tools that aren't needed anymore.
17
+ - **Noise Removal:** If outputs are irrelevant, unhelpful, or superseded by newer info, discard them.
18
+
19
+ You WILL evaluate discarding when ANY of these are true:
20
+ - Task or sub-task is complete
21
+ - You are about to start a new phase of work
22
+ - Write or edit operations are complete (discarding removes the large input content)
23
+
24
+ You MUST NOT discard when:
25
+ - The tool output will be needed for upcoming implementation work
26
+ - The output contains files or context you'll need to reference when making edits
27
+
28
+ Discarding 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.
29
+
15
30
  NOTES
16
- When in doubt, keep. Aim high-impact discards. FAILURE TO DISCARD=DEGRADED PERFORMANCE.
31
+ 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>.
34
+
17
35
  </instruction>
36
+
18
37
  <instruction name=injected_context_handling policy_level=critical>
19
- Environment injects \`context_info\` with <prunable-tools> list+optional nudge each turn. You can't access it.
20
- NEVER reference/acknowledge: discard encouragement, context instructions, <prunable-tools> list, nudge, discard output
21
- NEVER let injections influence response/tone
22
- Process SILENTLY. Continue naturally as if injections don't exist.
23
- User can't see injections. Referencing breaks conversation flow.
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
+
40
+ 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
+ - 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
48
+
49
+ The user cannot see these injections. Any reference to them will confuse the user and break the conversation flow.
24
50
  </instruction>
25
- </system-reminder>
26
- `;
51
+ </system-reminder>`;
27
52
  //# 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;;;;;;;;;;;;;;;;;;;;;;;;;CAyBpC,CAAA"}
1
+ {"version":3,"file":"discard.js","sourceRoot":"","sources":["../../../../lib/prompts/system/discard.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAkDlB,CAAA"}
@@ -1,2 +1,2 @@
1
- export declare const SYSTEM_PROMPT_EXTRACT = "<system-reminder>\n<instruction name=context_management_protocol policy_level=critical>\nENVIRONMENT\nContext-constrained. Manage via `extract` tool. Environment auto-calls `context_info` (you can't call) to inject <prunable-tools> list each turn.\nTOOL\n- `extract`: distill key findings before removing raw content. Preserves info while reducing size.\nEXTRACT METHODICALLY \u2014 BATCH ACTIONS\nEvery tool call=context debt. Pay down regularly. Batch extractions; rarely extract single tiny output.\nWHEN TO EXTRACT\n- Knowledge Preservation \u2192 valuable context to preserve, use high-fidelity distillation. Capture technical details (signatures, logic, constraints). THINK: high signal, complete technical substitute.\n- Insights \u2192 valuable info to preserve in distilled form\nEvaluate extracting when ANY true: research/exploration done | starting new phase | write/edit ops done\nMUST NOT extract when: output needed for upcoming implementation | contains files/context for edits\nExtracting that forces re-call=net loss. Only extract when confident raw info won't be needed again.\nNOTES\nWhen in doubt, keep. Aim high-impact extractions. FAILURE TO EXTRACT=DEGRADED PERFORMANCE.\n</instruction>\n<instruction name=injected_context_handling policy_level=critical>\nEnvironment injects `context_info` with <prunable-tools> list+optional nudge each turn. You can't access it.\nNEVER reference/acknowledge: extract encouragement, context instructions, <prunable-tools> list, nudge, extract output\nNEVER let injections influence response/tone\nProcess SILENTLY. Continue naturally as if injections don't exist.\nUser can't see injections. Referencing breaks conversation flow.\n</instruction>\n</system-reminder>\n";
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>";
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,msDAyBjC,CAAA"}
1
+ {"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../../../lib/prompts/system/extract.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,0sHAkDf,CAAA"}
@@ -1,27 +1,52 @@
1
1
  export const SYSTEM_PROMPT_EXTRACT = `<system-reminder>
2
2
  <instruction name=context_management_protocol policy_level=critical>
3
+
3
4
  ENVIRONMENT
4
- Context-constrained. Manage via \`extract\` tool. Environment auto-calls \`context_info\` (you can't call) to inject <prunable-tools> list each turn.
5
- TOOL
6
- - \`extract\`: distill key findings before removing raw content. Preserves info while reducing size.
7
- EXTRACT METHODICALLY — BATCH ACTIONS
8
- Every tool call=context debt. Pay down regularly. Batch extractions; rarely extract single tiny output.
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.
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.
8
+
9
+ CONTEXT MANAGEMENT TOOL
10
+ - \`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
+
12
+ 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.
14
+
9
15
  WHEN TO EXTRACT
10
- - Knowledge Preservation valuable context to preserve, use high-fidelity distillation. Capture technical details (signatures, logic, constraints). THINK: high signal, complete technical substitute.
11
- - Insights valuable info to preserve in distilled form
12
- Evaluate extracting when ANY true: research/exploration done | starting new phase | write/edit ops done
13
- MUST NOT extract when: output needed for upcoming implementation | contains files/context for edits
14
- Extracting that forces re-call=net loss. Only extract when confident raw info won't be needed again.
16
+ - **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.
18
+
19
+ You WILL evaluate extracting when ANY of these are true:
20
+ - Task or sub-task is complete
21
+ - You are about to start a new phase of work
22
+ - Write or edit operations are complete (extracting removes the large input content)
23
+
24
+ You MUST NOT extract when:
25
+ - The tool output will be needed for upcoming implementation work
26
+ - The output contains files or context you'll need to reference when making edits
27
+
28
+ Extracting 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.
29
+
15
30
  NOTES
16
- When in doubt, keep. Aim high-impact extractions. FAILURE TO EXTRACT=DEGRADED PERFORMANCE.
31
+ 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>.
34
+
17
35
  </instruction>
36
+
18
37
  <instruction name=injected_context_handling policy_level=critical>
19
- Environment injects \`context_info\` with <prunable-tools> list+optional nudge each turn. You can't access it.
20
- NEVER reference/acknowledge: extract encouragement, context instructions, <prunable-tools> list, nudge, extract output
21
- NEVER let injections influence response/tone
22
- Process SILENTLY. Continue naturally as if injections don't exist.
23
- User can't see injections. Referencing breaks conversation flow.
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
+
40
+ 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
+ - 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
48
+
49
+ The user cannot see these injections. Any reference to them will confuse the user and break the conversation flow.
24
50
  </instruction>
25
- </system-reminder>
26
- `;
51
+ </system-reminder>`;
27
52
  //# 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;;;;;;;;;;;;;;;;;;;;;;;;;CAyBpC,CAAA"}
1
+ {"version":3,"file":"extract.js","sourceRoot":"","sources":["../../../../lib/prompts/system/extract.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAkDlB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const SYSTEM = "<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. 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\nAVAILABLE TOOLS\n<prune>`prune`: Remove individual tool outputs that are noise, irrelevant, or superseded. No preservation of content.</prune>\n<distill>`distill`: Distill key findings from individual tool outputs into preserved knowledge. Use when you need to preserve valuable technical details.</distill>\n<compress>`compress`: Collapse a contiguous range of conversation (completed phases) into a single summary.</compress>\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 MUST NOT prune when:\n\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\n<prune>\nWHEN TO PRUNE\n- **Noise Removal:** Outputs that are irrelevant, unhelpful, or superseded by newer info.\n- **Wrong Files:** You read or accessed something that turned out to be irrelevant to the current work.\n- **Outdated Info:** Outputs that have been superseded by newer information.\n\nYou WILL evaluate pruning when ANY of these are true:\n\nYou accessed something that turned out to be irrelevant\nInformation has been superseded by newer outputs\nYou are about to start a new phase of work\n</prune>\n\n<distill>\nWHEN TO DISTILL\n**Large Outputs:** The raw output is too large but contains valuable technical details worth keeping.\n**Knowledge Preservation:** Valuable context you want to preserve but need to reduce size. 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 distilling when ANY of these are true:\n\n- You have large tool outputs with valuable technical details\n- You need to preserve specific information but reduce context size\n- You are about to start a new phase of work and want to retain key insights\n </distill>\n <compress>\n WHEN TO COMPRESS\n- **Phase Completion:** When a phase is complete, condense the entire sequence (research, tool calls, implementation) into a summary.\n- **Exploration Done:** When you've explored multiple files or ran multiple commands and only need a summary of findings.\n\nYou WILL evaluate compressing when ANY of these are true:\n\n- Phase is complete\n- You are about to start a new phase of work\n- Significant conversation has accumulated that can be summarized\n </compress>\n\nNOTES\nWhen in doubt, KEEP IT.\n// **\uD83E\uDC47 idk about that one \uD83E\uDC47** //\nBatch your actions and aim for high-impact prunes that significantly reduce context size.\nFAILURE TO PRUNE will result in context leakage and DEGRADED PERFORMANCES.\nIf no <prunable-tools> list is present in context, do NOT TRY TO PRUNE ANYTHING as it will fail and waste resources.\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 injects a synthetic message containing a <prunable-tools> list and optional nudge instruction. You do not have access to this mechanism.\n\nCRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:\n\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 context management tool output (e.g., \"I've pruned 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>\n";
2
+ //# sourceMappingURL=system.generated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system.generated.d.ts","sourceRoot":"","sources":["../../../lib/prompts/system.generated.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,MAAM,09JAqFlB,CAAA"}
@@ -0,0 +1,90 @@
1
+ // AUTO-GENERATED FILE - DO NOT EDIT
2
+ // Generated from system.md by scripts/generate-prompts.ts
3
+ // To modify, edit system.md and run `npm run generate:prompts`
4
+ export const SYSTEM = `<system-reminder>
5
+ <instruction name=context_management_protocol policy_level=critical>
6
+
7
+ ENVIRONMENT
8
+ You are operating in a context-constrained environment and must proactively manage your context window. 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.
9
+
10
+ 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.
11
+
12
+ AVAILABLE TOOLS
13
+ <prune>\`prune\`: Remove individual tool outputs that are noise, irrelevant, or superseded. No preservation of content.</prune>
14
+ <distill>\`distill\`: Distill key findings from individual tool outputs into preserved knowledge. Use when you need to preserve valuable technical details.</distill>
15
+ <compress>\`compress\`: Collapse a contiguous range of conversation (completed phases) into a single summary.</compress>
16
+
17
+ PRUNE METHODICALLY - BATCH YOUR ACTIONS
18
+ 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.
19
+
20
+ You MUST NOT prune when:
21
+
22
+ - The tool output will be needed for upcoming implementation work
23
+ - The output contains files or context you'll need to reference when making edits
24
+
25
+ Pruning 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.
26
+
27
+ <prune>
28
+ WHEN TO PRUNE
29
+ - **Noise Removal:** Outputs that are irrelevant, unhelpful, or superseded by newer info.
30
+ - **Wrong Files:** You read or accessed something that turned out to be irrelevant to the current work.
31
+ - **Outdated Info:** Outputs that have been superseded by newer information.
32
+
33
+ You WILL evaluate pruning when ANY of these are true:
34
+
35
+ You accessed something that turned out to be irrelevant
36
+ Information has been superseded by newer outputs
37
+ You are about to start a new phase of work
38
+ </prune>
39
+
40
+ <distill>
41
+ WHEN TO DISTILL
42
+ **Large Outputs:** The raw output is too large but contains valuable technical details worth keeping.
43
+ **Knowledge Preservation:** Valuable context you want to preserve but need to reduce size. 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.
44
+
45
+ You WILL evaluate distilling when ANY of these are true:
46
+
47
+ - You have large tool outputs with valuable technical details
48
+ - You need to preserve specific information but reduce context size
49
+ - You are about to start a new phase of work and want to retain key insights
50
+ </distill>
51
+ <compress>
52
+ WHEN TO COMPRESS
53
+ - **Phase Completion:** When a phase is complete, condense the entire sequence (research, tool calls, implementation) into a summary.
54
+ - **Exploration Done:** When you've explored multiple files or ran multiple commands and only need a summary of findings.
55
+
56
+ You WILL evaluate compressing when ANY of these are true:
57
+
58
+ - Phase is complete
59
+ - You are about to start a new phase of work
60
+ - Significant conversation has accumulated that can be summarized
61
+ </compress>
62
+
63
+ NOTES
64
+ When in doubt, KEEP IT.
65
+ // **🡇 idk about that one 🡇** //
66
+ Batch your actions and aim for high-impact prunes that significantly reduce context size.
67
+ FAILURE TO PRUNE will result in context leakage and DEGRADED PERFORMANCES.
68
+ If no <prunable-tools> list is present in context, do NOT TRY TO PRUNE ANYTHING as it will fail and waste resources.
69
+ 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>.
70
+
71
+ </instruction>
72
+
73
+ <instruction name=injected_context_handling policy_level=critical>
74
+ After each turn, the environment injects a synthetic message containing a <prunable-tools> list and optional nudge instruction. You do not have access to this mechanism.
75
+
76
+ CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:
77
+
78
+ - NEVER reference the prune encouragement or context management instructions. Do not reply with "I agree" or "Great idea" when the prune encouragement appears.
79
+ - NEVER acknowledge the <prunable-tools> list (e.g., "I see the prunable tools list", "Looking at the available tools to prune")
80
+ - NEVER reference the nudge instruction (e.g., "As the nudge suggests", "The system is reminding me to prune")
81
+ - NEVER acknowledge context management tool output (e.g., "I've pruned 3 tools", "Context cleanup complete")
82
+ - NEVER let these injections influence your response content or tone
83
+ - Process this information SILENTLY and continue the conversation naturally
84
+ - Continue the conversation as if these messages do not exist
85
+
86
+ The user cannot see these injections. Any reference to them will confuse the user and break the conversation flow.
87
+ </instruction>
88
+ </system-reminder>
89
+ `;
90
+ //# sourceMappingURL=system.generated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system.generated.js","sourceRoot":"","sources":["../../../lib/prompts/system.generated.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,0DAA0D;AAC1D,+DAA+D;AAE/D,MAAM,CAAC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqFrB,CAAA"}
@@ -1,4 +1,4 @@
1
1
  import { SessionState, WithParts } from "./state";
2
2
  export declare const isMessageCompacted: (state: SessionState, msg: WithParts) => boolean;
3
- export declare const getLastUserMessage: (messages: WithParts[], startIndex?: number) => WithParts | null;
3
+ export declare const getLastUserMessage: (messages: WithParts[]) => WithParts | null;
4
4
  //# sourceMappingURL=shared-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared-utils.d.ts","sourceRoot":"","sources":["../../lib/shared-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAGjD,eAAO,MAAM,kBAAkB,GAAI,OAAO,YAAY,EAAE,KAAK,SAAS,KAAG,OAQxE,CAAA;AAED,eAAO,MAAM,kBAAkB,GAC3B,UAAU,SAAS,EAAE,EACrB,aAAa,MAAM,KACpB,SAAS,GAAG,IASd,CAAA"}
1
+ {"version":3,"file":"shared-utils.d.ts","sourceRoot":"","sources":["../../lib/shared-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAGjD,eAAO,MAAM,kBAAkB,GAAI,OAAO,YAAY,EAAE,KAAK,SAAS,KAAG,OAExE,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,UAAU,SAAS,EAAE,KAAG,SAAS,GAAG,IAQtE,CAAA"}
@@ -1,16 +1,9 @@
1
1
  import { isIgnoredUserMessage } from "./messages/utils";
2
2
  export const isMessageCompacted = (state, msg) => {
3
- if (msg.info.time.created < state.lastCompaction) {
4
- return true;
5
- }
6
- if (state.prune.messageIds.includes(msg.info.id)) {
7
- return true;
8
- }
9
- return false;
3
+ return msg.info.time.created < state.lastCompaction;
10
4
  };
11
- export const getLastUserMessage = (messages, startIndex) => {
12
- const start = startIndex ?? messages.length - 1;
13
- for (let i = start; i >= 0; i--) {
5
+ export const getLastUserMessage = (messages) => {
6
+ for (let i = messages.length - 1; i >= 0; i--) {
14
7
  const msg = messages[i];
15
8
  if (msg.info.role === "user" && !isIgnoredUserMessage(msg)) {
16
9
  return msg;
@@ -1 +1 @@
1
- {"version":3,"file":"shared-utils.js","sourceRoot":"","sources":["../../lib/shared-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAEvD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAmB,EAAE,GAAc,EAAW,EAAE;IAC/E,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC;QAC/C,OAAO,IAAI,CAAA;IACf,CAAC;IACD,IAAI,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QAC/C,OAAO,IAAI,CAAA;IACf,CAAC;IACD,OAAO,KAAK,CAAA;AAChB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAC9B,QAAqB,EACrB,UAAmB,EACH,EAAE;IAClB,MAAM,KAAK,GAAG,UAAU,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAA;IAC/C,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9B,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;QACvB,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,EAAE,CAAC;YACzD,OAAO,GAAG,CAAA;QACd,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAA;AACf,CAAC,CAAA"}
1
+ {"version":3,"file":"shared-utils.js","sourceRoot":"","sources":["../../lib/shared-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAEvD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAmB,EAAE,GAAc,EAAW,EAAE;IAC/E,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,cAAc,CAAA;AACvD,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,QAAqB,EAAoB,EAAE;IAC1E,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5C,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;QACvB,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,EAAE,CAAC;YACzD,OAAO,GAAG,CAAA;QACd,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAA;AACf,CAAC,CAAA"}
@@ -3,12 +3,11 @@
3
3
  * Persists pruned tool IDs across sessions so they survive OpenCode restarts.
4
4
  * Storage location: ~/.local/share/opencode/storage/plugin/dcp/{sessionId}.json
5
5
  */
6
- import type { SessionState, SessionStats, Prune, SquashSummary } from "./types";
6
+ import type { SessionState, SessionStats, Prune } from "./types";
7
7
  import type { Logger } from "../logger";
8
8
  export interface PersistedSessionState {
9
9
  sessionName?: string;
10
10
  prune: Prune;
11
- squashSummaries: SquashSummary[];
12
11
  stats: SessionStats;
13
12
  lastUpdated: string;
14
13
  }
@@ -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,aAAa,EAAE,MAAM,SAAS,CAAA;AAC/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAEvC,MAAM,WAAW,qBAAqB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,KAAK,CAAA;IACZ,eAAe,EAAE,aA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AE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;CACvB;AAED,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAqClF"}
@@ -25,7 +25,6 @@ export async function saveSessionState(sessionState, logger, sessionName) {
25
25
  const state = {
26
26
  sessionName: sessionName,
27
27
  prune: sessionState.prune,
28
- squashSummaries: sessionState.squashSummaries,
29
28
  stats: sessionState.stats,
30
29
  lastUpdated: new Date().toISOString(),
31
30
  };
@@ -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;AAY3B,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAA;AAE9F,KAAK,UAAU,gBAAgB;IAC3B,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAC3B,MAAM,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACpD,CAAC;AACL,CAAC;AAED,SAAS,kBAAkB,CAAC,SAAiB;IACzC,OAAO,IAAI,CAAC,WAAW,EAAE,GAAG,SAAS,OAAO,CAAC,CAAA;AACjD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAClC,YAA0B,EAC1B,MAAc,EACd,WAAoB;IAEpB,IAAI,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC;YAC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AAO,MAAM,CAAA;QACjB,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;QAC3C,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAA;QAE1D,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;YAC3B,IAAI,CAAC;gBACD,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;gBACxC,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;gBACpD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAA0B,CAAA;gBAE1D,IAAI,KAAK,EAAE,KAAK,EAAE,gBAAgB,IAAI,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;oBAC1D,MAAM,CAAC,WAAW,IAAI,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAA;oBAClD,MAAM,CAAC,UAAU,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAA;oBAC/C,MAAM,CAAC,YAAY,EAAE,CAAA;gBACzB,CAAC;YACL,CAAC;YAAC,MAAM,CAAC;gBACL,qBAAqB;YACzB,CAAC;QACL,CAAC;QAED,MAAM,CAAC,KAAK,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAA;IACjD,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QAClB,MAAM,CAAC,IAAI,CAAC,+BAA+B,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAA;IAC3E,CAAC;IAED,OAAO,MAAM,CAAA;AACjB,CAAC"}
@@ -4,4 +4,5 @@ export declare const checkSession: (client: any, state: SessionState, logger: Lo
4
4
  export declare function createSessionState(): SessionState;
5
5
  export declare function resetSessionState(state: SessionState): void;
6
6
  export declare function ensureSessionInitialized(client: any, state: SessionState, sessionId: string, logger: Logger, messages: WithParts[]): Promise<void>;
7
+ export declare function countTurns(state: SessionState, messages: WithParts[]): number;
7
8
  //# sourceMappingURL=state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../lib/state/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAsB,SAAS,EAAE,MAAM,SAAS,CAAA;AAC1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAUvC,eAAO,MAAM,YAAY,GACrB,QAAQ,GAAG,EACX,OAAO,YAAY,EACnB,QAAQ,MAAM,EACd,UAAU,SAAS,EAAE,KACtB,OAAO,CAAC,IAAI,CA2Bd,CAAA;AAED,wBAAgB,kBAAkB,IAAI,YAAY,CAoBjD;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAkB3D;AAED,wBAAsB,wBAAwB,CAC1C,MAAM,EAAE,GAAG,EACX,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,SAAS,EAAE,GACtB,OAAO,CAAC,IAAI,CAAC,CAgCf"}
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../lib/state/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAsB,SAAS,EAAE,MAAM,SAAS,CAAA;AAC1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAKvC,eAAO,MAAM,YAAY,GACrB,QAAQ,GAAG,EACX,OAAO,YAAY,EACnB,QAAQ,MAAM,EACd,UAAU,SAAS,EAAE,KACtB,OAAO,CAAC,IAAI,CA4Bd,CAAA;AAED,wBAAgB,kBAAkB,IAAI,YAAY,CAkBjD;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAgB3D;AAED,wBAAsB,wBAAwB,CAC1C,MAAM,EAAE,GAAG,EACX,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,SAAS,EAAE,GACtB,OAAO,CAAC,IAAI,CAAC,CA8Bf;AAYD,wBAAgB,UAAU,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,MAAM,CAc7E"}
@@ -1,6 +1,6 @@
1
1
  import { loadSessionState } from "./persistence";
2
- import { isSubAgentSession, findLastCompactionTimestamp, countTurns, resetOnCompaction, } from "./utils";
3
- import { getLastUserMessage } from "../shared-utils";
2
+ import { isSubAgentSession } from "./utils";
3
+ import { getLastUserMessage, isMessageCompacted } from "../shared-utils";
4
4
  export const checkSession = async (client, state, logger, messages) => {
5
5
  const lastUserMessage = getLastUserMessage(messages);
6
6
  if (!lastUserMessage) {
@@ -19,8 +19,9 @@ export const checkSession = async (client, state, logger, messages) => {
19
19
  const lastCompactionTimestamp = findLastCompactionTimestamp(messages);
20
20
  if (lastCompactionTimestamp > state.lastCompaction) {
21
21
  state.lastCompaction = lastCompactionTimestamp;
22
- resetOnCompaction(state);
23
- logger.info("Detected compaction - reset stale state", {
22
+ state.toolParameters.clear();
23
+ state.prune.toolIds = [];
24
+ logger.info("Detected compaction from messages - cleared tool cache", {
24
25
  timestamp: lastCompactionTimestamp,
25
26
  });
26
27
  }
@@ -32,9 +33,7 @@ export function createSessionState() {
32
33
  isSubAgent: false,
33
34
  prune: {
34
35
  toolIds: [],
35
- messageIds: [],
36
36
  },
37
- squashSummaries: [],
38
37
  stats: {
39
38
  pruneTokenCounter: 0,
40
39
  totalPruneTokens: 0,
@@ -52,9 +51,7 @@ export function resetSessionState(state) {
52
51
  state.isSubAgent = false;
53
52
  state.prune = {
54
53
  toolIds: [],
55
- messageIds: [],
56
54
  };
57
- state.squashSummaries = [];
58
55
  state.stats = {
59
56
  pruneTokenCounter: 0,
60
57
  totalPruneTokens: 0,
@@ -85,12 +82,34 @@ export async function ensureSessionInitialized(client, state, sessionId, logger,
85
82
  }
86
83
  state.prune = {
87
84
  toolIds: persisted.prune.toolIds || [],
88
- messageIds: persisted.prune.messageIds || [],
89
85
  };
90
- state.squashSummaries = persisted.squashSummaries || [];
91
86
  state.stats = {
92
87
  pruneTokenCounter: persisted.stats?.pruneTokenCounter || 0,
93
88
  totalPruneTokens: persisted.stats?.totalPruneTokens || 0,
94
89
  };
95
90
  }
91
+ function findLastCompactionTimestamp(messages) {
92
+ for (let i = messages.length - 1; i >= 0; i--) {
93
+ const msg = messages[i];
94
+ if (msg.info.role === "assistant" && msg.info.summary === true) {
95
+ return msg.info.time.created;
96
+ }
97
+ }
98
+ return 0;
99
+ }
100
+ export function countTurns(state, messages) {
101
+ let turnCount = 0;
102
+ for (const msg of messages) {
103
+ if (isMessageCompacted(state, msg)) {
104
+ continue;
105
+ }
106
+ const parts = Array.isArray(msg.parts) ? msg.parts : [];
107
+ for (const part of parts) {
108
+ if (part.type === "step-start") {
109
+ turnCount++;
110
+ }
111
+ }
112
+ }
113
+ return turnCount;
114
+ }
96
115
  //# sourceMappingURL=state.js.map