feat: mentor skill
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
6f576940b7
commit
88bcb965bf
@@ -0,0 +1,31 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { join, dirname } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const root = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
||||
const skill = readFileSync(join(root, "mentor", "SKILL.md"), "utf8");
|
||||
const catalog = JSON.parse(readFileSync(join(root, "course", "catalog.json"), "utf8"));
|
||||
const entries = Array.isArray(catalog) ? catalog : catalog.entries ?? Object.values(catalog);
|
||||
|
||||
test("mentor_skill_frontmatter_has_name_and_description", () => {
|
||||
const m = /^---\n([\s\S]*?)\n---\n/.exec(skill);
|
||||
assert.ok(m, "frontmatter present");
|
||||
assert.match(m[1], /^name: systemic-design-mentor$/m);
|
||||
assert.match(m[1], /^description: \S.{40,}/m);
|
||||
});
|
||||
|
||||
test("mentor_skill_names_no_module_specific_cards", () => {
|
||||
const META = new Set(["TEXT", "ALL", "EMPTY"]);
|
||||
const names = entries
|
||||
.filter((e) => e.kind === "card" || (e.kind === "word" && e.role === "noun" && !META.has(e.name)))
|
||||
.map((e) => ({ name: e.name, flags: e.kind === "card" ? "i" : "" })) // noun words are ALL CAPS; "Baba Is You" the title is fine
|
||||
.filter((n) => n.name.length >= 2);
|
||||
assert.ok(names.length > 10, "catalog has names to check");
|
||||
const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
const hits = names
|
||||
.filter((n) => new RegExp(`(?<![A-Za-z0-9_])${esc(n.name)}(?![A-Za-z0-9_])`, n.flags).test(skill))
|
||||
.map((n) => n.name);
|
||||
assert.deepEqual(hits, []);
|
||||
});
|
||||
Reference in New Issue
Block a user