Capabilities · Updated 2026-08-05
AST Recovery
Understand how Orbit uses Abstract Syntax Trees to heal your application.
AST-Powered Recovery
Stability is paramount. Orbit features a sophisticated Recovery Manager that monitors your application state and fixes errors before they break your flow.
How it Works
Unlike basic text-replacement tools, Orbit operates on the Abstract Syntax Tree (AST) of your code. This allows for precise, semantic modifications that respect the structure and intent of your logic.
Key Capabilities
- Import Resolution: Automatically detects missing named or default exports and updates import statements across your project.
- Named Export Extraction: If you accidentally use a named import for a default export, the AST server identifies the mismatch and creates the necessary named exports in the source file.
- Pre-flight Validation: Before any code is committed to the sandbox, Orbit runs a multi-stage validation pass to ensure syntax correctness.
A Concrete Example
Imagine the generator emits a component that imports Button from ./ui, but the file only exports ButtonGroup and ButtonOld. A text-based tool would either fail or rename blindly. The AST server parses both files, confirms there is no Button export, and checks whether any export matches the expected component signature. If it finds ButtonOld with matching props, it either renames the export to Button or rewrites the import to ButtonOld and updates every usage — including type references and barrel re-exports — in one pass.
When Recovery Runs
Recovery is triggered at three points: during generation when the model's first draft fails to parse, during the post-generation typecheck when imports or exports mismatch, and during iteration when you request changes that touch existing modules. Each repair is scoped to the smallest safe edit, and the full pipeline re-validates after the fix. If a repair would be too invasive, Orbit surfaces the error and asks you how to proceed instead of guessing.
Server-Side Accuracy
To handle complex TypeScript transformations without bloating the client, Orbit uses a dedicated AST Server. This ensures that even large-scale refactors are handled with sub-second latency and absolute precision.
Frequently asked questions
How does Orbit heal broken code?
Orbit operates on the Abstract Syntax Tree (AST) of your code rather than raw text. It detects missing imports, mismatched named exports, and syntax errors, then applies semantic fixes before committing files to the sandbox.
Why does Orbit use an AST server?
Large TypeScript transformations are expensive in the browser. Orbit runs a dedicated AST server so even large refactors complete in sub-second latency without blocking the editor.
What happens if the model writes code that fails typecheck?
The build pipeline runs an inline typecheck after generation and gives the model one surgical fix turn. If issues remain, the self-heal loop and production gate handle them before a preview is unlocked.