mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-07 02:04:11 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
faa86eded0 | ||
|
|
44fa6e0a42 | ||
|
|
be9a1c76d4 | ||
|
|
fcc811d6a1 |
@@ -14,71 +14,66 @@
|
||||
|
||||
**When to Use**: Edit tool fails 1+ times on same file
|
||||
|
||||
### update Mode (Default)
|
||||
### Usage
|
||||
|
||||
**Best for**: Code block replacements, function rewrites, multi-line changes
|
||||
|
||||
```bash
|
||||
ccw tool exec edit_file '{
|
||||
"path": "file.py",
|
||||
"oldText": "def old():\n pass",
|
||||
"newText": "def new():\n return True"
|
||||
}'
|
||||
ccw tool exec edit_file --path "file.py" --old "def old():
|
||||
pass" --new "def new():
|
||||
return True"
|
||||
```
|
||||
|
||||
### line Mode (Precise Line Operations)
|
||||
**Parameters**:
|
||||
- `--path`: File path to edit
|
||||
- `--old`: Text to find and replace
|
||||
- `--new`: New text to insert
|
||||
|
||||
**Best for**: Config files, line insertions/deletions, precise line number control
|
||||
|
||||
```bash
|
||||
# Insert after specific line
|
||||
ccw tool exec edit_file '{
|
||||
"path": "config.txt",
|
||||
"mode": "line",
|
||||
"operation": "insert_after",
|
||||
"line": 10,
|
||||
"text": "new config line"
|
||||
}'
|
||||
|
||||
# Delete line range
|
||||
ccw tool exec edit_file '{
|
||||
"path": "log.txt",
|
||||
"mode": "line",
|
||||
"operation": "delete",
|
||||
"line": 5,
|
||||
"end_line": 8
|
||||
}'
|
||||
|
||||
# Replace specific line
|
||||
ccw tool exec edit_file '{
|
||||
"path": "script.sh",
|
||||
"mode": "line",
|
||||
"operation": "replace",
|
||||
"line": 3,
|
||||
"text": "#!/bin/bash"
|
||||
}'
|
||||
```
|
||||
|
||||
**Operations**:
|
||||
- `insert_before`: Insert text before specified line
|
||||
- `insert_after`: Insert text after specified line
|
||||
- `replace`: Replace line or line range
|
||||
- `delete`: Delete line or line range
|
||||
|
||||
### Mode Selection Guide
|
||||
|
||||
| Scenario | Mode | Reason |
|
||||
|----------|------|--------|
|
||||
| Code refactoring | update | Content-driven replacement |
|
||||
| Function rewrite | update | Simple oldText/newText |
|
||||
| Config line change | line | Precise line number control |
|
||||
| Insert at specific position | line | Exact line number needed |
|
||||
| Delete line range | line | Line-based operation |
|
||||
**Features**:
|
||||
- ✅ Exact text matching (precise and predictable)
|
||||
- ✅ Auto line ending adaptation (CRLF/LF)
|
||||
- ✅ No JSON escaping issues
|
||||
- ✅ Multi-line text supported with quotes
|
||||
|
||||
### Fallback Strategy
|
||||
|
||||
1. **Edit fails 1+ times** → Use `ccw tool exec edit_file` (update mode)
|
||||
2. **update mode fails** → Try line mode with precise line numbers
|
||||
3. **All fails** → Use Write to recreate file
|
||||
1. **Edit fails 1+ times** → Use `ccw tool exec edit_file`
|
||||
2. **Still fails** → Use Write to recreate file
|
||||
|
||||
**Default mode**: update (exact matching with line ending adaptation)
|
||||
## ⚡ 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)
|
||||
|
||||
27
CHANGELOG.md
27
CHANGELOG.md
@@ -5,6 +5,33 @@ All notable changes to Claude Code Workflow (CCW) will be documented in this fil
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [6.1.3] - 2025-12-09
|
||||
|
||||
### 🔧 CLI Tool Simplification
|
||||
|
||||
This release simplifies the `ccw tool exec edit_file` command for better usability.
|
||||
|
||||
#### 🔄 Changed
|
||||
- **Simplified edit_file**: Removed JSON input support, now uses parameter-based input only (`--path`, `--old`, `--new`)
|
||||
- **Removed line mode**: Line operations now recommended via `sed` command
|
||||
- **Updated tool-strategy.md**: Added sed as line operation alternative with usage examples
|
||||
|
||||
#### Usage
|
||||
```bash
|
||||
ccw tool exec edit_file --path "file.txt" --old "old text" --new "new text"
|
||||
```
|
||||
|
||||
## [6.1.2] - 2025-12-09
|
||||
|
||||
### 🔔 Dashboard Update Notification & Bug Fixes
|
||||
|
||||
#### ✨ Added
|
||||
- **Version Update Notification**: Dashboard now checks npm registry for updates and displays upgrade banner
|
||||
- **Version Check API**: New `/api/version-check` endpoint with 1-hour cache
|
||||
|
||||
#### 🐛 Fixed
|
||||
- **Hook Manager**: Fixed button click event handling for edit/delete operations (changed `e.target` to `e.currentTarget`)
|
||||
|
||||
## [5.9.6] - 2025-11-28
|
||||
|
||||
### 🚀 Review Cycle & Dashboard Enhancement
|
||||
|
||||
22
README.md
22
README.md
@@ -5,7 +5,7 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[](https://github.com/catlog22/Claude-Code-Workflow/releases)
|
||||
[](https://github.com/catlog22/Claude-Code-Workflow/releases)
|
||||
[](https://www.npmjs.com/package/claude-code-workflow)
|
||||
[](LICENSE)
|
||||
[]()
|
||||
@@ -18,13 +18,11 @@
|
||||
|
||||
**Claude Code Workflow (CCW)** is a JSON-driven multi-agent development framework with intelligent CLI orchestration (Gemini/Qwen/Codex), context-first architecture, and automated workflow execution. It transforms AI development from simple prompt chaining into a powerful orchestration system.
|
||||
|
||||
> **🎉 Version 6.1.0: Dashboard Icon Unification & CCW Tool System**
|
||||
> **🎉 Version 6.1.3: CLI Tool Simplification**
|
||||
>
|
||||
> **Core Improvements**:
|
||||
> - 🎨 **Dashboard Icon Unification**: Complete migration to Lucide Icons library across all views
|
||||
> - 🛠️ **CCW Tool Exec System**: New `ccw tool exec` command for executing tools with JSON parameters
|
||||
> - 🚀 **Explorer Enhancements**: Async task execution, CLI selector improvements, WebSocket frame handling
|
||||
> - ✨ **Smart Server Recognition**: Intelligent workspace switching and MCP multi-source configuration
|
||||
> - 🔧 **Simplified edit_file**: Parameter-based input only (`--path`, `--old`, `--new`)
|
||||
> - 📝 **Updated tool-strategy.md**: Added sed as line operation alternative
|
||||
>
|
||||
> See [CHANGELOG.md](CHANGELOG.md) for complete details.
|
||||
|
||||
@@ -66,18 +64,6 @@ ccw install -m Global
|
||||
ccw install -m Path -p /path/to/project
|
||||
```
|
||||
|
||||
### **🚀 Alternative: One-Click Script Install**
|
||||
|
||||
**Windows (PowerShell):**
|
||||
```powershell
|
||||
Invoke-Expression (Invoke-WebRequest -Uri "https://raw.githubusercontent.com/catlog22/Claude-Code-Workflow/main/install-remote.ps1" -UseBasicParsing).Content
|
||||
```
|
||||
|
||||
**Linux/macOS (Bash/Zsh):**
|
||||
```bash
|
||||
bash <(curl -fsSL https://raw.githubusercontent.com/catlog22/Claude-Code-Workflow/main/install-remote.sh)
|
||||
```
|
||||
|
||||
### **✅ Verify Installation**
|
||||
After installation, open **Claude Code** and verify that workflow commands are available by running:
|
||||
```bash
|
||||
|
||||
@@ -108,9 +108,12 @@ export function run(argv) {
|
||||
|
||||
// Tool command
|
||||
program
|
||||
.command('tool [subcommand] [args] [json]')
|
||||
.command('tool [subcommand] [args]')
|
||||
.description('Execute CCW tools')
|
||||
.action((subcommand, args, json) => toolCommand(subcommand, args, { json }));
|
||||
.option('--path <path>', 'File path (for edit_file)')
|
||||
.option('--old <text>', 'Old text to replace (for edit_file)')
|
||||
.option('--new <text>', 'New text (for edit_file)')
|
||||
.action((subcommand, args, options) => toolCommand(subcommand, args, options));
|
||||
|
||||
program.parse(argv);
|
||||
}
|
||||
|
||||
@@ -66,80 +66,13 @@ async function schemaAction(options) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read from stdin if available
|
||||
*/
|
||||
async function readStdin() {
|
||||
// Check if stdin is a TTY (interactive terminal)
|
||||
if (process.stdin.isTTY) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let data = '';
|
||||
|
||||
process.stdin.setEncoding('utf8');
|
||||
|
||||
process.stdin.on('readable', () => {
|
||||
let chunk;
|
||||
while ((chunk = process.stdin.read()) !== null) {
|
||||
data += chunk;
|
||||
}
|
||||
});
|
||||
|
||||
process.stdin.on('end', () => {
|
||||
resolve(data.trim() || null);
|
||||
});
|
||||
|
||||
process.stdin.on('error', (err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Smart JSON parser with Windows path handling
|
||||
*/
|
||||
function parseJsonWithPathFix(jsonString) {
|
||||
try {
|
||||
// Try normal parse first
|
||||
return JSON.parse(jsonString);
|
||||
} catch (firstError) {
|
||||
// If parsing fails, try to fix Windows paths
|
||||
try {
|
||||
// Pattern: "path": "X:\..." or "path":"X:\..."
|
||||
const fixedJson = jsonString.replace(
|
||||
/("(?:path|file|target|source|dest|destination)":\s*")([A-Za-z]:[^"]+)"/g,
|
||||
(match, prefix, path) => {
|
||||
// Convert backslashes to forward slashes (universal)
|
||||
const fixedPath = path.replace(/\\/g, '/');
|
||||
return `${prefix}${fixedPath}"`;
|
||||
}
|
||||
);
|
||||
|
||||
return JSON.parse(fixedJson);
|
||||
} catch (secondError) {
|
||||
// If still fails, throw original error with helpful message
|
||||
const errorMsg = firstError.message;
|
||||
const hint = errorMsg.includes('escaped character') || errorMsg.includes('position')
|
||||
? '\n\n' + chalk.yellow('Hint: Windows paths in JSON need forward slashes or double backslashes:') +
|
||||
'\n ' + chalk.green('✓ "D:/Claude_dms3/file.md"') +
|
||||
'\n ' + chalk.green('✓ "D:\\\\Claude_dms3\\\\file.md"') +
|
||||
'\n ' + chalk.red('✗ "D:\\Claude_dms3\\file.md"')
|
||||
: '';
|
||||
|
||||
throw new Error(errorMsg + hint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a tool with given parameters
|
||||
*/
|
||||
async function execAction(toolName, jsonInput, options) {
|
||||
async function execAction(toolName, options) {
|
||||
if (!toolName) {
|
||||
console.error(chalk.red('Tool name is required'));
|
||||
console.error(chalk.gray('Usage: ccw tool exec <tool-name> \'{"param": "value"}\''));
|
||||
console.error(chalk.gray('Usage: ccw tool exec edit_file --path file.txt --old "old" --new "new"'));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@@ -150,34 +83,22 @@ async function execAction(toolName, jsonInput, options) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Parse JSON input (default format)
|
||||
let params = {};
|
||||
// Build params from CLI options
|
||||
const params = {};
|
||||
|
||||
if (jsonInput) {
|
||||
try {
|
||||
params = parseJsonWithPathFix(jsonInput);
|
||||
} catch (error) {
|
||||
console.error(chalk.red(`Invalid JSON: ${error.message}`));
|
||||
if (toolName === 'edit_file') {
|
||||
if (!options.path || !options.old || !options.new) {
|
||||
console.error(chalk.red('edit_file requires --path, --old, and --new parameters'));
|
||||
console.error(chalk.gray('Usage: ccw tool exec edit_file --path file.txt --old "old text" --new "new text"'));
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Check for stdin input (for piped commands)
|
||||
const stdinData = await readStdin();
|
||||
if (stdinData) {
|
||||
// If tool has an 'input' parameter, use it
|
||||
// Otherwise, try to parse stdin as JSON and merge with params
|
||||
if (tool.parameters?.properties?.input) {
|
||||
params.input = stdinData;
|
||||
} else {
|
||||
try {
|
||||
const stdinJson = JSON.parse(stdinData);
|
||||
params = { ...stdinJson, ...params };
|
||||
} catch {
|
||||
// If not JSON, store as 'input' anyway
|
||||
params.input = stdinData;
|
||||
}
|
||||
}
|
||||
params.path = options.path;
|
||||
params.oldText = options.old;
|
||||
params.newText = options.new;
|
||||
} else {
|
||||
console.error(chalk.red(`Tool "${toolName}" is not supported via CLI parameters`));
|
||||
console.error(chalk.gray('Currently only edit_file is supported'));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Execute tool
|
||||
@@ -200,7 +121,7 @@ export async function toolCommand(subcommand, args, options) {
|
||||
await schemaAction({ name: args });
|
||||
break;
|
||||
case 'exec':
|
||||
await execAction(args, options.json, options);
|
||||
await execAction(args, options);
|
||||
break;
|
||||
default:
|
||||
console.log(chalk.bold.cyan('\nCCW Tool System\n'));
|
||||
@@ -209,9 +130,9 @@ export async function toolCommand(subcommand, args, options) {
|
||||
console.log(chalk.gray(' schema [name] Show tool schema (JSON)'));
|
||||
console.log(chalk.gray(' exec <name> Execute a tool'));
|
||||
console.log();
|
||||
console.log('Examples:');
|
||||
console.log('Usage:');
|
||||
console.log(chalk.gray(' ccw tool list'));
|
||||
console.log(chalk.gray(' ccw tool schema edit_file'));
|
||||
console.log(chalk.gray(' ccw tool exec edit_file \'{"path":"file.txt","oldText":"old","newText":"new"}\''));
|
||||
console.log(chalk.gray(' ccw tool exec edit_file --path file.txt --old "old text" --new "new text"'));
|
||||
}
|
||||
}
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "claude-code-workflow",
|
||||
"version": "6.0.5",
|
||||
"version": "6.1.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "claude-code-workflow",
|
||||
"version": "6.0.5",
|
||||
"version": "6.1.3",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"boxen": "^7.1.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "claude-code-workflow",
|
||||
"version": "6.1.2",
|
||||
"version": "6.1.3",
|
||||
"description": "JSON-driven multi-agent development framework with intelligent CLI orchestration (Gemini/Qwen/Codex), context-first architecture, and automated workflow execution",
|
||||
"type": "module",
|
||||
"main": "ccw/src/index.js",
|
||||
|
||||
Reference in New Issue
Block a user