diff --git a/2 - Projects/Smart Support.md b/2 - Projects/Smart Support.md index 2e8d468..e349064 100644 --- a/2 - Projects/Smart Support.md +++ b/2 - Projects/Smart Support.md @@ -211,6 +211,28 @@ cd backend && pytest --cov=app --cov-report=term-missing cd ../frontend && npm test ``` +## 自动编排脚本 + +项目 `scripts/` 目录下有基于 autonomous-agent-harness 模式的自动化脚本: + +| 脚本 | 用途 | 模式 | +|------|------|------| +| `auto-pilot.sh` | 多阶段自动执行(每阶段独立 `claude -p` session) | Sequential Pipeline | +| `dev-sequential.sh` | 单功能开发(plan → TDD → de-sloppify → verify → commit) | Sequential Pipeline | +| `de-sloppify.sh` | 独立清理 pass(新上下文 = 无作者偏见) | De-Sloppify | +| `full-verify.sh` | 全套质量门(测试、安全、模块独立性、代码质量) | Verification Pipeline | +| `pr-review-loop.sh` | 自动审查 open PRs | Continuous PR Loop | +| `health-monitor.sh` | 服务健康检查(可配 Windows Task Scheduler) | Scheduled Monitor | +| `phases.json` | 声明式阶段定义(任务、验收标准、模式、依赖) | 配置文件 | + +**大部分时候不需要外部脚本** — 在 Claude Code 内直接用: +- `/ecc:feature-dev "描述"` — 单功能全流程 +- `/gsd:autonomous` — 全项目多阶段自动 + +脚本只在以下场景使用:上下文窗口不够、无人值守运行、需要 Santa Method 消除作者偏见。 + +**CLAUDE.md 已更新**:Step 2 从 `/ecc:orchestrate`(legacy)迁移到 `/ecc:feature-dev` + GSD。 + ## 已知技术债务 - [ ] 认证/授权系统(生产部署前) diff --git a/4 - Resources/Claude-Code/Autonomous Agent Harness 自主代理框架.md b/4 - Resources/Claude-Code/Autonomous Agent Harness 自主代理框架.md new file mode 100644 index 0000000..23d3320 --- /dev/null +++ b/4 - Resources/Claude-Code/Autonomous Agent Harness 自主代理框架.md @@ -0,0 +1,239 @@ +--- +created: "2026-04-06" +type: resource +tags: [resource, claude-code, AI-tools, autonomous-agent, agent-harness, ECC, windows-compatible] +source: "~/.claude/skills/autonomous-agent-harness/SKILL.md" +--- + +# Autonomous Agent Harness 自主代理框架 + +把 Claude Code 变成持久化、自驱动的 Agent 系统,替代 AutoGPT/Hermes。核心理念:不需要额外框架,用 Claude Code 原生能力(crons + dispatch + MCP + memory)就能构建自主 Agent。 + +相关笔记:[[Autonomous Loops 自主循环模式]]、[[dmux 多Agent并行编排]]、[[ECC 编排替代方案 (orchestrate 迁移)]] + +## 架构 + +``` +┌─────────────────────────────────────────────────────┐ +│ Claude Code Runtime │ +│ │ +│ Crons (定时) Dispatch (远程) Memory Computer Use │ +│ │ │ │ │ │ +│ ▼ ▼ ▼ ▼ │ +│ ┌───────────────────────────────────────────────┐ │ +│ │ ECC Skill + Agent Layer │ │ +│ │ autonomous-loops / eval-harness / santa... │ │ +│ │ loop-operator / harness-optimizer agents │ │ +│ └───────────────────────────────────────────────┘ │ +│ │ │ │ │ │ +│ ▼ ▼ ▼ ▼ │ +│ ┌───────────────────────────────────────────────┐ │ +│ │ MCP Server Layer │ │ +│ │ memory github exa browser-use ... │ │ +│ └───────────────────────────────────────────────┘ │ +└─────────────────────────────────────────────────────┘ +``` + +## 5 大核心组件 + +### 1. 三层记忆系统 + +| 层级 | 机制 | 生命周期 | 用途 | +|------|------|----------|------| +| 短期 | `TodoWrite` | 单次会话内 | 任务追踪 | +| 中期 | `~/.claude/projects/*/memory/*.md` | 跨会话 | 项目上下文 | +| 长期 | MCP Memory Server (知识图谱) | 永久 | 实体、关系、观察 | + +### 2. 定时操作 (Crons) + +```bash +# Claude Code 内置 cron 能力 +# 例:每 30 分钟检查新 PR 并审查 +Cron: every 30 min during work hours +1. Check for new PRs on watched repos +2. For each new PR: pull branch, run tests, review +3. Post review comments via GitHub MCP +4. Update memory with review status +``` + +### 3. 远程 Agent (Dispatch) + +通过 `claude dispatch` 或 remote trigger 启动远程 Agent 实例。 + +### 4. Computer Use (MCP) + +通过 MCP browser/desktop 服务器实现屏幕交互、浏览器操作。 + +### 5. 任务队列 + +基于 memory 的持久化任务队列,跨会话保持任务状态。 + +--- + +## 关键 Agent + +### loop-operator + +运行自主循环的安全操作员: + +- 跟踪进度 checkpoint +- 检测停滞和重试风暴 +- 失败重复时暂停并缩小范围 +- 验证通过后才恢复 + +**升级条件**(任何一个为 true 则升级到人类): +- 连续 2 个 checkpoint 无进展 +- 重复相同 stack trace 的失败 +- 成本漂移超出预算窗口 +- merge 冲突阻塞队列 + +### harness-optimizer + +优化 Agent 框架配置的专家: + +1. 运行 `/harness-audit` 收集基线分数 +2. 识别 top 3 杠杆点(hooks, evals, routing, context, safety) +3. 提出最小可逆配置变更 +4. 应用并验证 +5. 报告前后对比 + +--- + +## 核心设计原则 + +### 1. Eval-First(评估先行) + +执行前定义完成标准。Eval 是 "AI 开发的单元测试"。 + +``` +目标 pass@3 > 90% +- 定义 capability eval (新功能能做什么) +- 定义 regression eval (不破坏已有功能) +``` + +### 2. De-Sloppify(去粗糙化) + +**永远不要给生成器加负面约束**("不要做 X")。让它自由生成,然后加独立清理 agent。 + +> 核心洞察:两个聚焦的 Agent 优于一个被约束的 Agent。 + +### 3. Santa Method(收敛循环) + +``` +Generator 生成 + → Reviewer A(安全+正确性)独立评估 + → Reviewer B(架构+测试)独立评估 + → 两者都 PASS 才算收敛 + → FAIL 则修复后用全新 Agent 重跑两个 Reviewer + → 最多 3 轮,超过则上报人类 +``` + +关键:Reviewer 从未看过 Generator 的推理过程,消除作者偏见。 + +### 4. 15 分钟单元规则 + +每个任务单元必须: +- 独立可验证 +- 单一主要风险 +- 明确的完成条件 +- 约 15 分钟可完成 + +### 5. 分离上下文窗口 + +每个管道阶段在独立 Agent 进程中运行。不同阶段用不同模型: + +| 阶段 | 模型 | +|------|------| +| Research | Sonnet | +| Plan | Opus | +| Implement | Sonnet / Codex | +| Review | Opus | + +### 6. 循环安全 + +- **必须有退出条件**:max-runs / max-cost / max-duration / completion signal +- **检测停滞和重试风暴** +- **质量门必须活跃**:eval baseline 必须存在 +- **回滚路径必须存在** + +--- + +## Hermes 组件替代表 + +| Hermes 组件 | ECC 替代 | +|-------------|---------| +| Task Queue | MCP Memory + TodoWrite | +| Long-term Memory | MCP Memory Server (知识图谱) | +| Tool Execution | MCP Server Layer | +| Planning | /ecc:plan + /ecc:feature-dev | +| Scheduling | Claude Code Crons | +| Computer Use | MCP Playwright / Desktop | +| Web Browsing | MCP Browser + Exa Search | + +--- + +## Windows 可用性 + +| 组件 | Windows | 说明 | +|------|---------|------| +| 三层记忆 | 可用 | 文件系统 + MCP | +| Crons | 可用 | Claude Code 原生 | +| Dispatch | 可用 | Claude Code 原生 | +| loop-operator agent | 可用 | Claude Code 内部 | +| 外部脚本(auto-pilot.sh) | 可用 | Git Bash | +| dmux 并行编排 | **不可用** | 需要 tmux(Linux/Mac) | + +Windows 上的并行替代:Claude Code 内置 Agent/Task tool 实现进程内并行子 agent。 + +--- + +## 实际例子 + +### Sequential Pipeline(最常用) + +```bash +#!/bin/bash +set -e +claude -p "读取 spec,实现功能,先写测试" +claude -p "审查改动,清理 slop,运行测试" +claude -p "运行构建 + lint + 测试,修复失败" +claude -p "创建 conventional commit" +``` + +### Cron 定时 PR 审查 + +``` +Cron: 工作时间每 30 分钟 +1. gh pr list --state open +2. 对每个 PR: 拉分支、运行测试、code-reviewer 审查 +3. GitHub MCP 发布评论 +4. memory 更新审查状态 +``` + +### 带成本控制的持续循环 + +```bash +continuous-claude --prompt "为未测试函数添加单元测试" --max-runs 10 +continuous-claude --prompt "修复所有 linter 错误" --max-cost 5.00 +continuous-claude --prompt "提升测试覆盖率" --max-duration 8h +``` + +--- + +## 反模式 + +| 反模式 | 问题 | 正确做法 | +|--------|------|---------| +| 无退出条件的循环 | 无限烧钱 | 始终设 max-runs/max-cost | +| 单 agent 自审自 | 作者偏见 | Santa Method 双独立 reviewer | +| 用否定指令约束生成 | 质量下降 | De-Sloppify 独立 pass | +| 迭代间无上下文桥 | 重复劳动 | SHARED_TASK_NOTES.md | +| 所有阶段同一上下文 | 偏见累积 | 每阶段独立进程 | + +## Related + +- [[Autonomous Loops 自主循环模式]] +- [[dmux 多Agent并行编排]] +- [[Ralphinho RFC-DAG 编排模式]] +- [[ECC 编排替代方案 (orchestrate 迁移)]] +- [[Everything Claude Code 完整指南]] diff --git a/4 - Resources/Claude-Code/Autonomous Loops 自主循环模式.md b/4 - Resources/Claude-Code/Autonomous Loops 自主循环模式.md index 7b9b88d..e0bf0d7 100644 --- a/4 - Resources/Claude-Code/Autonomous Loops 自主循环模式.md +++ b/4 - Resources/Claude-Code/Autonomous Loops 自主循环模式.md @@ -9,7 +9,7 @@ source: "~/.claude/skills/autonomous-loops/SKILL.md" ECC 提供的让 Claude Code 在无人干预下持续循环工作的模式集合。v1.10.0 中 `autonomous-loops` 已标记为兼容保留,新的 canonical 名称是 `continuous-agent-loop`。 -相关笔记:[[dmux 多Agent并行编排]]、[[Everything Claude Code 完整指南]]、[[Ralphinho RFC-DAG 编排模式]] +相关笔记:[[dmux 多Agent并行编排]]、[[Everything Claude Code 完整指南]]、[[Ralphinho RFC-DAG 编排模式]]、[[Autonomous Agent Harness 自主代理框架]]、[[ECC 编排替代方案 (orchestrate 迁移)]] ## 模式选择流程 diff --git a/4 - Resources/Claude-Code/ECC 编排替代方案 (orchestrate 迁移).md b/4 - Resources/Claude-Code/ECC 编排替代方案 (orchestrate 迁移).md new file mode 100644 index 0000000..e51b625 --- /dev/null +++ b/4 - Resources/Claude-Code/ECC 编排替代方案 (orchestrate 迁移).md @@ -0,0 +1,163 @@ +--- +created: "2026-04-06" +type: resource +tags: [resource, claude-code, AI-tools, orchestrate, migration, feature-dev, GSD, ECC, windows-compatible] +source: "https://github.com/affaan-m/everything-claude-code" +--- + +# ECC 编排替代方案 (orchestrate 迁移) + +`/ecc:orchestrate` 已标记为 legacy shim。底层委托给 `dmux-workflows`(需 tmux)和 `autonomous-agent-harness`(部分依赖 tmux)。Windows 上基本不可用。本文档记录迁移路径。 + +相关笔记:[[Autonomous Agent Harness 自主代理框架]]、[[Everything Claude Code 完整指南]] + +## orchestrate 做了什么 + +原来的 `/ecc:orchestrate feature "描述"` 内部流程: +1. Plan(规划) +2. TDD(测试驱动开发) +3. Code Review(代码审查) +4. Security Review(安全审查) +5. Verify(验证) + +接受参数:`feature`、`bugfix`、`refactor`、`security`、`custom`。 + +## 替代方案 + +### 路线 A:单功能/任务 — `/ecc:feature-dev`(推荐) + +**orchestrate 的最直接替代品。** 7 阶段全在 Claude Code 内部完成: + +``` +/ecc:feature-dev "add JWT authentication" +``` + +内部自动走: +1. **Discovery** — 读取需求,识别约束和验收标准 +2. **Codebase Exploration** — 用 `code-explorer` 分析相关代码 +3. **Clarifying Questions** — 提出设计/边界问题,等用户回答 +4. **Architecture Design** — 用 `code-architect` 设计,等用户批准 +5. **Implementation** — TDD 实现,小粒度提交 +6. **Quality Review** — 用 `code-reviewer` 审查,修复 critical/high 问题 +7. **Summary** — 总结构建内容,列出跟进项 + +### 路线 B:手动拆步骤 + +如果想更精细控制每一步: + +``` +/ecc:plan "描述" # 规划,等确认 +/ecc:tdd # RED → GREEN → REFACTOR +/ecc:code-review # 代码审查 +/ecc:security-review # 安全审查(涉及 auth/支付时) +/ecc:verify # 构建 + 测试 + lint + 覆盖率 +``` + +按工作类型选择组合: + +| 工作类型 | 推荐组合 | +|----------|---------| +| 新功能 | `/ecc:feature-dev` 一条龙 | +| Bug 修复 | `/ecc:tdd` → `/ecc:code-review` | +| 重构 | `/ecc:plan` → `/ecc:tdd` → `/ecc:code-review` | +| 安全相关 | 任何组合 + `/ecc:security-review` | +| 最终验证 | `/ecc:verify` | + +### 路线 C:全项目多阶段 — GSD + +GSD(Get Shit Done)是 ECC 集成的项目级编排系统,Windows 原生可用。 + +**安装:** +```bash +npx get-shit-done-cc@latest +``` + +**单阶段执行:** +``` +/gsd:discuss-phase 1 # 讨论实现决策 +/gsd:plan-phase 1 # 研究 + 规划 + 验证 +/gsd:execute-phase 1 # 按 wave 并行执行 +/gsd:verify-work 1 # 验收测试 +/gsd:ship 1 # 创建 PR +``` + +**全自动执行:** +``` +/gsd:autonomous # 执行所有剩余阶段 +/gsd:autonomous --from 6 # 从阶段 6 开始 +``` + +**GSD 完整生命周期:** +``` +/gsd:new-project # 初始化(研究 → 需求 → 路线图) +/gsd:plan-phase 1 # 规划阶段 1 +/gsd:execute-phase 1 # 执行 +/gsd:verify-work 1 # 验收 +/gsd:next # 自动推进到下一步 +... 重复 ... +/gsd:complete-milestone # 归档并打 tag +/gsd:new-milestone # 开始下一个版本 +``` + +--- + +## 迁移对照表 + +| 旧命令 | 新命令 | 说明 | +|--------|--------|------| +| `/ecc:orchestrate feature "desc"` | `/ecc:feature-dev "desc"` | 单功能全流程 | +| `/ecc:orchestrate bugfix "desc"` | `/ecc:tdd` + `/ecc:code-review` | 先写失败测试再修 | +| `/ecc:orchestrate refactor "desc"` | `/ecc:plan` + `/ecc:tdd` + `/ecc:code-review` | 先规划再重构 | +| `/ecc:orchestrate security "desc"` | 任何路线 + `/ecc:security-review` | 加安全审查 | +| 多阶段自动执行 | `/gsd:autonomous` | GSD 接管 | +| 并行编排 | 不可用(Windows) | 用 Agent/Task tool 做进程内并行 | + +## CLAUDE.md 更新 + +项目 CLAUDE.md 中 Step 2 应从: + +```markdown +| New feature | `/ecc:orchestrate feature` | +``` + +改为: + +```markdown +| New feature | `/ecc:feature-dev ` | +| Bug fix | `/ecc:tdd` then `/ecc:code-review` | +| Refactor | `/ecc:plan` then `/ecc:tdd` then `/ecc:code-review` | +| Full phase | `/gsd:execute-phase N` | +| All phases | `/gsd:autonomous` | +``` + +--- + +## Windows 可用性总结 + +| 方案 | Windows | 原理 | +|------|---------|------| +| `/ecc:feature-dev` | 可用 | Claude Code 内部,不依赖外部工具 | +| `/ecc:plan` + `/ecc:tdd` + ... | 可用 | 同上 | +| `/gsd:autonomous` | 可用 | 用 Claude Code Task tool 做并行 | +| `/ecc:orchestrate` | **不可用** | Legacy,底层依赖 tmux | +| `dmux-workflows` | **不可用** | 需要 tmux | +| `auto-pilot.sh` 脚本 | 可用 | Git Bash,每阶段独立 `claude -p` | + +--- + +## 什么时候需要外部脚本 + +大部分情况下 Claude Code 自己编排(`/ecc:feature-dev` 或 GSD)就够了。外部脚本(`auto-pilot.sh`)只在以下场景有价值: + +1. **上下文窗口不够** — 一个 phase 太大,塞不进单次会话 +2. **无人值守** — 睡觉前启动,醒来看结果 +3. **消除作者偏见** — Reviewer 必须在不同会话(Santa Method) +4. **可审计** — 每步有独立日志文件 + +## Related + +- [[Autonomous Agent Harness 自主代理框架]] +- [[Autonomous Loops 自主循环模式]] +- [[dmux 多Agent并行编排]] +- [[Everything Claude Code 完整指南]] +- [[GSD 方法论与最佳实践]] diff --git a/4 - Resources/Claude-Code/Everything Claude Code 完整指南.md b/4 - Resources/Claude-Code/Everything Claude Code 完整指南.md index c06594b..523e938 100644 --- a/4 - Resources/Claude-Code/Everything Claude Code 完整指南.md +++ b/4 - Resources/Claude-Code/Everything Claude Code 完整指南.md @@ -9,7 +9,7 @@ source: "https://github.com/affaan-m/everything-claude-code" 生产级 Claude Code 插件系统。v1.10.0 (2026-04-06 更新),包含 215 skills、112 agents、82 commands、hooks 和 rules (608 files total)。方法论与最佳实践见 [[Everything Claude Code 方法论与最佳实践]],按场景速查见 [[Everything Claude Code 用法速查]]。 -自主循环和并行编排详见:[[Autonomous Loops 自主循环模式]]、[[dmux 多Agent并行编排]]、[[Ralphinho RFC-DAG 编排模式]] +自主循环和并行编排详见:[[Autonomous Loops 自主循环模式]]、[[dmux 多Agent并行编排]]、[[Ralphinho RFC-DAG 编排模式]]、[[Autonomous Agent Harness 自主代理框架]]、[[ECC 编排替代方案 (orchestrate 迁移)]] ## 项目架构 @@ -47,7 +47,14 @@ bash install.sh python typescript golang # 按需选语言 | Legacy Command | 替代 Skill | |---|---| -| `/ecc:orchestrate` | `dmux-workflows` / `autonomous-agent-harness` | +| `/ecc:orchestrate` | `dmux-workflows` / `autonomous-agent-harness`(**注意:dmux 需 tmux,Windows 不可用。实际替代见下方**) | + +> **orchestrate 迁移指南**(详见 [[ECC 编排替代方案 (orchestrate 迁移)]]): +> - 单功能:`/ecc:feature-dev "描述"` — 7 阶段全流程,Windows 可用 +> - 手动拆步:`/ecc:plan` → `/ecc:tdd` → `/ecc:code-review` → `/ecc:verify` +> - 多阶段自动:`/gsd:autonomous` — GSD 系统,Windows 可用 +> - Bug 修复:`/ecc:tdd` → `/ecc:code-review` +> - 重构:`/ecc:plan` → `/ecc:tdd` → `/ecc:code-review` | `/ecc:verify` | `verification-loop` | | `/ecc:tdd` | `tdd-workflow` | | `/ecc:eval` | `eval-harness` | diff --git a/4 - Resources/Claude-Code/Ralphinho RFC-DAG 编排模式.md b/4 - Resources/Claude-Code/Ralphinho RFC-DAG 编排模式.md index e01af1f..d1d0777 100644 --- a/4 - Resources/Claude-Code/Ralphinho RFC-DAG 编排模式.md +++ b/4 - Resources/Claude-Code/Ralphinho RFC-DAG 编排模式.md @@ -9,7 +9,7 @@ source: "~/.claude/skills/ralphinho-rfc-pipeline/SKILL.md" 最复杂的自主循环模式。把 RFC/PRD 分解为依赖 DAG,按层并行执行,每个 unit 过分级质量管道,最后通过合并队列着陆。由 enitrat 创建。 -相关笔记:[[Autonomous Loops 自主��环模式]]、[[dmux 多Agent并行编排]] +相关笔记:[[Autonomous Loops 自主循环模式]]、[[dmux 多Agent并行编排]]、[[Autonomous Agent Harness 自主代理框架]]、[[ECC 编排替代方案 (orchestrate 迁移)]] ## 架构总览 diff --git a/4 - Resources/Claude-Code/dmux 多Agent并行编排.md b/4 - Resources/Claude-Code/dmux 多Agent并行编排.md index 8090c3b..2a2ff4e 100644 --- a/4 - Resources/Claude-Code/dmux 多Agent并行编排.md +++ b/4 - Resources/Claude-Code/dmux 多Agent并行编排.md @@ -7,9 +7,12 @@ source: "~/.claude/skills/dmux-workflows/SKILL.md" # dmux 多Agent并行编排 -用 tmux 管理多个 AI agent 面板,每个面板跑独立 agent 会话,最后合并结果。ECC v1.10.0 中 `/ecc:orchestrate` 的并行执行部分路由到此 skill。 +> **平台限制:需要 tmux,仅 Linux/macOS 可用。Windows 不可用(除非使用 WSL)。** +> Windows 替代方案见 [[ECC 编排替代方案 (orchestrate 迁移)]]。 -相关笔记:[[Autonomous Loops 自主循环模式]]、[[Everything Claude Code 完整指南]] +用 tmux 管理多个 AI agent 面板,每个面板跑独立 agent 会话,最后合并结果。ECC v1.10.0 中 `/ecc:orchestrate` 已标记为 legacy,底层的并行部分路由到此 skill。 + +相关笔记:[[Autonomous Loops 自主循环模式]]、[[Everything Claude Code 完整指南]]、[[ECC 编排替代方案 (orchestrate 迁移)]]、[[Autonomous Agent Harness 自主代理框架]] ## 什么是 dmux