skema-core 0.1.0 → 0.1.1

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