@forge/manifest
13.1.0-next.2-experimental-9423de113.1.0-next.3
out/validators/modules-validators/rovo/validate-skill-path.js~
out/validators/modules-validators/rovo/validate-skill-path.jsModified+15−24
Index: package/out/validators/modules-validators/rovo/validate-skill-path.js
===================================================================
--- package/out/validators/modules-validators/rovo/validate-skill-path.js
+++ package/out/validators/modules-validators/rovo/validate-skill-path.js
@@ -5,59 +5,50 @@
const utils_1 = require("../../../utils");
const text_1 = require("../../../text");
const fs_1 = require("fs");
const path_1 = require("path");
-const validateSkillPath = (allModules, resources, manifestDir, yamlContentByLine) => {
+const validateSkillPath = (allModules, manifestDir, yamlContentByLine) => {
const validationErrors = [];
const rovoSkills = allModules[types_1.AllModuleTypes.RovoSkill];
const seenPaths = new Set();
- const resourceMap = new Map((resources ?? []).map((resource) => [resource.key, resource.path]));
rovoSkills?.forEach((skill) => {
- if (seenPaths.has(skill.path)) {
+ const sourceDir = skill.source?.dir;
+ if (typeof sourceDir !== 'string' || sourceDir.trim() === '') {
validationErrors.push({
- message: text_1.errors.modules.rovo.skillPathNotUnique(skill.key, skill.path),
+ message: text_1.errors.modules.rovo.skillPathInvalidFormat(skill.key),
reference: text_1.References.Modules,
level: 'error',
...(0, utils_1.findPosition)(skill.key, yamlContentByLine)
});
return;
}
- seenPaths.add(skill.path);
- const match = utils_1.rovoSkillPathRegex.exec(skill.path);
- if (!match?.groups) {
+ if (seenPaths.has(sourceDir)) {
validationErrors.push({
- message: text_1.errors.modules.rovo.skillPathInvalidFormat(skill.key),
+ message: text_1.errors.modules.rovo.skillPathNotUnique(skill.key, sourceDir),
reference: text_1.References.Modules,
level: 'error',
...(0, utils_1.findPosition)(skill.key, yamlContentByLine)
});
return;
}
- const resourceKey = match.groups.resourceKey;
- const subdirectory = match.groups.subdirectory;
- if (subdirectory.startsWith('..')) {
+ seenPaths.add(sourceDir);
+ if ((0, path_1.isAbsolute)(sourceDir) ||
+ sourceDir.startsWith('..') ||
+ sourceDir.includes('/../') ||
+ sourceDir.includes('\\..\\') ||
+ sourceDir === '..') {
validationErrors.push({
message: text_1.errors.modules.rovo.skillPathInvalidFormat(skill.key),
reference: text_1.References.Modules,
level: 'error',
...(0, utils_1.findPosition)(skill.key, yamlContentByLine)
});
return;
}
- const resourcePath = resourceMap.get(resourceKey);
- if (!resourcePath) {
- validationErrors.push({
- message: text_1.errors.modules.rovo.skillPathUnknownResourceKey(skill.key, resourceKey),
- reference: text_1.References.Modules,
- level: 'error',
- ...(0, utils_1.findPosition)(skill.key, yamlContentByLine)
- });
- return;
- }
- const subdirectoryPath = (0, path_1.resolve)(manifestDir ?? '', resourcePath, subdirectory);
+ const subdirectoryPath = (0, path_1.resolve)(manifestDir ?? '', sourceDir);
if (!(0, fs_1.existsSync)(subdirectoryPath)) {
validationErrors.push({
- message: text_1.errors.modules.rovo.skillSubdirNotFound(skill.key, subdirectory),
+ message: text_1.errors.modules.rovo.skillSubdirNotFound(skill.key, sourceDir),
reference: text_1.References.Modules,
level: 'error',
...(0, utils_1.findPosition)(skill.key, yamlContentByLine)
});
@@ -65,9 +56,9 @@
}
const skillMdPath = (0, path_1.resolve)(subdirectoryPath, 'SKILL.md');
if (!(0, fs_1.existsSync)(skillMdPath)) {
validationErrors.push({
- message: text_1.errors.modules.rovo.skillSubdirMissingSkillMD(skill.key, subdirectory),
+ message: text_1.errors.modules.rovo.skillSubdirMissingSkillMD(skill.key, sourceDir),
reference: text_1.References.Modules,
level: 'error',
...(0, utils_1.findPosition)(skill.key, yamlContentByLine)
});