src/TypeScript source (ESM). Entry:src/index.ts→main.ts; shared helpers insrc/shared/.bin/CLI launcher (openrouter) that loadsdist/index.js.dist/build output (generated bynpm run build). Do not edit.tests/Vitest specs (e.g.,config.spec.ts,openrouter.spec.ts).docs/design and configuration notes;scripts/release/build helpers.- Config files: global
~/.config/openrouter-cli/config.json; project overrides.openrouterrc(.json|.yaml|.yml).
npm run dev— run CLI in TS directly (ts-node ESM). Example:npm run dev -- ask "Hello".npm run build— compile TypeScript todist/.npm test/npm run test:watch— run Vitest once / in watch mode.npm run lint— ESLint oversrc/**.npm run commit— Commitizen prompt for Conventional Commits.- After build:
openrouter --help(viabin/openrouter) ornode dist/index.js.
- TypeScript, ESM, 2-space indentation, single quotes allowed; prefer explicit return types for exported functions.
- File names: lowercase (e.g.,
main.ts,repl.ts,shared/openrouter.ts). - ESM import paths in TS include
.js(e.g.,import { x } from './main.js'). - Use helpers to protect secrets; never log API keys. Config files are written with chmod
600when possible. - Linting via flat-config ESLint (
eslint.config.js); pre-commit runslint-staged.
- Framework: Vitest. Place tests in
tests/*.spec.tswith clear, isolated cases. - Cover config precedence, URL joining, and CLI option parsing. Example: see
tests/openrouter.spec.tsforjoinUrl. - Run
npm testlocally; keep tests deterministic (no network). Mock I/O when needed.
- Follow Conventional Commits:
feat:,fix:,chore:,docs:,refactor:,test:; use scopes when helpful (e.g.,feat(config): ...). Usenpm run commit. - PRs: concise description, linked issues, CLI examples (commands/output), and updated docs when behavior changes. Ensure
lint,test, andbuildpass.
- Prefer
OPENROUTER_API_KEY/OPENAI_API_KEY; avoid committing secrets. Useopenrouter config --api-keyonly if persistence is required. - Example:
openrouter config --model meta-llama/llama-3.1-8b-instruct --domain https://openrouter.ai/api/v1.