@blueking/bkui-knowledge 0.0.1-beta.6 → 0.0.1-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -0
- package/bin/bkui-knowledge.js +60 -1
- package/knowledge/manifest.json +10 -1
- package/knowledge/skills/bkui-quick-start/SKILL.md +21 -37
- package/knowledge/skills/bkui-quick-start/references/components-list.md +17 -0
- package/knowledge/skills/bkui-quick-start/references/skills-index.md +26 -0
- package/knowledge/skills/external/vue-skills/LICENSE +21 -0
- package/knowledge/skills/external/vue-skills/README.md +69 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/SKILL.md +42 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/codeactions-save-performance.md +79 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/data-attributes-config.md +74 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/deep-watch-numeric.md +102 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/define-model-update-event.md +79 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/duplicate-plugin-detection.md +102 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/fallthrough-attributes.md +63 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/hmr-vue-ssr.md +124 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/module-resolution-bundler.md +81 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/pinia-store-mocking.md +159 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/script-setup-jsdoc.md +85 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/strict-css-modules.md +68 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/unplugin-auto-import-conflicts.md +97 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/volar-3-breaking-changes.md +66 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/vue-directive-comments.md +73 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/vue-router-typed-params.md +81 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/vue-tsc-strict-templates.md +69 -0
- package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/with-defaults-union-types.md +102 -0
- package/package.json +1 -1
- package/server/mcp-core.js +38 -8
package/README.md
CHANGED
|
@@ -172,6 +172,7 @@ AI: [获取 resource: example://table/basic]
|
|
|
172
172
|
| `code-review` | 代码评审专家 | 代码审查 |
|
|
173
173
|
| `js-security-check` | JavaScript 安全审查 | 安全 |
|
|
174
174
|
| `nodejs-security-check` | Node.js 安全审查 | 安全 |
|
|
175
|
+
| `vue-best-practices` | Vue 3 开发最佳实践 (外部) | TypeScript/Volar/vue-tsc |
|
|
175
176
|
|
|
176
177
|
### 页面模版 (在 bkui-builder 的 assets/ 中)
|
|
177
178
|
|
|
@@ -270,6 +271,37 @@ bkui-knowledge/
|
|
|
270
271
|
|
|
271
272
|
---
|
|
272
273
|
|
|
274
|
+
## 外部技能 (External Skills)
|
|
275
|
+
|
|
276
|
+
本项目集成了社区优秀的 Agent Skills 作为外部依赖:
|
|
277
|
+
|
|
278
|
+
| 技能 | 来源 | 描述 |
|
|
279
|
+
|------|------|------|
|
|
280
|
+
| `vue-best-practices` | [hyf0/vue-skills](https://github.com/hyf0/vue-skills) | Vue 3 TypeScript/vue-tsc/Volar 最佳实践 (17 条规则) |
|
|
281
|
+
|
|
282
|
+
### 更新外部技能
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
# 使用脚本更新
|
|
286
|
+
./scripts/update-external-skills.sh
|
|
287
|
+
|
|
288
|
+
# 或手动更新
|
|
289
|
+
git submodule update --remote --merge
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### 首次克隆项目
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
# 克隆时初始化子模块
|
|
296
|
+
git clone --recurse-submodules https://github.com/xxx/bkui-knowledge.git
|
|
297
|
+
|
|
298
|
+
# 或克隆后初始化
|
|
299
|
+
git submodule init
|
|
300
|
+
git submodule update
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
273
305
|
## 贡献知识
|
|
274
306
|
|
|
275
307
|
欢迎团队成员一起沉淀知识!所有贡献的内容都会自动遵循渐进式披露架构。
|
package/bin/bkui-knowledge.js
CHANGED
|
@@ -138,6 +138,58 @@ function needsSync(projectRoot, currentVersion, ideConfig) {
|
|
|
138
138
|
return localVersion !== currentVersion;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
/**
|
|
142
|
+
* 递归扫描目录,返回相对路径列表
|
|
143
|
+
* @param {string} dirPath - 目录路径
|
|
144
|
+
* @param {string} relativePath - 相对路径前缀
|
|
145
|
+
* @returns {string[]} 文件相对路径列表
|
|
146
|
+
*/
|
|
147
|
+
function scanSkillDir(dirPath, relativePath) {
|
|
148
|
+
const results = [];
|
|
149
|
+
try {
|
|
150
|
+
const items = fs.readdirSync(dirPath);
|
|
151
|
+
for (const item of items) {
|
|
152
|
+
const fullPath = path.join(dirPath, item);
|
|
153
|
+
const relPath = relativePath ? `${relativePath}/${item}` : item;
|
|
154
|
+
const stat = fs.statSync(fullPath);
|
|
155
|
+
if (stat.isDirectory()) {
|
|
156
|
+
results.push(...scanSkillDir(fullPath, relPath));
|
|
157
|
+
} else {
|
|
158
|
+
results.push(relPath);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
} catch (e) {
|
|
162
|
+
// 忽略错误
|
|
163
|
+
}
|
|
164
|
+
return results;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* 生成 skill 的可用资源列表
|
|
169
|
+
* @param {string} skillDir - skill 目录路径
|
|
170
|
+
* @param {string} skillId - skill ID
|
|
171
|
+
* @returns {string} 资源列表 Markdown
|
|
172
|
+
*/
|
|
173
|
+
function generateResourcesList(skillDir, skillId) {
|
|
174
|
+
const subDirs = ['scripts', 'references', 'assets', 'rules'];
|
|
175
|
+
const resources = [];
|
|
176
|
+
|
|
177
|
+
subDirs.forEach(dir => {
|
|
178
|
+
const dirPath = path.join(skillDir, dir);
|
|
179
|
+
if (fs.existsSync(dirPath)) {
|
|
180
|
+
const files = scanSkillDir(dirPath, '');
|
|
181
|
+
files.forEach(file => {
|
|
182
|
+
resources.push(`- \`skill://${skillId}/${dir}/${file}\``);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
if (resources.length > 0) {
|
|
188
|
+
return `\n\n---\n## 📦 可用资源\n\n${resources.join('\n')}\n\n> 根据 SKILL.md 中的 IF-THEN 规则判断是否需要加载\n`;
|
|
189
|
+
}
|
|
190
|
+
return '';
|
|
191
|
+
}
|
|
192
|
+
|
|
141
193
|
/**
|
|
142
194
|
* 同步 skills 到用户项目(从 npm 包内置的 knowledge 目录)
|
|
143
195
|
* @param {string} projectRoot - 项目根目录
|
|
@@ -178,7 +230,14 @@ function syncSkills(projectRoot, ideConfig) {
|
|
|
178
230
|
const skillFilePath = path.join(PKG_ROOT, 'knowledge', manifest.skills.base_path, skill.path);
|
|
179
231
|
if (!fs.existsSync(skillFilePath)) continue;
|
|
180
232
|
|
|
181
|
-
|
|
233
|
+
// 读取原始内容
|
|
234
|
+
let content = fs.readFileSync(skillFilePath, 'utf-8');
|
|
235
|
+
|
|
236
|
+
// 生成并附加资源列表(与 mcp-core.js 的 get_skill 逻辑一致)
|
|
237
|
+
const skillDir = path.dirname(skillFilePath);
|
|
238
|
+
const resourcesList = generateResourcesList(skillDir, skillId);
|
|
239
|
+
content += resourcesList;
|
|
240
|
+
|
|
182
241
|
fs.writeFileSync(path.join(skillsDir, `${skillId}.md`), content, 'utf-8');
|
|
183
242
|
|
|
184
243
|
log(` ✓ ${skillId}`);
|
package/knowledge/manifest.json
CHANGED
|
@@ -114,6 +114,15 @@
|
|
|
114
114
|
"category": "engineering",
|
|
115
115
|
"path": "bkui-quick-start/SKILL.md",
|
|
116
116
|
"tags": ["bkui", "规范", "索引", "入门"]
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"id": "vue-best-practices",
|
|
120
|
+
"name": "Vue 3 开发最佳实践",
|
|
121
|
+
"category": "engineering",
|
|
122
|
+
"path": "external/vue-skills/skills/vue-best-practices/SKILL.md",
|
|
123
|
+
"tags": ["vue3", "typescript", "vue-tsc", "volar", "vite", "pinia"],
|
|
124
|
+
"external": true,
|
|
125
|
+
"source": "https://github.com/hyf0/vue-skills"
|
|
117
126
|
}
|
|
118
127
|
]
|
|
119
128
|
},
|
|
@@ -670,5 +679,5 @@
|
|
|
670
679
|
]
|
|
671
680
|
},
|
|
672
681
|
|
|
673
|
-
"recommendedSkills": ["bkui-quick-start", "bkui-builder", "bkui-cheatsheet", "code-review", "js-security-check"]
|
|
682
|
+
"recommendedSkills": ["bkui-quick-start", "bkui-builder", "bkui-cheatsheet", "vue-best-practices", "code-review", "js-security-check"]
|
|
674
683
|
}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: bkui-quick-start
|
|
3
|
+
name: BKUI 快速入门
|
|
4
|
+
category: engineering
|
|
5
|
+
description: 蓝鲸前端知识库入口指南,包含规范、索引和工作流程
|
|
6
|
+
tags: [bkui, 规范, 索引, 入门, vue3]
|
|
7
|
+
updated_at: 2026-01-23
|
|
8
|
+
---
|
|
9
|
+
|
|
1
10
|
# BKUI 快速入门
|
|
2
11
|
|
|
3
|
-
>
|
|
12
|
+
> 蓝鲸前端知识库入口指南。
|
|
4
13
|
|
|
5
14
|
## 强制规范
|
|
6
15
|
|
|
@@ -17,31 +26,7 @@
|
|
|
17
26
|
| bk-menu | `:default-open-keys` | `:opened-keys` |
|
|
18
27
|
| bk-dialog | `v-model` | `v-model:isShow` |
|
|
19
28
|
|
|
20
|
-
##
|
|
21
|
-
|
|
22
|
-
通过 `get_skill({ skillId: 'xxx' })` 获取详情:
|
|
23
|
-
|
|
24
|
-
| ID | 名称 | 说明 |
|
|
25
|
-
|----|------|------|
|
|
26
|
-
| bkui-builder | 设计稿还原专家 | 包含布局模版和页面模版 (assets/) |
|
|
27
|
-
| bkui-cheatsheet | BKUI 组件速查 | Props 速查、常见坑点 |
|
|
28
|
-
| api-standard | 统一网络请求封装 | Axios 封装规范 |
|
|
29
|
-
| pinia-setup | 全局状态管理 | Pinia Store 模板 |
|
|
30
|
-
| permission-directive | 前端权限控制 | IAM 权限指令 |
|
|
31
|
-
| vite-migration | Webpack 到 Vite 迁移 | 迁移检查脚本 |
|
|
32
|
-
| bundle-optimization | Vite 构建优化 | 性能优化配置 |
|
|
33
|
-
| vue-composables | Vue 3 Composables | 最佳实践和模板 |
|
|
34
|
-
| virtual-list | 长列表虚拟滚动 | 性能优化方案 |
|
|
35
|
-
| unit-testing | 组件单元测试 | Vitest 测试模板 |
|
|
36
|
-
| code-review | 代码评审专家 | 评审规范和检查清单 |
|
|
37
|
-
| js-security-check | JavaScript 安全审查 | 前端安全检查 |
|
|
38
|
-
| nodejs-security-check | Node.js 安全审查 | 后端安全检查 |
|
|
39
|
-
|
|
40
|
-
## Component APIs
|
|
41
|
-
|
|
42
|
-
通过 `get_component_api({ componentName: 'xxx' })` 获取文档:
|
|
43
|
-
|
|
44
|
-
### 高优先级 (必须先查询)
|
|
29
|
+
## 高优先级组件
|
|
45
30
|
|
|
46
31
|
- `bk-navigation` - 布局组件,易出错
|
|
47
32
|
- `bk-menu` - 与 navigation 配合
|
|
@@ -49,20 +34,19 @@
|
|
|
49
34
|
- `bk-form` - 表单验证
|
|
50
35
|
- `bk-dialog` - v-model:isShow
|
|
51
36
|
|
|
52
|
-
### 全部组件
|
|
53
|
-
|
|
54
|
-
navigation, menu, table, form, dialog, button, input, select, checkbox, radio, date-picker, time-picker, pagination, message, notify, loading, popover, pop-confirm, tag, tag-input, alert, dropdown, tab, cascader, tree, steps, upload, sideslider, breadcrumb, card, collapse, affix, backtop, badge, divider, exception, image, link, progress, rate, slider, switcher, timeline, process, transfer, search-select, color-picker, container, resize-layout, fixed-navbar, code-diff, swiper, animate-number, overflow-title, virtual-render, scrollbar, info-box, config-provider
|
|
55
|
-
|
|
56
37
|
## 工作流程
|
|
57
38
|
|
|
58
39
|
1. **分析需求** → 确定需要哪些资源
|
|
59
|
-
2.
|
|
60
|
-
3.
|
|
61
|
-
4. **批量获取?** → `batch_load({ skillIds: [...], componentNames: [...] })`
|
|
40
|
+
2. **布局组件** → `get_component_api({ componentName: 'navigation' })`
|
|
41
|
+
3. **模板代码** → `get_skill({ skillId: 'bkui-builder' })`
|
|
62
42
|
|
|
63
43
|
## 触发条件
|
|
64
44
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
45
|
+
遇到 bk- 前缀组件、bkui-vue、蓝鲸前端、设计稿还原时使用。
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 按需加载资源
|
|
50
|
+
|
|
51
|
+
- `skill://bkui-quick-start/references/skills-index.md` - 完整 Skills 索引
|
|
52
|
+
- `skill://bkui-quick-start/references/components-list.md` - 组件完整列表
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# 组件完整列表
|
|
2
|
+
|
|
3
|
+
通过 `get_component_api({ componentName: 'xxx' })` 获取文档。
|
|
4
|
+
|
|
5
|
+
## 高优先级 (必须先查询)
|
|
6
|
+
|
|
7
|
+
| 组件 | 说明 |
|
|
8
|
+
|------|------|
|
|
9
|
+
| bk-navigation | 布局组件,易出错 |
|
|
10
|
+
| bk-menu | 与 navigation 配合 |
|
|
11
|
+
| bk-table | 列表页核心组件 |
|
|
12
|
+
| bk-form | 表单验证 |
|
|
13
|
+
| bk-dialog | v-model:isShow |
|
|
14
|
+
|
|
15
|
+
## 全部组件
|
|
16
|
+
|
|
17
|
+
navigation, menu, table, form, dialog, button, input, select, checkbox, radio, date-picker, time-picker, pagination, message, notify, loading, popover, pop-confirm, tag, tag-input, alert, dropdown, tab, cascader, tree, steps, upload, sideslider, breadcrumb, card, collapse, affix, backtop, badge, divider, exception, image, link, progress, rate, slider, switcher, timeline, process, transfer, search-select, color-picker, container, resize-layout, fixed-navbar, code-diff, swiper, animate-number, overflow-title, virtual-render, scrollbar, info-box, config-provider
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# 可用 Skills 索引
|
|
2
|
+
|
|
3
|
+
通过 `get_skill({ skillId: 'xxx' })` 获取详情:
|
|
4
|
+
|
|
5
|
+
## 工程化
|
|
6
|
+
|
|
7
|
+
| ID | 名称 | 说明 |
|
|
8
|
+
|----|------|------|
|
|
9
|
+
| bkui-builder | 设计稿还原专家 | 包含布局模版和页面模版 (assets/) |
|
|
10
|
+
| bkui-cheatsheet | BKUI 组件速查 | Props 速查、常见坑点 |
|
|
11
|
+
| api-standard | 统一网络请求封装 | Axios 封装规范 |
|
|
12
|
+
| pinia-setup | 全局状态管理 | Pinia Store 模板 |
|
|
13
|
+
| permission-directive | 前端权限控制 | IAM 权限指令 |
|
|
14
|
+
| vite-migration | Webpack 到 Vite 迁移 | 迁移检查脚本 |
|
|
15
|
+
| bundle-optimization | Vite 构建优化 | 性能优化配置 |
|
|
16
|
+
| vue-composables | Vue 3 Composables | 最佳实践和模板 |
|
|
17
|
+
| virtual-list | 长列表虚拟滚动 | 性能优化方案 |
|
|
18
|
+
|
|
19
|
+
## 质量保障
|
|
20
|
+
|
|
21
|
+
| ID | 名称 | 说明 |
|
|
22
|
+
|----|------|------|
|
|
23
|
+
| unit-testing | 组件单元测试 | Vitest 测试模板 |
|
|
24
|
+
| code-review | 代码评审专家 | 评审规范和检查清单 |
|
|
25
|
+
| js-security-check | JavaScript 安全审查 | 前端安全检查 |
|
|
26
|
+
| nodejs-security-check | Node.js 安全审查 | 后端安全检查 |
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 hyf0
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# vue-skills
|
|
2
|
+
|
|
3
|
+
Agent skills for Vue 3 development.
|
|
4
|
+
|
|
5
|
+
> 🚧 **Early Experiment**
|
|
6
|
+
>
|
|
7
|
+
> This repository is an early experiment in creating specialized skills for AI agents to enhance their capabilities in Vue 3 development. The skills are derived from real-world issues and best practices, but might be incomplete or inaccurate due to hallucinations.
|
|
8
|
+
>
|
|
9
|
+
> Please give feedback when encountering any issues.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx add-skill hyf0/vue-skills
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Available Skills
|
|
18
|
+
|
|
19
|
+
### vue-best-practices (17 rules)
|
|
20
|
+
|
|
21
|
+
Vue 3 development best practices covering TypeScript configuration, tooling troubleshooting, and testing patterns.
|
|
22
|
+
|
|
23
|
+
| Type | Count | Examples |
|
|
24
|
+
|------|-------|----------|
|
|
25
|
+
| Capability | 15 | vue-tsc strictTemplates, Volar 3.0 breaking changes, Vue 3.5 deep watch, @vue-ignore directives |
|
|
26
|
+
| Efficiency | 2 | HMR in SSR, Pinia store mocking |
|
|
27
|
+
|
|
28
|
+
**Key rules that models don't know without the skill:**
|
|
29
|
+
- `vue-tsc-strict-templates` - vueCompilerOptions.strictTemplates config
|
|
30
|
+
- `deep-watch-numeric` - Vue 3.5 `deep: 1` for efficient partial-depth watching
|
|
31
|
+
- `vue-directive-comments` - @vue-ignore, @vue-expect-error, @vue-skip directives
|
|
32
|
+
- `pinia-store-mocking` - createSpy requirement in @pinia/testing 1.0+
|
|
33
|
+
|
|
34
|
+
## Rule Types
|
|
35
|
+
|
|
36
|
+
Rules are classified into two categories:
|
|
37
|
+
|
|
38
|
+
- **Capability**: AI *cannot* solve the problem without the skill. These address version-specific issues, undocumented behaviors, recent features, or edge cases outside AI's training data.
|
|
39
|
+
|
|
40
|
+
- **Efficiency**: AI *can* solve the problem but not well. These provide optimal patterns, best practices, and consistent approaches that improve solution quality.
|
|
41
|
+
|
|
42
|
+
## Methodology
|
|
43
|
+
|
|
44
|
+
Every skill in this repository is created through a rigorous, evidence-based process:
|
|
45
|
+
|
|
46
|
+
**1. Real-World Issue Collection**
|
|
47
|
+
|
|
48
|
+
Skills are sourced from actual developer pain points encountered in production.
|
|
49
|
+
|
|
50
|
+
**2. Multi-Model Verification**
|
|
51
|
+
|
|
52
|
+
Each skill undergoes systematic testing:
|
|
53
|
+
- **Baseline test**: Verify the model fails to solve the problem *without* the skill
|
|
54
|
+
- **Skill test**: Confirm the model correctly solves the problem *with* the skill
|
|
55
|
+
- **Deletion criteria**: If both Sonnet AND Haiku pass without the skill, the rule will be deleted
|
|
56
|
+
|
|
57
|
+
**3. Model Tier Validation**
|
|
58
|
+
|
|
59
|
+
| Model | Without Skill | With Skill | Action |
|
|
60
|
+
|-------|--------------|------------|--------|
|
|
61
|
+
| Haiku | Fail | Pass | Keep |
|
|
62
|
+
| Sonnet | Fail | Pass | Keep |
|
|
63
|
+
| Both | Pass | - | Delete |
|
|
64
|
+
|
|
65
|
+
**Acceptance criteria**: A skill is only kept if it enables Haiku or Sonnet to solve a problem they couldn't solve without it.
|
|
66
|
+
|
|
67
|
+
## License
|
|
68
|
+
|
|
69
|
+
MIT
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: vue-best-practices
|
|
3
|
+
description: Vue 3 TypeScript, vue-tsc, Volar, Vite, component props, testing, composition API.
|
|
4
|
+
license: MIT
|
|
5
|
+
metadata:
|
|
6
|
+
author: hyf0
|
|
7
|
+
version: "7.0.0"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Vue Best Practices
|
|
11
|
+
|
|
12
|
+
## Capability Rules
|
|
13
|
+
|
|
14
|
+
| Rule | Keywords | Description |
|
|
15
|
+
|------|----------|-------------|
|
|
16
|
+
| [vue-tsc-strict-templates](rules/vue-tsc-strict-templates.md) | undefined component, template error, strictTemplates | Catch undefined components in templates |
|
|
17
|
+
| [fallthrough-attributes](rules/fallthrough-attributes.md) | fallthrough, $attrs, wrapper component | Type-check fallthrough attributes |
|
|
18
|
+
| [strict-css-modules](rules/strict-css-modules.md) | css modules, $style, typo | Catch CSS module class typos |
|
|
19
|
+
| [data-attributes-config](rules/data-attributes-config.md) | data-*, strictTemplates, attribute | Allow data-* attributes |
|
|
20
|
+
| [volar-3-breaking-changes](rules/volar-3-breaking-changes.md) | volar, vue-language-server, editor | Fix Volar 3.0 upgrade issues |
|
|
21
|
+
| [module-resolution-bundler](rules/module-resolution-bundler.md) | cannot find module, @vue/tsconfig, moduleResolution | Fix module resolution errors |
|
|
22
|
+
| [unplugin-auto-import-conflicts](rules/unplugin-auto-import-conflicts.md) | unplugin, auto-import, types any | Fix unplugin type conflicts |
|
|
23
|
+
| [codeactions-save-performance](rules/codeactions-save-performance.md) | slow save, vscode, performance | Fix slow save in large projects |
|
|
24
|
+
| [duplicate-plugin-detection](rules/duplicate-plugin-detection.md) | duplicate plugin, vite, vue plugin | Detect duplicate plugins |
|
|
25
|
+
| [define-model-update-event](rules/define-model-update-event.md) | defineModel, update event, undefined | Fix model update errors |
|
|
26
|
+
| [with-defaults-union-types](rules/with-defaults-union-types.md) | withDefaults, union type, default | Fix union type defaults |
|
|
27
|
+
| [deep-watch-numeric](rules/deep-watch-numeric.md) | watch, deep, array, Vue 3.5 | Efficient array watching |
|
|
28
|
+
| [vue-directive-comments](rules/vue-directive-comments.md) | @vue-ignore, @vue-skip, template | Control template type checking |
|
|
29
|
+
| [script-setup-jsdoc](rules/script-setup-jsdoc.md) | jsdoc, script setup, documentation | Add JSDoc to script setup |
|
|
30
|
+
| [vue-router-typed-params](rules/vue-router-typed-params.md) | route params, typed router, unplugin | Fix route params typing |
|
|
31
|
+
|
|
32
|
+
## Efficiency Rules
|
|
33
|
+
|
|
34
|
+
| Rule | Keywords | Description |
|
|
35
|
+
|------|----------|-------------|
|
|
36
|
+
| [hmr-vue-ssr](rules/hmr-vue-ssr.md) | hmr, ssr, hot reload | Fix HMR in SSR apps |
|
|
37
|
+
| [pinia-store-mocking](rules/pinia-store-mocking.md) | pinia, mock, vitest, store | Mock Pinia stores |
|
|
38
|
+
|
|
39
|
+
## Reference
|
|
40
|
+
|
|
41
|
+
- [Vue Language Tools](https://github.com/vuejs/language-tools)
|
|
42
|
+
- [Vue 3 Documentation](https://vuejs.org/)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Fix Slow Save Times with Code Actions Setting
|
|
3
|
+
impact: HIGH
|
|
4
|
+
impactDescription: fixes 30-60 second save delays in large Vue projects
|
|
5
|
+
type: capability
|
|
6
|
+
tags: performance, save-time, vscode, code-actions, volar
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Fix Slow Save Times with Code Actions Setting
|
|
10
|
+
|
|
11
|
+
**Impact: HIGH** - fixes 30-60 second save delays in large Vue projects
|
|
12
|
+
|
|
13
|
+
In large Vue projects, saving files can take 30-60+ seconds due to VSCode's code actions triggering expensive TypeScript state synchronization.
|
|
14
|
+
|
|
15
|
+
## Problem
|
|
16
|
+
|
|
17
|
+
Symptoms:
|
|
18
|
+
- Save operation takes 30+ seconds
|
|
19
|
+
- Editor becomes unresponsive during save
|
|
20
|
+
- CPU spikes when saving Vue files
|
|
21
|
+
- Happens more in larger projects
|
|
22
|
+
|
|
23
|
+
## Root Cause
|
|
24
|
+
|
|
25
|
+
VSCode emits document change events multiple times during save cycles. Each event triggers Volar to synchronize with TypeScript, causing expensive re-computation.
|
|
26
|
+
|
|
27
|
+
## Solution
|
|
28
|
+
|
|
29
|
+
Disable code actions or limit their timeout:
|
|
30
|
+
|
|
31
|
+
**Option 1: Disable code actions (fastest)**
|
|
32
|
+
```json
|
|
33
|
+
// .vscode/settings.json
|
|
34
|
+
{
|
|
35
|
+
"vue.codeActions.enabled": false
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Option 2: Limit code action time**
|
|
40
|
+
```json
|
|
41
|
+
// .vscode/settings.json
|
|
42
|
+
{
|
|
43
|
+
"vue.codeActions.savingTimeLimit": 1000
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Option 3: Disable specific code actions**
|
|
48
|
+
```json
|
|
49
|
+
// .vscode/settings.json
|
|
50
|
+
{
|
|
51
|
+
"vue.codeActions.enabled": true,
|
|
52
|
+
"editor.codeActionsOnSave": {
|
|
53
|
+
"source.organizeImports": "never"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## VSCode Version Requirement
|
|
59
|
+
|
|
60
|
+
VSCode 1.81.0+ includes fixes that reduce save time issues. Upgrade if using an older version.
|
|
61
|
+
|
|
62
|
+
## Additional Optimizations
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
// .vscode/settings.json
|
|
66
|
+
{
|
|
67
|
+
"vue.codeActions.enabled": false,
|
|
68
|
+
"editor.formatOnSave": true,
|
|
69
|
+
"editor.codeActionsOnSave": {},
|
|
70
|
+
"[vue]": {
|
|
71
|
+
"editor.formatOnSave": true,
|
|
72
|
+
"editor.defaultFormatter": "Vue.volar"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Reference
|
|
78
|
+
|
|
79
|
+
- [Vue Language Tools Discussion #2740](https://github.com/vuejs/language-tools/discussions/2740)
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Allow Data Attributes with Strict Templates
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
impactDescription: fixes data-testid and data-* attribute errors in strict mode
|
|
5
|
+
type: capability
|
|
6
|
+
tags: dataAttributes, vueCompilerOptions, strictTemplates, data-testid, testing
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Allow Data Attributes with Strict Templates
|
|
10
|
+
|
|
11
|
+
**Impact: MEDIUM** - fixes data-testid and data-* attribute errors in strict mode
|
|
12
|
+
|
|
13
|
+
With `strictTemplates` enabled, `data-*` attributes on components cause type errors. Use the `dataAttributes` option to allow specific patterns.
|
|
14
|
+
|
|
15
|
+
## Problem
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
<template>
|
|
19
|
+
<!-- Error: Property 'data-testid' does not exist on type... -->
|
|
20
|
+
<MyComponent data-testid="submit-button" />
|
|
21
|
+
|
|
22
|
+
<!-- Error: Property 'data-cy' does not exist on type... -->
|
|
23
|
+
<MyComponent data-cy="login-form" />
|
|
24
|
+
</template>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Solution
|
|
28
|
+
|
|
29
|
+
Configure `dataAttributes` to allow specific patterns:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
// tsconfig.json or tsconfig.app.json
|
|
33
|
+
{
|
|
34
|
+
"vueCompilerOptions": {
|
|
35
|
+
"strictTemplates": true,
|
|
36
|
+
"dataAttributes": ["data-*"]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Now all `data-*` attributes are allowed on any component.
|
|
42
|
+
|
|
43
|
+
## Specific Patterns
|
|
44
|
+
|
|
45
|
+
You can be more selective:
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"vueCompilerOptions": {
|
|
50
|
+
"dataAttributes": [
|
|
51
|
+
"data-testid",
|
|
52
|
+
"data-cy",
|
|
53
|
+
"data-test-*"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
This only allows the specified patterns, not all data attributes.
|
|
60
|
+
|
|
61
|
+
## Common Testing Attributes
|
|
62
|
+
|
|
63
|
+
For testing libraries, allow their specific attributes:
|
|
64
|
+
|
|
65
|
+
| Library | Attribute | Pattern |
|
|
66
|
+
|---------|-----------|---------|
|
|
67
|
+
| Testing Library | `data-testid` | `"data-testid"` |
|
|
68
|
+
| Cypress | `data-cy` | `"data-cy"` |
|
|
69
|
+
| Playwright | `data-testid` | `"data-testid"` |
|
|
70
|
+
| Generic | All data attributes | `"data-*"` |
|
|
71
|
+
|
|
72
|
+
## Reference
|
|
73
|
+
|
|
74
|
+
- [Vue Language Tools Wiki - Vue Compiler Options](https://github.com/vuejs/language-tools/wiki/Vue-Compiler-Options)
|
package/knowledge/skills/external/vue-skills/skills/vue-best-practices/rules/deep-watch-numeric.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Vue 3.5+ Deep Watch Numeric Depth
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
impactDescription: enables efficient array mutation watching with numeric deep option
|
|
5
|
+
type: capability
|
|
6
|
+
tags: watch, deep, vue-3.5, array, mutation, performance
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Vue 3.5+ Deep Watch Numeric Depth
|
|
10
|
+
|
|
11
|
+
**Impact: MEDIUM** - enables efficient array mutation watching with numeric deep option
|
|
12
|
+
|
|
13
|
+
Vue 3.5 introduced `deep: number` for watch depth control. This allows watching array mutations without the performance cost of deep traversal.
|
|
14
|
+
|
|
15
|
+
## Symptoms
|
|
16
|
+
|
|
17
|
+
- Array mutations not triggering watch callback
|
|
18
|
+
- Deep watch causing performance issues on large nested objects
|
|
19
|
+
- Unaware of new Vue 3.5 feature
|
|
20
|
+
|
|
21
|
+
> **Note:** TypeScript error "Type 'number' is not assignable to type 'boolean'" no longer occurs with Vue 3.5+ and current TypeScript versions. The types now correctly support numeric `deep` values.
|
|
22
|
+
|
|
23
|
+
## The Feature
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
// Vue 3.5+ only
|
|
27
|
+
watch(items, (newVal) => {
|
|
28
|
+
// Triggered on array mutations (push, pop, splice, etc.)
|
|
29
|
+
}, { deep: 1 })
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
| deep value | Behavior |
|
|
33
|
+
|------------|----------|
|
|
34
|
+
| `true` | Full recursive traversal (original behavior) |
|
|
35
|
+
| `false` | Only reference changes |
|
|
36
|
+
| `1` | One level deep - array mutations, not nested objects |
|
|
37
|
+
| `2` | Two levels deep |
|
|
38
|
+
| `n` | N levels deep |
|
|
39
|
+
|
|
40
|
+
## Fix
|
|
41
|
+
|
|
42
|
+
**Step 1: Ensure Vue 3.5+**
|
|
43
|
+
```bash
|
|
44
|
+
npm install vue@^3.5.0
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Step 2: Update @vue/runtime-core types**
|
|
48
|
+
```bash
|
|
49
|
+
npm install -D @vue/runtime-core@latest
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Step 3: Use numeric depth**
|
|
53
|
+
```typescript
|
|
54
|
+
import { watch, ref } from 'vue'
|
|
55
|
+
|
|
56
|
+
const items = ref([{ id: 1, data: { nested: 'value' } }])
|
|
57
|
+
|
|
58
|
+
// Watch array mutations only (push, pop, etc.)
|
|
59
|
+
watch(items, (newItems) => {
|
|
60
|
+
console.log('Array mutated')
|
|
61
|
+
}, { deep: 1 })
|
|
62
|
+
|
|
63
|
+
// Won't trigger on: items.value[0].data.nested = 'new'
|
|
64
|
+
// Will trigger on: items.value.push(newItem)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Performance Comparison
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
const largeNestedData = ref({ /* deeply nested structure */ })
|
|
71
|
+
|
|
72
|
+
// SLOW - traverses entire structure
|
|
73
|
+
watch(largeNestedData, handler, { deep: true })
|
|
74
|
+
|
|
75
|
+
// FAST - only watches top-level changes
|
|
76
|
+
watch(largeNestedData, handler, { deep: 1 })
|
|
77
|
+
|
|
78
|
+
// FASTEST - only reference changes
|
|
79
|
+
watch(largeNestedData, handler, { deep: false })
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Alternative: watchEffect for Selective Tracking
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
// Only tracks properties actually accessed
|
|
86
|
+
watchEffect(() => {
|
|
87
|
+
// Only re-runs when items.value.length or first item changes
|
|
88
|
+
console.log(items.value.length, items.value[0]?.id)
|
|
89
|
+
})
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## TypeScript Note
|
|
93
|
+
|
|
94
|
+
If TypeScript complains about numeric deep, ensure:
|
|
95
|
+
1. Vue version is 3.5+
|
|
96
|
+
2. `@vue/runtime-core` types are updated
|
|
97
|
+
3. tsconfig targets correct node_modules types
|
|
98
|
+
|
|
99
|
+
## Reference
|
|
100
|
+
|
|
101
|
+
- [Vue Watchers Docs](https://vuejs.org/guide/essentials/watchers.html)
|
|
102
|
+
- [Vue 3.5 Release Notes](https://blog.vuejs.org/posts/vue-3-5)
|