docs: 更新文档,增强CLI工具使用说明,明确命令行参数和上下文组装指南

This commit is contained in:
catlog22
2025-10-22 22:17:00 +08:00
parent 6fdcf9b8cc
commit d3f8d012a1
8 changed files with 89 additions and 10 deletions

View File

@@ -172,10 +172,18 @@ score = 0
"analyze" → "Code understanding and pattern identification"
```
**2. Context Assembly**:
```bash
# Default: comprehensive context
CONTEXT: @**/*
# Or specific patterns
CONTEXT: @CLAUDE.md @{discovered_file1} @{discovered_file2} ...
# Cross-directory references (requires --include-directories)
CONTEXT: @**/* @../shared/**/* @../types/**/*
## Discovered Context
- **Project Structure**: {module_summary}
- **Relevant Files**: {top_files_with_scores}
@@ -187,6 +195,12 @@ CONTEXT: @CLAUDE.md @{discovered_file1} @{discovered_file2} ...
{optional_best_practices_from_exa}
```
**Context Pattern Guidelines**:
- **Default**: Use `@**/*` for comprehensive context
- **Specific files**: `@src/**/*` or `@*.ts @*.tsx`
- **With docs**: `@CLAUDE.md @**/*CLAUDE.md`
- **Cross-directory**: Must use `--include-directories` parameter (see Command Construction)
**3. Template Selection**:
```
intent=analyze → ~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt
@@ -194,6 +208,14 @@ intent=execute + complex → ~/.claude/workflows/cli-templates/prompts/developme
intent=plan → ~/.claude/workflows/cli-templates/prompts/planning/task-breakdown.txt
```
**3a. RULES Field Guidelines**:
When using `$(cat ...)` for template loading:
- **Template reference only**: Use `$(cat ...)` directly, do NOT read template content first
- **NEVER use escape characters**: `\$`, `\"`, `\'` will break command substitution
- **Correct**: `RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt)`
- **Wrong**: `RULES: \$(cat ...)` or `RULES: $(cat \"...\")`
**4. Structured Prompt**:
```bash
PURPOSE: {enhanced_intent}
@@ -234,36 +256,91 @@ ELSE IF intent = 'discuss':
# User --tool flag overrides auto-selection
```
### Model Selection
**Gemini Models**:
- `gemini-2.5-pro` - Analysis tasks (default)
- `gemini-2.5-flash` - Documentation updates
**Qwen Models**:
- `coder-model` - Code analysis (default, -m optional)
- `vision-model` - Image analysis (rare usage)
**Codex Models**:
- `gpt-5` - Analysis & execution (default)
- `gpt5-codex` - Large context tasks
**Parameter Position**: `-m` must be placed AFTER prompt string
### Command Construction
**Gemini/Qwen (Analysis Mode)**:
```bash
cd {directory} && ~/.claude/scripts/{tool}-wrapper -p "
# Use 'gemini' (primary) or 'qwen' (fallback)
cd {directory} && gemini -p "
{enhanced_prompt}
"
# With model selection (NOTE: -m placed AFTER prompt)
cd {directory} && gemini -p "{enhanced_prompt}" -m gemini-2.5-pro
cd {directory} && qwen -p "{enhanced_prompt}" # coder-model default
```
**Gemini/Qwen (Write Mode)**:
```bash
cd {directory} && ~/.claude/scripts/{tool}-wrapper --approval-mode yolo -p "
# NOTE: --approval-mode yolo must be placed AFTER the prompt
cd {directory} && gemini -p "
{enhanced_prompt}
"
" -m gemini-2.5-flash --approval-mode yolo
# Fallback to Qwen
cd {directory} && qwen -p "{enhanced_prompt}" --approval-mode yolo
```
**Codex (Auto Mode)**:
```bash
# NOTE: -m, --skip-git-repo-check and -s danger-full-access must be placed at command END
codex -C {directory} --full-auto exec "
{enhanced_prompt}
" --skip-git-repo-check -s danger-full-access
" -m gpt-5 --skip-git-repo-check -s danger-full-access
```
**Codex (Resume for Related Tasks)**:
```bash
# Parameter Position: resume --last must be placed AFTER prompt at command END
codex --full-auto exec "
{continuation_prompt}
" resume --last --skip-git-repo-check -s danger-full-access
```
**Cross-Directory Context (Gemini/Qwen)**:
```bash
# When CONTEXT references external directories, use --include-directories
# TWO-STEP REQUIREMENT:
# Step 1: Reference in CONTEXT (@../shared/**/*)
# Step 2: Add --include-directories parameter
cd src/auth && gemini -p "
PURPOSE: {goal}
CONTEXT: @**/* @../shared/**/* @../types/**/*
...
" --include-directories ../shared,../types
```
### Directory Scope Rules
**Once `cd` to a directory**:
- **@ references ONLY apply to current directory and its subdirectories**
- `@**/*` = All files within current directory tree
- `@*.ts` = TypeScript files in current directory tree
- `@src/**/*` = Files within src subdirectory (if exists)
- **CANNOT reference parent or sibling directories via @ alone**
**To reference files outside current directory**:
- **Step 1**: Add `--include-directories` parameter
- **Step 2**: Explicitly reference in CONTEXT field with @ patterns
- **⚠️ BOTH steps are MANDATORY**
- **Rule**: If CONTEXT contains `@../dir/**/*`, command MUST include `--include-directories ../dir`
### Timeout Configuration
```javascript

