@morlay/dsh-preset 0.0.3 → 0.0.4
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 +55 -16
- package/cordis.patch.yml +13 -11
- package/package.json +4 -1
- package/src/__tests__/generated-presets.spec.ts +2 -2
- package/src/__tests__/patch.spec.ts +41 -0
- package/tool/generate-presets.ts +2 -2
package/README.md
CHANGED
|
@@ -6,12 +6,16 @@
|
|
|
6
6
|
|
|
7
7
|
## 内容
|
|
8
8
|
|
|
9
|
-
| 文件 | 作用
|
|
10
|
-
| -------------------------- |
|
|
11
|
-
| `cordis.patch.yml` | bundle patch:禁用官方 preset、注册本包 preset 为默认、声明个人 `llm-pi-ai` route |
|
|
12
|
-
| `tool/generate-presets.ts` | 从上游生成 preset 的模块 + tsdown hooks
|
|
13
|
-
| `dist/presets/standard/` | 构建产物:自定义 preset「标准模式」(由上游 `standard` 生成)
|
|
14
|
-
| `dist/presets/ptc/` | 构建产物:自定义 preset「PTC 模式」(由上游 `ptc` 生成)
|
|
9
|
+
| 文件 | 作用 |
|
|
10
|
+
| -------------------------- | ------------------------------------------------------------------------------------------------------------ |
|
|
11
|
+
| `cordis.patch.yml` | bundle patch:禁用官方 preset、注册本包 preset 为默认、声明个人 `llm-pi-ai` route、插入 `prompt-reminder` 行 |
|
|
12
|
+
| `tool/generate-presets.ts` | 从上游生成 preset 的模块 + tsdown hooks |
|
|
13
|
+
| `dist/presets/standard/` | 构建产物:自定义 preset「标准模式」(由上游 `standard` 生成) |
|
|
14
|
+
| `dist/presets/ptc/` | 构建产物:自定义 preset「PTC 模式」(由上游 `ptc` 生成) |
|
|
15
|
+
|
|
16
|
+
`cordis.patch.yml` 里插入的 `prompt-reminder`(`@morlay/dsh-prompt-reminder`)把被
|
|
17
|
+
裁掉的系统提示词 section 降级为 `<system-reminder>` user 消息,见「工具说明降级为
|
|
18
|
+
reminder」。
|
|
15
19
|
|
|
16
20
|
## 禁用官方 preset
|
|
17
21
|
|
|
@@ -69,11 +73,40 @@ section 在插件构造时注册;dev 模式重启 `just custom dev`/`just cust
|
|
|
69
73
|
roster(id 沿用官方名以走客户端语言字典),以及桌面形态下 preset 必须落在 dsh 包的
|
|
70
74
|
`config/agent-presets` 挂载点(见 dsh-desktopify 的 `dsh.desktop.agentPresets`)。
|
|
71
75
|
|
|
76
|
+
## 工具说明降级为 reminder,不进系统提示词
|
|
77
|
+
|
|
78
|
+
上游把每个工具的跨调用说明(`tool:bash`、`tool:read`、…)、Agent Teams 协作规则、
|
|
79
|
+
harness 源码位置、Web GUI 说明都注册成系统提示词的 section。本部署实测它们占
|
|
80
|
+
9200 字符里的约 7400:条数多、篇幅大、挤在上下文最前面,稀释真正要遵守的那几行
|
|
81
|
+
纪律。`cordis.patch.yml` 因此在 host plane 插一行:
|
|
82
|
+
|
|
83
|
+
```yaml
|
|
84
|
+
- insert:
|
|
85
|
+
- id: prompt-reminder
|
|
86
|
+
name: "@morlay/dsh-prompt-reminder"
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
一处定义覆盖全部 preset(standard / ptc 以及后续新增的)——这是与具体 preset 无关
|
|
90
|
+
的部署级策略,preset composition 不各自带这一行,生成器也就不必碰它。该插件注册
|
|
91
|
+
在 root scope,会收到每个 agent 的装配与 pre-step 事件(含子 agent):
|
|
92
|
+
|
|
93
|
+
- 装配(`system-prompt/assemble` 瀑布)时保留 `keep` 名单——默认是部署级
|
|
94
|
+
`deployment:persona-prefix` / `deployment:persona-suffix`——内的 section,其余
|
|
95
|
+
非空 section 从 assembly 移除并按 order 捕获文本;
|
|
96
|
+
- pre-step 时把捕获的文本作为一条 `<system-reminder>` user 消息注入,紧随本轮
|
|
97
|
+
用户消息之后;文本不变不重复注入,`plan:policy` / `tools:ptc-only` 这类按模式
|
|
98
|
+
渲染的 section 变化时追加一条新的全量 reminder(首行声明最新一条覆盖更早的)。
|
|
99
|
+
|
|
100
|
+
于是系统提示词只剩首尾两段个人提示词,其余内容仍在上下文里、但不再占系统提示词
|
|
101
|
+
的位置,也不再随模式切换改动。**为什么不用 `persona` 行的 `complete: true`**:那会
|
|
102
|
+
连 suffix 一起丢,且子 agent 自己注册同名 persona 时 `complete` 语义消失,保留 /
|
|
103
|
+
降级会不一致;本插件按 `keep` 名单匹配 section 名,两种 agent 行为一致。完整行为与
|
|
104
|
+
配置见 `packages/preset/dsh-prompt-reminder/README.md`。
|
|
105
|
+
|
|
72
106
|
## 工作区指令走官方行为,候选收紧为 AGENTS 系列
|
|
73
107
|
|
|
74
|
-
preset 里的 `agent-instructions`
|
|
75
|
-
|
|
76
|
-
仍按官方语义作为 user 消息注入一次。生成器只覆盖该行 config 的两个字段:
|
|
108
|
+
preset 里的 `agent-instructions` 行是官方 `@deepseek-ai/dsh-agent-instructions`:
|
|
109
|
+
baseline 按官方语义作为 user 消息注入一次。生成器只覆盖该行 config 的两个字段:
|
|
77
110
|
|
|
78
111
|
```yaml
|
|
79
112
|
instructionFileCandidates: ["AGENTS.md"] # 上游默认 ['AGENTS.md','CLAUDE.md']
|
|
@@ -82,8 +115,10 @@ localInstructionFileCandidates: ["AGENTS.local.md"] # 上游默认还含 CLAUDE.
|
|
|
82
115
|
|
|
83
116
|
即**不读 CLAUDE 系列**(本部署不需要 CLAUDE 兼容);`maxBytes` 等其余字段跟随上游。
|
|
84
117
|
|
|
85
|
-
|
|
86
|
-
|
|
118
|
+
本仓库曾有一个把 baseline 落点改成 system-prompt section 的 fork
|
|
119
|
+
(`@morlay/dsh-agent-instructions-as-prompt`),一直未接入默认打包;提示词分层定为
|
|
120
|
+
「系统提示词只留 persona、其余走 reminder」之后它已删除——baseline 留在 user 消息
|
|
121
|
+
通道与这个分层一致。
|
|
87
122
|
|
|
88
123
|
## preset 由构建生成,不是手工副本
|
|
89
124
|
|
|
@@ -102,10 +137,11 @@ pnpm --filter @morlay/dsh-preset run generate-presets [outDir]
|
|
|
102
137
|
```
|
|
103
138
|
|
|
104
139
|
脚本把上游 composition 当**数据**读入:`js-yaml` 用 include 的
|
|
105
|
-
`entryListSchema` 解析(`!!js` 标签保留为表达式节点)→ 在 JS
|
|
106
|
-
`persona`
|
|
107
|
-
|
|
108
|
-
persona
|
|
140
|
+
`entryListSchema` 解析(`!!js` 标签保留为表达式节点)→ 在 JS 里改三处(删掉
|
|
141
|
+
`persona` 行、把 `agent-instructions` 行的候选收紧为 AGENTS 系列、插入
|
|
142
|
+
`prompt-reminder` 行)→ `dump` 回 YAML。因此上游任何结构性改动(新增 / 重命名
|
|
143
|
+
row、改字段)都自动跟随,不依赖易碎的文本锚点;上游若删掉 `persona` 行,目标
|
|
144
|
+
(preset 不自带 persona)本就达成,脚本照常通过。
|
|
109
145
|
|
|
110
146
|
脚本先**整目录清空**输出目录再生成:产物完全派生自脚本,残留目录(改过
|
|
111
147
|
`source`、旧命名)不该留下——否则 discovery 会把它们当有效 preset 扫出来。
|
|
@@ -118,7 +154,7 @@ persona)本就达成,脚本照常通过。
|
|
|
118
154
|
|
|
119
155
|
1. 升级 `DEEPSEEK_HARNESS_VERSION` 并 sync/patch/build。
|
|
120
156
|
2. `pnpm --filter @morlay/dsh-preset run build`(build:done 会重新生成)
|
|
121
|
-
3. `pnpm exec vitest run packages/preset
|
|
157
|
+
3. `pnpm exec vitest run packages/preset` 确认无 drift(含 reminder 插件的行为测试)。
|
|
122
158
|
|
|
123
159
|
## 装配
|
|
124
160
|
|
|
@@ -159,6 +195,9 @@ profile 里把内容物化到该挂载点;`includeShippedRoot: false` 两种
|
|
|
159
195
|
## 维护注意
|
|
160
196
|
|
|
161
197
|
- `package.json` 的 `files` 必须含 `dist`(preset 在其中)与 `tool`,否则发布产物缺内容。
|
|
198
|
+
- `cordis.patch.yml` 插入的 `@morlay/dsh-prompt-reminder` 必须能被 **profile** 的依赖
|
|
199
|
+
树解析:示例 app 已在 `dependencies` 声明;换工作区时要一并声明,否则该行加载失败、
|
|
200
|
+
工具说明会留在系统提示词里。
|
|
162
201
|
- 生成器显式设 `quotingType: '"'`:`yaml.dump` 默认单引号而仓库 oxfmt 偏好双引号,
|
|
163
202
|
不指定会让生成器与 formatter 来回改;产物在 gitignore 的 dist 里,本就不参与 fmt。
|
|
164
203
|
- **dev 模式需要先构建**:`just dev` / `just desktop` / `just bundle` 都先跑
|
package/cordis.patch.yml
CHANGED
|
@@ -2,21 +2,16 @@
|
|
|
2
2
|
config:
|
|
3
3
|
includeHarnessIdentity: false
|
|
4
4
|
includeRuntimeContext: false
|
|
5
|
-
personaSuffix:
|
|
5
|
+
personaSuffix: |-
|
|
6
|
+
你的工作目录在 `{{cwd}}`,工作目录内的 AGENTS.md 的规则非常重要,必须严格遵守
|
|
6
7
|
personaPrefix: |-
|
|
7
8
|
你是一个经验丰富的编程专家,YAGNI 是你的编程哲学,PDCA 是你的行为规范
|
|
8
9
|
|
|
9
|
-
##
|
|
10
|
+
## 语言和行为
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
- **全局提示词**:
|
|
15
|
-
- 所有思考、分析、推理过程、工具调用描述等必须使用中文,专有名词除外
|
|
16
|
-
- 思考不要陷入重复循环,一旦循环,立即退出
|
|
17
|
-
- 思考聚焦需求理解与方案设计(要点、流程、验证策略),不预演具体代码实现;代码在 Do 阶段基于实际文件状态输出,正确性由 Check 验证
|
|
18
|
-
|
|
19
|
-
协议:动手前读相关 `AGENTS.md`(不凭记忆);过程中自检、违反即纠正;交付前核对红线与验证证据,未验证项必须标注;无法遵守时立即说明(不静默忽略、不自行判定「不适用」);派发子代理时把约束写进任务说明。
|
|
12
|
+
- 所有思考、分析、推理过程、工具调用描述等必须使用中文,专有名词除外
|
|
13
|
+
- 思考不要陷入重复循环,一旦循环,立即退出
|
|
14
|
+
- 思考聚焦需求理解与方案设计(要点、流程、验证策略),不预演具体代码实现;代码在 Do 阶段基于实际文件状态输出,正确性由 Check 验证
|
|
20
15
|
|
|
21
16
|
- id: agent-presets
|
|
22
17
|
config:
|
|
@@ -62,3 +57,10 @@
|
|
|
62
57
|
low: low
|
|
63
58
|
high: high
|
|
64
59
|
max: max
|
|
60
|
+
|
|
61
|
+
# 提示词分层:系统提示词只留上面的 persona,工具说明 / Agent Teams 规则 / plan
|
|
62
|
+
# 规则等由该插件降级为 <system-reminder> user 消息。部署级策略,在这里定义一次
|
|
63
|
+
# 即覆盖全部 preset(含子 agent),preset composition 不再各自带这一行。
|
|
64
|
+
- insert:
|
|
65
|
+
- id: prompt-reminder
|
|
66
|
+
name: "@morlay/dsh-prompt-reminder"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morlay/dsh-preset",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Personal dsh profile bundle: disables the shipped agent presets, builds generated standard / ptc presets into dist, and declares personal llm-pi-ai provider routes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
|
@@ -25,6 +25,9 @@
|
|
|
25
25
|
"./package.json": "./package.json",
|
|
26
26
|
"./cordis.patch.yml": "./cordis.patch.yml"
|
|
27
27
|
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@morlay/dsh-prompt-reminder": "^0.0.1"
|
|
30
|
+
},
|
|
28
31
|
"devDependencies": {
|
|
29
32
|
"@deepseek-ai/cordis-plugin-include": "^1.0.7",
|
|
30
33
|
"@deepseek-ai/dsh-agent-presets": "^0.1.5-rc.2",
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
/** 上游 preset 里承载工作区指令的行 id。 */
|
|
30
30
|
const INSTRUCTIONS_ROW_ID = "agent-instructions";
|
|
31
31
|
|
|
32
|
-
/**
|
|
32
|
+
/** 上游那行指向的官方插件(产物须保持官方名;提示词分层由 profile 的 patch 承担)。 */
|
|
33
33
|
const UPSTREAM_INSTRUCTIONS_PLUGIN = "@deepseek-ai/dsh-agent-instructions";
|
|
34
34
|
|
|
35
35
|
/** 产物里指令候选的文件名(字面量:不读 CLAUDE 系列)。 */
|
|
@@ -105,7 +105,7 @@ describe("generated presets", () => {
|
|
|
105
105
|
expect(productRow?.config?.localInstructionFileCandidates).toEqual(["AGENTS.local.md"]);
|
|
106
106
|
// 其余 config 字段跟随上游(如 maxBytes 的字节预算)。
|
|
107
107
|
expect(productRow?.config?.maxBytes).toBe(upstreamRow?.config?.maxBytes);
|
|
108
|
-
//
|
|
108
|
+
// 提示词分层(prompt-reminder)是 profile 的 bundle patch,不进 preset 产物。
|
|
109
109
|
expect(
|
|
110
110
|
product.some((row) => typeof row.name === "string" && row.name.startsWith("@morlay/")),
|
|
111
111
|
).toBe(false);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// 装配守卫:prompt-reminder 是 host plane 的唯一装配点。被误删 / 改名时提示词分层
|
|
2
|
+
// 静默失效(工具说明回到系统提示词),这里 fail loud;persona 是 keep 名单的唯一
|
|
3
|
+
// 提供者,删掉它系统提示词会变空。
|
|
4
|
+
|
|
5
|
+
import { readFileSync } from "node:fs";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { entryListSchema } from "@deepseek-ai/cordis-plugin-include";
|
|
8
|
+
import yaml from "js-yaml";
|
|
9
|
+
import { describe, expect, it } from "vitest";
|
|
10
|
+
|
|
11
|
+
const PATCH_PATH = join(process.cwd(), "packages/preset/dsh-preset/cordis.patch.yml");
|
|
12
|
+
|
|
13
|
+
/** patch 的一行;只用到覆盖目标与 insert 的新增行。 */
|
|
14
|
+
interface PatchRow {
|
|
15
|
+
id?: string;
|
|
16
|
+
config?: Record<string, unknown>;
|
|
17
|
+
insert?: { id?: string; name?: string }[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// 用 include 的 entry schema 解析:patch 里含 `!!js` 表达式,默认 schema 会拒绝。
|
|
21
|
+
const rows = yaml.load(readFileSync(PATCH_PATH, "utf8"), {
|
|
22
|
+
schema: entryListSchema,
|
|
23
|
+
}) as PatchRow[];
|
|
24
|
+
|
|
25
|
+
describe("dsh-preset patch wiring", () => {
|
|
26
|
+
it("declares the prompt-reminder row exactly once, on the local plugin", () => {
|
|
27
|
+
const inserted = rows
|
|
28
|
+
.flatMap((row) => row.insert ?? [])
|
|
29
|
+
.filter((row) => row.id === "prompt-reminder");
|
|
30
|
+
|
|
31
|
+
expect(inserted).toHaveLength(1);
|
|
32
|
+
expect(inserted[0]?.name).toBe("@morlay/dsh-prompt-reminder");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("keeps the deployment persona the reminder keeps in the system prompt", () => {
|
|
36
|
+
const config = rows.find((row) => row.id === "system-prompt")?.config;
|
|
37
|
+
|
|
38
|
+
expect(config?.personaPrefix).toBeTruthy();
|
|
39
|
+
expect(config?.personaSuffix).toBeTruthy();
|
|
40
|
+
});
|
|
41
|
+
});
|
package/tool/generate-presets.ts
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* `agent-instructions` 行的指令候选收紧为 AGENTS 系列),再 `dump` 回 YAML。
|
|
10
10
|
* 上游任何结构性改动(新增/重命名 row、改字段)都自动跟随,不依赖易碎的文本锚点。
|
|
11
11
|
*
|
|
12
|
-
* `agent-instructions`
|
|
13
|
-
*
|
|
12
|
+
* `agent-instructions` 行是上游官方插件:工作区指令的 baseline 留在 user 消息通道,
|
|
13
|
+
* 与「系统提示词只留 persona、其余走 reminder」的分层一致。
|
|
14
14
|
*
|
|
15
15
|
* 产物落在 `dist/` 而非源码树:dist 是构建输出(gitignore),既不会与 oxfmt
|
|
16
16
|
* 互相改格式,也不会把派生文件混进源码。
|