mirror of
https://github.com/waybarrios/opencode-power-pack.git
synced 2026-11-18 18:03:43 +00:00
- add native Claude Code plugin and marketplace manifests - document Claude Code installation, invocation, updates, and removal - reduce routing metadata and enforce a catalog budget - validate Agent Skills and Claude manifests in CI - remove wooyun-legacy from the package and provenance - update package metadata and tests for the 54-skill catalog
71 lines
2.4 KiB
JavaScript
71 lines
2.4 KiB
JavaScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { readdirSync, readFileSync, existsSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
|
|
const REPO = process.env.REPO || process.cwd();
|
|
const NAME_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
const SENTENCE_END = /[.!?"'\)\]]$/;
|
|
|
|
function parse(md) {
|
|
const m = md.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/);
|
|
const fm = {};
|
|
if (m) {
|
|
for (const line of m[1].split(/\r?\n/)) {
|
|
const i = line.indexOf(":");
|
|
if (i > 0) fm[line.slice(0, i).trim()] = line.slice(i + 1).trim();
|
|
}
|
|
}
|
|
return { fm, body: m ? m[2] : md, hasFrontmatter: !!m };
|
|
}
|
|
|
|
const skillsDir = join(REPO, "skills");
|
|
const names = readdirSync(skillsDir).filter((n) =>
|
|
existsSync(join(skillsDir, n, "SKILL.md"))
|
|
);
|
|
let catalogMetadataCharacters = 0;
|
|
|
|
for (const name of names) {
|
|
const skill = parse(readFileSync(join(skillsDir, name, "SKILL.md"), "utf8"));
|
|
|
|
test(`${name}: SKILL.md frontmatter`, () => {
|
|
assert.ok(skill.hasFrontmatter, "has YAML frontmatter");
|
|
assert.equal(skill.fm.name, name, "name matches the directory");
|
|
assert.match(skill.fm.name ?? "", NAME_RE, "name matches the slug regex");
|
|
const d = skill.fm.description ?? "";
|
|
assert.ok(d.length >= 1 && d.length <= 600, `description length 1..600 (is ${d.length})`);
|
|
assert.ok((skill.fm.license ?? "").length > 0, "license present");
|
|
});
|
|
|
|
catalogMetadataCharacters += name.length + (skill.fm.description ?? "").length;
|
|
|
|
test(`${name}: SKILL.md body under 500 lines`, () => {
|
|
assert.ok(skill.body.split(/\r?\n/).length < 500);
|
|
});
|
|
|
|
test(`${name}: descriptions not truncated`, () => {
|
|
assert.match((skill.fm.description ?? "").trim(), SENTENCE_END, "SKILL.md description not truncated");
|
|
});
|
|
|
|
test(`${name}: no duplicated block`, () => {
|
|
const check = (label, text) => {
|
|
const seen = new Set();
|
|
for (const raw of text.split(/\r?\n/)) {
|
|
const line = raw.replace(/\s+$/, "");
|
|
if (line.trim().length >= 50) {
|
|
assert.ok(!seen.has(line), `${label} repeats a line verbatim: "${line.slice(0, 60)}..."`);
|
|
seen.add(line);
|
|
}
|
|
}
|
|
};
|
|
check("SKILL.md", readFileSync(join(skillsDir, name, "SKILL.md"), "utf8"));
|
|
});
|
|
}
|
|
|
|
test("skill catalog stays within the phase-one routing budget", () => {
|
|
assert.ok(
|
|
catalogMetadataCharacters <= 15_500,
|
|
`name and description metadata is ${catalogMetadataCharacters} characters (budget 15500)`,
|
|
);
|
|
});
|