Skip to content

Commit b23df26

Browse files
Alph4d0gabien
andauthored
Release v1.2.2 — Model metadata overrides fix + Agent guidelines consolidation (#26)
* fix: apply model metadata overrides to provider models (#25) * fix: apply model metadata overrides to provider models * test: isolate auth store XDG data home * fix: treat string metadata matches as literals * refactor: centralize metadata extraction keys * fix: refresh legacy generated provider models --------- Co-authored-by: Sebastian Rumpf <alp4d0g007@googlemail.com> * docs: consolidate agent guidelines into AGENTS.md and symlink CLAUDE.md - Rewrite AGENTS.md by cherry-picking the best of AGENTS.md and CLAUDE.md: - Keep generic Agent Guidelines framing and all code style rules - Add Architecture section (dual entry points, core modules, fetch interceptor, caching) - Expand Common Commands (test runner, check:exports, single-file typecheck) - Add Testing, Important Configuration, and full Release Process sections - Delete CLAUDE.md and replace with symlink to AGENTS.md so both Claude Code and other agents read from the same canonical source. * chore: bump version to 1.2.2 * style: fix indentation in getApiMode warn() call Fixes pre-existing indentation issue flagged by kilo-code-bot review. No functional change. * perf: pre-process metadata blocks to avoid redundant regex/alias calculations Addresses gemini-code-assist review feedback on PR #26: - Pre-process array-based metadata blocks once: canonicalize string matches, compile regexes, and extract metadata upfront. - Replaces O(N*M) redundant resolveProviderAliasForMetadata + coerceRegExp calls inside per-model loops with a single pass over config blocks. - Adds processedBlockMatches() helper that uses pre-computed canonicalMatch instead of re-resolving aliases on every comparison. - No functional change — all 66 tests pass. --------- Co-authored-by: Alexander Bien <abien@gmx.net>
1 parent 5771b7c commit b23df26

6 files changed

Lines changed: 1081 additions & 241 deletions

File tree

AGENTS.md

Lines changed: 131 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,73 @@
11
# Agent Guidelines for opencode-omniroute-auth
22

3-
This file provides guidelines for AI agents operating in this repository.
3+
This file provides guidelines to AI agents when working with code in this repository.
44

55
## Overview
6-
OpenCode authentication plugin for the OmniRoute API. Features `/connect` command setup, API key auth, dynamic model fetching (`/v1/models`), and TTL caching.
76

8-
## Commands
7+
`opencode-omniroute-auth` is an OpenCode authentication plugin for the OmniRoute API. It provides a `/connect omniroute` command, API-key auth, dynamic model fetching from `/v1/models`, and combo model capability enrichment.
98

10-
### Build & Development
11-
```bash
12-
npm install # Install dependencies
13-
npm run build # Build the project (TypeScript compilation)
14-
npm run dev # Watch mode for development
15-
npm run clean # Clean build output
16-
npm run prepublishOnly # Build before publishing
17-
```
9+
## Common Commands
1810

19-
### Single File Build / Type-Check
2011
```bash
21-
npx tsc --noEmit src/plugin.ts # Type-check a single file
22-
npx tsc --build --verbose # Build with verbose output
23-
```
12+
# Build (required before running tests)
13+
npm run build
2414

25-
### Testing
26-
*Note: No test suite currently exists. When implemented, use:*
27-
```bash
28-
npm test # Run all tests
29-
npx jest src/plugin.test.ts # Run a single test file
30-
npm run test:watch # Run tests in watch mode
15+
# Watch mode during development
16+
npm run dev
17+
18+
# Run tests (builds first, then runs Node built-in test runner)
19+
npm test
20+
21+
# Run a single test file
22+
npm run build && node --test test/plugin.test.mjs
23+
24+
# Type-check a single file without emitting
25+
npx tsc --noEmit src/plugin.ts
26+
27+
# Clean build output
28+
npm run clean
29+
30+
# Validate dist exports satisfy plugin loader constraints
31+
npm run check:exports
32+
33+
# Full publish prep
34+
npm run prepublishOnly
3135
```
3236

37+
## Architecture
38+
39+
### Dual Entry Points
40+
41+
- **`index.ts`** — Main plugin export (`OmniRouteAuthPlugin`). Required by OpenCode's plugin loader. All root exports must be functions.
42+
- **`runtime.ts`** — Runtime utilities (`fetchModels`, `clearModelCache`, combo helpers, etc.) exported for programmatic use.
43+
44+
### Core Modules
45+
46+
| File | Responsibility |
47+
|------|----------------|
48+
| `src/plugin.ts` | Plugin implementation: `config` hook (registers `omniroute` provider), `auth` hook (`/connect` command), `loadProviderOptions` (fetches models and returns a `fetch` interceptor). |
49+
| `src/models.ts` | `fetchModels()` fetches `/v1/models`, manages an in-memory cache keyed by `baseUrl:apiKey`, falls back to defaults on failure. Orchestrates metadata enrichment via `models-dev.ts` and combo enrichment via `omniroute-combos.ts`. |
50+
| `src/models-dev.ts` | Fetches `https://models.dev/api.json`, builds indexed lookup maps (exact/normalized, provider-specific and global), and maps OmniRoute provider keys to models.dev providers via aliases. |
51+
| `src/omniroute-combos.ts` | Fetches combo definitions from `/api/combos`. Resolves underlying models and calculates lowest-common-denominator capabilities (min context/maxTokens, vision/tools only if ALL underlying models support them). |
52+
| `src/constants.ts` | Endpoints, default models, TTLs, timeouts. |
53+
| `src/types.ts` | Shared TypeScript interfaces. |
54+
55+
### Fetch Interceptor (`createFetchInterceptor` in `src/plugin.ts`)
56+
57+
The loader returns a `fetch` function that:
58+
1. Adds `Authorization: Bearer <apiKey>` and `Content-Type: application/json` headers.
59+
2. Only intercepts requests to the configured OmniRoute base URL (with safe prefix matching).
60+
3. Sanitizes Gemini tool schemas by stripping `$schema`, `$ref`, `ref`, and `additionalProperties` keywords when the model name includes "gemini".
61+
62+
### Caching Strategy
63+
64+
Three independent in-memory caches:
65+
- **Model cache** (`src/models.ts`) — keyed by `baseUrl:apiKey`, TTL defaults to 5 minutes.
66+
- **models.dev cache** (`src/models-dev.ts`) — global singleton, TTL defaults to 24 hours.
67+
- **Combo cache** (`src/omniroute-combos.ts`) — global singleton, TTL defaults to 5 minutes.
68+
69+
`clearModelCache()` also clears the combo cache.
70+
3371
## Code Style Guidelines
3472

3573
### TypeScript & Formatting
@@ -101,3 +139,75 @@ try {
101139
## Common Tasks
102140
- **Adding Exports**: Add in source file, re-export in `index.ts` (with `.js`), run `npm run build`.
103141
- **Debugging**: Look for `[OmniRoute]` prefix in console logs.
142+
143+
## Release Process
144+
145+
### 1. Prepare the version bump
146+
147+
1. Update `package.json` version.
148+
2. Update `CHANGELOG.md` with a new section for the release. Include the date and credit contributors by GitHub username (e.g., `@username`) when applicable.
149+
3. If there are missing changelog sections for prior releases (e.g., `1.1.0` was released but never documented), add them retroactively so the changelog is complete.
150+
4. Commit the changes:
151+
```bash
152+
git add package.json CHANGELOG.md
153+
git commit -m "chore: bump version to X.Y.Z"
154+
```
155+
156+
### 2. Merge to `main`
157+
158+
Ensure the release PR is merged into `main`:
159+
```bash
160+
git checkout main
161+
git pull origin main
162+
```
163+
164+
### 3. Tag the release
165+
166+
Create and push an annotated tag matching the version:
167+
```bash
168+
git tag -a vX.Y.Z -m "Release vX.Y.Z"
169+
git push origin vX.Y.Z
170+
```
171+
172+
### 4. Create the GitHub Release
173+
174+
Create a release from the tag using `gh`:
175+
```bash
176+
gh release create vX.Y.Z --title "vX.Y.Z" --notes "$(sed -n '/## \[X.Y.Z\]/,/^## /p' CHANGELOG.md | sed '$d')"
177+
```
178+
179+
Or use a prepared notes file if one exists in `docs/`:
180+
```bash
181+
gh release create vX.Y.Z --title "vX.Y.Z" --notes-file docs/release-notes-vX.Y.Z.md
182+
```
183+
184+
### 5. Publish to npm
185+
186+
1. Verify you are logged in:
187+
```bash
188+
npm whoami
189+
```
190+
2. Run the publish prep (clean, build, and export validation):
191+
```bash
192+
npm run prepublishOnly
193+
```
194+
3. Publish:
195+
```bash
196+
npm publish
197+
```
198+
199+
If npm requires an MFA/2FA OTP, publish with:
200+
```bash
201+
npm publish --otp <CODE>
202+
```
203+
204+
### 6. Post-release verification
205+
206+
- Confirm the package version on npm:
207+
```bash
208+
npm view opencode-omniroute-auth version
209+
```
210+
- Confirm the GitHub release exists:
211+
```bash
212+
gh release view vX.Y.Z
213+
```

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
All notable changes to this project are documented in this file.
44

5+
## [1.2.2] - 2026-05-22
6+
7+
### Added
8+
9+
- **Consolidated Agent Guidelines** — Merged `CLAUDE.md` and `AGENTS.md` into a single canonical `AGENTS.md` file. `CLAUDE.md` is now a symlink to `AGENTS.md` so both Claude Code and other agents read from the same source.
10+
- **Release Process Documentation** — Added complete release process steps to `AGENTS.md` (version bump, changelog, tag, GitHub release, npm publish, verification).
11+
12+
### Fixed
13+
14+
- **Model Metadata Overrides for Provider Models** — Fixed model metadata overrides not being applied to provider models returned by the `provider` hook. (`src/plugin.ts`) (@Alph4d0g)
15+
516
## [1.2.1] - 2026-05-19
617

718
### Added

CLAUDE.md

Lines changed: 0 additions & 170 deletions
This file was deleted.

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "opencode-omniroute-auth",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"description": "OpenCode authentication plugin for OmniRoute API with /connect command and dynamic model fetching",
55
"type": "module",
66
"main": "./dist/index.js",

0 commit comments

Comments
 (0)