Thank you for your interest in contributing to OpenCode Smart Voice Notify! This document provides guidelines for development, testing, and submitting contributions.
-
Clone the repository:
git clone https://github.com/MasuRii/opencode-smart-voice-notify.git cd opencode-smart-voice-notify -
Install dependencies: We recommend using Bun for the fastest development experience, but
npmalso works.bun install # or npm install -
Link to OpenCode: Add the local path to your
~/.config/opencode/opencode.json:{ "plugin": ["file:///path/to/opencode-smart-voice-notify"] }
We take testing seriously. All new features and bug fixes should include appropriate tests.
The project uses Bun's built-in test runner.
# Run all tests
bun test
# Run tests with coverage report
bun test --coverage
# Run tests in watch mode (useful during development)
bun test --watch
# Run a specific test file
bun test tests/unit/config.test.js- Unit Tests: Place in
tests/unit/. Name files as[module].test.js. - E2E Tests: Place in
tests/e2e/. Name files as[feature].test.js. - Integration Tests: Place in
tests/integration/. These tests use real API credentials.
We provide a comprehensive test setup in tests/setup.js which is preloaded for all tests. It includes utilities for:
- Filesystem Isolation:
createTestTempDir()creates a sandbox for each test. - Config Mocks:
createTestConfig()andcreateMinimalConfig(). - Shell Mocking:
createMockShellRunner()to intercept and verify shell commands. - SDK Mocking:
createMockClient()to simulate the OpenCode SDK environment. - Event Mocks:
createMockEventandmockEventsfactory for plugin events.
We maintain a high standard for code coverage.
- Minimum Requirement: 70% line coverage for all new code.
- Ideal: 90%+ function coverage.
- PRs that significantly decrease overall coverage may be rejected or require additional tests.
Avoid using real system calls or external APIs in unit and E2E tests.
Instead of using the real $ shell runner, use createMockShellRunner():
import { createMockShellRunner } from '../setup.js';
const mockShell = createMockShellRunner({
handler: (command) => {
if (command.includes('osascript')) return { stdout: Buffer.from('iTerm2') };
return { exitCode: 0 };
}
});
// Use it in your tests
await mockShell`echo "hello"`;
expect(mockShell.getCallCount()).toBe(1);Use createMockClient() to verify interactions with the OpenCode TUI, sessions, and permissions:
import { createMockClient } from '../setup.js';
const client = createMockClient();
await client.tui.showToast({ body: { message: 'Hello' } });
expect(client.tui.getToastCalls()[0].message).toBe('Hello');If you need to test real cloud APIs (ElevenLabs, OpenAI, etc.):
- Copy
tests/.env.exampletotests/.env.local. - Fill in your real API keys.
- Run
bun test tests/integration/.
NEVER commit tests/.env.local to the repository. It is included in .gitignore by default.
- Use ESM (ECMAScript Modules) syntax (
import/export). - Follow the existing code style (use 2 spaces for indentation).
- Add JSDoc comments for all new functions and modules.
- Ensure
bun run typecheck(if available) or basic linting passes.
- Create a new branch for your feature or bug fix.
- Implement your changes and add tests.
- Verify all tests pass locally (
bun test). - Ensure your changes follow the existing architecture patterns.
- Submit a PR with a clear description of what changed and why.
Thank you for contributing!