dsh-auto-compaction-engine 0.2.0 → 0.2.1
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/lib/index.js +29 -28
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
* At a configurable share of the model window (default 90%) this backend waits
|
|
7
7
|
* for the agent to go idle, then asks the routed model — replaying the current
|
|
8
8
|
* conversation as the prompt prefix so the provider's cache is reused — for a
|
|
9
|
-
* handoff checkpoint, and replaces the
|
|
10
|
-
* message.
|
|
11
|
-
*
|
|
9
|
+
* handoff checkpoint, and replaces the oldest compactable span with that one
|
|
10
|
+
* message. Selection comes from the stock backend, so a recent tail is kept
|
|
11
|
+
* verbatim (retainRatio 0.16 of the window by default) and the cut never splits
|
|
12
|
+
* a tool-call from its result; only the head of the history becomes the
|
|
13
|
+
* checkpoint.
|
|
12
14
|
*
|
|
13
15
|
* It subclasses the stock basic backend so selection, tool-pair balance,
|
|
14
16
|
* durable compaction markers, flushes and the idle admission reservation are
|
|
@@ -85,41 +87,40 @@ function readTemplate(filePath, autoCreate) {
|
|
|
85
87
|
|
|
86
88
|
|
|
87
89
|
const BUILTIN_INSTRUCTION = [
|
|
88
|
-
"
|
|
90
|
+
"你现在充当这个 AI 编程助手的压缩引擎。请把上面的对话压缩成一份结构化检查点,让另一个模型能在不丢失关键上下文的前提下接手继续这项工作。",
|
|
89
91
|
"",
|
|
90
|
-
"
|
|
92
|
+
"严格按下面给出的 Markdown 结构输出:每个小节都要保留,顺序不要变。用简短的要点,不要写成成段的散文。空的小节写「(无)」——绝不允许删掉某个小节。",
|
|
91
93
|
"",
|
|
92
|
-
"##
|
|
93
|
-
"-
|
|
94
|
+
"## 用户主要请求与意图",
|
|
95
|
+
"- [用户的原始目标以及后来的演变;措辞要紧之处逐字引用]",
|
|
94
96
|
"",
|
|
95
|
-
"##
|
|
96
|
-
"-
|
|
97
|
+
"## 关键技术概念",
|
|
98
|
+
"- [当前涉及的技术、框架、模式与约定]",
|
|
97
99
|
"",
|
|
98
|
-
"##
|
|
99
|
-
"-
|
|
100
|
+
"## 文件与代码",
|
|
101
|
+
"- [精确路径:为什么重要,关键改动或代码片段]",
|
|
100
102
|
"",
|
|
101
|
-
"##
|
|
102
|
-
"-
|
|
103
|
+
"## 报错与修复",
|
|
104
|
+
"- [错误:是怎么解决的,以及与之相关的用户反馈]",
|
|
103
105
|
"",
|
|
104
|
-
"##
|
|
105
|
-
"-
|
|
106
|
+
"## 未完成的任务",
|
|
107
|
+
"- [明确要求过但尚未完成的工作]",
|
|
106
108
|
"",
|
|
107
|
-
"##
|
|
108
|
-
"-
|
|
109
|
+
"## 当前工作",
|
|
110
|
+
"- [在这个检查点上具体正在做什么]",
|
|
109
111
|
"",
|
|
110
|
-
"##
|
|
111
|
-
"-
|
|
112
|
+
"## 下一步",
|
|
113
|
+
"- [紧接的单个动作,须与最近一次请求直接对齐;没有则写「(无)」]",
|
|
112
114
|
"",
|
|
113
|
-
"
|
|
114
|
-
"-
|
|
115
|
-
"- 如果对话里有用户粘贴的长文档或上一轮交接文档(例如包在 <compacted-summary> 标记里的那份),不要原样照抄:保留仍然生效的硬约束(路径、命令、版本、验收标准)并逐字引用其关键句,其余概括;过时的内容删掉,最终只输出一份同样结构的文档。",
|
|
116
|
-
"- 如果用户的早期消息给出了一份磁盘上的工程交接文档的绝对路径,必须逐字保留该路径并注明\"需要时重新读取该文件\";不要把它的内容当成必须在本文档里复述的东西。",
|
|
117
|
-
"- 不要提到这份交接文档本身,也不要说上下文被压缩或摘要。",
|
|
118
|
-
"- 只输出文档正文,不要调用任何工具。",
|
|
115
|
+
"## 关键上下文",
|
|
116
|
+
"- [决策及其理由、约束条件、用户偏好、尚未解决的问题、继续所需的资料]",
|
|
119
117
|
"",
|
|
120
|
-
"
|
|
121
|
-
"-
|
|
122
|
-
"-
|
|
118
|
+
"规则:",
|
|
119
|
+
"- 用简洁的中文工程表述书写。精确保留文件路径、命令、报错串、标识符、数值、函数签名与语法片段。",
|
|
120
|
+
"- 忠实保留用户的反馈与明确指令,尤其是纠正。",
|
|
121
|
+
"- 不要提到本摘要请求,也不要说上下文被压缩过。",
|
|
122
|
+
"- 只输出检查点正文:不要调用任何工具,也不要执行任何其他动作。",
|
|
123
|
+
"- 如果对话里已经含有 <compacted-summary> 块,那是一份 PRIOR 检查点。不要把它逐字抄到新的摘要里:保留仍然成立的事实,删掉过时的,并把更新的信息按同样的结构合并进这一份摘要。",
|
|
123
124
|
].join("\n");
|
|
124
125
|
|
|
125
126
|
function finishError(finish) {
|