dsh-coding 0.1.1-rc1 → 0.1.1-rc2

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/AGENTS.md ADDED
@@ -0,0 +1,80 @@
1
+ # AGENTS.md — DSH Coding 编程智能体维护指南
2
+
3
+ 面向智能体与维护者的通用指令与仓库入口。使用者看 [README](README.md);为什么这样设计见 [docs/DETAIL.md](docs/DETAIL.md)。
4
+
5
+ **按目录阅读**(上游 `agent-instructions` 会在触碰对应目录文件时自动注入子文件;也可以主动读):
6
+
7
+ - 改 `src/` 下任何代码前:先读 [src/AGENTS.md](https://github.com/ygzhang-lab/dsh-coding/blob/main/src/AGENTS.md)(DSH 契约表、约束 1-23、src 模块表、调试表)。
8
+ - 改 `test/` 前:读 [test/AGENTS.md](https://github.com/ygzhang-lab/dsh-coding/blob/main/test/AGENTS.md)(测试矩阵、验证步骤)。
9
+ - 改 `scripts/` 前:读 [scripts/AGENTS.md](https://github.com/ygzhang-lab/dsh-coding/blob/main/scripts/AGENTS.md)(构建流程与挂载调试)。
10
+
11
+ ## 会话边界:一次会话只跑一个任务
12
+
13
+ 一个 Coding 会话只服务一个任务;换任务请新开会话,不要在同一个会话里接着做第二个任务。
14
+
15
+ 原因:`coding_handoff` 的 constraints / decisions / findings / acceptance / tasks 等列表字段只追加,只有 `goal` 与 `delivered` 会覆盖;复用会话时,上一个任务的 `acceptance` 仍会满足新任务进入 verify / deliver 的门禁,等于用旧证据放行新任务。`coding_handoff({ reset: true })` 只重置验证重试预算,不清空交接记录。
16
+
17
+ ## 0. 不可违背的硬规则(速览,完整条款见 src/AGENTS.md)
18
+
19
+ 1. 门禁只用 `deny`,不要改成 `ask`(审批语义)。详见 src/AGENTS.md 约束 1。
20
+ 2. `tools.restrict` 裁剪与 `tools/pre-execute`/guard 拒绝必须双层并存。详见 src/AGENTS.md 约束 2。
21
+ 3. 子代理白名单只写在预设组合里,不继承父级限制,也不经 `agentOptions` 传递。详见 src/AGENTS.md 约束 4。
22
+ 4. 不新增自定义 Session 事件类型;新状态放进整值 checkpoint 或 `ctx.sessionProjections`。详见 src/AGENTS.md 约束 5。
23
+ 5. 所有监听与注册(含客户端 `locale`/Definition)都包在 `ctx.effect` 里。详见 src/AGENTS.md 约束 6。
24
+ 6. worker 路由缺失必须失败,不得回退主代理模型。详见 src/AGENTS.md 约束 7。
25
+
26
+ ## 1. 环境与命令
27
+
28
+ - Node.js ≥ 24.9.0(`.node-version` 已锁定)
29
+ - pnpm 12+
30
+ - DSH 0.2.2-rc.5(本插件按该版本的实际契约实现,见 src/AGENTS.md 的契约表)
31
+
32
+ ```bash
33
+ pnpm install
34
+ pnpm typecheck # tsc --noEmit
35
+ pnpm build # 生成 lib/*.js、lib/types/**、lib/client.js
36
+ pnpm test # 先 build,再 node --test test/*.test.mjs
37
+ ```
38
+
39
+ **测试跑的是构建产物 `lib/*.js`,不是源码。** 改完 `src/` 必须先 `pnpm build` 再跑测试,否则测的是旧代码;测试矩阵与验证步骤细节见 [test/AGENTS.md](test/AGENTS.md)。
40
+
41
+ ## 2. 目录总览
42
+
43
+ - `src/` —— 插件源码(含浏览器半 `src/client/`);src 模块表见 [src/AGENTS.md](src/AGENTS.md)。
44
+ - `test/` —— node:test 用例(跑构建产物)。
45
+ - `scripts/` —— 构建流程与挂载调试脚本。
46
+ - `docs/` —— 设计文档。
47
+ - `locale/` —— 界面文案。
48
+ - 根文件 —— `cordis.patch.yml`、`package.json`、`README.md`。
49
+
50
+ ## 3. 构建产物
51
+
52
+ | 入口 | 产物 | 说明 |
53
+ | --------------------- | ----------------- | ------------------------------------------------------------- |
54
+ | `dsh-coding` | `lib/index.js` | Host 设置服务;同时导出 `Config` 与 `configSchema` |
55
+ | `dsh-coding/preset` | `lib/preset.js` | 预设运行时 |
56
+ | `dsh-coding/editor` | `lib/editor.js` | `apply_patch` |
57
+ | `dsh-coding/verifier` | `lib/verifier.js` | `run_verification` |
58
+ | `dsh-coding/client` | `lib/client.js` | 浏览器模块表:`window.__ModuleLoader__.load({ id, factory })` |
59
+
60
+ 宿主代码只编译、不打包,所有 `@deepseek-ai/*` 保持外部引用,运行时由 DSH 安装目录解析;客户端用 esbuild 打包为 CJS,再由脚本包一层模块表工厂,React 由宿主模块表提供。`scripts/build.mjs` 先写临时目录、全部成功后才替换 `lib/`,构建失败不会留下半成品。
61
+
62
+ ## 4. 发布
63
+
64
+ ```bash
65
+ pnpm typecheck && pnpm build && pnpm test
66
+ pnpm pack --dry-run # 检查 files 是否包含 lib/locale/docs/icon/patch
67
+ pnpm publish # prepublishOnly 会再跑一遍 typecheck/build/test
68
+ ```
69
+
70
+ 本地安装调试:`plugin_manager install_bundle` 传工作区绝对路径,或 `dsh plugin --profile <profile> add /绝对路径`。替换已安装版本需先移除再安装(同一路径的 `link:` 会直接读取新产物,但正在运行的 JS 需要重载)。
71
+
72
+ ## 5. 跨平台注意事项
73
+
74
+ 项目在 macOS 上开发,Windows 上继续维护时注意以下已实测的差异:
75
+
76
+ 1. **shell 调用按平台分叉**:`src/verification.ts` 的 `shellArgv()` 在 Windows 上返回 `['cmd.exe','/d','/s','/c',command]`,其它平台返回 `['/bin/sh','-c',command]`。任何断言 `argv` 前缀的测试都必须按 `process.platform` 推导期望值,不要硬编码 `/bin/sh`。
77
+ 2. **DSH 沙箱会拦截子进程管道**:在 DSH 的 `workspace-write` 文件沙箱下,`pnpm build`(esbuild)与 `pnpm test`(`node --test` 为每个测试文件起子进程)会以 `spawn EPERM` 失败,因为子进程需要管道 stdio。这不是代码缺陷:在普通终端运行,或在 DSH 中对该命令提权后运行。
78
+ 3. **`src/system-language.ts` 只有 macOS 分支**:读取 `AppleLanguages` 的探测仅 macOS 生效,其它平台返回空数组并回退到宿主的 locale 解析;改语言逻辑时不要假设该模块在 Windows 有输出。
79
+ 4. **路径处理一律用 `node:path`**:不要拼接 `/` 或假设大小写不敏感;测试里的固定路径字符串(如 `/tmp/fixture`)只作为传入假 provider 的不透明值。
80
+ 5. 文档与代码注释使用中文,标识符、命令、报错原文保持原样。
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 ygzhang
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ygzhang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,6 +1,41 @@
1
1
  # DSH Coding 编程智能体
2
2
 
3
- DSH 编程智能体运行时插件,借鉴 Claude 任务编排机制,Codex 五段式契约层层推进,DeepSeek Pro 分析需求、编排任务,Flash 子智能体去干活,确保任务交付质量和 Token 价值最大化。
3
+ DSH 编程智能体插件,工程化任务编排机制,Codex 五段式契约层层推进,Pro 模型负责分析需求/编排任务,交由子代理隔离各项任务使用 Flash 模型干活,确保任务交付质量和 Token 价值最大化。
4
+ DSH programming intelligent agent plugin, engineering task orchestration mechanism, Codex five-stage contract progressing layer by layer, Pro model responsible for analyzing requirements/orchestrating tasks, delegating to sub-agents to isolate various tasks and using Flash model to perform work, ensuring task delivery quality and maximizing Token value.
5
+
6
+ [![GitHub Repo stars](https://img.shields.io/github/stars/ygzhang-lab/dsh-coding?style=flat&logo=github)](https://github.com/ygzhang-lab/dsh-coding)
7
+ ![GitHub License](https://img.shields.io/github/license/ygzhang-lab/dsh-coding)
8
+ [![NPM Version](https://img.shields.io/npm/v/dsh-coding)](https://www.npmjs.com/package/dsh-coding)
9
+ [![NPM Downloads](https://img.shields.io/npm/dy/dsh-coding)](https://www.npmjs.com/package/dsh-coding)
10
+ [![Listed on dsh-plugin.org](https://dsh-plugin.org/badges/listed.svg)](https://dsh-plugin.org/zh/plugins/ygzhang-lab/dsh-coding)
11
+
12
+ 插件名是 `dsh-coding`,NPM 包名是 `dsh-coding`,在 DSH 中的插件显示名是 **DSH Coding**。源码与 issue 在 [ygzhang-lab/dsh-coding](https://github.com/ygzhang-lab/dsh-coding)。
13
+
14
+ ## 本插件价值
15
+
16
+ **一切皆插件/自由过了火**
17
+
18
+ DSH 作为通用 Harness 基座,开源至今火出天际,但没有内置工程化任务智能体,能力依赖插件组合实现。自由是把双刃剑:社区插件生态丰富,不少插件维护滞后甚至无人维护;纯对话式、许愿式的编程方式,面对工程项目/模块构建这类长编程任务体验不佳,上下文遗忘、反复重来。
19
+
20
+ - **工程化任务设计**:内置工程化任务编排机制,Codex 五段式契约层层推进。脱离古法编程,不再靠对话框反复确认 Plan A、修复回归 Plan B。
21
+ - **提高任务交付质量**:每轮交付都要过门禁——需求分析充分、任务单明确、编辑完整落盘、验证真实跑过,避免“看起来做完”的常见问题。
22
+ - **Token 价值最大化**:Pro 模型只做需求分析与任务拆分,编辑与核查交给 Flash 子代理;工具表按阶段裁剪、交接记录有界,不为长对话和无关工具反复付费。
23
+ - **过程可见可回溯**:每轮一张会话控制卡片、每次 Coding 工具调用一枚阶段胶囊,都从持久事件回放;刷新、重开、翻页看到的都是当时真实的阶段与验证状态。
24
+
25
+ ## 特性
26
+
27
+ | 特性 | 工作机制 |
28
+ | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
29
+ | **阶段门禁由插件判定** | 模型只能提出推进请求(`requirements → plan → implement → verify → deliver`),是否放行由插件按事实决定:是否完成只读观察、是否有任务单、是否有编辑落盘、最近一次验证是否通过;被拒时返回含当前阶段、允许阶段与补救动作的 `reason` |
30
+ | **双层门禁,不靠提示词自律** | `tools/pre-execute` waterfall 负责友好拒绝,`ctx.tools.guard` 是单调生效的最终边界;两层共用同一个 `checkTool` 判定函数,不会漂移。门禁用 `deny` 而非 `ask`,模型看到 `Error: <reason>` 后自行纠正 |
31
+ | **工具按阶段物理裁剪** | 实现阶段主代理的工具表只剩 `delegate_implement`、`coding_handoff`、`todo_write`、shell(`bash` / `pwsh`)与控制类工具;编辑工具被移除,既看不见也调不到,改文件仍走 `delegate_implement`;交付阶段连命令也不授予 |
32
+ | **子代理隔离执行 + 模型分工** | planner / implement / verify 三个 worker 各有独立上下文、独立工具白名单与独立路由:Pro 负责勘探现状与拆分任务,Flash 负责编辑与核查。codex 下任务单严格大于三条(多文件改动)时 planner 是**强制步骤**:本会话未派发过 `delegate_plan` 就不能进入实现,派发失败也算一次尝试(尝试只记进整值 checkpoint,不新增 Session 事件);主 Agent 自身模型就是 planner 路由时跳过,`requirePlanner: off` 可整条关闭。worker 路由缺失、格式错误或模型不可用时直接失败并给出字段名与可用模型,绝不悄悄回退主代理模型。implement worker 固定携带仓库指令(`AGENTS.md`),verify worker 只在 codex 且任务复杂(多子任务或改动文件 ≥3)时才改用带指令的验证预设,普通核查保持精简 |
33
+ | **有界交接取代对话记忆** | 目标、约束、验收标准、决策与任务写进 `coding_handoff`,随 checkpoint 持久化,重启与翻页可恢复;注入 worker 提示词时按角色裁剪并有字符/条数上限,不把整段对话塞给子代理 |
34
+ | **语义化验证 + 防死循环** | `run_verification` 从项目 manifest 自动探测命令与包管理器(pnpm / npm / yarn / bun);命令级超时 `verificationTimeoutMs` 到点终止并记为失败;失败按签名计入 `maxVerifyAttempts` / `maxSameFailure`,耗尽后只放行一次 BLOCKED 交付,再次验证通过才自动清零 |
35
+ | **状态可见、控制回流** | 每轮一张会话控制卡片(模式、阶段路径、推理等级、验证状态、任务单进度、改动文件数),每次 Coding 工具调用一枚阶段胶囊;两者只读,控制动作一律经 `/coding` 命令回流 Host,前端不直接改状态,旧轮冻结在它实际运行的模式与阶段 |
36
+ | **本轮完成后一键生成交接文档** | 最新一轮卡片在该轮以 codex 交付并通过验证后出现「结束任务并生成交接文档」按钮,二次确认后把本轮目标、验收标准、交付记录、验证与改动文件写成 `<会话 cwd>/.agents/memory/<sessionId>-<YYYYMMDD-HHmmss>.md`;历史轮与非 codex 轮不显示按钮,按钮只写文档,不改变运行时状态 |
37
+ | **失败只播报一次** | 八个关键调度点(projection / restore / tool-table / reasoning / delegate / verification / handoff / command)的阻断性异常注入一条“运行中断”通知(原因 + 处理),不新开 Turn、不新增事件类型;同点恢复成功后自动清除 |
38
+ | **模式与推理等级可调** | 自动 / 问答 / 审查 / Codex 四种工作模式;推理等级支持 `auto` 按任务规模分类(问答与单文件 Low、多文件与模块级 High、项目级 Max,同一轮只升不降),也可配置固定或会话覆盖 |
4
39
 
5
40
  ## 安装
6
41
 
@@ -10,26 +45,33 @@ DSH 编程智能体运行时插件,借鉴 Claude 任务编排机制,Codex
10
45
  dsh plugin --profile <profile> add dsh-coding
11
46
  ```
12
47
 
13
- 安装插入五行:Host 设置服务、`Coding` 预设,以及三个内部 worker 预设(planner / implement / verify)。已有会话不受影响;只有选择 `Coding` 预设的新会话启用运行时。
48
+ ## 更新
49
+
50
+ 插件市场 / **插件** 页面:**DSH Coding** → **更新**。
51
+
52
+ 或手动更新:卸载插件再重新安装。
53
+
54
+ > 注意:插件卸载或更新后,需要重新启动 DSH 。
14
55
 
15
56
  ## 配置
16
57
 
17
- 装好后在 **插件 → DSH Coding 编程智能体** 页面可视化编辑(保存后立即生效)。`verificationCommands`、`verificationTimeoutMs` 与两个验证预算键是普通字段,需改插件包配置(`cordis.patch.yml`):
58
+ 装好后在 **插件 → DSH Coding 编程智能体** 页面可视化编辑(保存后立即生效)。`requirePlanner`、`verificationCommands`、`verificationTimeoutMs` 与两个验证预算键是普通字段(非 volatile,不出现在插件页),需改插件包配置(`cordis.patch.yml`):
18
59
 
19
60
  ```yaml
20
61
  - id: dsh-coding
21
62
  name: "dsh-coding"
22
63
  config:
23
- defaultMode: auto # auto | consult | review | codex
24
- language: auto # auto | zh | en
25
- reasoning: auto # auto | low | high | max
26
- plannerWorkerModel: provider/model # 必填
27
- implementWorkerModel: provider/model # 必填
28
- verifyWorkerModel: provider/model # 必填
29
- verificationTimeoutMs: 360000 # 单次验证命令超时(ms);0 表示不限制
30
- verificationCommands: {} # 按 kind / kind:scope 覆盖验证命令
31
- maxVerifyAttempts: 5 # 验证失败重试预算;0 表示不限制
32
- maxSameFailure: 2 # 相同失败签名连续出现上限;0 表示不限制
64
+ defaultMode: auto # auto | consult | review | codex
65
+ language: auto # auto | zh | en
66
+ reasoning: auto # auto | low | high | max
67
+ plannerWorkerModel: provider/model # 必填,插件安装初始值:deepseek-account/deepseek-v4-pro
68
+ requirePlanner: complex # complex | off;complex 时 codex 下任务单严格大于三条必须先 delegate_plan,off 关闭该门禁
69
+ implementWorkerModel: provider/model # 必填,插件安装初始值:deepseek-account/deepseek-flash
70
+ verifyWorkerModel: provider/model # 必填,插件安装初始值:deepseek-account/deepseek-flash
71
+ verificationTimeoutMs: 360000 # 单次验证命令的最长运行时间(毫秒);超时终止并记为失败。0 表示不限制。
72
+ verificationCommands: {} # 按 kind / kind:scope 覆盖验证命令
73
+ maxVerifyAttempts: 5 # 验证失败重试预算:0 表示不限制。耗尽后允许 BLOCKED 交付,避免死循环。
74
+ maxSameFailure: 2 # 相同失败签名连续出现上限;0 表示不限制
33
75
  ```
34
76
 
35
77
  默认值:planner 用 `deepseek-account/deepseek-v4-pro`(pro 模型负责勘探现状与拆分任务),implement / verify 用 `deepseek-account/deepseek-flash`(flash 模型执行编辑与核查);三个字段都可以在插件页里改。
@@ -40,31 +82,41 @@ dsh plugin --profile <profile> add dsh-coding
40
82
 
41
83
  ## 使用
42
84
 
43
- 1. 新建会话,预设选择 **Coding**。三个 worker 预设只用于 `delegate_*` 派发,不出现在预设列表。
85
+ 1. 新建会话,预设选择 **Coding**。worker 预设(共四个,含带仓库指令的 verify 变体)只用于 `delegate_*` 派发,不出现在预设列表。
44
86
  2. 空白首页输入框旁可选 **工作模式**(自动 / 问答 / 审查 / Codex)。默认 **自动** 先做需求分析,再用 `coding_mode` 选定后续工作流;不确定时回退到问答。
45
87
  3. 正常提需求:需求分析 → 规划(pro worker 勘探现状并输出单一职责子任务)→ 任务单 → 实现(flash worker)→ 验证。每个子任务写清目标、涉及文件、验收方式与不碰的范围。
46
-
47
- | 阶段 | 主代理可以做什么 |
48
- | --- | --- |
49
- | 需求分析 requirements | 读文件、搜索、检查命令;不能改文件、不能验证、不能委派 |
50
- | 规划 plan | 读 + `delegate_plan` + `todo_write`;先用 `coding_handoff` 记录 goal,再写任务单;没有任务单不能进入实现 |
51
- | 实现 implement | 只剩 `delegate_implement`、`coding_handoff`、`todo_write` 与控制类工具;编辑工具被移除 |
52
- | 验证 verify | 读 + `run_verification` / `delegate_verify` + `todo_write`;先记录验收标准,失败按预算重试;失败不能交付 |
53
- | 交付 deliver | 只读汇报;可把已完成条目勾成 completed;预算耗尽时为 BLOCKED 交付 |
54
-
55
- | 控制类工具 | 作用 |
56
- | --- | --- |
57
- | `coding_stage` | 查看或推进阶段,放行与否由插件判定 |
58
- | `coding_mode` / `coding_reasoning` | 选择工作流 / 调整推理等级 |
59
- | `coding_handoff` | 读写跨阶段交接记录(goal / constraints / acceptance / findings / decisions / open / tasks / changes);`{ reset: true }` 只重置验证重试预算,不清空记录 |
60
-
61
- | 命令 | 作用 |
62
- | --- | --- |
63
- | `/coding` | 查看当前阶段、模式、任务单与验证状态(状态行含 `handoff goal=…, acceptance=N`、`attempt N`、`BLOCKED`、`delivery BLOCKED`) |
64
- | `/coding auto / consult / review / codex` | 切换模式并新开一轮(`agent.followup()`) |
65
- | `/coding set <模式>` | 静默设置模式(卡片按钮与首页选择器使用) |
66
- | `/coding stage <阶段>` | 在当前轮内推进阶段(`agent.steer()`) |
67
- | `/coding reset` | 重置验证重试预算(交接记录与最近一次验证结果保留) |
88
+ 4. **一次会话只跑一个任务**:换任务请新开会话。`coding_handoff` 的 acceptance / constraints 等字段只追加,同一会话复用会让上一个任务的验收标准继续满足新任务的门禁;目前没有清空交接记录的入口(`coding_handoff({ reset: true })` 与 `/coding reset` 只重置验证重试预算)。
89
+
90
+ ## 最佳任务实践
91
+
92
+ 1. 一个任务只做同方向的一类事(不是一件事),避免大而全的“许愿式任务”,提示词不要长篇大论,最重要的是明确目标和边界。
93
+ 2. 创建项目级 AGENTS.md,记录项目背景、目标、当前状态、关键里程碑、交付物、验收标准、依赖关系、协作流程、常见问题、FAQ 等,作为需求分析的基础。
94
+ 3. 大型工程项目建议 + 模块级(目录级) AGENTS.md,记录模块背景、目标、当前状态、交付物、验收标准、依赖关系、协作流程、常见问题、FAQ 等,作为具体工程任务的基础。
95
+ 4. 使用 Git/GitLab 进行代码托管,按照一库一项目(服务)原则建仓管理,明确的标签化/版本号机制联动进行迭代发布。
96
+ 5. 编程智能体基于项目(服务)创建管理会话,养成开发文档/交接文档随时更新的好习惯,脱离智能体也能确保代码的可追溯性和可回溯性。
97
+
98
+ | 阶段 | 主代理可以做什么 |
99
+ | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
100
+ | 需求分析 requirements | 读文件、搜索、检查命令;不能改文件、不能验证、不能委派 |
101
+ | 规划 plan | 读 + `delegate_plan` + `todo_write`;先用 `coding_handoff` 记录 goal,再写任务单;没有任务单不能进入实现;任务单严格大于三条(多文件改动)时,未派发过 `delegate_plan` 不能进入实现——主 Agent 自身就是 planner 模型时跳过,单文件小改 1-3 条不强制 |
102
+ | 实现 implement | 只剩 `delegate_implement`、`coding_handoff`、`todo_write`、shell(`bash` / `pwsh`)与控制类工具;能自己跑安装、`git` 与一次性命令;编辑工具被移除,改文件仍走 `delegate_implement` |
103
+ | 验证 verify | 读 + `run_verification` / `delegate_verify` + `todo_write`;可跑临时命令复现失败,正式检查仍走 `run_verification`;先记录验收标准,失败按预算重试;失败不能交付 |
104
+ | 交付 deliver | 只读汇报;可把已完成条目勾成 completed;预算耗尽时为 BLOCKED 交付 |
105
+
106
+ | 控制类工具 | 作用 |
107
+ | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
108
+ | `coding_stage` | 查看或推进阶段,放行与否由插件判定 |
109
+ | `coding_mode` / `coding_reasoning` | 选择工作流 / 调整推理等级 |
110
+ | `coding_handoff` | 读写跨阶段交接记录(goal / constraints / acceptance / findings / decisions / open / tasks / changes);`{ reset: true }` 只重置验证重试预算,不清空记录 |
111
+
112
+ | 命令 | 作用 |
113
+ | ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
114
+ | `/coding` | 查看当前阶段、模式、任务单与验证状态(状态行含 `handoff goal=…, acceptance=N`、`attempt N`、`BLOCKED`、`delivery BLOCKED`、派发过 planner 时的 `planner completed\|failed`) |
115
+ | `/coding auto / consult / review / codex` | 切换模式并新开一轮(`agent.followup()`) |
116
+ | `/coding set <模式>` | 静默设置模式(卡片按钮与首页选择器使用) |
117
+ | `/coding stage <阶段>` | 在当前轮内推进阶段(`agent.steer()`) |
118
+ | `/coding reset` | 重置验证重试预算(交接记录与最近一次验证结果保留) |
119
+ | `/coding memory` | 写出本轮任务交接文档到项目根 `.agents/memory`(卡片按钮使用同一命令) |
68
120
 
69
121
  每轮结束处有**会话控制卡片**(模式、阶段路径、推理等级、验证状态、任务单进度、改动文件数;最新一轮可切换模式),每次 Coding 工具调用处有**阶段胶囊**。两者都从持久会话投影回放:刷新、重开、历史翻页都显示当时的真实状态,旧轮冻结在它实际运行的模式与阶段。
70
122
 
@@ -75,6 +127,12 @@ dsh plugin --profile <profile> add dsh-coding
75
127
  - 验证命令有总时限(`verificationTimeoutMs`,默认 6 分钟 = 360000 ms,可配置,`0` 不限制):到点终止并记为一次失败,避免测试脚本死循环一直等待。
76
128
  - 验证失败按预算重试(默认 5 次失败、同一失败签名 2 次);耗尽后 `coding_stage(deliver)` 放行但标记为 BLOCKED 交付,`coding_handoff({ reset: true })` 或 `/coding reset` 重置预算,只有验证通过才自动清零——这是防止死循环的出口。
77
129
 
130
+ ### 仓库指令(AGENTS.md)注入
131
+
132
+ - implement worker 固定携带仓库指令;verify worker 默认不带,只在 codex 模式且任务复杂时改用内部预设 `dsh-coding-verify-instructions`:判定条件是 `taskCount >= 2 || changedFiles >= 3`(多子任务代表跨任务依赖,≥3 个改动文件代表改动面大),普通单任务核查保持精简。
133
+ - 每次派发都是新的子会话,指令在会话启动时从磁盘读取,所以派发时读到的是最新内容;worker 运行中若指令文件被更新,上游会在该 worker 后续 `read` / `write` / `edit` 触碰文件时重新读取并注入 `Updated instructions from: …`,不会每步刷新,运行时也不缓存指令文本。
134
+ - **手工验证**:在 codex 会话完成一个多子任务改动后派发 verify,确认子代理会话里存在 `source.kind === 'agent-instructions'` 的 user 消息;把同一场景换成单任务单文件再派发 verify,则不应出现该消息。
135
+
78
136
  ### 失败提示
79
137
 
80
138
  - 关键调度点(子代理派发、验证启动/超时、工具表裁剪、会话恢复/投影、推理等级、交接写入、控制命令)遇到阻断性异常时,下一步会注入一条**运行中断**通知,写明原因与处理方式;状态行与会话 checkpoint 同时记录 `failure <point>`。
@@ -85,7 +143,8 @@ dsh plugin --profile <profile> add dsh-coding
85
143
  ## 文档
86
144
 
87
145
  - [设计思路与分层结构](docs/DETAIL.md)
88
- - [开发者文档](docs/DEVELOPMENT.md)
146
+ - [更新日志](docs/CHANGELOG.md)
147
+ - [维护者与智能体工作指南](AGENTS.md)
89
148
 
90
149
  ## 许可
91
150
 
package/cordis.patch.yml CHANGED
@@ -1,9 +1,10 @@
1
1
  # dsh-coding bundle.
2
2
  #
3
- # One passive Host settings row plus three preset declarations:
4
- # preset-dsh-coding the `Coding` preset a session selects
5
- # preset-dsh-coding-implement the isolated implement worker (internal)
6
- # preset-dsh-coding-verify the isolated verify worker (internal)
3
+ # One passive Host settings row plus four preset declarations:
4
+ # preset-dsh-coding the `Coding` preset a session selects
5
+ # preset-dsh-coding-implement the isolated implement worker (internal)
6
+ # preset-dsh-coding-verify the isolated verify worker (internal)
7
+ # preset-dsh-coding-verify-instructions the verify worker with repo instructions (internal)
7
8
  #
8
9
  # The worker presets are internal, but DSH has no hidden-preset flag, so they
9
10
  # are declared openly, ordered last, and named as workers. Their plugin lists ARE
@@ -20,6 +21,8 @@
20
21
  defaultMode: auto
21
22
  implementWorkerModel: deepseek-account/deepseek-flash
22
23
  plannerWorkerModel: deepseek-account/deepseek-v4-pro
24
+ # planner 门禁:complex 时 codex 复杂任务(任务单 >3 条)必须先派发 delegate_plan;off 关闭。
25
+ requirePlanner: complex
23
26
  verifyWorkerModel: deepseek-account/deepseek-flash
24
27
  # auto follows the DSH interface locale, then the host locale; zh/en pin it.
25
28
  language: auto
@@ -39,10 +42,9 @@
39
42
  id: dsh-coding
40
43
  name: Coding
41
44
  description: >-
42
- DSH 编程智能体运行时:requirements→plan→implement→verify→deliver 阶段由插件强制执行,
43
- implement 阶段只保留委派工具,编辑由隔离子代理完成,验证结果决定能否交付。
44
- A DSH coding-agent runtime: enforced requirements→plan→implement→verify→deliver stages,
45
- delegated edits from isolated worker subagents, and a verification gate before delivery.
45
+ DSH 编程智能体运行时:工程化任务编排机制,Codex 五段式契约层层推进,确保任务交付质量和 Token 价值最大化。
46
+ When the DSH programming intelligent agent runs, it employs an engineered task orchestration mechanism,
47
+ utilizing the Codex five-stage contract to progress step by step, ensuring task delivery quality and maximizing token value.
46
48
  order: 4
47
49
  plugins:
48
50
  # Identity and temperament only. The workflow contract is injected per
@@ -197,6 +199,10 @@
197
199
  name: "@deepseek-ai/dsh-tool-fs-search"
198
200
  config:
199
201
  sampleOverCapGlobResults: false
202
+ - id: agent-instructions
203
+ name: "@deepseek-ai/dsh-agent-instructions"
204
+ config:
205
+ maxBytes: 65536
200
206
  - id: dsh-coding-editor
201
207
  name: "dsh-coding/editor"
202
208
 
@@ -231,3 +237,40 @@
231
237
  sampleOverCapGlobResults: false
232
238
  - id: dsh-coding-verifier
233
239
  name: "dsh-coding/verifier"
240
+
241
+ # Verify worker with repository instructions. Dispatched only for a codex run
242
+ # that spans dependent sub-tasks or a broad change; a single-task check stays
243
+ # on the lean preset above.
244
+ - id: preset-dsh-coding-verify-instructions
245
+ name: "@deepseek-ai/dsh-agent-preset"
246
+ config:
247
+ id: dsh-coding-verify-instructions
248
+ name: Coding verify worker (repo instructions)
249
+ description: >-
250
+ Internal worker of the Coding preset: the verify worker with the repository
251
+ instructions injected. Dispatched by delegate_verify for a complex codex run.
252
+ order: 92
253
+ plugins:
254
+ - id: persona
255
+ name: "@deepseek-ai/dsh-persona"
256
+ config:
257
+ prefix: |-
258
+ You are the verify worker of the DSH Coding runtime. You hold no edit tool: you read files, search them, and run checks through run_verification. Never claim a passing check you did not run; report findings with file:line and a reproducible scenario, ordered by impact.
259
+ includeRuntimeContext: false
260
+ - id: tool-fs
261
+ name: "@deepseek-ai/dsh-tool-fs"
262
+ config:
263
+ applyPatch: false
264
+ write: false
265
+ edit: false
266
+ readImage: false
267
+ - id: tool-fs-search
268
+ name: "@deepseek-ai/dsh-tool-fs-search"
269
+ config:
270
+ sampleOverCapGlobResults: false
271
+ - id: dsh-coding-verifier
272
+ name: "dsh-coding/verifier"
273
+ - id: agent-instructions
274
+ name: "@deepseek-ai/dsh-agent-instructions"
275
+ config:
276
+ maxBytes: 65536
@@ -0,0 +1,47 @@
1
+ # 更新日志
2
+
3
+ 本文件记录 DSH Coding 编程智能体的版本变更。版本号遵循语义化版本(`MAJOR.MINOR.PATCH`),`rc` 后缀表示预发布版本;小节按发布时间倒序排列,最新的版本在最前。
4
+
5
+ ## 0.1.1-rc2(未发布)
6
+
7
+ `package.json` 当前版本为 `0.1.1-rc2`,尚未打标签、未发布。
8
+
9
+ ### 新增
10
+
11
+ - 任务交接文档:`/coding memory` 在会话工作目录的 `.agents/memory/<sessionId>-<UTC YYYYMMDD-HHmmss>.md` 写一篇本轮交接 Markdown,内容只取状态机与 `coding_handoff` 记录,不回读对话正文;同名文件不覆盖。实现在 `src/memory.ts`,Host 侧经 fs 服务写盘。
12
+ - planner 门禁:新增配置 `requirePlanner`(`complex` 默认 / `off`)。`complex` 下 codex 会话的任务单超过 3 条、尚未派发过 `delegate_plan`、且主 Agent 自身不是 planner 路由时,`coding_stage(implement)` 被拒并提示先派发 planner;该字段不可在插件页修改,写在 bundle 的 patch config 里。
13
+ - 轮次卡片新增「结束任务并生成交接文档」按钮,仅在最新一轮、codex 模式、该轮冻结阶段为 deliver 且验证通过时出现。
14
+ - `coding_handoff` 新增 `delivered` / `followUps` 字段:deliver 阶段记录本轮交付了什么与残余风险,下一轮与重开会话的 plan / implement worker 会读到(verify 分片不渲染,控制提示词体积)。
15
+ - 新增 verify worker 预设 `dsh-coding-verify-instructions`:仅 codex 模式且子任务数 ≥ 2 或改动文件数 ≥ 3 时加载仓库指令;implement 预设固定加载 `@deepseek-ai/dsh-agent-instructions`(`maxBytes: 65536`)。
16
+ - 主代理在 implement / verify 阶段获得 shell:`IMPLEMENT_TABLE` 同时列出 `bash` 与 `pwsh`,按平台由 `syncTable` 的已知工具过滤收窄。
17
+
18
+ ### 变更
19
+
20
+ - 阶段工具边界调整:`exec` 类工具在 requirements / plan / implement / verify 准入,只有 deliver 不授予;实现阶段编辑文件仍然只能走 `delegate_implement`。
21
+ - 文档新增「会话边界」约定:一个 Coding 会话只服务一个任务,换任务请新开会话。原因是 `coding_handoff` 的列表字段只追加(只有 `goal` / `delivered` 覆盖),复用会话会让上一个任务的 `acceptance` 满足新任务的 verify / deliver 门禁;`coding_handoff({ reset: true })` 只重置验证重试预算。
22
+ - README「使用」新增第 4 条会话边界提示(一次会话只跑一个任务,换任务请新开会话),与上面的约定同义,面向使用者。
23
+ - `/coding` 命令增加 `memory` 子命令,`/coding` 的帮助与输入提示同步更新。
24
+ - 插件详情文档指向 `README.md`(`locale/zh.json`、`locale/en.json` 的 `meta.detail`)。
25
+ - 文档重构:`AGENTS.md` 拆分为根(通用工作方式、环境、目录总览、构建产物、发布、跨平台、硬规则速览)+ `src/AGENTS.md`(DSH 契约表、实现约束 1-23、src 模块表、调试表)+ `test/AGENTS.md`(测试矩阵、手工验证)+ `scripts/AGENTS.md`(隔离挂载探针),目录级文件由 `agent-instructions` 在触碰对应目录时自动注入;`docs/DETAIL.md` 的文档引用改为分别指向这三处;`docs/DEVELOPMENT.md` 并入 `docs/DETAIL.md` 后删除;README 重写为面向使用者。
26
+ - `package.json` 补充 `author` / `repository` / `homepage` / `bugs` 元数据,`files` 增加 `AGENTS.md`。
27
+
28
+ ### 修复
29
+
30
+ - `scripts/build.mjs` 的目录原子换入在 Windows 上偶发 `EPERM`:新增 `renameWithRetry`,仅对 `EPERM` / `EBUSY` / `EACCES` 按 100ms × attempt 退避、最多 10 次;原子替换与失败回滚语义不变。
31
+ - 发布前检查修复:Coding 预设 `description` 结尾的双句点与行尾多余空格;根 `AGENTS.md` 与 `docs/DETAIL.md` 指向 `src/`、`test/`、`scripts/` 三个目录级文件的链接改为 GitHub 绝对地址(这三个文件不随 npm 包发布,相对链接在 npm 页面上会 404)。
32
+
33
+ ### 测试
34
+
35
+ - 测试总数 174,全部通过(`pnpm test`,先执行 `pnpm build`)。新增 `test/memory.test.mjs`(交接文档组装与写盘),并补充交接文档按钮、`delivered` / `followUps` 合并、`needsWorkspaceInstructions` 判定边界、verify 预设的条件选择、`requirePlanner` 门禁、shell 阶段准入、`agent-instructions` 预设行等断言。
36
+
37
+ ## 0.1.1-rc1(已发布)
38
+
39
+ 首个发布版本,对应标签 `v0.1.1-rc1`。
40
+
41
+ - 五段式契约:requirements → plan → implement → verify → deliver;`auto` / `consult` / `review` / `codex` 四种工作模式与各自的阶段集合。
42
+ - 双层门禁:`tools.restrict` 工具表裁剪 + `tools/pre-execute` / guard 拒绝,两层共用同一个 `checkTool` 判定。
43
+ - 三个 worker 预设(planner / implement / verify),工具白名单写在预设组合里,不继承父级限制。
44
+ - `coding_handoff` 跨阶段交接记录、`todo_write` 任务单、验证重试预算与 BLOCKED 交付出口。
45
+ - `run_verification` 结构化验证(命令解析、超时、失败输出解析)与 Codex 语法 `apply_patch` 编辑器。
46
+ - 浏览器半:阶段胶囊、轮次卡片、工作模式选择器、`/coding` 命令回执、插件配置页。
47
+ - 推理等级(`auto` / `low` / `high` / `max`)与会话语言(`auto` / `zh` / `en`)。