Files
Claude-Code-Workflow/.claude/workflows/tool-strategy.md
catlog22 e8f1caa219 feat: Enhance CLI components with icons and improve file editing capabilities
- Added icons to the CLI History and CLI Tools headers for better UI representation.
- Updated CLI Status component to include tool-specific classes for styling.
- Refactored CCW Install Panel to improve layout and functionality, including upgrade and uninstall buttons.
- Enhanced the edit-file tool with new features:
  - Support for creating parent directories when writing files.
  - Added dryRun mode for previewing changes without modifying files.
  - Implemented a unified diff output for changes made.
  - Enabled multi-edit support in update mode.
- Introduced a new Smart Search Tool with multiple search modes (auto, exact, fuzzy, semantic, graph) and intent classification.
- Created a Write File Tool to handle file creation and overwriting with backup options.
2025-12-11 23:06:47 +08:00

105 lines
2.8 KiB
Markdown

# Tool Strategy
## ⚡ Exa Triggering Mechanisms
**Auto-Trigger**:
- User mentions "exa-code" or code-related queries → `mcp__exa__get_code_context_exa`
- Need current web information → `mcp__exa__web_search_exa`
**Manual Trigger**:
- Complex API research → Exa Code Context
- Real-time information needs → Exa Web Search
## ⚡ CCW Tool Execution
### General Usage (JSON Parameters)
```bash
ccw tool exec <tool_name> '{"param": "value"}'
```
**Examples**:
```bash
ccw tool exec get_modules_by_depth '{}'
ccw tool exec classify_folders '{"path": "./src"}'
```
**Available Tools**: `ccw tool list`
### edit_file Tool
**When to Use**: Edit tool fails 1+ times on same file
```bash
# CLI shorthand
ccw tool exec edit_file --path "file.py" --old "old code" --new "new code"
# JSON (recommended)
ccw tool exec edit_file '{"path": "file.py", "oldText": "old", "newText": "new"}'
# dryRun - preview without modifying
ccw tool exec edit_file '{"path": "file.py", "oldText": "old", "newText": "new", "dryRun": true}'
# Multiple edits
ccw tool exec edit_file '{"path": "file.py", "edits": [{"oldText": "a", "newText": "b"}, {"oldText": "c", "newText": "d"}]}'
# Line mode
ccw tool exec edit_file '{"path": "file.py", "mode": "line", "operation": "insert_after", "line": 10, "text": "new"}'
```
**Parameters**: `path`*, `oldText`, `newText`, `edits[]`, `dryRun`, `replaceAll`, `mode` (update|line)
### write_file Tool
**When to Use**: Create new files or overwrite existing content
```bash
ccw tool exec write_file '{"path": "file.txt", "content": "Hello"}'
ccw tool exec write_file '{"path": "file.txt", "content": "new", "backup": true}'
```
**Parameters**: `path`*, `content`*, `createDirectories`, `backup`, `encoding`
### Fallback Strategy
1. **Edit fails 1+ times**`ccw tool exec edit_file`
2. **Still fails**`ccw tool exec write_file`
## ⚡ sed Line Operations (Line Mode Alternative)
**When to Use**: Precise line number control (insert, delete, replace specific lines)
### Common Operations
```bash
# Insert after line 10
sed -i '10a\new line content' file.txt
# Insert before line 5
sed -i '5i\new line content' file.txt
# Delete line 3
sed -i '3d' file.txt
# Delete lines 5-8
sed -i '5,8d' file.txt
# Replace line 3 content
sed -i '3c\replacement line' file.txt
# Replace lines 3-5 content
sed -i '3,5c\single replacement line' file.txt
```
### Operation Reference
| Operation | Command | Example |
|-----------|---------|---------|
| Insert after | `Na\text` | `sed -i '10a\new' file` |
| Insert before | `Ni\text` | `sed -i '5i\new' file` |
| Delete line | `Nd` | `sed -i '3d' file` |
| Delete range | `N,Md` | `sed -i '5,8d' file` |
| Replace line | `Nc\text` | `sed -i '3c\new' file` |
**Note**: Use `sed -i` for in-place file modification (works in Git Bash on Windows)