feat: Update initialization process to prioritize in-memory configuration for CLI tool selection

This commit is contained in:
catlog22
2026-01-28 23:20:50 +08:00
parent 6ac041c1d8
commit 63f0daebbb

View File

@@ -12,12 +12,14 @@ version: 1.0.0
## Initialization (Required First Step) ## Initialization (Required First Step)
**Before any tool selection or recommendation, ALWAYS**: **Before any tool selection or recommendation**:
1. Read the configuration file: 1. Check if configuration exists in memory:
```bash - If configuration is already in conversation memory → Use it directly
Read(file_path="~/.claude/cli-tools.json") - If NOT in memory → Read the configuration file:
``` ```bash
Read(file_path="~/.claude/cli-tools.json")
```
2. Parse the JSON to understand: 2. Parse the JSON to understand:
- Available tools and their `enabled` status - Available tools and their `enabled` status
@@ -28,14 +30,16 @@ version: 1.0.0
3. Use configuration throughout the selection process 3. Use configuration throughout the selection process
**Why**: Tools, models, and tags may change. Configuration file is the single source of truth. **Why**: Tools, models, and tags may change. Configuration file is the single source of truth.
**Optimization**: Reuse in-memory configuration to avoid redundant file reads.
## Process Flow ## Process Flow
``` ```
┌─ USER REQUEST ┌─ USER REQUEST
├─ STEP 1: Read Configuration ├─ STEP 1: Load Configuration
Read(file_path="~/.claude/cli-tools.json") Check if configuration exists in conversation memory
│ └─ If NOT in memory → Read(file_path="~/.claude/cli-tools.json")
├─ STEP 2: Understand User Intent ├─ STEP 2: Understand User Intent
│ ├─ Parse task type (analysis, implementation, security, etc.) │ ├─ Parse task type (analysis, implementation, security, etc.)
@@ -70,19 +74,22 @@ version: 1.0.0
**Path**: `~/.claude/cli-tools.json` (Global configuration) **Path**: `~/.claude/cli-tools.json` (Global configuration)
**IMPORTANT**: Always read this file first before making tool selections or recommendations. **IMPORTANT**: Check conversation memory first. Only read file if configuration is not in memory.
### Reading Configuration ### Reading Configuration
```bash **Priority**: Check conversation memory first
# Read the configuration file
cat ~/.claude/cli-tools.json
# Or use Read tool **Loading Options**:
Read(file_path="~/.claude/cli-tools.json") - **Option 1** (Preferred): Use in-memory configuration if already loaded in conversation
- **Option 2** (Fallback): Read from file when not in memory
```bash
# Read configuration file
cat ~/.claude/cli-tools.json
``` ```
The configuration file defines all available tools with their settings. The configuration defines all available tools with their enabled status, models, and tags.
### Configuration Structure ### Configuration Structure
@@ -108,7 +115,7 @@ Typical tools found in configuration (actual availability determined by reading
| `claude` | builtin | General tasks | | `claude` | builtin | General tasks |
| `opencode` | builtin | Open-source model fallback | | `opencode` | builtin | Open-source model fallback |
**Note**: Tool availability, models, and tags may differ. Always read `~/.claude/cli-tools.json` for current configuration. **Note**: Tool availability, models, and tags may differ. Use in-memory configuration or read `~/.claude/cli-tools.json` if not cached.
### Configuration Fields ### Configuration Fields
@@ -404,11 +411,12 @@ ccw cli --tool codex --mode review --commit abc123
### Selection Algorithm ### Selection Algorithm
**STEP 0 (REQUIRED)**: Read `~/.claude/cli-tools.json` to get current configuration **STEP 0 (REQUIRED)**: Load configuration (memory-first strategy)
```bash ```bash
# Always start with this # Check if configuration exists in conversation memory
Read(file_path="~/.claude/cli-tools.json") # If YES → Use in-memory configuration
# If NO → Read(file_path="~/.claude/cli-tools.json")
``` ```
Then proceed with selection: Then proceed with selection:
@@ -422,7 +430,9 @@ Then proceed with selection:
### Selection Decision Tree ### Selection Decision Tree
``` ```
0. READ ~/.claude/cli-tools.json 0. LOAD CONFIGURATION (memory-first)
├─ In memory? → Use it
└─ Not in memory? → Read ~/.claude/cli-tools.json
1. Explicit --tool specified? 1. Explicit --tool specified?
YES → Validate tool is enabled in config → Use it YES → Validate tool is enabled in config → Use it