dsh-plugin-capabilities 0.2.1 → 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,15 +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
- ...typeof record.skillCount === "number" ? { skillCount: record.skillCount } : {}
854
+ ...typeof record.skillCount === "number" ? { skillCount: record.skillCount } : {},
855
+ ...skills !== null ? { skills } : {}
837
856
  });
838
857
  }
839
858
  return out.length > 0 ? out : null;
@@ -863,7 +882,10 @@ function parseMcpIndex(parsed) {
863
882
  ...isString(record.url) ? { url: record.url } : {},
864
883
  homepage: record.homepage,
865
884
  ...isString(record.category) ? { category: record.category } : {},
866
- ...isString(record.runtime) ? { runtime: record.runtime } : {}
885
+ ...isString(record.runtime) ? { runtime: record.runtime } : {},
886
+ ...isStringArray(record.tools) ? { tools: record.tools } : {},
887
+ ...isString(record.detail) ? { detail: record.detail } : {},
888
+ ...isString(record.detailZh) ? { detailZh: record.detailZh } : {}
867
889
  });
868
890
  }
869
891
  return out.length > 0 ? out : null;