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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,33 @@ if task.status == "completed":

## Installation and Usage

Install the SDK using pip or uv:
Install the SDK using pip, pipx, or uv:

```bash
pip install codegen
# or
uv pip install codegen
pipx install codegen
# or
uv tool install codegen
```

### Keeping Up to Date

The Codegen CLI includes a built-in self-update system:

```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
```

The CLI automatically checks for updates daily and notifies you when a new version is available.

Get started at [codegen.com](https://codegen.com) and get your API token at [codegen.com/token](https://codegen.com/token).

You can interact with your AI engineer via API, or chat with it in Slack, Linear, Github, or on our website.
Expand Down
19 changes: 19 additions & 0 deletions docs/introduction/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,32 @@ codegen login
codegen login --token YOUR_API_TOKEN
```

### `codegen update`

Keep your CLI up to date with the latest features and improvements. The CLI automatically checks for updates daily and notifies you when new versions are available.

```bash
# Update to latest version
codegen update

# Check for updates without installing
codegen update --check

# Update to a specific version
codegen update --version 1.2.3

# Preview changes without updating
codegen update --dry-run
```

## What You Can Do

- **View and manage agents** - List agent runs, check status, and see detailed execution logs
- **Pull agent work** - Download branches and code changes created by agents directly to your local environment
- **Create new agents** - Trigger agent runs from the command line with custom prompts
- **Run Claude Code** - Execute Claude Code with OpenTelemetry monitoring and comprehensive logging
- **Manage organizations** - Switch between organizations and configure repositories
- **Stay up to date** - Built-in self-update system with automatic update notifications

<Note>
The CLI provides the same capabilities as the web UI and API, optimized for
Expand Down
23 changes: 22 additions & 1 deletion docs/introduction/sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,31 @@ if task.status == "completed":

## Installation

Install the [codegen](https://pypi.org/project/codegen/) package from PyPI:
Install the [codegen](https://pypi.org/project/codegen/) package from PyPI using your preferred package manager:

```bash
# Using pip
pip install codegen

# Using pipx (for CLI usage)
pipx install codegen

# Using uv
uv pip install codegen
# or
uv tool install codegen
```

### Keeping Up to Date

The CLI includes a built-in self-update system that checks for updates daily:

```bash
# Update to latest version
codegen update

# Check for updates
codegen update --check
```

## Get Started
Expand Down
293 changes: 293 additions & 0 deletions docs/self-update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,293 @@
# Self-Update System for Codegen CLI

The Codegen CLI includes a simplified self-update system that allows users to easily update to the latest version.

## Features

### 🚀 Smart Update Detection
- Automatically detects installation method (pip, pipx, uv tool, homebrew, development)
- Checks for updates periodically (once per day by default)
- Shows update notifications when new versions are available
- Fetches stable releases from PyPI

### 🔄 Update Management
- Update to latest stable version
- Update to specific versions
- Dry-run mode to preview changes
- Legacy mode for simple pip upgrades

### 🛡️ Safety Features
- Pre-update validation checks
- Major version update warnings
- Post-update tips and guidance

### 📊 Version Information
- List available versions
- Check for updates without installing
- View current and latest versions

## Usage

### Basic Commands

```bash
# Update to latest stable version
codegen update

# Check for available updates without installing
codegen update --check

# List available versions
codegen update --list

# Show version history
codegen update --history
```

### Advanced Options

```bash
# Update to specific version
codegen update --version 1.2.3

# Preview update without making changes
codegen update --dry-run

# Force update check (bypass cache)
codegen update --force

# Use legacy pip upgrade method
codegen update --legacy
```

## Release Information

The update system fetches stable releases from PyPI. Pre-release versions are automatically filtered out to ensure stability. Only production-ready versions are shown and available for installation through the update command.

## Installation Methods

The update system automatically detects how Codegen was installed and uses the appropriate update method:

### pip Installation
```bash
pip install codegen
# Updates via: pip install --upgrade codegen
```

### pipx Installation
```bash
pipx install codegen
# Updates via: pipx upgrade codegen
```

### UV Tool Installation
```bash
uv tool install codegen
# Updates via: uv tool install --upgrade codegen
```

### Homebrew Installation (macOS)
```bash
brew install codegen
# Updates via: brew upgrade codegen
```

### Development Installation
For development/editable installs, the update system will notify you to update via git:
```bash
git pull origin main
pip install -e .
```

## Update Process

The update system performs a streamlined update process:

### How Updates Work

1. **Version Check**: Fetches available versions from PyPI
2. **Comparison**: Compares current version with available versions
3. **Confirmation**: Asks for user confirmation before proceeding
4. **Installation**: Uses the appropriate package manager to update
5. **Verification**: Displays success message and restart instructions

### Major Version Updates

When updating to a new major version:
- The system warns about potential breaking changes
- Post-update tips are displayed
- Users are encouraged to check the changelog

## Update Notifications

The CLI checks for updates periodically and shows notifications when new versions are available:

```
ℹ️ A new version of Codegen CLI is available: 1.2.3
Run 'codegen update' to upgrade
```

### Disable Update Checks

To disable automatic update checks, set the environment variable:

```bash
export CODEGEN_DISABLE_UPDATE_CHECK=1
```

## Downgrading

If an update causes issues, you can downgrade to a previous version:

```bash
# Downgrade to a specific version
codegen update --version 1.2.2

# Or use your package manager directly
pip install codegen==1.2.2
pipx install codegen==1.2.2 --force
uv tool install codegen==1.2.2 --upgrade
```

## Configuration

Update settings are stored in `~/.codegen/`:

- `update_check.json` - Last update check timestamp and cache

## Troubleshooting

### Update Fails

1. Try using the legacy update method:
```bash
codegen update --legacy
```

2. Manually update via pip:
```bash
pip install --upgrade codegen
```

3. Check installation method:
```bash
which codegen
pip show codegen
```

### Permission Errors

If you get permission errors, you may need to use sudo (not recommended) or update your user installation:

```bash
# For user installation
pip install --user --upgrade codegen

# For pipx
pipx upgrade codegen
```

### Downgrade Issues

If you need to downgrade:

1. Use the update command with a specific version:
```bash
codegen update --version 1.2.2
```

2. Or manually install the desired version:
```bash
pip install codegen==1.2.2
pipx install codegen==1.2.2 --force
uv tool install codegen==1.2.2 --upgrade
```

## Development

### Testing Updates

Test the update system in development:

```bash
# Check current version
codegen --version

# Test update check
codegen update --check --force

# Test dry-run update
codegen update --dry-run

# Test specific version
codegen update --version 1.2.3 --dry-run
```

### Adding New Features

To add new update features:

1. Modify `updater.py` for core functionality
2. Update command options in `main.py`
3. Add tests for new functionality

## API Reference

### UpdateManager Class

```python
from codegen.cli.commands.update import UpdateManager

manager = UpdateManager()

# Check for updates
result = manager.check_for_updates(force=True)

# Perform update
success = manager.perform_update(target_version="1.2.3", dry_run=False)

# Check installation method
print(manager.install_method)
```

### Installation Methods

```python
from codegen.cli.commands.update.updater import InstallMethod

methods = [
InstallMethod.PIP,
InstallMethod.PIPX,
InstallMethod.UV_TOOL,
InstallMethod.HOMEBREW,
InstallMethod.DEVELOPMENT,
InstallMethod.UNKNOWN
]
```

## Best Practices

1. **Regular Updates**: Keep your CLI updated for latest features and security fixes
2. **Check Changelog**: Review breaking changes before major version updates
3. **Test in Dev**: Test updates in development environment first
4. **Use Dry Run**: Preview updates with `--dry-run` before applying
5. **Report Issues**: Report update issues to help improve the system

## Security

- Updates are fetched over HTTPS from PyPI
- Package signatures are verified by pip/pipx/uv
- Pre-release versions are filtered out automatically
- Major version updates require confirmation

## Future Enhancements

- [ ] Automatic rollback on update failure
- [ ] Configuration migration system
- [ ] Release notes integration
- [ ] Beta and nightly release channels
- [ ] Binary distribution for faster updates
- [ ] Automatic security update installation
- [ ] Update progress with detailed logging
- [ ] Network proxy support
- [ ] Offline update packages
Loading
Loading