@codewithdan/zingit 0.12.0 → 0.14.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/AGENTS.md CHANGED
@@ -2,10 +2,18 @@
2
2
 
3
3
  ## Project Overview
4
4
 
5
- ZingIt is a browser-based annotation tool that allows users to click on webpage elements and add notes/instructions. These annotations are then sent to an AI agent (Claude Code or GitHub Copilot) which can automatically implement the requested changes.
5
+ ZingIt is a browser-based annotation tool that allows users to click on webpage elements and add notes/instructions. These annotations are then sent to an AI agent (Claude Code, GitHub Copilot CLI, or OpenAI Codex) which can automatically implement the requested changes.
6
6
 
7
7
  **Use case**: Point-and-click UI feedback that gets automatically implemented by AI.
8
8
 
9
+ **Key Features**:
10
+ - Visual element selection with annotation
11
+ - Multi-agent support (Claude, Copilot, Codex)
12
+ - Automatic screenshot capture
13
+ - Change history tracking
14
+ - Remote/local URL detection with warnings
15
+ - Keyboard shortcuts for fast workflow
16
+
9
17
  ## Architecture
10
18
 
11
19
  ```
@@ -13,17 +21,18 @@ ZingIt is a browser-based annotation tool that allows users to click on webpage
13
21
  │ Browser │
14
22
  │ ┌─────────────────────────────────────────────────────┐ │
15
23
  │ │ ZingIt Client │ │
16
- │ │ (Lit Web Components injected via bookmarklet) │ │
24
+ │ │ (Lit Web Components - ?zingit URL parameter) │ │
17
25
  │ └──────────────────────┬──────────────────────────────┘ │
18
26
  └─────────────────────────┼───────────────────────────────────┘
19
27
  │ WebSocket
20
28
 
21
29
  ┌─────────────────────────────────────────────────────────────┐
22
30
  │ ZingIt Server │
23
- │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
24
- │ │ WebSocket │───▶│ Agent │───▶│ Claude Code
25
- │ │ Handler │ │ Registry │ │ or Copilot
26
- └─────────────┘ └─────────────┘ └─────────────┘
31
+ │ ┌─────────────┐ ┌─────────────┐ ┌──────────────┐
32
+ │ │ WebSocket │───▶│ Agent │───▶│ Claude Code
33
+ │ │ Handler │ │ Registry │ │ Copilot
34
+ │ │ │ │ │ Codex
35
+ │ └─────────────┘ └─────────────┘ └──────────────┘ │
27
36
  └─────────────────────────────────────────────────────────────┘
28
37
  ```
29
38
 
@@ -42,7 +51,10 @@ zingit/
42
51
  │ │ │ ├── settings.ts # Configuration panel
43
52
  │ │ │ ├── response.ts # Agent response display
44
53
  │ │ │ ├── toast.ts # Notification toasts
45
- │ │ │ └── help.ts # Keyboard shortcuts overlay
54
+ │ │ │ ├── help.ts # Keyboard shortcuts overlay
55
+ │ │ │ ├── history.ts # Change history panel
56
+ │ │ │ ├── site-header.ts # Demo site navigation
57
+ │ │ │ └── site-footer.ts # Demo site footer
46
58
  │ │ ├── services/
47
59
  │ │ │ ├── selector.ts # CSS selector generation
48
60
  │ │ │ ├── storage.ts # localStorage persistence
@@ -57,14 +69,22 @@ zingit/
57
69
  │ ├── about.html # Test page
58
70
  │ ├── contact.html # Test page
59
71
  │ ├── styles.css # Shared styles for test pages
60
- └── vite.config.ts # Build config (IIFE for bookmarklet)
72
+ ├── deploy/ # Build output for GitHub Pages
73
+ │ │ ├── index.html # Static version of demo site
74
+ │ │ └── styles.css # Copied styles
75
+ │ ├── scripts/
76
+ │ │ └── prepare-deploy.js # Prepares deploy folder
77
+ │ └── vite.config.ts # Build config
61
78
 
62
79
  ├── server/ # Node.js WebSocket server
63
80
  │ └── src/
64
81
  │ ├── agents/
65
82
  │ │ ├── base.ts # Abstract base agent class
