@skillbase/compiler 0.2.7 → 0.2.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.
package/dist/index.cjs CHANGED
@@ -53,7 +53,9 @@ __export(index_exports, {
53
53
  listTargets: () => listTargets,
54
54
  normalizeCanonical: () => normalizeCanonical,
55
55
  parseSkill: () => parseSkill,
56
+ parseSkillLenient: () => parseSkillLenient,
56
57
  parseSoul: () => parseSoul,
58
+ parseSoulLenient: () => parseSoulLenient,
57
59
  parsedSkillToCanonical: () => parsedSkillToCanonical,
58
60
  parsedSoulToCanonical: () => parsedSoulToCanonical,
59
61
  reorderSections: () => reorderSections,
@@ -223,6 +225,38 @@ function parseSkill(content) {
223
225
  body: body.trim()
224
226
  };
225
227
  }
228
+ function parseSkillLenient(content, options) {
229
+ const { data, content: body } = parseFrontmatter(content);
230
+ const filledDefaults = [];
231
+ if (data.schema_version === void 0 || data.schema_version === "") {
232
+ data.schema_version = 3;
233
+ filledDefaults.push("schema_version");
234
+ }
235
+ if (!data.name) {
236
+ data.name = options?.dirName ? options.dirName.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "") || "imported-skill" : "imported-skill";
237
+ filledDefaults.push("name");
238
+ }
239
+ if (!data.version) {
240
+ data.version = "1.0.0";
241
+ filledDefaults.push("version");
242
+ }
243
+ if (!data.author) {
244
+ data.author = options?.defaultAuthor ?? "unknown";
245
+ filledDefaults.push("author");
246
+ }
247
+ if (!data.license) {
248
+ data.license = options?.defaultLicense ?? "MIT";
249
+ filledDefaults.push("license");
250
+ }
251
+ if (!data.description) {
252
+ data.description = "";
253
+ filledDefaults.push("description");
254
+ }
255
+ return {
256
+ parsed: { frontmatter: data, body: body.trim() },
257
+ filledDefaults
258
+ };
259
+ }
226
260
  function serializeSkill(skill) {
227
261
  return stringifyFrontmatter(skill.body, skill.frontmatter);
228
262
  }
@@ -459,6 +493,34 @@ function parseSoul(content) {
459
493
  body: body.trim()
460
494
  };
461
495
  }
496
+ function parseSoulLenient(content, options) {
497
+ const { data, content: body } = parseFrontmatter(content);
498
+ const filledDefaults = [];
499
+ if (!data.name) {
500
+ data.name = options?.dirName ? options.dirName.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "") || "imported-persona" : "imported-persona";
501
+ filledDefaults.push("name");
502
+ }
503
+ if (!data.version) {
504
+ data.version = "1.0.0";
505
+ filledDefaults.push("version");
506
+ }
507
+ if (!data.author) {
508
+ data.author = options?.defaultAuthor ?? "unknown";
509
+ filledDefaults.push("author");
510
+ }
511
+ if (!data.license) {
512
+ data.license = options?.defaultLicense ?? "MIT";
513
+ filledDefaults.push("license");
514
+ }
515
+ if (!data.description) {
516
+ data.description = "";
517
+ filledDefaults.push("description");
518
+ }
519
+ return {
520
+ parsed: { frontmatter: data, body: body.trim() },
521
+ filledDefaults
522
+ };
523
+ }
462
524
  function serializeSoul(soul) {
463
525
  return stringifyFrontmatter(soul.body, soul.frontmatter);
464
526
  }
@@ -1912,7 +1974,9 @@ function getCompiler(target) {
1912
1974
  listTargets,
1913
1975
  normalizeCanonical,
1914
1976
  parseSkill,
1977
+ parseSkillLenient,
1915
1978
  parseSoul,
1979
+ parseSoulLenient,
1916
1980
  parsedSkillToCanonical,
1917
1981
  parsedSoulToCanonical,
1918
1982
  reorderSections,