dsh-skill-hub 0.3.19 → 0.3.20

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/CONTRIBUTING.md CHANGED
@@ -39,7 +39,7 @@ src/client/locales/ dictionaries by view (common/skills/market/sources/detai
39
39
  ```bash
40
40
  npm install
41
41
  npm run typecheck # tsc --noEmit
42
- npm test # vitest (258 tests across 14 suites)
42
+ npm test # vitest (266 tests across 14 suites)
43
43
  npm run build # tsc declarations + tsdown bundles (lib/index.js + lib/client.js)
44
44
  ```
45
45
 
package/README.md CHANGED
@@ -108,7 +108,7 @@ Host uses only `ctx.skills.snapshot/get`, `ctx.webServer.register`, `ctx.systemP
108
108
 
109
109
  ```bash
110
110
  npm run typecheck # tsc --noEmit
111
- npm test # 258 tests, 14 suites
111
+ npm test # 266 tests, 14 suites
112
112
  npm run build # tsc + tsdown → lib/index.js + lib/client.js
113
113
  ```
114
114
 
package/README.zh.md CHANGED
@@ -108,7 +108,7 @@ GitHub 仓库 ──扫描/导入──▶ ~/.dsh/skills
108
108
 
109
109
  ```bash
110
110
  npm run typecheck # tsc --noEmit
111
- npm test # 258 tests, 14 suites
111
+ npm test # 266 tests, 14 suites
112
112
  npm run build # tsc + tsdown → lib/index.js + lib/client.js
113
113
  ```
114
114
 
package/lib/client.js CHANGED
@@ -61,6 +61,10 @@ window.__ModuleLoader__.load({
61
61
  * `ctx.settings.update(HUB_ENTRY_ID, …)`.
62
62
  */
63
63
  const HUB_ENTRY_ID = "skill-hub";
64
+ /** HEX color validation shared by host routes and the settings card. */
65
+ const HEX_COLOR_RE = /^#[0-9a-f]{6}$/i;
66
+ /** GitHub token validation shared by host routes and the settings card. */
67
+ const GITHUB_TOKEN_RE = /^[A-Za-z0-9_\-]{8,255}$/;
64
68
  //#endregion
65
69
  //#region src/protocol/sources.ts
66
70
  /** 项目级技能来源(它们有 workspace 归属,不属于「个人」组)。 */
@@ -161,7 +165,7 @@ window.__ModuleLoader__.load({
161
165
  market() {
162
166
  return this.get(SKILL_HUB_API.market);
163
167
  }
164
- /** Add a market source repo; resolves with the fresh list. */
168
+ /** Add a market source repo; resolves with the fresh list plus the resolved slug. */
165
169
  addMarketSource(repo) {
166
170
  return this.post(SKILL_HUB_API.marketSource, { repo });
167
171
  }
@@ -1542,7 +1546,7 @@ window.__ModuleLoader__.load({
1542
1546
  });
1543
1547
  }
1544
1548
  function ColorField(props) {
1545
- const value = /^#[0-9a-f]{6}$/i.test(props.text) ? props.text : props.defaultColor;
1549
+ const value = HEX_COLOR_RE.test(props.text) ? props.text : props.defaultColor;
1546
1550
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1547
1551
  className: settings_card_module_css_default.field,
1548
1552
  children: [
@@ -2360,9 +2364,9 @@ window.__ModuleLoader__.load({
2360
2364
  function colorField(field) {
2361
2365
  return {
2362
2366
  field,
2363
- format: (value) => typeof value === "string" && /^#[0-9a-f]{6}$/i.test(value) ? value : "",
2367
+ format: (value) => typeof value === "string" && HEX_COLOR_RE.test(value) ? value : "",
2364
2368
  parse: (text) => {
2365
- if (/^#[0-9a-f]{6}$/i.test(text)) return {
2369
+ if (HEX_COLOR_RE.test(text)) return {
2366
2370
  kind: "set",
2367
2371
  value: text
2368
2372
  };
@@ -2381,7 +2385,7 @@ window.__ModuleLoader__.load({
2381
2385
  parse: (text) => {
2382
2386
  const trimmed = text.trim();
2383
2387
  if (trimmed === "") return void 0;
2384
- if (!/^[A-Za-z0-9_-]{8,255}$/.test(trimmed)) return void 0;
2388
+ if (!GITHUB_TOKEN_RE.test(trimmed)) return void 0;
2385
2389
  return {
2386
2390
  kind: "set",
2387
2391
  value: trimmed
@@ -6424,7 +6428,7 @@ window.__ModuleLoader__.load({
6424
6428
  setNewSourceName("");
6425
6429
  setRepoResult(null);
6426
6430
  setRepoSelected(/* @__PURE__ */ new Set());
6427
- const slug = result.repos[result.repos.length - 1].repo;
6431
+ const slug = result.repo;
6428
6432
  setScanningRepo(slug);
6429
6433
  setRepoDiscoverState({ status: "scanning" });
6430
6434
  try {