Contributing
Thank you for your interest in contributing to @sylphx/cat!
Getting Started
Prerequisites
- Node.js 18+
- Bun (recommended) or npm
- Git
Clone Repository
git clone https://github.com/SylphxAI/cat.git
cd catInstall Dependencies
bun install
# or
npm installRun Tests
bun test
# or
npm testBuild
bun run build
# or
npm run buildDevelopment Workflow
1. Create a Branch
git checkout -b feature/my-feature
# or
git checkout -b fix/my-bugfix2. Make Changes
Edit files in src/:
src/core/- Core logger implementationsrc/formatters/- Log formatterssrc/transports/- Log transportssrc/plugins/- Pluginssrc/serializers/- Serializerssrc/tracing/- W3C Trace Context
3. Write Tests
Add tests in tests/:
import { describe, it, expect } from 'bun:test'
import { createLogger } from '../src'
describe('MyFeature', () => {
it('works correctly', () => {
const logger = createLogger()
logger.info('Test')
expect(true).toBe(true)
})
})4. Run Tests
bun test5. Build
bun run build6. Commit
git add .
git commit -m "feat: add new feature"Use conventional commits:
feat:- New featurefix:- Bug fixdocs:- Documentationtest:- Testsrefactor:- Code refactoringperf:- Performance improvementchore:- Build/tooling changes
7. Push and Create PR
git push origin feature/my-featureThen create a pull request on GitHub.
Code Style
TypeScript
- Use TypeScript strict mode
- Export types for public API
- Avoid
any, useunknowninstead - Use interfaces for object shapes
// ✅ Good
interface LogEntry {
level: LogLevel
timestamp: number
message: string
data?: Record<string, unknown>
}
// ❌ Bad
type LogEntry = {
level: any
timestamp: any
message: any
data?: any
}Formatting
We use Prettier for code formatting:
bun run formatLinting
We use ESLint:
bun run lintTesting
Unit Tests
Test individual functions:
import { generateTraceId } from '../src/tracing/context'
describe('generateTraceId', () => {
it('generates valid trace ID', () => {
const traceId = generateTraceId()
expect(traceId).toMatch(/^[0-9a-f]{32}$/)
})
})Integration Tests
Test full workflows:
import { createLogger, otlpTransport } from '../src'
describe('OTLP integration', () => {
it('sends logs to OTLP endpoint', async () => {
const logger = createLogger({
transports: [otlpTransport({ endpoint: 'http://localhost:4318/v1/logs' })]
})
logger.info('Test')
await logger.flush()
// Verify log was sent
})
})Test Coverage
Aim for >90% code coverage:
bun test --coverageDocumentation
Code Comments
Add JSDoc comments for public API:
/**
* Create a new logger instance
* @param options - Logger configuration options
* @returns Logger instance
*/
export function createLogger(options?: LoggerOptions): Logger {
// ...
}Markdown Docs
Update documentation in docs/:
docs/guide/- User guidesdocs/api/- API referencedocs/examples/- Examples
Examples
Add examples in examples/:
// examples/my-feature.ts
import { createLogger } from '../src'
const logger = createLogger()
logger.info('Example')Performance
Benchmarks
Add benchmarks for performance-critical code:
import { bench, run } from 'mitata'
bench('createLogger', () => {
createLogger()
})
run()Profiling
Profile your changes:
node --prof examples/my-feature.ts
node --prof-process isolate-*.logPull Request Guidelines
PR Title
Use conventional commit format:
feat: add OTLP compression support
fix: correct trace ID validation
docs: update migration guidePR Description
Include:
- What changed
- Why it changed
- How to test it
- Breaking changes (if any)
Checklist
- [ ] Tests pass
- [ ] Code is formatted
- [ ] Documentation updated
- [ ] Examples added (if applicable)
- [ ] No breaking changes (or documented)
Areas to Contribute
High Priority
- Additional transports (Syslog, CloudWatch, etc.)
- Performance optimizations
- Bug fixes
- Documentation improvements
Medium Priority
- New plugins
- Enhanced formatters
- Additional serializers
- Test coverage improvements
Low Priority
- Examples
- Tooling improvements
- Refactoring
Community
Discord
Join our Discord: https://discord.gg/sylphx
Issues
Report bugs: https://github.com/SylphxAI/cat/issues
Discussions
Ask questions: https://github.com/SylphxAI/cat/discussions
License
By contributing, you agree that your contributions will be licensed under the MIT License.
Code of Conduct
Be respectful and constructive. We're all here to make @sylphx/cat better!
Thank you for contributing! 🐱