skema-core 0.1.0 → 0.1.2

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/README.md CHANGED
@@ -1,16 +1,26 @@
1
- # Skema
1
+ <p align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/petersenmatthew/skema/main/assets/logo-dark.svg">
4
+ <img src="https://raw.githubusercontent.com/petersenmatthew/skema/main/assets/logo-light.svg" alt="Skema" width="400">
5
+ </picture>
6
+ </p>
2
7
 
3
- A drawing-based website development tool that transforms how you annotate and communicate design changes.
8
+ <p align="center">
9
+ A drawing-based website development tool that transforms how you annotate and communicate design changes.
10
+ </p>
11
+
12
+ ---
4
13
 
5
14
  ## Overview
6
15
 
7
- Skema is a React component that provides a tldraw-powered drawing overlay for annotating and manipulating DOM elements visually. It sits on top of your localhost website, allowing developers to annotate, draw, and select DOM elements directly on the live page.
16
+ Skema is a React component that provides a tldraw-powered drawing overlay for annotating and manipulating DOM elements visually. It sits on top of your localhost website, allowing developers to annotate, draw, and select DOM elements directly on the live page. Combined with AI, your annotations become code changes.
8
17
 
9
18
  ## Features
10
19
 
11
20
  - **Drawing Overlay**: Use tldraw's powerful drawing tools directly on your website
12
21
  - **DOM Picker**: Select any element on the page to capture its selector, bounding box, and context
13
- - **Annotation Export**: Export all annotations in a structured JSON format optimized for AI agents
22
+ - **AI Code Generation**: Annotations are sent to AI (Gemini or Claude) which edits your code
23
+ - **Undo/Revert**: Git-based snapshots let you revert changes per-annotation
14
24
  - **Non-Invasive**: Transparent overlay that doesn't interfere with your page when not in use
15
25
 
16
26
  ## Installation
@@ -18,34 +28,40 @@ Skema is a React component that provides a tldraw-powered drawing overlay for an
18
28
  ### 1. Install the package
19
29
 
20
30
  ```bash
21
- bun add skema-core
22
- # or
23
31
  npm install skema-core
32
+ # or
33
+ bun add skema-core
24
34
  ```
25
35
 
26
- ### 2. Create the API route
36
+ ### 2. Install an AI CLI
27
37
 
28
- Run the init command to create the Gemini API route in your Next.js App Router project:
38
+ Skema uses CLI tools for AI code generation. Install at least one:
29
39
 
30
40
  ```bash
31
- bunx skema init
32
- # or
33
- npx skema init
34
- ```
41
+ # Gemini CLI (recommended)
42
+ npm install -g @anthropic-ai/gemini-cli
35
43
 
36
- This creates `app/api/gemini/route.ts` (or `src/app/api/gemini/route.ts`) which handles annotation processing.
44
+ # Or Claude Code CLI
45
+ npm install -g @anthropic-ai/claude-code
46
+ ```
37
47
 
38
- ### 3. Set up your Gemini API key
48
+ ### 3. Set up your API key
39
49
 
40
- Add your [Google AI API key](https://aistudio.google.com/apikey) to your `.env` file:
50
+ Skema uses vision AI to analyze your drawings. Add your API key to a `.env` file in your project root:
41
51
 
42
52
  ```env
43
- GEMINI_API_KEY=your_api_key_here
53
+ # For Gemini (recommended)
54
+ GEMINI_API_KEY=your_api_key
55
+
56
+ # Or for Claude
57
+ ANTHROPIC_API_KEY=your_api_key
44
58
  ```
45
59
 
60
+ Get your API key from [Google AI Studio](https://aistudio.google.com/apikey) or [Anthropic Console](https://console.anthropic.com/).
61
+
46
62
  ### 4. Add Skema to your app
47
63
 
48
- Wrap your app with the Skema component (development only):
64
+ Add the Skema component to your app (development only):
49
65
 
50
66
  ```tsx
51
67
  import { Skema } from 'skema-core';
