@doubao-dev/plugin-app-dev 0.0.0-stage → 0.0.40-canary-dea0ddc73-20261026073950
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 +10 -2
- package/dist/147.js +9 -0
- package/dist/assets.d.ts +5 -0
- package/dist/assets.js +4 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +1378 -0
- package/dist/plugin.d.ts +102 -0
- package/dist/plugin.js +4995 -0
- package/dist/preview.js +16 -0
- package/dist/rslib-runtime.js +33 -0
- package/dist/skills/doubao-plugin-app/SKILL.md +21 -0
- package/dist/skills/doubao-plugin-app/references/app-development.md +85 -0
- package/dist/skills/doubao-plugin-app/references/frontend/components/container-overlay.md +131 -0
- package/dist/skills/doubao-plugin-app/references/frontend/components/form-controls.md +146 -0
- package/dist/skills/doubao-plugin-app/references/frontend/components/interactive-controls.md +120 -0
- package/dist/skills/doubao-plugin-app/references/frontend/components/map-canvas.md +107 -0
- package/dist/skills/doubao-plugin-app/references/frontend/components/overview.md +43 -0
- package/dist/skills/doubao-plugin-app/references/frontend/components/scroll-list.md +149 -0
- package/dist/skills/doubao-plugin-app/references/frontend/components/text-media.md +209 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/01-/345/237/272/347/241/200.md +1389 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/02-/347/263/273/347/273/237.md +1376 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/03-/350/207/252/345/256/232/344/271/211/351/200/232/344/277/241.md +127 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/04-/345/256/232/344/275/215.md +784 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/05-/345/255/230/345/202/250.md +1176 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/06-/350/267/257/347/224/261.md +839 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/07-/347/225/214/351/235/242.md +376 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/08-/344/272/244/344/272/222.md +1319 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/09-/350/276/223/345/205/245.md +192 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/10-/347/275/221/347/273/234.md +900 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/11-/345/252/222/344/275/223.md +1496 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/12-/344/270/232/345/212/241/350/203/275/345/212/233.md +1281 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/13-/347/231/273/345/275/225.md +511 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/14-/346/224/257/344/273/230.md +943 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/15-/346/225/260/346/215/256/345/210/206/346/236/220.md +124 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/16-/350/223/235/347/211/231.md +3364 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/17-wi-fi.md +1028 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/18-/345/212/240/351/200/237/345/272/246/350/256/241.md +354 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/19-ibeacon.md +508 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/20-/347/275/227/347/233/230.md +320 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/21-/350/256/276/345/244/207/346/226/271/345/220/221.md +351 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/22-/351/231/200/350/236/272/344/273/252.md +354 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/23-/345/252/222/344/275/223-/350/256/276/345/244/207-/347/275/221/347/273/234.md +264 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/24-/347/237/255/344/277/241.md +155 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/25-/346/227/240/351/232/234/347/242/215.md +144 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/26-/345/237/272/347/241/200/344/277/241/346/201/257.md +238 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/27-/347/224/265/346/261/240.md +235 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/28-/345/211/252/350/264/264/346/235/277.md +303 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/29-/345/212/240/345/257/206.md +126 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/30-/346/227/245/345/216/206.md +417 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/31-/347/224/265/350/257/235.md +144 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/32-/346/211/253/347/240/201.md +236 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/33-/345/261/217/345/271/225.md +747 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/34-/351/234/207/345/212/250.md +277 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/35-/346/226/207/344/273/266/347/263/273/347/273/237.md +431 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/common-errors.md +69 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/groups.md +43 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/quick-reference.md +436 -0
- package/dist/skills/doubao-plugin-app/references/frontend/examples/common-patterns.md +590 -0
- package/dist/skills/doubao-plugin-app/references/frontend/examples/doubao-agentic-service-api-recipes.md +209 -0
- package/dist/skills/doubao-plugin-app/references/frontend/examples/page-widget-basics.md +368 -0
- package/dist/skills/doubao-plugin-app/references/frontend/examples/page-widget-recipes.md +65 -0
- package/dist/skills/doubao-plugin-app/references/frontend/framework/core.md +283 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/auth.md +277 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/best-practices.md +574 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/client-tools-and-events.md +209 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/component-development.md +832 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/debugger-mcp.md +537 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/expired-widget.md +101 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/performance-optimization.md +417 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/troubleshooting.md +278 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/best-practices.md +720 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/pseudo-classes.md +149 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/selectors.md +224 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/supported-properties.md +269 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/values-and-units.md +314 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/flex-layout.md +334 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/grid-layout.md +408 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/linear-layout.md +355 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/relative-layout.md +189 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/lynx-vs-web/css-differences.md +737 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/lynx-vs-web/migration-guide.md +669 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/lynx-vs-web/unsupported-features.md +290 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/overview.md +60 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/patterns/animation.md +243 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/patterns/responsive.md +194 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/patterns/theming.md +143 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/quick-reference.md +229 -0
- package/dist/skills/doubao-plugin-app/references/frontend/rules/dos-and-donts.md +479 -0
- package/dist/skills/doubao-plugin-app/references/frontend/widget-templates/design-boundary.md +46 -0
- package/dist/skills/doubao-plugin-app/references/frontend/widget-templates/overview.md +118 -0
- package/dist/skills/doubao-plugin-app/references/frontend/widget-templates/props.md +301 -0
- package/dist/skills/doubao-plugin-app/references/mcp-and-cards.md +38 -0
- package/dist/templates/README.md.template +11 -0
- package/dist/templates/com.doubao/app/manifest.yaml +41 -0
- package/dist/templates/com.doubao/app/package.json.template +13 -0
- package/dist/templates/com.doubao/app/src/app.config.ts.template +5 -0
- package/dist/templates/com.doubao/app/src/app.ts.template +3 -0
- package/dist/templates/com.doubao/app/src/pages/home/index.css +14 -0
- package/dist/templates/com.doubao/app/src/pages/home/index.tsx.template +14 -0
- package/dist/templates/com.doubao/app/src/widgets/example/index.tsx.template +29 -0
- package/dist/templates/com.doubao/app/tsconfig.json +19 -0
- package/dist/templates/mcp.json +9 -0
- package/dist/templates/plugin.json.template +29 -0
- package/dist/templates/skills/example/SKILL.md.template +14 -0
- package/dist/upload.d.ts +44 -0
- package/dist/upload.js +38 -0
- package/package.json +60 -3
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
# Template 模板 Props 参考
|
|
2
|
+
|
|
3
|
+
`priceExtraLoading` 在列表项上配置,默认 `false`,统一控制操作文案或 Tag 的加载状态。加载时隐藏原内容但保留区域高度,在下方区域靠右、垂直居中显示与 Button 相同的 16px 加载图标,图标右边缘与价格区域右边缘对齐。颜色跟随当前文案或标签文字并适配深浅色,屏蔽该区域点击;上方价格不变。没有非空文案和标签时不新增加载区域,业务负责切换状态。
|
|
4
|
+
|
|
5
|
+
所有模板从 `@doubao-dev/template` 导入。本文件记录当前版本支持的模板 Props 与行为约束。
|
|
6
|
+
|
|
7
|
+
约定:
|
|
8
|
+
|
|
9
|
+
- `TemplateText = string | number`,`TemplateKey = string | number`。
|
|
10
|
+
- `TemplateCardHeaderProps`:`actionText?: string` · `showAction?: boolean` · `onActionClick?: (event) => void`。
|
|
11
|
+
- `TemplateCardFooterProps`:`primaryActionButton?: TemplateCardFooterActionButton` · `secondaryActionButton?: TemplateCardFooterActionButton`。
|
|
12
|
+
- `TemplateCardFooterActionButton`:`text?` · `disabled?` · `loading?` · `throttle?` · `onClick?`。
|
|
13
|
+
- `header`、`footer` 和内容区相互独立。footer 不会影响 `items` 展示数量。
|
|
14
|
+
- 只使用各模板和列表项明确声明的公开字段。
|
|
15
|
+
- 只使用各模板和列表项明确声明的字段;没有匹配字段时不要自行拼装结构,按模板能力或新设计需求确认。
|
|
16
|
+
- `onClick` 作用在卡片根节点;卡片和 primitives 均不支持 `className` / `style`。
|
|
17
|
+
- 图片资源传运行时可访问 URL;本地图片放到业务项目 `src/assets` 后静态 `import` 再传入。
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Title — 标题展示组件
|
|
22
|
+
|
|
23
|
+
`import { Title, type TitleMaxLines, type TitleProps, type TitleValue } from '@doubao-dev/template/primitives'`
|
|
24
|
+
|
|
25
|
+
`Title` 用于卡片内容中的一行或两行标题排版,不是独立卡片模板。
|
|
26
|
+
|
|
27
|
+
| Prop | 类型 | 说明 |
|
|
28
|
+
|------|------|------|
|
|
29
|
+
| `text` | `string \| number` | 标题内容 |
|
|
30
|
+
| `maxLines` | `1 \| 2` | 最大行数,默认 `1`;超出后末行渐隐,不显示省略号 |
|
|
31
|
+
| `showArrow` | `boolean` | 是否展示右侧箭头,默认 `true` |
|
|
32
|
+
| `loading` | `boolean` | 展示扫光占位 |
|
|
33
|
+
|
|
34
|
+
箭头紧跟实际文字末尾,两行时跟随第二行末字;超长时保留箭头并渐隐其前方文字。隐藏箭头时,超长文字仍渐隐。
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Tag — 标签展示组件
|
|
39
|
+
|
|
40
|
+
`import { Tag, type TagProps, type TagTone, type TagValue } from '@doubao-dev/template/primitives'`
|
|
41
|
+
|
|
42
|
+
`Tag` 用于卡片内容中的营销、权威或常规辅助标签,不是独立卡片模板。
|
|
43
|
+
|
|
44
|
+
| Prop | 类型 | 说明 |
|
|
45
|
+
|------|------|------|
|
|
46
|
+
| `text` | `string \| number` | 标签内容,不截断 |
|
|
47
|
+
| `tone` | `'marketing' \| 'authority' \| 'neutral'` | 标签色调,默认 `authority` |
|
|
48
|
+
|
|
49
|
+
多个标签由业务容器横向排列,标签间距为 4px,容器高度为 26px;标签内容不会收缩或截断,空间不足时由业务容器隐藏放不下的整枚标签。
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Icon — 图标组件
|
|
54
|
+
|
|
55
|
+
`import { Icon, type IconName, type IconProps } from '@doubao-dev/template/primitives'`
|
|
56
|
+
|
|
57
|
+
`Icon` 通过名称选择模板体系提供的图标。
|
|
58
|
+
|
|
59
|
+
| Prop | 类型 | 说明 |
|
|
60
|
+
|------|------|------|
|
|
61
|
+
| `name` | `'add'` | 图标名称,当前仅支持 `add` |
|
|
62
|
+
|
|
63
|
+
`Icon` 只负责展示,不接收点击或状态属性;可点击的添加控件使用 `TemplateExtraAction` 的 `add` 类型。
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## OptionGroup — 选项集合组件
|
|
68
|
+
|
|
69
|
+
`import { OptionGroup, type OptionGroupItem, type OptionGroupProps, type OptionGroupSize, type OptionGroupValue } from '@doubao-dev/template/primitives'`
|
|
70
|
+
|
|
71
|
+
`OptionGroup` 用于座席、乘车人等选择场景,不是独立卡片模板;只接收结构化 `items`,不支持 `children`。
|
|
72
|
+
|
|
73
|
+
| Prop | 类型 | 说明 |
|
|
74
|
+
|------|------|------|
|
|
75
|
+
| `items` | `OptionGroupItem[]` | 选项数据,`value` 必须唯一 |
|
|
76
|
+
| `size` | `'md' \| 'lg'` | 默认 `md`;`md` 内容撑开,`lg` 按栏等分 |
|
|
77
|
+
| `columns` | `number` | 仅 `lg` 支持,每行栏数默认 `3` |
|
|
78
|
+
| `selectionMode` | `'single' \| 'multiple'` | 默认单选 |
|
|
79
|
+
| `value` | `OptionGroupValue \| OptionGroupValue[]` | 受控选择值,类型由选择模式决定 |
|
|
80
|
+
| `maxSelected` | `number` | 仅多选模式支持;双选时传 `2` |
|
|
81
|
+
| `onChange` | `(nextValue, item, event) => void` | 选择变化回调,返回完整的新值 |
|
|
82
|
+
|
|
83
|
+
`OptionGroupMediumItem`:`value` · `title` · `icon?: IconName` · `disabled?` · `onClick?`,不支持 `subtitle`。
|
|
84
|
+
|
|
85
|
+
`OptionGroupLargeItem`:`value` · `title` · `subtitle?` · `disabled?` · `onClick?`,不支持 `icon`。
|
|
86
|
+
|
|
87
|
+
组件统一使用 8px 间距并自动换行;`lg` 单行选项平均填满可用宽度,发生换行后各行保持相同栏宽和列位置,`md` 按内容宽度排列。用户点击时先触发选择变化,再触发 item 的 `onClick`;达到 `maxSelected` 后点击未选项不会触发 `onChange`,但仍会触发 item 的 `onClick`,已选项仍可取消;禁用项不触发事件。
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Price — 价格展示组件
|
|
92
|
+
|
|
93
|
+
`import { Price, type PricePrefixTone, type PriceProps, type PriceTone, type PriceValue } from '@doubao-dev/template/primitives'`
|
|
94
|
+
|
|
95
|
+
`Price` 用于卡片内容中的价格排版,不是独立卡片模板。
|
|
96
|
+
|
|
97
|
+
| Prop | 类型 | 说明 |
|
|
98
|
+
|------|------|------|
|
|
99
|
+
| `value` | `string \| number` | 价格值;字符串保留前导零和末尾小数位 |
|
|
100
|
+
| `currency` | `string` | 币种符号,默认 `¥`;空字符串隐藏 |
|
|
101
|
+
| `prefix` / `suffix` | `string` | 价格前缀 / 后缀 |
|
|
102
|
+
| `prefixTone` | `'default' \| 'highlight' \| 'muted'` | 前缀主文字色 / 营销红 / `--neutral-70`;不传时跟随价格色调 |
|
|
103
|
+
| `description` | `string` | 价格后的辅助信息 |
|
|
104
|
+
| `originalPrice` | `string \| number` | 原价,以删除线展示 |
|
|
105
|
+
| `tone` | `'default' \| 'highlight'` | 默认色或营销强调色 |
|
|
106
|
+
| `loading` | `boolean` | 展示扫光占位 |
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Stepper — 数量调节组件
|
|
111
|
+
|
|
112
|
+
`import { Stepper, type StepperProps } from '@doubao-dev/template/primitives'`
|
|
113
|
+
|
|
114
|
+
`Stepper` 是受控组件,点击后业务需根据 `onChange` 更新 `value`;也可作为 `ContentCardItem.action` 的 `stepper` 类型使用。
|
|
115
|
+
|
|
116
|
+
| Prop | 类型 | 说明 |
|
|
117
|
+
|------|------|------|
|
|
118
|
+
| `value` | `number` | 当前数量 |
|
|
119
|
+
| `min` | `number` | 最小值,默认 `0` |
|
|
120
|
+
| `max` | `number` | 可选的最大值 |
|
|
121
|
+
| `onChange` | `(value: number, event: TouchEvent) => void` | 点击可用的加减按钮时返回下一数量 |
|
|
122
|
+
|
|
123
|
+
每次增减 `1`;达到 `min` 或 `max` 时对应按钮不可点击,不触发 `onChange`。
|
|
124
|
+
数值区域固定宽 38px,左右各留 4px;组件总宽 86px,超长数值单行省略,不会撑宽组件。
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## CompositeCard — 组合卡
|
|
129
|
+
|
|
130
|
+
`import { CompositeCard, type CompositeCardContentSection, type CompositeCardOptionGroupSection, type CompositeCardProps, type CompositeCardSection, type CompositeCardTransitSection } from '@doubao-dev/template'`
|
|
131
|
+
|
|
132
|
+
| Prop | 类型 | 说明 |
|
|
133
|
+
|------|------|------|
|
|
134
|
+
| `header` | `TemplateCardHeaderProps` | 标准标题栏配置 |
|
|
135
|
+
| `sections` | `CompositeCardSection[]` | 单层有序模块数组,按配置顺序展示 |
|
|
136
|
+
| `footer` | `TemplateCardFooterProps` | 标准底部操作区配置 |
|
|
137
|
+
| `onClick` | `(event: TouchEvent) => void` | 卡片根节点点击回调 |
|
|
138
|
+
|
|
139
|
+
当前白名单:
|
|
140
|
+
|
|
141
|
+
- `CompositeCardTransitSection`:`{ type: 'transit', props: { items?: TransitCardItem[] } }`。
|
|
142
|
+
- `CompositeCardContentSection`:`{ type: 'content', props: { items?: ContentCardItem[] } }`;只复用 ContentCard 的内容区域,不渲染其卡片外壳、header 或 footer。
|
|
143
|
+
- `CompositeCardOptionGroupSection`:`{ type: 'option-group', props: OptionGroupProps }`。
|
|
144
|
+
|
|
145
|
+
`props` 透传给对应模块,因此模块原有的回调和具名内容字段仍然有效;组合器不开放 section `children`、任意 JSX、布局参数或 wrapper 样式,也不提供独立标题字段。标题、说明等内容通过 `content` section 表达。卡片统一管理标准 header/footer,复用模块保留原有内容留白、内部布局与窄屏策略;`OptionGroup` 由组合卡内的专用容器补充左右 12px、下方 16px,上方不额外留白。
|
|
146
|
+
|
|
147
|
+
`items` 为空的 section 会连同间距一起收起;运行时未知 `type` 不展示。`sections` 不支持运行中插入、删除或重排,不要求配置 section key。
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## MapCard — 地图卡
|
|
152
|
+
|
|
153
|
+
`import { MapCard, type MapCardMapProps, type MapCardMetaItem, type MapCardProps, type TemplateCardFooterActionButton } from '@doubao-dev/template'`
|
|
154
|
+
|
|
155
|
+
| Prop | 类型 | 说明 |
|
|
156
|
+
|------|------|------|
|
|
157
|
+
| `mapProps` | `Omit<MapProps, 'className' \| 'style'>` | 地图配置;卡片统一管理地图宽高和类名 |
|
|
158
|
+
| `title` | `TemplateText` | 信息区单行标题 |
|
|
159
|
+
| `showArrow` | `boolean` | 是否展示标题箭头,默认 `true` |
|
|
160
|
+
| `metaItems` | `MapCardMetaItem[]` | 辅助信息,最多展示前 2 项 |
|
|
161
|
+
| `inlineActions` | `TemplateCardFooterActionButton[]` | 右侧紧凑操作,最多展示前 2 个;双按钮依次按次按钮、主按钮渲染 |
|
|
162
|
+
| `footer` | `TemplateCardFooterProps` | 底部操作区配置 |
|
|
163
|
+
|
|
164
|
+
`MapCardMetaItem`:`key?` · `text: TemplateText` · `tone?: 'default' | 'highlight'`。多项之间由模板渲染分隔点。
|
|
165
|
+
|
|
166
|
+
地图区域高度固定为 168px。信息区和 footer 都是可选结构,可分别单独展示或组合展示。MapCard 不支持 `children`;地图覆盖物通过 `mapProps.children` 传入。
|
|
167
|
+
MapCard 的 `ref` 直接绑定到内部 Map,可通过 `MapRef` 调用地图实例方法。
|
|
168
|
+
地图左上角的应用插件标题由客户端 `titleType` 控制,MapCard 不重复渲染来源标题。
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## ContentCard — 列表卡
|
|
173
|
+
|
|
174
|
+
`import { ContentCard, type ContentCardItem, type ContentCardProps, type TemplateExtraAction, type TemplateCardHeaderProps, type TemplateCardFooterProps } from '@doubao-dev/template'`
|
|
175
|
+
|
|
176
|
+
| Prop | 类型 | 说明 |
|
|
177
|
+
|------|------|------|
|
|
178
|
+
| `header` | `TemplateCardHeaderProps` | 标题栏配置 |
|
|
179
|
+
| `items` | `ContentCardItem[]` | 列表数据,全量展示 |
|
|
180
|
+
| `footer` | `TemplateCardFooterProps` | 底部操作区配置 |
|
|
181
|
+
|
|
182
|
+
`ContentCardItem`:`key?` · `title?: string | number | ReactElement`(字符串/数字最多一行;两行标题传 `<Title maxLines={2} />`)· `subtitle?: string | number | ReactElement`(字符串/数字最多一行)· `description?: string | number | ReactElement`(字符串/数字最多一行)· `thumbnailSrc?: string` · `thumbnail?: ReactElement`(优先于 `thumbnailSrc`)· `action?: TemplateExtraAction`(包含 `stepper` 数量调节器)· `onClick?`
|
|
183
|
+
|
|
184
|
+
`TemplateExtraAction`:
|
|
185
|
+
|
|
186
|
+
- `{ type: 'button', text, disabled?, loading?, onClick? }`
|
|
187
|
+
- `{ type: 'add', disabled?, loading?, onClick? }`(24px × 24px 添加控件,内部图形为 12px × 12px,与 Stepper 的加号一致)
|
|
188
|
+
- `{ type: 'stepper', value, min?, max?, onChange? }`(受控数量调节器,宽 86px,单次增减 1)
|
|
189
|
+
- `{ type: 'switch', checked, disabled?, onChange? }`(受控)
|
|
190
|
+
- `{ type: 'playback', playing, progress?, disabled?, onToggle? }`(受控;`progress` 范围 `0~1`)
|
|
191
|
+
|
|
192
|
+
同一列表项的 `action.type` 从 `add` 切换为 `stepper` 时保持右侧加号位置并向左展开;由业务显式切换类型,不根据 `value` 自动展开或收起。
|
|
193
|
+
带缩略图时,文字高度超过 80px 图片则顶对齐,否则垂直居中;操作区始终相对图片垂直居中。
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## PriceActionCard — 价格操作卡
|
|
198
|
+
|
|
199
|
+
`import { PriceActionCard, type PriceActionCardItem, type PriceActionCardInfoRow, type PriceActionCardProps } from '@doubao-dev/template'`
|
|
200
|
+
|
|
201
|
+
| Prop | 类型 | 说明 |
|
|
202
|
+
|------|------|------|
|
|
203
|
+
| `header` | `TemplateCardHeaderProps` | 标题栏配置 |
|
|
204
|
+
| `items` | `PriceActionCardItem[]` | 价格列表 |
|
|
205
|
+
| `footer` | `TemplateCardFooterProps` | 底部操作区配置 |
|
|
206
|
+
|
|
207
|
+
`PriceActionCardItem`:`key?` · `price?: TemplateText` · `badgeText?: TemplateText` · `infoRows?: PriceActionCardInfoRow[]`(最多前 2 行)· `actionText?` · `onClick?` · `onActionClick?`
|
|
208
|
+
|
|
209
|
+
`PriceActionCardInfoRow`:`key?` · `text: TemplateText`
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## CouponCard — 券卡
|
|
214
|
+
|
|
215
|
+
`import { CouponCard, type CouponCardItem, type CouponCardProps } from '@doubao-dev/template'`
|
|
216
|
+
|
|
217
|
+
`items?: CouponCardItem[]`,默认空数组;`onClick?: (event) => void` 为卡片根节点点击回调。
|
|
218
|
+
|
|
219
|
+
`CouponCardItem`:`key?` · `value: string | number` · `unit?: string`(默认 `元`)· `condition?: string` · `sourceName?: string` · `title?: string` · `validityText?: string` · `actionText?: string`(默认 `立即用`,空字符串隐藏)· `disabled?: boolean` · `loading?: boolean` · `onClick?` · `onActionClick?`。
|
|
220
|
+
|
|
221
|
+
- 按 `items.length` 自动布局:单券高 80px、最大宽 400px;双券高 80px、间距 8px、每张最大宽 200px;三张及以上高 112px、间距 4px、每张宽 96–150px,超出横向滚动。
|
|
222
|
+
- `title`、`validityText` 仅在单券中展示;所有文案限制一行,超出省略。
|
|
223
|
+
- `disabled` 时整体透明度 50%,禁止券与按钮点击;使用后的文案与状态由业务更新。
|
|
224
|
+
- `loading` 由业务控制,复用 Button 加载态,保持操作按钮宽度并禁止重复点击;不影响券内容点击及整体透明度。
|
|
225
|
+
- 按钮不触发券或根节点点击;券配置 `onClick` 时阻止向根节点冒泡,未配置则保留冒泡。
|
|
226
|
+
- 仅支持结构化文本与回调,不支持 ReactNode、`children`、`style`、`className`,无 `header` / `footer`。
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## CheckoutCard — 提单卡(通用电商)
|
|
231
|
+
|
|
232
|
+
`import { CheckoutCard, type CheckoutCardProductItem, type CheckoutCardInfoItem, type CheckoutCardFeeItem, type CheckoutCardProps } from '@doubao-dev/template'`
|
|
233
|
+
|
|
234
|
+
| Prop | 类型 | 说明 |
|
|
235
|
+
|------|------|------|
|
|
236
|
+
| `header` | `TemplateCardHeaderProps` | 标题栏配置 |
|
|
237
|
+
| `productItems` | `CheckoutCardProductItem[]` | 商品摘要,支持单/多个 |
|
|
238
|
+
| `infoItems` | `CheckoutCardInfoItem[]` | 提单信息列表 |
|
|
239
|
+
| `feeItems` | `CheckoutCardFeeItem[]` | 费用明细,优惠信息也通过该属性传入 |
|
|
240
|
+
| `totalLabel` / `totalPrice` | `string` / `TemplateText` | 合计标签 / 合计价格 |
|
|
241
|
+
| `footer` | `TemplateCardFooterProps` | 底部操作区配置 |
|
|
242
|
+
|
|
243
|
+
`CheckoutCardProductItem` 继承商品摘要 props,并增加 `key?`。常用字段:`title?` · `tagText?: TemplateText`(展示在标题前)· `tagTone?: 'default' | 'highlight'`(默认 `default`)· `spec?` · `imageSrc?` · `image?: ReactElement` · `pricePrefix?` · `price?: TemplateText` · `quantity?: TemplateText` · `showChevron?` · `onClick?`
|
|
244
|
+
|
|
245
|
+
`CheckoutCardInfoItem`:`key?` · `label: string` · `value: TemplateText` · `valueExtra?: TemplateText`。两项使用相同样式,并与左侧 label 的首行对齐。
|
|
246
|
+
|
|
247
|
+
`CheckoutCardFeeItem`:`key?` · `label: string` · `value: TemplateText`
|
|
248
|
+
|
|
249
|
+
`feeItems` 作为单行整体与 `totalLabel` / `totalPrice` 共同布局;空间不足时合计整体换到第二行,两组各自超宽时单行省略,汇总区域最多两行。
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## TransitCard — 交通票务列表卡
|
|
254
|
+
|
|
255
|
+
`import { TransitCard, type TransitCardItem, type TransitCardPrice, type TransitCardPriceAction, type TransitCardPriceActionTone, type TransitCardProps, type TransitCardTag } from '@doubao-dev/template'`
|
|
256
|
+
|
|
257
|
+
| Prop | 类型 | 说明 |
|
|
258
|
+
|------|------|------|
|
|
259
|
+
| `header` | `TemplateCardHeaderProps` | 标题栏配置 |
|
|
260
|
+
| `items` | `TransitCardItem[]` | 行程列表,全量展示 |
|
|
261
|
+
| `footer` | `TemplateCardFooterProps` | 底部操作区配置 |
|
|
262
|
+
|
|
263
|
+
`TransitCardItem`:`key?` · `title?: string | number | ReactElement` · `departureMain?` / `departureSub?: TemplateText` · `transferTop?` / `transferBottom?: TemplateText` · `arrivalMain?` / `arrivalDayOffset?` / `arrivalSub?: TemplateText` · `price?: TransitCardPrice | TemplateText` · `priceAction?: TransitCardPriceAction` · `tag?: TransitCardTag` · `priceExtraLoading?: boolean` · `onClick?` · `onRouteClick?` · `onPriceClick?`
|
|
264
|
+
|
|
265
|
+
`onRouteClick` 覆盖左侧行程热区(含标题),`onPriceClick` 覆盖右侧价格热区(含标签或操作文案)。区域回调使用 `TouchEvent`,触发时不会再触发列表项 `onClick`;未配置区域回调时保留原有整项点击行为。
|
|
266
|
+
|
|
267
|
+
`TransitCardPrice`:`value: string | number` · `currency?: string`(默认 `¥`)· `prefix?: string` · `prefixTone?: 'default' | 'highlight' | 'muted'`(不传时跟随价格色调)· `tone?: 'default' | 'highlight'`。生成新代码时只使用结构化价格配置。
|
|
268
|
+
|
|
269
|
+
`price` 传数字时作为 `Price.value` 并使用默认币种;传字符串时按首个币种符号拆为 `prefix + currency + value`,没有币种符号时整串作为 `value` 且 `currency=""`。标量价格使用 Price 的默认 `tone`。
|
|
270
|
+
|
|
271
|
+
`TransitCardPriceAction`:`text: string | number` · `tone?: 'highlight' | 'muted'`(默认 `highlight`)· `showIcon?: boolean`(默认 `true`)。操作文案展示在价格下方,箭头样式由模板统一管理;与 `tag` 同时传入时优先展示 `priceAction`。
|
|
272
|
+
|
|
273
|
+
`TransitCardTag`:`text: string | number` · `tone?: 'marketing' | 'neutral'`(默认 `marketing`)。标签展示在价格下方;不传 `tag` 时保持单价格布局。
|
|
274
|
+
|
|
275
|
+
窄屏下模板会先压缩行程与价格之间的空白,再压缩出发、中转和到达列之间的空白;空间仍不足时隐藏价格,内容块本身保持原有宽度。
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## AskHumanCard — 人工确认选项卡
|
|
280
|
+
|
|
281
|
+
`import { AskHumanCard, type AskHumanCardItem, type AskHumanCardProps } from '@doubao-dev/template'`
|
|
282
|
+
|
|
283
|
+
| Prop | 类型 | 说明 |
|
|
284
|
+
|------|------|------|
|
|
285
|
+
| `items` | `AskHumanCardItem[]` | 选项列表 |
|
|
286
|
+
| `variant` | `'suggestion' \| 'jump'` | 选项行为语义;默认 `suggestion`,单个或两个固定跳转按钮用 `jump` |
|
|
287
|
+
| `onClick` | `(event) => void` | 卡片根节点点击 |
|
|
288
|
+
|
|
289
|
+
`AskHumanCardItem`:`key?` · `text?: TemplateText` · `loading?` · `openType?: 'launchApp'` · `launchAppUrl?` · `showArrow?: 'left' | 'right' | 'none'` · `onClick?` · `onLaunchApp?` · `onLaunchAppError?`
|
|
290
|
+
|
|
291
|
+
跳过、固定跳转等入口也通过 `items` 表达;`showArrow` 支持 `'left'`、`'right'`、`'none'`,默认不展示。单个全宽操作按钮用
|
|
292
|
+
`variant="jump"` 和一个 `items` 项表达。
|
|
293
|
+
|
|
294
|
+
## 内容槽位静态检查
|
|
295
|
+
|
|
296
|
+
文本字段类型为 `string | number | ReactElement`;构建检查允许字符串、数字或直接传入的 primitive `Tag` / `Title`。
|
|
297
|
+
媒体字段类型为 `ReactElement`;构建检查仅允许直接传入的 `<image />` 或 `<svg />`。
|
|
298
|
+
类型声明只约束值的类别,不能区分 JSX 的具体元素;primitive 从 template 的 `primitives` 子入口导入。
|
|
299
|
+
构建对可静态确定的违规节点输出 `[卡片检查]` warning,不改变运行时行为。
|
|
300
|
+
检查支持当前文件的常量、导入别名、命名空间、对象/数组展开、条件表达式和表达式形式的 map 回调。
|
|
301
|
+
跨文件数据、动态函数返回值等无法确定的内容会跳过;没有 warning 不代表所有内容均已验证。
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# MCP、业务 Skill 与卡片
|
|
2
|
+
|
|
3
|
+
## 配置职责
|
|
4
|
+
|
|
5
|
+
| 文件 | 职责 |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| 根目录 `mcp.json` | `mcpServers.<连接名>` 配置 type、url 和 headers,Web 模拟器目前接入单个 `streamable-http` 服务 |
|
|
8
|
+
| `plugin.json` | `extensions.com.doubao.mcpServers.<连接名>` 提供 displayName 和 displayDescription 多语言展示信息,连接名与 mcp.json 一致 |
|
|
9
|
+
| `com.doubao/app/manifest.yaml` | 声明工具输出、实体 schema 和卡片绑定;配置 mcp_server 时与 mcp.json 指向同一服务 |
|
|
10
|
+
| `skills/<name>/SKILL.md` | 指导模型何时调用工具、参数规则和结果处理 |
|
|
11
|
+
|
|
12
|
+
MCP 连接和服务展示信息属于整个插件,始终维护在插件根目录;`extensions.com.doubao` 是平台命名空间,不代表这些配置属于 App。App Manifest 只维护应用侧工具输出、实体和卡片绑定。
|
|
13
|
+
|
|
14
|
+
新项目已配置共享线上购物服务,无需启动本地 MCP。使用自建服务时由开发者启动;发布时应使用平台可访问的地址。
|
|
15
|
+
|
|
16
|
+
## 业务 Skill
|
|
17
|
+
|
|
18
|
+
每个业务 Skill 使用独立目录,YAML frontmatter 必须包含非空的 `name`、`description`、`metadata.display_name`(展示名称)和 `metadata.display_description`(展示描述)。`name` 与所在目录名一致,并避免与平台已有 Skill 重名;重命名时同步修改目录和字段。展示字段必须放在 `metadata` 下,不能用顶层 `description` 代替;以当前项目的业务 Skill 为例修改。
|
|
19
|
+
|
|
20
|
+
正文中的字段名、必填项、类型、范围和示例必须与 MCP `tools/list` 的 `inputSchema` 一致。购物示例 `search_products` 的 query 为非空字符串,limit 为 1~10 的整数;用户要求更多结果时也不能传入 100 等越界值。
|
|
21
|
+
|
|
22
|
+
依据工具实际结果回答,失败时说明原因。辅助资料可放入 references、scripts、assets,但当前 Web 模拟器只读取 SKILL.md 正文,不加载这些附件。
|
|
23
|
+
|
|
24
|
+
## 出卡契约
|
|
25
|
+
|
|
26
|
+
按当前模板的商品搜索链路,逐项核对:
|
|
27
|
+
|
|
28
|
+
1. 工具返回 `structuredContent.entities`;文本 `content` 不能代替结构化实体。
|
|
29
|
+
2. 每个实体的 `entity_type` 命中 Manifest 的 `entities`,`is_entity_id: true` 字段实际存在且稳定标识该实体。
|
|
30
|
+
3. `tools.<工具名>.output` 声明 `kind: entities` 和对应的 `entity_types`。
|
|
31
|
+
4. 实体的 `tool_card_binding.<工具名>` 指向 app.config.ts 中的 Widget ID;一个列表实体可以渲染一张含多项的卡片。
|
|
32
|
+
5. Widget 用 `useViewData<T>()` 读取该实体,字段和类型与返回数据一致,最后映射成卡片模板 props。
|
|
33
|
+
|
|
34
|
+
业务错误返回 `isError: true`,通过 structuredContent 的 code 和 message 提供数字错误码及文案,不生成成功实体。
|
|
35
|
+
|
|
36
|
+
## 排查顺序
|
|
37
|
+
|
|
38
|
+
先检查工具是否调用成功和参数校验,再核对原始实体、Manifest 映射、Widget 注册及字段,最后查看本地编译和 [模拟器日志与 Trace](frontend/guides/debugger-mcp.md)。平台同步与本地编译分别判断;反复安装不能解决个人测试插件接口不支持 App 的限制。
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# __PLUGIN_NAME__
|
|
2
|
+
|
|
3
|
+
应用插件项目,包含购物 MCP、商品搜索业务 Skill、App 页面和卡片。
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
dbx dev --app
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
输入 `web` 打开 Web 模拟器,发送“搜索牛奶”查看商品卡片。
|
|
10
|
+
|
|
11
|
+
项目配置与上传见 [CLI 开发 Skill](.agents/skills/doubao-plugin-cli/SKILL.md),页面和卡片开发见 [App 开发 Skill](.agents/skills/doubao-plugin-app/SKILL.md)。链接缺失时运行 `dbx skills`。
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
manifest_version: 2
|
|
2
|
+
permissions: []
|
|
3
|
+
mcp_server:
|
|
4
|
+
end_point: https://s0piqd9123oupmbgufs9i.apigateway-cn-beijing.volceapi.com/mcp
|
|
5
|
+
description: 初始化模板使用的共享购物示例 MCP 服务
|
|
6
|
+
mcp_config:
|
|
7
|
+
protocol: Streamable
|
|
8
|
+
tools:
|
|
9
|
+
search_products:
|
|
10
|
+
login_type: no_login
|
|
11
|
+
description: 根据关键词搜索商品,返回商品名称、规格和价格。
|
|
12
|
+
output:
|
|
13
|
+
kind: entities
|
|
14
|
+
entity_types:
|
|
15
|
+
- product_search_entity
|
|
16
|
+
entities:
|
|
17
|
+
product_search_entity:
|
|
18
|
+
schema:
|
|
19
|
+
search_id:
|
|
20
|
+
type: string
|
|
21
|
+
is_entity_id: true
|
|
22
|
+
entity_type:
|
|
23
|
+
type: string
|
|
24
|
+
llm_visible: false
|
|
25
|
+
query:
|
|
26
|
+
type: string
|
|
27
|
+
products:
|
|
28
|
+
type: array
|
|
29
|
+
items:
|
|
30
|
+
type: object
|
|
31
|
+
properties:
|
|
32
|
+
sku_id:
|
|
33
|
+
type: string
|
|
34
|
+
name:
|
|
35
|
+
type: string
|
|
36
|
+
spec:
|
|
37
|
+
type: string
|
|
38
|
+
price:
|
|
39
|
+
type: float
|
|
40
|
+
tool_card_binding:
|
|
41
|
+
search_products: example
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
|
|
3
|
+
export default function HomePage() {
|
|
4
|
+
return (
|
|
5
|
+
<view>
|
|
6
|
+
<navigation-bar title="示例页面" />
|
|
7
|
+
<view className="page">
|
|
8
|
+
<text className="title">应用插件已连接</text>
|
|
9
|
+
<text className="description">你已从对话卡片打开示例页面。</text>
|
|
10
|
+
<text className="description">修改此页面或卡片代码,保存后即可查看更新。</text>
|
|
11
|
+
</view>
|
|
12
|
+
</view>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useViewData } from '@doubao-dev/framework';
|
|
2
|
+
import { navigateTo } from '@doubao-dev/framework/api';
|
|
3
|
+
import { ContentCard } from '@doubao-dev/template';
|
|
4
|
+
|
|
5
|
+
type ProductSearch = {
|
|
6
|
+
products: { sku_id: string; name: string; spec: string; price: number }[];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default function ExampleCard() {
|
|
10
|
+
const data = useViewData<ProductSearch>();
|
|
11
|
+
return (
|
|
12
|
+
<ContentCard
|
|
13
|
+
items={(data?.products ?? []).map((product) => ({
|
|
14
|
+
key: product.sku_id,
|
|
15
|
+
title: product.name,
|
|
16
|
+
subtitle: product.spec,
|
|
17
|
+
description: `¥${product.price}`
|
|
18
|
+
}))}
|
|
19
|
+
footer={{
|
|
20
|
+
primaryActionButton: {
|
|
21
|
+
text: '打开示例页面',
|
|
22
|
+
onClick: () => {
|
|
23
|
+
void navigateTo({ url: '/pages/home/index' }).catch((error) => console.error(error));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"allowJs": true,
|
|
4
|
+
"noImplicitThis": true,
|
|
5
|
+
"jsx": "react-jsx",
|
|
6
|
+
"jsxImportSource": "@doubao-dev/framework",
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"resolveJsonModule": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"module": "esnext",
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"lib": ["ES2020", "DOM"],
|
|
13
|
+
"paths": {
|
|
14
|
+
"@/*": ["./src/*"]
|
|
15
|
+
},
|
|
16
|
+
"types": ["@doubao-dev/framework/types"]
|
|
17
|
+
},
|
|
18
|
+
"include": ["src"]
|
|
19
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
|
+
"name": "__PLUGIN_NAME__",
|
|
4
|
+
"description": "根据关键词搜索示例商品",
|
|
5
|
+
"extensions": {
|
|
6
|
+
"com.doubao": {
|
|
7
|
+
"displayName": {
|
|
8
|
+
"zh": "__PLUGIN_NAME__",
|
|
9
|
+
"en": "__PLUGIN_NAME__"
|
|
10
|
+
},
|
|
11
|
+
"displayDescription": {
|
|
12
|
+
"zh": "根据关键词搜索示例商品",
|
|
13
|
+
"en": "Search example products by keyword."
|
|
14
|
+
},
|
|
15
|
+
"mcpServers": {
|
|
16
|
+
"shopping": {
|
|
17
|
+
"displayName": {
|
|
18
|
+
"zh": "商品搜索",
|
|
19
|
+
"en": "Product search"
|
|
20
|
+
},
|
|
21
|
+
"displayDescription": {
|
|
22
|
+
"zh": "按关键词搜索示例商品。",
|
|
23
|
+
"en": "Search example products by keyword."
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: __PLUGIN_NAME__
|
|
3
|
+
description: 用户希望按关键词查找商品时,调用共享示例 MCP 的 search_products 工具。
|
|
4
|
+
metadata:
|
|
5
|
+
display_name: 商品搜索
|
|
6
|
+
display_description: 根据关键词搜索示例商品,查看名称、规格和价格。
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
用户要求查找商品时调用 `search_products`,将商品关键词作为 `query` 传入。
|
|
10
|
+
参数规则:`query` 必须是非空字符串;`limit` 必须是 1~10 的整数,默认传 3。
|
|
11
|
+
用户要求超过 10 条时,每次最多查询 10 条,不得传入 100 等超出范围的值。
|
|
12
|
+
例如搜索牛奶:`{"query":"牛奶","limit":3}`。
|
|
13
|
+
根据工具实际返回结果回答;工具失败时说明原因,不编造商品和价格。
|
|
14
|
+
结果中展示实际返回的名称、规格和价格;有 App 时由商品卡片呈现。
|
package/dist/upload.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
declare interface AppProject {
|
|
2
|
+
root: string;
|
|
3
|
+
plugin: {
|
|
4
|
+
name: string;
|
|
5
|
+
id?: string;
|
|
6
|
+
};
|
|
7
|
+
app?: {
|
|
8
|
+
root: string;
|
|
9
|
+
};
|
|
10
|
+
mcpServers: Record<string, unknown>[];
|
|
11
|
+
readSkills(): {
|
|
12
|
+
root: string;
|
|
13
|
+
content: string;
|
|
14
|
+
}[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare interface PreviewParams {
|
|
18
|
+
name?: string;
|
|
19
|
+
ability_id?: string;
|
|
20
|
+
version: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
declare interface PreviewTools {
|
|
24
|
+
withProgress<T>(message: string, action: () => Promise<T>): Promise<T>;
|
|
25
|
+
queryBuildStatus(params: PreviewParams, signal: AbortSignal): Promise<{
|
|
26
|
+
artifact_status?: string;
|
|
27
|
+
artifact_build_error_info?: {
|
|
28
|
+
error_info?: string;
|
|
29
|
+
error_code?: string;
|
|
30
|
+
};
|
|
31
|
+
}>;
|
|
32
|
+
createPreview(params: PreviewParams, signal: AbortSignal): Promise<{
|
|
33
|
+
preview?: {
|
|
34
|
+
preview_url?: string;
|
|
35
|
+
};
|
|
36
|
+
display_name?: string;
|
|
37
|
+
test_version?: string;
|
|
38
|
+
expires_at_ms?: string | number;
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export declare function showPreview(project: AppProject, version: string, tools: PreviewTools): Promise<void>;
|
|
43
|
+
|
|
44
|
+
export { }
|
package/dist/upload.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { setTimeout as promises_setTimeout } from "node:timers/promises";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
async function showPreview(project, version, tools) {
|
|
4
|
+
const { id, name } = project.plugin;
|
|
5
|
+
const params = {
|
|
6
|
+
...id ? {
|
|
7
|
+
ability_id: id
|
|
8
|
+
} : {
|
|
9
|
+
name
|
|
10
|
+
},
|
|
11
|
+
version
|
|
12
|
+
};
|
|
13
|
+
const signal = AbortSignal.timeout(600000);
|
|
14
|
+
z.string().regex(/^\d+\.\d+\.\d+$/, '版本号须为 x.y.z 格式').parse(version);
|
|
15
|
+
await tools.withProgress('等待云构建', async ()=>{
|
|
16
|
+
while(true){
|
|
17
|
+
const status = await tools.queryBuildStatus(params, signal);
|
|
18
|
+
if ('BUILD_SUCCEEDED' === status.artifact_status) return;
|
|
19
|
+
if ('BUILD_FAILED' === status.artifact_status) {
|
|
20
|
+
const error = status.artifact_build_error_info;
|
|
21
|
+
throw new Error(error?.error_info || error?.error_code || '云构建失败');
|
|
22
|
+
}
|
|
23
|
+
await promises_setTimeout(2000, void 0, {
|
|
24
|
+
signal
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const result = await tools.createPreview(params, signal);
|
|
29
|
+
if (!result.preview?.preview_url) throw new Error('服务端未返回预览链接');
|
|
30
|
+
const { printPreview } = await import("./preview.js");
|
|
31
|
+
await printPreview({
|
|
32
|
+
url: result.preview.preview_url,
|
|
33
|
+
name: result.display_name || name,
|
|
34
|
+
version: result.test_version || version,
|
|
35
|
+
expiresAt: result.expires_at_ms
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
export { showPreview };
|