Contributing
Thank you for your interest in contributing to LSJI!
Development Setup
# Clone the repository
git clone https://github.com/ryotagtagtag-wq/LSJI.git
cd LSJI
# Install dependencies
npm install
# Run tests
npm test
# Build documentation
cd docs && npm run build
Project Structure
LSJI/
├── src/ # Core library
│ ├── core/ # QLearning, Agent, Env
│ ├── storage/ # Storage backends
│ ├── envs/ # Built-in environments
│ ├── cli.ts # CLI
│ └── index.ts # Public exports
├── test/ # Vitest tests
├── docs/ # Docusaurus documentation
└── bin/ # CLI entry point
Making Changes
1. Create a Branch
git checkout -b feature/my-feature
2. Make Changes
Follow the existing code style:
- TypeScript with JSDoc comments
- ESM imports/exports
- No external dependencies in core
3. Run Tests
npm test
4. Update Documentation
If you add new features, update relevant docs in docs/docs/.
5. Commit
git add .
git commit -m "feat: add my feature"
Commit Message Format:
feat:— New featurefix:— Bug fixdocs:— Documentationrefactor:— Code refactoringtest:— Testschore:— Maintenance
6. Push and Create PR
git push origin feature/my-feature
Adding a New Environment
- Create
src/envs/my-env.tsextendingEnv - Implement all abstract methods
- Export from
src/index.ts - Add documentation in
docs/docs/api/environments.md - Add example in
docs/docs/examples/
Adding a New Storage Backend
- Create
src/storage/my-backend.tsextendingStorage - Implement all abstract methods
- Add to
createStoragefactory insrc/storage/index.ts - Export from
src/index.ts - Add tests in
test/storage/
Modifying Learning Algorithm
- Extend
QLearningclass or create new class insrc/core/ - Maintain compatibility with
Agentinterface - Add tests for new algorithm
- Document in
docs/docs/api/
Code Style
- TypeScript with strict mode
- ESM modules (
import/export) - JSDoc for all public APIs
- No
anyunless absolutely necessary - Async/await for async operations
Testing Guidelines
- Use
MemoryStoragefor unit tests - Test both success and error cases
- Test edge cases (empty Q-table, terminal states)
- Keep tests fast and isolated
// Example test structure
import { describe, it, expect, beforeEach } from 'vitest';
import { MyFeature } from '../src/core/my-feature';
import { MemoryStorage } from '../src/storage/memory';
describe('MyFeature', () => {
let storage;
let feature;
beforeEach(async () => {
storage = new MemoryStorage();
await storage.initialize();
feature = new MyFeature({ storage });
});
it('should do something', async () => {
const result = await feature.doSomething();
expect(result).toBe(expected);
});
});
Documentation
- Update relevant
.mdfiles indocs/docs/ - Add JSDoc comments for new public APIs
- Include code examples
License
By contributing, you agree that your contributions will be licensed under the Apache 2.0 License.
Questions?
- Open a GitHub Issue
- Start a Discussion