@anhlp/alp-core 0.0.1-beta.7 → 0.0.1-beta.8

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.
Files changed (124) hide show
  1. package/dist/library-edit.d.ts +51 -2
  2. package/dist/library-edit.js +160 -8
  3. package/dist/library.d.ts +14 -1
  4. package/dist/library.js +73 -5
  5. package/dist/models.d.ts +35 -0
  6. package/dist/models.js +17 -1
  7. package/dist/packs.d.ts +57 -0
  8. package/dist/packs.js +247 -0
  9. package/dist/permissions.d.ts +3 -2
  10. package/dist/permissions.js +6 -3
  11. package/dist/profiles.js +3 -3
  12. package/dist/providers.d.ts +2 -4
  13. package/dist/providers.js +20 -4
  14. package/dist/skill-validate.d.ts +85 -0
  15. package/dist/skill-validate.js +298 -0
  16. package/dist/upgrade.d.ts +10 -0
  17. package/dist/upgrade.js +112 -6
  18. package/dist/validation.js +2 -3
  19. package/package.json +18 -2
  20. package/src/library-edit.js +170 -8
  21. package/src/library.js +96 -6
  22. package/src/models.js +24 -0
  23. package/src/packs.js +246 -0
  24. package/src/permissions.d.ts +3 -2
  25. package/src/permissions.js +13 -3
  26. package/src/profiles.js +4 -4
  27. package/src/providers.js +20 -5
  28. package/src/resolver.js +1 -1
  29. package/src/skill-validate.js +287 -0
  30. package/src/upgrade.js +54 -6
  31. package/src/validation.js +3 -4
  32. package/templates/ALP.md +52 -52
  33. package/templates/agents/lead/AGENT.md +77 -74
  34. package/templates/agents/main/AGENT.md +153 -145
  35. package/templates/agents/oracle/AGENT.md +38 -37
  36. package/templates/agents/peer/AGENT.md +56 -52
  37. package/templates/agents/reviewer/AGENT.md +63 -65
  38. package/templates/agents/supervisor/AGENT.md +63 -63
  39. package/templates/packs/architecture/agents/architect/AGENT.md +41 -0
  40. package/templates/packs/architecture/agents/architect/agent.json +5 -0
  41. package/templates/packs/architecture/agents/docs-maintainer/AGENT.md +33 -0
  42. package/templates/packs/architecture/agents/docs-maintainer/agent.json +4 -0
  43. package/templates/packs/architecture/pack.json +7 -0
  44. package/templates/packs/architecture/teams/blueprint/HOUSE_RULES.md +12 -0
  45. package/templates/packs/architecture/teams/blueprint/team.json +19 -0
  46. package/templates/packs/backend/pack.json +6 -0
  47. package/templates/packs/backend/skills/backend-development/SKILL.md +102 -0
  48. package/templates/packs/backend/skills/backend-development/references/api-design.md +96 -0
  49. package/templates/packs/backend/skills/backend-development/references/authentication.md +78 -0
  50. package/templates/packs/backend/skills/backend-development/references/error-handling.md +86 -0
  51. package/templates/packs/backend/skills/backend-development/references/testing.md +81 -0
  52. package/templates/packs/backend/skills/databases/SKILL.md +103 -0
  53. package/templates/packs/backend/skills/databases/references/query-performance.md +87 -0
  54. package/templates/packs/backend/skills/databases/references/schema-and-migrations.md +87 -0
  55. package/templates/packs/design/pack.json +6 -0
  56. package/templates/packs/design/skills/ui-design/SKILL.md +86 -0
  57. package/templates/packs/design/skills/ui-design/references/design-tokens.md +67 -0
  58. package/templates/packs/design/skills/ui-design/references/interaction-states.md +73 -0
  59. package/templates/packs/design/skills/ui-design/references/layout-and-typography.md +71 -0
  60. package/templates/packs/design/skills/ui-design/references/ui-review.md +83 -0
  61. package/templates/packs/frontend/pack.json +6 -0
  62. package/templates/packs/frontend/skills/frontend-development/SKILL.md +105 -0
  63. package/templates/packs/frontend/skills/frontend-development/references/accessibility.md +86 -0
  64. package/templates/packs/frontend/skills/frontend-development/references/components-and-state.md +79 -0
  65. package/templates/packs/frontend/skills/frontend-development/references/data-fetching.md +86 -0
  66. package/templates/packs/frontend/skills/frontend-development/references/frameworks.md +77 -0
  67. package/templates/packs/frontend/skills/frontend-development/references/performance.md +78 -0
  68. package/templates/packs/integration/pack.json +6 -0
  69. package/templates/packs/integration/skills/mcp-integration/SKILL.md +100 -0
  70. package/templates/packs/integration/skills/mcp-integration/references/server-implementation.md +95 -0
  71. package/templates/packs/integration/skills/mcp-integration/references/testing.md +78 -0
  72. package/templates/packs/integration/skills/mcp-integration/references/tool-design.md +97 -0
  73. package/templates/packs/operations/pack.json +6 -0
  74. package/templates/packs/operations/skills/devops/SKILL.md +85 -0
  75. package/templates/packs/operations/skills/devops/references/ci-cd.md +84 -0
  76. package/templates/packs/operations/skills/devops/references/containers.md +85 -0
  77. package/templates/packs/operations/skills/devops/references/deployment-and-rollback.md +85 -0
  78. package/templates/packs/operations/skills/devops/references/observability.md +86 -0
  79. package/templates/packs/quality/pack.json +6 -0
  80. package/templates/packs/quality/skills/web-testing/SKILL.md +102 -0
  81. package/templates/packs/quality/skills/web-testing/references/e2e.md +85 -0
  82. package/templates/packs/quality/skills/web-testing/references/performance-testing.md +85 -0
  83. package/templates/packs/quality/skills/web-testing/references/security-testing.md +78 -0
  84. package/templates/packs/quality/skills/web-testing/references/unit-and-component.md +78 -0
  85. package/templates/role-skills.json +4 -4
  86. package/templates/skills/architecture-docs/SKILL.md +81 -0
  87. package/templates/skills/architecture-docs/references/adr.md +62 -0
  88. package/templates/skills/architecture-docs/references/diagrams.md +60 -0
  89. package/templates/skills/architecture-docs/references/evidence-rules.md +49 -0
  90. package/templates/skills/bug-loop/SKILL.md +41 -40
  91. package/templates/skills/bug-loop/references/test-proof.md +21 -19
  92. package/templates/skills/compact/SKILL.md +2 -2
  93. package/templates/skills/curate/SKILL.md +6 -5
  94. package/templates/skills/feature-architecture/SKILL.md +90 -0
  95. package/templates/skills/feature-architecture/references/architecture-contract.md +95 -0
  96. package/templates/skills/feature-architecture/references/feature-design.md +69 -0
  97. package/templates/skills/feature-architecture/scripts/check-boundaries.mjs +270 -0
  98. package/templates/skills/goal-griller/SKILL.md +27 -27
  99. package/templates/skills/prompt-leverage/SKILL.md +29 -27
  100. package/templates/skills/prompt-leverage/references/brief-template.md +9 -9
  101. package/templates/skills/release-readiness/SKILL.md +83 -0
  102. package/templates/skills/release-readiness/references/checklist.md +40 -0
  103. package/templates/skills/release-readiness/references/verdict-template.md +53 -0
  104. package/templates/skills/safe-refactor/SKILL.md +84 -0
  105. package/templates/skills/safe-refactor/references/characterization-tests.md +57 -0
  106. package/templates/skills/safe-refactor/references/compatibility-checklist.md +56 -0
  107. package/templates/skills/security-review/SKILL.md +87 -0
  108. package/templates/skills/security-review/references/checklist.md +74 -0
  109. package/templates/skills/security-review/references/severity.md +61 -0
  110. package/templates/skills/sequence-execution-plan/SKILL.md +41 -38
  111. package/templates/skills/sequence-execution-plan/references/plan-template.md +5 -5
  112. package/templates/skills/skill-authoring/SKILL.md +84 -0
  113. package/templates/skills/skill-authoring/references/evaluation.md +45 -0
  114. package/templates/skills/skill-authoring/references/skill-anatomy.md +74 -0
  115. package/templates/skills/skill-authoring/references/trigger-design.md +52 -0
  116. package/templates/skills/smart-commits/SKILL.md +37 -36
  117. package/templates/skills/test-strategy/SKILL.md +83 -0
  118. package/templates/skills/test-strategy/references/contract-tests.md +46 -0
  119. package/templates/skills/test-strategy/references/risk-matrix.md +53 -0
  120. package/templates/skills/xia/SKILL.md +40 -38
  121. package/templates/teams/cafe/HOUSE_RULES.md +1 -1
  122. package/templates/teams/cafe/team.json +1 -1
  123. package/templates/teams/pho/HOUSE_RULES.md +1 -1
  124. package/templates/teams/pho/team.json +1 -1
