@xbrowser/cli 1.9.6 → 1.9.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.
package/dist/cli.js CHANGED
@@ -10325,6 +10325,50 @@ async function infoFromMarketplacePlugin(slug, loader) {
10325
10325
  }
10326
10326
  return null;
10327
10327
  }
10328
+ function normalizePluginName(name) {
10329
+ return name.replace(/^@[^/]+\//, "").replace(/^xbrowser-plugin-/, "").toLowerCase();
10330
+ }
10331
+ async function searchLocalPlugins(query) {
10332
+ let installed;
10333
+ try {
10334
+ installed = await new PluginInstaller().list();
10335
+ } catch {
10336
+ return [];
10337
+ }
10338
+ if (!installed || installed.length === 0) return [];
10339
+ const q = normalizePluginName(query);
10340
+ if (!q) return [];
10341
+ const results = [];
10342
+ for (const p of installed) {
10343
+ const plugin = p;
10344
+ const name = String(plugin.name ?? "");
10345
+ const norm = normalizePluginName(name);
10346
+ if (norm === q) {
10347
+ results.push({ plugin, rank: 0 });
10348
+ } else if (norm.startsWith(q) || q.startsWith(norm)) {
10349
+ results.push({ plugin, rank: 1 });
10350
+ } else if (norm.includes(q) || q.includes(norm)) {
10351
+ results.push({ plugin, rank: 2 });
10352
+ }
10353
+ }
10354
+ results.sort((a, b) => a.rank - b.rank);
10355
+ const runtimeInfo = await buildRuntimePluginInfo().catch(() => /* @__PURE__ */ new Map());
10356
+ return results.map(({ plugin }) => {
10357
+ const name = String(plugin.name ?? "");
10358
+ const metadata = plugin.metadata;
10359
+ const staticCommands = metadata?.commands;
10360
+ const rt = runtimeInfo.get(name);
10361
+ const commands = rt?.commands || staticCommands;
10362
+ return {
10363
+ name: "@xbrowser/" + name,
10364
+ slug: name,
10365
+ description: metadata?.description,
10366
+ version: metadata?.version,
10367
+ commands,
10368
+ source: "local"
10369
+ };
10370
+ });
10371
+ }
10328
10372
  async function handleSearch(args, options, mode) {
10329
10373
  const query = args[0] || "";
10330
10374
  applyRegistryOverride(options);
@@ -10332,6 +10376,8 @@ async function handleSearch(args, options, mode) {
10332
10376
  const searchLimit = options.limit ? Number(options.limit) : 20;
10333
10377
  const searchOpts = { query, tag: options.tag, site: options.site, limit: searchLimit };
10334
10378
  const results = [];
10379
+ const localResults = await searchLocalPlugins(query);
10380
+ results.push(...localResults);
10335
10381
  const loader = await getPluginLoader();
10336
10382
  const pluginResults = await searchFromMarketplacePlugin2(searchOpts, loader);
10337
10383
  results.push(...pluginResults);
@@ -10344,15 +10390,24 @@ async function handleSearch(args, options, mode) {
10344
10390
  } catch {
10345
10391
  }
10346
10392
  }
10393
+ const seen = /* @__PURE__ */ new Set();
10394
+ const deduped = [];
10395
+ for (const r of results) {
10396
+ const key = normalizePluginName(String(r.name ?? ""));
10397
+ if (key && !seen.has(key)) {
10398
+ seen.add(key);
10399
+ deduped.push(r);
10400
+ }
10401
+ }
10347
10402
  if (mode === "json") {
10348
- outputEnvelope({ success: true, data: { results, total: results.length } }, { command: "plugin search" }, mode);
10403
+ outputEnvelope({ success: true, data: { results: deduped, total: deduped.length } }, { command: "plugin search" }, mode);
10349
10404
  } else {
10350
- if (results.length === 0) {
10405
+ if (deduped.length === 0) {
10351
10406
  console.log("No plugins found");
10352
10407
  return;
10353
10408
  }
10354
- for (const r of results) {
10355
- const src = r.source === "marketplace" ? "[marketplace]" : "[npm]";
10409
+ for (const r of deduped) {
10410
+ const src = r.source === "marketplace" ? "[marketplace]" : r.source === "local" ? "[local]" : "[npm]";
10356
10411
  const slug = r.slug ? ` (${r.slug})` : "";
10357
10412
  console.log(` ${src} ${r.name}${slug}`);
10358
10413
  if (r.description) console.log(` ${r.description}`);
@@ -10360,7 +10415,7 @@ async function handleSearch(args, options, mode) {
10360
10415
  if (r.downloads) console.log(` Downloads: ${r.downloads}`);
10361
10416
  console.log("");
10362
10417
  }
10363
- console.log(`Total: ${results.length} plugins`);
10418
+ console.log(`Total: ${deduped.length} plugins`);
10364
10419
  }
10365
10420
  }
10366
10421
  async function handlePluginInfo(args, options, mode) {
package/dist/index.js CHANGED
@@ -10711,6 +10711,50 @@ async function infoFromMarketplacePlugin(slug, loader) {
10711
10711
  }
10712
10712
  return null;
10713
10713
  }
10714
+ function normalizePluginName(name) {
10715
+ return name.replace(/^@[^/]+\//, "").replace(/^xbrowser-plugin-/, "").toLowerCase();
10716
+ }
10717
+ async function searchLocalPlugins(query) {
10718
+ let installed;
10719
+ try {
10720
+ installed = await new PluginInstaller().list();
10721
+ } catch {
10722
+ return [];
10723
+ }
10724
+ if (!installed || installed.length === 0) return [];
10725
+ const q = normalizePluginName(query);
10726
+ if (!q) return [];
10727
+ const results = [];
10728
+ for (const p of installed) {
10729
+ const plugin = p;
10730
+ const name = String(plugin.name ?? "");
10731
+ const norm = normalizePluginName(name);
10732
+ if (norm === q) {
10733
+ results.push({ plugin, rank: 0 });
10734
+ } else if (norm.startsWith(q) || q.startsWith(norm)) {
10735
+ results.push({ plugin, rank: 1 });
10736
+ } else if (norm.includes(q) || q.includes(norm)) {
10737
+ results.push({ plugin, rank: 2 });
10738
+ }
10739
+ }
10740
+ results.sort((a, b) => a.rank - b.rank);
10741
+ const runtimeInfo = await buildRuntimePluginInfo().catch(() => /* @__PURE__ */ new Map());
10742
+ return results.map(({ plugin }) => {
10743
+ const name = String(plugin.name ?? "");
10744
+ const metadata = plugin.metadata;
10745
+ const staticCommands = metadata?.commands;
10746
+ const rt = runtimeInfo.get(name);
10747
+ const commands = rt?.commands || staticCommands;
10748
+ return {
10749
+ name: "@xbrowser/" + name,
10750
+ slug: name,
10751
+ description: metadata?.description,
10752
+ version: metadata?.version,
10753
+ commands,
10754
+ source: "local"
10755
+ };
10756
+ });
10757
+ }
10714
10758
  async function handleSearch(args, options, mode) {
10715
10759
  const query = args[0] || "";
10716
10760
  applyRegistryOverride(options);
@@ -10718,6 +10762,8 @@ async function handleSearch(args, options, mode) {
10718
10762
  const searchLimit = options.limit ? Number(options.limit) : 20;
10719
10763
  const searchOpts = { query, tag: options.tag, site: options.site, limit: searchLimit };
10720
10764
  const results = [];
10765
+ const localResults = await searchLocalPlugins(query);
10766
+ results.push(...localResults);
10721
10767
  const loader = await getPluginLoader();
10722
10768
  const pluginResults = await searchFromMarketplacePlugin2(searchOpts, loader);
10723
10769
  results.push(...pluginResults);
@@ -10730,15 +10776,24 @@ async function handleSearch(args, options, mode) {
10730
10776
  } catch {
10731
10777
  }
10732
10778
  }
10779
+ const seen = /* @__PURE__ */ new Set();
10780
+ const deduped = [];
10781
+ for (const r of results) {
10782
+ const key = normalizePluginName(String(r.name ?? ""));
10783
+ if (key && !seen.has(key)) {
10784
+ seen.add(key);
10785
+ deduped.push(r);
10786
+ }
10787
+ }
10733
10788
  if (mode === "json") {
10734
- outputEnvelope({ success: true, data: { results, total: results.length } }, { command: "plugin search" }, mode);
10789
+ outputEnvelope({ success: true, data: { results: deduped, total: deduped.length } }, { command: "plugin search" }, mode);
10735
10790
  } else {
10736
- if (results.length === 0) {
10791
+ if (deduped.length === 0) {
10737
10792
  console.log("No plugins found");
10738
10793
  return;
10739
10794
  }
10740
- for (const r of results) {
10741
- const src = r.source === "marketplace" ? "[marketplace]" : "[npm]";
10795
+ for (const r of deduped) {
10796
+ const src = r.source === "marketplace" ? "[marketplace]" : r.source === "local" ? "[local]" : "[npm]";
10742
10797
  const slug = r.slug ? ` (${r.slug})` : "";
10743
10798
  console.log(` ${src} ${r.name}${slug}`);
10744
10799
  if (r.description) console.log(` ${r.description}`);
@@ -10746,7 +10801,7 @@ async function handleSearch(args, options, mode) {
10746
10801
  if (r.downloads) console.log(` Downloads: ${r.downloads}`);
10747
10802
  console.log("");
10748
10803
  }
10749
- console.log(`Total: ${results.length} plugins`);
10804
+ console.log(`Total: ${deduped.length} plugins`);
10750
10805
  }
10751
10806
  }
10752
10807
  async function handlePluginInfo(args, options, mode) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xbrowser/cli",
3
- "version": "1.9.6",
3
+ "version": "1.9.7",
4
4
  "description": "Browser automation CLI for web scraping, headless browsing, SEO analysis, and AI agent workflows. A command-line alternative to Playwright, Puppeteer, and Selenium.",
5
5
  "type": "module",
6
6
  "bin": {