doukui 0.0.0-stage → 0.3.1
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/LICENSE +21 -0
- package/README.en.md +42 -0
- package/README.md +147 -2
- package/bin/commands/build.js +178 -0
- package/bin/commands/config.js +88 -0
- package/bin/commands/help.js +83 -0
- package/bin/commands/init.js +194 -0
- package/bin/commands/install.js +202 -0
- package/bin/commands/interactive.js +352 -0
- package/bin/commands/list.js +108 -0
- package/bin/commands/loop-server.js +357 -0
- package/bin/commands/loop.js +1443 -0
- package/bin/commands/migrate.js +120 -0
- package/bin/commands/setup-global.js +81 -0
- package/bin/commands/status.js +140 -0
- package/bin/commands/team-cleanup.js +190 -0
- package/bin/commands/validate-config.js +35 -0
- package/bin/commands/validate.js +21 -0
- package/bin/commands/version.js +22 -0
- package/bin/context.js +143 -0
- package/bin/doukui.js +216 -0
- package/package.json +47 -4
- package/plugins/contracts/capabilities.js +268 -0
- package/plugins/contracts/checkresult-schema.json +75 -0
- package/plugins/contracts/config-schema.json +179 -0
- package/plugins/contracts/plugin-interface.js +262 -0
- package/plugins/contracts/plugin-schema.json +104 -0
- package/plugins/core/hook-session-start/index.js +281 -0
- package/plugins/core/hook-session-start/plugin.json +7 -0
- package/plugins/core/hook-skill-gate/index.js +661 -0
- package/plugins/core/hook-skill-gate/plugin.json +12 -0
- package/plugins/core/provider-loop-engine/index.js +1411 -0
- package/plugins/core/provider-loop-engine/plugin.json +15 -0
- package/plugins/core/provider-memory-store/index.js +510 -0
- package/plugins/core/provider-memory-store/plugin.json +9 -0
- package/plugins/core/provider-role-registry/index.js +376 -0
- package/plugins/core/provider-role-registry/plugin.json +9 -0
- package/plugins/core/provider-state-store/index.js +244 -0
- package/plugins/core/provider-state-store/plugin.json +9 -0
- package/plugins/core/provider-watchdog/assets/daemon-config.template.json +32 -0
- package/plugins/core/provider-watchdog/assets/lib/watchdog-multi-window.js +676 -0
- package/plugins/core/provider-watchdog/assets/watchdog.js +754 -0
- package/plugins/core/provider-watchdog/index.js +151 -0
- package/plugins/core/provider-watchdog/plugin.json +13 -0
- package/plugins/core/skill-agent-dispatcher/cleanup-reference.md +214 -0
- package/plugins/core/skill-agent-dispatcher/daemon-helpers-reference.md +249 -0
- package/plugins/core/skill-agent-dispatcher/plugin.json +13 -0
- package/plugins/core/skill-agent-dispatcher/roles-reference.md +253 -0
- package/plugins/core/skill-agent-dispatcher/skill.md +1291 -0
- package/plugins/core/skill-agentic-loop/plugin.json +20 -0
- package/plugins/core/skill-agentic-loop/skill.md +588 -0
- package/plugins/core/skill-batch-task-creator/plugin.json +15 -0
- package/plugins/core/skill-batch-task-creator/skill.md +620 -0
- package/plugins/core/skill-checklist/plugin.json +10 -0
- package/plugins/core/skill-checklist/skill.md +171 -0
- package/plugins/core/skill-completion-report/plugin.json +10 -0
- package/plugins/core/skill-completion-report/skill.md +331 -0
- package/plugins/core/skill-doukui-plan/plugin.json +15 -0
- package/plugins/core/skill-doukui-plan/skill.md +233 -0
- package/plugins/core/skill-doukui-sync/plugin.json +10 -0
- package/plugins/core/skill-doukui-sync/skill.md +76 -0
- package/plugins/core/skill-experience-logger/plugin.json +10 -0
- package/plugins/core/skill-experience-logger/skill.md +235 -0
- package/plugins/core/skill-human-checkpoint/plugin.json +10 -0
- package/plugins/core/skill-human-checkpoint/skill.md +194 -0
- package/plugins/core/skill-progress-tracker/plugin.json +10 -0
- package/plugins/core/skill-progress-tracker/skill.md +228 -0
- package/plugins/core/skill-role-manager/plugin.json +10 -0
- package/plugins/core/skill-role-manager/skill.md +252 -0
- package/plugins/core/skill-split-work-package/plugin.json +15 -0
- package/plugins/core/skill-split-work-package/skill.md +441 -0
- package/plugins/core/skill-task-archive/plugin.json +10 -0
- package/plugins/core/skill-task-archive/skill.md +116 -0
- package/plugins/core/skill-task-creator/plugin.json +15 -0
- package/plugins/core/skill-task-creator/skill.md +886 -0
- package/plugins/core/skill-team-cleanup/plugin.json +10 -0
- package/plugins/core/skill-team-cleanup/skill.md +266 -0
- package/plugins/core/skill-watchdog-manager/plugin.json +10 -0
- package/plugins/core/skill-watchdog-manager/skill.md +143 -0
- package/plugins/core/skill-workflow-orchestrator/plugin.json +13 -0
- package/plugins/core/skill-workflow-orchestrator/skill.md +273 -0
- package/plugins/core/validator-doc-sync/index.js +248 -0
- package/plugins/core/validator-doc-sync/plugin.json +12 -0
- package/plugins/core/validator-work-package/index.js +300 -0
- package/plugins/core/validator-work-package/plugin.json +12 -0
- package/plugins/plugin-registry.json +186 -0
- package/plugins/runtime/agent-def-generator.js +150 -0
- package/plugins/runtime/audit-logger.js +311 -0
- package/plugins/runtime/build-cli.js +89 -0
- package/plugins/runtime/checkresult-validator.js +131 -0
- package/plugins/runtime/claude-md-injector.js +159 -0
- package/plugins/runtime/cleanup-utils.js +293 -0
- package/plugins/runtime/config-manager.js +317 -0
- package/plugins/runtime/config-validator.js +320 -0
- package/plugins/runtime/context-window.js +81 -0
- package/plugins/runtime/event-bus.js +207 -0
- package/plugins/runtime/executor-claude.js +828 -0
- package/plugins/runtime/executor-default.js +448 -0
- package/plugins/runtime/executor-local.js +178 -0
- package/plugins/runtime/executor-sdk.js +415 -0
- package/plugins/runtime/harness-build.js +1037 -0
- package/plugins/runtime/hook-dispatcher.js +315 -0
- package/plugins/runtime/logger.js +192 -0
- package/plugins/runtime/loop-actuator.js +292 -0
- package/plugins/runtime/loop-coordinator.js +347 -0
- package/plugins/runtime/loop-defaults.js +29 -0
- package/plugins/runtime/loop-dispatch-batch.js +247 -0
- package/plugins/runtime/loop-executor.js +120 -0
- package/plugins/runtime/loop-report.js +327 -0
- package/plugins/runtime/loop-server-core.js +750 -0
- package/plugins/runtime/loop-snapshot.js +581 -0
- package/plugins/runtime/loop-trace.js +242 -0
- package/plugins/runtime/loop-worktree.js +404 -0
- package/plugins/runtime/manifest-resolver.js +457 -0
- package/plugins/runtime/multi-window-coordinator.js +560 -0
- package/plugins/runtime/objective-verifier.js +136 -0
- package/plugins/runtime/plan-lint.js +100 -0
- package/plugins/runtime/plan-reader.js +763 -0
- package/plugins/runtime/plugin-loader.js +798 -0
- package/plugins/runtime/plugin-trust.js +182 -0
- package/plugins/runtime/plugin-validator.js +491 -0
- package/plugins/runtime/provider-failover.js +114 -0
- package/plugins/runtime/provider-resolver.js +342 -0
- package/plugins/runtime/reflection-evaluator.js +545 -0
- package/plugins/runtime/resolve-plugin-path.js +297 -0
- package/plugins/runtime/safe-path.js +119 -0
- package/plugins/runtime/sandbox-context.js +235 -0
- package/plugins/runtime/sandbox-manager.js +609 -0
- package/plugins/runtime/sandbox-worker.js +215 -0
- package/plugins/runtime/self-rescue-ladder.js +38 -0
- package/plugins/runtime/settings-merger.js +172 -0
- package/plugins/runtime/state-store.js +527 -0
- package/plugins/runtime/team-cleanup.js +497 -0
- package/plugins/runtime/text-tokenize.js +25 -0
- package/plugins/runtime/validator-pipeline.js +475 -0
- package/plugins/runtime/yaml-parser.js +692 -0
- package/templates/harness-config.yaml +394 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Doukui contributors
|
|
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.en.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Doukui
|
|
2
|
+
|
|
3
|
+
> Multi-provider AI agent orchestration harness for Claude Code — goal-driven agentic loop, dependency-graph parallel dispatch, per-WP worktree isolation, and first-class multi-provider support (GLM / DeepSeek / MiMo / Claude)
|
|
4
|
+
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://github.com/chen-xiaochen/doukui)
|
|
7
|
+
|
|
8
|
+
**[中文文档](./README.md)**
|
|
9
|
+
|
|
10
|
+
> "Doukui" (斗魁) names the four stars forming the bowl of the Big Dipper — the pivot around which the handle turns. All work packages orbit it; many models drive it.
|
|
11
|
+
> Doukui is a ground-up rebuild of [tackle-harness](https://github.com/ph419/tackle-harness) v0.4.9 (Nov 2026, refactor phases A–E). Thanks to its predecessor.
|
|
12
|
+
|
|
13
|
+
## Why Doukui
|
|
14
|
+
|
|
15
|
+
You run Claude Code, but your daily models are domestic providers (Zhipu GLM / DeepSeek / MiMo) over Anthropic-compatible endpoints. The official ecosystem does not cover you: server-side compaction, the memory tool, and constrained decoding are Anthropic-side capabilities. **Doukui fills the orchestration layer that the domestic-model camp is missing**:
|
|
16
|
+
|
|
17
|
+
- **Plan first, human gate** — the AI outputs an implementation plan and work-package split; you approve before any code is written.
|
|
18
|
+
- **Parallel delivery by dependency graph** — large requests are split into work packages (WPs) dispatched in parallel; each WP runs in its own git worktree and is cherry-picked back.
|
|
19
|
+
- **Multi-provider in one plan** — switch providers with `--settings`; per-provider quota accounting, context-window tiering (DeepSeek V4 → 1M), GLM 5h-window quota as observability-only.
|
|
20
|
+
- **Selectable execution carrier** — `--executor=sdk` (Claude Agent SDK: streaming messages, session resume) or `--executor=default` (spawn CLI fallback, zero SDK dependency). Checklist self-reports pass through JSON Schema validation plus objective command cross-checking; LLM lying is overridden.
|
|
21
|
+
- **Experience accrues** — lessons are distilled after each task and stored per role for future sessions.
|
|
22
|
+
|
|
23
|
+
## Quick start
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install -g doukui
|
|
27
|
+
cd your-project
|
|
28
|
+
doukui init
|
|
29
|
+
|
|
30
|
+
# Smoke test (mock executor, free)
|
|
31
|
+
doukui loop test/fixtures/todo-cli-smoke.md --executor=local
|
|
32
|
+
|
|
33
|
+
# Real run: SDK carrier over a GLM plan (provider auto-detected from --settings)
|
|
34
|
+
doukui loop docs/plan/my-plan.md --executor=sdk \
|
|
35
|
+
--settings=~/.claude/settings-glm-5.2[1m]max.json
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Requires Node.js >= 18. See the [Chinese README](./README.md) for the full guide (command reference, plugin architecture, design docs, provider capability matrix).
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
MIT — see [LICENSE](LICENSE).
|
package/README.md
CHANGED
|
@@ -1,3 +1,148 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Doukui(斗魁)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Claude Code 的多模型编排 harness —— 目标驱动的 Agentic Loop、依赖图并行调度、per-WP worktree 隔离、多 provider 统筹(GLM / DeepSeek / MiMo / Claude)
|
|
4
|
+
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://github.com/chen-xiaochen/doukui)
|
|
7
|
+
|
|
8
|
+
**[English](./README.en.md)**
|
|
9
|
+
|
|
10
|
+
> 斗魁,北斗前四星之总称,勺子枢转的中心——众 WP 绕其调度,多模型供其驱策。
|
|
11
|
+
> Doukui 重构自 [tackle-harness](https://github.com/ph419/tackle-harness) v0.4.9(2026-11,Phase A-E 激进重构),致谢前身。
|
|
12
|
+
|
|
13
|
+
## 为什么是 Doukui
|
|
14
|
+
|
|
15
|
+
你在用 Claude Code,但主力模型是智谱 / DeepSeek / MiMo 这些国内大模型。官方生态帮不到你:服务端 compaction、memory tool、约束解码都是 Anthropic 端的能力。**Doukui 补的正是国内模型阵营缺失的那层编排基础设施**:
|
|
16
|
+
|
|
17
|
+
- **方案先行,人工把关** — AI 先输出实施方案和工作包拆分,等你确认后才动手写代码。不会出现「AI 自作主张改了一堆东西」的情况。
|
|
18
|
+
- **复杂需求,并行交付** — 大需求自动拆成多个独立工作包(WP),按依赖图调度多个 Agent 同时工作,每个 WP 独立 git worktree 隔离执行、cherry-pick 回填。
|
|
19
|
+
- **多模型统筹** — 一份 plan,provider 随意切:`--settings` 透传 GLM / DeepSeek / MiMo 的 Anthropic 兼容端点,按 provider 分桶记账额度、分档上下文窗口(DeepSeek V4 → 1M),GLM 5h 窗口配额只观测不阻断。
|
|
20
|
+
- **执行载体可选** — `--executor=sdk`(Claude Agent SDK:流式消息 + 断点续轮)或 `--executor=default`(spawn CLI,零 SDK 依赖回退)。checklist 自报经 schema 校验 + 客观命令交叉验证,LLM 谎报直接改判。
|
|
21
|
+
- **经验沉淀,越用越好** — 每次任务完成后自动提炼经验教训,按角色存档供后续会话参考。
|
|
22
|
+
|
|
23
|
+
## 核心概念:Agentic Loop
|
|
24
|
+
|
|
25
|
+
P1 审核通过后,`doukui loop` 以 Node 进程驱动决策状态机,按 `Observe → Think → Act → Reflect → Decide` 循环推进直到达成 / 发散 / 熔断 / 触顶:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# 冒烟(mock executor,不调真模型,免费验证收敛)
|
|
29
|
+
doukui loop test/fixtures/todo-cli-smoke.md --executor=local
|
|
30
|
+
|
|
31
|
+
# 真实执行:SDK 载体 + 智谱套餐档(provider 由 --settings 文件自动探测)
|
|
32
|
+
doukui loop docs/plan/my-plan.md --executor=sdk \
|
|
33
|
+
--settings=~/.claude/settings-glm-5.2[1m]max.json
|
|
34
|
+
|
|
35
|
+
# spawn CLI 载体(不装 SDK 时的回退,行为一致)
|
|
36
|
+
doukui loop docs/plan/my-plan.md --executor=default
|
|
37
|
+
|
|
38
|
+
# 并发批:默认 N=2,批内 WP 并行 spawn + per-WP worktree 隔离
|
|
39
|
+
doukui loop my-plan.md --executor=sdk --concurrency=2
|
|
40
|
+
|
|
41
|
+
# 多 loop 并行(state 物理隔离)
|
|
42
|
+
doukui loop planA.md --loop-id=A --executor=sdk &
|
|
43
|
+
doukui loop planB.md --loop-id=B --executor=sdk &
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- **决策单一真相源**:判定逻辑全部在 JS 引擎(`provider-loop-engine`)+ 单一阈值源(`loop-defaults.js`);skill 侧仅是行为镜像,由 CI 测试锁定一致性
|
|
47
|
+
- **三重上限保护 + 终态前自救链**:`max_iterations`(默认 6)、`max_round_time_ms`(10min)、`max_wall_time_ms`(1h)均可配置;触顶/发散后**不直接停人**——先自动穷尽自救(换 provider → 换模型,`loop.self_rescue` 可配),穷尽才停且报告标注已试级别
|
|
48
|
+
- **checklist 双重校验**:LLM 自报输出先过 JSON Schema(数值谎报硬改判),再对声明了 `verify.command` 的检查项实跑命令交叉验证(自报 pass 但 `npm test` 失败 → 判 fail)
|
|
49
|
+
- **verify 优先的验收**:plan 验收项可加 `[verify: npm test]` 尾标——命令可验证的项零 LLM 自由判断(更可靠且省 token)
|
|
50
|
+
- **断点恢复 + 精读 retry**:每 phase 落盘 state-store,防上下文压缩丢失;`--loop-id` 跨 run 恢复;SDK 载体额外支持 session 级续轮;retry 只注入与失败项相关的文档段落(非全量重灌)
|
|
51
|
+
- **plan.md 热更新**:运行中修改 plan.md,下一轮自动重解析依赖图
|
|
52
|
+
- **风险分级人审**:plan 顶层声明 `风险分级: low` + 环境设一次 `DOUKUI_LOW_RISK_GATE=1`,纯文档/测试类任务全程无人值守;未声明的 plan 照常完整人审
|
|
53
|
+
- **prompt cache 友好**:prompt 按「稳定前缀 → WP 文档 → 动态尾巴」排列,吃满 GLM/DeepSeek 的 context cache(同一 WP retry 前缀命中率 78%+)
|
|
54
|
+
|
|
55
|
+
## Provider 能力矩阵
|
|
56
|
+
|
|
57
|
+
SDK 载体在各 Anthropic 兼容端点的实测结果(探针脚本 `test/integration/test-provider-capability.js`,`DOUKUI_CAPABILITY_PROBE=1` 显式开启):
|
|
58
|
+
|
|
59
|
+
| 通道 | P1 stream | P2 fenced | P3 resume(断点续轮) | 备注 |
|
|
60
|
+
|---|---|---|---|---|
|
|
61
|
+
| 智谱 GLM(默认通道实测) | ✅ | ✅ | ✅ | resume 首轮偶发 >60s |
|
|
62
|
+
| DeepSeek / MiMo / Claude 官方 | 待跑探针补全 | — | — | 每通道 4 次最小调用 |
|
|
63
|
+
|
|
64
|
+
详见 [docs/design/provider-capability-matrix.md](docs/design/provider-capability-matrix.md)。
|
|
65
|
+
|
|
66
|
+
## 安装
|
|
67
|
+
|
|
68
|
+
前提: Node.js >= 18.0.0
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npm install -g doukui
|
|
72
|
+
cd your-project
|
|
73
|
+
doukui init # 创建配置目录 + 注册钩子
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
SDK 载体按需启用(可选依赖,不装不影响 default 载体):
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npm i -g @anthropic-ai/claude-agent-sdk
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## 命令一览
|
|
83
|
+
|
|
84
|
+
| 命令 | 说明 |
|
|
85
|
+
|------|------|
|
|
86
|
+
| `doukui init` | 首次安装:创建配置目录并注册钩子 |
|
|
87
|
+
| `doukui build` | 更新 .claude/settings.json,注册全局技能和钩子 |
|
|
88
|
+
| `doukui loop <plan>` | Node 进程驱动 Agentic Loop(`--executor=sdk\|default\|local` / `--concurrency=N` / `--loop-id=X` / `--settings=<path>`) |
|
|
89
|
+
| `doukui loop-server <start\|status\|abort>` | 多 loop 协调守护进程:全局视图、per-provider 额度池观测、全局熔断 |
|
|
90
|
+
| `doukui migrate` | 迁移旧项目配置 |
|
|
91
|
+
| `doukui team-cleanup <name>` | 确定性清理残留的 Agent Teams 团队目录 |
|
|
92
|
+
| `doukui validate` / `validate-config` | 插件格式 / harness-config 校验 |
|
|
93
|
+
| `doukui interactive` | 交互式插件管理(别名 `i`) |
|
|
94
|
+
| `doukui status` / `list` / `config` / `version` | 状态查询 |
|
|
95
|
+
|
|
96
|
+
## 工作流概览
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
需求 → 规划(P0) → 审核(P1) → 执行(P2) → 检查(P3) → 汇报(P4) → 交付
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
| 阶段 | 做什么 | 关键技能 |
|
|
103
|
+
|------|--------|----------|
|
|
104
|
+
| **P0 规划** | 解析需求,拆分为工作包,写入文档 | task-creator, split-work-package |
|
|
105
|
+
| **P1 审核** | 暂停等待你确认方案(强制人工介入) | human-checkpoint |
|
|
106
|
+
| **P2 执行** | 多 Agent 并行开发,按依赖图调度 | agent-dispatcher / agentic-loop |
|
|
107
|
+
| **P3 检查** | 代码/测试/文档质量验证,提炼经验 | checklist, experience-logger |
|
|
108
|
+
| **P4 汇报** | 生成完成报告,询问下一步 | completion-report |
|
|
109
|
+
|
|
110
|
+
## 插件架构
|
|
111
|
+
|
|
112
|
+
四类插件,共 26 个:
|
|
113
|
+
|
|
114
|
+
| 类型 | 数量 | 作用 |
|
|
115
|
+
|------|------|------|
|
|
116
|
+
| Skill | 17 | 可执行技能,Claude Code 直接调用 |
|
|
117
|
+
| Provider | 5 | 状态存储、loop 决策引擎、角色注册、记忆存储、守护进程 |
|
|
118
|
+
| Hook | 2 | 技能门控 + 会话启动注入 plan-mode 规则 |
|
|
119
|
+
| Validator | 2 | 文档同步验证、工作包验证 |
|
|
120
|
+
|
|
121
|
+
## 文档
|
|
122
|
+
|
|
123
|
+
- [Agentic Loop 设计](docs/design/agentic-loop-design.md) — 五阶段状态机、终止判定、持久化
|
|
124
|
+
- [工作流详解](docs/design/ai_workflow.md) — 完整数据流
|
|
125
|
+
- [配置参考](docs/design/config-reference.md) — harness-config.yaml 全量说明
|
|
126
|
+
- [Provider 能力矩阵](docs/design/provider-capability-matrix.md) — 各端点 SDK 能力实测
|
|
127
|
+
- [插件开发](docs/design/plugin-development.md) / [API 参考](docs/design/api-reference.md)
|
|
128
|
+
- [安全披露](SECURITY.md) — sandbox 能力声明当前为 decorative(未强制),加载第三方插件前请阅读
|
|
129
|
+
|
|
130
|
+
## 与前身的关系
|
|
131
|
+
|
|
132
|
+
| | tackle-harness(前身) | doukui |
|
|
133
|
+
|---|---|---|
|
|
134
|
+
| 执行载体 | spawn `claude -p` 单一路径 | Agent SDK(流式/续轮)+ spawn 回退 |
|
|
135
|
+
| 结构化输出 | fenced block 裸解析 | fenced + JSON Schema 校验 + 客观命令交叉验证 |
|
|
136
|
+
| 阈值/决策 | 三处硬编码重复、skill 与 engine 双源 | loop-defaults 单源 + CI 镜像锁 |
|
|
137
|
+
| 上下文窗口 | 固定 200K 默认 | 按 provider 分档(DeepSeek V4 → 1M) |
|
|
138
|
+
| 品牌/命令 | tackle-harness / tackle | doukui |
|
|
139
|
+
|
|
140
|
+
## 致谢
|
|
141
|
+
|
|
142
|
+
- [tackle-harness](https://github.com/ph419/tackle-harness) — 前身,Doukui 的全部骨架来源
|
|
143
|
+
- [Claude Agent SDK](https://github.com/anthropics/claude-agent-sdk-typescript) — SDK 载体
|
|
144
|
+
- DeerFlow — 记忆提取与插件架构参考
|
|
145
|
+
|
|
146
|
+
## 许可证
|
|
147
|
+
|
|
148
|
+
MIT License - 详见 [LICENSE](LICENSE)
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var path = require('path');
|
|
4
|
+
var fs = require('fs');
|
|
5
|
+
var safePath = require('../../plugins/runtime/safe-path');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Build command - Build all plugins into .claude/skills/ and update settings.json
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
module.exports = {
|
|
12
|
+
name: 'build',
|
|
13
|
+
description: 'Build all plugins (default)',
|
|
14
|
+
/**
|
|
15
|
+
* Execute the build command.
|
|
16
|
+
* @public
|
|
17
|
+
* @param {object} ctx - CLI context object
|
|
18
|
+
*/
|
|
19
|
+
execute: function (ctx) {
|
|
20
|
+
// Ensure harness-config.yaml exists (auto-create from template if missing)
|
|
21
|
+
var configDir = ctx.configDir;
|
|
22
|
+
var targetConfigPath = path.join(configDir, 'harness-config.yaml');
|
|
23
|
+
if (!fs.existsSync(targetConfigPath)) {
|
|
24
|
+
var templatePath = path.join(ctx.packageRoot, 'templates', 'harness-config.yaml');
|
|
25
|
+
if (fs.existsSync(templatePath)) {
|
|
26
|
+
if (!fs.existsSync(configDir)) {
|
|
27
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
28
|
+
}
|
|
29
|
+
var content = fs.readFileSync(templatePath, 'utf-8');
|
|
30
|
+
fs.writeFileSync(targetConfigPath, content, 'utf-8');
|
|
31
|
+
console.log('[doukui] Created default harness-config.yaml');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Detect if running in global mode (using --root to build external project)
|
|
36
|
+
var isGlobalMode = ctx.flags.root !== null && ctx.targetRoot !== process.cwd();
|
|
37
|
+
|
|
38
|
+
if (isGlobalMode) {
|
|
39
|
+
console.log(ctx.colorize('[doukui] Global mode detected (building external project)', 'cyan'));
|
|
40
|
+
console.log('[doukui] Skills and hooks will remain in the global installation.');
|
|
41
|
+
console.log('[doukui] Only settings.json will be updated in the target project.');
|
|
42
|
+
console.log('');
|
|
43
|
+
} else {
|
|
44
|
+
console.log(ctx.colorize('[doukui] Building plugins...', 'cyan'));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var builder = ctx.createBuilder();
|
|
48
|
+
var result;
|
|
49
|
+
|
|
50
|
+
if (isGlobalMode) {
|
|
51
|
+
// Global mode: skip building skills/hooks to project, only update settings
|
|
52
|
+
result = {
|
|
53
|
+
success: true,
|
|
54
|
+
built: [],
|
|
55
|
+
errors: [],
|
|
56
|
+
summary: '=== Build Report (Global Mode) ===\n\nInstallation: Global (external project)\nSkills output: ' + ctx.packageRoot + ' (global)\nHooks output: ' + ctx.packageRoot + ' (global)\n\nNo files written to target project.\nSkills and hooks are read from global installation.\n\nBuild SUCCEEDED (global mode)\n'
|
|
57
|
+
};
|
|
58
|
+
} else {
|
|
59
|
+
// Local mode: build normally
|
|
60
|
+
result = builder.build();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (result.success) {
|
|
64
|
+
if (ctx.flags.verbose) {
|
|
65
|
+
console.log(ctx.colorize('[doukui] Updating settings.json...', 'dim'));
|
|
66
|
+
}
|
|
67
|
+
builder.updateSettings(ctx.targetRoot, ctx.packageRoot);
|
|
68
|
+
builder.injectClaudeMdRules(ctx.targetRoot);
|
|
69
|
+
cleanStaleOutput(ctx, builder);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Apply colors to summary output
|
|
73
|
+
var coloredSummary = result.summary
|
|
74
|
+
.replace(/Build SUCCEEDED/g, ctx.colorize('Build SUCCEEDED', 'green'))
|
|
75
|
+
.replace(/Build COMPLETED WITH ERRORS/g, ctx.colorize('Build COMPLETED WITH ERRORS', 'yellow'))
|
|
76
|
+
.replace(/Validation PASSED/g, ctx.colorize('Validation PASSED', 'green'))
|
|
77
|
+
.replace(/Validation FAILED/g, ctx.colorize('Validation FAILED', 'red'));
|
|
78
|
+
|
|
79
|
+
console.log(coloredSummary);
|
|
80
|
+
|
|
81
|
+
if (result.success) {
|
|
82
|
+
console.log(ctx.colorize('[doukui] Settings updated: .claude/settings.json', 'green'));
|
|
83
|
+
console.log(ctx.colorize('[doukui] CLAUDE.md rules injected.', 'green'));
|
|
84
|
+
if (isGlobalMode) {
|
|
85
|
+
console.log(ctx.colorize('[doukui] Done! Project configured for global skills/hooks.', 'green'));
|
|
86
|
+
} else {
|
|
87
|
+
console.log(ctx.colorize('[doukui] Done! Skills are ready to use.', 'green'));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
ctx.exit(result.success ? 0 : 1);
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Remove stale output directories from disabled plugins.
|
|
97
|
+
* Only removes directories whose names match a registered-but-disabled plugin.
|
|
98
|
+
* User-created directories that don't match any plugin name are preserved.
|
|
99
|
+
*
|
|
100
|
+
* SECURITY: Ensures all deletion operations stay within the expected output directories.
|
|
101
|
+
*/
|
|
102
|
+
function cleanStaleOutput(ctx, builder) {
|
|
103
|
+
var registry = builder._readRegistry();
|
|
104
|
+
var plugins = registry.plugins || [];
|
|
105
|
+
var enabledNames = {};
|
|
106
|
+
var disabledNames = {};
|
|
107
|
+
for (var i = 0; i < plugins.length; i++) {
|
|
108
|
+
var regName = plugins[i].name;
|
|
109
|
+
var pDir = path.join(builder._pluginsDir, plugins[i].source || regName);
|
|
110
|
+
var metaPath = path.join(pDir, 'plugin.json');
|
|
111
|
+
var name = regName;
|
|
112
|
+
if (fs.existsSync(metaPath)) {
|
|
113
|
+
try {
|
|
114
|
+
var meta = JSON.parse(fs.readFileSync(metaPath, 'utf-8'));
|
|
115
|
+
name = meta.name || regName;
|
|
116
|
+
} catch (e) {
|
|
117
|
+
if (ctx.flags.verbose) {
|
|
118
|
+
console.log(ctx.colorize('[doukui] Warning: could not parse ' + metaPath, 'yellow'));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (plugins[i].enabled !== false) {
|
|
123
|
+
enabledNames[name] = true;
|
|
124
|
+
} else {
|
|
125
|
+
disabledNames[name] = true;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
var outputDirs = [
|
|
130
|
+
path.join(ctx.targetRoot, '.claude', 'skills'),
|
|
131
|
+
path.join(ctx.targetRoot, '.claude', 'hooks'),
|
|
132
|
+
];
|
|
133
|
+
|
|
134
|
+
for (var d = 0; d < outputDirs.length; d++) {
|
|
135
|
+
var dir = outputDirs[d];
|
|
136
|
+
|
|
137
|
+
// Security check: ensure the directory is within the expected output tree
|
|
138
|
+
var normalizedDir = path.normalize(dir);
|
|
139
|
+
// S6:用 isWithin 替代 indexOf===0,避免 /foo 被误判为 /foobar 的父目录
|
|
140
|
+
if (!safePath.isWithin(path.normalize(ctx.targetRoot), normalizedDir)) {
|
|
141
|
+
console.log(ctx.colorize('[doukui] Warning: skipping suspicious output directory', 'yellow'));
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (!fs.existsSync(dir)) continue;
|
|
146
|
+
var entries;
|
|
147
|
+
try { entries = fs.readdirSync(dir); } catch (e) { continue; }
|
|
148
|
+
for (var e = 0; e < entries.length; e++) {
|
|
149
|
+
var entryName = entries[e];
|
|
150
|
+
|
|
151
|
+
// Security: prevent path traversal in entry names
|
|
152
|
+
if (entryName.indexOf('..') !== -1 || entryName.indexOf('/') !== -1 || entryName.indexOf('\\') !== -1) {
|
|
153
|
+
console.log(ctx.colorize('[doukui] Warning: skipping suspicious entry name', 'yellow'));
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Only clean up if: directory name belongs to a registered disabled plugin
|
|
158
|
+
if (disabledNames[entryName] && !enabledNames[entryName]) {
|
|
159
|
+
var stalePath = path.join(dir, entryName);
|
|
160
|
+
|
|
161
|
+
// Final security check: verify the path is still within the output directory
|
|
162
|
+
var normalizedStalePath = path.normalize(stalePath);
|
|
163
|
+
// S6:用 isWithin 替代 indexOf===0(此处在 rmSync 前,最关键)
|
|
164
|
+
if (!safePath.isWithin(normalizedDir, normalizedStalePath)) {
|
|
165
|
+
console.log(ctx.colorize('[doukui] Warning: skipping suspicious stale path', 'yellow'));
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
try {
|
|
170
|
+
fs.rmSync(stalePath, { recursive: true, force: true });
|
|
171
|
+
console.log(ctx.colorize('[doukui] Cleaned disabled plugin output: ' + entryName, 'yellow'));
|
|
172
|
+
} catch (err) {
|
|
173
|
+
console.log(ctx.colorize('[doukui] Warning: could not remove ' + entryName, 'yellow'));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Config command - Show/validate current configuration
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
module.exports = {
|
|
10
|
+
name: 'config',
|
|
11
|
+
description: 'Show/validate current configuration',
|
|
12
|
+
/**
|
|
13
|
+
* Execute the config command.
|
|
14
|
+
* @public
|
|
15
|
+
* @param {object} ctx - CLI context object
|
|
16
|
+
*/
|
|
17
|
+
execute: function (ctx) {
|
|
18
|
+
console.log(ctx.colorize('=== Doukui Configuration ===', 'cyan'));
|
|
19
|
+
console.log('');
|
|
20
|
+
|
|
21
|
+
var configPath = ctx.configPath;
|
|
22
|
+
|
|
23
|
+
if (!fs.existsSync(configPath)) {
|
|
24
|
+
console.log(ctx.colorize('Configuration file not found:', 'yellow'));
|
|
25
|
+
console.log(' ' + configPath);
|
|
26
|
+
console.log('');
|
|
27
|
+
console.log('Run "doukui init" to create a default configuration.');
|
|
28
|
+
ctx.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
console.log('Configuration file: ' + configPath);
|
|
32
|
+
console.log('');
|
|
33
|
+
|
|
34
|
+
// Validate configuration
|
|
35
|
+
var builder = ctx.createBuilder();
|
|
36
|
+
var result = builder.validateConfig();
|
|
37
|
+
|
|
38
|
+
console.log('Validation status: ' + (result.valid ? ctx.colorize('Valid', 'green') : ctx.colorize('Invalid', 'red')));
|
|
39
|
+
|
|
40
|
+
if (result.warnings.length > 0) {
|
|
41
|
+
console.log('');
|
|
42
|
+
console.log(ctx.colorize('Warnings:', 'yellow'));
|
|
43
|
+
for (var i = 0; i < result.warnings.length; i++) {
|
|
44
|
+
console.log(' - ' + result.warnings[i]);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (!result.valid) {
|
|
49
|
+
console.log('');
|
|
50
|
+
console.log(ctx.colorize('Errors:', 'red'));
|
|
51
|
+
for (var j = 0; j < result.errors.length; j++) {
|
|
52
|
+
console.log(' - ' + result.errors[j]);
|
|
53
|
+
}
|
|
54
|
+
ctx.exit(1);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Show configuration summary
|
|
58
|
+
console.log('');
|
|
59
|
+
console.log(ctx.colorize('Configuration Summary:', 'cyan'));
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
var content = fs.readFileSync(configPath, 'utf-8');
|
|
63
|
+
var lines = content.split('\n');
|
|
64
|
+
|
|
65
|
+
// Extract and display top-level sections (zero-indent keys only)
|
|
66
|
+
var sections = [];
|
|
67
|
+
for (var k = 0; k < lines.length; k++) {
|
|
68
|
+
var line = lines[k];
|
|
69
|
+
var trimmed = line.trim();
|
|
70
|
+
if (trimmed && !trimmed.startsWith('#') && !trimmed.startsWith('-') &&
|
|
71
|
+
line === line.trimStart() && line.indexOf(':') !== -1) {
|
|
72
|
+
var sectionName = line.split(':')[0].trim();
|
|
73
|
+
if (sectionName && /^[a-z_]/.test(sectionName)) {
|
|
74
|
+
sections.push(sectionName);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (sections.length > 0) {
|
|
80
|
+
console.log(' Sections: ' + sections.join(', '));
|
|
81
|
+
}
|
|
82
|
+
} catch (e) {
|
|
83
|
+
console.log(' (Unable to parse configuration for summary)');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
ctx.exit(0);
|
|
87
|
+
},
|
|
88
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Help command - Show usage info
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
module.exports = {
|
|
8
|
+
name: 'help',
|
|
9
|
+
description: 'Show this help message',
|
|
10
|
+
/**
|
|
11
|
+
* Execute the help command.
|
|
12
|
+
* @public
|
|
13
|
+
* @param {object} ctx - CLI context object
|
|
14
|
+
*/
|
|
15
|
+
execute: function (ctx) {
|
|
16
|
+
console.log(ctx.colorize('doukui - Plugin-based AI Agent Harness for Claude Code', 'cyan'));
|
|
17
|
+
console.log('');
|
|
18
|
+
console.log('Usage:');
|
|
19
|
+
console.log(' doukui [command] [options]');
|
|
20
|
+
console.log('');
|
|
21
|
+
console.log('Commands:');
|
|
22
|
+
var helpCommands = [
|
|
23
|
+
['build', 'Build all plugins (default)'],
|
|
24
|
+
['validate', 'Validate plugin.json files'],
|
|
25
|
+
['validate-config', 'Validate harness-config.yaml'],
|
|
26
|
+
['init', 'First-time setup (build + config)'],
|
|
27
|
+
['install', 'Install an external plugin with security review'],
|
|
28
|
+
['migrate', 'Migrate legacy project structure to global setup'],
|
|
29
|
+
['status', 'Show build status and plugin statistics'],
|
|
30
|
+
['config', 'Show/validate current configuration'],
|
|
31
|
+
['list', 'List all registered plugins'],
|
|
32
|
+
['interactive', 'Interactive plugin management (alias: i)'],
|
|
33
|
+
['setup-global', 'Install global skills to ~/.claude/skills/'],
|
|
34
|
+
['loop', 'Run the agentic loop driver (Node process-level steady loop)'],
|
|
35
|
+
['loop-server', 'Global loop coordinator daemon (multi-loop view, quota, circuit break)'],
|
|
36
|
+
['team-cleanup', 'Deterministic agent-team directory cleanup'],
|
|
37
|
+
['version', 'Show version information'],
|
|
38
|
+
['help', 'Show this help message'],
|
|
39
|
+
];
|
|
40
|
+
var maxCmdLen = 0;
|
|
41
|
+
for (var ci = 0; ci < helpCommands.length; ci++) {
|
|
42
|
+
if (helpCommands[ci][0].length > maxCmdLen) maxCmdLen = helpCommands[ci][0].length;
|
|
43
|
+
}
|
|
44
|
+
for (var hi = 0; hi < helpCommands.length; hi++) {
|
|
45
|
+
var cmdName = helpCommands[hi][0];
|
|
46
|
+
var cmdPad = ' '.repeat(maxCmdLen - cmdName.length + 2);
|
|
47
|
+
console.log(' ' + ctx.colorize(cmdName, 'green') + cmdPad + helpCommands[hi][1]);
|
|
48
|
+
}
|
|
49
|
+
console.log('');
|
|
50
|
+
console.log('Options:');
|
|
51
|
+
console.log(' --root <path> Specify target project root (default: cwd)');
|
|
52
|
+
console.log(' --verbose Show detailed build output');
|
|
53
|
+
console.log(' --no-color Disable colored output');
|
|
54
|
+
console.log(' --help, -h Show this help message');
|
|
55
|
+
console.log(' --version, -v Show version information');
|
|
56
|
+
console.log('');
|
|
57
|
+
console.log(ctx.colorize('loop', 'green') + ' 子命令用法(Agentic Loop Node Driver):');
|
|
58
|
+
console.log(' doukui loop <plan.md> [options]');
|
|
59
|
+
console.log(' --executor=local|default executor 路由(默认 local;claude 为 default 别名)');
|
|
60
|
+
console.log(' --settings=<path> 指定 claude settings JSON(透传 claude --settings,');
|
|
61
|
+
console.log(' 按文件内 model 自动探测 provider 并门控额度,如 mimo / glm-5.2)');
|
|
62
|
+
console.log(' --loop-id=<name> per-loop 隔离 + 支持 --loop-id 恢复');
|
|
63
|
+
console.log(' --max-iters=<N> 最大迭代数(必须 >0)');
|
|
64
|
+
console.log(' --state-dir=<dir> 隔离 state 目录(默认 .doukui-state)');
|
|
65
|
+
console.log(' --dry-run 不执行 executor(调试)');
|
|
66
|
+
console.log(' --force 允许恢复已终态的 loop(覆盖终态保护)');
|
|
67
|
+
console.log('');
|
|
68
|
+
console.log(ctx.colorize('loop-server', 'green') + ' 子命令用法(全局 loop 协调守护进程):');
|
|
69
|
+
console.log(' doukui loop-server start [--state-dir=X] [--interval=N] [--no-circuit]');
|
|
70
|
+
console.log(' 轮询守护进程(额度池/全局熔断)');
|
|
71
|
+
console.log(' doukui loop-server stop [--state-dir=X]');
|
|
72
|
+
console.log(' 停止守护进程(跨平台 kill)');
|
|
73
|
+
console.log(' doukui loop-server status [--state-dir=X]');
|
|
74
|
+
console.log(' 单次全局快照');
|
|
75
|
+
console.log(' doukui loop-server list [--state-dir=X]');
|
|
76
|
+
console.log(' status 别名');
|
|
77
|
+
console.log(' doukui loop-server abort <loop-id> [--state-dir=X] [--reason=...]');
|
|
78
|
+
console.log(' 向指定 loop 下发熔断指令');
|
|
79
|
+
console.log('');
|
|
80
|
+
console.log('After running ' + ctx.colorize('doukui build', 'green') + ', skills are available in .claude/skills/');
|
|
81
|
+
console.log('and hooks are registered in .claude/settings.json');
|
|
82
|
+
},
|
|
83
|
+
};
|