codegen


Namecodegen JSON
Version 0.52.18 PyPI version JSON
download
home_pageNone
SummaryScriptable interface to a powerful, multi-lingual language server built on top of Tree-sitter
upload_time2025-03-21 12:50:49
maintainerNone
docs_urlNone
authorNone
requires_python<3.14,>=3.12
licenseApache-2.0
keywords code generation codebase codebase analysis codebase manipulation codebase transformation codegen refactoring
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <br />

<p align="center">
  <a href="https://docs.codegen.com">
    <img src="https://i.imgur.com/6RF9W0z.jpeg" />
  </a>
</p>

<h2 align="center">
  Scriptable interface to a powerful, multi-lingual language server.
</h2>

<div align="center">

[![PyPI](https://img.shields.io/badge/PyPi-codegen-gray?style=flat-square&color=blue)](https://pypi.org/project/codegen/)
[![Documentation](https://img.shields.io/badge/Docs-docs.codegen.com-purple?style=flat-square)](https://docs.codegen.com)
[![Slack Community](https://img.shields.io/badge/Slack-Join-4A154B?logo=slack&style=flat-square)](https://community.codegen.com)
[![License](https://img.shields.io/badge/Code%20License-Apache%202.0-gray?&color=gray)](https://github.com/codegen-sh/codegen-sdk/tree/develop?tab=Apache-2.0-1-ov-file)
[![Follow on X](https://img.shields.io/twitter/follow/codegen?style=social)](https://x.com/codegen)

</div>

<br />

[Codegen](https://docs.codegen.com) is a python library for manipulating codebases.

```python
from codegen import Codebase

# Codegen builds a complete graph connecting
# functions, classes, imports and their relationships
codebase = Codebase("./")

# Work with code without dealing with syntax trees or parsing
for function in codebase.functions:
    # Comprehensive static analysis for references, dependencies, etc.
    if not function.usages:
        # Auto-handles references and imports to maintain correctness
        function.move_to_file("deprecated.py")
```

Write code that transforms code. Codegen combines the parsing power of [Tree-sitter](https://tree-sitter.github.io/tree-sitter/) with the graph algorithms of [rustworkx](https://github.com/Qiskit/rustworkx) to enable scriptable, multi-language code manipulation at scale.

## Installation and Usage

We support

- Running Codegen in Python 3.12 - 3.13 (recommended: Python 3.13+)
- macOS and Linux
  - macOS is supported
  - Linux is supported on x86_64 and aarch64 with glibc 2.34+
  - Windows is supported via WSL. See [here](https://docs.codegen.com/building-with-codegen/codegen-with-wsl) for more details.
- Python, Typescript, Javascript and React codebases

```
# Install inside existing project
uv pip install codegen

# Install global CLI
uv tool install codegen --python 3.13

# Create a codemod for a given repo
cd path/to/repo
codegen init
codegen create test-function

# Run the codemod
codegen run test-function

# Create an isolated venv with codegen => open jupyter
codegen notebook
```

## Usage

See [Getting Started](https://docs.codegen.com/introduction/getting-started) for a full tutorial.

```
from codegen import Codebase
```

## Troubleshooting

Having issues? Here are some common problems and their solutions:

- **I'm hitting an UV error related to `[[ packages ]]`**: This means you're likely using an outdated version of UV. Try updating to the latest version with: `uv self update`.
- **I'm hitting an error about `No module named 'codegen.sdk.extensions.utils'`**: The compiled cython extensions are out of sync. Update them with `uv sync --reinstall-package codegen`.
- **I'm hitting a `RecursionError: maximum recursion depth exceeded` error while parsing my codebase**: If you are using python 3.12, try upgrading to 3.13. If you are already on 3.13, try upping the recursion limit with `sys.setrecursionlimit(10000)`.

If you run into additional issues not listed here, please [join our slack community](https://community.codegen.com) and we'll help you out!

## Resources

- [Docs](https://docs.codegen.com)
- [Getting Started](https://docs.codegen.com/introduction/getting-started)
- [Contributing](CONTRIBUTING.md)
- [Contact Us](https://codegen.com/contact)

## Why Codegen?

Software development is fundamentally programmatic. Refactoring a codebase, enforcing patterns, or analyzing control flow - these are all operations that can (and should) be expressed as programs themselves.

We built Codegen backwards from real-world refactors performed on enterprise codebases. Instead of starting with theoretical abstractions, we focused on creating APIs that match how developers actually think about code changes:

- **Natural mental model**: Write transforms that read like your thought process - "move this function", "rename this variable", "add this parameter". No more wrestling with ASTs or manual import management.

- **Battle-tested on complex codebases**: Handle Python, TypeScript, and React codebases with millions of lines of code.

- **Built for advanced intelligences**: As AI developers become more sophisticated, they need expressive yet precise tools to manipulate code. Codegen provides a programmatic interface that both humans and AI can use to express complex transformations through code itself.

## Contributing

Please see our [Contributing Guide](CONTRIBUTING.md) for instructions on how to set up the development environment and submit contributions.

## Enterprise

For more information on enterprise engagements, please [contact us](https://codegen.com/contact) or [request a demo](https://codegen.com/request-demo).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "codegen",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.14,>=3.12",
    "maintainer_email": null,
    "keywords": "code generation, codebase, codebase analysis, codebase manipulation, codebase transformation, codegen, refactoring",
    "author": null,
    "author_email": "Codegen Team <team@codegen.sh>",
    "download_url": null,
    "platform": null,
    "description": "<br />\n\n<p align=\"center\">\n  <a href=\"https://docs.codegen.com\">\n    <img src=\"https://i.imgur.com/6RF9W0z.jpeg\" />\n  </a>\n</p>\n\n<h2 align=\"center\">\n  Scriptable interface to a powerful, multi-lingual language server.\n</h2>\n\n<div align=\"center\">\n\n[![PyPI](https://img.shields.io/badge/PyPi-codegen-gray?style=flat-square&color=blue)](https://pypi.org/project/codegen/)\n[![Documentation](https://img.shields.io/badge/Docs-docs.codegen.com-purple?style=flat-square)](https://docs.codegen.com)\n[![Slack Community](https://img.shields.io/badge/Slack-Join-4A154B?logo=slack&style=flat-square)](https://community.codegen.com)\n[![License](https://img.shields.io/badge/Code%20License-Apache%202.0-gray?&color=gray)](https://github.com/codegen-sh/codegen-sdk/tree/develop?tab=Apache-2.0-1-ov-file)\n[![Follow on X](https://img.shields.io/twitter/follow/codegen?style=social)](https://x.com/codegen)\n\n</div>\n\n<br />\n\n[Codegen](https://docs.codegen.com) is a python library for manipulating codebases.\n\n```python\nfrom codegen import Codebase\n\n# Codegen builds a complete graph connecting\n# functions, classes, imports and their relationships\ncodebase = Codebase(\"./\")\n\n# Work with code without dealing with syntax trees or parsing\nfor function in codebase.functions:\n    # Comprehensive static analysis for references, dependencies, etc.\n    if not function.usages:\n        # Auto-handles references and imports to maintain correctness\n        function.move_to_file(\"deprecated.py\")\n```\n\nWrite code that transforms code. Codegen combines the parsing power of [Tree-sitter](https://tree-sitter.github.io/tree-sitter/) with the graph algorithms of [rustworkx](https://github.com/Qiskit/rustworkx) to enable scriptable, multi-language code manipulation at scale.\n\n## Installation and Usage\n\nWe support\n\n- Running Codegen in Python 3.12 - 3.13 (recommended: Python 3.13+)\n- macOS and Linux\n  - macOS is supported\n  - Linux is supported on x86_64 and aarch64 with glibc 2.34+\n  - Windows is supported via WSL. See [here](https://docs.codegen.com/building-with-codegen/codegen-with-wsl) for more details.\n- Python, Typescript, Javascript and React codebases\n\n```\n# Install inside existing project\nuv pip install codegen\n\n# Install global CLI\nuv tool install codegen --python 3.13\n\n# Create a codemod for a given repo\ncd path/to/repo\ncodegen init\ncodegen create test-function\n\n# Run the codemod\ncodegen run test-function\n\n# Create an isolated venv with codegen => open jupyter\ncodegen notebook\n```\n\n## Usage\n\nSee [Getting Started](https://docs.codegen.com/introduction/getting-started) for a full tutorial.\n\n```\nfrom codegen import Codebase\n```\n\n## Troubleshooting\n\nHaving issues? Here are some common problems and their solutions:\n\n- **I'm hitting an UV error related to `[[ packages ]]`**: This means you're likely using an outdated version of UV. Try updating to the latest version with: `uv self update`.\n- **I'm hitting an error about `No module named 'codegen.sdk.extensions.utils'`**: The compiled cython extensions are out of sync. Update them with `uv sync --reinstall-package codegen`.\n- **I'm hitting a `RecursionError: maximum recursion depth exceeded` error while parsing my codebase**: If you are using python 3.12, try upgrading to 3.13. If you are already on 3.13, try upping the recursion limit with `sys.setrecursionlimit(10000)`.\n\nIf you run into additional issues not listed here, please [join our slack community](https://community.codegen.com) and we'll help you out!\n\n## Resources\n\n- [Docs](https://docs.codegen.com)\n- [Getting Started](https://docs.codegen.com/introduction/getting-started)\n- [Contributing](CONTRIBUTING.md)\n- [Contact Us](https://codegen.com/contact)\n\n## Why Codegen?\n\nSoftware development is fundamentally programmatic. Refactoring a codebase, enforcing patterns, or analyzing control flow - these are all operations that can (and should) be expressed as programs themselves.\n\nWe built Codegen backwards from real-world refactors performed on enterprise codebases. Instead of starting with theoretical abstractions, we focused on creating APIs that match how developers actually think about code changes:\n\n- **Natural mental model**: Write transforms that read like your thought process - \"move this function\", \"rename this variable\", \"add this parameter\". No more wrestling with ASTs or manual import management.\n\n- **Battle-tested on complex codebases**: Handle Python, TypeScript, and React codebases with millions of lines of code.\n\n- **Built for advanced intelligences**: As AI developers become more sophisticated, they need expressive yet precise tools to manipulate code. Codegen provides a programmatic interface that both humans and AI can use to express complex transformations through code itself.\n\n## Contributing\n\nPlease see our [Contributing Guide](CONTRIBUTING.md) for instructions on how to set up the development environment and submit contributions.\n\n## Enterprise\n\nFor more information on enterprise engagements, please [contact us](https://codegen.com/contact) or [request a demo](https://codegen.com/request-demo).\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Scriptable interface to a powerful, multi-lingual language server built on top of Tree-sitter",
    "version": "0.52.18",
    "project_urls": {
        "Changelog": "https://docs.codegen.com/changelog/changelog",
        "Documentation": "https://docs.codegen.com",
        "Download": "https://github.com/codegen-sh/codegen-sdk/archive/7cd5c870df9679d334b0726f436e07af9f3d3ec7.zip",
        "Homepage": "https://www.codegen.com/",
        "Issues": "https://github.com/codegen-sh/codegen-sdk/issues",
        "Playground": "https://www.codegen.sh/",
        "Releasenotes": "https://github.com/codegen-sh/codegen-sdk/releases",
        "Repository": "https://github.com/codegen-sh/codegen-sdk"
    },
    "split_keywords": [
        "code generation",
        " codebase",
        " codebase analysis",
        " codebase manipulation",
        " codebase transformation",
        " codegen",
        " refactoring"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "269ac871ed4057473d121ce82afc467c325e9e64945d26b5668866a0d6c1bdff",
                "md5": "948b360f6a0badb261ed01f09b6291a7",
                "sha256": "a47e2c532e19d5630f7388dd25290216403c2b179dc194eb49465b41795f7254"
            },
            "downloads": -1,
            "filename": "codegen-0.52.18-cp312-cp312-macosx_10_13_x86_64.whl",
            "has_sig": false,
            "md5_digest": "948b360f6a0badb261ed01f09b6291a7",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": "<3.14,>=3.12",
            "size": 1209965,
            "upload_time": "2025-03-21T12:50:49",
            "upload_time_iso_8601": "2025-03-21T12:50:49.633696Z",
            "url": "https://files.pythonhosted.org/packages/26/9a/c871ed4057473d121ce82afc467c325e9e64945d26b5668866a0d6c1bdff/codegen-0.52.18-cp312-cp312-macosx_10_13_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7ccb7446ac953ee8984382084915401dfcee25d7afe26423027acff48c85cedc",
                "md5": "901e363f0fc81805cb1bc46b89a6b0f3",
                "sha256": "4c59082cace03b43743618846bebe43e78afa320de935cafe20d78f40162028d"
            },
            "downloads": -1,
            "filename": "codegen-0.52.18-cp312-cp312-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "901e363f0fc81805cb1bc46b89a6b0f3",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": "<3.14,>=3.12",
            "size": 1201103,
            "upload_time": "2025-03-21T12:50:52",
            "upload_time_iso_8601": "2025-03-21T12:50:52.472507Z",
            "url": "https://files.pythonhosted.org/packages/7c/cb/7446ac953ee8984382084915401dfcee25d7afe26423027acff48c85cedc/codegen-0.52.18-cp312-cp312-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2e668224689aec4c54d7d8d70023eb6d88de28f99df525589233d2d785fd5a76",
                "md5": "9d3a9d2d6588761b002a2bd825e0b618",
                "sha256": "e3a202868505c3d203fbd5bcc5f4ffd4d73a15ed455252dbd7907cf02bb63ab8"
            },
            "downloads": -1,
            "filename": "codegen-0.52.18-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_34_aarch64.whl",
            "has_sig": false,
            "md5_digest": "9d3a9d2d6588761b002a2bd825e0b618",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": "<3.14,>=3.12",
            "size": 2205396,
            "upload_time": "2025-03-21T12:50:54",
            "upload_time_iso_8601": "2025-03-21T12:50:54.200535Z",
            "url": "https://files.pythonhosted.org/packages/2e/66/8224689aec4c54d7d8d70023eb6d88de28f99df525589233d2d785fd5a76/codegen-0.52.18-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_34_aarch64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "64ccdef7565df3d370b8eb303dd9494a9001d9bc20f8b30a97e582c1b76df5f5",
                "md5": "47ad80594737316c1c661089d442971f",
                "sha256": "6dbb8d2534cbf6a77d564067da365645627398a2c6c7081df1f9187f8784593f"
            },
            "downloads": -1,
            "filename": "codegen-0.52.18-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_34_x86_64.whl",
            "has_sig": false,
            "md5_digest": "47ad80594737316c1c661089d442971f",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": "<3.14,>=3.12",
            "size": 2254673,
            "upload_time": "2025-03-21T12:50:55",
            "upload_time_iso_8601": "2025-03-21T12:50:55.959141Z",
            "url": "https://files.pythonhosted.org/packages/64/cc/def7565df3d370b8eb303dd9494a9001d9bc20f8b30a97e582c1b76df5f5/codegen-0.52.18-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_34_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a9f157463cb10d32134535848d21df3405c2843a53de441ed0876e8257ee85d2",
                "md5": "91e4022dcc85a7b035161343bb00258b",
                "sha256": "1906595c4b1235d0423030682a24de1dea519cad9efbf9e7e837408eee674df1"
            },
            "downloads": -1,
            "filename": "codegen-0.52.18-cp313-cp313-macosx_10_13_x86_64.whl",
            "has_sig": false,
            "md5_digest": "91e4022dcc85a7b035161343bb00258b",
            "packagetype": "bdist_wheel",
            "python_version": "cp313",
            "requires_python": "<3.14,>=3.12",
            "size": 1205387,
            "upload_time": "2025-03-21T12:50:57",
            "upload_time_iso_8601": "2025-03-21T12:50:57.791672Z",
            "url": "https://files.pythonhosted.org/packages/a9/f1/57463cb10d32134535848d21df3405c2843a53de441ed0876e8257ee85d2/codegen-0.52.18-cp313-cp313-macosx_10_13_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "83a845e22aa65bc15ed2142b561fca04dbc18f45d0abc0d38a2711df3248c85c",
                "md5": "3097eaa104c080215138a1752ab74d8a",
                "sha256": "6ab7fb699b9190cfbe868894470dc79ff9bef4245dc2e60b8d5fd1d8460f3972"
            },
            "downloads": -1,
            "filename": "codegen-0.52.18-cp313-cp313-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "3097eaa104c080215138a1752ab74d8a",
            "packagetype": "bdist_wheel",
            "python_version": "cp313",
            "requires_python": "<3.14,>=3.12",
            "size": 1197271,
            "upload_time": "2025-03-21T12:50:59",
            "upload_time_iso_8601": "2025-03-21T12:50:59.504757Z",
            "url": "https://files.pythonhosted.org/packages/83/a8/45e22aa65bc15ed2142b561fca04dbc18f45d0abc0d38a2711df3248c85c/codegen-0.52.18-cp313-cp313-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "df5995105151221d23d0c179912c59d2a5214564cdebb905ecd252d477aebfe4",
                "md5": "f43d738cedaf1e19ace662ce4a4e4a82",
                "sha256": "375e08d562642cdf50f0aa0058e3d86f6fc0ec1988399b849af7f9f0829f5cc7"
            },
            "downloads": -1,
            "filename": "codegen-0.52.18-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_34_aarch64.whl",
            "has_sig": false,
            "md5_digest": "f43d738cedaf1e19ace662ce4a4e4a82",
            "packagetype": "bdist_wheel",
            "python_version": "cp313",
            "requires_python": "<3.14,>=3.12",
            "size": 2198141,
            "upload_time": "2025-03-21T12:51:01",
            "upload_time_iso_8601": "2025-03-21T12:51:01.728607Z",
            "url": "https://files.pythonhosted.org/packages/df/59/95105151221d23d0c179912c59d2a5214564cdebb905ecd252d477aebfe4/codegen-0.52.18-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_34_aarch64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "44457f776f6052fc4c48af1ae9743e8fbccd470124e8de1f03dbcdf17130b5ec",
                "md5": "5597b208e1b7c6b15cef4990fd716c5d",
                "sha256": "13e8e0f15956c639c608da01fddddc0a3e27b027bf3f5705681211b80a73e44e"
            },
            "downloads": -1,
            "filename": "codegen-0.52.18-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_34_x86_64.whl",
            "has_sig": false,
            "md5_digest": "5597b208e1b7c6b15cef4990fd716c5d",
            "packagetype": "bdist_wheel",
            "python_version": "cp313",
            "requires_python": "<3.14,>=3.12",
            "size": 2244517,
            "upload_time": "2025-03-21T12:51:03",
            "upload_time_iso_8601": "2025-03-21T12:51:03.122195Z",
            "url": "https://files.pythonhosted.org/packages/44/45/7f776f6052fc4c48af1ae9743e8fbccd470124e8de1f03dbcdf17130b5ec/codegen-0.52.18-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_34_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-03-21 12:50:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "codegen-sh",
    "github_project": "codegen-sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "codegen"
}
        
Elapsed time: 0.59410s