mirror of
https://github.com/cexll/myclaude.git
synced 2026-02-14 03:31:58 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ba6950d21 | ||
|
|
7f790fbe15 | ||
|
|
06f14aa695 | ||
|
|
9fa872a1f0 |
@@ -363,6 +363,14 @@ func run() int {
|
|||||||
printHelp()
|
printHelp()
|
||||||
return 0
|
return 0
|
||||||
case "--parallel":
|
case "--parallel":
|
||||||
|
if len(os.Args) > 2 {
|
||||||
|
fmt.Fprintln(os.Stderr, "ERROR: --parallel reads its task configuration from stdin and does not accept additional arguments.")
|
||||||
|
fmt.Fprintln(os.Stderr, "Usage examples:")
|
||||||
|
fmt.Fprintln(os.Stderr, " codex-wrapper --parallel < tasks.txt")
|
||||||
|
fmt.Fprintln(os.Stderr, " echo '...' | codex-wrapper --parallel")
|
||||||
|
fmt.Fprintln(os.Stderr, " codex-wrapper --parallel <<'EOF'")
|
||||||
|
return 1
|
||||||
|
}
|
||||||
// Parallel mode: read task config from stdin
|
// Parallel mode: read task config from stdin
|
||||||
data, err := io.ReadAll(stdinReader)
|
data, err := io.ReadAll(stdinReader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -888,9 +896,15 @@ Usage:
|
|||||||
codex-wrapper - [workdir] Read task from stdin
|
codex-wrapper - [workdir] Read task from stdin
|
||||||
codex-wrapper resume <session_id> "task" [workdir]
|
codex-wrapper resume <session_id> "task" [workdir]
|
||||||
codex-wrapper resume <session_id> - [workdir]
|
codex-wrapper resume <session_id> - [workdir]
|
||||||
|
codex-wrapper --parallel Run tasks in parallel (config from stdin)
|
||||||
codex-wrapper --version
|
codex-wrapper --version
|
||||||
codex-wrapper --help
|
codex-wrapper --help
|
||||||
|
|
||||||
|
Parallel mode examples:
|
||||||
|
codex-wrapper --parallel < tasks.txt
|
||||||
|
echo '...' | codex-wrapper --parallel
|
||||||
|
codex-wrapper --parallel <<'EOF'
|
||||||
|
|
||||||
Environment Variables:
|
Environment Variables:
|
||||||
CODEX_TIMEOUT Timeout in milliseconds (default: 7200000)
|
CODEX_TIMEOUT Timeout in milliseconds (default: 7200000)
|
||||||
|
|
||||||
|
|||||||
@@ -180,26 +180,89 @@ EOF
|
|||||||
|
|
||||||
### Parallel Execution
|
### Parallel Execution
|
||||||
|
|
||||||
|
> Important:
|
||||||
|
> - `--parallel` only reads task definitions from stdin.
|
||||||
|
> - It does not accept extra command-line arguments (no inline `workdir`, `task`, or other params).
|
||||||
|
> - Put all task metadata and content in stdin; nothing belongs after `--parallel` on the command line.
|
||||||
|
|
||||||
|
**Correct vs Incorrect Usage**
|
||||||
|
|
||||||
|
**Correct:**
|
||||||
|
```bash
|
||||||
|
# Option 1: file redirection
|
||||||
|
codex-wrapper --parallel < tasks.txt
|
||||||
|
|
||||||
|
# Option 2: heredoc (recommended for multiple tasks)
|
||||||
|
codex-wrapper --parallel <<'EOF'
|
||||||
|
---TASK---
|
||||||
|
id: task1
|
||||||
|
workdir: /path/to/dir
|
||||||
|
---CONTENT---
|
||||||
|
task content
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Option 3: pipe
|
||||||
|
echo "---TASK---..." | codex-wrapper --parallel
|
||||||
|
```
|
||||||
|
|
||||||
|
**Incorrect (will trigger shell parsing errors):**
|
||||||
|
```bash
|
||||||
|
# Bad: no extra args allowed after --parallel
|
||||||
|
codex-wrapper --parallel - /path/to/dir <<'EOF'
|
||||||
|
...
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Bad: --parallel does not take a task argument
|
||||||
|
codex-wrapper --parallel "task description"
|
||||||
|
|
||||||
|
# Bad: workdir must live inside the task config
|
||||||
|
codex-wrapper --parallel /path/to/dir < tasks.txt
|
||||||
|
```
|
||||||
|
|
||||||
For multiple independent or dependent tasks, use `--parallel` mode with delimiter format:
|
For multiple independent or dependent tasks, use `--parallel` mode with delimiter format:
|
||||||
|
|
||||||
|
**Typical Workflow (analyze → implement → test, chained in a single parallel call)**:
|
||||||
```bash
|
```bash
|
||||||
codex-wrapper --parallel - <<'EOF'
|
codex-wrapper --parallel <<'EOF'
|
||||||
---TASK---
|
---TASK---
|
||||||
id: analyze_1732876800
|
id: analyze_1732876800
|
||||||
workdir: /home/user/project
|
workdir: /home/user/project
|
||||||
---CONTENT---
|
---CONTENT---
|
||||||
analyze requirements @spec.md
|
analyze @spec.md and summarize API and UI requirements
|
||||||
---TASK---
|
---TASK---
|
||||||
id: implement_1732876801
|
id: implement_1732876801
|
||||||
workdir: /home/user/project
|
workdir: /home/user/project
|
||||||
dependencies: analyze_1732876800
|
dependencies: analyze_1732876800
|
||||||
---CONTENT---
|
---CONTENT---
|
||||||
implement feature based on analyze_1732876800 analysis
|
implement features from analyze_1732876800 summary in backend @services and frontend @ui
|
||||||
---TASK---
|
---TASK---
|
||||||
id: docs_1732876802
|
id: test_1732876802
|
||||||
workdir: /home/user/project/docs
|
workdir: /home/user/project
|
||||||
|
dependencies: implement_1732876801
|
||||||
---CONTENT---
|
---CONTENT---
|
||||||
independent task runs in parallel with analyze_1732876800
|
add and run regression tests covering the new endpoints and UI flows
|
||||||
|
EOF
|
||||||
|
```
|
||||||
|
A single `codex-wrapper --parallel` call schedules all three stages concurrently, using `dependencies` to enforce sequential ordering without multiple invocations.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
codex-wrapper --parallel <<'EOF'
|
||||||
|
---TASK---
|
||||||
|
id: backend_1732876800
|
||||||
|
workdir: /home/user/project/backend
|
||||||
|
---CONTENT---
|
||||||
|
implement /api/orders endpoints with validation and pagination
|
||||||
|
---TASK---
|
||||||
|
id: frontend_1732876801
|
||||||
|
workdir: /home/user/project/frontend
|
||||||
|
---CONTENT---
|
||||||
|
build Orders page consuming /api/orders with loading/error states
|
||||||
|
---TASK---
|
||||||
|
id: tests_1732876802
|
||||||
|
workdir: /home/user/project/tests
|
||||||
|
dependencies: backend_1732876800, frontend_1732876801
|
||||||
|
---CONTENT---
|
||||||
|
run API contract tests and UI smoke tests (waits for backend+frontend)
|
||||||
EOF
|
EOF
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -211,15 +274,23 @@ EOF
|
|||||||
- `workdir: <path>`: Optional, working directory (default: `.`)
|
- `workdir: <path>`: Optional, working directory (default: `.`)
|
||||||
- Best practice: use absolute paths (e.g., `/home/user/project/backend`)
|
- Best practice: use absolute paths (e.g., `/home/user/project/backend`)
|
||||||
- Avoids ambiguity and ensures consistent behavior across environments
|
- Avoids ambiguity and ensures consistent behavior across environments
|
||||||
|
- Must be specified inside each task block; do not pass `workdir` as a CLI argument to `--parallel`
|
||||||
|
- Each task can set its own `workdir` when different directories are needed
|
||||||
- `dependencies: <id1>, <id2>`: Optional, comma-separated task IDs
|
- `dependencies: <id1>, <id2>`: Optional, comma-separated task IDs
|
||||||
- `session_id: <uuid>`: Optional, resume a previous session
|
- `session_id: <uuid>`: Optional, resume a previous session
|
||||||
- `---CONTENT---`: Separates metadata from task content
|
- `---CONTENT---`: Separates metadata from task content
|
||||||
- Task content: Any text, code, special characters (no escaping needed)
|
- Task content: Any text, code, special characters (no escaping needed)
|
||||||
|
|
||||||
|
**Dependencies Best Practices**
|
||||||
|
|
||||||
|
- Avoid multiple invocations: Place "analyze then implement" in a single `codex-wrapper --parallel` call, chaining them via `dependencies`, rather than running analysis first and then launching implementation separately.
|
||||||
|
- Naming convention: Use `<action>_<timestamp>` format (e.g., `analyze_1732876800`, `implement_1732876801`), where action names map to features/stages and timestamps ensure uniqueness and sortability.
|
||||||
|
- Dependency chain design: Keep chains short; only add dependencies for tasks that truly require ordering, let others run in parallel, avoiding over-serialization that reduces throughput.
|
||||||
|
|
||||||
**Resume Failed Tasks**:
|
**Resume Failed Tasks**:
|
||||||
```bash
|
```bash
|
||||||
# Use session_id from previous output to resume
|
# Use session_id from previous output to resume
|
||||||
codex-wrapper --parallel - <<'EOF'
|
codex-wrapper --parallel <<'EOF'
|
||||||
---TASK---
|
---TASK---
|
||||||
id: T2
|
id: T2
|
||||||
session_id: 019xxx-previous-session-id
|
session_id: 019xxx-previous-session-id
|
||||||
|
|||||||
Reference in New Issue
Block a user