Contributing
We welcome contributions to @selfagency/llm-stream-parser! This guide explains how to contribute.
Getting Started
- Fork the repository on GitHub
- Clone your fork locally
- Follow the Developer Guide for setup
Development Process
Creating a feature branch
bash
git checkout -b feat/your-feature-nameBranch naming conventions:
feat/- New featuresfix/- Bug fixesdocs/- Documentationtest/- Test additionsrefactor/- Code refactoring
Making changes
- Create focused, atomic commits
- Write clear commit messages
- Add tests alongside code changes
- Update documentation if needed
Code style
Our code style is enforced by tools:
bash
# Check formatting and linting
task check-all
# Auto-fix issues
task precommitTools used:
- Linting: oxlint (and oxlint-tsgolint for TypeScript)
- Formatting: oxfmt
- Type checking: TypeScript
Testing
All changes must include tests:
bash
# Run tests
task unit-tests
# Run with coverage
task unit-test-coverageTest structure:
- Colocate tests with source files (
.test.ts) - Test streaming behavior with partial chunks
- Verify safety rails (limits, scrubbing)
- Test error cases and edge cases
Submitting Changes
Pull Request Process
Before opening: Ensure local checks pass
bashtask check-all task unit-testsCreate PR with:
- Clear title describing the change
- Description of what and why
- Link any related issues
- Screenshots/examples if applicable
Address feedback: Update PR based on review comments
Merge: Maintainers will merge after approval
PR Title Format
Follow conventional commits:
feat: add support for custom tag namesfix: resolve JSON parsing with deep nestingdocs: update API reference examplestest: add coverage for streaming edge cases
Types of Contributions
Bug Reports
File issues with:
- Clear description of the bug
- Steps to reproduce
- Expected vs actual behavior
- Environment details (Node version, OS)
- Minimal code example
Feature Requests
Describe:
- Use case and motivation
- Expected behavior
- Potential implementation approach
- Any concerns or trade-offs
Documentation
Improvements to:
- README.md
- docs/ guides
- API reference
- Code comments
- Examples
Parser Improvements
- Better error messages
- Performance optimizations
- New parser utilities
- Adapter improvements
Testing Guidelines
What to test
- Normal operation with various inputs
- Edge cases (empty strings, deeply nested structures)
- Error cases (malformed input, limits exceeded)
- Streaming behavior (partial chunks, boundaries)
- Integration between parsers
Example test structure
typescript
import { describe, it, expect } from 'vitest';
import { parseJson } from '../index';
describe('parseJson', () => {
it('should parse valid JSON', () => {
const result = parseJson('{"key": "value"}');
expect(result.valid).toBe(true);
expect(result.data).toEqual({ key: 'value' });
});
it('should handle malformed JSON', () => {
const result = parseJson('{invalid}');
expect(result.valid).toBe(false);
expect(result.error).toBeDefined();
});
it('should enforce max depth limit', () => {
const deep = '{"a":' + '{"b":'.repeat(10) + '1' + '}'.repeat(11);
const result = parseJson(deep, { maxDepth: 5 });
expect(result.valid).toBe(false);
});
});Commit Messages
Write clear, descriptive commits:
text
Short summary (50 chars max)
Longer explanation of the change if needed.
Explain the why, not just the what.
Fixes #123
Related to #456Questions?
- Check the Developer Guide
- Review existing issues and PRs
- Open a discussion on GitHub
- Ask in the PR review
Thank you for contributing!