-
Notifications
You must be signed in to change notification settings - Fork 0
158 lines (144 loc) · 6.43 KB
/
verify-pack.yml
File metadata and controls
158 lines (144 loc) · 6.43 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: verify-pack
on:
push:
pull_request:
jobs:
verify:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Verify manifest structure and skill paths
run: |
node -e '
const fs = require("fs");
const path = require("path");
const fail = (message) => {
console.error(message);
process.exit(1);
};
const manifest = JSON.parse(fs.readFileSync("skills-pack.json", "utf8"));
if (!manifest.name || typeof manifest.name !== "string") {
fail("Manifest is missing a valid pack name.");
}
if (!manifest.default_install || typeof manifest.default_install !== "string") {
fail("Manifest is missing a valid default_install command.");
}
if (!Array.isArray(manifest.skills) || manifest.skills.length === 0) {
fail("Manifest must define at least one canonical skill.");
}
const canonicalNames = new Set(manifest.skills.map((skill) => skill.name));
const seenNames = new Set();
const readFrontmatterName = (skillFile) => {
const content = fs.readFileSync(skillFile, "utf8");
const frontmatter = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
if (!frontmatter) {
fail(`Missing frontmatter in ${skillFile}`);
}
const nameMatch = frontmatter[1].match(/^name:\s*(.+)$/m);
if (!nameMatch) {
fail(`Missing frontmatter name in ${skillFile}`);
}
return nameMatch[1].trim().replace(/^["'']|["'']$/g, "");
};
for (const skill of manifest.skills) {
if (!skill.name || !skill.path) {
fail(`Canonical skill entry is missing required fields: ${JSON.stringify(skill)}`);
}
if (seenNames.has(skill.name)) {
fail(`Duplicate manifest entry for skill: ${skill.name}`);
}
seenNames.add(skill.name);
const skillPath = path.resolve(skill.path);
const skillFile = path.join(skillPath, "SKILL.md");
if (!fs.existsSync(skillPath) || !fs.statSync(skillPath).isDirectory()) {
fail(`Canonical skill path does not exist: ${skill.path}`);
}
if (!fs.existsSync(skillFile)) {
fail(`Canonical skill is missing SKILL.md: ${skill.path}`);
}
const frontmatterName = readFrontmatterName(skillFile);
if (frontmatterName !== skill.name) {
fail(`Manifest name/path mismatch for ${skill.name}; SKILL.md declares ${frontmatterName}`);
}
}
if (manifest.aliases && !Array.isArray(manifest.aliases)) {
fail("Manifest aliases must be an array when present.");
}
'
- name: Verify discovery output matches manifest
run: |
OUTPUT="$(npx skills add . --list --full-depth)"
echo "$OUTPUT"
OUTPUT="$OUTPUT" node -e '
const fs = require("fs");
const manifest = JSON.parse(fs.readFileSync("skills-pack.json", "utf8"));
const names = manifest.skills.map((skill) => skill.name);
const output = process.env.OUTPUT ?? "";
const missing = names.filter((name) => !output.includes(name));
if (missing.length) {
console.error("Missing skills in discovery output:", missing.join(", "));
process.exit(1);
}
const unexpected = (output.match(/^\s*[A-Za-z0-9-]+$/gm) ?? [])
.map((line) => line.trim())
.filter((line) => line && !["Available Skills", "Use --skill <name> to install specific skills"].includes(line))
.filter((line) => !names.includes(line));
if (unexpected.length) {
console.error("Unexpected skills in discovery output:", unexpected.join(", "));
process.exit(1);
}
'
- name: Verify isolated --all install
env:
PACK_SOURCE: ${{ github.workspace }}
run: |
TMP_DIR="$(mktemp -d)"
pushd "$TMP_DIR" >/dev/null
npx skills add "$PACK_SOURCE" -y --all --copy
popd >/dev/null
TMP_DIR="$TMP_DIR" node -e '
const fs = require("fs");
const path = require("path");
const manifest = JSON.parse(fs.readFileSync("skills-pack.json", "utf8"));
const expected = manifest.skills.map((skill) => skill.name).sort();
const installedDir = path.join(process.env.TMP_DIR, ".agents", "skills");
const installed = fs.readdirSync(installedDir, { withFileTypes: true })
.filter((entry) => entry.isDirectory())
.map((entry) => entry.name)
.sort();
if (JSON.stringify(installed) !== JSON.stringify(expected)) {
console.error("Installed skills did not match manifest.");
console.error("Expected:", expected.join(", "));
console.error("Actual:", installed.join(", "));
process.exit(1);
}
'
- name: Verify README stays aligned with pack surface
run: |
node -e '
const fs = require("fs");
const manifest = JSON.parse(fs.readFileSync("skills-pack.json", "utf8"));
const readme = fs.readFileSync("README.md", "utf8");
const names = manifest.skills.map((skill) => skill.name);
for (const skillName of names) {
const installNeedle = `--skill ${skillName}`;
const commandNeedle = `\`$${skillName}\``;
if (!readme.includes(installNeedle)) {
console.error(`README is missing install command for ${skillName}`);
process.exit(1);
}
if (!readme.includes(commandNeedle)) {
console.error(`README is missing command table entry for ${skillName}`);
process.exit(1);
}
}
if (readme.includes("virus-scan")) {
console.error("README still contains removed skill name: virus-scan");
process.exit(1);
}
'