dsh-skill-hub 0.3.7 → 0.3.8

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.
Files changed (109) hide show
  1. package/README.md +40 -50
  2. package/README.zh.md +38 -48
  3. package/lib/client.js +2209 -1820
  4. package/lib/client.js.map +1 -1
  5. package/lib/index.js +653 -419
  6. package/lib/types/client/SkillHubSettingsCard.d.ts +1 -0
  7. package/lib/types/client/api.d.ts +12 -6
  8. package/lib/types/client/helpers.d.ts +0 -1
  9. package/lib/types/client/locales/common.d.ts +52 -0
  10. package/lib/types/client/locales/detail.d.ts +16 -0
  11. package/lib/types/client/locales/market.d.ts +73 -0
  12. package/lib/types/client/locales/settings.d.ts +41 -0
  13. package/lib/types/client/locales/skills.d.ts +65 -0
  14. package/lib/types/client/locales/sources.d.ts +35 -0
  15. package/lib/types/client/locales.d.ts +124 -118
  16. package/lib/types/client/panel/MarketSourceRow.d.ts +12 -0
  17. package/lib/types/client/panel/MarketView.d.ts +1 -0
  18. package/lib/types/client/panel/RepoScanCard.d.ts +10 -0
  19. package/lib/types/client/panel/hooks/shared.d.ts +72 -0
  20. package/lib/types/client/panel/hooks/useCatalogFlow.d.ts +62 -0
  21. package/lib/types/client/panel/hooks/useGroupFlow.d.ts +41 -0
  22. package/lib/types/client/panel/hooks/useMarketFlow.d.ts +73 -0
  23. package/lib/types/client/panel/hooks/useMetaFlow.d.ts +18 -0
  24. package/lib/types/client/panel/hooks/useSourceFlow.d.ts +44 -0
  25. package/lib/types/client/panel/market-format.d.ts +6 -0
  26. package/lib/types/client/panel/useSkillHub.d.ts +45 -73
  27. package/lib/types/client/settings-card.d.ts +20 -0
  28. package/lib/types/client/settings-form.d.ts +6 -0
  29. package/lib/types/protocol/api.d.ts +38 -0
  30. package/lib/types/protocol/catalog.d.ts +155 -0
  31. package/lib/types/protocol/config.d.ts +113 -0
  32. package/lib/types/protocol/groups.d.ts +95 -0
  33. package/lib/types/protocol/market.d.ts +94 -0
  34. package/lib/types/protocol/repo.d.ts +107 -0
  35. package/lib/types/protocol/sources.d.ts +139 -0
  36. package/lib/types/protocol/stats.d.ts +46 -0
  37. package/lib/types/protocol.d.ts +13 -743
  38. package/lib/types/repo/github-client.d.ts +42 -0
  39. package/lib/types/repo.d.ts +6 -17
  40. package/lib/types/routes/catalog.d.ts +7 -0
  41. package/lib/types/routes/config.d.ts +7 -0
  42. package/lib/types/routes/groups.d.ts +7 -0
  43. package/lib/types/routes/helpers.d.ts +145 -0
  44. package/lib/types/routes/market.d.ts +8 -0
  45. package/lib/types/routes/repo-import.d.ts +7 -0
  46. package/lib/types/routes/route-state.d.ts +55 -0
  47. package/lib/types/routes/sources.d.ts +8 -0
  48. package/lib/types/routes.d.ts +5 -34
  49. package/lib/types/stats.d.ts +3 -2
  50. package/lib/types/store/errors.d.ts +10 -0
  51. package/lib/types/store/migrate.d.ts +44 -0
  52. package/lib/types/store/paths.d.ts +32 -0
  53. package/lib/types/store/store.d.ts +133 -0
  54. package/lib/types/store.d.ts +7 -146
  55. package/package.json +28 -27
  56. package/src/client/SkillHubSettingsCard.tsx +17 -3
  57. package/src/client/api.ts +101 -195
  58. package/src/client/helpers.ts +10 -1
  59. package/src/client/locales/common.ts +102 -0
  60. package/src/client/locales/detail.ts +30 -0
  61. package/src/client/locales/market.ts +144 -0
  62. package/src/client/locales/settings.ts +80 -0
  63. package/src/client/locales/skills.ts +128 -0
  64. package/src/client/locales/sources.ts +68 -0
  65. package/src/client/locales.ts +26 -512
  66. package/src/client/panel/MarketSourceRow.tsx +108 -0
  67. package/src/client/panel/MarketView.tsx +12 -253
  68. package/src/client/panel/RepoScanCard.tsx +171 -0
  69. package/src/client/panel/hooks/shared.ts +81 -0
  70. package/src/client/panel/hooks/useCatalogFlow.ts +211 -0
  71. package/src/client/panel/hooks/useGroupFlow.ts +240 -0
  72. package/src/client/panel/hooks/useMarketFlow.ts +421 -0
  73. package/src/client/panel/hooks/useMetaFlow.ts +58 -0
  74. package/src/client/panel/hooks/useSourceFlow.ts +193 -0
  75. package/src/client/panel/market-format.ts +22 -0
  76. package/src/client/panel/useSkillHub.ts +141 -1032
  77. package/src/client/settings-card.tsx +51 -0
  78. package/src/client/settings-form.ts +18 -0
  79. package/src/index.ts +14 -4
  80. package/src/protocol/api.ts +38 -0
  81. package/src/protocol/catalog.ts +168 -0
  82. package/src/protocol/config.ts +145 -0
  83. package/src/protocol/groups.ts +106 -0
  84. package/src/protocol/market.ts +100 -0
  85. package/src/protocol/repo.ts +104 -0
  86. package/src/protocol/sources.ts +146 -0
  87. package/src/protocol/stats.ts +42 -0
  88. package/src/protocol.ts +83 -809
  89. package/src/repo/github-client.ts +131 -0
  90. package/src/repo.test.ts +24 -1
  91. package/src/repo.ts +50 -170
  92. package/src/routes/catalog.ts +309 -0
  93. package/src/routes/config.ts +119 -0
  94. package/src/routes/groups.ts +133 -0
  95. package/src/routes/helpers.ts +489 -0
  96. package/src/routes/market.ts +255 -0
  97. package/src/routes/repo-import.ts +267 -0
  98. package/src/routes/route-state.ts +89 -0
  99. package/src/routes/sources.ts +318 -0
  100. package/src/routes.test.ts +20 -0
  101. package/src/routes.ts +21 -1699
  102. package/src/stats.test.ts +58 -3
  103. package/src/stats.ts +45 -16
  104. package/src/store/errors.ts +14 -0
  105. package/src/store/migrate.ts +272 -0
  106. package/src/store/paths.ts +43 -0
  107. package/src/store/store.ts +532 -0
  108. package/src/store.test.ts +18 -0
  109. package/src/store.ts +7 -737
