dsh-plugin-capabilities 0.3.0 → 0.3.2
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/client.js +33 -5
- package/lib/client.js.map +2 -2
- package/lib/index.js +22 -2
- package/lib/index.js.map +2 -2
- package/market/mcp.json +313 -27
- package/market/skills.json +531 -4
- package/package.json +1 -1
- package/src/client/MarketTab.tsx +35 -5
- package/src/client/css.ts +13 -2
- package/src/client/index.ts +12 -1
- package/src/market.test.ts +6 -4
- package/src/market.ts +37 -3
package/src/client/MarketTab.tsx
CHANGED
|
@@ -129,6 +129,8 @@ export function MarketTab(props: { t: Translate; market: MarketInjected; mcp: Mc
|
|
|
129
129
|
const pick = <T,>(base: T, zh: T | undefined): T => (zhUi() && zh !== undefined ? zh : base)
|
|
130
130
|
const title = (entry: { name: string; nameZh?: string }): string => pick(entry.name, entry.nameZh)
|
|
131
131
|
const desc = (entry: { description: string; descriptionZh?: string }): string => pick(entry.description, entry.descriptionZh)
|
|
132
|
+
const longText = (entry: { description: string; descriptionZh?: string; detail?: string; detailZh?: string }): string =>
|
|
133
|
+
entry.detail !== undefined ? pick(entry.detail, entry.detailZh) : desc(entry)
|
|
132
134
|
|
|
133
135
|
const cardStop = (event: { stopPropagation(): void }): void => { event.stopPropagation() }
|
|
134
136
|
|
|
@@ -258,6 +260,9 @@ export function MarketTab(props: { t: Translate; market: MarketInjected; mcp: Mc
|
|
|
258
260
|
open={detailRepo !== null || detailServer !== null}
|
|
259
261
|
onClose={() => setDetail(null)}
|
|
260
262
|
title={detailRepo !== null ? title(detailRepo) : detailServer !== null ? title(detailServer) : ''}
|
|
263
|
+
closeLabel={t('close')}
|
|
264
|
+
className="dpc-marketDialog"
|
|
265
|
+
contentClassName="dpc-marketContent"
|
|
261
266
|
footer={
|
|
262
267
|
<>
|
|
263
268
|
{detailRepo !== null && (
|
|
@@ -294,22 +299,47 @@ export function MarketTab(props: { t: Translate; market: MarketInjected; mcp: Mc
|
|
|
294
299
|
</>
|
|
295
300
|
}
|
|
296
301
|
>
|
|
302
|
+
{(detailRepo !== null || detailServer !== null) && (
|
|
303
|
+
<div className="dpc-detailTagsRow">
|
|
304
|
+
{detailRepo !== null && detailRepo.skillCount !== undefined && (
|
|
305
|
+
<span className="dpc-tag">{t('marketSkillCount').replace('{n}', String(detailRepo.skillCount))}</span>
|
|
306
|
+
)}
|
|
307
|
+
{detailRepo !== null && detailRepo.installedId !== null && (
|
|
308
|
+
<span className="dpc-tag" data-kind="source">{t('marketInstalled')}</span>
|
|
309
|
+
)}
|
|
310
|
+
{detailServer !== null && (
|
|
311
|
+
<>
|
|
312
|
+
<span className="dpc-tag">{detailServer.transport}</span>
|
|
313
|
+
{detailServer.runtime !== undefined && <span className="dpc-tag">{detailServer.runtime}</span>}
|
|
314
|
+
{detailServer.category !== undefined && <span className="dpc-tag">{detailServer.category}</span>}
|
|
315
|
+
{detailServer.installed && <span className="dpc-tag" data-kind="source">{t('marketInstalled')}</span>}
|
|
316
|
+
</>
|
|
317
|
+
)}
|
|
318
|
+
</div>
|
|
319
|
+
)}
|
|
297
320
|
{detailRepo !== null && (
|
|
298
321
|
<>
|
|
299
|
-
<p className="dpc-detailDesc">{
|
|
322
|
+
<p className="dpc-detailDesc">{longText(detailRepo)}</p>
|
|
300
323
|
{detailRepo.skills !== undefined && detailRepo.skills.length > 0 && (
|
|
301
324
|
<div className="dpc-detailSection">
|
|
302
325
|
<div className="dpc-detailLabel">{t('marketSkillListLabel')}</div>
|
|
303
|
-
<
|
|
304
|
-
{detailRepo.skills.map(
|
|
305
|
-
|
|
326
|
+
<ul className="dpc-skillList">
|
|
327
|
+
{detailRepo.skills.map(item => (
|
|
328
|
+
<li className="dpc-skillItem" key={item.name}>
|
|
329
|
+
<code className="dpc-skillName">{item.name}</code>
|
|
330
|
+
{item.description !== undefined && (
|
|
331
|
+
<span className="dpc-skillDesc">{pick(item.description, item.descriptionZh)}</span>
|
|
332
|
+
)}
|
|
333
|
+
</li>
|
|
334
|
+
))}
|
|
335
|
+
</ul>
|
|
306
336
|
</div>
|
|
307
337
|
)}
|
|
308
338
|
</>
|
|
309
339
|
)}
|
|
310
340
|
{detailServer !== null && (
|
|
311
341
|
<>
|
|
312
|
-
<p className="dpc-detailDesc">{
|
|
342
|
+
<p className="dpc-detailDesc">{longText(detailServer)}</p>
|
|
313
343
|
{detailServer.command !== undefined && (
|
|
314
344
|
<div className="dpc-detailSection">
|
|
315
345
|
<div className="dpc-detailLabel">{t('marketCommandLabel')}</div>
|
package/src/client/css.ts
CHANGED
|
@@ -108,10 +108,21 @@ export const CSS = `
|
|
|
108
108
|
.dpc-format .dpc-form{margin-top:8px}
|
|
109
109
|
.dpc-formatHint{margin:2px 0 0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary)}
|
|
110
110
|
.dpc-code{margin:4px 0 8px;border:1px solid var(--dsw-alias-border-l2);border-radius:6px;padding:8px 10px;overflow-x:auto;background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);font-family:var(--ds-font-family-code);font-size:11px;line-height:17px;white-space:pre}
|
|
111
|
-
/* Market detail modal.
|
|
111
|
+
/* Market detail modal. The host dialog card is a fixed 380px column with no
|
|
112
|
+
scroll, which the long-form intros turn into a clipped strip — widen it
|
|
113
|
+
(doubled selector outranks the module class regardless of style order),
|
|
114
|
+
cap the height, and scroll inside the content region. */
|
|
115
|
+
.dpc-marketDialog.dpc-marketDialog{width:min(720px,100%);max-height:calc(100vh - 48px)}
|
|
116
|
+
.dpc-marketContent{overflow-y:auto;min-height:0}
|
|
117
|
+
.dpc-detailTagsRow{display:flex;flex-wrap:wrap;gap:4px;margin:0 0 8px}
|
|
112
118
|
.dpc-detailDesc{margin:0;font-size:13px;line-height:20px}
|
|
113
|
-
.dpc-detailSection{margin-top:
|
|
119
|
+
.dpc-detailSection{margin-top:14px;display:flex;flex-direction:column;gap:6px}
|
|
114
120
|
.dpc-detailLabel{font-size:11px;line-height:16px;color:var(--dsw-alias-label-secondary)}
|
|
115
121
|
.dpc-detailTags{display:flex;flex-wrap:wrap;gap:4px}
|
|
122
|
+
.dpc-skillList{margin:0;padding:0;list-style:none;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:4px 18px}
|
|
123
|
+
.dpc-skillItem{display:flex;gap:8px;align-items:baseline;font-size:12px;line-height:18px;min-width:0}
|
|
124
|
+
.dpc-skillName{font-family:var(--ds-font-family-code);color:var(--dsw-alias-label-primary);white-space:nowrap;flex:none}
|
|
125
|
+
.dpc-skillDesc{color:var(--dsw-alias-label-secondary);min-width:0}
|
|
126
|
+
@media(max-width:560px){.dpc-skillList{grid-template-columns:minmax(0,1fr)}}
|
|
116
127
|
@media(max-width:680px){.dpc-cards{grid-template-columns:minmax(0,1fr)}}
|
|
117
128
|
`
|
package/src/client/index.ts
CHANGED
|
@@ -131,6 +131,13 @@ export function apply(ctx: CapabilitiesClientContext): void {
|
|
|
131
131
|
})
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
/** One skill inside a market repository's inventory, as the browser sees it. */
|
|
135
|
+
export interface MarketSkillItemView {
|
|
136
|
+
name: string
|
|
137
|
+
description?: string
|
|
138
|
+
descriptionZh?: string
|
|
139
|
+
}
|
|
140
|
+
|
|
134
141
|
/** One skills-market repository as the browser sees it. */
|
|
135
142
|
export interface MarketRepoView {
|
|
136
143
|
id: string
|
|
@@ -138,10 +145,12 @@ export interface MarketRepoView {
|
|
|
138
145
|
nameZh?: string
|
|
139
146
|
description: string
|
|
140
147
|
descriptionZh?: string
|
|
148
|
+
detail?: string
|
|
149
|
+
detailZh?: string
|
|
141
150
|
url: string
|
|
142
151
|
homepage?: string
|
|
143
152
|
skillCount?: number
|
|
144
|
-
skills?:
|
|
153
|
+
skills?: MarketSkillItemView[]
|
|
145
154
|
}
|
|
146
155
|
|
|
147
156
|
/** One MCP-market server as the browser sees it. */
|
|
@@ -160,4 +169,6 @@ export interface MarketServerView {
|
|
|
160
169
|
category?: string
|
|
161
170
|
runtime?: string
|
|
162
171
|
tools?: string[]
|
|
172
|
+
detail?: string
|
|
173
|
+
detailZh?: string
|
|
163
174
|
}
|
package/src/market.test.ts
CHANGED
|
@@ -8,11 +8,13 @@ const okJson = (body: unknown): typeof fetch =>
|
|
|
8
8
|
describe('loadMarketIndex', () => {
|
|
9
9
|
it('prefers a valid remote index', async () => {
|
|
10
10
|
const index = await loadMarketIndex('skills', {
|
|
11
|
-
fetcher: okJson({ repos: [{ id: 'r1', name: 'Repo', description: 'd', url: 'https://github.com/a/b', skills: ['s1', 's2'] }] }),
|
|
11
|
+
fetcher: okJson({ repos: [{ id: 'r1', name: 'Repo', description: 'd', url: 'https://github.com/a/b', detail: 'long', detailZh: '长文', skills: [{ name: 's1', description: 'first', descriptionZh: '第一个' }, { name: 's2' }, 'junk'] }] }),
|
|
12
12
|
})
|
|
13
13
|
expect(index?.source).toBe('remote')
|
|
14
14
|
expect(index?.skills?.[0]?.id).toBe('r1')
|
|
15
|
-
expect(index?.skills?.[0]?.
|
|
15
|
+
expect(index?.skills?.[0]?.detail).toBe('long')
|
|
16
|
+
expect(index?.skills?.[0]?.detailZh).toBe('长文')
|
|
17
|
+
expect(index?.skills?.[0]?.skills).toEqual([{ name: 's1', description: 'first', descriptionZh: '第一个' }, { name: 's2' }])
|
|
16
18
|
})
|
|
17
19
|
|
|
18
20
|
it('falls back to the bundled snapshot when remote is unreachable or invalid', async () => {
|
|
@@ -30,7 +32,7 @@ describe('loadMarketIndex', () => {
|
|
|
30
32
|
const index = await loadMarketIndex('mcp', {
|
|
31
33
|
fetcher: okJson({
|
|
32
34
|
servers: [
|
|
33
|
-
{ id: 'ok', name: 'OK', description: 'd', transport: 'stdio', command: 'npx', args: ['-y', 'x'], envKeys: ['K'], homepage: 'https://x', tools: ['t1'] },
|
|
35
|
+
{ id: 'ok', name: 'OK', description: 'd', transport: 'stdio', command: 'npx', args: ['-y', 'x'], envKeys: ['K'], homepage: 'https://x', tools: ['t1'], detail: 'long' },
|
|
34
36
|
{ id: 'no-command', name: 'Bad', description: 'd', transport: 'stdio', homepage: 'https://x' },
|
|
35
37
|
{ id: 'no-home', name: 'Bad2', description: 'd', transport: 'stdio', command: 'npx' },
|
|
36
38
|
'not an object',
|
|
@@ -39,7 +41,7 @@ describe('loadMarketIndex', () => {
|
|
|
39
41
|
})
|
|
40
42
|
expect(index?.source).toBe('remote')
|
|
41
43
|
expect(index?.servers).toHaveLength(1)
|
|
42
|
-
expect(index?.servers?.[0]).toMatchObject({ id: 'ok', envKeys: ['K'], tools: ['t1'] })
|
|
44
|
+
expect(index?.servers?.[0]).toMatchObject({ id: 'ok', envKeys: ['K'], tools: ['t1'], detail: 'long' })
|
|
43
45
|
})
|
|
44
46
|
|
|
45
47
|
it('ships parseable bundled snapshots with expected top-level shape', () => {
|
package/src/market.ts
CHANGED
|
@@ -13,6 +13,13 @@ import { fileURLToPath } from 'node:url'
|
|
|
13
13
|
/** Which catalog a request wants. */
|
|
14
14
|
export type MarketKind = 'skills' | 'mcp'
|
|
15
15
|
|
|
16
|
+
/** One skill inside a market repository's inventory. */
|
|
17
|
+
export interface MarketSkillItem {
|
|
18
|
+
name: string
|
|
19
|
+
description?: string
|
|
20
|
+
descriptionZh?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
16
23
|
/** One installable skill repository in the skills index. */
|
|
17
24
|
export interface MarketSkillRepo {
|
|
18
25
|
id: string
|
|
@@ -20,11 +27,14 @@ export interface MarketSkillRepo {
|
|
|
20
27
|
nameZh?: string
|
|
21
28
|
description: string
|
|
22
29
|
descriptionZh?: string
|
|
30
|
+
/** Long-form intro for the detail view (falls back to description). */
|
|
31
|
+
detail?: string
|
|
32
|
+
detailZh?: string
|
|
23
33
|
url: string
|
|
24
34
|
homepage?: string
|
|
25
35
|
skillCount?: number
|
|
26
|
-
/** Skill
|
|
27
|
-
skills?:
|
|
36
|
+
/** Skill inventory for the market detail view. */
|
|
37
|
+
skills?: MarketSkillItem[]
|
|
28
38
|
}
|
|
29
39
|
|
|
30
40
|
/** One installable server in the MCP index. */
|
|
@@ -45,6 +55,9 @@ export interface MarketMcpServer {
|
|
|
45
55
|
runtime?: string
|
|
46
56
|
/** Tool names the server exposes, for the market detail view. */
|
|
47
57
|
tools?: string[]
|
|
58
|
+
/** Long-form intro for the detail view (falls back to description). */
|
|
59
|
+
detail?: string
|
|
60
|
+
detailZh?: string
|
|
48
61
|
}
|
|
49
62
|
|
|
50
63
|
export interface MarketIndex {
|
|
@@ -66,6 +79,22 @@ export function bundledMarketPath(kind: MarketKind): string {
|
|
|
66
79
|
const isString = (value: unknown): value is string => typeof value === 'string' && value !== ''
|
|
67
80
|
const isStringArray = (value: unknown): value is string[] => Array.isArray(value) && value.every(isString)
|
|
68
81
|
|
|
82
|
+
function parseSkillItems(value: unknown): MarketSkillItem[] | null {
|
|
83
|
+
if (!Array.isArray(value)) return null
|
|
84
|
+
const out: MarketSkillItem[] = []
|
|
85
|
+
for (const item of value) {
|
|
86
|
+
if (typeof item !== 'object' || item === null) continue
|
|
87
|
+
const record = item as Record<string, unknown>
|
|
88
|
+
if (!isString(record.name)) continue
|
|
89
|
+
out.push({
|
|
90
|
+
name: record.name,
|
|
91
|
+
...isString(record.description) ? { description: record.description } : {},
|
|
92
|
+
...isString(record.descriptionZh) ? { descriptionZh: record.descriptionZh } : {},
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
return out.length > 0 ? out : null
|
|
96
|
+
}
|
|
97
|
+
|
|
69
98
|
function parseSkillsIndex(parsed: unknown): MarketSkillRepo[] | null {
|
|
70
99
|
if (typeof parsed !== 'object' || parsed === null) return null
|
|
71
100
|
const repos = (parsed as { repos?: unknown }).repos
|
|
@@ -75,16 +104,19 @@ function parseSkillsIndex(parsed: unknown): MarketSkillRepo[] | null {
|
|
|
75
104
|
if (typeof entry !== 'object' || entry === null) continue
|
|
76
105
|
const record = entry as Record<string, unknown>
|
|
77
106
|
if (!isString(record.id) || !isString(record.name) || !isString(record.description) || !isString(record.url)) continue
|
|
107
|
+
const skills = parseSkillItems(record.skills)
|
|
78
108
|
out.push({
|
|
79
109
|
id: record.id,
|
|
80
110
|
name: record.name,
|
|
81
111
|
...isString(record.nameZh) ? { nameZh: record.nameZh } : {},
|
|
82
112
|
description: record.description,
|
|
83
113
|
...isString(record.descriptionZh) ? { descriptionZh: record.descriptionZh } : {},
|
|
114
|
+
...isString(record.detail) ? { detail: record.detail } : {},
|
|
115
|
+
...isString(record.detailZh) ? { detailZh: record.detailZh } : {},
|
|
84
116
|
url: record.url,
|
|
85
117
|
...isString(record.homepage) ? { homepage: record.homepage } : {},
|
|
86
118
|
...(typeof record.skillCount === 'number' ? { skillCount: record.skillCount } : {}),
|
|
87
|
-
...
|
|
119
|
+
...(skills !== null ? { skills } : {}),
|
|
88
120
|
})
|
|
89
121
|
}
|
|
90
122
|
return out.length > 0 ? out : null
|
|
@@ -117,6 +149,8 @@ function parseMcpIndex(parsed: unknown): MarketMcpServer[] | null {
|
|
|
117
149
|
...isString(record.category) ? { category: record.category } : {},
|
|
118
150
|
...isString(record.runtime) ? { runtime: record.runtime } : {},
|
|
119
151
|
...isStringArray(record.tools) ? { tools: record.tools } : {},
|
|
152
|
+
...isString(record.detail) ? { detail: record.detail } : {},
|
|
153
|
+
...isString(record.detailZh) ? { detailZh: record.detailZh } : {},
|
|
120
154
|
})
|
|
121
155
|
}
|
|
122
156
|
return out.length > 0 ? out : null
|