@uinaf/skillcheck 1.7.3 → 1.7.4

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.
package/dist/lint.js CHANGED
@@ -1,4 +1,4 @@
1
- import { FILE_BLOCK } from "./scenario.js";
1
+ import { FILE_BLOCK, isHiddenSkill, parseCriteria } from "./scenario.js";
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  //#region src/lint.ts
@@ -71,20 +71,31 @@ function lintSkills(root) {
71
71
  skills.push(path.join(dir, entry.name));
72
72
  }
73
73
  }
74
- lintTasks(skills, root, errors);
74
+ lintEvals(skills, root, errors);
75
75
  return {
76
76
  errors,
77
77
  count: skills.length
78
78
  };
79
79
  }
80
- function lintTasks(skills, root, errors) {
80
+ function lintEvals(skills, root, errors) {
81
81
  const names = skills.map((dir) => path.basename(dir));
82
82
  for (const dir of skills) {
83
83
  const evals = path.join(dir, "evals");
84
84
  if (!fs.existsSync(evals)) continue;
85
+ const skillMd = path.join(dir, "SKILL.md");
86
+ const hidden = fs.existsSync(skillMd) && isHiddenSkill(fs.readFileSync(skillMd, "utf8"));
85
87
  for (const scenario of fs.readdirSync(evals, { withFileTypes: true })) {
86
- const file = path.join(evals, scenario.name, "task.md");
87
- if (!scenario.isDirectory() || !fs.existsSync(file)) continue;
88
+ if (!scenario.isDirectory()) continue;
89
+ const scenarioDir = path.join(evals, scenario.name);
90
+ const criteria = path.join(scenarioDir, "criteria.json");
91
+ if (fs.existsSync(criteria)) try {
92
+ parseCriteria(scenarioDir, hidden);
93
+ } catch (err) {
94
+ const message = err instanceof Error ? err.message : String(err);
95
+ errors.push(`${path.relative(root, criteria)}: ${message}`);
96
+ }
97
+ const file = path.join(scenarioDir, "task.md");
98
+ if (!fs.existsSync(file)) continue;
88
99
  const text = fs.readFileSync(file, "utf8").replace(FILE_BLOCK, "");
89
100
  for (const name of names) {
90
101
  const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
package/dist/scenario.js CHANGED
@@ -12,14 +12,16 @@ function loadScenario(scenarioDir) {
12
12
  if (!match) throw new Error(`not a scenario dir (want .../skills/<skill>/evals/<scenario>): ${scenarioDir}`);
13
13
  const [, skill, scenario] = match;
14
14
  const taskMd = fs.readFileSync(path.join(scenarioDir, "task.md"), "utf8");
15
- const criteria = JSON.parse(fs.readFileSync(path.join(scenarioDir, "criteria.json"), "utf8"));
16
- if (criteria.type !== "weighted_checklist" || !Array.isArray(criteria.checklist) || criteria.checklist.length === 0) throw new Error(`unsupported or empty criteria in ${scenarioDir}`);
17
- if (criteria.skill_use !== void 0 && ![
18
- "required",
19
- "optional",
20
- "forbidden"
21
- ].includes(criteria.skill_use)) throw new Error(`skill_use must be "required", "optional", or "forbidden" in ${scenarioDir}`);
22
- for (const item of criteria.checklist) if (!(typeof item?.name === "string" && item.name.trim() !== "" && typeof item?.description === "string" && item.description.trim() !== "" && Number.isFinite(item?.max_score) && item.max_score > 0)) throw new Error(`invalid checklist item in ${scenarioDir}: ${JSON.stringify(item)}`);
15
+ const skillDir = path.resolve(scenarioDir, "../..");
16
+ const hidden = isHiddenSkill(fs.readFileSync(path.join(skillDir, "SKILL.md"), "utf8"));
17
+ let parsed;
18
+ try {
19
+ parsed = parseCriteria(scenarioDir, hidden);
20
+ } catch (err) {
21
+ const message = err instanceof Error ? err.message : String(err);
22
+ throw new Error(`${path.join(scenarioDir, "criteria.json")}: ${message}`, { cause: err });
23
+ }
24
+ const { criteria, alternatives } = parsed;
23
25
  const files = [];
24
26
  const task = taskMd.replace(FILE_BLOCK, (_, name, content) => {
25
27
  files.push({
@@ -28,13 +30,7 @@ function loadScenario(scenarioDir) {
28
30
  });
29
31
  return `(Input file \`${name.trim()}\` is available in your working directory.)`;
30
32
  });
31
- let prompt = task;
32
- const skillDir = path.resolve(scenarioDir, "../..");
33
- if (isHiddenSkill(fs.readFileSync(path.join(skillDir, "SKILL.md"), "utf8"))) {
34
- if (criteria.skill_use === "forbidden" || criteria.install !== void 0) throw new Error(`a hidden skill is always invoked, so it has no routing to test: ${scenarioDir}`);
35
- prompt = `Use the ${skill} skill for this task.\n\n${prompt}`;
36
- }
37
- const alternatives = resolveInstall(skillDir, criteria.install, scenarioDir);
33
+ const prompt = hidden ? `Use the ${skill} skill for this task.\n\n${task}` : task;
38
34
  return {
39
35
  skill,
40
36
  scenario,
@@ -47,7 +43,37 @@ function loadScenario(scenarioDir) {
47
43
  criteria
48
44
  };
49
45
  }
50
- function resolveInstall(skillDir, install, scenarioDir) {
46
+ function parseCriteria(scenarioDir, hidden) {
47
+ const text = fs.readFileSync(path.join(scenarioDir, "criteria.json"), "utf8");
48
+ let criteria;
49
+ try {
50
+ criteria = JSON.parse(text);
51
+ } catch (err) {
52
+ throw new Error(`not valid JSON: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
53
+ }
54
+ if (typeof criteria !== "object" || criteria === null || Array.isArray(criteria)) throw new Error("must be a JSON object");
55
+ if (criteria.type !== "weighted_checklist") throw new Error(`type must be "weighted_checklist", got ${JSON.stringify(criteria.type)}`);
56
+ if (!Array.isArray(criteria.checklist) || criteria.checklist.length === 0) throw new Error("checklist must be a non-empty array");
57
+ if (criteria.skill_use !== void 0 && ![
58
+ "required",
59
+ "optional",
60
+ "forbidden"
61
+ ].includes(criteria.skill_use)) throw new Error(`skill_use must be "required", "optional", or "forbidden"`);
62
+ for (const [i, item] of criteria.checklist.entries()) {
63
+ for (const key of ["name", "description"]) {
64
+ const value = item?.[key];
65
+ if (typeof value !== "string" || value.trim() === "") throw new Error(`checklist[${i}].${key} must be a non-empty string`);
66
+ }
67
+ if (!Number.isFinite(item.max_score) || item.max_score <= 0) throw new Error(`checklist[${i}].max_score must be a positive number`);
68
+ }
69
+ if (hidden && (criteria.skill_use === "forbidden" || criteria.install !== void 0)) throw new Error("a hidden skill is always invoked, so it has no routing to test");
70
+ const alternatives = resolveInstall(path.resolve(scenarioDir, "../.."), criteria.install);
71
+ return {
72
+ criteria,
73
+ alternatives
74
+ };
75
+ }
76
+ function resolveInstall(skillDir, install) {
51
77
  if (install === void 0) return [];
52
78
  const skillsRoot = path.dirname(skillDir);
53
79
  const self = path.basename(skillDir);
@@ -58,11 +84,11 @@ function resolveInstall(skillDir, install, scenarioDir) {
58
84
  };
59
85
  if (install === "all") {
60
86
  const all = fs.readdirSync(skillsRoot).filter(invocable).sort();
61
- if (all.length === 0) throw new Error(`install "all" finds no other model-invocable skill for ${scenarioDir}`);
87
+ if (all.length === 0) throw new Error(`install "all" finds no other model-invocable skill`);
62
88
  return all;
63
89
  }
64
- if (!Array.isArray(install) || install.length === 0) throw new Error(`install must be "all" or a non-empty list of skills in ${scenarioDir}`);
65
- for (const name of install) if (typeof name !== "string" || name.includes("/") || !invocable(name)) throw new Error(`install names ${JSON.stringify(name)}, not another model-invocable skill under the root, in ${scenarioDir}`);
90
+ if (!Array.isArray(install) || install.length === 0) throw new Error(`install must be "all" or a non-empty list of skills`);
91
+ for (const name of install) if (typeof name !== "string" || name.includes("/") || !invocable(name)) throw new Error(`install names ${JSON.stringify(name)}, not another model-invocable skill under the root`);
66
92
  return [...new Set(install)].sort();
67
93
  }
68
94
  function encodeRunNamePart(part) {
@@ -452,4 +478,4 @@ function generateRun(scenarioDir, opts, paths) {
452
478
  };
453
479
  }
454
480
  //#endregion
455
- export { DEFAULT_CLAUDE_AGENT, FILE_BLOCK, buildConfig, encodeRunNamePart, generateRun, handOverToAgent, isHiddenSkill, isIsolated, linkedSiblings, loadScenario, materialize, privateCodexHome, privateHome, requiredEvalPackages, resolvePackageDir, runNameFor, sdkNodeModulesDir, stripHiddenFlag, trialLabel };
481
+ export { DEFAULT_CLAUDE_AGENT, FILE_BLOCK, buildConfig, encodeRunNamePart, generateRun, handOverToAgent, isHiddenSkill, isIsolated, linkedSiblings, loadScenario, materialize, parseCriteria, privateCodexHome, privateHome, requiredEvalPackages, resolvePackageDir, runNameFor, sdkNodeModulesDir, stripHiddenFlag, trialLabel };
package/docs/scenarios.md CHANGED
@@ -51,6 +51,8 @@ its steps, or hint at the checklist: routing is part of what is being measured.
51
51
 
52
52
  `type` must be `weighted_checklist` and the checklist must be non-empty. Every
53
53
  item needs a non-empty `name` and `description` and a positive `max_score`.
54
+ Weights are relative; no total is required. `skillcheck lint` applies these
55
+ checks and the `skill_use` and `install` rules below to every `criteria.json`.
54
56
 
55
57
  Each item becomes one `llm-rubric` assertion weighted by `max_score`, inside an
56
58
  assert-set with threshold 0.7. A separate `skill-used` assertion sits outside
package/docs/usage.md CHANGED
@@ -23,6 +23,9 @@ Checks each `<root>/skills/<skill>/`:
23
23
  - No eval `task.md` names a skill from the root, outside its inline input
24
24
  files. A named skill gives routing away, and a no-skill control can read
25
25
  the operator's installed copy
26
+ - Every eval `criteria.json` is valid JSON and meets the
27
+ [criteria contract](scenarios.md#criteriajson) `run` enforces before it
28
+ starts, so a broken file fails CI instead of stopping a sweep midway
26
29
 
27
30
  Code spans and fenced blocks are stripped before links are checked, so example
28
31
  links never fail. External schemes and `#anchors` pass. Dot-directories under
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uinaf/skillcheck",
3
- "version": "1.7.3",
3
+ "version": "1.7.4",
4
4
  "description": "Lint and eval harness for agent skills",
5
5
  "homepage": "https://github.com/uinaf/skillcheck#readme",
6
6
  "bugs": {