create-vela-workflow 1.0.0
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 +136 -0
- package/bin/cli.js +188 -0
- package/docs/ai-workflow-tutorial.md +462 -0
- package/docs/official-site-tutorial.md +391 -0
- package/package.json +34 -0
- package/templates/.github/HARNESS-ENGINEERING-GUIDE.md +407 -0
- package/templates/.github/agents/vela-knowledge.agent.md +45 -0
- package/templates/.github/agents/vela-s1-prd.agent.md +69 -0
- package/templates/.github/agents/vela-s2-tech.agent.md +66 -0
- package/templates/.github/agents/vela-s3-coding.agent.md +301 -0
- package/templates/.github/agents/vela-workflow.agent.md +110 -0
- package/templates/.github/copilot-instructions.md +64 -0
- package/templates/.github/prompts/vela-apis.prompt.md +98 -0
- package/templates/.github/prompts/vela-best-practices.prompt.md +93 -0
- package/templates/.github/prompts/vela-components.prompt.md +118 -0
- package/templates/.github/prompts/vela-dev-guide.prompt.md +622 -0
- package/templates/.github/rules/project-init.md +45 -0
- package/templates/.github/rules/vela-coding-convention.md +324 -0
- package/templates/.github/rules/vela-css.md +217 -0
- package/templates/.github/rules/vela-design-driven.md +306 -0
- package/templates/.github/rules/vela-figma-mcp.md +198 -0
- package/templates/.github/rules/vela-format.md +119 -0
- package/templates/.github/rules/vela-layout.md +67 -0
- package/templates/.github/rules/vela-platform.md +46 -0
- package/templates/.github/rules/vela-quality.md +109 -0
- package/templates/.kiro/hooks/figma-design-check.kiro.hook +14 -0
- package/templates/.kiro/hooks/post-coding-validation.kiro.hook +13 -0
- package/templates/.kiro/hooks/validate-ux-files.kiro.hook +16 -0
- package/templates/.kiro/settings/mcp.json +7 -0
- package/templates/.kiro/skills/vela-js-app/SKILL.md +1072 -0
- package/templates/.kiro/steering/workflow-conventions.md +110 -0
- package/templates/.workflow/resource-paths.json +62 -0
- package/templates/.workflow/scripts/.gitkeep +0 -0
- package/templates/.workflow/scripts/checkpoint_manager.js +284 -0
- package/templates/.workflow/scripts/context_loader.js +841 -0
- package/templates/.workflow/scripts/figma_export.js +346 -0
- package/templates/.workflow/scripts/session_manager.js +438 -0
- package/templates/.workflow/stages/.gitkeep +0 -0
- package/templates/.workflow/stages/commands.md +171 -0
- package/templates/.workflow/stages/s1_prd.md +286 -0
- package/templates/.workflow/stages/s2_tech_design.md +302 -0
- package/templates/.workflow/stages/s3_coding.md +699 -0
- package/templates/.workflow/stages/s4_simulator.md +259 -0
- package/templates/.workflow/workflow-config.json +46 -0
- package/templates/.workflow/workflow_starter.md +912 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: VelaOS 平台硬约束 — 组件白名单、API 白名单、禁止的第三方依赖、生命周期、数据对象
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# VelaOS 平台硬约束
|
|
7
|
+
|
|
8
|
+
> ⚠️ 本文件为强制执行规则,AI 必须无条件遵守,不可协商或降级。
|
|
9
|
+
|
|
10
|
+
## 组件白名单
|
|
11
|
+
|
|
12
|
+
仅允许使用以下 Vela 内置组件,**禁止使用任何其他组件或第三方 UI 库**:
|
|
13
|
+
|
|
14
|
+
div, list, list-item, text, image, input, scroll, swiper, switch, slider, progress, picker, stack, span, marquee, barcode, qrcode, chart, image-animator, a
|
|
15
|
+
|
|
16
|
+
## API 白名单
|
|
17
|
+
|
|
18
|
+
仅允许使用以下 @system.xxx API,**使用前必须在 manifest.json features 中声明**:
|
|
19
|
+
|
|
20
|
+
router, app, fetch, storage, device, audio, prompt, sensor, vibrator, network, brightness, volume, battery, geolocation, record, file, crypto, configuration, interconnect, messagecenter
|
|
21
|
+
|
|
22
|
+
## 禁止的第三方依赖
|
|
23
|
+
|
|
24
|
+
| 类别 | 禁止项 | 替代方案 |
|
|
25
|
+
|------|--------|----------|
|
|
26
|
+
| UI 库 | antd, element-ui, vant, Material-UI | 使用内置组件 |
|
|
27
|
+
| JS 库 | axios, lodash, moment, echarts, jQuery | 使用 @system.fetch 等系统 API |
|
|
28
|
+
| 框架 | Vue, React, Angular, Svelte | VelaOS 原生 .ux 开发范式 |
|
|
29
|
+
| 构建工具 | hap-toolkit | 使用 aiot-toolkit |
|
|
30
|
+
|
|
31
|
+
## 页面生命周期
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
onInit → onReady → onShow → onHide → onDestroy
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
- `onDestroy` 中**必须**清理所有定时器、事件监听等资源
|
|
38
|
+
|
|
39
|
+
## 页面数据对象
|
|
40
|
+
|
|
41
|
+
| 对象 | 作用域 | 说明 |
|
|
42
|
+
|------|--------|------|
|
|
43
|
+
| `public` | 外部 | 允许被外部传入数据覆盖 |
|
|
44
|
+
| `protected` | 应用内部 | 允许被应用内部页面传参覆盖 |
|
|
45
|
+
| `private` | 页面内 | 不允许被覆盖 |
|
|
46
|
+
| `data` | 组件 | 组件级数据 |
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 代码质量标准 — 命名规范、错误处理、资源清理、禁止行为、自检清单
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Vela 快应用代码质量标准
|
|
7
|
+
|
|
8
|
+
> ⚠️ 本文件为强制执行规则,AI 必须无条件遵守。
|
|
9
|
+
|
|
10
|
+
## 命名规范
|
|
11
|
+
|
|
12
|
+
| 类型 | 规范 | 示例 |
|
|
13
|
+
|------|------|------|
|
|
14
|
+
| 变量/函数 | camelCase | `userName`, `getUserInfo()` |
|
|
15
|
+
| 组件 | PascalCase | `UserCard`, `MusicPlayer` |
|
|
16
|
+
| 常量 | UPPER_SNAKE_CASE | `MAX_RETRY_COUNT` |
|
|
17
|
+
| 页面路由 | kebab-case | `pages/user-detail/index.ux` |
|
|
18
|
+
|
|
19
|
+
## 错误处理
|
|
20
|
+
|
|
21
|
+
**所有 API 调用必须包含错误处理**:
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
// 正确 ✅
|
|
25
|
+
import fetch from '@system.fetch'
|
|
26
|
+
fetch.fetch({
|
|
27
|
+
url: 'https://api.example.com/data',
|
|
28
|
+
success: (response) => {
|
|
29
|
+
// 处理成功
|
|
30
|
+
},
|
|
31
|
+
fail: (data, code) => {
|
|
32
|
+
console.error(`请求失败: code=${code}`)
|
|
33
|
+
// 错误兜底
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
// 错误 ❌ — 没有错误处理
|
|
38
|
+
fetch.fetch({ url: 'https://api.example.com/data' })
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 网络请求规范
|
|
42
|
+
|
|
43
|
+
- **必须**设置超时时间
|
|
44
|
+
- **必须**提供失败兜底逻辑(如展示缓存数据或错误提示)
|
|
45
|
+
- **禁止**不处理 fail 回调
|
|
46
|
+
|
|
47
|
+
## 资源清理
|
|
48
|
+
|
|
49
|
+
在 `onDestroy` 中**必须**清理:
|
|
50
|
+
|
|
51
|
+
| 资源类型 | 清理方式 |
|
|
52
|
+
|----------|----------|
|
|
53
|
+
| 定时器 | `clearInterval(id)` / `clearTimeout(id)` |
|
|
54
|
+
| 事件监听 | `offXxx(event, handler)` |
|
|
55
|
+
| 动画 | 取消动画帧 |
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
export default {
|
|
59
|
+
private: {
|
|
60
|
+
timerId: null
|
|
61
|
+
},
|
|
62
|
+
onShow() {
|
|
63
|
+
this.timerId = setInterval(() => { /* ... */ }, 1000)
|
|
64
|
+
},
|
|
65
|
+
onDestroy() {
|
|
66
|
+
if (this.timerId) {
|
|
67
|
+
clearInterval(this.timerId)
|
|
68
|
+
this.timerId = null
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## 禁止行为
|
|
75
|
+
|
|
76
|
+
| 编号 | 禁止行为 | 原因 |
|
|
77
|
+
|------|----------|------|
|
|
78
|
+
| Q1 | `console.debug` 调试输出 | 使用系统日志或 prompt API |
|
|
79
|
+
| Q2 | 未处理的 Promise / fail 回调 | 导致静默失败 |
|
|
80
|
+
| Q3 | `onDestroy` 中未清理资源 | 内存泄漏 |
|
|
81
|
+
| Q4 | 非 UI 数据放入 ViewModel | 影响渲染性能 |
|
|
82
|
+
| Q5 | 直接重新赋值对象/数组 | 应原地修改属性 |
|
|
83
|
+
| Q6 | 在循环中创建闭包 | 性能问题 |
|
|
84
|
+
| Q7 | 超长函数(>50行) | 拆分为独立方法 |
|
|
85
|
+
|
|
86
|
+
## 代码自检清单
|
|
87
|
+
|
|
88
|
+
代码生成完成后,**必须**逐项检查:
|
|
89
|
+
|
|
90
|
+
- [ ] 所有组件来自白名单
|
|
91
|
+
- [ ] 所有 API 来白名单且在 features 中声明
|
|
92
|
+
- [ ] 无第三方依赖(package.json 检查)
|
|
93
|
+
- [ ] 无 console.log(使用 console.error 记录错误除外)
|
|
94
|
+
- [ ] 所有 fetch/API 调用有 fail 处理
|
|
95
|
+
- [ ] 所有定时器在 onDestroy 中清理
|
|
96
|
+
- [ ] 路由配置与实际页面文件一致
|
|
97
|
+
- [ ] .ux 文件 template 只有一个根节点
|
|
98
|
+
- [ ] 圆屏安全区域已应用
|
|
99
|
+
- [ ] CSS 仅使用 class 选择器(无元素/ID/后代/伪类选择器)
|
|
100
|
+
- [ ] CSS 无嵌套写法(扁平结构)
|
|
101
|
+
- [ ] CSS 无 Less/Sass/SCSS 语法
|
|
102
|
+
- [ ] class 命名符合 kebab-case 规范
|
|
103
|
+
- [ ] 用户提供设计稿时,已通过 MCP 获取设计稿节点数据
|
|
104
|
+
- [ ] 组件结构与设计稿层级一致
|
|
105
|
+
- [ ] 颜色、字号、间距与设计稿一致
|
|
106
|
+
- [ ] 所有静态资源已从设计稿导出到 `src/common/images/` 对应子目录
|
|
107
|
+
- [ ] 图片资源命名符合规范,无 placeholder 或外部 URL
|
|
108
|
+
- [ ] Mock 数据使用本地图片路径
|
|
109
|
+
- [ ] 页面视觉还原度与 UI 稿一致
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"enabled": true,
|
|
3
|
+
"name": "Figma Design Comparison Check",
|
|
4
|
+
"description": "After writing .ux page files, automatically compare the generated code against the Figma design to verify: layout structure matches, colors/fonts/sizes are correct, image assets are properly exported and referenced, and no SVG files are used (Vela doesn't support SVG).",
|
|
5
|
+
"version": "1",
|
|
6
|
+
"when": {
|
|
7
|
+
"type": "postToolUse",
|
|
8
|
+
"toolTypes": ["write"]
|
|
9
|
+
},
|
|
10
|
+
"then": {
|
|
11
|
+
"type": "askAgent",
|
|
12
|
+
"prompt": "If a .ux file was just written/modified AND there is a Figma design context available in this conversation, perform a design fidelity check:\n\n1. **Layout Match**: Compare the generated layout structure (flex-direction, alignment, spacing) against the Figma node structure. Check that container hierarchy matches.\n\n2. **Dimensions Check**: Verify key element dimensions (width, height, border-radius, padding, margin) match the Figma design values. All list items and cards should use FIXED width/height from the design, not percentage-based.\n\n3. **Color & Typography**: Confirm colors (#hex values), font-size, font-weight match the design tokens extracted from Figma.\n\n4. **Image Assets**: Check that:\n - All image references in the .ux file point to existing files in src/common/\n - NO SVG files are referenced (Vela doesn't support SVG, use PNG only)\n - Image files are valid PNG format and reasonable size (<200KB for icons)\n - Icons from Figma have been exported and downloaded as PNG\n\n5. **Scroll Container**: If the page content exceeds one screen, verify:\n - Root element is <scroll scroll-y=\"true\">\n - Inner container has explicit width: 100% and a fixed height value large enough for content\n\n6. **Safe Area**: For watch screens, verify padding accounts for circular screen safe area (top/bottom ~50px, left/right ~24-36px).\n\nReport any mismatches found. If no Figma context is available or the file is not a .ux file, skip this check silently."
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"enabled": true,
|
|
3
|
+
"name": "Post-Coding Quality Validation",
|
|
4
|
+
"description": "After S3 coding task completes, automatically run a quality validation check on the generated code to verify manifest routes match page files, image references exist, and API imports match feature declarations.",
|
|
5
|
+
"version": "1",
|
|
6
|
+
"when": {
|
|
7
|
+
"type": "postTaskExecution"
|
|
8
|
+
},
|
|
9
|
+
"then": {
|
|
10
|
+
"type": "askAgent",
|
|
11
|
+
"prompt": "Run a quality validation on the generated code: 1) Check manifest.json router.pages entries match actual page files in src/pages/ 2) Check all image paths referenced in .ux files exist in src/common/images/ 3) Check all @system.xxx imports have corresponding entries in manifest.json features array. Report results as a checklist."
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"enabled": true,
|
|
3
|
+
"name": "Validate UX Files on Save",
|
|
4
|
+
"description": "When a .ux file is saved, automatically check for common syntax issues like unclosed tags, missing imports, and invalid component references.",
|
|
5
|
+
"version": "1",
|
|
6
|
+
"when": {
|
|
7
|
+
"type": "fileEdited",
|
|
8
|
+
"patterns": [
|
|
9
|
+
"**/*.ux"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"then": {
|
|
13
|
+
"type": "askAgent",
|
|
14
|
+
"prompt": "Check the saved .ux file for common Vela quick app issues: 1) Unclosed template tags 2) Missing @system imports that are used in the script 3) list-item components missing the required 'type' attribute 4) Image src paths referencing non-existent files. Report any issues found concisely."
|
|
15
|
+
}
|
|
16
|
+
}
|