vite-plugin-specter 0.6.0 → 0.7.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
@@ -1,8 +1,8 @@
1
1
  # Specter
2
2
 
3
- **Hover any element on your dev site. See its styles. Copy to AI.**
3
+ **Point at any element on your dev site. Mark what to change — with exact values and a source anchor — and hand it to your AI.**
4
4
 
5
- Specter is a Vite plugin that adds an element inspector overlay to your dev server. Toggle it on, hover any element to see its styles, component name, and spacing. Copy with one shortcut and paste into your AI assistant for one-shot edits. Specter is automatically stripped from production builds.
5
+ Specter is a Vite plugin that overlays an element inspector on your dev server. Hover any element to see its styles, component name, and spacing; measure gaps Figma-style; mark elements as **Specs** with a plain-language note; then copy them all to your AI assistant — each one carries the exact current values and a greppable source anchor, so there's no "which element?" and no "what's the current value?". Optionally, push your Specs straight into Claude Code with `/spectify`. Specter is automatically stripped from production builds.
6
6
 
7
7
  ## Requirements
8
8
 
@@ -46,51 +46,84 @@ If you ever need Specter gone entirely, remove `specter()` from the Vite config
46
46
 
47
47
  ### Toggle on/off
48
48
 
49
- Press **Ctrl+Option+Z** to enter Specter mode. A small zap icon appears at the bottom-left. Press again (or Esc) to exit.
49
+ Press **Ctrl+Option+Z** to activate Specter. A small zap icon appears at the bottom-left. Press again (or **Esc**) to hide it — your Specs are kept and reappear when you reactivate.
50
50
 
51
- ### Inspect an element
51
+ ### Three modes
52
52
 
53
- Once active, just **hover** any element. A tooltip shows:
53
+ Specter has three modes; switching mode only changes *what's shown on screen* — you can mark a Spec in any of them.
54
+
55
+ | Mode | Enter | Shows |
56
+ |------|-------|-------|
57
+ | **Properties** (default) | — | Styles tooltip on hover |
58
+ | **Measure** | tap **Option** | Figma-style spacing to neighbors |
59
+ | **Comment** | **C** | Just an outline — for clean design review |
60
+
61
+ ### Inspect an element (Properties mode)
62
+
63
+ **Hover** any element. A tooltip shows:
54
64
 
55
65
  - HTML tag + React/Vue component name + dimensions
56
66
  - Text content (truncated)
57
67
  - Font: family, weight, size, line-height
58
- - Color (with hex) and background
68
+ - Color (with hex) and background — flagged `(hover)` if the value comes from a `:hover` rule
59
69
  - Padding, margin, border-radius (if non-zero)
60
70
  - Display + gap + flex direction
61
71
 
62
- ### Copy to clipboard
72
+ ### Measure spacing (Measure mode)
73
+
74
+ Tap **Option** to switch to Measure mode. Hover any element to see distances to its surrounding neighbors. Press **M** while hovering to **pin** that element, then hover another to measure the gap or inset between the two; **M** again unpins. Tap **Option** again to return to Properties.
63
75
 
64
- Press **Cmd+C** while hovering. The element info is copied in an AI-optimized format. Paste it into Claude, Cursor, or any AI assistant and say what you want changed.
76
+ ### Mark a Spec (and optionally annotate)
65
77
 
66
- ### Measure mode
78
+ Press **P** while hovering an element to mark it as a **Spec**. A note box opens on the element — type the change you want ("reduce width to 320", "tighten padding to 8px") and press **Enter**, or just leave it empty for a plain mark. Numbered badges appear on each marked element. Mark as many as you like across the page.
67
79
 
