Refactor CLI command usage from ccw cli exec to ccw cli -p for improved prompt handling

- Updated command patterns across documentation and templates to reflect the new CLI syntax.
- Enhanced CLI tool implementation to support reading prompts from files and multi-line inputs.
- Modified core components and views to ensure compatibility with the new command structure.
- Adjusted help messages and internationalization strings to align with the updated command format.
- Improved error handling and user notifications in the CLI execution flow.
This commit is contained in:
catlog22
2025-12-18 14:12:45 +08:00
parent e096fc98e2
commit 8dd4a513c8
52 changed files with 386 additions and 243 deletions

View File

@@ -470,14 +470,14 @@ function computeCliStrategy(task, allTasks) {
// Pattern: Gemini CLI deep analysis
{
"step": "gemini_analyze_[aspect]",
"command": "ccw cli exec 'PURPOSE: [goal]\\nTASK: [tasks]\\nMODE: analysis\\nCONTEXT: @[paths]\\nEXPECTED: [output]\\nRULES: $(cat [template]) | [constraints] | analysis=READ-ONLY' --tool gemini --mode analysis --cd [path]",
"command": "ccw cli -p 'PURPOSE: [goal]\\nTASK: [tasks]\\nMODE: analysis\\nCONTEXT: @[paths]\\nEXPECTED: [output]\\nRULES: $(cat [template]) | [constraints] | analysis=READ-ONLY' --tool gemini --mode analysis --cd [path]",
"output_to": "analysis_result"
},
// Pattern: Qwen CLI analysis (fallback/alternative)
{
"step": "qwen_analyze_[aspect]",
"command": "ccw cli exec '[similar to gemini pattern]' --tool qwen --mode analysis --cd [path]",
"command": "ccw cli -p '[similar to gemini pattern]' --tool qwen --mode analysis --cd [path]",
"output_to": "analysis_result"
},
@@ -518,7 +518,7 @@ The examples above demonstrate **patterns**, not fixed requirements. Agent MUST:
4. **Command Composition Patterns**:
- **Single command**: `bash([simple_search])`
- **Multiple commands**: `["bash([cmd1])", "bash([cmd2])"]`
- **CLI analysis**: `ccw cli exec '[prompt]' --tool gemini --mode analysis --cd [path]`
- **CLI analysis**: `ccw cli -p '[prompt]' --tool gemini --mode analysis --cd [path]`
- **MCP integration**: `mcp__[tool]__[function]([params])`
**Key Principle**: Examples show **structure patterns**, not specific implementations. Agent must create task-appropriate steps dynamically.
@@ -542,9 +542,9 @@ The `implementation_approach` supports **two execution modes** based on the pres
- **Use for**: Large-scale features, complex refactoring, or when user explicitly requests CLI tool usage
- **Required fields**: Same as default mode **PLUS** `command`, `resume_from` (optional)
- **Command patterns** (with resume support):
- `ccw cli exec '[prompt]' --tool codex --mode write --cd [path]`
- `ccw cli exec '[prompt]' --resume ${previousCliId} --tool codex --mode write` (resume from previous)
- `ccw cli exec '[prompt]' --tool gemini --mode write --cd [path]` (write mode)
- `ccw cli -p '[prompt]' --tool codex --mode write --cd [path]`
- `ccw cli -p '[prompt]' --resume ${previousCliId} --tool codex --mode write` (resume from previous)
- `ccw cli -p '[prompt]' --tool gemini --mode write --cd [path]` (write mode)
- **Resume mechanism**: When step depends on previous CLI execution, include `--resume` with previous execution ID
**Semantic CLI Tool Selection**:
@@ -621,7 +621,7 @@ Agent determines CLI tool usage per-step based on user semantics and task nature
"step": 3,
"title": "Execute implementation using CLI tool",
"description": "Use Codex/Gemini for complex autonomous execution",
"command": "ccw cli exec '[prompt]' --tool codex --mode write --cd [path]",
"command": "ccw cli -p '[prompt]' --tool codex --mode write --cd [path]",
"modification_points": ["[Same as default mode]"],
"logic_flow": ["[Same as default mode]"],
"depends_on": [1, 2],
@@ -634,7 +634,7 @@ Agent determines CLI tool usage per-step based on user semantics and task nature
"step": 4,
"title": "Continue implementation with context",
"description": "Resume from previous step with accumulated context",
"command": "ccw cli exec '[continuation prompt]' --resume ${step3_cli_id} --tool codex --mode write",
"command": "ccw cli -p '[continuation prompt]' --resume ${step3_cli_id} --tool codex --mode write",
"resume_from": "step3_cli_id", // Reference previous step's CLI ID
"modification_points": ["[Continue from step 3]"],
"logic_flow": ["[Build on previous output]"],

View File

@@ -148,7 +148,7 @@ discuss → multi (gemini + codex parallel)
**Gemini/Qwen (Analysis)**:
```bash
ccw cli exec "
ccw cli -p "
PURPOSE: {goal}
TASK: {task}
MODE: analysis
@@ -162,17 +162,17 @@ RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt)
**Gemini/Qwen (Write)**:
```bash
ccw cli exec "..." --tool gemini --mode write --cd {dir}
ccw cli -p "..." --tool gemini --mode write --cd {dir}
```
**Codex (Write)**:
```bash
ccw cli exec "..." --tool codex --mode write --cd {dir}
ccw cli -p "..." --tool codex --mode write --cd {dir}
```
**Cross-Directory** (Gemini/Qwen):
```bash
ccw cli exec "CONTEXT: @**/* @../shared/**/*" --tool gemini --mode analysis --cd src/auth --includeDirs ../shared
ccw cli -p "CONTEXT: @**/* @../shared/**/*" --tool gemini --mode analysis --cd src/auth --includeDirs ../shared
```
**Directory Scope**:

View File

@@ -78,7 +78,7 @@ rg "^import .* from " -n | head -30
### Gemini Semantic Analysis (deep-scan, dependency-map)
```bash
ccw cli exec "
ccw cli -p "
PURPOSE: {from prompt}
TASK: {from prompt}
MODE: analysis

View File

@@ -78,7 +78,7 @@ Phase 4: planObject Generation
## CLI Command Template
```bash
ccw cli exec "
ccw cli -p "
PURPOSE: Generate plan for {task_description}
TASK:
• Analyze task/bug description and context

View File

@@ -107,7 +107,7 @@ Phase 3: Task JSON Generation
**Template-Based Command Construction with Test Layer Awareness**:
```bash
ccw cli exec "
ccw cli -p "
PURPOSE: Analyze {test_type} test failures and generate fix strategy for iteration {iteration}
TASK:
• Review {failed_tests.length} {test_type} test failures: [{test_names}]
@@ -527,7 +527,7 @@ See: `.process/iteration-{iteration}-cli-output.txt`
1. **Detect test_type**: "integration" → Apply integration-specific diagnosis
2. **Execute CLI**:
```bash
ccw cli exec "PURPOSE: Analyze integration test failure...
ccw cli -p "PURPOSE: Analyze integration test failure...
TASK: Examine component interactions, data flow, interface contracts...
RULES: Analyze full call stack and data flow across components" --tool gemini --mode analysis
```

View File

@@ -123,7 +123,7 @@ When task JSON contains `flow_control.implementation_approach` array:
**CLI Command Execution (CLI Execute Mode)**:
When step contains `command` field with Codex CLI, execute via CCW CLI. For Codex resume:
- First task (`depends_on: []`): `ccw cli exec "..." --tool codex --mode write --cd [path]`
- First task (`depends_on: []`): `ccw cli -p "..." --tool codex --mode write --cd [path]`
- Subsequent tasks (has `depends_on`): Use CCW CLI with resume context to maintain session
**Test-Driven Development**:

View File

@@ -63,7 +63,7 @@ The agent supports **two execution modes** based on task JSON's `meta.cli_execut
- Agent substitutes [target_folders] into command
- Agent executes CLI command via CCW:
```bash
ccw cli exec "
ccw cli -p "
PURPOSE: Generate module documentation
TASK: Create API.md and README.md for each module
MODE: write
@@ -216,7 +216,7 @@ Before completion, verify:
{
"step": "analyze_module_structure",
"action": "Deep analysis of module structure and API",
"command": "ccw cli exec \"PURPOSE: Document module comprehensively\nTASK: Extract module purpose, architecture, public API, dependencies\nMODE: analysis\nCONTEXT: @**/* System: [system_context]\nEXPECTED: Complete module analysis for documentation\nRULES: $(cat ~/.claude/workflows/cli-templates/prompts/documentation/module-documentation.txt)\" --tool gemini --mode analysis --cd src/auth",
"command": "ccw cli -p \"PURPOSE: Document module comprehensively\nTASK: Extract module purpose, architecture, public API, dependencies\nMODE: analysis\nCONTEXT: @**/* System: [system_context]\nEXPECTED: Complete module analysis for documentation\nRULES: $(cat ~/.claude/workflows/cli-templates/prompts/documentation/module-documentation.txt)\" --tool gemini --mode analysis --cd src/auth",
"output_to": "module_analysis",
"on_error": "fail"
}