Self-Healing Code & Diagnostics

Coralite provides a comprehensive, AI-assisted self-healing diagnostic and AST auto-fixing engine designed to maintain zero-defect codebases across Web Components, Plugins, and Page templates.

AI Agent Ready: Coralite's diagnostic engine emits 4-part codeframes with exact source ranges and structural auto-fix actions, enabling AI pair-programming assistants to self-correct invalid code in a single turn.

1. The Self-Healing Compiler Loop #

The static analysis engine operates in a deterministic 4-stage self-healing compiler loop:

  1. Static Audit: Scans component templates, PostCSS stylesheets, JS AST blocks, and plugin definitions.
  2. Diagnostic Emission: Identifies structural violations, CSP anti-patterns, serialization leaks, and dead code, mapping them to explicit diagnostic codes (`CORALITE-E*`, `CORALITE-P*`, `CORALITE-PAGE-*`).
  3. AST Auto-Fixer: Applies 1-shot AST transformations (expression lifting to getters, dynamic client import rewriting, single-candidate ref injection, default stripping, and Two-Phase plugin currying).
  4. Post-Fix Re-audit: Re-evaluates modified source files to guarantee that zero errors remain and no regressions were introduced.

2. Comprehensive Diagnostic Catalog #

Component Diagnostics (CORALITE-E101 – E303, W401 – W402) #

Audits template syntax, script block boundaries, slot signatures, and state reactivity rules.

Plugin Diagnostics (CORALITE-P101 – P401) #

Audits plugin contracts, lifecycle hooks, and isomorphic client boundary serialization.

Page Document Diagnostics (CORALITE-PAGE-101 – 201) #

Audits HTML page documents against component schemas and encapsulation rules.

3. Automated AST Auto-Fixing (--fix & --dry-run) #

Execute 1-shot AST auto-fixing across your workspace using `coralite fix` or domain-specific commands:

bash
Code copied!
# Auto-fix all workspace components and plugins
coralite fix

# Preview proposed fixes in unified colorized diff format without modifying disk
coralite fix --dry-run

# Auto-fix components directly
coralite validate-components --fix

4. AI Pair-Programming with init-agent #

Scaffold zero-token rule files for AI coding assistants (Claude Code, Cursor, GitHub Copilot) to prevent hallucinations and ensure code compliance from the first prompt:

bash
Code copied!
# Scaffold AGENTS.md in repo root
coralite init-agent

# Scaffold AGENTS.md plus .cursor/rules/coralite.mdc and .claude/AGENTS.md
coralite init-agent --cursor --claude

5. Strict CI Quality Gates #

Integrate Coralite's strict audit into your continuous integration pipeline to guarantee zero warnings or dead code in production builds:

bash
Code copied!
# Strict workspace check (fails build if any errors or unused symbols exist)
coralite check --strict --coverage

Start Building with Coralite!

Use the scaffolding script to get jump started into your next project with Coralite

Copied commandline!