@@ -0,0 +1,298 @@
1
+ // packages/core/src/skill-validate.js
2
+ import { lstat, readFile, readdir, realpath, stat } from "node:fs/promises";
3
+ import path from "node:path";
4
+ var SPEC_KEYS = ["name", "description", "license", "compatibility", "metadata", "allowed-tools"];
5
+ var RUNTIME_KEYS = ["argument-hint", "disable-model-invocation", "user-invocable", "model", "version", "when_to_use", "mode"];
6
+ var NAME_MAX = 64;
7
+ var DESCRIPTION_MAX = 1024;
8
+ var INDEX_DESCRIPTION_CHARS = 400;
9
+ var COMPATIBILITY_MAX = 500;
10
+ var BODY_LINES_RECOMMENDED = 500;
11
+ var MAX_FILES = 2e3;
12
+ var NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
13
+ var TRIGGER_RE = /\b(use|when|before|after|whenever|for)\b|dùng|khi/i;
14
+ var specName = (name) => typeof name === "string" && name.length >= 1 && name.length <= NAME_MAX && NAME_RE.test(name);
15
+ function doubleQuoted(raw) {
16
+ try {
17
+ return JSON.parse(`"${raw.replace(/\\'/g, "'")}"`);
18
+ } catch {
19
+ return void 0;
20
+ }
21
+ }
22
+ function parseFrontmatter(text) {
23
+ const lines = text.split(/\r?\n/);
24
+ const data = {};
25
+ const problems = [];
26
+ const indent = (line) => /^ */.exec(line)[0].length;
27
+ let i = 0;
28
+ const scalar = (raw, key, baseIndent) => {
29
+ const value = raw.trim();
30
+ if (!value) {
31
+ const nested = {};
32
+ let found = false;
33
+ while (i < lines.length && (lines[i].trim() === "" || lines[i].trimStart().startsWith("#") || indent(lines[i]) > baseIndent)) {
34
+ const line = lines[i++];
35
+ if (!line.trim() || line.trimStart().startsWith("#")) continue;
36
+ const match = /^\s+([^:#\s][^:]*?):(?:\s+(.*)|\s*)$/.exec(line);
37
+ if (!match) {
38
+ problems.push(`${key}: unsupported YAML in '${line.trim()}' (use "key: value" lines)`);
39
+ continue;
40
+ }
41
+ found = true;
42
+ nested[match[1].trim()] = scalar(match[2] ?? "", `${key}.${match[1].trim()}`, indent(line));
43
+ }
44
+ return found ? nested : "";
45
+ }
46
+ if (value.startsWith('"')) {
47
+ const end = /^"((?:[^"\\]|\\.)*)"\s*(?:#.*)?$/.exec(value);
48
+ if (!end) {
49
+ problems.push(`${key}: unterminated or multi-line double-quoted value`);
50
+ return void 0;
51
+ }
52
+ const parsed = doubleQuoted(end[1]);
53
+ if (parsed === void 0) problems.push(`${key}: invalid escape in double-quoted value`);
54
+ return parsed;
55
+ }
56
+ if (value.startsWith("'")) {
57
+ const end = /^'((?:[^']|'')*)'\s*(?:#.*)?$/.exec(value);
58
+ if (!end) {
59
+ problems.push(`${key}: unterminated or multi-line single-quoted value`);
60
+ return void 0;
61
+ }
62
+ return end[1].replaceAll("''", "'");
63
+ }
64
+ const block = /^([|>])([+-]?)([1-9]?)([+-]?)\s*(?:#.*)?$/.exec(value);
65
+ if (block?.[3]) problems.push(`${key}: block scalar indentation indicators are not supported; indent the text instead`);
66
+ if (block) {
67
+ const body = [];
68
+ while (i < lines.length && (lines[i].trim() === "" || indent(lines[i]) > baseIndent)) body.push(lines[i++]);
69
+ while (body.length && !body[body.length - 1].trim()) body.pop();
70
+ const width = Math.min(...body.filter((line) => line.trim()).map(indent));
71
+ const content = body.map((line) => line.slice(Number.isFinite(width) ? width : 0));
72
+ const joined = block[1] === "|" ? content.join("\n") : content.join("\n").replace(/([^\n])\n(?=[^\n])/g, "$1 ");
73
+ return (block[2] || block[4]) === "-" ? joined : `${joined}
74
+ `;
75
+ }
76
+ if (/^[[{&*!%@`]/.test(value) || value.startsWith("- ")) {
77
+ problems.push(`${key}: unsupported YAML value '${value.slice(0, 40)}' (use a plain or quoted string)`);
78
+ return void 0;
79
+ }
80
+ let plain = value.replace(/\s+#.*$/, "");
81
+ while (i < lines.length && lines[i].trim() && indent(lines[i]) > baseIndent && !lines[i].trimStart().startsWith("#")) plain += ` ${lines[i++].trim()}`;
82
+ if (/:\s/.test(plain) || plain.endsWith(":")) problems.push(`${key}: plain value contains ": " which YAML rejects; quote the value`);
83
+ return plain;
84
+ };
85
+ while (i < lines.length) {
86
+ const line = lines[i++];
87
+ if (!line.trim() || line.trimStart().startsWith("#")) continue;
88
+ if (indent(line) > 0) {
89
+ problems.push(`unexpected indentation: '${line.trim().slice(0, 40)}'`);
90
+ continue;
91
+ }
92
+ const match = /^([^:#\s][^:]*?):(?:\s+(.*)|\s*)$/.exec(line);
93
+ if (!match) {
94
+ problems.push(`not a "key: value" line: '${line.trim().slice(0, 40)}'`);
95
+ continue;
96
+ }
97
+ const key = match[1].trim();
98
+ if (Object.hasOwn(data, key)) problems.push(`${key}: duplicate key`);
99
+ data[key] = scalar(match[2] ?? "", key, 0);
100
+ }
101
+ return { data, problems };
102
+ }
103
+ function splitSkill(text) {
104
+ const match = /^?---\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/.exec(text);
105
+ return match ? { frontmatter: match[1], body: text.slice(match[0].length) } : { frontmatter: void 0, body: text };
106
+ }
107
+ function skillReferences(markdown) {
108
+ const found = /* @__PURE__ */ new Set();
109
+ const withoutFences = markdown.replace(/^(```|~~~)[\s\S]*?^\1/gm, "");
110
+ for (const match of withoutFences.matchAll(/\]\(\s*<?([^)\s>]+)>?(?:\s+"[^"]*")?\s*\)/g)) found.add(match[1]);
111
+ for (const match of withoutFences.matchAll(/`([^`\s]+)`/g)) {
112
+ if (/^(?:\.\/)?references\/[^*<>{}$]+\.[a-z0-9]+$/i.test(match[1])) found.add(match[1]);
113
+ }
114
+ return [...found].filter((target) => !/^[a-z][\w+.-]*:/i.test(target) && !target.startsWith("#") && !target.startsWith("//")).map((target) => {
115
+ const plain = target.split("#")[0];
116
+ try {
117
+ return decodeURI(plain);
118
+ } catch {
119
+ return plain;
120
+ }
121
+ }).filter(Boolean);
122
+ }
123
+ var inside = (root, target) => {
124
+ const relative = path.relative(root, target);
125
+ return relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
126
+ };
127
+ function checkFrontmatter(frontmatter, directory, { strict = false } = {}) {
128
+ const findings = [];
129
+ const format = (code, message) => findings.push({ level: strict ? "error" : "warning", code, message });
130
+ const error = (code, message) => findings.push({ level: "error", code, message });
131
+ const warn = (code, message) => findings.push({ level: "warning", code, message });
132
+ if (frontmatter === void 0) {
133
+ format("NO_FRONTMATTER", 'SKILL.md has no YAML frontmatter; add "---\\nname: ...\\ndescription: ...\\n---" so agents see what the skill is for');
134
+ return { data: {}, findings };
135
+ }
136
+ const { data, problems } = parseFrontmatter(frontmatter);
137
+ for (const problem of problems) format("YAML", `frontmatter: ${problem}`);
138
+ const { name, description } = data;
139
+ if (name === void 0) format("NAME_MISSING", "frontmatter has no name");
140
+ else if (typeof name !== "string" || !specName(name)) format("NAME_FORMAT", `name '${name}' must be 1-${NAME_MAX} lowercase letters, digits and single hyphens, not starting or ending with one`);
141
+ if (typeof name === "string" && directory !== void 0 && name !== directory) format("NAME_DIRECTORY", `name '${name}' differs from its directory '${directory}'; agents find it by the directory name`);
142
+ if (directory !== void 0 && !specName(directory)) format("DIRECTORY_NAME", `directory '${directory}' is not a valid skill name; rename it to lowercase letters, digits and hyphens`);
143
+ if (description === void 0 || typeof description === "string" && !description.trim()) format("DESCRIPTION_MISSING", "frontmatter has no description: it is all an agent sees before opening the skill");
144
+ else if (typeof description !== "string") format("DESCRIPTION_FORMAT", "description must be text");
145
+ else {
146
+ const flat = description.replace(/\s+/g, " ").trim();
147
+ if (flat.length > DESCRIPTION_MAX) format("DESCRIPTION_LENGTH", `description has ${flat.length} characters; the limit is ${DESCRIPTION_MAX}`);
148
+ else if (flat.length > INDEX_DESCRIPTION_CHARS) warn("DESCRIPTION_CLIPPED", `description has ${flat.length} characters; ALP's skill index shows the first ${INDEX_DESCRIPTION_CHARS}`);
149
+ if (flat.length < 40) warn("DESCRIPTION_SHORT", "description is under 40 characters; say what the skill does and when to use it");
150
+ if (!TRIGGER_RE.test(flat)) warn("DESCRIPTION_TRIGGER", 'description does not say when to use the skill (for example "Use when ...")');
151
+ if (/[<>]/.test(flat)) format("DESCRIPTION_ANGLE", "description contains < or >, which some runtimes reject");
152
+ }
153
+ if (data.compatibility !== void 0 && (typeof data.compatibility !== "string" || data.compatibility.length > COMPATIBILITY_MAX)) format("COMPATIBILITY", `compatibility must be text of at most ${COMPATIBILITY_MAX} characters`);
154
+ if (data.license !== void 0 && typeof data.license !== "string") format("LICENSE", "license must be text");
155
+ if (data["allowed-tools"] !== void 0 && typeof data["allowed-tools"] !== "string") format("ALLOWED_TOOLS", "allowed-tools must be a space-separated string");
156
+ if (data["allowed-tools"] !== void 0) warn("ALLOWED_TOOLS_ADVISORY", "allowed-tools is advisory: ALP permissions come from the session mode and permission profiles, never from a skill");
157
+ if (data.metadata !== void 0 && (typeof data.metadata !== "object" || data.metadata === null || Object.values(data.metadata).some((value) => typeof value !== "string"))) format("METADATA", "metadata must map names to text values");
158
+ for (const key of Object.keys(data)) {
159
+ if (SPEC_KEYS.includes(key)) continue;
160
+ if (RUNTIME_KEYS.includes(key)) format("RUNTIME_KEY", `'${key}' is specific to one runtime; other runtimes ignore it`);
161
+ else format("UNKNOWN_KEY", `unknown frontmatter key '${key}'; the specification allows ${SPEC_KEYS.join(", ")}`);
162
+ }
163
+ return { data, findings };
164
+ }
165
+ var isText = (buffer) => !buffer.includes(0) && Buffer.from(buffer.toString("utf8"), "utf8").equals(buffer);
166
+ async function validateSkill(directory, { mode = "legacy", shipped = false } = {}) {
167
+ const root = path.resolve(directory);
168
+ const strict = mode === "strict";
169
+ const findings = [];
170
+ const add = (level, code, message, file) => findings.push({ level, code, message, ...file ? { file } : {} });
171
+ const format = (code, message, file) => add(strict ? "error" : "warning", code, message, file);
172
+ const result = () => {
173
+ const errors = findings.filter((f) => f.level === "error").map(({ level, ...f }) => f);
174
+ const warnings = findings.filter((f) => f.level === "warning").map(({ level, ...f }) => f);
175
+ return { name: path.basename(root), directory: root, mode, ok: errors.length === 0, errors, warnings, files };
176
+ };
177
+ let files = 0;
178
+ const info = await lstat(root).catch(() => void 0);
179
+ if (!info) {
180
+ add("error", "NOT_FOUND", `no skill directory at ${root}`);
181
+ return result();
182
+ }
183
+ if (info.isSymbolicLink()) add("warning", "DIRECTORY_LINK", "the skill directory is a symbolic link; its contents are checked where it points");
184
+ const real = await realpath(root).catch(() => root);
185
+ if (!await stat(real).then((s) => s.isDirectory(), () => false)) {
186
+ add("error", "NOT_DIRECTORY", `${root} is not a directory`);
187
+ return result();
188
+ }
189
+ const markdown = [];
190
+ let stopped = false;
191
+ const walk = async (relative) => {
192
+ let entries;
193
+ try {
194
+ entries = await readdir(path.join(real, relative), { withFileTypes: true });
195
+ } catch (error) {
196
+ add("error", "UNREADABLE", `${relative || "."} cannot be read: ${error.code ?? error.message}`, relative || void 0);
197
+ return;
198
+ }
199
+ for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
200
+ if (stopped) return;
201
+ const rel = path.join(relative, entry.name);
202
+ const full = path.join(real, rel);
203
+ if (++files > MAX_FILES) {
204
+ stopped = true;
205
+ add("error", "TOO_MANY_FILES", `more than ${MAX_FILES} files; a skill should hold instructions and small resources`);
206
+ return;
207
+ }
208
+ if (entry.name === "node_modules" || entry.name === ".git") {
209
+ add("warning", "BUNDLED_DEPENDENCIES", `${rel} is bundled; skills must not carry installed dependencies or repositories`, rel);
210
+ continue;
211
+ }
212
+ if (entry.isSymbolicLink()) {
213
+ const target = await realpath(full).catch(() => void 0);
214
+ if (target === void 0) add("error", "BROKEN_SYMLINK", `${rel} is a symbolic link to nothing`, rel);
215
+ else if (!inside(real, target)) add("error", "UNSAFE_SYMLINK", `${rel} links outside the skill (${target})`, rel);
216
+ else if (shipped) add("error", "SHIPPED_SYMLINK", `${rel} is a symbolic link; shipped skills hold plain files`, rel);
217
+ continue;
218
+ }
219
+ if (entry.isDirectory()) {
220
+ await walk(rel);
221
+ continue;
222
+ }
223
+ if (!entry.isFile()) {
224
+ add("error", "SPECIAL_FILE", `${rel} is not a regular file`, rel);
225
+ continue;
226
+ }
227
+ const posix = rel.split(path.sep).join("/");
228
+ if (shipped || posix.endsWith(".md") || posix.startsWith("scripts/")) {
229
+ let buffer;
230
+ try {
231
+ buffer = await readFile(full);
232
+ } catch (error) {
233
+ add("error", "UNREADABLE", `${rel} cannot be read: ${error.code ?? error.message}`, rel);
234
+ continue;
235
+ }
236
+ if (shipped && !isText(buffer)) add("error", "SHIPPED_BINARY", `${rel} is not UTF-8 text; ALP bundles carry shipped skills as text`, rel);
237
+ if (posix.endsWith(".md")) markdown.push([posix, buffer.toString("utf8")]);
238
+ if (posix.startsWith("scripts/") && !shipped && process.platform !== "win32" && buffer.subarray(0, 2).toString() === "#!" && !((await stat(full)).mode & 73)) {
239
+ add("warning", "SCRIPT_NOT_EXECUTABLE", `${rel} has a #! line but is not executable; run it with its interpreter or chmod +x it`, rel);
240
+ }
241
+ }
242
+ }
243
+ };
244
+ await walk("");
245
+ const skillFile = markdown.find(([file]) => file === "SKILL.md");
246
+ if (!skillFile) {
247
+ const other = await readdir(real).then((list) => list.find((name) => name.toLowerCase() === "skill.md"), () => void 0);
248
+ add("error", "SKILL_MD_MISSING", other ? `found ${other}; the file must be named SKILL.md` : "no SKILL.md");
249
+ return result();
250
+ }
251
+ const { frontmatter, body } = splitSkill(skillFile[1]);
252
+ for (const finding of checkFrontmatter(frontmatter, path.basename(root), { strict }).findings) add(finding.level, finding.code, finding.message, "SKILL.md");
253
+ if (!body.trim()) format("BODY_EMPTY", "SKILL.md has no instructions after its frontmatter", "SKILL.md");
254
+ const lines = body.split("\n").length;
255
+ if (lines > BODY_LINES_RECOMMENDED) add("warning", "BODY_LONG", `SKILL.md body has ${lines} lines; move detail into references/ (recommended under ${BODY_LINES_RECOMMENDED})`, "SKILL.md");
256
+ for (const [file, text] of markdown) {
257
+ const content = file === "SKILL.md" ? body : text;
258
+ for (const target of skillReferences(content)) {
259
+ if (path.isAbsolute(target) || /^[a-z]:[\\/]/i.test(target) || target.startsWith("~")) {
260
+ format("ABSOLUTE_REFERENCE", `${file} names the absolute path ${target}; use a path relative to the skill`, file);
261
+ continue;
262
+ }
263
+ const resolved = path.resolve(real, path.dirname(file), target);
264
+ if (!inside(real, resolved)) {
265
+ format("REFERENCE_OUTSIDE", `${file} points outside the skill: ${target}`, file);
266
+ continue;
267
+ }
268
+ const linked = await lstat(resolved).catch(() => void 0);
269
+ if (!linked) {
270
+ format("BROKEN_REFERENCE", `${file} points to ${target}, which does not exist`, file);
271
+ continue;
272
+ }
273
+ if (linked.isSymbolicLink()) {
274
+ const target2 = await realpath(resolved).catch(() => void 0);
275
+ if (!target2 || !inside(real, target2)) add("error", "REFERENCE_OUTSIDE", `${file} points through a link outside the skill: ${target}`, file);
276
+ }
277
+ }
278
+ }
279
+ return result();
280
+ }
281
+ function formatValidation(report) {
282
+ const head = `${report.ok ? "ok " : "FAIL"} ${report.name} (${report.mode}) ${report.directory}`;
283
+ const rows = [...report.errors.map((f) => ` error ${f.code}: ${f.message}`), ...report.warnings.map((f) => ` warning ${f.code}: ${f.message}`)];
284
+ return [head, ...rows].join("\n");
285
+ }
286
+ export {
287
+ DESCRIPTION_MAX,
288
+ INDEX_DESCRIPTION_CHARS,
289
+ NAME_MAX,
290
+ SPEC_KEYS,
291
+ checkFrontmatter,
292
+ formatValidation,
293
+ parseFrontmatter,
294
+ skillReferences,
295
+ specName,
296
+ splitSkill,
297
+ validateSkill
298
+ };
package/dist/upgrade.d.ts CHANGED
@@ -8,3 +8,13 @@ export function upgradeProject(projectRoot: any, { library, templates }?: {}): P
8
8
  created: string[];
9
9
  preserved: string[];
10
10
  }>;
