# ⚡ Quick Test Guide - Deep Search System

**Test ces commandes pour voir la vitesse !**

---

## 🔥 Tests Rapides (Copie-colle)

### 1. Analyse Profonde d'un Fichier
```bash
time rtanalyze apps/web/src/modules/planner/stores/plannerStore.ts | jq .
```
**Expected:** ~100ms, montre imports/exports/functions/stats

### 2. Trouver Tous les Fichiers Liés
```bash
time rtrelated "PlanCard" | jq .
```
**Expected:** ~50ms, montre definitions/imports/references

### 3. Analyse d'Impact (Blast Radius)
```bash
time rtimpact apps/web/src/modules/planner/stores/plannerStore.ts | jq .
```
**Expected:** ~108ms, montre 14 importers direct, blast radius = 28

### 4. Analyse Complète d'un Module
```bash
time rtmodule planner | jq .
```
**Expected:** ~200ms, montre ALL components/pages/services/stores/routes

### 5. Santé du Projet
```bash
time rthealth | jq .
```
**Expected:** ~163ms, montre TODOs/console.logs/@ts-ignores/coverage

---

## 🎯 Test Complet (Workflow Agent)

**Scenario:** Tu veux éditer `plannerStore.ts`

```bash
# Step 1: Deep analysis (100ms)
rtanalyze apps/web/src/modules/planner/stores/plannerStore.ts

# Step 2: Find related (50ms)
rtrelated "usePlannerStore"

# Step 3: Impact analysis (108ms)
rtimpact apps/web/src/modules/planner/stores/plannerStore.ts

# Step 4: Module context (200ms)
rtmodule planner

# Step 5: Search patterns (30ms each)
rta search/text "usePlannerStore"
rta search/text "createPlan"
rta search/count "Plan"

# Step 6: Health check (163ms)
rthealth

# TOTAL: ~651ms for COMPLETE understanding!
```

---

## 📊 Performance Comparison

**OLD way (grep):**
```bash
time grep -r "usePlannerStore" apps/
# → 2-5 seconds, partial results
```

**NEW way (ripgrep + deep search):**
```bash
time rtrelated "usePlannerStore"
# → 50ms, complete results (50-100x faster!)
```

---

## 🧪 Benchmarks

### Test Individual Commands

```bash
# Benchmark deep-analyze
hyperfine "rtd deep-analyze apps/web/src/modules/planner/stores/plannerStore.ts"

# Benchmark find-related
hyperfine "rtd find-related PlanCard"

# Benchmark impact
hyperfine "rtd impact apps/web/src/modules/planner/stores/plannerStore.ts"

# Benchmark module
hyperfine "rtd analyze-module planner"

# Benchmark health
hyperfine "rtd health"
```

---

## 🔍 Search Examples

### Find Where Component is Used
```bash
rtrelated "PlanCard"
rta search/text "import.*PlanCard"
rta search/count "PlanCard"
```

### Find Endpoint Usage
```bash
rta search/text "POST /api/plans"
rta search/text "GET /api/plans"
rta search/text "fetch.*plans"
```

### Find Store Action Usage
```bash
rta search/text "plannerStore\.createPlan"
rta search/text "plannerStore\.updatePlan"
rta search/count "plannerStore"
```

### Find Type Usage
```bash
rtrelated "Plan"
rta search/count "interface Plan"
rta search/count "type Plan"
```

---

## 💡 Pro Tips

### 1. Parallel Mental Execution
Agent peut planifier 10-20 commandes et les "exécuter" mentalement en parallèle (toutes prennent ~30-50ms)

### 2. Always Check Impact
Avant ANY edit:
```bash
rtimpact <file>
```
Si blast radius > 20, fais plus d'analyses avant d'éditer.

### 3. Module Overview First
Si tu ne connais pas le module:
```bash
rtmodule <domain>
```
Donne la structure complète en 200ms.

### 4. Health Check for Context
```bash
rthealth
```
Montre l'état général du projet (TODOs, console.logs, test coverage).

### 5. Cross-Reference Everything
```bash
rtrelated <symbol>    # Who uses it?
rta search/count     # How many times?
rtimpact <file>      # What breaks?
```

---

## 🎓 Test Sequence (Pour Agents)

**Challenge:** Analyse complète en moins de 1 seconde

```bash
# Parallel batch 1 (200ms total - slowest wins)
rtanalyze apps/web/src/modules/planner/stores/plannerStore.ts &
rtrelated "usePlannerStore" &
rtimpact apps/web/src/modules/planner/stores/plannerStore.ts &

# Parallel batch 2 (200ms total)
rtmodule planner &
rta search/text "usePlannerStore" &
rta search/text "createPlan" &
rta search/count "Plan" &

# Final (163ms)
rthealth

# TOTAL: 200 + 200 + 163 = 563ms for EVERYTHING!
```

---

## 🚀 Commandes Utiles

### Navigation Rapide
```bash
rt fsearch          # Fuzzy search files
rt jump             # Jump to indexed file
fo                  # Fuzzy open with preview
```

### Recherche Texte
```bash
ff                  # Live text search with fzf
rt search "term"    # Search text
rta search/text     # Agent API search (JSON)
```

### Stats & Info
```bash
rtstats            # Project stats
rttech             # Tech stack
rtmods             # List modules
```

### Project Health
```bash
rthealth           # Full health check
aginfo             # TODO count
scanjs             # Line count by file
```

---

## 📈 Expected Results

| Command | Time | Output |
|---------|------|--------|
| `rtanalyze` | 100ms | Imports, exports, functions, stats |
| `rtrelated` | 50ms | All files that use/define symbol |
| `rtimpact` | 108ms | Blast radius, direct importers |
| `rtmodule` | 200ms | Full module structure |
| `rthealth` | 163ms | Project quality metrics |
| `rta search/text` | 30ms | Ripgrep search (JSON) |
| `rta search/count` | 10ms | Count occurrences |

---

## 🎯 Success Criteria

**After testing, you should see:**
- ✅ All commands execute in < 300ms
- ✅ JSON output (agent-friendly)
- ✅ Complete information (not partial)
- ✅ Can do 10+ searches in < 1s
- ✅ No errors or warnings
- ✅ Results are accurate

**If any command takes > 500ms:** Check if indexing is needed:
```bash
rt index
```

---

## 🔧 Troubleshooting

### Command Not Found
```bash
# Re-source aliases
source scripts/rt-aliases.sh

# Or use full path
~/Documents/MyRoadTrip/scripts/rt-deep.sh deep-analyze <file>
```

### Slow Performance
```bash
# Rebuild index
rt index

# Clear cache
rm -rf ~/.rt-cli/cache/*

# Benchmark to compare
rt bench
```

### No Output
```bash
# Check if file exists
ls -la <file>

# Try with full path
rtd deep-analyze "$(pwd)/apps/web/src/..."

# Check ripgrep works
rg --version
```

---

**Ready? Copie les commandes ci-dessus et teste !** 🚀
