# Repository agent guide This file governs the entire `dsh-packycode-api` repository. ## Repository identity - Canonical repository: `https://github.com/BaronCyrus/dsh-packycode-api` - npm package: `dsh-packycode-api` - DSH plugin row: `packycode-api` - Model group display name: `PackyCode` - LLM provider route key: `packycode` ## Project boundaries - This is a permanent DSH profile plugin, not a temporary dynamic Cordis Plugin. - Host code belongs in `src/index.js` and its sibling modules; browser UI belongs in `src/client.jsx` and is built through the client wrapper in `tsdown.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.yml` or `llm-pi-ai` provider YAML. - Never introduce a silent fallback to another provider, another credential source, or an ambient `PACKY_CODE_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`, or `thinkingLevelMap` requires a note in `CHANGELOG.md` and a live check. ## Security requirements - Never print, log, commit, return to the browser, or include in diagnostics any API key. `scripts/live-check.mjs` may 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 generated `lib/index.js` or `lib/client.js`. - `lib/` is tracked and must be regenerated with `pnpm run build` after source changes. - `.artifacts/` and `node_modules/` are ignored and must never be committed. - `docs/releases/v.md` holds each version's GitHub Release notes. It is tracked and not packaged. - Add or update tests under `tests/` for behavior changes. ## Required validation ```sh 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 1. Synchronize and confirm a clean base: ```sh git fetch origin --tags --prune git status --short --branch git log --oneline HEAD..origin/main ``` Fast-forward clean remote changes before editing. Never discard remote changes. 2. Confirm the requested SemVer is unused: ```sh npm view dsh-packycode-api@ version --json git ls-remote --exit-code --tags origin refs/tags/v ``` For an unused npm version, `npm view` normally returns `E404`. An existing npm version or Git tag requires choosing a new version. 3. Update all release metadata together: `package.json` version, `CHANGELOG.md`, any version pinned in `README.md` / `README.en.md`, and the GitHub Release notes in `docs/releases/v.md`. The notes are in Chinese, like every earlier release: - The first line is `# v:<短标题>`, which becomes the release title. - Then a one-sentence summary and bullets with bold labels. - Then a `验证:…` paragraph. - They close with `在 DSH 插件管理中更新至 ****,然后重新打开 DSH 加载新版。` `node scripts/release-notes.mjs ` checks the file, and `pnpm run check` fails while the current `package.json` version has no valid notes. 4. Validate and inspect the exact release artifact: ```sh pnpm install --frozen-lockfile pnpm run check npm publish .artifacts/dsh-packycode-api-.tgz --access public --dry-run --json ``` 5. Commit the release and push `main` without force. [`.github/workflows/publish.yml`](.github/workflows/publish.yml) must already be on the commit that will be tagged. Do not push the tag in this step. 6. Confirm the package has a GitHub Actions trusted publisher before pushing the tag: repository `BaronCyrus/dsh-packycode-api`, workflow filename `publish.yml`, environment empty. Never request that a token, password, or one-time code be pasted into chat. 7. Create the annotated tag and push it. That push publishes with GitHub OIDC. The workflow's `release` job then creates the GitHub Release from `docs/releases/v.md` and attaches the tarball npm published. It is the only job with `contents: write`, and it runs no dependency code. Do not run `npm publish` locally for a release. A local publish cannot attach provenance. Do not set `NODE_AUTH_TOKEN` or a setup-node `registry-url` in the publish workflow; npm treats either as token auth and skips OIDC. ```sh git tag -a v -m "dsh-packycode-api v" git push origin v ``` `workflow_dispatch` on the same workflow only prints the OIDC identity npm will match. It does not publish. 8. Confirm that both jobs of the publish workflow succeeded for that tag before declaring the release public. Then check that npm serves the version and that `gh release view v` shows the notes, the `dsh-packycode-api-.tgz` asset and, for the newest version, the Latest mark. On an OIDC `package not found` error, 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. If npm published but the release job failed, re-run only that failed job. If the Release must be made by hand, attach the tarball npm serves, not a local `.artifacts` build: CI packs its own, so the local bytes differ. Fetch it with `npm pack dsh-packycode-api@`, and compare its SHA-512 with the registry's `dist.integrity`. Then run `gh release create v --verify-tag --title "" --notes-file `. The release job leaves an existing Release unchanged.