@lexwdex-org/opencode-dcp 3.2.0 → 3.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.
package/README.md CHANGED
@@ -61,7 +61,7 @@ Each level overrides the previous, so project settings take priority over global
61
61
 
62
62
  ```jsonc
63
63
  {
64
- "$schema": "https://raw.githubusercontent.com/Opencode-DCP/opencode-dynamic-context-pruning/master/dcp.schema.json",
64
+ "$schema": "https://raw.githubusercontent.com/LeXwDeX/opencode-dynamic-context-pruning/master/dcp.schema.json",
65
65
  // Enable or disable the plugin
66
66
  "enabled": true,
67
67
  // Automatically update npm-installed DCP when a newer npm latest is available.
package/dist/index.js CHANGED
@@ -1399,7 +1399,7 @@ function createDefaultConfig() {
1399
1399
  mkdirSync(GLOBAL_CONFIG_DIR, { recursive: true });
1400
1400
  }
1401
1401
  const configContent = `{
1402
- "$schema": "https://raw.githubusercontent.com/Opencode-DCP/opencode-dynamic-context-pruning/master/dcp.schema.json"
1402
+ "$schema": "https://raw.githubusercontent.com/LeXwDeX/opencode-dynamic-context-pruning/master/dcp.schema.json"
1403
1403
  }
1404
1404
  `;
1405
1405
  writeFileSync(GLOBAL_CONFIG_PATH_JSONC, configContent, "utf-8");
@@ -4840,164 +4840,144 @@ import { homedir as homedir4 } from "os";
4840
4840
 
4841
4841
  // lib/prompts/system.ts
4842
4842
  var SYSTEM = `
4843
- \u4F60\u5728\u4E00\u4E2A\u4E0A\u4E0B\u6587\u53D7\u9650\u7684\u73AF\u5883\u4E2D\u8FD0\u884C\u3002\u6301\u7EED\u7BA1\u7406\u4E0A\u4E0B\u6587\u4EE5\u907F\u514D\u5806\u79EF\u5E76\u4FDD\u6301\u68C0\u7D22\u8D28\u91CF\u3002\u9AD8\u6548\u7684\u4E0A\u4E0B\u6587\u7BA1\u7406\u5BF9\u4F60\u7684\u4EE3\u7406\u6027\u80FD\u81F3\u5173\u91CD\u8981\u3002
4843
+ You operate in a context-constrained environment. Manage context continuously to avoid buildup and preserve retrieval quality. Efficient context management is paramount for your agentic performance.
4844
4844
 
