vite-plugin-ai-annotator 1.0.1 → 1.0.3

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,19 +5,10 @@ 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
- ## Requirements
8
+ ## What is this?
9
9
 
10
- This plugin requires **Claude Code** CLI to be installed:
10
+ Point at any element on your webapp, type a request, and AI modifies your code instantly.
11
11
 
12
- ```bash
13
- bun install -g @anthropic-ai/claude-code
14
- ```
15
-
16
- > Claude Code is Anthropic's official CLI tool that provides AI assistance. [Learn more](https://docs.anthropic.com/en/docs/claude-code)
17
-
18
- ## What can this plugin help you?
19
-
20
- After installing the plugin, you can:
21
12
  - **Point directly at any element** on your webapp
22
13
  - **Type a short request** like "make it bigger", "center it", "change color to blue"
23
14
  - **Wait for AI to modify your code** - it automatically finds and updates the source files
@@ -25,17 +16,40 @@ After installing the plugin, you can:
25
16
 
26
17
  > Save cognitive load, because it's precious.
27
18
 
28
- ## Quick Start
19
+ ## Why use it?
20
+
21
+ Traditional workflow: inspect element → find source file → locate the code → make changes → check results.
22
+
23
+ With this plugin: point → describe → done.
24
+
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
31
+
32
+ ## Installation
29
33
 
30
- This is an **ESM-only Vite plugin**. Installation is simple!
34
+ ### Option 1: Automatic Setup (Recommended)
31
35
 
32
- ### 1. Install
36
+ Install the **Claude Code plugin** and let AI set everything up for you:
37
+
38
+ ```bash
39
+ claude plugin install claude-annotator-plugin@nguyenvanduocit
40
+ ```
41
+
42
+ Then ask Claude: *"Set up ai-annotator for my project"* - it handles the rest!
43
+
44
+ ### Option 2: Manual Setup
45
+
46
+ #### Step 1: Install the package
33
47
 
34
48
  ```bash
35
49
  bun add -d vite-plugin-ai-annotator
36
50
  ```
37
51
 
38
- ### 2. Add to Your Vite Config
52
+ #### Step 2: Add to your Vite config
39
53
 
40
54
  ```typescript
41
55
  import { defineConfig } from 'vite';
@@ -48,15 +62,23 @@ export default defineConfig({
48
62
  });
49
63
  ```
50
64
 
51
- ### 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
52
72
 
53
73
  ```bash
54
74
  bun dev
55
75
  ```
56
76
 
57
- That's it! The annotator toolbar will automatically appear in your application.
77
+ The annotator toolbar will automatically appear in your application.
58
78
 
59
- ## Plugin Options
79
+ ## Port Configuration
80
+
81
+ Default port is `7318`. You can customize it:
60
82
 
61
83
  ```typescript
62
84
  annotator({
@@ -65,19 +87,9 @@ annotator({
65
87
  })
66
88
  ```
67
89
 
68
- ## Framework Support
69
-
70
- Works with all Vite-supported frameworks:
71
-
72
- - ⚛️ **React** - Detects components, props, and state
73
- - 🟢 **Vue** - Understands composition/options API
74
- - 🅰️ **Angular** - Recognizes components and directives
75
- - 🟠 **Svelte** - Identifies components and stores
76
- - 📄 **Vanilla JS** - Works with plain HTML/CSS/JS
77
-
78
- ## Team Collaboration
90
+ ### Team Collaboration
79
91
 
80
- Want your entire team to modify the app? Configure for network access:
92
+ For network access (multiple team members modifying the same app):
81
93
 
82
94
  ```typescript
83
95
  annotator({
@@ -87,10 +99,10 @@ annotator({
87
99
  })
88
100
  ```
89
101
 
90
- Now anyone on your team can:
102
+ Team members can:
91
103
  1. Open the app at `https://myapp.com`
92
104
  2. Use the annotator toolbar to modify the UI
93
- 3. Changes are saved directly to the source files
94
- 4. Everyone sees updates in real-time!
105
+ 3. Changes save directly to source files
106
+ 4. Everyone sees updates in real-time
95
107
 
96
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>;