Metadata-Version: 2.5
Name: fireworks2bedrock-migrate
Version: 0.0.1
Summary: One-shot migration of Kimi K3 inference from Fireworks to Amazon Bedrock for Python repositories
Project-URL: Repository, https://github.com/HolboxAI/fireworks2bedrock-migrate
License-Expression: Apache-2.0
Requires-Python: >=3.9
Requires-Dist: libcst>=1.1.0
Provides-Extra: dev
Requires-Dist: pytest; extra == 'dev'
Description-Content-Type: text/markdown

# fireworks2bedrock-migrate

One-shot migration of **Kimi K3** inference from **Fireworks** to **Amazon Bedrock**, for **Python** repositories. One command scans the repository, rewrites the inference calls, and opens a pull request. The model does not change — only the backend does.

> JavaScript / TypeScript repositories use the npm package instead: `npx -y fireworks2bedrock-migrate migrate --pr`.

---

## For coding agents (use this README as a skill)

This package is meant to be driven by a coding agent. When asked to *"migrate this repository from Fireworks Kimi K3 to Bedrock"*, follow this workflow exactly and do not improvise on the parts it covers.

### Step 1 — Scan

```bash
uvx fireworks2bedrock-migrate scan <repo> --json
```

Read the `findings` and bucket them:

| classification | meaning |
|---|---|
| `MIGRATE` | will be rewritten |
| `BLOCK` | left untouched (fine-tuned models, non-inference APIs, adapters, dedicated deployments) |
| `REVIEW` | needs a decision (runtime `base_url` clients, computed model IDs, raw HTTP) |

### Step 2 — Migrate and open the pull request

```bash
uvx fireworks2bedrock-migrate migrate <repo> --pr --json
```

This creates the branch `f2b/kimi-k3-bedrock`, rewrites the `MIGRATE` files, drops in the `llm_client.py` helper and `f2b.json` routing config, adds the runtime dependencies, writes `BEDROCK_MIGRATION.md`, and opens the pull request.

### Step 3 — Act on the exit code

| code | meaning | what to do |
|---|---|---|
| `0` | migration applied (and PR opened with `--pr`) | go to Step 4 |
| `20` | nothing to migrate, or everything is `BLOCK` | report why; edit nothing |
| `30` | environment problem (dirty git tree, no `origin` remote) | report the message; edit nothing |

### Step 4 — Verify

The tool does not run the repository's own tests yet (`checks` in the JSON is reserved for that), so the agent verifies:

1. Read `review_items` from the JSON output — each one needs a decision before deploy.
2. Run the repository's own checks: `pytest -q`, plus lint/type-check/build from `.github/workflows/*.yml` or `pyproject.toml`.
3. Confirm the diff touches only `MIGRATE` files plus the helper and config.
4. Fix only failures in the files the tool listed, then push to the branch.

### Step 5 — Report

Report the pull request URL, the `BLOCK` items that were deliberately left alone, and any `REVIEW` items still needing attention.

### Rules — never break these

- Never edit a file or finding the tool classified `BLOCK`.
- Never hand-edit a model ID; the tool and `f2b.json` own that mapping.
- Never touch infrastructure files unless the tool lists them as `REVIEW`.
- Do not add setup steps for the developer — one command is the whole experience.

---

## What the migration changes

- Model ID `accounts/fireworks/models/kimi-k3` → `global.moonshotai.kimi-k3` (`us.moonshotai.kimi-k3` with `--us-only`)
- `OpenAI(...)` / `Fireworks(...)` / `AsyncFireworks(...)` / `ChatFireworks(...)` → `get_llm_client()` / `get_async_llm_client()` / `ChatOpenAI(model=KIMI_K3, ...)`
- Adds the `llm_client.py` helper, `f2b.json` routing config, and the runtime deps `openai` + `aws-bedrock-token-generator`
- Writes `BEDROCK_MIGRATION.md`: full change log, everything left untouched, the IAM policy to attach, and rollback steps

## Rollback

Set `F2B_BACKEND=fireworks` to route back to Fireworks with no code change.

## CLI reference

```
fireworks2bedrock-migrate scan    [path] [--json]
fireworks2bedrock-migrate migrate [path] [--pr] [--us-only] [--region <r>] [--json] [--no-git]
```

- `--pr` pushes the branch and opens a pull request (without it the commit stays local).
- `--us-only` targets the `us.moonshotai.kimi-k3` profile instead of `global.`.
- `--no-git` skips branch/commit/push (for testing).

## Scope

| Supported | Not supported (left as `BLOCK`) |
|---|---|
| Fireworks **base** Kimi K3 inference | fine-tuned models, LoRA adapters, dedicated deployments |
| OpenAI SDK, Fireworks SDK, LangChain, raw HTTP inference calls | fine-tuning, embeddings, datasets, batch, rerank, other non-inference APIs |
| Python repositories | other models and providers |
