Metadata-Version: 2.4
Name: refactorai-cli
Version: 0.7.3
Summary: Local-first CLI for the refactor platform
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: typer>=0.12.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: rich>=13.7.0
Requires-Dist: PyYAML>=6.0.1
Requires-Dist: refactorai-core>=3.2.15

# refactorai-cli

Public CLI package for Refactor.

- PyPI package name: `refactorai-cli`
- Installed command: `refactor`
- Python module package: `refactorai_cli`

By default, the CLI targets `https://api.refactorai.codes`.
Use `REFACTOR_PLATFORM_URL` only when you need to override the control-plane URL
(for self-hosted or local development environments).

## Local development install

From repository root:

```bash
pip install -e refactorai-core -e refactorai-cli
```

## Build

From repository root:

```bash
python -m pip install --upgrade build twine
python -m build "./refactorai-cli"
```

Artifacts are created in:

- `refactorai-cli/dist/*.whl`
- `refactorai-cli/dist/*.tar.gz`

## Publish

```bash
python -m twine check ./refactorai-cli/dist/*
python -m twine upload ./refactorai-cli/dist/*
```

## Install test (local)

```bash
python -m pip install ./refactorai-cli/dist/refactorai_cli-0.3.4-py3-none-any.whl
refactor --version
```

## Cloud BYOK setup (bring your own provider key)

Run cloud inference with your own provider credentials (no local runtime
required). Preferred path is env-key in project config (`provider_key:
${ENV_VAR}`). Platform-stored credentials (`credential_ref`) are optional
fallback.

```bash
# 1. Authenticate (developer key with the run:byok entitlement).
refactor login

# 2A. Preferred: set BYOK directly from project env in refactor.config:
#
# mode: cloud_byok
# provider: openai
# model_id: gpt-4.1-mini
# provider_key: ${OPENAI_API_KEY}
#
# 2B. Optional fallback: register a platform-stored credential from env.
export OPENAI_API_KEY=sk-...
refactor cloud credentials set --provider openai --from-env OPENAI_API_KEY --label "my key"
# -> prints a credential_ref, e.g. cred_01J...

# 3. If you use platform-stored fallback, set credential_ref in config:
#    credential_ref: cred_01J...

# 4. Verify readiness, then run.
refactor doctor
refactor review .
refactor code . --apply
```

Manage credentials:

```bash
refactor cloud credentials list
refactor cloud credentials remove --credential-ref cred_01J...
```
