Repository navigation
Expand file tree
/
Copy pathvalidate-plugins.js
More file actions
54 lines (50 loc) · 1.63 KB
/
Copy pathvalidate-plugins.js
File metadata and controls
54 lines (50 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env node
const fs = require("fs");
const path = require("path");
const root = process.cwd();
const pluginDir = path.join(root, "plugins", "lightspeed-github-ops");
const manifests = [
".codex-plugin/plugin.json",
".claude-plugin/plugin.json",
"copilot-plugin.json",
];
const errors = [];
if (!fs.existsSync(pluginDir)) {
errors.push("Missing plugin directory: plugins/lightspeed-github-ops");
} else {
for (const manifest of manifests) {
const manifestPath = path.join(pluginDir, manifest);
if (!fs.existsSync(manifestPath)) {
errors.push(
`Missing plugin manifest: plugins/lightspeed-github-ops/${manifest}`,
);
continue;
}
const data = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
const refs = [];
if (Array.isArray(data.skills)) refs.push(...data.skills);
if (Array.isArray(data.agents)) refs.push(...data.agents);
if (data.includes) {
if (Array.isArray(data.includes.skills))
refs.push(...data.includes.skills);
if (Array.isArray(data.includes.agents))
refs.push(...data.includes.agents);
}
for (const ref of refs) {
if (ref.startsWith("/") || ref.includes("..")) {
errors.push(`Unsafe manifest path in ${manifest}: ${ref}`);
continue;
}
const resolved = path.join(pluginDir, ref);
if (!fs.existsSync(resolved)) {
errors.push(`Missing referenced plugin file in ${manifest}: ${ref}`);
}
}
}
}
if (errors.length) {
console.error("Plugin validation failed:");
for (const error of errors) console.error(`- ${error}`);
process.exit(1);
}
console.log("Plugin validation passed.");