Skip to content

shiri-09/REPAIR.ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔧 REPAIR.ai

Autonomous Build & Test Failure Recovery via Agentic Intelligence

An agentic AI system that autonomously observes failing builds/tests, generates competing hypotheses, tests fixes, and learns from outcomes — all while making its reasoning transparently visible in real-time.

TypeScript Node.js Groq License: MIT


REPAIR.ai Architecture

🏆 Built for the 2026 Agentathon


✨ What Makes REPAIR.ai Different?

This is NOT a chatbot. This is NOT an automation script. This is an AUTONOMOUS AGENT.

REPAIR.ai is a goal-driven autonomous agent that follows the core agentic loop:

   ╭──────────────────────────────────────────╮
   │           AGENTIC LOOP                   │
   │                                          │
   │   PERCEIVE ──▶ REASON ──▶ ACT ──▶ LEARN  │
   │       ▲                           │      │
   │       └───────────────────────────┘      │
   ╰──────────────────────────────────────────╯
Phase Description
👁️ PERCEIVE Observes CI/build/test failures with deterministic signal extraction
🧠 REASON Generates 3-5 competing hypotheses with confidence scores
ACT Plans and executes safe, minimal, reversible fixes
📚 LEARN Reflects on outcomes and stores patterns for future

🎯 Key Features

🏆 Multi-Hypothesis Tournament

Watch hypotheses compete in real-time! Each hypothesis has a confidence score that updates dynamically as evidence comes in.

╔══════════════════════════════════════════════════════════════╗
║  🏆 HYPOTHESIS TOURNAMENT - Round 3                          ║
╠══════════════════════════════════════════════════════════════╣
║  🥇 Package typo: lodsh→lodash  [██████████████████░░] 90% ⬆️ ║
║  🥈 Missing type definitions    [████████████░░░░░░░░] 60% ⬇️ ║
║  🥉 Dependency version conflict [████████░░░░░░░░░░░░] 40% ➡️ ║
╚══════════════════════════════════════════════════════════════╝

⚡ Two-Tier Fix Strategy

TIER 1: Deterministic Fixes (Fast Path)

  • ⚡ Recognized known failure patterns
  • 🧠 Skips LLM reasoning
  • 🚀 Executes proven fixes directly

TIER 2: LLM-Powered Fixes (Smart Path)

  • 🤖 For novel failures
  • 💡 Intelligent reasoning
  • 🔍 Multi-hypothesis approach

🛡️ Production-Hardened LLM Integration

  • jsonrepair — Automatically fixes malformed LLM JSON output
  • Simplified retry — Reduces prompt verbosity on each retry
  • Temperature decay — Lowers temperature for more deterministic retries
  • Confidence clamping — Values always between 0.1-0.95

🧪 Adversarial Injection Testing

Inject failures on-demand to prove system robustness:

Injection Type Description
new_failure Introduces package typo
flaky_test Adds fake dependency
dependency_break Breaks existing dependency

📺 Real-Time Transparency UI

  • 🎮 Live hypothesis tournament visualization
  • 📜 Event timeline with full history
  • ⏪ Time travel slider (replay past states)
  • 🎉 Success celebration modal with confetti!

🚀 Quick Start

# 1. Clone the repository
git clone https://github.com/shiri-09/REPAIR.ai.git
cd REPAIR.ai

# 2. Install dependencies
npm install

# 3. Set up environment variables
cp .env.example .env
# Add your GROQ_API_KEY (free at console.groq.com)

# 4. Reset demo to broken state
reset-demo.bat  # Windows
./reset-demo.sh # Linux/Mac

# 5. Run the demo
npm run demo

Then open: http://localhost:3000 🌐


🏗️ Architecture

┌─────────────────────────────────────────────────────────────────────┐
│                         REPAIR.ai Architecture                       │
├─────────────────────────────────────────────────────────────────────┤
│                                                                      │
│  ┌─────────────────┐     ┌─────────────────┐     ┌───────────────┐  │
│  │  OBSERVATION    │────▶│   REASONING     │────▶│   EXECUTION   │  │
│  │     LAYER       │     │     ENGINE      │     │    LAYER      │  │
│  │ (Deterministic) │     │  (LLM-Powered)  │     │  (Sandboxed)  │  │
│  └─────────────────┘     └─────────────────┘     └───────────────┘  │
│         │                        │                       │          │
│         ▼                        ▼                       ▼          │
│  ┌─────────────────┐     ┌─────────────────┐     ┌───────────────┐  │
│  │    MEMORY       │◀────│   REFLECTION    │◀────│    SAFETY     │  │
│  │    SYSTEM       │     │    MODULE       │     │    GATES      │  │
│  │  (SQLite DB)    │     │ (Belief Update) │     │  (Rollback)   │  │
│  └─────────────────┘     └─────────────────┘     └───────────────┘  │
│                                                                      │
│  ┌─────────────────────────────────────────────────────────────┐    │
│  │              TRANSPARENCY UI (WebSocket Real-Time)           │    │
│  └─────────────────────────────────────────────────────────────┘    │
└─────────────────────────────────────────────────────────────────────┘

