Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 09:02:28 +08:00
commit 2381385537
33 changed files with 3414 additions and 0 deletions

267
commands/ai.md Normal file
View File

@@ -0,0 +1,267 @@
## Usage
`/ai <TASK_DESCRIPTION | list | info <role> | workflow | auto>`
## 🎯 Task Complexity Assessment
### Level 0: Micro Tasks - Direct execution
- **Scenario**: Information queries, file reading, status checks
- **Characteristics**: No code modification, pure information retrieval
- **Boundary**: <5 minutes, no professional knowledge needed
- **Triggers**: "view", "check", "display", "read"
- **Action**: Main controller completes directly, no agent calls
### Level 1: Simple Tasks - Single agent direct
- **Scenario**: Single file modification, basic configuration, simple functionality
- **Characteristics**: <50 lines of code, single technology stack, clear requirements
- **Boundary**: One professional domain, no cross-module impact
- **Triggers**: "add", "modify", "configure" single components
- **Action**: Direct call to 1 professional agent, bypassing director
### Level 2: Medium Tasks - Single agent complex
- **Scenario**: Complete functional modules, multi-file coordination, requires testing
- **Characteristics**: 50-200 lines of code, requires planning and validation
- **Boundary**: Single technology stack but complex logic, may require refactoring
- **Triggers**: "implement", "develop", "build" complete features
- **Action**: 1 professional agent handles full process, main controller monitors
### Level 3: Composite Tasks - Multi-agent serial
- **Scenario**: Cross-module functionality, frontend-backend coordination, 2-3 professional domains
- **Characteristics**: 200-500 lines of code, requires multi-step coordination
- **Boundary**: Clear dependency relationships, serial execution
- **Triggers**: "integrate", "connect", "full-stack" functionality
- **Action**: Main controller serially calls 2-3 agents
### Level 4: Parallel Tasks - Multi-agent concurrent
- **Scenario**: Independent module parallel development, performance optimization, multi-platform
- **Characteristics**: 3-5 independent workflows, can execute in parallel
- **Boundary**: Low conflict risk, high independence
- **Triggers**: "simultaneously", "parallel", "multi-platform" development
- **Action**: Main controller calls 3-5 agents in parallel
### Level 5: Enterprise Tasks - Director coordination
- **Scenario**: System refactoring, architecture upgrades, complex project analysis
- **Characteristics**: 5+ professional domains, complex dependencies, multi-phase planning
- **Boundary**: Requires specialized task decomposition and coordination management
- **Triggers**: "refactor", "architecture", "system analysis", "enterprise-level"
- **Action**: task-dispatch-director pure coordination, decompose into Level 1-3 tasks
## ⚡ Auto-Trigger Matrix
**Level 0 Trigger Conditions (no agent calls):**
- Keywords: "view", "check", "display", "read", "list", "status"
- Questions: "what is", "how to understand", "can you explain"
- Operations: Pure information queries, no modification requirements
**Level 1 Trigger Conditions (single agent direct):**
- Keywords: "add", "modify", "update", "configure", "adjust"
- Scope: Single file or component + single technology stack
- Examples: "add Vue component", "modify API endpoint", "configure database connection"
**Level 2 Trigger Conditions (single agent complex):**
- Keywords: "implement", "develop", "build", "create" functional modules
- Scope: Multi-file but single technology stack + requires testing
- Examples: "implement user login", "develop payment module", "build search functionality"
**Level 3 Trigger Conditions (multi-agent serial):**
- Keywords: "integrate", "connect", "full-stack", "end-to-end"
- Scope: 2-3 technology stacks collaboration + clear dependencies
- Examples: "frontend-backend integration", "API integration", "full-stack user system"
**Level 4 Trigger Conditions (multi-agent parallel):**
- Keywords: "simultaneously", "parallel", "multi-platform", "optimize"
- Scope: 3-5 independent modules + low conflict
- Examples: "multi-platform synchronized development", "comprehensive performance optimization"
**Level 5 Trigger Conditions (Director coordination):**
- Keywords: "refactor", "architecture", "system analysis", "enterprise-level", "complete solution"
- Scope: 5+ professional domains + complex planning
- Examples: "system architecture refactoring", "enterprise microservice design", "complex project analysis"
**Mandatory Director Bypass Conditions (Level 0-2):**
- Single file operations
- Clearly specified single technology stack
- User explicitly says "no team collaboration needed"
- Simple information queries and basic modifications
## 🚫 Direct Handling
Handle without agents:
- File reading, searching, basic analysis
- Simple code modifications or config updates
- Information queries and technical explanations
## 🛡️ Anti-Over-Engineering Principles
- **One goal, one agent**: Only call one agent unless true collaboration needed
- **Minimum viable solution**: Choose simplest working method
- **User-oriented**: Based on explicit user needs, not assumptions
## 🎯 Project-Specific Agents Support
### Agent Discovery System
The AI system intelligently detects and integrates both:
- **Global Agents**: Standard agents from `/agents/` directory (always available)
- **Project Agents**: Custom agents from `.claude/agents/` directory (created by `/initx`)
### Project Agent Features
- **Auto-Detection**: Automatically discovers agents in `.claude/agents/` when present
- **Priority System**: Project-specific agents take precedence over global agents
- **Smart Routing**: Intelligently routes to project agents when they match the task better
- **Seamless Integration**: Works with the same `/ai` command interface
### Using Project Agents
```bash
# After running /initx to create project-specific agents:
/ai "optimize checkout flow" # Uses vue-ecommerce-developer if created
/ai "implement payment integration" # Uses payment-integration-specialist
/ai list # Shows both global and project agents
```
## 👥 Team Members (when using `/ai list`)
**Note**: This list shows global agents. If you have run `/initx`, project-specific agents from `.claude/agents/` will also be available and displayed with a 🏢 icon.
### 🏛️ Leadership & Strategy
- 🎯 **task-dispatch-director** - Task coordination hub (⚠️ Never calls itself)
- 🏗️ **cto** - Technical strategy and architecture decisions
- 📊 **product-manager** - Product requirements and PRD creation
### 💻 Development Team
- 📋 **technical-solution-architect** - Technical solution design based on PRDs
- 🎨 **frontend-developer** - React expert, UI components, performance optimization
- 💾 **backend-developer** - Multi-stack API development (FastAPI/Spring Boot/Node.js)
- 🔧 **infrastructure-developer** - Development tools and automation scripts
- 🚀 **devops-engineer** - Docker containerization and deployment
### 🌟 Frontend Technology Stack Experts
- 🌟 **vue-developer** - Vue 2/3, Nuxt.js, component development, state management
- ⚛️ **react-developer** - React 18+, Next.js, modern Hooks patterns
### 🏗️ Backend Architecture Experts
- 🚀 **go-architect** - Go microservice architecture, distributed systems, cloud-native
- 🦀 **rust-architect** - Rust system programming, memory safety, high-performance computing
-**java-developer** - Java enterprise development, Spring Boot microservices
- 🌱 **spring-architect** - Spring full-stack, microservice architecture, enterprise design
### 🐍 Python Web Experts
- 🌶️ **flask-expert** - Flask framework, RESTful API, traditional web applications
-**fastapi-expert** - FastAPI framework, async programming, high-performance APIs
### 📱 Mobile Development
- 📱 **android-developer** - Android native development, Kotlin/Java, Material Design
- 🎨 **mobile-ui-designer** - Mobile UI/UX design, cross-platform interfaces
### 🔐 Security & Reverse Engineering
- 🎣 **android-hooking-expert** - Frida/Hook technology, dynamic analysis
- 📱 **xposed-developer** - Xposed module development, system-level customization
- 🔍 **reverse-engineer** - Code deobfuscation, static analysis
- 🦠 **malware-analyst** - Malware analysis, threat detection
### 🌙 Scripting & Automation
- 🌙 **lua-developer** - Lua script development (game/web/automation scripts)
### 🎨 Design Experts
- 🎨 **google-ui-designer** - Material Design, user experience design
### 🔧 Quality & Operations
- 👀 **code-review-expert** - Code quality review, security checks
- 🚀 **devops-engineer** - Docker deployment, CI/CD, operations monitoring
- 🧪 **test-expert** - Testing strategy, automated testing, performance testing
- 🐛 **qa-engineer** - Problem diagnosis, root cause analysis
- 🔬 **technical-researcher** - Technical research, feasibility analysis
## 🎮 Command Modes
### 🎯 Task Execution (Default)
```
/ai "Add login feature"
/ai "Optimize API performance"
/ai "Code review recent commits"
```
### 📚 Information
- `/ai list` - Show all team members (including project-specific agents if available)
- `/ai info <role>` - Get role details (works with both global and project agents)
- `/ai auto` - Enable maximum automation
- `/initx` - Initialize project and create custom AI team (see `/initx` command)
## 📊 Smart Parallel Task Execution Output
### **Smart Parallel Task Execution Output:**
```
🧠 Intelligent Analysis (ultrathink mode activated)
- Intent: [Detected user goal with confidence %]
- Complexity: [Simple(1-2)/Medium(3-4)/Complex(5)] (Auto-assessed)
- Agent Selection: [Global agents / Project-specific agents if available]
- Parallel Strategy: [Why this parallel approach was chosen]
- Estimated Speedup: [Expected efficiency gain vs serial execution]
🚀 Parallel Execution Plan (Multi-Phase Concurrent)
Phase 1 (Parallel): [3 agents] → [Concurrent analysis/planning]
├── 🎯 [Agent A] → [Specific deliverable] (parallel group 1)
├── 🎯 [Agent B] → [Specific deliverable] (parallel group 1)
└── 🎯 [Agent C] → [Specific deliverable] (parallel group 1)
Phase 2 (Parallel): [2 agents] → [Build on Phase 1 results]
├── 🔄 [Agent D] → [Integration task] (parallel group 2)
└── 🔄 [Agent E] → [Implementation task] (parallel group 2)
⚡ Launching Parallel AI Team...
├── 🚀 Phase 1: Launching 3 concurrent agents...
│ ├── ✅ [Agent A] completed: [result summary]
│ ├── ✅ [Agent B] completed: [result summary]
│ └── 🔄 [Agent C] retrying... (attempt 2/3)
├── 🔄 Integrating Phase 1 results...
├── 🚀 Phase 2: Launching 2 concurrent agents with enhanced context...
│ ├── ✅ [Agent D] completed: [result summary]
│ └── ✅ [Agent E] completed: [result summary]
✅ Mission Complete (Parallel Execution)
- 📦 **Deliverables**: [What was produced across all parallel phases]
- ⚡ **Performance**: [Actual speedup achieved: 3.2x faster than serial]
- 🛡️ **Reliability**: [Retry success rate: 2 retries, 100% final success]
- 🧠 **Learning**: [Pattern for future similar parallel executions]
```
### **Parallel Execution Status Indicators:**
```bash
🚀 Parallel Launch # Multiple agents starting simultaneously
⚡ Partial Success # Some agents completed, others retrying
🔄 Auto-Retry # Intelligent retry with exponential backoff
✅ Phase Complete # All agents in phase finished successfully
🔀 Context Merge # Integrating parallel results for next phase
🛡️ Fallback Mode # Serial execution after parallel retry exhaustion
```
### **Performance Metrics Display:**
```
📊 Parallel Performance Dashboard
- Concurrent agents launched: 8 total across 3 phases
- Parallel efficiency gain: 4.1x faster than serial execution
- Auto-retry success rate: 94% (3 retries recovered, 1 fallback)
- Resource utilization: 87% (optimal parallel agent distribution)
- Total execution time: 12 minutes (vs 49 minutes serial estimate)
```
## 🚀 System Benefits
### 🎯 **Precision Task Routing**
- **Level 0-2**: Bypass director overhead → Direct specialist assignment
- **Level 3-4**: Coordinated multi-agent execution → Optimal resource allocation
- **Level 5**: Enterprise-level orchestration → Complex project management
### ⚡ **Performance Optimization**
- **3x faster** for simple tasks (Level 0-1 direct execution)
- **2x more reliable** for complex tasks (proper coordination)
- **Zero agent overload** (strict role boundaries)
### 🛡️ **Anti-Deadlock Protection**
- **task-dispatch-director** limited to pure coordination only
- **Automatic fallback** when agents fail (3-retry rule)
- **Forced bypass** for simple operations (Level 0-2)
### 🎯 **Development Efficiency**
1. **Single Command** - No need to remember specific roles
2. **Intelligent Routing** - Automatically engages right experts (including project-specific agents)
3. **Full Workflow** - Handles complete development cycle
4. **Quality Gates** - Ensures proper reviews and testing
5. **Coordination** - Manages team collaboration
6. **Project Awareness** - Prioritizes custom project agents when available

