skillscout 0.0.0-stage → 0.1.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.
@@ -0,0 +1,22 @@
1
+ import { createHash } from "node:crypto";
2
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
3
+ import { join } from "node:path";
4
+ import { cacheDir } from "./paths.js";
5
+ function keyPath(kind, id, pin) {
6
+ const h = createHash("sha256").update(`${kind}\0${id}\0${pin}`).digest("hex").slice(0, 32);
7
+ return join(cacheDir(), "vet", `${h}.json`);
8
+ }
9
+ export async function loadVet(kind, id, pin) {
10
+ try {
11
+ return JSON.parse(await readFile(keyPath(kind, id, pin), "utf8"));
12
+ }
13
+ catch {
14
+ return undefined;
15
+ }
16
+ }
17
+ export async function saveVet(v) {
18
+ const p = keyPath(v.kind, v.id, v.sha);
19
+ await mkdir(join(cacheDir(), "vet"), { recursive: true });
20
+ await writeFile(p, JSON.stringify(v, null, 2));
21
+ }
22
+ //# sourceMappingURL=vetCache.js.map
package/dist/vetMcp.js ADDED
@@ -0,0 +1,289 @@
1
+ import { createHash } from "node:crypto";
2
+ import { sanitize } from "./sanitize.js";
3
+ import { llmReview } from "./scan/llm.js";
4
+ import { capFinding, scanFiles } from "./scan/rules.js";
5
+ import { repoProvenance } from "./sources/github.js";
6
+ import { getMcpServer } from "./sources/mcpRegistry.js";
7
+ import { npmTarballFiles, npmVersion, npmWeeklyDownloads, pypiFiles, pypiVersion, resolveNpmDeps } from "./sources/packages.js";
8
+ import { osvFindings } from "./sources/osv.js";
9
+ import { probeRemote } from "./sources/remoteProbe.js";
10
+ import { decide } from "./verdict.js";
11
+ import { saveVet } from "./vetCache.js";
12
+ // Lifecycle scripts that run when a *published* package is installed (prepare does not).
13
+ const INSTALL_SCRIPTS = ["preinstall", "install", "postinstall"];
14
+ const REVIEW_EXT = /\.(m?[jt]s|cjs|py|json|md|toml|cfg)$/i;
15
+ const SKIP_DIRS = /(^|\/)(test|tests|__tests__|examples?|docs?|\.github)\//i;
16
+ export async function vetMcp(name, opts = {}) {
17
+ const entry = await getMcpServer(name, opts.version);
18
+ const findings = [];
19
+ const reviewReasons = [];
20
+ const notes = [];
21
+ let files = [];
22
+ let skipped = [];
23
+ let hasCode = false;
24
+ let pin = entry.version;
25
+ let contentHash = "";
26
+ let plan;
27
+ if (entry.status && entry.status !== "active") {
28
+ findings.push({ rule: "registry-status", severity: "medium", file: "registry", message: `Registry status is "${sanitize(entry.status, 20)}"` });
29
+ }
30
+ notes.push(...namespaceNotes(entry));
31
+ const pkg = pickPackage(entry.packages ?? []);
32
+ const remote = entry.remotes?.[0];
33
+ const useRemote = (opts.prefer === "remote" && remote) || (!pkg && remote);
34
+ if (!useRemote && pkg) {
35
+ hasCode = true;
36
+ if (pkg.registryType === "npm") {
37
+ const { info, publishedAt } = await npmVersion(pkg.identifier, pkg.version);
38
+ pin = info.version;
39
+ contentHash = info.dist.integrity ?? "";
40
+ const scripts = Object.entries(info.scripts ?? {}).filter(([k]) => INSTALL_SCRIPTS.includes(k));
41
+ for (const [k, v] of scripts) {
42
+ findings.push({ rule: "install-script", severity: "high", file: "package.json", message: `Runs an npm "${k}" script on install`, excerpt: sanitize(v, 120) });
43
+ }
44
+ if (info.deprecated)
45
+ findings.push({ rule: "deprecated", severity: "medium", file: "package.json", message: `Package version is deprecated: ${sanitize(info.deprecated, 120)}` });
46
+ if (publishedAt && Date.now() - Date.parse(publishedAt) < 7 * 86_400_000)
47
+ notes.push(`Version ${info.version} was published less than 7 days ago.`);
48
+ const dl = await npmWeeklyDownloads(pkg.identifier);
49
+ if (dl !== undefined)
50
+ notes.push(`${dl} npm downloads last week.`);
51
+ const repoUrl = typeof info.repository === "string" ? info.repository : info.repository?.url;
52
+ if (entry.repository?.url && repoUrl && normalizeRepo(repoUrl) !== normalizeRepo(entry.repository.url)) {
53
+ findings.push({ rule: "repo-mismatch", severity: "medium", file: "package.json", message: "npm package repository differs from the registry entry's repository" });
54
+ }
55
+ // Direct dependencies: resolve, flag install scripts, and check package + deps against OSV.
56
+ const deps = await resolveNpmDeps(info.dependencies ?? {});
57
+ for (const d of deps.filter((d) => d.hasInstallScript)) {
58
+ findings.push({ rule: "dependency-install-script", severity: "medium", file: "package.json", message: `Dependency ${d.name}@${d.version} runs install scripts` });
59
+ }
60
+ const unresolved = deps.filter((d) => !d.version).length;
61
+ if (deps.length)
62
+ notes.push(`${deps.length} direct dependencies checked for install scripts and known vulnerabilities${unresolved ? ` (${unresolved} could not be resolved)` : ""}; transitive dependencies are not checked.`);
63
+ const osv = await osvFindings([
64
+ { ecosystem: "npm", name: info.name, version: info.version, via: "package.json" },
65
+ ...deps.filter((d) => d.version).map((d) => ({ ecosystem: "npm", name: d.name, version: d.version, via: `dependency ${d.name}` })),
66
+ ]);
67
+ findings.push(...osv.findings);
68
+ if (osv.error)
69
+ notes.push(osv.error);
70
+ const tar = await npmTarballFiles(info.dist.tarball);
71
+ files = tar.files.filter((f) => !f.path.includes("node_modules/"));
72
+ skipped = tar.skipped;
73
+ const scanned = scanFiles(files)
74
+ .filter((f) => !(f.rule === "package-install-script" && f.file === "package.json")) // reported above, precisely
75
+ .map(adjustForPackage);
76
+ findings.push(...scanned);
77
+ plan = npmPlan(entry, pkg, info.version);
78
+ }
79
+ else if (pkg.registryType === "pypi") {
80
+ const info = await pypiVersion(pkg.identifier, pkg.version);
81
+ pin = info.version;
82
+ contentHash = `pypi:${pkg.identifier}==${info.version}`;
83
+ if (info.yanked)
84
+ findings.push({ rule: "yanked", severity: "medium", file: "pypi", message: "This PyPI release was yanked" });
85
+ if (info.publishedAt && Date.now() - Date.parse(info.publishedAt) < 7 * 86_400_000)
86
+ notes.push(`Version ${info.version} was published less than 7 days ago.`);
87
+ const osv = await osvFindings([{ ecosystem: "PyPI", name: pkg.identifier, version: info.version, via: "pypi" }]);
88
+ findings.push(...osv.findings);
89
+ if (osv.error)
90
+ notes.push(osv.error);
91
+ if (info.dist) {
92
+ try {
93
+ const unpacked = await pypiFiles(info.dist);
94
+ files = unpacked.files;
95
+ skipped = unpacked.skipped;
96
+ findings.push(...scanFiles(files).map(adjustForPackage));
97
+ notes.push(`Scanned the ${info.dist.kind}; Python dependencies are not checked.`);
98
+ }
99
+ catch (e) {
100
+ reviewReasons.push(`Could not scan the PyPI distribution: ${sanitize(e.message, 120)}`);
101
+ }
102
+ }
103
+ else {
104
+ reviewReasons.push("No PyPI distribution file to scan.");
105
+ }
106
+ plan = pypiPlan(entry, pkg, info.version);
107
+ }
108
+ else if (pkg.registryType === "oci") {
109
+ pin = pkg.version ?? entry.version;
110
+ contentHash = `oci:${pkg.identifier}:${pin}`;
111
+ reviewReasons.push("Container image contents are not scanned. Prefer images pinned by digest from a publisher you trust.");
112
+ plan = ociPlan(entry, pkg, pin);
113
+ }
114
+ else {
115
+ reviewReasons.push(`Package type "${sanitize(pkg.registryType, 20)}" is not supported for scanning.`);
116
+ }
117
+ }
118
+ else if (remote) {
119
+ const res = await remoteVet(entry, remote, opts.probeRemote !== false);
120
+ findings.push(...res.findings);
121
+ reviewReasons.push(...res.reviewReasons);
122
+ files = res.files;
123
+ contentHash = res.contentHash;
124
+ plan = res.plan;
125
+ }
126
+ else {
127
+ throw new Error(`Registry entry ${name} has neither packages nor remotes`);
128
+ }
129
+ const provenance = await repoProvenanceFor(entry);
130
+ provenance.notes.push(...notes);
131
+ const reviewFiles = files
132
+ .filter((f) => REVIEW_EXT.test(f.path) && !SKIP_DIRS.test(f.path) && !/\.min\.js$|\.map$/.test(f.path))
133
+ .sort((a, b) => priority(a.path) - priority(b.path));
134
+ const llm = files.length
135
+ ? await llmReview({ kind: "mcp", name: entry.name, description: entry.description ?? "", files: reviewFiles })
136
+ : { status: "skipped", reason: "No source or tool descriptions available to review." };
137
+ const { verdict, risk, reasons } = decide({ staticFindings: findings, llm, partnerAudits: [], hasCode, reviewReasons });
138
+ const result = {
139
+ kind: "mcp",
140
+ id: entry.name,
141
+ source: pkg && !useRemote ? `${pkg.registryType}:${pkg.identifier}` : `remote:${remote?.url ?? ""}`,
142
+ path: "",
143
+ sha: pin,
144
+ contentHash: contentHash || "sha256:" + createHash("sha256").update(JSON.stringify(entry)).digest("hex"),
145
+ name: sanitize(entry.name, 120),
146
+ description: sanitize(entry.description, 600),
147
+ verdict,
148
+ risk,
149
+ reasons,
150
+ staticFindings: [...findings, ...(llm.findings ?? [])],
151
+ llm: { ...llm, findings: undefined },
152
+ partnerAudits: [],
153
+ provenance,
154
+ files: files.slice(0, 200).map((f) => ({ path: f.path, size: f.content.length, executable: f.executable })),
155
+ skipped,
156
+ registryVersion: entry.version,
157
+ mcpInstall: plan,
158
+ vettedAt: new Date().toISOString(),
159
+ };
160
+ await saveVet(result);
161
+ return result;
162
+ }
163
+ async function remoteVet(entry, remote, probe) {
164
+ const findings = [];
165
+ const reviewReasons = ["Remote server: its behavior and tool descriptions can change after vetting without a new version."];
166
+ let files = [];
167
+ let contentHash = "";
168
+ if (!remote.url.startsWith("https://")) {
169
+ findings.push({ rule: "insecure-transport", severity: "high", file: "registry", message: "Remote server does not use https" });
170
+ }
171
+ if (probe) {
172
+ const res = await probeRemote(remote.url, remote.type);
173
+ if (res.status === "ok") {
174
+ // Each tool description is instruction text the agent will read: scan it like markdown.
175
+ files = res.tools.map((t) => ({
176
+ path: `tools/${t.name.replace(/[^\w.-]/g, "_")}.md`,
177
+ content: Buffer.from(`# ${t.name}\n\n${t.description}\n\n${JSON.stringify(t.inputSchema ?? {}, null, 1)}`),
178
+ executable: false,
179
+ }));
180
+ findings.push(...scanFiles(files));
181
+ contentHash = "sha256:" + createHash("sha256").update(JSON.stringify(res.tools)).digest("hex");
182
+ if (res.tools.length > 60)
183
+ findings.push({ rule: "many-tools", severity: "low", file: "tools", message: `Exposes ${res.tools.length} tools (context cost)` });
184
+ }
185
+ else {
186
+ reviewReasons.push(`Tool descriptions not inspected: ${res.reason}`);
187
+ }
188
+ }
189
+ else {
190
+ reviewReasons.push("Tool descriptions not inspected (probe disabled).");
191
+ }
192
+ const headers = (remote.headers ?? []).map((h) => ({ name: sanitize(h.name, 80), secret: !!h.isSecret, description: sanitize(h.description, 200) }));
193
+ const envName = (h) => `${serverName(entry).toUpperCase().replace(/[^A-Z0-9]/g, "_")}_${h.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`;
194
+ const plan = {
195
+ serverName: serverName(entry),
196
+ config: {
197
+ type: remote.type === "sse" ? "sse" : "http",
198
+ url: remote.url,
199
+ ...(headers.length ? { headers: Object.fromEntries(headers.map((h) => [h.name, `\${${envName(h.name)}}`])) } : {}),
200
+ },
201
+ requiredEnv: headers.map((h) => ({ name: envName(h.name), secret: h.secret, description: `Value for header ${h.name}. ${h.description}` })),
202
+ };
203
+ return { findings, reviewReasons, files, contentHash, plan };
204
+ }
205
+ /**
206
+ * In an MCP *package*, markdown is human documentation that the agent never
207
+ * loads (unlike a skill, whose markdown is the agent's instructions), so doc
208
+ * findings are capped. What reaches the agent is the tool descriptions in code,
209
+ * which keep full severity.
210
+ */
211
+ export function adjustForPackage(f) {
212
+ if (/\.(md|mdx|markdown|txt)$/i.test(f.file) || /^(tests?|__tests__|docs?|examples?)\//.test(f.file))
213
+ return capFinding(f, "package documentation or tests");
214
+ // API-wrapper servers routinely read a token and call an API; keep it visible, not blocking.
215
+ if (f.rule === "possible-exfiltration") {
216
+ return { ...f, severity: "medium", message: `${f.message} (common for API servers; check the destination)` };
217
+ }
218
+ return f;
219
+ }
220
+ function pickPackage(pkgs) {
221
+ return pkgs.find((p) => p.registryType === "npm") ?? pkgs.find((p) => p.registryType === "pypi") ?? pkgs.find((p) => p.registryType === "oci") ?? pkgs[0];
222
+ }
223
+ function envPlan(pkg) {
224
+ const req = (pkg.environmentVariables ?? []).map((e) => ({ name: sanitize(e.name, 80), secret: !!e.isSecret, description: sanitize(e.description, 200) }));
225
+ const env = Object.fromEntries(req.filter((e) => /^[A-Z_][A-Z0-9_]*$/i.test(e.name)).map((e) => [e.name, `\${${e.name}}`]));
226
+ return { req, env };
227
+ }
228
+ function npmPlan(entry, pkg, version) {
229
+ const { req, env } = envPlan(pkg);
230
+ return {
231
+ serverName: serverName(entry),
232
+ config: { command: "npx", args: ["-y", `${pkg.identifier}@${version}`], ...(Object.keys(env).length ? { env } : {}) },
233
+ requiredEnv: req,
234
+ };
235
+ }
236
+ function pypiPlan(entry, pkg, version) {
237
+ const { req, env } = envPlan(pkg);
238
+ return {
239
+ serverName: serverName(entry),
240
+ config: { command: "uvx", args: [`${pkg.identifier}==${version}`], ...(Object.keys(env).length ? { env } : {}) },
241
+ requiredEnv: req,
242
+ };
243
+ }
244
+ function ociPlan(entry, pkg, tag) {
245
+ const { req, env } = envPlan(pkg);
246
+ const image = pkg.identifier.includes(":") || pkg.identifier.includes("@") ? pkg.identifier : `${pkg.identifier}:${tag}`;
247
+ return {
248
+ serverName: serverName(entry),
249
+ config: {
250
+ command: "docker",
251
+ args: ["run", "-i", "--rm", ...Object.keys(env).flatMap((k) => ["-e", k]), image],
252
+ ...(Object.keys(env).length ? { env } : {}),
253
+ },
254
+ requiredEnv: req,
255
+ };
256
+ }
257
+ export function serverName(entry) {
258
+ const last = entry.name.split("/").pop() ?? entry.name;
259
+ return last.replace(/[^A-Za-z0-9_-]/g, "-").slice(0, 60) || "mcp-server";
260
+ }
261
+ function namespaceNotes(entry) {
262
+ const [ns] = entry.name.split("/");
263
+ if (!ns)
264
+ return [];
265
+ if (/^io\.github\./.test(ns))
266
+ return [`Registry namespace ${sanitize(ns, 80)} is tied to a GitHub account.`];
267
+ return [`Registry namespace ${sanitize(ns, 80)} is tied to a domain (reverse-DNS).`];
268
+ }
269
+ async function repoProvenanceFor(entry) {
270
+ const m = entry.repository?.url?.match(/github\.com\/([^/]+)\/([^/#?]+?)(\.git)?(?:[/#?]|$)/);
271
+ if (!m)
272
+ return { notes: entry.repository?.url ? [] : ["No source repository listed."] };
273
+ return repoProvenance(m[1], m[2]);
274
+ }
275
+ function normalizeRepo(u) {
276
+ return u.toLowerCase().replace(/^git\+/, "").replace(/^git:\/\//, "https://").replace(/\.git$/, "").replace(/\/$/, "").replace(/^ssh:\/\/git@/, "https://");
277
+ }
278
+ function priority(p) {
279
+ if (p === "package.json")
280
+ return 0;
281
+ if (/readme/i.test(p))
282
+ return 1;
283
+ if (/(^|\/)(src|lib|dist|build)\/.*(tool|index|server)/i.test(p))
284
+ return 2;
285
+ if (/\.(m?[jt]s|cjs|py)$/.test(p))
286
+ return 3;
287
+ return 4;
288
+ }
289
+ //# sourceMappingURL=vetMcp.js.map
@@ -0,0 +1,221 @@
1
+ import { mkdir, writeFile, rm } from "node:fs/promises";
2
+ import { dirname, join } from "node:path";
3
+ import { hashFiles, LIMITS, mapLimit } from "./fetchSkill.js";
4
+ import { parseSkillRef } from "./ref.js";
5
+ import { sanitize } from "./sanitize.js";
6
+ import { llmReview } from "./scan/llm.js";
7
+ import { capFinding, scanFiles } from "./scan/rules.js";
8
+ import { getRawFile, getTree, repoProvenance, resolveCommit } from "./sources/github.js";
9
+ import { decide } from "./verdict.js";
10
+ import { loadVet, saveVet } from "./vetCache.js";
11
+ /**
12
+ * Claude Code plugins bundle commands, agents, skills, hooks and MCP servers.
13
+ * Hooks run shell commands automatically on agent events, so every hook is
14
+ * surfaced as a finding and any plugin with hooks needs a human look.
15
+ */
16
+ const CODE_EXT = /\.(sh|bash|zsh|py|js|mjs|cjs|ts|rb|pl|php|ps1|bat|cmd)$/i;
17
+ const AUTO_EVENTS = /^(SessionStart|SessionEnd|UserPromptSubmit|PreToolUse|PostToolUse|Stop|SubagentStop|PreCompact|Notification)$/;
18
+ const PKG_RUNNERS = /^(npx|bunx|pnpx|uvx|pipx)$/;
19
+ export function parsePluginRef(input) {
20
+ const body = input.trim();
21
+ const m = body.match(/^([^/:@\s]+)\/([^/:@\s]+)(@[^\s]+)?$/);
22
+ if (m)
23
+ return parseSkillRef(`${m[1]}/${m[2]}:${m[3] ?? ""}`);
24
+ return parseSkillRef(body);
25
+ }
26
+ export async function fetchPlugin(ref) {
27
+ const sha = await resolveCommit(ref.owner, ref.repo, ref.ref);
28
+ const tree = await getTree(ref.owner, ref.repo, sha);
29
+ const path = ref.path ?? "";
30
+ const prefix = path ? path + "/" : "";
31
+ const inDir = tree.filter((e) => e.type === "blob" && e.path.startsWith(prefix) && !/(^|\/)(\.git|node_modules)\//.test(e.path));
32
+ const rel = (p) => p.slice(prefix.length);
33
+ const looksLikePlugin = inDir.some((e) => /^(\.claude-plugin\/plugin\.json|hooks\/hooks\.json|\.mcp\.json|(commands|agents|skills)\/)/.test(rel(e.path)));
34
+ if (!looksLikePlugin)
35
+ throw new Error(`No Claude Code plugin found at ${ref.owner}/${ref.repo}:${path || "(root)"}`);
36
+ const skipped = [];
37
+ const wanted = [];
38
+ let total = 0;
39
+ for (const e of inDir.sort((a, b) => a.path.localeCompare(b.path))) {
40
+ const r = rel(e.path);
41
+ if (wanted.length >= LIMITS.maxFiles)
42
+ skipped.push({ path: r, reason: "file count limit" });
43
+ else if ((e.size ?? 0) > LIMITS.maxFileBytes)
44
+ skipped.push({ path: r, reason: "file too large" });
45
+ else if (total + (e.size ?? 0) > LIMITS.maxTotalBytes)
46
+ skipped.push({ path: r, reason: "total size limit" });
47
+ else if (e.mode === "120000")
48
+ skipped.push({ path: r, reason: "symlink" });
49
+ else {
50
+ total += e.size ?? 0;
51
+ wanted.push(e);
52
+ }
53
+ }
54
+ const files = await mapLimit(wanted, 8, async (e) => {
55
+ const content = await getRawFile(ref.owner, ref.repo, sha, e.path, LIMITS.maxFileBytes);
56
+ return { path: rel(e.path), size: content.length, executable: e.mode === "100755", content };
57
+ });
58
+ return { sha, path, files, skipped, contentHash: hashFiles(files) };
59
+ }
60
+ function json(files, path) {
61
+ const f = files.find((x) => x.path === path);
62
+ if (!f)
63
+ return undefined;
64
+ try {
65
+ return JSON.parse(f.content.toString("utf8"));
66
+ }
67
+ catch {
68
+ return undefined;
69
+ }
70
+ }
71
+ export function extractHooks(doc, file) {
72
+ const root = doc?.hooks ?? doc;
73
+ if (!root || typeof root !== "object")
74
+ return [];
75
+ const out = [];
76
+ for (const [event, groups] of Object.entries(root)) {
77
+ if (!Array.isArray(groups))
78
+ continue;
79
+ for (const g of groups) {
80
+ for (const h of g?.hooks ?? []) {
81
+ if (h?.command)
82
+ out.push({ event, matcher: g.matcher, command: String(h.command), file });
83
+ }
84
+ }
85
+ }
86
+ return out;
87
+ }
88
+ export function analyzePlugin(files) {
89
+ const findings = [];
90
+ const reviewReasons = [];
91
+ const manifest = json(files, ".claude-plugin/plugin.json");
92
+ if (!manifest)
93
+ findings.push({ rule: "no-manifest", severity: "low", file: ".claude-plugin/plugin.json", message: "No plugin manifest; components are inferred from directories" });
94
+ // Hooks: default file plus any declared in the manifest.
95
+ const hookSources = [];
96
+ const hf = json(files, "hooks/hooks.json");
97
+ if (hf)
98
+ hookSources.push([hf, "hooks/hooks.json"]);
99
+ if (manifest?.hooks && typeof manifest.hooks === "object")
100
+ hookSources.push([manifest.hooks, ".claude-plugin/plugin.json"]);
101
+ if (typeof manifest?.hooks === "string") {
102
+ const p = String(manifest.hooks).replace(/^\.\//, "");
103
+ const d = json(files, p);
104
+ if (d)
105
+ hookSources.push([d, p]);
106
+ }
107
+ const hooks = hookSources.flatMap(([d, f]) => extractHooks(d, f));
108
+ for (const h of hooks) {
109
+ const auto = AUTO_EVENTS.test(h.event);
110
+ const remoteCode = /\b(npx|bunx|pnpx|uvx|pipx)\b[^;&|]*(git\+|https?:\/\/)|\b(curl|wget)\b[^;&]*\|\s*(ba|z)?sh\b/i.test(h.command);
111
+ const net = remoteCode || /\b(curl|wget|ncat|ssh|scp)\b|\bnc\s|https?:\/\//i.test(h.command);
112
+ findings.push({
113
+ rule: remoteCode ? "hook-remote-code" : net ? "hook-network" : "plugin-hook",
114
+ severity: net ? "high" : "medium",
115
+ file: h.file,
116
+ message: `Runs a shell command automatically on ${h.event}${h.matcher ? ` (matcher: ${sanitize(h.matcher, 40)})` : ""}${auto ? "" : " (unrecognized event)"}${remoteCode ? ", downloading and running code that is not pinned" : net ? " and it uses the network" : ""}`,
117
+ excerpt: sanitize(h.command, 120),
118
+ });
119
+ }
120
+ if (hooks.length)
121
+ reviewReasons.push(`Plugin defines ${hooks.length} hook command(s) that run automatically without asking.`);
122
+ // MCP servers bundled with the plugin.
123
+ const mcpDoc = (json(files, ".mcp.json") ?? (typeof manifest?.mcpServers === "object" ? { mcpServers: manifest.mcpServers } : undefined));
124
+ const servers = Object.entries(mcpDoc?.mcpServers ?? mcpDoc ?? {});
125
+ for (const [name, cfg] of servers) {
126
+ if (!cfg || typeof cfg !== "object")
127
+ continue;
128
+ if (cfg.command && PKG_RUNNERS.test(cfg.command)) {
129
+ const pkgArg = (cfg.args ?? []).find((a) => !String(a).startsWith("-"));
130
+ if (pkgArg && !/@\d|==\d|@sha|:\d/.test(String(pkgArg).replace(/^@[^/]+\//, ""))) {
131
+ findings.push({ rule: "unpinned-mcp-package", severity: "medium", file: ".mcp.json", message: `MCP server "${sanitize(name, 40)}" runs an unpinned package; it can change after vetting`, excerpt: sanitize(pkgArg, 80) });
132
+ }
133
+ }
134
+ if (cfg.url)
135
+ reviewReasons.push(`Bundles remote MCP server "${sanitize(name, 40)}" (${sanitize(cfg.url, 80)}), not vetted here; vet it with vet_mcp_server if it is in the registry.`);
136
+ }
137
+ if (manifest?.dependencies)
138
+ reviewReasons.push("Plugin declares dependencies on other plugins, which are installed automatically and are not vetted here.");
139
+ return {
140
+ findings,
141
+ reviewReasons,
142
+ name: typeof manifest?.name === "string" ? manifest.name : undefined,
143
+ description: typeof manifest?.description === "string" ? manifest.description : undefined,
144
+ hooks,
145
+ mcpServers: servers.map(([n]) => n),
146
+ };
147
+ }
148
+ /** Parts of a plugin Claude Code loads or runs; findings elsewhere are capped. */
149
+ const PLUGIN_LOADED = /^(commands|agents|skills|hooks|scripts|bin|\.claude-plugin|output-styles)\/|^\.mcp\.json$/;
150
+ export function adjustForPlugin(f) {
151
+ if (/^(tests?|__tests__|spec|docs?|examples?|\.github)\//.test(f.file))
152
+ return capFinding(f, "tests or docs");
153
+ if (/\.(md|mdx|markdown|txt)$/i.test(f.file) && !PLUGIN_LOADED.test(f.file))
154
+ return capFinding(f, "documentation");
155
+ return f;
156
+ }
157
+ export async function vetPlugin(ref, opts = {}) {
158
+ const id = `${ref.owner}/${ref.repo}:${ref.path ?? ""}`;
159
+ const sha = await resolveCommit(ref.owner, ref.repo, ref.ref);
160
+ if (!opts.refresh) {
161
+ const cached = await loadVet("plugin", id, sha);
162
+ if (cached)
163
+ return cached;
164
+ }
165
+ const fetched = await fetchPlugin({ ...ref, ref: sha });
166
+ const a = analyzePlugin(fetched.files);
167
+ const staticFindings = [...a.findings, ...scanFiles(fetched.files).map(adjustForPlugin)];
168
+ for (const s of fetched.skipped)
169
+ staticFindings.push({ rule: "not-scanned", severity: "medium", file: s.path, message: `Not scanned: ${s.reason}` });
170
+ const name = sanitize(a.name ?? (ref.path?.split("/").pop() || ref.repo), 80);
171
+ const description = sanitize(a.description ?? "", 1200);
172
+ const codeFiles = fetched.files.filter((f) => f.executable || CODE_EXT.test(f.path));
173
+ const [llm, provenance] = await Promise.all([
174
+ llmReview({ kind: "plugin", name, description, files: fetched.files }),
175
+ repoProvenance(ref.owner, ref.repo),
176
+ ]);
177
+ if (a.mcpServers.length)
178
+ provenance.notes.push(`Bundles MCP server(s): ${a.mcpServers.map((n) => sanitize(n, 40)).join(", ")}.`);
179
+ const { verdict, risk, reasons } = decide({
180
+ staticFindings,
181
+ llm,
182
+ partnerAudits: [],
183
+ hasCode: codeFiles.length > 0 || a.hooks.length > 0 || a.mcpServers.length > 0,
184
+ codeNote: `${codeFiles.length} code file(s), ${a.hooks.length} hook(s), ${a.mcpServers.length} MCP server(s)`,
185
+ reviewReasons: a.reviewReasons,
186
+ });
187
+ const result = {
188
+ kind: "plugin",
189
+ id,
190
+ source: `${ref.owner}/${ref.repo}`,
191
+ path: fetched.path,
192
+ sha: fetched.sha,
193
+ contentHash: fetched.contentHash,
194
+ name,
195
+ description,
196
+ verdict,
197
+ risk,
198
+ reasons,
199
+ staticFindings: [...staticFindings, ...(llm.findings ?? [])],
200
+ llm: { ...llm, findings: undefined },
201
+ partnerAudits: [],
202
+ provenance,
203
+ files: fetched.files.map((f) => ({ path: f.path, size: f.size, executable: f.executable })),
204
+ skipped: fetched.skipped,
205
+ vettedAt: new Date().toISOString(),
206
+ };
207
+ await saveVet(result);
208
+ return result;
209
+ }
210
+ /** Write a vetted plugin's exact files into a directory (used by install). */
211
+ export async function writePluginFiles(files, dest) {
212
+ await rm(dest, { recursive: true, force: true });
213
+ for (const f of files) {
214
+ const target = join(dest, f.path);
215
+ if (!target.startsWith(dest + "/"))
216
+ throw new Error(`Path escapes plugin directory: ${f.path}`);
217
+ await mkdir(dirname(target), { recursive: true });
218
+ await writeFile(target, f.content, { mode: f.executable ? 0o755 : 0o644 });
219
+ }
220
+ }
221
+ //# sourceMappingURL=vetPlugin.js.map
@@ -0,0 +1,75 @@
1
+ import { fetchSkill, parseFrontmatter } from "./fetchSkill.js";
2
+ import { refId } from "./ref.js";
3
+ import { sanitize } from "./sanitize.js";
4
+ import { llmReview } from "./scan/llm.js";
5
+ import { scanFiles } from "./scan/rules.js";
6
+ import { repoProvenance, resolveCommit } from "./sources/github.js";
7
+ import { partnerAudits } from "./sources/skillssh.js";
8
+ import { decide } from "./verdict.js";
9
+ import { loadVet, saveVet } from "./vetCache.js";
10
+ const CODE_EXT = /\.(sh|bash|zsh|fish|py|js|mjs|cjs|ts|rb|pl|php|ps1|bat|cmd|go|rs|lua)$/i;
11
+ /**
12
+ * `fetched` is undefined on a cache hit: a commit is immutable, so a verdict for
13
+ * the same id + commit + path is reused without downloading anything.
14
+ * install_skill always re-downloads and checks the content hash.
15
+ */
16
+ export async function vetSkill(ref, opts = {}) {
17
+ const id = refId(ref);
18
+ if (!opts.refresh) {
19
+ const sha = await resolveCommit(ref.owner, ref.repo, ref.ref);
20
+ const cached = await loadVet("skill", id, sha);
21
+ if (cached && (ref.path === undefined || ref.path === cached.path))
22
+ return { result: cached };
23
+ ref = { ...ref, ref: sha }; // pin so the download below matches the commit we looked up
24
+ }
25
+ const fetched = await fetchSkill(ref);
26
+ const skillMd = fetched.files.find((f) => f.path === "SKILL.md");
27
+ const fm = skillMd ? parseFrontmatter(skillMd.content.toString("utf8")) : {};
28
+ const name = sanitize(fm.name ?? ref.skill, 100);
29
+ const description = sanitize(fm.description ?? "", 1200);
30
+ const staticFindings = scanFiles(fetched.files);
31
+ for (const s of fetched.skipped) {
32
+ staticFindings.push({ rule: "not-scanned", severity: "medium", file: s.path, message: `Not scanned: ${s.reason}` });
33
+ }
34
+ const codeFiles = fetched.files.filter((f) => f.executable || CODE_EXT.test(f.path)).map((f) => f.path);
35
+ const hasCode = codeFiles.length > 0;
36
+ const codeNote = `${codeFiles.length} code file(s) that run or get copied into your project, e.g. ${codeFiles.slice(0, 2).join(", ")}`;
37
+ const [llm, audits, provenance] = await Promise.all([
38
+ llmReview({ kind: "skill", name, description, files: fetched.files }),
39
+ partnerAudits(`${ref.owner}/${ref.repo}`, ref.skill),
40
+ repoProvenance(ref.owner, ref.repo),
41
+ ]);
42
+ if (audits.length) {
43
+ provenance.notes.push("Partner audits (skills.sh) apply to the version skills.sh indexed, which may differ from this commit.");
44
+ }
45
+ const { verdict, risk, reasons } = decide({
46
+ staticFindings,
47
+ llm,
48
+ partnerAudits: audits,
49
+ hasCode,
50
+ codeNote,
51
+ });
52
+ const result = {
53
+ kind: "skill",
54
+ id,
55
+ source: `${ref.owner}/${ref.repo}`,
56
+ path: fetched.path,
57
+ sha: fetched.sha,
58
+ contentHash: fetched.contentHash,
59
+ name,
60
+ description,
61
+ verdict,
62
+ risk,
63
+ reasons,
64
+ staticFindings: [...staticFindings, ...(llm.findings ?? [])],
65
+ llm: { ...llm, findings: undefined },
66
+ partnerAudits: audits,
67
+ provenance,
68
+ files: fetched.files.map((f) => ({ path: f.path, size: f.size, executable: f.executable })),
69
+ skipped: fetched.skipped,
70
+ vettedAt: new Date().toISOString(),
71
+ };
72
+ await saveVet(result);
73
+ return { result, fetched };
74
+ }
75
+ //# sourceMappingURL=vetSkill.js.map
package/package.json CHANGED
@@ -1,6 +1,56 @@
1
1
  {
2
2
  "name": "skillscout",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Find, security-vet and pin-install Claude Code skills, MCP servers and plugins for a project",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "build": "tsc",
8
+ "dev": "tsx src/index.ts",
9
+ "typecheck": "tsc --noEmit",
10
+ "test": "vitest run",
11
+ "eval": "tsx eval/run.ts"
12
+ },
13
+ "keywords": [
14
+ "mcp",
15
+ "claude-code",
16
+ "skills",
17
+ "security",
18
+ "mcp-server"
19
+ ],
20
+ "license": "MIT",
21
+ "type": "module",
22
+ "dependencies": {
23
+ "@anthropic-ai/sdk": "^1.16.0",
24
+ "@modelcontextprotocol/sdk": "^1.32.2",
25
+ "semver": "^7.8.6",
26
+ "undici": "^8.14.0",
27
+ "yaml": "^2.9.1",
28
+ "zod": "^4.6.7"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^26.6.11",
32
+ "@types/semver": "^7.8.0",
33
+ "tsx": "^4.23.15",
34
+ "typescript": "^7.0.2",
35
+ "vitest": "^5.1.2"
36
+ },
37
+ "bin": {
38
+ "skillscout": "dist/index.js"
39
+ },
40
+ "engines": {
41
+ "node": ">=22"
42
+ },
43
+ "mcpName": "io.github.ThomasXin50/skillscout",
44
+ "files": [
45
+ "dist/**/*.js",
46
+ "skills"
47
+ ],
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "git+https://github.com/ThomasXin50/skillscout.git"
51
+ },
52
+ "homepage": "https://github.com/ThomasXin50/skillscout#readme",
53
+ "bugs": {
54
+ "url": "https://github.com/ThomasXin50/skillscout/issues"
55
+ }
56
+ }