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.
- package/README.md +40 -50
- package/README.zh.md +38 -48
- package/lib/client.js +2209 -1820
- package/lib/client.js.map +1 -1
- package/lib/index.js +653 -419
- package/lib/types/client/SkillHubSettingsCard.d.ts +1 -0
- package/lib/types/client/api.d.ts +12 -6
- package/lib/types/client/helpers.d.ts +0 -1
- package/lib/types/client/locales/common.d.ts +52 -0
- package/lib/types/client/locales/detail.d.ts +16 -0
- package/lib/types/client/locales/market.d.ts +73 -0
- package/lib/types/client/locales/settings.d.ts +41 -0
- package/lib/types/client/locales/skills.d.ts +65 -0
- package/lib/types/client/locales/sources.d.ts +35 -0
- package/lib/types/client/locales.d.ts +124 -118
- package/lib/types/client/panel/MarketSourceRow.d.ts +12 -0
- package/lib/types/client/panel/MarketView.d.ts +1 -0
- package/lib/types/client/panel/RepoScanCard.d.ts +10 -0
- package/lib/types/client/panel/hooks/shared.d.ts +72 -0
- package/lib/types/client/panel/hooks/useCatalogFlow.d.ts +62 -0
- package/lib/types/client/panel/hooks/useGroupFlow.d.ts +41 -0
- package/lib/types/client/panel/hooks/useMarketFlow.d.ts +73 -0
- package/lib/types/client/panel/hooks/useMetaFlow.d.ts +18 -0
- package/lib/types/client/panel/hooks/useSourceFlow.d.ts +44 -0
- package/lib/types/client/panel/market-format.d.ts +6 -0
- package/lib/types/client/panel/useSkillHub.d.ts +45 -73
- package/lib/types/client/settings-card.d.ts +20 -0
- package/lib/types/client/settings-form.d.ts +6 -0
- package/lib/types/protocol/api.d.ts +38 -0
- package/lib/types/protocol/catalog.d.ts +155 -0
- package/lib/types/protocol/config.d.ts +113 -0
- package/lib/types/protocol/groups.d.ts +95 -0
- package/lib/types/protocol/market.d.ts +94 -0
- package/lib/types/protocol/repo.d.ts +107 -0
- package/lib/types/protocol/sources.d.ts +139 -0
- package/lib/types/protocol/stats.d.ts +46 -0
- package/lib/types/protocol.d.ts +13 -743
- package/lib/types/repo/github-client.d.ts +42 -0
- package/lib/types/repo.d.ts +6 -17
- package/lib/types/routes/catalog.d.ts +7 -0
- package/lib/types/routes/config.d.ts +7 -0
- package/lib/types/routes/groups.d.ts +7 -0
- package/lib/types/routes/helpers.d.ts +145 -0
- package/lib/types/routes/market.d.ts +8 -0
- package/lib/types/routes/repo-import.d.ts +7 -0
- package/lib/types/routes/route-state.d.ts +55 -0
- package/lib/types/routes/sources.d.ts +8 -0
- package/lib/types/routes.d.ts +5 -34
- package/lib/types/stats.d.ts +3 -2
- package/lib/types/store/errors.d.ts +10 -0
- package/lib/types/store/migrate.d.ts +44 -0
- package/lib/types/store/paths.d.ts +32 -0
- package/lib/types/store/store.d.ts +133 -0
- package/lib/types/store.d.ts +7 -146
- package/package.json +28 -27
- package/src/client/SkillHubSettingsCard.tsx +17 -3
- package/src/client/api.ts +101 -195
- package/src/client/helpers.ts +10 -1
- package/src/client/locales/common.ts +102 -0
- package/src/client/locales/detail.ts +30 -0
- package/src/client/locales/market.ts +144 -0
- package/src/client/locales/settings.ts +80 -0
- package/src/client/locales/skills.ts +128 -0
- package/src/client/locales/sources.ts +68 -0
- package/src/client/locales.ts +26 -512
- package/src/client/panel/MarketSourceRow.tsx +108 -0
- package/src/client/panel/MarketView.tsx +12 -253
- package/src/client/panel/RepoScanCard.tsx +171 -0
- package/src/client/panel/hooks/shared.ts +81 -0
- package/src/client/panel/hooks/useCatalogFlow.ts +211 -0
- package/src/client/panel/hooks/useGroupFlow.ts +240 -0
- package/src/client/panel/hooks/useMarketFlow.ts +421 -0
- package/src/client/panel/hooks/useMetaFlow.ts +58 -0
- package/src/client/panel/hooks/useSourceFlow.ts +193 -0
- package/src/client/panel/market-format.ts +22 -0
- package/src/client/panel/useSkillHub.ts +141 -1032
- package/src/client/settings-card.tsx +51 -0
- package/src/client/settings-form.ts +18 -0
- package/src/index.ts +14 -4
- package/src/protocol/api.ts +38 -0
- package/src/protocol/catalog.ts +168 -0
- package/src/protocol/config.ts +145 -0
- package/src/protocol/groups.ts +106 -0
- package/src/protocol/market.ts +100 -0
- package/src/protocol/repo.ts +104 -0
- package/src/protocol/sources.ts +146 -0
- package/src/protocol/stats.ts +42 -0
- package/src/protocol.ts +83 -809
- package/src/repo/github-client.ts +131 -0
- package/src/repo.test.ts +24 -1
- package/src/repo.ts +50 -170
- package/src/routes/catalog.ts +309 -0
- package/src/routes/config.ts +119 -0
- package/src/routes/groups.ts +133 -0
- package/src/routes/helpers.ts +489 -0
- package/src/routes/market.ts +255 -0
- package/src/routes/repo-import.ts +267 -0
- package/src/routes/route-state.ts +89 -0
- package/src/routes/sources.ts +318 -0
- package/src/routes.test.ts +20 -0
- package/src/routes.ts +21 -1699
- package/src/stats.test.ts +58 -3
- package/src/stats.ts +45 -16
- package/src/store/errors.ts +14 -0
- package/src/store/migrate.ts +272 -0
- package/src/store/paths.ts +43 -0
- package/src/store/store.ts +532 -0
- package/src/store.test.ts +18 -0
- package/src/store.ts +7 -737
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/** 用户自定义 tag 分组:纯组织视图,不改技能文件。 */
|
|
2
|
+
export interface SkillTag {
|
|
3
|
+
/** 稳定 ID(新建时由宿主生成)。 */
|
|
4
|
+
id: string;
|
|
5
|
+
/** 显示名。 */
|
|
6
|
+
name: string;
|
|
7
|
+
/** 成员技能名(集合技能与独立技能都可加入)。 */
|
|
8
|
+
skillNames: string[];
|
|
9
|
+
/** 默认场景(「通用」):系统预置、不可删除、新技能自动归入。 */
|
|
10
|
+
default?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** 系统集合组:按 origin(来源集合标识)自动聚合。 */
|
|
13
|
+
export interface CollectionGroup {
|
|
14
|
+
/** 集合名(origin 值,如 "superpowers" / "anthropics/skills")。 */
|
|
15
|
+
name: string;
|
|
16
|
+
/** 该集合下的技能名,按名称排序。 */
|
|
17
|
+
skillNames: string[];
|
|
18
|
+
}
|
|
19
|
+
/** GET /api/skill-hub/groups */
|
|
20
|
+
export interface GroupsResponse {
|
|
21
|
+
ok: true;
|
|
22
|
+
/** 用户自定义 tag 分组(按拖拽顺序)。 */
|
|
23
|
+
tags: SkillTag[];
|
|
24
|
+
/** 系统集合组(按拖拽顺序,兜底按名称)。 */
|
|
25
|
+
collections: CollectionGroup[];
|
|
26
|
+
/** skillName → 集合名 的完整映射。 */
|
|
27
|
+
origins: Record<string, string>;
|
|
28
|
+
/** 来源分组整体顺序(project / col:xxx / uncategorized-source),用于 SourcesView 顶层排序 */
|
|
29
|
+
sourceGroupOrder?: string[];
|
|
30
|
+
/** 兼容旧 collectionOrder 字段 */
|
|
31
|
+
collectionOrder?: string[];
|
|
32
|
+
}
|
|
33
|
+
/** POST /api/skill-hub/tag — 新建(缺省 id)或重命名(带 id)。 */
|
|
34
|
+
export interface TagSaveRequest {
|
|
35
|
+
/** 已有 tag 的 id;缺省表示新建。 */
|
|
36
|
+
id?: string;
|
|
37
|
+
/** 显示名(去空格后非空)。 */
|
|
38
|
+
name: string;
|
|
39
|
+
}
|
|
40
|
+
/** POST /api/skill-hub/tag */
|
|
41
|
+
export interface TagSaveResponse {
|
|
42
|
+
ok: true;
|
|
43
|
+
/** 变更后的全部 tag。 */
|
|
44
|
+
tags: SkillTag[];
|
|
45
|
+
}
|
|
46
|
+
/** POST /api/skill-hub/tag/delete */
|
|
47
|
+
export interface TagDeleteRequest {
|
|
48
|
+
id: string;
|
|
49
|
+
}
|
|
50
|
+
/** POST /api/skill-hub/tag/delete */
|
|
51
|
+
export interface TagDeleteResponse {
|
|
52
|
+
ok: true;
|
|
53
|
+
tags: SkillTag[];
|
|
54
|
+
}
|
|
55
|
+
/** POST /api/skill-hub/tag/members — 直接设置某 tag 的完整成员列表(幂等)。 */
|
|
56
|
+
export interface TagMembersRequest {
|
|
57
|
+
id: string;
|
|
58
|
+
/** 目标成员技能名;后端只保留目录中存在的名字。 */
|
|
59
|
+
skillNames: string[];
|
|
60
|
+
}
|
|
61
|
+
/** POST /api/skill-hub/tag/members */
|
|
62
|
+
export interface TagMembersResponse {
|
|
63
|
+
ok: true;
|
|
64
|
+
tags: SkillTag[];
|
|
65
|
+
}
|
|
66
|
+
/** POST /api/skill-hub/tag/reorder — 拖拽重排场景分组 */
|
|
67
|
+
export interface TagReorderRequest {
|
|
68
|
+
/** 按新顺序排列的 tag id 列表(需包含全部 id) */
|
|
69
|
+
orderedIds: string[];
|
|
70
|
+
}
|
|
71
|
+
/** POST /api/skill-hub/tag/reorder */
|
|
72
|
+
export interface TagReorderResponse {
|
|
73
|
+
ok: true;
|
|
74
|
+
tags: SkillTag[];
|
|
75
|
+
}
|
|
76
|
+
/** POST /api/skill-hub/collections/reorder — 拖拽重排来源集合 */
|
|
77
|
+
export interface CollectionReorderRequest {
|
|
78
|
+
/** 按新顺序排列的集合名列表(需包含全部 name) */
|
|
79
|
+
orderedNames: string[];
|
|
80
|
+
}
|
|
81
|
+
/** POST /api/skill-hub/collections/reorder */
|
|
82
|
+
export interface CollectionReorderResponse {
|
|
83
|
+
ok: true;
|
|
84
|
+
collections: CollectionGroup[];
|
|
85
|
+
order: string[];
|
|
86
|
+
}
|
|
87
|
+
/** POST /api/skill-hub/source-groups/reorder — 拖拽重排来源顶层分组(project / collections / personal) */
|
|
88
|
+
export interface SourceGroupReorderRequest {
|
|
89
|
+
/** 按新顺序排列的顶层分组 key 列表(project / col:xxx / uncategorized-source) */
|
|
90
|
+
orderedKeys: string[];
|
|
91
|
+
}
|
|
92
|
+
export interface SourceGroupReorderResponse {
|
|
93
|
+
ok: true;
|
|
94
|
+
order: string[];
|
|
95
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/** One market source: a tracked upstream repo plus its pinned version. */
|
|
2
|
+
export interface MarketSourceRecord {
|
|
3
|
+
/** Repo slug (owner/repo). */
|
|
4
|
+
repo: string;
|
|
5
|
+
/** Pinned version: release tag, branch name, or custom ref. Absent = not yet pinned. */
|
|
6
|
+
ref?: string;
|
|
7
|
+
/** Commit the pinned ref last resolved to (update-check baseline). */
|
|
8
|
+
commitSha?: string;
|
|
9
|
+
}
|
|
10
|
+
/** GET /api/skill-hub/market — the user's added market sources. */
|
|
11
|
+
export interface MarketSourcesResponse {
|
|
12
|
+
ok: true;
|
|
13
|
+
/** Added market sources, in addition order. */
|
|
14
|
+
repos: MarketSourceRecord[];
|
|
15
|
+
}
|
|
16
|
+
/** POST /api/skill-hub/market/source — add one repo as a market source. */
|
|
17
|
+
export interface MarketSourceRequest {
|
|
18
|
+
/** owner/repo, owner/repo@ref, or a github.com URL. */
|
|
19
|
+
repo: string;
|
|
20
|
+
}
|
|
21
|
+
/** POST /api/skill-hub/market/source|delete */
|
|
22
|
+
export interface MarketSourceResponse {
|
|
23
|
+
ok: true;
|
|
24
|
+
repos: MarketSourceRecord[];
|
|
25
|
+
}
|
|
26
|
+
/** POST /api/skill-hub/market/source/ref — pin a market source to an explicit ref. */
|
|
27
|
+
export interface MarketSourceRefRequest {
|
|
28
|
+
repo: string;
|
|
29
|
+
/** Release tag or branch name chosen for the repo. */
|
|
30
|
+
ref: string;
|
|
31
|
+
}
|
|
32
|
+
/** GET /api/skill-hub/market/source/versions?repo= — releases + branches for the version picker. */
|
|
33
|
+
export interface MarketSourceVersionsResponse {
|
|
34
|
+
ok: true;
|
|
35
|
+
repo: string;
|
|
36
|
+
/** Currently pinned ref, when one is recorded. */
|
|
37
|
+
current?: string;
|
|
38
|
+
/** Release tags, newest first (drafts excluded). */
|
|
39
|
+
releases: string[];
|
|
40
|
+
/** Branch names, default branch first. */
|
|
41
|
+
branches: string[];
|
|
42
|
+
}
|
|
43
|
+
/** Persisted market-stats snapshot (sidecar `marketStats` field): last fetched stars/downloads per repo. */
|
|
44
|
+
export interface MarketStatsSnapshot {
|
|
45
|
+
/** Epoch ms of the fetch this snapshot was built from (drives the hourly TTL). */
|
|
46
|
+
fetchedAt: number;
|
|
47
|
+
/** Per-repo numbers, keyed by repo slug. */
|
|
48
|
+
stats: Record<string, {
|
|
49
|
+
stars: number;
|
|
50
|
+
downloads: number;
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
53
|
+
/** GET /api/skill-hub/market/stats — stars + release-asset downloads per market source. */
|
|
54
|
+
export interface MarketStatsResponse {
|
|
55
|
+
ok: true;
|
|
56
|
+
results: Array<{
|
|
57
|
+
repo: string;
|
|
58
|
+
stars: number;
|
|
59
|
+
downloads: number;
|
|
60
|
+
/** Throttled: served from the hourly cache without a network round. */
|
|
61
|
+
throttled?: boolean;
|
|
62
|
+
/** Stale: older than the hourly TTL, a background refresh is on its way. */
|
|
63
|
+
stale?: boolean;
|
|
64
|
+
error?: string;
|
|
65
|
+
}>;
|
|
66
|
+
}
|
|
67
|
+
/** GET /api/skill-hub/market/check — update check over market sources. */
|
|
68
|
+
export interface MarketCheckResponse {
|
|
69
|
+
ok: true;
|
|
70
|
+
results: Array<{
|
|
71
|
+
repo: string;
|
|
72
|
+
/** Pinned ref, when one is recorded. */
|
|
73
|
+
ref?: string;
|
|
74
|
+
/** Latest release tag on the repo, when it has one. */
|
|
75
|
+
latestTag?: string;
|
|
76
|
+
/** Whether the pinned ref (or the repo) has moved ahead. */
|
|
77
|
+
updateAvailable: boolean;
|
|
78
|
+
/** Latest commit of the checked ref. */
|
|
79
|
+
commitSha: string;
|
|
80
|
+
/** Throttled: the check was skipped within the interval. */
|
|
81
|
+
throttled?: boolean;
|
|
82
|
+
error?: string;
|
|
83
|
+
}>;
|
|
84
|
+
}
|
|
85
|
+
/** POST /api/skill-hub/market/source/sync — align a market source to its pinned ref. */
|
|
86
|
+
export interface MarketSyncResponse {
|
|
87
|
+
ok: true;
|
|
88
|
+
repo: string;
|
|
89
|
+
/** The ref the source is now pinned to. */
|
|
90
|
+
ref: string;
|
|
91
|
+
commitSha: string;
|
|
92
|
+
/** Local skills tracked from this repo (candidates for a batch update). */
|
|
93
|
+
skills: string[];
|
|
94
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/** A skill discovered in a GitHub repo under any top-level root (e.g. skills/, templates/). */
|
|
2
|
+
export interface RepoSkillEntry {
|
|
3
|
+
/** Kebab-case skill name (directory basename). */
|
|
4
|
+
name: string;
|
|
5
|
+
/** Root-relative skill directory, e.g. skills/code-review. */
|
|
6
|
+
dir: string;
|
|
7
|
+
/** Root-relative SKILL.md path, e.g. skills/code-review/SKILL.md. */
|
|
8
|
+
path: string;
|
|
9
|
+
/** Repo root the skill lives in. */
|
|
10
|
+
root: RepoRoot;
|
|
11
|
+
/** Collection name recorded as origin after import. */
|
|
12
|
+
origin: string;
|
|
13
|
+
/** Number of files in the skill directory. */
|
|
14
|
+
fileCount: number;
|
|
15
|
+
/** Total bytes across all files in the skill directory. */
|
|
16
|
+
totalBytes: number;
|
|
17
|
+
/** Whether a same-named skill already exists locally. */
|
|
18
|
+
existing: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** 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. */
|
|
21
|
+
export type RepoRoot = string;
|
|
22
|
+
/** GET /api/skill-hub/repo — discover importable skills in a GitHub repo. */
|
|
23
|
+
export interface RepoDiscoverResponse {
|
|
24
|
+
ok: true;
|
|
25
|
+
repo: string;
|
|
26
|
+
/**
|
|
27
|
+
* Ref the discovery ran against (release tag / branch / default branch).
|
|
28
|
+
* Null means the repo has no release and no pinned ref — the client must
|
|
29
|
+
* ask the user to pick a branch (see `branches`) and pin it first.
|
|
30
|
+
*/
|
|
31
|
+
ref: string | null;
|
|
32
|
+
/** Branch names to choose from when ref is null (default branch first). */
|
|
33
|
+
branches?: string[];
|
|
34
|
+
entries: RepoSkillEntry[];
|
|
35
|
+
/** GitHub truncated the tree; discovery is partial (mirrors codex walk_truncated). */
|
|
36
|
+
truncated?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** POST /api/skill-hub/repo/import — install selected repo skills. */
|
|
39
|
+
export interface RepoImportRequest {
|
|
40
|
+
repo: string;
|
|
41
|
+
/** Selected SKILL.md paths from the discover response. */
|
|
42
|
+
paths: string[];
|
|
43
|
+
/** The ref the discovery ran against; the import must use the same one. */
|
|
44
|
+
ref?: string;
|
|
45
|
+
}
|
|
46
|
+
/** POST /api/skill-hub/repo/import — now creates an async job (B方案) */
|
|
47
|
+
export interface RepoImportResponse {
|
|
48
|
+
ok: true;
|
|
49
|
+
jobId: string;
|
|
50
|
+
total: number;
|
|
51
|
+
totalBytes: number;
|
|
52
|
+
}
|
|
53
|
+
/** GET /api/skill-hub/repo/import/progress?jobId=xxx */
|
|
54
|
+
export interface RepoImportProgressResponse {
|
|
55
|
+
ok: true;
|
|
56
|
+
jobId: string;
|
|
57
|
+
status: 'running' | 'done' | 'cancelled' | 'error';
|
|
58
|
+
total: number;
|
|
59
|
+
done: number;
|
|
60
|
+
/** 当前正在下载的 skill 名,done < total 时有效 */
|
|
61
|
+
current?: string;
|
|
62
|
+
/** 当前正在下载的文件路径(相对 skill dir) */
|
|
63
|
+
currentFile?: string;
|
|
64
|
+
/** 字节级进度 */
|
|
65
|
+
totalBytes: number;
|
|
66
|
+
downloadedBytes: number;
|
|
67
|
+
/** 下载速度 bytes/sec,running 时有效 */
|
|
68
|
+
bytesPerSecond?: number;
|
|
69
|
+
imported: Array<{
|
|
70
|
+
name: string;
|
|
71
|
+
origin: string;
|
|
72
|
+
path: string;
|
|
73
|
+
}>;
|
|
74
|
+
skipped: Array<{
|
|
75
|
+
name: string;
|
|
76
|
+
reason: 'exists';
|
|
77
|
+
}>;
|
|
78
|
+
failed: Array<{
|
|
79
|
+
name: string;
|
|
80
|
+
error: string;
|
|
81
|
+
}>;
|
|
82
|
+
/** error 状态时的原因 */
|
|
83
|
+
error?: string;
|
|
84
|
+
}
|
|
85
|
+
/** POST /api/skill-hub/repo/import/cancel */
|
|
86
|
+
export interface RepoImportCancelRequest {
|
|
87
|
+
jobId: string;
|
|
88
|
+
}
|
|
89
|
+
export interface RepoImportCancelResponse {
|
|
90
|
+
ok: true;
|
|
91
|
+
jobId: string;
|
|
92
|
+
status: 'cancelled' | 'done';
|
|
93
|
+
}
|
|
94
|
+
/** GET /api/skill-hub/update — check the plugin's own latest GitHub release. */
|
|
95
|
+
export interface UpdateCheckResponse {
|
|
96
|
+
ok: true;
|
|
97
|
+
/** Installed plugin version (from the bundled host build). */
|
|
98
|
+
currentVersion: string;
|
|
99
|
+
/** Latest release tag, normalized without the leading v; null when unknown. */
|
|
100
|
+
latestVersion: string | null;
|
|
101
|
+
/** True when latestVersion is strictly newer than currentVersion. */
|
|
102
|
+
updateAvailable: boolean;
|
|
103
|
+
/** Release page URL; null when unavailable. */
|
|
104
|
+
url: string | null;
|
|
105
|
+
/** Best-effort message when the check failed or no release exists. */
|
|
106
|
+
error?: string;
|
|
107
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { CollectionGroup } from './groups.ts';
|
|
2
|
+
import type { RepoRoot } from './repo.ts';
|
|
3
|
+
/** 来源跟踪记录:一组来自同一上游仓库根目录的技能。 */
|
|
4
|
+
export interface SourceRecord {
|
|
5
|
+
/** GitHub owner/repo。 */
|
|
6
|
+
repo: string;
|
|
7
|
+
/** 显式分支/tag;缺省表示默认分支。 */
|
|
8
|
+
ref?: string;
|
|
9
|
+
/** 技能在仓库中的根目录。 */
|
|
10
|
+
root: RepoRoot;
|
|
11
|
+
/** 上次导入/同步时的上游 commit SHA;空 = 尚未核对过。 */
|
|
12
|
+
commitSha: string;
|
|
13
|
+
/** 该来源下的技能名(来源组 = 这些技能)。 */
|
|
14
|
+
skills: string[];
|
|
15
|
+
/** 仓库内路径 → 文件大小 的基线清单(差异检测用;缺失 = 无基线)。 */
|
|
16
|
+
manifest?: Record<string, number>;
|
|
17
|
+
}
|
|
18
|
+
/** 回收站条目:上游删除后跟进删除(移入 .trash)的技能。 */
|
|
19
|
+
export interface TrashEntry {
|
|
20
|
+
name: string;
|
|
21
|
+
/** .trash 下的绝对路径。 */
|
|
22
|
+
path: string;
|
|
23
|
+
/** 移入回收站的时间(epoch ms)。 */
|
|
24
|
+
movedAt: number;
|
|
25
|
+
/** 移入回收站前的原始路径(目录或文件);旧版本条目没有该字段。 */
|
|
26
|
+
sourcePath?: string;
|
|
27
|
+
/**
|
|
28
|
+
* 移入回收站前的来源跟踪快照(恢复时用它把技能重新挂回来源记录,
|
|
29
|
+
* 否则恢复后的技能会丢失来源归属、变成「个人技能」)。
|
|
30
|
+
*/
|
|
31
|
+
origin?: {
|
|
32
|
+
repo: string;
|
|
33
|
+
root: RepoRoot;
|
|
34
|
+
ref?: string;
|
|
35
|
+
commitSha: string;
|
|
36
|
+
};
|
|
37
|
+
/** 移入回收站前所属的场景(tag)ID;恢复时重新加回这些场景。 */
|
|
38
|
+
tagIds?: string[];
|
|
39
|
+
}
|
|
40
|
+
/** GET /api/skill-hub/sources */
|
|
41
|
+
export interface SourcesResponse {
|
|
42
|
+
ok: true;
|
|
43
|
+
/** 全部来源记录(按 repo 排序)。 */
|
|
44
|
+
sources: SourceRecord[];
|
|
45
|
+
/** skillName → 集合名(由 sources 派生)。 */
|
|
46
|
+
origins: Record<string, string>;
|
|
47
|
+
/** 来源集合组(按 origin 聚合)。 */
|
|
48
|
+
collections: CollectionGroup[];
|
|
49
|
+
/** 回收站内容。 */
|
|
50
|
+
trash: TrashEntry[];
|
|
51
|
+
}
|
|
52
|
+
/** POST /api/skill-hub/sources/check — 检查指定(或全部)来源的上游更新。 */
|
|
53
|
+
export interface SourceCheckRequest {
|
|
54
|
+
/** 仅检查该 repo;缺省检查全部。 */
|
|
55
|
+
repo?: string;
|
|
56
|
+
}
|
|
57
|
+
/** 单个来源的检查结果。 */
|
|
58
|
+
export interface SourceCheckResult {
|
|
59
|
+
repo: string;
|
|
60
|
+
ref?: string;
|
|
61
|
+
/** 检查失败时的原因(如仓库不可达/限流)。 */
|
|
62
|
+
error?: string;
|
|
63
|
+
/** 上游 commit 是否变化。 */
|
|
64
|
+
changed: boolean;
|
|
65
|
+
/** 上游最新 commit SHA(检查成功时)。 */
|
|
66
|
+
commitSha?: string;
|
|
67
|
+
/** 上游有更新的技能名(changed 时经 tree 差异得出)。 */
|
|
68
|
+
updated: string[];
|
|
69
|
+
/** 上游已删除的技能名(changed 时经 tree 差异得出)。 */
|
|
70
|
+
deleted: string[];
|
|
71
|
+
/** 节流跳过(距上次检查不足 5 分钟,未访问网络)。 */
|
|
72
|
+
throttled?: boolean;
|
|
73
|
+
/** 该来源此前没有快照(迁移/旧记录),本次已回填 commit,尚未有差异基线。 */
|
|
74
|
+
unverified?: boolean;
|
|
75
|
+
}
|
|
76
|
+
/** POST /api/skill-hub/sources/check */
|
|
77
|
+
export interface SourceCheckResponse {
|
|
78
|
+
ok: true;
|
|
79
|
+
results: SourceCheckResult[];
|
|
80
|
+
}
|
|
81
|
+
/** POST /api/skill-hub/sources/sync — 按上游重新下载所选技能并更新快照。 */
|
|
82
|
+
export interface SourceSyncRequest {
|
|
83
|
+
repo: string;
|
|
84
|
+
/** 要同步的技能名;缺省同步该来源全部技能。 */
|
|
85
|
+
skills?: string[];
|
|
86
|
+
}
|
|
87
|
+
/** POST /api/skill-hub/sources/sync */
|
|
88
|
+
export interface SourceSyncResponse {
|
|
89
|
+
ok: true;
|
|
90
|
+
repo: string;
|
|
91
|
+
/** 同步后的上游 commit SHA。 */
|
|
92
|
+
commitSha: string;
|
|
93
|
+
/** 成功同步的技能。 */
|
|
94
|
+
synced: string[];
|
|
95
|
+
/** 失败的技能。 */
|
|
96
|
+
failed: Array<{
|
|
97
|
+
name: string;
|
|
98
|
+
error: string;
|
|
99
|
+
}>;
|
|
100
|
+
}
|
|
101
|
+
/** POST /api/skill-hub/sources/delete — 跟进上游删除,本地移入回收站。 */
|
|
102
|
+
export interface SourceDeleteRequest {
|
|
103
|
+
repo: string;
|
|
104
|
+
/** 要删除的技能名(移入 .trash)。 */
|
|
105
|
+
skills: string[];
|
|
106
|
+
}
|
|
107
|
+
/** POST /api/skill-hub/sources/delete */
|
|
108
|
+
export interface SourceDeleteResponse {
|
|
109
|
+
ok: true;
|
|
110
|
+
/** 已移入回收站的技能。 */
|
|
111
|
+
trashed: string[];
|
|
112
|
+
failed: Array<{
|
|
113
|
+
name: string;
|
|
114
|
+
error: string;
|
|
115
|
+
}>;
|
|
116
|
+
}
|
|
117
|
+
/** POST /api/skill-hub/sources/restore — 从回收站恢复一个技能。 */
|
|
118
|
+
export interface SourceRestoreRequest {
|
|
119
|
+
name: string;
|
|
120
|
+
}
|
|
121
|
+
/** POST /api/skill-hub/sources/restore */
|
|
122
|
+
export interface SourceRestoreResponse {
|
|
123
|
+
ok: true;
|
|
124
|
+
name: string;
|
|
125
|
+
path: string;
|
|
126
|
+
}
|
|
127
|
+
/** POST /api/skill-hub/sources/trash/clear — 永久删除回收站里的全部技能。 */
|
|
128
|
+
export interface SourceTrashClearResponse {
|
|
129
|
+
ok: true;
|
|
130
|
+
/** 已永久删除的技能名。 */
|
|
131
|
+
deleted: string[];
|
|
132
|
+
/** 未能删除的技能(保留在回收站中)。 */
|
|
133
|
+
failed: Array<{
|
|
134
|
+
name: string;
|
|
135
|
+
error: string;
|
|
136
|
+
}>;
|
|
137
|
+
}
|
|
138
|
+
/** 项目级技能来源(它们有 workspace 归属,不属于「个人」组)。 */
|
|
139
|
+
export declare function isProjectSource(source: string): boolean;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** One skill's invocation stats across the local session logs. */
|
|
2
|
+
export interface SkillStat {
|
|
3
|
+
/** Kebab-case skill name. */
|
|
4
|
+
name: string;
|
|
5
|
+
/** How many sessions recorded a user-explicit invocation of this skill. */
|
|
6
|
+
count: number;
|
|
7
|
+
/** Unix epoch ms of the most recent invocation (absent when never called). */
|
|
8
|
+
lastUsed?: number;
|
|
9
|
+
}
|
|
10
|
+
/** GET /api/skill-hub/stats */
|
|
11
|
+
export interface StatsResponse {
|
|
12
|
+
ok: true;
|
|
13
|
+
/** Whether a session-log source was available (false means counts are empty). */
|
|
14
|
+
available: boolean;
|
|
15
|
+
/** Sorted per-skill invocation counts. */
|
|
16
|
+
stats: SkillStat[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Persisted incremental-scan checkpoint for the usage statistics (sidecar
|
|
20
|
+
* `skillStats` field). Sessions created before `frozenBefore` are treated as
|
|
21
|
+
* finalized: their per-session counts live in `frozenSessions` (only sessions
|
|
22
|
+
* with at least one invocation are kept) and they are not re-read on
|
|
23
|
+
* incremental scans. A daily full reconciliation rebuilds the cache and
|
|
24
|
+
* advances the watermark, so a resumed old session is eventually re-counted.
|
|
25
|
+
*/
|
|
26
|
+
export interface SkillStatsCheckpoint {
|
|
27
|
+
/** The rolling-window configuration this checkpoint was built for (0 = all history). */
|
|
28
|
+
windowDays: number;
|
|
29
|
+
/** Watermark: every session with header.createdAt < this value is frozen. */
|
|
30
|
+
frozenBefore: number;
|
|
31
|
+
/** Per-session counts of finalized sessions, keyed by session id. */
|
|
32
|
+
frozenSessions: Record<string, {
|
|
33
|
+
createdAt: number;
|
|
34
|
+
counts: Record<string, {
|
|
35
|
+
count: number;
|
|
36
|
+
lastUsed: number;
|
|
37
|
+
}>;
|
|
38
|
+
}>;
|
|
39
|
+
/** Epoch ms of the last full reconciliation (drives the daily cadence). */
|
|
40
|
+
lastFullReconcile: number;
|
|
41
|
+
/**
|
|
42
|
+
* Totals from the last completed scan (any kind). Served instantly on cold
|
|
43
|
+
* start so a restart still shows numbers while the background rescan runs.
|
|
44
|
+
*/
|
|
45
|
+
lastTotals?: SkillStat[];
|
|
46
|
+
}
|