68
- Tap **Option** to switch to Measure mode. Hover any element to see distance measurements to its surrounding neighbors (like Figma's spacing view). Tap **Option** again to return to Properties mode.
80
+ ### Comment mode
69
81
 
70
- ### Pin an element
82
+ Press **C** for Comment mode: the props/measure overlays hide and you get just a hover outline — good for talking through a design without visual noise. Specs still capture full properties underneath, so a Comment-mode Spec copies exactly like any other.
71
83
 
72
- In Measure mode, press **M** while hovering to pin that element. Then hover any other element to measure the gap or inset between the two. Press **Cmd+C** to copy the measurement. Press **Esc** to clear the pin.
84
+ ### Specs side panel
73
85
 
74
- ### Multi-select
86
+ Press **L** to open the Specs review panel. It lists every Spec; hover a row to scroll to and highlight its element; edit or delete notes inline. Specs survive a reload (saved to `localStorage` per URL).
75
87
 
76
- Press **P** while hovering an element to pick it. Numbered badges appear on each picked element. Press **Cmd+C** to copy all selected elements at once. Press **Esc** to clear the selection.
88
+ ### Copy to your AI
77
89
 
78
- ### Annotate a change (skip the re-explaining)
90
+ Press **Cmd+C**:
79
91
 
80
- Press **N** while hovering an element to attach a change note to it. A small field opens on the element — type what you want ("reduce width to 320", "tighten padding to 8px"), press **Enter** to save. The element is added to the selection and its badge shows a chip with your note. Annotate as many issues across the page as you like, then press **Cmd+C** once.
92
+ - **With Specs marked** → copies **all** of them at once. Each block leads with your `✏️ CHANGE:` note (if any).
93
+ - **With nothing marked** → copies the hovered element's properties (or, in Measure mode, the measurement).
81
94
 
82
- Each element's copied block now leads with your instruction:
95
+ The copied format is lean and AI-ready — the current values plus a `find:` line that anchors the element in your source (test-id → id → aria-label → unique text → class → CSS path), so the assistant greps straight to the code:
83
96
 
84
97
  ```
85
- [Specter 1/3]
86
- ✏️ CHANGE: reduce width to 320, tighten vertical padding
87
- <button>.btn-primary Button 200×48
88
- font: Inter 600 14/20
89
- padding: 12px 20px
90
- ...
98
+ [Specter 1/2]
99
+ ✏️ CHANGE: tighten the vertical padding to 8px
100
+ <button> .btn-primary "Book a demo" 200×48
101
+ find: .btn-primary
102
+ font: Inter 600 14/20 · color: #fff · bg: #4f46e5 · padding: 12px 20px · radius: 10px · display: inline-flex
103
+
104
+ ---
105
+
106
+ [Specter 2/2]
107
+ ✏️ CHANGE: make this text darker — it fails contrast
108
+ <p> .hero-sub "Analytics that…" 560×57
109
+ find: .hero-sub
110
+ font: Inter 400 19/28.5 · color: #c7cbd1
91
111
  ```
92
112
 
93
- So when you paste into your AI assistant, it already knows both *what* to change and *which element* — no follow-up typing. Notes are ephemeral (cleared on **Esc** or when you toggle Specter off).
113
+ Paste into Claude, Cursor, or any AI assistant — the instructions travel with the elements, so there's nothing left to explain.
114
+
115
+ ## Share comments with another person
116
+
117
+ Specs aren't only for your AI — you can send them to a **person**. Mark comments on a page, open the Specs panel (**L**), and click **Share**. Specter copies a link; whoever opens it — on the same page, with Specter installed — sees your comments re-anchored on the exact same elements.
118
+
119
+ - **Comments only.** Only your notes and how to re-find each element travel — never the CSS properties or measurements. You're sharing feedback, not internals.
120
+ - **Same page, same element.** Comments re-anchor by a source locator, not screen coordinates. If the page changed so an element is gone or different, that comment shows as **MISSING** in the panel (with the reason) instead of landing on the wrong spot.
121
+ - **A link, or a file.** Small reviews copy as a normal link (`…/pricing#spx=…`) you paste into Slack or a message — the link is both the destination and the payload, so it opens the right page automatically. A large batch (or a page that uses `#`-routing) downloads a `comments.specter.json` file to send instead; use the **Import** button to open one you receive.
122
+ - **Zero backend.** The comments travel inside the link or file itself — no accounts, no server. One-way (no threads).
123
+
124
+ **Both people need Specter (v0.7+).** This is where the **browser extension** shines: it works on any deployed or staging URL, so two people looking at the same prototype can trade feedback without a shared dev server. A share link opened without Specter just shows the normal page — nothing breaks.
125
+
126
+ > Specter also ships as a **browser extension** for Chrome and Firefox, which runs on *any* website (no Vite required). The Share Comments flow above is designed for it. See the [GitHub repo](https://github.com/setugk/vite-plugin-specter) for links.
94
127
 
95
128
  ## Shortcut reference
96
129
 
@@ -98,36 +131,39 @@ So when you paste into your AI assistant, it already knows both *what* to change
98
131
  |--------|----------|
99
132
  | Toggle Specter | **Ctrl+Option+Z** |
100
133
  | Inspect element | Hover (while active) |
101
- | Copy properties | **Cmd+C** |
102
- | Switch to Measure mode | **Option** (tap) |
103
- | Pin element for measuring | **M** (in Measure mode) |
104
- | Pick element (multi-select) | **P** (in Properties mode) |
105
- | Annotate a change | **N** (in Properties mode) |
106
- | Clear pin / clear selection | **Esc** |
107
- | Exit Specter | **Esc** (when nothing selected/pinned) |
134
+ | Mark a Spec (+ optional note) | **P** |
135
+ | Copy (all Specs, or hovered element) | **Cmd+C** |
136
+ | Measure mode (toggle) | **Option** (tap) |
137
+ | Pin / unpin for measuring | **M** (in Measure mode) |
138
+ | Comment mode (toggle) | **C** |
139
+ | Specs panel (toggle) | **L** |
140
+ | Close panel / hide Specter | **Esc** |
141
+
142
+ ## Optional: push Specs straight to Claude Code (`/spectify`)
108
143
 
109
- ## Workflow with AI assistants
144
+ Instead of copy-paste, Specter can auto-sync your Specs to a local bridge that Claude Code reads on demand. Enable it in your Vite config:
145
+
146
+ ```ts
147
+ specter({ claudeBridge: true })
148
+ ```
110
149
 
111
- 1. Toggle Specter (Ctrl+Option+Z)
112
- 2. Hover the element you want to change
113
- 3. Either press **Cmd+C** to copy its properties, or press **N** to annotate the exact change you want first
114
- 4. Repeat **N** on every element you want to change, then **Cmd+C** once to copy them all
115
- 5. Paste into your AI assistant's chat — the instructions travel with the elements, so there's nothing left to explain
150
+ With it on, every Spec you mark auto-syncs (watch for the sync dot in the panel) to a local bridge at `http://127.0.0.1:8787`. Run the bridge (`node node_modules/vite-plugin-specter/mcp-bridge/server.mjs`, or register it in your project's `.mcp.json` so your IDE launches it), then in Claude Code run **`/spectify`** — it pulls whatever's currently synced and implements it. See [`mcp-bridge/`](https://github.com/setugk/vite-plugin-specter/tree/main/mcp-bridge) for setup. One bridge can serve several projects; `/spectify <port>` scopes to one.
116
151
 
117
- No more "which element?", no more "what's the current value?", and now no more re-typing the change. One paste gives your assistant everything it needs.
152
+ `claudeBridge` is **off by default** — the shipped plugin never opens a connection unless you enable it.
118
153
 
119
154
  ## Configuration
120
155
 
121
156
  ```ts
122
- specter() // Default shortcuts
123
- specter({ shortcuts: { activate: 'ctrl+shift+i' } }) // Custom activate shortcut
157
+ specter() // defaults
158
+ specter({ shortcuts: { activate: 'ctrl+shift+i' } }) // custom activate shortcut
159
+ specter({ claudeBridge: true }) // enable the Claude Code bridge
124
160
  ```
125
161
 
126
162
  The `activate` shortcut accepts any combination of `ctrl`, `alt`, `shift`, `meta`/`cmd`, and a key. Default is `ctrl+alt+z`.
127
163
 
128
164
  ## Optional: `data-style` attribute
129
165
 
130
- Tag elements with `data-style="keyName"` to show the style object key in the inspector:
166
+ Tag elements with `data-style="keyName"` to surface the style-object key in the inspector and the copied output:
131
167
 
132
168
  ```jsx
133
169
  <h1 data-style="pageTitle">Welcome</h1>