radar-cli 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +83 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -230,7 +230,21 @@ var knowledgeFrontmatterSchema = z.object({
230
230
  // src/commands/submit.ts
231
231
  function registerSubmit(program2) {
232
232
  program2.command("submit").description(
233
- "Submit a knowledge file to Radar. The file must be markdown with valid YAML frontmatter. Auto-approved, versioned, and attributed."
233
+ `Submit a knowledge file to Radar. The file must be markdown with valid YAML frontmatter. Auto-approved, versioned, and attributed.
234
+
235
+ Paths have NO file extensions (e.g. README not README.md, flows/login not flows/login.md).
236
+ File types: readme, sitemap, flow, script, selectors, api, guide.
237
+
238
+ Gotchas to document (type: guide, path: gotchas):
239
+ - CAPTCHAs or bot detection mechanisms
240
+ - Dynamic content that requires waiting (JS-rendered, lazy-loaded)
241
+ - Auth walls (what's behind login vs publicly accessible)
242
+ - Cookie consent popups or modals that block interaction
243
+ - Rate limiting indicators and thresholds
244
+ - Infinite scroll or pagination patterns
245
+ - A/B tests that change selectors or page structure
246
+ - Dynamic IDs that change across sessions
247
+ - Session expiry and re-authentication requirements`
234
248
  ).argument("<file>", "Path to a local markdown file with YAML frontmatter").requiredOption(
235
249
  "--contributor <name>",
236
250
  'Your name/identifier, e.g. "my-agent"'
@@ -339,6 +353,73 @@ The Browser Use agent will explore the site and generate knowledge files. Check
339
353
  });
340
354
  }
341
355
 
356
+ // src/commands/download.ts
357
+ import { resolve, dirname, join } from "path";
358
+ import { mkdir, writeFile } from "fs/promises";
359
+ function reconstructMarkdown2(file) {
360
+ const frontmatter = [
361
+ "---",
362
+ `title: "${file.title}"`,
363
+ `domain: "${file.domain}"`,
364
+ `path: "${file.path}"`,
365
+ file.type ? `type: "${file.type}"` : null,
366
+ `summary: "${file.summary}"`,
367
+ `tags: [${file.tags.map((t) => `"${t}"`).join(", ")}]`,
368
+ `entities:`,
369
+ ` primary: "${file.entities.primary}"`,
370
+ ` disambiguation: "${file.entities.disambiguation}"`,
371
+ ` related_concepts: [${file.entities.relatedConcepts.map((c) => `"${c}"`).join(", ")}]`,
372
+ `intent:`,
373
+ ` core_question: "${file.intent.coreQuestion}"`,
374
+ ` audience: "${file.intent.audience}"`,
375
+ `confidence: "${file.confidence}"`,
376
+ `requires_auth: ${file.requiresAuth}`,
377
+ file.scriptLanguage ? `script_language: "${file.scriptLanguage}"` : null,
378
+ file.selectorsCount !== void 0 ? `selectors_count: ${file.selectorsCount}` : null,
379
+ `related_files: [${file.relatedFiles.map((f) => `"${f}"`).join(", ")}]`,
380
+ `version: ${file.version}`,
381
+ `last_updated: "${new Date(file.lastUpdated).toISOString()}"`,
382
+ `last_contributor: "${file.lastContributor}"`,
383
+ `last_change_reason: "${file.lastChangeReason}"`,
384
+ "---"
385
+ ].filter((line) => line !== null).join("\n");
386
+ return `${frontmatter}
387
+
388
+ ${file.content}`;
389
+ }
390
+ function registerDownload(program2) {
391
+ program2.command("download").description(
392
+ "Download all knowledge files for a domain to a local directory as markdown files with YAML frontmatter"
393
+ ).argument("<domain>", "Website domain, e.g. github.com").argument("<directory>", "Local directory to write files to").action(async (domain, directory) => {
394
+ const client = getConvexClient();
395
+ const outDir = resolve(directory);
396
+ const files = await client.query(
397
+ api.files.listByDomainWithContent,
398
+ { domain }
399
+ );
400
+ if (files.length === 0) {
401
+ console.error(
402
+ `No files found for "${domain}". Use "radar list ${domain}" to verify.`
403
+ );
404
+ process.exit(1);
405
+ }
406
+ await mkdir(outDir, { recursive: true });
407
+ let written = 0;
408
+ for (const file of files) {
409
+ const filename = file.path.endsWith(".md") ? file.path : `${file.path}.md`;
410
+ const filePath = join(outDir, filename);
411
+ await mkdir(dirname(filePath), { recursive: true });
412
+ await writeFile(filePath, reconstructMarkdown2(file), "utf-8");
413
+ written++;
414
+ console.log(` ${filename}`);
415
+ }
416
+ console.log(
417
+ `
418
+ Downloaded ${written} file(s) for ${domain} to ${outDir}`
419
+ );
420
+ });
421
+ }
422
+
342
423
  // src/index.ts
343
424
  var program = new Command();
344
425
  program.name("radar-cli").description(
@@ -350,4 +431,5 @@ registerList(program);
350
431
  registerSearch(program);
351
432
  registerSubmit(program);
352
433
  registerExplore(program);
434
+ registerDownload(program);
353
435
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "radar-cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "CLI for Radar — the shared knowledge base for web agents",
5
5
  "type": "module",
6
6
  "bin": {