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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .github/workflows/generate-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- develop

permissions:
contents: write # Need write permission to commit changes
contents: write # Need write permission to commit changes

jobs:
generate-docs:
Expand All @@ -22,10 +22,10 @@ jobs:
uses: ./.github/actions/setup-environment

- name: Generate API reference
run: uv run python src/gscli/cli.py generate docs
run: uv run python src/graph-sitter/gscli/cli.py generate docs

- name: Generate System Prompt
run: uv run python src/gscli/cli.py generate system-prompt
run: uv run python src/graph-sitter/gscli/cli.py generate system-prompt

- name: Commit changes
run: |
Expand Down
94 changes: 65 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,63 +7,87 @@
</p>

<h2 align="center">
The SWE that Never Sleeps
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)
[![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 />

The Codegen SDK provides a programmatic interface to code agents provided by [Codegen](https://codegen.com).
[Codegen](https://docs.codegen.com) is a python library for manipulating codebases.

```python
from codegen.agents.agent import Agent
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.

# Initialize the Agent with your organization ID and API token
agent = Agent(
org_id="YOUR_ORG_ID", # Find this at codegen.com/developer
token="YOUR_API_TOKEN", # Get this from codegen.com/developer
# base_url="https://codegen-sh-rest-api.modal.run", # Optional - defaults to production
)
## Installation and Usage

# Run an agent with a prompt
task = agent.run(prompt="Implement a new feature to sort users by last login.")
We support

# Check the initial status
print(task.status)
- 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

# Refresh the task to get updated status (tasks can take time)
task.refresh()
```
# Install inside existing project
uv pip install codegen

# Check the updated status
print(task.status)
# Install global CLI
uv tool install codegen --python 3.13

# Once task is complete, you can access the result
if task.status == "completed":
print(task.result) # Result often contains code, summaries, or links
# 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 codegen => open jupyter
gs notebook
```

## Installation and Usage
## Usage

Install the SDK using pip or uv:
See [Getting Started](https://docs.codegen.com/introduction/getting-started) for a full tutorial.

```bash
pip install codegen
# or
uv pip install codegen
```
from codegen import Codebase
```

## Troubleshooting

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

Get started at [codegen.com](https://codegen.com) and get your API token at [codegen.com/developer](https://codegen.com/developer).
- **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)`.

You can interact with your AI engineer via API, or chat with it in Slack, Linear, Github, or on our website.
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

Expand All @@ -72,6 +96,18 @@ You can interact with your AI engineer via API, or chat with it in Slack, Linear
- [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.
Expand Down
2 changes: 1 addition & 1 deletion codegen-examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ uv tool install codegen
Initialize Codegen in your project

```bash
codegen init
gs init
```

Activate the virtual environment
Expand Down
2 changes: 1 addition & 1 deletion codegen-examples/examples/ai_impact_analysis/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
if not found_git:
# Option C: Use from_repo method which handles cloning
print("No local git repository found. Cloning a repository...")
codebase = Codebase.from_repo(repo_full_name="codegen-sh/codegen", language="python")
codebase = Codebase.from_repo(repo_full_name="codegen-sh/graph-sitter", language="python")

print(f"Codebase loaded with {len(codebase.files)} files and {len(codebase.symbols)} symbols")

Expand Down
6 changes: 3 additions & 3 deletions codegen-examples/examples/codegen-mcp-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div align="center">

[![Documentation](https://img.shields.io/badge/Docs-docs.codegen.com-purple?style=flat-square)](https://docs.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)
[![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)

</div>

Expand All @@ -36,7 +36,7 @@ This example demonstrates how to run a Model Control Protocol (MCP) server that
1. No installation is necessary, with the following command. Run this command directly or add it your `.json` mcp config file.

```bash
uvx --from 'git+https://github.com/codegen-sh/codegen-sdk.git#egg=codegen-mcp-server&subdirectory=codegen-examples/examples/codegen-mcp-server' codegen-mcp-server
uvx --from 'git+https://github.com/codegen-sh/graph-sitter.git#egg=codegen-mcp-server&subdirectory=codegen-examples/examples/codegen-mcp-server' codegen-mcp-server
```

### Example MCP Config
Expand All @@ -50,7 +50,7 @@ Here is an example mcp config that can be used with Cline or Claude desktop to i
"command": "uvx",
"args": [
"--from",
"git+https://github.com/codegen-sh/codegen-sdk.git#egg=codegen-mcp-server&subdirectory=codegen-examples/examples/codegen-mcp-server",
"git+https://github.com/codegen-sh/graph-sitter.git#egg=codegen-mcp-server&subdirectory=codegen-examples/examples/codegen-mcp-server",
"codegen-mcp-server"
],
"disabled": false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Please read two things before trying to install this codegen MCP server:

1. [Readme](https://raw.githubusercontent.com/codegen-sh/codegen-sdk/refs/heads/develop/codegen-examples/examples/codegen-mcp-server/README.md)
1. [Readme](https://raw.githubusercontent.com/codegen-sh/graph-sitter/refs/heads/develop/codegen-examples/examples/codegen-mcp-server/README.md)

- This contains the instructions for setting up the mcp server

Expand All @@ -10,7 +10,7 @@ Please read two things before trying to install this codegen MCP server:

Please use a CURL command to retrieve the contents of the readme and documentation and read both before starting to install the server.

1. curl -sL "https://raw.githubusercontent.com/codegen-sh/codegen-sdk/refs/heads/develop/README.md" | cat
1. curl -sL "https://raw.githubusercontent.com/codegen-sh/graph-sitter/refs/heads/develop/README.md" | cat

1. curl -sL "https://docs.codegen.com/llms.txt" | cat

Expand Down
4 changes: 2 additions & 2 deletions codegen-examples/examples/linear_webhooks/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion codegen-examples/examples/modal_repo_rag/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div align="center">

[![Documentation](https://img.shields.io/badge/Docs-docs.codegen.com-purple?style=flat-square)](https://docs.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)
[![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)

</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Currently, the `promise_chain.convert_to_async_await()` method handles the follo

**IMPORTANT:**

_There will be cases that the current `promise_chain.convert_to_async_await()` cannot handle. In those cases, either right your own transformation logic using the codegen-sdk or open an issue on the [Codegen](https://github.com/codegen-sh/codegen-sdk) repository._
_There will be cases that the current `promise_chain.convert_to_async_await()` cannot handle. In those cases, either right your own transformation logic using the codegen-sdk or open an issue on the [Codegen](https://github.com/codegen-sh/graph-sitter) repository._

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion codegen-examples/examples/repo_analytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ The script will output a detailed report including:
```
📊 Repository Analysis Report 📊
==================================================
📁 Repository: codegen-sh/codegen
📁 Repository: codegen-sh/graph-sitter
📝 Description: [Repository description from GitHub]

📈 Basic Metrics:
Expand Down
2 changes: 1 addition & 1 deletion codegen-examples/examples/repo_analytics/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def analyze_repo(repo_url: str) -> Dict[str, Any]:


if __name__ == "__main__":
repo_url = "codegen-sh/codegen"
repo_url = "codegen-sh/graph-sitter"
results = analyze_repo(repo_url)

print("\n📊 Repository Analysis Report 📊")
Expand Down
2 changes: 1 addition & 1 deletion codegen-examples/examples/slack_chatbot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div align="center">

[![Documentation](https://img.shields.io/badge/Docs-docs.codegen.com-purple?style=flat-square)](https://docs.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)
[![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)

</div>

Expand Down
4 changes: 2 additions & 2 deletions codegen-examples/examples/slack_chatbot/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ def format_response(answer: str, context: list[tuple[str, int]]) -> str:
"""Format the response for Slack with file links."""
response = f"*Answer:*\n{answer}\n\n*Relevant Files:*\n"
for filename, score in context:
github_link = f"https://github.com/codegen-sh/codegen-sdk/blob/develop/{filename}"
github_link = f"https://github.com/codegen-sh/graph-sitter/blob/develop/{filename}"
response += f"• <{github_link}|{filename}>\n"
return response


def answer_question(query: str) -> tuple[str, list[tuple[str, int]]]:
"""Use RAG to answer a question about FastAPI."""
# Initialize codebase. Smart about caching.
codebase = Codebase.from_repo("codegen-sh/codegen-sdk", language="python", tmp_dir="/root")
codebase = Codebase.from_repo("codegen-sh/graph-sitter", language="python", tmp_dir="/root")

# Initialize vector index
index = VectorIndex(codebase)
Expand Down
2 changes: 1 addition & 1 deletion codegen-examples/examples/symbol-attributions/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def print_symbol_attribution(codebase):
# Use from_repo method for a well-known repository
print("Using a sample repository...")
codebase = Codebase.from_repo(
repo_full_name="codegen-sh/codegen",
repo_full_name="codegen-sh/graph-sitter",
# commit="", # Using a specific commit for consistency
language="python",
)
Expand Down
72 changes: 0 additions & 72 deletions docs/_deprecated/graph-sitter/about.mdx

This file was deleted.

Loading
Loading