66
83
  │ │ ├── claude.ts # Claude Code CLI integration
67
- │ │ └── copilot.ts # GitHub Copilot SDK integration
84
+ │ │ ├── copilot.ts # GitHub Copilot SDK integration
85
+ │ │ └── codex.ts # OpenAI Codex integration
86
+ │ ├── handlers/
87
+ │ │ └── messageHandlers.ts # WebSocket message handlers
68
88
  │ ├── types.ts # Server-side TypeScript interfaces
69
89
  │ └── index.ts # WebSocket server entry point
70
90
 
@@ -80,11 +100,12 @@ zingit/
80
100
  - **Shadow DOM** - Style isolation (critical for bookmarklet injection)
81
101
 
82
102
  ### Server
83
- - **Node.js** - Runtime
103
+ - **Node.js** - Runtime (>=22.0.0)
84
104
  - **ws** - WebSocket library
85
105
  - **tsx** - TypeScript execution
86
106
  - **@anthropic-ai/claude-agent-sdk** - Claude Code integration
87
107
  - **@github/copilot-sdk** - GitHub Copilot integration
108
+ - **@openai/codex-sdk** - OpenAI Codex integration
88
109
 
89
110
  ## Key Concepts
90
111
 
@@ -98,16 +119,24 @@ An annotation captures:
98
119
  - `parentContext` - Parent element path for context
99
120
  - `textContent` - Plain text content
100
121
 
122
+ ### Change History
123
+ The history component tracks all changes made by the AI agent:
124
+ - Displays a chronological list of modifications
125
+ - Shows file paths and change summaries
126
+ - Allows users to review what was changed
127
+ - Accessible via the clock icon in the toolbar
128
+
101
129
  ### WebSocket Messages
102
130
  - **Client → Server**: `batch` (send annotations), `message` (follow-up), `reset` (clear session)
103
131
  - **Server → Client**: `connected`, `processing`, `delta` (streaming), `tool_start`/`tool_end`, `idle`, `error`
104
132
 
105
133
  ### Agent System
106
134
  The server uses a pluggable agent architecture:
107
- - Set `AGENT=claude` or `AGENT=copilot` environment variable
135
+ - Set `AGENT=claude`, `AGENT=copilot`, or `AGENT=codex` environment variable
108
136
  - Agents implement `Agent` interface with `createSession()` and `formatPrompt()`
109
137
  - Claude agent spawns `claude --print` CLI process
110
138
  - Copilot agent uses the GitHub Copilot SDK
139
+ - Codex agent uses the OpenAI Codex SDK
111
140
 
112
141
  ## Development Commands
113
142
 
@@ -116,26 +145,36 @@ The server uses a pluggable agent architecture:
116
145
  cd client
117
146
  npm install
118
147
  npm run dev # Start Vite dev server (http://localhost:5200)
119
- npm run build # Build for production (outputs IIFE bundle)
148
+ npm run build # Build for production
149
+ npm run deploy # Prepare and deploy to GitHub Pages
120
150
  npm run typecheck # Type check without emitting
121
151
  npm run typecheck:watch # Watch mode type checking
122
152
  ```
123
153
 
154
+ **Note**: The deploy script (`npm run deploy`) runs `prepare-deploy.js` which copies files to the `deploy/` folder, then uses `gh-pages` to publish to GitHub Pages.
155
+
124
156
  ### Server
125
157
  ```bash
126
158
  cd server
127
159
  npm install
128
- AGENT=claude npm run dev # Start with Claude Code agent
129
- AGENT=copilot npm run dev # Start with GitHub Copilot agent
130
- npm run typecheck # Type check
131
- npm run typecheck:watch # Watch mode type checking
160
+ npx cross-env AGENT=claude npm run dev # Start with Claude Code agent
161
+ npx cross-env AGENT=copilot npm run dev # Start with GitHub Copilot agent
162
+ npx cross-env AGENT=codex npm run dev # Start with OpenAI Codex agent
163
+ npm run typecheck # Type check
164
+ npm run typecheck:watch # Watch mode type checking
165
+ ```
166
+
167
+ ### Running the Published Package
168
+ ```bash
169
+ # For external users
170
+ npx cross-env PROJECT_DIR=/path/to/your/project npx @codewithdan/zingit
132
171
  ```
133
172
 
134
173
  ## Keyboard Shortcuts
135
174
 
136
175
  | Key | Action |
137
176
  |-----|--------|
138
- | `P` | Toggle annotation mode on/off |
177
+ | `Z` | Toggle annotation mode on/off |
139
178
  | `Ctrl/Cmd+Z` | Undo last annotation |
140
179
  | `?` | Show help overlay |
141
180
  | `` ` `` | Toggle ZingIt visibility |
