vite-plugin-ai-annotator 1.0.2 → 1.1.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/README.md CHANGED
@@ -5,49 +5,51 @@ AI-powered element annotator for Vite - Pick elements and get instant AI code mo
5
5
  [![Watch the Tutorial](https://img.youtube.com/vi/OuKnfCbmfTg/maxresdefault.jpg)](https://youtu.be/OuKnfCbmfTg)
6
6
  > 📺 **[Watch the Tutorial Video](https://youtu.be/OuKnfCbmfTg)** - See the plugin in action!
7
7
 
8
- ## Easy Setup with Claude Code Plugin
8
+ ## What is this?
9
9
 
10
- Don't want to manually install? Install the **Claude Code plugin** and let AI set everything up for you:
10
+ Point at any element on your webapp, type a request, and AI modifies your code instantly.
11
11
 
12
- ```bash
13
- claude plugin install claude-annotator-plugin@nguyenvanduocit
14
- ```
12
+ - **Point directly at any element** on your webapp
13
+ - **Type a short request** like "make it bigger", "center it", "change color to blue"
14
+ - **Wait for AI to modify your code** - it automatically finds and updates the source files
15
+ - **See instant results** - your changes appear immediately in the browser
15
16
 
16
- Then just ask Claude: *"Set up ai-annotator for my project"* - it will handle the rest!
17
+ > Save cognitive load, because it's precious.
17
18
 
18
- ## Manual Setup
19
+ ## Why use it?
19
20
 
20
- ### Requirements
21
+ Traditional workflow: inspect element → find source file → locate the code → make changes → check results.
21
22
 
22
- This plugin requires **Claude Code** CLI:
23
+ With this plugin: point describe → done.
23
24
 
24
- ```bash
25
- bun install -g @anthropic-ai/claude-code
26
- ```
25
+ Works with all Vite-supported frameworks:
26
+ - ⚛️ **React** - Detects components, props, and state
27
+ - 🟢 **Vue** - Understands composition/options API
28
+ - 🅰️ **Angular** - Recognizes components and directives
29
+ - 🟠 **Svelte** - Identifies components and stores
30
+ - 📄 **Vanilla JS** - Works with plain HTML/CSS/JS
27
31
 
28
- > Claude Code is Anthropic's official CLI tool. [Learn more](https://docs.anthropic.com/en/docs/claude-code)
32
+ ## Installation
29
33
 
30
- ## What can this plugin help you?
34
+ ### Option 1: Automatic Setup (Recommended)
31
35
 
32
- After installing the plugin, you can:
33
- - **Point directly at any element** on your webapp
34
- - **Type a short request** like "make it bigger", "center it", "change color to blue"
35
- - **Wait for AI to modify your code** - it automatically finds and updates the source files
36
- - **See instant results** - your changes appear immediately in the browser
36
+ Install the **Claude Code plugin** and let AI set everything up for you:
37
37
 
38
- > Save cognitive load, because it's precious.
38
+ ```bash
39
+ claude plugin install claude-annotator-plugin@nguyenvanduocit
40
+ ```
39
41
 
40
- ## Quick Start
42
+ Then ask Claude: *"Set up ai-annotator for my project"* - it handles the rest!
41
43
 
42
- This is an **ESM-only Vite plugin**. Installation is simple!
44
+ ### Option 2: Manual Setup
43
45
 
44
- ### 1. Install
46
+ #### Step 1: Install the package
45
47
 
46
48
  ```bash
47
49
  bun add -d vite-plugin-ai-annotator
48
50
  ```
49
51
 
50
- ### 2. Add to Your Vite Config
52
+ #### Step 2: Add to your Vite config
51
53
 
52
54
  ```typescript
53
55
  import { defineConfig } from 'vite';
@@ -60,15 +62,23 @@ export default defineConfig({
60
62
  });
61
63
  ```
62
64
 
63
- ### 3. Start Your Dev Server
65
+ #### Step 3: Add MCP to Claude Code
66
+
67
+ ```bash
68
+ claude mcp add annotator -- npx vite-plugin-ai-annotator
69
+ ```
70
+
71
+ #### Step 4: Start your dev server
64
72
 
65
73
  ```bash
66
74
  bun dev
67
75
  ```
68
76
 
69
- That's it! The annotator toolbar will automatically appear in your application.
77
+ The annotator toolbar will automatically appear in your application.
78
+
79
+ ## Port Configuration
70
80
 
71
- ## Plugin Options
81
+ Default port is `7318`. You can customize it:
72
82
 
73
83
  ```typescript
74
84
  annotator({
@@ -77,19 +87,9 @@ annotator({
77
87
  })
78
88
  ```
79
89
 
80
- ## Framework Support
81
-
82
- Works with all Vite-supported frameworks:
83
-
84
- - ⚛️ **React** - Detects components, props, and state
85
- - 🟢 **Vue** - Understands composition/options API
86
- - 🅰️ **Angular** - Recognizes components and directives
87
- - 🟠 **Svelte** - Identifies components and stores
88
- - 📄 **Vanilla JS** - Works with plain HTML/CSS/JS
89
-
90
- ## Team Collaboration
90
+ ### Team Collaboration
91
91
 
92
- Want your entire team to modify the app? Configure for network access:
92
+ For network access (multiple team members modifying the same app):
93
93
 
94
94
  ```typescript
95
95
  annotator({
@@ -99,10 +99,10 @@ annotator({
99
99
  })
100
100
  ```
101
101
 
102
- Now anyone on your team can:
102
+ Team members can:
103
103
  1. Open the app at `https://myapp.com`
104
104
  2. Use the annotator toolbar to modify the UI
105
- 3. Changes are saved directly to the source files
106
- 4. Everyone sees updates in real-time!
105
+ 3. Changes save directly to source files
106
+ 4. Everyone sees updates in real-time
107
107
 
108
108
  **Happy coding! 🚀**
@@ -7,4 +7,11 @@ export interface InspectionManager {
7
7
  isInInspectionMode(): boolean;
8
8
  destroy(): void;
9
9
  }
10
- export declare function createInspectionManager(onElementSelect?: (element: Element) => void, shouldIgnoreElement?: (element: Element) => boolean, isElementSelected?: (element: Element) => boolean): InspectionManager;
10
+ export interface InspectionCallbacks {
11
+ onElementSelect?: (element: Element) => void;
12
+ shouldIgnoreElement?: (element: Element) => boolean;
13
+ isElementSelected?: (element: Element) => boolean;
14
+ onEscape?: () => void;
15
+ onCopy?: () => void;
16
+ }
17
+ export declare function createInspectionManager(callbacks?: InspectionCallbacks): InspectionManager;
@@ -2,14 +2,16 @@
2
2
  * Element Selection Manager for element selection, highlighting, and badge management
3
3
  */
4
4
  import type { ElementData } from '../rpc/define';
5
+ import type { ComponentInfo } from './detectors';
5
6
  export interface SelectedElementInfo {
6
7
  color: string;
7
8
  originalOutline: string;
8
9
  originalOutlineOffset: string;
9
10
  index: number;
10
11
  }
12
+ type ComponentFinder = (el: Element) => ComponentInfo | null;
11
13
  export interface ElementSelectionManager {
12
- selectElement(element: Element, componentFinder?: (el: Element) => any): void;
14
+ selectElement(element: Element, componentFinder?: ComponentFinder): void;
13
15
  deselectElement(element: Element): void;
14
16
  clearAllSelections(): void;
15
17
  hasElement(element: Element): boolean;
@@ -17,8 +19,9 @@ export interface ElementSelectionManager {
17
19
  getSelectedCount(): number;
18
20
  findSelectedParent(element: Element): Element | null;
19
21
  findSelectedChildren(element: Element): Element[];
20
- buildHierarchicalStructure(componentFinder?: (el: Element) => any, imagePaths?: Map<Element, string>): ElementData[];
22
+ buildHierarchicalStructure(componentFinder?: ComponentFinder, imagePaths?: Map<Element, string>): ElementData[];
21
23
  setOnEditClick(callback: (element: Element) => void): void;
22
24
  updateBadgeCommentIndicator(element: Element, hasComment: boolean): void;
23
25
  }
24
26
  export declare function createElementSelectionManager(): ElementSelectionManager;
27
+ export {};
@@ -1,8 +1,8 @@
1
1
  /**
2
- * InstantCode Annotator Toolbar
2
+ * AI Annotator Toolbar
3
3
  *
4
4
  * Browser component that:
5
- * 1. Connects to InstantCode server via Socket.IO
5
+ * 1. Connects to AI Annotator server via Socket.IO
6
6
  * 2. Handles RPC requests from server (element selection, screenshots, etc.)
7
7
  * 3. Shows toolbar UI with inspect/clear buttons
8
8
  * 4. Shows commentPopover for adding comments when elements are selected
@@ -16,7 +16,9 @@ export declare class AnnotatorToolbar extends LitElement {
16
16
  private selectionCount;
17
17
  private isInspecting;
18
18
  private commentPopover;
19
+ private toastMessage;
19
20
  private popoverCleanup;
21
+ private toastTimeout;
20
22
  private socket;
21
23
  private rpc;
22
24
  private selectionManager;
@@ -45,17 +47,23 @@ export declare class AnnotatorToolbar extends LitElement {
45
47
  private removeSelectedElement;
46
48
  private showCommentPopoverForElement;
47
49
  private handlePopoverKeydown;
50
+ private handlePopoverInputKeydown;
48
51
  private hideCommentPopover;
49
52
  private handlePopoverInput;
50
53
  private shouldIgnoreElement;
51
54
  private cleanup;
52
55
  private log;
56
+ private exitInspectingMode;
57
+ private copySelectedElements;
53
58
  private toggleInspect;
54
59
  private handleClearClick;
55
60
  private renderCursorIcon;
56
61
  private renderTrashIcon;
57
62
  private renderCloseIcon;
58
63
  private renderHelpIcon;
64
+ private renderClipboardIcon;
65
+ private showToast;
66
+ private copySessionId;
59
67
  private renderErrorIcon;
60
68
  private openHelpPage;
61
69
  render(): import("lit-html").TemplateResult<1>;