4845
- \u4F60\u7528\u4E8E\u4E0A\u4E0B\u6587\u7BA1\u7406\u7684\u552F\u4E00\u5DE5\u5177\u662F \`compress\`\u3002\u5B83\u7528\u4F60\u751F\u6210\u7684\u6280\u672F\u6458\u8981\u66FF\u6362\u8F83\u65E7\u7684\u5BF9\u8BDD\u5185\u5BB9\u3002
4845
+ The ONLY tool you have for context management is \`compress\`. It replaces older conversation content with technical summaries you produce.
4846
4846
 
4847
- \u5173\u952E\u7EA6\u675F
4848
- - \u4E0A\u4E0B\u6587\u7BA1\u7406\u4EC5\u901A\u8FC7\u8C03\u7528 \`compress\` \u5DE5\u5177\u5B8C\u6210\u3002\u7EDD\u4E0D\u4EE5\u7EAF\u6587\u672C\u5F62\u5F0F\u751F\u6210\u6458\u8981\u3002
4849
- - **\u4E25\u683C\u7981\u6B62**\u5728\u6587\u672C\u54CD\u5E94\u4E2D\u8F93\u51FA \`<summary>\` \u6216 \`<analysis>\` XML \u6807\u7B7E\u3002\u8FD9\u4E9B\u6807\u7B7E\u4F1A\u5BFC\u81F4\u7CFB\u7EDF\u9519\u8BEF\u3002
4850
- - \u5982\u679C\u4F60\u8BA4\u4E3A\u4E0A\u4E0B\u6587\u9700\u8981\u538B\u7F29\uFF0C\u8C03\u7528 \`compress\` \u5DE5\u5177\u3002\u4E0D\u8981\u5185\u8054\u7F16\u5199\u6458\u8981\u3002
4851
- - \u6240\u6709\u8F93\u51FA\u5FC5\u987B\u4F7F\u7528**\u4E2D\u6587**\u3002
4852
- - \u5982\u679C\u9700\u8981\u5728\u6587\u672C\u4E2D\u7EC4\u7EC7\u4FE1\u606F\uFF0C\u4F7F\u7528 Markdown \u683C\u5F0F\uFF08\u5982 \`## \u5206\u6790\`\u3001\`## \u603B\u7ED3\`\uFF09\uFF0C\u7EDD\u4E0D\u4F7F\u7528 XML \u6807\u7B7E\u3002
4847
+ \`<dcp-message-id>\` and \`<dcp-system-reminder>\` tags are environment-injected metadata. Do not output them.
4853
4848
 
4854
- \`\` \u548C \`\` \u6807\u7B7E\u662F\u73AF\u5883\u6CE8\u5165\u7684\u5143\u6570\u636E\u3002\u4E0D\u8981\u8F93\u51FA\u5B83\u4EEC\u3002
4849
+ THE PHILOSOPHY OF COMPRESS
4850
+ \`compress\` transforms conversation content into dense, high-fidelity summaries. This is not cleanup - it is crystallization. Your summary becomes the authoritative record of what transpired.
4855
4851
 
4856
- \u538B\u7F29\u7684\u54F2\u5B66
4857
- \`compress\` \u5C06\u5BF9\u8BDD\u5185\u5BB9\u8F6C\u6362\u4E3A\u5BC6\u96C6\u3001\u9AD8\u4FDD\u771F\u7684\u6458\u8981\u3002\u8FD9\u4E0D\u662F\u6E05\u7406\u2014\u2014\u800C\u662F\u7ED3\u6676\u3002\u4F60\u7684\u6458\u8981\u6210\u4E3A\u6240\u53D1\u751F\u4E8B\u60C5\u7684\u6743\u5A01\u8BB0\u5F55\u3002
4852
+ Think of compression as phase transitions: raw exploration becomes refined understanding. The original context served its purpose; your summary now carries that understanding forward.
4858
4853
 
4859
- \u5C06\u538B\u7F29\u89C6\u4E3A\u76F8\u53D8\uFF1A\u539F\u59CB\u63A2\u7D22\u53D8\u4E3A\u7CBE\u70BC\u7406\u89E3\u3002\u539F\u59CB\u4E0A\u4E0B\u6587\u5DF2\u5B8C\u6210\u5176\u4F7F\u547D\uFF1B\u4F60\u7684\u6458\u8981\u73B0\u5728\u627F\u8F7D\u8BE5\u7406\u89E3\u5411\u524D\u3002
4854
+ COMPRESS WHEN
4860
4855
 
4861
- \u4F55\u65F6\u538B\u7F29
4856
+ A section is genuinely closed and the raw conversation has served its purpose:
4862
4857
 
4863
- \u5F53\u4E00\u4E2A\u90E8\u5206\u771F\u6B63\u5173\u95ED\u4E14\u539F\u59CB\u5BF9\u8BDD\u5DF2\u5B8C\u6210\u5176\u4F7F\u547D\u65F6\uFF1A
4858
+ - Research concluded and findings are clear
4859
+ - Implementation finished and verified
4860
+ - Exploration exhausted and patterns understood
4861
+ - Dead-end noise can be discarded without waiting for a whole chapter to close
4864
4862
 
4865
- - \u7814\u7A76\u5DF2\u5B8C\u6210\u4E14\u53D1\u73B0\u5DF2\u660E\u786E
4866
- - \u5B9E\u73B0\u5DF2\u5B8C\u6210\u5E76\u9A8C\u8BC1
4867
- - \u63A2\u7D22\u5DF2\u7A77\u5C3D\u4E14\u6A21\u5F0F\u5DF2\u7406\u89E3
4868
- - \u6B7B\u80E1\u540C\u566A\u97F3\u53EF\u4EE5\u5728\u4E0D\u7B49\u5F85\u6574\u4E2A\u7AE0\u8282\u5173\u95ED\u7684\u60C5\u51B5\u4E0B\u88AB\u4E22\u5F03
4863
+ DO NOT COMPRESS IF
4869
4864
 
4870
- \u4E0D\u8981\u538B\u7F29\u7684\u60C5\u51B5
4865
+ - Raw context is still relevant and needed for edits or precise references
4866
+ - The target content is still actively in progress
4867
+ - You may need exact code, error messages, or file contents in the immediate next steps
4871
4868
 
4872
- - \u539F\u59CB\u4E0A\u4E0B\u6587\u4ECD\u7136\u76F8\u5173\u4E14\u9700\u8981\u7528\u4E8E\u7F16\u8F91\u6216\u7CBE\u786E\u5F15\u7528
4873
- - \u76EE\u6807\u5185\u5BB9\u4ECD\u5728\u79EF\u6781\u8FDB\u884C\u4E2D
4874
- - \u4F60\u53EF\u80FD\u5728\u63A5\u4E0B\u6765\u7684\u6B65\u9AA4\u4E2D\u9700\u8981\u786E\u5207\u7684\u4EE3\u7801\u3001\u9519\u8BEF\u6D88\u606F\u6216\u6587\u4EF6\u5185\u5BB9
4869
+ Before compressing, ask: _"Is this section closed enough to become summary-only right now?"_
4875
4870
 
4876
- \u538B\u7F29\u524D\u95EE\u81EA\u5DF1\uFF1A_"\u8FD9\u4E2A\u90E8\u5206\u73B0\u5728\u662F\u5426\u8DB3\u591F\u5173\u95ED\u4EE5\u6210\u4E3A\u4EC5\u6458\u8981\uFF1F"_
4871
+ Evaluate conversation signal-to-noise REGULARLY. Use \`compress\` deliberately with quality-first summaries. Prioritize stale content intelligently to maintain a high-signal context window that supports your agency.
4877
4872
 
4878
- \u5B9A\u671F\u8BC4\u4F30\u5BF9\u8BDD\u7684\u4FE1\u566A\u6BD4\u3002\u6709\u610F\u8BC6\u5730\u4F7F\u7528 \`compress\` \u5E76\u63D0\u4F9B\u9AD8\u8D28\u91CF\u6458\u8981\u3002\u667A\u80FD\u5730\u4F18\u5148\u5904\u7406\u8FC7\u65F6\u5185\u5BB9\uFF0C\u4EE5\u7EF4\u62A4\u652F\u6301\u4F60\u4EE3\u7406\u80FD\u529B\u7684\u9AD8\u4FE1\u53F7\u4E0A\u4E0B\u6587\u7A97\u53E3\u3002
4879
-
4880
- \u4FDD\u6301\u9510\u5229\u3001\u9AD8\u8D28\u91CF\u7684\u4E0A\u4E0B\u6587\u7A97\u53E3\u4EE5\u83B7\u5F97\u6700\u4F73\u6027\u80FD\u662F\u4F60\u7684\u8D23\u4EFB\u3002
4873
+ It is of your responsibility to keep a sharp, high-quality context window for optimal performance.
4881
4874
  `;