@@ -151,8 +190,15 @@ The client persists state to `localStorage`:
151
190
 
152
191
  ## Important Implementation Details
153
192
 
193
+ ### Remote URL Detection
194
+ ZingIt detects when you're editing a published/remote site versus local development:
195
+ - **Local** (localhost, 127.0.0.1, etc.) - Changes appear immediately on refresh
196
+ - **Remote** (published sites) - Shows warning toast that changes are saved locally only
197
+ - Badge displayed in toolbar: "💻 Local" or "🌐 Remote"
198
+ - Warning can be dismissed but persists until user understands the limitation
199
+
154
200
  ### Shadow DOM
155
- All components use Shadow DOM for style isolation. This is critical because ZingIt is injected as a bookmarklet into arbitrary pages - styles must not leak in or out.
201
+ All components use Shadow DOM for style isolation. This is critical because ZingIt is injected into arbitrary pages - styles must not leak in or out.
156
202
 
157
203
  ### Viewport Coordinates
158
204
  The highlight and marker positioning uses viewport coordinates (not page coordinates) because the main `zing-ui` component is `position: fixed`. Use `getElementViewportRect()` from `geometry.ts`.
@@ -163,6 +209,15 @@ The WebSocket client implements exponential backoff reconnection:
163
209
  - Max 10 attempts before showing "Reconnect" button
164
210
  - Call `forceReconnect()` to manually retry
165
211
 
212
+ ### Toast Notifications
213
+ The toast system supports multiple types with different styling:
214
+ - **success** - Green background for successful operations
215
+ - **error** - Red background for failures
216
+ - **info** - Dark gray with subtle border
217
+ - **warning** - Dark gray with orange left border (for remote URL warnings)
218
+
219
+ Persistent toasts (duration=0) show a close button in the top-right corner.
220
+
166
221
  ### Component Communication
167
222
  Components communicate via custom events that bubble through Shadow DOM:
168
223
  ```typescript
@@ -173,6 +228,18 @@ this.dispatchEvent(new CustomEvent('save', {
173
228
  }));
174
229
  ```
175
230
 
231
+ ### Server Logging
232
+ Request boundaries are logged for debugging:
233
+ ```
234
+ [Batch] ===== Request started =====
235
+ [Batch] Prompt preview: Change the background color to blue...
236
+ [Batch] Image count: 2
237
+ ... processing logs ...
238
+ [Batch] ===== Request completed =====
239
+ ```
240
+
241
+ This makes it easy to track multiple concurrent requests and debug issues.
242
+
176
243
  ## Common Tasks
177
244
 
178
245
  ### Adding a New Component
@@ -194,21 +261,42 @@ Edit `client/src/components/toolbar.ts`:
194
261
  - Create handler method that dispatches event
195
262
  - Wire up event in `zing-ui.ts`
196
263
 
264
+ **Note**: Icons use SVG (not emoticons) for professional appearance and better rendering across platforms. The local/remote badge uses inline SVG icons with `currentColor` for theming.
265
+
197
266
  ## Testing
198
267
 
199
- Test pages are available at:
200
- - `http://localhost:5200/` - Main demo page
268
+ ### Demo Site
269
+ The main demo site (`client/index.html`) showcases ZingIt with:
270
+ - Hero section with features
271
+ - Installation instructions
272
+ - Toolbar icon reference table
273
+ - Try it with demo section
274
+ - Try it with your website section
275
+
276
+ ### Test Pages
277
+ Additional test pages are available:
201
278
  - `http://localhost:5200/products.html` - Product cards
202
279
  - `http://localhost:5200/about.html` - About page with stats/timeline
203
280
  - `http://localhost:5200/contact.html` - Contact form and FAQ
