diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 18d582a..00a6a4f 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -15,32 +15,25 @@ "source": "./skills/omo", "category": "development" }, - { - "name": "dev", - "description": "Lightweight development workflow with requirements clarification, parallel codex execution, and mandatory 90% test coverage", - "version": "5.6.1", - "source": "./dev-workflow", - "category": "development" - }, { "name": "requirements", "description": "Requirements-driven development workflow with quality gates for practical feature implementation", "version": "5.6.1", - "source": "./requirements-driven-workflow", + "source": "./agents/requirements", "category": "development" }, { "name": "bmad", "description": "Full BMAD agile workflow with role-based agents (PO, Architect, SM, Dev, QA) and interactive approval gates", "version": "5.6.1", - "source": "./bmad-agile-workflow", + "source": "./agents/bmad", "category": "development" }, { "name": "dev-kit", "description": "Essential development commands for coding, debugging, testing, optimization, and documentation", "version": "5.6.1", - "source": "./development-essentials", + "source": "./agents/development-essentials", "category": "productivity" }, { diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d69440..a97d81a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,66 +2,451 @@ All notable changes to this project will be documented in this file. -## [5.6.4] - 2026-01-15 +## [6.0.0] - 2026-01-26 ### 🚀 Features -- add reasoning effort config for codex backend -- default to skip-permissions and bypass-sandbox -- add multi-agent support with yolo mode -- add omo module for multi-agent orchestration -- add intelligent backend selection based on task complexity (#61) -- v5.4.0 structured execution report (#94) -- add millisecond-precision timestamps to all log entries (#91) -- skill-install install script and security scan -- add uninstall scripts with selective module removal - -### 🐛 Bug Fixes - -- filter codex stderr noise logs -- use config override for codex reasoning effort -- propagate SkipPermissions to parallel tasks (#113) -- add timeout for Windows process termination -- reject dash as workdir parameter (#118) -- add sleep in fake script to prevent CI race condition -- fix gemini env load -- fix omo -- fix codeagent skill TaskOutput -- 修复 Gemini init 事件 session_id 未提取的问题 (#111) -- Windows 后端退出:taskkill 结束进程树 + turn.completed 支持 (#108) -- support model parameter for all backends, auto-inject from settings (#105) -- replace setx with reg add to avoid 1024-char PATH truncation (#101) -- 移除未知事件格式的日志噪声 (#96) -- prevent duplicate PATH entries on reinstall (#95) -- Minor issues #12 and #13 - ASCII mode and performance optimization -- correct settings.json filename and bump version to v5.2.8 -- allow claude backend to read env from setting.json while preventing recursion (#92) -- comprehensive security and quality improvements for PR #85 & #87 (#90) -- Improve backend termination after message and extend timeout (#86) -- Parser重复解析优化 + 严重bug修复 + PR #86兼容性 (#88) -- filter noisy stderr output from gemini backend (#83) -- 修復 wsl install.sh 格式問題 (#78) -- 修复多 backend 并行日志 PID 混乱并移除包装格式 (#74) (#76) +- support `npx github:cexll/myclaude` for installation and execution +- default module changed from `dev` to `do` ### 🚜 Refactor -- remove sisyphus agent and unused code -- streamline agent documentation and remove sisyphus +- restructure: create `agents/` and move `bmad-agile-workflow` → `agents/bmad`, `requirements-driven-workflow` → `agents/requirements`, `development-essentials` → `agents/development-essentials` +- remove legacy directories: `docs/`, `hooks/`, `dev-workflow/` +- update references across `config.json`, `README.md`, `README_CN.md`, `marketplace.json`, etc. ### 📚 Documentation -- add OmO workflow to README and fix plugin marketplace structure -- update FAQ for default bypass/skip-permissions behavior -- 添加 FAQ 常见问题章节 -- update troubleshooting with idempotent PATH commands (#95) +- add `skills/README.md` and `PLUGIN_README.md` ### 💼 Other +- add `package.json` and `bin/cli.js` for npx packaging + +## [6.1.5] - 2026-01-25 + + +### 🐛 Bug Fixes + + +- correct gitignore to not exclude cmd/codeagent-wrapper + +## [6.1.4] - 2026-01-25 + + +### 🐛 Bug Fixes + + +- support concurrent tasks with unique state files + +## [6.1.3] - 2026-01-25 + + +### 🐛 Bug Fixes + + +- correct build path in release workflow + +- increase stdoutDrainTimeout from 100ms to 500ms + +## [6.1.2] - 2026-01-24 + + +### 🐛 Bug Fixes + + +- use ANTHROPIC_AUTH_TOKEN for Claude CLI env injection + +### 💼 Other + + +- update codeagent version + +### 📚 Documentation + + +- restructure root READMEs with do as recommended workflow + +- update do/omo/sparv module READMEs with detailed workflows + +- add README for bmad and requirements modules + +### 🧪 Testing + + +- use prefix match for version flag tests + +## [6.1.1] - 2026-01-23 + + +### 🚜 Refactor + + +- rename feature-dev to do workflow + +## [6.1.0] - 2026-01-23 + + +### ⚙️ Miscellaneous Tasks + + +- ignore references directory + +- add go.work.sum for workspace dependencies + +### 🐛 Bug Fixes + + +- read GEMINI_MODEL from ~/.gemini/.env ([#131](https://github.com/cexll/myclaude/issues/131)) + +- validate non-empty output message before printing + +### 🚀 Features + + +- add feature-dev skill with 7-phase workflow + +- support \${CLAUDE_PLUGIN_ROOT} variable in hooks config + +## [6.0.0-alpha1] - 2026-01-20 + + +### 🐛 Bug Fixes + + +- add missing cmd/codeagent/main.go entry point + +- update release workflow build path for new directory structure + +- write PATH config to both profile and rc files ([#128](https://github.com/cexll/myclaude/issues/128)) + +### 🚀 Features + + +- add course module with dev, product-requirements and test-cases skills + +- add hooks management to install.py + +### 🚜 Refactor + + +- restructure codebase to internal/ directory with modular architecture + +## [5.6.7] - 2026-01-17 + + +### 💼 Other + + +- remove .sparv + +### 📚 Documentation + + +- update 'Agent Hierarchy' model for frontend-ui-ux-engineer and document-writer in README ([#127](https://github.com/cexll/myclaude/issues/127)) + +- update mappings for frontend-ui-ux-engineer and document-writer in README ([#126](https://github.com/cexll/myclaude/issues/126)) + +### 🚀 Features + + +- add sparv module and interactive plugin manager + +- add sparv enhanced rules v1.1 + +- add sparv skill to claude-plugin v1.1.0 + +- feat sparv skill + +## [5.6.6] - 2026-01-16 + + +### 🐛 Bug Fixes + + +- remove extraneous dash arg for opencode stdin mode ([#124](https://github.com/cexll/myclaude/issues/124)) + +### 💼 Other + + +- update readme + +## [5.6.5] - 2026-01-16 + + +### 🐛 Bug Fixes + + +- correct default models for oracle and librarian agents ([#120](https://github.com/cexll/myclaude/issues/120)) + +### 🚀 Features + + +- feat dev skill + +## [5.6.4] - 2026-01-15 + + +### 🐛 Bug Fixes + + +- filter codex 0.84.0 stderr noise logs ([#122](https://github.com/cexll/myclaude/issues/122)) + +- filter codex stderr noise logs + +## [5.6.3] - 2026-01-14 + + +### ⚙️ Miscellaneous Tasks + + +- bump codeagent-wrapper version to 5.6.3 + +### 🐛 Bug Fixes + + +- update version tests to match 5.6.3 + +- use config override for codex reasoning effort + +## [5.6.2] - 2026-01-14 + + +### 🐛 Bug Fixes + + +- propagate SkipPermissions to parallel tasks ([#113](https://github.com/cexll/myclaude/issues/113)) + +- add timeout for Windows process termination + +- reject dash as workdir parameter ([#118](https://github.com/cexll/myclaude/issues/118)) + +### 📚 Documentation + + +- add OmO workflow to README and fix plugin marketplace structure + +### 🚜 Refactor + + +- remove sisyphus agent and unused code + +## [5.6.1] - 2026-01-13 + + +### 🐛 Bug Fixes + + +- add sleep in fake script to prevent CI race condition + +- fix gemini env load + +- fix omo + +### 🚀 Features + + +- add reasoning effort config for codex backend + +## [5.6.0] - 2026-01-13 + + +### 📚 Documentation + + +- update FAQ for default bypass/skip-permissions behavior + +### 🚀 Features + + +- default to skip-permissions and bypass-sandbox + +- add omo module for multi-agent orchestration + +### 🚜 Refactor + + +- streamline agent documentation and remove sisyphus + +## [5.5.0] - 2026-01-12 + + +### 🐛 Bug Fixes + + +- 修复 Gemini init 事件 session_id 未提取的问题 ([#111](https://github.com/cexll/myclaude/issues/111)) + +- fix codeagent skill TaskOutput + +### 💼 Other + + +- Merge branch 'master' of github.com:cexll/myclaude + - add test-cases skill + - add browser skill -- BMADh和Requirements-Driven支持根据语义生成对应的文档 (#82) + +### 🚀 Features + + +- add multi-agent support with yolo mode + +## [5.4.4] - 2026-01-08 + + +### 💼 Other + + +- 修复 Windows 后端退出:taskkill 结束进程树 + turn.completed 支持 ([#108](https://github.com/cexll/myclaude/issues/108)) + +## [5.4.3] - 2026-01-06 + + +### 🐛 Bug Fixes + + +- support model parameter for all backends, auto-inject from settings ([#105](https://github.com/cexll/myclaude/issues/105)) + +### 📚 Documentation + + +- add FAQ Q5 for permission/sandbox env vars + +### 🚀 Features + + +- feat skill-install install script and security scan + +- add uninstall scripts with selective module removal + +## [5.4.2] - 2025-12-31 + + +### 🐛 Bug Fixes + + +- replace setx with reg add to avoid 1024-char PATH truncation ([#101](https://github.com/cexll/myclaude/issues/101)) + +## [5.4.1] - 2025-12-26 + + +### 🐛 Bug Fixes + + +- 移除未知事件格式的日志噪声 ([#96](https://github.com/cexll/myclaude/issues/96)) + +- prevent duplicate PATH entries on reinstall ([#95](https://github.com/cexll/myclaude/issues/95)) + +### 📚 Documentation + + +- 添加 FAQ 常见问题章节 + +- update troubleshooting with idempotent PATH commands ([#95](https://github.com/cexll/myclaude/issues/95)) + +### 🚀 Features + + +- Add intelligent backend selection based on task complexity ([#61](https://github.com/cexll/myclaude/issues/61)) + +## [5.4.0] - 2025-12-24 + + +### 🐛 Bug Fixes + + +- Minor issues #12 and #13 - ASCII mode and performance optimization + +- code review fixes for PR #94 - all critical and major issues resolved + +### 🚀 Features + + +- v5.4.0 structured execution report ([#94](https://github.com/cexll/myclaude/issues/94)) + +## [5.2.8] - 2025-12-22 + + +### ⚙️ Miscellaneous Tasks + + +- simplify release workflow to use GitHub auto-generated notes + +### 🐛 Bug Fixes + + +- correct settings.json filename and bump version to v5.2.8 + +## [5.2.7] - 2025-12-21 + + +### ⚙️ Miscellaneous Tasks + + +- bump version to v5.2.7 + +### 🐛 Bug Fixes + + +- allow claude backend to read env from setting.json while preventing recursion ([#92](https://github.com/cexll/myclaude/issues/92)) + +- comprehensive security and quality improvements for PR #85 & #87 ([#90](https://github.com/cexll/myclaude/issues/90)) + +- Parser重复解析优化 + 严重bug修复 + PR #86兼容性 ([#88](https://github.com/cexll/myclaude/issues/88)) + +### 💼 Other + + +- Improve backend termination after message and extend timeout ([#86](https://github.com/cexll/myclaude/issues/86)) + +### 🚀 Features + + +- add millisecond-precision timestamps to all log entries ([#91](https://github.com/cexll/myclaude/issues/91)) + +## [5.2.6] - 2025-12-19 + + +### 🐛 Bug Fixes + + +- filter noisy stderr output from gemini backend ([#83](https://github.com/cexll/myclaude/issues/83)) + +- 修復 wsl install.sh 格式問題 ([#78](https://github.com/cexll/myclaude/issues/78)) + +### 💼 Other + + - update all readme +- BMADh和Requirements-Driven支持根据语义生成对应的文档 ([#82](https://github.com/cexll/myclaude/issues/82)) + +## [5.2.5] - 2025-12-17 + + +### 🐛 Bug Fixes + + +- 修复多 backend 并行日志 PID 混乱并移除包装格式 ([#74](https://github.com/cexll/myclaude/issues/74)) ([#76](https://github.com/cexll/myclaude/issues/76)) + +- replace "Codex" to "codeagent" in dev-plan-generator subagent + +- 修復 win python install.py + +### 💼 Other + + +- Merge pull request #71 from aliceric27/master + +- Merge branch 'cexll:master' into master + +- Merge pull request #72 from changxvv/master + +- update changelog + +- update codeagent skill backend select + ## [5.2.4] - 2025-12-16 diff --git a/Makefile b/Makefile index 557f4ac..bc3e6cd 100644 --- a/Makefile +++ b/Makefile @@ -7,12 +7,12 @@ help: @echo "Claude Code Multi-Agent Workflow - Quick Deployment" @echo "" - @echo "Recommended installation: python3 install.py --install-dir ~/.claude" + @echo "Recommended installation: npx github:cexll/myclaude" @echo "" @echo "Usage: make [target]" @echo "" @echo "Targets:" - @echo " install - LEGACY: install all configurations (prefer install.py)" + @echo " install - LEGACY: install all configurations (prefer npx github:cexll/myclaude)" @echo " deploy-bmad - Deploy BMAD workflow (bmad-pilot)" @echo " deploy-requirements - Deploy Requirements workflow (requirements-pilot)" @echo " deploy-essentials - Deploy Development Essentials workflow" @@ -31,16 +31,16 @@ CLAUDE_CONFIG_DIR = ~/.claude SPECS_DIR = .claude/specs # Workflow directories -BMAD_DIR = bmad-agile-workflow -REQUIREMENTS_DIR = requirements-driven-workflow -ESSENTIALS_DIR = development-essentials +BMAD_DIR = agents/bmad +REQUIREMENTS_DIR = agents/requirements +ESSENTIALS_DIR = agents/development-essentials ADVANCED_DIR = advanced-ai-agents OUTPUT_STYLES_DIR = output-styles # Install all configurations install: deploy-all @echo "⚠️ LEGACY PATH: make install will be removed in future versions." - @echo " Prefer: python3 install.py --install-dir ~/.claude" + @echo " Prefer: npx github:cexll/myclaude" @echo "✅ Installation complete!" # Deploy BMAD workflow @@ -159,4 +159,3 @@ changelog: @echo "" @echo "Preview the changes:" @echo " git diff CHANGELOG.md" - diff --git a/PLUGIN_README.md b/PLUGIN_README.md new file mode 100644 index 0000000..50fcee4 --- /dev/null +++ b/PLUGIN_README.md @@ -0,0 +1,18 @@ +# Plugin System + +Claude Code plugins for this repo are defined in `.claude-plugin/marketplace.json`. + +## Install + +```bash +/plugin marketplace add cexll/myclaude +/plugin list +``` + +## Available Plugins + +- `bmad` - BMAD workflow (`./agents/bmad`) +- `requirements` - requirements-driven workflow (`./agents/requirements`) +- `dev-kit` - development essentials (`./agents/development-essentials`) +- `omo` - orchestration skill (`./skills/omo`) +- `sparv` - SPARV workflow (`./skills/sparv`) diff --git a/README.md b/README.md index b97bfe3..22ae6dd 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,7 @@ ## Quick Start ```bash -git clone https://github.com/cexll/myclaude.git -cd myclaude -python3 install.py --install-dir ~/.claude +npx github:cexll/myclaude ``` ## Modules Overview @@ -22,28 +20,24 @@ python3 install.py --install-dir ~/.claude | Module | Description | Documentation | |--------|-------------|---------------| | [do](skills/do/README.md) | **Recommended** - 7-phase feature development with codeagent orchestration | `/do` command | -| [dev](dev-workflow/README.md) | Lightweight dev workflow with Codex integration | `/dev` command | | [omo](skills/omo/README.md) | Multi-agent orchestration with intelligent routing | `/omo` command | -| [bmad](bmad-agile-workflow/README.md) | BMAD agile workflow with 6 specialized agents | `/bmad-pilot` command | -| [requirements](requirements-driven-workflow/README.md) | Lightweight requirements-to-code pipeline | `/requirements-pilot` command | -| [essentials](development-essentials/README.md) | Core development commands and utilities | `/code`, `/debug`, etc. | +| [bmad](agents/bmad/README.md) | BMAD agile workflow with 6 specialized agents | `/bmad-pilot` command | +| [requirements](agents/requirements/README.md) | Lightweight requirements-to-code pipeline | `/requirements-pilot` command | +| [essentials](agents/development-essentials/README.md) | Core development commands and utilities | `/code`, `/debug`, etc. | | [sparv](skills/sparv/README.md) | SPARV workflow (Specify→Plan→Act→Review→Vault) | `/sparv` command | | course | Course development (combines dev + product-requirements + test-cases) | Composite module | ## Installation ```bash -# Install all enabled modules -python3 install.py --install-dir ~/.claude +# Interactive installer (recommended) +npx github:cexll/myclaude -# Install specific module -python3 install.py --module dev +# List installable items (modules / skills / wrapper) +npx github:cexll/myclaude --list -# List available modules -python3 install.py --list-modules - -# Force overwrite -python3 install.py --force +# Custom install directory / overwrite +npx github:cexll/myclaude --install-dir ~/.claude --force ``` ### Module Configuration @@ -53,13 +47,12 @@ Edit `config.json` to enable/disable modules: ```json { "modules": { - "dev": { "enabled": true }, "bmad": { "enabled": false }, "requirements": { "enabled": false }, "essentials": { "enabled": false }, "omo": { "enabled": false }, "sparv": { "enabled": false }, - "do": { "enabled": false }, + "do": { "enabled": true }, "course": { "enabled": false } } } @@ -70,7 +63,6 @@ Edit `config.json` to enable/disable modules: | Scenario | Recommended | |----------|-------------| | Feature development (default) | `/do` | -| Lightweight feature | `/dev` | | Bug investigation + fix | `/omo` | | Large enterprise project | `/bmad-pilot` | | Quick prototype | `/requirements-pilot` | @@ -105,9 +97,8 @@ Edit `config.json` to enable/disable modules: ## Documentation -- [Codeagent-Wrapper Guide](docs/CODEAGENT-WRAPPER.md) -- [Hooks Documentation](docs/HOOKS.md) - [codeagent-wrapper](codeagent-wrapper/README.md) +- [Plugin System](PLUGIN_README.md) ## Troubleshooting @@ -115,13 +106,14 @@ Edit `config.json` to enable/disable modules: **Codex wrapper not found:** ```bash -bash install.sh +# Select: codeagent-wrapper +npx github:cexll/myclaude ``` **Module not loading:** ```bash cat ~/.claude/installed_modules.json -python3 install.py --module --force +npx github:cexll/myclaude --force ``` **Backend CLI errors:** @@ -137,7 +129,6 @@ which gemini && gemini --version |-------|----------| | "Unknown event format" | Logging display issue, can be ignored | | Gemini can't read .gitignore files | Remove from .gitignore or use different backend | -| `/dev` slow | Check logs, try faster model, use single repo | | Codex permission denied | Set `approval_policy = "never"` in ~/.codex/config.yaml | See [GitHub Issues](https://github.com/cexll/myclaude/issues) for more. @@ -153,4 +144,3 @@ For commercial use without AGPL obligations, contact: evanxian9@gmail.com ## Support - [GitHub Issues](https://github.com/cexll/myclaude/issues) -- [Documentation](docs/) diff --git a/README_CN.md b/README_CN.md index ef68ba3..d6351fe 100644 --- a/README_CN.md +++ b/README_CN.md @@ -9,9 +9,7 @@ ## 快速开始 ```bash -git clone https://github.com/cexll/myclaude.git -cd myclaude -python3 install.py --install-dir ~/.claude +npx github:cexll/myclaude ``` ## 模块概览 @@ -19,11 +17,10 @@ python3 install.py --install-dir ~/.claude | 模块 | 描述 | 文档 | |------|------|------| | [do](skills/do/README.md) | **推荐** - 7 阶段功能开发 + codeagent 编排 | `/do` 命令 | -| [dev](dev-workflow/README.md) | 轻量级开发工作流 + Codex 集成 | `/dev` 命令 | | [omo](skills/omo/README.md) | 多智能体编排 + 智能路由 | `/omo` 命令 | -| [bmad](bmad-agile-workflow/README.md) | BMAD 敏捷工作流 + 6 个专业智能体 | `/bmad-pilot` 命令 | -| [requirements](requirements-driven-workflow/README.md) | 轻量级需求到代码流水线 | `/requirements-pilot` 命令 | -| [essentials](development-essentials/README.md) | 核心开发命令和工具 | `/code`, `/debug` 等 | +| [bmad](agents/bmad/README.md) | BMAD 敏捷工作流 + 6 个专业智能体 | `/bmad-pilot` 命令 | +| [requirements](agents/requirements/README.md) | 轻量级需求到代码流水线 | `/requirements-pilot` 命令 | +| [essentials](agents/development-essentials/README.md) | 核心开发命令和工具 | `/code`, `/debug` 等 | | [sparv](skills/sparv/README.md) | SPARV 工作流 (Specify→Plan→Act→Review→Vault) | `/sparv` 命令 | | course | 课程开发(组合 dev + product-requirements + test-cases) | 组合模块 | @@ -63,24 +60,6 @@ python3 install.py --install-dir ~/.claude --- -### Dev 工作流 - -轻量级开发工作流,适合简单功能开发。 - -```bash -/dev "实现 JWT 用户认证" -``` - -**6 步流程:** -1. 需求澄清 - 交互式问答 -2. Codex 深度分析 - 代码库探索 -3. 开发计划生成 - 结构化任务分解 -4. 并行执行 - Codex 并发执行 -5. 覆盖率验证 - 强制 ≥90% -6. 完成总结 - 报告生成 - ---- - ### OmO 多智能体编排器 基于风险信号智能路由任务到专业智能体。 @@ -189,17 +168,14 @@ python3 install.py --install-dir ~/.claude ## 安装 ```bash -# 安装所有启用的模块 -python3 install.py --install-dir ~/.claude +# 交互式安装器(推荐) +npx github:cexll/myclaude -# 安装特定模块 -python3 install.py --module dev +# 列出可安装项(module:* / skill:* / codeagent-wrapper) +npx github:cexll/myclaude --list -# 列出可用模块 -python3 install.py --list-modules - -# 强制覆盖 -python3 install.py --force +# 指定安装目录 / 强制覆盖 +npx github:cexll/myclaude --install-dir ~/.claude --force ``` ### 模块配置 @@ -209,13 +185,12 @@ python3 install.py --force ```json { "modules": { - "dev": { "enabled": true }, "bmad": { "enabled": false }, "requirements": { "enabled": false }, "essentials": { "enabled": false }, "omo": { "enabled": false }, "sparv": { "enabled": false }, - "do": { "enabled": false }, + "do": { "enabled": true }, "course": { "enabled": false } } } @@ -226,7 +201,6 @@ python3 install.py --force | 场景 | 推荐 | |------|------| | 功能开发(默认) | `/do` | -| 轻量级功能 | `/dev` | | Bug 调查 + 修复 | `/omo` | | 大型企业项目 | `/bmad-pilot` | | 快速原型 | `/requirements-pilot` | @@ -244,13 +218,14 @@ python3 install.py --force **Codex wrapper 未找到:** ```bash -bash install.sh +# 选择:codeagent-wrapper +npx github:cexll/myclaude ``` **模块未加载:** ```bash cat ~/.claude/installed_modules.json -python3 install.py --module --force +npx github:cexll/myclaude --force ``` ## FAQ @@ -259,7 +234,6 @@ python3 install.py --module --force |------|----------| | "Unknown event format" | 日志显示问题,可忽略 | | Gemini 无法读取 .gitignore 文件 | 从 .gitignore 移除或使用其他后端 | -| `/dev` 执行慢 | 检查日志,尝试更快模型,使用单一仓库 | | Codex 权限拒绝 | 在 ~/.codex/config.yaml 设置 `approval_policy = "never"` | 更多问题请访问 [GitHub Issues](https://github.com/cexll/myclaude/issues)。 @@ -275,4 +249,3 @@ AGPL-3.0 - 查看 [LICENSE](LICENSE) ## 支持 - [GitHub Issues](https://github.com/cexll/myclaude/issues) -- [文档](docs/) diff --git a/bmad-agile-workflow/.claude-plugin/plugin.json b/agents/bmad/.claude-plugin/plugin.json similarity index 100% rename from bmad-agile-workflow/.claude-plugin/plugin.json rename to agents/bmad/.claude-plugin/plugin.json diff --git a/docs/BMAD-WORKFLOW.md b/agents/bmad/BMAD-WORKFLOW.md similarity index 100% rename from docs/BMAD-WORKFLOW.md rename to agents/bmad/BMAD-WORKFLOW.md diff --git a/bmad-agile-workflow/README.md b/agents/bmad/README.md similarity index 99% rename from bmad-agile-workflow/README.md rename to agents/bmad/README.md index 74210a1..5fa1792 100644 --- a/bmad-agile-workflow/README.md +++ b/agents/bmad/README.md @@ -94,7 +94,7 @@ PO and Architect phases use iterative refinement: ## Directory Structure ``` -bmad-agile-workflow/ +agents/bmad/ ├── README.md ├── commands/ │ └── bmad-pilot.md diff --git a/bmad-agile-workflow/agents/bmad-architect.md b/agents/bmad/agents/bmad-architect.md similarity index 100% rename from bmad-agile-workflow/agents/bmad-architect.md rename to agents/bmad/agents/bmad-architect.md diff --git a/bmad-agile-workflow/agents/bmad-dev.md b/agents/bmad/agents/bmad-dev.md similarity index 100% rename from bmad-agile-workflow/agents/bmad-dev.md rename to agents/bmad/agents/bmad-dev.md diff --git a/bmad-agile-workflow/agents/bmad-orchestrator.md b/agents/bmad/agents/bmad-orchestrator.md similarity index 100% rename from bmad-agile-workflow/agents/bmad-orchestrator.md rename to agents/bmad/agents/bmad-orchestrator.md diff --git a/bmad-agile-workflow/agents/bmad-po.md b/agents/bmad/agents/bmad-po.md similarity index 100% rename from bmad-agile-workflow/agents/bmad-po.md rename to agents/bmad/agents/bmad-po.md diff --git a/bmad-agile-workflow/agents/bmad-qa.md b/agents/bmad/agents/bmad-qa.md similarity index 100% rename from bmad-agile-workflow/agents/bmad-qa.md rename to agents/bmad/agents/bmad-qa.md diff --git a/bmad-agile-workflow/agents/bmad-review.md b/agents/bmad/agents/bmad-review.md similarity index 100% rename from bmad-agile-workflow/agents/bmad-review.md rename to agents/bmad/agents/bmad-review.md diff --git a/bmad-agile-workflow/agents/bmad-sm.md b/agents/bmad/agents/bmad-sm.md similarity index 100% rename from bmad-agile-workflow/agents/bmad-sm.md rename to agents/bmad/agents/bmad-sm.md diff --git a/bmad-agile-workflow/commands/bmad-pilot.md b/agents/bmad/commands/bmad-pilot.md similarity index 100% rename from bmad-agile-workflow/commands/bmad-pilot.md rename to agents/bmad/commands/bmad-pilot.md diff --git a/development-essentials/.claude-plugin/plugin.json b/agents/development-essentials/.claude-plugin/plugin.json similarity index 100% rename from development-essentials/.claude-plugin/plugin.json rename to agents/development-essentials/.claude-plugin/plugin.json diff --git a/docs/DEVELOPMENT-COMMANDS.md b/agents/development-essentials/DEVELOPMENT-COMMANDS.md similarity index 99% rename from docs/DEVELOPMENT-COMMANDS.md rename to agents/development-essentials/DEVELOPMENT-COMMANDS.md index 2d948f5..5d670c6 100644 --- a/docs/DEVELOPMENT-COMMANDS.md +++ b/agents/development-essentials/DEVELOPMENT-COMMANDS.md @@ -304,7 +304,7 @@ Deep reasoning and analysis for complex problems. ## 🔌 Agent Configuration All commands use specialized agents configured in: -- `development-essentials/agents/` +- `agents/development-essentials/agents/` - Agent prompt templates - Tool access permissions - Output formatting diff --git a/development-essentials/README.md b/agents/development-essentials/README.md similarity index 97% rename from development-essentials/README.md rename to agents/development-essentials/README.md index 484b8d6..1c996f9 100644 --- a/development-essentials/README.md +++ b/agents/development-essentials/README.md @@ -244,8 +244,8 @@ Development Essentials 模块包含以下专用代理: ## 🔗 相关文档 - [主文档](../README.md) - 项目总览 -- [BMAD工作流](../docs/BMAD-WORKFLOW.md) - 完整敏捷流程 -- [Requirements工作流](../docs/REQUIREMENTS-WORKFLOW.md) - 轻量级开发流程 +- [BMAD工作流](../agents/bmad/BMAD-WORKFLOW.md) - 完整敏捷流程 +- [Requirements工作流](../agents/requirements/REQUIREMENTS-WORKFLOW.md) - 轻量级开发流程 - [插件系统](../PLUGIN_README.md) - 插件安装和管理 --- diff --git a/development-essentials/agents/bugfix-verify.md b/agents/development-essentials/agents/bugfix-verify.md similarity index 100% rename from development-essentials/agents/bugfix-verify.md rename to agents/development-essentials/agents/bugfix-verify.md diff --git a/development-essentials/agents/bugfix.md b/agents/development-essentials/agents/bugfix.md similarity index 100% rename from development-essentials/agents/bugfix.md rename to agents/development-essentials/agents/bugfix.md diff --git a/development-essentials/agents/code.md b/agents/development-essentials/agents/code.md similarity index 100% rename from development-essentials/agents/code.md rename to agents/development-essentials/agents/code.md diff --git a/development-essentials/agents/debug.md b/agents/development-essentials/agents/debug.md similarity index 100% rename from development-essentials/agents/debug.md rename to agents/development-essentials/agents/debug.md diff --git a/development-essentials/agents/optimize.md b/agents/development-essentials/agents/optimize.md similarity index 100% rename from development-essentials/agents/optimize.md rename to agents/development-essentials/agents/optimize.md diff --git a/development-essentials/commands/ask.md b/agents/development-essentials/commands/ask.md similarity index 100% rename from development-essentials/commands/ask.md rename to agents/development-essentials/commands/ask.md diff --git a/development-essentials/commands/bugfix.md b/agents/development-essentials/commands/bugfix.md similarity index 100% rename from development-essentials/commands/bugfix.md rename to agents/development-essentials/commands/bugfix.md diff --git a/development-essentials/commands/code.md b/agents/development-essentials/commands/code.md similarity index 100% rename from development-essentials/commands/code.md rename to agents/development-essentials/commands/code.md diff --git a/development-essentials/commands/debug.md b/agents/development-essentials/commands/debug.md similarity index 100% rename from development-essentials/commands/debug.md rename to agents/development-essentials/commands/debug.md diff --git a/development-essentials/commands/docs.md b/agents/development-essentials/commands/docs.md similarity index 100% rename from development-essentials/commands/docs.md rename to agents/development-essentials/commands/docs.md diff --git a/development-essentials/commands/enhance-prompt.md b/agents/development-essentials/commands/enhance-prompt.md similarity index 100% rename from development-essentials/commands/enhance-prompt.md rename to agents/development-essentials/commands/enhance-prompt.md diff --git a/development-essentials/commands/optimize.md b/agents/development-essentials/commands/optimize.md similarity index 100% rename from development-essentials/commands/optimize.md rename to agents/development-essentials/commands/optimize.md diff --git a/development-essentials/commands/refactor.md b/agents/development-essentials/commands/refactor.md similarity index 100% rename from development-essentials/commands/refactor.md rename to agents/development-essentials/commands/refactor.md diff --git a/development-essentials/commands/review.md b/agents/development-essentials/commands/review.md similarity index 100% rename from development-essentials/commands/review.md rename to agents/development-essentials/commands/review.md diff --git a/development-essentials/commands/test.md b/agents/development-essentials/commands/test.md similarity index 100% rename from development-essentials/commands/test.md rename to agents/development-essentials/commands/test.md diff --git a/development-essentials/commands/think.md b/agents/development-essentials/commands/think.md similarity index 100% rename from development-essentials/commands/think.md rename to agents/development-essentials/commands/think.md diff --git a/requirements-driven-workflow/.claude-plugin/plugin.json b/agents/requirements/.claude-plugin/plugin.json similarity index 100% rename from requirements-driven-workflow/.claude-plugin/plugin.json rename to agents/requirements/.claude-plugin/plugin.json diff --git a/requirements-driven-workflow/README.md b/agents/requirements/README.md similarity index 98% rename from requirements-driven-workflow/README.md rename to agents/requirements/README.md index c79c4ec..0d0fd5e 100644 --- a/requirements-driven-workflow/README.md +++ b/agents/requirements/README.md @@ -78,7 +78,7 @@ After code review passes (≥90%): ## Directory Structure ``` -requirements-driven-workflow/ +agents/requirements/ ├── README.md ├── commands/ │ └── requirements-pilot.md diff --git a/docs/REQUIREMENTS-WORKFLOW.md b/agents/requirements/REQUIREMENTS-WORKFLOW.md similarity index 100% rename from docs/REQUIREMENTS-WORKFLOW.md rename to agents/requirements/REQUIREMENTS-WORKFLOW.md diff --git a/requirements-driven-workflow/agents/requirements-code.md b/agents/requirements/agents/requirements-code.md similarity index 100% rename from requirements-driven-workflow/agents/requirements-code.md rename to agents/requirements/agents/requirements-code.md diff --git a/requirements-driven-workflow/agents/requirements-generate.md b/agents/requirements/agents/requirements-generate.md similarity index 100% rename from requirements-driven-workflow/agents/requirements-generate.md rename to agents/requirements/agents/requirements-generate.md diff --git a/requirements-driven-workflow/agents/requirements-review.md b/agents/requirements/agents/requirements-review.md similarity index 100% rename from requirements-driven-workflow/agents/requirements-review.md rename to agents/requirements/agents/requirements-review.md diff --git a/requirements-driven-workflow/agents/requirements-testing.md b/agents/requirements/agents/requirements-testing.md similarity index 100% rename from requirements-driven-workflow/agents/requirements-testing.md rename to agents/requirements/agents/requirements-testing.md diff --git a/requirements-driven-workflow/commands/requirements-pilot.md b/agents/requirements/commands/requirements-pilot.md similarity index 100% rename from requirements-driven-workflow/commands/requirements-pilot.md rename to agents/requirements/commands/requirements-pilot.md diff --git a/bin/cli.js b/bin/cli.js new file mode 100755 index 0000000..3b9fc3e --- /dev/null +++ b/bin/cli.js @@ -0,0 +1,730 @@ +#!/usr/bin/env node +"use strict"; + +const crypto = require("crypto"); +const fs = require("fs"); +const https = require("https"); +const os = require("os"); +const path = require("path"); +const readline = require("readline"); +const zlib = require("zlib"); +const { spawn } = require("child_process"); + +const REPO = { owner: "cexll", name: "myclaude" }; +const API_HEADERS = { + "User-Agent": "myclaude-npx", + Accept: "application/vnd.github+json", +}; + +function parseArgs(argv) { + const out = { + installDir: "~/.claude", + force: false, + dryRun: false, + list: false, + update: false, + tag: null, + }; + + for (let i = 0; i < argv.length; i++) { + const a = argv[i]; + if (a === "--install-dir") out.installDir = argv[++i]; + else if (a === "--force") out.force = true; + else if (a === "--dry-run") out.dryRun = true; + else if (a === "--list") out.list = true; + else if (a === "--update") out.update = true; + else if (a === "--tag") out.tag = argv[++i]; + else if (a === "-h" || a === "--help") out.help = true; + else throw new Error(`Unknown arg: ${a}`); + } + + return out; +} + +function printHelp() { + process.stdout.write( + [ + "myclaude (npx installer)", + "", + "Usage:", + " npx github:cexll/myclaude", + " npx github:cexll/myclaude --list", + " npx github:cexll/myclaude --update", + " npx github:cexll/myclaude --install-dir ~/.claude --force", + "", + "Options:", + " --install-dir Default: ~/.claude", + " --force Overwrite existing files", + " --dry-run Print actions only", + " --list List installable items and exit", + " --update Update already installed modules", + " --tag Install a specific GitHub tag", + ].join("\n") + "\n" + ); +} + +function withTimeout(promise, ms, label) { + let timer; + const timeout = new Promise((_, reject) => { + timer = setTimeout(() => reject(new Error(`Timeout: ${label}`)), ms); + }); + return Promise.race([promise, timeout]).finally(() => clearTimeout(timer)); +} + +function httpsGetJson(url) { + return new Promise((resolve, reject) => { + https + .get(url, { headers: API_HEADERS }, (res) => { + let body = ""; + res.setEncoding("utf8"); + res.on("data", (d) => (body += d)); + res.on("end", () => { + if (res.statusCode && res.statusCode >= 400) { + return reject( + new Error(`HTTP ${res.statusCode}: ${url}\n${body.slice(0, 500)}`) + ); + } + try { + resolve(JSON.parse(body)); + } catch (e) { + reject(new Error(`Invalid JSON from ${url}: ${e.message}`)); + } + }); + }) + .on("error", reject); + }); +} + +function downloadToFile(url, outPath) { + return new Promise((resolve, reject) => { + const file = fs.createWriteStream(outPath); + https + .get(url, { headers: API_HEADERS }, (res) => { + if ( + res.statusCode && + res.statusCode >= 300 && + res.statusCode < 400 && + res.headers.location + ) { + file.close(); + fs.unlink(outPath, () => { + downloadToFile(res.headers.location, outPath).then(resolve, reject); + }); + return; + } + if (res.statusCode && res.statusCode >= 400) { + file.close(); + fs.unlink(outPath, () => {}); + return reject(new Error(`HTTP ${res.statusCode}: ${url}`)); + } + res.pipe(file); + file.on("finish", () => file.close(resolve)); + }) + .on("error", (err) => { + file.close(); + fs.unlink(outPath, () => reject(err)); + }); + }); +} + +async function fetchLatestTag() { + const url = `https://api.github.com/repos/${REPO.owner}/${REPO.name}/releases/latest`; + const json = await httpsGetJson(url); + if (!json || typeof json.tag_name !== "string" || !json.tag_name.trim()) { + throw new Error("GitHub API: missing tag_name"); + } + return json.tag_name.trim(); +} + +async function fetchRemoteConfig(tag) { + const url = `https://api.github.com/repos/${REPO.owner}/${REPO.name}/contents/config.json?ref=${encodeURIComponent( + tag + )}`; + const json = await httpsGetJson(url); + if (!json || typeof json.content !== "string") { + throw new Error("GitHub contents API: missing config.json content"); + } + const buf = Buffer.from(json.content.replace(/\n/g, ""), "base64"); + return JSON.parse(buf.toString("utf8")); +} + +async function fetchRemoteSkills(tag) { + const url = `https://api.github.com/repos/${REPO.owner}/${REPO.name}/contents/skills?ref=${encodeURIComponent( + tag + )}`; + const json = await httpsGetJson(url); + if (!Array.isArray(json)) throw new Error("GitHub contents API: skills is not a directory"); + return json + .filter((e) => e && e.type === "dir" && typeof e.name === "string") + .map((e) => e.name) + .sort(); +} + +function repoRootFromHere() { + return path.resolve(__dirname, ".."); +} + +function readLocalConfig() { + const p = path.join(repoRootFromHere(), "config.json"); + return JSON.parse(fs.readFileSync(p, "utf8")); +} + +function listLocalSkills() { + const root = repoRootFromHere(); + const skillsDir = path.join(root, "skills"); + if (!fs.existsSync(skillsDir)) return []; + return fs + .readdirSync(skillsDir, { withFileTypes: true }) + .filter((d) => d.isDirectory()) + .map((d) => d.name) + .sort(); +} + +function expandHome(p) { + if (!p) return p; + if (p === "~") return os.homedir(); + if (p.startsWith("~/")) return path.join(os.homedir(), p.slice(2)); + return p; +} + +function readInstalledModuleNamesFromStatus(installDir) { + const p = path.join(installDir, "installed_modules.json"); + if (!fs.existsSync(p)) return null; + try { + const json = JSON.parse(fs.readFileSync(p, "utf8")); + const modules = json && json.modules; + if (!modules || typeof modules !== "object" || Array.isArray(modules)) return null; + return Object.keys(modules) + .filter((k) => typeof k === "string" && k.trim()) + .sort(); + } catch { + return null; + } +} + +async function dirExists(p) { + try { + return (await fs.promises.stat(p)).isDirectory(); + } catch { + return false; + } +} + +async function mergeDirLooksInstalled(srcDir, installDir) { + if (!(await dirExists(srcDir))) return false; + const subdirs = await fs.promises.readdir(srcDir, { withFileTypes: true }); + for (const d of subdirs) { + if (!d.isDirectory()) continue; + const srcSub = path.join(srcDir, d.name); + const entries = await fs.promises.readdir(srcSub, { withFileTypes: true }); + for (const e of entries) { + if (!e.isFile()) continue; + const dst = path.join(installDir, d.name, e.name); + if (fs.existsSync(dst)) return true; + } + } + return false; +} + +async function detectInstalledModuleNames(config, repoRoot, installDir) { + const mods = (config && config.modules) || {}; + const installed = []; + + for (const [name, mod] of Object.entries(mods)) { + const ops = Array.isArray(mod && mod.operations) ? mod.operations : []; + let ok = false; + + for (const op of ops) { + const type = op && op.type; + if (type === "copy_file" || type === "copy_dir") { + const target = typeof op.target === "string" ? op.target : ""; + if (target && fs.existsSync(path.join(installDir, target))) { + ok = true; + break; + } + } else if (type === "merge_dir") { + const source = typeof op.source === "string" ? op.source : ""; + if (source && (await mergeDirLooksInstalled(path.join(repoRoot, source), installDir))) { + ok = true; + break; + } + } + } + + if (ok) installed.push(name); + } + + return installed.sort(); +} + +async function updateInstalledModules(installDir, tag, config, dryRun) { + const mods = (config && config.modules) || {}; + if (!Object.keys(mods).length) throw new Error("No modules found in config.json"); + + let repoRoot = repoRootFromHere(); + let tmp = null; + + if (tag) { + tmp = path.join( + os.tmpdir(), + `myclaude-update-${Date.now()}-${crypto.randomBytes(4).toString("hex")}` + ); + await fs.promises.mkdir(tmp, { recursive: true }); + } + + try { + if (tag) { + const archive = path.join(tmp, "src.tgz"); + const url = `https://codeload.github.com/${REPO.owner}/${REPO.name}/tar.gz/refs/tags/${encodeURIComponent( + tag + )}`; + process.stdout.write(`Downloading ${REPO.owner}/${REPO.name}@${tag}...\n`); + await downloadToFile(url, archive); + process.stdout.write("Extracting...\n"); + const extracted = path.join(tmp, "src"); + await extractTarGz(archive, extracted); + repoRoot = extracted; + } else { + process.stdout.write("Offline mode: updating from local package contents.\n"); + } + + const fromStatus = readInstalledModuleNamesFromStatus(installDir); + const installed = fromStatus || (await detectInstalledModuleNames(config, repoRoot, installDir)); + const toUpdate = installed.filter((name) => Object.prototype.hasOwnProperty.call(mods, name)); + + if (!toUpdate.length) { + process.stdout.write(`No installed modules found in ${installDir}.\n`); + return; + } + + if (dryRun) { + for (const name of toUpdate) process.stdout.write(`module:${name}\n`); + return; + } + + await fs.promises.mkdir(installDir, { recursive: true }); + for (const name of toUpdate) { + process.stdout.write(`Updating module: ${name}\n`); + await applyModule(name, config, repoRoot, installDir, true); + } + } finally { + if (tmp) await rmTree(tmp); + } +} + +function buildItems(config, skills) { + const items = [{ id: "codeagent-wrapper", label: "codeagent-wrapper", kind: "wrapper" }]; + + const modules = (config && config.modules) || {}; + for (const [name, mod] of Object.entries(modules)) { + const desc = mod && typeof mod.description === "string" ? mod.description : ""; + items.push({ + id: `module:${name}`, + label: `module:${name}${desc ? ` - ${desc}` : ""}`, + kind: "module", + moduleName: name, + }); + } + + for (const s of skills) { + items.push({ id: `skill:${s}`, label: `skill:${s}`, kind: "skill", skillName: s }); + } + + return items; +} + +function clearScreen() { + process.stdout.write("\x1b[2J\x1b[H"); +} + +async function promptMultiSelect(items, title) { + if (!process.stdin.isTTY) { + throw new Error("No TTY. Use --list or run in an interactive terminal."); + } + + let idx = 0; + const selected = new Set(); + + readline.emitKeypressEvents(process.stdin); + process.stdin.setRawMode(true); + + function render() { + clearScreen(); + process.stdout.write(`${title}\n`); + process.stdout.write("↑↓ move Space toggle Enter confirm q quit\n\n"); + for (let i = 0; i < items.length; i++) { + const it = items[i]; + const cursor = i === idx ? ">" : " "; + const box = selected.has(it.id) ? "[x]" : "[ ]"; + process.stdout.write(`${cursor} ${box} ${it.label}\n`); + } + } + + function cleanup() { + process.stdin.setRawMode(false); + process.stdin.removeListener("keypress", onKey); + } + + function onKey(_, key) { + if (!key) return; + if (key.name === "c" && key.ctrl) { + cleanup(); + process.exit(130); + } + if (key.name === "q") { + cleanup(); + process.exit(0); + } + if (key.name === "up") idx = (idx - 1 + items.length) % items.length; + else if (key.name === "down") idx = (idx + 1) % items.length; + else if (key.name === "space") { + const id = items[idx].id; + if (selected.has(id)) selected.delete(id); + else selected.add(id); + } else if (key.name === "return") { + cleanup(); + clearScreen(); + const picked = items.filter((it) => selected.has(it.id)); + return resolvePick(picked); + } + render(); + } + + let resolvePick; + const result = new Promise((resolve) => { + resolvePick = resolve; + }); + + process.stdin.on("keypress", onKey); + render(); + return result; +} + +function isZeroBlock(b) { + for (let i = 0; i < b.length; i++) if (b[i] !== 0) return false; + return true; +} + +function tarString(b, start, len) { + return b + .toString("utf8", start, start + len) + .replace(/\0.*$/, "") + .trim(); +} + +function tarOctal(b, start, len) { + const s = tarString(b, start, len); + if (!s) return 0; + return parseInt(s, 8) || 0; +} + +function safePosixPath(p) { + const norm = path.posix.normalize(p); + if (norm.startsWith("/") || norm.startsWith("..") || norm.includes("/../")) { + throw new Error(`Unsafe path in archive: ${p}`); + } + return norm; +} + +async function extractTarGz(archivePath, destDir) { + await fs.promises.mkdir(destDir, { recursive: true }); + const gunzip = zlib.createGunzip(); + const stream = fs.createReadStream(archivePath).pipe(gunzip); + + let buf = Buffer.alloc(0); + let file = null; + let pad = 0; + let zeroBlocks = 0; + + for await (const chunk of stream) { + buf = Buffer.concat([buf, chunk]); + while (true) { + if (pad) { + if (buf.length < pad) break; + buf = buf.slice(pad); + pad = 0; + } + + if (!file) { + if (buf.length < 512) break; + const header = buf.slice(0, 512); + buf = buf.slice(512); + + if (isZeroBlock(header)) { + zeroBlocks++; + if (zeroBlocks >= 2) return; + continue; + } + zeroBlocks = 0; + + const name = tarString(header, 0, 100); + const prefix = tarString(header, 345, 155); + const full = prefix ? `${prefix}/${name}` : name; + const size = tarOctal(header, 124, 12); + const mode = tarOctal(header, 100, 8); + const typeflag = header[156]; + + const rel = safePosixPath(full.split("/").slice(1).join("/")); + if (!rel || rel === ".") { + file = null; + pad = 0; + continue; + } + + const outPath = path.join(destDir, ...rel.split("/")); + if (typeflag === 53) { + await fs.promises.mkdir(outPath, { recursive: true }); + if (mode) await fs.promises.chmod(outPath, mode); + file = null; + pad = 0; + continue; + } + + file = { outPath, size, remaining: size, chunks: [], mode }; + if (size === 0) { + await fs.promises.mkdir(path.dirname(outPath), { recursive: true }); + await fs.promises.writeFile(outPath, Buffer.alloc(0)); + if (mode) await fs.promises.chmod(outPath, mode); + file = null; + pad = 0; + } + continue; + } + + if (buf.length < file.remaining) { + file.chunks.push(buf); + file.remaining -= buf.length; + buf = Buffer.alloc(0); + break; + } + + file.chunks.push(buf.slice(0, file.remaining)); + buf = buf.slice(file.remaining); + file.remaining = 0; + + await fs.promises.mkdir(path.dirname(file.outPath), { recursive: true }); + await fs.promises.writeFile(file.outPath, Buffer.concat(file.chunks)); + if (file.mode) await fs.promises.chmod(file.outPath, file.mode); + + pad = (512 - (file.size % 512)) % 512; + file = null; + } + } +} + +async function copyFile(src, dst, force) { + if (!force && fs.existsSync(dst)) return; + await fs.promises.mkdir(path.dirname(dst), { recursive: true }); + await fs.promises.copyFile(src, dst); + const st = await fs.promises.stat(src); + await fs.promises.chmod(dst, st.mode); +} + +async function copyDirRecursive(src, dst, force) { + if (fs.existsSync(dst) && !force) return; + await fs.promises.mkdir(dst, { recursive: true }); + + const entries = await fs.promises.readdir(src, { withFileTypes: true }); + for (const e of entries) { + const s = path.join(src, e.name); + const d = path.join(dst, e.name); + if (e.isDirectory()) await copyDirRecursive(s, d, force); + else if (e.isFile()) await copyFile(s, d, force); + } +} + +async function mergeDir(src, installDir, force) { + const subdirs = await fs.promises.readdir(src, { withFileTypes: true }); + for (const d of subdirs) { + if (!d.isDirectory()) continue; + const srcSub = path.join(src, d.name); + const dstSub = path.join(installDir, d.name); + await fs.promises.mkdir(dstSub, { recursive: true }); + const entries = await fs.promises.readdir(srcSub, { withFileTypes: true }); + for (const e of entries) { + if (!e.isFile()) continue; + await copyFile(path.join(srcSub, e.name), path.join(dstSub, e.name), force); + } + } +} + +function runInstallSh(repoRoot, installDir) { + return new Promise((resolve, reject) => { + const cmd = process.platform === "win32" ? "cmd.exe" : "bash"; + const args = process.platform === "win32" ? ["/c", "install.bat"] : ["install.sh"]; + const p = spawn(cmd, args, { + cwd: repoRoot, + stdio: "inherit", + env: { ...process.env, INSTALL_DIR: installDir }, + }); + p.on("exit", (code) => { + if (code === 0) resolve(); + else reject(new Error(`install script failed (exit ${code})`)); + }); + }); +} + +async function rmTree(p) { + if (!fs.existsSync(p)) return; + if (fs.promises.rm) { + await fs.promises.rm(p, { recursive: true, force: true }); + return; + } + await fs.promises.rmdir(p, { recursive: true }); +} + +async function applyModule(moduleName, config, repoRoot, installDir, force) { + const mod = config && config.modules && config.modules[moduleName]; + if (!mod) throw new Error(`Unknown module: ${moduleName}`); + const ops = Array.isArray(mod.operations) ? mod.operations : []; + + for (const op of ops) { + const type = op && op.type; + if (type === "copy_file") { + await copyFile( + path.join(repoRoot, op.source), + path.join(installDir, op.target), + force + ); + } else if (type === "copy_dir") { + await copyDirRecursive( + path.join(repoRoot, op.source), + path.join(installDir, op.target), + force + ); + } else if (type === "merge_dir") { + await mergeDir(path.join(repoRoot, op.source), installDir, force); + } else if (type === "run_command") { + const cmd = typeof op.command === "string" ? op.command.trim() : ""; + if (cmd !== "bash install.sh") { + throw new Error(`Refusing run_command: ${cmd || "(empty)"}`); + } + await runInstallSh(repoRoot, installDir); + } else { + throw new Error(`Unsupported operation type: ${type}`); + } + } +} + +async function installSelected(picks, tag, config, installDir, force, dryRun) { + const needRepo = picks.some((p) => p.kind !== "wrapper"); + const needWrapper = picks.some((p) => p.kind === "wrapper"); + + if (dryRun) { + for (const p of picks) process.stdout.write(`- ${p.id}\n`); + return; + } + + const tmp = path.join( + os.tmpdir(), + `myclaude-${Date.now()}-${crypto.randomBytes(4).toString("hex")}` + ); + await fs.promises.mkdir(tmp, { recursive: true }); + + try { + let repoRoot = repoRootFromHere(); + if (needRepo || needWrapper) { + if (!tag) throw new Error("No tag available to download"); + const archive = path.join(tmp, "src.tgz"); + const url = `https://codeload.github.com/${REPO.owner}/${REPO.name}/tar.gz/refs/tags/${encodeURIComponent( + tag + )}`; + process.stdout.write(`Downloading ${REPO.owner}/${REPO.name}@${tag}...\n`); + await downloadToFile(url, archive); + process.stdout.write("Extracting...\n"); + const extracted = path.join(tmp, "src"); + await extractTarGz(archive, extracted); + repoRoot = extracted; + } + + await fs.promises.mkdir(installDir, { recursive: true }); + + for (const p of picks) { + if (p.kind === "wrapper") { + process.stdout.write("Installing codeagent-wrapper...\n"); + await runInstallSh(repoRoot, installDir); + continue; + } + if (p.kind === "module") { + process.stdout.write(`Installing module: ${p.moduleName}\n`); + await applyModule(p.moduleName, config, repoRoot, installDir, force); + continue; + } + if (p.kind === "skill") { + process.stdout.write(`Installing skill: ${p.skillName}\n`); + await copyDirRecursive( + path.join(repoRoot, "skills", p.skillName), + path.join(installDir, "skills", p.skillName), + force + ); + } + } + } finally { + await rmTree(tmp); + } +} + +async function main() { + const args = parseArgs(process.argv.slice(2)); + if (args.help) { + printHelp(); + return; + } + + const installDir = expandHome(args.installDir); + if (args.list && args.update) throw new Error("Cannot combine --list and --update"); + + let tag = args.tag; + if (!tag) { + try { + tag = await withTimeout(fetchLatestTag(), 5000, "fetch latest tag"); + } catch { + tag = null; + } + } + + let config = null; + let skills = []; + if (tag) { + try { + [config, skills] = await withTimeout( + Promise.all([fetchRemoteConfig(tag), fetchRemoteSkills(tag)]), + 8000, + "fetch config/skills" + ); + } catch { + config = null; + skills = []; + } + } + + if (!config) config = readLocalConfig(); + if (!skills.length) skills = listLocalSkills(); + + if (args.update) { + await updateInstalledModules(installDir, tag, config, args.dryRun); + process.stdout.write("Done.\n"); + return; + } + + const items = buildItems(config, skills); + if (args.list) { + for (const it of items) process.stdout.write(`${it.id}\n`); + return; + } + + const title = tag ? `myclaude installer (latest: ${tag})` : "myclaude installer (offline mode)"; + const picks = await promptMultiSelect(items, title); + if (!picks.length) { + process.stdout.write("Nothing selected.\n"); + return; + } + + await installSelected(picks, tag, config, installDir, args.force, args.dryRun); + process.stdout.write("Done.\n"); +} + +main().catch((err) => { + process.stderr.write(`ERROR: ${err && err.message ? err.message : String(err)}\n`); + process.exit(1); +}); diff --git a/docs/CODEAGENT-WRAPPER.md b/codeagent-wrapper/USER_GUIDE.md similarity index 98% rename from docs/CODEAGENT-WRAPPER.md rename to codeagent-wrapper/USER_GUIDE.md index d303805..55d46f4 100644 --- a/docs/CODEAGENT-WRAPPER.md +++ b/codeagent-wrapper/USER_GUIDE.md @@ -14,14 +14,10 @@ Multi-backend AI code execution wrapper supporting Codex, Claude, and Gemini. ## Installation ```bash -# Clone repository -git clone https://github.com/cexll/myclaude.git -cd myclaude +# Recommended: run the installer and select "codeagent-wrapper" +npx github:cexll/myclaude -# Install via install.py (includes binary compilation) -python3 install.py --module dev - -# Or manual installation +# Manual build (optional; requires repo checkout) cd codeagent-wrapper go build -o ~/.claude/bin/codeagent-wrapper ``` diff --git a/config.json b/config.json index c085882..a376f7d 100644 --- a/config.json +++ b/config.json @@ -3,75 +3,14 @@ "install_dir": "~/.claude", "log_file": "install.log", "modules": { - "dev": { - "enabled": true, - "description": "Core dev workflow with Codex integration", - "operations": [ - { - "type": "merge_dir", - "source": "dev-workflow", - "description": "Merge commands/ and agents/ into install dir" - }, - { - "type": "copy_file", - "source": "memorys/CLAUDE.md", - "target": "CLAUDE.md", - "description": "Copy core role and guidelines" - }, - { - "type": "copy_file", - "source": "skills/codeagent/SKILL.md", - "target": "skills/codeagent/SKILL.md", - "description": "Install codeagent skill" - }, - { - "type": "copy_file", - "source": "skills/product-requirements/SKILL.md", - "target": "skills/product-requirements/SKILL.md", - "description": "Install product-requirements skill" - }, - { - "type": "copy_file", - "source": "skills/prototype-prompt-generator/SKILL.md", - "target": "skills/prototype-prompt-generator/SKILL.md", - "description": "Install prototype-prompt-generator skill" - }, - { - "type": "copy_file", - "source": "skills/prototype-prompt-generator/references/prompt-structure.md", - "target": "skills/prototype-prompt-generator/references/prompt-structure.md", - "description": "Install prototype-prompt-generator prompt structure reference" - }, - { - "type": "copy_file", - "source": "skills/prototype-prompt-generator/references/design-systems.md", - "target": "skills/prototype-prompt-generator/references/design-systems.md", - "description": "Install prototype-prompt-generator design systems reference" - }, - { - "type": "run_command", - "command": "bash install.sh", - "description": "Install codeagent-wrapper binary", - "env": { - "INSTALL_DIR": "${install_dir}" - } - } - ] - }, "bmad": { "enabled": false, "description": "BMAD agile workflow with multi-agent orchestration", "operations": [ { "type": "merge_dir", - "source": "bmad-agile-workflow", + "source": "agents/bmad", "description": "Merge BMAD commands and agents" - }, - { - "type": "copy_file", - "source": "docs/BMAD-WORKFLOW.md", - "target": "docs/BMAD-WORKFLOW.md", - "description": "Copy BMAD workflow documentation" } ] }, @@ -81,14 +20,8 @@ "operations": [ { "type": "merge_dir", - "source": "requirements-driven-workflow", + "source": "agents/requirements", "description": "Merge requirements workflow commands and agents" - }, - { - "type": "copy_file", - "source": "docs/REQUIREMENTS-WORKFLOW.md", - "target": "docs/REQUIREMENTS-WORKFLOW.md", - "description": "Copy requirements workflow documentation" } ] }, @@ -98,14 +31,8 @@ "operations": [ { "type": "merge_dir", - "source": "development-essentials", + "source": "agents/development-essentials", "description": "Merge essential development commands" - }, - { - "type": "copy_file", - "source": "docs/DEVELOPMENT-COMMANDS.md", - "target": "docs/DEVELOPMENT-COMMANDS.md", - "description": "Copy development commands documentation" } ] }, @@ -170,7 +97,7 @@ ] }, "do": { - "enabled": false, + "enabled": true, "description": "7-phase feature development workflow with codeagent orchestration", "operations": [ { diff --git a/dev-workflow/.claude-plugin/plugin.json b/dev-workflow/.claude-plugin/plugin.json deleted file mode 100644 index b2bde11..0000000 --- a/dev-workflow/.claude-plugin/plugin.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "dev", - "description": "Lightweight development workflow with requirements clarification, parallel codex execution, and mandatory 90% test coverage", - "version": "5.6.1", - "author": { - "name": "cexll", - "email": "cexll@cexll.com" - } -} diff --git a/dev-workflow/README.md b/dev-workflow/README.md deleted file mode 100644 index d41c147..0000000 --- a/dev-workflow/README.md +++ /dev/null @@ -1,192 +0,0 @@ -# /dev - Minimal Dev Workflow - -## Overview - -A freshly designed lightweight development workflow with no legacy baggage, focused on delivering high-quality code fast. - -## Flow - -``` -/dev trigger - ↓ -AskUserQuestion (backend selection) - ↓ -AskUserQuestion (requirements clarification) - ↓ -codeagent analysis (plan mode + task typing + UI auto-detection) - ↓ -dev-plan-generator (create dev doc) - ↓ -codeagent concurrent development (2–5 tasks, backend routing) - ↓ -codeagent testing & verification (≥90% coverage) - ↓ -Done (generate summary) -``` - -## Step 0 + The 6 Steps - -### 0. Select Allowed Backends (FIRST ACTION) -- Use **AskUserQuestion** with multiSelect to ask which backends are allowed for this run -- Options (user can select multiple): - - `codex` - Stable, high quality, best cost-performance (default for most tasks) - - `claude` - Fast, lightweight (for quick fixes and config changes) - - `gemini` - UI/UX specialist (for frontend styling and components) -- If user selects ONLY `codex`, ALL subsequent tasks must use `codex` (including UI/quick-fix) - -### 1. Clarify Requirements -- Use **AskUserQuestion** to ask the user directly -- No scoring system, no complex logic -- 2–3 rounds of Q&A until the requirement is clear - -### 2. codeagent Analysis + Task Typing + UI Detection -- Call codeagent to analyze the request in plan mode style -- Extract: core functions, technical points, task list (2–5 items) -- For each task, assign exactly one type: `default` / `ui` / `quick-fix` -- UI auto-detection: needs UI work when task involves style assets (.css, .scss, styled-components, CSS modules, tailwindcss) OR frontend component files (.tsx, .jsx, .vue); output yes/no plus evidence - -### 3. Generate Dev Doc -- Call the **dev-plan-generator** agent -- Produce a single `dev-plan.md` -- Append a dedicated UI task when Step 2 marks `needs_ui: true` -- Include: task breakdown, `type`, file scope, dependencies, test commands - -### 4. Concurrent Development -- Work from the task list in dev-plan.md -- Route backend per task type (with user constraints + fallback): - - `default` → `codex` - - `ui` → `gemini` (enforced when allowed) - - `quick-fix` → `claude` - - Missing `type` → treat as `default` - - If the preferred backend is not allowed, fallback to an allowed backend by priority: `codex` → `claude` → `gemini` -- Independent tasks → run in parallel -- Conflicting tasks → run serially - -### 5. Testing & Verification -- Each codeagent task: - - Implements the feature - - Writes tests - - Runs coverage - - Reports results (≥90%) - -### 6. Complete -- Summarize task status -- Record coverage - -## Usage - -```bash -/dev "Implement user login with email + password" -``` - -No CLI flags required; workflow starts with an interactive backend selection. - -## Output Structure - -``` -.claude/specs/{feature_name}/ -└── dev-plan.md # Dev document generated by agent -``` - -Only one file—minimal and clear. - -## Core Components - -### Tools -- **AskUserQuestion**: interactive requirement clarification -- **codeagent skill**: analysis, development, testing; supports `--backend` for `codex` / `claude` / `gemini` -- **dev-plan-generator agent**: generate dev doc (subagent via Task tool, saves context) - -## Backend Selection & Routing -- **Step 0**: user selects allowed backends; if `仅 codex`, all tasks use codex -- **UI detection standard**: style files (.css, .scss, styled-components, CSS modules, tailwindcss) OR frontend component code (.tsx, .jsx, .vue) trigger `needs_ui: true` -- **Task type field**: each task in `dev-plan.md` must have `type: default|ui|quick-fix` -- **Routing**: `default`→codex, `ui`→gemini, `quick-fix`→claude; if disallowed, fallback to an allowed backend by priority: codex→claude→gemini - -## Key Features - -### ✅ Fresh Design -- No legacy project residue -- No complex scoring logic -- No extra abstraction layers - -### ✅ Minimal Orchestration -- Orchestrator controls the flow directly -- Only three tools/components -- Steps are straightforward - -### ✅ Concurrency -- Tasks split based on natural functional boundaries -- Auto-detect dependencies and conflicts -- codeagent executes independently with optimal backend - -### ✅ Quality Assurance -- Enforces 90% coverage -- codeagent tests and verifies its own work -- Automatic retry on failure - -## Example - -```bash -# Trigger -/dev "Add user login feature" - -# Step 0: Select backends -Q: Which backends are allowed? (multiSelect) -A: Selected: codex, claude - -# Step 1: Clarify requirements -Q: What login methods are supported? -A: Email + password -Q: Should login be remembered? -A: Yes, use JWT token - -# Step 2: codeagent analysis -Output: -- Core: email/password login + JWT auth -- Task 1: Backend API (type=default) -- Task 2: Password hashing (type=default) -- Task 3: Frontend form (type=ui) -UI detection: needs_ui = true (tailwindcss classes in frontend form) - -# Step 3: Generate doc -dev-plan.md generated with typed tasks ✓ - -# Step 4-5: Concurrent development (routing + fallback) -[task-1] Backend API (codex) → tests → 92% ✓ -[task-2] Password hashing (codex) → tests → 95% ✓ -[task-3] Frontend form (fallback to codex; gemini not allowed) → tests → 91% ✓ -``` - -## Directory Structure - -``` -dev-workflow/ -├── README.md # This doc -├── commands/ -│ └── dev.md # /dev workflow orchestrator definition -└── agents/ - └── dev-plan-generator.md # Dev plan document generator agent -``` - -Minimal structure, only three files. - -## When to Use - -✅ **Good for**: -- Any feature size -- Fast iterations -- High test coverage needs -- Wanting concurrent speed-up - -## Design Principles - -1. **KISS**: keep it simple -2. **Disposable**: no persistent config -3. **Quality first**: enforce 90% coverage -4. **Concurrency first**: leverage codeagent -5. **No legacy baggage**: clean-slate design - ---- - -**Philosophy**: zero tolerance for complexity—ship the smallest usable solution, like Linus would. diff --git a/dev-workflow/agents/dev-plan-generator.md b/dev-workflow/agents/dev-plan-generator.md deleted file mode 100644 index eaaf657..0000000 --- a/dev-workflow/agents/dev-plan-generator.md +++ /dev/null @@ -1,124 +0,0 @@ ---- -name: dev-plan-generator -description: Use this agent when you need to generate a structured development plan document (`dev-plan.md`) that breaks down a feature into concrete implementation tasks with testing requirements and acceptance criteria. This agent should be called after requirements analysis and before actual implementation begins.\n\n\nContext: User is orchestrating a feature development workflow and needs to create a development plan after codeagent analysis is complete.\nuser: "Create a development plan for the user authentication feature based on the requirements and analysis"\nassistant: "I'll use the Task tool to launch the dev-plan-generator agent to create the structured development plan document."\n\nThe user needs a dev-plan.md document generated from requirements and analysis. Use the dev-plan-generator agent to create the structured task breakdown.\n\n\n\n\nContext: Orchestrator has completed requirements gathering and codeagent analysis for a new feature and needs to generate the development plan before moving to implementation.\nuser: "We've completed the analysis for the payment integration feature. Generate the development plan."\nassistant: "I'm going to use the Task tool to launch the dev-plan-generator agent to create the dev-plan.md document with task breakdown and testing requirements."\n\nThis is the step in the workflow where the development plan document needs to be generated. Use the dev-plan-generator agent to create the structured plan.\n\n\n\n\nContext: User is working through a requirements-driven workflow and has just approved the technical specifications.\nuser: "The specs look good. Let's move forward with creating the implementation plan."\nassistant: "I'll use the Task tool to launch the dev-plan-generator agent to generate the dev-plan.md document with the task breakdown."\n\nAfter spec approval, the next step is generating the development plan. Use the dev-plan-generator agent to create the structured document.\n\n -tools: Glob, Grep, Read, Edit, Write, TodoWrite -model: sonnet -color: green ---- - -You are a specialized Development Plan Document Generator. Your sole responsibility is to create structured, actionable development plan documents (`dev-plan.md`) that break down features into concrete implementation tasks. - -## Your Role - -You receive context from an orchestrator including: -- Feature requirements description -- codeagent analysis results (feature highlights, task decomposition, UI detection flag, and task typing hints) -- Feature name (in kebab-case format) - -Your output is a single file: `./.claude/specs/{feature_name}/dev-plan.md` - -## Document Structure You Must Follow - -```markdown -# {Feature Name} - Development Plan - -## Overview -[One-sentence description of core functionality] - -## Task Breakdown - -### Task 1: [Task Name] -- **ID**: task-1 -- **type**: default|ui|quick-fix -- **Description**: [What needs to be done] -- **File Scope**: [Directories or files involved, e.g., src/auth/**, tests/auth/] -- **Dependencies**: [None or depends on task-x] -- **Test Command**: [e.g., pytest tests/auth --cov=src/auth --cov-report=term] -- **Test Focus**: [Scenarios to cover] - -### Task 2: [Task Name] -... - -(Tasks based on natural functional boundaries, typically 2-5) - -## Acceptance Criteria -- [ ] Feature point 1 -- [ ] Feature point 2 -- [ ] All unit tests pass -- [ ] Code coverage ≥90% - -## Technical Notes -- [Key technical decisions] -- [Constraints to be aware of] -``` - -## Generation Rules You Must Enforce - -1. **Task Count**: Generate tasks based on natural functional boundaries (no artificial limits) - - Typical range: 2-5 tasks - - Quality over quantity: prefer fewer well-scoped tasks over excessive fragmentation - - Each task should be independently completable by one agent -2. **Task Requirements**: Each task MUST include: - - Clear ID (task-1, task-2, etc.) - - A single task type field: `type: default|ui|quick-fix` - - Specific description of what needs to be done - - Explicit file scope (directories or files affected) - - Dependency declaration ("None" or "depends on task-x") - - Complete test command with coverage parameters - - Testing focus points (scenarios to cover) -3. **Task Independence**: Design tasks to be as independent as possible to enable parallel execution -4. **Test Commands**: Must include coverage parameters (e.g., `--cov=module --cov-report=term` for pytest, `--coverage` for npm) -5. **Coverage Threshold**: Always require ≥90% code coverage in acceptance criteria - -## Your Workflow - -1. **Analyze Input**: Review the requirements description and codeagent analysis results (including `needs_ui` and any task typing hints) -2. **Identify Tasks**: Break down the feature into 2-5 logical, independent tasks -3. **Determine Dependencies**: Map out which tasks depend on others (minimize dependencies) -4. **Assign Task Type**: For each task, set exactly one `type`: - - `ui`: touches UI/style/component work (e.g., .css/.scss/.tsx/.jsx/.vue, tailwind, design tweaks) - - `quick-fix`: small, fast changes (config tweaks, small bug fix, minimal scope); do NOT use for UI work - - `default`: everything else - - Note: `/dev` Step 4 routes backend by `type` (default→codex, ui→gemini, quick-fix→claude; missing type → default) -5. **Specify Testing**: For each task, define the exact test command and coverage requirements -6. **Define Acceptance**: List concrete, measurable acceptance criteria including the 90% coverage requirement -7. **Document Technical Points**: Note key technical decisions and constraints -8. **Write File**: Use the Write tool to create `./.claude/specs/{feature_name}/dev-plan.md` - -## Quality Checks Before Writing - -- [ ] Task count is between 2-5 -- [ ] Every task has all required fields (ID, type, Description, File Scope, Dependencies, Test Command, Test Focus) -- [ ] Test commands include coverage parameters -- [ ] Dependencies are explicitly stated -- [ ] Acceptance criteria includes 90% coverage requirement -- [ ] File scope is specific (not vague like "all files") -- [ ] Testing focus is concrete (not generic like "test everything") - -## Critical Constraints - -- **Document Only**: You generate documentation. You do NOT execute code, run tests, or modify source files. -- **Single Output**: You produce exactly one file: `dev-plan.md` in the correct location -- **Path Accuracy**: The path must be `./.claude/specs/{feature_name}/dev-plan.md` where {feature_name} matches the input -- **Language Matching**: Output language matches user input (Chinese input → Chinese doc, English input → English doc) -- **Structured Format**: Follow the exact markdown structure provided - -## Example Output Quality - -Refer to the user login example in your instructions as the quality benchmark. Your outputs should have: -- Clear, actionable task descriptions -- Specific file paths (not generic) -- Realistic test commands for the actual tech stack -- Concrete testing scenarios (not abstract) -- Measurable acceptance criteria -- Relevant technical decisions - -## Error Handling - -If the input context is incomplete or unclear: -1. Request the missing information explicitly -2. Do NOT proceed with generating a low-quality document -3. Do NOT make up requirements or technical details -4. Ask for clarification on: feature scope, tech stack, testing framework, file structure - -Remember: Your document will be used by other agents to implement the feature. Precision and completeness are critical. Every field must be filled with specific, actionable information. diff --git a/dev-workflow/commands/dev.md b/dev-workflow/commands/dev.md deleted file mode 100644 index c99c6bb..0000000 --- a/dev-workflow/commands/dev.md +++ /dev/null @@ -1,213 +0,0 @@ ---- -description: Extreme lightweight end-to-end development workflow with requirements clarification, intelligent backend selection, parallel codeagent execution, and mandatory 90% test coverage ---- - -You are the /dev Workflow Orchestrator, an expert development workflow manager specializing in orchestrating minimal, efficient end-to-end development processes with parallel task execution and rigorous test coverage validation. - ---- - -## CRITICAL CONSTRAINTS (NEVER VIOLATE) - -These rules have HIGHEST PRIORITY and override all other instructions: - -1. **NEVER use Edit, Write, or MultiEdit tools directly** - ALL code changes MUST go through codeagent-wrapper -2. **MUST use AskUserQuestion in Step 0** - Backend selection MUST be the FIRST action (before requirement clarification) -3. **MUST use AskUserQuestion in Step 1** - Do NOT skip requirement clarification -4. **MUST use TodoWrite after Step 1** - Create task tracking list before any analysis -5. **MUST use codeagent-wrapper for Step 2 analysis** - Do NOT use Read/Glob/Grep directly for deep analysis -6. **MUST wait for user confirmation in Step 3** - Do NOT proceed to Step 4 without explicit approval -7. **MUST invoke codeagent-wrapper --parallel for Step 4 execution** - Use Bash tool, NOT Edit/Write or Task tool - -**Violation of any constraint above invalidates the entire workflow. Stop and restart if violated.** - ---- - -**Core Responsibilities** -- Orchestrate a streamlined 7-step development workflow (Step 0 + Step 1–6): - 0. Backend selection (user constrained) - 1. Requirement clarification through targeted questioning - 2. Technical analysis using codeagent-wrapper - 3. Development documentation generation - 4. Parallel development execution (backend routing per task type) - 5. Coverage validation (≥90% requirement) - 6. Completion summary - -**Workflow Execution** -- **Step 0: Backend Selection [MANDATORY - FIRST ACTION]** - - MUST use AskUserQuestion tool as the FIRST action with multiSelect enabled - - Ask which backends are allowed for this /dev run - - Options (user can select multiple): - - `codex` - Stable, high quality, best cost-performance (default for most tasks) - - `claude` - Fast, lightweight (for quick fixes and config changes) - - `gemini` - UI/UX specialist (for frontend styling and components) - - Store the selected backends as `allowed_backends` set for routing in Step 4 - - Special rule: if user selects ONLY `codex`, then ALL subsequent tasks (including UI/quick-fix) MUST use `codex` (no exceptions) - -- **Step 1: Requirement Clarification [MANDATORY - DO NOT SKIP]** - - MUST use AskUserQuestion tool - - Focus questions on functional boundaries, inputs/outputs, constraints, testing, and required unit-test coverage levels - - Iterate 2-3 rounds until clear; rely on judgment; keep questions concise - - After clarification complete: MUST use TodoWrite to create task tracking list with workflow steps - -- **Step 2: codeagent-wrapper Deep Analysis (Plan Mode Style) [USE CODEAGENT-WRAPPER ONLY]** - - MUST use Bash tool to invoke `codeagent-wrapper` for deep analysis. Do NOT use Read/Glob/Grep tools directly - delegate all exploration to codeagent-wrapper. - - **How to invoke for analysis**: - ```bash - # analysis_backend selection: - # - prefer codex if it is in allowed_backends - # - otherwise pick the first backend in allowed_backends - codeagent-wrapper --backend {analysis_backend} - <<'EOF' - Analyze the codebase for implementing [feature name]. - - Requirements: - - [requirement 1] - - [requirement 2] - - Deliverables: - 1. Explore codebase structure and existing patterns - 2. Evaluate implementation options with trade-offs - 3. Make architectural decisions - 4. Break down into 2-5 parallelizable tasks with dependencies and file scope - 5. Classify each task with a single `type`: `default` / `ui` / `quick-fix` - 6. Determine if UI work is needed (check for .css/.tsx/.vue files) - - Output the analysis following the structure below. - EOF - ``` - - **When Deep Analysis is Needed** (any condition triggers): - - Multiple valid approaches exist (e.g., Redis vs in-memory vs file-based caching) - - Significant architectural decisions required (e.g., WebSockets vs SSE vs polling) - - Large-scale changes touching many files or systems - - Unclear scope requiring exploration first - - **UI Detection Requirements**: - - During analysis, output whether the task needs UI work (yes/no) and the evidence - - UI criteria: presence of style assets (.css, .scss, styled-components, CSS modules, tailwindcss) OR frontend component files (.tsx, .jsx, .vue) - - **What the AI backend does in Analysis Mode** (when invoked via codeagent-wrapper): - 1. **Explore Codebase**: Use Glob, Grep, Read to understand structure, patterns, architecture - 2. **Identify Existing Patterns**: Find how similar features are implemented, reuse conventions - 3. **Evaluate Options**: When multiple approaches exist, list trade-offs (complexity, performance, security, maintainability) - 4. **Make Architectural Decisions**: Choose patterns, APIs, data models with justification - 5. **Design Task Breakdown**: Produce parallelizable tasks based on natural functional boundaries with file scope and dependencies - - **Analysis Output Structure**: - ``` - ## Context & Constraints - [Tech stack, existing patterns, constraints discovered] - - ## Codebase Exploration - [Key files, modules, patterns found via Glob/Grep/Read] - - ## Implementation Options (if multiple approaches) - | Option | Pros | Cons | Recommendation | - - ## Technical Decisions - [API design, data models, architecture choices made] - - ## Task Breakdown - [2-5 tasks with: ID, description, file scope, dependencies, test command, type(default|ui|quick-fix)] - - ## UI Determination - needs_ui: [true/false] - evidence: [files and reasoning tied to style + component criteria] - ``` - - **Skip Deep Analysis When**: - - Simple, straightforward implementation with obvious approach - - Small changes confined to 1-2 files - - Clear requirements with single implementation path - -- **Step 3: Generate Development Documentation** - - invoke agent dev-plan-generator - - When creating `dev-plan.md`, ensure every task has `type: default|ui|quick-fix` - - Append a dedicated UI task if Step 2 marked `needs_ui: true` but no UI task exists - - Output a brief summary of dev-plan.md: - - Number of tasks and their IDs - - Task type for each task - - File scope for each task - - Dependencies between tasks - - Test commands - - Use AskUserQuestion to confirm with user: - - Question: "Proceed with this development plan?" (state backend routing rules and any forced fallback due to allowed_backends) - - Options: "Confirm and execute" / "Need adjustments" - - If user chooses "Need adjustments", return to Step 1 or Step 2 based on feedback - -- **Step 4: Parallel Development Execution [CODEAGENT-WRAPPER ONLY - NO DIRECT EDITS]** - - MUST use Bash tool to invoke `codeagent-wrapper --parallel` for ALL code changes - - NEVER use Edit, Write, MultiEdit, or Task tools to modify code directly - - Backend routing (must be deterministic and enforceable): - - Task field: `type: default|ui|quick-fix` (missing → treat as `default`) - - Preferred backend by type: - - `default` → `codex` - - `ui` → `gemini` (enforced when allowed) - - `quick-fix` → `claude` - - If user selected `仅 codex`: all tasks MUST use `codex` - - Otherwise, if preferred backend is not in `allowed_backends`, fallback to the first available backend by priority: `codex` → `claude` → `gemini` - - Build ONE `--parallel` config that includes all tasks in `dev-plan.md` and submit it once via Bash tool: - ```bash - # One shot submission - wrapper handles topology + concurrency - codeagent-wrapper --parallel <<'EOF' - ---TASK--- - id: [task-id-1] - backend: [routed-backend-from-type-and-allowed_backends] - workdir: . - dependencies: [optional, comma-separated ids] - ---CONTENT--- - Task: [task-id-1] - Reference: @.claude/specs/{feature_name}/dev-plan.md - Scope: [task file scope] - Test: [test command] - Deliverables: code + unit tests + coverage ≥90% + coverage summary - - ---TASK--- - id: [task-id-2] - backend: [routed-backend-from-type-and-allowed_backends] - workdir: . - dependencies: [optional, comma-separated ids] - ---CONTENT--- - Task: [task-id-2] - Reference: @.claude/specs/{feature_name}/dev-plan.md - Scope: [task file scope] - Test: [test command] - Deliverables: code + unit tests + coverage ≥90% + coverage summary - EOF - ``` - - **Note**: Use `workdir: .` (current directory) for all tasks unless specific subdirectory is required - - Execute independent tasks concurrently; serialize conflicting ones; track coverage reports - - Backend is routed deterministically based on task `type`, no manual intervention needed - -- **Step 5: Coverage Validation** - - Validate each task’s coverage: - - All ≥90% → pass - - Any <90% → request more tests (max 2 rounds) - -- **Step 6: Completion Summary** - - Provide completed task list, coverage per task, key file changes - -**Error Handling** -- **codeagent-wrapper failure**: Retry once with same input; if still fails, log error and ask user for guidance -- **Insufficient coverage (<90%)**: Request more tests from the failed task (max 2 rounds); if still fails, report to user -- **Dependency conflicts**: - - Circular dependencies: codeagent-wrapper will detect and fail with error; revise task breakdown to remove cycles - - Missing dependencies: Ensure all task IDs referenced in `dependencies` field exist -- **Parallel execution timeout**: Individual tasks timeout after 2 hours (configurable via CODEX_TIMEOUT); failed tasks can be retried individually -- **Backend unavailable**: If a routed backend is unavailable, fallback to another backend in `allowed_backends` (priority: codex → claude → gemini); if none works, fail with a clear error message - -**Quality Standards** -- Code coverage ≥90% -- Tasks based on natural functional boundaries (typically 2-5) -- Each task has exactly one `type: default|ui|quick-fix` -- Backend routed by `type`: `default`→codex, `ui`→gemini, `quick-fix`→claude (with allowed_backends fallback) -- Documentation must be minimal yet actionable -- No verbose implementations; only essential code - -**Communication Style** -- Be direct and concise -- Report progress at each workflow step -- Highlight blockers immediately -- Provide actionable next steps when coverage fails -- Prioritize speed via parallelization while enforcing coverage validation diff --git a/docs/HOOKS.md b/docs/HOOKS.md deleted file mode 100644 index af507f6..0000000 --- a/docs/HOOKS.md +++ /dev/null @@ -1,197 +0,0 @@ -# Claude Code Hooks Guide - -Hooks are shell scripts or commands that execute in response to Claude Code events. - -## Available Hook Types - -### 1. UserPromptSubmit -Runs after user submits a prompt, before Claude processes it. - -**Use cases:** -- Auto-activate skills based on keywords -- Add context injection -- Log user requests - -### 2. PostToolUse -Runs after Claude uses a tool. - -**Use cases:** -- Validate tool outputs -- Run additional checks (linting, formatting) -- Log tool usage - -### 3. Stop -Runs when Claude Code session ends. - -**Use cases:** -- Cleanup temporary files -- Generate session reports -- Commit changes automatically - -## Configuration - -Hooks are configured in `.claude/settings.json`: - -```json -{ - "hooks": { - "UserPromptSubmit": [ - { - "hooks": [ - { - "type": "command", - "command": "$CLAUDE_PROJECT_DIR/hooks/skill-activation-prompt.sh" - } - ] - } - ], - "PostToolUse": [ - { - "hooks": [ - { - "type": "command", - "command": "$CLAUDE_PROJECT_DIR/hooks/post-tool-check.sh" - } - ] - } - ] - } -} -``` - -## Creating Custom Hooks - -### Example: Pre-Commit Hook - -**File:** `hooks/pre-commit.sh` - -```bash -#!/bin/bash -set -e - -# Get staged files -STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM) - -# Run tests on Go files -GO_FILES=$(echo "$STAGED_FILES" | grep '\.go$' || true) -if [ -n "$GO_FILES" ]; then - go test ./... -short || exit 1 -fi - -# Validate JSON files -JSON_FILES=$(echo "$STAGED_FILES" | grep '\.json$' || true) -if [ -n "$JSON_FILES" ]; then - for file in $JSON_FILES; do - jq empty "$file" || exit 1 - done -fi - -echo "✅ Pre-commit checks passed" -``` - -**Register in settings.json:** - -```json -{ - "hooks": { - "PostToolUse": [ - { - "hooks": [ - { - "type": "command", - "command": "$CLAUDE_PROJECT_DIR/hooks/pre-commit.sh" - } - ] - } - ] - } -} -``` - -### Example: Auto-Format Hook - -**File:** `hooks/auto-format.sh` - -```bash -#!/bin/bash - -# Format Go files -find . -name "*.go" -exec gofmt -w {} \; - -# Format JSON files -find . -name "*.json" -exec jq --indent 2 . {} \; -exec mv {} {}.tmp \; -exec mv {}.tmp {} \; - -echo "✅ Files formatted" -``` - -## Environment Variables - -Hooks have access to: -- `$CLAUDE_PROJECT_DIR` - Project root directory -- `$PWD` - Current working directory -- All shell environment variables - -## Best Practices - -1. **Keep hooks fast** - Slow hooks block Claude Code -2. **Handle errors gracefully** - Return non-zero on failure -3. **Use absolute paths** - Reference `$CLAUDE_PROJECT_DIR` -4. **Make scripts executable** - `chmod +x hooks/script.sh` -5. **Test independently** - Run hooks manually first -6. **Document behavior** - Add comments explaining logic - -## Debugging Hooks - -Enable verbose logging: - -```bash -# Add to your hook -set -x # Print commands -set -e # Exit on error -``` - -Test manually: - -```bash -cd /path/to/project -./hooks/your-hook.sh -echo $? # Check exit code -``` - -## Built-in Hooks - -This repository includes: - -| Hook | File | Purpose | -|------|------|---------| -| Skill Activation | `skill-activation-prompt.sh` | Auto-suggest skills | -| Pre-commit | `pre-commit.sh` | Code quality checks | - -## Disabling Hooks - -Remove hook configuration from `.claude/settings.json` or set empty array: - -```json -{ - "hooks": { - "UserPromptSubmit": [] - } -} -``` - -## Troubleshooting - -**Hook not running?** -- Check `.claude/settings.json` syntax -- Verify script is executable: `ls -l hooks/` -- Check script path is correct - -**Hook failing silently?** -- Add `set -e` to script -- Check exit codes: `echo $?` -- Add logging: `echo "debug" >> /tmp/hook.log` - -## Further Reading - -- [Claude Code Hooks Documentation](https://docs.anthropic.com/claude-code/hooks) -- [Bash Scripting Guide](https://www.gnu.org/software/bash/manual/) diff --git a/docs/PLUGIN-SYSTEM.md b/docs/PLUGIN-SYSTEM.md deleted file mode 100644 index b6f04ab..0000000 --- a/docs/PLUGIN-SYSTEM.md +++ /dev/null @@ -1,348 +0,0 @@ -# Plugin System Guide - -> Native Claude Code plugin support for modular workflow installation - -## 🎯 Overview - -This repository provides 4 ready-to-use Claude Code plugins that can be installed individually or as a complete suite. - -## 📦 Available Plugins - -### 1. bmad-agile-workflow - -**Complete BMAD methodology with 6 specialized agents** - -**Commands**: -- `/bmad-pilot` - Full agile workflow orchestration - -**Agents**: -- `bmad-po` - Product Owner (Sarah) -- `bmad-architect` - System Architect (Winston) -- `bmad-sm` - Scrum Master (Mike) -- `bmad-dev` - Developer (Alex) -- `bmad-review` - Code Reviewer -- `bmad-qa` - QA Engineer (Emma) -- `bmad-orchestrator` - Main orchestrator - -**Use for**: Enterprise projects, complex features, full agile process - -### 2. requirements-driven-workflow - -**Streamlined requirements-to-code workflow** - -**Commands**: -- `/requirements-pilot` - Requirements-driven development flow - -**Agents**: -- `requirements-generate` - Requirements generation -- `requirements-code` - Code implementation -- `requirements-review` - Code review -- `requirements-testing` - Testing strategy - -**Use for**: Quick prototyping, simple features, rapid development - -### 3. development-essentials - -**Core development slash commands** - -**Commands**: -- `/code` - Direct implementation -- `/debug` - Systematic debugging -- `/test` - Testing strategy -- `/optimize` - Performance tuning -- `/bugfix` - Bug resolution -- `/refactor` - Code improvement -- `/review` - Code validation -- `/ask` - Technical consultation -- `/docs` - Documentation -- `/think` - Advanced analysis - -**Agents**: -- `code` - Code implementation -- `bugfix` - Bug fixing -- `debug` - Debugging -- `develop` - General development - -**Use for**: Daily coding tasks, quick implementations - -### 4. advanced-ai-agents - -**GPT-5 deep reasoning integration** - -**Commands**: None (agent-only) - -**Agents**: -- `gpt5` - Deep reasoning and analysis - -**Use for**: Complex architectural decisions, strategic planning - -## 🚀 Installation Methods - -### Method 1: Plugin Commands (Recommended) - -```bash -# List all available plugins -/plugin list - -# Get detailed information about a plugin -/plugin info bmad-agile-workflow - -# Install a specific plugin -/plugin install bmad-agile-workflow - -# Install all plugins -/plugin install bmad-agile-workflow -/plugin install requirements-driven-workflow -/plugin install development-essentials -/plugin install advanced-ai-agents - -# Remove an installed plugin -/plugin remove development-essentials -``` - -### Method 2: Repository Reference - -```bash -# Install from GitHub repository -/plugin marketplace add cexll/myclaude -``` - -This will present all available plugins from the repository. - -### Method 3: Make Commands - -For traditional installation or selective deployment: - -```bash -# Install everything -make install - -# Deploy specific workflows -make deploy-bmad # BMAD workflow only -make deploy-requirements # Requirements workflow only -make deploy-commands # All slash commands -make deploy-agents # All agents - -# Deploy everything -make deploy-all - -# View all options -make help -``` - -### Method 4: Manual Installation - -Copy files to Claude Code configuration directories: - -**Commands**: -```bash -cp bmad-agile-workflow/commands/*.md ~/.config/claude/commands/ -cp requirements-driven-workflow/commands/*.md ~/.config/claude/commands/ -cp development-essentials/commands/*.md ~/.config/claude/commands/ -``` - -**Agents**: -```bash -cp bmad-agile-workflow/agents/*.md ~/.config/claude/agents/ -cp requirements-driven-workflow/agents/*.md ~/.config/claude/agents/ -cp development-essentials/agents/*.md ~/.config/claude/agents/ -cp advanced-ai-agents/agents/*.md ~/.config/claude/agents/ -``` - -**Output Styles** (optional): -```bash -cp output-styles/*.md ~/.config/claude/output-styles/ -``` - -## 📋 Plugin Configuration - -Plugins are defined in `.claude-plugin/marketplace.json` following the Claude Code plugin specification. - -### Plugin Metadata Structure - -```json -{ - "name": "plugin-name", - "displayName": "Human Readable Name", - "description": "Plugin description", - "version": "1.0.0", - "author": "Author Name", - "category": "workflow|development|analysis", - "keywords": ["keyword1", "keyword2"], - "commands": ["command1", "command2"], - "agents": ["agent1", "agent2"] -} -``` - -## 🔧 Plugin Management - -### Check Installed Plugins - -```bash -/plugin list -``` - -Shows all installed plugins with their status. - -### Plugin Information - -```bash -/plugin info -``` - -Displays detailed information: -- Description -- Version -- Commands provided -- Agents included -- Author and keywords - -### Update Plugins - -Plugins are updated when you pull the latest repository changes: - -```bash -git pull origin main -make install -``` - -### Uninstall Plugins - -```bash -/plugin remove -``` - -Or manually remove files: - -```bash -# Remove commands -rm ~/.config/claude/commands/.md - -# Remove agents -rm ~/.config/claude/agents/.md -``` - -## 🎯 Plugin Selection Guide - -### Install Everything (Recommended for New Users) - -```bash -make install -``` - -Provides complete functionality with all workflows and commands. - -### Selective Installation - -**For Agile Teams**: -```bash -/plugin install bmad-agile-workflow -``` - -**For Rapid Development**: -```bash -/plugin install requirements-driven-workflow -/plugin install development-essentials -``` - -**For Individual Developers**: -```bash -/plugin install development-essentials -/plugin install advanced-ai-agents -``` - -**For Code Quality Focus**: -```bash -/plugin install development-essentials # Includes /review -/plugin install bmad-agile-workflow # Includes bmad-review -``` - -## 📁 Directory Structure - -``` -myclaude/ -├── .claude-plugin/ -│ └── marketplace.json # Plugin registry -├── bmad-agile-workflow/ -│ ├── commands/ -│ │ └── bmad-pilot.md -│ └── agents/ -│ ├── bmad-po.md -│ ├── bmad-architect.md -│ ├── bmad-sm.md -│ ├── bmad-dev.md -│ ├── bmad-review.md -│ ├── bmad-qa.md -│ └── bmad-orchestrator.md -├── requirements-driven-workflow/ -│ ├── commands/ -│ │ └── requirements-pilot.md -│ └── agents/ -│ ├── requirements-generate.md -│ ├── requirements-code.md -│ ├── requirements-review.md -│ └── requirements-testing.md -├── development-essentials/ -│ ├── commands/ -│ │ ├── code.md -│ │ ├── debug.md -│ │ ├── test.md -│ │ └── ... (more commands) -│ └── agents/ -│ ├── code.md -│ ├── bugfix.md -│ ├── debug.md -│ └── develop.md -├── advanced-ai-agents/ -│ └── agents/ -│ └── gpt5.md -└── output-styles/ - └── bmad-phase-context.md -``` - -## 🔄 Plugin Dependencies - -**No Dependencies**: All plugins work independently - -**Complementary Combinations**: -- BMAD + Advanced Agents (enhanced reviews) -- Requirements + Development Essentials (complete toolkit) -- All four plugins (full suite) - -## 🛠️ Makefile Reference - -```bash -# Installation -make install # Install all plugins -make deploy-all # Deploy all configurations - -# Selective Deployment -make deploy-bmad # BMAD workflow only -make deploy-requirements # Requirements workflow only -make deploy-commands # All slash commands only -make deploy-agents # All agents only - -# Testing -make test-bmad # Test BMAD workflow -make test-requirements # Test Requirements workflow - -# Cleanup -make clean # Remove generated artifacts -make help # Show all available commands -``` - -## 📚 Related Documentation - -- **[BMAD Workflow](BMAD-WORKFLOW.md)** - Complete BMAD guide -- **[Requirements Workflow](REQUIREMENTS-WORKFLOW.md)** - Lightweight workflow guide -- **[Development Commands](DEVELOPMENT-COMMANDS.md)** - Command reference -- **[Quick Start Guide](QUICK-START.md)** - Get started quickly - -## 🔗 External Resources - -- **[Claude Code Plugin Docs](https://docs.claude.com/en/docs/claude-code/plugins)** - Official plugin documentation -- **[Claude Code CLI](https://claude.ai/code)** - Claude Code interface - ---- - -**Modular Installation** - Install only what you need, when you need it. diff --git a/docs/QUICK-START.md b/docs/QUICK-START.md deleted file mode 100644 index 751696a..0000000 --- a/docs/QUICK-START.md +++ /dev/null @@ -1,326 +0,0 @@ -# Quick Start Guide - -> Get started with Claude Code Multi-Agent Workflow System in 5 minutes - -## 🚀 Installation (2 minutes) - -### Option 1: Plugin System (Fastest) - -```bash -# Install everything with one command -/plugin marketplace add cexll/myclaude -``` - -### Option 2: Make Install - -```bash -git clone https://github.com/cexll/myclaude.git -cd myclaude -make install -``` - -### Option 3: Selective Install - -```bash -# Install only what you need -/plugin install bmad-agile-workflow # Full agile workflow -/plugin install development-essentials # Daily coding commands -``` - -## 🎯 Your First Workflow (3 minutes) - -### Try BMAD Workflow - -Complete agile development automation: - -```bash -/bmad-pilot "Build a simple todo list API with CRUD operations" -``` - -**What happens**: -1. **Product Owner** generates requirements (PRD) -2. **Architect** designs system architecture -3. **Scrum Master** creates sprint plan -4. **Developer** implements code -5. **Reviewer** performs code review -6. **QA** runs tests - -All documents saved to `.claude/specs/todo-list-api/` - -### Try Requirements Workflow - -Fast prototyping: - -```bash -/requirements-pilot "Add user authentication to existing API" -``` - -**What happens**: -1. Generate functional requirements -2. Implement code -3. Review implementation -4. Create tests - -### Try Direct Commands - -Quick coding without workflow: - -```bash -# Implement a feature -/code "Add input validation for email fields" - -# Debug an issue -/debug "API returns 500 on missing parameters" - -# Add tests -/test "Create unit tests for validation logic" -``` - -## 📋 Common Use Cases - -### 1. New Feature Development - -**Complex Feature** (use BMAD): -```bash -/bmad-pilot "User authentication system with OAuth2, MFA, and role-based access control" -``` - -**Simple Feature** (use Requirements): -```bash -/requirements-pilot "Add pagination to user list endpoint" -``` - -**Tiny Feature** (use direct command): -```bash -/code "Add created_at timestamp to user model" -``` - -### 2. Bug Fixing - -**Complex Bug** (use debug): -```bash -/debug "Memory leak in background job processor" -``` - -**Simple Bug** (use bugfix): -```bash -/bugfix "Login button not working on mobile Safari" -``` - -### 3. Code Quality - -**Full Review**: -```bash -/review "Review authentication module for security issues" -``` - -**Refactoring**: -```bash -/refactor "Simplify user validation logic and remove duplication" -``` - -**Optimization**: -```bash -/optimize "Reduce database queries in dashboard API" -``` - -## 🎨 Workflow Selection Guide - -``` -┌─────────────────────────────────────────────────────────┐ -│ Choose Your Workflow │ -└─────────────────────────────────────────────────────────┘ - -Complex Business Feature + Architecture Needed - ↓ - 🏢 Use BMAD Workflow - /bmad-pilot "description" - • 6 specialized agents - • Quality gates (PRD ≥90, Design ≥90) - • Complete documentation - • Sprint planning included - -──────────────────────────────────────────────────────── - -Clear Requirements + Fast Iteration Needed - ↓ - ⚡ Use Requirements Workflow - /requirements-pilot "description" - • 4 phases: Requirements → Code → Review → Test - • Quality gate (Requirements ≥90) - • Minimal documentation - • Direct to implementation - -──────────────────────────────────────────────────────── - -Well-Defined Task + No Workflow Overhead - ↓ - 🔧 Use Direct Commands - /code | /debug | /test | /optimize - • Single-purpose commands - • Immediate execution - • No documentation overhead - • Perfect for daily tasks -``` - -## 💡 Tips for Success - -### 1. Be Specific - -**❌ Bad**: -```bash -/bmad-pilot "Build an app" -``` - -**✅ Good**: -```bash -/bmad-pilot "Build a task management API with user authentication, task CRUD, -task assignment, and real-time notifications via WebSocket" -``` - -### 2. Provide Context - -Include relevant technical details: -```bash -/code "Add Redis caching to user profile endpoint, cache TTL 5 minutes, -invalidate on profile update" -``` - -### 3. Engage with Agents - -During BMAD workflow, provide feedback at quality gates: - -``` -PO: "Here's the PRD (Score: 85/100)" -You: "Add mobile app support and offline mode requirements" -PO: "Updated PRD (Score: 94/100) ✅" -``` - -### 4. Review Generated Artifacts - -Check documents before confirming: -- `.claude/specs/{feature}/01-product-requirements.md` -- `.claude/specs/{feature}/02-system-architecture.md` -- `.claude/specs/{feature}/03-sprint-plan.md` - -### 5. Chain Commands for Complex Tasks - -Break down complex work: -```bash -/ask "Best approach for implementing real-time chat" -/bmad-pilot "Real-time chat system with message history and typing indicators" -/test "Add integration tests for chat message delivery" -/docs "Document chat API endpoints and WebSocket events" -``` - -## 🎓 Learning Path - -**Day 1**: Try direct commands -```bash -/code "simple task" -/test "add some tests" -/review "check my code" -``` - -**Day 2**: Try Requirements workflow -```bash -/requirements-pilot "small feature" -``` - -**Week 2**: Try BMAD workflow -```bash -/bmad-pilot "larger feature" -``` - -**Week 3**: Combine workflows -```bash -# Use BMAD for planning -/bmad-pilot "new module" --direct-dev - -# Use Requirements for sprint tasks -/requirements-pilot "individual task from sprint" - -# Use commands for daily work -/code "quick fix" -/test "add test" -``` - -## 📚 Next Steps - -### Explore Documentation - -- **[BMAD Workflow Guide](BMAD-WORKFLOW.md)** - Deep dive into full agile workflow -- **[Requirements Workflow Guide](REQUIREMENTS-WORKFLOW.md)** - Learn lightweight development -- **[Development Commands Reference](DEVELOPMENT-COMMANDS.md)** - All command details -- **[Plugin System Guide](PLUGIN-SYSTEM.md)** - Plugin management - -### Try Advanced Features - -**BMAD Options**: -```bash -# Skip testing for prototype -/bmad-pilot "prototype" --skip-tests - -# Skip sprint planning for quick dev -/bmad-pilot "feature" --direct-dev - -# Skip repo scan (if context exists) -/bmad-pilot "feature" --skip-scan -``` - -**Individual Agents**: -```bash -# Just requirements -/bmad-po "feature requirements" - -# Just architecture -/bmad-architect "system design" - -# Just orchestration -/bmad-orchestrator "complex project coordination" -``` - -### Check Quality - -Run tests and validation: -```bash -make test-bmad # Test BMAD workflow -make test-requirements # Test Requirements workflow -``` - -## 🆘 Troubleshooting - -**Commands not found**? -```bash -# Verify installation -/plugin list - -# Reinstall if needed -make install -``` - -**Agents not working**? -```bash -# Check agent configuration -ls ~/.config/claude/agents/ - -# Redeploy agents -make deploy-agents -``` - -**Output styles missing**? -```bash -# Deploy output styles -cp output-styles/*.md ~/.config/claude/output-styles/ -``` - -## 📞 Get Help - -- **Issues**: [GitHub Issues](https://github.com/cexll/myclaude/issues) -- **Documentation**: [docs/](.) -- **Examples**: Check `.claude/specs/` after running workflows -- **Make Help**: Run `make help` for all commands - ---- - -**You're ready!** Start with `/code "your first task"` and explore from there. diff --git a/hooks/hooks-config.json b/hooks/hooks-config.json deleted file mode 100644 index 85fd49d..0000000 --- a/hooks/hooks-config.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "UserPromptSubmit": [ - { - "hooks": [ - { - "type": "command", - "command": "$CLAUDE_PROJECT_DIR/hooks/skill-activation-prompt.sh" - } - ] - } - ] -} diff --git a/hooks/pre-commit.sh b/hooks/pre-commit.sh deleted file mode 100755 index 0336ac9..0000000 --- a/hooks/pre-commit.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/bash -# Example pre-commit hook -# This hook runs before git commit to validate code quality - -set -e - -# Get staged files -STAGED_FILES="$(git diff --cached --name-only --diff-filter=ACM)" - -if [ -z "$STAGED_FILES" ]; then - echo "No files to validate" - exit 0 -fi - -echo "Running pre-commit checks..." - -# Check Go files -GO_FILES="$(printf '%s\n' "$STAGED_FILES" | grep '\.go$' || true)" -if [ -n "$GO_FILES" ]; then - echo "Checking Go files..." - - if ! command -v gofmt &> /dev/null; then - echo "❌ gofmt not found. Please install Go (gofmt is included with the Go toolchain)." - exit 1 - fi - - # Format check - GO_FILE_ARGS=() - while IFS= read -r file; do - if [ -n "$file" ]; then - GO_FILE_ARGS+=("$file") - fi - done <<< "$GO_FILES" - - if [ "${#GO_FILE_ARGS[@]}" -gt 0 ]; then - UNFORMATTED="$(gofmt -l "${GO_FILE_ARGS[@]}")" - if [ -n "$UNFORMATTED" ]; then - echo "❌ The following files need formatting:" - echo "$UNFORMATTED" - echo "Run: gofmt -w " - exit 1 - fi - fi - - # Run tests - if command -v go &> /dev/null; then - echo "Running go tests..." - go test ./... -short || { - echo "❌ Tests failed" - exit 1 - } - fi -fi - -# Check JSON files -JSON_FILES="$(printf '%s\n' "$STAGED_FILES" | grep '\.json$' || true)" -if [ -n "$JSON_FILES" ]; then - echo "Validating JSON files..." - if ! command -v jq &> /dev/null; then - echo "❌ jq not found. Please install jq to validate JSON files." - exit 1 - fi - while IFS= read -r file; do - if [ -z "$file" ]; then - continue - fi - if ! jq empty "$file" 2>/dev/null; then - echo "❌ Invalid JSON: $file" - exit 1 - fi - done <<< "$JSON_FILES" -fi - -# Check Markdown files -MD_FILES="$(printf '%s\n' "$STAGED_FILES" | grep '\.md$' || true)" -if [ -n "$MD_FILES" ]; then - echo "Checking markdown files..." - # Add markdown linting if needed -fi - -echo "✅ All pre-commit checks passed" -exit 0 diff --git a/hooks/skill-activation-prompt.js b/hooks/skill-activation-prompt.js deleted file mode 100644 index 76d163f..0000000 --- a/hooks/skill-activation-prompt.js +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env node - -const fs = require("fs"); -const path = require("path"); - -function readInput() { - const raw = fs.readFileSync(0, "utf8").trim(); - if (!raw) return {}; - try { - return JSON.parse(raw); - } catch (_err) { - return {}; - } -} - -function extractPrompt(payload) { - return ( - payload.prompt || - payload.text || - payload.userPrompt || - (payload.data && payload.data.prompt) || - "" - ).toString(); -} - -function loadRules() { - const rulesPath = path.resolve(__dirname, "../skills/skill-rules.json"); - try { - const file = fs.readFileSync(rulesPath, "utf8"); - return JSON.parse(file); - } catch (_err) { - return { skills: {} }; - } -} - -function matchSkill(prompt, rule, skillName) { - const triggers = (rule && rule.promptTriggers) || {}; - const keywords = [...(triggers.keywords || []), skillName].filter(Boolean); - const patterns = triggers.intentPatterns || []; - const promptLower = prompt.toLowerCase(); - - const keyword = keywords.find((k) => promptLower.includes(k.toLowerCase())); - if (keyword) { - return `命中关键词 "${keyword}"`; - } - - for (const pattern of patterns) { - try { - if (new RegExp(pattern, "i").test(prompt)) { - return `命中模式 /${pattern}/`; - } - } catch (_err) { - continue; - } - } - return null; -} - -function main() { - const payload = readInput(); - const prompt = extractPrompt(payload); - if (!prompt.trim()) { - console.log(JSON.stringify({ suggestedSkills: [] }, null, 2)); - return; - } - - const rules = loadRules(); - const suggestions = []; - - for (const [name, rule] of Object.entries(rules.skills || {})) { - const matchReason = matchSkill(prompt, rule, name); - if (matchReason) { - suggestions.push({ - skill: name, - enforcement: rule.enforcement || "suggest", - priority: rule.priority || "normal", - reason: matchReason - }); - } - } - - console.log(JSON.stringify({ suggestedSkills: suggestions }, null, 2)); -} - -main(); diff --git a/hooks/skill-activation-prompt.sh b/hooks/skill-activation-prompt.sh deleted file mode 100755 index 2b50976..0000000 --- a/hooks/skill-activation-prompt.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -SCRIPT="$SCRIPT_DIR/skill-activation-prompt.js" - -if command -v node >/dev/null 2>&1; then - node "$SCRIPT" "$@" || true -else - echo '{"suggestedSkills":[],"meta":{"warning":"node not found"}}' -fi - -exit 0 diff --git a/hooks/test-skill-activation.sh b/hooks/test-skill-activation.sh deleted file mode 100755 index 72d86d2..0000000 --- a/hooks/test-skill-activation.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env bash - -# Simple test runner for skill-activation-prompt hook. -# Each case feeds JSON to the hook and validates suggested skills. - -set -uo pipefail - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -HOOK_SCRIPT="$SCRIPT_DIR/skill-activation-prompt.sh" - -parse_skills() { - node -e 'const data = JSON.parse(require("fs").readFileSync(0, "utf8")); const skills = (data.suggestedSkills || []).map(s => s.skill); console.log(skills.join(" "));' -} - -run_case() { - local name="$1" - local input="$2" - shift 2 - local expected=("$@") - - local output skills - output="$("$HOOK_SCRIPT" <<<"$input")" - skills="$(printf "%s" "$output" | parse_skills)" - - local pass=0 - if [[ ${#expected[@]} -eq 1 && ${expected[0]} == "none" ]]; then - [[ -z "$skills" ]] && pass=1 - else - pass=1 - for need in "${expected[@]}"; do - if [[ " $skills " != *" $need "* ]]; then - pass=0 - break - fi - done - fi - - if [[ $pass -eq 1 ]]; then - echo "PASS: $name" - else - echo "FAIL: $name" - echo " input: $input" - echo " expected skills: ${expected[*]}" - echo " actual skills: ${skills:-}" - return 1 - fi -} - -main() { - local status=0 - - run_case "keyword 'issue' => gh-workflow" \ - '{"prompt":"Please open an issue for this bug"}' \ - "gh-workflow" || status=1 - - run_case "keyword 'codex' => codex" \ - '{"prompt":"codex please handle this change"}' \ - "codex" || status=1 - - run_case "no matching keywords => none" \ - '{"prompt":"Just saying hello"}' \ - "none" || status=1 - - run_case "multiple keywords => codex & gh-workflow" \ - '{"prompt":"codex refactor then open an issue"}' \ - "codex" "gh-workflow" || status=1 - - if [[ $status -eq 0 ]]; then - echo "All tests passed." - else - echo "Some tests failed." - fi - - exit "$status" -} - -main "$@" diff --git a/install.py b/install.py index 291b148..00e6747 100644 --- a/install.py +++ b/install.py @@ -69,6 +69,11 @@ def parse_args(argv: Optional[Iterable[str]] = None) -> argparse.Namespace: action="store_true", help="Uninstall specified modules", ) + parser.add_argument( + "--update", + action="store_true", + help="Update already installed modules", + ) parser.add_argument( "--force", action="store_true", @@ -352,6 +357,19 @@ def check_module_installed(name: str, cfg: Dict[str, Any], ctx: Dict[str, Any]) target = (install_dir / op["target"]).expanduser().resolve() if target.exists(): return True + elif op_type == "merge_dir": + src = (ctx["config_dir"] / op["source"]).expanduser().resolve() + if not src.exists() or not src.is_dir(): + continue + for subdir in src.iterdir(): + if not subdir.is_dir(): + continue + for f in subdir.iterdir(): + if not f.is_file(): + continue + candidate = (install_dir / subdir.name / f.name).expanduser().resolve() + if candidate.exists(): + return True return False @@ -1063,6 +1081,74 @@ def main(argv: Optional[Iterable[str]] = None) -> int: print(f"\n✓ Uninstall complete") return 0 + # Handle --update + if getattr(args, "update", False): + try: + ensure_install_dir(ctx["install_dir"]) + except Exception as exc: + print(f"Failed to prepare install dir: {exc}", file=sys.stderr) + return 1 + + installed_status = get_installed_modules(config, ctx) + if args.module: + selected = select_modules(config, args.module) + modules = {k: v for k, v in selected.items() if installed_status.get(k, False)} + else: + modules = { + k: v + for k, v in config.get("modules", {}).items() + if installed_status.get(k, False) + } + + if not modules: + print("No installed modules to update.") + return 0 + + ctx["force"] = True + prepare_status_backup(ctx) + + total = len(modules) + print(f"Updating {total} module(s) in {ctx['install_dir']}...") + + results: List[Dict[str, Any]] = [] + for idx, (name, cfg) in enumerate(modules.items(), 1): + print(f"[{idx}/{total}] Updating module: {name}...") + try: + results.append(execute_module(name, cfg, ctx)) + print(f" ✓ {name} updated successfully") + except Exception as exc: # noqa: BLE001 + print(f" ✗ {name} failed: {exc}", file=sys.stderr) + rollback(ctx) + if not args.force: + return 1 + results.append( + { + "module": name, + "status": "failed", + "operations": [], + "installed_at": datetime.now().isoformat(), + } + ) + break + + current_status = load_installed_status(ctx) + for r in results: + if r.get("status") == "success": + current_status.setdefault("modules", {})[r["module"]] = r + current_status["updated_at"] = datetime.now().isoformat() + with Path(ctx["status_file"]).open("w", encoding="utf-8") as fh: + json.dump(current_status, fh, indent=2, ensure_ascii=False) + + success = sum(1 for r in results if r.get("status") == "success") + failed = len(results) - success + if failed == 0: + print(f"\n✓ Update complete: {success} module(s) updated") + else: + print(f"\n⚠ Update finished with errors: {success} success, {failed} failed") + if not args.force: + return 1 + return 0 + # No --module specified: enter interactive management mode if not args.module: try: diff --git a/install.sh b/install.sh index a189a3a..256b949 100644 --- a/install.sh +++ b/install.sh @@ -4,7 +4,7 @@ set -e if [ -z "${SKIP_WARNING:-}" ]; then echo "⚠️ WARNING: install.sh is LEGACY and will be removed in future versions." echo "Please use the new installation method:" - echo " python3 install.py --install-dir ~/.claude" + echo " npx github:cexll/myclaude" echo "" echo "Set SKIP_WARNING=1 to bypass this message" echo "Continuing with legacy installation in 5 seconds..." diff --git a/package.json b/package.json new file mode 100644 index 0000000..3de0388 --- /dev/null +++ b/package.json @@ -0,0 +1,26 @@ +{ + "name": "myclaude", + "version": "0.0.0", + "private": true, + "description": "Claude Code multi-agent workflows (npx installer)", + "license": "AGPL-3.0", + "bin": { + "myclaude": "bin/cli.js" + }, + "files": [ + "bin/", + ".claude-plugin/", + "agents/", + "skills/", + "memorys/", + "codeagent-wrapper/", + "config.json", + "install.py", + "install.sh", + "install.bat", + "PLUGIN_README.md", + "README.md", + "README_CN.md", + "LICENSE" + ] +} diff --git a/skills/README.md b/skills/README.md new file mode 100644 index 0000000..a45aff0 --- /dev/null +++ b/skills/README.md @@ -0,0 +1,23 @@ +# Skills + +This directory contains agent skills (each skill lives in its own folder with a `SKILL.md`). + +## Install with `npx` (recommended) + +List installable items: + +```bash +npx github:cexll/myclaude --list +``` + +Install (interactive; pick `skill:`): + +```bash +npx github:cexll/myclaude +``` + +Force overwrite / custom install directory: + +```bash +npx github:cexll/myclaude --install-dir ~/.claude --force +``` diff --git a/uninstall.sh b/uninstall.sh index 703475f..f1e33a8 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -28,7 +28,7 @@ Options: Examples: $0 --list # List installed modules $0 --dry-run # Preview what would be removed - $0 --module dev # Uninstall only 'dev' module + $0 --module do # Uninstall only 'do' module $0 -y # Uninstall all without confirmation $0 --purge -y # Remove everything (DANGEROUS) EOF