-
Notifications
You must be signed in to change notification settings - Fork 0
Development
eddy.wijaya edited this page Apr 3, 2026
·
3 revisions
Set up, build, test, and contribute to opencode-codex-quota.
| Requirement | Version |
|---|---|
| Node.js | >= 20 |
| TypeScript | >= 6.0 |
| npm | Latest |
# Clone the repository
git clone https://github.com/guyinwonder168/opencode-codex-quota.git
cd opencode-codex-quota
# Install dependencies
npm install| Command | Description |
|---|---|
npm run build |
TypeScript β dist/
|
npm run typecheck |
Type checking only (no emit) |
npm test |
Run all tests |
npm run test:coverage |
Run tests with coverage report |
npm run lint |
Check code style (Biome) |
npm run lint:fix |
Fix code style issues |
Tests use vitest with the Arrange-Act-Assert pattern. Mocks for fetch and fs are set up per test.
# Run all tests
npm test
# Run specific test file
npm test -- tests/auth-reader.test.ts
# Run with coverage
npm run test:coverage| File | Coverage |
|---|---|
tests/auth-reader.test.ts |
Auth reading, JWT parsing, E1/E2/E3/E9/E10/E11 errors |
tests/api-client.test.ts |
API calls, timeout, validation, E4βE8 errors |
tests/markdown.test.ts |
Progress bars, clock formatting, compact/full output |
tests/errors.test.ts |
All E1βE11 error message formatting |
tests/index.test.ts |
Plugin module shape, hooks, command registration |
tests/integration.test.ts |
Full pipeline from auth β API β Markdown |
opencode-codex-quota/
βββ src/
β βββ index.ts # Plugin entry point, tool definition
β βββ types.ts # All TypeScript interfaces
β βββ services/
β β βββ auth-reader.ts # Read auth.json β parse JWT β credentials
β β βββ api-client.ts # Call wham/usage β typed QuotaResponse
β βββ formatter/
β βββ markdown.ts # QuotaResponse β Markdown string
β βββ errors.ts # Error codes β Markdown error messages
βββ tests/
βββ auth-reader.test.ts
βββ api-client.test.ts
βββ markdown.test.ts
βββ errors.test.ts
βββ index.test.ts
βββ integration.test.ts
After building, point OpenCode at your local package:
{
"plugin": ["./path/to/opencode-codex-quota"]
}Then run /codex_quota in OpenCode to test.
The project uses Biome for linting and formatting:
-
No
anytypes β enforced bynoExplicitAny: "error" -
No banned imports β enforced by
noBannedImports: "error" - 2-space indentation β spaces, not tabs
- Organized imports β auto-sorted
Run npm run lint before committing.
Commits follow a structured wave pattern:
| Commit | Description |
|---|---|
| 1 | chore: project scaffolding with node.js, typescript, biome config |
| 2 | feat: add TypeScript type definitions for API + auth |
| 3 | feat: AuthReader service β read auth.json, parse JWT, handle E1-E11 errors |
| 4 | feat: ApiClient service β query wham/usage with timeout, validation, E4-E8 errors |
| 5 | feat: Formatter β Markdown output with compact/full modes, progress bars, time formatting |
| 6 | feat: error formatter β Markdown output for all E1-E11 scenarios |
| 7 | feat: plugin entry point β codex_quota tool with compact/full modes |
| 8 | test: integration tests β full pipeline from auth through API to markdown output |
| 9 | docs: add README with installation, usage, and development instructions |
Contributions are welcome! See CONTRIBUTING.md for guidelines.
- Architecture β Understand the component design
- Technical-Reference β API details and type definitions