From 1e0b9afdebc36862f6fa4aaae1213db2915d40c5 Mon Sep 17 00:00:00 2001 From: "codegen-sh[bot]" <131295404+codegen-sh[bot]@users.noreply.github.com> Date: Tue, 19 Aug 2025 20:16:25 +0000 Subject: [PATCH 1/4] Add CLI documentation to the Overview section Co-authored-by: Rushil Patel --- docs/docs.json | 1 + docs/introduction/cli.mdx | 164 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 165 insertions(+) create mode 100644 docs/introduction/cli.mdx diff --git a/docs/docs.json b/docs/docs.json index 47845451f..4c496eda1 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -18,6 +18,7 @@ "pages": [ "introduction/overview", "introduction/api", + "introduction/cli", "introduction/prompting", "introduction/community", "introduction/about", diff --git a/docs/introduction/cli.mdx b/docs/introduction/cli.mdx new file mode 100644 index 000000000..995a22411 --- /dev/null +++ b/docs/introduction/cli.mdx @@ -0,0 +1,164 @@ +--- +title: "Codegen CLI" +sidebarTitle: "CLI" +icon: "terminal" +iconType: "solid" +--- + +The Codegen CLI provides a command-line interface for interacting with [Codegen](https://codegen.com) SWE agents directly from your terminal. + + + Go to [developer settings](https://codegen.sh/token) to generate an API token for CLI authentication + + +## Installation + +Install the Codegen CLI using pip or uv: + +```bash +pip install codegen +# or +uv pip install codegen +``` + +## Authentication + +Before using the CLI, you need to authenticate with your Codegen API token: + +```bash +# Login with your API token +codegen login --token YOUR_API_TOKEN + +# Alternatively, you can set the CODEGEN_API_TOKEN environment variable +export CODEGEN_API_TOKEN=YOUR_API_TOKEN +``` + +## Basic Usage + +Once authenticated, you can use the CLI to interact with Codegen: + +```bash +# Get CLI help +codegen --help + +# View version information +codegen --version + +# Launch the interactive TUI interface +codegen +# or +codegen tui +``` + +## Available Commands + +The Codegen CLI offers several commands for different functionalities: + +| Command | Description | +| ------- | ----------- | +| `agent` | Create a new agent run with a prompt | +| `agents` | Manage and interact with your agents | +| `claude` | Run Claude Code with OpenTelemetry monitoring and logging | +| `config` | Manage configuration settings | +| `init` | Initialize or update the Codegen folder | +| `integrations` | Manage integrations with external services | +| `login` | Store authentication token | +| `logout` | Clear stored authentication token | +| `org` | Manage and switch between organizations | +| `profile` | Manage your Codegen profile | +| `repo` | Manage repository configuration and environment variables | +| `tools` | List available tools from the Codegen API | +| `tui` | Launch the interactive TUI interface | +| `update` | Update Codegen to the latest or specified version | + +## Common Workflows + +### Creating an Agent Run + +To create a new agent run with a prompt: + +```bash +codegen agent "Implement a function to calculate Fibonacci numbers in Python" +``` + +### Managing Organizations + +To list and switch between organizations: + +```bash +# List available organizations +codegen org list + +# Switch to a specific organization +codegen org switch ORG_ID +``` + +### Managing Repositories + +To configure repositories: + +```bash +# List repositories +codegen repo list + +# Configure a repository +codegen repo config REPO_NAME +``` + +### Using the TUI (Terminal User Interface) + +The Codegen CLI includes a rich terminal user interface for interactive use: + +```bash +codegen tui +``` + +This launches an interactive interface where you can: +- Create and manage agent runs +- View agent run status and results +- Configure settings +- Manage organizations and repositories + +## Environment Variables + +The CLI respects the following environment variables: + +| Variable | Description | +| -------- | ----------- | +| `CODEGEN_API_TOKEN` | Your Codegen API token for authentication | +| `CODEGEN_API_URL` | Custom API URL (if using a self-hosted instance) | +| `CODEGEN_ORG_ID` | Default organization ID | + +## What can I do with the Codegen CLI? + +The Codegen CLI is your terminal gateway to interacting with your AI Software Engineer. You can use it to: + +- **Run agents from your terminal**: Create agent runs with custom prompts directly from your command line +- **Manage your Codegen resources**: Configure organizations, repositories, and integrations +- **Integrate into scripts and workflows**: Incorporate Codegen capabilities into your shell scripts and automation workflows +- **Interactive TUI experience**: Use the rich terminal interface for a more visual interaction with Codegen + +Essentially, the CLI allows you to leverage Codegen's AI capabilities directly from your terminal or in automated scripts. + +## Get Started + +import { + COMMUNITY_SLACK_URL, + CODEGEN_SDK_GITHUB_URL, +} from "/snippets/links.mdx"; + + + + Sign up for a free account and get your API token. + + + Get help and connect with the Codegen community. + + + Learn how to use Codegen for common code transformation tasks. + + + Star us on GitHub and contribute to the project. + + + From 958502eaf96088d9519db390afbcb16cdfa2c467 Mon Sep 17 00:00:00 2001 From: "codegen-sh[bot]" <131295404+codegen-sh[bot]@users.noreply.github.com> Date: Tue, 19 Aug 2025 20:36:49 +0000 Subject: [PATCH 2/4] Update CLI documentation with additional details from Notion Co-authored-by: Rushil Patel --- docs/introduction/cli.mdx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/introduction/cli.mdx b/docs/introduction/cli.mdx index 995a22411..f308c4d9c 100644 --- a/docs/introduction/cli.mdx +++ b/docs/introduction/cli.mdx @@ -19,6 +19,8 @@ Install the Codegen CLI using pip or uv: pip install codegen # or uv pip install codegen +# or +uv tool install codegen ``` ## Authentication @@ -56,7 +58,7 @@ The Codegen CLI offers several commands for different functionalities: | Command | Description | | ------- | ----------- | -| `agent` | Create a new agent run with a prompt | +| `agent` | Create a new agent run with a prompt, fetch an existing agent run by ID, or pull PR branch | | `agents` | Manage and interact with your agents | | `claude` | Run Claude Code with OpenTelemetry monitoring and logging | | `config` | Manage configuration settings | @@ -78,7 +80,17 @@ The Codegen CLI offers several commands for different functionalities: To create a new agent run with a prompt: ```bash -codegen agent "Implement a function to calculate Fibonacci numbers in Python" +codegen agent --prompt "Implement a function to calculate Fibonacci numbers in Python" +``` + +You can also fetch an existing agent run by ID or pull a PR branch: + +```bash +# Get run details in JSON format +codegen agent --id 123 --json + +# Pull PR branch from an agent run +codegen agent --id 123 pull ``` ### Managing Organizations @@ -128,6 +140,7 @@ The CLI respects the following environment variables: | `CODEGEN_API_TOKEN` | Your Codegen API token for authentication | | `CODEGEN_API_URL` | Custom API URL (if using a self-hosted instance) | | `CODEGEN_ORG_ID` | Default organization ID | +| `REPOSITORY_ORG_ID` | Organization ID for repository-specific operations | ## What can I do with the Codegen CLI? @@ -161,4 +174,3 @@ import { Star us on GitHub and contribute to the project. - From 86815159b4162bd14855fdd41743f8b724f82eb0 Mon Sep 17 00:00:00 2001 From: "codegen-sh[bot]" <131295404+codegen-sh[bot]@users.noreply.github.com> Date: Tue, 19 Aug 2025 20:44:52 +0000 Subject: [PATCH 3/4] Update CLI documentation to closely match Notion document format Co-authored-by: Rushil Patel --- docs/introduction/cli.mdx | 197 +++++++++++++++++++------------------- 1 file changed, 99 insertions(+), 98 deletions(-) diff --git a/docs/introduction/cli.mdx b/docs/introduction/cli.mdx index f308c4d9c..d7562ee3c 100644 --- a/docs/introduction/cli.mdx +++ b/docs/introduction/cli.mdx @@ -5,131 +5,142 @@ icon: "terminal" iconType: "solid" --- -The Codegen CLI provides a command-line interface for interacting with [Codegen](https://codegen.com) SWE agents directly from your terminal. +# Codegen CLI Manual - - Go to [developer settings](https://codegen.sh/token) to generate an API token for CLI authentication - +Welcome to the Codegen CLI documentation. This guide covers all available commands and their usage patterns. ## Installation -Install the Codegen CLI using pip or uv: - ```bash -pip install codegen -# or -uv pip install codegen -# or uv tool install codegen ``` -## Authentication - -Before using the CLI, you need to authenticate with your Codegen API token: +## Initialization ```bash -# Login with your API token -codegen login --token YOUR_API_TOKEN - -# Alternatively, you can set the CODEGEN_API_TOKEN environment variable -export CODEGEN_API_TOKEN=YOUR_API_TOKEN +codegen login ``` -## Basic Usage +## CLI Reference -Once authenticated, you can use the CLI to interact with Codegen: +### `codegen` (root) -```bash -# Get CLI help -codegen --help +**Description:** Launches the interactive TUI if no subcommand is provided. -# View version information -codegen --version +--- -# Launch the interactive TUI interface -codegen -# or -codegen tui -``` +### `codegen agent` -## Available Commands +**Description:** Create a new agent run with a prompt, fetch an existing agent run by ID, or pull PR branch. -The Codegen CLI offers several commands for different functionalities: +**Usage Patterns:** +- **Create run:** `codegen agent --prompt "Your prompt"` +- **Get run JSON:** `codegen agent --id 123 --json` +- **Pull PR branch:** `codegen agent --id 123 pull` -| Command | Description | -| ------- | ----------- | -| `agent` | Create a new agent run with a prompt, fetch an existing agent run by ID, or pull PR branch | -| `agents` | Manage and interact with your agents | -| `claude` | Run Claude Code with OpenTelemetry monitoring and logging | -| `config` | Manage configuration settings | -| `init` | Initialize or update the Codegen folder | -| `integrations` | Manage integrations with external services | -| `login` | Store authentication token | -| `logout` | Clear stored authentication token | -| `org` | Manage and switch between organizations | -| `profile` | Manage your Codegen profile | -| `repo` | Manage repository configuration and environment variables | -| `tools` | List available tools from the Codegen API | -| `tui` | Launch the interactive TUI interface | -| `update` | Update Codegen to the latest or specified version | +**Options:** +- `--prompt, -p TEXT` The prompt to send to the agent (mutually exclusive with --id unless using create) +- `--id INT` Agent run ID to fetch or pull +- `--json` Output raw JSON response when fetching (flag) +- `--org-id INT` Organization ID (defaults to CODEGEN_API_TOKEN/REPOSITORY_ORG_ID or auto-detect) +- `--model TEXT` Model to use for this agent run (optional) +- `--repo-id INT` Repository ID to use for this agent run (optional) -## Common Workflows +**Positional Actions:** +- `pull` Pull the PR branch associated with an agent run (requires --id) -### Creating an Agent Run +--- -To create a new agent run with a prompt: +### `codegen agents` -```bash -codegen agent --prompt "Implement a function to calculate Fibonacci numbers in Python" -``` +**Description:** List and manage agent runs. -You can also fetch an existing agent run by ID or pull a PR branch: +**Usage Patterns:** +- **List runs:** `codegen agents list` +- **Get run details:** `codegen agents get 123` -```bash -# Get run details in JSON format -codegen agent --id 123 --json +**Options:** +- `--org-id INT` Organization ID (defaults to CODEGEN_ORG_ID/REPOSITORY_ORG_ID or auto-detect) +- `--limit INT` Maximum number of runs to return (default: 10) +- `--json` Output raw JSON response (flag) -# Pull PR branch from an agent run -codegen agent --id 123 pull -``` +--- -### Managing Organizations +### `codegen login` -To list and switch between organizations: +**Description:** Store authentication token. -```bash -# List available organizations -codegen org list +**Usage Patterns:** +- **Interactive login:** `codegen login` +- **Token login:** `codegen login --token YOUR_API_TOKEN` -# Switch to a specific organization -codegen org switch ORG_ID -``` +**Options:** +- `--token TEXT` API token to store +- `--no-verify` Skip token verification (flag) -### Managing Repositories +--- -To configure repositories: +### `codegen logout` -```bash -# List repositories -codegen repo list +**Description:** Clear stored authentication token. -# Configure a repository -codegen repo config REPO_NAME -``` +**Usage Pattern:** +- `codegen logout` -### Using the TUI (Terminal User Interface) +--- -The Codegen CLI includes a rich terminal user interface for interactive use: +### `codegen org` -```bash -codegen tui -``` +**Description:** Manage and switch between organizations. + +**Usage Patterns:** +- **List organizations:** `codegen org list` +- **Switch organization:** `codegen org switch ORG_ID` +- **Get current organization:** `codegen org current` -This launches an interactive interface where you can: -- Create and manage agent runs -- View agent run status and results -- Configure settings -- Manage organizations and repositories +**Options:** +- `--json` Output raw JSON response (flag) + +--- + +### `codegen repo` + +**Description:** Manage repository configuration and environment variables. + +**Usage Patterns:** +- **List repositories:** `codegen repo list` +- **Configure repository:** `codegen repo config REPO_NAME` +- **Get repository details:** `codegen repo get REPO_ID` + +**Options:** +- `--org-id INT` Organization ID (defaults to CODEGEN_ORG_ID or auto-detect) +- `--json` Output raw JSON response (flag) + +--- + +### `codegen tui` + +**Description:** Launch the interactive TUI interface. + +**Usage Pattern:** +- `codegen tui` + +--- + +### `codegen update` + +**Description:** Update Codegen to the latest or specified version. + +**Usage Patterns:** +- **Update to latest:** `codegen update` +- **Update to specific version:** `codegen update --version X.Y.Z` + +**Options:** +- `--version TEXT` Specific version to update to +- `--check` Only check for updates, don't install (flag) +- `--force` Force update even if already at latest version (flag) + +--- ## Environment Variables @@ -142,17 +153,6 @@ The CLI respects the following environment variables: | `CODEGEN_ORG_ID` | Default organization ID | | `REPOSITORY_ORG_ID` | Organization ID for repository-specific operations | -## What can I do with the Codegen CLI? - -The Codegen CLI is your terminal gateway to interacting with your AI Software Engineer. You can use it to: - -- **Run agents from your terminal**: Create agent runs with custom prompts directly from your command line -- **Manage your Codegen resources**: Configure organizations, repositories, and integrations -- **Integrate into scripts and workflows**: Incorporate Codegen capabilities into your shell scripts and automation workflows -- **Interactive TUI experience**: Use the rich terminal interface for a more visual interaction with Codegen - -Essentially, the CLI allows you to leverage Codegen's AI capabilities directly from your terminal or in automated scripts. - ## Get Started import { @@ -174,3 +174,4 @@ import { Star us on GitHub and contribute to the project. + From 9f6df926df6872cee143dc4944fafda581e9dca6 Mon Sep 17 00:00:00 2001 From: "codegen-sh[bot]" <131295404+codegen-sh[bot]@users.noreply.github.com> Date: Tue, 19 Aug 2025 21:33:57 +0000 Subject: [PATCH 4/4] Remove tui, update commands and environment variables section Co-authored-by: Rushil Patel --- docs/introduction/cli.mdx | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/docs/introduction/cli.mdx b/docs/introduction/cli.mdx index d7562ee3c..92f19109a 100644 --- a/docs/introduction/cli.mdx +++ b/docs/introduction/cli.mdx @@ -118,41 +118,6 @@ codegen login --- -### `codegen tui` - -**Description:** Launch the interactive TUI interface. - -**Usage Pattern:** -- `codegen tui` - ---- - -### `codegen update` - -**Description:** Update Codegen to the latest or specified version. - -**Usage Patterns:** -- **Update to latest:** `codegen update` -- **Update to specific version:** `codegen update --version X.Y.Z` - -**Options:** -- `--version TEXT` Specific version to update to -- `--check` Only check for updates, don't install (flag) -- `--force` Force update even if already at latest version (flag) - ---- - -## Environment Variables - -The CLI respects the following environment variables: - -| Variable | Description | -| -------- | ----------- | -| `CODEGEN_API_TOKEN` | Your Codegen API token for authentication | -| `CODEGEN_API_URL` | Custom API URL (if using a self-hosted instance) | -| `CODEGEN_ORG_ID` | Default organization ID | -| `REPOSITORY_ORG_ID` | Organization ID for repository-specific operations | - ## Get Started import { @@ -174,4 +139,3 @@ import { Star us on GitHub and contribute to the project. -