Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 17 additions & 29 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ Current honest state:
- the installer is implemented for Codex CLI
- the current bin surface is `gonkagate-codex`
- the runtime lives under `src/` and is compiled to `dist/`
- the current curated model registry contains two Codex model choices:
`moonshotai/Kimi-K2.6` (default) and `gpt-5.4`
- model availability is fetched from
`GET https://api.gonkagate.com/v1/models` with the user's API key
- the current verified upstream baseline is stable `@openai/codex` `0.118.0`
as of April 2, 2026

Expand All @@ -41,10 +41,11 @@ The intended happy path is:

1. user runs `npx @gonkagate/codex-setup`
2. installer prompts for a hidden GonkaGate `gp-...` key
3. installer offers a curated model picker
4. installer asks for `user` or `local` scope
5. installer writes the necessary Codex configuration layers
6. user returns to plain `codex`
3. installer fetches `GET https://api.gonkagate.com/v1/models` with bearer auth
4. installer offers a live model picker from the fetched response
5. installer asks for `user` or `local` scope
6. installer writes the necessary Codex configuration layers
7. user returns to plain `codex`

For `local` scope, the secret still lives only under `~/.codex/...`, while the
repo-local `.codex/config.toml` contains only activation settings.
Expand Down Expand Up @@ -72,8 +73,10 @@ refactor; it is a product change.
- repo-local `.codex/config.toml` should contain only local activation settings
- `projects."<abs-path>".trust_level = "trusted"` may need to be set in user
config when local scope is selected
- model selection should come from a curated registry and `model_catalog_json`,
not from raw `/v1/models` discovery as the main UX
- model selection comes from `GET https://api.gonkagate.com/v1/models` with the
user's API key
- `model_catalog_json` is generated from fetched model IDs plus generic
capability defaults, not from a checked-in model allowlist
- v1 targets Codex CLI first
- Codex Desktop App support is best-effort, not a guaranteed contract
- shell profile mutation is out of scope
Expand Down Expand Up @@ -105,12 +108,9 @@ These are implementation facts today, not future plans:
- `~/.codex/bin/gonkagate-token`
- `~/.codex/model-catalogs/gonkagate.json`
- `<project-root>/.codex/config.toml` for local scope only
- the current curated model catalog includes `gpt-5.4` and
`moonshotai/Kimi-K2.6`
- `scripts/model-catalog-source.json` is the committed curated source snapshot
for regenerating `src/constants/model-catalog.ts`
- `scripts/check-model-catalog.mjs` and `test/models.test.ts` guard against
drift between the committed source snapshot and generated catalog module
- model IDs are discovered at install time from GonkaGate `/v1/models`
- `test/model-discovery.test.ts` and `test/install-use-case.test.ts` cover live
model parsing, dynamic selection, and live `model_catalog_json` writes
- `test/install-use-case.test.ts` covers real file-writing behavior on temp
filesystems and git repos
- `test/package-contract.test.ts`, `test/docs-contract.test.ts`, and
Expand All @@ -131,7 +131,8 @@ This repo currently does:
- install and configure Codex CLI for GonkaGate
- write `~/.codex/config.toml`
- write `<project-root>/.codex/config.toml` for local scope
- generate `model_catalog_json` from a curated bundled registry
- fetch live GonkaGate models with the user's API key
- generate `model_catalog_json` from the live model IDs plus generic defaults
- create a helper auth command under `~/.codex/bin/`
- preserve unrelated Codex config via TOML merge
- create backups before replacing managed config or token files
Expand Down Expand Up @@ -169,9 +170,6 @@ This repo currently does not do:
│ ├── security.md
│ └── troubleshooting.md
├── scripts/
│ ├── check-model-catalog.mjs
│ ├── extract-model-catalog.mjs
│ ├── model-catalog-source.json
│ └── run-tests.mjs
├── src/
│ ├── cli.ts
Expand Down Expand Up @@ -219,20 +217,10 @@ The main installer flow and public CLI behavior.
Runtime implementation for prompts, TOML config merge, git safety, helper
command generation, and managed file writes.

### `scripts/extract-model-catalog.mjs`

