| Crates.io | amg |
| lib.rs | amg |
| version | 0.1.0 |
| created_at | 2025-12-31 19:04:56.088171+00 |
| updated_at | 2025-12-31 19:04:56.088171+00 |
| description | Resume Codex sessions by git branch |
| homepage | |
| repository | https://github.com/Cardosaum/amg |
| max_upload_size | |
| id | 2015147 |
| size | 168,316 |
A command-line tool to manage and resume Codex sessions by git branch name.
amg helps you quickly resume Codex sessions by matching them to git branch names. It searches through Codex session files (JSONL format) and finds the first session that matches your current or specified git branch, then resumes it with the appropriate configuration.
Install pre-built binaries without compiling from source:
# Install cargo-binstall first (one-time setup)
cargo install cargo-binstall
# Install amg
cargo binstall amg
This method downloads pre-built binaries from GitHub Releases, making installation much faster than compiling from source. Binaries are available for:
git clone https://github.com/Cardosaum/amg.git
cd amg
make install
This installs the binary to $HOME/.cargo/bin (default Cargo installation directory). Ensure $HOME/.cargo/bin is in your PATH (typically done automatically by rustup).
For a custom installation directory:
make install-custom ROOT=$HOME/.local
git clone https://github.com/Cardosaum/amg.git
cd amg
cargo install --path .
git clone https://github.com/Cardosaum/amg.git
cd amg
cargo build --release
The binary will be available at target/release/amg.
Resume a Codex session for a specific branch:
amg resume-branch <branch-name> --repo /path/to/repo
Or use the shorter aliases:
amg rb <branch-name> --repo /path/to/repo
amg resume <branch-name> --repo /path/to/repo
You can set environment variables to avoid passing flags every time:
export CODEX_REPO=/path/to/your/repo
export CODEX_CODEXDIR=/path/to/.codex # Optional, defaults to $HOME/.codex
Then simply run:
amg resume-branch main
--repo <REPO>: Repository path to grant Codex sandbox access to (required, or set CODEX_REPO)--codexdir <DIR>: Codex directory containing JSONL sessions (optional, defaults to $HOME/.codex, or set CODEX_CODEXDIR)-n, --dry-run: Print the command that would be executed without running it--no-tmux: Disable automatic tmux window creation (if $TMUX is set)# Resume session for 'main' branch
amg resume-branch main --repo ~/projects/my-repo
# Dry run to see what command would be executed
amg rb feature-branch --repo ~/projects/my-repo --dry-run
# Resume without tmux (run inline)
amg resume dev --repo ~/projects/my-repo --no-tmux
# Use environment variables
export CODEX_REPO=~/projects/my-repo
amg rb main
$HOME/.codex) for JSONL session files.payload.git.branch equals your specified branch namecargo build
# Using cargo test
cargo test
# Using nextest (faster, parallel)
cargo nextest run
# Or use the Makefile
make test-nextest
The project uses strict linting and formatting:
# Run all CI checks
make ci
# Format code
make fmt
# Run clippy
make lint
# Check formatting
make fmt-check
src/
├── bin/
│ └── amg.rs # Binary entry point
├── cli/
│ ├── mod.rs # Main CLI logic
│ ├── args.rs # CLI argument parsing
│ ├── codex_cmd.rs # Codex command building
│ ├── scan.rs # Session scanning
│ ├── process.rs # Process execution
│ ├── util.rs # Utility functions
│ ├── constants.rs # Constants
│ ├── logging.rs # Logging setup
│ └── prelude.rs # Common imports
└── lib.rs # Library root
This project uses release-plz for automated releases. The release process is fully automated through GitHub Actions.
Release PR Creation: When commits are pushed to main, release-plz automatically creates or updates a release Pull Request with:
Cargo.toml (based on Conventional Commits)CHANGELOG.md (generated from git history)Cargo.lock (if dependencies changed)Release PR Review: Maintainers review the release PR to ensure:
Publishing: When the release PR is merged, release-plz automatically:
amg-v<version>, e.g., amg-v0.1.0)Versions follow Semantic Versioning and are determined by commit types:
1.0.0 → 2.0.0): Breaking changes (detected by cargo-semver-checks or commits with BREAKING CHANGE:)1.0.0 → 1.1.0): New features (feat: commits)1.0.0 → 1.0.1): Bug fixes (fix: commits)Important: All commits must follow the Conventional Commits specification for automatic versioning to work correctly.
Commit format: type(scope): description
feat(cli): add new command → minor version bumpfix(scan): resolve session matching bug → patch version bumprefactor(util): improve error handling → no version bump (unless breaking)docs: update README → no version bumpchore(deps): update dependencies → no version bumpSee .cursor/rules/commits/RULE.md for detailed commit guidelines.
If you need to trigger a release manually or test locally:
# Install release-plz
cargo install --locked release-plz
# Update versions and changelog (creates release PR locally)
release-plz release-pr
# Publish to crates.io (after merging release PR)
release-plz release
For local development, you can use Bitwarden CLI to securely manage tokens required by release-plz.
Note: This repository intentionally does not integrate Bitwarden into GitHub Actions. CI releases use GitHub-native auth (the workflow
GITHUB_TOKENplus token-based authentication for crates.io publishing).
# One-time setup
make setup-bitwarden
# Run release-pr with tokens from Bitwarden
make release-pr-bw
# Run release with tokens from Bitwarden
make release-bw
Install Bitwarden CLI:
brew install bitwarden-cli # macOS
# See docs/BITWARDEN_SETUP.md for other platforms
Run setup script:
make setup-bitwarden
Create vault items in Bitwarden:
amg-release-github-token: Store your GitHub Personal Access Tokenamg-release-cargo-token (optional): Store your crates.io tokenRecommended Workflow:
Unlock Bitwarden and export session (do this once per terminal session):
export BW_SESSION=$(bw unlock --raw)
Run release commands:
make release-pr-bw # Run release-pr with Bitwarden tokens
make release-bw # Run release with Bitwarden tokens
Alternative: Interactive Unlock
If you haven't exported BW_SESSION, the script will prompt for your password:
make release-pr-bw # Will prompt for Bitwarden master password
Using scripts directly:
./scripts/release-with-bitwarden.sh release-pr
./scripts/release-with-bitwarden.sh release
Customizing vault item names:
export BW_GITHUB_TOKEN_ITEM=your-github-token-item
export BW_CARGO_TOKEN_ITEM=your-cargo-token-item
make release-pr-bw
For Automation / Non-Interactive (Discouraged):
Avoid BW_PASSWORD (it puts your Bitwarden master password in an environment variable). Prefer unlocking once interactively and exporting BW_SESSION:
export BW_SESSION=$(bw unlock --raw)
make release-pr-bw
If you must automate login, use API keys:
export BW_CLIENTID=your_client_id
export BW_CLIENTSECRET=your_client_secret
bw login --apikey
export BW_SESSION=$(bw unlock --raw)
make release-pr-bw
For detailed setup instructions and troubleshooting, see docs/BITWARDEN_SETUP.md.
Contributions are welcome! Please ensure:
make cimake fmtmake lintUse the format: type(scope): description
Types:
feat: New feature (causes minor version bump)fix: Bug fix (causes patch version bump)refactor: Code refactoring (no version bump unless breaking)test: Adding or updating tests (no version bump)docs: Documentation changes (no version bump)style: Code style changes (no version bump)chore: Maintenance tasks (no version bump)Examples:
feat(cli): add shorthand flag for repo argumentfix(scan): resolve session matching bugdocs: update installation instructionsSee .cursor/rules/commits/RULE.md for detailed guidelines.
Licensed under either of:
at your option.
Cardosaum