mcp-scraper 0.3.6 → 0.3.7

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.
Files changed (44) hide show
  1. package/README.md +18 -26
  2. package/dist/bin/api-server.cjs +158 -321
  3. package/dist/bin/api-server.cjs.map +1 -1
  4. package/dist/bin/api-server.js +1 -1
  5. package/dist/bin/browser-agent-stdio-server.cjs +39 -1750
  6. package/dist/bin/browser-agent-stdio-server.cjs.map +1 -1
  7. package/dist/bin/browser-agent-stdio-server.js +2 -4
  8. package/dist/bin/browser-agent-stdio-server.js.map +1 -1
  9. package/dist/bin/mcp-scraper-cli.cjs +47 -328
  10. package/dist/bin/mcp-scraper-cli.cjs.map +1 -1
  11. package/dist/bin/mcp-scraper-cli.js +7 -91
  12. package/dist/bin/mcp-scraper-cli.js.map +1 -1
  13. package/dist/bin/mcp-scraper-combined-stdio-server.cjs +78 -1796
  14. package/dist/bin/mcp-scraper-combined-stdio-server.cjs.map +1 -1
  15. package/dist/bin/mcp-scraper-combined-stdio-server.js +4 -6
  16. package/dist/bin/mcp-scraper-combined-stdio-server.js.map +1 -1
  17. package/dist/bin/mcp-scraper-install.cjs +4 -4
  18. package/dist/bin/mcp-scraper-install.cjs.map +1 -1
  19. package/dist/bin/mcp-scraper-install.js +2 -2
  20. package/dist/bin/mcp-stdio-server.cjs +18 -25
  21. package/dist/bin/mcp-stdio-server.cjs.map +1 -1
  22. package/dist/bin/mcp-stdio-server.js +2 -2
  23. package/dist/chunk-2NEVRPK3.js +7 -0
  24. package/dist/chunk-2NEVRPK3.js.map +1 -0
  25. package/dist/{chunk-ROZEDHAA.js → chunk-2O7RAK6E.js} +19 -26
  26. package/dist/chunk-2O7RAK6E.js.map +1 -0
  27. package/dist/{chunk-RVYHP7QN.js → chunk-ELI6NDEG.js} +4 -4
  28. package/dist/{chunk-RVYHP7QN.js.map → chunk-ELI6NDEG.js.map} +1 -1
  29. package/dist/{chunk-TK4D2BZ5.js → chunk-IWNLHCKA.js} +13 -694
  30. package/dist/chunk-IWNLHCKA.js.map +1 -0
  31. package/dist/{server-YSKBD2VX.js → server-HRVD52CX.js} +836 -114
  32. package/dist/server-HRVD52CX.js.map +1 -0
  33. package/docs/mcp-tool-craft-lint.generated.md +2 -5
  34. package/docs/mcp-tool-manifest.generated.json +9 -101
  35. package/package.json +1 -1
  36. package/dist/chunk-DUEW4EOO.js +0 -214
  37. package/dist/chunk-DUEW4EOO.js.map +0 -1
  38. package/dist/chunk-IHXHQL53.js +0 -7
  39. package/dist/chunk-IHXHQL53.js.map +0 -1
  40. package/dist/chunk-NXRWFOEZ.js +0 -816
  41. package/dist/chunk-NXRWFOEZ.js.map +0 -1
  42. package/dist/chunk-ROZEDHAA.js.map +0 -1
  43. package/dist/chunk-TK4D2BZ5.js.map +0 -1
  44. package/dist/server-YSKBD2VX.js.map +0 -1
@@ -8,14 +8,9 @@ import {
8
8
  workflowOutputBaseDir
9
9
  } from "../chunk-H2R232HK.js";
10
10
  import "../chunk-LFATOGDF.js";
11
- import {
12
- importChromeProfile,
13
- listLocalChromeProfiles,
14
- syncImportedChromeProfile
15
- } from "../chunk-DUEW4EOO.js";
16
11
  import {
17
12
  PACKAGE_VERSION
18
- } from "../chunk-IHXHQL53.js";
13
+ } from "../chunk-2NEVRPK3.js";
19
14
 
20
15
  // src/cli/human-cli.ts
21
16
  import { Command } from "commander";
@@ -36,15 +31,8 @@ function combinedNpxArgs(options = {}) {
36
31
  function envConfig(options) {
37
32
  const env = { MCP_SCRAPER_API_KEY: apiKeyValue(options) };
38
33
  const profileName = options.browserProfileName?.trim();
39
- if (options.browserMode === "local") {
40
- env.MCP_SCRAPER_BROWSER_MODE = "local";
41
- if (profileName) env.MCP_SCRAPER_BROWSER_PROFILE = profileName;
42
- const executablePath = options.browserExecutablePath?.trim();
43
- if (executablePath) env.MCP_SCRAPER_BROWSER_EXECUTABLE = executablePath;
44
- } else {
45
- if (profileName) env.BROWSER_AGENT_PROFILE_NAME = profileName;
46
- if (options.browserProfileSaveChanges === true) env.BROWSER_AGENT_PROFILE_SAVE_CHANGES = "true";
47
- }
34
+ if (profileName) env.BROWSER_AGENT_PROFILE_NAME = profileName;
35
+ if (options.browserProfileSaveChanges === true) env.BROWSER_AGENT_PROFILE_SAVE_CHANGES = "true";
48
36
  return env;
49
37
  }
50
38
  function tomlInlineTable(value) {
@@ -512,77 +500,9 @@ function buildHumanCli() {
512
500
  result.next_step ?? "Complete checkout, then retry the MCP request."
513
501
  ].join("\n"), false);
514
502
  });
515
- const browser = program.command("browser").description("Inspect developer-only local browser helpers. Customer auth uses hosted browser_profile_onboard.");
516
- browser.command("profiles").description("Developer-only: list local Chrome profiles and suggested managed browser profile names.").option("--email <email>", "Filter by Chrome account email or displayed profile name").option("--user-data-dir <path>", "Chrome user data directory").option("--json", "Print machine-readable JSON").action(async (opts) => {
517
- const profiles = await listLocalChromeProfiles(opts.userDataDir, opts.email);
518
- if (opts.json) {
519
- writeOutput({ profiles }, true);
520
- return;
521
- }
522
- if (!profiles.length) {
523
- writeOutput("No matching Chrome profiles found.", false);
524
- return;
525
- }
526
- const lines = [
527
- "Developer-only local Chrome profiles:",
528
- ...profiles.map((profile) => [
529
- `${profile.email || "(no email)"} ${profile.chromeProfileDirectory} ${profile.displayName}`,
530
- ` suggested profile name: ${profile.recommendedKernelProfileName}`,
531
- ` local Chrome path: ${profile.chromeProfilePath}`
532
- ].join("\n")),
533
- "",
534
- "Customer auth setup does not use local Chrome import.",
535
- 'In the MCP client, call browser_profile_onboard with url="https://google.com/", give the user the watch_url, then call browser_close after login to save the hosted profile.'
536
- ];
537
- writeOutput(lines.join("\n"), false);
538
- });
539
- browser.command("import-chrome").description("Developer-only: clone a local Chrome profile into MCP Scraper managed local browser storage.").option("--email <email>", "Chrome account email or displayed profile name to import").option("--name <name>", "Managed MCP Scraper browser profile name").option("--chrome-profile <directory>", "Chrome profile directory, for example Default or Profile 1").option("--user-data-dir <path>", "Source Chrome user data directory").option("--output-dir <path>", "Managed profile base directory").option("--browser-executable <path>", "Chrome executable path for local launches").option("--overwrite", "Overwrite an existing managed profile clone").option("--json", "Print machine-readable JSON").action(async (opts) => {
540
- const result = await importChromeProfile({
541
- email: opts.email,
542
- name: opts.name,
543
- chromeProfileDirectory: opts.chromeProfile,
544
- sourceUserDataDir: opts.userDataDir,
545
- outputDir: opts.outputDir,
546
- browserExecutablePath: opts.browserExecutable,
547
- overwrite: opts.overwrite
548
- });
549
- if (opts.json) {
550
- writeOutput(result, true);
551
- return;
552
- }
553
- writeOutput([
554
- `Imported Chrome profile: ${result.profile.name}`,
555
- `Source: ${result.sourceProfile.email || result.sourceProfile.displayName || result.sourceProfile.chromeProfileDirectory} (${result.sourceProfile.chromeProfileDirectory})`,
556
- `Managed user data dir: ${result.profile.userDataDir}`,
557
- "",
558
- "Developer-only local install/config command:",
559
- ` MCP_SCRAPER_API_KEY=sk_live_your_key mcp-scraper-cli agent install claude --apply --browser-mode local --browser-profile ${result.profile.name}`,
560
- "",
561
- "Customer auth setup should use browser_profile_onboard at Google, the hosted watch_url, and browser_close to save the hosted profile.",
562
- "Fully exit Claude Code and start a new Claude terminal after applying developer local config. Re-run sync-profile after signing into new sites in normal Chrome."
563
- ].join("\n"), false);
564
- });
565
- browser.command("sync-profile <name>").description("Refresh a managed local browser profile from its recorded source Chrome profile.").option("--output-dir <path>", "Managed profile base directory").option("--browser-executable <path>", "Chrome executable path for local launches").option("--json", "Print machine-readable JSON").action(async (name, opts) => {
566
- const result = await syncImportedChromeProfile(name, {
567
- outputDir: opts.outputDir,
568
- browserExecutablePath: opts.browserExecutable
569
- });
570
- if (opts.json) {
571
- writeOutput(result, true);
572
- return;
573
- }
574
- writeOutput([
575
- `Synced Chrome profile: ${result.profile.name}`,
576
- `Source: ${result.sourceProfile.email || result.sourceProfile.displayName || result.sourceProfile.chromeProfileDirectory} (${result.sourceProfile.chromeProfileDirectory})`,
577
- `Managed user data dir: ${result.profile.userDataDir}`,
578
- "Restart any local browser sessions that were using this profile."
579
- ].join("\n"), false);
580
- });
581
503
  const agent = program.command("agent").description("Generate AI-agent install configs and workflow prompts.");
