@bitget-ai/bitget-agent-skill 3.3.1 → 4.0.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.
@@ -1,21 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Bitget Skill Installer
3
+ * Bitget Agentic Skill Installer
4
4
  *
5
- * Usage (run explicitly — no postinstall side effects):
6
- * npx bitget-agent-skill # default: uta skill, Claude Code only
7
- * npx bitget-agent-skill --interactive # prompt to choose targets
8
- * npx bitget-agent-skill --target all # install to all supported tools
9
- * npx bitget-agent-skill --target claude # Claude Code only
10
- * npx bitget-agent-skill --target codex # Codex only
11
- * npx bitget-agent-skill --target openclaw # OpenClaw only
12
- * npx bitget-agent-skill --target claude,codex # multiple targets
13
- * npx bitget-agent-skill --skill agentic # install the Agentic (OAuth) skill instead
14
- * npx bitget-agent-skill --skill uta,agentic # install both skills
15
- * npx bitget-agent-skill --skill all # install all skills
5
+ * Copies the `bitget-agentic` skill directory (SKILL.md and its references/)
6
+ * into an AI tool's skills directory. No runtime, no API keys, no network access.
7
+ *
8
+ * Usage:
9
+ * npx @bitget-ai/bitget-agent-skill # Claude Code
10
+ * npx @bitget-ai/bitget-agent-skill --target all # every supported tool
11
+ * npx @bitget-ai/bitget-agent-skill --target codex,cursor # specific tools
12
+ * npx @bitget-ai/bitget-agent-skill --interactive # prompt to choose
16
13
  */
17
14
 
18
- import { copyFileSync, mkdirSync, existsSync, readdirSync } from "node:fs";
15
+ import { cpSync, mkdirSync, existsSync, rmSync } from "node:fs";
19
16
  import { join, dirname } from "node:path";
20
17
  import { fileURLToPath } from "node:url";
21
18
  import { homedir } from "node:os";
@@ -25,31 +22,12 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
25
22
  const PKG_ROOT = join(__dirname, "..");
26
23
  const HOME = homedir();
27
24
 
28
- // Installable skills — each copies its own SKILL.md (and optional reference
29
- // files) into a per-skill subdirectory under the AI tool's skills root.
30
- const SKILLS = {
31
- uta: {
32
- label: "UTA trading (manual API key)",
33
- skillSrcDir: join(PKG_ROOT, "skills", "uta"),
34
- skillDirName: "bitget-agent-skill",
35
- refFiles: [
36
- "commands.md",
37
- "discover-guide.md",
38
- "trading-safety.md",
39
- "error-codes.md",
40
- "auth-setup.md",
41
- "demo-trading.md",
42
- ],
43
- },
44
- agentic: {
45
- label: "Agentic sub-account (OAuth)",
46
- skillSrcDir: join(PKG_ROOT, "skills", "agentic"),
47
- skillDirName: "bitget-agentic",
48
- refFiles: [],
49
- },
50
- };
25
+ const SKILL_NAME = "bitget-agentic";
26
+ const SKILL_SRC_DIR = join(PKG_ROOT, "skills", SKILL_NAME);
27
+ const DEFAULT_TARGET = "claude";
51
28
 
