DeepSeek Harness 全盘自进化升级插件(MoonBit native)
Dependencies
让多种 Harness 平台的插件生态持续自我进化 —— 扫描 → 监控 → 识别 → 提案 → 人工审批 → 真实升级。支持:DeepSeek Harness(首打)/ Minimax Code / ZCode / Claude Code / OpenClaw
| 轮次 | 提交 | 关键变化 |
|---|---|---|
| 2.4.0 | 02e1d51 | DSH subagent 真实集成:1.0 端 dsh-runner.ts 适配 DSH 宿主编排协议,server.ts 新增 3 个 MCP 工具(get_execution_plan / report_task_result / finalize_execution),配套 371 行 DSH_INTEGRATION.md;MoonBit 端真实进程执行器由占位升级为 HARNESS_EVOLUTION_AGENT_CMD 环境变量驱动,scanner 加 list_skill_and_source_files 双收集;legacy-ts 增 41 个 test(store 状态机、server 注册、engine 映射),引入 eslint;版本元数据升 2.4.0 |
| 2.3.0 | a2381fd | v2.3.0 收尾:monitor.mbt 缩 367 行(抽到 monitor/deep_check.mbt / monitor/flush.mbt),config.mbt 缩 197 行(抽到 types/config_helpers.mbt);ServerState::with_harness_config 统一三段配置;五处版本元数据升 2.3.0 |
| 2.2.0 | 8b9970e | 接通 scan_targets 配置孤岛:plugin.json 的 scan_targets 段真正驱动扫描根,支持 ~/... 展开,缺失/类型不符/为空都回退默认根并点名告警;新增 ScanConfig::from_plugin_json 纯解析函数和 8 个白盒用例 |
| 2.2.0 | 8b9970e | 五处版本元数据一并升 2.2.0(moon.mod / plugin.json / jsonrpc server_version / DESIGN.md 镜像 / SKILL.md frontmatter) |
| 第六轮 | b9392eb | 信号缓冲有界化(max_buffered_signals=500,溢出丢最旧);num_field 拒绝 NaN / Infinity;删除全仓零调用点的 ::at 生产构造器 |
| 第四轮 | cd2c525 | 4 真 bug 修复(tdiv floor 误用 / generate_signature 剥掉 plugin_id / factory 前后空 trim 不一致 / cooldown_hours 走裸 to_int) |
| 第五轮 | b309000 | AgentDefStore::list 把「读不动」改告警;版本元数据补齐 2.1.0 |
| v2.1 | 0d3b0ce | 子 Agent 工厂落地:3 个 MCP 工具管理两个作用域(plugin / user)的定义文件 |
| 平台 | 宿主标识 | 配置路径 |
|---|---|---|
| DeepSeek Harness | ~/.deepseek/harness/plugins/, ~/.deepseek/harness/extensions/ | |
| Minimax Code | ~/.minimax/plugins/, ~/.minimax/extensions/ | |
| ZCode | ~/.zcode/cli/plugins/, ~/.zcode/skills/ | |
| Claude Code | OpenClaw 等开源 AI 平台 | |
| OpenClaw | ~/.openclaw/ |
flowchart TB
subgraph 宿主
Client["DeepSeek Harness / Minimax Code / ZCode / Claude Code"]
end
subgraph "harness-self-evolution(MCP server, stdio JSON-RPC)"
direction TB
HE["harness_evolution/<br/>装配与启动"]
MCP["mcp/<br/>10 工具 · stdio JSON-RPC"]
ENG["engine/<br/>决策树 + 风险评估"]
EXE["executor/<br/>DAG 分层 + Sub-Agent 编排"]
FAC["factory/<br/>子 Agent 定义管理"]
SCN["scanner/<br/>插件发现 + 信息提取"]
MON["monitor/<br/>性能采集 + 信号检测"]
ST["store/<br/>唯一持久化层<br/>(JSONL / 缓存 / 提案 / 子 Agent)"]
TY["types/<br/>19 张 wire 表 · 词汇表单一事实来源"]
UT["util/<br/>路径 / 时间 / 日志 / 4 个零依赖 Deep Module"]
end
Client -- "scan_plugins / propose_evolution /<br/>approve_proposal / execute_evolution /<br/>create_sub_agent ..." --> MCP
HE --> MCP
MCP --> ENG
MCP --> EXE
MCP --> SCN
MCP --> MON
MCP --> FAC
ENG --> ST
EXE --> ST
FAC --> ST
SCN --> ST
MON --> ST
SCN --> TY
ENG --> TY
EXE --> TY
FAC --> TY
MON --> TY
ENG --> MON
EXE --> MON
ST --> UT
TY --> UT
ENG --> UT
EXE --> UT
FAC --> UT
SCN --> UT
MON --> UT# 克隆(任选一)
git clone https://github.com/Across2005/harness-self-evolution-plugin.git
# 或
git clone https://www.gitlink.org.cn/Across2005/harness-self-evolution-plugin.git
cd harness-self-evolution-plugin
# 构建:check + test + build,产物复制到 bin\harness-evolution.exe
# 依赖由 moon 根据 moon.mod 里写死的精确版本自动拉取,无需单独的 install 步骤
.\build.ps1 all
# 链接到 ZCode(可选)
zcode plugin link .为什么锁死 async@0.20.1:0.21.x 开始使用 noraise + nocancel 效果注解语法,而当前工具链(moon 0.1.20260819)解析它会报 [3002] Parse error, unexpected token '+'。升级到能解析该语法的 moon 版本后方可放开约束。关于 moon.lock:本机工具链不产生模块根的 moon.lock(moon mod tidy 是独立插件 moon-mod,未安装时直接报错;.mooncakes/.moon-lock 实测为空)。可复现构建靠的是 moon.mod 里写死的精确版本而不是范围,并由架构守卫 G6 机器化钉住。用 moon tree 可随时核对实际解析结果(应为 moonbitlang/async@0.20.1)。
# 克隆仓库(任选一)
git clone https://github.com/Across2005/harness-self-evolution-plugin.git
cd harness-self-evolution-plugin
# 完整构建(检查 + 测试 + 构建)
.uild.ps1 all# 将插件链接到 ZCode(使宿主能发现并加载插件)
zcode plugin link .# 检查插件是否正常运行
zcode plugin list// 扫描所有插件
const result = await callMcpTool('scan_plugins', {});
// 获取插件性能指标
const metrics = await callMcpTool('get_plugin_metrics', { plugin_id: 'browser-use-0.4.1' });
// 生成进化提案
const proposal = await callMcpTool('propose_evolution', { plugin_id: 'browser-use-0.4.1' });# 启动插件(手动模式)
echo '{"jsonrpc":"2.0","method":"initialize","params":{},"id":1}' | .in\harness-evolution.exe
# 应该收到 JSON-RPC 响应| 命令 | 作用 |
|---|---|
| .\build.ps1 check | moon check --deny-warn --target native(零错零警才算过) |
| .\build.ps1 test | moon test --target native |
| .\build.ps1 build | release 构建 + 复制到 bin\harness-evolution.exe |
| .\build.ps1 fmt | moon fmt |
| .\build.ps1 all | 依次执行 check → test → build |
{
"scan_targets": ["~/plugins", "~/work/zcode-plugins"],
"evolution_config": {
"intensity": "50%",
"auto_approve": false,
"cooldown_hours": 24,
"max_log_bytes": 33554432,
"signal_thresholds": {
"consecutive_failures": 3,
"loop_detection": 5,
"latency_regression": 0.2
}
}
}| 工具 | 作用 |
|---|---|
| scan_plugins | 扫描所有插件(2.2.0 起按 scan_targets 段) |
| get_plugin_metrics | 获取插件性能指标 |
| propose_evolution | 生成进化提案(可带手动 signals) |
| approve_proposal | 批准提案(必经环节) |
| reject_proposal | 拒绝提案 |
| list_proposals | 列出所有提案 |
| execute_evolution | 执行已批准提案 |
| create_sub_agent | 创建子 Agent 定义文件(v2.1) |
| list_sub_agents | 列出子 Agent 定义(v2.1,可按 scope 过滤) |
| delete_sub_agent | 删除子 Agent 定义(v2.1) |
| analyze_plugins | 合并工具:扫描并/或获取指标(v2.3,mode=scan/metrics/both) |
| evolve_plugin | 合并工具:生成或执行提案(v2.3,action=propose/execute) |
| manage_sub_agent | 合并工具:管理子 Agent 定义(v2.3,action=create/list/delete) |
| get_execution_plan | NEW 获取任务 DAG(供 DSH Agent 编排 subagent) |
| report_task_result | NEW 回写 Sub-Agent 执行结果 |
| finalize_execution | NEW 完成执行并更新提案状态 |
⚠️ 给接手 Agent 的提示本插件的执行器已与 DSH 的 subagent 工具对接。 如果你是一个运行在 DSH 中的 Agent,请阅读 DSH_INTEGRATION.md 了解完整的集成模式。
// 1. 获取执行计划
const plan = await callMcpTool('execute_evolution', { proposal_id: 'evo-xxx', dry_run: false });
// 2. 按层级执行(同层并行,层间串行)
for (const layer of plan.task_dag) {
await Promise.all(layer.tasks.map(task =>
subagent({ prompt: task.prompt, description: task.agent })
));
}
// 3. 完成
await callMcpTool('finalize_execution', { proposal_id: 'evo-xxx', success: true });宿主 Agent MCP Server DSH subagent
│ │ │
├── execute_evolution ────────►│ │
│◄── task_dag ────────────────┤ │
│ │ │
├── subagent(prompt) ─────────┼────────────────────────────►│
│ (layer 0, 并行) │ │
│◄────────────────────────────┼──── result ─────────────────┤
│ │ │
├── report_task_result ──────►│ │
│ │ │
├── subagent(prompt) ─────────┼────────────────────────────►│
│ (layer 1) │ │
│◄────────────────────────────┼──── result ─────────────────┤
│ │ │
├── finalize_execution ──────►│ │
│◄── status: completed ───────┤ │plugin-cache.json # 扫描缓存(每条带目录指纹:mtime + 子项数 + 子项 mtime)
metrics.jsonl # 性能事件(monitor 写,受 max_log_bytes 约束)
signals.jsonl # 进化信号(monitor 写 / engine 读,受 max_log_bytes 约束)
proposals.jsonl # 进化提案(ProposalStore 唯一读写口,**不裁剪**)
execution.log # 执行日志(executor,**不裁剪**)
agents/ # 子 Agent 定义(factory 写,scope=plugin;scope=user 写到宿主用户目录)
数据根目录的默认值只在 `store/paths.mbt` 一处定义,并由 `mcp/architecture_test.mbt` 的 G4 守卫机器化地防止它再次扩散(1.0 版把它散落在 4 个文件里)。
> **关于 v1 目录**:2.0 使用 `v2/` 子目录,**不做自动迁移**。若检测到 1.0 的 `~/.harness-evolution/` 存在,启动时会在 stderr 提示一行,然后原样保留。原因是 1.0 的 `plugin-cache.json` 命中条件过于宽松(只要缓存非空就直接返回,从不校验目录是否还存在),实测会被一条指向已删除临时目录的幽灵记录永久毒化 —— 丢弃重扫比迁移更安全。
### 子 Agent 协同
```mermaid
flowchart LR
P[提案审批] --> E[Executor 启动]
E --> D[任务分解]
D --> CG[code-generator]
D --> TW[test-writer]
D --> DW[doc-writer]
D --> IT[integration]
D --> VA[validator]
CG --> T0[T0 语法]
TW --> T1[T1 功能]
VA --> T2[T2 回归]
T0 --> R[更新 Registry]
T1 --> R
T2 --> R| 守卫 | 约束 |
|---|---|
| G1 / G1b | 包依赖图与声明完全一致,且每条边严格向下(构造性无环) |
| G2 / G2b | @stdio.stdout 只在 mcp/server.mbt,@stdio.stderr 只在 util/log.mbt |
| G3 / G3b | @fs 的写操作只在 store/ |
| G4 / G4b | 数据目录字面量只在 store/paths.mbt |
| G5 / G5b | legacy-ts/tests/ 的 37 个 jest 用例逐条有 MoonBit 对应物 |
| G6 | moon.mod 只有一个外部依赖,且 native 是首选目标 |
cd legacy-ts
npm install
npx jest # 37 个用例git clone https://github.com/Across2005/harness-self-evolution-plugin.git
cd harness-self-evolution-plugin
# Full build: check + test + build
.\build.ps1 allzcode plugin link .zcode plugin list
# Should show: harness-self-evolution (v2.4.0) - Active// Scan all plugins
const result = await callMcpTool('scan_plugins', {});
// Get plugin metrics
const metrics = await callMcpTool('get_plugin_metrics', { plugin_id: 'browser-use-0.4.1' });
// Generate evolution proposal
const proposal = await callMcpTool('propose_evolution', { plugin_id: 'browser-use-0.4.1' });Install
Download zipDeepSeek Harness 全盘自进化升级插件(MoonBit native)
Dependencies