firecrawl-cli 1.9.3 → 1.9.5

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 (62) hide show
  1. package/README.md +129 -0
  2. package/dist/commands/browser.d.ts.map +1 -1
  3. package/dist/commands/browser.js +3 -2
  4. package/dist/commands/browser.js.map +1 -1
  5. package/dist/commands/experimental/backends.d.ts +19 -0
  6. package/dist/commands/experimental/backends.d.ts.map +1 -0
  7. package/dist/commands/experimental/backends.js +74 -0
  8. package/dist/commands/experimental/backends.js.map +1 -0
  9. package/dist/commands/experimental/index.d.ts +13 -0
  10. package/dist/commands/experimental/index.d.ts.map +1 -0
  11. package/dist/commands/experimental/index.js +227 -0
  12. package/dist/commands/experimental/index.js.map +1 -0
  13. package/dist/commands/experimental/shared.d.ts +17 -0
  14. package/dist/commands/experimental/shared.d.ts.map +1 -0
  15. package/dist/commands/experimental/shared.js +154 -0
  16. package/dist/commands/experimental/shared.js.map +1 -0
  17. package/dist/commands/experimental/workflows/competitor-analysis.d.ts +10 -0
  18. package/dist/commands/experimental/workflows/competitor-analysis.d.ts.map +1 -0
  19. package/dist/commands/experimental/workflows/competitor-analysis.js +196 -0
  20. package/dist/commands/experimental/workflows/competitor-analysis.js.map +1 -0
  21. package/dist/commands/experimental/workflows/deep-research.d.ts +11 -0
  22. package/dist/commands/experimental/workflows/deep-research.d.ts.map +1 -0
  23. package/dist/commands/experimental/workflows/deep-research.js +159 -0
  24. package/dist/commands/experimental/workflows/deep-research.js.map +1 -0
  25. package/dist/commands/experimental/workflows/demo.d.ts +11 -0
  26. package/dist/commands/experimental/workflows/demo.d.ts.map +1 -0
  27. package/dist/commands/experimental/workflows/demo.js +190 -0
  28. package/dist/commands/experimental/workflows/demo.js.map +1 -0
  29. package/dist/commands/experimental/workflows/knowledge-base.d.ts +11 -0
  30. package/dist/commands/experimental/workflows/knowledge-base.d.ts.map +1 -0
  31. package/dist/commands/experimental/workflows/knowledge-base.js +319 -0
  32. package/dist/commands/experimental/workflows/knowledge-base.js.map +1 -0
  33. package/dist/commands/experimental/workflows/lead-research.d.ts +11 -0
  34. package/dist/commands/experimental/workflows/lead-research.d.ts.map +1 -0
  35. package/dist/commands/experimental/workflows/lead-research.js +146 -0
  36. package/dist/commands/experimental/workflows/lead-research.js.map +1 -0
  37. package/dist/commands/experimental/workflows/qa.d.ts +11 -0
  38. package/dist/commands/experimental/workflows/qa.d.ts.map +1 -0
  39. package/dist/commands/experimental/workflows/qa.js +184 -0
  40. package/dist/commands/experimental/workflows/qa.js.map +1 -0
  41. package/dist/commands/experimental/workflows/research-papers.d.ts +11 -0
  42. package/dist/commands/experimental/workflows/research-papers.d.ts.map +1 -0
  43. package/dist/commands/experimental/workflows/research-papers.js +151 -0
  44. package/dist/commands/experimental/workflows/research-papers.js.map +1 -0
  45. package/dist/commands/experimental/workflows/seo-audit.d.ts +11 -0
  46. package/dist/commands/experimental/workflows/seo-audit.d.ts.map +1 -0
  47. package/dist/commands/experimental/workflows/seo-audit.js +155 -0
  48. package/dist/commands/experimental/workflows/seo-audit.js.map +1 -0
  49. package/dist/commands/experimental/workflows/shop.d.ts +11 -0
  50. package/dist/commands/experimental/workflows/shop.d.ts.map +1 -0
  51. package/dist/commands/experimental/workflows/shop.js +158 -0
  52. package/dist/commands/experimental/workflows/shop.js.map +1 -0
  53. package/dist/commands/init.d.ts +11 -1
  54. package/dist/commands/init.d.ts.map +1 -1
  55. package/dist/commands/init.js +474 -36
  56. package/dist/commands/init.js.map +1 -1
  57. package/dist/commands/login.d.ts.map +1 -1
  58. package/dist/commands/login.js +18 -0
  59. package/dist/commands/login.js.map +1 -1
  60. package/dist/index.js +17 -4
  61. package/dist/index.js.map +1 -1
  62. package/package.json +6 -3
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ /**
3
+ * Workflow: Demo Walkthrough
4
+ *
5
+ * Uses Firecrawl's cloud browser to walk through a product's key flows --
6
+ * signup, onboarding, pricing, docs -- step by step. Captures every screen,
7
+ * documents interactions, and produces a structured walkthrough report.
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.register = register;
44
+ const backends_1 = require("../backends");
45
+ const shared_1 = require("../shared");
46
+ // ─── Input gathering ────────────────────────────────────────────────────────
47
+ async function gatherInputs(prefill) {
48
+ const { input, select } = await Promise.resolve().then(() => __importStar(require('@inquirer/prompts')));
49
+ const rawUrl = prefill?.url ||
50
+ (await input({
51
+ message: 'What product do you want to walk through?',
52
+ validate: shared_1.validateUrl,
53
+ }));
54
+ const focus = await select({
55
+ message: 'What flows should the agent explore?',
56
+ choices: [
57
+ { name: 'Full product walkthrough (all key flows)', value: 'full' },
58
+ { name: 'Signup and onboarding flow', value: 'signup' },
59
+ { name: 'Pricing and plans', value: 'pricing' },
60
+ { name: 'Documentation and developer experience', value: 'docs' },
61
+ { name: 'Dashboard and core product', value: 'dashboard' },
62
+ ],
63
+ });
64
+ const context = await input({
65
+ message: 'Anything specific to look for? (leave blank to skip)',
66
+ default: '',
67
+ });
68
+ const output = await select({
69
+ message: 'How should the walkthrough be delivered?',
70
+ choices: [
71
+ { name: 'Print to terminal', value: 'terminal' },
72
+ { name: 'Save as Markdown file', value: 'markdown' },
73
+ ],
74
+ });
75
+ return { url: (0, shared_1.normalizeUrl)(rawUrl), focus, context, output };
76
+ }
77
+ // ─── System prompt ──────────────────────────────────────────────────────────
78
+ function buildSystemPrompt(opts) {
79
+ const outputInstructions = opts.output === 'markdown'
80
+ ? 'Save the walkthrough to a file called `demo-walkthrough.md` in the current directory. Tell the user the file path when done.'
81
+ : 'Print the full walkthrough to the terminal in well-formatted markdown.';
82
+ const focusInstructions = {
83
+ full: `Spawn these parallel agents, each walking a different flow:
84
+ 1. **Homepage & Marketing Agent** -- Open the homepage. Click through marketing pages (features, about, use cases). Document the messaging, value prop, key claims, and CTAs. Note what's above the fold vs below.
85
+ 2. **Signup & Onboarding Agent** -- Find the signup/get-started flow. Walk through every step of signup and onboarding. Document each screen, what's required, friction points, and the first-run experience. Do NOT submit real credentials -- just document the flow.
86
+ 3. **Pricing & Plans Agent** -- Navigate to pricing. Click to expand tiers, toggle monthly/annual, check feature comparisons. Document every plan, price, and feature. Look for hidden costs or confusing language.
87
+ 4. **Docs & Developer Experience Agent** -- Navigate to docs. Walk through the quickstart guide. Check navigation, code examples, search functionality. Document the developer onboarding experience.`,
88
+ signup: `Spawn these parallel agents to thoroughly explore the signup and onboarding experience:
89
+ 1. **Signup Discovery Agent** -- Find every signup entry point (header CTA, pricing page, landing pages). Document how many clicks to get to signup from different starting points.
90
+ 2. **Signup Flow Agent** -- Walk through the signup form step by step. Document every field, validation message, and screen transition. Note required vs optional fields. Do NOT submit real credentials.
91
+ 3. **Onboarding Agent** -- After signup screens, document the onboarding flow: welcome screens, setup wizards, tutorials, first-run experience. Walk through every step.
92
+ 4. **Social Proof Agent** -- Look for trust signals during signup: testimonials, logos, security badges, terms. Document what reassurance the user gets during the flow.`,
93
+ pricing: `Spawn these parallel agents to deeply analyze the pricing experience:
94
+ 1. **Pricing Page Agent** -- Navigate to the pricing page. Snapshot the full layout. Toggle between monthly/annual. Click to expand feature lists. Document every plan name, price, and feature.
95
+ 2. **Feature Comparison Agent** -- Find the feature comparison table or matrix. Click through each tier's detail page. Document what's included and excluded at each level.
96
+ 3. **Pricing Discovery Agent** -- Check multiple entry points to pricing (nav, footer, CTAs). Look for different pricing shown to different segments. Check if pricing changes based on region or plan selection.
97
+ 4. **Competitor Pricing Agent** -- Search for and scrape competitor pricing pages. Build a side-by-side comparison of pricing tiers and features.`,
98
+ docs: `Spawn these parallel agents to walk through the documentation experience:
99
+ 1. **Quickstart Agent** -- Find and follow the quickstart guide from start to finish. Try every step. Document the experience: was it clear? Were code examples correct? How long would it take a new developer?
100
+ 2. **Navigation Agent** -- Explore the doc structure. Click through the sidebar, use search, check breadcrumbs. Document the information architecture and how easy it is to find things.
101
+ 3. **Code Examples Agent** -- Find code examples across the docs. Check multiple languages/SDKs. Document which are available, their quality, and whether they look copy-pasteable.
102
+ 4. **API Reference Agent** -- Find the API reference. Walk through endpoints, check request/response examples, look for interactive "try it" features. Document completeness and usability.`,
103
+ dashboard: `Spawn these parallel agents to explore the core product experience:
104
+ 1. **Entry Point Agent** -- Find the login/dashboard entry. Document what the user sees on first login. Walk through the main navigation. Map out the product sections.
105
+ 2. **Core Flow Agent** -- Identify the primary user action (create something, configure something). Walk through it step by step. Document each screen and interaction.
106
+ 3. **Settings & Config Agent** -- Explore settings, integrations, API keys, team management. Document what's configurable and how.
107
+ 4. **Help & Support Agent** -- Find help resources within the product: tooltips, help center links, chat widgets, documentation links. Document what support is available in-context.`,
108
+ };
109
+ return `You are a product demo team lead powered by Firecrawl. You walk through a product's key flows using cloud browser automation, documenting every screen and interaction.
110
+
111
+ ${shared_1.QA_TOOLS_BLOCK}
112
+
113
+ ## Your Strategy
114
+
115
+ You are a **team lead**. Your job is to:
116
+
117
+ 1. **Open the site first** -- Run \`firecrawl browser "open <url>"\` yourself to get the initial page state and understand the site structure.
118
+ 2. **Spawn parallel subagents** -- Each agent walks through a different flow using \`firecrawl browser\`. They click, scroll, type, and snapshot their way through the product.
119
+ 3. **Collect results** -- Each agent reports back a step-by-step walkthrough of their flow.
120
+ 4. **Synthesize** -- Merge all walkthroughs into one structured report.
121
+
122
+ ## Agent Assignments
123
+
124
+ ${focusInstructions[opts.focus]}
125
+
126
+ ${shared_1.SUBAGENT_INSTRUCTIONS}
127
+
128
+ - Tell each agent to use \`firecrawl browser\` commands to navigate interactively
129
+ - Each agent should describe every screen they see: layout, content, CTAs, forms
130
+ - Agents should \`firecrawl browser "snapshot"\` at each step to see interactive elements
131
+ - Agents should note the user experience: what's clear, what's confusing, what's missing
132
+
133
+ ## Output Format
134
+
135
+ ${outputInstructions}
136
+
137
+ Structure the walkthrough as:
138
+
139
+ ### Product Overview
140
+ One paragraph summary of what the product does based on exploring it.
141
+
142
+ ### Flow Walkthroughs
143
+
144
+ For each flow explored:
145
+
146
+ #### [Flow Name]
147
+ Step-by-step walkthrough:
148
+ 1. **[Screen/Page Name]** -- What's on screen, key elements, what the user would do next
149
+ 2. **[Next Screen]** -- What changed, new elements, user actions available
150
+ ...
151
+
152
+ Key observations:
153
+ - What works well
154
+ - What's confusing or could be improved
155
+ - Notable UX patterns
156
+
157
+ ### Key Findings
158
+ - First impression and overall UX quality
159
+ - Standout features or patterns
160
+ - Friction points or usability issues
161
+ - How the product compares to typical products in the space
162
+
163
+ ### Recommendations
164
+ What could be improved, from a user experience perspective.
165
+
166
+ ### Pages Visited
167
+ Full list of every URL the agents navigated to.
168
+
169
+ ---
170
+
171
+ Be specific and descriptive. Don't just say "the pricing page looks good" -- describe what's on it, how it's organized, and what makes it effective or not.
172
+
173
+ Start by opening the site, then immediately fan out your agents to walk through different flows in parallel.`;
174
+ }
175
+ // ─── Command registration ───────────────────────────────────────────────────
176
+ function register(parentCmd, backend) {
177
+ const config = backends_1.BACKENDS[backend];
178
+ parentCmd
179
+ .command('demo')
180
+ .description("Walk through a product's key flows using cloud browser")
181
+ .argument('[url]', 'Product URL to explore')
182
+ .option('-y, --yes', 'Auto-approve all tool permissions')
183
+ .action(async (url, options) => {
184
+ const inputs = await gatherInputs(url ? { url } : undefined);
185
+ const skipPermissions = options.yes || (await (0, shared_1.askPermissionMode)(backend));
186
+ console.log(`\nLaunching ${config.displayName}...\n`);
187
+ (0, backends_1.launchAgent)(backend, buildSystemPrompt({ focus: inputs.focus, output: inputs.output }), (0, shared_1.buildMessage)([`Walk through ${inputs.url}`, inputs.context]), skipPermissions);
188
+ });
189
+ }
190
+ //# sourceMappingURL=demo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"demo.js","sourceRoot":"","sources":["../../../../src/commands/experimental/workflows/demo.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0KH,4BAqBC;AA5LD,0CAAkE;AAClE,sCAOmB;AAWnB,+EAA+E;AAE/E,KAAK,UAAU,YAAY,CAAC,OAA0B;IACpD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,wDAAa,mBAAmB,GAAC,CAAC;IAE5D,MAAM,MAAM,GACV,OAAO,EAAE,GAAG;QACZ,CAAC,MAAM,KAAK,CAAC;YACX,OAAO,EAAE,2CAA2C;YACpD,QAAQ,EAAE,oBAAW;SACtB,CAAC,CAAC,CAAC;IAEN,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC;QACzB,OAAO,EAAE,sCAAsC;QAC/C,OAAO,EAAE;YACP,EAAE,IAAI,EAAE,0CAA0C,EAAE,KAAK,EAAE,MAAM,EAAE;YACnE,EAAE,IA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;;;;;;;;;;;;;;;;;;;;;;6GAsCyF,CAAC;AAC9G,CAAC;AAED,+EAA+E;AAE/E,SAAgB,QAAQ,CAAC,SAAkB,EAAE,OAAgB;IAC3D,MAAM,MAAM,GAAG,mBAAQ,CAAC,OAAO,CAAC,CAAC;IAEjC,SAAS;SACN,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,wDAAwD,CAAC;SACrE,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;SAC3C,MAAM,CAAC,WAAW,EAAE,mCAAmC,CAAC;SACxD,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE;QAC7B,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAE7D,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,IAAA,0BAAiB,EAAC,OAAO,CAAC,CAAC,CAAC;QAC1E,OAAO,CAAC,GAAG,CAAC,eAAe,MAAM,CAAC,WAAW,OAAO,CAAC,CAAC;QAEtD,IAAA,sBAAW,EACT,OAAO,EACP,iBAAiB,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,EACjE,IAAA,qBAAY,EAAC,CAAC,gBAAgB,MAAM,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,EAC5D,eAAe,CAChB,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Workflow: Knowledge Base
3
+ *
4
+ * A single command that adapts based on the user's goal: local reference docs,
5
+ * RAG-ready chunks, fine-tuning datasets, or full doc site mirrors. All output
6
+ * follows the `.firecrawl/<hostname>/<path>/index.md` convention.
7
+ */
8
+ import { Command } from 'commander';
9
+ import { type Backend } from '../backends';
10
+ export declare function register(parentCmd: Command, backend: Backend): void;
11
+ //# sourceMappingURL=knowledge-base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"knowledge-base.d.ts","sourceRoot":"","sources":["../../../../src/commands/experimental/workflows/knowledge-base.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,OAAO,EAAyB,MAAM,aAAa,CAAC;AAwTlE,wBAAgB,QAAQ,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAgCnE"}
@@ -0,0 +1,319 @@
1
+ "use strict";
2
+ /**
3
+ * Workflow: Knowledge Base
4
+ *
5
+ * A single command that adapts based on the user's goal: local reference docs,
6
+ * RAG-ready chunks, fine-tuning datasets, or full doc site mirrors. All output
7
+ * follows the `.firecrawl/<hostname>/<path>/index.md` convention.
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.register = register;
44
+ const backends_1 = require("../backends");
45
+ const shared_1 = require("../shared");
46
+ // ─── Input gathering ────────────────────────────────────────────────────────
47
+ async function gatherInputs(prefill) {
48
+ const { input, select } = await Promise.resolve().then(() => __importStar(require('@inquirer/prompts')));
49
+ const rawSource = prefill?.source ||
50
+ (await input({
51
+ message: 'What do you want to build a knowledge base from? (URL or topic)',
52
+ validate: (0, shared_1.validateRequired)('URL or topic'),
53
+ }));
54
+ const goal = await select({
55
+ message: 'What are you building this for?',
56
+ choices: [
57
+ {
58
+ name: 'Local reference (organized markdown files)',
59
+ value: 'reference',
60
+ },
61
+ {
62
+ name: 'RAG / embedding pipeline (chunked, with metadata)',
63
+ value: 'rag',
64
+ },
65
+ { name: 'Fine-tuning dataset (JSONL training data)', value: 'train' },
66
+ { name: 'Documentation scrape (mirror a doc site)', value: 'docs' },
67
+ ],
68
+ });
69
+ let trainFormat = '';
70
+ let trainExamples = '';
71
+ if (goal === 'train') {
72
+ trainFormat = (await select({
73
+ message: 'Training data format?',
74
+ choices: [
75
+ { name: 'OpenAI JSONL (messages array)', value: 'openai' },
76
+ { name: 'Alpaca (instruction/input/output)', value: 'alpaca' },
77
+ { name: 'ShareGPT (conversations)', value: 'sharegpt' },
78
+ ],
79
+ }));
80
+ trainExamples = await input({
81
+ message: 'Roughly how many training examples?',
82
+ default: '100',
83
+ });
84
+ }
85
+ const depth = await select({
86
+ message: 'How thorough?',
87
+ choices: [
88
+ { name: 'Quick (5-10 sources)', value: 'quick' },
89
+ { name: 'Thorough (15-25 sources)', value: 'thorough' },
90
+ { name: 'Exhaustive (25+ sources)', value: 'exhaustive' },
91
+ ],
92
+ });
93
+ const context = await input({
94
+ message: 'Any specific focus or instructions? (leave blank to skip)',
95
+ default: '',
96
+ });
97
+ const outputDir = await input({
98
+ message: 'Output directory?',
99
+ default: '.firecrawl/',
100
+ });
101
+ return {
102
+ source: (0, shared_1.normalizeSource)(rawSource),
103
+ goal,
104
+ depth,
105
+ context,
106
+ outputDir,
107
+ trainFormat,
108
+ trainExamples,
109
+ };
110
+ }
111
+ // ─── System prompt ──────────────────────────────────────────────────────────
112
+ const FILE_CONVENTION = `## File Organization
113
+
114
+ **IMPORTANT:** Follow the same structure as \`firecrawl download\`. Save all files under \`.firecrawl/\` using nested directories that mirror each URL's hostname and path:
115
+
116
+ \`\`\`
117
+ .firecrawl/
118
+ <hostname>/
119
+ <path>/
120
+ index.md # Page content as clean markdown
121
+ \`\`\`
122
+
123
+ For example, \`https://docs.stripe.com/api/charges\` becomes:
124
+ \`\`\`
125
+ .firecrawl/docs.stripe.com/api/charges/index.md
126
+ \`\`\`
127
+
128
+ Strip \`www.\` from hostnames. Each page gets its own directory with an \`index.md\` inside it.`;
129
+ function buildGoalInstructions(opts) {
130
+ switch (opts.goal) {
131
+ case 'reference':
132
+ return `${FILE_CONVENTION}
133
+
134
+ Also create these at the root of \`${opts.outputDir}\`:
135
+ - \`index.md\` -- Table of contents with links to all scraped pages
136
+ - \`sources.json\` -- All URLs scraped with metadata (title, type, url)
137
+
138
+ Each markdown file should have frontmatter:
139
+ \`\`\`yaml
140
+ ---
141
+ title: "Page Title"
142
+ url: "https://..."
143
+ source: "Source Name"
144
+ type: "docs | article | tutorial | reference | discussion"
145
+ ---
146
+ \`\`\`
147
+
148
+ Focus on clean, readable markdown. Preserve code examples and formatting.`;
149
+ case 'rag':
150
+ return `${FILE_CONVENTION}
151
+
152
+ After scraping, chunk each page into embedding-ready pieces (500-1500 tokens). Save chunks alongside the source:
153
+ \`\`\`
154
+ .firecrawl/<hostname>/<path>/
155
+ index.md # Full page content
156
+ chunks/
157
+ 001.md # Chunk 1
158
+ 002.md # Chunk 2
159
+ \`\`\`
160
+
161
+ Each chunk file should have frontmatter:
162
+ \`\`\`yaml
163
+ ---
164
+ title: "Page Title"
165
+ url: "https://..."
166
+ chunk: 1
167
+ total_chunks: 5
168
+ section: "Section Name"
169
+ ---
170
+ \`\`\`
171
+
172
+ Also create \`${opts.outputDir}/manifest.json\` listing every chunk with its metadata for easy ingestion into a vector store.`;
173
+ case 'train':
174
+ return `${FILE_CONVENTION}
175
+
176
+ Scrape source pages into the \`.firecrawl/\` directory structure first, then generate training data from the scraped content.
177
+
178
+ ## Training Data Format
179
+
180
+ ${opts.trainFormat === 'openai'
181
+ ? `OpenAI fine-tuning JSONL. Each line:
182
+ \`\`\`json
183
+ {"messages": [{"role": "system", "content": "..."}, {"role": "user", "content": "..."}, {"role": "assistant", "content": "..."}]}
184
+ \`\`\``
185
+ : opts.trainFormat === 'alpaca'
186
+ ? `Alpaca format JSONL. Each line:
187
+ \`\`\`json
188
+ {"instruction": "...", "input": "...", "output": "..."}
189
+ \`\`\``
190
+ : `ShareGPT conversation JSONL. Each line:
191
+ \`\`\`json
192
+ {"conversations": [{"from": "human", "value": "..."}, {"from": "gpt", "value": "..."}]}
193
+ \`\`\``}
194
+
195
+ Target ~${opts.trainExamples} examples.
196
+
197
+ Save the dataset to \`training-data.jsonl\` in the current directory.
198
+
199
+ Also save \`training-metadata.json\` with:
200
+ - Total examples generated
201
+ - Sources used (URLs)
202
+ - Topic coverage breakdown
203
+ - Format used
204
+
205
+ ### Quality Guidelines
206
+
207
+ - Each example should be self-contained and accurate
208
+ - Vary the instruction style (questions, commands, scenarios)
209
+ - Include code examples where relevant
210
+ - Remove boilerplate, navigation, and ads from scraped content
211
+ - Cite the source URL in a metadata field for traceability
212
+ - Deduplicate similar examples`;
213
+ case 'docs':
214
+ return `${FILE_CONVENTION}
215
+
216
+ Also create \`${opts.outputDir}/index.md\` as a table of contents linking to all scraped pages, organized by section.
217
+
218
+ Each markdown file should have frontmatter:
219
+ \`\`\`yaml
220
+ ---
221
+ title: "Page Title"
222
+ url: "https://..."
223
+ section: "Section Name"
224
+ ---
225
+ \`\`\`
226
+
227
+ Be thorough. Scrape every page, preserve all code examples. This content will be used as LLM context, so accuracy matters.`;
228
+ default:
229
+ return FILE_CONVENTION;
230
+ }
231
+ }
232
+ function buildAgentStrategy(goal) {
233
+ switch (goal) {
234
+ case 'docs':
235
+ return `## Agent Assignments
236
+
237
+ Spawn agents based on the doc structure:
238
+ 1. **Section Agent** (one per major section) -- Scrape all pages in the section. Save each page as clean markdown. Preserve code examples and formatting.
239
+
240
+ Start by mapping the site with \`firecrawl map\` to discover all pages, then divide by section.`;
241
+ case 'train':
242
+ return `## Agent Assignments
243
+
244
+ Spawn agents by source type:
245
+ 1. **Documentation Agent** -- Scrape official docs. Generate instruction/response pairs from doc sections (e.g., "How do I X?" with the answer from docs).
246
+ 2. **Tutorial Agent** -- Scrape tutorials and how-to articles. Generate step-by-step instruction pairs.
247
+ 3. **Q&A Agent** -- Scrape Stack Overflow, GitHub discussions, forums. Extract real question/answer pairs.
248
+ 4. **Reference Agent** -- Scrape reference material. Generate factual Q&A pairs.`;
249
+ default:
250
+ return `## Agent Assignments
251
+
252
+ Spawn agents by source type:
253
+ 1. **Official Docs Agent** -- Find and scrape official documentation, reference material, specs.
254
+ 2. **Articles & Tutorials Agent** -- Find and scrape the best articles, blog posts, tutorials.
255
+ 3. **Community & Discussions Agent** -- Find and scrape relevant forum posts, Stack Overflow answers, GitHub discussions.
256
+ 4. **Reference Agent** -- Wikipedia, glossaries, standards documents, whitepapers.
257
+
258
+ Adjust agents based on what sources exist for the topic.`;
259
+ }
260
+ }
261
+ function buildSystemPrompt(opts) {
262
+ const depthInstructions = {
263
+ quick: 'Find and scrape 5-10 of the best sources.',
264
+ thorough: 'Find and scrape 15-25 sources covering different perspectives.',
265
+ exhaustive: 'Find and scrape 25+ sources including primary docs, articles, tutorials, and reference material.',
266
+ };
267
+ return `You are a knowledge base team lead powered by Firecrawl. You scrape web content and organize it into structured, LLM-ready formats.
268
+
269
+ ${shared_1.FIRECRAWL_TOOLS_BLOCK}
270
+
271
+ ## Depth
272
+
273
+ ${depthInstructions[opts.depth]}
274
+
275
+ ## Your Strategy
276
+
277
+ You are a **team lead**. Your job is to:
278
+
279
+ 1. **Find the best sources** -- ${opts.goal === 'docs' ? 'Map the documentation site to discover all pages.' : 'Search broadly to identify the most valuable sources on the topic.'}
280
+ 2. **Spawn parallel subagents** -- Divide the work across agents. Each scrapes their assigned sources.
281
+ 3. **Collect and organize** -- Build the final output structure from all agent results.
282
+
283
+ ${buildAgentStrategy(opts.goal)}
284
+
285
+ ${shared_1.SUBAGENT_INSTRUCTIONS}
286
+
287
+ ${buildGoalInstructions(opts)}
288
+
289
+ ---
290
+
291
+ Tell the user the output path when done.
292
+
293
+ Start immediately.`;
294
+ }
295
+ // ─── Command registration ───────────────────────────────────────────────────
296
+ function register(parentCmd, backend) {
297
+ const config = backends_1.BACKENDS[backend];
298
+ parentCmd
299
+ .command('knowledge-base')
300
+ .description('Build a knowledge base from web content (docs, RAG, fine-tuning)')
301
+ .argument('[source]', 'URL or topic to build from')
302
+ .option('-y, --yes', 'Auto-approve all tool permissions')
303
+ .action(async (source, options) => {
304
+ const inputs = await gatherInputs(source ? { source } : undefined);
305
+ const skipPermissions = options.yes || (await (0, shared_1.askPermissionMode)(backend));
306
+ console.log(`\nLaunching ${config.displayName}...\n`);
307
+ (0, backends_1.launchAgent)(backend, buildSystemPrompt({
308
+ goal: inputs.goal,
309
+ depth: inputs.depth,
310
+ outputDir: inputs.outputDir,
311
+ trainFormat: inputs.trainFormat,
312
+ trainExamples: inputs.trainExamples,
313
+ }), (0, shared_1.buildMessage)([
314
+ `Build a knowledge base from: ${inputs.source}`,
315
+ inputs.context,
316
+ ]), skipPermissions);
317
+ });
318
+ }
319
+ //# sourceMappingURL=knowledge-base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"knowledge-base.js","sourceRoot":"","sources":["../../../../src/commands/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EAAE,4BAA4B,CAAC;SAClD,MAAM,CAAC,WAAW,EAAE,mCAAmC,CAAC;SACxD,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;QAChC,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAEnE,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,IAAA,0BAAiB,EAAC,OAAO,CAAC,CAAC,CAAC;QAC1E,OAAO,CAAC,GAAG,CAAC,eAAe,MAAM,CAAC,WAAW,OAAO,CAAC,CAAC;QAEtD,IAAA,sBAAW,EACT,OAAO,EACP,iBAAiB,CAAC;YAChB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,aAAa,EAAE,MAAM,CAAC,aAAa;SACpC,CAAC,EACF,IAAA,qBAAY,EAAC;YACX,gCAAgC,MAAM,CAAC,MAAM,EAAE;YAC/C,MAAM,CAAC,OAAO;SACf,CAAC,EACF,eAAe,CAChB,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Workflow: Lead Research
3
+ *
4
+ * Spawns parallel agents to research a company, recent news/activity, and
5
+ * optionally a specific person -- all at once. Results are synthesized into
6
+ * a brief with talking points and pain points.
7
+ */
8
+ import { Command } from 'commander';
9
+ import { type Backend } from '../backends';
10
+ export declare function register(parentCmd: Command, backend: Backend): void;
11
+ //# sourceMappingURL=lead-research.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lead-research.d.ts","sourceRoot":"","sources":["../../../../src/commands/experimental/workflows/lead-research.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,OAAO,EAAyB,MAAM,aAAa,CAAC;AAkHlE,wBAAgB,QAAQ,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAyBnE"}