4882
4875
 
4883
4876
  // lib/prompts/compress-range.ts
4884
- var COMPRESS_RANGE = `\u5C06\u5BF9\u8BDD\u4E2D\u7684\u4E00\u4E2A\u8303\u56F4\u6298\u53E0\u4E3A\u8BE6\u7EC6\u6458\u8981\u3002
4885
-
4886
- \u8F93\u51FA\u683C\u5F0F
4887
- \u6BCF\u4E2A\u6458\u8981\u5FC5\u987B\u4F7F\u7528 Markdown \u6807\u9898\u7ED3\u6784\uFF1A
4888
-
4889
- \`\`\`
4890
- ## \u5206\u6790
4891
- [\u5206\u6790\uFF1A\u63A2\u7D22\u4E86\u4EC0\u4E48\u3001\u9047\u5230\u4E86\u4EC0\u4E48\u95EE\u9898\u3001\u5C1D\u8BD5\u4E86\u54EA\u4E9B\u65B9\u6CD5]
4892
-
4893
- ## \u603B\u7ED3
4894
- [\u603B\u7ED3\uFF1A\u6700\u7EC8\u7ED3\u8BBA\u3001\u5173\u952E\u51B3\u7B56\u3001\u91CD\u8981\u6587\u4EF6\u8DEF\u5F84\u3001\u51FD\u6570\u7B7E\u540D\u3001\u4EE3\u7801\u53D8\u66F4]
4895
- \`\`\`
4896
-
4897
- \u7981\u6B62\u4F7F\u7528 \`<analysis>\` \u6216 \`<summary>\` \u7B49 XML \u6807\u7B7E\u3002\u53EA\u4F7F\u7528 Markdown \`## \u5206\u6790\` \u548C \`## \u603B\u7ED3\` \u6807\u9898\u3002
4877
+ var COMPRESS_RANGE = `Collapse a range in the conversation into a detailed summary.
4898
4878
 
4899
- \u6458\u8981\u8981\u6C42
4900
- \u6458\u8981\u5FC5\u987B\u8BE6\u5C3D\u3002\u6355\u83B7\u6587\u4EF6\u8DEF\u5F84\u3001\u51FD\u6570\u7B7E\u540D\u3001\u6240\u505A\u51B3\u7B56\u3001\u53D1\u73B0\u7684\u7EA6\u675F\u3001\u5173\u952E\u53D1\u73B0\u2026\u2026\u6240\u6709\u7EF4\u6301\u4E0A\u4E0B\u6587\u5B8C\u6574\u6027\u7684\u5185\u5BB9\u3002\u8FD9\u4E0D\u662F\u7B80\u77ED\u7B14\u8BB0\u2014\u2014\u800C\u662F\u4E00\u4EFD\u6743\u5A01\u8BB0\u5F55\uFF0C\u5FE0\u5B9E\u5230\u539F\u59CB\u5BF9\u8BDD\u4E0D\u518D\u6709\u4EFB\u4F55\u4EF7\u503C\u3002
4879
+ THE SUMMARY
4880
+ Your summary must be EXHAUSTIVE. Capture file paths, function signatures, decisions made, constraints discovered, key findings... EVERYTHING that maintains context integrity. This is not a brief note - it is an authoritative record so faithful that the original conversation adds no value.
4901
4881
 
4902
- \u7528\u6237\u610F\u56FE\u4FDD\u771F
4903
- \u5F53\u538B\u7F29\u8303\u56F4\u5305\u542B\u7528\u6237\u6D88\u606F\u65F6\uFF0C\u683C\u5916\u5C0F\u5FC3\u5730\u4FDD\u7559\u7528\u6237\u610F\u56FE\u3002\u4E0D\u8981\u6539\u53D8\u8303\u56F4\u3001\u7EA6\u675F\u3001\u4F18\u5148\u7EA7\u3001\u9A8C\u6536\u6807\u51C6\u6216\u8BF7\u6C42\u7684\u7ED3\u679C\u3002
4904
- \u5F53\u7528\u6237\u6D88\u606F\u8DB3\u591F\u77ED\u65F6\u76F4\u63A5\u5F15\u7528\u3002\u76F4\u63A5\u5F15\u7528\u5728\u6700\u80FD\u4FDD\u7559\u7CBE\u786E\u542B\u4E49\u65F6\u4F18\u5148\u4F7F\u7528\u3002
4882
+ USER INTENT FIDELITY
4883
+ When the compressed range includes user messages, preserve the user's intent with extra care. Do not change scope, constraints, priorities, acceptance criteria, or requested outcomes.
4884
+ Directly quote user messages when they are short enough to include safely. Direct quotes are preferred when they best preserve exact meaning.
4905
4885
 
