skilldb 0.5.2 → 0.7.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.
- package/dist/cli.js +33 -9
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +32 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +32 -8
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +188 -13
- package/dist/mcp.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -57,7 +57,13 @@ var SkillDBClient = class {
|
|
|
57
57
|
}
|
|
58
58
|
return h;
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
/** Make an authenticated request to any endpoint (used by MCP tools for private skills). */
|
|
61
|
+
async rawRequest(endpoint, init) {
|
|
62
|
+
const url = `${this.baseUrl}${endpoint}`;
|
|
63
|
+
const headers = { ...this.headers(), ...init?.headers || {} };
|
|
64
|
+
return fetch(url, { ...init, headers });
|
|
65
|
+
}
|
|
66
|
+
async typedRequest(endpoint, params) {
|
|
61
67
|
const url = new URL(`${this.baseUrl}${endpoint}`);
|
|
62
68
|
if (params) {
|
|
63
69
|
for (const [k, v] of Object.entries(params)) {
|
|
@@ -66,15 +72,33 @@ var SkillDBClient = class {
|
|
|
66
72
|
}
|
|
67
73
|
const res = await fetch(url.toString(), { headers: this.headers() });
|
|
68
74
|
if (!res.ok) {
|
|
69
|
-
const body = await res.json().catch(() =>
|
|
70
|
-
const
|
|
75
|
+
const body = await res.json().catch(() => null);
|
|
76
|
+
const apiError = body && typeof body === "object" ? body.error : null;
|
|
77
|
+
const status = res.status;
|
|
78
|
+
const statusText = res.statusText || "Unknown";
|
|
79
|
+
let msg;
|
|
80
|
+
if (apiError) {
|
|
81
|
+
msg = apiError;
|
|
82
|
+
} else if (status === 500) {
|
|
83
|
+
msg = `SkillDB API internal error (HTTP 500). The service may be experiencing issues. Check status at https://skilldb.dev/api/v1/status`;
|
|
84
|
+
} else if (status === 503) {
|
|
85
|
+
msg = `SkillDB API unavailable (HTTP 503). The skills index may not be loaded. Check status at https://skilldb.dev/api/v1/status`;
|
|
86
|
+
} else if (status === 401) {
|
|
87
|
+
msg = `Invalid or expired API key (HTTP 401). Get a free key at https://skilldb.dev/api-access`;
|
|
88
|
+
} else if (status === 429) {
|
|
89
|
+
msg = `Rate limit exceeded (HTTP 429). Authenticate with an API key for higher limits: https://skilldb.dev/api-access`;
|
|
90
|
+
} else if (status === 404) {
|
|
91
|
+
msg = `Resource not found (HTTP 404). The requested skill or endpoint does not exist.`;
|
|
92
|
+
} else {
|
|
93
|
+
msg = `SkillDB API error: HTTP ${status} ${statusText}. Check https://skilldb.dev/api/v1/status for service health.`;
|
|
94
|
+
}
|
|
71
95
|
throw new Error(msg);
|
|
72
96
|
}
|
|
73
97
|
return res.json();
|
|
74
98
|
}
|
|
75
99
|
/** Search skills by keyword. */
|
|
76
100
|
async search(query, options) {
|
|
77
|
-
return this.
|
|
101
|
+
return this.typedRequest("/skills", {
|
|
78
102
|
search: query,
|
|
79
103
|
category: options?.category ?? "",
|
|
80
104
|
pack: options?.pack ?? "",
|
|
@@ -86,7 +110,7 @@ var SkillDBClient = class {
|
|
|
86
110
|
}
|
|
87
111
|
/** List skills with optional filters and sorting. */
|
|
88
112
|
async list(options) {
|
|
89
|
-
return this.
|
|
113
|
+
return this.typedRequest("/skills", {
|
|
90
114
|
category: options?.category ?? "",
|
|
91
115
|
pack: options?.pack ?? "",
|
|
92
116
|
search: options?.search ?? "",
|
|
@@ -99,21 +123,21 @@ var SkillDBClient = class {
|
|
|
99
123
|
/** Get a single skill by ID (e.g. "software-skills/code-review.md"). */
|
|
100
124
|
async get(id) {
|
|
101
125
|
const encoded = encodeURIComponent(id);
|
|
102
|
-
const res = await this.
|
|
126
|
+
const res = await this.typedRequest(`/skills/${encoded}`, {
|
|
103
127
|
include_content: "true"
|
|
104
128
|
});
|
|
105
129
|
return "skill" in res ? res.skill : res;
|
|
106
130
|
}
|
|
107
131
|
/** Batch retrieve multiple skills by IDs (max 50). */
|
|
108
132
|
async batch(ids) {
|
|
109
|
-
return this.
|
|
133
|
+
return this.typedRequest("/skills", {
|
|
110
134
|
ids: ids.slice(0, 50).join(","),
|
|
111
135
|
include_content: "true"
|
|
112
136
|
});
|
|
113
137
|
}
|
|
114
138
|
/** Get search autocomplete suggestions. */
|
|
115
139
|
async suggest(query) {
|
|
116
|
-
return this.
|
|
140
|
+
return this.typedRequest("/skills/suggest", { q: query });
|
|
117
141
|
}
|
|
118
142
|
/** Validate that the configured API key works. */
|
|
119
143
|
async validate() {
|
|
@@ -1922,7 +1946,7 @@ async function purgeCommand(options) {
|
|
|
1922
1946
|
}
|
|
1923
1947
|
stats.activeKept = 0;
|
|
1924
1948
|
}
|
|
1925
|
-
writeManifest(
|
|
1949
|
+
writeManifest(manifest, cwd);
|
|
1926
1950
|
console.log(pc18.green(`
|
|
1927
1951
|
\u2713 Purge complete`));
|
|
1928
1952
|
console.log(` Skills removed: ${stats.skillsRemoved}`);
|