@toolr/seedr 0.1.65 → 0.1.67

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.
@@ -74,6 +74,12 @@ async function searchItems(query) {
74
74
  (item) => item.slug.toLowerCase().includes(lowerQuery) || item.name.toLowerCase().includes(lowerQuery) || item.description.toLowerCase().includes(lowerQuery)
75
75
  );
76
76
  }
77
+ async function getItemFull(item) {
78
+ const typeDir = item.type + "s";
79
+ const itemJsonPath = `${typeDir}/${item.slug}/item.json`;
80
+ const content = await loadFile(itemJsonPath);
81
+ return JSON.parse(content);
82
+ }
77
83
  function getItemBaseUrl(item) {
78
84
  if (item.externalUrl) {
79
85
  const rawUrl = item.externalUrl.replace("github.com", "raw.githubusercontent.com").replace("/tree/", "/");
@@ -105,22 +111,27 @@ function getItemSourcePath(item) {
105
111
  }
106
112
  async function fetchItemToDestination(item, destPath) {
107
113
  const { remote } = getItemBaseUrl(item);
108
- if (item.contents?.files) {
114
+ let files = item.contents?.files;
115
+ if (!files && item.type === "plugin") {
116
+ const full = await getItemFull(item);
117
+ files = full.contents?.files;
118
+ }
119
+ if (files) {
109
120
  await mkdir(destPath, { recursive: true });
110
- await fetchFileTree(item.contents.files, remote, destPath);
121
+ await fetchFileTree(files, remote, destPath);
111
122
  return;
112
123
  }
113
124
  const filesToFetch = item.type === "skill" ? ["SKILL.md"] : item.type === "plugin" ? [".claude-plugin/plugin.json"] : [`${item.type}.md`];
114
125
  await mkdir(destPath, { recursive: true });
115
- for (const file of filesToFetch) {
126
+ await Promise.all(filesToFetch.map(async (file) => {
116
127
  const content = await fetchRemote(`${remote}/${file}`);
117
128
  const filePath = join(destPath, file);
118
129
  await mkdir(dirname(filePath), { recursive: true });
119
130
  await writeFile(filePath, content, "utf-8");
120
- }
131
+ }));
121
132
  }
122
133
  async function fetchFileTree(nodes, baseUrl, destPath) {
123
- for (const node of nodes) {
134
+ await Promise.all(nodes.map(async (node) => {
124
135
  const nodePath = join(destPath, node.name);
125
136
  if (node.type === "directory") {
126
137
  await mkdir(nodePath, { recursive: true });
@@ -131,7 +142,7 @@ async function fetchFileTree(nodes, baseUrl, destPath) {
131
142
  const content = await fetchRemote(`${baseUrl}/${node.name}`);
132
143
  await writeFile(nodePath, content, "utf-8");
133
144
  }
134
- }
145
+ }));
135
146
  }
136
147
 
137
148
  // src/config/tools.ts
@@ -320,8 +331,10 @@ async function ensureDir(path) {
320
331
  }
321
332
  async function installFile(source, destination, method) {
322
333
  await ensureDir(dirname2(destination));
323
- if (await exists(destination)) {
334
+ try {
324
335
  await unlink(destination);
336
+ } catch (e) {
337
+ if (e.code !== "ENOENT") throw e;
325
338
  }
326
339
  if (method === "symlink") {
327
340
  const relPath = relative(dirname2(destination), source);
@@ -350,9 +363,7 @@ async function copyDirectory(source, destination) {
350
363
  }
351
364
  async function installDirectory(source, destination, method) {
352
365
  await ensureDir(dirname2(destination));
353
- if (await exists(destination)) {
354
- await rm(destination, { recursive: true });
355
- }
366
+ await rm(destination, { recursive: true, force: true });
356
367
  if (method === "symlink") {
357
368
  const relPath = relative(dirname2(destination), source);
358
369
  await symlink(relPath, destination);
@@ -363,28 +374,24 @@ async function installDirectory(source, destination, method) {
363
374
 
364
375
  // src/utils/detection.ts
365
376
  async function detectInstalledTools(cwd = process.cwd()) {
366
- const detected = [];
367
- for (const tool of ALL_TOOLS) {
377
+ const checks = ALL_TOOLS.flatMap((tool) => {
368
378
  const projectPath = getToolPath(tool, "project", cwd);
369
- if (await exists(projectPath)) {
370
- detected.push({ tool, scope: "project", path: projectPath });
371
- }
372
379
  const userPath = getToolPath(tool, "user", cwd);
373
- if (await exists(userPath)) {
374
- detected.push({ tool, scope: "user", path: userPath });
375
- }
376
- }
377
- return detected;
380
+ return [
381
+ exists(projectPath).then((found) => found ? { tool, scope: "project", path: projectPath } : null),
382
+ exists(userPath).then((found) => found ? { tool, scope: "user", path: userPath } : null)
383
+ ];
384
+ });
385
+ const results = await Promise.all(checks);
386
+ return results.filter((r) => r !== null);
378
387
  }
379
388
  async function detectProjectTools(cwd = process.cwd()) {
380
- const detected = [];
381
- for (const tool of ALL_TOOLS) {
389
+ const checks = ALL_TOOLS.map(async (tool) => {
382
390
  const projectPath = getToolPath(tool, "project", cwd);
383
- if (await exists(projectPath)) {
384
- detected.push(tool);
385
- }
386
- }
387
- return detected;
391
+ return await exists(projectPath) ? tool : null;
392
+ });
393
+ const results = await Promise.all(checks);
394
+ return results.filter((t) => t !== null);
388
395
  }
389
396
  async function isToolInstalled(tool, scope, cwd = process.cwd()) {
390
397
  const effectiveScope = scope === "local" ? "project" : scope;
@@ -423,9 +430,7 @@ import chalk from "chalk";
423
430
  import ora from "ora";
424
431
  async function installToCentralLocation(item, sourcePath, cwd) {
425
432
  const centralPath = getAgentsPath("skill", item.slug, cwd);
426
- if (await exists(centralPath)) {
427
- await rm2(centralPath, { recursive: true });
428
- }
433
+ await rm2(centralPath, { recursive: true, force: true });
429
434
  if (sourcePath && await exists(sourcePath)) {
430
435
  await copyDirectory(sourcePath, centralPath);
431
436
  } else {
@@ -435,9 +440,7 @@ async function installToCentralLocation(item, sourcePath, cwd) {
435
440
  }
436
441
  async function createToolSymlink(centralPath, destPath) {
437
442
  await ensureDir(dirname3(destPath));
438
- if (await exists(destPath)) {
439
- await rm2(destPath, { recursive: true });
440
- }
443
+ await rm2(destPath, { recursive: true, force: true });
441
444
  const relPath = relative2(dirname3(destPath), centralPath);
442
445
  await symlink2(relPath, destPath);
443
446
  }
@@ -503,8 +506,7 @@ async function uninstallSkill(slug, tool, scope, cwd = process.cwd()) {
503
506
  if (!await exists(destPath)) {
504
507
  return false;
505
508
  }
506
- const { rm: rm3 } = await import("fs/promises");
507
- await rm3(destPath, { recursive: true });
509
+ await rm2(destPath, { recursive: true });
508
510
  return true;
509
511
  }
510
512
  async function getInstalledSkills(tool, scope, cwd = process.cwd()) {
package/dist/cli.js CHANGED
@@ -22,7 +22,7 @@ import {
22
22
  searchItems,
23
23
  skillHandler,
24
24
  writeTextFile
25
- } from "./chunk-JFTWHQQ7.js";
25
+ } from "./chunk-DI5Z3O3G.js";
26
26
 
27
27
  // src/cli.ts
28
28
  import { Command as Command5 } from "commander";
@@ -164,7 +164,7 @@ function trackInstalls(slug, type, results, scope) {
164
164
  type,
165
165
  tool: result.tool,
166
166
  scope,
167
- version: "0.1.65"
167
+ version: "0.1.67"
168
168
  }),
169
169
  signal: AbortSignal.timeout(4e3)
170
170
  }).catch(() => {
@@ -278,11 +278,15 @@ import ora2 from "ora";
278
278
  import { readFile, writeFile } from "fs/promises";
279
279
  import { dirname } from "path";
280
280
  async function readJson(path) {
281
- if (!await exists(path)) {
282
- return {};
281
+ try {
282
+ const content = await readFile(path, "utf-8");
283
+ return JSON.parse(content);
284
+ } catch (error2) {
285
+ if (error2.code === "ENOENT") {
286
+ return {};
287
+ }
288
+ throw error2;
283
289
  }
284
- const content = await readFile(path, "utf-8");
285
- return JSON.parse(content);
286
290
  }
287
291
  async function writeJson(path, data) {
288
292
  await ensureDir(dirname(path));
@@ -457,9 +461,11 @@ async function uninstallHook(slug, tool, scope, cwd = process.cwd()) {
457
461
  const hooksDir = getHooksDir(scope, cwd);
458
462
  const scriptFileName = scriptFile || `${slug}.sh`;
459
463
  const scriptFilePath = join2(hooksDir, scriptFileName);
460
- if (await exists(scriptFilePath)) {
464
+ try {
461
465
  await rm(scriptFilePath);
462
466
  removed = true;
467
+ } catch (e) {
468
+ if (e.code !== "ENOENT") throw e;
463
469
  }
464
470
  return removed;
465
471
  }
@@ -678,6 +684,9 @@ var settingsHandler = {
678
684
  // src/handlers/plugin.ts
679
685
  import { homedir as homedir2 } from "os";
680
686
  import { join as join3 } from "path";
687
+ import { mkdir as mkdir2, rm as rm2 } from "fs/promises";
688
+ import { execFile } from "child_process";
689
+ import { promisify } from "util";
681
690
  import chalk7 from "chalk";
682
691
  import ora5 from "ora";
683
692
  var home = homedir2();
@@ -703,9 +712,6 @@ async function ensureMarketplaceRegistered(marketplace, item) {
703
712
  const repo = item.externalUrl ? extractGitHubRepo(item.externalUrl) : null;
704
713
  if (!repo) return;
705
714
  const installLocation = join3(MARKETPLACES_DIR, marketplace);
706
- const { execFile } = await import("child_process");
707
- const { mkdir: mkdir2 } = await import("fs/promises");
708
- const { promisify } = await import("util");
709
715
  const execFileAsync = promisify(execFile);
710
716
  await mkdir2(MARKETPLACES_DIR, { recursive: true });
711
717
  await execFileAsync("git", [
@@ -746,7 +752,6 @@ async function installPluginForTool(item, tool, scope, method, cwd) {
746
752
  const pluginId = getPluginId(pluginName, marketplace);
747
753
  await ensureMarketplaceRegistered(marketplace, item);
748
754
  const cachePath = getPluginCachePath(marketplace, pluginName, version);
749
- const { rm: rm2 } = await import("fs/promises");
750
755
  await installDirectory(tmpPath, cachePath, "copy");
751
756
  await rm2(tmpPath, { recursive: true, force: true });
752
757
  const now = (/* @__PURE__ */ new Date()).toISOString();
@@ -972,8 +977,8 @@ var addCommand = new Command("add").description("Install a skill, agent, hook, o
972
977
  error(`No handler found for type "${item.type}"`);
973
978
  process.exit(1);
974
979
  }
975
- const typeCompatible = filterCompatibleTools(item.type, item.compatibility);
976
980
  let tools = resolveTools(options.agents, item);
981
+ const typeCompatible = filterCompatibleTools(item.type, item.compatibility);
977
982
  if (tools.length === 0) {
978
983
  if (typeCompatible.length === 1) {
979
984
  tools = typeCompatible;
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  loadManifest,
16
16
  searchItems,
17
17
  uninstallSkill
18
- } from "./chunk-JFTWHQQ7.js";
18
+ } from "./chunk-DI5Z3O3G.js";
19
19
 
20
20
  // src/converters/index.ts
21
21
  import matter from "gray-matter";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toolr/seedr",
3
- "version": "0.1.65",
3
+ "version": "0.1.67",
4
4
  "description": "Seed your projects with AI configurations",
5
5
  "type": "module",
6
6
  "bin": {