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
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Generate changelog
env:
OPEN_AI_TOKEN: ${{ secrets.OPEN_AI_TOKEN }}
run: uv run python src/codegen/gscli/cli.py generate changelog --openai-key ${{ secrets.OPEN_AI_TOKEN }}
run: uv run python src/gscli/cli.py generate changelog --openai-key ${{ secrets.OPEN_AI_TOKEN }}

- name: Commit changes
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/generate-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
uses: ./.github/actions/setup-environment

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

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

- name: Commit changes
run: |
Expand Down
21 changes: 10 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
default_language_version:
python: python3.13
repos:

- repo: https://github.com/ComPWA/taplo-pre-commit
rev: v0.9.3
hooks:
Expand All @@ -24,7 +23,7 @@ repos:
- id: biome-check
language: node
additional_dependencies: ["@biomejs/[email protected]"]
exclude: (src/codemods/eval)|(tests/unit/skills/snapshots)|(tests/unit/codegen/sdk/output)|(tests/integration/verified_codemods)|(docs/samples)
exclude: (src/codemods/eval)|(tests/unit/skills/snapshots)|(tests/unit/sdk/output)|(tests/integration/verified_codemods)|(docs/samples)
- repo: https://github.com/MarcoGorelli/cython-lint
rev: v0.16.6
hooks:
Expand Down Expand Up @@ -88,13 +87,13 @@ repos:
args: ["--frozen", "--all-packages", "--all-extras"]

- repo: https://github.com/hukkin/mdformat
rev: 0.7.22 # Use the ref you want to point at
rev: 0.7.22 # Use the ref you want to point at
hooks:
- id: mdformat
language: python
# Optionally add plugins
additional_dependencies:
- mdformat-gfm
- mdformat-ruff
- mdformat-config
- mdformat-pyproject
- id: mdformat
language: python
# Optionally add plugins
additional_dependencies:
- mdformat-gfm
- mdformat-ruff
- mdformat-config
- mdformat-pyproject
2 changes: 1 addition & 1 deletion codegen-examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ We recommend using [`uv`](https://github.com/astral-sh/uv) with Python 3.13 for

To install Codegen, please follow the [official installation guide](https://docs.codegen.com/introduction/installation). Once Codegen is installed, use these steps to run the examples in this repository:

Install the Codegen CLI globally
Install the graph_sitter.cli globally

```bash
uv tool install codegen
Expand Down
2 changes: 1 addition & 1 deletion codegen-examples/STRUCTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Your `run.py` should follow this structure, demonstrated well in the `generate_t

```python
import codegen
from codegen import Codebase
from graph_sitter import Codebase
from codegen.sdk.core import Function
# ... other imports
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from codegen import Codebase
from codegen.extensions.attribution.main import (
from graph_sitter import Codebase
from graph_sitter.extensions.attribution.main import (
add_attribution_to_symbols,
analyze_ai_impact,
)
Expand Down
8 changes: 4 additions & 4 deletions codegen-examples/examples/ai_impact_analysis/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import traceback
import os

from codegen import Codebase
from codegen.extensions.attribution.cli import run
from codegen.git.repo_operator.repo_operator import RepoOperator
from codegen.git.schemas.repo_config import RepoConfig
from graph_sitter import Codebase
from graph_sitter.extensions.attribution.cli import run
from graph_sitter.git.repo_operator.repo_operator import RepoOperator
from graph_sitter.git.schemas.repo_config import RepoConfig
from graph_sitter.codebase.config import ProjectConfig
from graph_sitter.shared.enums.programming_language import ProgrammingLanguage

Expand Down
28 changes: 14 additions & 14 deletions codegen-examples/examples/codegen-mcp-server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
from typing import Annotated, Any, Dict, List, Optional

import requests
from codegen import Codebase
from codegen.cli.api.client import RestAPI
from codegen.cli.api.endpoints import CODEGEN_SYSTEM_PROMPT_URL
from codegen.cli.auth.token_manager import get_current_token
from codegen.cli.codemod.convert import convert_to_cli
from codegen.cli.utils.default_code import DEFAULT_CODEMOD
from codegen.extensions.tools.reveal_symbol import reveal_symbol
from graph_sitter import Codebase
from graph_sitter.cli.api.client import RestAPI
from graph_sitter.cli.api.endpoints import CODEGEN_SYSTEM_PROMPT_URL
from graph_sitter.cli.auth.token_manager import get_current_token
from graph_sitter.cli.codemod.convert import convert_to_cli
from graph_sitter.cli.utils.default_code import DEFAULT_CODEMOD
from graph_sitter.extensions.tools.reveal_symbol import reveal_symbol
from mcp.server.fastmcp import FastMCP

logger = getLogger(__name__)
Expand Down Expand Up @@ -168,7 +168,7 @@ def codegen_system_prompt():
For example, consider the following script:

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

# Codegen builds a complete graph connecting
# functions, classes, imports and their relationships
Expand All @@ -195,7 +195,7 @@ def codegen_system_prompt():

They live in the `.codegen/codemods/{name}/{name.py}` directory, and take the following form:
```python
from codegen import Codebase
from graph_sitter import Codebase

@codegen.function('{name}')
def codemod(codebase: Codebase):
Expand Down Expand Up @@ -364,7 +364,7 @@ async def run_codemod(
try:
# Get the codemod using CodemodManager
try:
from codegen.cli.utils.codemod_manager import CodemodManager
from graph_sitter.cli.utils.codemod_manager import CodemodManager

codemod = CodemodManager.get_codemod(name, start_path=state.parsed_codebase.repo_path)
except Exception as e:
Expand All @@ -378,15 +378,15 @@ async def run_codemod(

# Validate arguments if schema exists
if codemod.arguments_type_schema:
from codegen.cli.utils.json_schema import validate_json
from graph_sitter.cli.utils.json_schema import validate_json

if not validate_json(codemod.arguments_type_schema, args_dict):
return {"error": f"Invalid arguments format. Expected schema: {codemod.arguments_type_schema}"}
except json.JSONDecodeError:
return {"error": "Invalid JSON in arguments parameter"}

# Create a session for the codemod
from codegen.cli.auth.session import CodegenSession
from graph_sitter.cli.auth.session import CodegenSession

session = CodegenSession(state.parsed_codebase.repo_path)
session.codebase = state.parsed_codebase
Expand Down Expand Up @@ -417,8 +417,8 @@ async def run_codemod(
async def reset() -> Dict[str, Any]:
try:
# Import necessary functions from reset command
from codegen.cli.commands.reset.main import backup_codegen_files, remove_untracked_files, restore_codegen_files
from codegen.cli.git.repo import get_git_repo
from graph_sitter.cli.commands.reset.main import backup_codegen_files, remove_untracked_files, restore_codegen_files
from graph_sitter.cli.git.repo import get_git_repo
from pygit2.enums import ResetMode

# Get the git repository
Expand Down
2 changes: 1 addition & 1 deletion codegen-examples/examples/cyclomatic_complexity/run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import codegen
from codegen import Codebase
from graph_sitter import Codebase
from graph_sitter.core.statements.for_loop_statement import ForLoopStatement
from graph_sitter.core.statements.if_block_statement import IfBlockStatement
from graph_sitter.core.statements.try_catch_statement import TryCatchStatement
Expand Down
2 changes: 1 addition & 1 deletion codegen-examples/examples/delete_dead_code/run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import codegen
from codegen import Codebase
from graph_sitter import Codebase


@codegen.function("delete-dead-code")
Expand Down
2 changes: 1 addition & 1 deletion codegen-examples/examples/dict_to_schema/run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import codegen
from codegen import Codebase
from graph_sitter import Codebase


@codegen.function("dict-to-pydantic-schema")
Expand Down
2 changes: 1 addition & 1 deletion codegen-examples/examples/document_functions/run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import codegen
from codegen import Codebase
from graph_sitter import Codebase
from graph_sitter.core.external_module import ExternalModule
from graph_sitter.core.import_resolution import Import
from graph_sitter.core.symbol import Symbol
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import codebase
from codegen import Codebase
from graph_sitter import Codebase

# Initialize codebase

Expand Down
2 changes: 1 addition & 1 deletion codegen-examples/examples/fragment_to_shorthand/run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import codegen
from codegen import Codebase
from graph_sitter import Codebase


@codegen.function("fragment_to_shorthand")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import codegen
from codegen import Codebase
from graph_sitter import Codebase


@codegen.function("freezegun-to-timemachine")
Expand Down
2 changes: 1 addition & 1 deletion codegen-examples/examples/generate_training_data/run.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json

import codegen
from codegen import Codebase
from graph_sitter import Codebase
from graph_sitter.core.external_module import ExternalModule
from graph_sitter.core.import_resolution import Import
from graph_sitter.core.symbol import Symbol
Expand Down
4 changes: 2 additions & 2 deletions codegen-examples/examples/github_checks/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import modal
from codegen import CodegenApp, Codebase
from codegen.extensions.github.types.events.pull_request import PullRequestLabeledEvent
from codegen.extensions.tools.github.create_pr_comment import create_pr_comment
from graph_sitter.extensions.github.types.events.pull_request import PullRequestLabeledEvent
from graph_sitter.extensions.tools.github.create_pr_comment import create_pr_comment
from dotenv import load_dotenv
import networkx as nx

Expand Down
2 changes: 1 addition & 1 deletion codegen-examples/examples/linear_webhooks/webhooks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import modal.running_app
from codegen.extensions.events.app import CodegenApp
from graph_sitter.extensions.events.app import CodegenApp
import modal

image = modal.Image.debian_slim(python_version="3.13").apt_install("git").pip_install("fastapi[standard]", "codegen>=v0.22.2")
Expand Down
4 changes: 2 additions & 2 deletions codegen-examples/examples/modal_repo_analytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ uv add modal
2. Start the API server:

```bash
modal serve src/codegen/extensions/modal/api.py
modal serve src/graph_sitter.extensions/modal/api.py
```

3. Test with curl:
Expand Down Expand Up @@ -64,5 +64,5 @@ The API is built using:
To deploy changes:

```bash
modal deploy src/codegen/extensions/modal/api.py
modal deploy src/graph_sitter.extensions/modal/api.py
```
2 changes: 1 addition & 1 deletion codegen-examples/examples/modal_repo_analytics/api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Modal API endpoint for repository analysis."""

import modal # deptry: ignore
from codegen import Codebase
from graph_sitter import Codebase
from pydantic import BaseModel

# Create image with dependencies
Expand Down
4 changes: 2 additions & 2 deletions codegen-examples/examples/modal_repo_rag/api.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Modal API endpoint for RAG-based code Q&A using Codegen's VectorIndex."""

import modal
from codegen import Codebase
from codegen.extensions import VectorIndex
from graph_sitter import Codebase
from graph_sitter.extensions import VectorIndex
from pydantic import BaseModel

# Create image with dependencies
Expand Down
2 changes: 1 addition & 1 deletion codegen-examples/examples/modules_dependencies/run.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import codegen
import networkx as nx
from codegen import Codebase
from graph_sitter import Codebase


@codegen.function("visualize-modules-dependencies")
Expand Down
2 changes: 1 addition & 1 deletion codegen-examples/examples/openapi_decorators/run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import codegen
from codegen import Codebase
from graph_sitter import Codebase


def analyze_model_fields(method) -> dict:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"metadata": {},
"outputs": [],
"source": [
"from codegen import Codebase\n",
"from graph_sitter import Codebase\n",
"from graph_sitter.enums import ProgrammingLanguage\n",
"from graph_sitter.core.statements.statement import StatementType"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"metadata": {},
"outputs": [],
"source": [
"from codegen import Codebase"
"from graph_sitter import Codebase"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion codegen-examples/examples/promises_to_async_await/run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import codegen
from codegen import Codebase
from graph_sitter import Codebase
from graph_sitter.core.statements.statement import StatementType


Expand Down
2 changes: 1 addition & 1 deletion codegen-examples/examples/python2_to_python3/run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import codegen
from codegen import Codebase
from graph_sitter import Codebase

# Initialize codebase

Expand Down
2 changes: 1 addition & 1 deletion codegen-examples/examples/reexport_management/run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import codegen
from codegen import Codebase
from graph_sitter import Codebase
from graph_sitter.typescript.file import TSImport

processed_imports = set()
Expand Down
2 changes: 1 addition & 1 deletion codegen-examples/examples/remove_default_exports/run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import codegen
from codegen import Codebase
from graph_sitter import Codebase
from graph_sitter.typescript.file import TSFile


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"metadata": {},
"outputs": [],
"source": [
"from codegen import Codebase\n",
"from graph_sitter import Codebase\n",
"import networkx as nx\n",
"from utils import visualize_graph # utility function to visualize a networkx graph"
]
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
@@ -1,5 +1,5 @@
from typing import Dict, Any
from codegen import Codebase
from graph_sitter import Codebase
from graph_sitter.core.statements.for_loop_statement import ForLoopStatement
from graph_sitter.core.statements.if_block_statement import IfBlockStatement
from graph_sitter.core.statements.try_catch_statement import TryCatchStatement
Expand Down
4 changes: 2 additions & 2 deletions codegen-examples/examples/slack_chatbot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ for all files in a codebase. It handles chunking large files and maintains
a persistent index for faster subsequent queries.

*Relevant Files:*
• src/codegen/extensions/vector_index.py
• src/codegen/extensions/tools/semantic_search.py
• src/graph_sitter.extensions/vector_index.py
• src/graph_sitter.extensions/tools/semantic_search.py
```

## Environment Variables
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 @@ -4,8 +4,8 @@
from typing import Any

import modal
from codegen import Codebase
from codegen.extensions import VectorIndex
from graph_sitter import Codebase
from graph_sitter.extensions import VectorIndex
from fastapi import FastAPI, Request
from openai import OpenAI
from slack_bolt import App
Expand Down
2 changes: 1 addition & 1 deletion codegen-examples/examples/sqlalchemy_1.6_to_2.0/run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import codegen
from codegen import Codebase
from graph_sitter import Codebase
from graph_sitter.core.detached_symbols.function_call import FunctionCall
from graph_sitter.core.expressions.chained_attribute import ChainedAttribute

Expand Down
Loading
Loading