Thank you for your interest in contributing to Token Optimizer MCP! This document provides guidelines and information for contributors.
- Node.js: Version 20.x or higher
- npm: Version 8.x or higher
- Git: Latest stable version
- TypeScript: 5.9+ (installed via npm)
-
Fork and Clone
git clone https://github.com/YOUR_USERNAME/token-optimizer-mcp.git cd token-optimizer-mcp -
Install Dependencies
npm install
-
Build the Project
npm run build
-
Verify Installation
npm test
-
Create a Feature Branch
git checkout -b feat/your-feature-name # or git checkout -b fix/your-bug-fix -
Make Changes
- Write your code following our coding standards
- Add tests for new functionality
- Update documentation as needed
-
Build and Test
npm run build npm test npm run lint -
Commit Your Changes
git add . git commit -m "feat: add new feature"
-
Push and Create PR
git push origin feat/your-feature-name
We use ESLint and Prettier to maintain consistent code style.
- Run linter:
npm run lint - Auto-fix issues:
npm run lint:fix - Format code:
npm run format - Check formatting:
npm run format:check
-
Type Safety
- Always provide explicit types for function parameters and return values
- Avoid using
any- useunknownor proper types instead - Use TypeScript's strict mode features
-
File Organization
- One primary export per file
- Group related types and interfaces together
- Use barrel exports (
index.ts) for clean imports
-
Naming Conventions
- Files: kebab-case (e.g.,
smart-cache.ts) - Classes: PascalCase (e.g.,
CacheEngine) - Functions: camelCase (e.g.,
getCachedData) - Constants: UPPER_SNAKE_CASE (e.g.,
MAX_CACHE_SIZE) - Interfaces/Types: PascalCase (e.g.,
CacheOptions)
- Files: kebab-case (e.g.,
-
Error Handling
- Always handle errors explicitly
- Use custom error classes for specific error types
- Provide meaningful error messages
We follow Conventional Commits specification:
<type>(<scope>): <subject>
<body>
<footer>
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringperf: Performance improvementstest: Adding or updating testschore: Maintenance tasksci: CI/CD changes
Examples:
feat(cache): add predictive caching capability
fix(compression): resolve memory leak in brotli compression
docs(api): update smart-cache documentation
test(cache): add integration tests for cache warmupImportant Notes:
- Use present tense ("add feature" not "added feature")
- Use imperative mood ("move cursor to..." not "moves cursor to...")
- First line should be 72 characters or less
- Reference issues in footer (e.g., "Closes #123")
feat/feature-name- New featuresfix/bug-description- Bug fixesdocs/documentation-update- Documentation updatesrefactor/code-improvement- Code refactoringtest/test-addition- Test additionschore/maintenance-task- Maintenance tasks
# Run all tests
npm test
# Run with coverage
npm run test:coverage
# Run in watch mode (development)
npm run dev- Minimum coverage: 80% overall
- Line coverage: 80%
- Branch coverage: 75%
- Function coverage: 80%
-
Test File Location
- Place test files next to the code they test
- Use
.test.tsextension (e.g.,smart-cache.test.ts)
-
Test Structure
import { describe, it, expect } from '@jest/globals'; describe('FeatureName', () => { describe('methodName', () => { it('should do something specific', () => { // Arrange const input = 'test'; // Act const result = methodName(input); // Assert expect(result).toBe('expected'); }); }); });
-
Test Coverage Areas
- Happy path scenarios
- Error conditions
- Edge cases
- Boundary conditions
- Integration points
For performance-critical features, include benchmarks:
npm run benchmarkExpected performance targets:
- Cache operations: <10ms
- Token counting: <5ms per 1000 tokens
- Compression: ~1ms per KB
- Cache hit rate: >80%
-
Ensure all tests pass
npm test npm run lint npm run build -
Update documentation
- Add/update JSDoc comments
- Update README.md if needed
- Update API.md for new tools
-
Add tests
- New features must include tests
- Bug fixes should include regression tests
- Maintain or improve coverage
When you create a PR, fill out the template completely:
- Description: Clear explanation of changes
- Type of change: feat/fix/docs/etc.
- Checklist: All items must be checked
- Related issues: Link to issues
All PRs must pass:
-
Continuous Integration
- Build succeeds
- All tests pass
- Code coverage meets threshold
-
Code Quality
- ESLint passes (no errors)
- Prettier formatting applied
- TypeScript type checks pass
-
Review Requirements
- At least 1 approval from maintainers
- All conversations resolved
- No merge conflicts
-
Automated Checks
- CI/CD pipeline runs automatically
- Code quality tools provide feedback
-
Code Review
- Maintainers review code quality
- Security implications considered
- Performance impact evaluated
-
Feedback and Iteration
- Address reviewer comments
- Push updates to the same branch
- Request re-review when ready
-
Merge
- Maintainer merges approved PRs
- Squash and merge is preferred
- Delete branch after merge
We use semantic-release for automated versioning and publishing:
-
Version Bumps
feat:→ Minor version (0.x.0)fix:→ Patch version (0.0.x)BREAKING CHANGE:→ Major version (x.0.0)
-
Release Triggers
- Automatic on merge to
mainbranch - Triggered by CI/CD pipeline
- Changelog auto-generated
- Automatic on merge to
-
Publishing
- npm package published automatically
- GitHub release created
- Changelog updated
See RELEASE.md for detailed release procedures.
Please review and follow our Code of Conduct.
- GitHub Issues: Bug reports and feature requests
- Pull Requests: Code contributions and discussions
- Discussions: General questions and ideas
- Check existing issues
- Read the documentation
- Review examples
By contributing to Token Optimizer MCP, you agree that your contributions will be licensed under the MIT License.
Contributors are recognized in:
- GitHub contributors page
- Release notes
- Project README (for significant contributions)
Thank you for contributing to Token Optimizer MCP!