Skip to main content

scripts-verify-critical-components

#!/usr/bin/env python3 """

title: "Get script directory for path resolution (works from any cwd)" component_type: script version: "1.0.0" audience: contributor status: stable summary: "Verify Critical Components" keywords: ['components', 'critical', 'verify'] tokens: ~500 created: 2025-12-22 updated: 2025-12-22 script_name: "verify-critical-components.py" language: python executable: true usage: "python3 scripts/verify-critical-components.py [options]" python_version: "3.10+" dependencies: [] modifies_files: false network_access: false requires_auth: false

Verify Critical Components

Ensures critical CODITECT components are available and functional. Prevents session startup with missing infrastructure.

Part of Phase 5.2: Session Initialization Created: 2025-11-29 """

import argparse import sys import json from pathlib import Path from typing import List, Tuple, Dict, Any

Get script directory for path resolution (works from any cwd)

SCRIPT_DIR = Path(file).resolve().parent CORE_ROOT = SCRIPT_DIR.parent

Critical components required for CODITECT operation

CRITICAL_COMPONENTS = { 'agent': [ 'codi-documentation-writer', 'orchestrator', 'codebase-locator', 'codebase-analyzer', 'documentation-librarian' ], 'script': [ 'component_activator.py', 'registry_loader.py', 'framework_bridge.py', 'agent_dispatcher.py' ] }

def load_activation_status() -> Dict[str, Any]: """Load component activation status""" status_file = CORE_ROOT / '.coditect' / 'component-activation-status.json'

if not status_file.exists():
print("❌ Error: component-activation-status.json not found")
print(" Run: python3 scripts/generate-activation-status.py")
sys.exit(1)

with open(status_file, 'r') as f:
return json.load(f)

def verify_component_exists(component_type: str, component_name: str, status: Dict[str, Any]) -> Tuple[bool, str]: """ Verify a component exists and is accessible

Returns:
(exists, message)
"""
# Find component in activation status
for component in status.get('components', []):
if (component.get('type') == component_type and
component.get('name') == component_name):

# Check if file exists
path = Path(component.get('path', ''))
if not path.exists():
return False, f"File not found: {path}"

# Check if activated
if not component.get('activated', False):
return False, f"Not activated (reason: {component.get('reason', 'unknown')})"

return True, f"Available at {path}"

return False, "Not found in activation status"

def verify_all_critical_components(status: Dict[str, Any]) -> Tuple[bool, List[str]]: """ Verify all critical components

Returns:
(all_ok, messages)
"""
messages = []
all_ok = True

for component_type, component_names in CRITICAL_COMPONENTS.items():
for component_name in component_names:
exists, message = verify_component_exists(component_type, component_name, status)

if exists:
messages.append(f"✅ {component_type}/{component_name}: {message}")
else:
messages.append(f"❌ {component_type}/{component_name}: {message}")
all_ok = False

return all_ok, messages

def parse_args(): """Parse command line arguments""" parser = argparse.ArgumentParser( description='Verify critical CODITECT components are available and functional.', formatter_class=argparse.RawDescriptionHelpFormatter, epilog=''' Examples: %(prog)s # Verify all critical components %(prog)s --json # Output results as JSON %(prog)s --verbose # Show detailed verification info %(prog)s --list # List critical components without verifying

Critical components include:

  • Core agents: codi-documentation-writer, orchestrator, etc.
  • Core scripts: component_activator.py, registry_loader.py, etc.

Part of CODITECT Phase 5.2: Session Initialization ''' ) parser.add_argument('--json', action='store_true', help='Output results as JSON') parser.add_argument('--verbose', '-v', action='store_true', help='Verbose output') parser.add_argument('--list', action='store_true', help='List critical components without verifying') return parser.parse_args()

def main(): """Main entry point""" args = parse_args()

# Handle --list
if args.list:
print("Critical Components:")
for comp_type, names in CRITICAL_COMPONENTS.items():
print(f"\n {comp_type}:")
for name in names:
print(f" - {name}")
return

try:
# Load activation status
status = load_activation_status()

# Verify critical components
all_ok, messages = verify_all_critical_components(status)

# Print results
print("🔍 Critical Component Verification:")
print()
for message in messages:
print(f" {message}")
print()

if all_ok:
print("✅ All critical components verified")
sys.exit(0)
else:
print("❌ Some critical components missing or unavailable")
print()
print("To activate missing components:")
print(" python3 scripts/update-component-activation.py activate <type> <name>")
sys.exit(1)

except Exception as e:
print(f"❌ Error: {e}")
sys.exit(1)

if name == 'main': main()