- Build:
mise run buildorbun build ./src/index.ts --outdir dist --target bun - Test:
mise run testorbun test - Single Test:
bun test BackgroundTask.test.ts(use file glob pattern) - Watch Mode:
bun test --watch - Lint:
mise run lint(eslint) - Fix Lint:
mise run lint:fix(eslint --fix) - Format:
mise run format(prettier)
- Use ES6
import/exportsyntax (module: "ESNext", type: "module") - Group imports: external libraries first, then internal modules
- Use explicit file extensions (
.ts) for internal imports
- Single quotes (
singleQuote: true) - Line width: 100 characters
- Tab width: 2 spaces
- Trailing commas: ES5 (no trailing commas in function parameters)
- Semicolons: enabled
- NeverNesters: avoid deeply nested structures. Always exit early.
- Strict mode: enforced (
"strict": true) - Classes: PascalCase (e.g.,
BackgroundTask,BackgroundTaskManager) - Methods/properties: camelCase
- Status strings: use union types (e.g.,
'pending' | 'running' | 'completed' | 'failed' | 'cancelled') - Explicit types: prefer explicit type annotations over inference
- Return types: optional (not required but recommended for public methods)
- Check error type before accessing error properties:
error instanceof Error ? error.toString() : String(error) - Log errors with
[ERROR]prefix for consistency - Always provide error context when recording output
@typescript-eslint/no-explicit-any: warn (avoidanytype)no-console: error (minimize console logs)prettier/prettier: error (formatting violations are errors)
- Framework: vitest with
describe&itblocks - Style: Descriptive nested test cases with clear expectations
- Assertion library:
expect()(vitest)
- Store temporary data in
.memory/directory (gitignored)
- Type: ES Module package for OpenCode plugin system
- Target: Bun runtime, ES2021+
- Purpose: Background task execution and lifecycle management