204
281
 
282
+ Add `?zingit` to any URL to activate the annotation tool.
283
+
205
284
  ## Build Output
206
285
 
207
286
  The Vite build produces:
208
- - `dist/zingit.es.js` - ES module version
209
- - `dist/zingit.iife.js` - IIFE for bookmarklet injection
287
+ - `dist/zingit-client.js` - Bundled client code
210
288
 
211
- The IIFE can be used as a bookmarklet:
212
- ```javascript
213
- javascript:(function(){var s=document.createElement('script');s.src='http://localhost:5200/dist/zingit.iife.js';document.body.appendChild(s);})()
289
+ Published to npm as `@codewithdan/zingit` and available via CDN:
290
+ ```html
291
+ <script src="https://cdn.jsdelivr.net/npm/@codewithdan/zingit@latest/dist/zingit-client.js"></script>
214
292
  ```
293
+
294
+ Users activate ZingIt by adding `?zingit` to any URL: `http://localhost:5200/?zingit`
295
+
296
+ ## GitHub Actions Workflow
297
+
298
+ Automated release and deployment on commits starting with "release:":
299
+ 1. Runs `npm run release` - versions, builds, and publishes to npm
300
+ 2. Runs `npm run deploy` - deploys demo site to GitHub Pages
301
+
302
+ Requires `NPM_TOKEN` secret in repository settings.
package/README.md CHANGED
@@ -11,57 +11,97 @@ Streamline how you share UI changes with your AI assistant. Select elements, ann
11
11
  - **Real-time Streaming** - Watch the AI work in real-time
12
12
  - **Smart Selectors** - Auto-generates CSS selectors for precise targeting
13
13
  - **Screenshot Capture** - Automatically capture annotated elements to provide visual context to agents
14
+ - **Change History** - Track all modifications made by your AI assistant
15
+ - **Remote/Local Detection** - Warns when editing published sites vs local development
14
16
 
15
17
  ## Quick Start
16
18
 
17
- ### Option 1: Try the Live Demo
19
+ ### Option 1: Clone the Repo and Run Locally
18
20
 