52
- // Skill destinations per AI tool
29
+ // Skill destinations per AI tool. Codex reads user skills from ~/.agents/skills,
30
+ // a location Cursor and OpenClaw also read.
53
31
  const TARGETS = {
54
32
  claude: {
55
33
  label: "Claude Code",
@@ -57,7 +35,14 @@ const TARGETS = {
57
35
  },
58
36
  codex: {
59
37
  label: "Codex",
60
- skillsRoot: join(HOME, ".codex", "skills"),
38
+ skillsRoot: join(HOME, ".agents", "skills"),
39
+ // Older Codex versions read ~/.codex/skills. Refresh a copy that an earlier
40
+ // version of this installer put there, so it does not go stale.
41
+ legacySkillsRoot: join(HOME, ".codex", "skills"),
42
+ },
43
+ cursor: {
44
+ label: "Cursor",
45
+ skillsRoot: join(HOME, ".cursor", "skills"),
61
46
  },
62
47
  openclaw: {
63
48
  label: "OpenClaw",
@@ -65,34 +50,52 @@ const TARGETS = {
65
50
  },
66
51
  };
67
52
 
68
- function installTo(targetKey, skillKey) {
69
- const target = TARGETS[targetKey];
70
- const skill = SKILLS[skillKey];
71
- const skillDir = join(target.skillsRoot, skill.skillDirName);
72
- const refsDir = join(skillDir, "references");
53
+ // Skill folders installed by earlier versions that this version replaces.
54
+ // They are reported, never deleted: they live in the user's own directory.
55
+ const OBSOLETE_SKILL_DIRS = {
56
+ "bitget-agent-skill":
57
+ "the old local API-key skill (bgc). It is discontinued and can conflict with this one",
58
+ "bitget-agentic-connect":
59
+ "the old first-time connect guide. It is now part of bitget-agentic and its copy is out of date",
60
+ };
61
+
62
+ function copySkill(skillsRoot) {
63
+ const dest = join(skillsRoot, SKILL_NAME);
64
+ mkdirSync(skillsRoot, { recursive: true });
65
+ // Replace the whole folder so files removed in a newer version do not linger.
66
+ rmSync(dest, { recursive: true, force: true });
67
+ cpSync(SKILL_SRC_DIR, dest, { recursive: true });
68
+ return dest;
69
+ }
73
70
 
74
- mkdirSync(skillDir, { recursive: true });
71
+ function installTo(targetKey) {
72
+ const target = TARGETS[targetKey];
73
+ const dest = copySkill(target.skillsRoot);
74
+ console.log(` ✓ ${target.label} → ${join(dest, "SKILL.md")}`);
75
75
 
76
- const skillSrc = join(skill.skillSrcDir, "SKILL.md");
77
- copyFileSync(skillSrc, join(skillDir, "SKILL.md"));
76
+ if (target.legacySkillsRoot && existsSync(join(target.legacySkillsRoot, SKILL_NAME))) {
77
+ const legacyDest = copySkill(target.legacySkillsRoot);
78
+ console.log(` ✓ ${target.label} (older location) → ${join(legacyDest, "SKILL.md")}`);
79
+ }
80
+ }
78
81
 
79
- if (skill.refFiles.length > 0) {
80
- mkdirSync(refsDir, { recursive: true });
81
- for (const f of skill.refFiles) {
82
- const src = join(PKG_ROOT, "references", f);
83
- if (existsSync(src)) {
84
- copyFileSync(src, join(refsDir, f));
82
+ function reportObsolete(targetKey) {
83
+ const target = TARGETS[targetKey];
84
+ const roots = [target.skillsRoot, target.legacySkillsRoot].filter(Boolean);
85
+ for (const root of roots) {
86
+ for (const [dirName, why] of Object.entries(OBSOLETE_SKILL_DIRS)) {
87
+ const dir = join(root, dirName);
88
+ if (existsSync(dir)) {
89
+ console.log(`\nNote: ${dir} is ${why}. Remove that directory.`);
85
90
  }
86
91
  }
87
92
  }
88
-
89
- console.log(` ✓ ${target.label} (${skill.label}) → ${join(skillDir, "SKILL.md")}`);
90
93
  }
91
94
 
92
95
  async function promptTargets() {
93
96
  const rl = createInterface({ input: process.stdin, output: process.stdout });
94
97
 
95
- console.log("\nBitget Skill — choose installation targets:\n");
98
+ console.log("\nBitget Agentic skill — choose installation targets:\n");
96
99
  const keys = Object.keys(TARGETS);
97
100
  keys.forEach((k, i) => {
98
101
  console.log(` ${i + 1}. ${TARGETS[k].label} (${TARGETS[k].skillsRoot})`);
@@ -101,105 +104,102 @@ async function promptTargets() {
101
104
  console.log();
102
105
 
103
106
  return new Promise((resolve) => {
104
- rl.question(
105
- `Enter numbers separated by commas [default: 1]: `,
106
- (answer) => {
107
- rl.close();
108
- const trimmed = answer.trim();
109
- if (!trimmed || trimmed === "1") {
110
- resolve(["claude"]);
111
- return;
112
- }
113
- if (trimmed === String(keys.length + 1)) {
114
- resolve(keys);
115
- return;
116
- }
117
- const selected = trimmed
118
- .split(",")
119
- .map((s) => parseInt(s.trim(), 10) - 1)
120
- .filter((i) => i >= 0 && i < keys.length)
121
- .map((i) => keys[i]);
122
- resolve(selected.length > 0 ? selected : ["claude"]);
107
+ rl.question(`Enter numbers separated by commas [default: 1]: `, (answer) => {
108
+ rl.close();
109
+ const trimmed = answer.trim();
110
+ if (!trimmed || trimmed === "1") {
111
+ resolve([DEFAULT_TARGET]);
112
+ return;
123
113
  }
124
- );
114
+ if (trimmed === String(keys.length + 1)) {
115
+ resolve(keys);
116
+ return;
117
+ }
118
+ const selected = trimmed
119
+ .split(",")
120
+ .map((s) => parseInt(s.trim(), 10) - 1)
121
+ .filter((i) => i >= 0 && i < keys.length)
122
+ .map((i) => keys[i]);
123
+ resolve(selected.length > 0 ? selected : [DEFAULT_TARGET]);
124
+ });
125
125
  });
126
126
  }
127
127
 
128
- function parseListFlag(args, name, validKeys) {
128
+ function flagValue(args, name) {
129
129
  const arg = args.find((a) => a.startsWith(`--${name}=`) || a === `--${name}`);
130
130
  if (!arg) return null;
131
- const value =
132
- arg === `--${name}` ? args[args.indexOf(`--${name}`) + 1] : arg.split("=")[1];
131
+ return arg === `--${name}` ? args[args.indexOf(`--${name}`) + 1] || null : arg.split("=")[1] || null;
132
+ }
133
+
134
+ function parseTargets(args) {
135
+ const value = flagValue(args, "target");
133
136
  if (!value) return null;
134
- if (value === "all") return Object.keys(validKeys);
137
+ if (value === "all") return Object.keys(TARGETS);
135
138
  const keys = value
136
139
  .split(",")
137
140
  .map((s) => s.trim())
138
- .filter((k) => k in validKeys);
141
+ .filter((k) => k in TARGETS);
139
142
  if (keys.length === 0) {
143
+ console.warn(`Unknown target(s): ${value}. Valid: ${Object.keys(TARGETS).join(", ")}, all`);
144
+ process.exit(1);
145
+ }
146
+ return keys;
147
+ }
148
+
149
+ // --skill is no longer needed: the package ships one skill. It is still
150
+ // accepted so that commands from older guides keep working.
151
+ function handleDeprecatedSkillFlag(args) {
152
+ const value = flagValue(args, "skill");
153
+ if (!value) return;
154
+ const requested = value.split(",").map((s) => s.trim());
155
+ if (requested.includes("uta")) {
140
156
  console.warn(
141
- `Unknown ${name}(s): ${value}. Valid: ${Object.keys(validKeys).join(", ")}, all`
157
+ "The local API-key skill (uta, driven by the bgc CLI) was removed in 4.0.0 and is " +
158
+ "no longer supported. Run again without --skill to install the cloud MCP skill."
142
159
  );
143
160
  process.exit(1);
144
161
  }
145
- return keys;
162
+ console.log(`Note: --skill is no longer needed and is ignored; installing ${SKILL_NAME}.`);
146
163
  }
147
164
 
148
165
  async function main() {
149
166
  const args = process.argv.slice(2);
150
- const isInteractive = args.includes("--interactive");
151
- const targetValue = parseListFlag(args, "target", TARGETS);
152
- const skillValue = parseListFlag(args, "skill", SKILLS);
153
-
154
- let selectedTargetKeys;
155
- const selectedSkillKeys = skillValue || ["uta"];
167
+ handleDeprecatedSkillFlag(args);
156
168
 
157
- if (isInteractive) {
158
- // Interactive mode — prompt user
169
+ let targetKeys;
170
+ if (args.includes("--interactive")) {
159
171
  try {
160
- selectedTargetKeys = await promptTargets();
172
+ targetKeys = await promptTargets();
161
173
  } catch {
162
- selectedTargetKeys = ["claude"];
174
+ targetKeys = [DEFAULT_TARGET];
163
175
  }
164
- } else if (targetValue) {
165
- selectedTargetKeys = targetValue;
166
176
  } else {
167
- // Default postinstall: Claude Code, uta skill only, silent on failure
168
- try {
169
- installTo("claude", "uta");
170
- } catch (err) {
171
- console.warn("Could not auto-install skill:", err.message);
172
- }
173
- return;
177
+ targetKeys = parseTargets(args) || [DEFAULT_TARGET];
174
178
  }
175
179
 
176
- console.log("\nInstalling Bitget skill...");
180
+ console.log("\nInstalling the Bitget Agentic skill...");
177
181
  let ok = 0;
178
- const total = selectedTargetKeys.length * selectedSkillKeys.length;
179
- for (const targetKey of selectedTargetKeys) {
180
- for (const skillKey of selectedSkillKeys) {
181
- try {
182
- installTo(targetKey, skillKey);
183
- ok++;
184
- } catch (err) {
185
- console.warn(` ✗ ${TARGETS[targetKey].label} (${SKILLS[skillKey].label}): ${err.message}`);
186
- }
182
+ for (const targetKey of targetKeys) {
183
+ try {
184
+ installTo(targetKey);
185
+ ok++;
186
+ } catch (err) {
187
+ console.warn(` ✗ ${TARGETS[targetKey].label}: ${err.message}`);
187
188
  }
188
189
  }
189
- console.log(`\nDone — installed ${ok} of ${total} target/skill combinations.`);
190
+ console.log(`\nDone — installed to ${ok} of ${targetKeys.length} target(s).`);
190
191
 
191
- if (selectedTargetKeys.includes("claude")) {
192
- console.log(
193
- "\nClaude Code: restart Claude Code to pick up the skill, or run:\n" +
194
- " claude skills list"
195
- );
196
- }
197
- if (selectedTargetKeys.includes("codex")) {
198
- console.log("\nCodex: skill will be loaded automatically from ~/.codex/skills/");
199
- }
200
- if (selectedTargetKeys.includes("openclaw")) {
201
- console.log("\nOpenClaw: skill will be loaded automatically from ~/.openclaw/skills/");
192
+ for (const targetKey of targetKeys) reportObsolete(targetKey);
193
+
194
+ if (targetKeys.includes("claude")) {
195
+ console.log("\nClaude Code: restart Claude Code to pick up the skill.");
202
196
  }
197
+ console.log(
198
+ "\nNext: ask your AI agent to read the installed SKILL.md and connect " +
199
+ "https://agent.bitget.com/mcp."
200
+ );
201
+
202
+ if (ok < targetKeys.length) process.exit(1);
203
203
  }
204
204
 
205
205
  main();
@@ -0,0 +1,240 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Validates every skill under skills/ against the Agent Skills specification
4
+ * (https://agentskills.io/specification) and the authoring limits this repo
5
+ * holds itself to. Exits non-zero on any error, so it can gate build and publish.
6
+ *
7
+ * Usage: node scripts/validate-skills.mjs
8
+ *
9
+ * The frontmatter parser is deliberately small: it accepts only top-level
10
+ * `key: value`, folded `key: >` blocks, and one flat `metadata:` map of quoted
11
+ * strings. Anything else is reported, which is how the "metadata is a map of
12
+ * string keys to string values" rule is enforced.
13
+ */
14
+
15
+ import { readFileSync, readdirSync, existsSync, statSync } from "node:fs";
16
+ import { join, dirname, relative, resolve, sep } from "node:path";
17
+ import { fileURLToPath } from "node:url";
18
+
19
+ const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
20
+ const SKILLS_DIR = join(ROOT, "skills");
21
+
22
+ // Fields accepted by every Agent Skills host. Host-specific fields would make
23
+ // the skill fail to load elsewhere.
24
+ const ALLOWED_KEYS = new Set([
25
+ "name",
26
+ "description",
27
+ "license",
28
+ "compatibility",
29
+ "metadata",
30
+ "allowed-tools",
31
+ ]);
32
+ const NAME_MAX = 64;
33
+ const DESCRIPTION_MAX = 1024;
34
+ const COMPATIBILITY_MAX = 500;
35
+ const BODY_MAX_LINES = 500;
36
+ // The spec recommends under 5000 tokens. Roughly 4 characters per token.
37
+ const BODY_MAX_TOKENS = 5000;
38
+ const CHARS_PER_TOKEN = 4;
39
+ // Reference files longer than this need a contents list at the top.
40
+ const REFERENCE_TOC_LINES = 100;
41
+ const RESERVED_NAME_WORDS = ["anthropic", "claude"];
42
+
43
+ function unquote(value) {
44
+ const v = value.trim();
45
+ if (v.length >= 2 && (v[0] === '"' || v[0] === "'") && v[v.length - 1] === v[0]) {
46
+ return { text: v.slice(1, -1), quoted: true };
47
+ }
48
+ return { text: v, quoted: false };
49
+ }
50
+
51
+ function parseFrontmatter(source, errors) {
52
+ if (!source.startsWith("---\n")) {
53
+ errors.push("SKILL.md must start with a `---` frontmatter line");
54
+ return null;
55
+ }
56
+ const end = source.indexOf("\n---", 4);
57
+ if (end === -1) {
58
+ errors.push("frontmatter is not closed with `---`");
59
+ return null;
60
+ }
61
+ const lines = source.slice(4, end).split("\n");
62
+ const body = source.slice(end + 4).replace(/^\n/, "");
63
+ const fields = {};
64
+
65
+ for (let i = 0; i < lines.length; i++) {
66
+ const line = lines[i];
67
+ if (!line.trim()) continue;
68
+ const top = /^([A-Za-z][\w-]*):(.*)$/.exec(line);
69
+ if (!top) {
70
+ errors.push(`frontmatter line ${i + 2} is not a top-level \`key: value\`: ${line.trim()}`);
71
+ continue;
72
+ }
73
+ const [, key, rest] = top;
74
+ const value = rest.trim();
75
+
76
+ const collectIndented = () => {
77
+ const block = [];
78
+ while (i + 1 < lines.length && (/^\s+\S/.test(lines[i + 1]) || !lines[i + 1].trim())) {
79
+ block.push(lines[++i]);
80
+ }
81
+ return block;
82
+ };
83
+
84
+ if (value === ">" || value === ">-" || value === "|" || value === "|-") {
85
+ const block = collectIndented().map((l) => l.trim());
86
+ fields[key] = value.startsWith(">") ? block.filter(Boolean).join(" ") : block.join("\n");
87
+ } else if (value === "") {
88
+ const map = {};
89
+ for (const entry of collectIndented()) {
90
+ if (!entry.trim()) continue;
91
+ const m = /^ {2}([A-Za-z][\w-]*):\s*(.+)$/.exec(entry);
92
+ if (!m) {
93
+ errors.push(`\`${key}\` must be a flat map of \`key: "string"\` pairs; found: ${entry.trim()}`);
94
+ continue;
95
+ }
96
+ const { text, quoted } = unquote(m[2]);
97
+ if (!quoted) {
98
+ errors.push(`\`${key}.${m[1]}\` must be a quoted string so YAML cannot read it as a number or date`);
99
+ }
100
+ map[m[1]] = text;
101
+ }
102
+ fields[key] = map;
103
+ } else {
104
+ fields[key] = unquote(value).text;
105
+ }
106
+ }
107
+ return { fields, body };
108
+ }
109
+
110
+ function validateSkill(dirName) {
111
+ const errors = [];
112
+ const skillDir = join(SKILLS_DIR, dirName);
113
+ const skillFile = join(skillDir, "SKILL.md");
114
+ if (!existsSync(skillFile)) {
115
+ return [`missing SKILL.md`];
116
+ }
117
+ const source = readFileSync(skillFile, "utf8");
118
+ const parsed = parseFrontmatter(source, errors);
119
+ if (!parsed) return errors;
120
+ const { fields, body } = parsed;
121
+
122
+ for (const key of Object.keys(fields)) {
123
+ if (!ALLOWED_KEYS.has(key)) {
124
+ errors.push(`frontmatter field \`${key}\` is not in the Agent Skills spec (${[...ALLOWED_KEYS].join(", ")})`);
125
+ }
126
+ }
127
+
128
+ // name
129
+ const name = fields.name;
130
+ if (typeof name !== "string" || !name) {
131
+ errors.push("`name` is required");
132
+ } else {
133
+ if (name.length > NAME_MAX) errors.push(`\`name\` is ${name.length} characters (max ${NAME_MAX})`);
134
+ if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(name)) {
135
+ errors.push("`name` may contain only lowercase letters, digits, and single hyphens, and cannot start or end with a hyphen");
136
+ }
137
+ if (name !== dirName) errors.push(`\`name\` (${name}) must match the directory name (${dirName})`);
138
+ for (const word of RESERVED_NAME_WORDS) {
139
+ if (name.includes(word)) errors.push(`\`name\` cannot contain the reserved word "${word}"`);
140
+ }
141
+ }
142
+
143
+ // description
144
+ const description = fields.description;
145
+ if (typeof description !== "string" || !description) {
146
+ errors.push("`description` is required");
147
+ } else {
148
+ if (description.length > DESCRIPTION_MAX) {
149
+ errors.push(`\`description\` is ${description.length} characters (max ${DESCRIPTION_MAX})`);
150
+ }
151
+ if (/[<>]/.test(description)) errors.push("`description` cannot contain `<` or `>`");
152
+ }
153
+
154
+ if (typeof fields.compatibility === "string" && fields.compatibility.length > COMPATIBILITY_MAX) {
155
+ errors.push(`\`compatibility\` is ${fields.compatibility.length} characters (max ${COMPATIBILITY_MAX})`);
156
+ }
157
+ if ("metadata" in fields && (typeof fields.metadata !== "object" || fields.metadata === null)) {
158
+ errors.push("`metadata` must be a map of string keys to string values");
159
+ }
160
+
161
+ // body size
162
+ const bodyLines = body.split("\n").length;
163
+ const bodyTokens = Math.ceil(body.length / CHARS_PER_TOKEN);
164
+ if (bodyLines > BODY_MAX_LINES) errors.push(`SKILL.md body is ${bodyLines} lines (max ${BODY_MAX_LINES})`);
165
+ if (bodyTokens > BODY_MAX_TOKENS) {
166
+ errors.push(`SKILL.md body is about ${bodyTokens} tokens (max ${BODY_MAX_TOKENS}); move detail into references/`);
167
+ }
168
+
169
+ // links from SKILL.md: relative, forward slashes, inside the skill, existing
170
+ const linked = new Set();
171
+ for (const m of body.matchAll(/\]\(([^)\s]+)\)/g)) {
172
+ const target = m[1].split("#")[0];
173
+ if (!target || /^[a-z][a-z0-9+.-]*:/i.test(target)) continue; // external or anchor
174
+ if (target.includes("\\")) errors.push(`link \`${target}\` uses a backslash; use forward slashes`);
175
+ const abs = resolve(skillDir, target);
176
+ if (abs !== skillDir && !abs.startsWith(skillDir + sep)) {
177
+ errors.push(`link \`${target}\` points outside the skill directory`);
178
+ } else if (!existsSync(abs)) {
179
+ errors.push(`link \`${target}\` does not resolve to a file`);
180
+ } else {
181
+ linked.add(abs);
182
+ }
183
+ }
184
+
185
+ // every reference file is reachable from SKILL.md (one level deep)
186
+ const refsDir = join(skillDir, "references");
187
+ if (existsSync(refsDir)) {
188
+ for (const entry of readdirSync(refsDir)) {
189
+ const abs = join(refsDir, entry);
190
+ if (statSync(abs).isDirectory()) {
191
+ errors.push(`references/${entry}/ is nested; keep reference files one level deep`);
192
+ continue;
193
+ }
194
+ const rel = relative(skillDir, abs).split(sep).join("/");
195
+ if (!linked.has(abs)) errors.push(`${rel} is not linked from SKILL.md, so an agent cannot discover it`);
196
+ const text = readFileSync(abs, "utf8");
197
+ if (text.split("\n").length > REFERENCE_TOC_LINES && !/^## Contents\s*$/m.test(text)) {
198
+ errors.push(`${rel} is over ${REFERENCE_TOC_LINES} lines and needs a "## Contents" list at the top`);
199
+ }
200
+ }
201
+ }
202
+
203
+ if (!errors.length) {
204
+ console.log(
205
+ ` ✓ ${dirName}: description ${description.length}/${DESCRIPTION_MAX} chars, ` +
206
+ `body ${bodyLines} lines, about ${bodyTokens} tokens`
207
+ );
208
+ }
209
+ return errors;
210
+ }
211
+
212
+ function main() {
213
+ if (!existsSync(SKILLS_DIR)) {
214
+ console.error("skills/ directory not found");
215
+ process.exit(1);
216
+ }
217
+ const dirs = readdirSync(SKILLS_DIR).filter((d) => statSync(join(SKILLS_DIR, d)).isDirectory());
218
+ if (dirs.length === 0) {
219
+ console.error("no skills found under skills/");
220
+ process.exit(1);
221
+ }
222
+
223
+ console.log("Validating skills against the Agent Skills specification...");
224
+ let failed = 0;
225
+ for (const dir of dirs) {
226
+ const errors = validateSkill(dir);
227
+ if (errors.length) {
228
+ failed++;
229
+ console.error(` ✗ ${dir}`);
230
+ for (const e of errors) console.error(` - ${e}`);
231
+ }
232
+ }
233
+ if (failed) {
234
+ console.error(`\n${failed} of ${dirs.length} skill(s) failed validation.`);
235
+ process.exit(1);
236
+ }
237
+ console.log(`\nAll ${dirs.length} skill(s) are valid.`);
238
+ }
239
+
240
+ main();