@@ -3,747 +3,17 @@
3
3
  * both the host half and the browser half import. The browser half must never
4
4
  * depend on host SDK packages, so registry types are re-spelled here as
5
5
  * plain JSON-safe interfaces.
6
+ *
7
+ * 按域拆分后的重导出入口:老 `from './protocol.ts'` 写法保持可用,
8
+ * 新代码可按需直引 `from './protocol/<domain>.ts'`。
6
9
  */
7
- /** Browser-facing base paths of the skill-hub API family. */
8
- export declare const SKILL_HUB_API: {
9
- readonly catalog: "/api/skill-hub/catalog";
10
- readonly skill: "/api/skill-hub/skill";
11
- readonly skillDelete: "/api/skill-hub/skill/delete";
12
- readonly toggle: "/api/skill-hub/toggle";
13
- readonly toggleBatch: "/api/skill-hub/toggle-batch";
14
- readonly create: "/api/skill-hub/create";
15
- readonly stats: "/api/skill-hub/stats";
16
- readonly config: "/api/skill-hub/config";
17
- readonly market: "/api/skill-hub/market";
18
- readonly marketSource: "/api/skill-hub/market/source";
19
- readonly marketSourceDelete: "/api/skill-hub/market/source/delete";
20
- readonly marketSourceRef: "/api/skill-hub/market/source/ref";
21
- readonly marketCheck: "/api/skill-hub/market/check";
22
- readonly marketSync: "/api/skill-hub/market/source/sync";
23
- readonly repo: "/api/skill-hub/repo";
24
- readonly repoImport: "/api/skill-hub/repo/import";
25
- readonly repoImportProgress: "/api/skill-hub/repo/import/progress";
26
- readonly repoImportCancel: "/api/skill-hub/repo/import/cancel";
27
- readonly update: "/api/skill-hub/update";
28
- readonly groups: "/api/skill-hub/groups";
29
- readonly tag: "/api/skill-hub/tag";
30
- readonly tagDelete: "/api/skill-hub/tag/delete";
31
- readonly tagMembers: "/api/skill-hub/tag/members";
32
- readonly tagReorder: "/api/skill-hub/tag/reorder";
33
- readonly collectionReorder: "/api/skill-hub/collections/reorder";
34
- readonly sourceGroupReorder: "/api/skill-hub/source-groups/reorder";
35
- readonly sources: "/api/skill-hub/sources";
36
- readonly sourceCheck: "/api/skill-hub/sources/check";
37
- readonly sourceSync: "/api/skill-hub/sources/sync";
38
- readonly sourceDelete: "/api/skill-hub/sources/delete";
39
- readonly sourceRestore: "/api/skill-hub/sources/restore";
40
- readonly sourceTrashClear: "/api/skill-hub/sources/trash/clear";
41
- readonly diagnosticFix: "/api/skill-hub/diagnostic/fix";
42
- readonly marketSourceVersions: "/api/skill-hub/market/source/versions";
43
- };
44
- /** User-level roots the hub may write to (matches dsh-skill-filesystem ranks 400/500). */
45
- export type WritableRoot = 'user-dsh' | 'user-agents';
46
- /** Invocation policy resolved by the registry, re-spelled for the wire. */
47
- export interface HubInvocation {
48
- /** Whether model-facing catalogs may load this skill. */
49
- modelInvocable: boolean;
50
- /** Whether human-facing command catalogs may load this skill. */
51
- userInvocable: boolean;
52
- }
53
- /** One enabled skill row in the catalog. */
54
- export interface CatalogSkill {
55
- name: string;
56
- description: string;
57
- whenToUse?: string;
58
- invocation: HubInvocation;
59
- provider: string;
60
- /** Whether the hub may toggle this skill (user-level filesystem skills only). */
61
- writable: boolean;
62
- /** 技能来源标识(user-dsh/user-agents/project-dsh/project-agents/...)。 */
63
- source: string;
64
- /** SKILL.md creation time (epoch ms); used for "added" sorting. Absent when unknown. */
65
- addedAt?: number;
66
- /** SKILL.md last-modified time (epoch ms); used for "updated" display. Absent when unknown. */
67
- updatedAt?: number;
68
- /** 项目技能的所属工作区路径(仅 project-dsh/project-agents 来源携带)。 */
69
- workspace?: string;
70
- /** 工作区显示标题(来自 workspace.json;无则回退为路径)。 */
71
- workspaceTitle?: string;
72
- /** UI metadata from agents/openai.yaml (mirrors codex SkillInterface). */
73
- displayName?: string;
74
- shortDescription?: string;
75
- brandColor?: string;
76
- iconSmall?: string;
77
- iconLarge?: string;
78
- defaultPrompt?: string;
79
- }
80
- /** One disabled skill tracked by the hub sidecar (SKILL.md renamed away). */
81
- export interface DisabledSkill {
82
- name: string;
83
- description: string;
84
- /** Absolute path of the renamed file (SKILL.md.disabled / <name>.md.disabled). */
85
- path: string;
86
- root: WritableRoot;
87
- disabledAt: number;
88
- }
89
- /** One discovery diagnostic: a file the filesystem provider skips, with the reason. */
90
- export interface DiagnosticEntry {
91
- path: string;
92
- root: string;
93
- reason: string;
94
- /** Whether this diagnostic can be auto-fixed (e.g. unquoted colon). */
95
- fixable?: boolean;
96
- }
97
- /** POST /api/skill-hub/diagnostic/fix — repair a fixable diagnostic in place. */
98
- export interface DiagnosticFixRequest {
99
- path: string;
100
- }
101
- export interface DiagnosticFixResponse {
102
- ok: true;
103
- path: string;
104
- }
105
- /** GET /api/skill-hub/catalog */
106
- export interface CatalogResponse {
107
- ok: true;
108
- /** 已安装插件自身的版本号(package.json version),面板标题旁显示。 */
109
- pluginVersion: string;
110
- /** Whether discovery completed within a stable catalog revision. */
111
- complete: boolean;
112
- /** Sorted winning summaries of every enabled skill (all roots + providers). */
113
- skills: CatalogSkill[];
114
- /** Skills the hub has toggled off (kept outside provider discovery). */
115
- disabled: DisabledSkill[];
116
- /** Files in the writable roots the provider ignores, with reasons. */
117
- diagnostics: DiagnosticEntry[];
118
- /** Skill names that appeared in multiple roots (first wins, others hidden). Mirrors codex name_counts. */
119
- duplicateNames?: string[];
120
- }
121
- /** GET /api/skill-hub/skill */
122
- export interface SkillDetail {
123
- name: string;
124
- description: string;
125
- whenToUse?: string;
126
- invocation: HubInvocation;
127
- provider: string;
128
- /** Absolute file path when the skill came from disk. */
129
- path?: string;
130
- /** SKILL.md creation time (epoch ms); absent when the file is unreadable. */
131
- addedAt?: number;
132
- /** SKILL.md last-modified time (epoch ms); absent when the file is unreadable. */
133
- updatedAt?: number;
134
- /** Markdown instruction body. */
135
- content: string;
136
- displayName?: string;
137
- shortDescription?: string;
138
- brandColor?: string;
139
- iconSmall?: string;
140
- iconLarge?: string;
141
- defaultPrompt?: string;
142
- }
143
- export interface SkillDetailResponse {
144
- ok: true;
145
- skill: SkillDetail;
146
- }
147
- /** POST /api/skill-hub/skill/delete — 把单个技能移入回收站(可恢复)。 */
148
- export interface SkillDeleteRequest {
149
- name: string;
150
- }
151
- /** POST /api/skill-hub/skill/delete */
152
- export interface SkillDeleteResponse {
153
- ok: true;
154
- name: string;
155
- /** 移入回收站后的路径(目录或文件)。 */
156
- path: string;
157
- }
158
- /** POST /api/skill-hub/toggle */
159
- export interface ToggleRequest {
160
- /** Kebab-case skill name. */
161
- name: string;
162
- /** true re-enables a hub-disabled skill; false disables an enabled one. */
163
- enabled: boolean;
164
- }
165
- export interface ToggleResponse {
166
- ok: true;
167
- /** Fresh catalog after the mutation (the filesystem provider may lag a beat). */
168
- catalog: CatalogResponse;
169
- }
170
- /** POST /api/skill-hub/toggle-batch — one group of skills, one write. */
171
- export interface ToggleBatchRequest {
172
- names: string[];
173
- enabled: boolean;
174
- }
175
- /** POST /api/skill-hub/toggle-batch */
176
- export interface ToggleBatchResponse {
177
- ok: true;
178
- catalog: CatalogResponse;
179
- /** Per-name failures (unknown/read-only skills); empty means all landed. */
180
- failures: Array<{
181
- name: string;
182
- error: string;
183
- }>;
184
- }
185
- /** POST /api/skill-hub/create */
186
- export interface CreateRequest {
187
- /** Kebab-case skill name (validated with the official isSkillName grammar). */
188
- name: string;
189
- /** Optional one-line routing description for the frontmatter. */
190
- description?: string;
191
- /** Target user root; defaults to user-dsh (~/.dsh/skills). */
192
- root?: WritableRoot;
193
- }
194
- export interface CreateResponse {
195
- ok: true;
196
- path: string;
197
- root: WritableRoot;
198
- }
199
- /** One skill's invocation stats across the local session logs. */
200
- export interface SkillStat {
201
- /** Kebab-case skill name. */
202
- name: string;
203
- /** How many sessions recorded a user-explicit invocation of this skill. */
204
- count: number;
205
- /** Unix epoch ms of the most recent invocation (absent when never called). */
206
- lastUsed?: number;
207
- }
208
- /** GET /api/skill-hub/stats */
209
- export interface StatsResponse {
210
- ok: true;
211
- /** Whether a session-log source was available (false means counts are empty). */
212
- available: boolean;
213
- /** Sorted per-skill invocation counts. */
214
- stats: SkillStat[];
215
- }
216
- /**
217
- * Persisted incremental-scan checkpoint for the usage statistics (sidecar
218
- * `skillStats` field). Sessions created before `frozenBefore` are treated as
219
- * finalized: their per-session counts live in `frozenSessions` (only sessions
220
- * with at least one invocation are kept) and they are not re-read on
221
- * incremental scans. A daily full reconciliation rebuilds the cache and
222
- * advances the watermark, so a resumed old session is eventually re-counted.
223
- */
224
- export interface SkillStatsCheckpoint {
225
- /** The rolling-window configuration this checkpoint was built for (0 = all history). */
226
- windowDays: number;
227
- /** Watermark: every session with header.createdAt < this value is frozen. */
228
- frozenBefore: number;
229
- /** Per-session counts of finalized sessions, keyed by session id. */
230
- frozenSessions: Record<string, {
231
- createdAt: number;
232
- counts: Record<string, {
233
- count: number;
234
- lastUsed: number;
235
- }>;
236
- }>;
237
- /** Epoch ms of the last full reconciliation (drives the daily cadence). */
238
- lastFullReconcile: number;
239
- }
240
- /** JSON error body shared by every route. */
241
- export interface ErrorResponse {
242
- error: string;
243
- }
244
- /** The skill hub's own runtime configuration, edited from the settings card. */
245
- export interface HubConfig {
246
- /** Master switch: routes, provider, and announcement all go live with this. */
247
- enabled: boolean;
248
- /** When true, a system-prompt section announces the hub to every agent. */
249
- announceToAgent: boolean;
250
- /** Model-invocable dot color (#rrggbb); absent means the panel default. */
251
- dotModelColor?: string;
252
- /** User-invocable dot color (#rrggbb); absent means the panel default. */
253
- dotUserColor?: string;
254
- /** Show per-skill invocation count chip. Default true. */
255
- showUseCount?: boolean;
256
- /** Show per-skill last-used relative time. Default true. */
257
- showUseTime?: boolean;
258
- /** Show group-header usage summaries (count + last used). Default true. */
259
- showGroupSummary?: boolean;
260
- /** 统计滚动窗口天数:只统计最近 N 天的使用;0 = 全部历史。默认 0。 */
261
- statsWindowDays?: number;
262
- /** 自动统计扫描间隔(分钟,最小 1)。默认 5。 */
263
- statsScanMinutes?: number;
264
- }
265
- /**
266
- * The resolved shape of the hub's settings namespace (schema defaults, then
267
- * the composition base, then the user layer). Kept as a type alias so the
268
- * browser-side settings scope snapshot is index-compatible with the card
269
- * form's record shape.
270
- */
271
- export type HubSettingsValue = {
272
- enabled: boolean;
273
- announceToAgent: boolean;
274
- showUseCount: boolean;
275
- showUseTime: boolean;
276
- showGroupSummary: boolean;
277
- /** Model-invocable dot color (#rrggbb); absent means the panel default. */
278
- dotModelColor?: string;
279
- /** User-invocable dot color (#rrggbb); absent means the panel default. */
280
- dotUserColor?: string;
281
- /** 统计滚动窗口天数(0 = 全部历史)。 */
282
- statsWindowDays?: number;
283
- /** 自动统计扫描间隔(分钟)。 */
284
- statsScanMinutes?: number;
285
- };
286
- /**
287
- * Hub config defaults — the single source every layer reads: the cordis
288
- * schema (index.ts), the host's saved-override merge, and the routes'
289
- * fallback view. Changing a default here changes all three.
290
- */
291
- export declare const HUB_CONFIG_DEFAULTS: {
292
- readonly enabled: true;
293
- readonly announceToAgent: true;
294
- readonly showUseCount: true;
295
- readonly showUseTime: true;
296
- readonly showGroupSummary: true;
297
- readonly statsWindowDays: 14;
298
- readonly statsScanMinutes: 5;
299
- };
300
- /**
301
- * Resolve the effective hub config: saved sidecar overrides win over the
302
- * cordis composition entry (the web card owns runtime config), missing
303
- * booleans fall back to HUB_CONFIG_DEFAULTS, and dot colors pass through
304
- * (saved first, then base) only when set. Numeric stats knobs are clamped to
305
- * their sane ranges (window ≥ 0, scan interval ≥ 1 minute).
306
- */
307
- export declare function resolveHubConfig(saved: Partial<HubConfig>, base?: Partial<HubConfig>): HubConfig;
308
- /** HEX color validation shared by host routes and the settings card. */
309
- export declare const HEX_COLOR_RE: RegExp;
310
- /** GET /api/skill-hub/config */
311
- export interface ConfigResponse {
312
- ok: true;
313
- /** 已安装插件自身的版本号(package.json version),设置卡标题旁显示。 */
314
- pluginVersion: string;
315
- /** Effective configuration (saved overrides merged over the defaults). */
316
- config: HubConfig;
317
- /** Raw user overrides persisted in the sidecar (absent fields inherit defaults). */
318
- saved: Partial<HubConfig>;
319
- }
320
- /** POST /api/skill-hub/config — a partial patch; omitted fields keep their values. */
321
- export interface ConfigRequest {
322
- /** Set the field; null clears the saved override so it re-inherits the default. */
323
- enabled?: boolean | null;
324
- /** Set the field; null clears the saved override so it re-inherits the default. */
325
- announceToAgent?: boolean | null;
326
- /** Set the field; null clears the saved override so it re-inherits the default. */
327
- showUseCount?: boolean | null;
328
- /** Set the field; null clears the saved override so it re-inherits the default. */
329
- showUseTime?: boolean | null;
330
- /** Set the field; null clears the saved override so it re-inherits the default. */
331
- showGroupSummary?: boolean | null;
332
- /** Set the dot color; null clears the saved override so it re-inherits the default. */
333
- dotModelColor?: string | null;
334
- /** Set the dot color; null clears the saved override so it re-inherits the default. */
335
- dotUserColor?: string | null;
336
- /** 统计滚动窗口天数(0 = 全部历史);null 清除覆盖回默认。 */
337
- statsWindowDays?: number | null;
338
- /** 自动统计扫描间隔(分钟);null 清除覆盖回默认。 */
339
- statsScanMinutes?: number | null;
340
- }
341
- /** One market source: a tracked upstream repo plus its pinned version. */
342
- export interface MarketSourceRecord {
343
- /** Repo slug (owner/repo). */
344
- repo: string;
345
- /** Pinned version: release tag, branch name, or custom ref. Absent = not yet pinned. */
346
- ref?: string;
347
- /** Commit the pinned ref last resolved to (update-check baseline). */
348
- commitSha?: string;
349
- }
350
- /** GET /api/skill-hub/market — the user's added market sources. */
351
- export interface MarketSourcesResponse {
352
- ok: true;
353
- /** Added market sources, in addition order. */
354
- repos: MarketSourceRecord[];
355
- }
356
- /** POST /api/skill-hub/market/source — add one repo as a market source. */
357
- export interface MarketSourceRequest {
358
- /** owner/repo, owner/repo@ref, or a github.com URL. */
359
- repo: string;
360
- }
361
- /** POST /api/skill-hub/market/source|delete */
362
- export interface MarketSourceResponse {
363
- ok: true;
364
- repos: MarketSourceRecord[];
365
- }
366
- /** POST /api/skill-hub/market/source/ref — pin a market source to an explicit ref. */
367
- export interface MarketSourceRefRequest {
368
- repo: string;
369
- /** Release tag or branch name chosen for the repo. */
370
- ref: string;
371
- }
372
- /** GET /api/skill-hub/market/source/versions?repo= — releases + branches for the version picker. */
373
- export interface MarketSourceVersionsResponse {
374
- ok: true;
375
- repo: string;
376
- /** Currently pinned ref, when one is recorded. */
377
- current?: string;
378
- /** Release tags, newest first (drafts excluded). */
379
- releases: string[];
380
- /** Branch names, default branch first. */
381
- branches: string[];
382
- }
383
- /** GET /api/skill-hub/market/check — update check over market sources. */
384
- export interface MarketCheckResponse {
385
- ok: true;
386
- results: Array<{
387
- repo: string;
388
- /** Pinned ref, when one is recorded. */
389
- ref?: string;
390
- /** Latest release tag on the repo, when it has one. */
391
- latestTag?: string;
392
- /** Whether the pinned ref (or the repo) has moved ahead. */
393
- updateAvailable: boolean;
394
- /** Latest commit of the checked ref. */
395
- commitSha: string;
396
- /** Throttled: the check was skipped within the interval. */
397
- throttled?: boolean;
398
- error?: string;
399
- }>;
400
- }
401
- /** POST /api/skill-hub/market/source/sync — align a market source to its pinned ref. */
402
- export interface MarketSyncResponse {
403
- ok: true;
404
- repo: string;
405
- /** The ref the source is now pinned to. */
406
- ref: string;
407
- commitSha: string;
408
- /** Local skills tracked from this repo (candidates for a batch update). */
409
- skills: string[];
410
- }
411
- /** A skill discovered in a GitHub repo under any top-level root (e.g. skills/, templates/). */
412
- export interface RepoSkillEntry {
413
- /** Kebab-case skill name (directory basename). */
414
- name: string;
415
- /** Root-relative skill directory, e.g. skills/code-review. */
416
- dir: string;
417
- /** Root-relative SKILL.md path, e.g. skills/code-review/SKILL.md. */
418
- path: string;
419
- /** Repo root the skill lives in. */
420
- root: RepoRoot;
421
- /** Collection name recorded as origin after import. */
422
- origin: string;
423
- /** Number of files in the skill directory. */
424
- fileCount: number;
425
- /** Total bytes across all files in the skill directory. */
426
- totalBytes: number;
427
- /** Whether a same-named skill already exists locally. */
428
- existing: boolean;
429
- }
430
- /** Skill root in a GitHub repo: the top-level directory that contains skills (e.g. skills, design-templates, templates). Auto-derived from SKILL.md locations, not hard-coded. */
431
- export type RepoRoot = string;
432
- /** GET /api/skill-hub/repo — discover importable skills in a GitHub repo. */
433
- export interface RepoDiscoverResponse {
434
- ok: true;
435
- repo: string;
436
- /**
437
- * Ref the discovery ran against (release tag / branch / default branch).
438
- * Null means the repo has no release and no pinned ref — the client must
439
- * ask the user to pick a branch (see `branches`) and pin it first.
440
- */
441
- ref: string | null;
442
- /** Branch names to choose from when ref is null (default branch first). */
443
- branches?: string[];
444
- entries: RepoSkillEntry[];
445
- /** GitHub truncated the tree; discovery is partial (mirrors codex walk_truncated). */
446
- truncated?: boolean;
447
- }
448
- /** POST /api/skill-hub/repo/import — install selected repo skills. */
449
- export interface RepoImportRequest {
450
- repo: string;
451
- /** Selected SKILL.md paths from the discover response. */
452
- paths: string[];
453
- /** The ref the discovery ran against; the import must use the same one. */
454
- ref?: string;
455
- }
456
- /** POST /api/skill-hub/repo/import — now creates an async job (B方案) */
457
- export interface RepoImportResponse {
458
- ok: true;
459
- jobId: string;
460
- total: number;
461
- totalBytes: number;
462
- }
463
- /** GET /api/skill-hub/repo/import/progress?jobId=xxx */
464
- export interface RepoImportProgressResponse {
465
- ok: true;
466
- jobId: string;
467
- status: 'running' | 'done' | 'cancelled' | 'error';
468
- total: number;
469
- done: number;
470
- /** 当前正在下载的 skill 名,done < total 时有效 */
471
- current?: string;
472
- /** 当前正在下载的文件路径(相对 skill dir) */
473
- currentFile?: string;
474
- /** 字节级进度 */
475
- totalBytes: number;
476
- downloadedBytes: number;
477
- /** 下载速度 bytes/sec,running 时有效 */
478
- bytesPerSecond?: number;
479
- imported: Array<{
480
- name: string;
481
- origin: string;
482
- path: string;
483
- }>;
484
- skipped: Array<{
485
- name: string;
486
- reason: 'exists';
487
- }>;
488
- failed: Array<{
489
- name: string;
490
- error: string;
491
- }>;
492
- /** error 状态时的原因 */
493
- error?: string;
494
- }
495
- /** POST /api/skill-hub/repo/import/cancel */
496
- export interface RepoImportCancelRequest {
497
- jobId: string;
498
- }
499
- export interface RepoImportCancelResponse {
500
- ok: true;
501
- jobId: string;
502
- status: 'cancelled' | 'done';
503
- }
504
- /** GET /api/skill-hub/update — check the plugin's own latest GitHub release. */
505
- export interface UpdateCheckResponse {
506
- ok: true;
507
- /** Installed plugin version (from the bundled host build). */
508
- currentVersion: string;
509
- /** Latest release tag, normalized without the leading v; null when unknown. */
510
- latestVersion: string | null;
511
- /** True when latestVersion is strictly newer than currentVersion. */
512
- updateAvailable: boolean;
513
- /** Release page URL; null when unavailable. */
514
- url: string | null;
515
- /** Best-effort message when the check failed or no release exists. */
516
- error?: string;
517
- }
518
- /** 用户自定义 tag 分组:纯组织视图,不改技能文件。 */
519
- export interface SkillTag {
520
- /** 稳定 ID(新建时由宿主生成)。 */
521
- id: string;
522
- /** 显示名。 */
523
- name: string;
524
- /** 成员技能名(集合技能与独立技能都可加入)。 */
525
- skillNames: string[];
526
- /** 默认场景(「通用」):系统预置、不可删除、新技能自动归入。 */
527
- default?: boolean;
528
- }
529
- /** 系统集合组:按 origin(来源集合标识)自动聚合。 */
530
- export interface CollectionGroup {
531
- /** 集合名(origin 值,如 "superpowers" / "anthropics/skills")。 */
532
- name: string;
533
- /** 该集合下的技能名,按名称排序。 */
534
- skillNames: string[];
535
- }
536
- /** GET /api/skill-hub/groups */
537
- export interface GroupsResponse {
538
- ok: true;
539
- /** 用户自定义 tag 分组(按拖拽顺序)。 */
540
- tags: SkillTag[];
541
- /** 系统集合组(按拖拽顺序,兜底按名称)。 */
542
- collections: CollectionGroup[];
543
- /** skillName → 集合名 的完整映射。 */
544
- origins: Record<string, string>;
545
- /** 来源分组整体顺序(project / col:xxx / uncategorized-source),用于 SourcesView 顶层排序 */
546
- sourceGroupOrder?: string[];
547
- /** 兼容旧 collectionOrder 字段 */
548
- collectionOrder?: string[];
549
- }
550
- /** POST /api/skill-hub/tag — 新建(缺省 id)或重命名(带 id)。 */
551
- export interface TagSaveRequest {
552
- /** 已有 tag 的 id;缺省表示新建。 */
553
- id?: string;
554
- /** 显示名(去空格后非空)。 */
555
- name: string;
556
- }
557
- /** POST /api/skill-hub/tag */
558
- export interface TagSaveResponse {
559
- ok: true;
560
- /** 变更后的全部 tag。 */
561
- tags: SkillTag[];
562
- }
563
- /** POST /api/skill-hub/tag/delete */
564
- export interface TagDeleteRequest {
565
- id: string;
566
- }
567
- /** POST /api/skill-hub/tag/delete */
568
- export interface TagDeleteResponse {
569
- ok: true;
570
- tags: SkillTag[];
571
- }
572
- /** POST /api/skill-hub/tag/members — 直接设置某 tag 的完整成员列表(幂等)。 */
573
- export interface TagMembersRequest {
574
- id: string;
575
- /** 目标成员技能名;后端只保留目录中存在的名字。 */
576
- skillNames: string[];
577
- }
578
- /** POST /api/skill-hub/tag/members */
579
- export interface TagMembersResponse {
580
- ok: true;
581
- tags: SkillTag[];
582
- }
583
- /** POST /api/skill-hub/tag/reorder — 拖拽重排场景分组 */
584
- export interface TagReorderRequest {
585
- /** 按新顺序排列的 tag id 列表(需包含全部 id) */
586
- orderedIds: string[];
587
- }
588
- /** POST /api/skill-hub/tag/reorder */
589
- export interface TagReorderResponse {
590
- ok: true;
591
- tags: SkillTag[];
592
- }
593
- /** POST /api/skill-hub/collections/reorder — 拖拽重排来源集合 */
594
- export interface CollectionReorderRequest {
595
- /** 按新顺序排列的集合名列表(需包含全部 name) */
596
- orderedNames: string[];
597
- }
598
- /** POST /api/skill-hub/collections/reorder */
599
- export interface CollectionReorderResponse {
600
- ok: true;
601
- collections: CollectionGroup[];
602
- order: string[];
603
- }
604
- /** POST /api/skill-hub/source-groups/reorder — 拖拽重排来源顶层分组(project / collections / personal) */
605
- export interface SourceGroupReorderRequest {
606
- /** 按新顺序排列的顶层分组 key 列表(project / col:xxx / uncategorized-source) */
607
- orderedKeys: string[];
608
- }
609
- export interface SourceGroupReorderResponse {
610
- ok: true;
611
- order: string[];
612
- }
613
- /** 来源跟踪记录:一组来自同一上游仓库根目录的技能。 */
614
- export interface SourceRecord {
615
- /** GitHub owner/repo。 */
616
- repo: string;
617
- /** 显式分支/tag;缺省表示默认分支。 */
618
- ref?: string;
619
- /** 技能在仓库中的根目录。 */
620
- root: RepoRoot;
621
- /** 上次导入/同步时的上游 commit SHA;空 = 尚未核对过。 */
622
- commitSha: string;
623
- /** 该来源下的技能名(来源组 = 这些技能)。 */
624
- skills: string[];
625
- /** 仓库内路径 → 文件大小 的基线清单(差异检测用;缺失 = 无基线)。 */
626
- manifest?: Record<string, number>;
627
- }
628
- /** 回收站条目:上游删除后跟进删除(移入 .trash)的技能。 */
629
- export interface TrashEntry {
630
- name: string;
631
- /** .trash 下的绝对路径。 */
632
- path: string;
633
- /** 移入回收站的时间(epoch ms)。 */
634
- movedAt: number;
635
- /** 移入回收站前的原始路径(目录或文件);旧版本条目没有该字段。 */
636
- sourcePath?: string;
637
- /**
638
- * 移入回收站前的来源跟踪快照(恢复时用它把技能重新挂回来源记录,
639
- * 否则恢复后的技能会丢失来源归属、变成「个人技能」)。
640
- */
641
- origin?: {
642
- repo: string;
643
- root: RepoRoot;
644
- ref?: string;
645
- commitSha: string;
646
- };
647
- /** 移入回收站前所属的场景(tag)ID;恢复时重新加回这些场景。 */
648
- tagIds?: string[];
649
- }
650
- /** GET /api/skill-hub/sources */
651
- export interface SourcesResponse {
652
- ok: true;
653
- /** 全部来源记录(按 repo 排序)。 */
654
- sources: SourceRecord[];
655
- /** skillName → 集合名(由 sources 派生)。 */
656
- origins: Record<string, string>;
657
- /** 来源集合组(按 origin 聚合)。 */
658
- collections: CollectionGroup[];
659
- /** 回收站内容。 */
660
- trash: TrashEntry[];
661
- }
662
- /** POST /api/skill-hub/sources/check — 检查指定(或全部)来源的上游更新。 */
663
- export interface SourceCheckRequest {
664
- /** 仅检查该 repo;缺省检查全部。 */
665
- repo?: string;
666
- }
667
- /** 单个来源的检查结果。 */
668
- export interface SourceCheckResult {
669
- repo: string;
670
- ref?: string;
671
- /** 检查失败时的原因(如仓库不可达/限流)。 */
672
- error?: string;
673
- /** 上游 commit 是否变化。 */
674
- changed: boolean;
675
- /** 上游最新 commit SHA(检查成功时)。 */
676
- commitSha?: string;
677
- /** 上游有更新的技能名(changed 时经 tree 差异得出)。 */
678
- updated: string[];
679
- /** 上游已删除的技能名(changed 时经 tree 差异得出)。 */
680
- deleted: string[];
681
- /** 节流跳过(距上次检查不足 5 分钟,未访问网络)。 */
682
- throttled?: boolean;
683
- /** 该来源此前没有快照(迁移/旧记录),本次已回填 commit,尚未有差异基线。 */
684
- unverified?: boolean;
685
- }
686
- /** POST /api/skill-hub/sources/check */
687
- export interface SourceCheckResponse {
688
- ok: true;
689
- results: SourceCheckResult[];
690
- }
691
- /** POST /api/skill-hub/sources/sync — 按上游重新下载所选技能并更新快照。 */
692
- export interface SourceSyncRequest {
693
- repo: string;
694
- /** 要同步的技能名;缺省同步该来源全部技能。 */
695
- skills?: string[];
696
- }
697
- /** POST /api/skill-hub/sources/sync */
698
- export interface SourceSyncResponse {
699
- ok: true;
700
- repo: string;
701
- /** 同步后的上游 commit SHA。 */
702
- commitSha: string;
703
- /** 成功同步的技能。 */
704
- synced: string[];
705
- /** 失败的技能。 */
706
- failed: Array<{
707
- name: string;
708
- error: string;
709
- }>;
710
- }
711
- /** POST /api/skill-hub/sources/delete — 跟进上游删除,本地移入回收站。 */
712
- export interface SourceDeleteRequest {
713
- repo: string;
714
- /** 要删除的技能名(移入 .trash)。 */
715
- skills: string[];
716
- }
717
- /** POST /api/skill-hub/sources/delete */
718
- export interface SourceDeleteResponse {
719
- ok: true;
720
- /** 已移入回收站的技能。 */
721
- trashed: string[];
722
- failed: Array<{
723
- name: string;
724
- error: string;
725
- }>;
726
- }
727
- /** POST /api/skill-hub/sources/restore — 从回收站恢复一个技能。 */
728
- export interface SourceRestoreRequest {
729
- name: string;
730
- }
731
- /** POST /api/skill-hub/sources/restore */
732
- export interface SourceRestoreResponse {
733
- ok: true;
734
- name: string;
735
- path: string;
736
- }
737
- /** POST /api/skill-hub/sources/trash/clear — 永久删除回收站里的全部技能。 */
738
- export interface SourceTrashClearResponse {
739
- ok: true;
740
- /** 已永久删除的技能名。 */
741
- deleted: string[];
742
- /** 未能删除的技能(保留在回收站中)。 */
743
- failed: Array<{
744
- name: string;
745
- error: string;
746
- }>;
747
- }
748
- /** 项目级技能来源(它们有 workspace 归属,不属于「个人」组)。 */
749
- export declare function isProjectSource(source: string): boolean;
10
+ export { SKILL_HUB_API } from './protocol/api.ts';
11
+ export type { WritableRoot, HubInvocation, CatalogSkill, DisabledSkill, DiagnosticEntry, DiagnosticFixRequest, DiagnosticFixResponse, CatalogResponse, SkillDetail, SkillDetailResponse, SkillDeleteRequest, SkillDeleteResponse, ToggleRequest, ToggleResponse, ToggleBatchRequest, ToggleBatchResponse, CreateRequest, CreateResponse, } from './protocol/catalog.ts';
12
+ export type { SkillStat, StatsResponse, SkillStatsCheckpoint } from './protocol/stats.ts';
13
+ export type { ErrorResponse, HubConfig, HubSettingsValue, ConfigResponse, ConfigRequest } from './protocol/config.ts';
14
+ export { HUB_CONFIG_DEFAULTS, HEX_COLOR_RE, GITHUB_TOKEN_RE, resolveHubConfig } from './protocol/config.ts';
15
+ export type { MarketSourceRecord, MarketSourcesResponse, MarketSourceRequest, MarketSourceResponse, MarketSourceRefRequest, MarketSourceVersionsResponse, MarketStatsSnapshot, MarketStatsResponse, MarketCheckResponse, MarketSyncResponse, } from './protocol/market.ts';
16
+ export type { RepoSkillEntry, RepoRoot, RepoDiscoverResponse, RepoImportRequest, RepoImportResponse, RepoImportProgressResponse, RepoImportCancelRequest, RepoImportCancelResponse, UpdateCheckResponse, } from './protocol/repo.ts';
17
+ export type { SkillTag, CollectionGroup, GroupsResponse, TagSaveRequest, TagSaveResponse, TagDeleteRequest, TagDeleteResponse, TagMembersRequest, TagMembersResponse, TagReorderRequest, TagReorderResponse, CollectionReorderRequest, CollectionReorderResponse, SourceGroupReorderRequest, SourceGroupReorderResponse, } from './protocol/groups.ts';
18
+ export type { SourceRecord, TrashEntry, SourcesResponse, SourceCheckRequest, SourceCheckResult, SourceCheckResponse, SourceSyncRequest, SourceSyncResponse, SourceDeleteRequest, SourceDeleteResponse, SourceRestoreRequest, SourceRestoreResponse, SourceTrashClearResponse, } from './protocol/sources.ts';
19
+ export { isProjectSource } from './protocol/sources.ts';