Development
Gitorial Development
Join the Gitorial community and contribute to building the future of interactive coding education. This guide covers everything you need to know to contribute to the Gitorial VS Code extension.
Quick Start
Prerequisites
- Node.js: v20 or higher
- pnpm: v10 or higher
- VS Code: v1.87 or higher
- Git: Latest version
Development Setup
# 1. Clone the repositorygit clone https://github.com/gitorial-sdk/gitorial-vscode.gitcd gitorial-vscode
# 2. Install dependenciespnpm install
# 3. Start development modepnpm run dev
# 4. Open in VS Code for developmentcode .
# 5. Press F5 to run in Extension Development HostArchitecture Overview
Gitorial follows a Clean Architecture pattern with three distinct layers:
1. UI Layer (src/ui/)
Orchestrates user interactions between VS Code APIs and domain services.
Key Modules:
- Tutorial Controller (
src/ui/tutorial/): Manages tutorial lifecycle, navigation, and webview communication - Webview Manager (
src/ui/webview/): Handles panel management and extension-webview communication - System Operations (
src/ui/system/): Extension-wide operations and global commands
2. Domain Layer (src/domain/)
Contains core business logic independent of UI and infrastructure concerns.
Key Modules:
- Models:
Tutorial,Step,EnrichedStep(core entities) - Services:
TutorialService,TutorialBuilder,DiffService(business logic) - Repositories: Data persistence interfaces
- Ports: External dependency interfaces
3. Infrastructure Layer (src/infrastructure/)
Implements domain ports and handles VS Code APIs and external systems.
Key Modules:
- Adapters: Concrete implementations of domain ports
- Repositories: Data persistence implementations
- Factories: Component creation and dependency injection
Development Patterns
Message-Driven Communication
The webview and extension communicate through strongly-typed messages:
// Messages defined in packages/shared-types/src/ui/messages/interface TutorialMessage { type: 'step-navigation' | 'content-update' | 'progress-sync'; payload: any;}Modular Controllers
Tutorial functionality is split across focused controllers:
lifecycle.ts: Loading, initialization, cleanupnavigation.ts: Step navigation and progress trackingwebview.ts: Panel management and communicationeditor.ts: VS Code editor integration
Resource Management
Dedicated managers handle VS Code resources:
- EditorManager: VS Code editor tabs and diff views
- WebviewPanelManager: Webview panel lifecycle
- TabTrackingService: Open tab tracking per step
Adding New Features
1. Define the Interface
Add the interface to src/domain/ports/:
export interface ICustomFeature { execute(data: CustomData): Promise<CustomResult>;}2. Implement Business Logic
Add the service to src/domain/services/:
export class CustomFeatureService { async execute(data: CustomData): Promise<CustomResult> { // Business logic here }}3. Create the Adapter
Implement the port in src/infrastructure/adapters/:
export class CustomFeatureAdapter implements ICustomFeature { async execute(data: CustomData): Promise<CustomResult> { // VS Code API integration }}4. Wire Up the UI
Connect everything in src/ui/tutorial/controller/:
// Add to the main controllerthis.customFeature = new CustomFeatureService( new CustomFeatureAdapter());Testing
Running Tests
# Run all testspnpm run test
# Run unit tests onlypnpm run test:unit
# Run integration tests onlypnpm run test:integration
# Run with coveragepnpm run test:coverageTest Structure
- Unit Tests: Located alongside source files (
*.test.ts) - Integration Tests: Located in
src/test/ - Framework: Mocha + Chai
Writing Tests
import { expect } from 'chai';import { CustomFeatureService } from './CustomFeatureService';
describe('CustomFeatureService', () => { it('should execute custom feature', async () => { const service = new CustomFeatureService(); const result = await service.execute(testData); expect(result).to.deep.equal(expectedResult); });});Building & Packaging
Development Build
# Build for developmentpnpm run build
# Build and watch for changespnpm run devProduction Build
# Create production buildpnpm run build
# Package as .vsixpnpm run packageBuild Process
- TypeScript Compilation: Source code compiled to JavaScript
- Webview Build: Svelte frontend bundled with Vite
- Extension Bundle: Everything packaged with esbuild
- VSIX Creation: Final
.vsixpackage for distribution
Code Style & Quality
Linting
# Check code stylepnpm run lint
# Fix auto-fixable issuespnpm run lint:fixType Checking
# Run TypeScript type checkingpnpm run typecheckCode Style Guidelines
- Follow existing TypeScript/Svelte conventions
- Use meaningful variable and function names
- Write self-documenting code with clear intent
- Follow the Clean Architecture dependency rules
Contributing Workflow
1. Choose an Issue
- Browse GitHub Issues
- Look for issues labeled
good first issueorhelp wanted - Comment on issues you’re interested in
2. Create a Branch
git checkout -b feature/amazing-new-feature3. Make Changes
- Follow the established code patterns
- Add tests for new functionality
- Update documentation if needed
4. Test Thoroughly
pnpm run testpnpm run lintpnpm run typecheck5. Submit a Pull Request
- Push your branch to GitHub
- Create a detailed pull request description
- Reference related issues
- Be responsive to feedback
Educational Content Detection
The extension automatically detects educational patterns in code:
// These patterns trigger special handlingconst EDUCATIONAL_PATTERNS = [ 'TODO:', 'FIXME:', 'unimplemented!()', 'todo!()', '???', '/* ... implement ... */'];Performance Considerations
Optimization Guidelines
- Lazy Loading: Load heavy operations only when needed
- Debouncing: Debounce frequent operations like file watching
- Memory Management: Properly dispose of VS Code resources
- Bundle Size: Monitor and optimize extension bundle size
Debugging Performance
- Use VS Code’s built-in performance tools
- Monitor memory usage in Extension Development Host
- Profile slow operations with built-in timers
Resources & Support
Documentation
Community
- GitHub Issues - Bug reports and feature requests
- Discussions - Community discussions
Getting Help
- Check existing issues for similar problems
- Search the codebase for related functionality
- Ask questions in GitHub Discussions
Version History
v0.2.2 (Current)
- Enhanced tutorial navigation
- Improved content rendering
- Better VS Code integration
- Performance optimizations
v0.2.1
- Bug fixes and stability improvements
- Enhanced error handling
- Updated dependencies
v0.2.0
- Major architecture improvements
- New tutorial features
- Enhanced developer experience
Thank you for your interest in contributing to Gitorial! Your contributions help make interactive learning more accessible for developers worldwide.