feat: Add smart tech stack detection for code-developer and code-review-test agents

- Add intelligent task-based loading of tech stack guidelines
- Only load tech stacks for development and code review tasks
- Simplify detection logic using ls commands instead of complex find
- Support TypeScript, React, Python, Java, Go, and JavaScript stacks
- Optimize performance by skipping detection for non-relevant tasks

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
catlog22
2025-09-28 14:38:36 +08:00
parent b956943f15
commit 5d08c5381d
2 changed files with 59 additions and 57 deletions

View File

@@ -49,27 +49,26 @@ You will review code changes AND handle test implementation by understanding the
## Analysis CLI Context Activation Rules
**🎯 Pre-Analysis: Tech Stack Detection and Loading**
MANDATORY FIRST STEP for all reviews:
**🎯 Pre-Analysis: Smart Tech Stack Loading**
Only for code review tasks:
```bash
# Step 1: Detect project tech stack
TECH_STACK="default"
if find . -name "tsconfig.json" -o -name "*.ts" -o -name "*.tsx" 2>/dev/null | head -1; then
TECH_STACK="typescript-dev"
elif find . -name "package.json" 2>/dev/null | xargs grep -l "react" 2>/dev/null; then
TECH_STACK="react-dev"
elif find . -name "*.py" -o -name "requirements.txt" -o -name "pyproject.toml" 2>/dev/null | head -1; then
TECH_STACK="python-dev"
elif find . -name "*.java" -o -name "pom.xml" -o -name "build.gradle" 2>/dev/null | head -1; then
TECH_STACK="java-dev"
elif find . -name "*.go" -o -name "go.mod" 2>/dev/null | head -1; then
TECH_STACK="go-dev"
elif find . -name "*.js" -o -name "package.json" 2>/dev/null | head -1; then
TECH_STACK="javascript-dev"
# Smart detection: Only load tech stack for code reviews
if [[ "$TASK_DESCRIPTION" =~ (review|test|check|analyze|audit) ]] && [[ "$TASK_DESCRIPTION" =~ (code|implementation|module|component) ]]; then
# Simple tech stack detection
if ls *.ts *.tsx 2>/dev/null | head -1; then
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/typescript-dev.md)
elif grep -q "react" package.json 2>/dev/null; then
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/react-dev.md)
elif ls *.py requirements.txt 2>/dev/null | head -1; then
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/python-dev.md)
elif ls *.java pom.xml build.gradle 2>/dev/null | head -1; then
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/java-dev.md)
elif ls *.go go.mod 2>/dev/null | head -1; then
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/go-dev.md)
elif ls *.js package.json 2>/dev/null | head -1; then
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/javascript-dev.md)
fi
fi
# Step 2: Load tech stack guidelines
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/${TECH_STACK}.md 2>/dev/null || echo "# Default Development Guidelines\nFollow general best practices.")
```
**🎯 Flow Control Detection**
@@ -85,24 +84,26 @@ When task assignment includes flow control marker:
**Context Gathering Decision Logic**:
```
MANDATORY FIRST STEP:
→ Execute tech stack detection and load guidelines into [tech_guidelines] variable
IF task is code review related (review|test|check|analyze|audit + code|implementation|module|component):
→ Execute smart tech stack detection and load guidelines into [tech_guidelines] variable
→ All subsequent review criteria must align with loaded tech stack principles
ELSE:
→ Skip tech stack loading for non-code-review tasks
IF task contains [FLOW_CONTROL] flag:
→ Execute each flow control step sequentially for context gathering
→ Use four flexible context acquisition methods:
* Document references (cat commands with tech stack context)
* Search commands (grep/rg/find for tech-specific patterns)
* CLI analysis (gemini/codex with tech stack guidelines)
* Free exploration (Read/Grep/Search tools guided by tech principles)
* Document references (cat commands)
* Search commands (grep/rg/find)
* CLI analysis (gemini/codex)
* Free exploration (Read/Grep/Search tools)
→ Process [variable_name] references in commands
→ Accumulate context through step outputs
Ensure [tech_guidelines] informs all analysis steps
Include [tech_guidelines] in analysis if available
ELIF reviewing >3 files OR security changes OR architecture modifications:
→ Execute default flow control analysis (AUTO-TRIGGER) with tech stack guidelines
→ Execute default flow control analysis (AUTO-TRIGGER)
ELSE:
→ Proceed with tech-stack-informed review using standard quality checks
→ Proceed with review using standard quality checks (with tech guidelines if loaded)
```
## Review Process (Mode-Adaptive)