DeepSeek Harness
DeepSeek Harness CLI 与 Headless 模式:Profile、参数和自动化
理解 dsh 如何区分启动参数与应用参数,以及 Headless 如何运行一次持久化任务。

你将学会
- Launcher flags and profile app arguments have separate parsing boundaries.
- Headless mode prints one persisted task result and exits.
- Dump the composed config before automating a profile.
开始前需要
- Basic HTTP and API knowledge
Leave with a concrete implementation checklist and a testable starting point.
先看结论
- 启动器参数和应用参数有明确解析边界。
- Headless 会打印一次持久化任务结果后退出。
- 自动化前先 dump 组合配置。
理解启动边界
CLI 文档把 dsh 定义为 Profile 启动器。启动器参数必须放在前面,第一个无法识别的 token 会交给选中的应用,避免 Web 参数被误判为启动器参数。
`dsh web` 是 Web Profile 的别名;`dsh --profile headless "job"` 则运行一次新的持久化 Session,打印最终回答后退出。
启动前检查
`--dump-default-config` 和 `--dump-config` 可以在真正启动前检查组合树。你可以确认 Bundle 顺序、Profile 补丁、Home 补丁和命令行 overlay。
Profile 目录包含 package.json、带有有序 Bundle 列表的 dsh.profile,以及用户自己的 cordis.patch.yml。按 id 匹配的补丁会替换整行配置。
谨慎自动化
Headless 适合一次性任务和 CI 实验,但仍会创建持久化 Session。每个独立任务都应有清晰的 Session 身份,并使用隔离工作区。
源码运行要求先构建包和前端产物,再用 `pnpm dsh` 转发参数执行 TypeScript 入口。
如何选择
| 比较维度 | 方案 A | 方案 B |
|---|---|---|
| Best when | You need predictable behavior and easy auditing | You need adaptive optimization and have reliable telemetry |
| Main risk | May leave performance on the table | Can become difficult to explain or debug |
实施步骤
- 1
需要交互服务器时选择 Web,需要一次性任务时选择 Headless。
- 2
dump 配置并核对补丁优先级。
- 3
为自动化隔离工作区和 Session 身份。
- 4
源码流程先 build,再使用 pnpm dsh。
可复制示例
dsh --help
dsh web --port 8080
dsh --profile headless "summarize this workspace"
dsh --profile web --dump-config常见问题
Headless 模式做什么?
它运行一次新的持久化 Session,打印最终回答后退出,不启动 Web UI 服务。
资料来源
- DeepSeek Harness CLI README来源核查 2026-08-27