19
- Visit **[danwahlin.github.io/zingit](https://danwahlin.github.io/zingit)** and follow the setup steps.
21
+ 1. **Install an AI agent** - Install and login to one of these AI agents on your dev machine:
20
22
 
21
- ### Option 2: Clone the Repo and Run Locally
23
+ - [Claude Code](https://github.com/anthropics/claude-code)
24
+ - [GitHub Copilot CLI](https://github.com/github/copilot-cli)
25
+ - [OpenAI Codex](https://github.com/openai/codex)
22
26
 
23
- 1. Clone the repo.
27
+ 2. **Clone and setup**:
24
28
 
25
- 2. Install an AI agent (Claude Code, GitHub Copilot CLI, or OpenAI Codex).
26
-
27
- - [Claude Code](https://github.com/anthropics/claude-code)
28
- - [GitHub Copilot CLI](https://github.com/github/copilot-cli)
29
- - [OpenAI Codex](https://github.com/openai/codex)
29
+ ```bash
30
+ git clone https://github.com/danwahlin/zingit.git
31
+ ```
30
32
 
31
- 3. Start the server:
33
+ 3. **Start the ZingIt server** (in one terminal):
32
34
 
33
35
  ```bash
34
- PROJECT_DIR=/path/to/your/project npx @codewithdan/zingit
36
+ cd zingit/server
37
+ npm install
38
+ npx cross-env PROJECT_DIR=../client npm run dev
35
39
  ```
36
40
 
37
41
  Server runs on `ws://localhost:3000`
38
42
 
39
- 4. Open your web app in a browser.
43
+ 4. **Run the demo site** (in another terminal):
40
44
 
41
45
  ```bash
42
- cd client
46
+ cd zingit/client
47
+ npm install
43
48
  npm run dev
44
49
  ```
45
50
 
46
- 5. Visit [http://localhost:5200/index.html?zingit](http://localhost:5200/index.html?zingit) to load ZingIt.
51
+ 5. Visit [http://localhost:5200/?zingit](http://localhost:5200/?zingit) to see ZingIt in action!
47
52
 
48
- 6. Select the agent to use and start annotating!
53
+ 6. You'll be prompted to select an AI agent. Start annotating!
49
54
 
50
- ### Option 3: Add to Your Page
55
+ ### Option 2: Add to Your Website
51
56
 
52
- Follow the step above to start the server, then add this script to your page:
57
+ 1. **Start the ZingIt server**:
58
+
59
+ ```bash
60
+ npx cross-env PROJECT_DIR=/path/to/your/project npx @codewithdan/zingit
61
+ ```
62
+
63
+ Replace `/path/to/your/project` with your project path.
64
+
65
+ 2. **Add the ZingIt script** to your HTML pages just before the closing `</body>` tag:
53
66
 
54
67
  ```html
55
- <script src="https://cdn.jsdelivr.net/npm/@codewithdan/zingit@latest/client/dist/zingit-client.js"></script>
56
- <script>ZingIt.connect('ws://localhost:3000');</script>
68
+ <script src="https://cdn.jsdelivr.net/npm/@codewithdan/zingit@latest/dist/zingit-client.js"></script>
57
69
  ```
58
70
 
71
+ 3. **Run your website's dev server** and visit it with `?zingit` added to the URL.
72
+
73
+ Example: `http://localhost:5200/?zingit`
74
+
59
75
  ## Usage
60
76
 
61
- 1. **Press `Z`** to toggle annotation mode
62
- 2. **Click elements** to annotate them
63
- 3. **Click the sparkle icon** (✨) to send to your AI agent
64
- 4. **Watch the agent work** in the response panel
77
+ 1. **Press `Z`** to toggle annotation mode on/off
78
+ 2. **Click elements** on your page to annotate them - add notes about changes you want
79
+ 3. **Click the sparkle icon** (✨) in the toolbar to send annotations to your AI agent
80
+ 4. **Watch the agent work** in real-time - the response panel shows streaming updates
81
+
82
+ ### Toolbar Icons
83
+
84
+ | Icon | Description |
85
+ |------|-------------|
86
+ | **ON/OFF** | Toggle annotation mode |
87
+ | **✨** (Sparkle) | Send annotations to AI agent |
88
+ | **🕒** (Clock) | View change history |
89
+ | **📋** (Copy) | Export annotations as Markdown |
90
+ | **🧹** (Broom) | Clear all annotations |
91
+ | **?** | View keyboard shortcuts |
92
+ | **⚙️** (Gear) | Open settings |
93
+ | **✕** | Close ZingIt toolbar |
94
+
95
+ ### Keyboard Shortcuts
96
+
97
+ | Key | Action |
98
+ |-----|--------|
99
+ | `Z` | Toggle annotation mode on/off |
100
+ | `Ctrl/Cmd+Z` | Undo last annotation |
101
+ | `?` | Show help overlay |
102
+ | `` ` `` | Toggle ZingIt visibility |
103
+ | `Esc` | Close current panel/modal |
104
+ | `Ctrl/Cmd+Enter` | Save annotation (in modal) |
65
105
 
66
106
  ## Configuration
67
107
 
@@ -89,8 +129,9 @@ zingit/
89
129
  ## Troubleshooting
90
130
 
91
131
  **WebSocket not connected**
92
- - Ensure server is running: `PROJECT_DIR=/path npx @codewithdan/zingit`
132
+ - Ensure server is running: `npx cross-env PROJECT_DIR=/path npx @codewithdan/zingit`
93
133
  - Check WebSocket URL in settings (default: `ws://localhost:3000`)
134
+ - Make sure you've added `?zingit` to your URL
94
135
 
95
136
  **Agent not responding**
96
137
  - Verify AI agent is installed and authenticated
@@ -100,6 +141,11 @@ zingit/
100
141
  - Annotations are URL-specific and stored in localStorage
101
142
  - Changing pages clears annotations
102
143
 
144
+ **Changes not appearing on published site**
145
+ - If you see a "Remote" badge in the toolbar, you're editing a published site
146
+ - Changes are saved locally only - to see them, run the project locally or deploy the updated files
147
+ - For best experience, use ZingIt with local development (localhost)
148
+
103
149
  ## License
104
150
 
105
151
  MIT