From ecffd14e06147579be234ae561c9debfdadb278f Mon Sep 17 00:00:00 2001 From: "codegen-sh[bot]" <131295404+codegen-sh[bot]@users.noreply.github.com> Date: Thu, 27 Mar 2025 16:19:51 +0000 Subject: [PATCH 1/4] Update README.md with correct codegen create command syntax --- CLA.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CLA.md b/CLA.md index 1c22a4b92..9c2a9da39 100644 --- a/CLA.md +++ b/CLA.md @@ -1,6 +1,6 @@ # **Contributor License Agreement (CLA)** -**Effective Date:** 1/17/2025 +**Effective Date:** 3/27/2024 **Project Name:** codegen diff --git a/README.md b/README.md index f9e94756b..07874da9b 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ uv tool install codegen --python 3.13 # Create a codemod for a given repo cd path/to/repo codegen init -codegen create test-function +codegen create test-function . -d "describe what you want to do" # Run the codemod codegen run test-function From 5ed17dde48edb8264e49e46f72cac75b80109086 Mon Sep 17 00:00:00 2001 From: "codegen-sh[bot]" <131295404+codegen-sh[bot]@users.noreply.github.com> Date: Thu, 27 Mar 2025 16:26:29 +0000 Subject: [PATCH 2/4] Update README.md with improved formatting and content --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 07874da9b..89c5ea0cf 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@
-[Codegen](https://docs.codegen.com) is a python library for manipulating codebases. +[Codegen](https://docs.codegen.com) is a Python library for manipulating codebases at scale. ```python from codegen import Codebase @@ -43,16 +43,16 @@ Write code that transforms code. Codegen combines the parsing power of [Tree-sit ## Installation and Usage -We support +We support: - Running Codegen in Python 3.12 - 3.13 (recommended: Python 3.13+) - macOS and Linux - - macOS is supported + - macOS is fully 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 +- Python, TypeScript, JavaScript and React codebases -``` +```bash # Install inside existing project uv pip install codegen @@ -75,7 +75,7 @@ codegen notebook See [Getting Started](https://docs.codegen.com/introduction/getting-started) for a full tutorial. -``` +```python from codegen import Codebase ``` @@ -91,7 +91,7 @@ If you run into additional issues not listed here, please [join our slack commun ## Resources -- [Docs](https://docs.codegen.com) +- [Documentation](https://docs.codegen.com) - [Getting Started](https://docs.codegen.com/introduction/getting-started) - [Contributing](CONTRIBUTING.md) - [Contact Us](https://codegen.com/contact) From 89ed32fabe600527828603d59b69aa43edd5a83d Mon Sep 17 00:00:00 2001 From: "codegen-sh[bot]" <131295404+codegen-sh[bot]@users.noreply.github.com> Date: Thu, 27 Mar 2025 20:00:53 +0000 Subject: [PATCH 3/4] Update README with improved documentation and examples --- README.md | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 89c5ea0cf..19515c5d3 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@
-[Codegen](https://docs.codegen.com) is a Python library for manipulating codebases at scale. +[Codegen](https://docs.codegen.com) is a Python library for manipulating codebases at scale with a natural, intuitive API. ```python from codegen import Codebase @@ -62,10 +62,10 @@ uv tool install codegen --python 3.13 # Create a codemod for a given repo cd path/to/repo codegen init -codegen create test-function . -d "describe what you want to do" +codegen create my-function . -d "describe what you want to do" # Run the codemod -codegen run test-function +codegen run my-function --apply-local # Create an isolated venv with codegen => open jupyter codegen notebook @@ -77,8 +77,29 @@ See [Getting Started](https://docs.codegen.com/introduction/getting-started) for ```python from codegen import Codebase + +# Initialize a codebase object +codebase = Codebase("./") + +# Find and manipulate functions +for function in codebase.functions: + # Analyze function properties + print(f"Function: {function.name}, Lines: {len(function.body_lines)}") + + # Rename functions matching a pattern + if function.name.startswith("old_"): + new_name = function.name.replace("old_", "new_") + function.rename(new_name) ``` +## Features + +- **Intuitive API**: Work with code using natural operations like `rename()`, `move_to_file()`, and `add_parameter()` +- **Multi-language support**: Works with Python, TypeScript, JavaScript, and React +- **Comprehensive analysis**: Automatically tracks references, dependencies, and usages +- **Import management**: Handles import statements automatically when moving or renaming code +- **Codemod framework**: Create, share, and run code transformations with the CLI + ## Troubleshooting Having issues? Here are some common problems and their solutions: @@ -93,6 +114,8 @@ If you run into additional issues not listed here, please [join our slack commun - [Documentation](https://docs.codegen.com) - [Getting Started](https://docs.codegen.com/introduction/getting-started) +- [API Reference](https://docs.codegen.com/api-reference/codebase) +- [CLI Commands](https://docs.codegen.com/cli/about) - [Contributing](CONTRIBUTING.md) - [Contact Us](https://codegen.com/contact) From a7bfef9500a6da89f9a1c1ac6a31a2425d0cce86 Mon Sep 17 00:00:00 2001 From: "codegen-sh[bot]" <131295404+codegen-sh[bot]@users.noreply.github.com> Date: Thu, 27 Mar 2025 20:01:41 +0000 Subject: [PATCH 4/4] Automated pre-commit update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 19515c5d3..6d49ca933 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ codebase = Codebase("./") for function in codebase.functions: # Analyze function properties print(f"Function: {function.name}, Lines: {len(function.body_lines)}") - + # Rename functions matching a pattern if function.name.startswith("old_"): new_name = function.name.replace("old_", "new_")