mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-11 02:33:51 +08:00
feat: Add CCW MCP server and tools integration
- Introduced `ccw-mcp` command for running CCW tools as an MCP server. - Updated `package.json` to include new MCP dependencies and scripts. - Enhanced CLI with new options for `codex_lens` tool. - Implemented MCP server logic to expose CCW tools via Model Context Protocol. - Added new tools and updated existing ones for better functionality and documentation. - Created quick start and full documentation for MCP server usage. - Added tests for MCP server functionality to ensure reliability.
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
# Development Guidelines
|
||||
|
||||
## Overview
|
||||
|
||||
This document defines project-specific coding standards and development principles.
|
||||
### CLI Tool Context Protocols
|
||||
For all CLI tool usage, command syntax, and integration guidelines:
|
||||
### Tool Context Protocols
|
||||
For all tool usage, command syntax, and integration guidelines:
|
||||
- **Tool Strategy**: @~/.claude/workflows/tool-strategy.md
|
||||
- **Intelligent Context Strategy**: @~/.claude/workflows/intelligent-tools-strategy.md
|
||||
- **Context Search Commands**: @~/.claude/workflows/context-search-strategy.md
|
||||
|
||||
@@ -10,107 +10,61 @@
|
||||
- Complex API research → Exa Code Context
|
||||
- Real-time information needs → Exa Web Search
|
||||
|
||||
## ⚡ CCW Tool Execution
|
||||
## ⚡ CCW MCP Tools
|
||||
|
||||
### General Usage (JSON Parameters)
|
||||
**优先使用 MCP 工具** (无需 Shell 转义,直接 JSON 参数)
|
||||
|
||||
```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
|
||||
### edit_file
|
||||
|
||||
**When to Use**: Edit tool fails 1+ times on same file
|
||||
|
||||
```bash
|
||||
# Basic edit
|
||||
ccw tool exec edit_file --path "file.py" --old "old code" --new "new code"
|
||||
|
||||
# Preview without modifying (dry run)
|
||||
ccw tool exec edit_file --path "file.py" --old "old" --new "new" --dry-run
|
||||
|
||||
# Replace all occurrences
|
||||
ccw tool exec edit_file --path "file.py" --old "old" --new "new" --replace-all
|
||||
|
||||
# Line mode - insert after line
|
||||
ccw tool exec edit_file --path "file.py" --mode line --operation insert_after --line 10 --text "new line"
|
||||
|
||||
# Line mode - insert before line
|
||||
ccw tool exec edit_file --path "file.py" --mode line --operation insert_before --line 5 --text "new line"
|
||||
|
||||
# Line mode - replace line
|
||||
ccw tool exec edit_file --path "file.py" --mode line --operation replace --line 3 --text "replacement"
|
||||
|
||||
# Line mode - delete line
|
||||
ccw tool exec edit_file --path "file.py" --mode line --operation delete --line 3
|
||||
```
|
||||
mcp__ccw-tools__edit_file(path="file.py", oldText="old", newText="new")
|
||||
mcp__ccw-tools__edit_file(path="file.py", oldText="old", newText="new", dryRun=true)
|
||||
mcp__ccw-tools__edit_file(path="file.py", oldText="old", newText="new", replaceAll=true)
|
||||
mcp__ccw-tools__edit_file(path="file.py", mode="line", operation="insert_after", line=10, text="new line")
|
||||
```
|
||||
|
||||
**Parameters**: `--path`*, `--old`, `--new`, `--dry-run`, `--replace-all`, `--mode` (update|line), `--operation`, `--line`, `--text`
|
||||
**Options**: `dryRun` (preview diff), `replaceAll`, `mode` (update|line), `operation`, `line`, `text`
|
||||
|
||||
### write_file Tool
|
||||
### write_file
|
||||
|
||||
**When to Use**: Create new files or overwrite existing content
|
||||
|
||||
```bash
|
||||
# Basic write
|
||||
ccw tool exec write_file --path "file.txt" --content "Hello"
|
||||
|
||||
# With backup
|
||||
ccw tool exec write_file --path "file.txt" --content "new content" --backup
|
||||
|
||||
# Create directories if needed
|
||||
ccw tool exec write_file --path "new/path/file.txt" --content "content" --create-directories
|
||||
```
|
||||
mcp__ccw-tools__write_file(path="file.txt", content="Hello")
|
||||
mcp__ccw-tools__write_file(path="file.txt", content="code with `backticks` and ${vars}", backup=true)
|
||||
```
|
||||
|
||||
**Parameters**: `--path`*, `--content`*, `--create-directories`, `--backup`, `--encoding`
|
||||
**Options**: `backup`, `createDirectories`, `encoding`
|
||||
|
||||
### codex_lens
|
||||
|
||||
**When to Use**: Code indexing and semantic search
|
||||
|
||||
```
|
||||
mcp__ccw-tools__codex_lens(action="init", path=".")
|
||||
mcp__ccw-tools__codex_lens(action="search", query="function main", path=".")
|
||||
mcp__ccw-tools__codex_lens(action="search_files", query="pattern", limit=20)
|
||||
mcp__ccw-tools__codex_lens(action="symbol", file="src/main.py")
|
||||
```
|
||||
|
||||
**Actions**: `init`, `search`, `search_files`, `symbol`, `status`, `update`
|
||||
|
||||
### smart_search
|
||||
|
||||
**When to Use**: Quick search without indexing, natural language queries
|
||||
|
||||
```
|
||||
mcp__ccw-tools__smart_search(query="function main", path=".")
|
||||
mcp__ccw-tools__smart_search(query="def init", mode="exact")
|
||||
mcp__ccw-tools__smart_search(query="authentication logic", mode="semantic")
|
||||
```
|
||||
|
||||
**Modes**: `auto` (default), `exact`, `fuzzy`, `semantic`, `graph`
|
||||
|
||||
### Fallback Strategy
|
||||
|
||||
1. **Edit fails 1+ times** → `ccw tool exec edit_file`
|
||||
2. **Still fails** → `ccw tool exec write_file`
|
||||
1. **Edit fails 1+ times** → `mcp__ccw-tools__edit_file`
|
||||
2. **Still fails** → `mcp__ccw-tools__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)
|
||||
|
||||
Reference in New Issue
Block a user