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/ 装配与启动"]
MCP["mcp/ 10 工具 · stdio JSON-RPC"]
ENG["engine/ 决策树 + 风险评估"]
EXE["executor/ DAG 分层 + Sub-Agent 编排"]
FAC["factory/ 子 Agent 定义管理"]
SCN["scanner/ 插件发现 + 信息提取"]
MON["monitor/ 性能采集 + 信号检测"]
ST["store/ 唯一持久化层 (JSONL / 缓存 / 提案 / 子 Agent)"]
TY["types/ 19 张 wire 表 · 词汇表单一事实来源"]
UT["util/ 路径 / 时间 / 日志 / 4 个零依赖 Deep Module"]
end
Client -- "scan_plugins / propose_evolution / approve_proposal / execute_evolution / 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
A self-evolution plugin for multiple Harness platforms (primary: DeepSeek Harness). It scans plugins, monitors performance, detects signals, drafts upgrade proposals, and (only after explicit human approval) executes the upgrade. The user touches it in exactly one place: reviewing proposals.
DSH subagent integration: the 1.0 side now ships a dsh-runner.ts adapter that hands a topology-sorted task DAG to the host DeepSeek Harness Agent; the host executes each layer in parallel via subagent calls, then writes results back via report_task_result and finalizes with finalize_execution. See DSH_INTEGRATION.md (371 lines) for the full host-side contract.
Real process runner: MoonBit’s runner.mbt reads HARNESS_EVOLUTION_AGENT_CMD (template with {prompt} / {input} placeholders) and dispatches to @process; falls back to a mock when unset, with sandbox and streaming-IO extension points preserved.
Scanner one-pass dual collection: list_skill_and_source_files collects skill and source manifests in a single walk, halving I/O for large plugin trees.
JsonlStore backward read: tolerates v1/v2 records and normalises to v3 schema on load.
1.0 hygiene: legacy-ts/.eslintrc.js lands; tests/server.test.ts and tests/store.test.ts close the 1.0 coverage gap (75/75, +41 tests in this round).
Combined test count: 422/422 (MoonBit 347 + legacy-ts 75).
Windows: Visual Studio C++ Build Tools (cl.exe) + Windows SDK (auto-detected by build.ps1)
Host environment (choose one):
DeepSeek Harness
Minimax Code CLI: npm install -g mmx-cli
ZCode CLI
Claude Code / OpenClaw (as MCP server)
2. Clone and Build
git clone https://github.com/Across2005/harness-self-evolution-plugin.git
cd harness-self-evolution-plugin
# Full build: check + test + build
.\build.ps1 all
The output binary is at bin/harness-evolution.exe.
3. Link to Host (ZCode)
zcode plugin link .
4. Run
The plugin runs as an MCP server, automatically started by the host:
Harness Self-Evolution Plugin
English · 中文
中文
一句话定位
挂在多种 Harness 平台上的自进化插件(首打 DeepSeek Harness)。用户全程只介入一处:看提案,点同意或不同意。
最新进展(v2.4.0,2026-09-09)
02e1d51dsh-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.0a2381fdmonitor/deep_check.mbt/monitor/flush.mbt),config.mbt 缩 197 行(抽到types/config_helpers.mbt);ServerState::with_harness_config统一三段配置;五处版本元数据升 2.3.08b9970escan_targets配置孤岛:plugin.json的scan_targets段真正驱动扫描根,支持~/...展开,缺失/类型不符/为空都回退默认根并点名告警;新增ScanConfig::from_plugin_json纯解析函数和 8 个白盒用例8b9970emoon.mod/plugin.json/jsonrpc server_version/DESIGN.md镜像 /SKILL.mdfrontmatter)b9392ebmax_buffered_signals=500,溢出丢最旧);num_field拒绝NaN/Infinity;删除全仓零调用点的::at生产构造器cd2c525tdivfloor 误用 /generate_signature剥掉 plugin_id / factory 前后空 trim 不一致 /cooldown_hours走裸to_int)b309000AgentDefStore::list把「读不动」改告警;版本元数据补齐 2.1.00d3b0ce完整门禁(
build.ps1 -Task all):Total tests: 347, passed: 347, failed: 0.,退出码 0,产物bin/harness-evolution.exe1,293,824 B,独立两跑一致。1.0 参考实现(legacy-ts/,TypeScript + Node)6 suites / 75 tests 全过,跨实现合计 422/422。特性
plugin.json/SKILL.md,评复杂度、接口清晰度、文档质量。pending → approved → executing → completed,非approved拒绝执行。create_sub_agent/list_sub_agents/delete_sub_agent)管理两个作用域的 Markdown + YAML frontmatter 定义文件;路径 A 出厂模板、路径 B 动态管理均已上线,路径 C(OCR 触发真实派发)待平台回调。兼容性
本插件兼容多种 Harness 平台:
zcode plugin link/zcode plugin list等)多宿主支持
~/.deepseek/harness/plugins/,~/.deepseek/harness/extensions/~/.minimax/plugins/,~/.minimax/extensions/~/.zcode/cli/plugins/,~/.zcode/skills/~/.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/装配与启动"] MCP["mcp/
10 工具 · stdio JSON-RPC"] ENG["engine/
决策树 + 风险评估"] EXE["executor/
DAG 分层 + Sub-Agent 编排"] FAC["factory/
子 Agent 定义管理"] SCN["scanner/
插件发现 + 信息提取"] MON["monitor/
性能采集 + 信号检测"] ST["store/
唯一持久化层
(JSONL / 缓存 / 提案 / 子 Agent)"] TY["types/
19 张 wire 表 · 词汇表单一事实来源"] UT["util/
路径 / 时间 / 日志 / 4 个零依赖 Deep Module"] end Client -- "scan_plugins / propose_evolution /
approve_proposal / execute_evolution /
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
依赖图是严格分层的(
util → types → store → scanner/monitor → engine/executor/factory → mcp → harness_evolution),由src/mcp/architecture_test.mbt的 11 条守卫(G1–G6)机器化验证;任何新增反向边、往 stdout 写日志、绕过store/持久化,都会在moon test里立刻变红。安装
前置要求:
moon)。cl.exe)+ Windows SDK。native 后端把 MoonBit 编译成 C 再用 MSVC 链接,build.ps1会自动探测并注入INCLUDE/LIB/PATH,不需要手工跑vcvars64.bat。mcode)运行时不需要 Node.js —— 产物是独立的 native 可执行文件。
快速开始
1. 环境准备
确保已安装以下工具:
moon):从 MoonBit 官网 下载安装cl.exe)+ Windows SDK(build.ps1会自动探测)npm install -g mmx-cli2. 获取与构建
构建成功后,产物位于
bin/harness-evolution.exe。3. 链接到宿主(ZCode)
4. 启动插件
插件作为 MCP 服务器运行,由宿主自动启动。启动流程:
.zcode-plugin/plugin.json配置bin/harness-evolution.exe进程scan_targets)5. 验证运行
应该能看到
harness-self-evolution (v2.4.0) - Active。6. 使用插件功能
通过宿主调用 MCP 工具:
手动测试(可选)
如需手动测试 MCP 服务器,可使用 MCP 客户端工具:
build.ps1子命令.\build.ps1 checkmoon check --deny-warn --target native(零错零警才算过).\build.ps1 testmoon test --target native.\build.ps1 buildbin\harness-evolution.exe.\build.ps1 fmtmoon fmt.\build.ps1 all配置
配置只来自
.zcode-plugin/plugin.json的evolution_config段(查找顺序:$HARNESS_EVOLUTION_CONFIG→<cwd>/.zcode-plugin/plugin.json→ 内置默认值)。**AGENTS.md不参与任何配置解析**。2.2.0 起,
plugin.json的scan_targets段 真正驱动扫描根:数组里的每个路径(支持~/...)替换内置的 3 个默认根;未配置/为空/类型不符时回退默认根并启动时点名告警。不存在的路径在扫描时跳过并打一行 stderr 提示。完整语义见CONTEXT.md的「配置来源」一节。字段含义(完整列表与边界见
CONTEXT.md与DESIGN.md):intensity:"100%"强信号或两个中信号均可触发;"50%"仅强信号触发;"0%"关闭所有进化检查。出厂默认 50%。auto_approve:故意不接通。1.0 里它是配置孤岛(写了但无消费方),2.0 起遇true显式告警并回落false—— 人工审批是「自动改代码失控」的唯一闸门。cooldown_hours:同一插件两次提案的最短间隔,默认 24,下界 1。max_log_bytes:metrics.jsonl/signals.jsonl的保留上限(字节,默认 32 MiB,下界 1 MiB),超限后自动裁到只保留最新的完整行。proposals.jsonl(审计事实来源)与execution.log不裁剪。signal_thresholds.*:连续失败次数 / 循环检测次数 / 性能回归比例。调用模式
本插件是 MCP 服务器,一切行为都由工具调用驱动:
scan_plugins(2.2.0 起按plugin.json的scan_targets段指定根)建立档案。record_tool_call/record_user_feedback注入事件。propose_evolution基于信号生成提案。approve_proposal→execute_evolution(必经人工审批)。MCP 工具(16 个)
scan_pluginsscan_targets段)get_plugin_metricspropose_evolutionsignals)approve_proposalreject_proposallist_proposalsexecute_evolutioncreate_sub_agentlist_sub_agentsscope过滤)delete_sub_agentanalyze_pluginsmode=scan/metrics/both)evolve_pluginaction=propose/execute)manage_sub_agentaction=create/list/delete)get_execution_planreport_task_resultfinalize_executionDSH Sub-Agent 集成
快速开始:
执行流程:
详细文档见
DSH_INTEGRATION.md。数据存储
所有数据以 JSONL / JSON 格式存储在同一个数据根目录下(默认
~/.harness-evolution/v2/,可用$HARNESS_EVOLUTION_HOME覆盖):子 Agent 用户目录(scope=user)按宿主类型区分:
~/.deepseek/harness/agents/~/.minimax/agents/~/.zcode/agents/可通过环境变量
HARNESS_EVOLUTION_HOST切换宿主类型。出厂模板随插件的
agents/目录分发(frontmatter + 系统提示词,ZCode 的 agent 载体格式),宿主会自动发现加载;create_sub_agent/list_sub_agents/delete_sub_agent三个工具可以增删管理这些定义。设计与研究结论见docs/subagent-factory.md。架构守卫(G1–G6)
@stdio.stdout只在mcp/server.mbt,@stdio.stderr只在util/log.mbt@fs的写操作只在store/store/paths.mbtlegacy-ts/tests/的 37 个 jest 用例逐条有 MoonBit 对应物moon.mod只有一个外部依赖,且 native 是首选目标每条守卫都做过负向探针验证(人为引入违规确认会变红),否则「永远通过的测试」只是装饰。
与 1.0(TypeScript)版对拍
1.0 的完整工程保留在
legacy-ts/,仍可运行:它是 2.0 移植正确性的客观参照:G5 守卫会解析这 37 个用例名,逐条核对 MoonBit 侧的对应测试是否仍然存在。
风险缓解
approve_proposal。pending → approved → executing → completed(或被reject_proposal回到rejected),非法跃迁一律拒。signal_buffer上限 500 条(max_buffered_signals),溢出丢最旧。num_field拒绝NaN/Infinity,回落默认值并点名告警。metrics.jsonl/signals.jsonl受max_log_bytes约束,超限保留最新完整行。propose_evolution的signals参数按设计是 medium 强度,默认 50% 只放行 strong —— 手动信号在出厂默认配置下不会触发提案;要把手动信号生效得把intensity设为"100%"(已知缺陷第 1 条 F5)。record_tool_call/record_user_feedback在本仓库里没有生产调用方(1.0 也一样)。可走手动路径,但自动信号需 Harness 侧注入事件(注入点已就绪,待平台回调)。文档
CONTEXT.md—— 设计上下文、缺陷清单、配置来源、架构守卫、Matt Pocock 原则 ↔ 进化类型映射DESIGN.md—— 详细设计、模块边界、调用链DSH_INTEGRATION.md—— DSH Sub-Agent 集成指南docs/subagent-factory.md—— 子 Agent 工厂的设计与研究结论specs/minimax-code-support.md—— Minimax Code 扫描支持规格legacy-ts/—— 1.0(TypeScript)版的完整工程,作为移植正确性的客观参照贡献
欢迎提交 Issue 和 Pull Request。请先读
CONTEXT.md的「架构不变量」与「Matt Pocock 原则」两节 —— 任何反向边、往 stdout 写日志、绕过store/持久化、引入裸配置孤岛,都会被架构守卫在moon test阶段直接拒。许可证
MIT
English
What is this
A self-evolution plugin for multiple Harness platforms (primary: DeepSeek Harness). It scans plugins, monitors performance, detects signals, drafts upgrade proposals, and (only after explicit human approval) executes the upgrade. The user touches it in exactly one place: reviewing proposals.
Supported platforms: DeepSeek Harness / Minimax Code / ZCode / Claude Code / OpenClaw
Latest (v2.4.0, 2026-09-09)
dsh-runner.tsadapter that hands a topology-sorted task DAG to the host DeepSeek Harness Agent; the host executes each layer in parallel viasubagentcalls, then writes results back viareport_task_resultand finalizes withfinalize_execution. SeeDSH_INTEGRATION.md(371 lines) for the full host-side contract.runner.mbtreadsHARNESS_EVOLUTION_AGENT_CMD(template with{prompt}/{input}placeholders) and dispatches to@process; falls back to a mock when unset, with sandbox and streaming-IO extension points preserved.list_skill_and_source_filescollects skill and source manifests in a single walk, halving I/O for large plugin trees.legacy-ts/.eslintrc.jslands;tests/server.test.tsandtests/store.test.tsclose the 1.0 coverage gap (75/75, +41 tests in this round).Quickstart
1. Prerequisites
moon): download from MoonBit websitecl.exe) + Windows SDK (auto-detected bybuild.ps1)npm install -g mmx-cli2. Clone and Build
The output binary is at
bin/harness-evolution.exe.3. Link to Host (ZCode)
4. Run
The plugin runs as an MCP server, automatically started by the host:
.zcode-plugin/plugin.jsonconfigurationbin/harness-evolution.exescan_targets)5. Verify
6. Use Plugin Features
Documentation
CONTEXT.md— design context, defect ledger, config source, architecture guardsDESIGN.md— detailed designdocs/subagent-factory.md— sub-agent factoryLicense
MIT