11
+ /** The hashes above, by project-relative path, so a test can hold the list to the templates. */
12
+ export const shippedRoleHashes: {
13
+ 'ALP.md': string[];
14
+ '.alp/agents/main/AGENT.md': string[];
15
+ '.alp/agents/lead/AGENT.md': string[];
16
+ '.alp/agents/peer/AGENT.md': string[];
17
+ '.alp/agents/oracle/AGENT.md': string[];
18
+ '.alp/agents/reviewer/AGENT.md': string[];
19
+ '.alp/agents/supervisor/AGENT.md': string[];
20
+ };
package/dist/upgrade.js CHANGED
@@ -13,13 +13,118 @@ var legacy = {
13
13
  ".alp/agents/main/AGENT.md": "# Main agent\n\nHelp with tasks in this project.\n"
14
14
  };
15
15
  var teamV1 = {
16
- "ALP.md": ["c2785aac6538d10e79bd6fb59b11066ccdec77287edf950fad59aa57bf3417f1", "0875293195d35d965effb70bb150d1edbc789f66f72c545f7760dea4346b1a9a"],
17
- ".alp/agents/main/AGENT.md": ["15d217cbc5ede782790d1086124598d9a2b5ff13bcf971a37231962fcef1b47c", "e7201a1ed7800d7500b5c8091bd8a435aa9d5138f247c2b02b8bf76299387c90", "5001b807bbb686aa1a3b7ecadf9501428909e052e8231281454fd41cbe0ebf27", "90f9903fcc97ddf6336e1a28b81103dddc60a6038dcf74d326be8998862cb022", "9085ab906e2744a4151ae5c63dd66a545115cd4c876be1fd80f0a0ed4e623da8", "fb55cfb0852d07592090de2c49e6c5c2b57936cbffc823dd24767c2db5e5f7fb"],
18
- ".alp/agents/lead/AGENT.md": ["c259b085a3c102445f97e5c7d402ca68347bcc1a9b02d6ab96e02be6d8b6f9af", "2eef2a4474f757cd89b35b50638a1b23fe49a54c26bf0dedb24a96d7117ddd92", "6c71393c9b3aa655c4731bda96396ea3ec0d4da62cddb3ad50d1a24113416b77", "a382f0faa724e23a0ba9c212205978aa3fef87c3aecdf8823fba136e04568487", "547e3f8fc354b22c7beb3432182d68f4de1f24938375c8bfb167ae8afbf97de2"],
19
- ".alp/agents/peer/AGENT.md": ["f3dcf16c8c899a5378a468e922ca3956fd72cbb3e3798ed1109f11e01aa8f476", "39ccf3317eba3003faad77ebad4489fae3eb3c4d89258a03f619d1d3d65af0b7", "c59e45e8f22eb0daca9b8b5e1b19e90666156807f160e75a21eca48b5fee1102", "9623dbf76eda598f6267629e993663c149acb0efd253f3900a4ee1eda8f2f9e7"],
20
- ".alp/agents/oracle/AGENT.md": ["cdce1babcd587a190dc94a32a951ed70ce2c75f99c205a4049df940851ac7059"],
21
- ".alp/agents/reviewer/AGENT.md": ["6eab9f918c79335a0665bf4e3a3a26b66258684d6725c4c95637e70e8d355123"]
16
+ "ALP.md": [
17
+ "c2785aac6538d10e79bd6fb59b11066ccdec77287edf950fad59aa57bf3417f1",
18
+ "0875293195d35d965effb70bb150d1edbc789f66f72c545f7760dea4346b1a9a",
19
+ "fe0d5e6f64ef5a5030ee99feaf083f062a8e5136ac52d451e2ca7cdacb21d14f",
20
+ "e04fe558a26d6e3c9b08211c426a83c368e4f0d15b0929e55df8ab4e5c4bb932",
21
+ // 61181b5
22
+ "ff1a7da448b735a9b4f88e3d9b6006d048114d3becee96a331d225b63e453c56",
23
+ // ca2a971
24
+ "263135a3139eb40501f6e502271e946ec3db4692b63e39c2dd349ac0aaae6d62",
25
+ // 818ab2e
26
+ "e855f56ca0af0691c731ac5f2eb93d2528e339f2dbfd6f2376594f878d2c11e1",
27
+ // 1f827c6
28
+ "48c6a0f80b41958457f8dbaaad7a4b3118efeaf5feb6ae626501c2f7896b077d"
29
+ ],
30
+ // PR #330 (replaces 83388aa's hash, which never reached main)
31
+ ".alp/agents/main/AGENT.md": [
32
+ "15d217cbc5ede782790d1086124598d9a2b5ff13bcf971a37231962fcef1b47c",
33
+ "e7201a1ed7800d7500b5c8091bd8a435aa9d5138f247c2b02b8bf76299387c90",
34
+ "5001b807bbb686aa1a3b7ecadf9501428909e052e8231281454fd41cbe0ebf27",
35
+ "90f9903fcc97ddf6336e1a28b81103dddc60a6038dcf74d326be8998862cb022",
36
+ "9085ab906e2744a4151ae5c63dd66a545115cd4c876be1fd80f0a0ed4e623da8",
37
+ "fb55cfb0852d07592090de2c49e6c5c2b57936cbffc823dd24767c2db5e5f7fb",
38
+ "91b71f5750e75f707488b70618e1d65a63aabf7518762f97ea0fde999d36fead",
39
+ "60d92fa634e178244a38e99c074e169af1847d7512e268262148ec15ebf08bed",
40
+ // 61181b5
41
+ "b501142ebff430e2ac6d0c3ecb2673cbf0fe0e1fa123b73b113ba9b4aa5f3a39",
42
+ // ca2a971
43
+ "ddbd75ebacf5f13615fa3da4941a389b14b534742032c3046e0e6c214a46c989",
44
+ // ec26e6c
45
+ "5d610e7639bc8eaa29ad4119a5c090cbd286bd217f2f4a7d3abdd59725a985c1",
46
+ // a1acd92
47
+ "28037d678457a392a42510d57919b14a643ea729c2a358fa7aeee4b7a33e6727",
48
+ // 8d0e12a
49
+ "b4435cf5ef8cfab2238eee86298f21cfa508e3fdeb6b3e697fde94160c341fe7",
50
+ // 105f68f
51
+ "973539ce5dd998440cb59938f37260760f96f66a67b66369fcb28421acd49903",
52
+ // 40ce2de
53
+ "ab85e561f62a46e8838cc955984b66583a7325e69c1e7f2fd049479241553751",
54
+ // cc9215e
55
+ "8b8d0bff45d245543f543ecd15043be38fd03edd364c6750aac58b87785c1afa",
56
+ // 818ab2e
57
+ "2e82f110b108032c3c4444c306e73409bb6b481e5dc9ab080fe1ee2eb583fb78",
58
+ // b8d2fbc
59
+ "cde93f41883b26c2ef7636735d88be8fb202b143c479821647799c83b7d673dc",
60
+ // 9180aa1
61
+ "29f181001edfee5521d8f4965b33f501f8ef869f6af3abf74a05e5f1623809ac",
62
+ // f4d7986
63
+ "d6f8002a81e3e0b7bb5868a6834d7be37731cc307877d7a03513067be10cad2f",
64
+ // 1f827c6
65
+ "b9bdd073e22903e3813f13caf87c9341215476ed692b3f04bc0971b66fd93ac5"
66
+ ],
67
+ // 83388aa
68
+ ".alp/agents/lead/AGENT.md": [
69
+ "c259b085a3c102445f97e5c7d402ca68347bcc1a9b02d6ab96e02be6d8b6f9af",
70
+ "2eef2a4474f757cd89b35b50638a1b23fe49a54c26bf0dedb24a96d7117ddd92",
71
+ "6c71393c9b3aa655c4731bda96396ea3ec0d4da62cddb3ad50d1a24113416b77",
72
+ "a382f0faa724e23a0ba9c212205978aa3fef87c3aecdf8823fba136e04568487",
73
+ "547e3f8fc354b22c7beb3432182d68f4de1f24938375c8bfb167ae8afbf97de2",
74
+ "f3609df1486c0911459d8ee7d823b344369df0538654b0de6e9bc23170186b22",
75
+ "1674d7b96450824111ce885c828af51aa8924c38888bdeb583f4f31684c2bf60",
76
+ // 61181b5
77
+ "7cd01a44200fda79ae0979a4975c483494a35e2e8c144b4e56f0b61046fc1a67",
78
+ // ca2a971
79
+ "c622392fcb94aeec18efcb12fe9ed574117304af02c303d0f575a2181991b454",
80
+ // 8d0e12a
81
+ "6e9166b3b72333b76b4b2ef5a7778e142d6fd3c1023efd8a792bec1b12516415",
82
+ // 40ce2de
83
+ "8aef2591deb1ca12f3cbc843445688140aeb03f7c42bff8e15ef74bdd03be940",
84
+ // 1f827c6
85
+ "e241608ee9579ed894024cba8f9b7b60e75283179d68ebbd4cb28a526c78965d"
86
+ ],
87
+ // 83388aa
88
+ ".alp/agents/peer/AGENT.md": [
89
+ "f3dcf16c8c899a5378a468e922ca3956fd72cbb3e3798ed1109f11e01aa8f476",
90
+ "39ccf3317eba3003faad77ebad4489fae3eb3c4d89258a03f619d1d3d65af0b7",
91
+ "c59e45e8f22eb0daca9b8b5e1b19e90666156807f160e75a21eca48b5fee1102",
92
+ "9623dbf76eda598f6267629e993663c149acb0efd253f3900a4ee1eda8f2f9e7",
93
+ "20b0d2b6be74597ea1f39cf6d2d56c0ef2bffe39cb3bfe1ae41761748ef9bfae",
94
+ "da389b7fa194fcf4cb8683664d30e06197999d804ec4ee94c1889bb397f540a9",
95
+ // 61181b5
96
+ "c7c8f4c5468484bab165f8f32b141398a259d4e6e9966e304528d82858e6807e",
97
+ // ca2a971
98
+ "d7cbdac679c82086ce2601d0a2c82480f6b2300ea011a9e07862f1b900d6ac75"
99
+ ],
100
+ // 1f827c6
101
+ ".alp/agents/oracle/AGENT.md": [
102
+ "cdce1babcd587a190dc94a32a951ed70ce2c75f99c205a4049df940851ac7059",
103
+ "0907091b17aa8e54215b65171433f222b8491e9490a16a66b6a2b8cffc3f9023",
104
+ "ae6219e0141d290705ed45992f0cc78688d17c78757f7f1f72f1639432e110cc"
105
+ ],
106
+ // 1f827c6
107
+ ".alp/agents/reviewer/AGENT.md": [
108
+ "6eab9f918c79335a0665bf4e3a3a26b66258684d6725c4c95637e70e8d355123",
109
+ "1809de0be6473d5f9ceeae2d35128d52a0c0cde3968b45a7569ceae7a8a74416",
110
+ "56bebc192fda9d67bc2ceaf14d4f0cf274eaa40bf3e652caaf85c239eba1a253"
111
+ ],
112
+ // 1f827c6
113
+ ".alp/agents/supervisor/AGENT.md": [
114
+ "81ac93f4fbf2337224f838d39a9c4ef13fdba12d5fc7de681a00628bf9e69a27",
115
+ "a2be7e682b030d2ff122ba4e836b1c89858493a05937fa11ad1fa808e0df9c8d",
116
+ // 61181b5
117
+ "d26d642128bedb6c90d4a84b227877ae4ea8be0838de75f40d786c0ba55183ae",
118
+ // ec26e6c
119
+ "f920b505cda38c90f7014827352225846b6b1e35a40675e2f5d01b03cee250ce",
120
+ // cdbc297
121
+ "10e22e451264a901a7ad62e04189a91fae70940a62f4646f22c1135244986d03",
122
+ // cc9215e
123
+ "6c306170ee5218313c93dc8bc1049e1dd9daf401073fda4c476ff4b5630765ab"
124
+ ]
125
+ // 1f827c6
22
126
  };