Regenerates the bundled curated model catalog from the committed source
snapshot under `scripts/model-catalog-source.json`.

### `scripts/check-model-catalog.mjs`

Verifies that the committed generated model catalog still matches the source
snapshot and generator output.

### `test/install-use-case.test.ts`

The main runtime behavior proof slice for config writing, local scope, tracked
project config fallback, and backups.
project config fallback, backups, and live model catalog behavior.

### `.claude/skills/` and `.agents/skills/`

Expand Down
11 changes: 3 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,17 @@

## [Unreleased]

- Updated bundled Kimi K2.6 `model_catalog_json` context window to the current
Gonka deployment value, `240000`.
- Added `moonshotai/Kimi-K2.6` as the default curated GonkaGate Codex model
and generated `model_catalog_json`.
- Replaced the checked-in GonkaGate model allowlist with live
`GET https://api.gonkagate.com/v1/models` discovery.
- Implemented the interactive Codex installer behind
`npx @gonkagate/codex-setup`.
- Added command-backed GonkaGate provider setup for Codex CLI, including
token-file storage, helper command generation, curated `model_catalog_json`,
token-file storage, helper command generation, live `model_catalog_json`,
user and local scope handling, backups, and local git safety.
- Added runtime tests for config writing, tracked local config fallback, and
secret-preserving backup behavior.
- Refactored config planning so scope-to-layer ownership is centralized and
TOML no-op detection now lives in the managed-write seam.
- Added explicit `model-catalog:generate` and `model-catalog:check` workflows,
a committed model-catalog source snapshot, and drift checks for the generated
curated catalog module.
- Updated `README.md`, `docs/`, and repository contract files to describe the
implemented installer rather than the earlier scaffold-only state.

Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ What the installer does today:
- checks that `codex` is available and that the local Codex CLI is at least
`0.118.0`
- prompts for a hidden GonkaGate `gp-...` key
- uses a curated model registry bundled with this package
- currently ships curated Codex model choices: `moonshotai/Kimi-K2.6`
(default) and `gpt-5.4`
- fetches `GET https://api.gonkagate.com/v1/models` with that key
- uses the live `/v1/models` response as the model source of truth
- asks whether GonkaGate should be activated in `user` or `local` scope
- keeps the secret, helper command, and curated model catalog under
- keeps the secret, helper command, and live model catalog under
`~/.codex/...` by default, or under `CODEX_HOME` when that env var is set
- writes or updates the necessary Codex config layers
- creates backups before replacing existing managed files
Expand All @@ -30,11 +29,11 @@ What the installer does today:

- writes provider config, model activation, and `model_catalog_json` to
`~/.codex/config.toml`
- keeps the token file, helper command, and curated catalog under `~/.codex/...`
- keeps the token file, helper command, and live catalog under `~/.codex/...`

`local` scope:

- still keeps the secret, helper command, and curated catalog under `~/.codex/...`
- still keeps the secret, helper command, and live catalog under `~/.codex/...`
- writes only activation settings to `<project-root>/.codex/config.toml`
- writes the provider definition and
`projects."<abs-path>".trust_level = "trusted"` to user config
Expand All @@ -49,7 +48,7 @@ What the installer does today:

```toml
model_provider = "gonkagate"
model = "moonshotai/Kimi-K2.6"
model = "model-id-returned-by-v1-models"
model_catalog_json = "/Users/you/.codex/model-catalogs/gonkagate.json"

[model_providers.gonkagate]
Expand All @@ -65,7 +64,7 @@ trust entry, while `<project-root>/.codex/config.toml` activates:

```toml
model_provider = "gonkagate"
model = "moonshotai/Kimi-K2.6"
model = "model-id-returned-by-v1-models"
model_catalog_json = "/Users/you/.codex/model-catalogs/gonkagate.json"
```

Expand All @@ -80,8 +79,10 @@ model_catalog_json = "/Users/you/.codex/model-catalogs/gonkagate.json"
- The auth path is command-backed bearer token retrieval through
`model_providers.<id>.auth`.
- The installer never writes directly to `auth.json`.
- Model selection comes from a curated registry and `model_catalog_json`, not
raw `/v1/models` discovery.
- Model selection comes from `GET https://api.gonkagate.com/v1/models` with
the user's API key.
- The installer writes `model_catalog_json` from the live model IDs plus
generic Codex capability defaults, not from a checked-in allowlist.
- v1 targets Codex CLI first. Desktop app behavior is best-effort rather than
a product promise.

