Skip to main content

Decompiling

The decompiler reverse-engineers an existing codebase into a fully executable appgrammar. It runs the same 5-step creation pipeline but in reverse: instead of generating architecture from a description, it extracts architecture from source code.

Why Decompile?

Decompiling is useful when you want to:

  • Reproduce an existing project with modifications (change the database, add features)
  • Document a codebase as an executable plan that new team members can follow
  • Breed an existing project with another appgrammar to combine their architectures
  • Transmute an existing project to a different technology stack

The output is a standard appgrammar, identical in structure to one created from scratch. All the same tools (breed, fork, amplify, transmute) work on decompiled appgrammars.

Codebase Snapshot Format

Call appgrammar_decompile with a description and a codebase_snapshot object:

{
"description": "A Next.js SaaS dashboard with billing",
"codebase_snapshot": {
"files": [
{
"path": "src/app/page.tsx",
"content": "export default function Home() {...}",
"language": "typescript",
"size": 1240
},
{
"path": "src/lib/db.ts",
"content": "import { Pool } from 'pg'; ...",
"language": "typescript",
"size": 890
}
],
"tree": "src/\n app/\n page.tsx\n lib/\n db.ts",
"package_json": { "dependencies": { "next": "^14.0.0" } },
"total_files": 47,
"total_lines": 8200
},
"language": "typescript",
"framework": "next.js",
"database": "postgresql"
}

Snapshot Fields

FieldRequiredDescription
filesYesArray of file objects with path, content, language, and size
treeYesDirectory tree as a string (like the output of the tree command)
package_jsonNoParsed package.json for dependency analysis
tsconfigNoParsed tsconfig.json for TypeScript configuration
total_filesYesTotal number of files in the codebase
total_linesYesTotal lines of code

You do not need to include every file. Include key structural files: entry points, configuration, database models, route definitions, and representative components. The decompiler infers the rest from the tree and dependencies.

The 5-Step Reverse Pipeline

Each step analyzes existing code rather than generating from a description:

  1. Architecture Extraction -- Identifies modules, dependencies, and technology choices from source code
  2. Design System Extraction -- Extracts UI framework, colors, typography, and component patterns from CSS/config
  3. Reconstruction Task DAG -- Determines build order to reproduce the codebase, with parallel stages
  4. File Registry -- Maps every source file to its module, exports, imports, and role
  5. Step Enrichment -- Generates compressed specifications for each reconstruction step

Submitting Step Results

The flow is identical to forward creation. Submit each step via appgrammar_decompile_submit with the appgrammar_id, token, and structured result from your LLM. After all 5 steps, the appgrammar is ready for execution via appgrammar_start.

Web UI

The /tools/decompile page shows your decompilation sessions with step progress and provides the MCP configuration snippet. Sessions appear alongside your other appgrammars on the dashboard.