mirror of
https://github.com/cexll/myclaude.git
synced 2026-02-05 02:30:26 +08:00
feat(codeagent-wrapper): 完整多后端支持与安全优化
修复 PR #53 中发现的问题,实现完整的多后端功能: **多后端功能完整性** - Claude/Gemini 后端支持 workdir (-C) 和 resume (--session-id) 参数 - 并行模式支持全局 --backend 参数和任务级 backend 配置 - 后端参数映射统一,支持 new/resume 两种模式 **安全控制** - Claude 后端默认启用 --dangerously-skip-permissions 以支持自动化 - 通过 CODEAGENT_SKIP_PERMISSIONS 环境变量控制权限检查 - 不同后端行为区分:Claude 默认跳过,Codex/Gemini 默认启用 **并发控制** - 新增 CODEAGENT_MAX_PARALLEL_WORKERS 环境变量限制并发数 - 实现 fail-fast context 取消机制 - Worker pool 防止资源耗尽,支持并发监控日志 **向后兼容** - 版本号统一管理,提供 codex-wrapper 兼容脚本 - 所有默认行为保持不变 - 支持渐进式迁移 **测试覆盖** - 总体覆盖率 93.4%(超过 90% 要求) - 新增后端参数、并行模式、并发控制测试用例 - 核心模块覆盖率:backend.go 100%, config.go 97.8%, executor.go 96.4% **文档更新** - 更新 skills/codeagent/SKILL.md 反映多后端和安全控制 - 添加 CHANGELOG.md 记录重要变更 - 更新 README 版本说明和安装脚本 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@ description: Execute codeagent-wrapper for multi-backend AI code tasks. Supports
|
||||
|
||||
## Overview
|
||||
|
||||
Execute codeagent-wrapper commands with pluggable AI backends (Codex, Claude, Gemini). Supports file references via `@` syntax and parallel task execution.
|
||||
Execute codeagent-wrapper commands with pluggable AI backends (Codex, Claude, Gemini). Supports file references via `@` syntax, parallel task execution with backend selection, and configurable security controls.
|
||||
|
||||
## When to Use
|
||||
|
||||
@@ -49,7 +49,8 @@ codeagent-wrapper --backend gemini "simple task"
|
||||
|
||||
- `task` (required): Task description, supports `@file` references
|
||||
- `working_dir` (optional): Working directory (default: current)
|
||||
- `--backend` (optional): Select AI backend (codex/claude/gemini)
|
||||
- `--backend` (optional): Select AI backend (codex/claude/gemini, default: codex)
|
||||
- **Note**: Claude backend defaults to `--dangerously-skip-permissions` for automation compatibility
|
||||
|
||||
## Return Format
|
||||
|
||||
@@ -60,18 +61,25 @@ Agent response text here...
|
||||
SESSION_ID: 019a7247-ac9d-71f3-89e2-a823dbd8fd14
|
||||
```
|
||||
|
||||
## Resume Session
|
||||
## Resume Session
|
||||
|
||||
```bash
|
||||
# Resume with default backend
|
||||
codeagent-wrapper resume <session_id> - <<'EOF'
|
||||
<follow-up task>
|
||||
EOF
|
||||
|
||||
# Resume with specific backend
|
||||
codeagent-wrapper --backend claude resume <session_id> - <<'EOF'
|
||||
<follow-up task>
|
||||
EOF
|
||||
```
|
||||
|
||||
## Parallel Execution
|
||||
|
||||
**With global backend**:
|
||||
```bash
|
||||
codeagent-wrapper --parallel <<'EOF'
|
||||
codeagent-wrapper --parallel --backend claude <<'EOF'
|
||||
---TASK---
|
||||
id: task1
|
||||
workdir: /path/to/dir
|
||||
@@ -85,12 +93,44 @@ dependent task
|
||||
EOF
|
||||
```
|
||||
|
||||
**With per-task backend**:
|
||||
```bash
|
||||
codeagent-wrapper --parallel <<'EOF'
|
||||
---TASK---
|
||||
id: task1
|
||||
backend: codex
|
||||
workdir: /path/to/dir
|
||||
---CONTENT---
|
||||
analyze code structure
|
||||
---TASK---
|
||||
id: task2
|
||||
backend: claude
|
||||
dependencies: task1
|
||||
---CONTENT---
|
||||
design architecture based on analysis
|
||||
---TASK---
|
||||
id: task3
|
||||
backend: gemini
|
||||
dependencies: task2
|
||||
---CONTENT---
|
||||
generate implementation code
|
||||
EOF
|
||||
```
|
||||
|
||||
**Concurrency Control**:
|
||||
Set `CODEAGENT_MAX_PARALLEL_WORKERS` to limit concurrent tasks (default: unlimited).
|
||||
|
||||
## Environment Variables
|
||||
|
||||
- `CODEX_TIMEOUT`: Override timeout in milliseconds (default: 7200000)
|
||||
- `CODEX_TIMEOUT`: Override timeout in milliseconds (default: 7200000 = 2 hours)
|
||||
- `CODEAGENT_SKIP_PERMISSIONS`: Control permission checks
|
||||
- For **Claude** backend: Set to `true`/`1` to **disable** `--dangerously-skip-permissions` (default: enabled)
|
||||
- For **Codex/Gemini** backends: Set to `true`/`1` to enable permission skipping (default: disabled)
|
||||
- `CODEAGENT_MAX_PARALLEL_WORKERS`: Limit concurrent tasks in parallel mode (default: unlimited, recommended: 8)
|
||||
|
||||
## Invocation Pattern
|
||||
|
||||
**Single Task**:
|
||||
```
|
||||
Bash tool parameters:
|
||||
- command: codeagent-wrapper --backend <backend> - [working_dir] <<'EOF'
|
||||
@@ -99,3 +139,33 @@ Bash tool parameters:
|
||||
- timeout: 7200000
|
||||
- description: <brief description>
|
||||
```
|
||||
|
||||
**Parallel Tasks**:
|
||||
```
|
||||
Bash tool parameters:
|
||||
- command: codeagent-wrapper --parallel --backend <backend> <<'EOF'
|
||||
---TASK---
|
||||
id: task_id
|
||||
backend: <backend> # Optional, overrides global
|
||||
workdir: /path
|
||||
dependencies: dep1, dep2
|
||||
---CONTENT---
|
||||
task content
|
||||
EOF
|
||||
- timeout: 7200000
|
||||
- description: <brief description>
|
||||
```
|
||||
|
||||
## Security Best Practices
|
||||
|
||||
- **Claude Backend**: Defaults to `--dangerously-skip-permissions` for automation workflows
|
||||
- To enforce permission checks with Claude: Set `CODEAGENT_SKIP_PERMISSIONS=true`
|
||||
- **Codex/Gemini Backends**: Permission checks enabled by default
|
||||
- **Concurrency Limits**: Set `CODEAGENT_MAX_PARALLEL_WORKERS` in production to prevent resource exhaustion
|
||||
- **Automation Context**: This wrapper is designed for AI-driven automation where permission prompts would block execution
|
||||
|
||||
## Recent Updates
|
||||
|
||||
- Multi-backend support for all modes (workdir, resume, parallel)
|
||||
- Security controls with configurable permission checks
|
||||
- Concurrency limits with worker pool and fail-fast cancellation
|
||||
|
||||
Reference in New Issue
Block a user