How Codegen Works
Codegen enables developers to engage in metaprogramming - manipulating code with code.
Codemods
Codegen allows developers to write codemods - programs that run on a codebase to make changes.
Codegen provides a powerful IDE for the composition of these codemods, as well as a runtime for executing them on codebases.
GraphSitter
Codegen codemods are composed with a sophisticated library, GraphSitter
, that simplifies and streamlines the process of code transformation via static program analysis.
GraphSitter
exposes a high-level Python API for code manipulation, with a focus on simplicity, readability, and efficiency, like so:
Constructing the Codebase Graph
GraphSitter
is backed by a powerful graph representation of the codebase.
GraphSitter leverages Tree-sitter to parse AST-level code representations. It then stitches these together to form a comprehensive graph datastructure representing symbols, files, imports and more.
Parsing Code Files
Under the hood, GraphSitter is built on Tree-sitter, a powerful parser.
While Tree-sitter provides a robust and flexible framework for parsing code at the AST level, it can be challenging to use for complex code modifications. GraphSitter simplifies the process by providing a high-level API that allows developers to write intuitive and powerful code modifications with ease.
AI Powered Codemod Creation
Codegen uses AI to create codemods that are tailored to your specific codebase. This allows developers to focus on the code changes they want to make, rather than the technical details of the modifications.
Was this page helpful?