@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 +1 -1
- package/dist/index.js +91 -111
- package/dist/index.js.map +1 -1
- package/dist/lib/prompts/compress-message.d.ts +1 -1
- package/dist/lib/prompts/compress-message.d.ts.map +1 -1
- package/dist/lib/prompts/compress-range.d.ts +1 -1
- package/dist/lib/prompts/compress-range.d.ts.map +1 -1
- package/dist/lib/prompts/system.d.ts +1 -1
- package/dist/lib/prompts/system.d.ts.map +1 -1
- package/package.json +1 -1
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/
|
|
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/
|
|
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
|
-
|
|
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
|
-
|
|
4845
|
+
The ONLY tool you have for context management is \`compress\`. It replaces older conversation content with technical summaries you produce.
|
|
4846
4846
|
|
|
4847
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
4854
|
+
COMPRESS WHEN
|
|
4860
4855
|
|
|
4861
|
-
|
|
4856
|
+
A section is genuinely closed and the raw conversation has served its purpose:
|
|
4862
4857
|
|
|
4863
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
-
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
4900
|
-
|
|
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
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
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
|
-
|
|
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
|
-
|
|
4909
|
-
|
|
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
|
-
|
|
4893
|
+
Compressed block sections in context are clearly marked with a header:
|
|
4914
4894
|
|
|
4915
|
-
- \`[
|
|
4895
|
+
- \`[Compressed conversation section]\`
|
|
4916
4896
|
|
|
4917
|
-
|
|
4897
|
+
Compressed block IDs always use the \`bN\` form (never \`mNNNN\`) and are represented in the same XML metadata tag format.
|
|
4918
4898
|
|
|
4919
|
-
|
|
4899
|
+
Rules:
|
|
4920
4900
|
|
|
4921
|
-
-
|
|
4922
|
-
-
|
|
4923
|
-
-
|
|
4924
|
-
-
|
|
4925
|
-
-
|
|
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
|
-
|
|
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
|
-
|
|
4930
|
-
|
|
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
|
-
-
|
|
4933
|
-
-
|
|
4934
|
-
-
|
|
4935
|
-
-
|
|
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
|
-
|
|
4938
|
-
|
|
4917
|
+
BOUNDARY IDS
|
|
4918
|
+
You specify boundaries by ID using the injected IDs visible in the conversation:
|
|
4939
4919
|
|
|
4940
|
-
- \`mNNNN\`
|
|
4941
|
-
- \`bN\`
|
|
4920
|
+
- \`mNNNN\` IDs identify raw messages
|
|
4921
|
+
- \`bN\` IDs identify previously compressed blocks
|
|
4942
4922
|
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
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
|
-
|
|
4927
|
+
Rules:
|
|
4948
4928
|
|
|
4949
|
-
-
|
|
4950
|
-
-
|
|
4951
|
-
- \`startId\`
|
|
4952
|
-
-
|
|
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
|
-
|
|
4955
|
-
|
|
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 =
|
|
4939
|
+
var COMPRESS_MESSAGE = `Collapse selected individual messages in the conversation into detailed summaries.
|
|
4960
4940
|
|
|
4961
|
-
|
|
4962
|
-
|
|
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
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
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
|
-
|
|
4969
|
-
|
|
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
|
-
|
|
4972
|
-
|
|
4951
|
+
MESSAGE IDS
|
|
4952
|
+
You specify individual raw messages by ID using the injected IDs visible in the conversation:
|
|
4973
4953
|
|
|
4974
|
-
- \`mNNNN\`
|
|
4954
|
+
- \`mNNNN\` IDs identify raw messages
|
|
4975
4955
|
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
\`priority\`
|
|
4980
|
-
|
|
4981
|
-
|
|
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
|
-
|
|
4963
|
+
Rules:
|
|
4984
4964
|
|
|
4985
|
-
-
|
|
4986
|
-
-
|
|
4987
|
-
-
|
|
4988
|
-
-
|
|
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
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
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
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
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
|