4906
- \u540C\u65F6\u4FDD\u6301\u7CBE\u7B80\u3002\u53BB\u9664\u566A\u97F3\uFF1A\u65E0\u679C\u7684\u5931\u8D25\u5C1D\u8BD5\u3001\u5197\u957F\u7684\u5DE5\u5177\u8F93\u51FA\u3001\u53CD\u590D\u63A2\u7D22\u3002\u7559\u4E0B\u7684\u5E94\u8BE5\u662F\u7EAF\u4FE1\u53F7\u2014\u2014\u4FDD\u7559\u5B8C\u6574\u7406\u89E3\u3001\u96F6\u6B67\u4E49\u7684\u7CBE\u534E\u7EC6\u8282\u3002
4886
+ Yet be LEAN. Strip away the noise: failed attempts that led nowhere, verbose tool outputs, back-and-forth exploration. What remains should be pure signal - golden nuggets of detail that preserve full understanding with zero ambiguity.
4907
4887
 
4908
- \u538B\u7F29\u5757\u5360\u4F4D\u7B26
4909
- \u5F53\u9009\u5B9A\u8303\u56F4\u5305\u542B\u4E4B\u524D\u538B\u7F29\u7684\u5757\u65F6\uFF0C\u5F15\u7528\u65F6\u4F7F\u7528\u4EE5\u4E0B\u7CBE\u786E\u5360\u4F4D\u7B26\u683C\u5F0F\uFF1A
4888
+ COMPRESSED BLOCK PLACEHOLDERS
4889
+ When the selected range includes previously compressed blocks, use this exact placeholder format when referencing one:
4910
4890
 
