Files
Web_Template_Vue3_Dev/AI-Coding/AI-Reuse-Playbook.md

55 lines
1.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# AI 复用操作手册(轻量化)
> 目标:在“不改动现有代码”的前提下,用文档约束 AI 从本仓库抽取能力,并确保抽取结果可验证。
## A. 选模块(先确定要什么)
在开始任何代码生成/迁移前AI 必须先回答:
- 我要复用的能力类型:`layout | component | plugin | util | store | i18n | api | mock | config`
- 复用方式:`copy-snippet`(复制片段)或 `copy-module`(整目录)
- 目标项目构建工具:`Vue CLI` / `Vite` / 其他
> 推荐:优先 `copy-module`(减少遗漏依赖),再做裁剪。
## B. 定位入口(必须列出入口文件)
- 全局能力:`library/index.ts``setupVab`
- 初始化:`src/main.ts`
- 路由:`src/router/index.ts`
- 状态:`src/store/index.ts`
- i18n`src/i18n/index.ts`
- Mock`mock/index.js`
AI 输出中必须包含:入口文件列表 + 为什么需要它们。
## C. 最小闭包(必须列出依赖闭包)
AI 必须同时列出:
- 直接依赖import 的文件/包)
- 运行时依赖例如全局样式、icons、插件自动加载
- 类型依赖(`types/` 目录与 `/#`
- alias 依赖(`@``@vab``~``/#`
> 如果依赖闭包不清晰,禁止直接迁移;应先补规格(见 `openspec-lite/`)。
## D. 迁移后验收(必须可执行)
最低验收:
- `pnpm run serve` 能启动
- 页面可渲染
- 路由能跳转
- i18n/store 能注入
- Mock若启用能命中
## E. 输出格式(给 OpenSpec/AI 工具链用)
当 AI 完成一次抽取/复用任务时,输出必须包含:
- **变更文件清单**(新增/修改/删除)
- **复用模块清单**(从哪里来、被用在何处)
- **验收命令**lint/test/build/serve
- **风险说明**可能破坏的点alias、插件自动加载、生产 mock 等)