pi-deepseek-harness-anchor
DeepSeek V4 Pro/Flash harness trajectory anchoring for Pi: Minimal-persona first turn, narrow tool pair, durable promotion, DSH-compatible str_replace_editor
Package details
Install pi-deepseek-harness-anchor from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-deepseek-harness-anchor- Package
pi-deepseek-harness-anchor- Version
0.1.1- Published
- Aug 16, 2026
- Downloads
- 382/mo · 13/wk
- Author
- lertian
- License
- MIT
- Types
- extension
- Size
- 34.4 KB
- Dependencies
- 0 dependencies · 3 peers
Pi manifest JSON
{
"extensions": [
"./extensions/deepseek-anchor/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-deepseek-harness-anchor
DeepSeek V4 Pro/Flash trajectory anchoring for Pi: the first turn of a session runs with an anchored persona (Minimal for Pro, weak-mode w7 for Flash) and a narrow bash + str_replace_editor tool pair, then the full Pi tool set is restored after the first durable signal (tool call or complete reply). Ships a DSH-schema-compatible str_replace_editor. Non-matching models are left completely untouched.
pi install npm:pi-deepseek-harness-anchor
# or from source:
pi install git:github.com/lertian/pi-deepseek-harness-anchor@v0.1.0
一个面向 Pi 的 DeepSeek V4 轨迹锚定扩展。
deepseek-v4-flash使用dsh-routing-suite的 Router Standard 首轮形态:weak 模式 w7 persona(分类指令 + 回顾/反跑题锚 + 深度思考锚),只暴露bash+str_replace_editor,首次工具调用后恢复 Pi 原工具集。deepseek-v4-pro使用dsh-anchored-standard的首轮形态:同样收窄 system prompt 与工具面,首次工具调用或首个完整回复后恢复;compaction 后进行一次恢复锚定。- 非匹配模型不改 system prompt,也不会启用
str_replace_editor。
扩展带有一个按 DeepSeek Harness schema 实现的 str_replace_editor,支持 view、create、str_replace 和 insert。这很重要,因为参考项目的实验结论指向 API 可见的真实工具 schema,而不是提示词中出现的工具名称。
安装
# 从 npm(推荐)
pi install npm:pi-deepseek-harness-anchor
# 或从 git tag
pi install git:github.com/lertian/pi-deepseek-harness-anchor@v0.1.0
# 本地开发
pi install /path/to/pi-deepseek-harness-anchor
临时试用:
pi -e /path/to/pi-deepseek-harness-anchor/extensions/deepseek-anchor/index.ts
安装后在 Pi 中执行 /reload,或启动新会话。状态栏会显示:
anchor:flash/anchoring
anchor:pro/promoted
模型匹配
默认根据模型 ID、显示名或 provider/model 的归一化文本做包含匹配:包含 deepseek-v4-flash 时走 Flash,包含 deepseek-v4-pro 时走 Pro。因此 g-deepseek-v4-flash 和带版本后缀的同族模型会自动触发;不包含任一标记的 DeepSeek 模型不会触发。
{
"flashModelIds": ["deepseek-v4-flash"],
"proModelIds": ["deepseek-v4-pro"]
}
可在 ~/.pi/agent/deepseek-anchor.json 配置额外匹配标记,也可在受信任项目的 .pi/deepseek-anchor.json 覆盖:
{
"enabled": true,
"flashModelIds": ["deepseek-v4-flash", "team-v4-flash"],
"proModelIds": ["deepseek-v4-pro", "team-v4-pro"],
"flashNearFieldGuidance": true,
"reanchorProAfterCompaction": true
}
控制命令
/deepseek-anchor status
/deepseek-anchor rearm
/deepseek-anchor promote
/deepseek-anchor off
/deepseek-anchor on
promote 是 Flash 首轮没有调用工具时的手动逃生口。状态通过 Pi custom entry 持久化,并按当前分支恢复。
实现边界
Pi 的 before_agent_start 在每次用户提交后触发,而工具循环中的后续模型请求不会再次触发。扩展因此在会话/模型切换时提前收窄工具,在 tool_call 或 message_end 时恢复工具;首个用户轮次使用 Minimal system prompt,后续用户轮次恢复 Pi 原 system prompt。
Pro 在普通 compaction 后进入一次恢复锚定。若 compaction 是上下文溢出后的即时重试(willRetry: true),扩展不会启动一个只有工具面、没有 Minimal system prompt 的不完整锚定,而是保持晋升状态。
str_replace_editor 会拒绝非普通文件、保留非“文件不存在”类的系统错误、响应取消信号,并在提交前检查文件身份与元数据是否变化。Pi 的进程内 mutation queue 和这些检查不能提供跨进程的原子 compare-and-swap;外部进程恰好在最终检查后写入同一文件时,仍存在很小的竞争窗口。
扩展不修改 provider HTTP payload、reasoning 参数或 thinking 历史。参考仓库没有实现这些 OpenCode-Go 传输层行为,猜测性地改 wire format 会把锚定问题和 provider 兼容问题混在一起。