skill-distill 1.0.3 → 1.0.5

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.js CHANGED
@@ -606,7 +606,41 @@ ${userPrompts.map((p) => `- ${p}`).join("\n")}` : "";
606
606
  qualityEnhancement(JSON.stringify(skill, null, 2)),
607
607
  SYSTEM_SKILL_WRITER
608
608
  );
609
- return this.parseJson(response, z2.any());
609
+ try {
610
+ const enhanced = this.parseJson(response, z2.any());
611
+ const mergedSteps = (enhanced.steps ?? skill.steps ?? []).map((step) => {
612
+ if (typeof step === "object" && step !== null) {
613
+ const s = step;
614
+ return {
615
+ title: String(s.title ?? s.name ?? "Step"),
616
+ description: String(s.description ?? s.content ?? ""),
617
+ substeps: Array.isArray(s.substeps) ? s.substeps.map(String) : void 0
618
+ };
619
+ }
620
+ return { title: "Step", description: String(step) };
621
+ });
622
+ const mergedExamples = (enhanced.examples ?? skill.examples ?? []).map((ex) => {
623
+ if (typeof ex === "string") return ex;
624
+ if (typeof ex === "object" && ex !== null) {
625
+ const e = ex;
626
+ return String(e.text ?? e.example ?? e.content ?? JSON.stringify(ex));
627
+ }
628
+ return String(ex);
629
+ });
630
+ return {
631
+ metadata: enhanced.metadata ?? skill.metadata ?? { name: "Untitled", description: "", version: "1.0.0" },
632
+ overview: enhanced.overview ?? skill.overview ?? "",
633
+ triggers: enhanced.triggers ?? skill.triggers ?? [],
634
+ prerequisites: enhanced.prerequisites ?? skill.prerequisites ?? [],
635
+ steps: mergedSteps,
636
+ parameters: enhanced.parameters ?? skill.parameters ?? [],
637
+ errorHandling: enhanced.errorHandling ?? skill.errorHandling ?? {},
638
+ examples: mergedExamples,
639
+ notes: enhanced.notes ?? skill.notes ?? []
640
+ };
641
+ } catch {
642
+ return skill;
643
+ }
610
644
  }
611
645
  async generateDescription(intent) {
612
646
  const response = await this.chat(