radar-cli 0.1.1 → 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 +106 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ var api = anyApi;
12
12
  var components = componentsGeneric();
13
13
 
14
14
  // src/convex-client.ts
15
- var DEFAULT_CONVEX_URL = "https://tough-bird-920.convex.cloud";
15
+ var DEFAULT_CONVEX_URL = "https://fine-vole-489.convex.cloud";
16
16
  var cachedClient = null;
17
17
  function getConvexClient() {
18
18
  if (cachedClient) return cachedClient;
@@ -182,10 +182,29 @@ import { parse } from "zod-matter";
182
182
 
183
183
  // src/schemas/frontmatter.ts
184
184
  import { z } from "zod";
185
+ var FILE_TYPES = [
186
+ "readme",
187
+ "sitemap",
188
+ "flow",
189
+ "script",
190
+ "selectors",
191
+ "api",
192
+ "guide"
193
+ ];
194
+ var SCRIPT_LANGUAGES = [
195
+ "playwright-ts",
196
+ "playwright-py",
197
+ "puppeteer",
198
+ "selenium-py",
199
+ "selenium-java",
200
+ "cypress",
201
+ "other"
202
+ ];
185
203
  var knowledgeFrontmatterSchema = z.object({
186
204
  title: z.string(),
187
205
  domain: z.string(),
188
206
  path: z.string(),
207
+ type: z.enum(FILE_TYPES),
189
208
  summary: z.string().max(300),
190
209
  tags: z.array(z.string()),
191
210
  entities: z.object({
@@ -199,6 +218,7 @@ var knowledgeFrontmatterSchema = z.object({
199
218
  }),
200
219
  confidence: z.enum(["low", "medium", "high"]),
201
220
  requires_auth: z.boolean(),
221
+ script_language: z.enum(SCRIPT_LANGUAGES).optional(),
202
222
  selectors_count: z.number().int().min(0).optional(),
203
223
  related_files: z.array(z.string()).default([]),
204
224
  version: z.number().int().positive(),
@@ -210,7 +230,21 @@ var knowledgeFrontmatterSchema = z.object({
210
230
  // src/commands/submit.ts
211
231
  function registerSubmit(program2) {
212
232
  program2.command("submit").description(
213
- "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`
214
248
  ).argument("<file>", "Path to a local markdown file with YAML frontmatter").requiredOption(
215
249
  "--contributor <name>",
216
250
  'Your name/identifier, e.g. "my-agent"'
@@ -248,6 +282,7 @@ Ensure the markdown has valid YAML frontmatter matching the knowledge file schem
248
282
  const result = await client.mutation(api.files.submit, {
249
283
  domain: fm.domain,
250
284
  path: fm.path,
285
+ type: fm.type,
251
286
  title: fm.title,
252
287
  summary: fm.summary,
253
288
  tags: fm.tags,
@@ -262,6 +297,7 @@ Ensure the markdown has valid YAML frontmatter matching the knowledge file schem
262
297
  },
263
298
  confidence: fm.confidence,
264
299
  requiresAuth: fm.requires_auth,
300
+ scriptLanguage: fm.script_language,
265
301
  selectorsCount: fm.selectors_count,
266
302
  relatedFiles: fm.related_files,
267
303
  content: body.trim(),
@@ -317,6 +353,73 @@ The Browser Use agent will explore the site and generate knowledge files. Check
317
353
  });
318
354
  }
319
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
+
320
423
  // src/index.ts
321
424
  var program = new Command();
322
425
  program.name("radar-cli").description(
@@ -328,4 +431,5 @@ registerList(program);
328
431
  registerSearch(program);
329
432
  registerSubmit(program);
330
433
  registerExplore(program);
434
+ registerDownload(program);
331
435
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "radar-cli",
3
- "version": "0.1.1",
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": {