Skip to content

feat(CG-10367): from codegen import Codebase #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 24, 2025
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
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Codegen

[![Documentation](https://img.shields.io/badge/docs-docs.codegen.com-blue)](https://docs.codegen.com)
[![Unit Tests](https://github.com/codegen-sh/codegen-sdk/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/codegen-sh/codegen-sdk/actions/workflows/unit-tests.yml)

[Codegen](https://docs.codegen.com) is a python library for manipulating codebases.

Expand Down Expand Up @@ -42,7 +41,7 @@ We built Codegen backwards from real-world refactors performed on enterprise cod

- **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 and validated on refactors at companies like [Ramp](https://ramp.com).
- **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.

Expand Down
5 changes: 5 additions & 0 deletions src/codegen/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from codegen.cli.sdk.decorator import function
from codegen.cli.sdk.functions import Function
from codegen.sdk.core.codebase import Codebase

__all__ = ["Codebase", "Function", "function"]
16 changes: 16 additions & 0 deletions tests/unit/test_imports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import codegen
from codegen import Codebase


def test_codegen_imports():
# Test decorated function
@codegen.function(name="sample_codemod")
def run(codebase):
pass

# Test class
cls = codegen.Function
assert cls is not None

codebase = Codebase("./")
assert codebase is not None
Loading