OninOneProxy
CLAUDE.md4 starsChanged 4 months agoMITView on GitHub
Attribution: OninOneProxy is a derivative distribution based on 9Router by decolua, licensed under MIT. OninOneProxy (oninoneproxy) — a unified AI API gateway + Next.js dashboard. It exposes one OpenAI-compatible endpoint (/v1/*) and routes traffic across 40+ upstream providers with format translation, model-combo fallback, multi-account fallback, OAuth/API-key credential management, token refresh, quota/usage tracking, and optional cloud sync. Two published artifacts live in this one repo: - The dashboard + gateway (root package.json, oninoneproxy) — the Next.js server that does the actual…
- Reads credentials
- Installs packages
In this repository2 other files it gives its agents.
- AGENTS.mdAGENTS.md
- open-sse/AGENTS.mdAGENTS.md
The file
We split this CLAUDE.md into the rules it gives an agent
11 rules. About 0 are common, 2 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 27
Default runtime port is 20130 (dashboard at /dashboard, API at /v1).
- Very specific: line 72
Never hardcode role/block/model strings — use open-sse/translator/schema/ and open-sse/config/ constants.
- Very specific: line 76
Add a provider: copy providers/REGISTRY_TEMPLATE.js, add models to config/providerModels.js.
- Very specific: line 104
MUST run impact analysis before editing any symbol: Before modifying a function, class, or method, run impact({target: "symbolName", …
- Distinctive: line 106
MUST warn the user: if impact analysis returns HIGH or CRITICAL risk before proceeding with edits.
- Very specific: line 107
When exploring unfamiliar code, use query({query: "concept"}) to find execution flows instead of grepping.
- Very specific: line 108
When you need full context on a specific symbol — callers, callees, which execution flows it participates in — use context({name: …
- Very specific: line 112
NEVER edit a function, class, or method without first running impact on it.
- Distinctive: line 113
NEVER ignore HIGH or CRITICAL risk warnings from impact analysis.
- Very specific: line 114
NEVER rename symbols with find-and-replace — use rename which understands the call graph.
- Very specific: line 115
NEVER commit changes without running detect_changes() to check affected scope.
≈ “Common” is an estimate: at least 1 in 5 of the 29,248 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
Attribution: OninOneProxy is a derivative distribution based on 9Router by decolua, licensed under MIT.
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
What this is
OninOneProxy (oninoneproxy) — a unified AI API gateway + Next.js dashboard. It exposes one OpenAI-compatible endpoint (/v1/*) and routes traffic across 40+ upstream providers with format translation, model-combo fallback, multi-account fallback, OAuth/API-key credential management, token refresh, quota/usage tracking, and optional cloud sync.
Two published artifacts live in this one repo:
- The dashboard + gateway (root
package.json,oninoneproxy) — the Next.js server that does the actual routing. - The CLI launcher (
cli/, published to npm asoninoneproxy-cli) — a separate package that installs/starts the server and manages the tray. It has its ownpackage.json, version, and build.
The code lives in src/ (Next.js app + dashboard/compat APIs), open-sse/ (the provider-agnostic routing/translation engine), cli/ (the launcher package), and tests/.
Commands
Dashboard/gateway (run from repo root):
cp .env.example .env
npm install
PORT=20130 NEXT_PUBLIC_BASE_URL=http://localhost:20130 npm run dev # dev (webpack, port 20127 by default via next dev)
npm run build && PORT=20130 HOSTNAME=0.0.0.0 npm run start # production- Bun variants:
npm run dev:bun/build:bun/start:bun. - Default runtime port is 20130 (dashboard at
/dashboard, API at/v1). - Lint:
npx eslint .(configeslint.config.mjs, extendseslint-config-next).
CLI package (cli/):
npm run cli:pack # build + npm pack from root
cd cli && npm run dev # nodemon watchTests (vitest, in tests/, an independent ESM package — not wired into root npm test):
npm install # ROOT deps first — tests import from src/ which needs `open`, `undici`, etc.
cd tests && npm install # then tests' own deps (vitest) → tests/node_modules (allowed by tests/.gitignore)
npx vitest run # all tests; auto-discovers tests/vitest.config.js
npx vitest run unit/capabilities.test.js # single file (path relative to tests/)The committed
tests/package.jsontestscript hardcodes Unix paths (NODE_PATH=/tmp/node_modules …) — a shared-install workaround from upstream. On Windows (or anywhere), ignore it and use thenpx vitestform above;vitest.config.jsresolves theopen-sse/@/aliases from the repo root regardless of where vitest lives.The suite is NOT expected to be all-green on a plain checkout. ~938 pass, ~64 fail. Judge regressions with
tests/__baseline__/verify-no-regression.mjs, not a raw run. Expected red:
- 26 catalogued in
tests/__baseline__/known-fails.txt(rtk, oauth-cursor-auto-import, translator-request-normalization, …).unit/embeddings.cloud.test.jsimportscloud/src/handlers/embeddings.js— thecloud/worker dir is not in this repo, so it always fails here.unit/xai-oauth-service.test.jstimes out (5s) when the xAI endpoint-discovery fetch isn't reachable/mocked.real/*.real.test.jsmake live provider calls — need credentials, skip otherwise.
*.real.test.jsundertests/translator/real/make live provider calls — skip unless credentials are set.- Regression baselines:
tests/__baseline__/verify-*.mjscompare against committed snapshots (providers, aliases, OAuth URLs). Run these after touching provider registry / alias logic.
Architecture
Two authoritative docs already exist — read them before working in these areas rather than re-deriving:
docs/ARCHITECTURE.md— full system: request lifecycle, combo/account fallback, OAuth + token refresh, cloud sync, data model.open-sse/AGENTS.md— the routing/translation engine's own conventions and "how to add a provider/executor/translator". Read this before editing anything underopen-sse/.
Request flow (the thing to understand first)
src/app/api/v1/* route (Next rewrite maps /v1/* → /api/v1/* in next.config.mjs)
→ src/sse/handlers/chat.js (parse, combo expansion, account-selection loop)
→ open-sse/handlers/chatCore.js (detect source format, translate request, dispatch to executor, retry/refresh, stream setup)
→ open-sse/executors/* (per-provider upstream call; default.js handles any OpenAI-compatible provider)
→ open-sse/translator/* (client format ↔ provider format)
→ SSE back to client.
src/sse/ is the app-side entry glue; open-sse/ is the provider-agnostic engine (also usable standalone). Cross that boundary consciously.
Translator engine (open-sse/translator/)
- Pivots through OpenAI as the intermediate format. A translator registered on an exact
source:targetpair (e.g.claude:kiro) runs as a direct route, skipping the lossy double-hop. Prefer a direct route for fragile pairs (thinking blocks, tool ids, non-base64 images,is_error). - Translators self-register via
register(from, to, reqFn, resFn)as an import side effect — a new translator file MUST be imported inopen-sse/translator/index.jsor it never runs. - Never hardcode role/block/model strings — use
open-sse/translator/schema/andopen-sse/config/constants. Config-driven and DRY is enforced by convention here.
Provider registry (open-sse/providers/registry/*)
- One file per provider.
providers/registry/index.jsis an auto-generated static import list — regenerate it withscripts/migrate-registry.mjs/injectDisplayToRegistry.mjs, don't hand-edit. - Add a provider: copy
providers/REGISTRY_TEMPLATE.js, add models toconfig/providerModels.js. Only add an executor for non-OpenAI-compatible upstreams.
Persistence — IMPORTANT (ARCHITECTURE.md is stale here)
State is no longer db.json. It's a SQLite layer under src/lib/db/ with an adapter fallback chain (driver.js): bun:sqlite → better-sqlite3 (optional native dep) → node:sqlite (Node ≥22.5) → sql.js (pure-JS fallback, always works). better-sqlite3 is deliberately in optionalDependencies so install never fails without build tools.
src/lib/localDb.jsis a backward-compat shim re-exportingsrc/lib/db/index.js. New code should import from@/lib/db/index.js; per-entity logic lives insrc/lib/db/repos/*. Schema/migrations insrc/lib/db/migrations/.- DB file location resolves via
src/lib/db/paths.js(DATA_DIR, else~/.oninoneproxy/).). - Usage/logs (
src/lib/usageDb.js,usage.json+log.txt) still live under~/.oninoneproxyand do not followDATA_DIR.
RTK token saver (open-sse/rtk/)
Pre-translate hooks that compress tool_result content in-place to cut tokens. Fail-open: any error returns null and leaves the body untouched — never throw out of them. Skips is_error/status:"error" results to preserve traces.
Conventions & gotchas
- Plain JavaScript (ESM), no TypeScript.
@/*path alias →src/*(jsconfig.json). custom-server.jswraps the Next standalone server to derive client IP from the TCP socket and strip attacker-controlledX-Forwarded-For— trusting forwarding headers only from a loopback reverse proxy. Preserve this when touching request/IP/rate-limit code.- Security-sensitive env:
JWT_SECRET(session cookie),INITIAL_PASSWORD(default123456— must override),API_KEY_SECRET,MACHINE_ID_SALT. Full env contract in.env.exampleand ARCHITECTURE.md's env matrix. - Binary/protobuf upstreams (kiro EventStream, cursor protobuf, commandcode NDJSON) don't round-trip through OpenAI — they're handled inside their own executor, not the translator.
- Versioning: root and
cli/are versioned independently; changes are logged inCHANGELOG.md. Commit style is Conventional Commits (fix(translator): …,feat(...)).
<!-- gitnexus:start -->GitNexus — Code Intelligence
This project is indexed by GitNexus as OninOneProxy (15960 symbols, 34192 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
Index stale? Run
node .gitnexus/run.cjs analyzefrom the project root — it auto-selects an available runner. No.gitnexus/run.cjsyet?npx gitnexus analyze(npm 11 crash →npm i -g gitnexus; #1939).
Always Do
- MUST run impact analysis before editing any symbol. Before modifying a function, class, or method, run
impact({target: "symbolName", direction: "upstream"})and report the blast radius (direct callers, affected processes, risk level) to the user. - MUST run
detect_changes()before committing to verify your changes only affect expected symbols and execution flows. For regression review, compare against the default branch:detect_changes({scope: "compare", base_ref: "main"}). - MUST warn the user if impact analysis returns HIGH or CRITICAL risk before proceeding with edits.
- When exploring unfamiliar code, use
query({query: "concept"})to find execution flows instead of grepping. It returns process-grouped results ranked by relevance. - When you need full context on a specific symbol — callers, callees, which execution flows it participates in — use
context({name: "symbolName"}).
Never Do
- NEVER edit a function, class, or method without first running
impacton it. - NEVER ignore HIGH or CRITICAL risk warnings from impact analysis.
- NEVER rename symbols with find-and-replace — use
renamewhich understands the call graph. - NEVER commit changes without running
detect_changes()to check affected scope.
Resources
| Resource | Use for |
gitnexus://repo/OninOneProxy/context | Codebase overview, check index freshness |
gitnexus://repo/OninOneProxy/clusters | All functional areas |
gitnexus://repo/OninOneProxy/processes | All execution flows |
gitnexus://repo/OninOneProxy/process/{name} | Step-by-step execution trace |
CLI
| Task | Read this skill file |
| Understand architecture / "How does X work?" | .claude/skills/gitnexus/gitnexus-exploring/SKILL.md |
| Blast radius / "What breaks if I change X?" | .claude/skills/gitnexus/gitnexus-impact-analysis/SKILL.md |
| Trace bugs / "Why is X failing?" | .claude/skills/gitnexus/gitnexus-debugging/SKILL.md |
| Rename / extract / split / refactor | .claude/skills/gitnexus/gitnexus-refactoring/SKILL.md |
| Tools, resources, schema reference | .claude/skills/gitnexus/gitnexus-guide/SKILL.md |
| Index, status, clean, wiki CLI commands | .claude/skills/gitnexus/gitnexus-cli/SKILL.md |
<!-- gitnexus:end -->Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