290
commands/initx.md Normal file
View File

@@ -0,0 +1,290 @@
# InitX - Project Intelligence & Agent Recruitment System
## Usage
`/initx [OPTIONS]`
## 🎯 Core Function
Analyze project codebase, detect technology stack, and **CREATE NEW PROJECT-SPECIFIC AGENTS** tailored to your unique requirements. Saves custom agents to `.claude/agents/` and updates project `CLAUDE.md`.
## 🚀 Command Modes
### 🎯 Basic Usage
```bash
/initx # Smart analysis & agent creation
/initx --preview # Preview mode (no file creation)
/initx --force # Force overwrite existing agents
```
### 📊 Advanced Options
- `--mode=minimal` - Create only essential agents
- `--focus=security` - Focus on security-specific agents
- `--exclude=ui` - Skip UI/design agents
- `--template=mobile` - Use mobile project template
- `--model=inherit` - Force all agents to use specified model (inherit/sonnet/opus/haiku)
## 🧠 Intelligence Detection Matrix
### Technology Stack Recognition
```yaml
Frontend: vue (*.vue, nuxt.config.js), react (*.jsx, next.config.js), angular
Backend: fastapi (main.py), spring (pom.xml), go (go.mod), node (express/koa)
Mobile: android (*.kt, AndroidManifest.xml), flutter (pubspec.yaml)
Security: reversing (*.apk, frida scripts), hooking (xposed modules)
```
### Project Complexity Assessment
- **Simple**: 1-2 custom agents (single stack)
- **Medium**: 3-5 custom agents (multi-stack)
- **Complex**: 5-8 custom agents (microservices)
- **Enterprise**: 8+ custom agents (distributed)
## 🤖 Agent Creation Algorithm
### Phase 1: Core Stack Agents
**Creates NEW specialized agents based on detected stack:**
- `vue-{project-name}-developer` - Project-specific Vue expert
- `api-{domain}-specialist` - Custom API integration expert
- `{database}-data-architect` - Database-specific data expert
### Phase 2: Domain-Specific Agents
**Creates NEW agents for unique project domains:**
- `{domain}-business-logic-expert` - Business rules specialist
- `{integration}-connector-agent` - Third-party integration expert
- `{platform}-deployment-specialist` - Platform-specific deployment
### Phase 3: Quality & Operations Agents
**Creates NEW agents for project-specific QA:**
- `{stack}-testing-specialist` - Stack-specific testing expert
- `{environment}-ops-engineer` - Environment-specific operations
## 📁 Generated Structure
```
project_root/
├── .claude/
│ └── agents/ # NEW custom agents
│ ├── vue-ecommerce-developer.md
│ ├── payment-integration-specialist.md
│ ├── postgres-data-architect.md
│ └── aws-deployment-specialist.md
├── CLAUDE.md # Updated with new team
└── .gitignore # Updated exclusions
```
## 🏗️ Custom Agent Template
⚠️ **LANGUAGE REQUIREMENT**: All agent content MUST be generated in ENGLISH.
```markdown
---
name: {project-domain}-{specialization}-agent
description: Project-specific {specialization} expert for {project_name}
model: inherit # Options: inherit | sonnet | opus | haiku
---
You are the **{Project Domain} {Specialization} Agent** for the {project_name} project.
## STRICT AGENT BOUNDARIES
**ALLOWED ACTIONS:**
- {Domain-specific actions based on project analysis}
- {Tech stack specific implementations}
- {Integration and performance optimizations}
**FORBIDDEN ACTIONS:**
- {Cross-domain work} (delegate to {appropriate_agent})
- Infrastructure concerns (delegate to devops-engineer)
- Security audits (delegate to code-review-expert)
**CORE MISSION:** {Single sentence describing the agent's purpose}
## RESPONSIBILITIES
### 1. {Primary Domain Area}
- {Specific responsibilities based on project analysis}
- {Pattern implementations from detected codebase}
### 2. {Quality & Testing}
- {Testing requirements specific to domain}
- {Performance criteria for project}
### 3. {Collaboration}
- Input from: {upstream agents}
- Output to: {downstream agents}
- Coordinate with: {peer agents}
## TECHNOLOGY STACK
**Primary**: {Detected technologies with versions}
**Integrations**: {Third-party services}
**Constraints**: Work exclusively within {project_domain} of {project_name}
```
## 🧠 Intelligent Model Selection System
### Model Selection Matrix
```yaml
Complex Reasoning (opus): Architecture design, security analysis, microservices
Balanced Performance (sonnet): Most development agents, API/database, testing
Simple Fast (haiku): Config generation, simple scripts, documentation
Inherit from Parent (inherit): Maintain consistency, avoid switching overhead
```
### Force Model Option (--model parameter)
```bash
/initx --model=inherit # All agents inherit from parent (best for cost control)
/initx --model=sonnet # All agents use Sonnet (balanced performance)
/initx --model=opus # All agents use Opus (maximum reasoning)
/initx --model=haiku # All agents use Haiku (fastest response)
```
⚠️ Using `--model` overrides intelligent model selection for consistency/cost control.
### User Confirmation Flow
#### Standard Mode (Intelligent Model Selection)
```bash
🤖 Agent Creation - {agent_name}
📊 Recommended: {suggested_model} ({reason})
Select model: [1] ✅ Recommended [2] Opus [3] Sonnet [4] Haiku [5] Inherit
Confirm? [y/N]
```
#### Force Model Mode (--model parameter)
```bash
🤖 Agent Creation - {agent_name}
📊 Model: {forced_model} (forced by --model)
Confirm? [y/N]
```
### ⚠️ IMPORTANT: Language Requirements
**All generated agents MUST be created in English**, regardless of the user's input language:
- Agent names: Always in English (e.g., `vue-ecommerce-developer`, not `vue-电商-开发者`)
- Agent descriptions: Always in English
- Agent content: Always in English
- Documentation comments: Always in English
This ensures consistency and compatibility across all projects and teams.
## ⚡ Execution Flow
### Phase 1: Project Intelligence (15s)
```bash
🔍 Analyzing project structure...
├── 📊 Detecting tech stack and versions
├── 🏗️ Identifying architecture patterns
├── 📈 Assessing complexity and scale
└── 🎯 Discovering unique requirements
✅ Analysis Complete
- Type: E-commerce Web App
- Stack: Vue 3 + FastAPI + PostgreSQL
- Complexity: Medium (4/5)
- Unique: Payment integration, inventory management
```
### Phase 2: Agent Creation & Confirmation (20s)
#### Standard Mode:
```bash
🤖 Intelligent Model Matching...
vue-ecommerce-developer (recommended: sonnet)
├─ Reason: Vue 3 patterns, balanced performance
├─ Select: [1] ✅ sonnet [2] opus [3] haiku [4] inherit
└─ ✅ Created
fastapi-payment-specialist (recommended: opus)
├─ Reason: Payment integration, complex logic
├─ Select: [1] ✅ opus [2] sonnet [3] haiku [4] inherit
└─ ✅ Created
[... more agents ...]
📊 Created 8 agents: 4 sonnet, 2 opus, 1 haiku, 1 inherit
```
#### Force Model Mode (/initx --model=inherit):
```bash
🤖 Force Model: inherit (all agents use parent model)
vue-ecommerce-developer
├─ ⚠️ Using inherit (recommended: sonnet)
└─ ✅ Created
fastapi-payment-specialist
├─ ⚠️ Using inherit (recommended: opus)
└─ ✅ Created
[... more agents ...]
📊 Created 8 agents: 8 inherit (forced)
```
### Phase 3: Team Configuration (10s)
```bash
📝 Configuring AI team collaboration...
├── 📁 Saving agents to .claude/agents/ directory
├── 🔧 Setting up collaboration matrix and dependencies
├── 📋 Updating CLAUDE.md with team information
└── 🎯 Ready for project-specific task execution
✅ Custom AI team ready!
🚀 Use /ai "optimize checkout flow" to engage specialist team
```
## 🎛️ Smart Templates
### E-commerce Project
```yaml
detected_patterns: [shopping_cart, payment_flow, inventory]
created_agents:
- payment-integration-specialist
- inventory-management-expert
- customer-analytics-agent
- ecommerce-testing-specialist
```
### Security Research Project
```yaml
detected_patterns: [apk_analysis, hooking, reverse_engineering]
created_agents:
- android-malware-analyst
- frida-hooking-specialist
- apk-reverse-engineer
- vulnerability-scanner-expert
```
### Microservices Project
```yaml
detected_patterns: [service_mesh, api_gateway, distributed_data]
created_agents:
- service-mesh-architect
- api-gateway-specialist
- distributed-data-expert
- microservices-testing-specialist
```
## 🚀 System Benefits
### 🎯 **Project-Specific Intelligence**
- **Custom Agents**: Tailored to your exact tech stack and domain
- **Smart Collaboration**: Agents know your project's integration points
- **Model Flexibility**: Choose optimal model strategy with `--model` parameter
### ⚡ **Rapid Development**
- **10x Faster**: Custom experts vs generic agents
- **Zero Learning Curve**: Agents pre-configured for your project
- **Cost Control**: Force consistent model usage with `--model=inherit`
### 💰 **Cost Management**
- **Default**: Intelligent per-agent model selection
- **--model=inherit**: Maximum cost control
- **--model=sonnet**: Balanced cost/performance
- **--model=haiku**: Minimum cost, fast response
---
**InitX creates your perfect AI development team - not just assigns existing ones!**
🚀 One command, custom specialists, exponential productivity!