@naylabs/agent-lens 0.0.0-stage → 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sumit Nayyar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,177 @@
1
- # Temporary Holding Version
1
+ # AgentLens
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A visual review and feedback overlay for React applications, designed to generate structured, context-rich execution prompts for AI coding agents.
4
+
5
+ ---
6
+
7
+ ## 1. What is it
8
+
9
+ **AgentLens** is a lightweight in-browser inspection overlay for React web applications. It allows developers and designers to click on any UI element in a running application, annotate it with visual pins and actionable instructions, and automatically compile all feedback into structured, developer-grade markdown prompts ready for AI coding agents (such as Antigravity, Claude, Cursor, Copilot, and others).
10
+
11
+ ### Key Capabilities:
12
+ - **DOM Element Pinning:** Click buttons, containers, cards, or dialogs to anchor visual feedback pins directly to target elements.
13
+ - **Automatic React & DOM Metadata Extraction:** Automatically captures the component name (e.g. `<HeroSection>`), source file location (when React DevTools/Fiber information is available), unique CSS selectors, class names, and computed layout styles (dimensions, padding, margins, colors, border-radius).
14
+ - **Style Isolation via Shadow DOM:** Renders completely inside an isolated Shadow DOM container so host application styles (e.g., Tailwind CSS, CSS resets) never affect AgentLens, and AgentLens styles never bleed into your app.
15
+ - **Event Shielding:** Intercepts pointer events during the capture phase, preventing outside-click handlers on modals, popovers, and dropdowns from prematurely closing when placing pins.
16
+ - **3-Second Freeze Timer:** Temporarily freezes UI interactions to make it easy to inspect transient elements like hover cards, active dropdowns, and tooltips.
17
+ - **One-Click Agent Prompt Compiler:** Aggregates all placed pins into a formatted markdown prompt containing route, viewport, component references, and implementation guidance.
18
+
19
+ ---
20
+
21
+ ## 2. How to install it
22
+
23
+ ### Package Manager Installation
24
+
25
+ Install `@naylabs/agent-lens` as a development dependency in your project:
26
+
27
+ ```bash
28
+ # npm
29
+ npm install --save-dev @naylabs/agent-lens
30
+
31
+ # pnpm
32
+ pnpm add -D @naylabs/agent-lens
33
+
34
+ # yarn
35
+ yarn add -D @naylabs/agent-lens
36
+
37
+ # bun
38
+ bun add -d @naylabs/agent-lens
39
+ ```
40
+
41
+ ### Installing in Your System (Local Development / Linking)
42
+
43
+ If you are developing locally or want to use a local build across multiple projects on your machine:
44
+
45
+ #### Option A: Clone and Build Locally
46
+ ```bash
47
+ git clone https://github.com/Skn1999/agent-lens.git
48
+ cd agent-lens
49
+ npm install
50
+ npm run build
51
+ ```
52
+
53
+ #### Option B: Global Symlink (`npm link`)
54
+ 1. In the `agent-lens` directory, create a global symlink:
55
+ ```bash
56
+ cd /path/to/agent-lens
57
+ npm link
58
+ ```
59
+ 2. In your target project directory, link the package:
60
+ ```bash
61
+ cd /path/to/your-project
62
+ npm link @naylabs/agent-lens
63
+ ```
64
+
65
+ #### Option C: Install Directly via Local File Path
66
+ In your target project, install directly pointing to the local directory:
67
+ ```bash
68
+ cd /path/to/your-project
69
+ npm install /path/to/agent-lens
70
+ ```
71
+
72
+ ---
73
+
74
+ ## 3. How to use it
75
+
76
+ ### Basic Setup
77
+
78
+ Mount `<AgentLens />` at the root of your React application (for example, in `App.tsx` or your root layout). It is recommended to enable it only during development:
79
+
80
+ ```tsx
81
+ import React from 'react';
82
+ import { AgentLens } from '@naylabs/agent-lens';
83
+
84
+ export default function App() {
85
+ return (
86
+ <>
87
+ <YourApplicationRoutes />
88
+
89
+ {/* Render AgentLens during development */}
90
+ {process.env.NODE_ENV === 'development' && <AgentLens />}
91
+
92
+ {/* Or with Vite: */}
93
+ {/* {import.meta.env.DEV && <AgentLens />} */}
94
+ </>
95
+ );
96
+ }
97
+ ```
98
+
99
+ ### Component Props
100
+
101
+ | Prop | Type | Default | Description |
102
+ | :--- | :--- | :--- | :--- |
103
+ | `defaultCategory` | `'style' \| 'copy' \| 'layout' \| 'motion' \| 'bug' \| 'general'` | `'style'` | Initial category selected when creating a new pin. |
104
+ | `onPromptCopied` | `(promptText: string, pinCount: number) => void` | `undefined` | Optional callback triggered when the compiled prompt is copied to clipboard. |
105
+
106
+ ### Feedback Workflow
107
+
108
+ 1. **Activate Inspect:** Click the floating launcher pill or press `Option + C` (`Alt + C`).
109
+ 2. **Select Element:** Click on any element on the page to place a numbered pin.
110
+ 3. **Add Instructions:** Select a category (`Style`, `Copy`, `Layout`, `Motion`, `Bug`, `Note`), type your requested change, and press `Cmd + Enter` / `Ctrl + Enter` to save.
111
+ 4. **Copy Prompt:** Click **Copy Prompt** in the dock or pin tray.
112
+ 5. **Feed to AI Agent:** Paste the generated markdown directly into your AI coding assistant.
113
+
114
+ ---
115
+
116
+ ## 4. Shortcuts
117
+
118
+ | Shortcut | Description |
119
+ | :--- | :--- |
120
+ | **`Option + C`** / **`Alt + C`** | Toggle Inspect mode globally from anywhere (works even inside input fields and active modals). |
121
+ | **`C`** | Toggle Inspect mode (when not typing in an input or text area). |
122
+ | **`Option + F`** / **`Alt + F`** | Trigger the **3-Second Freeze Timer** (allows you to open hover states or dropdowns before inspecting). |
123
+ | **`Cmd + Enter`** / **`Ctrl + Enter`** | Save comment in the active pin popover. |
124
+ | **`Esc`** | Close the active popover, close the tray, cancel freeze timer, or exit inspect mode. |
125
+
126
+ ---
127
+
128
+ ## 5. Agent copy prompt format
129
+
130
+ When you click **Copy Prompt**, AgentLens compiles your visual pins into a structured markdown document. Below is an example of the output generated:
131
+
132
+ ````markdown
133
+ ### AgentLens: Visual UI Feedback (2 items)
134
+ **Context:** Route: `/dashboard` | Viewport: `1440 × 900px` (Desktop (>= 1024px))
135
+ **Timestamp:** 08:30 PM
136
+
137
+ Please implement the following visual and code adjustments:
138
+
139
+ ---
140
+
141
+ #### Pin #1: <HeroHeader> (button)
142
+ - **Category:** [Style]
143
+ - **Instruction:** "Increase height to 44px, use rounded-full, change background to zinc-900, text to white"
144
+ - **Source Component:** `src/components/HeroHeader.tsx:42`
145
+ - **CSS Selector:** `header > nav > button.cta-primary`
146
+ - **Current Text Snippet:** "Get Started"
147
+ - **Current Classes:** `bg-blue-600 text-white px-4 py-2 rounded-md`
148
+ - **Computed Styles:** box: 138px × 36px | padding: 8px 16px | bg: rgb(37, 99, 235) | color: rgb(255, 255, 255) | radius: 6px
149
+
150
+ #### Pin #2: <ProjectGrid> (div)
151
+ - **Category:** [Layout]
152
+ - **Instruction:** "Reduce grid gap on mobile from gap-8 to gap-4"
153
+ - **Source Component:** `src/components/ProjectGrid.tsx:18`
154
+ - **CSS Selector:** `section#projects > div.grid`
155
+ - **Current Classes:** `grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8`
156
+ - **Computed Styles:** box: 1200px × 640px | display: grid | gap: 32px
157
+
158
+ ---
159
+ **Implementation Guidance:**
160
+ 1. Locate each component file indicated above.
161
+ 2. Apply the requested visual styling, copy, or layout adjustments.
162
+ 3. Ensure responsive behavior is preserved across breakpoints.
163
+ ````
164
+
165
+ ---
166
+
167
+ ## 6. How to submit feature request
168
+
169
+ If you have suggestions, feature requests, or improvements, please email me at:
170
+
171
+ **[sknayyar.sk@gmail.com](mailto:sknayyar.sk@gmail.com)**
172
+
173
+ ---
174
+
175
+ ## 7. License
176
+
177
+ This project is licensed under the [MIT License](LICENSE).
@@ -0,0 +1,3 @@
1
+ import { default as React } from 'react';
2
+ import { AgentLensProps } from './types';
3
+ export declare const AgentLens: React.FC<AgentLensProps>;
@@ -0,0 +1,13 @@
1
+ import { default as React } from 'react';
2
+ interface ArcDockProps {
3
+ isInspectActive: boolean;
4
+ pinCount: number;
5
+ isTrayOpen: boolean;
6
+ freezeCountdown: number | null;
7
+ onToggleInspect: () => void;
8
+ onToggleTray: () => void;
9
+ onTriggerFreeze: () => void;
10
+ onCopyPrompt: () => void;
11
+ }
12
+ export declare const ArcDock: React.FC<ArcDockProps>;
13
+ export {};
@@ -0,0 +1,8 @@
1
+ import { default as React } from 'react';
2
+ interface ArcInspectorProps {
3
+ isActive: boolean;
4
+ onSelectElement: (element: HTMLElement) => void;
5
+ shadowHost: HTMLElement | null;
6
+ }
7
+ export declare const ArcInspector: React.FC<ArcInspectorProps>;
8
+ export {};
@@ -0,0 +1,9 @@
1
+ import { default as React } from 'react';
2
+ import { AgentPin } from '../types';
3
+ interface ArcPinBadgeProps {
4
+ pin: AgentPin;
5
+ isActive: boolean;
6
+ onClick: () => void;
7
+ }
8
+ export declare const ArcPinBadge: React.FC<ArcPinBadgeProps>;
9
+ export {};
@@ -0,0 +1,10 @@
1
+ import { default as React } from 'react';
2
+ import { AgentPin, PinCategory } from '../types';
3
+ interface ArcPopoverProps {
4
+ pin: AgentPin;
5
+ onSave: (instruction: string, category: PinCategory) => void;
6
+ onDelete: () => void;
7
+ onClose: () => void;
8
+ }
9
+ export declare const ArcPopover: React.FC<ArcPopoverProps>;
10
+ export {};
@@ -0,0 +1,12 @@
1
+ import { default as React } from 'react';
2
+ import { AgentPin } from '../types';
3
+ interface ArcTrayProps {
4
+ pins: AgentPin[];
5
+ isOpen: boolean;
6
+ onSelectPin: (pin: AgentPin) => void;
7
+ onDeletePin: (pinId: string) => void;
8
+ onClearAll: () => void;
9
+ onClose: () => void;
10
+ }
11
+ export declare const ArcTray: React.FC<ArcTrayProps>;
12
+ export {};
@@ -0,0 +1,25 @@
1
+ import { default as React } from 'react';
2
+ export declare const LensIcon: React.FC<{
3
+ size?: number;
4
+ }>;
5
+ export declare const PinIcon: React.FC<{
6
+ size?: number;
7
+ }>;
8
+ export declare const CopyIcon: React.FC<{
9
+ size?: number;
10
+ }>;
11
+ export declare const CheckIcon: React.FC<{
12
+ size?: number;
13
+ }>;
14
+ export declare const TrashIcon: React.FC<{
15
+ size?: number;
16
+ }>;
17
+ export declare const CloseIcon: React.FC<{
18
+ size?: number;
19
+ }>;
20
+ export declare const ListIcon: React.FC<{
21
+ size?: number;
22
+ }>;
23
+ export declare const FreezeIcon: React.FC<{
24
+ size?: number;
25
+ }>;
@@ -0,0 +1,5 @@
1
+ import { ElementMetadata } from '../types';
2
+ /**
3
+ * Extracts comprehensive metadata for an inspected element
4
+ */
5
+ export declare function extractElementMetadata(element: HTMLElement): ElementMetadata;
@@ -0,0 +1,5 @@
1
+ import { AgentPin } from '../types';
2
+ /**
3
+ * Compiles a list of visual pins into a structured prompt for AI coding agents
4
+ */
5
+ export declare function compileAgentPrompt(pins: AgentPin[]): string;
@@ -0,0 +1,4 @@
1
+ export { AgentLens } from './AgentLens';
2
+ export { compileAgentPrompt } from './core/prompt-compiler';
3
+ export { extractElementMetadata } from './core/extractor';
4
+ export type { AgentLensProps, AgentPin, ElementMetadata, PinCategory, ComputedStyleMetrics, } from './types';
@@ -0,0 +1,4 @@
1
+ export { AgentLens } from './AgentLens';
2
+ export { compileAgentPrompt } from './core/prompt-compiler';
3
+ export { extractElementMetadata } from './core/extractor';
4
+ export type { AgentLensProps, AgentPin, ElementMetadata, PinCategory, ComputedStyleMetrics, } from './types';