Expand Down
20 changes: 0 additions & 20 deletions contract-definitions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,6 @@
// Source snapshot: scripts/contract-source.json
// Do not edit by hand.

export const SUPPORTED_MODELS_CONTRACT: readonly [
{
readonly key: "moonshotai/Kimi-K2.6";
readonly displayName: "Kimi K2.6";
readonly modelId: "moonshotai/Kimi-K2.6";
readonly description: "Moonshot AI multimodal agentic coding model for long-horizon tasks.";
readonly isDefault: true;
},
{
readonly key: "gpt-5.4";
readonly displayName: "GPT-5.4";
readonly modelId: "gpt-5.4";
readonly description: "Current validated GonkaGate model for Codex CLI.";
readonly isDefault: false;
},
];

export type SupportedModelContractDefinition =
(typeof SUPPORTED_MODELS_CONTRACT)[number];

export const VERIFIED_CODEX_CONTRACT: {
readonly minVersion: "0.118.0";
readonly modelCatalogVersion: "rust-v0.118.0";
Expand Down
18 changes: 0 additions & 18 deletions contract-definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,6 @@
// Source snapshot: scripts/contract-source.json
// Do not edit by hand.

export const SUPPORTED_MODELS_CONTRACT = [
{
key: "moonshotai/Kimi-K2.6",
displayName: "Kimi K2.6",
modelId: "moonshotai/Kimi-K2.6",
description:
"Moonshot AI multimodal agentic coding model for long-horizon tasks.",
isDefault: true,
},
{
key: "gpt-5.4",
displayName: "GPT-5.4",
modelId: "gpt-5.4",
description: "Current validated GonkaGate model for Codex CLI.",
isDefault: false,
},
];

export const VERIFIED_CODEX_CONTRACT = {
minVersion: "0.118.0",
modelCatalogVersion: "rust-v0.118.0",
Expand Down
1 change: 0 additions & 1 deletion contract-metadata.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export interface ContractMetadata {
readonly cliVersion: "0.1.0";
readonly packageName: "@gonkagate/codex-setup";
readonly publicEntrypoint: "npx @gonkagate/codex-setup";
readonly supportedModels: typeof import("./contract-definitions.js").SUPPORTED_MODELS_CONTRACT;
readonly verifiedCodex: typeof import("./contract-definitions.js").VERIFIED_CODEX_CONTRACT;
}

Expand Down
6 changes: 1 addition & 5 deletions contract-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@
// Source snapshot: package.json + scripts/contract-source.json
// Do not edit by hand.

import {
SUPPORTED_MODELS_CONTRACT,
VERIFIED_CODEX_CONTRACT,
} from "./contract-definitions.js";
import { VERIFIED_CODEX_CONTRACT } from "./contract-definitions.js";

export const CONTRACT_METADATA = {
binName: "gonkagate-codex",
binPath: "bin/gonkagate-codex.js",
cliVersion: "0.1.0",
packageName: "@gonkagate/codex-setup",
publicEntrypoint: "npx @gonkagate/codex-setup",
supportedModels: SUPPORTED_MODELS_CONTRACT,
verifiedCodex: VERIFIED_CODEX_CONTRACT,
};
48 changes: 27 additions & 21 deletions docs/how-it-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,27 @@ npx @gonkagate/codex-setup
1. Check that `codex` is available and that the installed Codex CLI is at
least `0.118.0`.
2. Prompt for a GonkaGate `gp-...` key through a hidden input.
3. Choose a model from the curated registry bundled with this package.
Today that registry contains `moonshotai/Kimi-K2.6` (default) and
`gpt-5.4`.
4. Choose `user` or `local` scope.
5. Save the secret only under `~/.codex/...` (or `CODEX_HOME` when that env
3. Fetch `GET https://api.gonkagate.com/v1/models` with bearer auth using the
user's key.
4. Choose a model from the live `/v1/models` response. Non-interactive setup
uses the first returned model unless the response later exposes an explicit
default signal.
5. Choose `user` or `local` scope.
6. Save the secret only under `~/.codex/...` (or `CODEX_HOME` when that env
var is set), never inside the repository.
6. Write or update the helper token command under `~/.codex/bin/`.
7. Write or update the curated `model_catalog_json` under
7. Write or update the helper token command under `~/.codex/bin/`.
8. Write or update the live `model_catalog_json` under
`~/.codex/model-catalogs/gonkagate.json`.
8. Write or update the user-level provider definition in
9. Write or update the user-level provider definition in
`~/.codex/config.toml`.
9. When `local` scope is chosen:
- write only activation settings to `<project-root>/.codex/config.toml`
- set `projects."<abs-path>".trust_level = "trusted"` in user config
- keep the local config file out of git by default through `.git/info/exclude`
10. Create backups before replacing existing managed config or token files.
11. Tell the user to verify with `codex`, then `/status`, and fall back to
10. When `local` scope is chosen:

- write only activation settings to `<project-root>/.codex/config.toml`
- set `projects."<abs-path>".trust_level = "trusted"` in user config
- keep the local config file out of git by default through `.git/info/exclude`

11. Create backups before replacing existing managed config or token files.
12. Tell the user to verify with `codex`, then `/status`, and fall back to
`/debug-config` if needed.

## Why A Custom Provider
Expand Down Expand Up @@ -61,15 +65,17 @@ That gives the product the intended UX:
The implementation intentionally does not write directly to Codex auth storage
internals such as `auth.json`.

## Why Curated Models
## Why Live Models

The model picker does not depend on runtime `/v1/models` discovery as the main
UX.
The model picker uses `GET https://api.gonkagate.com/v1/models` with the
user's API key as the source of truth. If GonkaGate adds or removes a model,
the setup flow follows the live response without requiring a repository
change.

Instead, the installer ships curated Codex model metadata and writes a local
`model_catalog_json` file. That keeps the onboarding surface stable even if the
gateway model list changes or exposes ids that should not be part of the public
setup experience.
The installer still writes `model_catalog_json` because Codex reads model
metadata from that file. Its entries are generated from the fetched model IDs
plus generic capability defaults that apply to any returned model, not from a
checked-in model allowlist.

## Scope Model

Expand Down
2 changes: 2 additions & 0 deletions docs/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ so the implementation is intentionally conservative.
- Keep the secret under `~/.codex/...` with owner-only permissions.
- Use a helper command plus Codex provider `auth` config instead of relying on
exported env vars.
- Fetch `GET https://api.gonkagate.com/v1/models` with bearer auth only after
the hidden key prompt and local key validation.
- Preserve unrelated Codex config instead of overwriting the whole file.
- Create backups before replacing existing managed config or token files.

Expand Down
4 changes: 3 additions & 1 deletion docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ integration will not be viable.

Codex does not have a Claude Code-style repo-local secret layer. To keep the
repository settings safe, the secret still lives in `~/.codex/...`, while the
repo-local file only activates provider, model, and catalog selection.
repo-local file only activates provider, model, and catalog selection. Model
availability comes from `GET https://api.gonkagate.com/v1/models` with the
user's API key.

## What if `.codex/config.toml` is already tracked?

Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@
"dev": "tsx src/cli.ts",
"format": "prettier --write .",
"format:check": "prettier --check .",
"model-catalog:check": "node scripts/check-model-catalog.mjs",
"model-catalog:generate": "node scripts/extract-model-catalog.mjs",
"package:check": "publint",
"prepack": "npm run ci",
"test": "npm run build && node scripts/run-tests.mjs",
"typecheck": "tsc -p tsconfig.json",
"ci": "npm run typecheck && npm run test && npm run contract:check && npm run model-catalog:check && npm run format:check && npm run package:check"
"ci": "npm run typecheck && npm run test && npm run contract:check && npm run format:check && npm run package:check"
},
"engines": {
"node": ">=22.14.0"
Expand Down
33 changes: 0 additions & 33 deletions scripts/check-model-catalog.mjs

This file was deleted.

Loading
Loading