dsh-plugin-capabilities 0.3.0 → 0.3.1

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/lib/index.js CHANGED
@@ -816,6 +816,21 @@ function bundledMarketPath(kind) {
816
816
  }
817
817
  var isString = (value) => typeof value === "string" && value !== "";
818
818
  var isStringArray = (value) => Array.isArray(value) && value.every(isString);
819
+ function parseSkillItems(value) {
820
+ if (!Array.isArray(value)) return null;
821
+ const out = [];
822
+ for (const item of value) {
823
+ if (typeof item !== "object" || item === null) continue;
824
+ const record = item;
825
+ if (!isString(record.name)) continue;
826
+ out.push({
827
+ name: record.name,
828
+ ...isString(record.description) ? { description: record.description } : {},
829
+ ...isString(record.descriptionZh) ? { descriptionZh: record.descriptionZh } : {}
830
+ });
831
+ }
832
+ return out.length > 0 ? out : null;
833
+ }
819
834
  function parseSkillsIndex(parsed) {
820
835
  if (typeof parsed !== "object" || parsed === null) return null;
821
836
  const repos = parsed.repos;
@@ -825,16 +840,19 @@ function parseSkillsIndex(parsed) {
825
840
  if (typeof entry !== "object" || entry === null) continue;
826
841
  const record = entry;
827
842
  if (!isString(record.id) || !isString(record.name) || !isString(record.description) || !isString(record.url)) continue;
843
+ const skills = parseSkillItems(record.skills);
828
844
  out.push({
829
845
  id: record.id,
830
846
  name: record.name,
831
847
  ...isString(record.nameZh) ? { nameZh: record.nameZh } : {},
832
848
  description: record.description,
833
849
  ...isString(record.descriptionZh) ? { descriptionZh: record.descriptionZh } : {},
850
+ ...isString(record.detail) ? { detail: record.detail } : {},
851
+ ...isString(record.detailZh) ? { detailZh: record.detailZh } : {},
834
852
  url: record.url,
835
853
  ...isString(record.homepage) ? { homepage: record.homepage } : {},
836
854
  ...typeof record.skillCount === "number" ? { skillCount: record.skillCount } : {},
837
- ...isStringArray(record.skills) ? { skills: record.skills } : {}
855
+ ...skills !== null ? { skills } : {}
838
856
  });
839
857
  }
840
858
  return out.length > 0 ? out : null;
@@ -865,7 +883,9 @@ function parseMcpIndex(parsed) {
865
883
  homepage: record.homepage,
866
884
  ...isString(record.category) ? { category: record.category } : {},
867
885
  ...isString(record.runtime) ? { runtime: record.runtime } : {},
868
- ...isStringArray(record.tools) ? { tools: record.tools } : {}
886
+ ...isStringArray(record.tools) ? { tools: record.tools } : {},
887
+ ...isString(record.detail) ? { detail: record.detail } : {},
888
+ ...isString(record.detailZh) ? { detailZh: record.detailZh } : {}
869
889
  });
870
890
  }
871
891
  return out.length > 0 ? out : null;