provisioning/.migration/agents/03_analyze_env.sh
Jesús Pérez 19d2d1ae58 feat: add token-efficient migration agent scripts
- 01_analyze_syntax.sh: Find syntax errors (~1500 tokens)
- 02_fix_syntax.sh: Fix syntax in specific files (~1000 tokens)
- 03_analyze_env.sh: Find ENV references (~1200 tokens)
- 04_migrate_env.sh: Migrate ENV to config (~1500 tokens)
- 05_test_module.sh: Test modules after migration (~800 tokens)
- migration_coordinator.sh: Orchestrate complete migration
- README.md: Usage instructions and safety features

Total migration cost: ~15-20k tokens vs 50k+ monolithic approach
2025-09-22 23:44:56 +01:00

62 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# Agent 3: ENV Reference Analyzer
# Finds all ENV variable references that need migration
# Token-efficient: ~1200 tokens total
echo "🔍 Launching ENV Reference Analyzer Agent..."
# Create knowledge bundle for agent
KNOWLEDGE=$(cat << 'EOF'
# ENV Reference Analysis Task
## Find These Patterns:
- $env.PROVISIONING
- $env.PROVISIONING_DEBUG
- $env.PROVISIONING_OUT
- $env.PROVISIONING_ARGS
- $env.PROVISIONING_MODULE
- $env.PROVISIONING_*PATH
## Categorize:
1. **MIGRATE**: Static config values
- PROVISIONING (base path)
- PROVISIONING_DEBUG
- PROVISIONING_*_PATH
2. **KEEP**: Runtime state
- PROVISIONING_ARGS (command args)
- PROVISIONING_OUT (output redirection)
- NOW (timestamps)
- CURRENT_* (context variables)
## Output Format:
```json
{
"migrate_to_config": [
{"file": "path/file.nu", "line": 45, "var": "PROVISIONING", "replacement": "get-base-path"}
],
"keep_as_env": [
{"file": "path/file.nu", "line": 23, "var": "PROVISIONING_ARGS", "reason": "runtime"}
],
"total_env_refs": 89,
"migration_needed": 56
}
```
EOF
)
# Launch Claude Code agent
claude-code task \
--description "Find ENV references needing migration" \
--prompt "$KNOWLEDGE
TASK: Find all \$env.PROVISIONING_* references in .nu files
SCOPE: All core/ directories
CATEGORIZE: Which need migration vs which stay as ENV
OUTPUT: JSON report with migration plan" \
--type "general-purpose" \
> .migration/state/env_analysis.json
echo "✅ ENV analysis complete. Results in .migration/state/env_analysis.json"
echo "📊 Run: cat .migration/state/env_analysis.json | jq '.migrate_to_config | length'"