skillhub 0.1.0 → 0.1.2

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 +37 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@ import {
12
12
  // src/index.ts
13
13
  import { Command } from "commander";
14
14
  import chalk5 from "chalk";
15
+ import { createRequire } from "module";
15
16
 
16
17
  // src/commands/install.ts
17
18
  import fs from "fs-extra";
@@ -22,6 +23,27 @@ import { parseSkillMd } from "skillhub-core";
22
23
 
23
24
  // src/utils/api.ts
24
25
  var API_BASE_URL = process.env.SKILLHUB_API_URL || "https://skills.palebluedot.live/api";
26
+ var API_TIMEOUT = parseInt(process.env.SKILLHUB_API_TIMEOUT || "30000");
27
+ if (typeof process !== "undefined" && process.env.NODE_TLS_REJECT_UNAUTHORIZED === void 0) {
28
+ }
29
+ async function fetchWithTimeout(url, options = {}) {
30
+ const controller = new AbortController();
31
+ const timeoutId = setTimeout(() => controller.abort(), API_TIMEOUT);
32
+ try {
33
+ const response = await fetch(url, {
34
+ ...options,
35
+ signal: controller.signal
36
+ });
37
+ return response;
38
+ } catch (error) {
39
+ if (error.name === "AbortError") {
40
+ throw new Error(`Request timeout after ${API_TIMEOUT / 1e3}s. Check your internet connection or try again later.`);
41
+ }
42
+ throw new Error(`Network error: ${error.message}`);
43
+ } finally {
44
+ clearTimeout(timeoutId);
45
+ }
46
+ }
25
47
  async function searchSkills(query, options = {}) {
26
48
  const params = new URLSearchParams({
27
49
  q: query,
@@ -31,25 +53,27 @@ async function searchSkills(query, options = {}) {
31
53
  if (options.platform) {
32
54
  params.set("platform", options.platform);
33
55
  }
34
- const response = await fetch(`${API_BASE_URL}/skills?${params}`);
56
+ const response = await fetchWithTimeout(`${API_BASE_URL}/skills?${params}`);
35
57
  if (!response.ok) {
36
- throw new Error(`API error: ${response.status}`);
58
+ const text = await response.text().catch(() => "");
59
+ throw new Error(`API error ${response.status}: ${text || response.statusText}`);
37
60
  }
38
61
  return response.json();
39
62
  }
40
63
  async function getSkill(id) {
41
- const response = await fetch(`${API_BASE_URL}/skills/${encodeURIComponent(id)}`);
64
+ const response = await fetchWithTimeout(`${API_BASE_URL}/skills/${encodeURIComponent(id)}`);
42
65
  if (response.status === 404) {
43
66
  return null;
44
67
  }
45
68
  if (!response.ok) {
46
- throw new Error(`API error: ${response.status}`);
69
+ const text = await response.text().catch(() => "");
70
+ throw new Error(`API error ${response.status}: ${text || response.statusText}`);
47
71
  }
48
72
  return response.json();
49
73
  }
50
74
  async function trackInstall(skillId, platform, method = "cli") {
51
75
  try {
52
- await fetch(`${API_BASE_URL}/skills/${encodeURIComponent(skillId)}/install`, {
76
+ await fetchWithTimeout(`${API_BASE_URL}/skills/${encodeURIComponent(skillId)}/install`, {
53
77
  method: "POST",
54
78
  headers: { "Content-Type": "application/json" },
55
79
  body: JSON.stringify({ platform, method })
@@ -303,7 +327,11 @@ async function search(query, options) {
303
327
  }
304
328
  } catch (error) {
305
329
  spinner.fail("Search failed");
306
- console.error(chalk2.red(error.message));
330
+ const err = error;
331
+ console.error(chalk2.red(err.message || "Unknown error"));
332
+ if (process.env.DEBUG) {
333
+ console.error(chalk2.dim("Stack:"), err.stack);
334
+ }
307
335
  process.exit(1);
308
336
  }
309
337
  }
@@ -454,7 +482,9 @@ function maskSecret(value) {
454
482
  }
455
483
 
456
484
  // src/index.ts
457
- var VERSION = "0.1.0";
485
+ var require2 = createRequire(import.meta.url);
486
+ var pkg = require2("../package.json");
487
+ var VERSION = pkg.version;
458
488
  var program = new Command();
459
489
  program.name("skillhub").description("CLI for managing AI Agent skills").version(VERSION);
460
490
  program.command("install <skill-id>").description("Install a skill from the registry").option("-p, --platform <platform>", "Target platform (claude, codex, copilot, cursor, windsurf)", "claude").option("--project", "Install in the current project instead of globally").option("-f, --force", "Overwrite existing skill").action(async (skillId, options) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skillhub",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "CLI tool for managing AI Agent skills - search, install, and update skills for Claude, Codex, Copilot, and more",
5
5
  "author": "SkillHub Contributors",
6
6
  "license": "MIT",