diff --git a/.claude/commands/qwen/analyze.md b/.claude/commands/qwen/analyze.md new file mode 100644 index 00000000..594d2dfd --- /dev/null +++ b/.claude/commands/qwen/analyze.md @@ -0,0 +1,96 @@ +--- +name: analyze +description: Quick analysis of codebase patterns, architecture, and code quality using qwen CLI +usage: /qwen:analyze +argument-hint: "analysis target or type" +examples: + - /qwen:analyze "React hooks patterns" + - /qwen:analyze "authentication security" + - /qwen:analyze "performance bottlenecks" + - /qwen:analyze "API design patterns" +model: haiku +--- + +# qwen Analysis Command (/qwen:analyze) + +## Overview +Quick analysis tool for codebase insights using intelligent pattern detection and template-driven analysis. + +**Core Guidelines**: @~/.claude/workflows/intelligent-tools-strategy.md + +## Analysis Types + +| Type | Purpose | Example | +|------|---------|---------| +| **pattern** | Code pattern detection | "React hooks usage patterns" | +| **architecture** | System structure analysis | "component hierarchy structure" | +| **security** | Security vulnerabilities | "authentication vulnerabilities" | +| **performance** | Performance bottlenecks | "rendering performance issues" | +| **quality** | Code quality assessment | "testing coverage analysis" | +| **dependencies** | Third-party analysis | "outdated package dependencies" | + +## Quick Usage + +### Basic Analysis +```bash +/qwen:analyze "authentication patterns" +``` +**Executes**: `qwen -p -a "@{**/*auth*} @{CLAUDE.md} $(template:analysis/pattern.txt)"` + +### Targeted Analysis +```bash +/qwen:analyze "React component architecture" +``` +**Executes**: `qwen -p -a "@{src/components/**/*} @{CLAUDE.md} $(template:analysis/architecture.txt)"` + +### Security Focus +```bash +/qwen:analyze "API security vulnerabilities" +``` +**Executes**: `qwen -p -a "@{**/api/**/*} @{CLAUDE.md} $(template:analysis/security.txt)"` + +## Templates Used + +Templates are automatically selected based on analysis type: +- **Pattern Analysis**: `~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt` +- **Architecture Analysis**: `~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt` +- **Security Analysis**: `~/.claude/workflows/cli-templates/prompts/analysis/security.txt` +- **Performance Analysis**: `~/.claude/workflows/cli-templates/prompts/analysis/performance.txt` + +## Workflow Integration + +โš ๏ธ **Session Check**: Automatically detects active workflow session via `.workflow/.active-*` marker file. + +**Analysis results saved to:** +- Active session: `.workflow/WFS-[topic]/.chat/analysis-[timestamp].md` +- No session: Temporary analysis output + +## Common Patterns + +### Technology Stack Analysis +```bash +/qwen:analyze "project technology stack" +# Auto-detects: package.json, config files, dependencies +``` + +### Code Quality Review +```bash +/qwen:analyze "code quality and standards" +# Auto-targets: source files, test files, CLAUDE.md +``` + +### Migration Planning +```bash +/qwen:analyze "legacy code modernization" +# Focuses: older patterns, deprecated APIs, upgrade paths +``` + +## Output Format + +Analysis results include: +- **File References**: Specific file:line locations +- **Code Examples**: Relevant code snippets +- **Patterns Found**: Common patterns and anti-patterns +- **Recommendations**: Actionable improvements +- **Integration Points**: How components connect + diff --git a/.claude/commands/qwen/chat.md b/.claude/commands/qwen/chat.md new file mode 100644 index 00000000..e6096ce2 --- /dev/null +++ b/.claude/commands/qwen/chat.md @@ -0,0 +1,93 @@ +--- +name: chat + +description: Simple qwen CLI interaction command for direct codebase analysis +usage: /qwen:chat "inquiry" +argument-hint: "your question or analysis request" +examples: + - /qwen:chat "analyze the authentication flow" + - /qwen:chat "how can I optimize this React component performance?" + - /qwen:chat "review security vulnerabilities in src/auth/" +allowed-tools: Bash(qwen:*) +model: sonnet +--- + +### ๐Ÿš€ **Command Overview: `/qwen:chat`** + +- **Type**: Basic qwen CLI Wrapper +- **Purpose**: Direct interaction with the `qwen` CLI for simple codebase analysis +- **Core Tool**: `Bash(qwen:*)` - Executes the external qwen CLI tool + +### ๐Ÿ“ฅ **Parameters & Usage** + +- **`` (Required)**: Your question or analysis request +- **`--all-files` (Optional)**: Includes the entire codebase in the analysis context +- **`--save-session` (Optional)**: Saves the interaction to current workflow session directory +- **File References**: Specify files or patterns using `@{path/to/file}` syntax + +### ๐Ÿ”„ **Execution Workflow** + +`Parse Input` **->** `Assemble Context` **->** `Construct Prompt` **->** `Execute qwen CLI` **->** `(Optional) Save Session` + +### ๐Ÿ“š **Context Assembly** + +Context is gathered from: +1. **Project Guidelines**: Always includes `@{CLAUDE.md,**/*CLAUDE.md}` +2. **User-Explicit Files**: Files specified by the user (e.g., `@{src/auth/*.js}`) +3. **All Files Flag**: The `--all-files` flag includes the entire codebase + +### ๐Ÿ“ **Prompt Format** + +``` +=== CONTEXT === +@{CLAUDE.md,**/*CLAUDE.md} [Project guidelines] +@{target_files} [User-specified files or all files if --all-files is used] + +=== USER INPUT === +[The user inquiry text] +``` + +### โš™๏ธ **Execution Implementation** + +```pseudo +FUNCTION execute_qwen_chat(user_inquiry, flags): + // Construct basic prompt + prompt = "=== CONTEXT ===\n" + prompt += "@{CLAUDE.md,**/*CLAUDE.md}\n" + + // Add user-specified files or all files + IF flags contain "--all-files": + result = execute_tool("Bash(qwen:*)", "--all-files", "-p", prompt + user_inquiry) + ELSE: + prompt += "\n=== USER INPUT ===\n" + user_inquiry + result = execute_tool("Bash(qwen:*)", "-p", prompt) + + // Save session if requested + IF flags contain "--save-session": + save_chat_session(user_inquiry, result) + + RETURN result +END FUNCTION +``` + +### ๐Ÿ’พ **Session Persistence** + +When `--save-session` flag is used: +- Check for existing active session (`.workflow/.active-*` markers) +- Save to existing session's `.chat/` directory or create new session +- File format: `chat-YYYYMMDD-HHMMSS.md` +- Include query, context, and response in saved file + +**Session Template:** +```markdown +# Chat Session: [Timestamp] + +## Query +[Original user inquiry] + +## Context +[Files and patterns included in analysis] + +## qwen Response +[Complete response from qwen CLI] +``` \ No newline at end of file diff --git a/.claude/commands/qwen/execute.md b/.claude/commands/qwen/execute.md new file mode 100644 index 00000000..d9eb43ed --- /dev/null +++ b/.claude/commands/qwen/execute.md @@ -0,0 +1,168 @@ +--- +name: execute +description: Auto-execution of implementation tasks with YOLO permissions and intelligent context inference +usage: /qwen:execute +argument-hint: "implementation description or task-id" +examples: + - /qwen:execute "implement user authentication system" + - /qwen:execute "optimize React component performance" + - /qwen:execute IMPL-001 + - /qwen:execute "fix API performance issues" +allowed-tools: Bash(qwen:*) +model: sonnet +--- + +# qwen Execute Command (/qwen:execute) + +## Overview + +**โšก YOLO-enabled execution**: Auto-approves all confirmations for streamlined implementation workflow. + +**Purpose**: Execute implementation tasks using intelligent context inference and qwen CLI with full permissions. + +**Core Guidelines**: @~/.claude/workflows/intelligent-tools-strategy.md + +## ๐Ÿšจ YOLO Permissions + +**All confirmations auto-approved by default:** +- โœ… File pattern inference confirmation +- โœ… qwen execution confirmation +- โœ… File modification confirmation +- โœ… Implementation summary generation + +## Execution Modes + +### 1. Description Mode +**Input**: Natural language description +```bash +/qwen:execute "implement JWT authentication with middleware" +``` +**Process**: Keyword analysis โ†’ Pattern inference โ†’ Context collection โ†’ Execution + +### 2. Task ID Mode +**Input**: Workflow task identifier +```bash +/qwen:execute IMPL-001 +``` +**Process**: Task JSON parsing โ†’ Scope analysis โ†’ Context integration โ†’ Execution + +## Context Inference Logic + +**Auto-selects relevant files based on:** +- **Keywords**: "auth" โ†’ `@{**/*auth*,**/*user*}` +- **Technology**: "React" โ†’ `@{src/**/*.{jsx,tsx}}` +- **Task Type**: "api" โ†’ `@{**/api/**/*,**/routes/**/*}` +- **Always includes**: `@{CLAUDE.md,**/*CLAUDE.md}` + +## Command Options + +| Option | Purpose | +|--------|---------| +| `--debug` | Verbose execution logging | +| `--save-session` | Save complete execution session to workflow | + +## Workflow Integration + +### Session Management +โš ๏ธ **Auto-detects active session**: Checks `.workflow/.active-*` marker file + +**Session storage:** +- **Active session exists**: Saves to `.workflow/WFS-[topic]/.chat/execute-[timestamp].md` +- **No active session**: Creates new session directory + +### Task Integration +```bash +# Execute specific workflow task +/qwen:execute IMPL-001 + +# Loads from: .task/IMPL-001.json +# Uses: task context, brainstorming refs, scope definitions +# Updates: workflow status, generates summary +``` + +## Execution Templates + +### User Description Template +```bash +qwen --all-files -p "@{inferred_patterns} @{CLAUDE.md,**/*CLAUDE.md} + +Implementation Task: [user_description] + +Provide: +- Specific implementation code +- File modification locations (file:line) +- Test cases +- Integration guidance" +``` + +### Task ID Template +```bash +qwen --all-files -p "@{task_files} @{brainstorming_refs} @{CLAUDE.md,**/*CLAUDE.md} + +Task: [task_title] (ID: [task-id]) +Type: [task_type] +Scope: [task_scope] + +Execute implementation following task acceptance criteria." +``` + +## Auto-Generated Outputs + +### 1. Implementation Summary +**Location**: `.summaries/[TASK-ID]-summary.md` or auto-generated ID + +```markdown +# Task Summary: [Task-ID] [Description] + +## Implementation +- **Files Modified**: [file:line references] +- **Features Added**: [specific functionality] +- **Context Used**: [inferred patterns] + +## Integration +- [Links to workflow documents] +``` + +### 2. Execution Session +**Location**: `.chat/execute-[timestamp].md` + +```markdown +# Execution Session: [Timestamp] + +## Input +[User description or Task ID] + +## Context Inference +[File patterns used with rationale] + +## Implementation Results +[Generated code and modifications] + +## Status Updates +[Workflow integration updates] +``` + +## Error Handling + +- **Task ID not found**: Lists available tasks +- **Pattern inference failure**: Uses generic `src/**/*` pattern +- **Execution failure**: Attempts fallback with simplified context +- **File modification errors**: Reports specific file/permission issues + +## Performance Features + +- **Smart caching**: Frequently used pattern mappings +- **Progressive inference**: Precise โ†’ broad pattern fallback +- **Parallel execution**: When multiple contexts needed +- **Directory optimization**: Switches to optimal execution path + +## Integration Workflow + +**Typical sequence:** +1. `workflow:plan` โ†’ Creates tasks +2. `/qwen:execute IMPL-001` โ†’ Executes with YOLO permissions +3. Auto-updates workflow status and generates summaries +4. `workflow:review` โ†’ Final validation + +**vs. `/qwen:analyze`**: Execute performs analysis **and implementation**, analyze is read-only. + diff --git a/.claude/commands/qwen/mode/auto.md b/.claude/commands/qwen/mode/auto.md new file mode 100644 index 00000000..f61e9e44 --- /dev/null +++ b/.claude/commands/qwen/mode/auto.md @@ -0,0 +1,188 @@ +--- +name: auto +description: Auto-select and execute appropriate template based on user input analysis +usage: /qwen:mode:auto "description of task or problem" +argument-hint: "description of what you want to analyze or plan" +examples: + - /qwen:mode:auto "authentication system keeps crashing during login" + - /qwen:mode:auto "design a real-time notification architecture" + - /qwen:mode:auto "database connection errors in production" + - /qwen:mode:auto "plan user dashboard with analytics features" +allowed-tools: Bash(ls:*), Bash(qwen:*) +model: sonnet +--- + +# Auto Template Selection (/qwen:mode:auto) + +## Overview +Automatically analyzes user input to select the most appropriate template and execute qwen CLI with optimal context. + +**Directory Analysis Rule**: Intelligent detection of directory context intent - automatically navigate to target directory when analysis scope is directory-specific. + +**--cd Parameter Rule**: When `--cd` parameter is provided, always execute `cd [path] && qwen --all-files -p "prompt"` to ensure analysis occurs in the specified directory context. + +**Process**: List Templates โ†’ Analyze Input โ†’ Select Template โ†’ Execute with Context + +## Usage + +### Auto-Detection Examples +```bash +# Bug-related keywords โ†’ selects bug-fix.md +/qwen:mode:auto "React component not rendering after state update" + +# Planning keywords โ†’ selects plan.md +/qwen:mode:auto "design microservices architecture for user management" + +# Error/crash keywords โ†’ selects bug-fix.md +/qwen:mode:auto "API timeout errors in production environment" + +# Architecture/design keywords โ†’ selects plan.md +/qwen:mode:auto "implement real-time chat system architecture" + +# With directory context +/qwen:mode:auto "authentication issues" --cd "src/auth" +``` + +## Template Selection Logic + +### Dynamic Template Discovery +**Templates auto-discovered from**: `~/.claude/prompt-templates/` + +Templates are dynamically read from the directory, including their metadata (name, description, keywords) from the YAML frontmatter. + +### Template Metadata Parsing + +Each template contains YAML frontmatter with: +```yaml +--- +name: template-name +description: Template purpose description +category: template-category +keywords: [keyword1, keyword2, keyword3] +--- +``` + +**Auto-selection based on:** +- **Template keywords**: Matches user input against template-defined keywords +- **Template name**: Direct name matching (e.g., "bug-fix" matches bug-related queries) +- **Template description**: Semantic matching against description text + +## Command Execution + +### Step 1: Template Discovery +```bash +# Dynamically discover all templates and extract YAML frontmatter +cd ~/.claude/prompt-templates && echo "Discovering templates..." && for template_file in *.md; do echo "=== $template_file ==="; head -6 "$template_file" 2>/dev/null || echo "Error reading $template_file"; echo; done +``` + +### Step 2: Dynamic Template Analysis & Selection +```pseudo +FUNCTION select_template(user_input): + templates = list_directory("~/.claude/prompt-templates/") + template_metadata = {} + + # Parse all templates for metadata + FOR each template_file in templates: + content = read_file(template_file) + yaml_front = extract_yaml_frontmatter(content) + template_metadata[template_file] = { + "name": yaml_front.name, + "description": yaml_front.description, + "keywords": yaml_front.keywords || [], + "category": yaml_front.category || "general" + } + + input_lower = user_input.toLowerCase() + best_match = null + highest_score = 0 + + # Score each template against user input + FOR each template, metadata in template_metadata: + score = 0 + + # Keyword matching (highest weight) + FOR each keyword in metadata.keywords: + IF input_lower.contains(keyword.toLowerCase()): + score += 3 + + # Template name matching + IF input_lower.contains(metadata.name.toLowerCase()): + score += 2 + + # Description semantic matching + FOR each word in metadata.description.split(): + IF input_lower.contains(word.toLowerCase()) AND word.length > 3: + score += 1 + + IF score > highest_score: + highest_score = score + best_match = template + + # Default to first template if no matches + RETURN best_match || templates[0] +END FUNCTION +``` + +### Step 3: Execute with Dynamically Selected Template +```bash +# Basic execution with selected template +qwen --all-files -p "$(cat ~/.claude/prompt-templates/[selected_template]) + +User Input: [user_input]" + +# With --cd parameter +cd [specified_directory] && qwen --all-files -p "$(cat ~/.claude/prompt-templates/[selected_template]) + +User Input: [user_input]" +``` + +**Template selection is completely dynamic** - any new templates added to the directory will be automatically discovered and available for selection based on their YAML frontmatter. + + +### Manual Template Override +```bash +# Force specific template +/qwen:mode:auto "user authentication" --template bug-fix.md +/qwen:mode:auto "fix login issues" --template plan.md +``` + +### Dynamic Template Listing +```bash +# List all dynamically discovered templates +/qwen:mode:auto --list-templates +# Output: +# Dynamically discovered templates in ~/.claude/prompt-templates/: +# - bug-fix.md (็”จไบŽๅฎšไฝbugๅนถๆไพ›ไฟฎๆ”นๅปบ่ฎฎ) [Keywords: ่ง„ๅˆ’, bug, ไฟฎๆ”นๆ–นๆกˆ] +# - plan.md (่ฝฏไปถๆžถๆž„่ง„ๅˆ’ๅ’ŒๆŠ€ๆœฏๅฎž็Žฐ่ฎกๅˆ’ๅˆ†ๆžๆจกๆฟ) [Keywords: ่ง„ๅˆ’, ๆžถๆž„, ๅฎž็Žฐ่ฎกๅˆ’, ๆŠ€ๆœฏ่ฎพ่ฎก, ไฟฎๆ”นๆ–นๆกˆ] +# - [any-new-template].md (Auto-discovered description) [Keywords: auto-parsed] +``` + +**Complete template discovery** - new templates are automatically detected and their metadata parsed from YAML frontmatter. + +## Auto-Selection Examples + +### Dynamic Selection Examples +```bash +# Selection based on template keywords and metadata +"login system crashes on startup" โ†’ Matches template with keywords: [bug, ไฟฎๆ”นๆ–นๆกˆ] +"design user dashboard with analytics" โ†’ Matches template with keywords: [่ง„ๅˆ’, ๆžถๆž„, ๆŠ€ๆœฏ่ฎพ่ฎก] +"database timeout errors in production" โ†’ Matches template with keywords: [bug, ไฟฎๆ”นๆ–นๆกˆ] +"implement real-time notification system" โ†’ Matches template with keywords: [่ง„ๅˆ’, ๅฎž็Žฐ่ฎกๅˆ’, ๆŠ€ๆœฏ่ฎพ่ฎก] + +# Any new templates added will be automatically matched +"[user input]" โ†’ Dynamically matches against all template keywords and descriptions +``` + + +## Session Integration + +saves to: +`.workflow/WFS-[topic]/.chat/auto-[template]-[timestamp].md` + +**Session includes:** +- Original user input +- Template selection reasoning +- Template used +- Complete analysis results + +This command streamlines template usage by automatically detecting user intent and selecting the optimal template for analysis. \ No newline at end of file diff --git a/.claude/commands/qwen/mode/bug-index.md b/.claude/commands/qwen/mode/bug-index.md new file mode 100644 index 00000000..2bef9ece --- /dev/null +++ b/.claude/commands/qwen/mode/bug-index.md @@ -0,0 +1,76 @@ +--- +name: bug-index +description: Bug analysis and fix suggestions using specialized template +usage: /qwen:mode:bug-index "bug description" +argument-hint: "description of the bug or error you're experiencing" +examples: + - /qwen:mode:bug-index "authentication null pointer error in login flow" + - /qwen:mode:bug-index "React component not re-rendering after state change" + - /qwen:mode:bug-index "database connection timeout in production" +allowed-tools: Bash(qwen:*) +model: sonnet +--- + +# Bug Analysis Command (/qwen:mode:bug-index) + +## Overview +Systematic bug analysis and fix suggestions using expert diagnostic template. + +**Directory Analysis Rule**: Intelligent detection of directory context intent - automatically navigate to target directory when analysis scope is directory-specific. + +**--cd Parameter Rule**: When `--cd` parameter is provided, always execute `cd [path] && qwen --all-files -p "prompt"` to ensure analysis occurs in the specified directory context. + +## Usage + +### Basic Bug Analysis +```bash +/qwen:mode:bug-index "authentication null pointer error" +``` + +### Bug Analysis with Directory Context +```bash +/qwen:mode:bug-index "authentication error" --cd "src/auth" +``` + + +### Save to Workflow Session +```bash +/qwen:mode:bug-index "API timeout issues" --save-session +``` + +## Command Execution + +**Template Used**: `~/.claude/prompt-templates/bug-fix.md` + +**Executes**: +```bash +# Basic usage +qwen --all-files -p "$(cat ~/.claude/prompt-templates/bug-fix.md) + +Bug Description: [user_description]" + +# With --cd parameter +cd [specified_directory] && qwen --all-files -p "$(cat ~/.claude/prompt-templates/bug-fix.md) + +Bug Description: [user_description]" +``` + +## Analysis Focus + +The bug-fix template provides: +- **Root Cause Analysis**: Systematic investigation +- **Code Path Tracing**: Following execution flow +- **Targeted Solutions**: Specific, minimal fixes +- **Impact Assessment**: Understanding side effects + + +## Session Output + +saves to: +`.workflow/WFS-[topic]/.chat/bug-index-[timestamp].md` + +**Includes:** +- Bug description +- Template used +- Analysis results +- Recommended actions \ No newline at end of file diff --git a/.claude/commands/qwen/mode/plan-precise.md b/.claude/commands/qwen/mode/plan-precise.md new file mode 100644 index 00000000..917a4e77 --- /dev/null +++ b/.claude/commands/qwen/mode/plan-precise.md @@ -0,0 +1,140 @@ +--- +name: plan-precise +description: Precise path planning analysis for complex projects +usage: /qwen:mode:plan-precise "planning topic" +examples: + - /qwen:mode:plan-precise "design authentication system" + - /qwen:mode:plan-precise "refactor database layer architecture" +--- + +### ๐Ÿš€ Command Overview: `/qwen:mode:plan-precise` + +Precise path-based planning analysis using user-specified directories instead of --all-files. + +### ๐Ÿ“ Execution Template + +```pseudo +# Precise path planning with user-specified scope + +PLANNING_TOPIC = user_argument +PATHS_FILE = "./planning-paths.txt" + +# Step 1: Check paths file exists +IF not file_exists(PATHS_FILE): + Write(PATHS_FILE, template_content) + echo "๐Ÿ“ Created planning-paths.txt in project root" + echo "Please edit file and add paths to analyze" + # USER_INPUT: User edits planning-paths.txt and presses Enter + wait_for_user_input() +ELSE: + echo "๐Ÿ“ Using existing planning-paths.txt" + echo "Current paths preview:" + Bash(grep -v '^#' "$PATHS_FILE" | grep -v '^$' | head -5) + # USER_INPUT: User confirms y/n + user_confirm = prompt("Continue with these paths? (y/n): ") + IF user_confirm != "y": + echo "Please edit planning-paths.txt and retry" + exit + +# Step 2: Read and validate paths +paths_ref = Bash(.claude/scripts/read-paths.sh "$PATHS_FILE") + +IF paths_ref is empty: + echo "โŒ No valid paths found in planning-paths.txt" + echo "Please add at least one path and retry" + exit + +echo "๐ŸŽฏ Analysis paths: $paths_ref" +echo "๐Ÿ“‹ Planning topic: $PLANNING_TOPIC" + +# BASH_EXECUTION_STOPS โ†’ MODEL_ANALYSIS_BEGINS +``` + +### ๐Ÿง  Model Analysis Phase + +After bash script prepares paths, model takes control to: + +1. **Present Configuration**: Show user the detected paths and analysis scope +2. **Request Confirmation**: Wait for explicit user approval +3. **Execute Analysis**: Run qwen with precise path references + +### ๐Ÿ“‹ Execution Flow + +```pseudo +# Step 1: Present plan to user +PRESENT_PLAN: + ๐Ÿ“‹ Precise Path Planning Configuration: + + Topic: design authentication system + Paths: src/auth/**/* src/middleware/auth* tests/auth/**/* config/auth.json + qwen Reference: $(.claude/scripts/read-paths.sh ./planning-paths.txt) + + โš ๏ธ Continue with analysis? (y/n) + +# Step 2: MANDATORY user confirmation +IF user_confirms(): + # Step 3: Execute qwen analysis + Bash(qwen -p "$(.claude/scripts/read-paths.sh ./planning-paths.txt) @{CLAUDE.md} $(cat ~/.claude/prompt-templates/plan.md) + +Planning Topic: $PLANNING_TOPIC") +ELSE: + abort_execution() + echo "Edit planning-paths.txt and retry" +``` + +### โœจ Features + +- **Root Level Config**: `./planning-paths.txt` in project root (no subdirectories) +- **Simple Workflow**: Check file โ†’ Present plan โ†’ Confirm โ†’ Execute +- **Path Focused**: Only analyzes user-specified paths, not entire project +- **No Complexity**: No validation, suggestions, or result saving - just core function +- **Template Creation**: Auto-creates template file if missing + +### ๐Ÿ“š Usage Examples + +```bash +# Create analysis for authentication system +/qwen:mode:plan-precise "design authentication system" + +# System creates planning-paths.txt (if needed) +# User edits: src/auth/**/* tests/auth/**/* config/auth.json +# System confirms paths and executes analysis +``` + +### ๐Ÿ” Complete Execution Example + +```bash +# 1. Command execution +$ /qwen:mode:plan-precise "design authentication system" + +# 2. System output +๐Ÿ“‹ Precise Path Planning Configuration: + +Topic: design authentication system +Paths: src/auth/**/* src/middleware/auth* tests/auth/**/* config/auth.json +qwen Reference: @{src/auth/**/*,src/middleware/auth*,tests/auth/**/*,config/auth.json} + +โš ๏ธ Continue with analysis? (y/n) + +# 3. User confirms +$ y + +# 4. Actual qwen command executed +$ qwen -p "$(.claude/scripts/read-paths.sh ./planning-paths.txt) @{CLAUDE.md} $(cat ~/.claude/prompt-templates/plan.md) + +Planning Topic: design authentication system" +``` + +### ๐Ÿ”ง Path File Format + +Simple text file in project root: `./planning-paths.txt` + +``` +# Comments start with # +src/auth/**/* +src/middleware/auth* +tests/auth/**/* +config/auth.json +docs/auth/*.md +``` + diff --git a/.claude/commands/qwen/mode/plan.md b/.claude/commands/qwen/mode/plan.md new file mode 100644 index 00000000..5394dcda --- /dev/null +++ b/.claude/commands/qwen/mode/plan.md @@ -0,0 +1,62 @@ +--- +name: plan +description: Project planning and architecture analysis using qwen CLI with specialized template +usage: /qwen:mode:plan "planning topic" +argument-hint: "planning topic or architectural challenge to analyze" +examples: + - /qwen:mode:plan "design user dashboard feature architecture" + - /qwen:mode:plan "plan microservices migration strategy" + - /qwen:mode:plan "implement real-time notification system" +allowed-tools: Bash(qwen:*) +model: sonnet +--- + +# Planning Analysis Command (/qwen:mode:plan) + +## Overview +**This command uses qwen CLI for comprehensive project planning and architecture analysis.** It leverages qwen CLI's powerful codebase analysis capabilities combined with expert planning templates to provide strategic insights and implementation roadmaps. + +### Key Features +- **qwen CLI Integration**: Utilizes qwen CLI's deep codebase analysis for informed planning decisions + +**--cd Parameter Rule**: When `--cd` parameter is provided, always execute `cd [path] && qwen --all-files -p "prompt"` to ensure analysis occurs in the specified directory context. + +## Usage + +### Basic Usage +```bash +/qwen:mode:plan "design authentication system" +``` + +### Directory-Specific Analysis +```bash +/qwen:mode:plan "design authentication system" --cd "src/auth" +``` + +## Command Execution + +**Smart Directory Detection**: Auto-detects relevant directories based on topic keywords + +**Executes**: +```bash +# Project-wide analysis +qwen --all-files -p "$(cat ~/.claude/prompt-templates/plan.md) +Planning Topic: [user_description]" + +# Directory-specific analysis +cd [directory] && qwen --all-files -p "$(cat ~/.claude/prompt-templates/plan.md) +Planning Topic: [user_description]" +``` + + +## Session Output + +saves to: +`.workflow/WFS-[topic]/.chat/plan-[timestamp].md` + +**Includes:** +- Planning topic +- Template used +- Analysis results +- Implementation roadmap +- Key decisions \ No newline at end of file diff --git a/.claude/commands/task/create.md b/.claude/commands/task/create.md index aeab5733..7715a28a 100644 --- a/.claude/commands/task/create.md +++ b/.claude/commands/task/create.md @@ -45,7 +45,7 @@ Output: โœ… Task created: IMPL-1 Title: Build authentication module Type: feature -Agent: @code-developer +Agent: code-developer Status: pending ``` @@ -105,10 +105,10 @@ Tasks inherit from: ## Agent Assignment Based on task type and title keywords: -- **Build/Implement** โ†’ `@code-developer` -- **Design/Plan** โ†’ `@planning-agent` -- **Test/Validate** โ†’ `@code-review-test-agent` -- **Review/Audit** โ†’ `@review-agent` +- **Build/Implement** โ†’ @code-developer +- **Design/Plan** โ†’ @planning-agent +- **Test/Validate** โ†’ @code-review-test-agent +- **Review/Audit** โ†’ @review-agent` ## Validation Rules @@ -141,7 +141,7 @@ Based on task type and title keywords: โœ… Created IMPL-1: Implement user authentication Type: feature -Agent: @code-developer +Agent: code-developer Status: pending ``` @@ -151,7 +151,7 @@ Status: pending โœ… Created IMPL-2: Fix login validation bug Type: bugfix -Agent: @code-developer +Agent: code-developer Status: pending ``` diff --git a/.claude/commands/task/execute.md b/.claude/commands/task/execute.md index 5cdc2961..880ca68e 100644 --- a/.claude/commands/task/execute.md +++ b/.claude/commands/task/execute.md @@ -138,7 +138,7 @@ This is the simplified data structure loaded to provide context for task executi "title": "Build authentication module", "type": "feature", "status": "active", - "agent": "@code-developer", + "agent": "code-developer", "context": { "requirements": ["JWT authentication", "OAuth2 support"], "scope": ["src/auth/*", "tests/auth/*"], @@ -209,7 +209,7 @@ This is the simplified data structure loaded to provide context for task executi } }, "execution": { - "agent": "@code-developer", + "agent": "code-developer", "mode": "auto", "attempts": 0 } @@ -262,7 +262,7 @@ Optional summary file generated at `.summaries/IMPL-[task-id]-summary.md`. - Added tests in tests/auth.test.ts ## Execution Results -- **Agent**: @code-developer +- **Agent**: code-developer - **Status**: completed ## Files Modified diff --git a/.claude/scripts/qwen-wrapper b/.claude/scripts/qwen-wrapper new file mode 100644 index 00000000..7ac38bf1 --- /dev/null +++ b/.claude/scripts/qwen-wrapper @@ -0,0 +1,141 @@ +#!/bin/bash +# qwen-wrapper - Token-aware wrapper for qwen command +# Location: ~/.claude/scripts/qwen-wrapper +# +# This wrapper automatically manages --all-files flag based on project token count +# Usage: qwen-wrapper [-C ] [all qwen options] +# -C Change to specified directory before analysis (relative or absolute path) + +set -e + +# Configuration +DEFAULT_TOKEN_LIMIT=2000000 +TOKEN_LIMIT=${QWEN_TOKEN_LIMIT:-$DEFAULT_TOKEN_LIMIT} + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +# Function to count tokens (approximate: chars/4) +count_tokens() { + local total_chars=0 + local file_count=0 + + # Count characters in common source files + while IFS= read -r -d '' file; do + if [[ -f "$file" && -r "$file" ]]; then + local chars=$(wc -c < "$file" 2>/dev/null || echo 0) + total_chars=$((total_chars + chars)) + file_count=$((file_count + 1)) + fi + done < <(find . -type f \( -name "*.py" -o -name "*.js" -o -name "*.ts" -o -name "*.tsx" -o -name "*.jsx" -o -name "*.java" -o -name "*.cpp" -o -name "*.c" -o -name "*.h" -o -name "*.rs" -o -name "*.go" -o -name "*.md" -o -name "*.txt" -o -name "*.json" -o -name "*.yaml" -o -name "*.yml" -o -name "*.xml" -o -name "*.html" -o -name "*.css" -o -name "*.scss" -o -name "*.sass" -o -name "*.php" -o -name "*.rb" -o -name "*.sh" -o -name "*.bash" \) -not -path "*/node_modules/*" -not -path "*/.git/*" -not -path "*/dist/*" -not -path "*/build/*" -not -path "*/.next/*" -not -path "*/.nuxt/*" -not -path "*/target/*" -not -path "*/vendor/*" -print0 2>/dev/null) + + local estimated_tokens=$((total_chars / 4)) + echo "$estimated_tokens $file_count" +} + +# Parse arguments to check for flags +has_all_files=false +has_approval_mode=false +change_dir="" +args=() + +# Check for existing flags and -c parameter +i=0 +while [[ $i -lt $# ]]; do + arg="${!i}" + case "$arg" in + "--all-files") + has_all_files=true + args+=("$arg") + ;; + --approval-mode*) + has_approval_mode=true + args+=("$arg") + ;; + "-C") + # Next argument is the directory + i=$((i + 1)) + if [[ $i -lt $# ]]; then + change_dir="${!i}" + echo -e "${YELLOW}๐Ÿ“ Directory change requested: $change_dir${NC}" >&2 + else + echo -e "${RED}โŒ Error: -C requires a directory path${NC}" >&2 + exit 1 + fi + ;; + *) + args+=("$arg") + ;; + esac + i=$((i + 1)) +done + +# Change directory if requested +original_dir="" +if [[ -n "$change_dir" ]]; then + original_dir=$(pwd) + if [[ -d "$change_dir" ]]; then + echo -e "${GREEN}๐Ÿ“ Changing to directory: $change_dir${NC}" >&2 + cd "$change_dir" || { + echo -e "${RED}โŒ Error: Cannot change to directory: $change_dir${NC}" >&2 + exit 1 + } + else + echo -e "${RED}โŒ Error: Directory does not exist: $change_dir${NC}" >&2 + exit 1 + fi +fi + +# Count tokens (in the target directory if -c was used) +echo -e "${YELLOW}๐Ÿ” Analyzing project size...${NC}" >&2 +read -r token_count file_count <<< "$(count_tokens)" + +echo -e "${YELLOW}๐Ÿ“Š Project stats: ~${token_count} tokens across ${file_count} files${NC}" >&2 + +# Decision logic for --all-files flag +if [[ $token_count -lt $TOKEN_LIMIT ]]; then + if [[ "$has_all_files" == false ]]; then + echo -e "${GREEN}โœ… Small project (${token_count} < ${TOKEN_LIMIT} tokens): Adding --all-files${NC}" >&2 + args=("--all-files" "${args[@]}") + else + echo -e "${GREEN}โœ… Small project (${token_count} < ${TOKEN_LIMIT} tokens): Keeping --all-files${NC}" >&2 + fi +else + if [[ "$has_all_files" == true ]]; then + echo -e "${RED}โš ๏ธ Large project (${token_count} >= ${TOKEN_LIMIT} tokens): Removing --all-files to avoid token limits${NC}" >&2 + echo -e "${YELLOW}๐Ÿ’ก Consider using specific @{patterns} for targeted analysis${NC}" >&2 + # Remove --all-files from args + new_args=() + for arg in "${args[@]}"; do + if [[ "$arg" != "--all-files" ]]; then + new_args+=("$arg") + fi + done + args=("${new_args[@]}") + else + echo -e "${RED}โš ๏ธ Large project (${token_count} >= ${TOKEN_LIMIT} tokens): Avoiding --all-files${NC}" >&2 + echo -e "${YELLOW}๐Ÿ’ก Consider using specific @{patterns} for targeted analysis${NC}" >&2 + fi +fi + +# Auto-add approval-mode if not specified +if [[ "$has_approval_mode" == false ]]; then + # Check if this is an analysis task (contains words like "analyze", "review", "understand") + prompt_text="${args[*]}" + if [[ "$prompt_text" =~ (analyze|analysis|review|understand|inspect|examine) ]]; then + echo -e "${GREEN}๐Ÿ“‹ Analysis task detected: Adding --approval-mode default${NC}" >&2 + args=("--approval-mode" "default" "${args[@]}") + else + echo -e "${YELLOW}โšก Execution task detected: Adding --approval-mode yolo${NC}" >&2 + args=("--approval-mode" "yolo" "${args[@]}") + fi +fi + +# Show final command (for transparency) +echo -e "${YELLOW}๐Ÿš€ Executing: qwen ${args[*]}${NC}" >&2 + +# Execute qwen with adjusted arguments +exec qwen "${args[@]}" \ No newline at end of file