From 0a07138c27d9c7115a744775420330967f6957d6 Mon Sep 17 00:00:00 2001 From: catlog22 Date: Wed, 28 Jan 2026 22:55:36 +0800 Subject: [PATCH] feat: Add ccw-cli-tools skill specification with unified execution framework and configuration-driven tool selection --- .claude/commands/workflow/debug-with-file.md | 12 +- .codex/skills/ccw-cli-tools/SKILL.md | 549 +++++++++++++++++++ ccw/src/core/routes/claude-routes.ts | 84 ++- 3 files changed, 623 insertions(+), 22 deletions(-) create mode 100644 .codex/skills/ccw-cli-tools/SKILL.md diff --git a/.claude/commands/workflow/debug-with-file.md b/.claude/commands/workflow/debug-with-file.md index 6fc1016a..320fb9b8 100644 --- a/.claude/commands/workflow/debug-with-file.md +++ b/.claude/commands/workflow/debug-with-file.md @@ -17,6 +17,8 @@ Enhanced evidence-based debugging with **documented exploration process**. Recor **Core workflow**: Explore → Document → Log → Analyze → Correct Understanding → Fix → Verify +**Scope**: Adds temporary debug logging to observe program state; cleans up all instrumentation after resolution. Does NOT execute code injection, security testing, or modify program behavior. + **Key enhancements over /workflow:debug**: - **understanding.md**: Timeline of exploration and learning - **Gemini-assisted correction**: Validates and corrects hypotheses @@ -44,7 +46,7 @@ Explore Mode: ├─ Locate error source in codebase ├─ Document initial understanding in understanding.md ├─ Generate testable hypotheses with Gemini validation - ├─ Add NDJSON logging instrumentation + ├─ Add NDJSON debug logging statements └─ Output: Hypothesis list + await user reproduction Analyze Mode: @@ -216,9 +218,9 @@ Save Gemini output to `hypotheses.json`: } ``` -**Step 1.4: Add NDJSON Instrumentation** +**Step 1.4: Add NDJSON Debug Logging** -For each hypothesis, add logging (same as original debug command). +For each hypothesis, add temporary logging statements to observe program state at key execution points. Use NDJSON format for structured log parsing. These are read-only observations that do not modify program behavior. **Step 1.5: Update understanding.md** @@ -441,7 +443,7 @@ What we learned from this debugging session: **Step 3.3: Cleanup** -Remove debug instrumentation (same as original command). +Remove all temporary debug logging statements added during investigation. Verify no instrumentation code remains in production code. --- @@ -647,7 +649,7 @@ Why is config value None during update? | Feature | /workflow:debug | /workflow:debug-with-file | |---------|-----------------|---------------------------| -| NDJSON logging | ✅ | ✅ | +| NDJSON debug logging | ✅ | ✅ | | Hypothesis generation | Manual | Gemini-assisted | | Exploration documentation | ❌ | ✅ understanding.md | | Understanding evolution | ❌ | ✅ Timeline + corrections | diff --git a/.codex/skills/ccw-cli-tools/SKILL.md b/.codex/skills/ccw-cli-tools/SKILL.md new file mode 100644 index 00000000..4ce343de --- /dev/null +++ b/.codex/skills/ccw-cli-tools/SKILL.md @@ -0,0 +1,549 @@ +--- +name: ccw-cli-tools +description: CLI tools execution specification (gemini/claude/codex/qwen/opencode) with unified prompt template, mode options, and auto-invoke triggers for code analysis and implementation tasks. Supports configurable CLI endpoints for analysis, write, and review modes. +version: 1.0.0 +--- + +# CLI Tools - Unified Execution Framework + +**Purpose**: Structured CLI tool usage with configuration-driven tool selection, unified prompt templates, and quality-gated execution. + +**Configuration**: `~/.claude/cli-tools.json` (Global, always read at initialization) + +## Initialization (Required First Step) + +**Before any tool selection or recommendation, ALWAYS**: + +1. Read the configuration file: + ```bash + Read(file_path="~/.claude/cli-tools.json") + ``` + +2. Parse the JSON to understand: + - Available tools and their `enabled` status + - Each tool's `primaryModel` and `secondaryModel` + - Tags defined for tag-based routing + - Tool types (builtin, cli-wrapper, api-endpoint) + +3. Use configuration throughout the selection process + +**Why**: Tools, models, and tags may change. Configuration file is the single source of truth. + +## Process Flow + +``` +┌─ USER REQUEST +│ +├─ STEP 1: Read Configuration +│ └─ Read(file_path="~/.claude/cli-tools.json") +│ +├─ STEP 2: Understand User Intent +│ ├─ Parse task type (analysis, implementation, security, etc.) +│ ├─ Extract required capabilities (tags) +│ └─ Identify scope (files, modules) +│ +├─ STEP 3: Select Tool (based on config) +│ ├─ Explicit --tool specified? +│ │ YES → Validate in config → Use it +│ │ NO → Match tags with enabled tools → Select best match +│ │ → No match → Use first enabled tool (default) +│ └─ Get primaryModel from config +│ +├─ STEP 4: Build Prompt +│ └─ Use 6-field template: PURPOSE, TASK, MODE, CONTEXT, EXPECTED, CONSTRAINTS +│ +├─ STEP 5: Select Rule Template +│ ├─ Determine rule from task type +│ └─ Pass via --rule parameter +│ +├─ STEP 6: Execute CLI Command +│ └─ ccw cli -p "" --tool --mode --rule +│ +└─ STEP 7: Handle Results + ├─ On success → Deliver output to user + └─ On failure → Check secondaryModel or fallback tool +``` + +## Configuration Reference + +### Configuration File Location + +**Path**: `~/.claude/cli-tools.json` (Global configuration) + +**IMPORTANT**: Always read this file first before making tool selections or recommendations. + +### Reading Configuration + +```bash +# Read the configuration file +cat ~/.claude/cli-tools.json + +# Or use Read tool +Read(file_path="~/.claude/cli-tools.json") +``` + +The configuration file defines all available tools with their settings. + +### Configuration Structure + +The JSON file contains a `tools` object where each tool has these fields: + +| Field | Type | Description | Example | +|-------|------|-------------|---------| +| `enabled` | boolean | Tool availability status | `true` or `false` | +| `primaryModel` | string | Default model for execution | `"gemini-2.5-pro"` | +| `secondaryModel` | string | Fallback model on primary failure | `"gemini-2.5-flash"` | +| `tags` | array | Capability tags for routing | `["分析", "Debug"]` | +| `type` | string | Tool type | `"builtin"`, `"cli-wrapper"`, `"api-endpoint"` | + +### Expected Tools (Reference Only) + +Typical tools found in configuration (actual availability determined by reading the file): + +| Tool | Typical Type | Common Use | +|------|--------------|------------| +| `gemini` | builtin | Analysis, Debug (分析, Debug tags) | +| `qwen` | builtin | General coding | +| `codex` | builtin | Code review, implementation | +| `claude` | builtin | General tasks | +| `opencode` | builtin | Open-source model fallback | + +**Note**: Tool availability, models, and tags may differ. Always read `~/.claude/cli-tools.json` for current configuration. + +### Configuration Fields + +- **`enabled`**: Tool availability (boolean) +- **`primaryModel`**: Default model for execution +- **`secondaryModel`**: Fallback model on primary failure +- **`tags`**: Capability tags for routing (分析, Debug, implementation, etc.) +- **`type`**: Tool type (builtin, cli-wrapper, api-endpoint) + +## Universal Prompt Template + +**Structure**: Every CLI command follows this 6-field template + +```bash +ccw cli -p "PURPOSE: [goal] + [why] + [success criteria] + [scope] +TASK: • [step 1: specific action] • [step 2: specific action] • [step 3: specific action] +MODE: [analysis|write|review] +CONTEXT: @[file patterns] | Memory: [session/tech/module context] +EXPECTED: [deliverable format] + [quality criteria] + [structure requirements] +CONSTRAINTS: [domain constraints]" --tool --mode --rule