deveco-harness 0.1.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.en.md +71 -0
- package/README.md +71 -0
- package/deveco-harness.example.jsonc +32 -0
- package/dist/index.js +758 -0
- package/package.json +48 -0
- package/prompts/build.txt +164 -0
- package/prompts/plan.txt +118 -0
- package/skills/arkts-error-fixes/README.md +151 -0
- package/skills/arkts-error-fixes/SKILL.md +150 -0
- package/skills/arkts-error-fixes/assets/AnyTypeError.ets +269 -0
- package/skills/arkts-error-fixes/assets/AppStorageError.ets +22 -0
- package/skills/arkts-error-fixes/assets/ArrowFunctionConversionError.ets +42 -0
- package/skills/arkts-error-fixes/assets/AvoidAreaTypeError.ets +43 -0
- package/skills/arkts-error-fixes/assets/BreakpointTypeError.ets +71 -0
- package/skills/arkts-error-fixes/assets/CatchClauseTypeError.ets +54 -0
- package/skills/arkts-error-fixes/assets/ColorConsistencyError.ets +88 -0
- package/skills/arkts-error-fixes/assets/ColorPropertyError.ets +39 -0
- package/skills/arkts-error-fixes/assets/ContextTypeError.ets +105 -0
- package/skills/arkts-error-fixes/assets/DecoratorStateError.ets +64 -0
- package/skills/arkts-error-fixes/assets/DisplayListenerTypeError.ets +129 -0
- package/skills/arkts-error-fixes/assets/DuplicateEntryError.ets +35 -0
- package/skills/arkts-error-fixes/assets/ESObjectTypeError.ets +137 -0
- package/skills/arkts-error-fixes/assets/FontColorPropertyError.ets +42 -0
- package/skills/arkts-error-fixes/assets/FunctionReturnTypeError.ets +41 -0
- package/skills/arkts-error-fixes/assets/IDataSourceError.ets +79 -0
- package/skills/arkts-error-fixes/assets/ImplementationNotAllowedError.ets +38 -0
- package/skills/arkts-error-fixes/assets/InterfaceMethodSignatureError.ets +43 -0
- package/skills/arkts-error-fixes/assets/NotificationError.ets +34 -0
- package/skills/arkts-error-fixes/assets/ObjectLiteralInterfaceError.ets +49 -0
- package/skills/arkts-error-fixes/assets/ObjectLiteralTypeError.ets +54 -0
- package/skills/arkts-error-fixes/assets/ObjectSpreadError.ets +29 -0
- package/skills/arkts-error-fixes/assets/PossiblyNullError.ets +32 -0
- package/skills/arkts-error-fixes/assets/ResourceConversionError.ets +159 -0
- package/skills/arkts-error-fixes/assets/StandaloneFunctionContext.ets +116 -0
- package/skills/arkts-error-fixes/assets/StandaloneFunctionError.ets +85 -0
- package/skills/arkts-error-fixes/assets/StorageLinkDefaultError.ets +41 -0
- package/skills/arkts-error-fixes/assets/TitleButtonRectTypeError.ets +86 -0
- package/skills/arkts-error-fixes/assets/UnusedVariableWarning.ets +102 -0
- package/skills/arkts-error-fixes/assets/UtilityTypeError.ets +176 -0
- package/skills/arkts-error-fixes/assets/WindowRectSizeError.ets +65 -0
- package/skills/arkts-error-fixes/assets/WindowTypeError.ets +37 -0
- package/skills/arkts-error-fixes/reference/any_type_errors.md +433 -0
- package/skills/arkts-error-fixes/reference/appstorage_errors.md +95 -0
- package/skills/arkts-error-fixes/reference/arrow_function_conversion_errors.md +163 -0
- package/skills/arkts-error-fixes/reference/avoid_area_type_errors.md +59 -0
- package/skills/arkts-error-fixes/reference/breakpoint_type_errors.md +122 -0
- package/skills/arkts-error-fixes/reference/catch_clause_type_errors.md +89 -0
- package/skills/arkts-error-fixes/reference/color_consistency_errors.md +209 -0
- package/skills/arkts-error-fixes/reference/color_property_errors.md +136 -0
- package/skills/arkts-error-fixes/reference/context_type_errors.md +260 -0
- package/skills/arkts-error-fixes/reference/decorator_state_errors.md +109 -0
- package/skills/arkts-error-fixes/reference/display_listener_type_errors.md +149 -0
- package/skills/arkts-error-fixes/reference/duplicate_entry_errors.md +193 -0
- package/skills/arkts-error-fixes/reference/esobject_type_errors.md +110 -0
- package/skills/arkts-error-fixes/reference/fontcolor_property_errors.md +104 -0
- package/skills/arkts-error-fixes/reference/function_return_type_errors.md +194 -0
- package/skills/arkts-error-fixes/reference/idata_source_errors.md +77 -0
- package/skills/arkts-error-fixes/reference/implementation_not_allowed_errors.md +191 -0
- package/skills/arkts-error-fixes/reference/interface_method_signature_errors.md +143 -0
- package/skills/arkts-error-fixes/reference/notification_errors.md +110 -0
- package/skills/arkts-error-fixes/reference/object_literal_interface_errors.md +156 -0
- package/skills/arkts-error-fixes/reference/object_literal_type_errors.md +110 -0
- package/skills/arkts-error-fixes/reference/object_spread_errors.md +105 -0
- package/skills/arkts-error-fixes/reference/possibly_null_errors.md +156 -0
- package/skills/arkts-error-fixes/reference/resource_conversion_errors.md +154 -0
- package/skills/arkts-error-fixes/reference/standalone_function_errors.md +68 -0
- package/skills/arkts-error-fixes/reference/storage_link_default_errors.md +124 -0
- package/skills/arkts-error-fixes/reference/title_button_rect_type_errors.md +167 -0
- package/skills/arkts-error-fixes/reference/unused_variable_warnings.md +295 -0
- package/skills/arkts-error-fixes/reference/utility_type_errors.md +290 -0
- package/skills/arkts-error-fixes/reference/window_rect_size_errors.md +70 -0
- package/skills/arkts-error-fixes/reference/window_type_errors.md +95 -0
- package/skills/arkts-grammar-standards/SKILL.md +71 -0
- package/skills/arkts-grammar-standards/references/basic-syntax.md +103 -0
- package/skills/arkts-grammar-standards/references/restrictions.md +100 -0
- package/skills/arkts-grammar-standards/references/topic-aliases.json +93 -0
- package/skills/arkts-grammar-standards/references/ts-diff.md +108 -0
- package/skills/arkts-runtime-fix/SKILL.md +152 -0
- package/skills/arkts-runtime-fix/SKILL_CN.md +123 -0
- package/skills/arkts-runtime-fix/evals/evals.json +17 -0
- package/skills/arkts-runtime-fix/scripts/collect-hilog.mjs +116 -0
- package/skills/arkts-runtime-fix/scripts/collect-hilog.ts +115 -0
- package/skills/arkts-runtime-fix/scripts/fetch-faultlog.mjs +117 -0
- package/skills/arkts-runtime-fix/scripts/fetch-faultlog.ts +116 -0
- package/skills/arkts-runtime-fix/scripts/jscrash-report.mjs +149 -0
- package/skills/arkts-runtime-fix/scripts/parse-jscrash-log.mjs +126 -0
- package/skills/arkts-runtime-fix/scripts/parse-jscrash-log.ts +126 -0
- package/skills/arkts-runtime-fix/scripts/probe-faultlogger.mjs +160 -0
- package/skills/arkts-runtime-fix/scripts/probe-faultlogger.ts +160 -0
- package/skills/arkts-runtime-fix/scripts/shared/hdc.mjs +107 -0
- package/skills/arkts-runtime-fix/scripts/shared/hdc.ts +58 -0
- package/skills/arkts-runtime-fix/scripts/shared/jscrash-faultlogger.mjs +143 -0
- package/skills/arkts-runtime-fix/scripts/shared/jscrash-faultlogger.ts +148 -0
- package/skills/arkts-runtime-fix/scripts/shared/jscrash-parse.mjs +389 -0
- package/skills/arkts-runtime-fix/scripts/shared/jscrash-parse.ts +409 -0
- package/skills/arkts-runtime-fix/scripts/shared/utils.mjs +27 -0
- package/skills/arkts-runtime-fix/scripts/shared/utils.ts +27 -0
- package/skills/arkui-knowledge/SKILL.md +90 -0
- package/skills/arkui-knowledge/references/api-guardrails.md +60 -0
- package/skills/arkui-knowledge/references/common-mistakes.md +119 -0
- package/skills/arkui-knowledge/references/component-cookbook.md +135 -0
- package/skills/arkui-knowledge/references/ui-quality-checklist.md +36 -0
- package/skills/deveco-create-project/SKILL.md +144 -0
- package/skills/deveco-create-project/application/AppScope/app.json5 +10 -0
- package/skills/deveco-create-project/application/AppScope/resources/base/element/string.json +8 -0
- package/skills/deveco-create-project/application/AppScope/resources/base/media/background.png +0 -0
- package/skills/deveco-create-project/application/AppScope/resources/base/media/foreground.png +0 -0
- package/skills/deveco-create-project/application/AppScope/resources/base/media/layered_image.json +7 -0
- package/skills/deveco-create-project/application/build-profile.json5 +42 -0
- package/skills/deveco-create-project/application/code-linter.json5 +32 -0
- package/skills/deveco-create-project/application/entry/build-profile.json5 +33 -0
- package/skills/deveco-create-project/application/entry/hvigorfile.ts +7 -0
- package/skills/deveco-create-project/application/entry/obfuscation-rules.txt +23 -0
- package/skills/deveco-create-project/application/entry/oh-package.json5 +10 -0
- package/skills/deveco-create-project/application/entry/src/main/ets/entryability/EntryAbility.ets +63 -0
- package/skills/deveco-create-project/application/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +31 -0
- package/skills/deveco-create-project/application/entry/src/main/ets/pages/Index.ets +38 -0
- package/skills/deveco-create-project/application/entry/src/main/module.json5 +50 -0
- package/skills/deveco-create-project/application/entry/src/main/resources/base/element/color.json +8 -0
- package/skills/deveco-create-project/application/entry/src/main/resources/base/element/float.json +8 -0
- package/skills/deveco-create-project/application/entry/src/main/resources/base/element/string.json +16 -0
- package/skills/deveco-create-project/application/entry/src/main/resources/base/media/background.png +0 -0
- package/skills/deveco-create-project/application/entry/src/main/resources/base/media/foreground.png +0 -0
- package/skills/deveco-create-project/application/entry/src/main/resources/base/media/layered_image.json +7 -0
- package/skills/deveco-create-project/application/entry/src/main/resources/base/media/startIcon.png +0 -0
- package/skills/deveco-create-project/application/entry/src/main/resources/base/profile/backup_config.json +3 -0
- package/skills/deveco-create-project/application/entry/src/main/resources/base/profile/main_pages.json +5 -0
- package/skills/deveco-create-project/application/entry/src/main/resources/dark/element/color.json +8 -0
- package/skills/deveco-create-project/application/hvigor/hvigor-config.json5 +23 -0
- package/skills/deveco-create-project/application/hvigorfile.ts +7 -0
- package/skills/deveco-create-project/application/oh-package.json5 +10 -0
- package/skills/deveco-create-project/scripts/copy-template.mjs +216 -0
- package/skills/deveco-create-project/scripts/copy-template.ts +214 -0
- package/skills/deveco-create-project/scripts/detect-sdk.mjs +82 -0
- package/skills/deveco-create-project/scripts/detect-sdk.ts +95 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# ArkUI Common Mistakes
|
|
2
|
+
|
|
3
|
+
Check this file before implementing ArkUI tabs, lists, state decorators, dialogs, navigation, or custom builders.
|
|
4
|
+
|
|
5
|
+
## Tabs and TabContent
|
|
6
|
+
|
|
7
|
+
Avoid: passing an object parameter with a builder callback into `TabContent`.
|
|
8
|
+
|
|
9
|
+
Correct:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
TabContent() {
|
|
13
|
+
Column() {
|
|
14
|
+
Text('首页')
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
.tabBar('首页')
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Rules:
|
|
21
|
+
|
|
22
|
+
- `Tabs` direct children should be `TabContent`.
|
|
23
|
+
- `TabContent` label content belongs in `.tabBar(...)`.
|
|
24
|
+
- Do not place unrelated components directly under `Tabs`.
|
|
25
|
+
|
|
26
|
+
## ForEach and LazyForEach
|
|
27
|
+
|
|
28
|
+
Avoid: a key generator callback that opens a block but does not return the key string.
|
|
29
|
+
|
|
30
|
+
Correct:
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
ForEach(this.items, (item: ItemInfo) => {
|
|
34
|
+
Text(item.title)
|
|
35
|
+
}, (item: ItemInfo) => item.id)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Rules:
|
|
39
|
+
|
|
40
|
+
- The key generator must return a stable string.
|
|
41
|
+
- Avoid index keys for business data because item order can change.
|
|
42
|
+
- `LazyForEach` requires a real lazy data source and should be placed in supported scroll containers.
|
|
43
|
+
|
|
44
|
+
## State decorators
|
|
45
|
+
|
|
46
|
+
Avoid: placing `@State` on top-level variables, local variables, plain classes, or component inputs.
|
|
47
|
+
|
|
48
|
+
Correct:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
@Component
|
|
52
|
+
struct MessagePanel {
|
|
53
|
+
@State message: string = ''
|
|
54
|
+
|
|
55
|
+
build() {
|
|
56
|
+
Text(this.message)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Rules:
|
|
62
|
+
|
|
63
|
+
- State decorators belong on component member declarations.
|
|
64
|
+
- `@State` is for component-local V1 state.
|
|
65
|
+
- `@Prop` is for parent-to-child input.
|
|
66
|
+
- `@Link` is for two-way binding in V1 components.
|
|
67
|
+
- `@Local` and `@Param` belong to V2 components.
|
|
68
|
+
- Do not mix V1 and V2 decorator families in one component.
|
|
69
|
+
|
|
70
|
+
## Component attributes
|
|
71
|
+
|
|
72
|
+
Avoid: shorthand modifier names borrowed from other UI systems.
|
|
73
|
+
|
|
74
|
+
Correct:
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
Text('标题')
|
|
78
|
+
.backgroundColor('#FFFFFF')
|
|
79
|
+
.fontSize(16)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Rules:
|
|
83
|
+
|
|
84
|
+
- Use real ArkUI modifier names.
|
|
85
|
+
- Match modifiers to the component that owns them.
|
|
86
|
+
- Do not borrow CSS, Android, other UI framework, or web shorthand.
|
|
87
|
+
|
|
88
|
+
## Dialog buttons
|
|
89
|
+
|
|
90
|
+
Avoid: alert dialog button entries that use a label field named `text`.
|
|
91
|
+
|
|
92
|
+
Correct:
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
AlertDialog.show({
|
|
96
|
+
message: '确认删除?',
|
|
97
|
+
primaryButton: { value: '确定', action: () => {} }
|
|
98
|
+
})
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Rules:
|
|
102
|
+
|
|
103
|
+
- Alert dialog button label field is `value`.
|
|
104
|
+
- Keep cancel behavior limited to closing the dialog unless the requirement says otherwise.
|
|
105
|
+
- Follow the current project dialog or toast wrapper when one exists.
|
|
106
|
+
|
|
107
|
+
## UI visibility and interaction
|
|
108
|
+
|
|
109
|
+
Common failures:
|
|
110
|
+
|
|
111
|
+
- Required text is rendered under an overlay.
|
|
112
|
+
- Clickable text is used when the requirement requires `Button`.
|
|
113
|
+
- A tab label exists in code but is not visible on the tab bar.
|
|
114
|
+
- State changes happen in code but the updated text is not rendered.
|
|
115
|
+
- New UI is added outside the current launch page or reachable navigation path.
|
|
116
|
+
|
|
117
|
+
Guardrail:
|
|
118
|
+
|
|
119
|
+
- After writing UI, trace the visible path from the launch page to each required element and each required click result.
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# ArkUI Component Cookbook
|
|
2
|
+
|
|
3
|
+
This file keeps high-frequency ArkUI patterns close to the `arkui-knowledge` skill. Prefer project-local code style, but use these shapes to avoid common API mistakes.
|
|
4
|
+
|
|
5
|
+
## Tabs and TabContent
|
|
6
|
+
|
|
7
|
+
Use `Tabs` for tabbed pages. Direct children should be `TabContent`.
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
Tabs({ barPosition: BarPosition.End }) {
|
|
11
|
+
TabContent() {
|
|
12
|
+
Column() {
|
|
13
|
+
Text('首页')
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
.tabBar('首页')
|
|
17
|
+
|
|
18
|
+
TabContent() {
|
|
19
|
+
Column() {
|
|
20
|
+
Text('发现')
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
.tabBar('发现')
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Key rules:
|
|
28
|
+
|
|
29
|
+
- `TabContent()` has no object parameter.
|
|
30
|
+
- Put tab label content in `.tabBar(...)`.
|
|
31
|
+
- Keep each tab body inside the `TabContent` block.
|
|
32
|
+
- Use `.onChange((index: number) => { ... })` when selected tab state must refresh other UI.
|
|
33
|
+
|
|
34
|
+
## List, Grid, and ForEach
|
|
35
|
+
|
|
36
|
+
Use `ForEach` for ordinary in-memory arrays and small lists.
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
interface CardItem {
|
|
40
|
+
id: string
|
|
41
|
+
title: string
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@State cards: CardItem[] = [
|
|
45
|
+
{ id: 'card-1', title: '卡片 1' },
|
|
46
|
+
{ id: 'card-2', title: '卡片 2' }
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
Grid() {
|
|
50
|
+
ForEach(this.cards, (item: CardItem) => {
|
|
51
|
+
GridItem() {
|
|
52
|
+
Text(item.title)
|
|
53
|
+
}
|
|
54
|
+
}, (item: CardItem) => item.id)
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Key rules:
|
|
59
|
+
|
|
60
|
+
- The key function returns a stable string.
|
|
61
|
+
- Do not use a key callback that returns no value.
|
|
62
|
+
- Use `ListItem` inside `List`.
|
|
63
|
+
- Use `GridItem` inside `Grid`.
|
|
64
|
+
- Use `LazyForEach` only with a proper data source when lazy rendering is needed.
|
|
65
|
+
|
|
66
|
+
## TextInput, Button, and state refresh
|
|
67
|
+
|
|
68
|
+
Use state variables for user input and validation messages.
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
@State userName: string = ''
|
|
72
|
+
@State errorText: string = ''
|
|
73
|
+
|
|
74
|
+
Column({ space: 12 }) {
|
|
75
|
+
TextInput({ placeholder: '请输入用户名', text: this.userName })
|
|
76
|
+
.onChange((value: string) => {
|
|
77
|
+
this.userName = value
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
Button('注册')
|
|
81
|
+
.onClick(() => {
|
|
82
|
+
this.errorText = this.userName.length === 0 ? '请填写完整信息' : '注册成功'
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
Text(this.errorText)
|
|
86
|
+
.fontColor(this.errorText === '注册成功' ? Color.Green : Color.Red)
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Key rules:
|
|
91
|
+
|
|
92
|
+
- State that drives visible UI should use the existing component decorator family.
|
|
93
|
+
- `TextInput` changes should update state in `.onChange(...)`.
|
|
94
|
+
- Required validation messages must be rendered in the page, not only logged.
|
|
95
|
+
|
|
96
|
+
## Dialog and Toast
|
|
97
|
+
|
|
98
|
+
For simple confirmation, use alert dialog APIs already used by the project. Button entries use `value` for the visible label.
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
this.getUIContext().showAlertDialog({
|
|
102
|
+
title: '确认进入订座?',
|
|
103
|
+
message: '确认进入订座?',
|
|
104
|
+
primaryButton: {
|
|
105
|
+
value: '去订座',
|
|
106
|
+
action: () => {
|
|
107
|
+
this.getUIContext().getPromptAction().showToast({ message: '已打开订座' })
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
secondaryButton: {
|
|
111
|
+
value: '再想想',
|
|
112
|
+
action: () => {}
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Key rules:
|
|
118
|
+
|
|
119
|
+
- Use `value` for alert dialog button text.
|
|
120
|
+
- Do not invent `text` fields for alert dialog buttons.
|
|
121
|
+
- Prefer the project's current dialog/toast pattern when it already exists.
|
|
122
|
+
- Keep cancel actions side-effect free when the requirement says cancel only closes the dialog.
|
|
123
|
+
|
|
124
|
+
## Navigation and NavDestination
|
|
125
|
+
|
|
126
|
+
Follow the existing navigation architecture. Do not replace project routing only to add one page.
|
|
127
|
+
|
|
128
|
+
For projects already using `Navigation`, register or route to `NavDestination` through the existing `NavPathStack` or project router wrapper. For projects using a custom app router, follow that wrapper and existing page registration pattern.
|
|
129
|
+
|
|
130
|
+
Key rules:
|
|
131
|
+
|
|
132
|
+
- Preserve the existing navigation mechanism.
|
|
133
|
+
- Keep page names and builder exports consistent with nearby pages.
|
|
134
|
+
- Pass only the parameters required by the target page.
|
|
135
|
+
- Verify the first visible screen and the new navigation path.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# ArkUI UI Quality Checklist
|
|
2
|
+
|
|
3
|
+
Use this checklist before finalizing ArkUI UI changes.
|
|
4
|
+
|
|
5
|
+
## Requirement visibility
|
|
6
|
+
|
|
7
|
+
- Required labels, button text, tab labels, card titles, and dialog text appear on the target screen.
|
|
8
|
+
- Text is not hidden by overlays, zero-size containers, off-screen placement, or low contrast.
|
|
9
|
+
- The first screen remains reachable from the app launch path.
|
|
10
|
+
|
|
11
|
+
## Interaction
|
|
12
|
+
|
|
13
|
+
- Required buttons use `Button` when the requirement asks for `Button`.
|
|
14
|
+
- Click handlers update visible state, switch tabs, open dialogs, navigate, or show the requested response.
|
|
15
|
+
- Cancel and close actions do not perform extra business actions.
|
|
16
|
+
- Required click targets remain large enough and visually clear.
|
|
17
|
+
|
|
18
|
+
## Layout quality
|
|
19
|
+
|
|
20
|
+
- New UI follows nearby spacing, color, typography, density, and component style.
|
|
21
|
+
- Layout nesting is only deep enough to express the UI.
|
|
22
|
+
- Dynamic text, lists, and tab content have stable width/height constraints where needed.
|
|
23
|
+
- New elements do not overlap existing banners, cards, bottom bars, or system safe areas.
|
|
24
|
+
|
|
25
|
+
## State and rendering
|
|
26
|
+
|
|
27
|
+
- UI-driving state uses the current component's decorator family.
|
|
28
|
+
- Lists and grids render stable keys.
|
|
29
|
+
- Conditional UI still leaves required content reachable.
|
|
30
|
+
- Dialog, toast, and navigation code follows existing project patterns.
|
|
31
|
+
|
|
32
|
+
## Change scope
|
|
33
|
+
|
|
34
|
+
- Only files required by the UI task are modified.
|
|
35
|
+
- Existing business flow, page registration, resource naming, and navigation architecture are preserved.
|
|
36
|
+
- No state-management migration, navigation rewrite, or broad refactor is introduced without an explicit request.
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deveco-create-project
|
|
3
|
+
description: Load this skill when creating, initializing, or scaffolding an ArkTS project, including "0-1", "from scratch", "new ArkTS project", "新建工程", "创建项目", and empty directory initialization tasks. Load this skill even if the target directory already exists — never assume an existing same-named directory is the user's intended project and skip to build_project/start_app. If the user provides a Chinese or other non-ASCII project name (e.g. 购物车, 天气预报), you MUST propose 2-3 UpperCamelCase ASCII candidates (e.g. 购物车 → ShoppingCart / ShopCart / Cart) and let the user choose via AskUserQuestion BEFORE invoking the script — never pass non-ASCII names through to the script, and never pick a single translation on the user's behalf. Use the skill's private TypeScript script to create ArkTS projects reliably.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# deveco-create-project
|
|
7
|
+
|
|
8
|
+
Use the skill's private script to create an ArkTS project, instead of relying on the model to copy template files one by one.
|
|
9
|
+
|
|
10
|
+
## Required Parameters
|
|
11
|
+
|
|
12
|
+
Confirm the following parameters before execution. Ask the user if any required value is missing:
|
|
13
|
+
|
|
14
|
+
| Parameter | Required | Default | Example |
|
|
15
|
+
|------|---------|--------|------|
|
|
16
|
+
| `projectPath` | Required | — | `/Users/yellow/Desktop/projects` |
|
|
17
|
+
| `appName` | Required | — | `HelloWorld` |
|
|
18
|
+
| `bundleName` | Auto-derived, no need to ask | `com.example.{appName lowercase}` | `com.example.helloworld` |
|
|
19
|
+
| `apiLevel` | Optional | Auto-detect from DevEco SDK metadata, fallback to `22` | `21` |
|
|
20
|
+
|
|
21
|
+
### appName rules
|
|
22
|
+
|
|
23
|
+
`appName` must match `^[A-Za-z][A-Za-z0-9_]{0,127}$`. Chinese / non-ASCII names are NOT allowed — the script will reject them (exit code `4`, `APP_NAME_INVALID`).
|
|
24
|
+
|
|
25
|
+
When the user provides a Chinese or other non-ASCII name, you MUST:
|
|
26
|
+
1. Propose 2-3 UpperCamelCase ASCII candidates based on meaning (e.g. `购物车` → `ShoppingCart` / `ShopCart` / `Cart`; `天气预报` → `WeatherForecast` / `Weather` / `Forecast`). Fall back to pinyin only when meaning is unclear.
|
|
27
|
+
2. Let the user pick one via `AskUserQuestion` before invoking the script — do NOT pick on the user's behalf, even if one option seems obviously best.
|
|
28
|
+
3. Never pass the original non-ASCII name to the script.
|
|
29
|
+
|
|
30
|
+
### Target directory conflict
|
|
31
|
+
|
|
32
|
+
If `{projectPath}/{appName}` already exists and is not empty, the script will exit with code `2` and emit a `PROJECT_EXISTS` JSON payload. When you see it, ask the user via `AskUserQuestion` whether to overwrite, rename, or cancel — do NOT silently re-run or delete the directory yourself.
|
|
33
|
+
|
|
34
|
+
If the user explicitly specifies an SDK/API level, pass it through directly.
|
|
35
|
+
If the user does not specify one, do not let the model invent a version. Let the script detect it using this fixed priority:
|
|
36
|
+
|
|
37
|
+
1. `DEVECO_HOME/sdk/default/sdk-pkg.json` → `data` → `apiVersion`
|
|
38
|
+
2. fallback to `22`
|
|
39
|
+
|
|
40
|
+
The script's stdout JSON (`apiLevel`, `source`, `detectedFrom`) is authoritative — do not re-read files under `{DEVECO_HOME}/sdk/**` to verify it.
|
|
41
|
+
|
|
42
|
+
### Optional: Brief Requirement Checklist for Complex App Requests
|
|
43
|
+
|
|
44
|
+
If the current session is already executing an approved Plan Mode plan or an existing plan file is referenced, do not create another plan, do not call `plan_enter` or `plan_write`, and do not ask for plan approval again. Treat the existing plan as the source of truth.
|
|
45
|
+
|
|
46
|
+
If there is no existing approved plan and the user asks to create a new project with a complex app requirement, make a brief requirement checklist before copying or editing files.
|
|
47
|
+
|
|
48
|
+
The checklist must list:
|
|
49
|
+
- pages to implement
|
|
50
|
+
- the first screen / entry page
|
|
51
|
+
- navigation between pages
|
|
52
|
+
- key feature points for each page
|
|
53
|
+
- verification points for pages and navigation
|
|
54
|
+
|
|
55
|
+
Keep this checklist concise and continue automatically unless required project parameters are missing or the requirement is contradictory.
|
|
56
|
+
Do not expand this skill into ArkUI design guidance; load `arkui-knowledge` before implementing UI code.
|
|
57
|
+
|
|
58
|
+
## Execution Steps
|
|
59
|
+
|
|
60
|
+
> `copy-template.mjs` reads the sibling skill directory `deveco-create-project/application/` as the template source by default.
|
|
61
|
+
> This script runs with Node.js. If `node` is not available in the environment, stop immediately and explain that to the user.
|
|
62
|
+
> Default skills are extracted to a local user skill directory before execution. Keep all scripts in this skill self-contained and do not import repo-only source files.
|
|
63
|
+
|
|
64
|
+
### Step 1: Run the Private Script
|
|
65
|
+
|
|
66
|
+
Run the following with Shell:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
node "{SKILL_DIR}/scripts/copy-template.mjs" --project-path "{projectPath}" --app-name "{appName}" --bundle-name "{bundleName}" --api-level "{apiLevel}"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
If `apiLevel` is not explicitly provided by the user, omit `--api-level` and let the script detect it from DevEco metadata.
|
|
73
|
+
|
|
74
|
+
Execution requirements:
|
|
75
|
+
|
|
76
|
+
- Do not manually copy template files one by one.
|
|
77
|
+
- Let the script handle recursive copying, binary asset copying, placeholder replacement, and basic validation.
|
|
78
|
+
- The script is responsible for SDK detection. Do not decide the SDK version in the prompt by guesswork.
|
|
79
|
+
- If the script exits with a non-zero code, report the error to the user and stop.
|
|
80
|
+
|
|
81
|
+
### Step 2: Verify the Result
|
|
82
|
+
|
|
83
|
+
At minimum, verify that the following file exists:
|
|
84
|
+
|
|
85
|
+
- `{projectPath}/{appName}/build-profile.json5`
|
|
86
|
+
|
|
87
|
+
If the file is missing, treat the creation as failed and do not proceed to later compile or page-generation steps.
|
|
88
|
+
|
|
89
|
+
If the script reports `source: "fallback"`, the local SDK metadata is incomplete — deliver the project path, warn the user (e.g. "Find no sdk-pkg.json, can not probe sdk version").
|
|
90
|
+
|
|
91
|
+
### Step 3: Switch Session Project Context (Required)
|
|
92
|
+
|
|
93
|
+
After project creation succeeds, call `switch_cwd` and set the target path to the generated project root (`{projectPath}/{appName}`).
|
|
94
|
+
|
|
95
|
+
Reason:
|
|
96
|
+
|
|
97
|
+
- `build_project` and `start_app` only work correctly when the current session context directory is the actual project root.
|
|
98
|
+
- This skill creates a full project under the current path; without switching context to that generated path, subsequent build/run actions may fail or target the wrong directory.
|
|
99
|
+
|
|
100
|
+
If `switch_cwd` fails, report the context switch failure and stop. Do not continue to feature implementation, `build_project`, or `start_app`.
|
|
101
|
+
|
|
102
|
+
### Step 4: Continue Feature Work in the Generated Project
|
|
103
|
+
|
|
104
|
+
If the user's request includes app behavior, UI, pages, or business requirements in addition to project creation, continue only after `switch_cwd` succeeds.
|
|
105
|
+
|
|
106
|
+
Before implementing the feature:
|
|
107
|
+
|
|
108
|
+
- Read `entry/src/main/resources/base/profile/main_pages.json` to identify the launch page list.
|
|
109
|
+
- Read the launch page file, usually `entry/src/main/ets/pages/Index.ets` and `entry/src/main/ets/entryability/EntryAbility.ets`.
|
|
110
|
+
- Modify the actual launch page or its navigation path so the requested feature is reachable from the first screen.
|
|
111
|
+
|
|
112
|
+
> **CRITICAL: `EntryAbility.ets` and `main_pages.json` must stay in sync.**
|
|
113
|
+
>
|
|
114
|
+
> `EntryAbility.ets` calls `windowStage.loadContent('pages/SomePage', ...)` to load the first screen.
|
|
115
|
+
> That page path **must** appear in `main_pages.json`'s `src` array — otherwise the framework silently fails to load the page, resulting in a **white screen**.
|
|
116
|
+
>
|
|
117
|
+
> When you create custom pages and update `main_pages.json`, you **must** also update `EntryAbility.ets`:
|
|
118
|
+
> - If you **rename or replace** the first entry in `main_pages.json`, update `loadContent()` to match the new first page.
|
|
119
|
+
> - If you **prepend** a new splash/landing page to `main_pages.json`, update `loadContent()` to point to that page.
|
|
120
|
+
>
|
|
121
|
+
> Always re-read both files after editing to confirm they are consistent.
|
|
122
|
+
|
|
123
|
+
- Do not finish by only creating a new named page/component unless the launch page routes to it.
|
|
124
|
+
|
|
125
|
+
> **CRITICAL: Desktop app name — both `app_name` and `EntryAbility_label` must be updated.**
|
|
126
|
+
>
|
|
127
|
+
> The desktop icon label is controlled by `EntryAbility_label`, not `app_name`:
|
|
128
|
+
> - `AppScope/resources/base/element/string.json` → `app_name` — used as the **application-level** label (settings, etc.).
|
|
129
|
+
> - `entry/src/main/resources/base/element/string.json` → `EntryAbility_label` — used as the **Ability-level** label (**this is what appears on the desktop icon**).
|
|
130
|
+
|
|
131
|
+
- After changes, run `build_project`; if it succeeds, run `start_app`.
|
|
132
|
+
|
|
133
|
+
### Step 5: Report Back to the User
|
|
134
|
+
|
|
135
|
+
Report after all requested creation, implementation, build, run, and verification work is complete, or immediately when a blocking failure stops the flow.
|
|
136
|
+
|
|
137
|
+
Output:
|
|
138
|
+
|
|
139
|
+
- The absolute project path
|
|
140
|
+
- App name / bundle name / API Level
|
|
141
|
+
- `source` of the selected API level: `user_input` / `sdk_pkg` / `fallback`
|
|
142
|
+
- Whether the template integrity check passed
|
|
143
|
+
- Whether `switch_cwd` succeeded
|
|
144
|
+
- Build/run/verification status when feature work was requested
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"app": {
|
|
3
|
+
"signingConfigs": [],
|
|
4
|
+
"products": [
|
|
5
|
+
{
|
|
6
|
+
"name": "default",
|
|
7
|
+
"signingConfig": "default",
|
|
8
|
+
"targetSdkVersion": "6.0.2(22)",
|
|
9
|
+
"compatibleSdkVersion": "6.0.2(22)",
|
|
10
|
+
"runtimeOS": "HarmonyOS",
|
|
11
|
+
"buildOption": {
|
|
12
|
+
"strictMode": {
|
|
13
|
+
"caseSensitiveCheck": true,
|
|
14
|
+
"useNormalizedOHMUrl": true
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"buildModeSet": [
|
|
20
|
+
{
|
|
21
|
+
"name": "debug",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "release"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"modules": [
|
|
29
|
+
{
|
|
30
|
+
"name": "entry",
|
|
31
|
+
"srcPath": "./entry",
|
|
32
|
+
"targets": [
|
|
33
|
+
{
|
|
34
|
+
"name": "default",
|
|
35
|
+
"applyToProducts": [
|
|
36
|
+
"default"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files": [
|
|
3
|
+
"**/*.ets"
|
|
4
|
+
],
|
|
5
|
+
"ignore": [
|
|
6
|
+
"**/src/ohosTest/**/*",
|
|
7
|
+
"**/src/test/**/*",
|
|
8
|
+
"**/src/mock/**/*",
|
|
9
|
+
"**/node_modules/**/*",
|
|
10
|
+
"**/oh_modules/**/*",
|
|
11
|
+
"**/build/**/*",
|
|
12
|
+
"**/.preview/**/*"
|
|
13
|
+
],
|
|
14
|
+
"ruleSet": [
|
|
15
|
+
"plugin:@performance/recommended",
|
|
16
|
+
"plugin:@typescript-eslint/recommended"
|
|
17
|
+
],
|
|
18
|
+
"rules": {
|
|
19
|
+
"@security/no-unsafe-aes": "error",
|
|
20
|
+
"@security/no-unsafe-hash": "error",
|
|
21
|
+
"@security/no-unsafe-mac": "warn",
|
|
22
|
+
"@security/no-unsafe-dh": "error",
|
|
23
|
+
"@security/no-unsafe-dsa": "error",
|
|
24
|
+
"@security/no-unsafe-ecdsa": "error",
|
|
25
|
+
"@security/no-unsafe-rsa-encrypt": "error",
|
|
26
|
+
"@security/no-unsafe-rsa-sign": "error",
|
|
27
|
+
"@security/no-unsafe-rsa-key": "error",
|
|
28
|
+
"@security/no-unsafe-dsa-key": "error",
|
|
29
|
+
"@security/no-unsafe-dh-key": "error",
|
|
30
|
+
"@security/no-unsafe-3des": "error"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"apiType": "stageMode",
|
|
3
|
+
"buildOption": {
|
|
4
|
+
"resOptions": {
|
|
5
|
+
"copyCodeResource": {
|
|
6
|
+
"enable": false
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"buildOptionSet": [
|
|
11
|
+
{
|
|
12
|
+
"name": "release",
|
|
13
|
+
"arkOptions": {
|
|
14
|
+
"obfuscation": {
|
|
15
|
+
"ruleOptions": {
|
|
16
|
+
"enable": false,
|
|
17
|
+
"files": [
|
|
18
|
+
"./obfuscation-rules.txt"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
"targets": [
|
|
26
|
+
{
|
|
27
|
+
"name": "default"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "ohosTest",
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @ts-nocheck – HarmonyOS template file, only used when copied into a DevEco project
|
|
2
|
+
import { hapTasks } from '@ohos/hvigor-ohos-plugin';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
|
|
6
|
+
plugins: [] /* Custom plugin to extend the functionality of Hvigor. */
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Define project specific obfuscation rules here.
|
|
2
|
+
# You can include the obfuscation configuration files in the current module's build-profile.json5.
|
|
3
|
+
#
|
|
4
|
+
# For more details, see
|
|
5
|
+
# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/source-obfuscation
|
|
6
|
+
|
|
7
|
+
# Obfuscation options:
|
|
8
|
+
# -disable-obfuscation: disable all obfuscations
|
|
9
|
+
# -enable-property-obfuscation: obfuscate the property names
|
|
10
|
+
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
|
|
11
|
+
# -compact: remove unnecessary blank spaces and all line feeds
|
|
12
|
+
# -remove-log: remove all console.* statements
|
|
13
|
+
# -print-namecache: print the name cache that contains the mapping from the old names to new names
|
|
14
|
+
# -apply-namecache: reuse the given cache file
|
|
15
|
+
|
|
16
|
+
# Keep options:
|
|
17
|
+
# -keep-property-name: specifies property names that you want to keep
|
|
18
|
+
# -keep-global-name: specifies names that you want to keep in the global scope
|
|
19
|
+
|
|
20
|
+
-enable-property-obfuscation
|
|
21
|
+
-enable-toplevel-obfuscation
|
|
22
|
+
-enable-filename-obfuscation
|
|
23
|
+
-enable-export-obfuscation
|