Thank you for your interest in contributing to the OpenCode Resources Loader Plugin! This document provides guidelines and instructions for contributing.
- Code of Conduct
- Getting Started
- Development Setup
- How to Contribute
- Contribution Guidelines
- Pull Request Process
- Coding Standards
- Testing Guidelines
- Documentation
- Community
This project adheres to a Code of Conduct that all contributors are expected to follow. Please be respectful and constructive in all interactions.
- Be respectful: Treat everyone with respect and consideration
- Be collaborative: Work together and help each other
- Be inclusive: Welcome newcomers and diverse perspectives
- Be constructive: Provide helpful feedback and criticism
- Node.js >= 18.0.0
- Bun >= 1.0.0 (recommended)
- Git
- OpenCode for testing
-
Fork the repository on GitHub
-
Clone your fork:
git clone https://github.com/YOUR_USERNAME/opencode-resources-loader-plugin.git cd opencode-resources-loader-plugin -
Add upstream remote:
git remote add upstream https://github.com/pantheon-org/opencode-resources-loader-plugin.git
-
Install dependencies:
bun install
-
Verify setup:
bun test bun run type-check bun run lint
Before creating a bug report:
- Check existing issues to avoid duplicates
- Gather information: Version, OS, steps to reproduce
- Create detailed issue: Include code samples, error messages, expected vs actual behavior
Bug Report Template:
**Describe the bug**
A clear description of the bug.
**To Reproduce**
Steps to reproduce:
1. ...
2. ...
**Expected behavior**
What you expected to happen.
**Actual behavior**
What actually happened.
**Environment**
- OS: [e.g., macOS 14.0]
- Node version: [e.g., 20.0.0]
- Bun version: [e.g., 1.0.0]
- Plugin version: [e.g., 1.1.1]
**Additional context**
Any other relevant information.Before suggesting a feature:
- Check existing issues and discussions
- Describe use case: Explain why this feature is needed
- Propose solution: Suggest how it could work
Feature Request Template:
**Problem Statement**
Describe the problem this feature would solve.
**Proposed Solution**
Describe your proposed solution.
**Alternatives Considered**
Describe alternative solutions you've considered.
**Additional Context**
Any other relevant information.-
Pick an issue or create one for your contribution
-
Create a branch:
git checkout -b feature/your-feature-name
-
Make your changes:
- Write code following our coding standards
- Add tests for new features
- Update documentation
-
Test your changes:
bun test bun run type-check bun run lint -
Commit your changes:
git add . git commit -m "feat: your feature description"
-
Push to your fork:
git push origin feature/your-feature-name
-
Create a pull request on GitHub
Follow Conventional Commits:
<type>(<scope>): <description>
[optional body]
[optional footer]
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting)refactor: Code refactoringtest: Test changeschore: Build/tooling changesperf: Performance improvements
Examples:
feat(search): add multi-token query support
fix(cache): correct TTL expiration logic
docs: update API documentation
test(discovery): add tests for nested resources
refactor: simplify scoring algorithm
perf(index): optimize resource indexingUse descriptive branch names:
feature/add-semantic-searchfix/cache-expiration-bugdocs/improve-readmerefactor/simplify-parser
All contributions require code review:
- Be patient: Reviews may take time
- Be responsive: Address feedback promptly
- Be open: Consider alternative approaches
- Be collaborative: Work with reviewers
- All tests pass (
bun test) - Type checking passes (
bun run type-check) - Linting passes (
bun run lint) - Code is formatted (
bun run format) - Documentation is updated
- CHANGELOG.md is updated (for significant changes)
## Description
Brief description of the changes.
## Motivation
Why are these changes needed?
## Changes Made
- Change 1
- Change 2
- Change 3
## Testing
How were these changes tested?
## Related Issues
Closes #123
Related to #456
## Checklist
- [ ] Tests pass
- [ ] Type checking passes
- [ ] Linting passes
- [ ] Documentation updated
- [ ] CHANGELOG updated (if applicable)- CI checks: Wait for automated checks to complete
- Review: Respond to reviewer feedback
- Update: Make requested changes
- Approval: Wait for maintainer approval
- Merge: Maintainer will merge your PR
- Use TypeScript for all code
- Enable strict mode
- Provide type annotations for public APIs
- Avoid
anytype (useunknownif needed)
- Use Prettier for formatting (configured in
.prettierrc) - Follow ESLint rules (configured in
eslint.config.cjs) - Maximum line length: 100 characters
- Use meaningful variable names
- Add comments for complex logic
// Good: Type-safe, clear naming
interface SearchOptions {
query: string;
type?: ResourceType;
maxResults?: number;
}
function searchResources(index: ResourceIndex, options: SearchOptions): SearchResult[] {
// Implementation...
}
// Avoid: Unclear types, poor naming
function search(idx: any, q: string, t?: string, m?: number): any[] {
// Implementation...
}// 1. Imports (external first, then internal)
import { z } from 'zod';
import { ResourceType } from './types';
// 2. Type definitions
interface SearchOptions {
// ...
}
// 3. Constants
const CACHE_TTL = 5 * 60 * 1000;
// 4. Functions
export function searchResources(...) {
// ...
}import { describe, test, expect } from 'bun:test';
describe('searchResources', () => {
test('should return results for valid query', () => {
// Arrange
const index = buildTestIndex();
const query = 'api documentation';
// Act
const results = searchResources(index, query);
// Assert
expect(results.length).toBeGreaterThan(0);
expect(results[0].score).toBeGreaterThan(0);
});
});- Unit tests: Test individual functions
- Integration tests: Test complete workflows
- Edge cases: Empty inputs, large files, invalid data
- Target: >= 80% code coverage
# All tests
bun test
# With coverage
bun run test:coverage
# Watch mode
bun test --watch
# Specific file
bun test src/search-resources.test.ts- Add JSDoc comments for public APIs
- Document complex algorithms
- Include examples in comments
/**
* Search resources by keyword with relevance scoring
*
* @param index - Resource index to search
* @param query - Search query (case-insensitive)
* @param type - Optional resource type filter
* @param maxResults - Maximum results to return (default: 10)
* @returns Array of search results sorted by relevance
*
* @example
* const results = searchResources(index, 'api documentation', 'checklist');
*/
export function searchResources(
index: ResourceIndex,
query: string,
type?: ResourceType,
maxResults: number = 10,
): SearchResult[] {
// Implementation...
}When adding features:
- Update relevant markdown files in
src/ - Update documentation site in
pages/src/content/docs/ - Add examples to README.md
- Update API reference
The project uses Astro for documentation:
cd pages
bun install
bun run dev # Start dev server
bun run build # Build for production- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: GitHub Pages
- Be respectful and professional
- Stay on topic
- Help others when possible
- Share knowledge and learnings
Contributors are recognized in:
- GitHub contributors page
- Release notes
- Project documentation
Thank you for contributing to OpenCode Resources Loader Plugin!