Thank you for your interest in contributing to Morphkit! This guide will help you get set up and productive.
- Bun 1.0+ (primary runtime and test runner)
- Node.js 18+ (for compatibility)
- TypeScript 5.7+ (strict mode enforced)
# Clone your fork
git clone https://github.com/<your-username>/morphkit.git
cd morphkit
# Install dependencies
bun install
# Run tests
bun test
# Type-check
bun run typecheckVerify everything passes before making changes.
Morphkit uses a three-stage pipeline:
CLI → Analyzer → Semantic Model → Generator
- Analyzer (
src/analyzer/) — Parses TypeScript/React source using ts-morph. Extracts components, routes, state, and API calls. - Semantic Model (
src/semantic/) — Transforms analyzer output into a framework-agnosticSemanticAppModel, then adapts it for iOS patterns. - Generator (
src/generator/) — Produces SwiftUI views, models, navigation, and networking code from the semantic model.
Each stage is independent and independently testable. The SemanticAppModel is the boundary between analysis and generation.
- Strict mode is enforced (
bun run typecheckmust pass with zero errors). - Use
constby default. Useletonly when reassignment is necessary. - Prefer explicit return types on exported functions.
All shared types are defined as Zod schemas in src/semantic/model.ts and inferred via z.infer<>. This is the single source of truth.
// Correct: define the schema, infer the type
export const ScreenSchema = z.object({ ... });
export type Screen = z.infer<typeof ScreenSchema>;
// Incorrect: defining standalone interfaces for shared types
export interface Screen { ... }When adding new fields, update the Zod schema in model.ts first, then update the builder and generators.
- Analyzers have their own types (
ExtractedComponent,ExtractedRoute, etc.) that are mapped to semantic model types in the builder. - Generators must conform to model types, not define their own.
- Reuse the
typeDefToSwift()function inswiftui-generator.tsfor TypeScript-to-Swift type conversion. Do not duplicate it.
- All existing tests must pass before submitting a PR.
- Add tests for any new feature or bug fix.
- Tests should verify generated output structure, not exact string matches.
test/
├── analyzer/ # Unit tests for each extractor
├── semantic/ # Builder tests
├── generator/ # Generator output tests
├── e2e/ # Full pipeline integration tests
└── __fixtures__/ # Sample Next.js app for integration tests
bun test # Run all tests
bun test test/analyzer/ # Run analyzer tests only
bun run typecheck # TypeScript strict checkingUse test/__fixtures__/ for integration test data. The fixture directory contains a sample Next.js e-commerce app that exercises the full pipeline. Add new fixture files there when testing new patterns.
- Fork the repository and create a feature branch from
main. - Branch naming:
feat/description,fix/description, ordocs/description. - Make your changes following the code style guidelines above.
- Test: Run
bun testandbun run typecheck. Both must pass. - Commit with clear, descriptive messages.
- Open a PR against
mainwith:- A summary of what changed and why.
- How to test the changes.
- Any relevant issue numbers.
PRs require review before merging. Maintainers may request changes.
Morphkit is designed to be extensible. To add support for a new source framework (e.g., Vue, Svelte) or a new generation target:
- Add extractors in
src/analyzer/following the pattern of existing extractors (component, route, state, API). - Update
src/analyzer/repo-scanner.tsto detect the framework. - Map extracted data to the existing
SemanticAppModeltypes insrc/semantic/builder.ts. - Add fixture files in
test/__fixtures__/and write tests.
- Add a new generator directory under
src/generator/. - Consume the
SemanticAppModel— do not add analyzer-specific logic to generators. - Add templates in
templates/if needed. - Write tests that verify output structure.
- Add the pattern to the appropriate Zod schema in
src/semantic/model.ts. - Update the adapter in
src/semantic/adapter.tsto map web patterns to the new pattern. - Add generation logic in the relevant generator.
- Add test coverage.
Open an issue on GitHub or start a discussion. We're happy to help.