mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-12 02:37:45 +08:00
feat: add --mode review support for codex CLI
- Add 'review' to mode enum in ParamsSchema and schema - Implement codex review subcommand in buildCommand (uses --uncommitted by default) - Other tools (gemini/qwen/claude) accept review mode but no operation change - Update cli-tools-usage.md with review mode documentation
This commit is contained in:
@@ -85,11 +85,14 @@ Tools are selected based on **tags** defined in the configuration. Use tags to m
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Explicit tool selection
|
# Explicit tool selection
|
||||||
ccw cli -p "<PROMPT>" --tool <tool-id> --mode <analysis|write>
|
ccw cli -p "<PROMPT>" --tool <tool-id> --mode <analysis|write|review>
|
||||||
|
|
||||||
# Model override
|
# Model override
|
||||||
ccw cli -p "<PROMPT>" --tool <tool-id> --model <model-id> --mode <analysis|write>
|
ccw cli -p "<PROMPT>" --tool <tool-id> --model <model-id> --mode <analysis|write>
|
||||||
|
|
||||||
|
# Code review (codex only)
|
||||||
|
ccw cli -p "<PROMPT>" --tool codex --mode review
|
||||||
|
|
||||||
# Tag-based auto-selection (future)
|
# Tag-based auto-selection (future)
|
||||||
ccw cli -p "<PROMPT>" --tags <tag1,tag2> --mode <analysis|write>
|
ccw cli -p "<PROMPT>" --tags <tag1,tag2> --mode <analysis|write>
|
||||||
```
|
```
|
||||||
@@ -330,6 +333,14 @@ RULES: $(cat ~/.claude/workflows/cli-templates/protocols/write-protocol.md) $(ca
|
|||||||
- Use For: Feature implementation, bug fixes, documentation, code creation, file modifications
|
- Use For: Feature implementation, bug fixes, documentation, code creation, file modifications
|
||||||
- Specification: Requires explicit `--mode write`
|
- Specification: Requires explicit `--mode write`
|
||||||
|
|
||||||
|
- **`review`**
|
||||||
|
- Permission: Read-only (code review output)
|
||||||
|
- Use For: Git-aware code review of uncommitted changes, branch diffs, specific commits
|
||||||
|
- Specification: **codex only** - uses `codex review` subcommand with `--uncommitted` by default
|
||||||
|
- Tool Behavior:
|
||||||
|
- `codex`: Executes `codex review --uncommitted [prompt]` for structured code review
|
||||||
|
- Other tools (gemini/qwen/claude): Accept mode but no operation change (treated as analysis)
|
||||||
|
|
||||||
### Command Options
|
### Command Options
|
||||||
|
|
||||||
- **`--tool <tool>`**
|
- **`--tool <tool>`**
|
||||||
@@ -337,8 +348,9 @@ RULES: $(cat ~/.claude/workflows/cli-templates/protocols/write-protocol.md) $(ca
|
|||||||
- Default: First enabled tool in config
|
- Default: First enabled tool in config
|
||||||
|
|
||||||
- **`--mode <mode>`**
|
- **`--mode <mode>`**
|
||||||
- Description: **REQUIRED**: analysis, write
|
- Description: **REQUIRED**: analysis, write, review
|
||||||
- Default: **NONE** (must specify)
|
- Default: **NONE** (must specify)
|
||||||
|
- Note: `review` mode triggers `codex review` subcommand for codex tool only
|
||||||
|
|
||||||
- **`--model <model>`**
|
- **`--model <model>`**
|
||||||
- Description: Model override
|
- Description: Model override
|
||||||
@@ -463,6 +475,17 @@ RULES: $(cat ~/.claude/workflows/cli-templates/protocols/write-protocol.md) $(ca
|
|||||||
" --tool <tool-id> --mode write
|
" --tool <tool-id> --mode write
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Code Review Task** (codex review mode):
|
||||||
|
```bash
|
||||||
|
# Review uncommitted changes (default)
|
||||||
|
ccw cli -p "Focus on security vulnerabilities and error handling" --tool codex --mode review
|
||||||
|
|
||||||
|
# Review with custom instructions
|
||||||
|
ccw cli -p "Check for breaking changes in API contracts and backward compatibility" --tool codex --mode review
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Note**: `--mode review` only triggers special behavior for `codex` tool (uses `codex review --uncommitted`). Other tools accept the mode but execute as standard analysis.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Permission Framework
|
### Permission Framework
|
||||||
@@ -472,6 +495,7 @@ RULES: $(cat ~/.claude/workflows/cli-templates/protocols/write-protocol.md) $(ca
|
|||||||
**Mode Hierarchy**:
|
**Mode Hierarchy**:
|
||||||
- `analysis`: Read-only, safe for auto-execution
|
- `analysis`: Read-only, safe for auto-execution
|
||||||
- `write`: Create/Modify/Delete files, full operations - requires explicit `--mode write`
|
- `write`: Create/Modify/Delete files, full operations - requires explicit `--mode write`
|
||||||
|
- `review`: Git-aware code review (codex only), read-only output - requires explicit `--mode review`
|
||||||
- **Exception**: User provides clear instructions like "modify", "create", "implement"
|
- **Exception**: User provides clear instructions like "modify", "create", "implement"
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -502,7 +526,7 @@ RULES: $(cat ~/.claude/workflows/cli-templates/protocols/write-protocol.md) $(ca
|
|||||||
### Planning Checklist
|
### Planning Checklist
|
||||||
|
|
||||||
- [ ] **Purpose defined** - Clear goal and intent
|
- [ ] **Purpose defined** - Clear goal and intent
|
||||||
- [ ] **Mode selected** - `--mode analysis|write`
|
- [ ] **Mode selected** - `--mode analysis|write|review`
|
||||||
- [ ] **Context gathered** - File references + memory (default `@**/*`)
|
- [ ] **Context gathered** - File references + memory (default `@**/*`)
|
||||||
- [ ] **Directory navigation** - `--cd` and/or `--includeDirs`
|
- [ ] **Directory navigation** - `--cd` and/or `--includeDirs`
|
||||||
- [ ] **Tool selected** - Explicit `--tool` or tag-based auto-selection
|
- [ ] **Tool selected** - Explicit `--tool` or tag-based auto-selection
|
||||||
@@ -514,5 +538,5 @@ RULES: $(cat ~/.claude/workflows/cli-templates/protocols/write-protocol.md) $(ca
|
|||||||
1. **Load configuration** - Read `cli-tools.json` for available tools
|
1. **Load configuration** - Read `cli-tools.json` for available tools
|
||||||
2. **Match by tags** - Select tool based on task requirements
|
2. **Match by tags** - Select tool based on task requirements
|
||||||
3. **Validate enabled** - Ensure selected tool is enabled
|
3. **Validate enabled** - Ensure selected tool is enabled
|
||||||
4. **Execute with mode** - Always specify `--mode analysis|write`
|
4. **Execute with mode** - Always specify `--mode analysis|write|review`
|
||||||
5. **Fallback gracefully** - Use secondary model or next matching tool on failure
|
5. **Fallback gracefully** - Use secondary model or next matching tool on failure
|
||||||
|
|||||||
@@ -1216,7 +1216,7 @@ export async function cliCommand(
|
|||||||
console.log(chalk.gray(' -f, --file <file> Read prompt from file (recommended for multi-line prompts)'));
|
console.log(chalk.gray(' -f, --file <file> Read prompt from file (recommended for multi-line prompts)'));
|
||||||
console.log(chalk.gray(' -p, --prompt <text> Prompt text (single-line)'));
|
console.log(chalk.gray(' -p, --prompt <text> Prompt text (single-line)'));
|
||||||
console.log(chalk.gray(' --tool <tool> Tool: gemini, qwen, codex (default: gemini)'));
|
console.log(chalk.gray(' --tool <tool> Tool: gemini, qwen, codex (default: gemini)'));
|
||||||
console.log(chalk.gray(' --mode <mode> Mode: analysis, write, auto (default: analysis)'));
|
console.log(chalk.gray(' --mode <mode> Mode: analysis, write, auto, review (default: analysis)'));
|
||||||
console.log(chalk.gray(' -d, --debug Enable debug logging for troubleshooting'));
|
console.log(chalk.gray(' -d, --debug Enable debug logging for troubleshooting'));
|
||||||
console.log(chalk.gray(' --model <model> Model override'));
|
console.log(chalk.gray(' --model <model> Model override'));
|
||||||
console.log(chalk.gray(' --cd <path> Working directory'));
|
console.log(chalk.gray(' --cd <path> Working directory'));
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ interface ClaudeWithSettingsParams {
|
|||||||
prompt: string;
|
prompt: string;
|
||||||
settingsPath: string;
|
settingsPath: string;
|
||||||
endpointId: string;
|
endpointId: string;
|
||||||
mode: 'analysis' | 'write' | 'auto';
|
mode: 'analysis' | 'write' | 'auto' | 'review';
|
||||||
workingDir: string;
|
workingDir: string;
|
||||||
cd?: string;
|
cd?: string;
|
||||||
includeDirs?: string[];
|
includeDirs?: string[];
|
||||||
@@ -351,7 +351,7 @@ type BuiltinCliTool = typeof BUILTIN_CLI_TOOLS[number];
|
|||||||
const ParamsSchema = z.object({
|
const ParamsSchema = z.object({
|
||||||
tool: z.string().min(1, 'Tool is required'), // Accept any tool ID (built-in or custom endpoint)
|
tool: z.string().min(1, 'Tool is required'), // Accept any tool ID (built-in or custom endpoint)
|
||||||
prompt: z.string().min(1, 'Prompt is required'),
|
prompt: z.string().min(1, 'Prompt is required'),
|
||||||
mode: z.enum(['analysis', 'write', 'auto']).default('analysis'),
|
mode: z.enum(['analysis', 'write', 'auto', 'review']).default('analysis'),
|
||||||
format: z.enum(['plain', 'yaml', 'json']).default('plain'), // Multi-turn prompt concatenation format
|
format: z.enum(['plain', 'yaml', 'json']).default('plain'), // Multi-turn prompt concatenation format
|
||||||
model: z.string().optional(),
|
model: z.string().optional(),
|
||||||
cd: z.string().optional(),
|
cd: z.string().optional(),
|
||||||
@@ -1176,7 +1176,8 @@ export const schema: ToolSchema = {
|
|||||||
Modes:
|
Modes:
|
||||||
- analysis: Read-only operations (default)
|
- analysis: Read-only operations (default)
|
||||||
- write: File modifications allowed
|
- write: File modifications allowed
|
||||||
- auto: Full autonomous operations (codex only)`,
|
- auto: Full autonomous operations (codex only)
|
||||||
|
- review: Code review mode (codex uses 'codex review' subcommand, others accept but no operation change)`,
|
||||||
inputSchema: {
|
inputSchema: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
@@ -1191,8 +1192,8 @@ Modes:
|
|||||||
},
|
},
|
||||||
mode: {
|
mode: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
enum: ['analysis', 'write', 'auto'],
|
enum: ['analysis', 'write', 'auto', 'review'],
|
||||||
description: 'Execution mode (default: analysis)',
|
description: 'Execution mode (default: analysis). review mode uses codex review subcommand for codex tool.',
|
||||||
default: 'analysis'
|
default: 'analysis'
|
||||||
},
|
},
|
||||||
model: {
|
model: {
|
||||||
|
|||||||
@@ -223,7 +223,21 @@ export function buildCommand(params: {
|
|||||||
|
|
||||||
case 'codex':
|
case 'codex':
|
||||||
useStdin = true;
|
useStdin = true;
|
||||||
if (nativeResume?.enabled) {
|
if (mode === 'review') {
|
||||||
|
// codex review mode: non-interactive code review
|
||||||
|
// Format: codex review [OPTIONS] [PROMPT]
|
||||||
|
args.push('review');
|
||||||
|
// Default to --uncommitted if no specific review target in prompt
|
||||||
|
args.push('--uncommitted');
|
||||||
|
if (model) {
|
||||||
|
args.push('-m', model);
|
||||||
|
}
|
||||||
|
// codex review uses positional prompt argument, not stdin
|
||||||
|
useStdin = false;
|
||||||
|
if (prompt) {
|
||||||
|
args.push(prompt);
|
||||||
|
}
|
||||||
|
} else if (nativeResume?.enabled) {
|
||||||
args.push('resume');
|
args.push('resume');
|
||||||
if (nativeResume.isLatest) {
|
if (nativeResume.isLatest) {
|
||||||
args.push('--last');
|
args.push('--last');
|
||||||
|
|||||||
Reference in New Issue
Block a user