Thank you for your interest in contributing to Syrin! This document provides guidelines and instructions for contributing to the project.
- Code of Conduct
- Getting Started
- Development Setup
- Project Structure
- Development Workflow
- Code Standards
- Testing
- Submitting Changes
- Common Tasks
By participating in this project, you agree to maintain a respectful and inclusive environment for all contributors.
- Node.js: >= 20.12.0
- npm: Latest version (comes with Node.js)
- Git: For version control
-
Fork the repository on GitHub
-
Clone your fork:
git clone https://github.com/YOUR_USERNAME/cli.git cd syrin -
Add the upstream repository:
git remote add upstream https://github.com/Syrin-Labs/cli.git
npm installnpm run buildThis compiles TypeScript to JavaScript in the dist/ directory.
Run the test suite to ensure everything is working:
npm run test:runsyrin/
├── src/ # Source TypeScript files
│ ├── cli/ # CLI commands and utilities
│ ├── config/ # Configuration management
│ ├── constants/ # Constants and messages
│ ├── events/ # Event system
│ ├── presentation/ # UI components (React/Ink)
│ ├── runtime/ # Runtime logic (LLM, MCP, analysis)
│ ├── types/ # Type definitions
│ └── utils/ # Utility functions
├── dist/ # Compiled JavaScript (generated)
├── tests/ # Test files (co-located with source)
├── package.json # Project configuration
├── tsconfig.json # TypeScript configuration
└── eslint.config.cjs # ESLint configurationCreate a feature branch from main:
git checkout main
git pull upstream main
git checkout -b feat/your-feature-nameBranch naming conventions:
feat/- New featuresfix/- Bug fixesdocs/- Documentation updatesrefactor/- Code refactoringtest/- Test improvements
- Write clean, maintainable code
- Follow the existing code style
- Add tests for new functionality
- Update documentation as needed
Before submitting, ensure all tests pass:
# Run all tests
npm run test:run
# Run tests in watch mode (for development)
npm test
# Run tests with coverage
npm run test:coverage
# Run tests with UI
npm run test:uiEnsure your code follows the project's style:
# Check for linting errors
npm run lint
# Auto-fix linting issues
npm run lint:fix
# Check formatting
npm run format:check
# Auto-format code
npm run formatVerify TypeScript compilation:
npm run type-check- Use TypeScript for all source code
- Prefer explicit types over
any - Use interfaces for object shapes
- Use
typefor unions, intersections, and aliases - Follow the existing patterns in the codebase
- The project uses ES Modules (
"type": "module"in package.json) - Use
import/exportsyntax, notrequire()/module.exports - Use
import.meta.urlinstead of__dirnamefor ESM compatibility
- Follow ESLint rules (configured in
eslint.config.cjs) - Use Prettier for formatting
- Maximum line length: Follow Prettier defaults
- Use meaningful variable and function names
- Add JSDoc comments for public APIs
- Co-locate test files with source files (
.test.tssuffix) - Group related functionality in the same directory
- Use index files for clean exports
- Use typed error classes from
@/utils/errors - Provide clear, actionable error messages
- Handle errors at appropriate levels
- Write tests for all new functionality
- Use Vitest as the testing framework
- Follow the existing test patterns
- Test files should be named
*.test.ts
import { describe, it, expect, vi } from 'vitest';
describe('FeatureName', () => {
it('should do something', () => {
// Arrange
const input = 'test';
// Act
const result = functionUnderTest(input);
// Assert
expect(result).toBe('expected');
});
});- Use Vitest's
vi.mock()for module mocking - Use
vi.fn()for function mocks - Prefer ES6 imports over CommonJS
require()in tests - Mock external dependencies (network requests, file system, etc.)
- Aim for high test coverage
- Focus on testing behavior, not implementation
- Include edge cases and error scenarios
# Run all tests once
npm run test:run
# Run tests in watch mode
npm test
# Run with coverage report
npm run test:coverage
# Run with UI (interactive)
npm run test:uiWrite clear, descriptive commit messages:
type(scope): brief description
Longer explanation if needed. Explain what and why, not how.Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Test additions or changeschore: Maintenance tasks
Examples:
feat(cli): add --json flag to analyse command
fix(version): correct package.json path resolution in ESM
docs(readme): update installation instructionsBefore committing, ensure:
- All tests pass (
npm run test:run) - Code is linted (
npm run lint) - Code is formatted (
npm run format:check) - TypeScript compiles (
npm run type-check) - Build succeeds (
npm run build) - Commit message follows conventions
-
Update your branch:
git checkout main git pull upstream main git checkout your-branch git rebase main
-
Push your changes:
git push origin your-branch
-
Create a Pull Request:
- Go to the GitHub repository
- Click "New Pull Request"
- Select your branch
- Fill out the PR template
-
PR Description should include:
- What changes were made
- Why the changes were needed
- How to test the changes
- Any breaking changes
- Related issues
-
Respond to feedback:
- Address review comments
- Make requested changes
- Keep the PR focused and small when possible
Your PR will be reviewed for:
- ✅ Code quality and style
- ✅ Test coverage
- ✅ Documentation updates
- ✅ Backward compatibility
- ✅ Performance implications
- ✅ Security considerations
- Create command file in
src/cli/commands/ - Implement the command handler
- Register in
src/cli/index.ts - Add tests in
src/cli/commands/command-name.test.ts - Update documentation
- Create provider in
src/runtime/llm/ - Implement the provider interface
- Register in
src/runtime/llm/factory.ts - Add tests
- Update configuration schema
- Create rule file in
src/runtime/analysis/rules/ - Implement rule logic
- Register in the analysis system
- Add tests
- Update documentation
Enable debug logging:
DEBUG=syrin:* npm run build && node dist/index.js <command>Run tests with verbose output:
npm test -- --reporter=verboseCheck build output:
npm run build
ls -la dist/- Documentation: https://docs.syrin.dev
- Issues: https://github.com/Syrin-Labs/cli/issues
- Discussions: Use GitHub Discussions for questions
By contributing, you agree that your contributions will be licensed under the ISC License.
Thank you for contributing to Syrin! 🎉