4911
4891
  - \`(bN)\`
4912
4892
 
4913
- \u4E0A\u4E0B\u6587\u4E2D\u7684\u538B\u7F29\u5757\u90E8\u5206\u7528\u6807\u9898\u660E\u786E\u6807\u8BB0\uFF1A
4893
+ Compressed block sections in context are clearly marked with a header:
4914
4894
 
4915
- - \`[\u5DF2\u538B\u7F29\u7684\u5BF9\u8BDD\u90E8\u5206]\`
4895
+ - \`[Compressed conversation section]\`
4916
4896
 
4917
- \u538B\u7F29\u5757 ID \u59CB\u7EC8\u4F7F\u7528 \`bN\` \u5F62\u5F0F\uFF08\u4E0D\u662F \`mNNNN\`\uFF09\uFF0C\u5E76\u4EE5\u76F8\u540C\u7684 XML \u5143\u6570\u636E\u6807\u7B7E\u683C\u5F0F\u8868\u793A\u3002
4897
+ Compressed block IDs always use the \`bN\` form (never \`mNNNN\`) and are represented in the same XML metadata tag format.
4918
4898
 
4919
- \u89C4\u5219\uFF1A
4899
+ Rules:
4920
4900
 
4921
- - \u6BCF\u4E2A\u5FC5\u9700\u7684\u5757\u5360\u4F4D\u7B26\u6070\u597D\u5305\u542B\u4E00\u6B21\u3002
4922
- - \u4E0D\u8981\u4E3A\u9009\u5B9A\u8303\u56F4\u4E4B\u5916\u7684\u5757\u53D1\u660E\u5360\u4F4D\u7B26\u3002
4923
- - \u5C06 \`(bN)\` \u5360\u4F4D\u7B26\u89C6\u4E3A\u4FDD\u7559\u6807\u8BB0\u3002\u9664\u4E86\u6709\u610F\u5360\u4F4D\u7B26\u5916\uFF0C\u4E0D\u8981\u5728\u4EFB\u4F55\u5730\u65B9\u8F93\u51FA \`(bN)\` \u6587\u672C\u3002
4924
- - \u5982\u679C\u9700\u8981\u5728\u6B63\u6587\u4E2D\u63D0\u53CA\u4E00\u4E2A\u5757\uFF0C\u4F7F\u7528\u7EAF\u6587\u672C\u5982 \`\u538B\u7F29\u5757 bN\`\uFF08\u4E0D\u4F5C\u4E3A\u5360\u4F4D\u7B26\uFF09\u3002
4925
- - \u6700\u7EC8\u786E\u5B9A\u524D\u7684\u9884\u68C0\uFF1A\u6458\u8981\u4E2D\u7684 \`(bN)\` \u5360\u4F4D\u7B26\u96C6\u5408\u5FC5\u987B\u4E0E\u5FC5\u9700\u96C6\u5408\u5B8C\u5168\u5339\u914D\uFF0C\u65E0\u91CD\u590D\u3002
4901
+ - Include every required block placeholder exactly once.
4902
+ - Do not invent placeholders for blocks outside the selected range.
4903
+ - Treat \`(bN)\` placeholders as RESERVED TOKENS. Do not emit \`(bN)\` text anywhere except intentional placeholders.
4904
+ - If you need to mention a block in prose, use plain text like \`compressed bN\` (not as a placeholder).
4905
+ - Preflight check before finalizing: the set of \`(bN)\` placeholders in your summary must exactly match the required set, with no duplicates.
4926
4906
 
4927
- \u8FD9\u4E9B\u5360\u4F4D\u7B26\u662F\u8BED\u4E49\u5F15\u7528\u3002\u5F53\u5DE5\u5177\u5904\u7406\u4F60\u7684\u8F93\u51FA\u65F6\uFF0C\u5B83\u4EEC\u5C06\u88AB\u66FF\u6362\u4E3A\u5B8C\u6574\u7684\u5B58\u50A8\u538B\u7F29\u5757\u5185\u5BB9\u3002
4907
+ These placeholders are semantic references. They will be replaced with the full stored compressed block content when the tool processes your output.
4928
4908
 
4929
- \u5360\u4F4D\u7B26\u7684\u6D41\u7545\u6027
4930
- \u4F7F\u7528\u538B\u7F29\u5757\u5360\u4F4D\u7B26\u65F6\uFF0C\u7F16\u5199\u5468\u56F4\u7684\u6458\u8981\u6587\u672C\uFF0C\u4F7F\u5176\u5728\u5360\u4F4D\u7B26\u5C55\u5F00\u540E\u4ECD\u7136\u6B63\u786E\u53EF\u8BFB\u3002
4909
+ FLOW PRESERVATION WITH PLACEHOLDERS
4910
+ When you use compressed block placeholders, write the surrounding summary text so it still reads correctly AFTER placeholder expansion.
4931
4911
 
4932
- - \u5C06\u6BCF\u4E2A\u5360\u4F4D\u7B26\u89C6\u4E3A\u5B8C\u6574\u5BF9\u8BDD\u6BB5\u7684\u66FF\u4EE3\uFF0C\u800C\u4E0D\u662F\u77ED\u6807\u7B7E\u3002
4933
- - \u786E\u4FDD\u6BCF\u4E2A\u5360\u4F4D\u7B26\u524D\u540E\u7684\u8FC7\u6E21\u4FDD\u7559\u65F6\u95F4\u987A\u5E8F\u548C\u56E0\u679C\u5173\u7CFB\u3002
4934
- - \u4E0D\u8981\u7F16\u5199\u4F9D\u8D56\u4E8E\u5360\u4F4D\u7B26\u4FDD\u6301\u5B57\u9762\u610F\u4E49\u7684\u6587\u672C\uFF08\u4F8B\u5982"\u5982 \`(b2)\` \u4E2D\u6240\u8FF0"\uFF09\u3002
4935
- - \u5F53\u6BCF\u4E2A\u5360\u4F4D\u7B26\u88AB\u66FF\u6362\u4E3A\u5176\u5B8C\u6574\u538B\u7F29\u5757\u5185\u5BB9\u540E\uFF0C\u6700\u7EC8\u542B\u4E49\u5FC5\u987B\u8FDE\u8D2F\u3002
4912
+ - Treat each placeholder as a stand-in for a full conversation segment, not as a short label.
4913
+ - Ensure transitions before and after each placeholder preserve chronology and causality.
4914
+ - Do not write text that depends on the placeholder staying literal (for example, "as noted in \`(b2)\`").
4915
+ - Your final meaning must be coherent once each placeholder is replaced with its full compressed block content.
4936
4916
 
4937
- \u8FB9\u754C ID
4938
- \u4F7F\u7528\u5BF9\u8BDD\u4E2D\u53EF\u89C1\u7684\u6CE8\u5165 ID \u6309 ID \u6307\u5B9A\u8FB9\u754C\uFF1A
4917
+ BOUNDARY IDS
4918
+ You specify boundaries by ID using the injected IDs visible in the conversation:
4939
4919
 
4940
- - \`mNNNN\` ID \u6807\u8BC6\u539F\u59CB\u6D88\u606F
4941
- - \`bN\` ID \u6807\u8BC6\u4E4B\u524D\u538B\u7F29\u7684\u5757
4920
+ - \`mNNNN\` IDs identify raw messages
4921
+ - \`bN\` IDs identify previously compressed blocks
4942
4922
 
4943
- \u6BCF\u6761\u6D88\u606F\u5728 XML \u5143\u6570\u636E\u6807\u7B7E\u5185\u6709 ID\uFF0C\u5982 \`\`\u3002
4944
- \u76F8\u540C\u7684 ID \u6807\u7B7E\u51FA\u73B0\u5728\u8BE5\u6D88\u606F\u6240\u5C5E\u7684\u6BCF\u4E2A\u5DE5\u5177\u8F93\u51FA\u4E2D\u2014\u2014\u6BCF\u4E2A\u552F\u4E00 ID \u6807\u8BC6\u4E00\u6761\u5B8C\u6574\u6D88\u606F\u3002
4945
- \u5C06\u8FD9\u4E9B\u6807\u7B7E\u4EC5\u89C6\u4E3A\u8FB9\u754C\u5143\u6570\u636E\uFF0C\u800C\u975E\u5DE5\u5177\u7ED3\u679C\u5185\u5BB9\u3002
4923
+ Each message has an ID inside XML metadata tags like \`<dcp-message-id>...</dcp-message-id>\`.
4924
+ The same ID tag appears in every tool output of the message it belongs to \u2014 each unique ID identifies one complete message.
4925
+ Treat these tags as boundary metadata only, not as tool result content.
4946
4926
 
4947
- \u89C4\u5219\uFF1A
4927
+ Rules:
4948
4928
 
4949
- - \u76F4\u63A5\u4ECE\u4E0A\u4E0B\u6587\u4E2D\u7684\u6CE8\u5165 ID \u9009\u53D6 \`startId\` \u548C \`endId\`\u3002
4950
- - ID \u5FC5\u987B\u5B58\u5728\u4E8E\u5F53\u524D\u53EF\u89C1\u4E0A\u4E0B\u6587\u4E2D\u3002
4951
- - \`startId\` \u5FC5\u987B\u51FA\u73B0\u5728 \`endId\` \u4E4B\u524D\u3002
4952
- - \u4E0D\u8981\u53D1\u660E ID\u3002\u53EA\u4F7F\u7528\u4E0A\u4E0B\u6587\u4E2D\u5B58\u5728\u7684 ID\u3002
4929
+ - Pick \`startId\` and \`endId\` directly from injected IDs in context.
4930
+ - IDs must exist in the current visible context.
4931
+ - \`startId\` must appear before \`endId\`.
4932
+ - Do not invent IDs. Use only IDs that are present in context.
4953
4933
 
4954
- \u6279\u91CF\u5904\u7406
4955
- \u5F53\u591A\u4E2A\u72EC\u7ACB\u8303\u56F4\u5DF2\u51C6\u5907\u597D\u4E14\u8FB9\u754C\u4E0D\u91CD\u53E0\u65F6\uFF0C\u5C06\u5B83\u4EEC\u5168\u90E8\u4F5C\u4E3A\u5355\u72EC\u6761\u76EE\u5305\u542B\u5728\u5355\u6B21\u5DE5\u5177\u8C03\u7528\u7684 \`content\` \u6570\u7EC4\u4E2D\u3002\u6BCF\u4E2A\u6761\u76EE\u5E94\u6709\u81EA\u5DF1\u7684 \`startId\`\u3001\`endId\` \u548C \`summary\`\u3002
4934
+ BATCHING
4935
+ When multiple independent ranges are ready and their boundaries do not overlap, include all of them as separate entries in the \`content\` array of a single tool call. Each entry should have its own \`startId\`, \`endId\`, and \`summary\`.
4956
4936
  `;