📁 Project Structure

REPAIR.ai/
├── src/
│   ├── index.ts              # Main REPAIRSystem class
│   ├── cli.ts                # Command-line interface
│   ├── types/                # TypeScript type definitions
│   │
│   ├── observation/          # 👁️ OBSERVATION LAYER
│   │   └── index.ts          # Error parsing, evidence extraction
│   │
│   ├── reasoning/            # 🧠 REASONING ENGINE
│   │   ├── index.ts          # Main ReasoningEngine
│   │   ├── llm-client.ts     # LLM abstraction (Groq/Gemini/Ollama)
│   │   ├── hypothesis-generator.ts  # Multi-hypothesis generation
│   │   ├── hypothesis-tournament.ts # Tournament & ranking
│   │   └── reflection-module.ts     # Outcome reflection
│   │
│   ├── planner/              # 📋 ACTION PLANNING
│   │   └── index.ts          # Fix planning with deterministic path
│   │
│   ├── mcp/                  # 🎮 MCP RUNTIME
│   │   ├── runtime.ts        # Core repair loop
│   │   ├── memory.ts         # SQLite memory system
│   │   └── adversarial.ts    # Adversarial injection
│   │
│   └── ui/                   # 📺 TRANSPARENCY UI
│       ├── index.ts          # Express + WebSocket dashboard
│       └── ws-server.ts      # Real-time updates
│
├── examples/
│   ├── broken-app/           # Demo target (intentionally broken)
│   └── broken-app-backup/    # Original broken state backup
│
└── reset-demo.bat            # Reset demo script

🛡️ Safety Features

Feature Description
🔄 Reversible Actions Pre-execution snapshots for instant rollback
🎯 Blast Radius Assessment Minimal, moderate, or significant impact warning
⚠️ Risk Level Gating Low/medium/high with appropriate controls
Command Whitelisting Only approved commands can execute
🔁 Loop Prevention Maximum attempt limits to prevent infinite loops

🤖 LLM Configuration

REPAIR.ai supports multiple LLM providers:

Provider Model Cost Setup
Groq (Recommended) Llama 3.3 70B 🆓 FREE GROQ_API_KEY
Gemini Gemini Pro 💳 Paid GEMINI_API_KEY
Ollama Mistral/Llama 🆓 FREE Local install

Environment Variables

# LLM Providers (at least one required)
GROQ_API_KEY=your_groq_key         # FREE at console.groq.com
GEMINI_API_KEY=your_gemini_key     # Optional fallback
PRIMARY_LLM=groq                    # groq | gemini | ollama

# Ollama (optional, for local LLM)
OLLAMA_URL=http://localhost:11434
OLLAMA_MODEL=mistral

# Safety Settings
MAX_REPAIR_ATTEMPTS=10
MAX_HYPOTHESIS_COUNT=5

# UI
UI_PORT=3000

🎮 CLI Commands

Command Description
npm run demo Run demo with transparency UI
npm run repair -- fix --project ./path --log build.log Repair specific project
npm run ui Start UI only
npm run dev Development mode (watch)
npm run typecheck TypeScript type checking
npm test Run tests

📖 Programmatic API

import { REPAIRSystem } from 'repair-ai';

const repair = new REPAIRSystem({
  projectPath: './my-project',
  enableUI: true,
  uiPort: 3000,
});

const result = await repair.repair({
  projectPath: './my-project',
  buildLog: 'npm ERR! notarget No matching version...',
  exitCode: 1,
  command: 'npm install',
});

if (result.success) {
  console.log('✅ Fixed:', result.hypothesis.description);
  console.log('📝 Changes:', result.action.changes);
}

📊 Performance Metrics

Metric Value
🎯 Fix Rate (Known Patterns) 100%
⏱️ Average Fix Time <30 seconds
🔄 LLM Error Recovery 80-90%
💡 Hypothesis Generation 3-5 in <5 seconds

🔧 Tech Stack

TypeScript
TypeScript
5.7
Node.js
Node.js
20+
Express
Express
Web Server
SQLite
SQLite
Memory DB
Component Technology
🧠 LLM Primary Groq (Llama 3.3 70B)
🔌 Real-time WebSocket (ws)
🛠️ JSON Hardening jsonrepair
✅ Validation Zod
💻 CLI Commander.js

👩‍💻 Development

# Install dependencies
npm install

# Build TypeScript
npm run build

# Watch mode development
npm run dev

# Run tests
npm test

# Type check
npm run typecheck

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.


🔧 REPAIR.ai

Because fixing bugs shouldn't require human attention at 2am.


Built with ❤️ for the 2026 Agentathon


GitHub stars

About

REPAIR.ai is an AI-powered self-healing system that detects failures, performs root-cause analysis, explains issues, and executes safe automated repairs across real-world software and infrastructure.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors