### Start Development Server Source: https://github.com/codegen-sh/codegen/blob/develop/docs/README.md Installs Mintlify globally and starts the development server with hot reloading from the docs directory. ```bash npm i -g mintlify mintlify dev --port 3333 ``` -------------------------------- ### Combined Setup Commands Source: https://github.com/codegen-sh/codegen/blob/develop/docs/sandboxes/setup-commands.mdx A combination of commands to set a Node.js version, install dependencies using npm ci, and run a build script. ```bash # Or a combination of commands nvm use 18 npm ci npm run build ``` -------------------------------- ### Available Installation Methods Source: https://github.com/codegen-sh/codegen/blob/develop/docs/self-update.md Lists the different methods supported for installing or updating the codegen CLI. ```APIDOC ## InstallMethod Enum ### Description Represents the various methods by which the codegen CLI can be installed or updated. ### Members - **PIP**: Installation using pip. - **PIPX**: Installation using pipx. - **UV_TOOL**: Installation using uv. - **HOMEBREW**: Installation using Homebrew. - **DEVELOPMENT**: Installation from a development source. - **UNKNOWN**: An unrecognized installation method. ``` -------------------------------- ### Available Installation Methods Source: https://github.com/codegen-sh/codegen/blob/develop/docs/self-update.md Lists the different installation methods supported by the CLI's update mechanism. Requires importing InstallMethod. ```python from codegen.cli.commands.update.updater import InstallMethod methods = [ InstallMethod.PIP, InstallMethod.PIPX, InstallMethod.UV_TOOL, InstallMethod.HOMEBREW, InstallMethod.DEVELOPMENT, InstallMethod.UNKNOWN ] ``` -------------------------------- ### Install Codegen Package Source: https://github.com/codegen-sh/codegen/blob/develop/docs/introduction/sdk.mdx Install the codegen package from PyPI using pip, pipx, or uv. ```bash # Using pip pip install codegen ``` ```bash # Using pipx (for CLI usage) pipx install codegen ``` ```bash # Using uv uv pip install codegen ``` ```bash # or uv tool install codegen ``` -------------------------------- ### Set Up Development Environment with UV Source: https://github.com/codegen-sh/codegen/blob/develop/CONTRIBUTING.md Sets up a Python virtual environment and installs development dependencies using UV. Ensure UV is installed and activated before running these commands. ```bash uv venv source .venv/bin/activate uv sync --dev ``` -------------------------------- ### Start Node.js Development Server Source: https://github.com/codegen-sh/codegen/blob/develop/docs/sandboxes/web-preview.mdx Use this command to start a Node.js development server using npm. Ensure your project has a `dev` script defined in `package.json`. ```bash # For a Node.js/npm project npm run dev ``` -------------------------------- ### Install Codegen CLI Source: https://github.com/codegen-sh/codegen/blob/develop/docs/capabilities/claude-code.mdx Install the Codegen CLI tool. This is the first step to integrating Claude Code with Codegen. ```bash uv tool install codegen ``` -------------------------------- ### Install Codegen SDK Source: https://github.com/codegen-sh/codegen/blob/develop/README.md Install the Codegen SDK using pip, pipx, or uv. Choose the command that best suits your Python environment management. ```bash pip install codegen # or pipx install codegen # or uv tool install codegen ``` -------------------------------- ### Enhance claude/main.py with Logging Source: https://github.com/codegen-sh/codegen/blob/develop/QUICK_START_LOGGING.md Integrate logging into the `_run_claude_interactive` function to record the start, completion, or failure of a Claude session. This example demonstrates logging session-specific details and outcomes. ```python logger = get_logger(__name__) def _run_claude_interactive(resolved_org_id: int, no_mcp: bool | None) -> None: session_id = generate_session_id() # ADD: Log session start logger.info("Claude session started", extra={ "operation": "claude.session_start", "session_id": session_id[:8], # Short version for privacy "org_id": resolved_org_id }) # Your existing code... try: process = subprocess.Popen([claude_path, "--session-id", session_id]) returncode = process.wait() # ADD: Log session end logger.info("Claude session completed", extra={ "operation": "claude.session_complete", "session_id": session_id[:8], "exit_code": returncode, "status": "COMPLETE" if returncode == 0 else "ERROR" }) except Exception as e: # ADD: Log session error logger.error("Claude session failed", extra={ "operation": "claude.session_error", "session_id": session_id[:8], "error": str(e) }) ``` -------------------------------- ### Setup Python Environment with pyenv Source: https://github.com/codegen-sh/codegen/blob/develop/docs/sandboxes/setup-commands.mdx Configure a specific Python version and install project dependencies using pip. This is useful for projects requiring compatibility with older Python versions. ```bash # Setup with specific Python version for compatibility pyenv install 3.12.0 pyenv local 3.12.0 python -m venv venv source venv/bin/activate pip install -r requirements.txt ``` -------------------------------- ### Install Codegen Agent SDK Source: https://github.com/codegen-sh/codegen/blob/develop/src/codegen/agents/README.md Install the Codegen Agent SDK using pip. Ensure you have the latest version. ```bash pip install codegen ``` -------------------------------- ### Initialize TokenManager and Get Token Source: https://github.com/codegen-sh/codegen/blob/develop/src/codegen/cli/auth/token_manager.ipynb Demonstrates how to initialize the TokenManager and retrieve an authentication token. Ensure the TokenManager class is imported. ```python from codegen.cli.auth.token_manager import TokenManager token_manager = TokenManager() print(token_manager.get_token()) ``` -------------------------------- ### Install Codegen via pipx Source: https://github.com/codegen-sh/codegen/blob/develop/docs/self-update.md Use this command to install Codegen using pipx. To update, use the `upgrade` subcommand. ```bash pipx install codegen # Updates via: pipx upgrade codegen ``` -------------------------------- ### Install Codegen via UV Tool Source: https://github.com/codegen-sh/codegen/blob/develop/docs/self-update.md Use this command to install Codegen using the UV tool. To update, use the `--upgrade` flag. ```bash uv tool install codegen # Updates via: uv tool install --upgrade codegen ``` -------------------------------- ### Install npm Dependencies Source: https://github.com/codegen-sh/codegen/blob/develop/docs/sandboxes/setup-commands.mdx Use this command to install project dependencies using npm. Ensure Node.js is available in the environment. ```bash # Switch to Node.js version 20 nvm use 20 # Install npm dependencies npm install ``` -------------------------------- ### Install pyenv and Configure Python Source: https://github.com/codegen-sh/codegen/blob/develop/docs/sandboxes/setup-commands.mdx Install pyenv, add it to the PATH, and configure it to manage Python versions. This is a prerequisite for using pyenv to manage Python environments. ```bash # Install pyenv curl https://pyenv.run | bash # Add pyenv to PATH (for current session) export PATH="$HOME/.pyenv/bin:$PATH" eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)" # Install Python 3.12 (or your desired version) pyenv install 3.12.0 # Set Python 3.12 as the local version for your project pyenv local 3.12.0 # Create a virtual environment with Python 3.12 python -m venv venv source venv/bin/activate # Install your dependencies pip install -r requirements.txt ``` -------------------------------- ### Start Ruby on Rails Development Server Source: https://github.com/codegen-sh/codegen/blob/develop/docs/sandboxes/web-preview.mdx Use this command to start a Ruby on Rails development server. It binds to `127.0.0.1` and specifies port 3000 for Codegen's Web Preview. ```bash # For a Ruby on Rails project bundle exec rails server -b 127.0.0.1 -p 3000 ``` -------------------------------- ### Install Codegen via pip Source: https://github.com/codegen-sh/codegen/blob/develop/docs/self-update.md Use this command to install Codegen using pip. To update, use the `--upgrade` flag. ```bash pip install codegen # Updates via: pip install --upgrade codegen ``` -------------------------------- ### Install UV Package Manager on macOS Source: https://github.com/codegen-sh/codegen/blob/develop/CONTRIBUTING.md Installs the UV package manager using Homebrew on macOS. For other platforms, refer to the official UV installation documentation. ```bash brew install uv ``` -------------------------------- ### Start Python Django Development Server Source: https://github.com/codegen-sh/codegen/blob/develop/docs/sandboxes/web-preview.mdx Use this command to start a Python Django development server. It binds to `127.0.0.1` and listens on port 3000, which is required for Codegen's Web Preview. ```bash # For a Python/Django project python manage.py runserver 127.0.0.1:3000 ``` -------------------------------- ### Manage Python Versions with uv Source: https://github.com/codegen-sh/codegen/blob/develop/docs/sandboxes/setup-commands.mdx Use the `uv` package manager to install a specific Python version and create a virtual environment, then install project dependencies. ```bash # Install Python 3.12 and create a virtual environment uv venv --python=3.12 # Activate the virtual environment source .venv/bin/activate # Install dependencies uv pip install -r requirements.txt --refresh --upgrade ``` -------------------------------- ### Install Codegen via Homebrew (macOS) Source: https://github.com/codegen-sh/codegen/blob/develop/docs/self-update.md Use this command to install Codegen using Homebrew on macOS. To update, use the `upgrade` command. ```bash brew install codegen # Updates via: brew upgrade codegen ``` -------------------------------- ### Example AGENTS.md Rule File Source: https://github.com/codegen-sh/codegen/blob/develop/docs/settings/repo-rules.mdx This markdown file demonstrates how to structure backend development rules, including database operations and API design conventions. It's automatically detected by Codegen. ```markdown # Backend Development Rules ## Database - Use Prisma for database operations - Always use transactions for multi-step operations - Include proper error handling for all database calls ## API Design - Follow REST conventions - Use proper HTTP status codes - Include request/response validation ``` -------------------------------- ### Log Operation Start and End Source: https://github.com/codegen-sh/codegen/blob/develop/QUICK_START_LOGGING.md Use this pattern to log the start and end of an operation, including relevant input and success status. This is useful for tracking the lifecycle of tasks. ```python logger = get_logger(__name__) # At start of function logger.info("Operation started", extra={ "operation": "command.subcommand", "user_input": relevant_input }) # At end of function logger.info("Operation completed", extra={ "operation": "command.subcommand", "success": True }) ``` -------------------------------- ### Manual Codegen MCP Server Setup Source: https://github.com/codegen-sh/codegen/blob/develop/src/codegen/cli/mcp/README.md Manually add a new MCP server in the Cursor IDE settings. This involves providing a name, type, and the command to run the Codegen MCP server. ```text Name: codegen-mcp Type: Command Command: uv --directory /codegen-sdk/src/codegen/cli/mcp run server.py ``` -------------------------------- ### Slack Thread Example Source: https://github.com/codegen-sh/codegen/blob/develop/docs/capabilities/interrupts.mdx Demonstrates how a user can interrupt a Codegen task in a Slack thread to add new requirements. The conversation shows iterative refinement of a user registration form. ```text User: @codegen create a user registration form Codegen: I'll create a user registration form! 📝 [working...] User: Make sure it includes email verification Codegen: Got it! Adding email verification to the registration form 📧 User: And add password strength requirements Codegen: Perfect! I'll include password strength validation as well 🔒 ``` -------------------------------- ### Create Virtual Environment for Older Python Source: https://github.com/codegen-sh/codegen/blob/develop/docs/sandboxes/setup-commands.mdx Create a virtual environment using a specific older Python version (e.g., 3.12) and activate it to install compatible packages. ```bash # Create a virtual environment with a specific Python version python3.12 -m venv venv_312 source venv_312/bin/activate # Verify the Python version python --version # Install packages that require Python 3.12 pip install argis==2.4.0 # Example package that needs older Python # Deactivate when done deactivate ``` -------------------------------- ### CI/CD Workflow with Codegen Integration Source: https://github.com/codegen-sh/codegen/blob/develop/docs/api-reference/github-actions.mdx This example shows how to integrate Codegen reviews into an existing CI/CD pipeline. The Codegen review job runs only after the tests have passed successfully. ```yaml name: CI/CD with Codegen on: pull_request: types: [opened, synchronize] jobs: tests: runs-on: ubuntu-latest steps: - name: Run tests run: npm test codegen-review: needs: tests # Only run review if tests pass if: success() runs-on: ubuntu-latest steps: # ... Codegen review steps deploy: needs: [tests, codegen-review] if: success() && github.ref == 'refs/heads/main' runs-on: ubuntu-latest steps: - name: Deploy run: npm run deploy ``` -------------------------------- ### Slack Interrupt Example Source: https://github.com/codegen-sh/codegen/blob/develop/docs/capabilities/interrupts.mdx Demonstrates how a user can send an interrupt message to Codegen in Slack by mentioning it. This allows for adding new requirements during an ongoing task. ```text User: @codegen can you fix the login bug? Codegen: I'll fix the login bug! 🔧 [starts working] User: Actually, make sure to also handle the password reset flow Codegen: Got it! I'll include the password reset flow in my fix 👍 ``` -------------------------------- ### Troubleshoot update failures Source: https://github.com/codegen-sh/codegen/blob/develop/docs/self-update.md If updates fail, try the legacy update method or manually update via pip. Verify your installation path and details using 'which' and 'pip show'. ```bash codegen update --legacy ``` ```bash pip install --upgrade codegen ``` ```bash which codegen ``` ```bash pip show codegen ``` -------------------------------- ### Linear Interrupt Example Source: https://github.com/codegen-sh/codegen/blob/develop/docs/capabilities/interrupts.mdx Illustrates how a user can interrupt Codegen in Linear by adding a comment to an issue. This allows for providing additional requirements or clarifications while the agent is working. ```text Issue: Fix authentication system Codegen: Working on the authentication fix... [User adds comment]: "Please also add 2FA support" Codegen: I see you've added 2FA requirements - incorporating that now! ``` -------------------------------- ### List Available Codegen CLI Versions Source: https://github.com/codegen-sh/codegen/blob/develop/docs/self-update.md This command displays a list of all available stable versions of the Codegen CLI that can be installed. It helps in identifying specific versions for potential upgrades. ```bash # List available versions codegen update --list ``` -------------------------------- ### Enhance agent/main.py with Logging Source: https://github.com/codegen-sh/codegen/blob/develop/QUICK_START_LOGGING.md Add logging statements to track the start, success, and failure of agent creation operations. This snippet shows how to log operation details and errors using `logger.info` and `logger.error`. ```python from codegen.shared.logging.get_logger import get_logger logger = get_logger(__name__) def create(prompt: str, org_id: int | None = None, ...): """Create a new agent run with the given prompt.""" # ADD: Log start logger.info("Agent creation started", extra={ "operation": "agent.create", "org_id": org_id, "prompt_length": len(prompt) }) # Your existing code... try: response = requests.post(url, headers=headers, json=payload) agent_run_data = response.json() # ADD: Log success logger.info("Agent created successfully", extra={ "operation": "agent.create", "agent_run_id": agent_run_data.get("id"), "status": agent_run_data.get("status") }) except requests.RequestException as e: # ADD: Log error logger.error("Agent creation failed", extra={ "operation": "agent.create", "error_type": "api_error", "error": str(e) }) # Your existing error handling... ``` -------------------------------- ### Initialize and Run Agent with Python SDK Source: https://github.com/codegen-sh/codegen/blob/develop/docs/introduction/sdk.mdx Initialize the Agent with your organization ID and API token. Then, run an agent with a prompt and check its status and result. ```python from codegen import Agent # Initialize the Agent with your organization ID and API token agent = Agent(org_id="...", token="...") # Run an agent with a prompt task = agent.run(prompt="Leave a review on PR #123") # Check the initial status print(task.status) # Refresh the task to get updated status (tasks can take time) task.refresh() if task.status == "completed": print(task.result) # Result often contains code, summaries, or links ``` -------------------------------- ### Initialize CodegenSession Source: https://github.com/codegen-sh/codegen/blob/develop/src/codegen/cli/auth/session.ipynb Create a session with the current directory as the repository path. Inspects session properties like repo_path, config, and existing session status. ```python from pathlib import Path from codegen.cli.auth.session import CodegenSession # Create a session with the current directory as repo_path session = CodegenSession(repo_path=Path(".")) print(f"Session: {session}") print(f"Repo path: {session.repo_path}") print(f"Config: {session.config}") print(f"Existing session: {session.existing}") ``` -------------------------------- ### Load .env.prod for ENV=prod Source: https://github.com/codegen-sh/codegen/blob/develop/src/codegen/cli/env/global_env.ipynb Sets the ENV environment variable to 'prod' and then initializes GlobalEnv, printing the ALGOLIA_SEARCH_KEY. This assumes .env.prod exists and contains the key. ```python # test: ENV=prod loads .env.prod import os os.environ["ENV"] = "prod" from codegen.cli.env.global_env import GlobalEnv global_env = GlobalEnv() print(global_env.ALGOLIA_SEARCH_KEY) ``` -------------------------------- ### Initialize and Run Agent Source: https://github.com/codegen-sh/codegen/blob/develop/README.md Initialize the Agent with your organization ID and API token, then run a task with a prompt. Refresh the task to check its status and access the result upon completion. ```python from codegen.agents.agent import Agent # Initialize the Agent with your organization ID and API token agent = Agent( org_id="YOUR_ORG_ID", # Find this at codegen.com/token token="YOUR_API_TOKEN", # Get this from codegen.com/token # base_url="https://codegen-sh-rest-api.modal.run", # Optional - defaults to production ) # Run an agent with a prompt task = agent.run(prompt="Implement a new feature to sort users by last login.") # Check the initial status print(task.status) # Refresh the task to get updated status (tasks can take time) task.refresh() # Check the updated status print(task.status) # Once task is complete, you can access the result if task.status == "completed": print(task.result) # Result often contains code, summaries, or links ``` -------------------------------- ### Initialize and Run Agent Source: https://github.com/codegen-sh/codegen/blob/develop/src/codegen/agents/README.md Initialize the Agent with organization ID and API token, then run a task with a prompt. Check and refresh task status, and access the result upon completion. ```python from codegen.agents.agent import Agent # Initialize the Agent with your organization ID and API token agent = Agent( org_id="11", # Your organization ID token="your_api_token_here", # Your API authentication token base_url="https://codegen-sh-rest-api.modal.run", # Optional - defaults to this URL ) # Run an agent with a prompt task = agent.run(prompt="Which github repos can you currently access?") # Check the initial status print(task.status) # Returns the current status of the task (e.g., "queued", "in_progress", etc.) # Refresh the task to get updated status task.refresh() # Check the updated status print(task.status) # Once task is complete, you can access the result if task.status == "completed": print(task.result) ``` -------------------------------- ### Update Development Installation Source: https://github.com/codegen-sh/codegen/blob/develop/docs/self-update.md For development installs, update Codegen by pulling the latest changes from the main branch and reinstalling in editable mode. ```bash git pull origin main pip install -e . ``` -------------------------------- ### Create an Agent Run Source: https://github.com/codegen-sh/codegen/blob/develop/docs/api-reference/overview.mdx Initiates an agent run with a specific prompt and repository ID. Ensure you replace placeholders with your actual API key, organization ID, and repository ID. ```bash curl -X POST "https://api.codegen.com/v1/organizations/{org_id}/agent/run" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "prompt": "Add error handling to the user authentication function", "repo_id": 123 }' ``` -------------------------------- ### Agent Class Initialization Source: https://github.com/codegen-sh/codegen/blob/develop/src/codegen/agents/README.md Instantiate the Agent class with required token and optional organization ID and base URL. ```python Agent(token: str, org_id: Optional[int] = None, base_url: Optional[str] = CODEGEN_BASE_API_URL) ``` -------------------------------- ### Update Codegen CLI to a Specific Version Source: https://github.com/codegen-sh/codegen/blob/develop/docs/self-update.md Install a particular version of the Codegen CLI by specifying the version number. This is useful for rolling back or installing a known stable release. ```bash # Update to specific version codegen update --version 1.2.3 ``` -------------------------------- ### Linear Issue Example Source: https://github.com/codegen-sh/codegen/blob/develop/docs/capabilities/interrupts.mdx Illustrates how a user can add comments to a Linear issue to interrupt and modify a Codegen task. This example shows the iterative process of implementing search functionality with added filters and sorting. ```text Linear Issue: "Implement search functionality" Codegen: Working on search functionality... [User adds comment]: "Please include filters for date and category" Codegen: I see you've added filter requirements - implementing date and category filters now! [User adds comment]: "Also add sorting options" Codegen: Adding sorting options to the search as well! 📊 ``` -------------------------------- ### Authenticate with Python SDK Source: https://github.com/codegen-sh/codegen/blob/develop/docs/api-reference/authentication.mdx Initialize the Python SDK with your organization ID and API token for automatic authentication. ```python from codegen import Agent # Initialize with your credentials agent = Agent(org_id="YOUR_ORG_ID", token="YOUR_API_TOKEN") # The SDK handles authentication automatically task = agent.run(prompt="Fix the bug in user authentication") ``` -------------------------------- ### Update Codegen CLI Source: https://github.com/codegen-sh/codegen/blob/develop/README.md Manage Codegen CLI versions. Update to the latest version, check for available updates, or specify a version for installation. ```bash # Update to the latest version codegen update # Check for available updates codegen update --check # Update to a specific version codegen update --version 1.2.3 ``` -------------------------------- ### New Version Notification Source: https://github.com/codegen-sh/codegen/blob/develop/docs/self-update.md This is an example of the notification displayed when a new version of the Codegen CLI is available. It prompts the user to run the update command. ```text â„šī¸ A new version of Codegen CLI is available: 1.2.3 Run 'codegen update' to upgrade ``` -------------------------------- ### Run Claude with Telemetry Source: https://github.com/codegen-sh/codegen/blob/develop/docs/capabilities/claude-code.mdx Execute Claude through the Codegen CLI to enable full telemetry and cloud logging for your session. Ensure Claude is installed locally. ```bash codegen claude "Help me refactor this authentication module" ``` -------------------------------- ### Validate RunCodemodOutput with Correct Data Source: https://github.com/codegen-sh/codegen/blob/develop/src/codegen/cli/utils/schema.ipynb Use `model_validate` to validate a dictionary against the `RunCodemodOutput` schema. This example shows successful validation with correct data types. ```python # with model that should validate from codegen.cli.api.schemas import RunCodemodOutput res = RunCodemodOutput.model_validate( { "success": True, "web_link": "https://chadcode.sh/codemod/13264/code/21435/run/28349/playground/diff", "logs": "", "observation": 'diff --git a/codegen-backend/app/utils/slack/interactive/handlers/BaseSlackActionHandler.py b/codegen-backend/app/utils/slack/interactive/handlers/BaseSlackActionHandler.py\nindex 2dce963196b418caad011d175fb3110e03a8fe73..77c430a5acfb1613ac42c5712cc2859f31d7d773 100644\n--- a/codegen-backend/app/utils/slack/interactive/handlers/BaseSlackActionHandler.py\n+++ b/codegen-backend/app/utils/slack/interactive/handlers/BaseSlackActionHandler.py\n@@ -1,12 +1,1 @@\n-from sqlalchemy.orm import Session\n-\n-\n-class BaseSlackInteractiveActionHandler:\n- db: Session\n-\n- def __init__(self, db: Session) -> None:\n- self.db = db\n-\n- # TODO: convert the message information into a shared schema\n- def process_action(self, action_payload: str, channel_id: str, thread_ts: str):\n- raise NotImplementedError(f"process_action not implemented for {self.__class__.__name__}!")\n+update\n\ No newline at end of file\n', }, ) print(res) ``` -------------------------------- ### Initialize and Analyze Codebase Source: https://github.com/codegen-sh/codegen/blob/develop/docs/introduction/how-it-works.mdx Initialize a Codebase object to perform static analysis on a project directory. Access pre-computed symbol dependencies and usages instantly. ```python # Initialize and analyze the codebase from codegen import Codebase codebase = Codebase("./") # Access pre-computed relationships function = codebase.get_symbol("process_data") print(f"Dependencies: {function.dependencies}") # Instant lookup print(f"Usages: {function.usages}") # No parsing needed ``` -------------------------------- ### Resolve permission errors during update Source: https://github.com/codegen-sh/codegen/blob/develop/docs/self-update.md For permission errors, consider using pip's user installation or pipx for upgrades. Avoid using sudo if possible. ```bash pip install --user --upgrade codegen ``` ```bash pipx upgrade codegen ``` -------------------------------- ### Check for Codegen CLI Updates Source: https://github.com/codegen-sh/codegen/blob/develop/docs/self-update.md Run this command to check if a new version of the Codegen CLI is available without initiating an installation. It will notify you if an update is found. ```bash # Check for available updates without installing codegen update --check ``` -------------------------------- ### Import and Initialize Logger Source: https://github.com/codegen-sh/codegen/blob/develop/QUICK_START_LOGGING.md Import the `get_logger` function and initialize the logger for the current module. This is the first step to enable structured logging. ```python from codegen.shared.logging.get_logger import get_logger logger = get_logger(__name__) ``` -------------------------------- ### Downgrade codegen to a specific version Source: https://github.com/codegen-sh/codegen/blob/develop/docs/self-update.md Use the update command with a specific version to revert to a previous release. Alternatively, use your package manager directly for manual installation. ```bash codegen update --version 1.2.2 ``` ```bash pip install codegen==1.2.2 ``` ```bash pipx install codegen==1.2.2 --force ``` ```bash uv tool install codegen==1.2.2 --upgrade ``` -------------------------------- ### Agent run() Method Source: https://github.com/codegen-sh/codegen/blob/develop/src/codegen/agents/README.md Execute an agent task using the run method with a prompt string. ```python run(prompt: str) -> AgentTask ``` -------------------------------- ### Agent Class Initialization Source: https://github.com/codegen-sh/codegen/blob/develop/src/codegen/agents/README.md Initializes the Agent client with your organization ID and API token. The base URL can also be optionally specified. ```APIDOC ## Agent Class ```python Agent(token: str, org_id: Optional[int] = None, base_url: Optional[str] = CODEGEN_BASE_API_URL) ``` ### Parameters - `token` (required): Your API authentication token - `org_id` (optional): Your organization ID. If not provided, defaults to environment variable `CODEGEN_ORG_ID` or "1" - `base_url` (optional): API base URL. Defaults to "https://codegen-sh-rest-api.modal.run" ``` -------------------------------- ### Navigate to Image Cache Settings Source: https://github.com/codegen-sh/codegen/blob/develop/docs/sandboxes/image-snapshots.mdx Access your repository's image cache settings page to manage snapshot configurations. ```bash https://codegen.com/repos/{repoName}/image-cache ```