# Changelog

## 0.3.1 — 2026-08-20

### Changed

- Removed `[oc-zen] hidden N model(s)` / `[oc-go] hidden N model(s)` runtime
  info logs. The visibility rules in `~/.pi/agent/pi-other-provider.json`
  are fully documented in [README.md → Model visibility](README.md#model-visibility-onoff-in-model);
  the per-startup log was redundant and noisy when this extension is loaded
  by many pi-crew child workers in parallel. Use `/providers` (this package)
  or `/model` (pi) to inspect the effective visible list.

## 0.3.0 — 2026-08-10

### Added

- **Factory Droid provider** (`factory-droid`) — session-based agent adapter
  for [Factory Droid](https://docs.factory.ai) (`src/backends/factorydroid/`).
  Factory is **not** OpenAI/Anthropic-compatible, so this backend drives the
  Droid Sessions REST API directly: resolve a Factory computer (reuse an
  active `e2b` computer, or **auto-create** one from a cloud template — option
  B), create a stateful session per pi conversation, send the newest user
  message, poll until the agent loop finishes, and surface the final assistant
  text as simulated streaming deltas. Factory's `tool_use`/`tool_result`
  blocks (the Droid's own internal actions) are intentionally **not** surfaced
  as pi tool calls; each pi turn is one complete Factory agent turn.
    - 18 static models from docs.factory.ai/models (incl. `auto` = Factory
      Router); all-zero pricing table (Factory is subscription-billed via credit
      multipliers — see `FACTORY_DROID_MODEL_MULTIPLIERS`).
    - Auth: `FACTORY_API_KEY` env var (`fk-…`) or `~/.factory/settings.json`.
    - Env overrides: `FACTORY_DROID_COMPUTER_ID`, `FACTORY_DROID_MACHINE_TEMPLATE_ID`,
      `FACTORY_DROID_BASE`.
    - Zero runtime dependencies maintained (direct `fetch`; `@factory/droid-sdk`
      deliberately NOT used — it spawns the `droid` CLI subprocess, leaks the
      full `process.env` into it, and pulls ~8 transitive deps).
    - `tests/test-factorydroid-vendor.ts` — 25 tests incl. end-to-end stream
      runs with a mocked `fetchImpl` (computer reuse + auto-create paths, usage
      deltas, error paths, abort).
    - Docs: [docs/FACTORYDROID-BACKEND.md](docs/FACTORYDROID-BACKEND.md).

## 0.2.0 — 2026-08-07

### Fixed

- **Gotcha hooks were silently bypassed for oc-zen / oc-go.** Registered
  models now carry the `OPENCODE_CUSTOM_API` ("opencode-custom") marker on
  `model.api` instead of the real protocol, so pi's `streamWith` routes
  streaming through `createOpencodeStreamSimple` (which re-derives the real
  protocol from the catalog and applies the 5 gotcha hooks). Previously
  `model.api` held the real protocol while the provider `api` was the marker,
  so `model.api === extension.api` was false and pi called pi-ai's streamer
  directly — the gotchas (client_metadata, effort tiers, reasoning_content, …)
  never ran. Command Code was unaffected (its models had no `api`, falling
  back to the provider marker). Adds a `streamers` DI param on
  `createOpencodeStreamSimple` and `tests/test-stream.ts` integration tests.

### Added

- **Model/provider visibility control** (`src/visibility.ts`) — turn the
  three package providers (`oc-zen`, `oc-go`, `commandcode`) on/off in pi's
  `/model` selector. Two layers: provider-level disable (`enabled: false` in
  config or the new `PI_OTHER_PROVIDER_DISABLE` env var, `*` = all), and
  model-level filtering (`showOnly` / `hide` glob patterns). Affects only
  these three providers; other pi providers are untouched. Implemented at the
  source (models list + refreshModels persist/restore phases) since pi's own
  `filterModels` hook is not forwarded from extensions. Adds the
  `PI_OTHER_PROVIDER_CONFIG` env var (custom config file path).
- **`/providers` slash command** (`src/command.ts`) — interactive TUI
  (`SettingsList`) to toggle models and providers on/off directly inside pi,
  writing the visibility config live. Rich UI in TUI mode with an automatic
  `ctx.ui.select` dialog fallback for RPC / when `pi-tui` is unavailable.
  `pi-tui` added as an optional peer dependency.
- **Live catalog refresh** (`refreshModels`) for `oc-zen` / `oc-go` — fetches
  the upstream `/models` endpoint and persists through **pi's own model-store
  cache** (`~/.pi/agent/models-store.json`). Two-phase hook: restores the
  persisted catalog on the offline phase, fetches + persists on the network
  phase. New upstream models appear automatically; the static catalogs stay as
  the offline baseline.
- `GO_MODELS_URL` config constant (Go live models endpoint).
- Command Code request hardening (aligned with OmniRoute's commandCode
  executor):
    - `x-cli-environment: "external"` (was `"production"`)
    - `x-taste-learning: "false"` (privacy opt-out; was `"true"`)
    - `max_tokens` is only forwarded when pi sets one, clamped to the 200k
      endpoint ceiling (no more fabricated 64k / "Too big" rejections)
    - passthrough of `reasoning_effort` / `reasoning` / `thinking` / `effort` /
      `output_config` / `extra_body` (payload-rule overrides are not dropped)
    - `reasoningEffort` option → `params.reasoning_effort` (pi's standard mechanism)
    - `memory` / `taste` / `skills` sent as `""` (was `null`)
    - `permissionMode: "standard"`
- **Stable `threadId` per pi conversation** — Command Code requests now use
  `options.sessionId` (fallback: fresh uuid), enabling upstream prefix caching
  (cache-hit savings) across turns.

### Docs

- Complete documentation set: README (rewritten), docs/ARCHITECTURE.md,
  docs/OPENCODE-BACKEND.md, docs/COMMANDCODE-BACKEND.md, docs/CACHING.md,
  docs/COMPARISON.md, docs/DEVELOPMENT.md.

## 0.1.0

Initial release.

### Added

- **`oc-zen`** provider — OpenCode Zen with corrected per-model protocol routing
  and a comprehensive static model catalog (GPT-5.x, Claude 4.x, Gemini 3.x,
  Qwen, MiniMax M3, GLM, Kimi, big-pickle, …).
- **`oc-go`** provider — OpenCode Go with corrected routing:
    - Go Qwen3.x → `/messages` (anthropic-messages) instead of `/chat/completions`
    - Go MiniMax M2.5/M2.7/M3 → `/messages` instead of `/chat/completions`
    - Effort-tier alias expansion (deepseek-v4-pro-low, glm-5.2-high, …)
- **`commandcode`** provider — vendored from `pi-commandcode-provider`.
- Data-driven routing table (`getProtocolForModel`) with pattern fallback for
  live/passthrough model ids.
- Five `onPayload` gotcha hooks: `stripClientMetadata`, `limitTools`,
  `rewriteEffortTier`, `stripBooleanReasoning`, `injectReasoningContent`.
- Auth resolution from `OPENCODE_API_KEY` env var and `~/.pi/agent/auth.json`.
- Pricing overlays extracted from pi-ai built-in `opencode`/`opencode-go` catalogs.
- Unit tests (mocked HTTP) covering routing correctness, gotcha transforms, and
  auth resolution.

### Notes

- Uses **new** provider IDs (`oc-zen`, `oc-go`) to avoid clobbering the built-in
  `opencode` / `opencode-go` providers.
- pi-ai v0.77+ no longer exports `AssistantMessageEventStream` as a value from
  its package root; a minimal async-queue shim is used for the Command Code
  stream factory.
