You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://x.com/codegen)
20
20
21
21
</div>
22
22
23
23
<br />
24
24
25
-
The Codegen SDK provides a programmatic interface to code agents provided by [Codegen](https://codegen.com).
25
+
[Codegen](https://docs.codegen.com) is a python library for manipulating codebases.
26
26
27
27
```python
28
-
from codegen.agents.agent import Agent
28
+
from codegen import Codebase
29
+
30
+
# Codegen builds a complete graph connecting
31
+
# functions, classes, imports and their relationships
32
+
codebase = Codebase("./")
33
+
34
+
# Work with code without dealing with syntax trees or parsing
35
+
for function in codebase.functions:
36
+
# Comprehensive static analysis for references, dependencies, etc.
37
+
ifnot function.usages:
38
+
# Auto-handles references and imports to maintain correctness
39
+
function.move_to_file("deprecated.py")
40
+
```
41
+
42
+
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.
29
43
30
-
# Initialize the Agent with your organization ID and API token
31
-
agent = Agent(
32
-
org_id="YOUR_ORG_ID", # Find this at codegen.com/developer
33
-
token="YOUR_API_TOKEN", # Get this from codegen.com/developer
34
-
# base_url="https://codegen-sh-rest-api.modal.run", # Optional - defaults to production
35
-
)
44
+
## Installation and Usage
36
45
37
-
# Run an agent with a prompt
38
-
task = agent.run(prompt="Implement a new feature to sort users by last login.")
- Linux is supported on x86_64 and aarch64 with glibc 2.34+
52
+
- Windows is supported via WSL. See [here](https://docs.codegen.com/building-with-codegen/codegen-with-wsl) for more details.
53
+
- Python, Typescript, Javascript and React codebases
42
54
43
-
# Refresh the task to get updated status (tasks can take time)
44
-
task.refresh()
55
+
```
56
+
# Install inside existing project
57
+
uv pip install codegen
45
58
46
-
#Check the updated status
47
-
print(task.status)
59
+
# Install global CLI
60
+
uv tool install codegen --python 3.13
48
61
49
-
# Once task is complete, you can access the result
50
-
if task.status =="completed":
51
-
print(task.result) # Result often contains code, summaries, or links
62
+
# Create a codemod for a given repo
63
+
cd path/to/repo
64
+
gs init
65
+
gs create test-function
66
+
67
+
# Run the codemod
68
+
gs run test-function
69
+
70
+
# Create an isolated venv with codegen => open jupyter
71
+
gs notebook
52
72
```
53
73
54
-
## Installation and Usage
74
+
## Usage
55
75
56
-
Install the SDK using pip or uv:
76
+
See [Getting Started](https://docs.codegen.com/introduction/getting-started) for a full tutorial.
57
77
58
-
```bash
59
-
pip install codegen
60
-
# or
61
-
uv pip install codegen
62
78
```
79
+
from codegen import Codebase
80
+
```
81
+
82
+
## Troubleshooting
83
+
84
+
Having issues? Here are some common problems and their solutions:
63
85
64
-
Get started at [codegen.com](https://codegen.com) and get your API token at [codegen.com/developer](https://codegen.com/developer).
86
+
-**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`.
87
+
-**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`.
88
+
-**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)`.
65
89
66
-
You can interact with your AI engineer via API, or chat with it in Slack, Linear, Github, or on our website.
90
+
If you run into additional issues not listed here, please [join our slack community](https://community.codegen.com) and we'll help you out!
67
91
68
92
## Resources
69
93
@@ -72,6 +96,18 @@ You can interact with your AI engineer via API, or chat with it in Slack, Linear
72
96
-[Contributing](CONTRIBUTING.md)
73
97
-[Contact Us](https://codegen.com/contact)
74
98
99
+
## Why Codegen?
100
+
101
+
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.
102
+
103
+
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:
104
+
105
+
-**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.
106
+
107
+
-**Battle-tested on complex codebases**: Handle Python, TypeScript, and React codebases with millions of lines of code.
108
+
109
+
-**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.
110
+
75
111
## Contributing
76
112
77
113
Please see our [Contributing Guide](CONTRIBUTING.md) for instructions on how to set up the development environment and submit contributions.
Copy file name to clipboardExpand all lines: codegen-examples/examples/promises_to_async_await/README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,7 +101,7 @@ Currently, the `promise_chain.convert_to_async_await()` method handles the follo
101
101
102
102
**IMPORTANT:**
103
103
104
-
_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._
104
+
_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._
0 commit comments