127
+ var shippedRoleHashes = teamV1;
23
128
  var renamedProfiles = { smart: "pho", supervised: "cafe" };
24
129
  async function skillFiles(directory) {
25
130
  const files = /* @__PURE__ */ new Map();
@@ -196,5 +301,6 @@ async function retireAgentCopies(root, result, backupPath, replace) {
196
301
  });
197
302
  }
198
303
  export {
304
+ shippedRoleHashes,
199
305
  upgradeProject
200
306
  };
@@ -1,7 +1,7 @@
1
1
  // packages/core/src/validation.js
2
2
  import path from "node:path";
3
3
  import { AlpError } from "./errors.js";
4
- import { MODELS } from "./models.js";
4
+ import { EFFORTS, knownModel } from "./models.js";
5
5
  import { validatePermissions } from "./permissions.js";
6
6
  import { validateVerify } from "./verify.js";
7
7
  var object = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
@@ -10,7 +10,6 @@ var stringMap = (value) => object(value) && Object.values(value).every((v) => ty
10
10
  function requireValue(condition, code, source, message) {
11
11
  if (!condition) throw new AlpError(code, `${source}: ${message}`);
12
12
  }
13
- var EFFORTS = ["none", "off", "low", "medium", "high", "xhigh", "max", "ultra", "ultracode"];
14
13
  var PROJECT_SETTINGS = ["$schema", "defaultAgent", "workflow", "runtime", "permissions", "verify", "delegation", "team", "profile", "templateDefaults", "compact", "curate"];
15
14
  var USER_SETTINGS = ["$schema", "language", "permissions", "limits", "recovery", "web", "curate"];
16
15
  var RETIRED_SETTINGS = { project: {}, user: {} };
@@ -110,7 +109,7 @@ function validateSettings(settings, source) {
110
109
  const [provider, model, effort] = entry.split(":");
111
110
  check(model !== "*" || agent !== "oracle" && agent !== "main", `${at}: ${agent} runs on a named model, not any model`);
112
111
  if (effort !== void 0) {
113
- const known = MODELS.find((candidate) => candidate.runtime === provider && candidate.id === model);
112
+ const known = knownModel(`${provider}:${model}`);
114
113
  check(EFFORTS.includes(effort), `${at}: effort ${effort} is unsupported`);
115
114
  check(!known?.efforts.length || known.efforts.includes(effort), `${at}: ${provider}:${model} takes effort ${known?.efforts.join(", ")}`);
116
115
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anhlp/alp-core",
3
- "version": "0.0.1-beta.7",
3
+ "version": "0.0.1-beta.8",
4
4
  "type": "module",
5
5
  "description": "ALP core module",
6
6
  "files": [
@@ -294,13 +294,29 @@
294
294
  },
295
295
  "types": "./dist/packaged.d.ts",
296
296
  "default": "./src/packaged.js"
297
+ },
298
+ "./skill-validate": {
299
+ "alp-source": {
300
+ "types": "./src/skill-validate.js",
301
+ "default": "./src/skill-validate.js"
302
+ },
303
+ "types": "./dist/skill-validate.d.ts",
304
+ "default": "./src/skill-validate.js"
305
+ },
306
+ "./packs": {
307
+ "alp-source": {
308
+ "types": "./src/packs.js",
309
+ "default": "./src/packs.js"
310
+ },
311
+ "types": "./dist/packs.d.ts",
312
+ "default": "./src/packs.js"
297
313
  }
298
314
  },
299
315
  "engines": {
300
316
  "node": ">=22.12"
301
317
  },
302
318
  "dependencies": {
303
- "@anhlp/alp-protocol": "0.0.1-beta.7"
319
+ "@anhlp/alp-protocol": "0.0.1-beta.8"
304
320
  },
305
321
  "scripts": {
306
322
  "build": "node ../../scripts/build-workspace.mjs core",