diff --git a/.claude/workflows/cli-tools-usage.md b/.claude/workflows/cli-tools-usage.md index b56b39d9..63b6bb3d 100644 --- a/.claude/workflows/cli-tools-usage.md +++ b/.claude/workflows/cli-tools-usage.md @@ -139,9 +139,7 @@ RULES: $(cat ~/.claude/workflows/cli-templates/protocols/write-protocol.md) $(ca - Recommended MODE: `analysis` (read-only) for analysis tasks, `write` for file creation - Priority: Prefer Gemini; use Qwen as fallback -**Models** (override via `--model`): -- Gemini: `gemini-2.5-pro` -- Qwen: `coder-model`, `vision-model` + **Error Handling**: HTTP 429 may show error but still return results - check if results exist @@ -154,19 +152,25 @@ RULES: $(cat ~/.claude/workflows/cli-templates/protocols/write-protocol.md) $(ca - Best for: Implementation, testing, automation, bug fixes - No default MODE - must explicitly specify `--mode analysis` or `--mode write` -**Models**: `gpt-5.2` ### Session Resume -**Resume via `--resume` parameter**: +**When to Use**: +- Multi-round planning (analysis → planning → implementation) +- Multi-model collaboration (Gemini → Codex on same topic) +- Topic continuity (building on previous findings) + +**Usage**: ```bash -ccw cli -p "Continue analyzing" --tool gemini --mode analysis --resume # Resume last session -ccw cli -p "Fix issues found" --tool codex --mode write --resume # Resume specific session +ccw cli -p "Continue analyzing" --tool gemini --mode analysis --resume # Resume last +ccw cli -p "Fix issues found" --tool codex --mode write --resume # Resume specific +ccw cli -p "Merge findings" --tool gemini --mode analysis --resume , # Merge multiple ``` -- **`--resume` (empty)**: Resume most recent session -- **`--resume `**: Resume specific execution ID +- **`--resume`**: Last session +- **`--resume `**: Specific session +- **`--resume ,`**: Merge sessions (comma-separated) **Context Assembly** (automatic): ``` @@ -223,7 +227,6 @@ Every command MUST include these fields: - Bad Example: (missing) - Good Example: "$(cat ~/.claude/workflows/cli-templates/protocols/analysis-protocol.md) $(cat ~/.claude/workflows/cli-templates/prompts/analysis/03-assess-security-risks.txt) \| Focus on authentication \| Ignore test files" - ### CONTEXT Configuration **Format**: `CONTEXT: [file patterns] | Memory: [memory context]` @@ -293,15 +296,6 @@ ccw cli -p 'RULES: $(cat ~/.claude/workflows/cli-templates/protocols/analysis-pr ccw cli -p "RULES: \$(cat ~/.claude/workflows/cli-templates/protocols/analysis-protocol.md) ..." --tool gemini ``` -**Examples**: -```bash -# Specific template (preferred) -RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/01-diagnose-bug-root-cause.txt) | Focus on auth | analysis=READ-ONLY - -# Universal fallback (when no specific template matches) -RULES: $(cat ~/.claude/workflows/cli-templates/prompts/universal/00-universal-rigorous-style.txt) | Focus on security patterns | analysis=READ-ONLY -``` - ### Template System **Base Path**: `~/.claude/workflows/cli-templates/prompts/` @@ -376,10 +370,6 @@ RULES: $(cat ~/.claude/workflows/cli-templates/prompts/universal/00-universal-ri - Description: Resume previous session - Default: - -- **`--no-stream`** - - Description: Disable streaming - - Default: false - ### Directory Configuration #### Working Directory (`--cd`) @@ -500,10 +490,6 @@ RULES: $(cat ~/.claude/workflows/cli-templates/protocols/write-protocol.md) $(ca **Codex Multiplier**: 3x allocated time (minimum 15min / 900000ms) -```bash -ccw cli -p "" --tool gemini --mode analysis --timeout 600000 # 10 min -ccw cli -p "" --tool codex --mode write --timeout 1800000 # 30 min -``` ### Permission Framework @@ -528,13 +514,6 @@ ccw cli -p "" --tool codex --mode write --timeout 1800000 # 30 min - **Discover patterns first** - Use rg/MCP before CLI execution - **Default to full context** - Use `@**/*` unless specific files needed -### Workflow Integration - -- **Understanding**: `ccw cli -p "" --tool gemini --mode analysis` -- **Architecture**: `ccw cli -p "" --tool gemini --mode analysis` -- **Implementation**: `ccw cli -p "" --tool codex --mode write` -- **Quality**: `ccw cli -p "" --tool codex --mode write` - ### Planning Checklist - [ ] **Purpose defined** - Clear goal and intent diff --git a/ccw/src/commands/cli.ts b/ccw/src/commands/cli.ts index 2603ea35..a9e44673 100644 --- a/ccw/src/commands/cli.ts +++ b/ccw/src/commands/cli.ts @@ -402,14 +402,16 @@ async function execAction(positionalPrompt: string | undefined, options: CliExec finalPrompt = positionalPrompt; } - if (!finalPrompt) { + // Prompt is required unless resuming + if (!finalPrompt && !resume) { console.error(chalk.red('Error: Prompt is required')); console.error(chalk.gray('Usage: ccw cli -p "" --tool gemini')); console.error(chalk.gray(' or: ccw cli -f prompt.txt --tool codex')); + console.error(chalk.gray(' or: ccw cli --resume --tool gemini')); process.exit(1); } - const prompt_to_use = finalPrompt; + const prompt_to_use = finalPrompt || ''; // Parse resume IDs for merge scenario const resumeIds = resume && typeof resume === 'string' ? resume.split(',').map(s => s.trim()).filter(Boolean) : []; @@ -679,14 +681,14 @@ export async function cliCommand( default: { const execOptions = options as CliExecOptions; - // Auto-exec if: has -p/--prompt, has --stdin, has --resume, or subcommand looks like a prompt + // Auto-exec if: has -p/--prompt, has -f/--file, has --resume, or subcommand looks like a prompt const hasPromptOption = !!execOptions.prompt; - const hasStdin = !!execOptions.stdin; + const hasFileOption = !!execOptions.file; const hasResume = execOptions.resume !== undefined; const subcommandIsPrompt = subcommand && !subcommand.startsWith('-'); - if (hasPromptOption || hasStdin || hasResume || subcommandIsPrompt) { - // Treat as exec: use subcommand as positional prompt if no -p option + if (hasPromptOption || hasFileOption || hasResume || subcommandIsPrompt) { + // Treat as exec: use subcommand as positional prompt if no -p/-f option const positionalPrompt = subcommandIsPrompt ? subcommand : undefined; await execAction(positionalPrompt, execOptions); } else { @@ -694,38 +696,32 @@ export async function cliCommand( console.log(chalk.bold.cyan('\n CCW CLI Tool Executor\n')); console.log(' Unified interface for Gemini, Qwen, and Codex CLI tools.\n'); console.log(' Usage:'); - console.log(chalk.gray(' ccw cli -p "" --tool Direct execution (recommended)')); - console.log(chalk.gray(' ccw cli "" --tool Shorthand')); - console.log(chalk.gray(' ccw cli exec "" --tool Explicit exec')); + console.log(chalk.gray(' ccw cli -p "" --tool Execute with prompt')); + console.log(chalk.gray(' ccw cli -f prompt.txt --tool Execute from file')); console.log(); console.log(' Subcommands:'); console.log(chalk.gray(' status Check CLI tools availability')); console.log(chalk.gray(' storage [cmd] Manage CCW storage (info/clean/config)')); - console.log(chalk.gray(' exec Execute a CLI tool (optional, default behavior)')); console.log(chalk.gray(' history Show execution history')); console.log(chalk.gray(' detail Show execution detail')); console.log(chalk.gray(' test-parse [args] Debug CLI argument parsing')); console.log(); - console.log(' Exec Options:'); - console.log(chalk.gray(' -p, --prompt Prompt text (preferred for multi-line)')); + console.log(' Options:'); + console.log(chalk.gray(' -p, --prompt Prompt text')); console.log(chalk.gray(' -f, --file Read prompt from file')); - console.log(chalk.gray(' --stdin Read prompt from stdin')); - console.log(chalk.gray(' --tool Tool to use: gemini, qwen, codex (default: gemini)')); + console.log(chalk.gray(' --tool Tool: gemini, qwen, codex (default: gemini)')); console.log(chalk.gray(' --mode Mode: analysis, write, auto (default: analysis)')); console.log(chalk.gray(' --model Model override')); console.log(chalk.gray(' --cd Working directory')); - console.log(chalk.gray(' --includeDirs Additional directories (comma-separated)')); - console.log(chalk.gray(' ccw cli -ps> Timeout in milliseconds (default: 300000)')); - console.log(chalk.gray(' --no-stream Disable streaming output')); + console.log(chalk.gray(' --includeDirs Additional directories')); + console.log(chalk.gray(' --timeout Timeout (default: 300000)')); console.log(chalk.gray(' --resume [id] Resume previous session')); - console.log(chalk.gray(' --id Custom execution ID')); console.log(); console.log(' Examples:'); console.log(chalk.gray(' ccw cli -p "Analyze auth module" --tool gemini')); - console.log(chalk.gray(' ccw cli "Simple prompt" --tool codex --mode write')); - console.log(chalk.gray(' ccw cli -p "$(cat prompt.txt)" --tool gemini')); + console.log(chalk.gray(' ccw cli -f prompt.txt --tool codex --mode write')); + console.log(chalk.gray(' ccw cli -p "$(cat template.md)" --tool gemini')); console.log(chalk.gray(' ccw cli --resume --tool gemini')); - console.log(chalk.gray(' ccw cli history --tool gemini --limit 10')); console.log(); } }