582
- agent.command("install <host>").description("Print or apply install/config instructions for codex, claude/claude-code, or claude-desktop.").option("--api-key <key>", "API key to place in generated config").option("--package <spec>", "npm package spec", "mcp-scraper@latest").option("--browser-mode <mode>", "Browser mode: hosted or local", "hosted").option("--browser-profile <name>", "Default browser profile for browser_open sessions. In local mode this is a managed MCP Scraper profile name; in hosted mode it is a Kernel profile name.").option("--browser-executable <path>", "Chrome executable path for local browser mode").option("--save-browser-profile-changes", "Persist cookies/local storage back to the named browser profile when sessions close").option("--apply", "Apply the config to the local client when supported. For Claude Code, this upserts the user-scope mcp-scraper server.").option("--json", "Print machine-readable JSON").action(async (hostInput, opts) => {
504
+ agent.command("install <host>").description("Print or apply install/config instructions for codex, claude/claude-code, or claude-desktop.").option("--api-key <key>", "API key to place in generated config").option("--package <spec>", "npm package spec", "mcp-scraper@latest").option("--browser-profile <name>", "Default saved browser profile for browser_open sessions.").option("--save-browser-profile-changes", "Persist cookies/local storage back to the named browser profile when sessions close").option("--apply", "Apply the config to the local client when supported. For Claude Code, this upserts the user-scope mcp-scraper server.").option("--json", "Print machine-readable JSON").action(async (hostInput, opts) => {
583
505
  const host = normalizeAgentHost(hostInput);
584
- const browserMode = String(opts.browserMode ?? "hosted");
585
- if (!["hosted", "local"].includes(browserMode)) throw new Error("Unknown browser mode. Use: hosted or local");
586
506
  const apiKey = opts.apiKey ?? process.env.MCP_SCRAPER_API_KEY;
587
507
  if (opts.apply) {
588
508
  if (host !== "claude") throw new Error('--apply is currently supported for Claude Code only. Use host "claude" or "claude-code".');
@@ -592,10 +512,8 @@ function buildHumanCli() {
592
512
  const configOptions = {
593
513
  apiKey,
594
514
  packageSpec: opts.package,
595
- browserMode,
596
515
  browserProfileName: opts.browserProfile,
597
- browserProfileSaveChanges: opts.saveBrowserProfileChanges,
598
- browserExecutablePath: opts.browserExecutable
516
+ browserProfileSaveChanges: opts.saveBrowserProfileChanges
599
517
  };
600
518
  const remove = await runLocalCommand("claude", claudeMcpRemoveArgs());
601
519
  const add = await runLocalCommand("claude", claudeMcpAddArgs(configOptions));
@@ -625,7 +543,7 @@ function buildHumanCli() {
625
543
  "Applied Claude Code MCP config: mcp-scraper",
626
544
  remove.code === 0 ? "Replaced existing mcp-scraper entry." : "No existing mcp-scraper entry found; added a new one.",
627
545
  "Command: npx -y -p " + opts.package + " mcp-scraper-combined",
628
- browserMode === "local" && opts.browserProfile ? `Local browser profile: ${opts.browserProfile}` : "",
546
+ opts.browserProfile ? `Browser profile: ${opts.browserProfile}` : "",
629
547
  "",
630
548
  "Next step: fully exit Claude Code, start a new Claude terminal, then run:",
631
549
  " claude mcp list",
@@ -638,10 +556,8 @@ ${result.list}` : ""
638
556
  const text = renderAgentInstall(host, {
639
557
  apiKey: opts.apiKey,
640
558
  packageSpec: opts.package,
641
- browserMode,
642
559
  browserProfileName: opts.browserProfile,
643
- browserProfileSaveChanges: opts.saveBrowserProfileChanges,
644
- browserExecutablePath: opts.browserExecutable
560
+ browserProfileSaveChanges: opts.saveBrowserProfileChanges
645
561
  });
646
562
  writeOutput(opts.json ? { host, text } : text, opts.json);
647
563
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cli/human-cli.ts","../../src/cli/agent-config.ts","../../src/cli/doctor.ts","../../src/cli/prompts.ts","../../bin/mcp-scraper-cli.ts"],"sourcesContent":["import { Command } from 'commander'\nimport { spawn } from 'node:child_process'\nimport { mkdir, writeFile } from 'node:fs/promises'\nimport { basename, join } from 'node:path'\nimport { PACKAGE_VERSION } from '../version.js'\nimport { listLocalChromeProfiles } from '../lib/chrome-profiles.js'\nimport { importChromeProfile, syncImportedChromeProfile } from '../lib/local-browser-profiles.js'\nimport {\n claudeMcpAddArgs,\n claudeMcpRemoveArgs,\n normalizeAgentHost,\n renderAgentInstall,\n type AgentHost,\n type BrowserMode,\n} from './agent-config.js'\nimport { renderDoctor, runDoctor } from './doctor.js'\nimport { listPrompts, renderPrompt } from './prompts.js'\nimport { workflowOutputBaseDir } from '../workflows/artifact-writer.js'\nimport { findWorkflowReport, listWorkflowDefinitions, listWorkflowReports, openWorkflowReport, runWorkflow } from '../workflows/registry.js'\n\nfunction numberOpt(value: unknown): number | undefined {\n if (value === undefined || value === null || value === '') return undefined\n const parsed = Number(value)\n return Number.isFinite(parsed) ? parsed : undefined\n}\n\nfunction booleanOpt(value: unknown): boolean | undefined {\n if (value === undefined) return undefined\n if (typeof value === 'boolean') return value\n if (value === 'true') return true\n if (value === 'false') return false\n return undefined\n}\n\nfunction compactInput(input: Record<string, unknown>): Record<string, unknown> {\n return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== undefined))\n}\n\nfunction workflowInput(id: string, opts: Record<string, unknown>): Record<string, unknown> {\n if (id === 'agent-packet' || id === 'serp-comparison' || id === 'ai-overview-language') {\n return compactInput({\n keyword: opts.keyword,\n domain: opts.domain,\n url: opts.url,\n location: opts.location,\n maxResults: numberOpt(opts.maxResults),\n maxQuestions: numberOpt(opts.maxQuestions),\n extractTop: numberOpt(opts.extractTop),\n includeSerp: opts.serp === false ? false : undefined,\n includePaa: opts.paa === false ? false : undefined,\n includeAiOverview: booleanOpt(opts.includeAiOverview),\n returnPartial: opts.returnPartial === false ? false : undefined,\n })\n }\n\n if (id === 'paa-expansion-brief') {\n return compactInput({\n keyword: opts.keyword,\n location: opts.location,\n maxQuestions: numberOpt(opts.maxQuestions),\n depth: numberOpt(opts.depth),\n returnPartial: opts.returnPartial === false ? false : undefined,\n })\n }\n\n if (id === 'directory' || id === 'local-competitive-audit' || id === 'map-comparison') {\n return compactInput({\n query: opts.query,\n location: opts.location,\n state: opts.state,\n minPopulation: numberOpt(opts.minPop ?? opts.minPopulation),\n maxCities: numberOpt(opts.maxCities),\n maxResultsPerCity: numberOpt(opts.perCity ?? opts.maxResultsPerCity ?? opts.maxResults),\n concurrency: numberOpt(opts.concurrency),\n proxyMode: opts.proxyMode,\n hydrateTop: id === 'local-competitive-audit' || id === 'map-comparison' ? numberOpt(opts.hydrateTop) : undefined,\n maxReviews: id === 'local-competitive-audit' || id === 'map-comparison' ? numberOpt(opts.reviews ?? opts.maxReviews) : undefined,\n returnPartial: opts.returnPartial === false ? false : undefined,\n })\n }\n\n return compactInput(opts)\n}\n\nfunction writeOutput(data: unknown, json: boolean | undefined): void {\n if (json) {\n process.stdout.write(`${JSON.stringify(data, null, 2)}\\n`)\n } else if (typeof data === 'string') {\n process.stdout.write(`${data}\\n`)\n } else {\n process.stdout.write(`${JSON.stringify(data, null, 2)}\\n`)\n }\n}\n\nfunction maskSecrets(value: string): string {\n return value.replace(/sk_[A-Za-z0-9_-]+/g, 'sk_***')\n}\n\nfunction runLocalCommand(command: string, args: string[]): Promise<{ code: number; stdout: string; stderr: string }> {\n return new Promise((resolve) => {\n const child = spawn(command, args, { stdio: ['ignore', 'pipe', 'pipe'] })\n const stdout: Buffer[] = []\n const stderr: Buffer[] = []\n let settled = false\n const done = (result: { code: number; stdout: string; stderr: string }) => {\n if (settled) return\n settled = true\n resolve(result)\n }\n child.stdout.on('data', chunk => stdout.push(Buffer.from(chunk)))\n child.stderr.on('data', chunk => stderr.push(Buffer.from(chunk)))\n child.on('error', err => {\n done({ code: 127, stdout: '', stderr: err.message })\n })\n child.on('close', code => {\n done({\n code: typeof code === 'number' ? code : 1,\n stdout: Buffer.concat(stdout).toString('utf8'),\n stderr: Buffer.concat(stderr).toString('utf8'),\n })\n })\n })\n}\n\nfunction cadenceOpt(opts: Record<string, unknown>): 'daily' | 'weekly' | 'monthly' {\n if (opts.daily) return 'daily'\n if (opts.monthly) return 'monthly'\n return 'weekly'\n}\n\nfunction apiOptions(opts: Record<string, unknown>): { apiUrl: string; apiKey: string } {\n const apiKey = String(opts.apiKey ?? process.env.MCP_SCRAPER_API_KEY ?? '').trim()\n if (!apiKey) throw new Error('MCP_SCRAPER_API_KEY is required. Pass --api-key or set the environment variable.')\n return {\n apiUrl: String(opts.apiUrl ?? process.env.MCP_SCRAPER_API_URL ?? 'https://mcpscraper.dev').replace(/\\/$/, ''),\n apiKey,\n }\n}\n\nfunction openExternalUrl(url: string): boolean {\n const command = process.platform === 'darwin'\n ? 'open'\n : process.platform === 'win32'\n ? 'cmd'\n : 'xdg-open'\n const args = process.platform === 'win32' ? ['/c', 'start', '', url] : [url]\n try {\n const child = spawn(command, args, { detached: true, stdio: 'ignore' })\n child.unref()\n return true\n } catch {\n return false\n }\n}\n\nasync function apiRequest<T>(path: string, method: string, opts: Record<string, unknown>, body?: unknown): Promise<T> {\n const { apiUrl, apiKey } = apiOptions(opts)\n const res = await fetch(`${apiUrl}${path}`, {\n method,\n headers: {\n 'Content-Type': 'application/json',\n 'x-api-key': apiKey,\n },\n body: body == null ? undefined : JSON.stringify(body),\n })\n const data = await res.json().catch(() => ({}))\n if (!res.ok) {\n const message = typeof (data as { error?: unknown }).error === 'string'\n ? (data as { error: string }).error\n : `API request failed with ${res.status}`\n throw new Error(message)\n }\n return data as T\n}\n\nfunction addWorkflowInputOptions(command: Command): Command {\n return command\n .option('--keyword <keyword>', 'Agent packet keyword')\n .option('--domain <domain>', 'Target domain')\n .option('--url <url>', 'Target page URL')\n .option('--location <location>', 'Target location')\n .option('--max-results <n>', 'Maximum SERP or Maps results')\n .option('--max-questions <n>', 'Maximum PAA questions')\n .option('--extract-top <n>', 'Top result pages or citation pages to extract')\n .option('--depth <n>', 'PAA expansion depth')\n .option('--no-serp', 'Skip SERP evidence for agent packet')\n .option('--no-paa', 'Skip PAA evidence for agent packet')\n .option('--query <query>', 'Business category or workflow query')\n .option('--state <state>', 'US state')\n .option('--min-pop <n>', 'Minimum city population')\n .option('--max-cities <n>', 'Maximum selected cities')\n .option('--per-city <n>', 'Maps results per city')\n .option('--concurrency <n>', 'City search concurrency')\n .option('--proxy-mode <mode>', 'Proxy mode: location, configured, or none')\n .option('--hydrate-top <n>', 'Profiles to hydrate per city for competitive audits')\n .option('--reviews <n>', 'Review cards to collect per hydrated profile')\n .option('--no-return-partial', 'Fail instead of writing partial artifacts')\n}\n\nexport function buildHumanCli(): Command {\n const program = new Command()\n program\n .name('mcp-scraper-cli')\n .description('Human CLI for MCP Scraper setup, workflows, reports, and agent-ready SEO artifacts.')\n .version(PACKAGE_VERSION)\n\n program.command('doctor')\n .description('Check local setup, API key, output directory, package version, and recommended MCP config.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--output-dir <path>', 'Output directory to test')\n .option('--json', 'Print machine-readable JSON')\n .action(async (opts) => {\n const output = await runDoctor({ apiKey: opts.apiKey, apiUrl: opts.apiUrl, outputDir: opts.outputDir })\n writeOutput(opts.json ? output : renderDoctor(output), opts.json)\n if (!output.ok) process.exitCode = 1\n })\n\n const billing = program.command('billing').description('Inspect billing and start checkout flows.')\n const billingConcurrency = billing.command('concurrency').description('Manage MCP Scraper concurrency slots.')\n\n billingConcurrency.command('info')\n .description('Show current concurrency limit and extra-slot price.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--json', 'Print machine-readable JSON')\n .action(async (opts) => {\n const result = await apiRequest<{ concurrency: Record<string, unknown> }>('/billing/credits', 'POST', opts, {})\n if (opts.json) writeOutput(result.concurrency, true)\n else {\n const upgrade = result.concurrency?.upgrade as Record<string, unknown> | undefined\n writeOutput([\n `Current limit: ${result.concurrency?.current_limit ?? 'unknown'} concurrent operations`,\n `Extra slots: ${result.concurrency?.current_extra_slots ?? 'unknown'}`,\n `Extra concurrency slot: ${upgrade?.price_label ?? '$5/month'}`,\n `Upgrade command: ${upgrade?.terminal_command ?? 'mcp-scraper-cli billing concurrency checkout'}`,\n ].join('\\n'), false)\n }\n })\n\n billingConcurrency.command('checkout')\n .description('Create a hosted Stripe checkout for one extra concurrency slot.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--json', 'Print machine-readable JSON')\n .option('--no-open', 'Print the checkout URL without opening a browser')\n .action(async (opts) => {\n const result = await apiRequest<{ checkout_url: string; price?: { price_label?: string }; next_step?: string }>('/billing/concurrency/terminal-checkout', 'POST', opts, {})\n if (opts.json) {\n writeOutput(result, true)\n return\n }\n const opened = opts.open !== false && openExternalUrl(result.checkout_url)\n writeOutput([\n `Extra concurrency slot: ${result.price?.price_label ?? '$5/month'}`,\n opened ? `Opened checkout: ${result.checkout_url}` : `Checkout URL: ${result.checkout_url}`,\n result.next_step ?? 'Complete checkout, then retry the MCP request.',\n ].join('\\n'), false)\n })\n\n const browser = program.command('browser').description('Inspect developer-only local browser helpers. Customer auth uses hosted browser_profile_onboard.')\n browser.command('profiles')\n .description('Developer-only: list local Chrome profiles and suggested managed browser profile names.')\n .option('--email <email>', 'Filter by Chrome account email or displayed profile name')\n .option('--user-data-dir <path>', 'Chrome user data directory')\n .option('--json', 'Print machine-readable JSON')\n .action(async (opts) => {\n const profiles = await listLocalChromeProfiles(opts.userDataDir, opts.email)\n if (opts.json) {\n writeOutput({ profiles }, true)\n return\n }\n if (!profiles.length) {\n writeOutput('No matching Chrome profiles found.', false)\n return\n }\n const lines = [\n 'Developer-only local Chrome profiles:',\n ...profiles.map(profile => [\n `${profile.email || '(no email)'}\\t${profile.chromeProfileDirectory}\\t${profile.displayName}`,\n ` suggested profile name: ${profile.recommendedKernelProfileName}`,\n ` local Chrome path: ${profile.chromeProfilePath}`,\n ].join('\\n')),\n '',\n 'Customer auth setup does not use local Chrome import.',\n 'In the MCP client, call browser_profile_onboard with url=\"https://google.com/\", give the user the watch_url, then call browser_close after login to save the hosted profile.',\n ]\n writeOutput(lines.join('\\n'), false)\n })\n\n browser.command('import-chrome')\n .description('Developer-only: clone a local Chrome profile into MCP Scraper managed local browser storage.')\n .option('--email <email>', 'Chrome account email or displayed profile name to import')\n .option('--name <name>', 'Managed MCP Scraper browser profile name')\n .option('--chrome-profile <directory>', 'Chrome profile directory, for example Default or Profile 1')\n .option('--user-data-dir <path>', 'Source Chrome user data directory')\n .option('--output-dir <path>', 'Managed profile base directory')\n .option('--browser-executable <path>', 'Chrome executable path for local launches')\n .option('--overwrite', 'Overwrite an existing managed profile clone')\n .option('--json', 'Print machine-readable JSON')\n .action(async (opts) => {\n const result = await importChromeProfile({\n email: opts.email,\n name: opts.name,\n chromeProfileDirectory: opts.chromeProfile,\n sourceUserDataDir: opts.userDataDir,\n outputDir: opts.outputDir,\n browserExecutablePath: opts.browserExecutable,\n overwrite: opts.overwrite,\n })\n if (opts.json) {\n writeOutput(result, true)\n return\n }\n writeOutput([\n `Imported Chrome profile: ${result.profile.name}`,\n `Source: ${result.sourceProfile.email || result.sourceProfile.displayName || result.sourceProfile.chromeProfileDirectory} (${result.sourceProfile.chromeProfileDirectory})`,\n `Managed user data dir: ${result.profile.userDataDir}`,\n '',\n 'Developer-only local install/config command:',\n ` MCP_SCRAPER_API_KEY=sk_live_your_key mcp-scraper-cli agent install claude --apply --browser-mode local --browser-profile ${result.profile.name}`,\n '',\n 'Customer auth setup should use browser_profile_onboard at Google, the hosted watch_url, and browser_close to save the hosted profile.',\n 'Fully exit Claude Code and start a new Claude terminal after applying developer local config. Re-run sync-profile after signing into new sites in normal Chrome.',\n ].join('\\n'), false)\n })\n\n browser.command('sync-profile <name>')\n .description('Refresh a managed local browser profile from its recorded source Chrome profile.')\n .option('--output-dir <path>', 'Managed profile base directory')\n .option('--browser-executable <path>', 'Chrome executable path for local launches')\n .option('--json', 'Print machine-readable JSON')\n .action(async (name: string, opts) => {\n const result = await syncImportedChromeProfile(name, {\n outputDir: opts.outputDir,\n browserExecutablePath: opts.browserExecutable,\n })\n if (opts.json) {\n writeOutput(result, true)\n return\n }\n writeOutput([\n `Synced Chrome profile: ${result.profile.name}`,\n `Source: ${result.sourceProfile.email || result.sourceProfile.displayName || result.sourceProfile.chromeProfileDirectory} (${result.sourceProfile.chromeProfileDirectory})`,\n `Managed user data dir: ${result.profile.userDataDir}`,\n 'Restart any local browser sessions that were using this profile.',\n ].join('\\n'), false)\n })\n\n const agent = program.command('agent').description('Generate AI-agent install configs and workflow prompts.')\n agent.command('install <host>')\n .description('Print or apply install/config instructions for codex, claude/claude-code, or claude-desktop.')\n .option('--api-key <key>', 'API key to place in generated config')\n .option('--package <spec>', 'npm package spec', 'mcp-scraper@latest')\n .option('--browser-mode <mode>', 'Browser mode: hosted or local', 'hosted')\n .option('--browser-profile <name>', 'Default browser profile for browser_open sessions. In local mode this is a managed MCP Scraper profile name; in hosted mode it is a Kernel profile name.')\n .option('--browser-executable <path>', 'Chrome executable path for local browser mode')\n .option('--save-browser-profile-changes', 'Persist cookies/local storage back to the named browser profile when sessions close')\n .option('--apply', 'Apply the config to the local client when supported. For Claude Code, this upserts the user-scope mcp-scraper server.')\n .option('--json', 'Print machine-readable JSON')\n .action(async (hostInput: AgentHost, opts) => {\n const host = normalizeAgentHost(hostInput)\n const browserMode = String(opts.browserMode ?? 'hosted') as BrowserMode\n if (!['hosted', 'local'].includes(browserMode)) throw new Error('Unknown browser mode. Use: hosted or local')\n const apiKey = opts.apiKey ?? process.env.MCP_SCRAPER_API_KEY\n if (opts.apply) {\n if (host !== 'claude') throw new Error('--apply is currently supported for Claude Code only. Use host \"claude\" or \"claude-code\".')\n if (!apiKey?.trim()) {\n throw new Error('MCP_SCRAPER_API_KEY is required for --apply. Set it in the environment or pass --api-key.')\n }\n\n const configOptions = {\n apiKey,\n packageSpec: opts.package,\n browserMode,\n browserProfileName: opts.browserProfile,\n browserProfileSaveChanges: opts.saveBrowserProfileChanges,\n browserExecutablePath: opts.browserExecutable,\n }\n const remove = await runLocalCommand('claude', claudeMcpRemoveArgs())\n const add = await runLocalCommand('claude', claudeMcpAddArgs(configOptions))\n if (add.code !== 0) {\n const reason = maskSecrets([add.stderr, add.stdout].filter(Boolean).join('\\n').trim())\n throw new Error([\n 'Claude Code MCP registration failed.',\n reason || 'No error output returned.',\n 'Make sure Claude Code is installed and the `claude` command is on PATH.',\n ].join('\\n'))\n }\n const list = await runLocalCommand('claude', ['mcp', 'list'])\n const result = {\n host: 'claude',\n applied: true,\n replacedExisting: remove.code === 0,\n command: 'npx',\n args: ['-y', '-p', opts.package, 'mcp-scraper-combined'],\n nextStep: 'Fully exit Claude Code, start a new Claude terminal, then run: claude mcp list',\n list: maskSecrets([list.stdout, list.stderr].filter(Boolean).join('\\n').trim()),\n }\n if (opts.json) {\n writeOutput(result, true)\n return\n }\n writeOutput([\n 'Applied Claude Code MCP config: mcp-scraper',\n remove.code === 0 ? 'Replaced existing mcp-scraper entry.' : 'No existing mcp-scraper entry found; added a new one.',\n 'Command: npx -y -p ' + opts.package + ' mcp-scraper-combined',\n browserMode === 'local' && opts.browserProfile ? `Local browser profile: ${opts.browserProfile}` : '',\n '',\n 'Next step: fully exit Claude Code, start a new Claude terminal, then run:',\n ' claude mcp list',\n '',\n result.list ? `Current Claude MCP list:\\n${result.list}` : '',\n ].filter(Boolean).join('\\n'), false)\n return\n }\n const text = renderAgentInstall(host, {\n apiKey: opts.apiKey,\n packageSpec: opts.package,\n browserMode,\n browserProfileName: opts.browserProfile,\n browserProfileSaveChanges: opts.saveBrowserProfileChanges,\n browserExecutablePath: opts.browserExecutable,\n })\n writeOutput(opts.json ? { host, text } : text, opts.json)\n })\n\n agent.command('prompt [name]')\n .description('Print an agent prompt template.')\n .option('--json', 'Print machine-readable JSON')\n .action((name: string | undefined, opts) => {\n if (!name) {\n writeOutput(opts.json ? { prompts: listPrompts() } : listPrompts().join('\\n'), opts.json)\n return\n }\n const text = renderPrompt(name)\n writeOutput(opts.json ? { name, text } : text, opts.json)\n })\n\n const workflow = program.command('workflow').description('Run named SEO workflows.')\n workflow.command('list')\n .description('List available workflows.')\n .option('--json', 'Print machine-readable JSON')\n .action((opts) => {\n const rows = listWorkflowDefinitions()\n if (opts.json) writeOutput({ workflows: rows }, true)\n else writeOutput(rows.map(row => `${row.id}\\t${row.title}\\n ${row.description}`).join('\\n'), false)\n })\n\n workflow.command('run <id>')\n .description('Run a workflow and save local artifacts.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--output-dir <path>', 'Workflow output directory')\n .option('--json', 'Print machine-readable JSON')\n .option('--keyword <keyword>', 'Agent packet keyword')\n .option('--domain <domain>', 'Target domain')\n .option('--url <url>', 'Target page URL')\n .option('--location <location>', 'Target location')\n .option('--max-results <n>', 'Maximum SERP or Maps results')\n .option('--max-questions <n>', 'Maximum PAA questions')\n .option('--extract-top <n>', 'Top result pages or citation pages to extract')\n .option('--depth <n>', 'PAA expansion depth')\n .option('--no-serp', 'Skip SERP evidence for agent packet')\n .option('--no-paa', 'Skip PAA evidence for agent packet')\n .option('--query <query>', 'Business category or workflow query')\n .option('--state <state>', 'US state')\n .option('--min-pop <n>', 'Minimum city population')\n .option('--max-cities <n>', 'Maximum selected cities')\n .option('--per-city <n>', 'Maps results per city')\n .option('--concurrency <n>', 'City search concurrency')\n .option('--proxy-mode <mode>', 'Proxy mode: location, configured, or none')\n .option('--hydrate-top <n>', 'Profiles to hydrate per city for competitive audits')\n .option('--reviews <n>', 'Review cards to collect per hydrated profile')\n .option('--no-return-partial', 'Fail instead of writing partial artifacts')\n .action(async (id: string, opts) => {\n const summary = await runWorkflow(id, workflowInput(id, opts), {\n apiKey: opts.apiKey,\n apiUrl: opts.apiUrl,\n outputDir: opts.outputDir,\n })\n if (opts.json) writeOutput(summary, true)\n else {\n writeOutput([\n `${summary.title}: ${summary.status}`,\n summary.summary,\n summary.reportPath ? `Report: ${summary.reportPath}` : '',\n summary.warnings.length ? `Warnings:\\n${summary.warnings.map(w => `- ${w}`).join('\\n')}` : '',\n ].filter(Boolean).join('\\n'), false)\n }\n })\n\n const report = program.command('report').description('List and open local workflow reports.')\n report.command('list')\n .description('List recent workflow reports.')\n .option('--output-dir <path>', 'Workflow output directory')\n .option('--json', 'Print machine-readable JSON')\n .action(async (opts) => {\n const reports = await listWorkflowReports(opts.outputDir)\n writeOutput(opts.json ? { reports } : reports.map(r => `${r.startedAt}\\t${r.workflow}\\t${r.status}\\t${r.reportPath ?? r.manifestPath}`).join('\\n'), opts.json)\n })\n report.command('path [id]')\n .description('Print a report path. Defaults to last.')\n .option('--output-dir <path>', 'Workflow output directory')\n .option('--json', 'Print machine-readable JSON')\n .action(async (id = 'last', opts) => {\n const found = await findWorkflowReport(id, opts.outputDir)\n if (!found?.reportPath) throw new Error(`No report found for \"${id}\"`)\n writeOutput(opts.json ? { path: found.reportPath, run: found } : found.reportPath, opts.json)\n })\n report.command('open [id]')\n .description('Open a report. Defaults to last.')\n .option('--output-dir <path>', 'Workflow output directory')\n .option('--json', 'Print machine-readable JSON instead of opening')\n .action(async (id = 'last', opts) => {\n if (opts.json) {\n const found = await findWorkflowReport(id, opts.outputDir)\n if (!found?.reportPath) throw new Error(`No report found for \"${id}\"`)\n writeOutput({ path: found.reportPath, run: found }, true)\n return\n }\n const path = await openWorkflowReport(id, opts.outputDir)\n writeOutput(`Opened: ${path}`, false)\n })\n\n const schedule = program.command('schedule').description('Create and manage hosted workflow schedules.')\n addWorkflowInputOptions(schedule.command('create <workflowId>')\n .description('Create a recurring hosted workflow schedule.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--name <name>', 'Schedule name')\n .option('--daily', 'Run daily')\n .option('--weekly', 'Run weekly')\n .option('--monthly', 'Run monthly')\n .option('--timezone <tz>', 'Schedule timezone', 'UTC')\n .option('--webhook <url>', 'HTTPS webhook URL')\n .option('--next-run-at <iso>', 'First run time as an ISO timestamp')\n .option('--json', 'Print machine-readable JSON'))\n .action(async (workflowId: string, opts) => {\n const result = await apiRequest('/workflows/schedules', 'POST', opts, {\n workflowId,\n name: opts.name,\n input: workflowInput(workflowId, opts),\n cadence: cadenceOpt(opts),\n timezone: opts.timezone,\n webhookUrl: opts.webhook,\n nextRunAt: opts.nextRunAt,\n })\n writeOutput(result, opts.json)\n })\n\n schedule.command('list')\n .description('List hosted workflow schedules.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--json', 'Print machine-readable JSON')\n .action(async (opts) => {\n const result = await apiRequest<{ schedules: Array<Record<string, unknown>> }>('/workflows/schedules', 'GET', opts)\n if (opts.json) writeOutput(result, true)\n else writeOutput(result.schedules.map(scheduleRow => `${scheduleRow.id}\\t${scheduleRow.status}\\t${scheduleRow.workflow_id}\\t${scheduleRow.next_run_at ?? ''}`).join('\\n'), false)\n })\n\n schedule.command('pause <id>')\n .description('Pause a hosted workflow schedule.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--json', 'Print machine-readable JSON')\n .action(async (id: string, opts) => writeOutput(await apiRequest(`/workflows/schedules/${id}`, 'PATCH', opts, { status: 'paused' }), opts.json))\n\n schedule.command('resume <id>')\n .description('Resume a hosted workflow schedule.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--json', 'Print machine-readable JSON')\n .action(async (id: string, opts) => writeOutput(await apiRequest(`/workflows/schedules/${id}`, 'PATCH', opts, { status: 'active' }), opts.json))\n\n schedule.command('delete <id>')\n .description('Delete a hosted workflow schedule.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--json', 'Print machine-readable JSON')\n .action(async (id: string, opts) => writeOutput(await apiRequest(`/workflows/schedules/${id}`, 'DELETE', opts), opts.json))\n\n schedule.command('run <id>')\n .description('Run a hosted workflow schedule now.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--json', 'Print machine-readable JSON')\n .action(async (id: string, opts) => writeOutput(await apiRequest(`/workflows/schedules/${id}/run`, 'POST', opts, {}), opts.json))\n\n const runs = program.command('runs').description('Inspect and download hosted workflow runs.')\n runs.command('list')\n .description('List hosted workflow runs.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--json', 'Print machine-readable JSON')\n .action(async (opts) => {\n const result = await apiRequest<{ runs: Array<Record<string, unknown>> }>('/workflows/runs', 'GET', opts)\n if (opts.json) writeOutput(result, true)\n else writeOutput(result.runs.map(run => `${run.id}\\t${run.status}\\t${run.workflow_id}\\t${run.queued_at}`).join('\\n'), false)\n })\n\n runs.command('status <id>')\n .description('Show a hosted workflow run.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--json', 'Print machine-readable JSON')\n .action(async (id: string, opts) => writeOutput(await apiRequest(`/workflows/runs/${id}`, 'GET', opts), opts.json))\n\n runs.command('download <id>')\n .description('Download hosted workflow run artifacts.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--output-dir <path>', 'Download directory')\n .option('--json', 'Print machine-readable JSON')\n .action(async (id: string, opts) => {\n const result = await apiRequest<{ run: { id: string; artifacts?: Array<{ id: string; label: string; path: string }> } }>(`/workflows/runs/${id}`, 'GET', opts)\n const { apiUrl, apiKey } = apiOptions(opts)\n const outDir = join(opts.outputDir ?? workflowOutputBaseDir(), 'workflow-downloads', id)\n await mkdir(outDir, { recursive: true })\n const downloaded: string[] = []\n for (const artifact of result.run.artifacts ?? []) {\n const res = await fetch(`${apiUrl}/workflows/runs/${id}/artifacts/${artifact.id}`, { headers: { 'x-api-key': apiKey } })\n if (!res.ok) throw new Error(`Failed to download ${artifact.label}: HTTP ${res.status}`)\n const file = join(outDir, basename(artifact.path))\n await writeFile(file, Buffer.from(await res.arrayBuffer()))\n downloaded.push(file)\n }\n writeOutput(opts.json ? { runId: id, files: downloaded } : downloaded.join('\\n'), opts.json)\n })\n\n return program\n}\n\nexport async function runHumanCli(argv = process.argv): Promise<void> {\n await buildHumanCli().parseAsync(argv)\n}\n","export type AgentHost = 'codex' | 'claude' | 'claude-code' | 'claude-desktop'\nexport type BrowserMode = 'hosted' | 'local'\n\nexport interface AgentConfigOptions {\n apiKey?: string\n packageSpec?: string\n browserMode?: BrowserMode\n browserProfileName?: string\n browserProfileSaveChanges?: boolean\n browserExecutablePath?: string\n}\n\nfunction apiKeyValue(options: AgentConfigOptions): string {\n return options.apiKey?.trim() || 'sk_live_your_key'\n}\n\nfunction packageSpec(options: AgentConfigOptions): string {\n return options.packageSpec?.trim() || 'mcp-scraper@latest'\n}\n\nexport function combinedNpxArgs(options: AgentConfigOptions = {}): string[] {\n return ['-y', '-p', packageSpec(options), 'mcp-scraper-combined']\n}\n\nfunction envConfig(options: AgentConfigOptions): Record<string, string> {\n const env: Record<string, string> = { MCP_SCRAPER_API_KEY: apiKeyValue(options) }\n const profileName = options.browserProfileName?.trim()\n if (options.browserMode === 'local') {\n env.MCP_SCRAPER_BROWSER_MODE = 'local'\n if (profileName) env.MCP_SCRAPER_BROWSER_PROFILE = profileName\n const executablePath = options.browserExecutablePath?.trim()\n if (executablePath) env.MCP_SCRAPER_BROWSER_EXECUTABLE = executablePath\n } else {\n if (profileName) env.BROWSER_AGENT_PROFILE_NAME = profileName\n if (options.browserProfileSaveChanges === true) env.BROWSER_AGENT_PROFILE_SAVE_CHANGES = 'true'\n }\n return env\n}\n\nfunction tomlInlineTable(value: Record<string, string>): string {\n const entries = Object.entries(value).map(([key, item]) => `${key} = ${JSON.stringify(item)}`)\n return `{ ${entries.join(', ')} }`\n}\n\nexport function renderCodexConfig(options: AgentConfigOptions = {}): string {\n return [\n '[mcp_servers.mcp-scraper]',\n 'command = \"npx\"',\n `args = ${JSON.stringify(combinedNpxArgs(options))}`,\n `env = ${tomlInlineTable(envConfig(options))}`,\n ].join('\\n')\n}\n\nexport function renderClaudeCommand(options: AgentConfigOptions = {}): string {\n const env = Object.entries(envConfig(options)).map(([key, value]) => ` --env ${key}=${value}`)\n return [\n 'claude mcp add mcp-scraper --scope user',\n ...env,\n ` -- npx ${combinedNpxArgs(options).join(' ')}`,\n ].join(' \\\\\\n')\n}\n\nexport function claudeMcpRemoveArgs(): string[] {\n return ['mcp', 'remove', 'mcp-scraper', '-s', 'user']\n}\n\nexport function claudeMcpAddArgs(options: AgentConfigOptions = {}): string[] {\n const args = ['mcp', 'add', 'mcp-scraper', '--scope', 'user']\n for (const [key, value] of Object.entries(envConfig(options))) {\n args.push('--env', `${key}=${value}`)\n }\n args.push('--', 'npx', ...combinedNpxArgs(options))\n return args\n}\n\nexport function normalizeAgentHost(host: string): AgentHost {\n if (host === 'claude-code') return 'claude'\n if (host === 'claude' || host === 'codex' || host === 'claude-desktop') return host\n throw new Error('Unknown host \"' + host + '\". Use: codex, claude, claude-code, or claude-desktop')\n}\n\nexport function renderClaudeDesktopConfig(options: AgentConfigOptions = {}): string {\n return JSON.stringify({\n mcpServers: {\n 'mcp-scraper': {\n command: 'npx',\n args: combinedNpxArgs(options),\n env: envConfig(options),\n },\n },\n }, null, 2)\n}\n\nexport function renderAgentInstall(host: AgentHost, options: AgentConfigOptions = {}): string {\n const normalizedHost = normalizeAgentHost(host)\n const restart = 'Restart the MCP client so it starts a fresh npx process.'\n const applyCommand = `MCP_SCRAPER_API_KEY=${apiKeyValue(options)} npx -y -p mcp-scraper@latest mcp-scraper-cli agent install claude --apply`\n if (normalizedHost === 'codex') {\n return [\n '# Codex MCP config',\n renderCodexConfig(options),\n '',\n restart,\n ].join('\\n')\n }\n if (normalizedHost === 'claude') {\n return [\n '# Claude Code command',\n renderClaudeCommand(options),\n '',\n '# One-command Claude Code setup',\n applyCommand,\n '',\n restart,\n ].join('\\n')\n }\n return [\n '# Claude Desktop config',\n renderClaudeDesktopConfig(options),\n '',\n 'Desktop Extension: https://mcpscraper.dev/downloads/mcp-scraper.mcpb',\n restart,\n ].join('\\n')\n}\n","import { access, mkdir, readFile } from 'node:fs/promises'\nimport { homedir } from 'node:os'\nimport { join } from 'node:path'\nimport { PACKAGE_VERSION } from '../version.js'\nimport { combinedNpxArgs } from './agent-config.js'\n\nexport type DoctorStatus = 'pass' | 'warn' | 'fail' | 'skip'\n\nexport interface DoctorCheck {\n id: string\n label: string\n status: DoctorStatus\n detail: string\n fix?: string\n}\n\nexport interface DoctorOptions {\n apiKey?: string\n apiUrl?: string\n outputDir?: string\n fetchImpl?: typeof fetch\n}\n\nexport interface DoctorOutput {\n ok: boolean\n version: string\n npmLatest: string | null\n checks: DoctorCheck[]\n recommendedConfig: {\n command: 'npx'\n args: string[]\n env: Record<string, string>\n }\n}\n\nfunction status(ok: boolean, warn = false): DoctorStatus {\n if (ok) return 'pass'\n return warn ? 'warn' : 'fail'\n}\n\nfunction parseMajor(version: string): number {\n return Number(version.replace(/^v/, '').split('.')[0] ?? 0)\n}\n\nasync function readKeyFile(): Promise<string | null> {\n const path = process.env.MCP_SCRAPER_KEY_PATH?.trim() || join(homedir(), '.mcp-scraper-key')\n try {\n const value = (await readFile(path, 'utf8')).trim()\n return value || null\n } catch {\n return null\n }\n}\n\nasync function npmLatest(fetchImpl: typeof fetch): Promise<string | null> {\n try {\n const res = await fetchImpl('https://registry.npmjs.org/mcp-scraper/latest', {\n signal: AbortSignal.timeout(5_000),\n })\n if (!res.ok) return null\n const data = await res.json() as { version?: string }\n return data.version ?? null\n } catch {\n return null\n }\n}\n\nexport async function runDoctor(options: DoctorOptions = {}): Promise<DoctorOutput> {\n const fetchImpl = options.fetchImpl ?? fetch\n const apiUrl = (options.apiUrl ?? process.env.MCP_SCRAPER_API_URL ?? 'https://mcpscraper.dev').replace(/\\/$/, '')\n const outputDir = options.outputDir ?? process.env.MCP_SCRAPER_OUTPUT_DIR ?? join(homedir(), 'Downloads', 'mcp-scraper')\n const configuredKey = options.apiKey?.trim() || process.env.MCP_SCRAPER_API_KEY?.trim() || await readKeyFile()\n const latest = await npmLatest(fetchImpl)\n\n const checks: DoctorCheck[] = []\n const nodeMajor = parseMajor(process.version)\n checks.push({\n id: 'node',\n label: 'Node.js',\n status: status(nodeMajor >= 20),\n detail: process.version,\n fix: nodeMajor >= 20 ? undefined : 'Install Node.js 20 or newer.',\n })\n\n checks.push({\n id: 'package_version',\n label: 'Local package',\n status: latest && latest !== PACKAGE_VERSION ? 'warn' : 'pass',\n detail: latest ? `local ${PACKAGE_VERSION}, npm latest ${latest}` : `local ${PACKAGE_VERSION}, npm latest unavailable`,\n fix: latest && latest !== PACKAGE_VERSION ? 'Use mcp-scraper@latest and restart the MCP client.' : undefined,\n })\n\n checks.push({\n id: 'api_key',\n label: 'API key',\n status: configuredKey ? 'pass' : 'warn',\n detail: configuredKey ? 'configured' : 'not configured',\n fix: configuredKey ? undefined : 'Set MCP_SCRAPER_API_KEY or pass --api-key.',\n })\n\n try {\n await mkdir(outputDir, { recursive: true })\n await access(outputDir)\n checks.push({ id: 'output_dir', label: 'Output directory', status: 'pass', detail: outputDir })\n } catch (err) {\n checks.push({\n id: 'output_dir',\n label: 'Output directory',\n status: 'fail',\n detail: outputDir,\n fix: err instanceof Error ? err.message : 'Create a writable output directory.',\n })\n }\n\n if (configuredKey) {\n try {\n const res = await fetchImpl(`${apiUrl}/me`, {\n headers: { 'x-api-key': configuredKey },\n signal: AbortSignal.timeout(8_000),\n })\n checks.push({\n id: 'api_reachability',\n label: 'Hosted API',\n status: res.ok ? 'pass' : 'fail',\n detail: `${apiUrl}/me returned ${res.status}`,\n fix: res.ok ? undefined : 'Verify the API key and account status.',\n })\n } catch (err) {\n checks.push({\n id: 'api_reachability',\n label: 'Hosted API',\n status: 'fail',\n detail: err instanceof Error ? err.message : String(err),\n fix: 'Check network access and MCP_SCRAPER_API_URL.',\n })\n }\n } else {\n checks.push({\n id: 'api_reachability',\n label: 'Hosted API',\n status: 'skip',\n detail: 'skipped because no API key is configured',\n })\n }\n\n checks.push({\n id: 'mcp_config',\n label: 'MCP command',\n status: 'pass',\n detail: `npx ${combinedNpxArgs().join(' ')}`,\n fix: 'Restart the MCP client after package updates.',\n })\n\n return {\n ok: checks.every(check => check.status === 'pass' || check.status === 'skip'),\n version: PACKAGE_VERSION,\n npmLatest: latest,\n checks,\n recommendedConfig: {\n command: 'npx',\n args: combinedNpxArgs(),\n env: { MCP_SCRAPER_API_KEY: configuredKey ? '$MCP_SCRAPER_API_KEY' : 'sk_live_your_key' },\n },\n }\n}\n\nexport function renderDoctor(output: DoctorOutput): string {\n const icon: Record<DoctorStatus, string> = { pass: 'PASS', warn: 'WARN', fail: 'FAIL', skip: 'SKIP' }\n const lines = [\n `mcp-scraper doctor v${output.version}`,\n '',\n ...output.checks.map(check => {\n const fix = check.fix ? `\\n Fix: ${check.fix}` : ''\n return `[${icon[check.status]}] ${check.label}: ${check.detail}${fix}`\n }),\n '',\n `Recommended MCP command: npx ${output.recommendedConfig.args.join(' ')}`,\n ]\n return lines.join('\\n')\n}\n\n","export const AGENT_PROMPTS: Record<string, string> = {\n 'agent-packet': [\n '# MCP Scraper Agent Packet Prompt',\n '',\n 'Use MCP Scraper as the evidence layer. Run the agent-packet workflow for the target keyword/domain, then treat `evidence.json`, `sources.csv`, and `competitors.csv` as source of truth.',\n '',\n 'Do not invent citations. If a recommendation is not supported by the packet, mark it as an assumption. Turn the evidence into a concise SEO brief, an implementation task list, and content recommendations tied to source rows.',\n ].join('\\n'),\n 'local-competitive-audit': [\n '# MCP Scraper Local Competitive Audit Prompt',\n '',\n 'Run the local-competitive-audit workflow for the niche and markets. Use the city summary, competitor CSV, and review-insight CSV to identify market difficulty, review themes, GBP category patterns, and weak competitors.',\n '',\n 'Ground recommendations in Maps rank position, review count, star rating, categories, profile details, and review topics. Do not overstate heuristic opportunity scores.',\n ].join('\\n'),\n 'directory-workflow': [\n '# MCP Scraper Directory Workflow Prompt',\n '',\n 'Use directory_workflow when the user wants cities selected by population and Google Maps candidates per city. Keep query and location separate. Preserve result_position, source_location, review stars/count, categories, and profile URLs for downstream CSV or directory use.',\n ].join('\\n'),\n 'map-comparison': [\n '# MCP Scraper Maps Comparison Prompt',\n '',\n 'Run the map-comparison workflow when the user wants to compare local Maps competitors in a city or across selected markets. Use `maps-results.csv`, `map-comparison.csv`, and `profile-insights.csv` as source of truth.',\n '',\n 'Ground recommendations in result_position, review_stars, review_count, category, website presence, review topics, and profile attributes. Treat review gaps and missing websites as opportunity signals, not guaranteed ranking factors.',\n ].join('\\n'),\n 'serp-comparison': [\n '# MCP Scraper SERP Comparison Prompt',\n '',\n 'Run the serp-comparison workflow when the user wants to know why competitors outrank a page or what the SERP rewards. Use organic results, extracted page headings, PAA questions, and AI Overview citations before making recommendations.',\n '',\n 'Tie each recommendation to `content-gaps.csv`, `page-comparison.csv`, `paa-questions.csv`, or `ai-overview-citations.csv`. Do not invent missing sections or citations.',\n ].join('\\n'),\n 'paa-expansion-brief': [\n '# MCP Scraper PAA Expansion Brief Prompt',\n '',\n 'Run the paa-expansion-brief workflow when the user wants to figure out what to write from People Also Ask expansion. Use `section-map.csv` to structure the brief and `paa-questions.csv` for exact customer-language headings.',\n '',\n 'Answer the highest-priority questions directly, preserve source URLs when present, and separate evidence-backed sections from assumptions.',\n ].join('\\n'),\n 'ai-overview-language': [\n '# MCP Scraper AI Overview Language Prompt',\n '',\n 'Run the ai-overview-language workflow when the user wants to know how to phrase content for AI Overview inclusion. Use `claim-patterns.csv`, `language-guidance.csv`, `ai-overview-citations.csv`, and PAA follow-ups as evidence.',\n '',\n 'Recommend concise answer blocks, criteria/step language, citation hooks, and follow-up sections. Do not claim the target will be cited; frame the output as evidence-based language guidance.',\n ].join('\\n'),\n 'ai-citation-monitor': [\n '# MCP Scraper AI Citation Monitor Prompt',\n '',\n 'Use search_serp and harvest_paa to check whether the target brand/domain appears in AI Overview citations, organic results, People Also Ask sources, local pack, forums, and videos. Save evidence before summarizing trends or gaps.',\n ].join('\\n'),\n 'serp-brief': [\n '# MCP Scraper SERP Brief Prompt',\n '',\n 'Use live SERP, PAA, AI Overview, forum, video, and source evidence to create a writer brief. Tie each recommended section to evidence rows and identify missing proof, entities, comparisons, and customer questions.',\n ].join('\\n'),\n}\n\nexport function listPrompts(): string[] {\n return Object.keys(AGENT_PROMPTS).sort()\n}\n\nexport function renderPrompt(name: string): string {\n const prompt = AGENT_PROMPTS[name]\n if (!prompt) throw new Error(`Unknown prompt \"${name}\". Available: ${listPrompts().join(', ')}`)\n return prompt\n}\n","#!/usr/bin/env node\nimport { runHumanCli } from '../src/cli/human-cli.js'\n\nrunHumanCli().catch((err) => {\n console.error(err instanceof Error ? err.message : String(err))\n process.exit(1)\n})\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,SAAAA,QAAO,iBAAiB;AACjC,SAAS,UAAU,QAAAC,aAAY;;;ACS/B,SAAS,YAAY,SAAqC;AACxD,SAAO,QAAQ,QAAQ,KAAK,KAAK;AACnC;AAEA,SAAS,YAAY,SAAqC;AACxD,SAAO,QAAQ,aAAa,KAAK,KAAK;AACxC;AAEO,SAAS,gBAAgB,UAA8B,CAAC,GAAa;AAC1E,SAAO,CAAC,MAAM,MAAM,YAAY,OAAO,GAAG,sBAAsB;AAClE;AAEA,SAAS,UAAU,SAAqD;AACtE,QAAM,MAA8B,EAAE,qBAAqB,YAAY,OAAO,EAAE;AAChF,QAAM,cAAc,QAAQ,oBAAoB,KAAK;AACrD,MAAI,QAAQ,gBAAgB,SAAS;AACnC,QAAI,2BAA2B;AAC/B,QAAI,YAAa,KAAI,8BAA8B;AACnD,UAAM,iBAAiB,QAAQ,uBAAuB,KAAK;AAC3D,QAAI,eAAgB,KAAI,iCAAiC;AAAA,EAC3D,OAAO;AACL,QAAI,YAAa,KAAI,6BAA6B;AAClD,QAAI,QAAQ,8BAA8B,KAAM,KAAI,qCAAqC;AAAA,EAC3F;AACA,SAAO;AACT;AAEA,S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,QAAQ;AAC3B,UAAQ,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAC9D,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["mkdir","join","join","mkdir"]}
1
+ {"version":3,"sources":["../../src/cli/human-cli.ts","../../src/cli/agent-config.ts","../../src/cli/doctor.ts","../../src/cli/prompts.ts","../../bin/mcp-scraper-cli.ts"],"sourcesContent":["import { Command } from 'commander'\nimport { spawn } from 'node:child_process'\nimport { mkdir, writeFile } from 'node:fs/promises'\nimport { basename, join } from 'node:path'\nimport { PACKAGE_VERSION } from '../version.js'\nimport {\n claudeMcpAddArgs,\n claudeMcpRemoveArgs,\n normalizeAgentHost,\n renderAgentInstall,\n type AgentHost,\n} from './agent-config.js'\nimport { renderDoctor, runDoctor } from './doctor.js'\nimport { listPrompts, renderPrompt } from './prompts.js'\nimport { workflowOutputBaseDir } from '../workflows/artifact-writer.js'\nimport { findWorkflowReport, listWorkflowDefinitions, listWorkflowReports, openWorkflowReport, runWorkflow } from '../workflows/registry.js'\n\nfunction numberOpt(value: unknown): number | undefined {\n if (value === undefined || value === null || value === '') return undefined\n const parsed = Number(value)\n return Number.isFinite(parsed) ? parsed : undefined\n}\n\nfunction booleanOpt(value: unknown): boolean | undefined {\n if (value === undefined) return undefined\n if (typeof value === 'boolean') return value\n if (value === 'true') return true\n if (value === 'false') return false\n return undefined\n}\n\nfunction compactInput(input: Record<string, unknown>): Record<string, unknown> {\n return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== undefined))\n}\n\nfunction workflowInput(id: string, opts: Record<string, unknown>): Record<string, unknown> {\n if (id === 'agent-packet' || id === 'serp-comparison' || id === 'ai-overview-language') {\n return compactInput({\n keyword: opts.keyword,\n domain: opts.domain,\n url: opts.url,\n location: opts.location,\n maxResults: numberOpt(opts.maxResults),\n maxQuestions: numberOpt(opts.maxQuestions),\n extractTop: numberOpt(opts.extractTop),\n includeSerp: opts.serp === false ? false : undefined,\n includePaa: opts.paa === false ? false : undefined,\n includeAiOverview: booleanOpt(opts.includeAiOverview),\n returnPartial: opts.returnPartial === false ? false : undefined,\n })\n }\n\n if (id === 'paa-expansion-brief') {\n return compactInput({\n keyword: opts.keyword,\n location: opts.location,\n maxQuestions: numberOpt(opts.maxQuestions),\n depth: numberOpt(opts.depth),\n returnPartial: opts.returnPartial === false ? false : undefined,\n })\n }\n\n if (id === 'directory' || id === 'local-competitive-audit' || id === 'map-comparison') {\n return compactInput({\n query: opts.query,\n location: opts.location,\n state: opts.state,\n minPopulation: numberOpt(opts.minPop ?? opts.minPopulation),\n maxCities: numberOpt(opts.maxCities),\n maxResultsPerCity: numberOpt(opts.perCity ?? opts.maxResultsPerCity ?? opts.maxResults),\n concurrency: numberOpt(opts.concurrency),\n proxyMode: opts.proxyMode,\n hydrateTop: id === 'local-competitive-audit' || id === 'map-comparison' ? numberOpt(opts.hydrateTop) : undefined,\n maxReviews: id === 'local-competitive-audit' || id === 'map-comparison' ? numberOpt(opts.reviews ?? opts.maxReviews) : undefined,\n returnPartial: opts.returnPartial === false ? false : undefined,\n })\n }\n\n return compactInput(opts)\n}\n\nfunction writeOutput(data: unknown, json: boolean | undefined): void {\n if (json) {\n process.stdout.write(`${JSON.stringify(data, null, 2)}\\n`)\n } else if (typeof data === 'string') {\n process.stdout.write(`${data}\\n`)\n } else {\n process.stdout.write(`${JSON.stringify(data, null, 2)}\\n`)\n }\n}\n\nfunction maskSecrets(value: string): string {\n return value.replace(/sk_[A-Za-z0-9_-]+/g, 'sk_***')\n}\n\nfunction runLocalCommand(command: string, args: string[]): Promise<{ code: number; stdout: string; stderr: string }> {\n return new Promise((resolve) => {\n const child = spawn(command, args, { stdio: ['ignore', 'pipe', 'pipe'] })\n const stdout: Buffer[] = []\n const stderr: Buffer[] = []\n let settled = false\n const done = (result: { code: number; stdout: string; stderr: string }) => {\n if (settled) return\n settled = true\n resolve(result)\n }\n child.stdout.on('data', chunk => stdout.push(Buffer.from(chunk)))\n child.stderr.on('data', chunk => stderr.push(Buffer.from(chunk)))\n child.on('error', err => {\n done({ code: 127, stdout: '', stderr: err.message })\n })\n child.on('close', code => {\n done({\n code: typeof code === 'number' ? code : 1,\n stdout: Buffer.concat(stdout).toString('utf8'),\n stderr: Buffer.concat(stderr).toString('utf8'),\n })\n })\n })\n}\n\nfunction cadenceOpt(opts: Record<string, unknown>): 'daily' | 'weekly' | 'monthly' {\n if (opts.daily) return 'daily'\n if (opts.monthly) return 'monthly'\n return 'weekly'\n}\n\nfunction apiOptions(opts: Record<string, unknown>): { apiUrl: string; apiKey: string } {\n const apiKey = String(opts.apiKey ?? process.env.MCP_SCRAPER_API_KEY ?? '').trim()\n if (!apiKey) throw new Error('MCP_SCRAPER_API_KEY is required. Pass --api-key or set the environment variable.')\n return {\n apiUrl: String(opts.apiUrl ?? process.env.MCP_SCRAPER_API_URL ?? 'https://mcpscraper.dev').replace(/\\/$/, ''),\n apiKey,\n }\n}\n\nfunction openExternalUrl(url: string): boolean {\n const command = process.platform === 'darwin'\n ? 'open'\n : process.platform === 'win32'\n ? 'cmd'\n : 'xdg-open'\n const args = process.platform === 'win32' ? ['/c', 'start', '', url] : [url]\n try {\n const child = spawn(command, args, { detached: true, stdio: 'ignore' })\n child.unref()\n return true\n } catch {\n return false\n }\n}\n\nasync function apiRequest<T>(path: string, method: string, opts: Record<string, unknown>, body?: unknown): Promise<T> {\n const { apiUrl, apiKey } = apiOptions(opts)\n const res = await fetch(`${apiUrl}${path}`, {\n method,\n headers: {\n 'Content-Type': 'application/json',\n 'x-api-key': apiKey,\n },\n body: body == null ? undefined : JSON.stringify(body),\n })\n const data = await res.json().catch(() => ({}))\n if (!res.ok) {\n const message = typeof (data as { error?: unknown }).error === 'string'\n ? (data as { error: string }).error\n : `API request failed with ${res.status}`\n throw new Error(message)\n }\n return data as T\n}\n\nfunction addWorkflowInputOptions(command: Command): Command {\n return command\n .option('--keyword <keyword>', 'Agent packet keyword')\n .option('--domain <domain>', 'Target domain')\n .option('--url <url>', 'Target page URL')\n .option('--location <location>', 'Target location')\n .option('--max-results <n>', 'Maximum SERP or Maps results')\n .option('--max-questions <n>', 'Maximum PAA questions')\n .option('--extract-top <n>', 'Top result pages or citation pages to extract')\n .option('--depth <n>', 'PAA expansion depth')\n .option('--no-serp', 'Skip SERP evidence for agent packet')\n .option('--no-paa', 'Skip PAA evidence for agent packet')\n .option('--query <query>', 'Business category or workflow query')\n .option('--state <state>', 'US state')\n .option('--min-pop <n>', 'Minimum city population')\n .option('--max-cities <n>', 'Maximum selected cities')\n .option('--per-city <n>', 'Maps results per city')\n .option('--concurrency <n>', 'City search concurrency')\n .option('--proxy-mode <mode>', 'Proxy mode: location, configured, or none')\n .option('--hydrate-top <n>', 'Profiles to hydrate per city for competitive audits')\n .option('--reviews <n>', 'Review cards to collect per hydrated profile')\n .option('--no-return-partial', 'Fail instead of writing partial artifacts')\n}\n\nexport function buildHumanCli(): Command {\n const program = new Command()\n program\n .name('mcp-scraper-cli')\n .description('Human CLI for MCP Scraper setup, workflows, reports, and agent-ready SEO artifacts.')\n .version(PACKAGE_VERSION)\n\n program.command('doctor')\n .description('Check local setup, API key, output directory, package version, and recommended MCP config.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--output-dir <path>', 'Output directory to test')\n .option('--json', 'Print machine-readable JSON')\n .action(async (opts) => {\n const output = await runDoctor({ apiKey: opts.apiKey, apiUrl: opts.apiUrl, outputDir: opts.outputDir })\n writeOutput(opts.json ? output : renderDoctor(output), opts.json)\n if (!output.ok) process.exitCode = 1\n })\n\n const billing = program.command('billing').description('Inspect billing and start checkout flows.')\n const billingConcurrency = billing.command('concurrency').description('Manage MCP Scraper concurrency slots.')\n\n billingConcurrency.command('info')\n .description('Show current concurrency limit and extra-slot price.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--json', 'Print machine-readable JSON')\n .action(async (opts) => {\n const result = await apiRequest<{ concurrency: Record<string, unknown> }>('/billing/credits', 'POST', opts, {})\n if (opts.json) writeOutput(result.concurrency, true)\n else {\n const upgrade = result.concurrency?.upgrade as Record<string, unknown> | undefined\n writeOutput([\n `Current limit: ${result.concurrency?.current_limit ?? 'unknown'} concurrent operations`,\n `Extra slots: ${result.concurrency?.current_extra_slots ?? 'unknown'}`,\n `Extra concurrency slot: ${upgrade?.price_label ?? '$5/month'}`,\n `Upgrade command: ${upgrade?.terminal_command ?? 'mcp-scraper-cli billing concurrency checkout'}`,\n ].join('\\n'), false)\n }\n })\n\n billingConcurrency.command('checkout')\n .description('Create a hosted Stripe checkout for one extra concurrency slot.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--json', 'Print machine-readable JSON')\n .option('--no-open', 'Print the checkout URL without opening a browser')\n .action(async (opts) => {\n const result = await apiRequest<{ checkout_url: string; price?: { price_label?: string }; next_step?: string }>('/billing/concurrency/terminal-checkout', 'POST', opts, {})\n if (opts.json) {\n writeOutput(result, true)\n return\n }\n const opened = opts.open !== false && openExternalUrl(result.checkout_url)\n writeOutput([\n `Extra concurrency slot: ${result.price?.price_label ?? '$5/month'}`,\n opened ? `Opened checkout: ${result.checkout_url}` : `Checkout URL: ${result.checkout_url}`,\n result.next_step ?? 'Complete checkout, then retry the MCP request.',\n ].join('\\n'), false)\n })\n\n const agent = program.command('agent').description('Generate AI-agent install configs and workflow prompts.')\n agent.command('install <host>')\n .description('Print or apply install/config instructions for codex, claude/claude-code, or claude-desktop.')\n .option('--api-key <key>', 'API key to place in generated config')\n .option('--package <spec>', 'npm package spec', 'mcp-scraper@latest')\n .option('--browser-profile <name>', 'Default saved browser profile for browser_open sessions.')\n .option('--save-browser-profile-changes', 'Persist cookies/local storage back to the named browser profile when sessions close')\n .option('--apply', 'Apply the config to the local client when supported. For Claude Code, this upserts the user-scope mcp-scraper server.')\n .option('--json', 'Print machine-readable JSON')\n .action(async (hostInput: AgentHost, opts) => {\n const host = normalizeAgentHost(hostInput)\n const apiKey = opts.apiKey ?? process.env.MCP_SCRAPER_API_KEY\n if (opts.apply) {\n if (host !== 'claude') throw new Error('--apply is currently supported for Claude Code only. Use host \"claude\" or \"claude-code\".')\n if (!apiKey?.trim()) {\n throw new Error('MCP_SCRAPER_API_KEY is required for --apply. Set it in the environment or pass --api-key.')\n }\n\n const configOptions = {\n apiKey,\n packageSpec: opts.package,\n browserProfileName: opts.browserProfile,\n browserProfileSaveChanges: opts.saveBrowserProfileChanges,\n }\n const remove = await runLocalCommand('claude', claudeMcpRemoveArgs())\n const add = await runLocalCommand('claude', claudeMcpAddArgs(configOptions))\n if (add.code !== 0) {\n const reason = maskSecrets([add.stderr, add.stdout].filter(Boolean).join('\\n').trim())\n throw new Error([\n 'Claude Code MCP registration failed.',\n reason || 'No error output returned.',\n 'Make sure Claude Code is installed and the `claude` command is on PATH.',\n ].join('\\n'))\n }\n const list = await runLocalCommand('claude', ['mcp', 'list'])\n const result = {\n host: 'claude',\n applied: true,\n replacedExisting: remove.code === 0,\n command: 'npx',\n args: ['-y', '-p', opts.package, 'mcp-scraper-combined'],\n nextStep: 'Fully exit Claude Code, start a new Claude terminal, then run: claude mcp list',\n list: maskSecrets([list.stdout, list.stderr].filter(Boolean).join('\\n').trim()),\n }\n if (opts.json) {\n writeOutput(result, true)\n return\n }\n writeOutput([\n 'Applied Claude Code MCP config: mcp-scraper',\n remove.code === 0 ? 'Replaced existing mcp-scraper entry.' : 'No existing mcp-scraper entry found; added a new one.',\n 'Command: npx -y -p ' + opts.package + ' mcp-scraper-combined',\n opts.browserProfile ? `Browser profile: ${opts.browserProfile}` : '',\n '',\n 'Next step: fully exit Claude Code, start a new Claude terminal, then run:',\n ' claude mcp list',\n '',\n result.list ? `Current Claude MCP list:\\n${result.list}` : '',\n ].filter(Boolean).join('\\n'), false)\n return\n }\n const text = renderAgentInstall(host, {\n apiKey: opts.apiKey,\n packageSpec: opts.package,\n browserProfileName: opts.browserProfile,\n browserProfileSaveChanges: opts.saveBrowserProfileChanges,\n })\n writeOutput(opts.json ? { host, text } : text, opts.json)\n })\n\n agent.command('prompt [name]')\n .description('Print an agent prompt template.')\n .option('--json', 'Print machine-readable JSON')\n .action((name: string | undefined, opts) => {\n if (!name) {\n writeOutput(opts.json ? { prompts: listPrompts() } : listPrompts().join('\\n'), opts.json)\n return\n }\n const text = renderPrompt(name)\n writeOutput(opts.json ? { name, text } : text, opts.json)\n })\n\n const workflow = program.command('workflow').description('Run named SEO workflows.')\n workflow.command('list')\n .description('List available workflows.')\n .option('--json', 'Print machine-readable JSON')\n .action((opts) => {\n const rows = listWorkflowDefinitions()\n if (opts.json) writeOutput({ workflows: rows }, true)\n else writeOutput(rows.map(row => `${row.id}\\t${row.title}\\n ${row.description}`).join('\\n'), false)\n })\n\n workflow.command('run <id>')\n .description('Run a workflow and save local artifacts.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--output-dir <path>', 'Workflow output directory')\n .option('--json', 'Print machine-readable JSON')\n .option('--keyword <keyword>', 'Agent packet keyword')\n .option('--domain <domain>', 'Target domain')\n .option('--url <url>', 'Target page URL')\n .option('--location <location>', 'Target location')\n .option('--max-results <n>', 'Maximum SERP or Maps results')\n .option('--max-questions <n>', 'Maximum PAA questions')\n .option('--extract-top <n>', 'Top result pages or citation pages to extract')\n .option('--depth <n>', 'PAA expansion depth')\n .option('--no-serp', 'Skip SERP evidence for agent packet')\n .option('--no-paa', 'Skip PAA evidence for agent packet')\n .option('--query <query>', 'Business category or workflow query')\n .option('--state <state>', 'US state')\n .option('--min-pop <n>', 'Minimum city population')\n .option('--max-cities <n>', 'Maximum selected cities')\n .option('--per-city <n>', 'Maps results per city')\n .option('--concurrency <n>', 'City search concurrency')\n .option('--proxy-mode <mode>', 'Proxy mode: location, configured, or none')\n .option('--hydrate-top <n>', 'Profiles to hydrate per city for competitive audits')\n .option('--reviews <n>', 'Review cards to collect per hydrated profile')\n .option('--no-return-partial', 'Fail instead of writing partial artifacts')\n .action(async (id: string, opts) => {\n const summary = await runWorkflow(id, workflowInput(id, opts), {\n apiKey: opts.apiKey,\n apiUrl: opts.apiUrl,\n outputDir: opts.outputDir,\n })\n if (opts.json) writeOutput(summary, true)\n else {\n writeOutput([\n `${summary.title}: ${summary.status}`,\n summary.summary,\n summary.reportPath ? `Report: ${summary.reportPath}` : '',\n summary.warnings.length ? `Warnings:\\n${summary.warnings.map(w => `- ${w}`).join('\\n')}` : '',\n ].filter(Boolean).join('\\n'), false)\n }\n })\n\n const report = program.command('report').description('List and open local workflow reports.')\n report.command('list')\n .description('List recent workflow reports.')\n .option('--output-dir <path>', 'Workflow output directory')\n .option('--json', 'Print machine-readable JSON')\n .action(async (opts) => {\n const reports = await listWorkflowReports(opts.outputDir)\n writeOutput(opts.json ? { reports } : reports.map(r => `${r.startedAt}\\t${r.workflow}\\t${r.status}\\t${r.reportPath ?? r.manifestPath}`).join('\\n'), opts.json)\n })\n report.command('path [id]')\n .description('Print a report path. Defaults to last.')\n .option('--output-dir <path>', 'Workflow output directory')\n .option('--json', 'Print machine-readable JSON')\n .action(async (id = 'last', opts) => {\n const found = await findWorkflowReport(id, opts.outputDir)\n if (!found?.reportPath) throw new Error(`No report found for \"${id}\"`)\n writeOutput(opts.json ? { path: found.reportPath, run: found } : found.reportPath, opts.json)\n })\n report.command('open [id]')\n .description('Open a report. Defaults to last.')\n .option('--output-dir <path>', 'Workflow output directory')\n .option('--json', 'Print machine-readable JSON instead of opening')\n .action(async (id = 'last', opts) => {\n if (opts.json) {\n const found = await findWorkflowReport(id, opts.outputDir)\n if (!found?.reportPath) throw new Error(`No report found for \"${id}\"`)\n writeOutput({ path: found.reportPath, run: found }, true)\n return\n }\n const path = await openWorkflowReport(id, opts.outputDir)\n writeOutput(`Opened: ${path}`, false)\n })\n\n const schedule = program.command('schedule').description('Create and manage hosted workflow schedules.')\n addWorkflowInputOptions(schedule.command('create <workflowId>')\n .description('Create a recurring hosted workflow schedule.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--name <name>', 'Schedule name')\n .option('--daily', 'Run daily')\n .option('--weekly', 'Run weekly')\n .option('--monthly', 'Run monthly')\n .option('--timezone <tz>', 'Schedule timezone', 'UTC')\n .option('--webhook <url>', 'HTTPS webhook URL')\n .option('--next-run-at <iso>', 'First run time as an ISO timestamp')\n .option('--json', 'Print machine-readable JSON'))\n .action(async (workflowId: string, opts) => {\n const result = await apiRequest('/workflows/schedules', 'POST', opts, {\n workflowId,\n name: opts.name,\n input: workflowInput(workflowId, opts),\n cadence: cadenceOpt(opts),\n timezone: opts.timezone,\n webhookUrl: opts.webhook,\n nextRunAt: opts.nextRunAt,\n })\n writeOutput(result, opts.json)\n })\n\n schedule.command('list')\n .description('List hosted workflow schedules.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--json', 'Print machine-readable JSON')\n .action(async (opts) => {\n const result = await apiRequest<{ schedules: Array<Record<string, unknown>> }>('/workflows/schedules', 'GET', opts)\n if (opts.json) writeOutput(result, true)\n else writeOutput(result.schedules.map(scheduleRow => `${scheduleRow.id}\\t${scheduleRow.status}\\t${scheduleRow.workflow_id}\\t${scheduleRow.next_run_at ?? ''}`).join('\\n'), false)\n })\n\n schedule.command('pause <id>')\n .description('Pause a hosted workflow schedule.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--json', 'Print machine-readable JSON')\n .action(async (id: string, opts) => writeOutput(await apiRequest(`/workflows/schedules/${id}`, 'PATCH', opts, { status: 'paused' }), opts.json))\n\n schedule.command('resume <id>')\n .description('Resume a hosted workflow schedule.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--json', 'Print machine-readable JSON')\n .action(async (id: string, opts) => writeOutput(await apiRequest(`/workflows/schedules/${id}`, 'PATCH', opts, { status: 'active' }), opts.json))\n\n schedule.command('delete <id>')\n .description('Delete a hosted workflow schedule.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--json', 'Print machine-readable JSON')\n .action(async (id: string, opts) => writeOutput(await apiRequest(`/workflows/schedules/${id}`, 'DELETE', opts), opts.json))\n\n schedule.command('run <id>')\n .description('Run a hosted workflow schedule now.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--json', 'Print machine-readable JSON')\n .action(async (id: string, opts) => writeOutput(await apiRequest(`/workflows/schedules/${id}/run`, 'POST', opts, {}), opts.json))\n\n const runs = program.command('runs').description('Inspect and download hosted workflow runs.')\n runs.command('list')\n .description('List hosted workflow runs.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--json', 'Print machine-readable JSON')\n .action(async (opts) => {\n const result = await apiRequest<{ runs: Array<Record<string, unknown>> }>('/workflows/runs', 'GET', opts)\n if (opts.json) writeOutput(result, true)\n else writeOutput(result.runs.map(run => `${run.id}\\t${run.status}\\t${run.workflow_id}\\t${run.queued_at}`).join('\\n'), false)\n })\n\n runs.command('status <id>')\n .description('Show a hosted workflow run.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--json', 'Print machine-readable JSON')\n .action(async (id: string, opts) => writeOutput(await apiRequest(`/workflows/runs/${id}`, 'GET', opts), opts.json))\n\n runs.command('download <id>')\n .description('Download hosted workflow run artifacts.')\n .option('--api-key <key>', 'MCP Scraper API key')\n .option('--api-url <url>', 'MCP Scraper API URL', 'https://mcpscraper.dev')\n .option('--output-dir <path>', 'Download directory')\n .option('--json', 'Print machine-readable JSON')\n .action(async (id: string, opts) => {\n const result = await apiRequest<{ run: { id: string; artifacts?: Array<{ id: string; label: string; path: string }> } }>(`/workflows/runs/${id}`, 'GET', opts)\n const { apiUrl, apiKey } = apiOptions(opts)\n const outDir = join(opts.outputDir ?? workflowOutputBaseDir(), 'workflow-downloads', id)\n await mkdir(outDir, { recursive: true })\n const downloaded: string[] = []\n for (const artifact of result.run.artifacts ?? []) {\n const res = await fetch(`${apiUrl}/workflows/runs/${id}/artifacts/${artifact.id}`, { headers: { 'x-api-key': apiKey } })\n if (!res.ok) throw new Error(`Failed to download ${artifact.label}: HTTP ${res.status}`)\n const file = join(outDir, basename(artifact.path))\n await writeFile(file, Buffer.from(await res.arrayBuffer()))\n downloaded.push(file)\n }\n writeOutput(opts.json ? { runId: id, files: downloaded } : downloaded.join('\\n'), opts.json)\n })\n\n return program\n}\n\nexport async function runHumanCli(argv = process.argv): Promise<void> {\n await buildHumanCli().parseAsync(argv)\n}\n","export type AgentHost = 'codex' | 'claude' | 'claude-code' | 'claude-desktop'\n\nexport interface AgentConfigOptions {\n apiKey?: string\n packageSpec?: string\n browserProfileName?: string\n browserProfileSaveChanges?: boolean\n}\n\nfunction apiKeyValue(options: AgentConfigOptions): string {\n return options.apiKey?.trim() || 'sk_live_your_key'\n}\n\nfunction packageSpec(options: AgentConfigOptions): string {\n return options.packageSpec?.trim() || 'mcp-scraper@latest'\n}\n\nexport function combinedNpxArgs(options: AgentConfigOptions = {}): string[] {\n return ['-y', '-p', packageSpec(options), 'mcp-scraper-combined']\n}\n\nfunction envConfig(options: AgentConfigOptions): Record<string, string> {\n const env: Record<string, string> = { MCP_SCRAPER_API_KEY: apiKeyValue(options) }\n const profileName = options.browserProfileName?.trim()\n if (profileName) env.BROWSER_AGENT_PROFILE_NAME = profileName\n if (options.browserProfileSaveChanges === true) env.BROWSER_AGENT_PROFILE_SAVE_CHANGES = 'true'\n return env\n}\n\nfunction tomlInlineTable(value: Record<string, string>): string {\n const entries = Object.entries(value).map(([key, item]) => `${key} = ${JSON.stringify(item)}`)\n return `{ ${entries.join(', ')} }`\n}\n\nexport function renderCodexConfig(options: AgentConfigOptions = {}): string {\n return [\n '[mcp_servers.mcp-scraper]',\n 'command = \"npx\"',\n `args = ${JSON.stringify(combinedNpxArgs(options))}`,\n `env = ${tomlInlineTable(envConfig(options))}`,\n ].join('\\n')\n}\n\nexport function renderClaudeCommand(options: AgentConfigOptions = {}): string {\n const env = Object.entries(envConfig(options)).map(([key, value]) => ` --env ${key}=${value}`)\n return [\n 'claude mcp add mcp-scraper --scope user',\n ...env,\n ` -- npx ${combinedNpxArgs(options).join(' ')}`,\n ].join(' \\\\\\n')\n}\n\nexport function claudeMcpRemoveArgs(): string[] {\n return ['mcp', 'remove', 'mcp-scraper', '-s', 'user']\n}\n\nexport function claudeMcpAddArgs(options: AgentConfigOptions = {}): string[] {\n const args = ['mcp', 'add', 'mcp-scraper', '--scope', 'user']\n for (const [key, value] of Object.entries(envConfig(options))) {\n args.push('--env', `${key}=${value}`)\n }\n args.push('--', 'npx', ...combinedNpxArgs(options))\n return args\n}\n\nexport function normalizeAgentHost(host: string): AgentHost {\n if (host === 'claude-code') return 'claude'\n if (host === 'claude' || host === 'codex' || host === 'claude-desktop') return host\n throw new Error('Unknown host \"' + host + '\". Use: codex, claude, claude-code, or claude-desktop')\n}\n\nexport function renderClaudeDesktopConfig(options: AgentConfigOptions = {}): string {\n return JSON.stringify({\n mcpServers: {\n 'mcp-scraper': {\n command: 'npx',\n args: combinedNpxArgs(options),\n env: envConfig(options),\n },\n },\n }, null, 2)\n}\n\nexport function renderAgentInstall(host: AgentHost, options: AgentConfigOptions = {}): string {\n const normalizedHost = normalizeAgentHost(host)\n const restart = 'Restart the MCP client so it starts a fresh npx process.'\n const applyCommand = `MCP_SCRAPER_API_KEY=${apiKeyValue(options)} npx -y -p mcp-scraper@latest mcp-scraper-cli agent install claude --apply`\n if (normalizedHost === 'codex') {\n return [\n '# Codex MCP config',\n renderCodexConfig(options),\n '',\n restart,\n ].join('\\n')\n }\n if (normalizedHost === 'claude') {\n return [\n '# Claude Code command',\n renderClaudeCommand(options),\n '',\n '# One-command Claude Code setup',\n applyCommand,\n '',\n restart,\n ].join('\\n')\n }\n return [\n '# Claude Desktop config',\n renderClaudeDesktopConfig(options),\n '',\n 'Desktop Extension: https://mcpscraper.dev/downloads/mcp-scraper.mcpb',\n restart,\n ].join('\\n')\n}\n","import { access, mkdir, readFile } from 'node:fs/promises'\nimport { homedir } from 'node:os'\nimport { join } from 'node:path'\nimport { PACKAGE_VERSION } from '../version.js'\nimport { combinedNpxArgs } from './agent-config.js'\n\nexport type DoctorStatus = 'pass' | 'warn' | 'fail' | 'skip'\n\nexport interface DoctorCheck {\n id: string\n label: string\n status: DoctorStatus\n detail: string\n fix?: string\n}\n\nexport interface DoctorOptions {\n apiKey?: string\n apiUrl?: string\n outputDir?: string\n fetchImpl?: typeof fetch\n}\n\nexport interface DoctorOutput {\n ok: boolean\n version: string\n npmLatest: string | null\n checks: DoctorCheck[]\n recommendedConfig: {\n command: 'npx'\n args: string[]\n env: Record<string, string>\n }\n}\n\nfunction status(ok: boolean, warn = false): DoctorStatus {\n if (ok) return 'pass'\n return warn ? 'warn' : 'fail'\n}\n\nfunction parseMajor(version: string): number {\n return Number(version.replace(/^v/, '').split('.')[0] ?? 0)\n}\n\nasync function readKeyFile(): Promise<string | null> {\n const path = process.env.MCP_SCRAPER_KEY_PATH?.trim() || join(homedir(), '.mcp-scraper-key')\n try {\n const value = (await readFile(path, 'utf8')).trim()\n return value || null\n } catch {\n return null\n }\n}\n\nasync function npmLatest(fetchImpl: typeof fetch): Promise<string | null> {\n try {\n const res = await fetchImpl('https://registry.npmjs.org/mcp-scraper/latest', {\n signal: AbortSignal.timeout(5_000),\n })\n if (!res.ok) return null\n const data = await res.json() as { version?: string }\n return data.version ?? null\n } catch {\n return null\n }\n}\n\nexport async function runDoctor(options: DoctorOptions = {}): Promise<DoctorOutput> {\n const fetchImpl = options.fetchImpl ?? fetch\n const apiUrl = (options.apiUrl ?? process.env.MCP_SCRAPER_API_URL ?? 'https://mcpscraper.dev').replace(/\\/$/, '')\n const outputDir = options.outputDir ?? process.env.MCP_SCRAPER_OUTPUT_DIR ?? join(homedir(), 'Downloads', 'mcp-scraper')\n const configuredKey = options.apiKey?.trim() || process.env.MCP_SCRAPER_API_KEY?.trim() || await readKeyFile()\n const latest = await npmLatest(fetchImpl)\n\n const checks: DoctorCheck[] = []\n const nodeMajor = parseMajor(process.version)\n checks.push({\n id: 'node',\n label: 'Node.js',\n status: status(nodeMajor >= 20),\n detail: process.version,\n fix: nodeMajor >= 20 ? undefined : 'Install Node.js 20 or newer.',\n })\n\n checks.push({\n id: 'package_version',\n label: 'Local package',\n status: latest && latest !== PACKAGE_VERSION ? 'warn' : 'pass',\n detail: latest ? `local ${PACKAGE_VERSION}, npm latest ${latest}` : `local ${PACKAGE_VERSION}, npm latest unavailable`,\n fix: latest && latest !== PACKAGE_VERSION ? 'Use mcp-scraper@latest and restart the MCP client.' : undefined,\n })\n\n checks.push({\n id: 'api_key',\n label: 'API key',\n status: configuredKey ? 'pass' : 'warn',\n detail: configuredKey ? 'configured' : 'not configured',\n fix: configuredKey ? undefined : 'Set MCP_SCRAPER_API_KEY or pass --api-key.',\n })\n\n try {\n await mkdir(outputDir, { recursive: true })\n await access(outputDir)\n checks.push({ id: 'output_dir', label: 'Output directory', status: 'pass', detail: outputDir })\n } catch (err) {\n checks.push({\n id: 'output_dir',\n label: 'Output directory',\n status: 'fail',\n detail: outputDir,\n fix: err instanceof Error ? err.message : 'Create a writable output directory.',\n })\n }\n\n if (configuredKey) {\n try {\n const res = await fetchImpl(`${apiUrl}/me`, {\n headers: { 'x-api-key': configuredKey },\n signal: AbortSignal.timeout(8_000),\n })\n checks.push({\n id: 'api_reachability',\n label: 'Hosted API',\n status: res.ok ? 'pass' : 'fail',\n detail: `${apiUrl}/me returned ${res.status}`,\n fix: res.ok ? undefined : 'Verify the API key and account status.',\n })\n } catch (err) {\n checks.push({\n id: 'api_reachability',\n label: 'Hosted API',\n status: 'fail',\n detail: err instanceof Error ? err.message : String(err),\n fix: 'Check network access and MCP_SCRAPER_API_URL.',\n })\n }\n } else {\n checks.push({\n id: 'api_reachability',\n label: 'Hosted API',\n status: 'skip',\n detail: 'skipped because no API key is configured',\n })\n }\n\n checks.push({\n id: 'mcp_config',\n label: 'MCP command',\n status: 'pass',\n detail: `npx ${combinedNpxArgs().join(' ')}`,\n fix: 'Restart the MCP client after package updates.',\n })\n\n return {\n ok: checks.every(check => check.status === 'pass' || check.status === 'skip'),\n version: PACKAGE_VERSION,\n npmLatest: latest,\n checks,\n recommendedConfig: {\n command: 'npx',\n args: combinedNpxArgs(),\n env: { MCP_SCRAPER_API_KEY: configuredKey ? '$MCP_SCRAPER_API_KEY' : 'sk_live_your_key' },\n },\n }\n}\n\nexport function renderDoctor(output: DoctorOutput): string {\n const icon: Record<DoctorStatus, string> = { pass: 'PASS', warn: 'WARN', fail: 'FAIL', skip: 'SKIP' }\n const lines = [\n `mcp-scraper doctor v${output.version}`,\n '',\n ...output.checks.map(check => {\n const fix = check.fix ? `\\n Fix: ${check.fix}` : ''\n return `[${icon[check.status]}] ${check.label}: ${check.detail}${fix}`\n }),\n '',\n `Recommended MCP command: npx ${output.recommendedConfig.args.join(' ')}`,\n ]\n return lines.join('\\n')\n}\n\n","export const AGENT_PROMPTS: Record<string, string> = {\n 'agent-packet': [\n '# MCP Scraper Agent Packet Prompt',\n '',\n 'Use MCP Scraper as the evidence layer. Run the agent-packet workflow for the target keyword/domain, then treat `evidence.json`, `sources.csv`, and `competitors.csv` as source of truth.',\n '',\n 'Do not invent citations. If a recommendation is not supported by the packet, mark it as an assumption. Turn the evidence into a concise SEO brief, an implementation task list, and content recommendations tied to source rows.',\n ].join('\\n'),\n 'local-competitive-audit': [\n '# MCP Scraper Local Competitive Audit Prompt',\n '',\n 'Run the local-competitive-audit workflow for the niche and markets. Use the city summary, competitor CSV, and review-insight CSV to identify market difficulty, review themes, GBP category patterns, and weak competitors.',\n '',\n 'Ground recommendations in Maps rank position, review count, star rating, categories, profile details, and review topics. Do not overstate heuristic opportunity scores.',\n ].join('\\n'),\n 'directory-workflow': [\n '# MCP Scraper Directory Workflow Prompt',\n '',\n 'Use directory_workflow when the user wants cities selected by population and Google Maps candidates per city. Keep query and location separate. Preserve result_position, source_location, review stars/count, categories, and profile URLs for downstream CSV or directory use.',\n ].join('\\n'),\n 'map-comparison': [\n '# MCP Scraper Maps Comparison Prompt',\n '',\n 'Run the map-comparison workflow when the user wants to compare local Maps competitors in a city or across selected markets. Use `maps-results.csv`, `map-comparison.csv`, and `profile-insights.csv` as source of truth.',\n '',\n 'Ground recommendations in result_position, review_stars, review_count, category, website presence, review topics, and profile attributes. Treat review gaps and missing websites as opportunity signals, not guaranteed ranking factors.',\n ].join('\\n'),\n 'serp-comparison': [\n '# MCP Scraper SERP Comparison Prompt',\n '',\n 'Run the serp-comparison workflow when the user wants to know why competitors outrank a page or what the SERP rewards. Use organic results, extracted page headings, PAA questions, and AI Overview citations before making recommendations.',\n '',\n 'Tie each recommendation to `content-gaps.csv`, `page-comparison.csv`, `paa-questions.csv`, or `ai-overview-citations.csv`. Do not invent missing sections or citations.',\n ].join('\\n'),\n 'paa-expansion-brief': [\n '# MCP Scraper PAA Expansion Brief Prompt',\n '',\n 'Run the paa-expansion-brief workflow when the user wants to figure out what to write from People Also Ask expansion. Use `section-map.csv` to structure the brief and `paa-questions.csv` for exact customer-language headings.',\n '',\n 'Answer the highest-priority questions directly, preserve source URLs when present, and separate evidence-backed sections from assumptions.',\n ].join('\\n'),\n 'ai-overview-language': [\n '# MCP Scraper AI Overview Language Prompt',\n '',\n 'Run the ai-overview-language workflow when the user wants to know how to phrase content for AI Overview inclusion. Use `claim-patterns.csv`, `language-guidance.csv`, `ai-overview-citations.csv`, and PAA follow-ups as evidence.',\n '',\n 'Recommend concise answer blocks, criteria/step language, citation hooks, and follow-up sections. Do not claim the target will be cited; frame the output as evidence-based language guidance.',\n ].join('\\n'),\n 'ai-citation-monitor': [\n '# MCP Scraper AI Citation Monitor Prompt',\n '',\n 'Use search_serp and harvest_paa to check whether the target brand/domain appears in AI Overview citations, organic results, People Also Ask sources, local pack, forums, and videos. Save evidence before summarizing trends or gaps.',\n ].join('\\n'),\n 'serp-brief': [\n '# MCP Scraper SERP Brief Prompt',\n '',\n 'Use live SERP, PAA, AI Overview, forum, video, and source evidence to create a writer brief. Tie each recommended section to evidence rows and identify missing proof, entities, comparisons, and customer questions.',\n ].join('\\n'),\n}\n\nexport function listPrompts(): string[] {\n return Object.keys(AGENT_PROMPTS).sort()\n}\n\nexport function renderPrompt(name: string): string {\n const prompt = AGENT_PROMPTS[name]\n if (!prompt) throw new Error(`Unknown prompt \"${name}\". Available: ${listPrompts().join(', ')}`)\n return prompt\n}\n","#!/usr/bin/env node\nimport { runHumanCli } from '../src/cli/human-cli.js'\n\nrunHumanCli().catch((err) => {\n console.error(err instanceof Error ? err.message : String(err))\n process.exit(1)\n})\n\n"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,SAAAA,QAAO,iBAAiB;AACjC,SAAS,UAAU,QAAAC,aAAY;;;ACM/B,SAAS,YAAY,SAAqC;AACxD,SAAO,QAAQ,QAAQ,KAAK,KAAK;AACnC;AAEA,SAAS,YAAY,SAAqC;AACxD,SAAO,QAAQ,aAAa,KAAK,KAAK;AACxC;AAEO,SAAS,gBAAgB,UAA8B,CAAC,GAAa;AAC1E,SAAO,CAAC,MAAM,MAAM,YAAY,OAAO,GAAG,sBAAsB;AAClE;AAEA,SAAS,UAAU,SAAqD;AACtE,QAAM,MAA8B,EAAE,qBAAqB,YAAY,OAAO,EAAE;AAChF,QAAM,cAAc,QAAQ,oBAAoB,KAAK;AACrD,MAAI,YAAa,K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