@lmzhen/dsh-evolution-core 0.1.0-rc.27 → 0.1.0-rc.28

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
@@ -1696,8 +1696,15 @@ var SkillLibrary = class {
1696
1696
  return summaries;
1697
1697
  }
1698
1698
  async read(name) {
1699
+ if (this.badName(name) !== null) return null;
1699
1700
  return this.io.readText(join(skillDir(this.root, name), "SKILL.md"));
1700
1701
  }
1702
+ /** Name-format guard shared by every path-building mutator/reader. */
1703
+ badName(name) {
1704
+ const normalized = name.trim();
1705
+ if (!SKILL_NAME_RE.test(normalized) || normalized.length > this.limits.maxNameLength) return `Invalid skill name "${normalized}". Use lowercase letters, digits, and hyphens (<= ${this.limits.maxNameLength}).`;
1706
+ return null;
1707
+ }
1701
1708
  async writeProtection(name, origin = "foreground") {
1702
1709
  const dir = skillDir(this.root, name);
1703
1710
  for (const marker of ["bundled", "hub-installed"]) if (await this.io.exists(markerPath(dir, marker))) return marker;
@@ -1720,16 +1727,19 @@ var SkillLibrary = class {
1720
1727
  }
1721
1728
  /** Whether the skill carries the bundled marker (curator prune-builtins eligibility). */
1722
1729
  async isBundled(name) {
1730
+ if (this.badName(name) !== null) return false;
1723
1731
  const dir = skillDir(this.root, name);
1724
1732
  return await this.io.exists(markerPath(dir, "bundled"));
1725
1733
  }
1726
1734
  /** Whether the skill carries the pinned marker (the marker is the factual source; usage.pinned mirrors it). */
1727
1735
  async isPinned(name) {
1736
+ if (this.badName(name) !== null) return false;
1728
1737
  const dir = skillDir(this.root, name);
1729
1738
  return await this.io.exists(markerPath(dir, "pinned"));
1730
1739
  }
1731
1740
  /** Count non-empty support subdirectories (richness input for quality scoring). */
1732
1741
  async countSupportDirs(name) {
1742
+ if (this.badName(name) !== null) return 0;
1733
1743
  const dir = skillDir(this.root, name);
1734
1744
  let entries;
1735
1745
  try {
@@ -1836,6 +1846,11 @@ var SkillLibrary = class {
1836
1846
  };
1837
1847
  }
1838
1848
  async update(name, content, origin = "foreground") {
1849
+ const badName = this.badName(name);
1850
+ if (badName) return {
1851
+ ok: false,
1852
+ message: badName
1853
+ };
1839
1854
  const dir = skillDir(this.root, name);
1840
1855
  const md = await this.io.readText(join(dir, "SKILL.md"));
1841
1856
  if (!md) return {
@@ -1866,6 +1881,11 @@ var SkillLibrary = class {
1866
1881
  };
1867
1882
  }
1868
1883
  async patch(name, oldString, newString, filePath = "", replaceAll = false, origin = "foreground") {
1884
+ const badName = this.badName(name);
1885
+ if (badName) return {
1886
+ ok: false,
1887
+ message: badName
1888
+ };
1869
1889
  const dir = skillDir(this.root, name);
1870
1890
  const skillMd = join(dir, "SKILL.md");
1871
1891
  if (!await this.io.exists(skillMd)) return {
@@ -1927,6 +1947,11 @@ var SkillLibrary = class {
1927
1947
  };
1928
1948
  }
1929
1949
  async archive(name, options = {}) {
1950
+ const badName = this.badName(name);
1951
+ if (badName) return {
1952
+ ok: false,
1953
+ message: badName
1954
+ };
1930
1955
  const dir = skillDir(this.root, name);
1931
1956
  const md = await this.io.readText(join(dir, "SKILL.md"));
1932
1957
  if (!md) return {
@@ -2085,6 +2110,11 @@ var SkillLibrary = class {
2085
2110
  };
2086
2111
  }
2087
2112
  async writeSupportFile(name, filePath, content, origin = "foreground") {
2113
+ const badName = this.badName(name);
2114
+ if (badName) return {
2115
+ ok: false,
2116
+ message: badName
2117
+ };
2088
2118
  const dir = skillDir(this.root, name);
2089
2119
  if (!await this.io.exists(join(dir, "SKILL.md"))) return {
2090
2120
  ok: false,
@@ -2120,6 +2150,11 @@ var SkillLibrary = class {
2120
2150
  };
2121
2151
  }
2122
2152
  async removeSupportFile(name, filePath, origin = "foreground") {
2153
+ const badName = this.badName(name);
2154
+ if (badName) return {
2155
+ ok: false,
2156
+ message: badName
2157
+ };
2123
2158
  const dir = skillDir(this.root, name);
2124
2159
  if (!await this.io.exists(join(dir, "SKILL.md"))) return {
2125
2160
  ok: false,
@@ -57,6 +57,8 @@ export declare class SkillLibrary {
57
57
  constructor(root?: string, io?: EvolutionIoLike, limits?: SkillLimits);
58
58
  list(): Promise<SkillSummary[]>;
59
59
  read(name: string): Promise<string | null>;
60
+ /** Name-format guard shared by every path-building mutator/reader. */
61
+ private badName;
60
62
  writeProtection(name: string, origin?: WriteOrigin): Promise<string | null>;
61
63
  deleteProtection(name: string, options?: {
62
64
  allowBundled?: boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-evolution-core",
3
3
  "description": "Shared stores, prompts, signals and lifecycle logic for the dsh-evolution plugin family (community build)",
4
- "version": "0.1.0-rc.27",
4
+ "version": "0.1.0-rc.28",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },