morphkit-cli 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +145 -0
- package/README.md +321 -20
- package/dist/index.js +1165 -381
- package/dist/mcp/server.js +289704 -0
- package/package.json +31 -8
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Contributing to Morphkit
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to Morphkit! This guide will help you get set up and productive.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- **Bun** 1.0+ (primary runtime and test runner)
|
|
8
|
+
- **Node.js** 18+ (for compatibility)
|
|
9
|
+
- **TypeScript** 5.7+ (strict mode enforced)
|
|
10
|
+
|
|
11
|
+
## Getting Started
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Clone your fork
|
|
15
|
+
git clone https://github.com/<your-username>/morphkit.git
|
|
16
|
+
cd morphkit
|
|
17
|
+
|
|
18
|
+
# Install dependencies
|
|
19
|
+
bun install
|
|
20
|
+
|
|
21
|
+
# Run tests
|
|
22
|
+
bun test
|
|
23
|
+
|
|
24
|
+
# Type-check
|
|
25
|
+
bun run typecheck
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Verify everything passes before making changes.
|
|
29
|
+
|
|
30
|
+
## Architecture Overview
|
|
31
|
+
|
|
32
|
+
Morphkit uses a three-stage pipeline:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
CLI → Analyzer → Semantic Model → Generator
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
1. **Analyzer** (`src/analyzer/`) — Parses TypeScript/React source using ts-morph. Extracts components, routes, state, and API calls.
|
|
39
|
+
2. **Semantic Model** (`src/semantic/`) — Transforms analyzer output into a framework-agnostic `SemanticAppModel`, then adapts it for iOS patterns.
|
|
40
|
+
3. **Generator** (`src/generator/`) — Produces SwiftUI views, models, navigation, and networking code from the semantic model.
|
|
41
|
+
|
|
42
|
+
Each stage is independent and independently testable. The `SemanticAppModel` is the boundary between analysis and generation.
|
|
43
|
+
|
|
44
|
+
## Code Style
|
|
45
|
+
|
|
46
|
+
### TypeScript
|
|
47
|
+
|
|
48
|
+
- Strict mode is enforced (`bun run typecheck` must pass with zero errors).
|
|
49
|
+
- Use `const` by default. Use `let` only when reassignment is necessary.
|
|
50
|
+
- Prefer explicit return types on exported functions.
|
|
51
|
+
|
|
52
|
+
### Zod-First Types
|
|
53
|
+
|
|
54
|
+
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.
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
// Correct: define the schema, infer the type
|
|
58
|
+
export const ScreenSchema = z.object({ ... });
|
|
59
|
+
export type Screen = z.infer<typeof ScreenSchema>;
|
|
60
|
+
|
|
61
|
+
// Incorrect: defining standalone interfaces for shared types
|
|
62
|
+
export interface Screen { ... }
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
When adding new fields, update the Zod schema in `model.ts` first, then update the builder and generators.
|
|
66
|
+
|
|
67
|
+
### Pipeline Conventions
|
|
68
|
+
|
|
69
|
+
- Analyzers have their own types (`ExtractedComponent`, `ExtractedRoute`, etc.) that are mapped to semantic model types in the builder.
|
|
70
|
+
- Generators must conform to model types, not define their own.
|
|
71
|
+
- Reuse the `typeDefToSwift()` function in `swiftui-generator.ts` for TypeScript-to-Swift type conversion. Do not duplicate it.
|
|
72
|
+
|
|
73
|
+
## Testing
|
|
74
|
+
|
|
75
|
+
### Requirements
|
|
76
|
+
|
|
77
|
+
- All existing tests must pass before submitting a PR.
|
|
78
|
+
- Add tests for any new feature or bug fix.
|
|
79
|
+
- Tests should verify generated output structure, not exact string matches.
|
|
80
|
+
|
|
81
|
+
### Test Structure
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
test/
|
|
85
|
+
├── analyzer/ # Unit tests for each extractor
|
|
86
|
+
├── semantic/ # Builder tests
|
|
87
|
+
├── generator/ # Generator output tests
|
|
88
|
+
├── e2e/ # Full pipeline integration tests
|
|
89
|
+
└── __fixtures__/ # Sample Next.js app for integration tests
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Running Tests
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
bun test # Run all tests
|
|
96
|
+
bun test test/analyzer/ # Run analyzer tests only
|
|
97
|
+
bun run typecheck # TypeScript strict checking
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Integration Tests
|
|
101
|
+
|
|
102
|
+
Use `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.
|
|
103
|
+
|
|
104
|
+
## Pull Request Process
|
|
105
|
+
|
|
106
|
+
1. **Fork** the repository and create a feature branch from `main`.
|
|
107
|
+
2. **Branch naming**: `feat/description`, `fix/description`, or `docs/description`.
|
|
108
|
+
3. **Make your changes** following the code style guidelines above.
|
|
109
|
+
4. **Test**: Run `bun test` and `bun run typecheck`. Both must pass.
|
|
110
|
+
5. **Commit** with clear, descriptive messages.
|
|
111
|
+
6. **Open a PR** against `main` with:
|
|
112
|
+
- A summary of what changed and why.
|
|
113
|
+
- How to test the changes.
|
|
114
|
+
- Any relevant issue numbers.
|
|
115
|
+
|
|
116
|
+
PRs require review before merging. Maintainers may request changes.
|
|
117
|
+
|
|
118
|
+
## Adding Support for New Frameworks
|
|
119
|
+
|
|
120
|
+
Morphkit is designed to be extensible. To add support for a new source framework (e.g., Vue, Svelte) or a new generation target:
|
|
121
|
+
|
|
122
|
+
### New Source Framework
|
|
123
|
+
|
|
124
|
+
1. Add extractors in `src/analyzer/` following the pattern of existing extractors (component, route, state, API).
|
|
125
|
+
2. Update `src/analyzer/repo-scanner.ts` to detect the framework.
|
|
126
|
+
3. Map extracted data to the existing `SemanticAppModel` types in `src/semantic/builder.ts`.
|
|
127
|
+
4. Add fixture files in `test/__fixtures__/` and write tests.
|
|
128
|
+
|
|
129
|
+
### New Generation Target
|
|
130
|
+
|
|
131
|
+
1. Add a new generator directory under `src/generator/`.
|
|
132
|
+
2. Consume the `SemanticAppModel` — do not add analyzer-specific logic to generators.
|
|
133
|
+
3. Add templates in `templates/` if needed.
|
|
134
|
+
4. Write tests that verify output structure.
|
|
135
|
+
|
|
136
|
+
### New Layout or View Pattern
|
|
137
|
+
|
|
138
|
+
1. Add the pattern to the appropriate Zod schema in `src/semantic/model.ts`.
|
|
139
|
+
2. Update the adapter in `src/semantic/adapter.ts` to map web patterns to the new pattern.
|
|
140
|
+
3. Add generation logic in the relevant generator.
|
|
141
|
+
4. Add test coverage.
|
|
142
|
+
|
|
143
|
+
## Questions?
|
|
144
|
+
|
|
145
|
+
Open an issue on [GitHub](https://github.com/ashlrai/morphkit/issues) or start a discussion. We're happy to help.
|
package/README.md
CHANGED
|
@@ -4,30 +4,110 @@
|
|
|
4
4
|
|
|
5
5
|
Morphkit is a semantic AI agent that understands your TypeScript/React web app's *intent* — not just its code — and generates a production-quality SwiftUI Xcode project. It parses your components, routes, state, and API calls, builds a framework-agnostic semantic model, then emits idiomatic Swift targeting iOS 17+.
|
|
6
6
|
|
|
7
|
-
[](https://www.npmjs.com/package/morphkit)
|
|
7
|
+
[](https://www.npmjs.com/package/morphkit-cli)
|
|
8
8
|
[](LICENSE)
|
|
9
|
+
[](https://github.com/ashlrai/morphkit/actions)
|
|
9
10
|
|
|
10
|
-
**[morphkit.dev](https://morphkit.dev)** | **[GitHub](https://github.com/ashlrai/morphkit)** | **[Issues](https://github.com/ashlrai/morphkit/issues)**
|
|
11
|
+
**[morphkit.dev](https://morphkit.dev)** | **[Docs](https://morphkit.dev/docs)** | **[GitHub](https://github.com/ashlrai/morphkit)** | **[Issues](https://github.com/ashlrai/morphkit/issues)**
|
|
11
12
|
|
|
12
13
|
---
|
|
13
14
|
|
|
14
15
|
## Quick Start
|
|
15
16
|
|
|
16
17
|
```bash
|
|
17
|
-
#
|
|
18
|
-
|
|
18
|
+
# 1. See what Morphkit will build (always free)
|
|
19
|
+
npx morphkit-cli plan ./my-webapp
|
|
19
20
|
|
|
20
|
-
#
|
|
21
|
-
|
|
21
|
+
# 2. Generate a full SwiftUI Xcode project
|
|
22
|
+
npx morphkit-cli generate ./my-webapp -o ./ios-app
|
|
22
23
|
|
|
23
|
-
#
|
|
24
|
-
|
|
24
|
+
# 3. Auto-complete all TODOs with AI (uses your Claude API key)
|
|
25
|
+
npx morphkit-cli complete ./ios-app
|
|
25
26
|
|
|
26
|
-
#
|
|
27
|
-
|
|
27
|
+
# 4. Build and run
|
|
28
|
+
cd ios-app && swift build
|
|
29
|
+
open Package.swift # Opens in Xcode
|
|
28
30
|
```
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
Morphkit auto-detects your backend stack (Supabase, Stripe, SSE streaming, etc.)
|
|
33
|
+
and generates the right iOS SDK integrations. No configuration needed.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Using with Claude Code
|
|
38
|
+
|
|
39
|
+
Morphkit generates everything Claude Code needs to complete the iOS app screen-by-screen:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# 1. Generate the iOS project
|
|
43
|
+
npx morphkit generate ./my-nextjs-app --output ./ios-app
|
|
44
|
+
|
|
45
|
+
# 2. Register the MCP server in Claude Code
|
|
46
|
+
npx morphkit setup
|
|
47
|
+
|
|
48
|
+
# 3. Open in Claude Code and complete everything
|
|
49
|
+
cd ios-app
|
|
50
|
+
# Run /complete-all to wire up every screen
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### What gets generated for AI
|
|
54
|
+
|
|
55
|
+
| File | Purpose |
|
|
56
|
+
|------|---------|
|
|
57
|
+
| `CLAUDE.md` | Implementation guide with API contract, Swift conventions, completion manifest |
|
|
58
|
+
| `.claude/commands/` | Slash commands: `/complete-screen`, `/verify`, `/next`, `/complete-all` |
|
|
59
|
+
| `.claude/settings.json` | Auto-registers the MCP server so tools are available immediately |
|
|
60
|
+
|
|
61
|
+
### MCP Tools
|
|
62
|
+
|
|
63
|
+
| Tool | Description |
|
|
64
|
+
|------|-------------|
|
|
65
|
+
| `morphkit_analyze` | Analyze a web app and return its semantic model |
|
|
66
|
+
| `morphkit_generate` | Generate a complete SwiftUI project from a web app |
|
|
67
|
+
| `morphkit_plan` | Generate a prioritized implementation plan |
|
|
68
|
+
| `morphkit_screen_context` | Get full context for completing a specific screen |
|
|
69
|
+
| `morphkit_verify` | Check project completion: build status, TODO census, completion % |
|
|
70
|
+
| `morphkit_next_task` | Get the next recommended screen to implement |
|
|
71
|
+
| `morphkit_completion_status` | Machine-readable JSON with exact TODO locations for automated loops |
|
|
72
|
+
| `morphkit_complete_screen` | Full context for completing a single screen (view, API, models, reference) |
|
|
73
|
+
| `morphkit_fix_build_error` | Parse Swift build errors and return structured context for fixes |
|
|
74
|
+
|
|
75
|
+
### Plan Command
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Analyze your app and get a comprehensive iOS conversion plan (always free)
|
|
79
|
+
npx morphkit plan ./my-webapp
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Complete Command
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Auto-complete all MORPHKIT-TODOs using Claude API
|
|
86
|
+
npx morphkit complete ./ios-app
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Doctor Command
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Diagnose your Morphkit configuration
|
|
93
|
+
npx morphkit doctor
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Verify Command
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
npx morphkit verify ./ios-app
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
Build: ✓ pass (0 errors)
|
|
104
|
+
TODOs: 12 remaining (wire-api-fetch: 8, wire-api-action: 4)
|
|
105
|
+
Screens: 4/6 complete (67%)
|
|
106
|
+
API: 6/8 endpoints wired (75%)
|
|
107
|
+
Models: 5/5 complete (100%)
|
|
108
|
+
Overall: 72% complete
|
|
109
|
+
Next: Complete CartView — 3 TODOs remaining
|
|
110
|
+
```
|
|
31
111
|
|
|
32
112
|
---
|
|
33
113
|
|
|
@@ -71,11 +151,28 @@ Every generated file includes a source mapping comment tracing back to the origi
|
|
|
71
151
|
- **API client generation** — `fetch` calls and API routes become a typed `URLSession` networking layer with `async/await`.
|
|
72
152
|
- **Confidence scoring** — Every generated file is tagged high/medium/low confidence so you know what to review first.
|
|
73
153
|
- **Preview data factories** — `#if DEBUG` extensions with `.preview()` methods for every model, so SwiftUI previews work out of the box.
|
|
74
|
-
- **AI-enhanced analysis (optional)** — Connect
|
|
154
|
+
- **AI-enhanced analysis (optional)** — Connect Claude, OpenAI, or Grok for deeper intent extraction, smarter component mapping, and navigation planning.
|
|
75
155
|
- **Zero runtime dependencies** — Generated Swift code uses only Foundation and SwiftUI. No third-party pods or packages.
|
|
76
156
|
|
|
77
157
|
---
|
|
78
158
|
|
|
159
|
+
## Auto-Detected Integrations
|
|
160
|
+
|
|
161
|
+
Morphkit automatically detects your backend services and generates the right iOS SDK integration:
|
|
162
|
+
|
|
163
|
+
| Web Service | iOS Output | Detection |
|
|
164
|
+
|-------------|-----------|-----------|
|
|
165
|
+
| Supabase | Supabase Swift SDK (`SupabaseManager.swift`) | `@supabase/supabase-js` in package.json |
|
|
166
|
+
| Stripe | WKWebView Checkout (`PaymentManager.swift`) | `stripe` in package.json |
|
|
167
|
+
| SSE Streaming | URLSession AsyncBytes (`SSEClient.swift`) | `text/event-stream` in API routes |
|
|
168
|
+
| react-markdown | MarkdownUI package | `react-markdown` in package.json |
|
|
169
|
+
| Firebase | Firebase iOS SDK | `firebase` in package.json |
|
|
170
|
+
| Clerk | Clerk iOS | `@clerk/nextjs` in package.json |
|
|
171
|
+
|
|
172
|
+
No configuration needed — Morphkit reads your `package.json` and source files to determine what to generate.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
79
176
|
## How It Works
|
|
80
177
|
|
|
81
178
|
Morphkit runs a three-stage pipeline:
|
|
@@ -309,6 +406,82 @@ bunx morphkit preview ./my-app --screen Products
|
|
|
309
406
|
|--------|-------------|
|
|
310
407
|
| `-s, --screen <name>` | Preview only files matching a specific screen name |
|
|
311
408
|
|
|
409
|
+
### `morphkit verify <path>`
|
|
410
|
+
|
|
411
|
+
Check completion status of a generated iOS project.
|
|
412
|
+
|
|
413
|
+
```bash
|
|
414
|
+
bunx morphkit verify ./ios-app
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
Reports build status, TODO census by category, screen/API/model completion percentages, and recommends the next step.
|
|
418
|
+
|
|
419
|
+
### `morphkit setup`
|
|
420
|
+
|
|
421
|
+
Register the Morphkit MCP server in Claude Code's settings.
|
|
422
|
+
|
|
423
|
+
```bash
|
|
424
|
+
bunx morphkit setup
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
Writes to `.claude/settings.json` so Claude Code can call `morphkit_analyze`, `morphkit_verify`, etc. directly.
|
|
428
|
+
|
|
429
|
+
### `morphkit sync <source> <target>`
|
|
430
|
+
|
|
431
|
+
Re-sync a generated iOS project after changes to the source web app.
|
|
432
|
+
|
|
433
|
+
```bash
|
|
434
|
+
bunx morphkit sync ./my-nextjs-app ./ios-app
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
### `morphkit watch <path>`
|
|
438
|
+
|
|
439
|
+
Watch a web app directory and re-generate on changes.
|
|
440
|
+
|
|
441
|
+
```bash
|
|
442
|
+
bunx morphkit watch ./my-nextjs-app --output ./ios-app
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
### `morphkit plan <path>`
|
|
446
|
+
|
|
447
|
+
Analyze a web app and generate a comprehensive iOS conversion plan. Always free — no API key required.
|
|
448
|
+
|
|
449
|
+
```bash
|
|
450
|
+
npx morphkit-cli plan ./my-webapp
|
|
451
|
+
npx morphkit-cli plan ./my-webapp --output plan.md
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
| Option | Description |
|
|
455
|
+
|--------|-------------|
|
|
456
|
+
| `-o, --output <file>` | Write the plan to a file instead of stdout |
|
|
457
|
+
|
|
458
|
+
### `morphkit complete <project-path>`
|
|
459
|
+
|
|
460
|
+
Auto-complete all MORPHKIT-TODOs in a generated iOS project using the Claude API.
|
|
461
|
+
|
|
462
|
+
```bash
|
|
463
|
+
npx morphkit-cli complete ./ios-app
|
|
464
|
+
npx morphkit-cli complete ./ios-app --model claude-sonnet-4-6 --max-iterations 30
|
|
465
|
+
npx morphkit-cli complete ./ios-app --dry-run
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
| Option | Description |
|
|
469
|
+
|--------|-------------|
|
|
470
|
+
| `--model <model>` | Claude model to use (default: `claude-sonnet-4-6`) |
|
|
471
|
+
| `--max-iterations <n>` | Maximum completion iterations (default: `30`) |
|
|
472
|
+
| `--dry-run` | Preview changes without writing files |
|
|
473
|
+
| `-v, --verbose` | Show detailed completion output |
|
|
474
|
+
|
|
475
|
+
### `morphkit doctor`
|
|
476
|
+
|
|
477
|
+
Diagnose Morphkit configuration and environment.
|
|
478
|
+
|
|
479
|
+
```bash
|
|
480
|
+
npx morphkit-cli doctor
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
Checks: Bun runtime, Swift toolchain, API keys, config file, MCP server registration.
|
|
484
|
+
|
|
312
485
|
---
|
|
313
486
|
|
|
314
487
|
## Configuration
|
|
@@ -317,11 +490,33 @@ bunx morphkit preview ./my-app --screen Products
|
|
|
317
490
|
|
|
318
491
|
| Variable | Required | Description |
|
|
319
492
|
|----------|----------|-------------|
|
|
320
|
-
| `
|
|
493
|
+
| `ANTHROPIC_API_KEY` | No | Anthropic API key for Claude-powered analysis (recommended) |
|
|
494
|
+
| `OPENAI_API_KEY` | No | OpenAI API key for GPT-powered analysis |
|
|
495
|
+
| `XAI_API_KEY` | No | xAI API key for Grok-powered analysis |
|
|
496
|
+
| `MORPHKIT_API_KEY` | No | Morphkit API key for cloud features and usage metering |
|
|
497
|
+
|
|
498
|
+
### AI Provider Configuration
|
|
499
|
+
|
|
500
|
+
Morphkit supports multiple AI providers for enhanced analysis. The AI layer is fully optional — all core functionality works without it using heuristic-based analysis.
|
|
501
|
+
|
|
502
|
+
```bash
|
|
503
|
+
# Use Claude (recommended)
|
|
504
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
505
|
+
morphkit generate ./app --ai-provider claude
|
|
506
|
+
|
|
507
|
+
# Use OpenAI
|
|
508
|
+
export OPENAI_API_KEY=sk-...
|
|
509
|
+
morphkit generate ./app --ai-provider openai
|
|
321
510
|
|
|
322
|
-
|
|
511
|
+
# Use Grok
|
|
512
|
+
export XAI_API_KEY=xai-...
|
|
513
|
+
morphkit generate ./app --ai-provider grok
|
|
323
514
|
|
|
324
|
-
|
|
515
|
+
# Disable AI (heuristics only)
|
|
516
|
+
morphkit generate ./app --no-ai
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
When an AI provider is configured, Morphkit uses it to:
|
|
325
520
|
|
|
326
521
|
- **Analyze intent** — understand *why* a component exists, not just what it renders
|
|
327
522
|
- **Map components** — intelligently match React patterns to SwiftUI equivalents
|
|
@@ -329,7 +524,7 @@ When `XAI_API_KEY` is set, Morphkit can use xAI Grok to:
|
|
|
329
524
|
- **Architect state** — recommend `@Observable` store structure based on your Zustand/Redux/Context patterns
|
|
330
525
|
- **Generate code** — produce more nuanced SwiftUI for complex screen layouts
|
|
331
526
|
|
|
332
|
-
|
|
527
|
+
If multiple API keys are set, Morphkit auto-detects the best available provider. You can override with `--ai-provider`.
|
|
333
528
|
|
|
334
529
|
---
|
|
335
530
|
|
|
@@ -338,8 +533,8 @@ The AI layer is fully optional. All core functionality works without it.
|
|
|
338
533
|
| Framework | Status | Notes |
|
|
339
534
|
|-----------|--------|-------|
|
|
340
535
|
| Next.js App Router | Supported | Full support for file-based routing, layouts, loading states, API routes |
|
|
341
|
-
| Next.js Pages Router |
|
|
342
|
-
| React + Vite |
|
|
536
|
+
| Next.js Pages Router | Partial | Route detection, component/state extraction, generation working |
|
|
537
|
+
| React + Vite | Partial | Component/state extraction, React Router detection working |
|
|
343
538
|
| React + CRA | Planned | Same as Vite support |
|
|
344
539
|
|
|
345
540
|
### Supported Web Patterns
|
|
@@ -409,7 +604,7 @@ bun install
|
|
|
409
604
|
### Commands
|
|
410
605
|
|
|
411
606
|
```bash
|
|
412
|
-
# Run all tests (
|
|
607
|
+
# Run all tests (263 tests, 1422 assertions)
|
|
413
608
|
bun test
|
|
414
609
|
|
|
415
610
|
# TypeScript strict type checking
|
|
@@ -432,7 +627,7 @@ The test suite covers the full pipeline with a sample Next.js e-commerce app (`t
|
|
|
432
627
|
- **Swift quality tests** — Validates generated code compiles and follows iOS conventions
|
|
433
628
|
|
|
434
629
|
```
|
|
435
|
-
|
|
630
|
+
263 pass | 0 fail | 1422 expect() calls
|
|
436
631
|
```
|
|
437
632
|
|
|
438
633
|
### Project Conventions
|
|
@@ -444,6 +639,112 @@ The test suite covers the full pipeline with a sample Next.js e-commerce app (`t
|
|
|
444
639
|
|
|
445
640
|
---
|
|
446
641
|
|
|
642
|
+
## Authentication
|
|
643
|
+
|
|
644
|
+
Morphkit uses API keys for authentication and usage metering.
|
|
645
|
+
|
|
646
|
+
```bash
|
|
647
|
+
# Set your API key as an environment variable
|
|
648
|
+
export MORPHKIT_API_KEY=morphkit_sk_your_key_here
|
|
649
|
+
|
|
650
|
+
# Or pass it directly
|
|
651
|
+
morphkit generate ./my-app --api-key morphkit_sk_your_key_here
|
|
652
|
+
|
|
653
|
+
# Or save it to ~/.morphkit/config
|
|
654
|
+
mkdir -p ~/.morphkit
|
|
655
|
+
echo "api_key = morphkit_sk_your_key_here" > ~/.morphkit/config
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
**Free tier**: 20 conversions/month. **Pro** ($19/mo): unlimited conversions.
|
|
659
|
+
|
|
660
|
+
Get your API key at [morphkit.dev/dashboard](https://morphkit.dev/dashboard).
|
|
661
|
+
|
|
662
|
+
### Self-Hosted
|
|
663
|
+
|
|
664
|
+
Morphkit is fully open-source (MIT). For enterprise users who want to self-host:
|
|
665
|
+
|
|
666
|
+
1. Clone the repository
|
|
667
|
+
2. Set up your own Supabase project for auth/metering (optional)
|
|
668
|
+
3. Set `MORPHKIT_API_URL` to your instance URL, or run without auth
|
|
669
|
+
|
|
670
|
+
```bash
|
|
671
|
+
# Run without authentication (local/self-hosted mode)
|
|
672
|
+
bun run src/index.ts generate ./my-app
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
---
|
|
676
|
+
|
|
677
|
+
## Contributing
|
|
678
|
+
|
|
679
|
+
We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
680
|
+
|
|
681
|
+
```bash
|
|
682
|
+
# Quick start for contributors
|
|
683
|
+
git clone https://github.com/ashlrai/morphkit.git
|
|
684
|
+
cd morphkit
|
|
685
|
+
bun install
|
|
686
|
+
bun test # Run tests
|
|
687
|
+
bun run typecheck # Type checking
|
|
688
|
+
```
|
|
689
|
+
|
|
690
|
+
---
|
|
691
|
+
|
|
692
|
+
## Limitations & Unsupported Patterns
|
|
693
|
+
|
|
694
|
+
- **Frameworks:** Only Next.js App Router and plain React + Vite are currently supported. Next.js Pages Router has partial support (route detection only).
|
|
695
|
+
- **CSS-in-JS:** Styled-components, Emotion, and other CSS-in-JS libraries are not extracted. Tailwind CSS utility classes and plain CSS are supported.
|
|
696
|
+
- **GraphQL:** GraphQL schemas and queries are detected in analysis but do not produce generated networking code. REST/fetch patterns are fully supported.
|
|
697
|
+
- **Monorepo:** Monorepo project structures (Turborepo, Nx, Lerna) are untested and may not resolve cross-package imports correctly.
|
|
698
|
+
- **Real-time data:** WebSocket connections and real-time data subscriptions (e.g., Supabase Realtime, Socket.io) are not supported. These are surfaced as TODOs in generated code.
|
|
699
|
+
- **Server Components:** React Server Components are analyzed for route structure but their server-side data fetching is mapped to client-side `async/await` patterns.
|
|
700
|
+
|
|
701
|
+
---
|
|
702
|
+
|
|
703
|
+
## Troubleshooting
|
|
704
|
+
|
|
705
|
+
**"No components found"**
|
|
706
|
+
Ensure you are pointing Morphkit at the project root directory that contains `package.json`. Morphkit uses `package.json` to detect the framework and find source files.
|
|
707
|
+
|
|
708
|
+
**"Swift syntax error" warnings after generation**
|
|
709
|
+
Check the warning details in the CLI output. Common causes:
|
|
710
|
+
- Type mismatches where a scalar was assigned an array value (these are emitted as TODOs)
|
|
711
|
+
- Missing entity definitions for referenced types
|
|
712
|
+
- Complex generic types that don't have a direct Swift equivalent
|
|
713
|
+
|
|
714
|
+
These warnings are non-fatal — the generated project is still usable but may need manual fixes in the flagged files.
|
|
715
|
+
|
|
716
|
+
**Stack trace or crash on error**
|
|
717
|
+
Report the issue at [github.com/ashlrai/morphkit/issues](https://github.com/ashlrai/morphkit/issues) with the full error output and your framework/version info.
|
|
718
|
+
|
|
719
|
+
**AI provider not working**
|
|
720
|
+
- Verify your API key is set correctly: `echo $ANTHROPIC_API_KEY`
|
|
721
|
+
- Try with `--no-ai` to confirm the issue is AI-specific
|
|
722
|
+
- Check that your API key has sufficient quota/credits
|
|
723
|
+
|
|
724
|
+
---
|
|
725
|
+
|
|
726
|
+
## Roadmap
|
|
727
|
+
|
|
728
|
+
- [x] Next.js App Router (full support)
|
|
729
|
+
- [x] TypeScript interfaces → Swift Codable structs
|
|
730
|
+
- [x] Zustand/Redux state → @Observable stores
|
|
731
|
+
- [x] API routes → URLSession client
|
|
732
|
+
- [ ] Next.js Pages Router
|
|
733
|
+
- [x] React + Vite
|
|
734
|
+
- [ ] Remix
|
|
735
|
+
- [ ] Vue.js / Nuxt
|
|
736
|
+
- [ ] Android (Jetpack Compose) output
|
|
737
|
+
- [ ] Watch app generation
|
|
738
|
+
- [ ] Widget generation
|
|
739
|
+
|
|
740
|
+
---
|
|
741
|
+
|
|
742
|
+
## Security
|
|
743
|
+
|
|
744
|
+
Report security vulnerabilities to security@morphkit.dev. See [SECURITY.md](SECURITY.md).
|
|
745
|
+
|
|
746
|
+
---
|
|
747
|
+
|
|
447
748
|
## License
|
|
448
749
|
|
|
449
750
|
MIT — [AshlrAI](https://ashlr.ai)
|