@@ -55,7 +71,7 @@ export default function Page() {
55
71
  <>
56
72
  {/* Your page content */}
57
73
  <main>...</main>
58
-
74
+
59
75
  {/* Skema overlay - only in development */}
60
76
  {process.env.NODE_ENV === 'development' && <Skema />}
61
77
  </>
@@ -63,53 +79,86 @@ export default function Page() {
63
79
  }
64
80
  ```
65
81
 
82
+ ### 5. Start the daemon
83
+
84
+ In a separate terminal, start the Skema daemon in your project directory:
85
+
86
+ ```bash
87
+ npx skema-core
88
+ ```
89
+
90
+ The daemon runs a WebSocket server that:
91
+ - Connects to your browser (auto-connects to `ws://localhost:9999`)
92
+ - Receives annotations from the Skema component
93
+ - Spawns AI CLI to generate code changes
94
+ - Streams results back to the browser
95
+ - Creates git snapshots for undo/revert
96
+
66
97
  That's it! Press **⌘⇧E** (Cmd+Shift+E) to toggle the Skema overlay.
67
98
 
99
+ ## Daemon Options
100
+
101
+ ```bash
102
+ npx skema-core # Start daemon (default port 9999)
103
+ npx skema-core --port 8080 # Custom port
104
+ npx skema-core --provider claude # Use Claude Code CLI instead of Gemini
105
+ npx skema-core --dir /path/to/proj # Set working directory
106
+ npx skema-core init # Initialize project (creates config files)
107
+ npx skema-core help # Show help
108
+ ```
109
+
110
+ > **Note**: After installing `skema-core`, you can also use the `skema` command directly (e.g., `skema init`).
111
+
68
112
  ## Keyboard Shortcuts
69
113
 
70
114
  - **⌘⇧E** (Cmd+Shift+E / Ctrl+Shift+E): Toggle Skema overlay
71
115
  - **P**: Activate DOM Picker tool
72
116
 
73
- ## Export Format
74
-
75
- When you export annotations, Skema generates a JSON structure like this:
76
-
77
- ```json
78
- {
79
- "version": "1.0.0",
80
- "timestamp": "2024-01-24T12:00:00Z",
81
- "viewport": {
82
- "width": 1920,
83
- "height": 1080,
84
- "scrollX": 0,
85
- "scrollY": 150
86
- },
87
- "pathname": "/",
88
- "annotations": [
89
- {
90
- "type": "dom_selection",
91
- "id": "dom-1706097600000-abc123",
92
- "selector": ".hero-section > button.cta-primary",
93
- "tagName": "button",
94
- "elementPath": ".hero-section > button",
95
- "text": "Get Started",
96
- "boundingBox": { "x": 100, "y": 200, "width": 150, "height": 40 },
97
- "timestamp": 1706097600000,
98
- "pathname": "/"
99
- }
100
- ]
101
- }
102
- ```
103
-
104
117
  ## Props
105
118
 
106
119
  | Prop | Type | Default | Description |
107
120
  |------|------|---------|-------------|
108
121
  | `enabled` | `boolean` | `true` | Whether Skema overlay is enabled |
122
+ | `daemonUrl` | `string \| null` | `'ws://localhost:9999'` | WebSocket URL for daemon. Set to `null` to disable auto-connection |
109
123
  | `onAnnotationsChange` | `(annotations: Annotation[]) => void` | - | Callback when annotations change |
124
+ | `onAnnotationSubmit` | `(annotation: Annotation, comment: string) => void` | - | Custom handler for annotation submission |
125
+ | `onAnnotationDelete` | `(annotationId: string) => void` | - | Custom handler for annotation deletion |
110
126
  | `toggleShortcut` | `string` | `'mod+shift+e'` | Keyboard shortcut to toggle Skema |
111
127
  | `initialAnnotations` | `Annotation[]` | `[]` | Initial annotations to load |
112
128
  | `zIndex` | `number` | `99999` | Z-index for the overlay |
129
+ | `isProcessing` | `boolean` | - | Shows processing animation |
130
+ | `onProcessingCancel` | `() => void` | - | Callback when user cancels processing |
131
+
132
+ ## Next.js Configuration
133
+
134
+ ```js
135
+ // next.config.js
136
+ module.exports = {
137
+ reactStrictMode: false, // Required for tldraw
138
+ transpilePackages: ['skema-core'],
139
+ };
140
+ ```
141
+
142
+ ## Architecture
143
+
144
+ ```
145
+ ┌──────────────────┐ WebSocket ┌─────────────────┐
146
+ │ Browser │ ←───────────────→ │ Daemon │
147
+ │ (Skema overlay) │ │ (skema-core) │
148
+ └──────────────────┘ └────────┬────────┘
149
+ │ spawns
150
+
151
+ ┌─────────────────┐
152
+ │ AI CLI │
153
+ │ (gemini/claude)│
154
+ └─────────────────┘
155
+ ```
156
+
157
+ 1. User creates annotation in browser
158
+ 2. Skema sends annotation to daemon via WebSocket
159
+ 3. Daemon creates git snapshot, builds prompt, spawns AI CLI
160
+ 4. AI CLI modifies files, streams output back
161
+ 5. User can revert changes using git snapshots
113
162
 
114
163
  ## License
115
164