@githumbi/grabby 0.1.0 → 0.1.1
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/CHANGELOG.md +6 -0
- package/README.md +3 -2
- package/dist/chunk-6CBIOKZV.cjs.map +1 -1
- package/dist/cli/index.js +32 -10
- package/dist/cli/index.js.map +1 -1
- package/dist/core/index.cjs.map +1 -1
- package/dist/live/index.cjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @githumbi/grabby
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4742695: Everything the CLI generates is now pinned to an exact version: the `.mcp.json` entry from `grabby add mcp` and `grabby pull` run one specific `@githumbi/grabby-server` release instead of any `0.x`, and the script tag printed by `grabby init` uses this exact version with Subresource Integrity hashes for the loader and the full build. Re-run `npx grabby add mcp` after upgrading to move the pin.
|
|
8
|
+
|
|
3
9
|
## 0.1.0
|
|
4
10
|
|
|
5
11
|
First release as Grabby (formerly angular-grab).
|
package/README.md
CHANGED
|
@@ -163,7 +163,7 @@ npx @githumbi/grabby-server start --public
|
|
|
163
163
|
></script>
|
|
164
164
|
```
|
|
165
165
|
|
|
166
|
-
Pin an exact version.
|
|
166
|
+
Pin an exact version (never a range like `@0.1`: a range would serve a hijacked release to every visitor the moment it's published), and add Subresource Integrity so a tampered CDN copy won't run: `integrity` and `crossorigin="anonymous"` cover the loader, and `data-integrity` covers the full build it fetches. `npx grabby init --live --server … --key … --dry-run` prints this tag with both hashes filled in.
|
|
167
167
|
|
|
168
168
|
or with a bundler:
|
|
169
169
|
|
|
@@ -180,7 +180,7 @@ Reviewers get a **Comment** button and a short three-step tip. After their first
|
|
|
180
180
|
**4. Pull the feedback into your agent:**
|
|
181
181
|
|
|
182
182
|
```bash
|
|
183
|
-
npx @githumbi/grabby-server pull --server https://feedback.your-site.com --token sk_…
|
|
183
|
+
npx -y @githumbi/grabby-server@0.1.0 pull --server https://feedback.your-site.com --token sk_…
|
|
184
184
|
```
|
|
185
185
|
|
|
186
186
|
This prints every open comment, grouped by file and labelled by author, and saves the screenshots to `./.grabby/screenshots/` where your agent can open them. The comments are then marked resolved, so the next pull shows only new feedback. Use `--keep` to leave them open or `--delete` to remove them.
|
|
@@ -239,6 +239,7 @@ Mark parts of your page:
|
|
|
239
239
|
- **The UI is isolated** in a shadow root and built without `innerHTML`, so page CSS can't break it and nothing a user types can run as code. It works under strict CSP (`style-src 'self'`) and Trusted Types.
|
|
240
240
|
- **The collector** stays on localhost unless started with `--public`, and then refuses to start without an admin token, a project key and a list of allowed sites. The public key can only add comments; reading, resolving and deleting need the admin token. Input is validated and size-capped, screenshots are checked by their bytes, only the browser that wrote a comment can attach its screenshot, and requests are rate-limited. Locally, it rejects DNS-rebinding attempts.
|
|
241
241
|
- **Comments are user input.** MCP results tell your agent to treat them as data, not instructions. Review what an agent does with feedback from people you don't know.
|
|
242
|
+
- **Supply chain.** Neither package has install scripts. Everything Grabby generates for you is pinned to an exact version: the `.mcp.json` entry and `grabby pull` run one specific `@githumbi/grabby-server` release (re-run `npx grabby add mcp` after upgrading to move it), and the CDN tag from `grabby init` carries integrity hashes. Releases are built in CI and published with npm trusted publishing and provenance; see [SECURITY.md](SECURITY.md#how-releases-are-protected) for how the repository itself is hardened.
|
|
242
243
|
|
|
243
244
|
Report vulnerabilities privately; see [SECURITY.md](SECURITY.md).
|
|
244
245
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/grabby/grabby/packages/grabby/dist/chunk-6CBIOKZV.cjs","../src/core/live/activation.ts"],"names":[],"mappings":"AAAA;ACMO,IAAM,WAAA,EAAa,QAAA;AAC1B,IAAM,SAAA,EAAW,gBAAA;AAEjB,SAAS,OAAA,CAAA,EAA0B;AACjC,EAAA,IAAI;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AAChD,EAAA,OAAO,iBAAA,CAAkB,CAAA;AAC3B;ADHA;AACA;AACE;AACA;AACA;AACF,wJAAC","file":"/home/runner/work/grabby/grabby/packages/grabby/dist/chunk-6CBIOKZV.cjs","sourcesContent":[null,"/**\n * Live sites keep Grabby hidden from ordinary visitors. It appears for\n * someone who opens a feedback link (https://site/?grabby=<projectKey>) and\n * stays for that browser tab until they exit feedback mode.\n */\n\nexport const LINK_PARAM = 'grabby';\nconst FLAG_KEY = 'grabby:v1:live';\n\nfunction session(): Storage | null {\n try { return window.sessionStorage; } catch { return null; }\n}\n\nexport function isFeedbackSession(): boolean {\n return session()?.getItem(FLAG_KEY) === '1';\n}\n\nexport function startFeedbackSession(): void {\n try { session()?.setItem(FLAG_KEY, '1'); } catch { /* private mode: lasts for this page only */ }\n}\n\nexport function endFeedbackSession(): void {\n try { session()?.removeItem(FLAG_KEY); } catch { /* ignore */ }\n}\n\n/**\n * Starts a feedback session if the URL carries a matching link, then removes\n * the parameter so it isn't shared by accident when the page is bookmarked\n * or copied. With no projectKey configured, any non-empty value works.\n */\nexport function consumeFeedbackLink(projectKey?: string): boolean {\n try {\n const url = new URL(window.location.href);\n const value = url.searchParams.get(LINK_PARAM);\n if (value !== null) {\n if (value && (!projectKey || value === projectKey)) startFeedbackSession();\n url.searchParams.delete(LINK_PARAM);\n window.history.replaceState(window.history.state, '', url.pathname + url.search + url.hash);\n }\n } catch { /* unusual URL; nothing to consume */ }\n return isFeedbackSession();\n}\n"]}
|
package/dist/cli/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import { parseArgs } from "util";
|
|
|
6
6
|
|
|
7
7
|
// src/cli/commands/init.ts
|
|
8
8
|
import { execSync } from "child_process";
|
|
9
|
+
import { createHash } from "crypto";
|
|
9
10
|
import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
10
11
|
import { join as join2, relative } from "path";
|
|
11
12
|
import { createInterface } from "readline";
|
|
@@ -130,6 +131,10 @@ function patchAngularAppConfig(code) {
|
|
|
130
131
|
return { status: "patched", code: insertImport(withProvider, "import { provideGrabby } from '@githumbi/grabby/angular';") };
|
|
131
132
|
}
|
|
132
133
|
|
|
134
|
+
// src/cli/versions.ts
|
|
135
|
+
var GRABBY_VERSION = "0.1.1";
|
|
136
|
+
var SERVER_PACKAGE = `@githumbi/grabby-server@${"0.1.0"}`;
|
|
137
|
+
|
|
133
138
|
// src/cli/commands/init.ts
|
|
134
139
|
var PKG = "@githumbi/grabby";
|
|
135
140
|
var c = {
|
|
@@ -139,6 +144,27 @@ var c = {
|
|
|
139
144
|
bold: (s) => `\x1B[1m${s}\x1B[0m`,
|
|
140
145
|
dim: (s) => `\x1B[2m${s}\x1B[0m`
|
|
141
146
|
};
|
|
147
|
+
function sri(file) {
|
|
148
|
+
try {
|
|
149
|
+
const data = readFileSync2(new URL(`../${file}`, import.meta.url));
|
|
150
|
+
return `sha384-${createHash("sha384").update(data).digest("base64")}`;
|
|
151
|
+
} catch {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function cdnScriptTag(live) {
|
|
156
|
+
const file = live ? "loader.global.js" : "grabby.global.js";
|
|
157
|
+
const own = sri(file);
|
|
158
|
+
const full = live ? sri("grabby.global.js") : null;
|
|
159
|
+
const attrs = [
|
|
160
|
+
`src="https://cdn.jsdelivr.net/npm/${PKG}@${GRABBY_VERSION}/dist/${file}"`,
|
|
161
|
+
...own ? [`integrity="${own}"`, 'crossorigin="anonymous"'] : [],
|
|
162
|
+
...full ? [`data-integrity="${full}"`] : [],
|
|
163
|
+
...live ? ['data-mode="live"', `data-server="${live.server}"`, `data-project-key="${live.projectKey}"`] : [],
|
|
164
|
+
"defer"
|
|
165
|
+
];
|
|
166
|
+
return `<script ${attrs.join(" ")}></script>`;
|
|
167
|
+
}
|
|
142
168
|
var log = (msg = "") => console.log(msg && `${c.cyan("[grabby]")} ${msg}`);
|
|
143
169
|
var warn = (msg) => console.log(`${c.yellow("[grabby]")} ${msg}`);
|
|
144
170
|
function tryPatch(file, patch, describe, manual, changes, manualSteps) {
|
|
@@ -218,12 +244,9 @@ function plan(stack, options) {
|
|
|
218
244
|
live ? `In a client-only script/plugin: import('@githumbi/grabby/live').then((g) => g.${liveCall});` : "In a client-only script/plugin: if (import.meta.env.DEV) import('@githumbi/grabby').then((g) => g.initGrabby());"
|
|
219
245
|
);
|
|
220
246
|
break;
|
|
221
|
-
default:
|
|
222
|
-
const attrs = live ? ` data-mode="live" data-server="${live.server}" data-project-key="${live.projectKey}"` : "";
|
|
223
|
-
const file = live ? "loader.global.js" : "grabby.global.js";
|
|
247
|
+
default:
|
|
224
248
|
manual.push(`Add before </body>:
|
|
225
|
-
|
|
226
|
-
}
|
|
249
|
+
${cdnScriptTag(live)}`);
|
|
227
250
|
}
|
|
228
251
|
return { changes, manual, devDependency: !live };
|
|
229
252
|
}
|
|
@@ -278,7 +301,7 @@ async function init(options = {}) {
|
|
|
278
301
|
if (options.live) {
|
|
279
302
|
console.log(`
|
|
280
303
|
Share this feedback link with reviewers: ${c.bold(`https://<your-site>/?grabby=${options.live.projectKey}`)}`);
|
|
281
|
-
console.log(` Pull their comments: ${c.bold(`npx
|
|
304
|
+
console.log(` Pull their comments: ${c.bold(`npx -y ${SERVER_PACKAGE} pull --server ${options.live.server} --token <admin token>`)}
|
|
282
305
|
`);
|
|
283
306
|
} else {
|
|
284
307
|
console.log(`
|
|
@@ -292,7 +315,6 @@ async function init(options = {}) {
|
|
|
292
315
|
// src/cli/commands/add-mcp.ts
|
|
293
316
|
import { existsSync as existsSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
294
317
|
import { join as join3 } from "path";
|
|
295
|
-
var MCP_PACKAGE = "@githumbi/grabby-server@0";
|
|
296
318
|
var MCP_SERVER_NAME = "grabby";
|
|
297
319
|
function log2(msg) {
|
|
298
320
|
console.log(`\x1B[36m[grabby]\x1B[0m ${msg}`);
|
|
@@ -309,13 +331,13 @@ function getMcpServerEntry() {
|
|
|
309
331
|
return {
|
|
310
332
|
type: "stdio",
|
|
311
333
|
command: "cmd",
|
|
312
|
-
args: ["/c", "npx", "-y",
|
|
334
|
+
args: ["/c", "npx", "-y", SERVER_PACKAGE, "mcp"]
|
|
313
335
|
};
|
|
314
336
|
}
|
|
315
337
|
return {
|
|
316
338
|
type: "stdio",
|
|
317
339
|
command: "npx",
|
|
318
|
-
args: ["-y",
|
|
340
|
+
args: ["-y", SERVER_PACKAGE, "mcp"]
|
|
319
341
|
};
|
|
320
342
|
}
|
|
321
343
|
async function addMcp() {
|
|
@@ -365,7 +387,7 @@ function fail(err) {
|
|
|
365
387
|
var argv = process.argv.slice(2);
|
|
366
388
|
var [command, subcommand] = argv;
|
|
367
389
|
if (command === "pull") {
|
|
368
|
-
const args = ["-y",
|
|
390
|
+
const args = ["-y", SERVER_PACKAGE, "pull", ...argv.slice(1)];
|
|
369
391
|
const windows = process.platform === "win32";
|
|
370
392
|
if (windows && !args.every((a) => /^[\w@./:=,+-]+$/.test(a))) {
|
|
371
393
|
fail(`unsupported characters in arguments; run it directly: npx ${args.join(" ")}`);
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/index.ts","../../src/cli/commands/init.ts","../../src/cli/utils/detect-stack.ts","../../src/cli/utils/patch-source.ts","../../src/cli/commands/add-mcp.ts"],"sourcesContent":["import { spawn } from 'child_process';\nimport { parseArgs } from 'util';\nimport { init } from './commands/init';\nimport { addMcp } from './commands/add-mcp';\n\nconst HELP = `Grabby: point at any UI element, leave a comment, hand it to your AI agent.\n\nUsage\n npx grabby init Set up Grabby in this project (asks before changing files)\n --yes Apply without asking\n --dry-run Only show what would change\n --no-install Don't install the package\n --live --server <url> --key <pk_…>\n Set up live-site feedback instead of local dev mode\n npx grabby add mcp Let your AI agent read comments over MCP (.mcp.json)\n npx grabby pull [options] Print collected comments for your agent (runs grabby-server pull)\n`;\n\nfunction fail(err: unknown): never {\n console.error('\\x1b[31mError:\\x1b[0m', err instanceof Error ? err.message : String(err));\n process.exit(1);\n}\n\nconst argv = process.argv.slice(2);\nconst [command, subcommand] = argv;\n\nif (command === 'pull') {\n // The collector owns pulling; forward to it so there's one implementation.\n const args = ['-y', '@githumbi/grabby-server@0', 'pull', ...argv.slice(1)];\n const windows = process.platform === 'win32';\n // npx is a .cmd on Windows, which Node only runs through a shell. Only\n // pass plain flag/value characters so nothing can be interpreted by it.\n if (windows && !args.every((a) => /^[\\w@./:=,+-]+$/.test(a))) {\n fail(`unsupported characters in arguments; run it directly: npx ${args.join(' ')}`);\n }\n const child = spawn(windows ? 'npx.cmd' : 'npx', args, { stdio: 'inherit', shell: windows });\n child.on('exit', (code) => process.exit(code ?? 1));\n} else if (command === 'add' && subcommand === 'mcp') {\n addMcp().catch(fail);\n} else if (!command || command === 'init') {\n const { values } = parseArgs({\n args: argv.slice(command ? 1 : 0),\n options: {\n yes: { type: 'boolean', short: 'y' },\n 'dry-run': { type: 'boolean' },\n 'no-install': { type: 'boolean' },\n live: { type: 'boolean' },\n server: { type: 'string' },\n key: { type: 'string' },\n },\n });\n if (values.live && (!values.server || !values.key)) {\n fail('--live needs --server <collector url> and --key <project key> (from `npx @githumbi/grabby-server init`)');\n }\n init({\n yes: values.yes,\n dryRun: values['dry-run'],\n noInstall: values['no-install'],\n live: values.live ? { server: values.server!, projectKey: values.key! } : undefined,\n }).catch(fail);\n} else if (command === 'help' || command === '--help' || command === '-h') {\n console.log(HELP);\n} else {\n console.error(`Unknown command: ${argv.join(' ')}\\n`);\n console.log(HELP);\n process.exit(1);\n}\n","import { execSync } from 'child_process';\nimport { existsSync, readFileSync, writeFileSync } from 'fs';\nimport { join, relative } from 'path';\nimport { createInterface } from 'readline';\nimport { detectStack, installCommand, type Stack } from '../utils/detect-stack';\nimport { patchViteConfig, patchEntry, patchAngularJson, patchAngularAppConfig, type PatchResult } from '../utils/patch-source';\n\nconst PKG = '@githumbi/grabby';\n\nexport interface InitOptions {\n cwd?: string;\n /** Apply without asking. */\n yes?: boolean;\n /** Show the plan only. */\n dryRun?: boolean;\n /** Skip installing the package. */\n noInstall?: boolean;\n /** Set up live-site feedback instead of local developer mode. */\n live?: { server: string; projectKey: string };\n}\n\nconst c = {\n cyan: (s: string) => `\\x1b[36m${s}\\x1b[0m`,\n yellow: (s: string) => `\\x1b[33m${s}\\x1b[0m`,\n green: (s: string) => `\\x1b[32m${s}\\x1b[0m`,\n bold: (s: string) => `\\x1b[1m${s}\\x1b[0m`,\n dim: (s: string) => `\\x1b[2m${s}\\x1b[0m`,\n};\n\nconst log = (msg = '') => console.log(msg && `${c.cyan('[grabby]')} ${msg}`);\nconst warn = (msg: string) => console.log(`${c.yellow('[grabby]')} ${msg}`);\n\ninterface Change {\n file: string;\n describe: string;\n next: string;\n}\n\nfunction tryPatch(file: string | null, patch: (code: string) => PatchResult, describe: string, manual: string, changes: Change[], manualSteps: string[]): void {\n if (!file || !existsSync(file)) {\n manualSteps.push(manual);\n return;\n }\n const result = patch(readFileSync(file, 'utf8'));\n if (result.status === 'patched') changes.push({ file, describe, next: result.code });\n else if (result.status === 'already') log(`${describe}: already set up`);\n else manualSteps.push(`${manual}\\n ${c.dim(`(couldn't edit ${file} automatically: ${result.reason})`)}`);\n}\n\n/** What to change for each stack. Anything not safely automatable becomes a manual step. */\nfunction plan(stack: Stack, options: InitOptions): { changes: Change[]; manual: string[]; devDependency: boolean } {\n const changes: Change[] = [];\n const manual: string[] = [];\n const live = options.live;\n const liveCall = live ? `initGrabbyLive({ server: '${live.server}', projectKey: '${live.projectKey}' })` : '';\n\n switch (stack.framework) {\n case 'angular': {\n tryPatch(join(stack.root, 'angular.json'), patchAngularJson, 'use the Grabby builders',\n 'In angular.json, set build → \"@githumbi/grabby:application\" and serve → \"@githumbi/grabby:dev-server\".', changes, manual);\n const appConfig = ['src/app/app.config.ts', 'src/app.config.ts'].map((f) => join(stack.root, f)).find((f) => existsSync(f)) ?? null;\n tryPatch(appConfig, patchAngularAppConfig, 'add provideGrabby()',\n \"In app.config.ts: import { provideGrabby } from '@githumbi/grabby/angular'; and add provideGrabby() to providers.\", changes, manual);\n if (live) manual.push(`For live feedback, pass the options: provideGrabby({ mode: 'live', server: '${live.server}', projectKey: '${live.projectKey}' })`);\n break;\n }\n case 'react':\n case 'vue':\n case 'svelte':\n case 'solid':\n case 'preact': {\n if (stack.framework !== 'svelte' && !live) {\n tryPatch(stack.viteConfig, patchViteConfig, 'add the source-location plugin',\n \"In your bundler config add the plugin first: import grabby from '@githumbi/grabby/plugin'; plugins: [grabby.vite(), …] (also grabby.webpack(), grabby.rspack(), …)\", changes, manual);\n }\n tryPatch(stack.entry, (code) => patchEntry(code, { live }), live ? 'start live feedback' : 'start Grabby in development builds',\n live\n ? `In your entry file: import { initGrabbyLive } from '@githumbi/grabby/live'; ${liveCall};`\n : \"In your entry file: import { initGrabby } from '@githumbi/grabby'; if (import.meta.env.DEV) initGrabby();\", changes, manual);\n break;\n }\n case 'next':\n manual.push(\n \"next.config: const grabby = require('@githumbi/grabby/plugin').default; webpack: (config) => { config.plugins.unshift(grabby.webpack()); return config; }\",\n live\n ? `In a client component rendered by your root layout: useEffect(() => { import('@githumbi/grabby/live').then((g) => g.${liveCall}); }, []);`\n : \"In a client component rendered by your root layout: useEffect(() => { if (process.env.NODE_ENV === 'development') import('@githumbi/grabby').then((g) => g.initGrabby()); }, []);\",\n );\n break;\n case 'nuxt':\n case 'sveltekit':\n case 'astro':\n manual.push(\n stack.framework === 'nuxt' ? \"nuxt.config: vite: { plugins: [require('@githumbi/grabby/plugin').default.vite()] }\" : 'No build plugin needed for Svelte-based apps; Astro can add grabby.vite() under vite.plugins.',\n live\n ? `In a client-only script/plugin: import('@githumbi/grabby/live').then((g) => g.${liveCall});`\n : \"In a client-only script/plugin: if (import.meta.env.DEV) import('@githumbi/grabby').then((g) => g.initGrabby());\",\n );\n break;\n default: {\n const attrs = live ? ` data-mode=\"live\" data-server=\"${live.server}\" data-project-key=\"${live.projectKey}\"` : '';\n const file = live ? 'loader.global.js' : 'grabby.global.js';\n manual.push(`Add before </body>:\\n <script src=\"https://cdn.jsdelivr.net/npm/${PKG}@0.1/dist/${file}\"${attrs} defer></script>`);\n }\n }\n\n return { changes, manual, devDependency: !live };\n}\n\nasync function confirm(question: string): Promise<boolean> {\n if (!process.stdin.isTTY) return false;\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n const answer = await new Promise<string>((resolve) => rl.question(question, resolve));\n rl.close();\n return /^y(es)?$/i.test(answer.trim());\n}\n\nexport async function init(options: InitOptions = {}): Promise<void> {\n const stack = detectStack(options.cwd);\n const rel = (f: string) => relative(stack.root, f) || f;\n log(`Project: ${stack.root}`);\n log(`Detected: ${stack.framework}${stack.viteConfig ? ' + Vite' : ''} · ${stack.packageManager}${options.live ? ' · live feedback' : ''}`);\n log();\n\n const { changes, manual, devDependency } = plan(stack, options);\n const install = stack.hasPackageJson && !options.noInstall ? installCommand(stack.packageManager, PKG, devDependency) : null;\n\n if (!install && changes.length === 0 && manual.length === 0) {\n log(c.green('Everything is already set up.'));\n return;\n }\n\n console.log(c.bold(' Grabby will:'));\n if (install) console.log(` • run ${c.bold(install)}`);\n for (const ch of changes) console.log(` • edit ${c.bold(rel(ch.file))}: ${ch.describe}`);\n if (manual.length) {\n console.log(c.bold('\\n You\\'ll need to do by hand:'));\n manual.forEach((m, i) => console.log(` ${i + 1}. ${m}`));\n }\n console.log('');\n\n if (options.dryRun) return;\n if (changes.length || install) {\n const go = options.yes || await confirm(' Go ahead? [y/N] ');\n if (!go) {\n warn(process.stdin.isTTY ? 'Nothing changed.' : 'Nothing changed (not a terminal; re-run with --yes to apply).');\n return;\n }\n }\n\n if (install) {\n try {\n execSync(install, { cwd: stack.root, stdio: 'inherit' });\n } catch {\n warn(`Install failed; run it yourself: ${install}`);\n }\n }\n for (const ch of changes) {\n writeFileSync(ch.file, ch.next, 'utf8');\n log(`${c.green('✓')} ${rel(ch.file)}`);\n }\n\n console.log('');\n log(c.green('Done.'));\n if (options.live) {\n console.log(`\\n Share this feedback link with reviewers: ${c.bold(`https://<your-site>/?grabby=${options.live.projectKey}`)}`);\n console.log(` Pull their comments: ${c.bold(`npx @githumbi/grabby-server pull --server ${options.live.server} --token <admin token>`)}\\n`);\n } else {\n console.log(`\\n Start your dev server, press ${c.bold('Alt+G')} (${c.bold('Option+G')} on Mac), click anything, and comment.`);\n console.log(` Then use ${c.bold('Copy all')} and paste into your AI agent.`);\n console.log(` Want your agent to read comments directly? Run ${c.bold('npx grabby add mcp')}.\\n`);\n }\n}\n","import { existsSync, readFileSync } from 'fs';\nimport { join, dirname } from 'path';\n\nexport type PackageManager = 'pnpm' | 'yarn' | 'bun' | 'npm';\nexport type Framework = 'angular' | 'next' | 'nuxt' | 'sveltekit' | 'astro' | 'react' | 'vue' | 'svelte' | 'solid' | 'preact' | 'html';\n\nexport interface Stack {\n root: string;\n packageManager: PackageManager;\n framework: Framework;\n /** vite.config.* when the project builds with Vite. */\n viteConfig: string | null;\n /** The file that mounts the app, where initGrabby() goes. */\n entry: string | null;\n hasPackageJson: boolean;\n}\n\nconst VITE_CONFIGS = ['vite.config.ts', 'vite.config.mts', 'vite.config.js', 'vite.config.mjs'];\nconst ENTRIES = ['src/main.tsx', 'src/main.ts', 'src/main.jsx', 'src/main.js', 'src/index.tsx', 'src/index.jsx', 'src/index.ts', 'src/index.js'];\n\nexport function findProjectRoot(start: string = process.cwd()): string {\n let dir = start;\n while (true) {\n if (existsSync(join(dir, 'package.json'))) return dir;\n const parent = dirname(dir);\n if (parent === dir) return start;\n dir = parent;\n }\n}\n\nexport function detectPackageManager(root: string): PackageManager {\n // Walk up for lockfiles too: a workspace package's lockfile lives at the repo root.\n let dir = root;\n while (true) {\n if (existsSync(join(dir, 'pnpm-lock.yaml'))) return 'pnpm';\n if (existsSync(join(dir, 'yarn.lock'))) return 'yarn';\n if (existsSync(join(dir, 'bun.lockb')) || existsSync(join(dir, 'bun.lock'))) return 'bun';\n if (existsSync(join(dir, 'package-lock.json'))) return 'npm';\n const parent = dirname(dir);\n if (parent === dir) return 'npm';\n dir = parent;\n }\n}\n\nexport function detectStack(start: string = process.cwd()): Stack {\n const root = findProjectRoot(start);\n const pkgPath = join(root, 'package.json');\n const hasPackageJson = existsSync(pkgPath);\n let deps: Record<string, string> = {};\n if (hasPackageJson) {\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));\n deps = { ...pkg.dependencies, ...pkg.devDependencies };\n } catch { /* unreadable package.json: treat as plain HTML */ }\n }\n const has = (name: string) => name in deps;\n\n let framework: Framework = 'html';\n if (existsSync(join(root, 'angular.json')) || has('@angular/core')) framework = 'angular';\n else if (has('next')) framework = 'next';\n else if (has('nuxt')) framework = 'nuxt';\n else if (has('@sveltejs/kit')) framework = 'sveltekit';\n else if (has('astro')) framework = 'astro';\n else if (has('solid-js')) framework = 'solid';\n else if (has('preact')) framework = 'preact';\n else if (has('react')) framework = 'react';\n else if (has('vue')) framework = 'vue';\n else if (has('svelte')) framework = 'svelte';\n\n const viteConfig = VITE_CONFIGS.map((f) => join(root, f)).find((f) => existsSync(f)) ?? null;\n const entry = ENTRIES.map((f) => join(root, f)).find((f) => existsSync(f)) ?? null;\n\n return { root, packageManager: detectPackageManager(root), framework, viteConfig, entry, hasPackageJson };\n}\n\nexport function installCommand(pm: PackageManager, pkg: string, dev: boolean): string {\n switch (pm) {\n case 'pnpm': return `pnpm add ${dev ? '-D ' : ''}${pkg}`;\n case 'yarn': return `yarn add ${dev ? '-D ' : ''}${pkg}`;\n case 'bun': return `bun add ${dev ? '-d ' : ''}${pkg}`;\n default: return `npm install ${dev ? '-D ' : ''}${pkg}`;\n }\n}\n","/*\n * Small, conservative source edits. Each patch either applies cleanly to a\n * recognisable pattern or declines, so `grabby init` never writes a guess;\n * when it declines, init prints the lines to add by hand instead.\n */\n\nexport type PatchResult =\n | { status: 'patched'; code: string }\n | { status: 'already' }\n | { status: 'unrecognised'; reason: string };\n\n/** Index just after the last top-level import statement (0 when there are none). */\nfunction afterImports(code: string): number {\n const re = /^import\\s[^;]*?(?:from\\s+)?['\"][^'\"]+['\"];?[ \\t]*$/gm;\n let end = 0;\n for (let m = re.exec(code); m; m = re.exec(code)) end = m.index + m[0].length;\n return end;\n}\n\nfunction insertImport(code: string, statement: string): string {\n const at = afterImports(code);\n if (at === 0) return `${statement}\\n${code}`;\n return `${code.slice(0, at)}\\n${statement}${code.slice(at)}`;\n}\n\n/** Adds `grabby.vite()` first in the `plugins: [...]` array of a Vite config. */\nexport function patchViteConfig(code: string): PatchResult {\n if (code.includes('@githumbi/grabby/plugin')) return { status: 'already' };\n const plugins = /plugins\\s*:\\s*\\[/.exec(code);\n if (!plugins) return { status: 'unrecognised', reason: 'no `plugins: [ … ]` array found' };\n const at = plugins.index + plugins[0].length;\n // First, so it stamps source before framework plugins compile it.\n const withPlugin = `${code.slice(0, at)}grabby.vite(), ${code.slice(at)}`;\n return { status: 'patched', code: insertImport(withPlugin, \"import grabby from '@githumbi/grabby/plugin';\") };\n}\n\n/** Starts Grabby in the app's entry file, in development builds only. */\nexport function patchEntry(code: string, options: { live?: { server: string; projectKey: string } } = {}): PatchResult {\n if (code.includes('@githumbi/grabby')) return { status: 'already' };\n const at = afterImports(code);\n if (at === 0 && /\\bimport\\b/.test(code.slice(0, 200))) {\n return { status: 'unrecognised', reason: 'could not find where the imports end' };\n }\n const call = options.live\n ? `initGrabbyLive({ server: ${JSON.stringify(options.live.server)}, projectKey: ${JSON.stringify(options.live.projectKey)} });`\n : 'if (import.meta.env.DEV) initGrabby();';\n const imp = options.live\n ? \"import { initGrabbyLive } from '@githumbi/grabby/live';\"\n : \"import { initGrabby } from '@githumbi/grabby';\";\n const withImport = insertImport(code, imp);\n const afterAll = afterImports(withImport);\n return { status: 'patched', code: `${withImport.slice(0, afterAll)}\\n\\n${call}${withImport.slice(afterAll)}` };\n}\n\n/**\n * Swaps the Angular builders for Grabby's, editing the builder strings in\n * place so angular.json keeps its formatting (and any comments).\n */\nexport function patchAngularJson(code: string): PatchResult {\n if (code.includes('@githumbi/grabby:')) return { status: 'already' };\n const next = code\n .replace(/\"@angular(?:-devkit\\/build-angular|\\/build):application\"/g, '\"@githumbi/grabby:application\"')\n .replace(/\"@angular(?:-devkit\\/build-angular|\\/build):dev-server\"/g, '\"@githumbi/grabby:dev-server\"');\n if (next === code) {\n return { status: 'unrecognised', reason: 'no @angular/build:application or :dev-server builder found (Angular 17+ is required)' };\n }\n return { status: 'patched', code: next };\n}\n\n/** Adds provideGrabby() to the providers array of app.config.ts. */\nexport function patchAngularAppConfig(code: string): PatchResult {\n if (code.includes('provideGrabby')) return { status: 'already' };\n const providers = /providers\\s*:\\s*\\[/.exec(code);\n if (!providers) return { status: 'unrecognised', reason: 'no `providers: [ … ]` array found' };\n const at = providers.index + providers[0].length;\n const withProvider = `${code.slice(0, at)}provideGrabby(), ${code.slice(at)}`;\n return { status: 'patched', code: insertImport(withProvider, \"import { provideGrabby } from '@githumbi/grabby/angular';\") };\n}\n","import { existsSync, readFileSync, writeFileSync } from 'fs';\nimport { join } from 'path';\n\n// Pinned to a major version: an MCP server runs with your editor's\n// permissions, so it shouldn't silently jump to whatever @latest becomes.\nconst MCP_PACKAGE = '@githumbi/grabby-server@0';\nconst MCP_SERVER_NAME = 'grabby';\n\nfunction log(msg: string): void {\n console.log(`\\x1b[36m[grabby]\\x1b[0m ${msg}`);\n}\n\nfunction warn(msg: string): void {\n console.log(`\\x1b[33m[grabby]\\x1b[0m ${msg}`);\n}\n\nfunction success(msg: string): void {\n console.log(`\\x1b[32m[grabby]\\x1b[0m ${msg}`);\n}\n\nfunction getMcpServerEntry(): { type: string; command: string; args: string[] } {\n const isWindows = process.platform === 'win32';\n if (isWindows) {\n return {\n type: 'stdio',\n command: 'cmd',\n args: ['/c', 'npx', '-y', MCP_PACKAGE, 'mcp'],\n };\n }\n return {\n type: 'stdio',\n command: 'npx',\n args: ['-y', MCP_PACKAGE, 'mcp'],\n };\n}\n\nexport async function addMcp(): Promise<void> {\n log('Adding grabby MCP server...\\n');\n\n const mcpJsonPath = join(process.cwd(), '.mcp.json');\n let config: Record<string, unknown> = {};\n\n if (existsSync(mcpJsonPath)) {\n try {\n config = JSON.parse(readFileSync(mcpJsonPath, 'utf-8'));\n } catch {\n // Never clobber a file we can't read: it may hold other servers' config.\n warn('.mcp.json exists but is not valid JSON; leaving it alone. Add this entry by hand:');\n console.log(JSON.stringify({ mcpServers: { [MCP_SERVER_NAME]: getMcpServerEntry() } }, null, 2));\n return;\n }\n }\n\n const servers = (config.mcpServers as Record<string, unknown>) ?? {};\n servers[MCP_SERVER_NAME] = getMcpServerEntry();\n config.mcpServers = servers;\n\n writeFileSync(mcpJsonPath, JSON.stringify(config, null, 2) + '\\n');\n success('Added grabby MCP server to .mcp.json');\n\n console.log('');\n console.log(' It also collects comments from your app on http://localhost:3456.');\n console.log(\" Point Grabby at it: initGrabby({ server: 'http://localhost:3456' })\");\n console.log('');\n console.log(' \\x1b[1mRestart your editor\\x1b[0m to activate the MCP connection.');\n console.log(' When prompted, \\x1b[1mapprove the MCP server\\x1b[0m in your editor.');\n console.log('');\n}\n"],"mappings":";;;AAAA,SAAS,aAAa;AACtB,SAAS,iBAAiB;;;ACD1B,SAAS,gBAAgB;AACzB,SAAS,cAAAA,aAAY,gBAAAC,eAAc,qBAAqB;AACxD,SAAS,QAAAC,OAAM,gBAAgB;AAC/B,SAAS,uBAAuB;;;ACHhC,SAAS,YAAY,oBAAoB;AACzC,SAAS,MAAM,eAAe;AAgB9B,IAAM,eAAe,CAAC,kBAAkB,mBAAmB,kBAAkB,iBAAiB;AAC9F,IAAM,UAAU,CAAC,gBAAgB,eAAe,gBAAgB,eAAe,iBAAiB,iBAAiB,gBAAgB,cAAc;AAExI,SAAS,gBAAgB,QAAgB,QAAQ,IAAI,GAAW;AACrE,MAAI,MAAM;AACV,SAAO,MAAM;AACX,QAAI,WAAW,KAAK,KAAK,cAAc,CAAC,EAAG,QAAO;AAClD,UAAM,SAAS,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,QAAQ,MAAM,UAAU,YAAY,OAAO,MAAM,EAAE,OAAO,WAAW,OAAO,QAAQ,CAAC;AAC3F,QAAM,GAAG,QAAQ,CAAC,SAAS,QAAQ,KAAK,QAAQ,CAAC,CAAC;AACpD,WAAW,YAAY,SAAS,eAAe,OAAO;AACpD,SAAO,EAAE,MAAM,IAAI;AACrB,WAAW,CAAC,WAAW,YAAY,QAAQ;AACzC,QAAM,EAAE,OAAO,IAAI,UAAU;AAAA,IAC3B,MAAM,KAAK,MAAM,UAAU,IAAI,CAAC;AAAA,IAChC,SAAS;AAAA,MACP,KAAK,EAAE,MAAM,WAAW,OAAO,IAAI;AAAA,MACnC,WAAW,EAAE,MAAM,UAAU;AAAA,MAC7B,cAAc,EAAE,MAAM,UAAU;AAAA,MAChC,MAAM,EAAE,MAAM,UAAU;AAAA,MACxB,QAAQ,EAAE,MAAM,SAAS;AAAA,MACzB,KAAK,EAAE,MAAM,SAAS;AAAA,IACxB;AAAA,EACF,CAAC;AACD,MAAI,OAAO,SAAS,CAAC,OAAO,UAAU,CAAC,OAAO,MAAM;AAClD,SAAK,yGAAyG;AAAA,EAChH;AACA,OAAK;AAAA,IACH,KAAK,OAAO;AAAA,IACZ,QAAQ,OAAO,SAAS;AAAA,IACxB,WAAW,OAAO,YAAY;AAAA,IAC9B,MAAM,OAAO,OAAO,EAAE,QAAQ,OAAO,QAAS,YAAY,OAAO,IAAK,IAAI;AAAA,EAC5E,CAAC,EAAE,MAAM,IAAI;AACf,WAAW,YAAY,UAAU,YAAY,YAAY,YAAY,MAAM;AACzE,UAAQ,IAAI,IAAI;AAClB,OAAO;AACL,UAAQ,MAAM,oBAAoB,KAAK,KAAK,GAAG,CAAC;AAAA,CAAI;AACpD,UAAQ,IAAI,IAAI;AAChB,UAAQ,KAAK,CAAC;AAChB;","names":["existsSync","readFileSync","join","existsSync","readFileSync","join","existsSync","readFileSync","writeFileSync","join","log","warn"]}
|
|
1
|
+
{"version":3,"sources":["../../src/cli/index.ts","../../src/cli/commands/init.ts","../../src/cli/utils/detect-stack.ts","../../src/cli/utils/patch-source.ts","../../src/cli/versions.ts","../../src/cli/commands/add-mcp.ts"],"sourcesContent":["import { spawn } from 'child_process';\nimport { parseArgs } from 'util';\nimport { init } from './commands/init';\nimport { addMcp } from './commands/add-mcp';\nimport { SERVER_PACKAGE } from './versions';\n\nconst HELP = `Grabby: point at any UI element, leave a comment, hand it to your AI agent.\n\nUsage\n npx grabby init Set up Grabby in this project (asks before changing files)\n --yes Apply without asking\n --dry-run Only show what would change\n --no-install Don't install the package\n --live --server <url> --key <pk_…>\n Set up live-site feedback instead of local dev mode\n npx grabby add mcp Let your AI agent read comments over MCP (.mcp.json)\n npx grabby pull [options] Print collected comments for your agent (runs grabby-server pull)\n`;\n\nfunction fail(err: unknown): never {\n console.error('\\x1b[31mError:\\x1b[0m', err instanceof Error ? err.message : String(err));\n process.exit(1);\n}\n\nconst argv = process.argv.slice(2);\nconst [command, subcommand] = argv;\n\nif (command === 'pull') {\n // The collector owns pulling; forward to it so there's one implementation.\n const args = ['-y', SERVER_PACKAGE, 'pull', ...argv.slice(1)];\n const windows = process.platform === 'win32';\n // npx is a .cmd on Windows, which Node only runs through a shell. Only\n // pass plain flag/value characters so nothing can be interpreted by it.\n if (windows && !args.every((a) => /^[\\w@./:=,+-]+$/.test(a))) {\n fail(`unsupported characters in arguments; run it directly: npx ${args.join(' ')}`);\n }\n const child = spawn(windows ? 'npx.cmd' : 'npx', args, { stdio: 'inherit', shell: windows });\n child.on('exit', (code) => process.exit(code ?? 1));\n} else if (command === 'add' && subcommand === 'mcp') {\n addMcp().catch(fail);\n} else if (!command || command === 'init') {\n const { values } = parseArgs({\n args: argv.slice(command ? 1 : 0),\n options: {\n yes: { type: 'boolean', short: 'y' },\n 'dry-run': { type: 'boolean' },\n 'no-install': { type: 'boolean' },\n live: { type: 'boolean' },\n server: { type: 'string' },\n key: { type: 'string' },\n },\n });\n if (values.live && (!values.server || !values.key)) {\n fail('--live needs --server <collector url> and --key <project key> (from `npx @githumbi/grabby-server init`)');\n }\n init({\n yes: values.yes,\n dryRun: values['dry-run'],\n noInstall: values['no-install'],\n live: values.live ? { server: values.server!, projectKey: values.key! } : undefined,\n }).catch(fail);\n} else if (command === 'help' || command === '--help' || command === '-h') {\n console.log(HELP);\n} else {\n console.error(`Unknown command: ${argv.join(' ')}\\n`);\n console.log(HELP);\n process.exit(1);\n}\n","import { execSync } from 'child_process';\nimport { createHash } from 'crypto';\nimport { existsSync, readFileSync, writeFileSync } from 'fs';\nimport { join, relative } from 'path';\nimport { createInterface } from 'readline';\nimport { detectStack, installCommand, type Stack } from '../utils/detect-stack';\nimport { patchViteConfig, patchEntry, patchAngularJson, patchAngularAppConfig, type PatchResult } from '../utils/patch-source';\nimport { GRABBY_VERSION, SERVER_PACKAGE } from '../versions';\n\nconst PKG = '@githumbi/grabby';\n\nexport interface InitOptions {\n cwd?: string;\n /** Apply without asking. */\n yes?: boolean;\n /** Show the plan only. */\n dryRun?: boolean;\n /** Skip installing the package. */\n noInstall?: boolean;\n /** Set up live-site feedback instead of local developer mode. */\n live?: { server: string; projectKey: string };\n}\n\nconst c = {\n cyan: (s: string) => `\\x1b[36m${s}\\x1b[0m`,\n yellow: (s: string) => `\\x1b[33m${s}\\x1b[0m`,\n green: (s: string) => `\\x1b[32m${s}\\x1b[0m`,\n bold: (s: string) => `\\x1b[1m${s}\\x1b[0m`,\n dim: (s: string) => `\\x1b[2m${s}\\x1b[0m`,\n};\n\n/**\n * Subresource Integrity for a script-tag build shipped next to this CLI\n * (dist/cli → dist). It's the same file jsDelivr serves for this exact\n * version, so a tampered CDN copy won't run.\n */\nfunction sri(file: string): string | null {\n try {\n const data = readFileSync(new URL(`../${file}`, import.meta.url));\n return `sha384-${createHash('sha384').update(data).digest('base64')}`;\n } catch {\n return null; // running from source\n }\n}\n\n/** A script tag pinned to this exact version, with integrity hashes. */\nexport function cdnScriptTag(live?: { server: string; projectKey: string }): string {\n const file = live ? 'loader.global.js' : 'grabby.global.js';\n const own = sri(file);\n // The loader fetches the full build itself; data-integrity covers that file.\n const full = live ? sri('grabby.global.js') : null;\n const attrs = [\n `src=\"https://cdn.jsdelivr.net/npm/${PKG}@${GRABBY_VERSION}/dist/${file}\"`,\n ...(own ? [`integrity=\"${own}\"`, 'crossorigin=\"anonymous\"'] : []),\n ...(full ? [`data-integrity=\"${full}\"`] : []),\n ...(live ? ['data-mode=\"live\"', `data-server=\"${live.server}\"`, `data-project-key=\"${live.projectKey}\"`] : []),\n 'defer',\n ];\n return `<script ${attrs.join(' ')}></script>`;\n}\n\nconst log = (msg = '') => console.log(msg && `${c.cyan('[grabby]')} ${msg}`);\nconst warn = (msg: string) => console.log(`${c.yellow('[grabby]')} ${msg}`);\n\ninterface Change {\n file: string;\n describe: string;\n next: string;\n}\n\nfunction tryPatch(file: string | null, patch: (code: string) => PatchResult, describe: string, manual: string, changes: Change[], manualSteps: string[]): void {\n if (!file || !existsSync(file)) {\n manualSteps.push(manual);\n return;\n }\n const result = patch(readFileSync(file, 'utf8'));\n if (result.status === 'patched') changes.push({ file, describe, next: result.code });\n else if (result.status === 'already') log(`${describe}: already set up`);\n else manualSteps.push(`${manual}\\n ${c.dim(`(couldn't edit ${file} automatically: ${result.reason})`)}`);\n}\n\n/** What to change for each stack. Anything not safely automatable becomes a manual step. */\nfunction plan(stack: Stack, options: InitOptions): { changes: Change[]; manual: string[]; devDependency: boolean } {\n const changes: Change[] = [];\n const manual: string[] = [];\n const live = options.live;\n const liveCall = live ? `initGrabbyLive({ server: '${live.server}', projectKey: '${live.projectKey}' })` : '';\n\n switch (stack.framework) {\n case 'angular': {\n tryPatch(join(stack.root, 'angular.json'), patchAngularJson, 'use the Grabby builders',\n 'In angular.json, set build → \"@githumbi/grabby:application\" and serve → \"@githumbi/grabby:dev-server\".', changes, manual);\n const appConfig = ['src/app/app.config.ts', 'src/app.config.ts'].map((f) => join(stack.root, f)).find((f) => existsSync(f)) ?? null;\n tryPatch(appConfig, patchAngularAppConfig, 'add provideGrabby()',\n \"In app.config.ts: import { provideGrabby } from '@githumbi/grabby/angular'; and add provideGrabby() to providers.\", changes, manual);\n if (live) manual.push(`For live feedback, pass the options: provideGrabby({ mode: 'live', server: '${live.server}', projectKey: '${live.projectKey}' })`);\n break;\n }\n case 'react':\n case 'vue':\n case 'svelte':\n case 'solid':\n case 'preact': {\n if (stack.framework !== 'svelte' && !live) {\n tryPatch(stack.viteConfig, patchViteConfig, 'add the source-location plugin',\n \"In your bundler config add the plugin first: import grabby from '@githumbi/grabby/plugin'; plugins: [grabby.vite(), …] (also grabby.webpack(), grabby.rspack(), …)\", changes, manual);\n }\n tryPatch(stack.entry, (code) => patchEntry(code, { live }), live ? 'start live feedback' : 'start Grabby in development builds',\n live\n ? `In your entry file: import { initGrabbyLive } from '@githumbi/grabby/live'; ${liveCall};`\n : \"In your entry file: import { initGrabby } from '@githumbi/grabby'; if (import.meta.env.DEV) initGrabby();\", changes, manual);\n break;\n }\n case 'next':\n manual.push(\n \"next.config: const grabby = require('@githumbi/grabby/plugin').default; webpack: (config) => { config.plugins.unshift(grabby.webpack()); return config; }\",\n live\n ? `In a client component rendered by your root layout: useEffect(() => { import('@githumbi/grabby/live').then((g) => g.${liveCall}); }, []);`\n : \"In a client component rendered by your root layout: useEffect(() => { if (process.env.NODE_ENV === 'development') import('@githumbi/grabby').then((g) => g.initGrabby()); }, []);\",\n );\n break;\n case 'nuxt':\n case 'sveltekit':\n case 'astro':\n manual.push(\n stack.framework === 'nuxt' ? \"nuxt.config: vite: { plugins: [require('@githumbi/grabby/plugin').default.vite()] }\" : 'No build plugin needed for Svelte-based apps; Astro can add grabby.vite() under vite.plugins.',\n live\n ? `In a client-only script/plugin: import('@githumbi/grabby/live').then((g) => g.${liveCall});`\n : \"In a client-only script/plugin: if (import.meta.env.DEV) import('@githumbi/grabby').then((g) => g.initGrabby());\",\n );\n break;\n default:\n manual.push(`Add before </body>:\\n ${cdnScriptTag(live)}`);\n }\n\n return { changes, manual, devDependency: !live };\n}\n\nasync function confirm(question: string): Promise<boolean> {\n if (!process.stdin.isTTY) return false;\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n const answer = await new Promise<string>((resolve) => rl.question(question, resolve));\n rl.close();\n return /^y(es)?$/i.test(answer.trim());\n}\n\nexport async function init(options: InitOptions = {}): Promise<void> {\n const stack = detectStack(options.cwd);\n const rel = (f: string) => relative(stack.root, f) || f;\n log(`Project: ${stack.root}`);\n log(`Detected: ${stack.framework}${stack.viteConfig ? ' + Vite' : ''} · ${stack.packageManager}${options.live ? ' · live feedback' : ''}`);\n log();\n\n const { changes, manual, devDependency } = plan(stack, options);\n const install = stack.hasPackageJson && !options.noInstall ? installCommand(stack.packageManager, PKG, devDependency) : null;\n\n if (!install && changes.length === 0 && manual.length === 0) {\n log(c.green('Everything is already set up.'));\n return;\n }\n\n console.log(c.bold(' Grabby will:'));\n if (install) console.log(` • run ${c.bold(install)}`);\n for (const ch of changes) console.log(` • edit ${c.bold(rel(ch.file))}: ${ch.describe}`);\n if (manual.length) {\n console.log(c.bold('\\n You\\'ll need to do by hand:'));\n manual.forEach((m, i) => console.log(` ${i + 1}. ${m}`));\n }\n console.log('');\n\n if (options.dryRun) return;\n if (changes.length || install) {\n const go = options.yes || await confirm(' Go ahead? [y/N] ');\n if (!go) {\n warn(process.stdin.isTTY ? 'Nothing changed.' : 'Nothing changed (not a terminal; re-run with --yes to apply).');\n return;\n }\n }\n\n if (install) {\n try {\n execSync(install, { cwd: stack.root, stdio: 'inherit' });\n } catch {\n warn(`Install failed; run it yourself: ${install}`);\n }\n }\n for (const ch of changes) {\n writeFileSync(ch.file, ch.next, 'utf8');\n log(`${c.green('✓')} ${rel(ch.file)}`);\n }\n\n console.log('');\n log(c.green('Done.'));\n if (options.live) {\n console.log(`\\n Share this feedback link with reviewers: ${c.bold(`https://<your-site>/?grabby=${options.live.projectKey}`)}`);\n console.log(` Pull their comments: ${c.bold(`npx -y ${SERVER_PACKAGE} pull --server ${options.live.server} --token <admin token>`)}\\n`);\n } else {\n console.log(`\\n Start your dev server, press ${c.bold('Alt+G')} (${c.bold('Option+G')} on Mac), click anything, and comment.`);\n console.log(` Then use ${c.bold('Copy all')} and paste into your AI agent.`);\n console.log(` Want your agent to read comments directly? Run ${c.bold('npx grabby add mcp')}.\\n`);\n }\n}\n","import { existsSync, readFileSync } from 'fs';\nimport { join, dirname } from 'path';\n\nexport type PackageManager = 'pnpm' | 'yarn' | 'bun' | 'npm';\nexport type Framework = 'angular' | 'next' | 'nuxt' | 'sveltekit' | 'astro' | 'react' | 'vue' | 'svelte' | 'solid' | 'preact' | 'html';\n\nexport interface Stack {\n root: string;\n packageManager: PackageManager;\n framework: Framework;\n /** vite.config.* when the project builds with Vite. */\n viteConfig: string | null;\n /** The file that mounts the app, where initGrabby() goes. */\n entry: string | null;\n hasPackageJson: boolean;\n}\n\nconst VITE_CONFIGS = ['vite.config.ts', 'vite.config.mts', 'vite.config.js', 'vite.config.mjs'];\nconst ENTRIES = ['src/main.tsx', 'src/main.ts', 'src/main.jsx', 'src/main.js', 'src/index.tsx', 'src/index.jsx', 'src/index.ts', 'src/index.js'];\n\nexport function findProjectRoot(start: string = process.cwd()): string {\n let dir = start;\n while (true) {\n if (existsSync(join(dir, 'package.json'))) return dir;\n const parent = dirname(dir);\n if (parent === dir) return start;\n dir = parent;\n }\n}\n\nexport function detectPackageManager(root: string): PackageManager {\n // Walk up for lockfiles too: a workspace package's lockfile lives at the repo root.\n let dir = root;\n while (true) {\n if (existsSync(join(dir, 'pnpm-lock.yaml'))) return 'pnpm';\n if (existsSync(join(dir, 'yarn.lock'))) return 'yarn';\n if (existsSync(join(dir, 'bun.lockb')) || existsSync(join(dir, 'bun.lock'))) return 'bun';\n if (existsSync(join(dir, 'package-lock.json'))) return 'npm';\n const parent = dirname(dir);\n if (parent === dir) return 'npm';\n dir = parent;\n }\n}\n\nexport function detectStack(start: string = process.cwd()): Stack {\n const root = findProjectRoot(start);\n const pkgPath = join(root, 'package.json');\n const hasPackageJson = existsSync(pkgPath);\n let deps: Record<string, string> = {};\n if (hasPackageJson) {\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));\n deps = { ...pkg.dependencies, ...pkg.devDependencies };\n } catch { /* unreadable package.json: treat as plain HTML */ }\n }\n const has = (name: string) => name in deps;\n\n let framework: Framework = 'html';\n if (existsSync(join(root, 'angular.json')) || has('@angular/core')) framework = 'angular';\n else if (has('next')) framework = 'next';\n else if (has('nuxt')) framework = 'nuxt';\n else if (has('@sveltejs/kit')) framework = 'sveltekit';\n else if (has('astro')) framework = 'astro';\n else if (has('solid-js')) framework = 'solid';\n else if (has('preact')) framework = 'preact';\n else if (has('react')) framework = 'react';\n else if (has('vue')) framework = 'vue';\n else if (has('svelte')) framework = 'svelte';\n\n const viteConfig = VITE_CONFIGS.map((f) => join(root, f)).find((f) => existsSync(f)) ?? null;\n const entry = ENTRIES.map((f) => join(root, f)).find((f) => existsSync(f)) ?? null;\n\n return { root, packageManager: detectPackageManager(root), framework, viteConfig, entry, hasPackageJson };\n}\n\nexport function installCommand(pm: PackageManager, pkg: string, dev: boolean): string {\n switch (pm) {\n case 'pnpm': return `pnpm add ${dev ? '-D ' : ''}${pkg}`;\n case 'yarn': return `yarn add ${dev ? '-D ' : ''}${pkg}`;\n case 'bun': return `bun add ${dev ? '-d ' : ''}${pkg}`;\n default: return `npm install ${dev ? '-D ' : ''}${pkg}`;\n }\n}\n","/*\n * Small, conservative source edits. Each patch either applies cleanly to a\n * recognisable pattern or declines, so `grabby init` never writes a guess;\n * when it declines, init prints the lines to add by hand instead.\n */\n\nexport type PatchResult =\n | { status: 'patched'; code: string }\n | { status: 'already' }\n | { status: 'unrecognised'; reason: string };\n\n/** Index just after the last top-level import statement (0 when there are none). */\nfunction afterImports(code: string): number {\n const re = /^import\\s[^;]*?(?:from\\s+)?['\"][^'\"]+['\"];?[ \\t]*$/gm;\n let end = 0;\n for (let m = re.exec(code); m; m = re.exec(code)) end = m.index + m[0].length;\n return end;\n}\n\nfunction insertImport(code: string, statement: string): string {\n const at = afterImports(code);\n if (at === 0) return `${statement}\\n${code}`;\n return `${code.slice(0, at)}\\n${statement}${code.slice(at)}`;\n}\n\n/** Adds `grabby.vite()` first in the `plugins: [...]` array of a Vite config. */\nexport function patchViteConfig(code: string): PatchResult {\n if (code.includes('@githumbi/grabby/plugin')) return { status: 'already' };\n const plugins = /plugins\\s*:\\s*\\[/.exec(code);\n if (!plugins) return { status: 'unrecognised', reason: 'no `plugins: [ … ]` array found' };\n const at = plugins.index + plugins[0].length;\n // First, so it stamps source before framework plugins compile it.\n const withPlugin = `${code.slice(0, at)}grabby.vite(), ${code.slice(at)}`;\n return { status: 'patched', code: insertImport(withPlugin, \"import grabby from '@githumbi/grabby/plugin';\") };\n}\n\n/** Starts Grabby in the app's entry file, in development builds only. */\nexport function patchEntry(code: string, options: { live?: { server: string; projectKey: string } } = {}): PatchResult {\n if (code.includes('@githumbi/grabby')) return { status: 'already' };\n const at = afterImports(code);\n if (at === 0 && /\\bimport\\b/.test(code.slice(0, 200))) {\n return { status: 'unrecognised', reason: 'could not find where the imports end' };\n }\n const call = options.live\n ? `initGrabbyLive({ server: ${JSON.stringify(options.live.server)}, projectKey: ${JSON.stringify(options.live.projectKey)} });`\n : 'if (import.meta.env.DEV) initGrabby();';\n const imp = options.live\n ? \"import { initGrabbyLive } from '@githumbi/grabby/live';\"\n : \"import { initGrabby } from '@githumbi/grabby';\";\n const withImport = insertImport(code, imp);\n const afterAll = afterImports(withImport);\n return { status: 'patched', code: `${withImport.slice(0, afterAll)}\\n\\n${call}${withImport.slice(afterAll)}` };\n}\n\n/**\n * Swaps the Angular builders for Grabby's, editing the builder strings in\n * place so angular.json keeps its formatting (and any comments).\n */\nexport function patchAngularJson(code: string): PatchResult {\n if (code.includes('@githumbi/grabby:')) return { status: 'already' };\n const next = code\n .replace(/\"@angular(?:-devkit\\/build-angular|\\/build):application\"/g, '\"@githumbi/grabby:application\"')\n .replace(/\"@angular(?:-devkit\\/build-angular|\\/build):dev-server\"/g, '\"@githumbi/grabby:dev-server\"');\n if (next === code) {\n return { status: 'unrecognised', reason: 'no @angular/build:application or :dev-server builder found (Angular 17+ is required)' };\n }\n return { status: 'patched', code: next };\n}\n\n/** Adds provideGrabby() to the providers array of app.config.ts. */\nexport function patchAngularAppConfig(code: string): PatchResult {\n if (code.includes('provideGrabby')) return { status: 'already' };\n const providers = /providers\\s*:\\s*\\[/.exec(code);\n if (!providers) return { status: 'unrecognised', reason: 'no `providers: [ … ]` array found' };\n const at = providers.index + providers[0].length;\n const withProvider = `${code.slice(0, at)}provideGrabby(), ${code.slice(at)}`;\n return { status: 'patched', code: insertImport(withProvider, \"import { provideGrabby } from '@githumbi/grabby/angular';\") };\n}\n","declare const __GRABBY_VERSION__: string;\ndeclare const __GRABBY_SERVER_VERSION__: string;\n\n/** This package's version, filled in at build time. */\nexport const GRABBY_VERSION = __GRABBY_VERSION__;\n\n/**\n * The collector, pinned to an exact version. An MCP server runs with your\n * editor's permissions, and `npx` re-resolves a range on every launch, so a\n * range would let one bad publish reach every user at once. Re-running\n * `grabby add mcp` after upgrading Grabby moves the pin.\n */\nexport const SERVER_PACKAGE = `@githumbi/grabby-server@${__GRABBY_SERVER_VERSION__}`;\n","import { existsSync, readFileSync, writeFileSync } from 'fs';\nimport { join } from 'path';\nimport { SERVER_PACKAGE as MCP_PACKAGE } from '../versions';\nconst MCP_SERVER_NAME = 'grabby';\n\nfunction log(msg: string): void {\n console.log(`\\x1b[36m[grabby]\\x1b[0m ${msg}`);\n}\n\nfunction warn(msg: string): void {\n console.log(`\\x1b[33m[grabby]\\x1b[0m ${msg}`);\n}\n\nfunction success(msg: string): void {\n console.log(`\\x1b[32m[grabby]\\x1b[0m ${msg}`);\n}\n\nfunction getMcpServerEntry(): { type: string; command: string; args: string[] } {\n const isWindows = process.platform === 'win32';\n if (isWindows) {\n return {\n type: 'stdio',\n command: 'cmd',\n args: ['/c', 'npx', '-y', MCP_PACKAGE, 'mcp'],\n };\n }\n return {\n type: 'stdio',\n command: 'npx',\n args: ['-y', MCP_PACKAGE, 'mcp'],\n };\n}\n\nexport async function addMcp(): Promise<void> {\n log('Adding grabby MCP server...\\n');\n\n const mcpJsonPath = join(process.cwd(), '.mcp.json');\n let config: Record<string, unknown> = {};\n\n if (existsSync(mcpJsonPath)) {\n try {\n config = JSON.parse(readFileSync(mcpJsonPath, 'utf-8'));\n } catch {\n // Never clobber a file we can't read: it may hold other servers' config.\n warn('.mcp.json exists but is not valid JSON; leaving it alone. Add this entry by hand:');\n console.log(JSON.stringify({ mcpServers: { [MCP_SERVER_NAME]: getMcpServerEntry() } }, null, 2));\n return;\n }\n }\n\n const servers = (config.mcpServers as Record<string, unknown>) ?? {};\n servers[MCP_SERVER_NAME] = getMcpServerEntry();\n config.mcpServers = servers;\n\n writeFileSync(mcpJsonPath, JSON.stringify(config, null, 2) + '\\n');\n success('Added grabby MCP server to .mcp.json');\n\n console.log('');\n console.log(' It also collects comments from your app on http://localhost:3456.');\n console.log(\" Point Grabby at it: initGrabby({ server: 'http://localhost:3456' })\");\n console.log('');\n console.log(' \\x1b[1mRestart your editor\\x1b[0m to activate the MCP connection.');\n console.log(' When prompted, \\x1b[1mapprove the MCP server\\x1b[0m in your editor.');\n console.log('');\n}\n"],"mappings":";;;AAAA,SAAS,aAAa;AACtB,SAAS,iBAAiB;;;ACD1B,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,cAAAA,aAAY,gBAAAC,eAAc,qBAAqB;AACxD,SAAS,QAAAC,OAAM,gBAAgB;AAC/B,SAAS,uBAAuB;;;ACJhC,SAAS,YAAY,oBAAoB;AACzC,SAAS,MAAM,eAAe;AAgB9B,IAAM,eAAe,CAAC,kBAAkB,mBAAmB,kBAAkB,iBAAiB;AAC9F,IAAM,UAAU,CAAC,gBAAgB,eAAe,gBAAgB,eAAe,iBAAiB,iBAAiB,gBAAgB,cAAc;AAExI,SAAS,gBAAgB,QAAgB,QAAQ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AAc,EAAE,MAAM,UAAU;AAAA,MAChC,MAAM,EAAE,MAAM,UAAU;AAAA,MACxB,QAAQ,EAAE,MAAM,SAAS;AAAA,MACzB,KAAK,EAAE,MAAM,SAAS;AAAA,IACxB;AAAA,EACF,CAAC;AACD,MAAI,OAAO,SAAS,CAAC,OAAO,UAAU,CAAC,OAAO,MAAM;AAClD,SAAK,yGAAyG;AAAA,EAChH;AACA,OAAK;AAAA,IACH,KAAK,OAAO;AAAA,IACZ,QAAQ,OAAO,SAAS;AAAA,IACxB,WAAW,OAAO,YAAY;AAAA,IAC9B,MAAM,OAAO,OAAO,EAAE,QAAQ,OAAO,QAAS,YAAY,OAAO,IAAK,IAAI;AAAA,EAC5E,CAAC,EAAE,MAAM,IAAI;AACf,WAAW,YAAY,UAAU,YAAY,YAAY,YAAY,MAAM;AACzE,UAAQ,IAAI,IAAI;AAClB,OAAO;AACL,UAAQ,MAAM,oBAAoB,KAAK,KAAK,GAAG,CAAC;AAAA,CAAI;AACpD,UAAQ,IAAI,IAAI;AAChB,UAAQ,KAAK,CAAC;AAChB;","names":["existsSync","readFileSync","join","readFileSync","existsSync","join","existsSync","readFileSync","writeFileSync","join","log","warn","join","existsSync","readFileSync","writeFileSync"]}
|