@eum-agent/skill-management 1.1.0 → 1.2.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,7 +1,6 @@
1
- import { a as unpackZip } from "./http-BcaAiHxl.js";
1
+ import { a as unpackZip } from "./http-D2qzcvim.js";
2
2
  import { parentPort, workerData } from "node:worker_threads";
3
3
  //#region src/archive-worker.ts
4
- /** Inflates a completely checked archive away from the Gateway event loop. */
5
4
  if (!parentPort) throw new Error("archive inflation requires a background worker");
6
5
  parentPort.postMessage(unpackZip(workerData.bytes, workerData.maximum));
7
6
  parentPort.close();
@@ -0,0 +1,620 @@
1
+ import { createRequire } from "node:module";
2
+ import { createHash } from "node:crypto";
3
+ //#region src/runtime/skills/normalize.ts
4
+ function yaml$1() {
5
+ return createRequire(import.meta.url)("yaml");
6
+ }
7
+ const SKILL_NAME = /^[a-z0-9]+(-[a-z0-9]+)*$/;
8
+ const DESCRIPTION_MAX = 1024;
9
+ const ALLOWED = /* @__PURE__ */ new Set([
10
+ "name",
11
+ "description",
12
+ "license",
13
+ "compatibility",
14
+ "metadata",
15
+ "allowed-tools"
16
+ ]);
17
+ function length(text) {
18
+ return Array.from(text).length;
19
+ }
20
+ function truncate(text, max) {
21
+ const points = Array.from(text);
22
+ return points.length <= max ? text : points.slice(0, max).join("");
23
+ }
24
+ function isRecord(value) {
25
+ return typeof value === "object" && value !== null && !Array.isArray(value);
26
+ }
27
+ function scalarText(value) {
28
+ if (typeof value === "string") return value;
29
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
30
+ }
31
+ function metadataText(value) {
32
+ return scalarText(value) ?? JSON.stringify(value) ?? String(value);
33
+ }
34
+ function readLines(block) {
35
+ const fields = {};
36
+ for (const line of block.split("\n")) {
37
+ if (line.trim() === "") continue;
38
+ const colon = line.indexOf(":");
39
+ if (colon === -1) continue;
40
+ fields[line.slice(0, colon).trim()] = line.slice(colon + 1).trim();
41
+ }
42
+ return fields;
43
+ }
44
+ function readFrontmatter(text) {
45
+ const lines = text.replace(/^\ufeff/, "").split("\n");
46
+ if (lines[0]?.trim() !== "---") return void 0;
47
+ const end = lines.findIndex((line, index) => index > 0 && line.trim() === "---");
48
+ if (end === -1) return void 0;
49
+ const block = lines.slice(1, end).map((line) => line.replace(/\r$/, "")).join("\n");
50
+ const rest = lines.slice(end + 1).join("\n");
51
+ try {
52
+ const parsed = yaml$1().parse(block);
53
+ if (parsed === null || parsed === void 0) return {
54
+ fields: {},
55
+ syntax: "yaml",
56
+ rest
57
+ };
58
+ if (isRecord(parsed)) return {
59
+ fields: parsed,
60
+ syntax: "yaml",
61
+ rest
62
+ };
63
+ } catch {}
64
+ return {
65
+ fields: readLines(block),
66
+ syntax: "lines",
67
+ rest
68
+ };
69
+ }
70
+ function isStandardName(name) {
71
+ return length(name) <= 64 && SKILL_NAME.test(name);
72
+ }
73
+ function conformance(front, dirName) {
74
+ const issues = [];
75
+ const { fields } = front;
76
+ if (front.syntax === "lines") issues.push({
77
+ code: "syntax",
78
+ detail: "frontmatter is not YAML"
79
+ });
80
+ if (!isStandardName(dirName)) issues.push({
81
+ code: "dir-invalid",
82
+ detail: dirName
83
+ });
84
+ const name = fields.name;
85
+ if (name === void 0) issues.push({
86
+ code: "name-missing",
87
+ detail: "name"
88
+ });
89
+ else if (typeof name !== "string") issues.push({
90
+ code: "field-type",
91
+ detail: "name"
92
+ });
93
+ else {
94
+ if (!isStandardName(name)) issues.push({
95
+ code: "name-invalid",
96
+ detail: name
97
+ });
98
+ if (name !== dirName) issues.push({
99
+ code: "name-mismatch",
100
+ detail: name
101
+ });
102
+ }
103
+ const description = fields.description;
104
+ if (description !== void 0 && typeof description !== "string") issues.push({
105
+ code: "field-type",
106
+ detail: "description"
107
+ });
108
+ const descriptionText = scalarText(description);
109
+ if (descriptionText !== void 0 && length(descriptionText.trim()) > 1024) issues.push({
110
+ code: "description-long",
111
+ detail: String(length(descriptionText.trim()))
112
+ });
113
+ for (const key of [
114
+ "license",
115
+ "compatibility",
116
+ "allowed-tools"
117
+ ]) {
118
+ const value = fields[key];
119
+ if (value !== void 0 && typeof value !== "string") issues.push({
120
+ code: "field-type",
121
+ detail: key
122
+ });
123
+ }
124
+ const compatibility = scalarText(fields.compatibility);
125
+ if (compatibility !== void 0 && length(compatibility) > 500) issues.push({
126
+ code: "compatibility-long",
127
+ detail: String(length(compatibility))
128
+ });
129
+ const metadata = fields.metadata;
130
+ if (metadata !== void 0) {
131
+ if (!isRecord(metadata)) issues.push({
132
+ code: "field-type",
133
+ detail: "metadata"
134
+ });
135
+ else for (const [key, value] of Object.entries(metadata)) if (typeof value !== "string") issues.push({
136
+ code: "metadata-value",
137
+ detail: key
138
+ });
139
+ }
140
+ for (const key of Object.keys(fields)) if (!ALLOWED.has(key)) issues.push({
141
+ code: "extra-field",
142
+ detail: key
143
+ });
144
+ return issues;
145
+ }
146
+ function normalize(front, name) {
147
+ const { fields } = front;
148
+ const descriptionText = scalarText(fields.description)?.trim() ?? "";
149
+ if (descriptionText === "") return void 0;
150
+ const metadata = {};
151
+ const moved = [];
152
+ if (fields.metadata !== void 0) {
153
+ if (isRecord(fields.metadata)) for (const [key, value] of Object.entries(fields.metadata)) metadata[key] = metadataText(value);
154
+ else moved.push(["metadata", fields.metadata]);
155
+ }
156
+ const text = (key) => {
157
+ const value = fields[key];
158
+ if (value === void 0 || value === null) return void 0;
159
+ if (key === "allowed-tools" && Array.isArray(value) && value.every((one) => typeof one === "string")) return value.join(" ");
160
+ const scalar = scalarText(value);
161
+ if (scalar !== void 0) return scalar;
162
+ moved.push([key, value]);
163
+ };
164
+ const license = text("license");
165
+ const compatibilityRaw = text("compatibility");
166
+ const allowedTools = text("allowed-tools");
167
+ for (const [key, value] of Object.entries(fields)) if (!ALLOWED.has(key)) moved.push([key, value]);
168
+ for (const [key, value] of moved) {
169
+ const target = Object.hasOwn(metadata, key) ? `x-${key}` : key;
170
+ metadata[target] = metadataText(value);
171
+ }
172
+ const compatibility = compatibilityRaw === void 0 ? void 0 : truncate(compatibilityRaw, 500);
173
+ return {
174
+ name,
175
+ description: truncate(descriptionText, DESCRIPTION_MAX),
176
+ ...license === void 0 ? {} : { license },
177
+ ...compatibility === void 0 || compatibility === "" ? {} : { compatibility },
178
+ ...allowedTools === void 0 ? {} : { "allowed-tools": allowedTools },
179
+ ...Object.keys(metadata).length === 0 ? {} : { metadata }
180
+ };
181
+ }
182
+ function render(standard, rest) {
183
+ return `---\n${yaml$1().stringify(standard, { lineWidth: 0 })}---\n${rest}`;
184
+ }
185
+ function asFrontmatter(standard) {
186
+ return {
187
+ fields: { ...standard },
188
+ syntax: "yaml",
189
+ rest: ""
190
+ };
191
+ }
192
+ //#endregion
193
+ //#region src/validation/measure.ts
194
+ function splitLines(text) {
195
+ const lines = [];
196
+ let start = 0;
197
+ for (let index = 0; index < text.length; index++) {
198
+ const char = text.charCodeAt(index);
199
+ if (char !== 10 && char !== 13) continue;
200
+ const next = char === 13 && text.charCodeAt(index + 1) === 10 ? index + 2 : index + 1;
201
+ lines.push({
202
+ start,
203
+ end: index,
204
+ next
205
+ });
206
+ start = next;
207
+ index = next - 1;
208
+ }
209
+ if (start < text.length) lines.push({
210
+ start,
211
+ end: text.length,
212
+ next: text.length
213
+ });
214
+ return lines;
215
+ }
216
+ function measureText(text) {
217
+ return {
218
+ lines: splitLines(text).length,
219
+ bytes: Buffer.byteLength(text, "utf8")
220
+ };
221
+ }
222
+ //#endregion
223
+ //#region src/validation/creator.ts
224
+ const CREATOR_POLICY = "creator-v1";
225
+ const MAX_DIAGNOSTICS = 1e4;
226
+ const CREATOR_LIMITS = {
227
+ warnLines: 300,
228
+ warnBytes: 16384,
229
+ maxLines: 500,
230
+ maxBytes: 32768,
231
+ files: 256,
232
+ depth: 8,
233
+ fileBytes: 1048576,
234
+ skillBytes: 8388608,
235
+ manifestResources: 256
236
+ };
237
+ const RESOURCE_MANIFEST = "assets/resource-manifest.json";
238
+ const TEXT = /\.(md|markdown|txt|json|ya?ml|toml|py|sh|bash|zsh|js|mjs|cjs|ts|rb|pl|ps1|bat|cmd|html?|css|xml|csv|ini|cfg)$/i;
239
+ const MARKDOWN = /\.(md|markdown)$/i;
240
+ const EXTERNAL = /^(https?|mailto):/i;
241
+ const SCHEME = /^[a-z][a-z0-9+.-]*:/i;
242
+ const INCOMPLETE = /* @__PURE__ */ new Set([
243
+ "scan_incomplete",
244
+ "validation_incomplete",
245
+ "source_changed"
246
+ ]);
247
+ const SECRET_RULES = [
248
+ ["private-key", /-----BEGIN [A-Z ]*PRIVATE KEY-----/],
249
+ ["aws-access-key", /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/],
250
+ ["github-token", /\bgh[pousr]_[A-Za-z0-9]{36,}\b/],
251
+ ["api-key-sk", /\bsk-[A-Za-z0-9_-]{32,}/],
252
+ ["slack-token", /\bxox[abprs]-[A-Za-z0-9-]{10,}/],
253
+ ["google-api-key", /\bAIza[0-9A-Za-z_-]{35}\b/],
254
+ ["assigned-credential", /\b(?:api[_-]?key|secret|token|password|passwd)\b["']?\s*[:=]\s*["']?[A-Za-z0-9_\-+/]{16,}/i]
255
+ ];
256
+ const TEMPLATE = /\{\{\s*[A-Za-z_][\w.-]*\s*\}\}|\bREPLACE_ME\b|\bTODO:|\[TODO\]/;
257
+ const LOCAL_PATH = /(?:^|[\s"'`(=])(?:\/Users\/[^/\s]+\/|\/home\/[^/\s]+\/|[A-Za-z]:\\Users\\)/;
258
+ const CJK = /[\u3040-\u30ff\u3400-\u9fff\uac00-\ud7af]/;
259
+ const ISSUE_CODES = {
260
+ syntax: "frontmatter_syntax",
261
+ "name-missing": "name_missing",
262
+ "name-mismatch": "name_mismatch",
263
+ "name-invalid": "name_invalid",
264
+ "dir-invalid": "directory_invalid",
265
+ "extra-field": "field_unknown",
266
+ "metadata-value": "field_type",
267
+ "description-long": "description_long",
268
+ "compatibility-long": "compatibility_long",
269
+ "field-type": "field_type"
270
+ };
271
+ const isControl = (code) => code <= 31 || code >= 127 && code <= 159 || code === 8232 || code === 8233;
272
+ const hasControl = (text) => {
273
+ for (let index = 0; index < text.length; index++) if (isControl(text.charCodeAt(index))) return true;
274
+ return false;
275
+ };
276
+ function safeLabel(text, max = 256) {
277
+ let escaped = "";
278
+ for (const char of text) {
279
+ const code = char.charCodeAt(0);
280
+ escaped += isControl(code) ? `\\u${code.toString(16).padStart(4, "0")}` : char;
281
+ }
282
+ const points = Array.from(escaped);
283
+ return points.length <= max ? escaped : `${points.slice(0, max - 1).join("")}\u2026`;
284
+ }
285
+ function decodeUtf8(bytes) {
286
+ try {
287
+ return new TextDecoder("utf-8", {
288
+ fatal: true,
289
+ ignoreBOM: true
290
+ }).decode(bytes);
291
+ } catch {
292
+ return;
293
+ }
294
+ }
295
+ function sha256(bytes) {
296
+ return createHash("sha256").update(bytes).digest("hex");
297
+ }
298
+ function pathProblem(path) {
299
+ if (/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/.test(path)) return "contains unpaired surrogates";
300
+ const parts = path.split("/");
301
+ for (const part of parts) {
302
+ if (part === "" || part === "." || part === "..") return "contains an empty or dot segment";
303
+ if (part.includes("\\")) return "contains a backslash";
304
+ if (hasControl(part)) return "contains a control character";
305
+ }
306
+ }
307
+ function resolveTarget(fromDirectory, target) {
308
+ const stack = [...fromDirectory];
309
+ const parts = target.split("/");
310
+ for (const [index, part] of parts.entries()) {
311
+ if (part === "" && index === parts.length - 1 && index > 0) continue;
312
+ if (part === "") return void 0;
313
+ if (part === ".") continue;
314
+ if (part === "..") {
315
+ if (stack.length === 0) return void 0;
316
+ stack.pop();
317
+ continue;
318
+ }
319
+ stack.push(part);
320
+ }
321
+ return stack.join("/");
322
+ }
323
+ function frontmatterOf(text) {
324
+ const lines = splitLines(text);
325
+ const first = lines[0];
326
+ if (!first || text.slice(first.start, first.end) !== "---" || first.next === first.end) return void 0;
327
+ for (const line of lines.slice(1)) {
328
+ if (text.slice(line.start, line.end) !== "---") continue;
329
+ return {
330
+ block: text.slice(first.next, line.start),
331
+ bodyStart: line.next
332
+ };
333
+ }
334
+ }
335
+ function yaml() {
336
+ return createRequire(import.meta.url)("yaml");
337
+ }
338
+ function validateCreatorSkill(input) {
339
+ const diagnostics = [];
340
+ let overflow = false;
341
+ const add = (diagnostic) => {
342
+ if (diagnostics.length < 9999) diagnostics.push(diagnostic);
343
+ else overflow = true;
344
+ };
345
+ const error = (code, message, path, line) => add({
346
+ severity: "error",
347
+ code,
348
+ message,
349
+ ...path === void 0 ? {} : { path },
350
+ ...line === void 0 ? {} : { line }
351
+ });
352
+ const warning = (code, message, path, line) => add({
353
+ severity: "warning",
354
+ code,
355
+ message,
356
+ ...path === void 0 ? {} : { path },
357
+ ...line === void 0 ? {} : { line }
358
+ });
359
+ let incomplete = false;
360
+ for (const one of input.scan ?? []) {
361
+ add(one);
362
+ if (INCOMPLETE.has(one.code)) incomplete = true;
363
+ }
364
+ const files = [...input.files].sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
365
+ const paths = new Set(files.map((one) => one.path));
366
+ const directories = /* @__PURE__ */ new Set();
367
+ for (const one of files) {
368
+ const parts = one.path.split("/");
369
+ for (let count = 1; count < parts.length; count++) directories.add(parts.slice(0, count).join("/"));
370
+ }
371
+ if (files.length > CREATOR_LIMITS.files) error("file_count", `The skill holds ${files.length} files; the limit is ${CREATOR_LIMITS.files}.`);
372
+ const totalSize = files.reduce((sum, one) => sum + one.size, 0);
373
+ if (totalSize > CREATOR_LIMITS.skillBytes) error("skill_too_large", `The skill holds ${totalSize} bytes; the limit is ${CREATOR_LIMITS.skillBytes}.`);
374
+ const overLimits = files.length > CREATOR_LIMITS.files || totalSize > CREATOR_LIMITS.skillBytes;
375
+ const folded = /* @__PURE__ */ new Map();
376
+ for (const one of files) {
377
+ const label = safeLabel(one.path);
378
+ const problem = pathProblem(one.path);
379
+ if (problem) error("path_invalid", `The path ${problem}.`, label);
380
+ if (one.path.split("/").length > CREATOR_LIMITS.depth) error("path_depth", `The path is deeper than ${CREATOR_LIMITS.depth} segments.`, label);
381
+ if (one.size > CREATOR_LIMITS.fileBytes && one.path !== "SKILL.md") error("resource_too_large", `The file exceeds ${CREATOR_LIMITS.fileBytes} bytes.`, label);
382
+ const key = one.path.normalize("NFC").toLowerCase();
383
+ const prior = folded.get(key);
384
+ if (prior !== void 0) error("path_collision", `The path collides with ${safeLabel(prior)} by case or Unicode normalization.`, label);
385
+ else folded.set(key, one.path);
386
+ if (one.bytes === void 0) {
387
+ incomplete = true;
388
+ if (one.size <= CREATOR_LIMITS.fileBytes && !overLimits) error("scan_incomplete", "The file bytes were not captured.", label);
389
+ } else if (one.bytes.byteLength !== one.size) {
390
+ incomplete = true;
391
+ error("scan_incomplete", "Captured bytes differ from the observed size.", label);
392
+ }
393
+ }
394
+ const texts = /* @__PURE__ */ new Map();
395
+ for (const one of files) {
396
+ if (one.bytes === void 0 || !(TEXT.test(one.path) || one.path === "SKILL.md")) continue;
397
+ const label = safeLabel(one.path);
398
+ const text = decodeUtf8(one.bytes);
399
+ if (text === void 0) {
400
+ error("encoding_invalid", "The file is not valid UTF-8.", label);
401
+ continue;
402
+ }
403
+ texts.set(one.path, text);
404
+ }
405
+ const skillFile = files.find((one) => one.path === "SKILL.md");
406
+ const skillText = texts.get("SKILL.md");
407
+ let total = {
408
+ lines: 0,
409
+ bytes: skillFile?.size ?? 0
410
+ };
411
+ let body = {
412
+ lines: 0,
413
+ bytes: 0
414
+ };
415
+ if (!skillFile) error("skill_missing", "The candidate root has no SKILL.md.");
416
+ if (skillText !== void 0) {
417
+ total = measureText(skillText);
418
+ if (skillText.startsWith("\ufeff")) error("encoding_bom", "SKILL.md starts with a byte order mark.", "SKILL.md");
419
+ const front = skillText.startsWith("\ufeff") ? void 0 : frontmatterOf(skillText);
420
+ if (front) body = measureText(skillText.slice(front.bodyStart));
421
+ if (!skillText.startsWith("\ufeff") && !front) error("frontmatter_missing", "SKILL.md must open with a --- line closed by another --- line.", "SKILL.md", 1);
422
+ if (front) checkFrontmatter(front.block, input.directoryName, error, warning);
423
+ if (total.lines > CREATOR_LIMITS.warnLines || total.bytes > CREATOR_LIMITS.warnBytes) warning("size_warning", `SKILL.md has ${total.lines} lines and ${total.bytes} bytes; keep it within ${CREATOR_LIMITS.warnLines} lines and ${CREATOR_LIMITS.warnBytes} bytes.`, "SKILL.md");
424
+ if (total.lines > CREATOR_LIMITS.maxLines || total.bytes > CREATOR_LIMITS.maxBytes) error("size_exceeded", `SKILL.md has ${total.lines} lines and ${total.bytes} bytes; publication allows at most ${CREATOR_LIMITS.maxLines} lines and ${CREATOR_LIMITS.maxBytes} bytes.`, "SKILL.md");
425
+ } else if (skillFile && skillFile.size > CREATOR_LIMITS.maxBytes) error("size_exceeded", `SKILL.md exceeds ${CREATOR_LIMITS.maxBytes} bytes.`, "SKILL.md");
426
+ const exists = (path) => paths.has(path) || directories.has(path.replace(/\/$/, ""));
427
+ for (const [path, text] of texts) {
428
+ const label = safeLabel(path);
429
+ contentRules(text, label, error, warning);
430
+ if (MARKDOWN.test(path)) {
431
+ const from = path.split("/").slice(0, -1);
432
+ for (const link of markdownTargets(text)) checkTarget(link.target, from, label, link.line, exists, error);
433
+ }
434
+ }
435
+ const manifestText = texts.get(RESOURCE_MANIFEST);
436
+ if (manifestText !== void 0) checkManifest(manifestText, exists, error);
437
+ if (overflow) {
438
+ incomplete = true;
439
+ diagnostics.push({
440
+ severity: "error",
441
+ code: "validation_incomplete",
442
+ message: `More than 9999 diagnostics; the report is incomplete.`
443
+ });
444
+ }
445
+ const order = (one) => one.severity === "error" ? 0 : 1;
446
+ const sorted = diagnostics.map((one, index) => ({
447
+ one,
448
+ index
449
+ })).sort((a, b) => {
450
+ if (a.one.code === "validation_incomplete") return 1;
451
+ if (b.one.code === "validation_incomplete") return -1;
452
+ const severity = order(a.one) - order(b.one);
453
+ if (severity) return severity;
454
+ const pathA = a.one.path ?? "";
455
+ const pathB = b.one.path ?? "";
456
+ if (pathA !== pathB) return pathA < pathB ? -1 : 1;
457
+ return (a.one.line ?? 0) - (b.one.line ?? 0) || a.index - b.index;
458
+ }).map(({ one }) => one);
459
+ const errors = sorted.filter((one) => one.severity === "error").length;
460
+ const manifest = files.map((one) => ({
461
+ path: one.path,
462
+ size: one.size,
463
+ sha256: one.bytes === void 0 ? "" : sha256(one.bytes)
464
+ }));
465
+ return {
466
+ policyVersion: CREATOR_POLICY,
467
+ passed: errors === 0 && !incomplete,
468
+ complete: !incomplete,
469
+ measurements: {
470
+ total,
471
+ body,
472
+ tokenEstimate: {
473
+ method: "utf8-bytes/4-ceil",
474
+ total: Math.ceil(total.bytes / 4),
475
+ body: Math.ceil(body.bytes / 4)
476
+ }
477
+ },
478
+ counts: {
479
+ errors,
480
+ warnings: sorted.length - errors
481
+ },
482
+ files: manifest,
483
+ manifestDigest: manifestDigest(manifest),
484
+ diagnostics: sorted
485
+ };
486
+ }
487
+ function manifestDigest(files) {
488
+ return sha256(JSON.stringify([CREATOR_POLICY, files.map((one) => [
489
+ one.path,
490
+ one.size,
491
+ one.sha256
492
+ ])]));
493
+ }
494
+ function checkFrontmatter(block, directoryName, error, warning) {
495
+ let fields;
496
+ try {
497
+ fields = yaml().parse(block, {
498
+ uniqueKeys: true,
499
+ strict: true,
500
+ prettyErrors: false
501
+ });
502
+ } catch {
503
+ error("frontmatter_syntax", "The frontmatter is not valid YAML with unique keys.", "SKILL.md");
504
+ return;
505
+ }
506
+ if (fields === null || fields === void 0) fields = {};
507
+ if (typeof fields !== "object" || Array.isArray(fields)) {
508
+ error("frontmatter_syntax", "The frontmatter is not a YAML mapping.", "SKILL.md");
509
+ return;
510
+ }
511
+ const record = fields;
512
+ for (const issue of conformance({
513
+ fields: record,
514
+ syntax: "yaml",
515
+ rest: ""
516
+ }, directoryName)) {
517
+ const field = [
518
+ "extra-field",
519
+ "field-type",
520
+ "metadata-value"
521
+ ].includes(issue.code) ? ` (${safeLabel(issue.detail, 64)})` : "";
522
+ error(ISSUE_CODES[issue.code], `Frontmatter does not meet the skill standard: ${issue.code}${field}.`, "SKILL.md");
523
+ }
524
+ const description = record.description;
525
+ if (typeof description !== "string" || description.trim() === "") error("description_missing", "The frontmatter needs a nonempty description string.", "SKILL.md");
526
+ else if (CJK.test(description)) warning("language_hint", "The description appears not to be English; model-facing text should be English.", "SKILL.md");
527
+ }
528
+ function contentRules(text, path, error, warning) {
529
+ for (const [index, line] of splitLines(text).entries()) {
530
+ const value = text.slice(line.start, line.end);
531
+ for (const [rule, pattern] of SECRET_RULES) {
532
+ if (!pattern.test(value)) continue;
533
+ error("secret_suspected", `Suspected credential matched rule ${rule}; the value is not shown.`, path, index + 1);
534
+ break;
535
+ }
536
+ if (TEMPLATE.test(value)) warning("template_residue", "Template placeholder text remains.", path, index + 1);
537
+ if (LOCAL_PATH.test(value)) warning("local_absolute_path", "A local home-directory path appears; it is not portable.", path, index + 1);
538
+ }
539
+ }
540
+ function markdownTargets(text) {
541
+ const found = [];
542
+ let fence;
543
+ for (const [index, line] of splitLines(text).entries()) {
544
+ const value = text.slice(line.start, line.end);
545
+ const marker = /^ {0,3}(`{3,}|~{3,})/.exec(value);
546
+ if (fence !== void 0) {
547
+ if (marker && marker[1][0] === fence[0] && marker[1].length >= fence.length && value.trim() === marker[1]) fence = void 0;
548
+ continue;
549
+ }
550
+ if (marker) {
551
+ fence = marker[1];
552
+ continue;
553
+ }
554
+ const visible = value.replace(/(`+)[^`]*?\1/g, "");
555
+ const definition = /^ {0,3}\[[^\]]+\]:\s*(<[^>]*>|\S+)/.exec(visible);
556
+ if (definition) found.push({
557
+ target: definition[1],
558
+ line: index + 1
559
+ });
560
+ for (const match of visible.matchAll(/!?\[[^\]]*\]\(\s*(<[^>]*>|[^)\s]+)(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\s*\)/g)) found.push({
561
+ target: match[1],
562
+ line: index + 1
563
+ });
564
+ }
565
+ return found;
566
+ }
567
+ function checkTarget(raw, from, path, line, exists, error) {
568
+ let target = raw.startsWith("<") && raw.endsWith(">") ? raw.slice(1, -1) : raw;
569
+ if (target === "" || target.startsWith("#") || EXTERNAL.test(target)) return;
570
+ if (SCHEME.test(target)) {
571
+ error("resource_path", "A local reference uses an unsupported scheme or drive.", path, line);
572
+ return;
573
+ }
574
+ target = target.replace(/[?#].*$/, "");
575
+ if (target === "") return;
576
+ let decoded;
577
+ try {
578
+ decoded = decodeURIComponent(target);
579
+ } catch {
580
+ error("resource_path", "A local reference has an invalid percent escape.", path, line);
581
+ return;
582
+ }
583
+ if (decoded.includes("\\") || hasControl(decoded)) {
584
+ error("resource_path", "A local reference contains a backslash or control character.", path, line);
585
+ return;
586
+ }
587
+ if (decoded.startsWith("/")) {
588
+ error("resource_path", "A local reference is absolute.", path, line);
589
+ return;
590
+ }
591
+ const resolved = resolveTarget(from, decoded);
592
+ if (resolved === void 0 || resolved === "") {
593
+ error("resource_path", "A local reference escapes the skill root or has an empty segment.", path, line);
594
+ return;
595
+ }
596
+ if (!exists(resolved)) error("resource_missing", `A local reference names ${safeLabel(resolved)}, which is not in the skill.`, path, line);
597
+ }
598
+ function checkManifest(text, exists, error) {
599
+ let value;
600
+ try {
601
+ value = JSON.parse(text);
602
+ } catch {
603
+ error("manifest_invalid", "The resource manifest is not valid JSON.", RESOURCE_MANIFEST);
604
+ return;
605
+ }
606
+ const record = value;
607
+ if (!(typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).every((key) => key === "schemaVersion" || key === "resources") && record.schemaVersion === 1 && Array.isArray(record.resources) && record.resources.length <= CREATOR_LIMITS.manifestResources && record.resources.every((one) => typeof one === "string"))) {
608
+ error("manifest_invalid", `The resource manifest must be {"schemaVersion":1,"resources":[...]} with at most ${CREATOR_LIMITS.manifestResources} strings.`, RESOURCE_MANIFEST);
609
+ return;
610
+ }
611
+ for (const [index, resource] of record.resources.entries()) {
612
+ if (pathProblem(resource) || resource.startsWith("/")) {
613
+ error("resource_path", `Resource ${index} is not a safe relative path.`, RESOURCE_MANIFEST);
614
+ continue;
615
+ }
616
+ if (!exists(resource)) error("resource_missing", `Resource ${index} names ${safeLabel(resource)}, which is not in the skill.`, RESOURCE_MANIFEST);
617
+ }
618
+ }
619
+ //#endregion
620
+ export { manifestDigest as a, asFrontmatter as c, normalize as d, readFrontmatter as f, RESOURCE_MANIFEST as i, conformance as l, CREATOR_POLICY as n, safeLabel as o, render as p, MAX_DIAGNOSTICS as r, validateCreatorSkill as s, CREATOR_LIMITS as t, isStandardName as u };