mirror of
https://github.com/proffesor-for-testing/agentic-qe.git
synced 2026-09-19 08:45:47 +08:00
fd2f37eaa0
Changes: - Fix README.md agent counts (48 QE agents = 41 main + 7 subagents) - Fix README.md skill counts (15 QE-specific skills) - Fix v3/README.md agent counts (47 → 48) - Fix init-wizard.ts hooks from 'npx @agentic-qe/v3' to 'npx agentic-qe' - Complete v2 → v2/ folder reorganization (54 items moved) - Update root package.json to point to v3 as main version Verified claims: - 48 QE agents (41 main + 7 TDD subagents) - 15 QE-specific skills - 12 DDD bounded contexts - ~5,600+ tests - HNSW, ReasoningBank, Queen Coordinator features exist Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Phase 1 Examples (v1.0.5)
This directory contains code examples demonstrating Phase 1 features: Multi-Model Router and Streaming MCP Tools.
📁 Directory Structure
phase1/
├── routing/
│ ├── basic-routing.ts # Basic model selection
│ └── cost-tracking.ts # Cost tracking and reporting
├── streaming/
│ ├── test-generation-stream.ts # Streaming test generation
│ └── test-execution-stream.ts # Streaming test execution
└── cost-tracking/
└── budget-management.ts # Budget management and forecasting
🚀 Quick Start
Prerequisites
# Install dependencies
npm install agentic-qe@latest
npm install progress chalk ora
# Set API keys
export OPENAI_API_KEY="sk-..."
export ANTHROPIC_API_KEY="sk-ant-..."
Run Examples
# Routing examples
npx ts-node routing/basic-routing.ts
npx ts-node routing/cost-tracking.ts
# Streaming examples
npx ts-node streaming/test-generation-stream.ts
npx ts-node streaming/test-execution-stream.ts
# Budget management
npx ts-node cost-tracking/budget-management.ts
📚 Examples Overview
1. Basic Routing (routing/basic-routing.ts)
Demonstrates basic model selection based on task complexity.
Features:
- Simple task routing (GPT-3.5)
- Complex task routing (GPT-4)
- Critical task routing (Claude Sonnet 4.5)
- Cost estimation
Key Concepts:
const router = new ModelRouter(config);
const selection = await router.selectModel(task);
console.log(`Selected: ${selection.modelId}`);
console.log(`Cost: $${selection.estimatedCost}`);
2. Cost Tracking (routing/cost-tracking.ts)
Comprehensive cost tracking and reporting.
Features:
- Real-time cost tracking
- Budget management
- Cost breakdown by model/agent
- Savings analysis
- CSV/JSON export
Key Concepts:
const tracker = new CostTracker();
tracker.setBudget({ period: 'daily', limit: 50.00 });
// Track execution
tracker.record(execution);
// Get report
const report = await tracker.getBreakdown();
console.log(`Savings: ${report.savings.percentage}%`);
3. Test Generation Streaming (streaming/test-generation-stream.ts)
Real-time progress updates for test generation.
Features:
- Live progress bar
- Test-by-test updates
- Coverage tracking
- Colored terminal output
- Metrics monitoring
Key Concepts:
const stream = await fleet.streamTestGeneration(options);
stream.on('progress', (update) => {
console.log(`${update.progress}%`);
});
stream.on('test:generated', (test) => {
console.log(`✓ ${test.name}`);
});
const result = await stream.complete();
4. Test Execution Streaming (streaming/test-execution-stream.ts)
Real-time progress updates for test execution.
Features:
- Live test results
- Pass/fail tracking
- Coverage updates
- Suite summaries
- Failed test details
Key Concepts:
const stream = await fleet.streamTestExecution(options);
stream.on('test:passed', (test) => {
console.log(`✓ ${test.name}`);
});
stream.on('test:failed', (test) => {
console.error(`✗ ${test.name}: ${test.error.message}`);
});
5. Budget Management (cost-tracking/budget-management.ts)
Comprehensive budget management and forecasting.
Features:
- Multi-level budgets (daily, monthly, project, team)
- Alert configuration
- Dynamic adjustments
- Cost forecasting
- Report generation
Key Concepts:
const budgetManager = new BudgetManager();
// Set budgets
await budgetManager.setBudget({
period: 'daily',
limit: 50.00,
onExceeded: 'pause'
});
// Check status
const status = await budgetManager.getStatus('daily-budget');
// Forecast
const forecast = await budgetManager.forecastCosts({
period: 'month'
});
🎯 Use Cases
Cost Optimization
- Start with Basic Routing to understand model selection
- Add Cost Tracking to monitor spending
- Implement Budgets to control costs
- Use Forecasting for planning
Real-Time Monitoring
- Enable Streaming for long operations
- Add Progress Bars for better UX
- Track Metrics for performance
- Handle Errors gracefully
Team Management
- Set Team Budgets for cost allocation
- Configure Alerts for notifications
- Generate Reports for stakeholders
- Optimize Rules based on usage
📖 Related Documentation
- Multi-Model Router Guide
- Streaming API Tutorial
- Cost Optimization Best Practices
- Migration Guide
- Routing API Reference
- Streaming API Reference
💡 Tips
Performance
- Use streaming for operations >5 seconds
- Enable caching for repeated operations
- Batch operations when possible
- Monitor memory usage
Cost Savings
- Use GPT-3.5 for simple tasks (10x cheaper)
- Enable adaptive routing (learns over time)
- Set daily/monthly budgets
- Review cost reports weekly
Reliability
- Always handle errors
- Implement fallback chains
- Clean up event listeners
- Monitor connection status
🐛 Troubleshooting
"No models available"
// Ensure models are configured
const router = new ModelRouter({
models: {
available: [
{ id: 'gpt-3.5-turbo', provider: 'openai', costPer1kTokens: 0.002, maxTokens: 4096 }
]
}
});
"API key not found"
export OPENAI_API_KEY="sk-..."
export ANTHROPIC_API_KEY="sk-ant-..."
"No progress updates"
// Attach listeners BEFORE starting stream
stream.on('progress', handler);
await stream.start(); // Not before!
🤝 Contributing
Have a great example? Submit a PR!
- Create example file in appropriate directory
- Add documentation comments
- Include expected output
- Update this README
Questions? Open an issue: https://github.com/proffesor-for-testing/agentic-qe/issues