Thank you for your interest in contributing to nano-opencode! This guide will help you get started.
- Fork and clone the repository:
git clone https://github.com/yourusername/nano-opencode.git
cd nano-opencode- Install dependencies:
npm install- Set up environment variables:
cp .env.example .env
# Edit .env and add your API keys- Run in development mode:
npm run devsrc/
├── app.ts # Entry point
├── cli.ts # CLI interface
├── config.ts # Configuration
├── store.ts # Session storage
├── types.ts # Type definitions
├── providers/ # LLM providers
└── tools/ # Tool implementations
- Create a new branch:
git checkout -b feature/your-feature-name- Make your changes and ensure tests pass:
npm test- Type check your code:
npm run typecheck- Commit your changes:
git add .
git commit -m "feat: add your feature description"We follow conventional commits:
feat:- New featurefix:- Bug fixdocs:- Documentation changesstyle:- Formatting, no code changerefactor:- Code restructuringperf:- Performance improvementtest:- Test additions or changesbuild:- Build system changesci:- CI configuration changeschore:- Maintenance tasksrevert:- Revert a commitdeps:- Dependency updates
- Create a new file in
src/tools/:
import type { Tool } from '../types.js';
export const myTool: Tool = {
name: 'my_tool',
description: 'What this tool does',
parameters: {
type: 'object',
properties: {
// Define parameters
},
required: ['required_param'],
},
execute: async (args) => {
// Implementation
return 'Result string';
},
};- Register it in
src/tools/index.ts:
import { myTool } from './mytool.js';
export const allTools: Tool[] = [
// ... existing tools
myTool,
];- Add tests in
test/tools.test.ts
- Create a new file in
src/providers/:
import type { LLMProvider, Message, Tool, StreamChunk } from '../types.js';
export class MyProvider implements LLMProvider {
name = 'myprovider';
constructor(apiKey: string, model: string, maxTokens: number) {
// Initialize
}
async chat(
messages: Message[],
tools: Tool[],
onChunk: (chunk: StreamChunk) => void
): Promise<Message> {
// Implementation
}
}- Register it in
src/providers/index.ts
- Write tests for all new functionality
- Ensure all tests pass before submitting
- Maintain or improve code coverage
- Use TypeScript strict mode
- Follow existing code patterns
- Use meaningful variable names
- Add comments for complex logic
- Keep functions small and focused
- Update README.md if needed
- Update tests
- Ensure all tests pass
- Update CHANGELOG.md (if exists)
- Create a pull request with a clear description
Open an issue for discussion before starting major changes.
By contributing, you agree that your contributions will be licensed under the MIT License.