4957
4937
 
4958
4938
  // lib/prompts/compress-message.ts
4959
- var COMPRESS_MESSAGE = `\u5C06\u5BF9\u8BDD\u4E2D\u9009\u5B9A\u7684\u5355\u6761\u6D88\u606F\u6298\u53E0\u4E3A\u8BE6\u7EC6\u6458\u8981\u3002
4939
+ var COMPRESS_MESSAGE = `Collapse selected individual messages in the conversation into detailed summaries.
4960
4940
 
4961
- \u6458\u8981\u8981\u6C42
4962
- \u6458\u8981\u5FC5\u987B\u8BE6\u5C3D\u3002\u6355\u83B7\u6587\u4EF6\u8DEF\u5F84\u3001\u51FD\u6570\u7B7E\u540D\u3001\u6240\u505A\u51B3\u7B56\u3001\u53D1\u73B0\u7684\u7EA6\u675F\u3001\u5173\u952E\u53D1\u73B0\u3001\u5DE5\u5177\u7ED3\u679C\uFF0C\u4EE5\u53CA\u91CD\u8981\u7684\u7528\u6237\u610F\u56FE\u7EC6\u8282\u2026\u2026\u6240\u6709\u5728\u539F\u59CB\u6D88\u606F\u88AB\u79FB\u9664\u540E\u4FDD\u7559\u5176\u4EF7\u503C\u7684\u5185\u5BB9\u3002
4941
+ THE SUMMARY
4942
+ Your summary must be EXHAUSTIVE. Capture file paths, function signatures, decisions made, constraints discovered, key findings, tool outcomes, and user intent details that matter... EVERYTHING that preserves the value of the selected message after the raw message is removed.
4963
4943
 
4964
- \u7528\u6237\u610F\u56FE\u4FDD\u771F
4965
- \u5F53\u9009\u5B9A\u6D88\u606F\u5305\u542B\u7528\u6237\u610F\u56FE\u65F6\uFF0C\u683C\u5916\u5C0F\u5FC3\u5730\u4FDD\u7559\u8BE5\u610F\u56FE\u3002\u4E0D\u8981\u6539\u53D8\u8303\u56F4\u3001\u7EA6\u675F\u3001\u4F18\u5148\u7EA7\u3001\u9A8C\u6536\u6807\u51C6\u6216\u8BF7\u6C42\u7684\u7ED3\u679C\u3002
4966
- \u5F53\u76F4\u63A5\u5F15\u7528\u7B80\u77ED\u7528\u6237\u6307\u4EE4\u6700\u80FD\u4FDD\u7559\u7CBE\u786E\u542B\u4E49\u65F6\uFF0C\u76F4\u63A5\u5F15\u7528\u3002
4944
+ USER INTENT FIDELITY
4945
+ When a selected message contains user intent, preserve that intent with extra care. Do not change scope, constraints, priorities, acceptance criteria, or requested outcomes.
4946
+ Directly quote short user instructions when that best preserves exact meaning.
4967
4947
 
