feat: 增加文件模式参考和复杂模式发现的示例,增强 CLI 命令的文档

This commit is contained in:
catlog22
2025-10-05 10:26:08 +08:00
parent 7d9adf5a55
commit a9d6de228e
7 changed files with 291 additions and 34 deletions

View File

@@ -18,18 +18,14 @@ allowed-tools: SlashCommand(*), Bash(*)
Execute implementation tasks with YOLO permissions (auto-approves all confirmations).
**Supported Tools**: codex, gemini (default), qwen
**Key Feature**: Automatic context inference and file pattern detection
## YOLO Permissions
## Core Concepts
### YOLO Permissions
Auto-approves: file pattern inference, execution, file modifications, summary generation
## Enhancement Integration
**When `--enhance` flag present** (Description Mode only): Execute `/enhance-prompt "[description]"` first, then use enhanced output (INTENT/CONTEXT/ACTION) for execution.
**Note**: Task ID Mode uses task JSON directly (no enhancement).
## Execution Modes
### Execution Modes
**1. Description Mode** (supports `--enhance`):
- Input: Natural language description
@@ -39,7 +35,7 @@ Auto-approves: file pattern inference, execution, file modifications, summary ge
- Input: Workflow task identifier (e.g., `IMPL-001`)
- Process: Task JSON parsing → Scope analysis → Execute
## Context Inference
### Context Inference
Auto-selects files based on:
- **Keywords**: "auth" → `@{**/*auth*,**/*user*}`
@@ -47,22 +43,42 @@ Auto-selects files based on:
- **Task Type**: "api" → `@{**/api/**/*,**/routes/**/*}`
- **Always**: `@{CLAUDE.md,**/*CLAUDE.md}`
## Options
### File Pattern Reference
- All files: `@{**/*}`
- Source files: `@{src/**/*}`
- TypeScript: `@{*.ts,*.tsx}`
- JavaScript: `@{*.js,*.jsx}`
- Python: `@{*.py}`
- Tests: `@{**/*.test.*,**/*.spec.*}`
- Config files: `@{*.config.*,**/config/**/*}`
- `--debug`: Verbose logging
- `--save-session`: Save execution to workflow session
### Complex Pattern Discovery
For precise file targeting, use semantic discovery BEFORE CLI execution:
## Workflow Integration
**Workflow**: Discover → Extract precise paths → Build CONTEXT field
**Session Management**: Auto-detects `.workflow/.active-*` marker
- **Active**: Save to `.workflow/WFS-[id]/.chat/execute-[timestamp].md`
- **None**: Create new session
```bash
# Step 1: Discover files semantically
rg "target_pattern" --files-with-matches --type ts
mcp__code-index__find_files(pattern="*auth*")
**Task Integration**: Load from `.task/[TASK-ID].json`, update status, generate summary
# Step 2: Build precise CONTEXT from discovery results
CONTEXT: @{src/auth/module.ts,src/middleware/auth.ts,CLAUDE.md}
## Command Template
# Step 3: Execute with precise file references
codex -C src --full-auto exec "
PURPOSE: Implement authentication
TASK: Add JWT validation
MODE: auto
CONTEXT: @{auth/module.ts,middleware/auth.ts,CLAUDE.md}
EXPECTED: Complete implementation
RULES: Follow security best practices
" --skip-git-repo-check -s danger-full-access
```
**Gemini/Qwen** (with YOLO approval):
## Command Templates
### Gemini/Qwen (with YOLO approval)
```bash
cd [dir] && ~/.claude/scripts/[gemini|qwen]-wrapper --approval-mode yolo -p "
PURPOSE: [implementation goal]
@@ -74,7 +90,7 @@ RULES: $(cat ~/.claude/workflows/cli-templates/prompts/[category]/[template].txt
"
```
**Codex**:
### Codex
```bash
codex -C [dir] --full-auto exec "
PURPOSE: [implementation goal]
@@ -89,21 +105,75 @@ RULES: [constraints]
codex -C [dir] -i design.png --full-auto exec "..." --skip-git-repo-check -s danger-full-access
```
## Examples
### Codex with Resume (for related tasks)
```bash
/cli:execute "implement JWT authentication with middleware" # Description mode
/cli:execute --enhance "implement JWT authentication" # Enhanced
/cli:execute IMPL-001 # Task ID mode
/cli:execute --tool codex "optimize database queries" # Codex execution
# First task - establish session
codex -C [dir] --full-auto exec "
PURPOSE: [implementation goal]
TASK: [specific task]
MODE: auto
CONTEXT: @{inferred_patterns} @{CLAUDE.md}
EXPECTED: Implementation with file:line references
RULES: [constraints]
" --skip-git-repo-check -s danger-full-access
# Related follow-up task - continue session
codex --full-auto exec "
PURPOSE: [continuation goal]
TASK: [related task]
MODE: auto
CONTEXT: Previous implementation from session
EXPECTED: Enhanced/extended implementation
RULES: Maintain consistency with previous work
" resume --last --skip-git-repo-check -s danger-full-access
```
## Auto-Generated Outputs
**Resume Decision**: Use `resume --last` when current task extends/relates to previous execution in conversation memory. See intelligent-tools-strategy.md for auto-resume rules.
## Enhancement Integration
**When `--enhance` flag present** (Description Mode only):
1. Execute `/enhance-prompt "[description]"` first
2. Use enhanced output (INTENT/CONTEXT/ACTION) for execution
3. Build command with enhanced context
**Note**: Task ID Mode uses task JSON directly (no enhancement).
## Options
- `--tool <codex|gemini|qwen>`: Select CLI tool (default: gemini)
- `--enhance`: Enhance input with `/enhance-prompt` first
- `--debug`: Verbose logging
- `--save-session`: Save execution to workflow session
## Workflow Integration
**Session Management**: Auto-detects `.workflow/.active-*` marker
- **Active**: Save to `.workflow/WFS-[id]/.chat/execute-[timestamp].md`
- **None**: Create new session
**Task Integration**: Load from `.task/[TASK-ID].json`, update status, generate summary
**Auto-Generated Outputs**:
- **Summary**: `.summaries/[TASK-ID]-summary.md`
- **Session**: `.chat/execute-[timestamp].md`
## Notes
## Examples
**vs. `/cli:analyze`**: Execute performs implementation, analyze is read-only.
```bash
# Description mode (default: gemini)
/cli:execute "implement JWT authentication with middleware"
# Enhanced prompt
/cli:execute --enhance "implement JWT authentication"
# Task ID mode
/cli:execute IMPL-001
# Codex execution
/cli:execute --tool codex "optimize database queries"
# Qwen with enhancement
/cli:execute --tool qwen --enhance "refactor auth module"
```