Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,22 @@ jobs:
access-check:
runs-on: ubuntu-latest
steps:
- uses: actions-cool/check-user-permission@v2
- name: Check if bot account
id: bot-check
run: |
actor="${{ github.triggering_actor }}"
echo "Checking actor: $actor"
if [[ "$actor" == *"[bot]" ]] || [[ "$actor" == "renovate" ]] || [[ "$actor" == "dependabot" ]]; then
echo "is_bot=true" >> $GITHUB_OUTPUT
echo "Detected bot account: $actor - skipping permission check"
exit 0
else
echo "is_bot=false" >> $GITHUB_OUTPUT
echo "Detected human account: $actor"
fi
- name: Check user permissions
if: steps.bot-check.outputs.is_bot == 'false'
uses: actions-cool/check-user-permission@v2
with:
require: write
username: ${{ github.triggering_actor }}
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<div align="center">

[![PyPI](https://img.shields.io/badge/PyPi-codegen-gray?style=flat-square&color=blue)](https://pypi.org/project/codegen/)
[![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)
Expand All @@ -25,7 +25,7 @@
[Graph-sitter](https://graph-sitter.com) is a python library for manipulating codebases.

```python
from codegen import Codebase
from graph_sitter import Codebase

# Graph-sitter builds a complete graph connecting
# functions, classes, imports and their relationships
Expand Down Expand Up @@ -67,7 +67,7 @@ gs create test-function
# Run the codemod
gs run test-function

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

Expand All @@ -84,7 +84,7 @@ from graph_sitter import Codebase
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 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!
Expand Down
2 changes: 1 addition & 1 deletion architecture/3. imports-exports/A. Imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Import resolution follows AST construction in the code analysis pipeline. It identifies dependencies between modules and builds a graph of relationships across the codebase.

> NOTE: This is an actively evolving part of Codegen SDK, so some details here may be imcomplete, outdated, or incorrect.
> NOTE: This is an actively evolving part of Graph-sitter SDK, so some details here may be imcomplete, outdated, or incorrect.

## Purpose

Expand Down
14 changes: 7 additions & 7 deletions architecture/architecture.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Architecture of the Codegen SDK
# Architecture of the Graph-sitter SDK

This is a technical document explaining the architecture of the Codegen SDK.
This is a technical document explaining the architecture of the Graph-sitter SDK.

## Purpose of the SDK

Expand All @@ -17,7 +17,7 @@ This SDK is designed to accomplish a large set of use cases in one tool:

### Performance

A key problem is performance. We must be able to quickly respond to user requests on enterprise codebases (IE: renaming a symbol). However, we don't know what those requests are in advance and the scope of these requests can be quite massive (They may choose to iterate over a large number of symbols and their usages). To respond to these problems, we introduced codegen cloud. We split operations into two parts:
A key problem is performance. We must be able to quickly respond to user requests on enterprise codebases (IE: renaming a symbol). However, we don't know what those requests are in advance and the scope of these requests can be quite massive (They may choose to iterate over a large number of symbols and their usages). To respond to these problems, we introduced graph-sitter cloud. We split operations into two parts:

- A "parse" step that builds up a graph of the codebase
- This can take a long time to complete, but it only needs to be done once
Expand All @@ -34,12 +34,12 @@ To accomplish these goals, we can look at existing classes of solutions:

### Language Server Architecture

The immediate question is: why not use a language server? They have a lot of the same goals as codegen, but do not address many of our goals:
The immediate question is: why not use a language server? They have a lot of the same goals as graph-sitter, but do not address many of our goals:

- Language servers can handle many of these same use cases, but they are not as performant as we need.
- Generally, language servers compute their results lazily. This doesn't work for us because we need to perform a large number of operations on the codebase.
- While the LSP protocol is powerful, it is not designed to be scriptable the way codegen is.
- In Python, many of the language servers are an aglamation of many different tools and libraries. None are very good at refactoring or offer the comprehensive set of features that codegen does.
- While the LSP protocol is powerful, it is not designed to be scriptable the way graph-sitter is.
- In Python, many of the language servers are an aglamation of many different tools and libraries. None are very good at refactoring or offer the comprehensive set of features that graph-sitter does.

Generally language servers parse codebases in response to user actions. This is not a good fit for us because we need to perform a large number of operations on the codebase without knowing which symbols are being changed or queried.

Expand All @@ -56,7 +56,7 @@ Generally compilers build up knowledge of the entire codebase in a single pass.

## Architecture

The codegen SDK combines aspects of both systems to accomplish our goals.
The graph-sitter SDK combines aspects of both systems to accomplish our goals.
At a high level our architecture is:

1. We discover files to parse
Expand Down
2 changes: 1 addition & 1 deletion architecture/external/dependency-manager.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Dependency Manager

> WARNING: Dependency manager is an experimental feature designed for Codegen Cloud! The current implementation WILL delete any existing `node_modules` folder!
> WARNING: Dependency manager is an experimental feature designed for Graph-sitter Cloud! The current implementation WILL delete any existing `node_modules` folder!

## Motivation

Expand Down
4 changes: 2 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Documentation](https://img.shields.io/badge/docs-graph-sitter.com-blue)](https://graph-sitter.com)

This is a collection of examples using [Codegen](https://codegen.com). You can use these examples to learn how to use Codegen and build custom code transformations.
This is a collection of examples using [Graph-sitter](https://graph-sitter.com). You can use these examples to learn how to use Graph-sitter and build custom code transformations.

## Setup

Expand Down Expand Up @@ -32,7 +32,7 @@ Your environment is now ready to run example codemods.

### IDE Configuration (Optional)

To configure your IDE for optimal use with Codegen, follow our [IDE setup guide](https://graph-sitter.com/introduction/ide-usage#configuring-your-ide-interpreter).
To configure your IDE for optimal use with Graph-sitter, follow our [IDE setup guide](https://graph-sitter.com/introduction/ide-usage#configuring-your-ide-interpreter).

## Examples

Expand Down
4 changes: 2 additions & 2 deletions examples/STRUCTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Your `run.py` should follow this structure, demonstrated well in the `generate_t
```python
import graph_sitter
from graph_sitter import Codebase
from codegen.sdk.core import Function
from graph_sitter.core import Function
# ... other imports
```

Expand Down Expand Up @@ -177,4 +177,4 @@ Before submitting:
1. Ensure the example runs with minimal setup
1. Check that documentation is clear and accurate

Remember: Your example might be used by both humans and AI to understand Codegen's capabilities. Clear structure and documentation help everyone use your code effectively.
Remember: Your example might be used by both humans and AI to understand Graph-sitter's capabilities. Clear structure and documentation help everyone use your code effectively.
2 changes: 1 addition & 1 deletion examples/examples/ai_impact_analysis/dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A web dashboard for visualizing AI-generated code contributions in your codebase
```bash
uv venv
source .venv/bin/activate
uv pip install modal codegen fastapi
uv pip install modal graph-sitter fastapi
```

2. Deploy or serve the Modal endpoint:
Expand Down
8 changes: 4 additions & 4 deletions examples/examples/codegen-mcp-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</p>

<h2 align="center">
An MCP server implementation that integrates the codegen sdk.
An MCP server implementation that integrates the graph-sitter sdk.

</h2>

Expand All @@ -18,10 +18,10 @@

</div>

This example demonstrates how to run a Model Control Protocol (MCP) server that integrates with Codegen. The server provides:
This example demonstrates how to run a Model Control Protocol (MCP) server that integrates with Graph-sitter. The server provides:

1. A standardized interface for model inference
1. Integration with Codegen's core functionality, parsing codebases and executing codemods
1. Integration with Graph-sitter's core functionality, parsing codebases and executing codemods
1. Support for various LLM providers through the MCP protocol

## Quick Start
Expand Down Expand Up @@ -64,4 +64,4 @@ Here is an example mcp config that can be used with Cline or Claude desktop to i

- `parse_codebase`: Parses a codebase located at the provided path.
- `check_parse_status`: Provides the current parsing status for the provided codebase.
- `execute_codemod`: Executes a codemod script on a parsed codebase. This is where the codegen sdk leveraged to run simple or sophisticated codemods on the codebase.
- `execute_codemod`: Executes a codemod script on a parsed codebase. This is where the graph-sitter sdk leveraged to run simple or sophisticated codemods on the codebase.
4 changes: 2 additions & 2 deletions examples/examples/cyclomatic_complexity/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Cyclomatic Complexity Analyzer

This example demonstrates how to analyze the cyclomatic complexity of Python codebases using Codegen. The script provides detailed insights into code complexity by analyzing control flow structures and providing a comprehensive report.
This example demonstrates how to analyze the cyclomatic complexity of Python codebases using Graph-sitter. The script provides detailed insights into code complexity by analyzing control flow structures and providing a comprehensive report.

> [!NOTE]
> The cyclomatic complexity metric helps identify complex code that might need refactoring. A higher score indicates more complex code with multiple decision points.
Expand All @@ -15,7 +15,7 @@ The script (`run.py`) performs the complexity analysis in several key steps:
codebase = Codebase.from_repo("fastapi/fastapi")
```

- Loads any Python codebase into Codegen's analysis engine
- Loads any Python codebase into Graph-sitter's analysis engine
- Works with local or remote Git repositories
- Supports analyzing specific commits

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/delete_dead_code/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Delete Dead Code

This example demonstrates how to identify and remove dead code from a codebase using Codegen. The script efficiently cleans up unused functions and variables, helping maintain a lean and efficient codebase.
This example demonstrates how to identify and remove dead code from a codebase using Graph-sitter. The script efficiently cleans up unused functions and variables, helping maintain a lean and efficient codebase.

> [!NOTE]
> Dead code refers to code that is not being used or referenced anywhere in your codebase. However, some code might appear unused but should not be deleted, such as test files, functions with decorators, public API endpoints, and event handlers.
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/dict_to_schema/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The script (`run.py`) automates the entire conversion process in a few key steps
codebase = Codebase.from_repo("modal-labs/modal-client")
```

- Loads your codebase into Codegen's intelligent code analysis engine
- Loads your codebase into Graph-sitter's intelligent code analysis engine
- Provides a simple SDK for making codebase-wide changes
- Supports any Git repository as input

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/document_functions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This example demonstrates how to use Graph-sitter to automatically generate comp

## Overview

The script uses Codegen's symbol analysis capabilities to:
The script uses Graph-sitter's symbol analysis capabilities to:

1. Identify functions without docstrings
1. Analyze their dependencies and usages up to N degrees deep
Expand Down
4 changes: 2 additions & 2 deletions examples/examples/fragment_to_shorthand/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The script automates the entire conversion process in a few key steps:

1. **Zero Manual Updates**

- Codegen SDK handles all Fragment replacements
- Graph-sitter SDK handles all Fragment replacements
- Automatically cleans up imports

1. **Consistent Changes**
Expand All @@ -66,7 +66,7 @@ The script will:
- [React Fragments](https://react.dev/reference/react/Fragment)
- [JSX Fragments](https://react.dev/reference/jsx#jsx-fragments)
- [Graph-sitter Documentation](https://graph-sitter.com)
- [More on Codegen SDK jsx elements API](https://graph-sitter.com/api-reference/typescript/JSXElement#jsxelement)
- [More on Graph-sitter SDK jsx elements API](https://graph-sitter.com/api-reference/typescript/JSXElement#jsxelement)

## Contributing

Expand Down
Loading