4968
- \u540C\u65F6\u4FDD\u6301\u7CBE\u7B80\u3002\u53BB\u9664\u566A\u97F3\uFF1A\u65E0\u679C\u7684\u5931\u8D25\u5C1D\u8BD5\u3001\u5197\u957F\u7684\u5DE5\u5177\u8F93\u51FA\u548C\u91CD\u590D\u3002\u7559\u4E0B\u7684\u5E94\u8BE5\u662F\u7EAF\u4FE1\u53F7\u2014\u2014\u4FDD\u7559\u5B8C\u6574\u7406\u89E3\u3001\u96F6\u6B67\u4E49\u7684\u7CBE\u534E\u7EC6\u8282\u3002
4969
- \u5982\u679C\u6D88\u606F\u4E0D\u5305\u542B\u91CD\u8981\u7684\u6280\u672F\u51B3\u7B56\u3001\u4EE3\u7801\u53D8\u66F4\u6216\u7528\u6237\u9700\u6C42\uFF0C\u751F\u6210\u6700\u5C0F\u5316\u7684\u4E00\u884C\u6458\u8981\u800C\u975E\u8BE6\u7EC6\u6458\u8981\u3002
4948
+ Yet be LEAN. Strip away the noise: failed attempts that led nowhere, verbose tool output, and repetition. What remains should be pure signal - golden nuggets of detail that preserve full understanding with zero ambiguity.
4949
+ If a message contains no significant technical decisions, code changes, or user requirements, produce a minimal one-line summary rather than a detailed one.
4970
4950
 
4971
- \u6D88\u606F ID
4972
- \u4F7F\u7528\u5BF9\u8BDD\u4E2D\u53EF\u89C1\u7684\u6CE8\u5165 ID \u6309 ID \u6307\u5B9A\u5355\u6761\u539F\u59CB\u6D88\u606F\uFF1A
4951
+ MESSAGE IDS
4952
+ You specify individual raw messages by ID using the injected IDs visible in the conversation:
4973
4953
 
