rune-grab 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 Rune Labs
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 ADDED
@@ -0,0 +1,77 @@
1
+ # rune-grab
2
+
3
+ Point at any UI element, grab its context, and send it to Claude, Cursor, Codex, or Claude Code.
4
+
5
+ Works with React, Vue, Svelte, or plain HTML.
6
+
7
+ ## Install
8
+
9
+ Run this from your project root:
10
+
11
+ ```bash
12
+ npx rune-grab init
13
+ ```
14
+
15
+ Supports Vite, Next.js, and Webpack. Only loads in development — nothing ships to production.
16
+
17
+ Run your dev server and press **Cmd+Shift+G** to start grabbing.
18
+
19
+ ## How it works
20
+
21
+ A small floating menu appears at the bottom of your page during development. It has two modes:
22
+
23
+ **Screenshot** — drag a rectangle to capture a region as a screenshot with context.
24
+
25
+ **Inspect** — hover over any element to see its component name and file path. Click it, optionally type a comment, and press Enter to send.
26
+
27
+ Everything is copied to your clipboard. On localhost, rune-grab auto-detects React, Vue, and Svelte components with file paths and line numbers.
28
+
29
+ ## Auto-paste (optional)
30
+
31
+ By default, grabs go to your clipboard and you paste manually. If you want rune-grab to automatically switch to Claude, Cursor, or Codex and paste for you:
32
+
33
+ ```json
34
+ {
35
+ "scripts": {
36
+ "dev": "rune-grab serve & your-dev-command"
37
+ }
38
+ }
39
+ ```
40
+
41
+ Then flip the auto-paste toggle in the floating menu. macOS only.
42
+
43
+ ## Configuration (optional)
44
+
45
+ Everything works out of the box. If you want to change the shortcut, default target, or other behavior, call `init()` in your code:
46
+
47
+ ```ts
48
+ import { init } from 'rune-grab'
49
+
50
+ init({
51
+ shortcut: 'Meta+Shift+K',
52
+ target: 'claude',
53
+ skipComponents: ['StyledButton']
54
+ })
55
+ ```
56
+
57
+ | Option | Type | Default | Description |
58
+ |--------|------|---------|-------------|
59
+ | `shortcut` | `string` | `'Meta+Shift+G'` | Keyboard shortcut |
60
+ | `target` | `TargetApp` | `'clipboard'` | Default target: `clipboard`, `claude`, `cursor`, `codex`, `claude-code` |
61
+ | `showTargetPicker` | `boolean` | `true` | Show target picker in menu |
62
+ | `maxStackDepth` | `number` | `3` | Component stack trace depth |
63
+ | `skipComponents` | `string[]` | `[]` | Component names to ignore |
64
+ | `onGrab` | `(result) => void` | — | Callback on grab |
65
+ | `onToggle` | `(active) => void` | — | Callback on toggle |
66
+
67
+ ## Uninstall
68
+
69
+ Remove the package and delete the snippet that `init` added to your project (search for `rune-grab` in your `index.html` or layout file).
70
+
71
+ ```bash
72
+ npm uninstall rune-grab
73
+ ```
74
+
75
+ ## License
76
+
77
+ MIT
package/dist/cli.js ADDED
@@ -0,0 +1,350 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/cli.ts
4
+ import { fileURLToPath } from "url";
5
+ import { dirname, join as join2 } from "path";
6
+ import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
7
+ import { execSync as execSync2 } from "child_process";
8
+
9
+ // src/targets/helper-server.ts
10
+ import { createServer } from "http";
11
+ import { execSync } from "child_process";
12
+ import { writeFileSync, mkdtempSync, rmSync, readFileSync, existsSync } from "fs";
13
+ import { tmpdir } from "os";
14
+ import { join } from "path";
15
+
16
+ // src/targets/app.ts
17
+ var APP_BUNDLE_IDS = {
18
+ claude: "com.anthropic.claudefordesktop",
19
+ cursor: "com.todesktop.230313mzl4w4u92",
20
+ codex: "com.openai.codex",
21
+ "claude-code": "",
22
+ clipboard: ""
23
+ };
24
+ var APP_NAMES = {
25
+ claude: "Claude",
26
+ cursor: "Cursor",
27
+ codex: "Codex",
28
+ "claude-code": "Claude Code",
29
+ clipboard: "Clipboard"
30
+ };
31
+
32
+ // src/targets/helper-server.ts
33
+ var DEFAULT_PORT = 19274;
34
+ var cachedIIFE = null;
35
+ function copyText(text) {
36
+ execSync("pbcopy", { input: text, encoding: "utf-8" });
37
+ }
38
+ function copyImage(base64DataUrl) {
39
+ const tmpDir = mkdtempSync(join(tmpdir(), "rune-grab-"));
40
+ const imgPath = join(tmpDir, "grab.png");
41
+ const base64 = base64DataUrl.replace(/^data:image\/\w+;base64,/, "");
42
+ writeFileSync(imgPath, Buffer.from(base64, "base64"));
43
+ return imgPath;
44
+ }
45
+ function activateAndPaste(target) {
46
+ if (target === "claude-code") {
47
+ const script2 = `
48
+ set iTermRunning to false
49
+ tell application "System Events"
50
+ if exists (process "iTerm2") then set iTermRunning to true
51
+ end tell
52
+ if iTermRunning then
53
+ tell application "iTerm2" to activate
54
+ else
55
+ tell application "Terminal" to activate
56
+ end if
57
+ delay 0.3
58
+ tell application "System Events"
59
+ keystroke "v" using command down
60
+ end tell
61
+ `;
62
+ execSync(`osascript -e '${script2.replace(/'/g, `'"'"'`)}'`);
63
+ return;
64
+ }
65
+ const bundleId = APP_BUNDLE_IDS[target];
66
+ if (!bundleId) return;
67
+ const script = `
68
+ tell application id "${bundleId}"
69
+ activate
70
+ end tell
71
+ delay 0.3
72
+ tell application "System Events"
73
+ keystroke "v" using command down
74
+ end tell
75
+ `;
76
+ execSync(`osascript -e '${script.replace(/'/g, `'"'"'`)}'`);
77
+ }
78
+ function parseBody(req) {
79
+ return new Promise((resolve, reject) => {
80
+ let body = "";
81
+ req.on("data", (chunk) => body += chunk);
82
+ req.on("end", () => {
83
+ try {
84
+ resolve(JSON.parse(body));
85
+ } catch (e) {
86
+ reject(e);
87
+ }
88
+ });
89
+ req.on("error", reject);
90
+ });
91
+ }
92
+ function setCors(res) {
93
+ res.setHeader("Access-Control-Allow-Origin", "*");
94
+ res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
95
+ res.setHeader("Access-Control-Allow-Headers", "Content-Type");
96
+ }
97
+ function loadIIFE(iifePath2) {
98
+ if (cachedIIFE) return cachedIIFE;
99
+ if (iifePath2 && existsSync(iifePath2)) {
100
+ cachedIIFE = readFileSync(iifePath2, "utf-8");
101
+ return cachedIIFE;
102
+ }
103
+ return null;
104
+ }
105
+ function startHelperServer(port = DEFAULT_PORT, iifePath2) {
106
+ loadIIFE(iifePath2);
107
+ const server = createServer(async (req, res) => {
108
+ setCors(res);
109
+ if (req.method === "OPTIONS") {
110
+ res.writeHead(204);
111
+ res.end();
112
+ return;
113
+ }
114
+ if (req.method === "GET" && req.url === "/health") {
115
+ res.writeHead(200, { "Content-Type": "application/json" });
116
+ res.end(JSON.stringify({ ok: true, version: "0.1.0" }));
117
+ return;
118
+ }
119
+ if (req.method === "GET" && req.url === "/rune-grab.js") {
120
+ const script = cachedIIFE;
121
+ if (script) {
122
+ res.writeHead(200, { "Content-Type": "application/javascript", "Cache-Control": "no-cache" });
123
+ res.end(script);
124
+ } else {
125
+ res.writeHead(404, { "Content-Type": "application/json" });
126
+ res.end(JSON.stringify({ error: "IIFE bundle not found" }));
127
+ }
128
+ return;
129
+ }
130
+ if (req.method === "POST" && req.url === "/paste") {
131
+ let tmpImgPath = null;
132
+ try {
133
+ const data = await parseBody(req);
134
+ const { target, text, image } = data;
135
+ if (image) {
136
+ tmpImgPath = copyImage(image);
137
+ execSync(`osascript -e 'set the clipboard to (read (POSIX file "${tmpImgPath}") as \xABclass PNGf\xBB)'`);
138
+ } else {
139
+ copyText(text);
140
+ }
141
+ activateAndPaste(target);
142
+ res.writeHead(200, { "Content-Type": "application/json" });
143
+ res.end(JSON.stringify({ ok: true, target, app: APP_NAMES[target] }));
144
+ } catch (e) {
145
+ res.writeHead(500, { "Content-Type": "application/json" });
146
+ res.end(JSON.stringify({ ok: false, error: e.message }));
147
+ } finally {
148
+ if (tmpImgPath) {
149
+ try {
150
+ rmSync(tmpImgPath, { recursive: true });
151
+ } catch {
152
+ }
153
+ }
154
+ }
155
+ return;
156
+ }
157
+ res.writeHead(404, { "Content-Type": "application/json" });
158
+ res.end(JSON.stringify({ error: "Not found" }));
159
+ });
160
+ server.listen(port, "127.0.0.1", () => {
161
+ console.log(`
162
+ rune-grab running on http://127.0.0.1:${port}`);
163
+ if (cachedIIFE) {
164
+ console.log(` Add this to your HTML:`);
165
+ console.log(` <script src="http://localhost:${port}/rune-grab.js"></script>`);
166
+ }
167
+ console.log(` Auto-paste targets: ${Object.values(APP_NAMES).filter(Boolean).join(", ")}
168
+ `);
169
+ });
170
+ process.on("SIGINT", () => {
171
+ server.close();
172
+ process.exit(0);
173
+ });
174
+ process.on("SIGTERM", () => {
175
+ server.close();
176
+ process.exit(0);
177
+ });
178
+ }
179
+
180
+ // src/cli.ts
181
+ var __dirname = dirname(fileURLToPath(import.meta.url));
182
+ var iifePath = join2(__dirname, "rune-grab.iife.global.js");
183
+ var args = process.argv.slice(2);
184
+ var command = args[0];
185
+ var SNIPPET_VITE = `
186
+ <!-- rune-grab: dev-only element grabber -->
187
+ <script type="module">if(import.meta.env.DEV)import('rune-grab')</script>`;
188
+ var SNIPPET_NEXT_APP = `
189
+ {/* rune-grab: dev-only element grabber */}
190
+ {process.env.NODE_ENV === 'development' && <script src="https://unpkg.com/rune-grab/dist/rune-grab.iife.global.js" />}`;
191
+ var SNIPPET_NEXT_PAGES = `
192
+ {/* rune-grab: dev-only element grabber */}
193
+ {process.env.NODE_ENV === 'development' && <script src="https://unpkg.com/rune-grab/dist/rune-grab.iife.global.js" />}`;
194
+ var SNIPPET_WEBPACK = `
195
+ // rune-grab: dev-only element grabber
196
+ if (process.env.NODE_ENV === 'development') import('rune-grab');`;
197
+ function detect(cwd) {
198
+ if (existsSync2(join2(cwd, "vite.config.ts")) || existsSync2(join2(cwd, "vite.config.js")) || existsSync2(join2(cwd, "vite.config.mts"))) {
199
+ const indexHtml2 = join2(cwd, "index.html");
200
+ if (existsSync2(indexHtml2)) return { framework: "vite", file: indexHtml2 };
201
+ }
202
+ if (existsSync2(join2(cwd, "next.config.js")) || existsSync2(join2(cwd, "next.config.mjs")) || existsSync2(join2(cwd, "next.config.ts"))) {
203
+ const appLayouts = [
204
+ join2(cwd, "app", "layout.tsx"),
205
+ join2(cwd, "app", "layout.jsx"),
206
+ join2(cwd, "src", "app", "layout.tsx"),
207
+ join2(cwd, "src", "app", "layout.jsx")
208
+ ];
209
+ for (const f of appLayouts) {
210
+ if (existsSync2(f)) return { framework: "next-app", file: f };
211
+ }
212
+ const pagesDocuments = [
213
+ join2(cwd, "pages", "_document.tsx"),
214
+ join2(cwd, "pages", "_document.jsx"),
215
+ join2(cwd, "src", "pages", "_document.tsx"),
216
+ join2(cwd, "src", "pages", "_document.jsx")
217
+ ];
218
+ for (const f of pagesDocuments) {
219
+ if (existsSync2(f)) return { framework: "next-pages", file: f };
220
+ }
221
+ return { framework: "next-app", file: null };
222
+ }
223
+ if (existsSync2(join2(cwd, "webpack.config.js")) || existsSync2(join2(cwd, "webpack.config.ts"))) {
224
+ const entries = [
225
+ join2(cwd, "src", "index.tsx"),
226
+ join2(cwd, "src", "index.ts"),
227
+ join2(cwd, "src", "index.jsx"),
228
+ join2(cwd, "src", "index.js"),
229
+ join2(cwd, "src", "main.tsx"),
230
+ join2(cwd, "src", "main.ts")
231
+ ];
232
+ for (const f of entries) {
233
+ if (existsSync2(f)) return { framework: "webpack", file: f };
234
+ }
235
+ }
236
+ const indexHtml = join2(cwd, "index.html");
237
+ if (existsSync2(indexHtml)) {
238
+ const content = readFileSync2(indexHtml, "utf-8");
239
+ if (content.includes("import.meta")) return { framework: "vite", file: indexHtml };
240
+ }
241
+ return { framework: "unknown", file: null };
242
+ }
243
+ function alreadyInstalled(content) {
244
+ return content.includes("rune-grab");
245
+ }
246
+ function detectPackageManager(cwd) {
247
+ if (existsSync2(join2(cwd, "pnpm-lock.yaml"))) return "pnpm";
248
+ if (existsSync2(join2(cwd, "yarn.lock"))) return "yarn";
249
+ if (existsSync2(join2(cwd, "bun.lockb")) || existsSync2(join2(cwd, "bun.lock"))) return "bun";
250
+ return "npm";
251
+ }
252
+ function installPackage(cwd) {
253
+ if (existsSync2(join2(cwd, "node_modules", "rune-grab"))) return;
254
+ const pm = detectPackageManager(cwd);
255
+ const cmd = pm === "yarn" ? "yarn add -D rune-grab" : `${pm} install -D rune-grab`;
256
+ console.log(`
257
+ Installing rune-grab with ${pm}...`);
258
+ try {
259
+ execSync2(cmd, { cwd, stdio: "pipe" });
260
+ } catch {
261
+ console.log(` Could not install automatically. Run: ${cmd}
262
+ `);
263
+ }
264
+ }
265
+ function initCommand() {
266
+ const cwd = process.cwd();
267
+ installPackage(cwd);
268
+ const { framework, file } = detect(cwd);
269
+ if (framework === "unknown" || !file) {
270
+ console.log("\n Could not detect your framework.\n");
271
+ console.log(" Add this to your HTML before </body>:\n");
272
+ console.log(' <script type="module">');
273
+ console.log(" if (import.meta.env.DEV) import('rune-grab')");
274
+ console.log(" </script>\n");
275
+ return;
276
+ }
277
+ const content = readFileSync2(file, "utf-8");
278
+ if (alreadyInstalled(content)) {
279
+ console.log(`
280
+ rune-grab is already set up in ${relative(cwd, file)}
281
+ `);
282
+ return;
283
+ }
284
+ let updated;
285
+ switch (framework) {
286
+ case "vite": {
287
+ updated = content.replace("</body>", `${SNIPPET_VITE}
288
+ </body>`);
289
+ break;
290
+ }
291
+ case "next-app": {
292
+ updated = content.replace("</body>", `${SNIPPET_NEXT_APP}
293
+ </body>`);
294
+ break;
295
+ }
296
+ case "next-pages": {
297
+ if (content.includes("<Main")) {
298
+ updated = content.replace(/<Main\s*\/?>/, `$&${SNIPPET_NEXT_PAGES}`);
299
+ } else {
300
+ updated = content.replace("</Head>", `</Head>${SNIPPET_NEXT_PAGES}`);
301
+ }
302
+ break;
303
+ }
304
+ case "webpack": {
305
+ updated = SNIPPET_WEBPACK + "\n" + content;
306
+ break;
307
+ }
308
+ default:
309
+ return;
310
+ }
311
+ writeFileSync2(file, updated, "utf-8");
312
+ const label = framework === "vite" ? "Vite" : framework === "next-app" ? "Next.js (App Router)" : framework === "next-pages" ? "Next.js (Pages Router)" : "Webpack";
313
+ console.log(`
314
+ rune-grab installed for ${label}`);
315
+ console.log(` Modified: ${relative(cwd, file)}`);
316
+ console.log(`
317
+ Run your dev server and press Cmd+Shift+G to start grabbing.
318
+ `);
319
+ }
320
+ function relative(from, to) {
321
+ if (to.startsWith(from)) {
322
+ const rel = to.slice(from.length);
323
+ return rel.startsWith("/") ? rel.slice(1) : rel;
324
+ }
325
+ return to;
326
+ }
327
+ function printUsage() {
328
+ console.log(`
329
+ rune-grab
330
+
331
+ Usage:
332
+ npx rune-grab init Set up rune-grab in your project
333
+ npx rune-grab serve [--port PORT] Start the dev server (for auto-paste)
334
+ `);
335
+ }
336
+ switch (command) {
337
+ case "init":
338
+ initCommand();
339
+ break;
340
+ case "serve": {
341
+ const portIdx = args.indexOf("--port");
342
+ const port = portIdx !== -1 ? parseInt(args[portIdx + 1], 10) : DEFAULT_PORT;
343
+ startHelperServer(port, iifePath);
344
+ break;
345
+ }
346
+ default:
347
+ printUsage();
348
+ break;
349
+ }
350
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli.ts","../src/targets/helper-server.ts","../src/targets/app.ts"],"sourcesContent":["import { fileURLToPath } from 'node:url';\nimport { dirname, join } from 'node:path';\nimport { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { execSync } from 'node:child_process';\nimport { startHelperServer, DEFAULT_PORT } from './targets/helper-server.js';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst iifePath = join(__dirname, 'rune-grab.iife.global.js');\n\nconst args = process.argv.slice(2);\nconst command = args[0];\n\nconst SNIPPET_VITE = `\\n<!-- rune-grab: dev-only element grabber -->\\n<script type=\"module\">if(import.meta.env.DEV)import('rune-grab')</script>`;\n\nconst SNIPPET_NEXT_APP = `\\n{/* rune-grab: dev-only element grabber */}\\n{process.env.NODE_ENV === 'development' && <script src=\"https://unpkg.com/rune-grab/dist/rune-grab.iife.global.js\" />}`;\n\nconst SNIPPET_NEXT_PAGES = `\\n {/* rune-grab: dev-only element grabber */}\\n {process.env.NODE_ENV === 'development' && <script src=\"https://unpkg.com/rune-grab/dist/rune-grab.iife.global.js\" />}`;\n\nconst SNIPPET_WEBPACK = `\\n// rune-grab: dev-only element grabber\\nif (process.env.NODE_ENV === 'development') import('rune-grab');`;\n\ntype Framework = 'vite' | 'next-app' | 'next-pages' | 'webpack' | 'unknown';\n\nfunction detect(cwd: string): { framework: Framework; file: string | null } {\n if (existsSync(join(cwd, 'vite.config.ts')) || existsSync(join(cwd, 'vite.config.js')) || existsSync(join(cwd, 'vite.config.mts'))) {\n const indexHtml = join(cwd, 'index.html');\n if (existsSync(indexHtml)) return { framework: 'vite', file: indexHtml };\n }\n\n if (existsSync(join(cwd, 'next.config.js')) || existsSync(join(cwd, 'next.config.mjs')) || existsSync(join(cwd, 'next.config.ts'))) {\n const appLayouts = [\n join(cwd, 'app', 'layout.tsx'),\n join(cwd, 'app', 'layout.jsx'),\n join(cwd, 'src', 'app', 'layout.tsx'),\n join(cwd, 'src', 'app', 'layout.jsx'),\n ];\n for (const f of appLayouts) {\n if (existsSync(f)) return { framework: 'next-app', file: f };\n }\n\n const pagesDocuments = [\n join(cwd, 'pages', '_document.tsx'),\n join(cwd, 'pages', '_document.jsx'),\n join(cwd, 'src', 'pages', '_document.tsx'),\n join(cwd, 'src', 'pages', '_document.jsx'),\n ];\n for (const f of pagesDocuments) {\n if (existsSync(f)) return { framework: 'next-pages', file: f };\n }\n\n return { framework: 'next-app', file: null };\n }\n\n if (existsSync(join(cwd, 'webpack.config.js')) || existsSync(join(cwd, 'webpack.config.ts'))) {\n const entries = [\n join(cwd, 'src', 'index.tsx'),\n join(cwd, 'src', 'index.ts'),\n join(cwd, 'src', 'index.jsx'),\n join(cwd, 'src', 'index.js'),\n join(cwd, 'src', 'main.tsx'),\n join(cwd, 'src', 'main.ts'),\n ];\n for (const f of entries) {\n if (existsSync(f)) return { framework: 'webpack', file: f };\n }\n }\n\n const indexHtml = join(cwd, 'index.html');\n if (existsSync(indexHtml)) {\n const content = readFileSync(indexHtml, 'utf-8');\n if (content.includes('import.meta')) return { framework: 'vite', file: indexHtml };\n }\n\n return { framework: 'unknown', file: null };\n}\n\nfunction alreadyInstalled(content: string): boolean {\n return content.includes('rune-grab');\n}\n\nfunction detectPackageManager(cwd: string): 'pnpm' | 'yarn' | 'bun' | 'npm' {\n if (existsSync(join(cwd, 'pnpm-lock.yaml'))) return 'pnpm';\n if (existsSync(join(cwd, 'yarn.lock'))) return 'yarn';\n if (existsSync(join(cwd, 'bun.lockb')) || existsSync(join(cwd, 'bun.lock'))) return 'bun';\n return 'npm';\n}\n\nfunction installPackage(cwd: string): void {\n if (existsSync(join(cwd, 'node_modules', 'rune-grab'))) return;\n\n const pm = detectPackageManager(cwd);\n const cmd = pm === 'yarn' ? 'yarn add -D rune-grab' : `${pm} install -D rune-grab`;\n\n console.log(`\\n Installing rune-grab with ${pm}...`);\n try {\n execSync(cmd, { cwd, stdio: 'pipe' });\n } catch {\n console.log(` Could not install automatically. Run: ${cmd}\\n`);\n }\n}\n\nfunction initCommand(): void {\n const cwd = process.cwd();\n\n installPackage(cwd);\n\n const { framework, file } = detect(cwd);\n\n if (framework === 'unknown' || !file) {\n console.log('\\n Could not detect your framework.\\n');\n console.log(' Add this to your HTML before </body>:\\n');\n console.log(' <script type=\"module\">');\n console.log(' if (import.meta.env.DEV) import(\\'rune-grab\\')');\n console.log(' </script>\\n');\n return;\n }\n\n const content = readFileSync(file, 'utf-8');\n\n if (alreadyInstalled(content)) {\n console.log(`\\n rune-grab is already set up in ${relative(cwd, file)}\\n`);\n return;\n }\n\n let updated: string;\n\n switch (framework) {\n case 'vite': {\n updated = content.replace('</body>', `${SNIPPET_VITE}\\n</body>`);\n break;\n }\n case 'next-app': {\n updated = content.replace('</body>', `${SNIPPET_NEXT_APP}\\n </body>`);\n break;\n }\n case 'next-pages': {\n if (content.includes('<Main')) {\n updated = content.replace(/<Main\\s*\\/?>/, `$&${SNIPPET_NEXT_PAGES}`);\n } else {\n updated = content.replace('</Head>', `</Head>${SNIPPET_NEXT_PAGES}`);\n }\n break;\n }\n case 'webpack': {\n updated = SNIPPET_WEBPACK + '\\n' + content;\n break;\n }\n default:\n return;\n }\n\n writeFileSync(file, updated, 'utf-8');\n\n const label = framework === 'vite' ? 'Vite'\n : framework === 'next-app' ? 'Next.js (App Router)'\n : framework === 'next-pages' ? 'Next.js (Pages Router)'\n : 'Webpack';\n\n console.log(`\\n rune-grab installed for ${label}`);\n console.log(` Modified: ${relative(cwd, file)}`);\n console.log(`\\n Run your dev server and press Cmd+Shift+G to start grabbing.\\n`);\n}\n\nfunction relative(from: string, to: string): string {\n if (to.startsWith(from)) {\n const rel = to.slice(from.length);\n return rel.startsWith('/') ? rel.slice(1) : rel;\n }\n return to;\n}\n\nfunction printUsage(): void {\n console.log(`\n rune-grab\n\n Usage:\n npx rune-grab init Set up rune-grab in your project\n npx rune-grab serve [--port PORT] Start the dev server (for auto-paste)\n`);\n}\n\nswitch (command) {\n case 'init':\n initCommand();\n break;\n case 'serve': {\n const portIdx = args.indexOf('--port');\n const port = portIdx !== -1 ? parseInt(args[portIdx + 1], 10) : DEFAULT_PORT;\n startHelperServer(port, iifePath);\n break;\n }\n default:\n printUsage();\n break;\n}\n","import { createServer, type IncomingMessage, type ServerResponse } from 'node:http';\nimport { execSync } from 'node:child_process';\nimport { writeFileSync, mkdtempSync, rmSync, readFileSync, existsSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\nimport type { TargetApp } from '../core/types.js';\nimport { APP_NAMES, APP_BUNDLE_IDS } from './app.js';\n\nconst DEFAULT_PORT = 19274;\nlet cachedIIFE: string | null = null;\n\ninterface PasteRequest {\n target: TargetApp;\n text: string;\n image: string | null; // base64 data URL\n label: string;\n}\n\nfunction copyText(text: string): void {\n execSync('pbcopy', { input: text, encoding: 'utf-8' });\n}\n\nfunction copyImage(base64DataUrl: string): string {\n const tmpDir = mkdtempSync(join(tmpdir(), 'rune-grab-'));\n const imgPath = join(tmpDir, 'grab.png');\n\n const base64 = base64DataUrl.replace(/^data:image\\/\\w+;base64,/, '');\n writeFileSync(imgPath, Buffer.from(base64, 'base64'));\n\n return imgPath;\n}\n\nfunction activateAndPaste(target: TargetApp): void {\n if (target === 'claude-code') {\n const script = `\n set iTermRunning to false\n tell application \"System Events\"\n if exists (process \"iTerm2\") then set iTermRunning to true\n end tell\n if iTermRunning then\n tell application \"iTerm2\" to activate\n else\n tell application \"Terminal\" to activate\n end if\n delay 0.3\n tell application \"System Events\"\n keystroke \"v\" using command down\n end tell\n `;\n execSync(`osascript -e '${script.replace(/'/g, \"'\\\"'\\\"'\")}'`);\n return;\n }\n\n const bundleId = APP_BUNDLE_IDS[target];\n if (!bundleId) return;\n\n const script = `\n tell application id \"${bundleId}\"\n activate\n end tell\n delay 0.3\n tell application \"System Events\"\n keystroke \"v\" using command down\n end tell\n `;\n execSync(`osascript -e '${script.replace(/'/g, \"'\\\"'\\\"'\")}'`);\n}\n\nfunction parseBody(req: IncomingMessage): Promise<PasteRequest> {\n return new Promise((resolve, reject) => {\n let body = '';\n req.on('data', (chunk) => (body += chunk));\n req.on('end', () => {\n try {\n resolve(JSON.parse(body));\n } catch (e) {\n reject(e);\n }\n });\n req.on('error', reject);\n });\n}\n\nfunction setCors(res: ServerResponse): void {\n res.setHeader('Access-Control-Allow-Origin', '*');\n res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');\n res.setHeader('Access-Control-Allow-Headers', 'Content-Type');\n}\n\nfunction loadIIFE(iifePath?: string): string | null {\n if (cachedIIFE) return cachedIIFE;\n if (iifePath && existsSync(iifePath)) {\n cachedIIFE = readFileSync(iifePath, 'utf-8');\n return cachedIIFE;\n }\n return null;\n}\n\nexport function startHelperServer(port = DEFAULT_PORT, iifePath?: string): void {\n loadIIFE(iifePath);\n\n const server = createServer(async (req, res) => {\n setCors(res);\n\n if (req.method === 'OPTIONS') {\n res.writeHead(204);\n res.end();\n return;\n }\n\n if (req.method === 'GET' && req.url === '/health') {\n res.writeHead(200, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify({ ok: true, version: '0.1.0' }));\n return;\n }\n\n if (req.method === 'GET' && req.url === '/rune-grab.js') {\n const script = cachedIIFE;\n if (script) {\n res.writeHead(200, { 'Content-Type': 'application/javascript', 'Cache-Control': 'no-cache' });\n res.end(script);\n } else {\n res.writeHead(404, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify({ error: 'IIFE bundle not found' }));\n }\n return;\n }\n\n if (req.method === 'POST' && req.url === '/paste') {\n let tmpImgPath: string | null = null;\n try {\n const data = await parseBody(req);\n const { target, text, image } = data;\n\n if (image) {\n tmpImgPath = copyImage(image);\n execSync(`osascript -e 'set the clipboard to (read (POSIX file \"${tmpImgPath}\") as «class PNGf»)'`);\n } else {\n copyText(text);\n }\n\n activateAndPaste(target);\n\n res.writeHead(200, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify({ ok: true, target, app: APP_NAMES[target] }));\n } catch (e: any) {\n res.writeHead(500, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify({ ok: false, error: e.message }));\n } finally {\n if (tmpImgPath) {\n try { rmSync(tmpImgPath, { recursive: true }); } catch { }\n }\n }\n return;\n }\n\n res.writeHead(404, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify({ error: 'Not found' }));\n });\n\n server.listen(port, '127.0.0.1', () => {\n console.log(`\\n rune-grab running on http://127.0.0.1:${port}`);\n if (cachedIIFE) {\n console.log(` Add this to your HTML:`);\n console.log(` <script src=\"http://localhost:${port}/rune-grab.js\"><\\/script>`);\n }\n console.log(` Auto-paste targets: ${Object.values(APP_NAMES).filter(Boolean).join(', ')}\\n`);\n });\n\n process.on('SIGINT', () => {\n server.close();\n process.exit(0);\n });\n process.on('SIGTERM', () => {\n server.close();\n process.exit(0);\n });\n}\n\nexport { DEFAULT_PORT };\n","import type { GrabResult, TargetApp } from '../core/types.js';\nimport { copyToClipboard } from './clipboard.js';\n\nconst HELPER_PORT = 19274;\n\nasync function isHelperRunning(): Promise<boolean> {\n try {\n const ac = new AbortController();\n const timer = setTimeout(() => ac.abort(), 500);\n const res = await fetch(`http://127.0.0.1:${HELPER_PORT}/health`, {\n signal: ac.signal,\n });\n clearTimeout(timer);\n return res.ok;\n } catch {\n return false;\n }\n}\n\nasync function sendToHelper(target: TargetApp, result: GrabResult): Promise<boolean> {\n try {\n const res = await fetch(`http://127.0.0.1:${HELPER_PORT}/paste`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n target,\n text: result.text,\n image: result.image ?? null,\n label: result.label,\n }),\n });\n return res.ok;\n } catch {\n return false;\n }\n}\n\nexport const APP_BUNDLE_IDS: Record<TargetApp, string> = {\n claude: 'com.anthropic.claudefordesktop',\n cursor: 'com.todesktop.230313mzl4w4u92',\n codex: 'com.openai.codex',\n 'claude-code': '',\n clipboard: '',\n};\n\nexport const APP_NAMES: Record<TargetApp, string> = {\n claude: 'Claude',\n cursor: 'Cursor',\n codex: 'Codex',\n 'claude-code': 'Claude Code',\n clipboard: 'Clipboard',\n};\n\nexport async function sendToApp(target: TargetApp, result: GrabResult): Promise<{ success: boolean; method: 'auto' | 'clipboard' }> {\n await copyToClipboard(result);\n\n if (target === 'clipboard') {\n return { success: true, method: 'clipboard' };\n }\n\n const helperUp = await isHelperRunning();\n if (helperUp) {\n const ok = await sendToHelper(target, result);\n if (ok) return { success: true, method: 'auto' };\n }\n\n return { success: true, method: 'clipboard' };\n}\n\n"],"mappings":";;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,SAAS,QAAAA,aAAY;AAC9B,SAAS,cAAAC,aAAY,gBAAAC,eAAc,iBAAAC,sBAAqB;AACxD,SAAS,YAAAC,iBAAgB;;;ACHzB,SAAS,oBAA+D;AACxE,SAAS,gBAAgB;AACzB,SAAS,eAAe,aAAa,QAAQ,cAAc,kBAAkB;AAC7E,SAAS,cAAc;AACvB,SAAS,YAAY;;;ACiCd,IAAM,iBAA4C;AAAA,EACvD,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,eAAe;AAAA,EACf,WAAW;AACb;AAEO,IAAM,YAAuC;AAAA,EAClD,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,eAAe;AAAA,EACf,WAAW;AACb;;;AD3CA,IAAM,eAAe;AACrB,IAAI,aAA4B;AAShC,SAAS,SAAS,MAAoB;AACpC,WAAS,UAAU,EAAE,OAAO,MAAM,UAAU,QAAQ,CAAC;AACvD;AAEA,SAAS,UAAU,eAA+B;AAChD,QAAM,SAAS,YAAY,KAAK,OAAO,GAAG,YAAY,CAAC;AACvD,QAAM,UAAU,KAAK,QAAQ,UAAU;AAEvC,QAAM,SAAS,cAAc,QAAQ,4BAA4B,EAAE;AACnE,gBAAc,SAAS,OAAO,KAAK,QAAQ,QAAQ,CAAC;AAEpD,SAAO;AACT;AAEA,SAAS,iBAAiB,QAAyB;AACjD,MAAI,WAAW,eAAe;AAC5B,UAAMC,UAAS;AAAA;AAAA;AAAA;AA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A;AAAA;AAAA;AAAA;AAAA;AAAA,CAMb;AACD;AAEA,QAAQ,SAAS;AAAA,EACf,KAAK;AACH,gBAAY;AACZ;AAAA,EACF,KAAK,SAAS;AACZ,UAAM,UAAU,KAAK,QAAQ,QAAQ;AACrC,UAAM,OAAO,YAAY,KAAK,SAAS,KAAK,UAAU,CAAC,GAAG,EAAE,IAAI;AAChE,sBAAkB,MAAM,QAAQ;AAChC;AAAA,EACF;AAAA,EACA;AACE,eAAW;AACX;AACJ;","names":["join","existsSync","readFileSync","writeFileSync","execSync","script","iifePath","join","existsSync","indexHtml","readFileSync","execSync","writeFileSync"]}
@@ -0,0 +1,84 @@
1
+ interface GrabResult {
2
+ type: 'reference' | 'screenshot';
3
+ label: string;
4
+ text: string;
5
+ prompt: string;
6
+ image?: string;
7
+ meta: ElementMeta;
8
+ }
9
+ interface ElementMeta {
10
+ tag: string;
11
+ visibleText: string;
12
+ html: string;
13
+ attrs: {
14
+ role?: string;
15
+ ariaLabel?: string;
16
+ alt?: string;
17
+ placeholder?: string;
18
+ type?: string;
19
+ href?: string;
20
+ id?: string;
21
+ testId?: string;
22
+ };
23
+ component?: ComponentInfo;
24
+ componentStack?: ComponentFrame[];
25
+ styles?: string;
26
+ isLocal: boolean;
27
+ }
28
+ interface ComponentInfo {
29
+ name: string;
30
+ filePath: string | null;
31
+ line: number | null;
32
+ column: number | null;
33
+ }
34
+ interface ComponentFrame {
35
+ name: string;
36
+ filePath: string | null;
37
+ line: number | null;
38
+ }
39
+ type TargetApp = 'claude' | 'cursor' | 'codex' | 'claude-code' | 'clipboard';
40
+ interface RuneGrabConfig {
41
+ shortcut?: string;
42
+ target?: TargetApp;
43
+ accentColor?: string;
44
+ maxStackDepth?: number;
45
+ onGrab?: (result: GrabResult) => void;
46
+ onToggle?: (active: boolean) => void;
47
+ showTargetPicker?: boolean;
48
+ skipComponents?: string[];
49
+ }
50
+
51
+ declare function activate(): void;
52
+ declare function deactivate(): void;
53
+ declare function toggle(): void;
54
+ declare function isActive(): boolean;
55
+ declare function setTarget(target: TargetApp): void;
56
+ declare function getTarget(): TargetApp;
57
+ declare function init(userConfig?: RuneGrabConfig): () => void;
58
+
59
+ declare function extractElementMeta(el: Element, customSkip?: Set<string>): ElementMeta;
60
+ declare function buildLabel(meta: ElementMeta): string;
61
+ declare function buildContextText(meta: ElementMeta, prompt?: string): string;
62
+
63
+ declare function detectComponent(el: Element, customSkip?: Set<string>): ComponentInfo | null;
64
+ declare function detectComponentStack(el: Element, maxDepth?: number, customSkip?: Set<string>): ComponentFrame[];
65
+
66
+ type CaptureProvider = (rect: DOMRect) => Promise<string | null>;
67
+ declare function setCaptureProvider(provider: CaptureProvider): void;
68
+ declare function captureRect(rect: {
69
+ x: number;
70
+ y: number;
71
+ width: number;
72
+ height: number;
73
+ }, format?: 'image/png' | 'image/jpeg', quality?: number): Promise<string | null>;
74
+ declare function releaseStream(): void;
75
+
76
+ declare function copyToClipboard(result: GrabResult): Promise<boolean>;
77
+
78
+ declare const APP_NAMES: Record<TargetApp, string>;
79
+ declare function sendToApp(target: TargetApp, result: GrabResult): Promise<{
80
+ success: boolean;
81
+ method: 'auto' | 'clipboard';
82
+ }>;
83
+
84
+ export { APP_NAMES, type ComponentFrame, type ComponentInfo, type ElementMeta, type GrabResult, type RuneGrabConfig, type TargetApp, activate, buildContextText, buildLabel, captureRect, copyToClipboard, deactivate, detectComponent, detectComponentStack, extractElementMeta, getTarget, init, isActive, releaseStream, sendToApp, setCaptureProvider, setTarget, toggle };
@@ -0,0 +1,84 @@
1
+ interface GrabResult {
2
+ type: 'reference' | 'screenshot';
3
+ label: string;
4
+ text: string;
5
+ prompt: string;
6
+ image?: string;
7
+ meta: ElementMeta;
8
+ }
9
+ interface ElementMeta {
10
+ tag: string;
11
+ visibleText: string;
12
+ html: string;
13
+ attrs: {
14
+ role?: string;
15
+ ariaLabel?: string;
16
+ alt?: string;
17
+ placeholder?: string;
18
+ type?: string;
19
+ href?: string;
20
+ id?: string;
21
+ testId?: string;
22
+ };
23
+ component?: ComponentInfo;
24
+ componentStack?: ComponentFrame[];
25
+ styles?: string;
26
+ isLocal: boolean;
27
+ }
28
+ interface ComponentInfo {
29
+ name: string;
30
+ filePath: string | null;
31
+ line: number | null;
32
+ column: number | null;
33
+ }
34
+ interface ComponentFrame {
35
+ name: string;
36
+ filePath: string | null;
37
+ line: number | null;
38
+ }
39
+ type TargetApp = 'claude' | 'cursor' | 'codex' | 'claude-code' | 'clipboard';
40
+ interface RuneGrabConfig {
41
+ shortcut?: string;
42
+ target?: TargetApp;
43
+ accentColor?: string;
44
+ maxStackDepth?: number;
45
+ onGrab?: (result: GrabResult) => void;
46
+ onToggle?: (active: boolean) => void;
47
+ showTargetPicker?: boolean;
48
+ skipComponents?: string[];
49
+ }
50
+
51
+ declare function activate(): void;
52
+ declare function deactivate(): void;
53
+ declare function toggle(): void;
54
+ declare function isActive(): boolean;
55
+ declare function setTarget(target: TargetApp): void;
56
+ declare function getTarget(): TargetApp;
57
+ declare function init(userConfig?: RuneGrabConfig): () => void;
58
+
59
+ declare function extractElementMeta(el: Element, customSkip?: Set<string>): ElementMeta;
60
+ declare function buildLabel(meta: ElementMeta): string;
61
+ declare function buildContextText(meta: ElementMeta, prompt?: string): string;
62
+
63
+ declare function detectComponent(el: Element, customSkip?: Set<string>): ComponentInfo | null;
64
+ declare function detectComponentStack(el: Element, maxDepth?: number, customSkip?: Set<string>): ComponentFrame[];
65
+
66
+ type CaptureProvider = (rect: DOMRect) => Promise<string | null>;
67
+ declare function setCaptureProvider(provider: CaptureProvider): void;
68
+ declare function captureRect(rect: {
69
+ x: number;
70
+ y: number;
71
+ width: number;
72
+ height: number;
73
+ }, format?: 'image/png' | 'image/jpeg', quality?: number): Promise<string | null>;
74
+ declare function releaseStream(): void;
75
+
76
+ declare function copyToClipboard(result: GrabResult): Promise<boolean>;
77
+
78
+ declare const APP_NAMES: Record<TargetApp, string>;
79
+ declare function sendToApp(target: TargetApp, result: GrabResult): Promise<{
80
+ success: boolean;
81
+ method: 'auto' | 'clipboard';
82
+ }>;
83
+
84
+ export { APP_NAMES, type ComponentFrame, type ComponentInfo, type ElementMeta, type GrabResult, type RuneGrabConfig, type TargetApp, activate, buildContextText, buildLabel, captureRect, copyToClipboard, deactivate, detectComponent, detectComponentStack, extractElementMeta, getTarget, init, isActive, releaseStream, sendToApp, setCaptureProvider, setTarget, toggle };