Metadata-Version: 2.4
Name: agentctx
Version: 0.4.0
Summary: kubectx-like CLI for switching Codex auth profiles
License: MIT
License-File: LICENSE
Keywords: codex,cli,profiles,kubectx
Author: Nikolay Baryshnikov
Author-email: root@k0d.ru
Requires-Python: >=3.8,<4.0
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Natural Language :: Russian
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Project-URL: Homepage, https://github.com/18studio/agentctx
Project-URL: Repository, https://github.com/18studio/agentctx
Description-Content-Type: text/markdown

# agentctx

`agentctx` is a kubectx-like CLI for saving and switching local Codex auth profiles.

It manages copies of `~/.codex/auth.json` under `~/.agentctx` and atomically swaps the active auth file when you switch profiles. When saving the current auth via `=.`, the profile name is derived from the user's email claim in the JWT. Token contents are never printed.

## Install

```bash
pipx install agentctx
```

For local development:

```bash
poetry install
poetry run agentctx --help
```

## Usage

```bash
agentctx                 # list profiles or open fzf selector when interactive
agentctx work            # switch to profile
agentctx -               # switch to previous profile
agentctx -c              # show current profile
agentctx =.              # save/rename current Codex auth as JWT email profile
agentctx user@example.com=. # same, but validate name matches JWT email
agentctx prod=work       # rename profile
agentctx -d old-profile  # delete profile
agentctx -u              # unset current marker
agentctx -V              # show version
```

Long aliases:

```bash
agentctx --current
agentctx --unset
agentctx --version
```

CRUD-style subcommands are intentionally not part of the public CLI.

## Storage

```text
~/.agentctx/
  profiles/
    <email-or-name>/
      auth.json
      metadata.json
  backups/
    auth-<timestamp>.json
  current
  previous
  lock
```

Active Codex auth remains:

```text
~/.codex/auth.json
```

## Security behavior

- validates JSON before saving or switching;
- rejects symlinks and non-regular auth files;
- writes auth files atomically with temporary files in the target directory;
- uses `0600` permissions for active, profile, and backup auth files where supported;
- creates backups before switching profiles;
- never prints token contents.

## Development

```bash
poetry check
poetry run pytest
poetry build
```

## Publish

```bash
make publish
```

`make publish` bumps the minor version, syncs `agentctx.__version__`, runs checks/tests, builds a clean `dist/`, and publishes with `poetry publish`.