4974
- - \`mNNNN\` ID \u6807\u8BC6\u539F\u59CB\u6D88\u606F
4954
+ - \`mNNNN\` IDs identify raw messages
4975
4955
 
4976
- \u6BCF\u6761\u6D88\u606F\u5728 XML \u5143\u6570\u636E\u6807\u7B7E\u5185\u6709 ID\uFF0C\u5982 \`\`\u3002
4977
- \u76F8\u540C\u7684 ID \u6807\u7B7E\u51FA\u73B0\u5728\u8BE5\u6D88\u606F\u6240\u5C5E\u7684\u6BCF\u4E2A\u5DE5\u5177\u8F93\u51FA\u4E2D\u2014\u2014\u6BCF\u4E2A\u552F\u4E00 ID \u6807\u8BC6\u4E00\u6761\u5B8C\u6574\u6D88\u606F\u3002
4978
- \u5C06\u8FD9\u4E9B\u6807\u7B7E\u4EC5\u89C6\u4E3A\u6D88\u606F\u5143\u6570\u636E\uFF0C\u800C\u975E\u8981\u6458\u8981\u7684\u5185\u5BB9\u3002\u53EA\u4F7F\u7528\u5185\u90E8\u7684 \`mNNNN\` \u503C\u4F5C\u4E3A \`messageId\`\u3002
4979
- \`priority\` \u5C5E\u6027\u8868\u793A\u76F8\u5BF9\u4E0A\u4E0B\u6587\u6210\u672C\u3002\u5F53\u9AD8\u4F18\u5148\u7EA7\u6D88\u606F\u7684\u5B8C\u6574\u6587\u672C\u5BF9\u5F53\u524D\u4EFB\u52A1\u4E0D\u518D\u5FC5\u8981\u65F6\uFF0C\u4F60\u5FC5\u987B\u538B\u7F29\u5B83\u4EEC\u3002
4980
- \u5982\u679C\u5B58\u5728\u4E4B\u524D\u7684\u538B\u7F29\u5DE5\u5177\u7ED3\u679C\uFF0C\u59CB\u7EC8\u5728\u66F4\u5E7F\u6CDB\u7684\u538B\u7F29\u8FC7\u7A0B\u4E2D\u5C06\u5B83\u4EEC\u6700\u5C0F\u5316\u5730\u538B\u7F29\u548C\u6458\u8981\u3002\u4E0D\u8981\u4EC5\u4E3A\u4E86\u91CD\u65B0\u538B\u7F29\u4E4B\u524D\u7684\u538B\u7F29\u7ED3\u679C\u800C\u8C03\u7528\u538B\u7F29\u5DE5\u5177\u3002
4981
- \u6807\u8BB0\u4E3A \`\` \u7684\u6D88\u606F\u4E0D\u80FD\u88AB\u538B\u7F29\u3002
4956
+ Each message has an ID inside XML metadata tags like \`<dcp-message-id priority="high">m0007</dcp-message-id>\`.
4957
+ The same ID tag appears in every tool output of the message it belongs to \u2014 each unique ID identifies one complete message.
4958
+ Treat these tags as message metadata only, not as content to summarize. Use only the inner \`mNNNN\` value as the \`messageId\`.
4959
+ The \`priority\` attribute indicates relative context cost. You MUST compress high-priority messages when their full text is no longer necessary for the active task.
4960
+ If prior compress-tool results are present, always compress and summarize them minimally only as part of a broader compression pass. Do not invoke the compress tool solely to re-compress an earlier compression result.
4961
+ Messages marked as \`<dcp-message-id>BLOCKED</dcp-message-id>\` cannot be compressed.
4982
4962
 
4983
- \u89C4\u5219\uFF1A
4963
+ Rules:
4984
4964
 
4985
- - \u76F4\u63A5\u4ECE\u4E0A\u4E0B\u6587\u4E2D\u53EF\u89C1\u7684\u6CE8\u5165 ID \u9009\u53D6\u6BCF\u4E2A \`messageId\`\u3002
4986
- - \u53EA\u4F7F\u7528 \`mNNNN\` \u5F62\u5F0F\u7684\u539F\u59CB\u6D88\u606F ID\u3002
4987
- - \u590D\u5236 ID \u65F6\u5FFD\u7565 \`priority\` \u7B49 XML \u5C5E\u6027\uFF1B\u53EA\u4F7F\u7528\u5185\u90E8\u7684 \`mNNNN\` \u503C\u3002
4988
- - \u4E0D\u8981\u53D1\u660E ID\u3002\u53EA\u4F7F\u7528\u4E0A\u4E0B\u6587\u4E2D\u5B58\u5728\u7684 ID\u3002
4965
+ - Pick each \`messageId\` directly from injected IDs visible in context.
4966
+ - Only use raw message IDs of the form \`mNNNN\`.
4967
+ - Ignore XML attributes such as \`priority\` when copying the ID; use only the inner \`mNNNN\` value.
4968
+ - Do not invent IDs. Use only IDs that are present in context.
4989
4969
 
4990
- \u6279\u91CF\u5904\u7406
4991
- \u5F53\u591A\u6761\u6D88\u606F\u53EF\u4EE5\u5B89\u5168\u538B\u7F29\u65F6\uFF0C\u5728\u5355\u6B21\u5DE5\u5177\u8C03\u7528\u4E2D\u9009\u62E9\u591A\u6761\u6D88\u606F\u3002
4992
- \u6BCF\u4E2A\u6761\u76EE\u5E94\u6070\u597D\u6458\u8981\u4E00\u6761\u6D88\u606F\uFF0C\u5DE5\u5177\u53EF\u4EE5\u5728\u4E00\u6B21\u6279\u91CF\u4E2D\u63A5\u6536\u4EFB\u610F\u6570\u91CF\u7684\u6761\u76EE\u3002
4970
+ BATCHING
4971
+ Select MANY messages in a single tool call when they are safe to compress.
4972
+ Each entry should summarize exactly one message, and the tool can receive as many entries as needed in one batch.
4993
4973
 
4994
- \u901A\u7528\u6E05\u7406
4995
- \u4F7F\u7528\u4E3B\u9898"\u901A\u7528\u6E05\u7406"\u8FDB\u884C\u5E7F\u6CDB\u7684\u6E05\u7406\u3002
4996
- \u5728\u901A\u7528\u6E05\u7406\u671F\u95F4\uFF0C\u538B\u7F29\u6240\u6709\u4E0E\u5F53\u524D\u4EFB\u52A1\u65E0\u5173\u7684\u4E2D\u9AD8\u4F18\u5148\u7EA7\u6D88\u606F\u3002
4997
- \u4F18\u5316\u51CF\u5C11\u4E0A\u4E0B\u6587\u5360\u7528\uFF0C\u800C\u975E\u6309\u4E3B\u9898\u5206\u7EC4\u6D88\u606F\u3002
4998
- \u4E0D\u8981\u538B\u7F29\u6389\u4ECD\u7136\u6D3B\u8DC3\u7684\u6307\u4EE4\u3001\u672A\u89E3\u51B3\u7684\u95EE\u9898\u6216\u53EF\u80FD\u5F88\u5FEB\u91CD\u8981\u7684\u7EA6\u675F\u3002
4999
- \u4F18\u5148\u5904\u7406\u4E0A\u4E0B\u6587\u4E2D\u6700\u65E9\u7684\u6D88\u606F\uFF0C\u56E0\u4E3A\u5B83\u4EEC\u4E0E\u5F53\u524D\u4EFB\u52A1\u7684\u76F8\u5173\u6027\u6700\u4F4E\u3002
5000
- \u901A\u7528\u6E05\u7406\u5E94\u5B9A\u671F\u5728\u5176\u4ED6\u6B63\u5E38\u538B\u7F29\u5DE5\u5177\u8C03\u7528\u4E4B\u95F4\u8FDB\u884C\uFF0C\u800C\u975E\u4F5C\u4E3A\u538B\u7F29\u7684\u4E3B\u8981\u5F62\u5F0F\u3002
4974
+ GENERAL CLEANUP
4975
+ Use the topic "general cleanup" for broad cleanup passes.
4976
+ During general cleanup, compress all medium and high-priority messages that are not relevant to the active task.
4977
+ Optimize for reducing context footprint, not for grouping messages by topic.
4978
+ Do not compress away still-active instructions, unresolved questions, or constraints that are likely to matter soon.
4979
+ Prioritize the earliest messages in the context as they will be the least relevant to the active task.
4980
+ General cleanup should be done periodically between other normal compression tool passes, not as the primary form of compression.
5001
4981
  `;
5002
4982
 
5003
4983
  // lib/prompts/context-limit-nudge.ts