src/index.tsis the CLI entrypoint and command router (login,overview,status,logout).- Core modules are split by concern:
src/oauth.ts(OAuth flow),src/whoop.ts(WHOOP API calls),src/config.ts(local config persistence), andsrc/format.ts(human-readable output). - Shared contracts live in
src/types.ts; constants are insrc/constants.ts. - Tests are module-aligned under
test/(for example,test/oauth.test.ts,test/whoop.test.ts). - No generated build artifacts are committed; this project runs directly with Bun.
bun installinstalls dependencies.bun run src/index.ts helpshows CLI usage.bun run src/index.ts loginstarts OAuth login with interactive credential prompts.bun run src/index.ts overview --jsonfetches overview data as raw JSON.bun testruns the Bun test suite.bunx tsc --noEmitruns strict TypeScript checks usingtsconfig.json.
- Language: TypeScript (ES modules, strict mode enabled).
- Follow existing formatting: 2-space indentation, semicolons, trailing commas, and clear guard-clause control flow.
- Naming:
camelCasefor functions/variables,PascalCasefor types/interfaces/classes,UPPER_SNAKE_CASEfor constants. - Keep modules focused and minimal; prefer explicit error messages over implicit failures.
- Framework:
bun:testwithdescribe,test, andexpect. - Place tests in
test/with the pattern<module>.test.ts. - Inject/mimic dependencies (for example, pass
fetchImpl) to avoid real network calls. - Cover success and failure paths, especially OAuth/token refresh and empty WHOOP collection responses.
- Never commit WHOOP credentials, tokens, or local config files.
- Config is stored via
confin the OS app config directory (whoo/config.json). - Mask secrets in logs and screenshots.
- WHOOP API documentation: https://developer.whoop.com/docs/introduction
- WHOOP API schema: https://developer.whoop.com/api