graph-sitter


Namegraph-sitter JSON
Version 0.56.14 PyPI version JSON
download
home_pageNone
SummaryScriptable interface to a powerful, multi-lingual language server built on top of Tree-sitter
upload_time2025-10-09 22:16:15
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://graph-sitter.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-graph--sitter-gray?style=flat-square&color=blue)](https://pypi.org/project/graph-sitter/)
[![Documentation](https://img.shields.io/badge/Docs-graph-sitter.com-purple?style=flat-square)](https://graph-sitter.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/graph-sitter/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 />

[Graph-sitter](https://graph-sitter.com) is a python library for manipulating codebases.

```python
from graph_sitter import Codebase

# Graph-sitter 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. Graph-sitter 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 Graph-sitter 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://graph-sitter.com/building-with-graph-sitter/codegen-with-wsl) for more details.
- Python, Typescript, Javascript and React codebases

```
# Install inside existing project
uv pip install graph-sitter

# Install global CLI
uv tool install graph-sitter --python 3.13

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

# Run the codemod
gs run test-function

# Create an isolated venv with graph-sitter => open jupyter
gs notebook
```

## Usage

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

```
from graph_sitter 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 'graph_sitter.sdk.extensions.utils'`**: The compiled cython extensions are out of sync. Update them with `uv sync --reinstall-package graph-sitter`.
- **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://graph-sitter.com)
- [Getting Started](https://graph-sitter.com/introduction/getting-started)
- [Contributing](CONTRIBUTING.md)
- [Contact Us](https://codegen.com/contact)

## Why Graph-sitter?

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 Graph-sitter 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. Graph-sitter 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": "graph-sitter",
    "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://graph-sitter.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-graph--sitter-gray?style=flat-square&color=blue)](https://pypi.org/project/graph-sitter/)\n[![Documentation](https://img.shields.io/badge/Docs-graph-sitter.com-purple?style=flat-square)](https://graph-sitter.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/graph-sitter/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[Graph-sitter](https://graph-sitter.com) is a python library for manipulating codebases.\n\n```python\nfrom graph_sitter import Codebase\n\n# Graph-sitter 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. Graph-sitter 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 Graph-sitter 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://graph-sitter.com/building-with-graph-sitter/codegen-with-wsl) for more details.\n- Python, Typescript, Javascript and React codebases\n\n```\n# Install inside existing project\nuv pip install graph-sitter\n\n# Install global CLI\nuv tool install graph-sitter --python 3.13\n\n# Create a codemod for a given repo\ncd path/to/repo\ngs init\ngs create test-function\n\n# Run the codemod\ngs run test-function\n\n# Create an isolated venv with graph-sitter => open jupyter\ngs notebook\n```\n\n## Usage\n\nSee [Getting Started](https://graph-sitter.com/introduction/getting-started) for a full tutorial.\n\n```\nfrom graph_sitter 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 'graph_sitter.sdk.extensions.utils'`**: The compiled cython extensions are out of sync. Update them with `uv sync --reinstall-package graph-sitter`.\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://graph-sitter.com)\n- [Getting Started](https://graph-sitter.com/introduction/getting-started)\n- [Contributing](CONTRIBUTING.md)\n- [Contact Us](https://codegen.com/contact)\n\n## Why Graph-sitter?\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 Graph-sitter 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. Graph-sitter 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.56.14",
    "project_urls": {
        "Changelog": "https://graph-sitter.com/changelog/changelog",
        "Documentation": "https://graph-sitter.com",
        "Download": "https://github.com/codegen-sh/graph-sitter/archive/233454f54ff381852111fdf91e04169de106bcb9.zip",
        "Homepage": "https://www.codegen.com/",
        "Issues": "https://github.com/codegen-sh/graph-sitter/issues",
        "Playground": "https://www.codegen.sh/",
        "Releasenotes": "https://github.com/codegen-sh/graph-sitter/releases",
        "Repository": "https://github.com/codegen-sh/graph-sitter"
    },
    "split_keywords": [
        "code generation",
        " codebase",
        " codebase analysis",
        " codebase manipulation",
        " codebase transformation",
        " codegen",
        " refactoring"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "002153978e3483571d0f3c3a8037a092bd08febbca461b716df021965f57b30d",
                "md5": "d40bc61c40e4cffd8dd6f55cb6d5fa25",
                "sha256": "8f00ce821c2c6b24fc425513b95414808b7131645241bb2f80344cf79f867abe"
            },
            "downloads": -1,
            "filename": "graph_sitter-0.56.14-cp312-cp312-macosx_10_13_x86_64.whl",
            "has_sig": false,
            "md5_digest": "d40bc61c40e4cffd8dd6f55cb6d5fa25",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": "<3.14,>=3.12",
            "size": 1058779,
            "upload_time": "2025-10-09T22:16:15",
            "upload_time_iso_8601": "2025-10-09T22:16:15.861944Z",
            "url": "https://files.pythonhosted.org/packages/00/21/53978e3483571d0f3c3a8037a092bd08febbca461b716df021965f57b30d/graph_sitter-0.56.14-cp312-cp312-macosx_10_13_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "13aa6b5f57cb5ee9c71ec83e2dae66481c78c9f1bc2c121d65ce05f8d811fb98",
                "md5": "32cde641a6f9abbb60b8c7709ac35bdd",
                "sha256": "ebe7c96b50936713ed96a16a097c1179a46812597354674a102cc9dba9c827b4"
            },
            "downloads": -1,
            "filename": "graph_sitter-0.56.14-cp312-cp312-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "32cde641a6f9abbb60b8c7709ac35bdd",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": "<3.14,>=3.12",
            "size": 1063987,
            "upload_time": "2025-10-09T22:16:17",
            "upload_time_iso_8601": "2025-10-09T22:16:17.279160Z",
            "url": "https://files.pythonhosted.org/packages/13/aa/6b5f57cb5ee9c71ec83e2dae66481c78c9f1bc2c121d65ce05f8d811fb98/graph_sitter-0.56.14-cp312-cp312-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3c23163a98798754627c01bf47b228a0b4b6a640d5babee0e49a98a9e110b8cd",
                "md5": "033766e2bef0ac5df4c4b8e88caf5075",
                "sha256": "c2050ef0b046b1f4cf6f7e82e91d413dbb50a90759b3ce79b42afff0a701d17d"
            },
            "downloads": -1,
            "filename": "graph_sitter-0.56.14-cp312-cp312-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl",
            "has_sig": false,
            "md5_digest": "033766e2bef0ac5df4c4b8e88caf5075",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": "<3.14,>=3.12",
            "size": 2110058,
            "upload_time": "2025-10-09T22:16:19",
            "upload_time_iso_8601": "2025-10-09T22:16:19.051879Z",
            "url": "https://files.pythonhosted.org/packages/3c/23/163a98798754627c01bf47b228a0b4b6a640d5babee0e49a98a9e110b8cd/graph_sitter-0.56.14-cp312-cp312-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8b4288b80942cd98c324198de9e8f33a1333273b815b72f0568f901e98880954",
                "md5": "3f15815c563381c2920130dfdb1c503c",
                "sha256": "da5bbbbac4e49bb8149cac48c3d5bd946509e11f06db81eb99fc0ff7f309f467"
            },
            "downloads": -1,
            "filename": "graph_sitter-0.56.14-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl",
            "has_sig": false,
            "md5_digest": "3f15815c563381c2920130dfdb1c503c",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": "<3.14,>=3.12",
            "size": 2076719,
            "upload_time": "2025-10-09T22:16:20",
            "upload_time_iso_8601": "2025-10-09T22:16:20.461356Z",
            "url": "https://files.pythonhosted.org/packages/8b/42/88b80942cd98c324198de9e8f33a1333273b815b72f0568f901e98880954/graph_sitter-0.56.14-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4da4e004f4a400db466ca244e28d89c49d83266c62c7f280c9b5dfa81dce80a2",
                "md5": "854d2227c074db03242ab2291ffc41b3",
                "sha256": "d87fb58a884923fe05c9a16bdfbd2a4b65220aeedf3b14abe7c43d0fc5f9f65f"
            },
            "downloads": -1,
            "filename": "graph_sitter-0.56.14-cp313-cp313-macosx_10_13_x86_64.whl",
            "has_sig": false,
            "md5_digest": "854d2227c074db03242ab2291ffc41b3",
            "packagetype": "bdist_wheel",
            "python_version": "cp313",
            "requires_python": "<3.14,>=3.12",
            "size": 1058065,
            "upload_time": "2025-10-09T22:16:22",
            "upload_time_iso_8601": "2025-10-09T22:16:22.595012Z",
            "url": "https://files.pythonhosted.org/packages/4d/a4/e004f4a400db466ca244e28d89c49d83266c62c7f280c9b5dfa81dce80a2/graph_sitter-0.56.14-cp313-cp313-macosx_10_13_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b869b56d193f901a434a0d693f0b2af96362a3e65e7181e0902162784fdd9c94",
                "md5": "6b44776dd148d768860f328531ba2c00",
                "sha256": "b97eef80eece38d62836eeb8365853c50de24ba10c2af68bcd37ad637d27a63d"
            },
            "downloads": -1,
            "filename": "graph_sitter-0.56.14-cp313-cp313-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "6b44776dd148d768860f328531ba2c00",
            "packagetype": "bdist_wheel",
            "python_version": "cp313",
            "requires_python": "<3.14,>=3.12",
            "size": 1062747,
            "upload_time": "2025-10-09T22:16:23",
            "upload_time_iso_8601": "2025-10-09T22:16:23.611097Z",
            "url": "https://files.pythonhosted.org/packages/b8/69/b56d193f901a434a0d693f0b2af96362a3e65e7181e0902162784fdd9c94/graph_sitter-0.56.14-cp313-cp313-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "58a0d718532a873a5c35d5af816afc700af9a3e9e2fa91fbb51d08cbd333f32a",
                "md5": "6ac65b9bd55f5cd57cc6d9b732addc34",
                "sha256": "eefbe22471dd9947f94939142c4a37560993ba1f8205815098906bcb806ad3df"
            },
            "downloads": -1,
            "filename": "graph_sitter-0.56.14-cp313-cp313-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl",
            "has_sig": false,
            "md5_digest": "6ac65b9bd55f5cd57cc6d9b732addc34",
            "packagetype": "bdist_wheel",
            "python_version": "cp313",
            "requires_python": "<3.14,>=3.12",
            "size": 2104340,
            "upload_time": "2025-10-09T22:16:24",
            "upload_time_iso_8601": "2025-10-09T22:16:24.876666Z",
            "url": "https://files.pythonhosted.org/packages/58/a0/d718532a873a5c35d5af816afc700af9a3e9e2fa91fbb51d08cbd333f32a/graph_sitter-0.56.14-cp313-cp313-manylinux1_x86_64.manylinux_2_34_x86_64.manylinux_2_5_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a51473643aeef6e44efabce1c9a983035d841f31cf93e941e41c69cf5eea8872",
                "md5": "6faf27a18516a84d723b1a488e537ed1",
                "sha256": "c5cfadcec6470afb52a57e73d49687e4a80adc9138964cd4debf58229efe9ff2"
            },
            "downloads": -1,
            "filename": "graph_sitter-0.56.14-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl",
            "has_sig": false,
            "md5_digest": "6faf27a18516a84d723b1a488e537ed1",
            "packagetype": "bdist_wheel",
            "python_version": "cp313",
            "requires_python": "<3.14,>=3.12",
            "size": 2072417,
            "upload_time": "2025-10-09T22:16:26",
            "upload_time_iso_8601": "2025-10-09T22:16:26.070964Z",
            "url": "https://files.pythonhosted.org/packages/a5/14/73643aeef6e44efabce1c9a983035d841f31cf93e941e41c69cf5eea8872/graph_sitter-0.56.14-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_34_aarch64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-09 22:16:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "codegen-sh",
    "github_project": "graph-sitter",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "graph-sitter"
}
        
Elapsed time: 2.04749s