From e982981a83a51688d50203a9a22a6e2e0cc160c6 Mon Sep 17 00:00:00 2001 From: Lan_zhijiang Date: Fri, 23 Oct 2026 14:32:58 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix(web):=20=E4=BF=AE=E6=AD=A3=20Agent=20?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E5=B9=B6=E8=87=AA=E5=8A=A8=E5=BD=92=E6=A1=A3?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E8=BF=81=E7=A7=BB=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 纠正组件选型和依赖说明,补齐签名类型并移除重复文档 - 接入迁移自动归档、失败恢复和发布前检查 - 扩展实际包消费验证,并覆盖归档与元数据失败重试 --- .changeset/agent-reference-corrections.md | 7 + CONTRIBUTING.md | 12 ++ package.json | 9 +- packages/web/MIGRATION.md | 68 +++---- packages/web/skill.seed.json | 10 +- packages/web/skills/ui-web/SKILL.md | 5 +- .../ui-web/references/common-mistakes.md | 100 +-------- .../references/components/InkAutoForm.md | 6 +- .../ui-web/references/components/InkButton.md | 2 +- .../components/InkDatetimePickerView.md | 2 +- .../ui-web/references/components/InkDialog.md | 17 +- .../references/components/InkDoubleCheck.md | 2 +- .../references/components/InkDropdown.md | 6 +- .../ui-web/references/components/InkField.md | 2 +- .../ui-web/references/components/InkForm.md | 2 +- .../ui-web/references/components/InkHeader.md | 2 +- .../ui-web/references/components/InkImage.md | 12 +- .../ui-web/references/components/InkInput.md | 2 +- .../references/components/InkJsonEditor.md | 6 +- .../references/components/InkLoading.md | 2 +- .../references/components/InkPagination.md | 2 +- .../ui-web/references/components/InkPicker.md | 2 +- .../references/components/InkPlaceholder.md | 2 +- .../ui-web/references/components/InkPopup.md | 15 +- .../ui-web/references/components/InkScrim.md | 2 +- .../references/components/InkSkeleton.md | 2 +- .../ui-web/references/components/InkSwitch.md | 2 +- .../ui-web/references/components/InkTabs.md | 19 +- .../references/components/InkTextarea.md | 2 +- .../references/components/InkTooltip.md | 2 +- .../ui-web/references/composition-recipes.md | 2 +- scripts/build-agent-skills.md | 6 + scripts/build-agent-skills.ts | 43 ++-- scripts/check-package-contract.ts | 17 +- scripts/lib/component-api.ts | 30 +++ scripts/test-version-package.ts | 190 ++++++++++++++++++ scripts/version-package.ts | 121 +++++++++++ 37 files changed, 533 insertions(+), 200 deletions(-) create mode 100644 .changeset/agent-reference-corrections.md create mode 100644 scripts/test-version-package.ts create mode 100644 scripts/version-package.ts diff --git a/.changeset/agent-reference-corrections.md b/.changeset/agent-reference-corrections.md new file mode 100644 index 0000000..117c525 --- /dev/null +++ b/.changeset/agent-reference-corrections.md @@ -0,0 +1,7 @@ +--- +"@inkcre/ui-web": patch +--- + +修正 Agent 组件选型和表单示例说明,按实际版本整理迁移要求;API 参考从签名补出组件本地类型结构,明确与包根导出类型的区别,并移除重复的组件误用汇总及消费者入口中的维护指令。 + +迁移指南增加统一的下一版本区,由现有版本准备命令自动归档,并在发布前检查待定内容已处理。 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7fe77d7..19a9a2e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -44,6 +44,18 @@ For interaction or visual behavior changes, also review the affected Story or re consuming page — build and coverage checks do not prove those behaviors correct. Check selection follows the [organization verification policy](https://github.com/InKCre/.github/blob/main/TESTING.md). +## 包版本与迁移说明 + +需要消费者调整调用或特别复核的变化写入 `packages/web/MIGRATION.md` 的 `## 下一版本` 区,并为 Web 包添加 Changeset。正文中的小节使用三级标题;CHANGELOG 记录版本变化,MIGRATION 只说明升级动作和兼容边界,不重复完整变更列表。 + +运行 `pnpm changeset:version` 推进版本。它先恢复未完成的迁移归档,再执行 Changesets,将待定正文归入新的正式版本,最后同步包元数据。`migration-base` 标记记录待定内容开始积累时的包版本,由命令维护,不手改;版本发生变化但没有迁移内容时也会更新标记。版本标题表示该版本包含这些变化,不表示 registry 已发布成功。 + +归档通过一次文件替换同时更新正文与基准,已有历史不改写。Changesets 成功后若归档或元数据生成失败,修复报错后重跑同一命令;先完成恢复,再添加下一批 Changeset。Changesets 自身失败时可能留下部分版本文件,需要先检查其输出与工作树,不将部分结果直接发布。目标版本已存在迁移历史时,命令报错并保留原文,交由维护者核对。 + +`pnpm check:release` 校验迁移结构并在临时工作区验证版本推进、失败恢复与重复执行;普通 PR 可以保留待定内容。`pnpm changeset:publish` 在发布前要求基准与包版本一致、待定区为空,不能用裸 `changeset publish` 绕过检查。当前归档入口只支持正式版本;引入预发布流程时需同步定义迁移归属和恢复规则。 + +组件用途、交互和示例变化的文档责任见[Agent 文档生成说明](scripts/build-agent-skills.md#内容责任)。作者核对受影响的选型与限制,审阅者通过相关 Story 或实际消费者动作确认;结构、类型和构建检查只承担各自能观察到的事实。 + ## Token pipeline `tokens/inkcre.tokens.json` is the Token specification source. Figma proposes value diff --git a/package.json b/package.json index 8d18e06..36930c7 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "check:generated": "tsx scripts/check-generated.ts", "check:stories": "tsx scripts/check-story-coverage.ts", "check:package": "tsx scripts/check-package-contract.ts", + "check:release": "tsx scripts/version-package.ts --check && tsx --test scripts/test-version-package.ts", "check:token-workflow": "tsx scripts/prepare-token-update.ts fixture", "tokens:update": "tsx scripts/prepare-token-update.ts apply", "type-check": "pnpm type-check:root && pnpm --filter @inkcre/ui-web type-check", @@ -23,13 +24,13 @@ "format": "oxfmt .oxfmtrc.json package.json pnpm-workspace.yaml tsconfig.json scripts .github/workflows/*.yml README.md DESIGN.md docs/design && pnpm --filter @inkcre/ui-web format", "format:check": "oxfmt --check .oxfmtrc.json package.json pnpm-workspace.yaml tsconfig.json scripts .github/workflows/*.yml README.md DESIGN.md docs/design && pnpm --filter @inkcre/ui-web format:check", "lint": "oxlint --deny-warnings scripts && pnpm --filter @inkcre/ui-web lint", - "check": "pnpm format:check && pnpm lint && pnpm check:generated && pnpm --filter @inkcre/ui-web skill:validate && pnpm check:stories && pnpm check:token-workflow && pnpm type-check:root && pnpm build && pnpm check:package && pnpm story", + "check": "pnpm format:check && pnpm lint && pnpm check:generated && pnpm --filter @inkcre/ui-web skill:validate && pnpm check:stories && pnpm check:token-workflow && pnpm check:release && pnpm type-check:root && pnpm build && pnpm check:package && pnpm story", "changeset": "changeset", "changeset:add": "changeset add", - "changeset:version": "changeset version && pnpm build-package-metadata", - "changeset:publish": "changeset publish", + "changeset:version": "tsx scripts/version-package.ts", + "changeset:publish": "tsx scripts/version-package.ts --check-publish && changeset publish", "changeset:status": "changeset status", - "release": "pnpm changeset:version && changeset publish" + "release": "pnpm changeset:version && pnpm changeset:publish" }, "devDependencies": { "@changesets/cli": "^2.29.8", diff --git a/packages/web/MIGRATION.md b/packages/web/MIGRATION.md index 1fe0fc7..cbf1e63 100644 --- a/packages/web/MIGRATION.md +++ b/packages/web/MIGRATION.md @@ -1,4 +1,12 @@ -# 未发布:InkImage 连续缩放与平移 +# 迁移指南 + +按升级前版本到目标版本之间的条目检查消费者改动。下面的版本号表示包含该变化的版本;当前安装方式与依赖以 [README](README.md) 和目标版本的 package.json 为准。 + +## 下一版本 + + + +## 2.3.0:InkImage 连续缩放与平移 InkImage 的 props、模型、事件和插槽保持不变。展开视图默认完整显示图片,新增围绕指针的滚轮缩放、拖动平移、触屏双指缩放和双击 / 双点快捷缩放。比例从适应窗口连续变化到 800%,100% 是快捷比例。操作区提供缩放、当前比例、适应窗口和原尺寸按钮;每次打开或更换 src 都恢复全图。 @@ -6,11 +14,11 @@ InkImage 的 props、模型、事件和插槽保持不变。展开视图默认 依赖内部展开容器样式的消费者应移除对图片尺寸、transform、滚动位置和标题底板的覆盖,再用长图、宽图、长说明及窄视口核对。原尺寸以上的缩放只放大已有像素,不请求更高分辨率资源。 -# 待发布:AutoForm 字段交互 +## 2.2.1:AutoForm 字段交互 普通 nullable 文本现在直接显示输入,不需要先点击“设置值”。未编辑的 null、未设置字段与空字符串仍各自保留;“清空值”显式置 null。Boolean 字段使用已有 sm 开关。公开模型与事件不变,重新构建即可采用;nullable object、array、Boolean、enum 与日期的状态选择沿用原语义。 -# 未发布:场景化加载、Dialog 动作与相对间距 +## 2.2.0:场景化加载、Dialog 动作与相对间距 InkLoading 默认仍为三个方块,用于内容区、图谱和预览等待。新增 `variant="spinner"` 与可见 `label`;没有可见标签时继续支持 aria-label。新增 InkSkeleton 单块骨架,用 class/style 定义具体宽高,整个区域由宿主提供一次加载说明。Loading、Skeleton 与 Button 等待图形响应 prefers-reduced-motion。 @@ -18,14 +26,12 @@ InkDialog 的 pending 继续锁住内部 InkButton、确认、取消、Escape 五个 ref.space 源值改为 rem:xs/sm/md/lg/xl 为 0.25/0.5/1/2/3.5rem。Token 路径、sys 引用与 Sass/Uno 用法不变,16px 根字号下等大,20px 时间距按比例放大;复核表单、按钮、Dropdown、Tabs、Dialog、Header 的换行。radius 和 ref.size 不变。Figma 的 dimension 提议须保留已有单位,单位变更改为显式仓库迁移。 -# 未发布:默认配色与阴影 +## 2.0.1:默认配色与阴影 浅深主题的主动作、普通表面与 Switch 采用中性灰配对;危险按钮底色保持灰红,需要注意的反馈文字使用较纯的语义色。覆盖层阴影缩小偏移与模糊范围。公开角色、组件 API 与调用方式保持不变,升级后重新构建即可获得默认值。 使用主题覆盖的消费者应一起复核前景、背景、hover/pressed 与选中状态,尤其是深色危险按钮的深色文字配对。普通状态不因成功或进行中而自动着色,使用范围见[页面组合](docs/design/composition.md)。Sass `apply-elevation` 读取运行时变量,Uno 阴影工具类使用构建值;修改根级阴影变量不会改变已经生成的 Uno 阴影,详见[样式指南](styles/README.md)。 -下面记录已随 2.0.0 发布的迁移要求;从 1.x 升级时同时完成。 - ## 2.0.0:Token 与样式契约 本次升级统一了文本角色、运行时读取与状态配色。包名、组件模型和事件沿用本文后续契约,但旧文本外观和部分 Token 路径不兼容。先升级依赖及锁文件,再迁移以下调用,最后以安装产物验证页面。不要把同名角色当成旧度量的兼容别名。 @@ -51,8 +57,6 @@ InkDialog 的 pending 继续锁住内部 InkButton、确认、取消、Escape Button pending 的覆盖层改为相邻 spinner;依赖 `ink-button__loading-overlay` 的样式需要移除。Button、带框输入和 Switch 的固定高度改为可增长的最小高度,Switch xs 从 18px 增至至少 24px,两个状态文案共同决定宽度。Dropdown 选中说明、DoubleCheck 普通标题、Image 标题底板和遮罩透明度已改正,Dialog 同样由 Popup 承担内边距,默认宽度上限 640px,窄视口两侧各留 16px;清理相应下游补丁后再复核。 -已知 impl-ts 调用包括:settings 的 `apply-font('title', 'lg')`;LogsViewer/RecallSearch 的 body-md 和错误背景;JobCard/任务详情/peerCard 的反馈颜色;侧栏、来源内容和设置通知中的 muted;info-base/list 的页面标题与空间。逐处按用途迁移,不能全局机械替换。extension registry 的实际消费位置尚未确认,须在消费者验收中补齐。 - Figma 导入也改变:仅更新已知路径的值,显式提供 releaseType,旧的全量导出包含已删除角色时会失败。维护者应更新发送端或准备只含已知值的提议;具体接收端格式见仓库 Token 生成说明。 验证浅深/系统主题、320px 窄容器、长中英文、200% 文字和浏览器缩放,检查焦点、错误、disabled、pending、selected,以及表单真实保存。生产者验证不代表消费者已升级;回退需同时恢复升级前依赖、锁文件和调用适配。 @@ -63,8 +67,8 @@ Figma 导入也改变:仅更新已知路径的值,显式提供 releaseType 本节对应 2.0.0 的基础控件、弹层和 schema 编辑契约调整。升级时完成以下迁移并验证真实保存流程。 -- InkButton 默认原生类型改为 button。表单提交写 `nativeType="submit"`;type 仍控制 default/square 外形。impl-ts 的 info-base/list 和 RecallSearch 搜索按钮依赖旧默认提交行为,需要明确标记。 -- InkJsonEditor 的模型现在包含原始文本和无效 JSON。将直接 JSON.parse 的 computed setter 改为独立字符串草稿,监听 validation;仅在 valid=true 且结果 text 与草稿一致时解析和持久化。impl-ts 的 peerCard 配置编辑属于这种调用,必须迁移,否则输入中间态会让 setter 抛错。 +- InkButton 默认原生类型改为 button。表单提交写 `nativeType="submit"`;type 仍控制 default/square 外形。检查原先依赖默认提交行为的搜索和保存按钮。 +- InkJsonEditor 的模型现在包含原始文本和无效 JSON。将直接 JSON.parse 的 computed setter 改为独立字符串草稿,监听 validation;仅在 valid=true 且结果 text 与草稿一致时解析和持久化,否则输入中间态会让 setter 抛错。 - InkPicker 的内置日期选择只在 Confirm 更新 Date,取消不再提交。初始化可用 null;JSON 日期字符串应由消费者转换,InkAutoForm 已提供其内部字符串边界。 - Popup/Scrim 使用原生 dialog。提供 aria-label 或 aria-labelledby;不要依赖旧遮罩 DOM 选择器。scrim=false 保留非模态行为,默认模式由浏览器提供背景隔离、嵌套与焦点管理。 - useOptionalVModel 与内部 optional model 统一:传入非 undefined 的模型由父级控制,父级拒绝更新时显示不会擅自改变。传常量 false 不等于省略模型。 @@ -96,47 +100,29 @@ function save() { --- -## 从 `@inkcre/web-design` 迁移 +## 2.0.0:依赖与文档交付 -本页说明旧包身份迁移到 `@inkcre/ui-web` 的操作。`@inkcre/ui-web` 延续旧包的 `1.2.x` 版本线,身份迁移保留了 Vue 组件与类型(`Ink*`)、CSS 类(`.ink-*`)、Sass API 和设计变量。后续版本的变化应同时阅读 [CHANGELOG](https://github.com/InKCre/ui/blob/main/packages/web/CHANGELOG.md),不能将身份迁移的兼容承诺推广到所有版本升级。 +CodeMirror、JSON 语言服务、VueUse 和 dayjs 从消费者提供的 peer 改为包内运行时依赖。包括 `vscode-languageserver-textdocument` 在内,仅为旧 UI peer 安装且没有其他调用的声明可以移除;消费者自身代码仍使用这些库时保留直接依赖。vue-router 不再是 UI 的 peer,适配器继续接受公开 InkRouter 接口。Vue 由宿主提供,UnoCSS 是使用 `/uno` 时才需要的可选 peer。 -## 消费者操作 - -1. 选择已发布的目标版本,将依赖改为精确版本的 `@inkcre/ui-web`。 -2. 替换旧包导入,包括 `/styles`、`/styles/functions`、`/styles/mixins`、`/tokens/*`、`/utils`、`/locales` 和 `/uno` 等公开子路径。 -3. 移除曾用于绕过旧 exports 问题的 node_modules 或 dist 文件系统别名。 -4. 更新消费者锁文件,然后用冻结安装、类型检查、构建和受影响页面验证该精确产物。开发源码联调不能替代此步骤。 +Vue 最低支持版本提高到 3.5.25,以匹配该版本生成的组件声明。useId 可用不能单独证明声明兼容整个 3.5 系列,升级前同时校准 Vue。 -## 依赖边界 +源码联调若把所有旧 peer 都映射到消费者 node_modules,应改为只共享真实 peer,让 JSON 服务等内部依赖从 UI 包解析。当前依赖范围和集成方式见 [README](README.md)。 -新包将声明的 peer 外置。消费者的安装图必须能解析目标版本声明的依赖;其中 `vscode-languageserver-textdocument` 是 InkJsonEditor 的显式 peer。以目标版本 `package.json` 和消费者锁文件为准,不靠本机已有的开发依赖补齐缺失项。 +设计规则和组件参考随包交付,直接读取 Markdown 或通过 Intent 加载即可。当前接入方式见 [Agent Skill](README.md#agent-skill)。 -## 随包 Skill +## 1.2.x:从 `@inkcre/web-design` 迁移 -当前 Skill 位于 `skills/ui-web`,旧 `agent-skills/` 不再提供。消费者在自己的 package.json 中显式信任包: +本节说明旧包身份迁移到 `@inkcre/ui-web` 的操作。`@inkcre/ui-web` 延续旧包的 `1.2.x` 版本线,身份迁移保留了 Vue 组件与类型(`Ink*`)、CSS 类(`.ink-*`)、Sass API 和设计变量。后续版本的变化应同时阅读 [CHANGELOG](https://github.com/InKCre/ui/blob/main/packages/web/CHANGELOG.md),不能将身份迁移的兼容承诺推广到所有版本升级。 -```json -{ - "intent": { - "skills": ["@inkcre/ui-web"] - } -} -``` +### 消费者操作 -已安装 TanStack Intent 的消费者可运行 `pnpm exec intent load @inkcre/ui-web#ui-web`。也可以直接阅读[随包 Skill](skills/ui-web/SKILL.md);它是文档入口,不是运行时 JavaScript 导出。 +1. 选择已发布的目标版本,将依赖改为精确版本的 `@inkcre/ui-web`。 +2. 替换旧包导入,包括 `/styles`、`/styles/functions`、`/styles/mixins`、`/tokens/*`、`/utils`、`/locales` 和 `/uno` 等公开子路径。 +3. 移除曾用于绕过旧 exports 问题的 node_modules 或 dist 文件系统别名。 +4. 更新消费者锁文件,然后用冻结安装、类型检查、构建和受影响页面验证该精确产物。开发源码联调不能替代此步骤。 -## 回退 +### 回退 回退时恢复消费者升级前的依赖、锁文件、导入和相关适配,再验证完整消费流程。历史身份迁移使用 `@inkcre/web-design@1.2.2` 作为回退版本;当前应用若已采用较新的组件能力,应使用自身升级前的版本,而不是直接回退到历史迁移提交。 旧包的可安装性、权限和废弃状态应在需要回退时查询 registry,本页不承诺其当前远端状态。包注册表认证入口见[安装说明](README.md#安装)。 - -## L3 文档与依赖交付 - -设计规则从随包 DESIGN.md 读取;Agent Skill 继续位于 `skills/ui-web`。模型、类型、默认值、事件载荷和插槽参数现在由源码生成,完整配方来自可检查的 Story 源文件。消费者显式配置可信包或直接读取 Markdown。 - -Vue 继续由宿主提供,UnoCSS 仍为使用 `/uno` 时才需要的可选 peer。CodeMirror、JSON 语言服务、VueUse 和 dayjs 改由 UI 包声明运行时依赖;消费者自身代码仍使用这些库时保留直接依赖,仅为旧 UI peer 安装且没有其他调用的声明可以移除。vue-router 不再是 UI 的 peer,适配器继续接受公开 InkRouter 接口。公开子路径和组件交互不因这次依赖责任调整而改变。 - -独立安装且关闭 skipLibCheck 的检查发现,Vue 3.5.0 无法读取由 Vue 3.5.25 生成的组件声明。当前最低支持版本因此校准为 3.5.25,消费者升级前同时更新 Vue。useId 可用只能说明运行时下限,不能证明生成声明兼容整个 3.5 系列。 - -源码联调原先若把所有旧 peer 都映射到消费者 node_modules,需要改为仅共享 Vue 等真实 peer,让 JSON 服务等内部依赖从 UI 包解析。当前 JSON 语言服务固定 5.6.4;5.7.2 已观察到诊断消息类型与 schema 错误码变化,不能直接替换。Uno preset 直接返回标准 preset 对象,构建时通过 satisfies Preset 校验,发布其实际返回类型;不再把聚合入口的 CLI/配置加载器类型作为公开声明的必要依赖。 diff --git a/packages/web/skill.seed.json b/packages/web/skill.seed.json index 6e2fa7c..74f4df7 100644 --- a/packages/web/skill.seed.json +++ b/packages/web/skill.seed.json @@ -28,8 +28,7 @@ "avoid": [ "Do not invent props or events from conventions used by another UI library.", "Do not treat low-level InkPopup or InkScrim as a replacement for InkDialog when the standard dialog workflow fits.", - "Do not expose repository paths, generated implementation files, or internal prop helpers to consumers.", - "Do not edit this generated skill tree directly; update skill.seed.json or public component facts and regenerate it." + "Do not depend on repository paths, generated implementation files, or internal prop helpers." ] }, "components": { @@ -107,7 +106,7 @@ ], "avoidWhen": [ "Only a low-level positioned surface is needed; use InkPopup.", - "A compact confirmation popup attached to one trigger is enough; use InkDoubleCheck." + "A simple action needs a centered confirmation with title, message, and two choices; use InkDoubleCheck." ], "composeWith": ["InkButton", "InkForm", "InkLoading", "InkPopup"], "apiCaveats": [ @@ -444,7 +443,8 @@ ], "commonMistakes": [ "Do not keep a second local selection state when the route already owns it." - ] + ], + "publicTypes": ["InkTab", "InkTabsExpose"] }, "InkTextarea": { "intent": ["multiline text input", "description field", "long-form form value"], @@ -507,7 +507,7 @@ "caveats": [ "Do not normalize every control to the same model prop name; use each component's actual API.", "Do not wrap controls in duplicate InkField labels when they already consume InkForm context.", - "示例的文本和颜色工具类需要 presetInk;应用入口加载样式。未使用 Uno 时可用同名 Sass 角色和系统变量。" + "示例使用普通 CSS 和系统变量;应用入口加载 @inkcre/ui-web/styles 即可,无需 UnoCSS。" ], "exampleFile": "SettingsForm.vue" }, diff --git a/packages/web/skills/ui-web/SKILL.md b/packages/web/skills/ui-web/SKILL.md index 6bbc5fa..bf6faae 100644 --- a/packages/web/skills/ui-web/SKILL.md +++ b/packages/web/skills/ui-web/SKILL.md @@ -70,12 +70,11 @@ app.use(InKCreUiWeb); - `references/composition-recipes.md`: reviewed multi-component workflows. - `references/integration.md`: installation, router, and i18n boundaries. - `references/styling-and-themes.md`: CSS, Sass, tokens, and themes. -- `references/common-mistakes.md`: package-specific failure modes. +- `references/common-mistakes.md`: cross-component mistakes; component-specific cautions stay in each component reference. - `references/components/Ink*.md`: generated public API facts plus reviewed guidance. ## Avoid - Do not invent props or events from conventions used by another UI library. - Do not treat low-level InkPopup or InkScrim as a replacement for InkDialog when the standard dialog workflow fits. -- Do not expose repository paths, generated implementation files, or internal prop helpers to consumers. -- Do not edit this generated skill tree directly; update skill.seed.json or public component facts and regenerate it. +- Do not depend on repository paths, generated implementation files, or internal prop helpers. diff --git a/packages/web/skills/ui-web/references/common-mistakes.md b/packages/web/skills/ui-web/references/common-mistakes.md index 84f0365..7b4bd6a 100644 --- a/packages/web/skills/ui-web/references/common-mistakes.md +++ b/packages/web/skills/ui-web/references/common-mistakes.md @@ -11,102 +11,4 @@ - 仅因数值相同就选择某个 Token,或为补齐规则自行创造不存在的 Token;应按用途选择共享角色,页面局部布局可以使用普通 CSS。 - Loading every component reference when progressive disclosure only requires a few. -## InkAutoForm - -- Do not assume complete JSON Schema coverage. -- Do not use it merely to avoid designing a workflow-specific form. - -## InkButton - -- Do not replace a destructive confirmation flow with a danger-colored button alone. - -## InkDatetimePickerView - -- Do not duplicate popup, formatting, and field responsibilities already owned by InkPicker. - -## InkDialog - -- Do not nest a second independently controlled scrim beneath the dialog. -- Do not invent open/update:open semantics without checking the emitted events. - -## InkDoubleCheck - -- 业务动作绑定 confirm,不绑定触发按钮的 click。 - -## InkDropdown - -- Do not assume an empty model triggers lazy loading. -- Do not mix static options and refresher behavior without defining precedence. - -## InkField - -- Do not create nested duplicate labels around controls that already consume form context. - -## InkForm - -- Do not infer full validation orchestration from the form wrapper. -- Do not bypass the shared layout with unrelated local field markup. - -## InkHeader - -- Do not use the application header as a generic card or section title. - -## InkImage - -- Do not enable expansion when the source cannot provide a useful larger view. - -## InkInput - -- Do not use the inline visual mode as a substitute for explicit edit permissions. - -## InkJsonEditor - -- Do not silently coerce invalid JSON into a different value. -- Do not use it for ordinary multiline text. - -## InkLoading - -- Do not leave a loading indicator active after the operation reaches an empty or error state. - -## InkPagination - -- Do not render inaccessible or clickable pages outside the valid range. - -## InkPicker - -- Do not assume every picker value is a Date. -- Do not duplicate the popup state outside the component without a controlled-state reason. - -## InkPlaceholder - -- Do not use the same generic copy for empty, filtered-empty, permission, and error states. - -## InkPopup - -- Do not stack multiple scrims for one overlay. -- Do not omit focus and keyboard behavior when building a dialog-like custom popup. - -## InkScrim - -- Do not render an orphan scrim without an overlay lifecycle. -- Do not rely on visual dimming alone for modal accessibility. - -## InkSkeleton - -- 不要画假的可点击操作,不要在错误或空态保留骨架。 - -## InkSwitch - -- Do not optimistically show a successful state when the async change can still fail. - -## InkTabs - -- Do not keep a second local selection state when the route already owns it. - -## InkTextarea - -- Do not assume v-model without checking the argument used by the value contract. - -## InkTooltip - -- Do not hide validation errors, destructive consequences, or required instructions in a tooltip. +组件专属提醒见 [组件索引](component-map.md) 指向的对应参考;按任务读取即可。 diff --git a/packages/web/skills/ui-web/references/components/InkAutoForm.md b/packages/web/skills/ui-web/references/components/InkAutoForm.md index 8971e99..7c80c21 100644 --- a/packages/web/skills/ui-web/references/components/InkAutoForm.md +++ b/packages/web/skills/ui-web/references/components/InkAutoForm.md @@ -52,10 +52,12 @@ - None. -- Public types: `JSONSchema`, `JSONSchemaProperty`, `FormValidation` +- Types exported from the package root: `JSONSchema`, `JSONSchemaProperty`, `FormValidation` - Story variants: `Text Fields with Validation`, `Textarea (Long Text)`, `Boolean Switches`, `Dropdown (Enum Values)`, `Date and Time Pickers`, `Default Values from Schema`, `Validation Errors`, `Invalid Schema Handling`, `Complex Form (Mixed Field Types)`, `Inline Layout`, `Row Layout`, `Existing values, numeric and date boundaries`, `Nested credentials, arrays and nullable values` -### Public type definitions +### API type definitions + +以下源码定义解释参数和事件载荷;可从包根导入的类型仅限上面列出的名称。 ```ts export interface JSONSchema { diff --git a/packages/web/skills/ui-web/references/components/InkButton.md b/packages/web/skills/ui-web/references/components/InkButton.md index bf60546..ccc7ed8 100644 --- a/packages/web/skills/ui-web/references/components/InkButton.md +++ b/packages/web/skills/ui-web/references/components/InkButton.md @@ -56,7 +56,7 @@ - `default`: `{}` - `suffix-icon`: `{}` -- Public types: None +- Types exported from the package root: None - Story variants: `Subtle`, `Primary`, `Danger`, `Medium (Default)`, `Small`, `Loading State - Subtle`, `Loading State - Primary`, `Loading State - Danger`, `Very Long Text`, `Short Text`, `Icon Prefix`, `Icon Suffix`, `Icon Only (Square)`, `Explicit form submission` diff --git a/packages/web/skills/ui-web/references/components/InkDatetimePickerView.md b/packages/web/skills/ui-web/references/components/InkDatetimePickerView.md index 5414187..49176b9 100644 --- a/packages/web/skills/ui-web/references/components/InkDatetimePickerView.md +++ b/packages/web/skills/ui-web/references/components/InkDatetimePickerView.md @@ -51,7 +51,7 @@ - None. -- Public types: None +- Types exported from the package root: None - Story variants: `Basic` diff --git a/packages/web/skills/ui-web/references/components/InkDialog.md b/packages/web/skills/ui-web/references/components/InkDialog.md index e6c3b17..67a8a68 100644 --- a/packages/web/skills/ui-web/references/components/InkDialog.md +++ b/packages/web/skills/ui-web/references/components/InkDialog.md @@ -16,7 +16,7 @@ ## Avoid When - Only a low-level positioned surface is needed; use InkPopup. -- A compact confirmation popup attached to one trigger is enough; use InkDoubleCheck. +- A simple action needs a centered confirmation with title, message, and two choices; use InkDoubleCheck. ## Compose With @@ -60,9 +60,22 @@ - `default`: `{ cancel: () => void; confirm: () => void; isLoading: boolean; }` - `footer`: `{ cancel: () => void; confirm: () => void; isLoading: boolean; }` -- Public types: None +- Types exported from the package root: None - Story variants: `Basic`, `Custom footer failure and retry`, `Async`, `Without Cancel` +### API type definitions + +以下源码定义解释参数和事件载荷;可从包根导入的类型仅限上面列出的名称。 + +```ts +export type DialogPosition = + | "center" + | "left" + | "right" + | "bottom" + | "top" + | [number, number, number, number]; +``` ## API Caveats diff --git a/packages/web/skills/ui-web/references/components/InkDoubleCheck.md b/packages/web/skills/ui-web/references/components/InkDoubleCheck.md index 52842a8..3ebd031 100644 --- a/packages/web/skills/ui-web/references/components/InkDoubleCheck.md +++ b/packages/web/skills/ui-web/references/components/InkDoubleCheck.md @@ -47,7 +47,7 @@ - `default`: `{}` -- Public types: None +- Types exported from the package root: None - Story variants: `Delete Confirmation` diff --git a/packages/web/skills/ui-web/references/components/InkDropdown.md b/packages/web/skills/ui-web/references/components/InkDropdown.md index bd462db..5eed825 100644 --- a/packages/web/skills/ui-web/references/components/InkDropdown.md +++ b/packages/web/skills/ui-web/references/components/InkDropdown.md @@ -64,10 +64,12 @@ - None. -- Public types: `DropdownOption` +- Types exported from the package root: `DropdownOption` - Story variants: `Basic`, `With Refresh`, `Async Options`, `With Descriptions`, `Preselected Async Value`, `With Stepping`, `Stepping & Refresh`, `Keyboard Navigation` -### Public type definitions +### API type definitions + +以下源码定义解释参数和事件载荷;可从包根导入的类型仅限上面列出的名称。 ```ts export interface DropdownOption { diff --git a/packages/web/skills/ui-web/references/components/InkField.md b/packages/web/skills/ui-web/references/components/InkField.md index d747dc4..80b1f91 100644 --- a/packages/web/skills/ui-web/references/components/InkField.md +++ b/packages/web/skills/ui-web/references/components/InkField.md @@ -54,7 +54,7 @@ - `label-right`: `{}` - `default`: `{}` -- Public types: None +- Types exported from the package root: None - Story variants: `Column`, `Inline`, `Row`, `Optional`, `Required`, `Very Long Label`, `Very Long Value`, `Empty Value` diff --git a/packages/web/skills/ui-web/references/components/InkForm.md b/packages/web/skills/ui-web/references/components/InkForm.md index 6e46d54..edcbd47 100644 --- a/packages/web/skills/ui-web/references/components/InkForm.md +++ b/packages/web/skills/ui-web/references/components/InkForm.md @@ -46,7 +46,7 @@ - `default`: `{}` -- Public types: None +- Types exported from the package root: None - Story variants: `完整设置表单与保存失败`, `宿主路由语言和主题适配`, `JSON 草稿与验证后保存`, `Column Layout`, `Inline Layout`, `Reactive layout`, `长标签、错误与窄容器` diff --git a/packages/web/skills/ui-web/references/components/InkHeader.md b/packages/web/skills/ui-web/references/components/InkHeader.md index 31e8c77..c1ac938 100644 --- a/packages/web/skills/ui-web/references/components/InkHeader.md +++ b/packages/web/skills/ui-web/references/components/InkHeader.md @@ -49,7 +49,7 @@ - `right-icon`: `{}` -- Public types: None +- Types exported from the package root: None - Story variants: `Basic`, `With Logo`, `Without Logo`, `Auto Page Title` diff --git a/packages/web/skills/ui-web/references/components/InkImage.md b/packages/web/skills/ui-web/references/components/InkImage.md index 8cdba4b..b801556 100644 --- a/packages/web/skills/ui-web/references/components/InkImage.md +++ b/packages/web/skills/ui-web/references/components/InkImage.md @@ -55,9 +55,19 @@ - `expanded-header`: `{}` - `expanded-footer`: `{}` -- Public types: None +- Types exported from the package root: None - Story variants: `Basic Usage`, `With Title`, `Custom Size (Style + Class)`, `Custom Thumbnail Slot`, `Eager Loading (lazy: false)`, `With Expanded Footer`, `With Custom Header`, `Large Image Detail`, `Tall Image With Long Caption`, `Controlled Preview And Source Change`, `Unavailable Image` +### API type definitions + +以下源码定义解释参数和事件载荷;可从包根导入的类型仅限上面列出的名称。 + +```ts +export interface InkImageErrorPayload { + error: Event; + src: string; +} +``` ## API Caveats diff --git a/packages/web/skills/ui-web/references/components/InkInput.md b/packages/web/skills/ui-web/references/components/InkInput.md index bca762a..2a2998b 100644 --- a/packages/web/skills/ui-web/references/components/InkInput.md +++ b/packages/web/skills/ui-web/references/components/InkInput.md @@ -61,7 +61,7 @@ - `default`: `{}` -- Public types: None +- Types exported from the package root: None - Story variants: `Column Layout`, `Inline Layout`, `Optional`, `Required`, `Inline Editable`, `Inline confirmation and cancellation`, `Password (Default)`, `Password with Toggle` diff --git a/packages/web/skills/ui-web/references/components/InkJsonEditor.md b/packages/web/skills/ui-web/references/components/InkJsonEditor.md index c118538..d15f0ac 100644 --- a/packages/web/skills/ui-web/references/components/InkJsonEditor.md +++ b/packages/web/skills/ui-web/references/components/InkJsonEditor.md @@ -61,10 +61,12 @@ - None. -- Public types: `JsonEditorValidation` +- Types exported from the package root: `JsonEditorValidation` - Story variants: `Basic`, `JSON Schema`, `In popup`, `Validated save and isolated editors` -### Public type definitions +### API type definitions + +以下源码定义解释参数和事件载荷;可从包根导入的类型仅限上面列出的名称。 ```ts export interface JsonEditorValidation { diff --git a/packages/web/skills/ui-web/references/components/InkLoading.md b/packages/web/skills/ui-web/references/components/InkLoading.md index a04313b..fba21e4 100644 --- a/packages/web/skills/ui-web/references/components/InkLoading.md +++ b/packages/web/skills/ui-web/references/components/InkLoading.md @@ -49,7 +49,7 @@ - None. -- Public types: None +- Types exported from the package root: None - Story variants: `Content waiting`, `Inline spinner`, `Sizes and density` diff --git a/packages/web/skills/ui-web/references/components/InkPagination.md b/packages/web/skills/ui-web/references/components/InkPagination.md index 1bdbcb5..0faf6e2 100644 --- a/packages/web/skills/ui-web/references/components/InkPagination.md +++ b/packages/web/skills/ui-web/references/components/InkPagination.md @@ -48,7 +48,7 @@ - None. -- Public types: None +- Types exported from the package root: None - Story variants: `Few Pages (1-5)`, `Many Pages (1-20)`, `First Page`, `Last Page`, `Single Page Only`, `Text Type - Few Pages`, `Text Type - Many Pages` diff --git a/packages/web/skills/ui-web/references/components/InkPicker.md b/packages/web/skills/ui-web/references/components/InkPicker.md index 65fe7f3..4da2326 100644 --- a/packages/web/skills/ui-web/references/components/InkPicker.md +++ b/packages/web/skills/ui-web/references/components/InkPicker.md @@ -64,7 +64,7 @@ - `default`: `{ closePopup: () => void; modelValue: ([{ readonly type: PropType; }] extends [Prop] ? unknown extends V ? keyof V extends never ? IfAny : V : V : { readonly type: PropType; }) | undefined; }` -- Public types: None +- Types exported from the package root: None - Story variants: `Date Picker`, `Required Field` diff --git a/packages/web/skills/ui-web/references/components/InkPlaceholder.md b/packages/web/skills/ui-web/references/components/InkPlaceholder.md index bcc3892..17ca734 100644 --- a/packages/web/skills/ui-web/references/components/InkPlaceholder.md +++ b/packages/web/skills/ui-web/references/components/InkPlaceholder.md @@ -52,7 +52,7 @@ - `description`: `{}` - `actions`: `{}` -- Public types: None +- Types exported from the package root: None - Story variants: `Empty State - Default`, `Empty State - Custom Text`, `Empty State - Custom Illustration`, `Error State - Default`, `Error State - Custom Text`, `Empty State - With Actions`, `Error State - With Retry Action`, `Custom Illustration Slot`, `Custom Title Slot`, `Fully Custom Content`, `Long Description` diff --git a/packages/web/skills/ui-web/references/components/InkPopup.md b/packages/web/skills/ui-web/references/components/InkPopup.md index 29ced2d..bc724b6 100644 --- a/packages/web/skills/ui-web/references/components/InkPopup.md +++ b/packages/web/skills/ui-web/references/components/InkPopup.md @@ -50,9 +50,22 @@ - `default`: `{}` -- Public types: None +- Types exported from the package root: None - Story variants: `Default Popup`, `Modeless Popup` +### API type definitions + +以下源码定义解释参数和事件载荷;可从包根导入的类型仅限上面列出的名称。 + +```ts +export type PopupPosition = + | "center" + | "left" + | "right" + | "bottom" + | "top" + | [number, number, number, number]; +``` ## API Caveats diff --git a/packages/web/skills/ui-web/references/components/InkScrim.md b/packages/web/skills/ui-web/references/components/InkScrim.md index 895bbe3..d1cb94a 100644 --- a/packages/web/skills/ui-web/references/components/InkScrim.md +++ b/packages/web/skills/ui-web/references/components/InkScrim.md @@ -49,7 +49,7 @@ - `default`: `{ close: () => void; }` -- Public types: None +- Types exported from the package root: None - Story variants: `Open Scrim`, `Closed Scrim`, `Dismissible (closeOnScrim: true)`, `Non-Dismissible (closeOnScrim: false)` diff --git a/packages/web/skills/ui-web/references/components/InkSkeleton.md b/packages/web/skills/ui-web/references/components/InkSkeleton.md index dbf42fe..c641d90 100644 --- a/packages/web/skills/ui-web/references/components/InkSkeleton.md +++ b/packages/web/skills/ui-web/references/components/InkSkeleton.md @@ -44,7 +44,7 @@ - None. -- Public types: None +- Types exported from the package root: None - Story variants: `Known list structure` diff --git a/packages/web/skills/ui-web/references/components/InkSwitch.md b/packages/web/skills/ui-web/references/components/InkSwitch.md index 48e2afc..3cd2ca5 100644 --- a/packages/web/skills/ui-web/references/components/InkSwitch.md +++ b/packages/web/skills/ui-web/references/components/InkSwitch.md @@ -53,7 +53,7 @@ - None. -- Public types: None +- Types exported from the package root: None - Story variants: `Extra Small`, `Small`, `Medium`, `Large`, `Off`, `On`, `长状态文案保持轨道尺寸` diff --git a/packages/web/skills/ui-web/references/components/InkTabs.md b/packages/web/skills/ui-web/references/components/InkTabs.md index 08e17d1..cf9e055 100644 --- a/packages/web/skills/ui-web/references/components/InkTabs.md +++ b/packages/web/skills/ui-web/references/components/InkTabs.md @@ -48,9 +48,26 @@ - None. -- Public types: None +- Types exported from the package root: `InkTab`, `InkTabsExpose` - Story variants: `Controlled tabs` +### API type definitions + +以下源码定义解释参数和事件载荷;可从包根导入的类型仅限上面列出的名称。 + +```ts +export interface InkTab { + value: string; + label: string; + /** Route target understood by the consumer-provided link component. */ + to?: unknown; +} + +export interface InkTabsExpose { + getTabId: (value: string) => string; + getPanelId: (value: string) => string; +} +``` ## API Caveats diff --git a/packages/web/skills/ui-web/references/components/InkTextarea.md b/packages/web/skills/ui-web/references/components/InkTextarea.md index e83dfac..2f05f82 100644 --- a/packages/web/skills/ui-web/references/components/InkTextarea.md +++ b/packages/web/skills/ui-web/references/components/InkTextarea.md @@ -58,7 +58,7 @@ - None. -- Public types: None +- Types exported from the package root: None - Story variants: `Default`, `Optional`, `Required`, `Customize Rows`, `代码显式使用等宽字体` diff --git a/packages/web/skills/ui-web/references/components/InkTooltip.md b/packages/web/skills/ui-web/references/components/InkTooltip.md index 8c585df..3e26936 100644 --- a/packages/web/skills/ui-web/references/components/InkTooltip.md +++ b/packages/web/skills/ui-web/references/components/InkTooltip.md @@ -47,7 +47,7 @@ - `default`: `{ describedby: string | undefined; }` -- Public types: None +- Types exported from the package root: None - Story variants: `Top`, `Bottom`, `Left`, `Right`, `Long Text` diff --git a/packages/web/skills/ui-web/references/composition-recipes.md b/packages/web/skills/ui-web/references/composition-recipes.md index 67661d7..2f84165 100644 --- a/packages/web/skills/ui-web/references/composition-recipes.md +++ b/packages/web/skills/ui-web/references/composition-recipes.md @@ -92,7 +92,7 @@ async function submit() { - Do not normalize every control to the same model prop name; use each component's actual API. - Do not wrap controls in duplicate InkField labels when they already consume InkForm context. -- 示例的文本和颜色工具类需要 presetInk;应用入口加载样式。未使用 Uno 时可用同名 Sass 角色和系统变量。 +- 示例使用普通 CSS 和系统变量;应用入口加载 @inkcre/ui-web/styles 即可,无需 UnoCSS。 ## Schema Configuration diff --git a/scripts/build-agent-skills.md b/scripts/build-agent-skills.md index 7fd6814..c4b76a8 100644 --- a/scripts/build-agent-skills.md +++ b/scripts/build-agent-skills.md @@ -10,8 +10,14 @@ API 通过 Vue 官方 `vue-component-meta` 读取 props、models 对应的更新 模型由实际 prop 与同名 update 事件配对识别。props 默认列是声明值/表达式,不能把 undefined 当成组件内部没有显示回退。泛型组件可能保留 Vue 推导的条件类型;模型载荷与组件说明一起解释其使用边界。工具发现结构不代表行为已经得到验证,不能从元数据推断确认取消等语义。 +生成器沿公开签名使用的标识符补出同一组件目录中的类型定义及其本地引用,不遍历第三方类型图。`publicTypes` 只列包根可导入的名称,不能为补文档把内部类型误标为公开导出。包契约检查从安装参考提取代表性的 prop/event 类型定义,交给 TypeScript 与实际组件签名比对。 + +组件专属误用提醒只进入对应组件参考;全局 common-mistakes 保留跨组件事项。维护生成器和 seed 的操作留在本页,消费者 Skill 只提供选型、使用和验证所需的信息。 + 完整配方存放在 `packages/web/stories/recipes/*.vue`,由普通 Story 引用,seed 只保存 `exampleFile`。同一源文件被嵌入随包 Markdown;包契约检查从安装后的 Markdown 提取这些代码块,核对与源文件一致,再以公开入口通过类型检查和构建。摘要步骤可以解释设计意图,不再维护另一份代码字符串。 +修改组件用途、交互或配方时,同时核对该组件的选型与 caveat,以及其他组件指向它的选型描述。用受影响 Story 或真实消费者动作核对这些说明;生成物一致、示例能编译,不证明选型与依赖要求正确。依赖、默认值和类型等可恢复事实优先引用相应权威,不在人工摘要里再维护一套。 + ## 命令与交付 ```bash diff --git a/scripts/build-agent-skills.ts b/scripts/build-agent-skills.ts index dc78228..346418b 100644 --- a/scripts/build-agent-skills.ts +++ b/scripts/build-agent-skills.ts @@ -9,7 +9,12 @@ import { } from "node:fs"; import { dirname, relative, resolve } from "node:path"; import { createChecker, type ComponentMeta } from "vue-component-meta"; -import { propDefault, propType, typeDeclarations } from "./lib/component-api.js"; +import { + propDefault, + propType, + typeDeclarations, + referencedTypeDeclarations, +} from "./lib/component-api.js"; import { repositoryRoot, readComponentManifest, @@ -191,15 +196,24 @@ function buildModel(): SkillModel { ]), ); + for (const name of componentSeed.publicTypes ?? []) { + if (!definitions.has(name)) + throw new Error(`Missing public type ${component.name}.${name}`); + } + return { ...component, ...componentSeed, api, - typeDefinitions: (componentSeed.publicTypes ?? []).map((name) => { - const definition = definitions.get(name); - if (!definition) throw new Error(`Missing public type ${component.name}.${name}`); - return definition; - }), + typeDefinitions: referencedTypeDeclarations( + [ + ...(componentSeed.publicTypes ?? []), + ...api.props.filter((prop) => !prop.global).map(propType), + ...api.events.map((event) => event.type), + ...api.slots.map((slot) => slot.type), + ], + definitions, + ), storyVariants: extractStoryVariants(storySource), publicTypes: componentSeed.publicTypes ?? [], apiCaveats: componentSeed.apiCaveats ?? [], @@ -294,7 +308,7 @@ ${bullets(model.skill.rules)} - \`references/composition-recipes.md\`: reviewed multi-component workflows. - \`references/integration.md\`: installation, router, and i18n boundaries. - \`references/styling-and-themes.md\`: CSS, Sass, tokens, and themes. -- \`references/common-mistakes.md\`: package-specific failure modes. +- \`references/common-mistakes.md\`: cross-component mistakes; component-specific cautions stay in each component reference. - \`references/components/Ink*.md\`: generated public API facts plus reviewed guidance. ## Avoid @@ -420,22 +434,13 @@ ${bullets(model.styling.tokenLayers)} } function renderCommonMistakes(model: SkillModel): string { - const componentMistakes = model.components - .filter((component) => component.commonMistakes.length > 0) - .map( - (component) => `## ${component.name} - -${bullets(component.commonMistakes)}`, - ) - .join("\n\n"); - return `${GENERATED_HEADER} # Common Mistakes ${bullets(model.commonMistakes)} -${componentMistakes} +组件专属提醒见 [组件索引](component-map.md) 指向的对应参考;按任务读取即可。 `; } @@ -495,10 +500,10 @@ ${inlineCode(component.composeWith)} - Import: \`import { ${component.name} } from "${packageName}";\` ${renderApi(component.api)} -- Public types: ${inlineCode(component.publicTypes)} +- Types exported from the package root: ${inlineCode(component.publicTypes)} - Story variants: ${inlineCode(component.storyVariants)} -${component.typeDefinitions.length ? "### Public type definitions\n\n```ts\n" + component.typeDefinitions.join("\n\n") + "\n```\n" : ""} +${component.typeDefinitions.length ? "### API type definitions\n\n以下源码定义解释参数和事件载荷;可从包根导入的类型仅限上面列出的名称。\n\n```ts\n" + component.typeDefinitions.join("\n\n") + "\n```\n" : ""} ## API Caveats ${bullets(component.apiCaveats)} diff --git a/scripts/check-package-contract.ts b/scripts/check-package-contract.ts index 4af49ca..83fcfe3 100644 --- a/scripts/check-package-contract.ts +++ b/scripts/check-package-contract.ts @@ -313,6 +313,16 @@ try { dialogReference.includes("isLoading: boolean"), "Scoped slot arguments must be available to consumers", ); + const imageReference = readFileSync( + resolve(packedRoot, "skills/ui-web/references/components/InkImage.md"), + "utf8", + ); + const documentedTypes = [dialogReference, imageReference].map((reference) => { + const definition = reference.match(/### API type definitions[\s\S]*?```ts\n([\s\S]*?)\n```/); + assert.ok(definition, "Consumer API types must be explained in the installed reference"); + return definition[1]; + }); + writeFileSync(resolve(consumerRoot, "DocumentedTypes.ts"), documentedTypes.join("\n\n")); for (const file of [ "README.md", "MIGRATION.md", @@ -388,11 +398,16 @@ try { writeFileSync( resolve(consumerRoot, "App.vue"), `