skillhub 0.1.0 → 0.1.1

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 +26 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -22,6 +22,25 @@ import { parseSkillMd } from "skillhub-core";
22
22
 
23
23
  // src/utils/api.ts
24
24
  var API_BASE_URL = process.env.SKILLHUB_API_URL || "https://skills.palebluedot.live/api";
25
+ var API_TIMEOUT = parseInt(process.env.SKILLHUB_API_TIMEOUT || "30000");
26
+ async function fetchWithTimeout(url, options = {}) {
27
+ const controller = new AbortController();
28
+ const timeoutId = setTimeout(() => controller.abort(), API_TIMEOUT);
29
+ try {
30
+ const response = await fetch(url, {
31
+ ...options,
32
+ signal: controller.signal
33
+ });
34
+ return response;
35
+ } catch (error) {
36
+ if (error.name === "AbortError") {
37
+ throw new Error(`Request timeout after ${API_TIMEOUT / 1e3}s. Check your internet connection or try again later.`);
38
+ }
39
+ throw new Error(`Network error: ${error.message}`);
40
+ } finally {
41
+ clearTimeout(timeoutId);
42
+ }
43
+ }
25
44
  async function searchSkills(query, options = {}) {
26
45
  const params = new URLSearchParams({
27
46
  q: query,
@@ -31,25 +50,27 @@ async function searchSkills(query, options = {}) {
31
50
  if (options.platform) {
32
51
  params.set("platform", options.platform);
33
52
  }
34
- const response = await fetch(`${API_BASE_URL}/skills?${params}`);
53
+ const response = await fetchWithTimeout(`${API_BASE_URL}/skills?${params}`);
35
54
  if (!response.ok) {
36
- throw new Error(`API error: ${response.status}`);
55
+ const text = await response.text().catch(() => "");
56
+ throw new Error(`API error ${response.status}: ${text || response.statusText}`);
37
57
  }
38
58
  return response.json();
39
59
  }
40
60
  async function getSkill(id) {
41
- const response = await fetch(`${API_BASE_URL}/skills/${encodeURIComponent(id)}`);
61
+ const response = await fetchWithTimeout(`${API_BASE_URL}/skills/${encodeURIComponent(id)}`);
42
62
  if (response.status === 404) {
43
63
  return null;
44
64
  }
45
65
  if (!response.ok) {
46
- throw new Error(`API error: ${response.status}`);
66
+ const text = await response.text().catch(() => "");
67
+ throw new Error(`API error ${response.status}: ${text || response.statusText}`);
47
68
  }
48
69
  return response.json();
49
70
  }
50
71
  async function trackInstall(skillId, platform, method = "cli") {
51
72
  try {
52
- await fetch(`${API_BASE_URL}/skills/${encodeURIComponent(skillId)}/install`, {
73
+ await fetchWithTimeout(`${API_BASE_URL}/skills/${encodeURIComponent(skillId)}/install`, {
53
74
  method: "POST",
54
75
  headers: { "Content-Type": "application/json" },
55
76
  body: JSON.stringify({ platform, method })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skillhub",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
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",