Skip to main content

TypeScript Self-Healing System - Quick Start

TypeScript Self-Healing System - Quick Start

Separation of Duties: See Separation of Duties - Getting started guides document onboarding. They do NOT own agent manifests, execution, or infrastructure configuration.

Immediate Actions

1. Start Qdrant (Required for pattern learning)

docker run -d -p 6333:6333 --name qdrant qdrant/qdrant

2. Heal Current Project (agent-buildkit)

cd $LLM_ROOT/worktrees/33-fix-typescript-compilation-errors tsx $LLM_ROOT/scripts/intelligent-healer.ts .

3. Scan All Projects

tsx $LLM_ROOT/scripts/scan-all-projects.ts

4. View Health Dashboard

tsx $LLM_ROOT/scripts/ts-health-dashboard.ts

Current Status

agent-buildkit: 2,695 errors (down from 7,914 - 66% reduction)

Error Breakdown

  • TS2339 (841): Property does not exist - Manual fix needed
  • TS2304 (747): Cannot find name - Auto-fixable
  • TS2307 (369): Cannot find module - Auto-fixable
  • TS2532 (127): Possibly undefined - Manual fix needed
  • TS2322 (91): Type mismatch - Manual fix needed

Auto-Fixes Applied

  1. Created src/types/global.d.ts - Node.js globals
  2. Created src/types/modules.d.ts - Missing module declarations
  3. Created src/types/globals.d.ts - Service constants
  4. Updated tsconfig.json - Optimal compiler settings

Next Steps

For agent-buildkit (current project)

  1. Fix TS2339 errors (841 remaining)

    • Add proper type definitions for Agent interface
    • Add metrics property to Agent type
  2. Fix TS2532 errors (127 remaining)

    • Add null checks: if (obj) { ... }
    • Use optional chaining: obj?.property
  3. Fix TS2322 errors (91 remaining)

    • Correct type mismatches
    • Add type assertions where needed

For other projects

Run healer on each project:

# Agent Infrastructure tsx scripts/intelligent-healer.ts $LLM_ROOT/common_npm/agent-brain tsx scripts/intelligent-healer.ts $LLM_ROOT/common_npm/agent-chat tsx scripts/intelligent-healer.ts $LLM_ROOT/common_npm/agent-mesh tsx scripts/intelligent-healer.ts $LLM_ROOT/common_npm/agent-protocol tsx scripts/intelligent-healer.ts $LLM_ROOT/common_npm/agent-router # Platform Services tsx scripts/intelligent-healer.ts $LLM_ROOT/common_npm/workflow-engine tsx scripts/intelligent-healer.ts $LLM_ROOT/common_npm/compliance-engine tsx scripts/intelligent-healer.ts $LLM_ROOT/common_npm/agentic-flows

Prevention Setup

Install Pre-Commit Hook

cd $LLM_ROOT/common_npm/agent-buildkit ln -s ../../../scripts/prevent-ts-errors.sh .git/hooks/pre-commit chmod +x .git/hooks/pre-commit

Add to CI/CD

Already created: .gitlab/workflows/typescript-guard.yml

Merge this to enable automatic checks on all MRs.

Pattern Learning

Every time you run the healer, patterns are stored in Qdrant:

  • Error codes and frequencies
  • Fix strategies that worked
  • Cross-project correlations

The system learns and improves auto-fixes over time.

Monitoring

# Check health of all projects tsx scripts/ts-health-dashboard.ts # Scan specific project tsx scripts/intelligent-healer.ts /path/to/project # View stored patterns curl http://localhost:6333/collections/ts_error_patterns

Tips

  1. Run healer after npm install - Catches new type issues early
  2. Check dashboard weekly - Monitor error trends
  3. Commit healer reports - Track improvements over time
  4. Share patterns - Qdrant learns from all projects

Troubleshooting

Qdrant not running

docker ps | grep qdrant docker start qdrant

Healer not fixing errors

# Check what it tried to fix cat .ts-healer-report.json # Verify TypeScript config cat tsconfig.json | grep -A5 compilerOptions

Pre-commit hook not working

# Make sure it's executable chmod +x .git/hooks/pre-commit # Test manually .git/hooks/pre-commit

Full Documentation

See: $LLM_ROOT/docs/TYPESCRIPT-SELF-HEALING.md