Files
proffesor-for-testing__agen…/scripts/consolidate-coverage-tools.sh
Profa 56d1502089 feat(mcp): implement Phase 1 & 2 tool optimization (Issue #115)
Phase 1 Track A - Legacy Tool Removal:
- Remove 11 legacy tools from agenticQETools array
- Remove corresponding TOOL_NAMES entries
- Remove legacy handler registrations from server.ts
- Legacy tools removed: test_generate, quality_analyze, predict_defects,
  optimize_tests, quality_gate_execute, quality_validate_metrics,
  quality_risk_assess, quality_decision_make, quality_policy_check,
  requirements_validate, requirements_generate_bdd

Phase 2 - Lazy Loading Integration:
- Wire ListToolsRequestSchema to use lazy loader
- Return only 14 core tools on initial load (vs 84 total)
- Domain-specific tools loaded on-demand via tools_load_domain
- Add tools_discover and tools_load_domain meta-tools
- Add tool-categories.ts with domain organization
- Add lazy-loader.ts for dynamic tool loading
- Add server-instructions.ts for MCP instructions

Additional Changes:
- Add analysis documentation for optimization work
- Add IntervalRegistry utility for timer management
- Update jest.setup.ts and MemoryManager for stability
- Add coverage tools consolidation plan

Verified Metrics:
- Tool count: 98 → 84 (-14 legacy tools)
- Initial load: 84 → 14 tools
- Token reduction: ~16,885 → ~2,612 tokens (85% reduction)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 18:49:18 +00:00

48 lines
2.2 KiB
Bash

#!/bin/bash
# Script to consolidate coverage analysis tools
# This script:
# 1. Comments out deprecated coverage tools
# 2. Updates TOOL_NAMES constants
# 3. Removes server.ts routing for deprecated tools
set -e
TOOLS_FILE="src/mcp/tools.ts"
SERVER_FILE="src/mcp/server.ts"
echo "Step 1: Comment out coverage_analyze_with_risk_scoring tool definition..."
# Find the line number where this tool starts
LINE_START=$(grep -n "name: 'mcp__agentic_qe__coverage_analyze_with_risk_scoring'" "$TOOLS_FILE" | head -1 | cut -d: -f1)
# Find where it ends (next tool or closing brace)
LINE_END=$(tail -n +$LINE_START "$TOOLS_FILE" | grep -n "^ }," | head -1 | cut -d: -f1)
LINE_END=$((LINE_START + LINE_END - 1))
echo " Tool spans lines $LINE_START to $LINE_END"
# Use sed to comment out those lines
sed -i "${LINE_START},$((LINE_END))s/^/ \/\/ /" "$TOOLS_FILE"
# Add deprecation comment
sed -i "${LINE_START}i\ // DEPRECATED: Use coverage_analyze_stream with mode='risk-scored' instead\n // Kept for backward compatibility only - will be removed in v3.0.0" "$TOOLS_FILE"
echo "Step 2: Comment out TOOL_NAMES constants..."
sed -i 's/^ COVERAGE_ANALYZE_SUBLINEAR:/ \/\/ COVERAGE_ANALYZE_SUBLINEAR:/' "$TOOLS_FILE"
sed -i 's/COVERAGE_ANALYZE_SUBLINEAR;$/COVERAGE_ANALYZE_SUBLINEAR; \/\/ DEPRECATED/' "$TOOLS_FILE"
sed -i 's/^ COVERAGE_GAPS_DETECT:/ \/\/ COVERAGE_GAPS_DETECT:/' "$TOOLS_FILE"
sed -i 's/COVERAGE_GAPS_DETECT;$/COVERAGE_GAPS_DETECT; \/\/ DEPRECATED/' "$TOOLS_FILE"
sed -i 's/^ COVERAGE_ANALYZE_WITH_RISK_SCORING:/ \/\/ COVERAGE_ANALYZE_WITH_RISK_SCORING:/' "$TOOLS_FILE"
sed -i 's/COVERAGE_ANALYZE_WITH_RISK_SCORING;$/COVERAGE_ANALYZE_WITH_RISK_SCORING; \/\/ DEPRECATED/' "$TOOLS_FILE"
echo "Step 3: Update Phase 3 comment..."
sed -i 's/\/\/ Coverage Domain Tools (4 tools)/\/\/ Coverage Domain Tools (Now 2 active tools after consolidation)/' "$TOOLS_FILE"
echo "Done! Coverage tools consolidated."
echo "Remaining active tools:"
echo " - coverage_analyze_stream (unified: basic/risk-scored/sublinear modes)"
echo " - coverage_detect_gaps_ml (unified: ML and non-ML modes via useML parameter)"
echo " - coverage_recommend_tests (unchanged)"
echo " - coverage_calculate_trends (unchanged)"