View File

@@ -364,7 +364,8 @@ bash(
if [[ "$tool" == "codex" ]]; then
echo "codex -C \${dir} --full-auto exec \"...\" --skip-git-repo-check -s danger-full-access"
else
echo "bash(cd \${dir} && ~/.claude/scripts/${tool}-wrapper ${approval_flag} -p \"...\")"
echo "bash(cd \${dir} && ${tool} ${approval_flag} -p \"...\")"
# Direct CLI commands for gemini/qwen
fi
)
```

View File

@@ -136,7 +136,7 @@ Task(
Execute Gemini/Qwen CLI for deep analysis (saves main thread tokens):
\`\`\`bash
cd . && ~/.claude/scripts/${tool}-wrapper -p "
cd . && ${tool} -p "
PURPOSE: Extract project core context for task: ${task_description}
TASK: Analyze project architecture, tech stack, key patterns, relevant files
MODE: analysis

View File

@@ -250,7 +250,7 @@ TOOLS (try in order): {{tool_1}}, {{tool_2}}, {{tool_3}}
EXECUTION SCRIPT: ~/.claude/scripts/update_module_claude.sh
- Accepts strategy parameter: multi-layer | single-layer
- Tool execution via CLI wrapper (gemini/qwen/codex)
- Tool execution via direct CLI commands (gemini/qwen/codex)
EXECUTION FLOW (for each module):
1. Tool fallback loop (exit on first success):

View File

@@ -237,7 +237,7 @@ Final Score: Max(0, Base Score - Deductions)
### Command Chain
- **Called After**: `/workflow:execute` (when TDD tasks completed)
- **Calls**: `/workflow:tools:tdd-coverage-analysis`, Gemini wrapper
- **Calls**: `/workflow:tools:tdd-coverage-analysis`, Gemini CLI
- **Related**: `/workflow:tdd-plan`, `/workflow:status`
### Basic Usage

View File

@@ -219,7 +219,7 @@ Iteration N (managed by test-cycle-execute orchestrator):
#### When Test Failures Occur
1. **[Orchestrator]** Detects failures from agent output
2. **[Orchestrator]** Collects failure context from `.process/test-results.json` and logs
3. **[Orchestrator]** Runs Gemini/Qwen wrapper with failure context
3. **[Orchestrator]** Runs Gemini/Qwen CLI with failure context
4. **[CLI Tool]** Analyzes failures and generates fix strategy
5. **[Orchestrator]** Saves analysis to `.process/iteration-N-analysis.md`
6. **[Orchestrator]** Generates `IMPL-fix-N.json` with strategy content (not just path)

View File

@@ -452,7 +452,7 @@ Update workflow-session.json with TDD metadata:
### Command Chain
- **Called By**: `/workflow:tdd-plan` (Phase 4)
- **Calls**: Gemini wrapper for TDD breakdown
- **Calls**: Gemini CLI for TDD breakdown
- **Followed By**: `/workflow:execute`, `/workflow:tdd-verify`
### Basic Usage

View File

@@ -72,6 +72,7 @@ For all CLI tool usage, command syntax, and integration guidelines:
## Platform-Specific Guidelines
### Windows Path Format Guidelines
- always use complete absolute Windows paths with drive letters and backslashes for ALL file operations
- **MCP Tools**: Use double backslash `D:\\path\\file.txt` (MCP doesn't support POSIX `/d/path`)
- **Bash Commands**: Use forward slash `D:/path/file.txt` or POSIX `/d/path/file.txt`
- **Relative Paths**: No conversion needed `./src`, `../config`