Derived from dsh-packycode-api 1.1.7 (MIT) and rebuilt for the Geek2API (sub2api) gateway: multi-endpoint failover, /v1/usage balances with wallet dedupe, per-key coverage from /v1/models, sub2api failure wording, a Claude runtime switch (HTTP or local CLI), and Claude/GPT web search backends. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
5.2 KiB
Repository agent guide
This file governs the entire dsh-geek2api repository.
Repository identity
- Canonical repository: not published yet (derived from
https://github.com/BaronCyrus/dsh-packycode-api, MIT) - npm package:
dsh-geek2api - DSH plugin row:
geek2api - Model group display name:
Geek2API - Gateway: Geek2API, a sub2api deployment. Entry points:
hk,hk2,hk3,hk4,www.geek2api.com. Default endpoints are geek2api.com hosts only. - LLM provider route key:
geek2api
Project boundaries
- This is a permanent DSH profile plugin, not a temporary dynamic Cordis Plugin.
- Host code belongs in
src/index.jsand its sibling modules; browser UI belongs insrc/client.jsxand is built through the client wrapper intsdown.config.mjs. - The route is self-contained: the plugin builds its own pi-ai provider, catalog, key ring, and balance reader. It must never require the user to edit
cordis.patch.ymlorllm-pi-aiprovider YAML. - Never introduce a silent fallback to another provider, another credential source, or an ambient
GEEK2API_API_KEY. Only keys the user added through this plugin may authenticate a request. - The catalog declares protocols and effort levels from vendor documentation. Changing a model's
api,baseUrl, orthinkingLevelMaprequires a note inCHANGELOG.mdand a live check.
Security requirements
- Never print, log, commit, return to the browser, or include in diagnostics any API key.
scripts/live-check.mjsmay read the stored key but must only ever print its masked tail. - Credentials and balance requests stay host-side. Browser RPC returns only the projections in
src/rpc.js. - Balance requests stay bounded by a timeout and configured with
redirect: 'error'. - Preserve unrelated DSH plugins, profiles, sessions, settings, and credentials.
- Do not start, stop, or restart DSH without explicit user permission.
Source and generated files
- Edit
src/; never hand-edit generatedlib/index.jsorlib/client.js. lib/is tracked and must be regenerated withpnpm run buildafter source changes..artifacts/andnode_modules/are ignored and must never be committed.- Add or update tests under
tests/for behavior changes.
Required validation
pnpm install
pnpm run check
pnpm run check must run every test, rebuild both bundles, and produce the versioned tarball in .artifacts/.
Live gateway behavior is verified with node scripts/live-check.mjs after a build. It consumes a small amount of quota; run it when a change touches the catalog, the provider composition, or the failure classification. Do not claim runtime success from a passing build alone.
Release authorization
npm publish, Git tags, GitHub Releases, and version publication are externally visible and partially irreversible. Execute them only when the user explicitly asks to publish or release and confirms the target version. A request to modify, test, or commit alone is not release authorization.
Never reuse, move, delete, or overwrite a published npm version or Git tag. If a published version needs a correction, create a new patch version.
Release checklist
-
Synchronize and confirm a clean base:
git fetch origin --tags --prune git status --short --branch git log --oneline HEAD..origin/mainFast-forward clean remote changes before editing. Never discard remote changes.
-
Confirm the requested SemVer is unused:
npm view dsh-geek2api@<version> version --json git ls-remote --exit-code --tags origin refs/tags/v<version>For an unused npm version,
npm viewnormally returnsE404. An existing npm version or Git tag requires choosing a new version. -
Update all release metadata together:
package.jsonversion,CHANGELOG.md, and any version pinned inREADME.md/README.en.md. -
Validate and inspect the exact release artifact:
pnpm install --frozen-lockfile pnpm run check npm publish .artifacts/dsh-geek2api-<version>.tgz --access public --dry-run --json -
Commit the release and push
mainwithout force..github/workflows/publish.ymlmust already be on the commit that will be tagged. Do not push the tag in this step. -
Confirm the package has a GitHub Actions trusted publisher before pushing the tag: repository
<owner>/dsh-geek2api, workflow filenamepublish.yml, environment empty. Never request that a token, password, or one-time code be pasted into chat. -
Create the annotated tag and push it. That push publishes with GitHub OIDC. Do not run
npm publishlocally for a release. A local publish cannot attach provenance. Do not setNODE_AUTH_TOKENor a setup-noderegistry-urlin the publish workflow; npm treats either as token auth and skips OIDC.git tag -a v<version> -m "dsh-geek2api v<version>" git push origin v<version>workflow_dispatchon the same workflow only prints the OIDC identity npm will match. It does not publish. -
Confirm the publish workflow succeeded for that tag before declaring the release public. On an OIDC
package not founderror, fix the trusted publisher and re-run the same workflow. Do not move the tag. If the tagged tree itself must change, publish a new patch version.