agent-ui-annotation 0.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 +219 -0
- package/dist/agent-ui-annotation.js +3263 -0
- package/dist/agent-ui-annotation.js.map +1 -0
- package/dist/agent-ui-annotation.umd.cjs +1007 -0
- package/dist/agent-ui-annotation.umd.cjs.map +1 -0
- package/dist/index.d.ts +682 -0
- package/package.json +81 -0
package/README.md
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# agent-ui-annotation
|
|
2
|
+
|
|
3
|
+
A web page annotation toolbar for AI coding agents. Click on elements, add notes, and export structured markdown that helps AI assistants locate and modify specific UI components.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
When working with AI coding agents, communicating which visual element needs modification can be challenging. Saying "fix the blue button in the sidebar" is ambiguous. agent-ui-annotation solves this by allowing you to:
|
|
8
|
+
|
|
9
|
+
1. Click any element on a web page
|
|
10
|
+
2. Add feedback or notes
|
|
11
|
+
3. Export structured markdown with element identifiers, CSS selectors, and context
|
|
12
|
+
|
|
13
|
+
The exported markdown gives AI agents the precise information needed to locate elements in code.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# npm
|
|
19
|
+
npm install agent-ui-annotation
|
|
20
|
+
|
|
21
|
+
# pnpm
|
|
22
|
+
pnpm add agent-ui-annotation
|
|
23
|
+
|
|
24
|
+
# yarn
|
|
25
|
+
yarn add agent-ui-annotation
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
### Vanilla JavaScript
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
import { createAnnotation } from 'agent-ui-annotation';
|
|
34
|
+
|
|
35
|
+
const annotation = createAnnotation({
|
|
36
|
+
theme: 'auto',
|
|
37
|
+
onAnnotationCreate: (annotation) => console.log('Created:', annotation),
|
|
38
|
+
onCopy: (markdown) => console.log('Copied:', markdown),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Activate the toolbar
|
|
42
|
+
annotation.activate();
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### As a Web Component
|
|
46
|
+
|
|
47
|
+
```html
|
|
48
|
+
<script type="module">
|
|
49
|
+
import 'agent-ui-annotation';
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<agent-ui-annotation theme="auto" output-level="standard"></agent-ui-annotation>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### React
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { AgentUIAnnotation } from 'agent-ui-annotation/react';
|
|
59
|
+
|
|
60
|
+
function App() {
|
|
61
|
+
return (
|
|
62
|
+
<AgentUIAnnotation
|
|
63
|
+
theme="auto"
|
|
64
|
+
outputLevel="standard"
|
|
65
|
+
onAnnotationCreate={(annotation) => console.log('Created:', annotation)}
|
|
66
|
+
onCopy={(markdown) => console.log('Copied:', markdown)}
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Features
|
|
73
|
+
|
|
74
|
+
### Click-to-Annotate
|
|
75
|
+
Click any element to add feedback. The toolbar captures the element type, location, and your notes.
|
|
76
|
+
|
|
77
|
+
### Smart Element Identification
|
|
78
|
+
Generates human-readable names like `button "Save"` or `input [email]` that AI agents can understand.
|
|
79
|
+
|
|
80
|
+
### CSS Selector Paths
|
|
81
|
+
Creates CSS selectors (e.g., `form > .actions > button`) for precise element location.
|
|
82
|
+
|
|
83
|
+
### Multi-Select
|
|
84
|
+
Hold and drag to select multiple elements at once.
|
|
85
|
+
|
|
86
|
+
### Freeze Mode
|
|
87
|
+
Pause CSS animations and videos to capture specific states.
|
|
88
|
+
|
|
89
|
+
### Block Page Interactions
|
|
90
|
+
When active, clicks are blocked from triggering buttons/links while annotating (configurable in settings).
|
|
91
|
+
|
|
92
|
+
### Output Detail Levels
|
|
93
|
+
|
|
94
|
+
| Level | Description |
|
|
95
|
+
|-------|-------------|
|
|
96
|
+
| Compact | `1. **button "Save"**: Change color to blue` |
|
|
97
|
+
| Standard | Element + path + comment with headers |
|
|
98
|
+
| Detailed | + classes, position, nearby context |
|
|
99
|
+
| Forensic | + full DOM path, computed styles, accessibility info |
|
|
100
|
+
|
|
101
|
+
### Persistence
|
|
102
|
+
Annotations are saved to localStorage and persist across page reloads (7-day retention).
|
|
103
|
+
|
|
104
|
+
## API Reference
|
|
105
|
+
|
|
106
|
+
### Options
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
interface AnnotationOptions {
|
|
110
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
111
|
+
outputLevel?: 'compact' | 'standard' | 'detailed' | 'forensic';
|
|
112
|
+
annotationColor?: string;
|
|
113
|
+
onAnnotationCreate?: (annotation: Annotation) => void;
|
|
114
|
+
onAnnotationUpdate?: (annotation: Annotation) => void;
|
|
115
|
+
onAnnotationDelete?: (id: string) => void;
|
|
116
|
+
onAnnotationsClear?: (annotations: Annotation[]) => void;
|
|
117
|
+
onCopy?: (content: string, level: OutputLevel) => void;
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Instance Methods
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
interface AnnotationInstance {
|
|
125
|
+
activate(): void;
|
|
126
|
+
deactivate(): void;
|
|
127
|
+
toggle(): void;
|
|
128
|
+
copyOutput(level?: OutputLevel): Promise<boolean>;
|
|
129
|
+
getOutput(level?: OutputLevel): string;
|
|
130
|
+
clearAll(): void;
|
|
131
|
+
destroy(): void;
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Web Component Attributes
|
|
136
|
+
|
|
137
|
+
| Attribute | Type | Default | Description |
|
|
138
|
+
|-----------|------|---------|-------------|
|
|
139
|
+
| `theme` | `light` \| `dark` \| `auto` | `auto` | Color theme |
|
|
140
|
+
| `output-level` | `compact` \| `standard` \| `detailed` \| `forensic` | `standard` | Output detail level |
|
|
141
|
+
| `annotation-color` | string | `#AF52DE` | Marker color |
|
|
142
|
+
| `disabled` | boolean | `false` | Disable the toolbar |
|
|
143
|
+
|
|
144
|
+
### Custom Events
|
|
145
|
+
|
|
146
|
+
| Event | Detail | Description |
|
|
147
|
+
|-------|--------|-------------|
|
|
148
|
+
| `annotation:create` | `{ annotation: Annotation }` | Annotation created |
|
|
149
|
+
| `annotation:update` | `{ annotation: Annotation }` | Annotation updated |
|
|
150
|
+
| `annotation:delete` | `{ id: string }` | Annotation deleted |
|
|
151
|
+
| `annotation:clear` | `{ annotations: Annotation[] }` | All annotations cleared |
|
|
152
|
+
| `annotation:copy` | `{ content: string, level: OutputLevel }` | Output copied |
|
|
153
|
+
|
|
154
|
+
## Output Examples
|
|
155
|
+
|
|
156
|
+
### Compact
|
|
157
|
+
|
|
158
|
+
```markdown
|
|
159
|
+
1. **button "Save"**: Change color to blue
|
|
160
|
+
2. **input [email]**: Add validation
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Standard
|
|
164
|
+
|
|
165
|
+
```markdown
|
|
166
|
+
## Page Feedback: /dashboard
|
|
167
|
+
|
|
168
|
+
### 1. button "Save"
|
|
169
|
+
**Location:** form > .actions > button
|
|
170
|
+
**Feedback:** Change color to blue
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
### 2. input [email]
|
|
175
|
+
**Location:** form > .form-group > input
|
|
176
|
+
**Feedback:** Add validation
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Forensic
|
|
180
|
+
|
|
181
|
+
Includes complete DOM path, computed styles, accessibility info, viewport dimensions, and timestamps.
|
|
182
|
+
|
|
183
|
+
## Architecture
|
|
184
|
+
|
|
185
|
+
agent-ui-annotation uses a three-layer architecture:
|
|
186
|
+
|
|
187
|
+
1. **Core** - Framework-agnostic business logic
|
|
188
|
+
2. **Web Components** - Shadow DOM rendering
|
|
189
|
+
3. **Framework Adapters** - React, Angular, Vanilla JS wrappers
|
|
190
|
+
|
|
191
|
+
## Development
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
# Install dependencies
|
|
195
|
+
pnpm install
|
|
196
|
+
|
|
197
|
+
# Run development server
|
|
198
|
+
pnpm dev
|
|
199
|
+
|
|
200
|
+
# Build for production
|
|
201
|
+
pnpm build
|
|
202
|
+
|
|
203
|
+
# Run tests
|
|
204
|
+
pnpm test
|
|
205
|
+
|
|
206
|
+
# Type check
|
|
207
|
+
pnpm typecheck
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Browser Support
|
|
211
|
+
|
|
212
|
+
- Chrome 90+
|
|
213
|
+
- Firefox 90+
|
|
214
|
+
- Safari 14+
|
|
215
|
+
- Edge 90+
|
|
216
|
+
|
|
217
|
+
## License
|
|
218
|
+
|
|
219
|
+
MIT
|