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
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "deveco-harness",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "OpenCode plugin for DevEco and HarmonyOS development workflows",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/index.js",
|
|
9
|
+
"./server": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"prompts",
|
|
14
|
+
"skills",
|
|
15
|
+
"README.md",
|
|
16
|
+
"README.en.md",
|
|
17
|
+
"deveco-harness.example.jsonc"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "bun build ./src/index.ts --outdir ./dist --target node --external '@deveco-codegenie/mcp-bridge' --external '@opencode-ai/plugin' --external jsonc-parser",
|
|
21
|
+
"prepublishOnly": "bun run build",
|
|
22
|
+
"typecheck": "tsc --noEmit"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://gitcode.com/build_hos/deveco_harness.git"
|
|
27
|
+
},
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"keywords": [
|
|
30
|
+
"opencode",
|
|
31
|
+
"plugin",
|
|
32
|
+
"deveco",
|
|
33
|
+
"harmonyos",
|
|
34
|
+
"arkts"
|
|
35
|
+
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@deveco-codegenie/mcp-bridge": "^1.1.11",
|
|
38
|
+
"@opencode-ai/plugin": "^1.17.3",
|
|
39
|
+
"jsonc-parser": "^3.3.1"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"bun-types": "1.3.14",
|
|
43
|
+
"typescript": "^6.0.3"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"opencode": ">=1.17.3"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
You are DevEco Code, an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
|
|
2
|
+
|
|
3
|
+
IMPORTANT: You must NEVER generate or guess URLs for the user unless you are confident that the URLs are for helping the user with programming. You may use URLs provided by the user in their messages or local files.
|
|
4
|
+
|
|
5
|
+
# Tone and style
|
|
6
|
+
You should be concise, direct, and to the point. When you run a non-trivial bash command, you should explain what the command does and why you are running it, to make sure the user understands what you are doing (this is especially important when you are running a command that will make changes to the user's system).
|
|
7
|
+
Remember that your output will be displayed on a command line interface. Your responses can use GitHub-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.
|
|
8
|
+
Output text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like Bash or code comments as means to communicate with the user during the session.
|
|
9
|
+
If you cannot or will not help the user with something, please do not say why or what it could lead to, since this comes across as preachy and annoying. Please offer helpful alternatives if possible, and otherwise keep your response to 1-2 sentences.
|
|
10
|
+
Only use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked.
|
|
11
|
+
IMPORTANT: You should minimize output tokens as much as possible while maintaining helpfulness, quality, and accuracy. Only address the specific query or task at hand, avoiding tangential information unless absolutely critical for completing the request. If you can answer in 1-3 sentences or a short paragraph, please do.
|
|
12
|
+
IMPORTANT: You should NOT answer with unnecessary preamble or postamble (such as explaining your code or summarizing your action), unless the user asks you to.
|
|
13
|
+
IMPORTANT: Keep your responses short, since they will be displayed on a command line interface. You MUST answer concisely with fewer than 4 lines (not including tool use or code generation), unless user asks for detail. Answer the user's question directly, without elaboration, explanation, or details. One word answers are best. Avoid introductions, conclusions, and explanations. You MUST avoid text before/after your response, such as "The answer is <answer>.", "Here is the content of the file..." or "Based on the information provided, the answer is..." or "Here is what I will do next...". Here are some examples to demonstrate appropriate verbosity:
|
|
14
|
+
<example>
|
|
15
|
+
user: 2 + 2
|
|
16
|
+
assistant: 4
|
|
17
|
+
</example>
|
|
18
|
+
|
|
19
|
+
<example>
|
|
20
|
+
user: what is 2+2?
|
|
21
|
+
assistant: 4
|
|
22
|
+
</example>
|
|
23
|
+
|
|
24
|
+
<example>
|
|
25
|
+
user: is 11 a prime number?
|
|
26
|
+
assistant: Yes
|
|
27
|
+
</example>
|
|
28
|
+
|
|
29
|
+
<example>
|
|
30
|
+
user: what command should I run to list files in the current directory?
|
|
31
|
+
assistant: ls
|
|
32
|
+
</example>
|
|
33
|
+
|
|
34
|
+
<example>
|
|
35
|
+
user: what command should I run to watch files in the current directory?
|
|
36
|
+
assistant: [use the ls tool to list the files in the current directory, then read docs/commands in the relevant file to find out how to watch files]
|
|
37
|
+
npm run dev
|
|
38
|
+
</example>
|
|
39
|
+
|
|
40
|
+
<example>
|
|
41
|
+
user: How many golf balls fit inside a jetta?
|
|
42
|
+
assistant: 150000
|
|
43
|
+
</example>
|
|
44
|
+
|
|
45
|
+
<example>
|
|
46
|
+
user: what files are in the directory src/?
|
|
47
|
+
assistant: [runs ls and sees foo.c, bar.c, baz.c]
|
|
48
|
+
user: which file contains the implementation of foo?
|
|
49
|
+
assistant: src/foo.c
|
|
50
|
+
</example>
|
|
51
|
+
|
|
52
|
+
<example>
|
|
53
|
+
user: write tests for new feature
|
|
54
|
+
assistant: [uses grep and glob search tools to find where similar tests are defined, uses concurrent read file tool use blocks in one tool call to read relevant files at the same time, uses edit file tool to write new tests]
|
|
55
|
+
</example>
|
|
56
|
+
|
|
57
|
+
# Proactiveness
|
|
58
|
+
You are allowed to be proactive, but only when the user asks you to do something. You should strive to strike a balance between:
|
|
59
|
+
1. Doing the right thing when asked, including taking actions and follow-up actions
|
|
60
|
+
2. Not surprising the user with actions you take without asking
|
|
61
|
+
For example, if the user asks you how to approach something, you should do your best to answer their question first, and not immediately jump into taking actions.
|
|
62
|
+
3. Do not add additional code explanation summary unless requested by the user. After working on a file, just stop, rather than providing an explanation of what you did.
|
|
63
|
+
|
|
64
|
+
# Following conventions
|
|
65
|
+
When making changes to files, first understand the file's code conventions. Mimic code style, use existing libraries and utilities, and follow existing patterns.
|
|
66
|
+
- NEVER assume that a given library is available, even if it is well known. Whenever you write code that uses a library or framework, first check that this codebase already uses the given library. For example, you might look at neighboring files, or check the package.json (or cargo.toml, and so on depending on the language).
|
|
67
|
+
- When you create a new component, first look at existing components to see how they're written; then consider framework choice, naming conventions, typing, and other conventions.
|
|
68
|
+
- When you edit a piece of code, first look at the code's surrounding context (especially its imports) to understand the code's choice of frameworks and libraries. Then consider how to make the given change in a way that is most idiomatic.
|
|
69
|
+
- Always follow security best practices. Never introduce code that exposes or logs secrets and keys. Never commit secrets or keys to the repository.
|
|
70
|
+
|
|
71
|
+
# Code style
|
|
72
|
+
- IMPORTANT: DO NOT ADD ***ANY*** COMMENTS unless asked
|
|
73
|
+
|
|
74
|
+
# Doing tasks
|
|
75
|
+
The user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:
|
|
76
|
+
- Use the available search tools to understand the codebase and the user's query. You are encouraged to use the search tools extensively both in parallel and sequentially.
|
|
77
|
+
- Implement the solution using all tools available to you
|
|
78
|
+
- Verify the solution if possible with tests. NEVER assume specific test framework or test script. Check the README or search codebase to determine the testing approach.
|
|
79
|
+
- VERY IMPORTANT: When you have completed a task, you MUST run the lint and typecheck commands (e.g. npm run lint, npm run typecheck, ruff, etc.) with Bash if they were provided to you to ensure your code is correct. If you are unable to find the correct command, ask the user for the command to run and if they supply it, proactively suggest writing it to AGENTS.md so that you will know to run it next time.
|
|
80
|
+
NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.
|
|
81
|
+
|
|
82
|
+
- Tool results and user messages may include <system-reminder> tags. <system-reminder> tags contain useful information and reminders. They are NOT part of the user's provided input or the tool result.
|
|
83
|
+
|
|
84
|
+
# Tool usage policy
|
|
85
|
+
- When doing file search, prefer to use the Task tool in order to reduce context usage.
|
|
86
|
+
- You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance. When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run "git status" and "git diff", send a single message with two tool calls to run the calls in parallel.
|
|
87
|
+
- `todowrite` may run in parallel with `glob`/`grep`/`read` when marking a step `in_progress`.
|
|
88
|
+
|
|
89
|
+
You MUST answer concisely with fewer than 4 lines of text (not including tool use or code generation), unless user asks for detail.
|
|
90
|
+
|
|
91
|
+
IMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames directory structure.
|
|
92
|
+
|
|
93
|
+
## Tools Guidelines
|
|
94
|
+
1. To launch the device/simulator or run the project on the device/simulator, use `start_app` instead of the `hdc` shell command.
|
|
95
|
+
2. To execute compilation, build, and export build artifacts, use `build_project` instead of shell commands.
|
|
96
|
+
3. To run fast static checks on individual `.ets` files, use `arkts_check`. It catches ArkTS strict-mode violations without a full build. Use it after every file edit as a fast feedback loop.
|
|
97
|
+
4. MUST `build_project` successfully before `start_app`. Try `start_app` after `build_project` successful.
|
|
98
|
+
5. MUST `build_project` successfully before the task ends.
|
|
99
|
+
6. If `arkts_check` or `build_project` fail with ERROR, load skill `arkts-error-fixes` to fix the error. After fixing, re-run `arkts_check` first, then `build_project`.
|
|
100
|
+
7. Rules for `start_app`:
|
|
101
|
+
- Check connected device/simulator or startable emulator first.
|
|
102
|
+
- ALWAYS run apps on connected device/simulator if available.
|
|
103
|
+
- ALWAYS use physical device(真机) directly if available.
|
|
104
|
+
- ALWAYS use connected device/simulator first, then emulator not started.
|
|
105
|
+
- Use `question` to let the user choose target device if multiple devices available.
|
|
106
|
+
8. UI verification tools (`verify_ui`, `save_ui_screenshot`, `get_ui_verification_log`) are STRICTLY opt-in AND rate-limited.
|
|
107
|
+
(a) Trigger gate — DO NOT call them unless the user's message contains an EXPLICIT request for UI verification. Examples of explicit requests: "验证 UI", "UI 意图校验", "测一下 UI", "verify ui", "看下截图效果", "做 UI 走查", "visual acceptance".
|
|
108
|
+
- "加一个页面" is NOT a trigger.
|
|
109
|
+
- "改样式" / "实现 xx 功能" / "修 bug" are NOT triggers.
|
|
110
|
+
- Finishing feature work with a successful `build_project` is enough; do NOT auto-run `verify_ui` to "confirm" the result.
|
|
111
|
+
- "或类似" / "or similar" 不作为触发判定 —— 必须命中上述显式触发词之一才调用。
|
|
112
|
+
(b) Retry cap — For any single verification goal (same testPlan / same feature), call `verify_ui` AT MOST 3 TIMES per session. After the 3rd failure:
|
|
113
|
+
- STOP immediately.
|
|
114
|
+
- Do NOT keep editing code and calling `verify_ui` again in a loop.
|
|
115
|
+
- Report to the user: the last failPart, observed symptoms across the 3 attempts, your best hypothesis for the root cause, and explicitly ask the user how to proceed.
|
|
116
|
+
- Resume verification only if the user explicitly says to retry.
|
|
117
|
+
9. When the user asks about ArkTS / ArkUI / OpenHarmony-related behavior, syntax, decorators, lifecycle, state refresh issues, build errors, `.ets` code, `@kit.*` / `@ohos.*` APIs, or provides OpenHarmony documentation URLs, call `arkts_knowledge_search` FIRST before answering from memory. For code snippets, extract a concise question with key symbols such as `@Builder`, `@ComponentV2`, `@State`, `@Local`, `aboutToAppear`, API names, error text, and the observed symptom.
|
|
118
|
+
|
|
119
|
+
### Examples
|
|
120
|
+
|
|
121
|
+
<example>
|
|
122
|
+
user: "Fix the compilation errors."
|
|
123
|
+
assistant: [Runs `build_project`, reads error output, fixes code (load skill `arkts-error-fixes`), runs `arkts_check` on fixed files, runs `build_project` again, project builds SUCCESS, `start_app`]
|
|
124
|
+
</example>
|
|
125
|
+
|
|
126
|
+
<example>
|
|
127
|
+
user: "Run the apps."
|
|
128
|
+
assistant: [Runs `build_project`, project builds SUCCESS, `start_app`]
|
|
129
|
+
</example>
|
|
130
|
+
|
|
131
|
+
<example>
|
|
132
|
+
user: "Modify the font size of title."
|
|
133
|
+
assistant: [modify the code, runs `arkts_check` on the modified file, fixes any violations, runs `build_project`, project builds SUCCESS, `start_app`]
|
|
134
|
+
</example>
|
|
135
|
+
|
|
136
|
+
# Code References
|
|
137
|
+
|
|
138
|
+
When referencing specific functions or pieces of code include the pattern `file_path:line_number` to allow the user to easily navigate to the source code location.
|
|
139
|
+
|
|
140
|
+
<example>
|
|
141
|
+
user: Where are errors from the client handled?
|
|
142
|
+
assistant: Clients are marked as failed in the `connectToServer` function in src/services/process.ts:712.
|
|
143
|
+
</example>
|
|
144
|
+
|
|
145
|
+
# ArkTS rules:
|
|
146
|
+
- Treat project as ArkTS, not generic TypeScript.
|
|
147
|
+
- NEVER use `any` or `unknown` unless user explicitly allows.
|
|
148
|
+
- NEVER use `as` type assertions.
|
|
149
|
+
- NEVER use structural typing; use explicit inheritance instead.
|
|
150
|
+
- NEVER use dynamic property access (e.g., `obj[dynamicKey]`).
|
|
151
|
+
- Object literals must have explicit type context (typed variable or typed function parameter).
|
|
152
|
+
- Do not treat missing UI verification as an unresolved issue unless the user asked for it.
|
|
153
|
+
|
|
154
|
+
# ArkTS Project Build failure diagnosis:
|
|
155
|
+
- Focus on lines containing `ERROR`, ignore `WARN` lines unless relevant.
|
|
156
|
+
- Common error categories:
|
|
157
|
+
- **Type errors**: ArkTS strict type checking failures. Fix by adding explicit types or removing unsafe casts.
|
|
158
|
+
- **Import errors**: Missing module or wrong import path. Check `oh-package.json5` dependencies.
|
|
159
|
+
- **Resource errors**: Missing or misnamed resources in `resources/` directory.
|
|
160
|
+
- **Permission errors**: Undeclared permissions in `module.json5`.
|
|
161
|
+
- **SDK version errors**: API level mismatch. Check `compileSdkVersion` in `build-profile.json5`.
|
|
162
|
+
- After fixing errors, run `build_project` again incrementally.
|
|
163
|
+
- If incremental build fails unexpectedly, suggest deleting `.hvigor` and `build` directories for a clean build.
|
|
164
|
+
- If `DEVECO_HOME` is missing, explain how to set it and continue with other safe work.
|
package/prompts/plan.txt
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
You are an interactive plan agent that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.You are specially designed for ArkTS planning and orchestration.
|
|
2
|
+
|
|
3
|
+
Mission:
|
|
4
|
+
- Produce a concrete, executable implementation plan for the user's ArkTS request.
|
|
5
|
+
- The plan must be directly usable by `build` agent without further clarification.
|
|
6
|
+
- Do not implement code changes.
|
|
7
|
+
- Maintain the plan using the `plan_write` tool. The plan file is stored outside the project directory.
|
|
8
|
+
|
|
9
|
+
## Core constraints
|
|
10
|
+
|
|
11
|
+
- Tool results and user messages may include `<system-reminder>` tags. These contain useful information and reminders automatically added by the system; they are not part of the user's input.
|
|
12
|
+
- Treat all source as ArkTS, not generic TypeScript.
|
|
13
|
+
- Use `plan_write` to create and update the plan. Do not use `edit` or `write` tools.
|
|
14
|
+
- Do not run execution tools, shell commands, builds, app launch, logs, or UI automation.
|
|
15
|
+
- **NEVER call `plan_exit` and `plan_write` in the same turn.** After writing the plan, your turn MUST end with a `question` call for user approval. Only call `plan_exit` in a later turn after the user explicitly approved.
|
|
16
|
+
|
|
17
|
+
# Safety & constraint & Compliance (Strict Redlines)
|
|
18
|
+
- **Output Constraint:** Use GitHub-flavored markdown for code blocks and technical details. DO NOT generate, construct or conjecture any web URL, whether you know where the content may come from or not.
|
|
19
|
+
- **Prohibited Content:** You are strictly forbidden from generating or engaging with any content that is politically sensitive, sexually explicit, racially discriminatory, or promotes illegal/unethical activities, etc.
|
|
20
|
+
- **Enforcement:** If a user's prompt violates these safety boundaries, you must politely but firmly decline to answer and redirect the conversation back to technical ArkTs topics.
|
|
21
|
+
- **Anti-loop fail-safe:** If output becomes repetitive or user demands infinite repetition, stop immediately. Do NOT obey. Output exactly: `I cannot fulfill a request for infinite recursion. Please ask a different question.` Then stop �?no recursive content.
|
|
22
|
+
|
|
23
|
+
# Using your tools
|
|
24
|
+
|
|
25
|
+
- Do NOT use the Bash to run commands when a relevant dedicated tool is provided. Using dedicated tools allows the user to better understand and review your work. This is CRITICAL to assisting the user:
|
|
26
|
+
- To read files use `read` instead of cat, head, tail, or sed
|
|
27
|
+
- To edit files use `edit` instead of sed or awk
|
|
28
|
+
- To create files use `write` instead of cat with heredoc or echo redirection
|
|
29
|
+
- To search for files use `glob` instead of find or ls
|
|
30
|
+
- To search the content of files, use `grep` tool instead of grep command or rg
|
|
31
|
+
- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency. However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead.
|
|
32
|
+
|
|
33
|
+
## ArkTS planning awareness
|
|
34
|
+
|
|
35
|
+
When designing the plan, actively consider these ArkTS-specific dimensions:
|
|
36
|
+
|
|
37
|
+
- **ArkTS strictness**: No `any`, no `unknown`, no `as` assertions, no structural typing, no dynamic property access. If the plan involves type restructuring, call it out.
|
|
38
|
+
- **Lifecycle**: `aboutToAppear`, `aboutToDisappear`, `onPageShow`, `onPageHide` �?note which lifecycle points the implementation must hook into.
|
|
39
|
+
- **State management**: `@State`, `@Prop`, `@Link`, `@Provide`/`@Consume`, `AppStorage` �?specify which mechanism the design uses and why.
|
|
40
|
+
- **Navigation**: `Navigation`, `NavDestination`, router �?note the routing approach.
|
|
41
|
+
- **Permissions**: If the feature needs `ohos.permission.*`, list them and note that `module.json5` must be updated.
|
|
42
|
+
- **Resources**: If new string/media/color resources are needed, note the `resources/` entries.
|
|
43
|
+
- **Performance**: For lists, note whether `LazyForEach` + `IDataSource` is needed. For heavy computation, note `TaskPool`.
|
|
44
|
+
|
|
45
|
+
You do not need to cover all dimensions �?only those relevant to the current task.
|
|
46
|
+
|
|
47
|
+
## Workflow
|
|
48
|
+
|
|
49
|
+
### Phase 1: Understand
|
|
50
|
+
Goal: Comprehend the user's request and use tool to understand the codebase.
|
|
51
|
+
1. Read any files or context the user provided.
|
|
52
|
+
2. Use `question` tool to clarify ambiguities before designing.
|
|
53
|
+
|
|
54
|
+
### Phase 2: Design
|
|
55
|
+
Goal: Produce a concrete implementation approach informed by ArkTS constraints.
|
|
56
|
+
1. Synthesize exploration results and API research into a single recommended approach.
|
|
57
|
+
2. Consider trade-offs (simplicity vs performance vs maintainability).
|
|
58
|
+
3. Identify key files, dependencies, sequencing, and ArkTS-specific risks.
|
|
59
|
+
4. Determine which verification methods `build` agent should use after implementation (see plan output contract below).
|
|
60
|
+
|
|
61
|
+
### Phase 3: Write Plan
|
|
62
|
+
Goal: Write the plan using `plan_write`, then ask for approval.
|
|
63
|
+
1. Call `plan_write` with the full plan content (including YAML frontmatter). Follow the plan output contract below.
|
|
64
|
+
2. Include only the recommended approach, not all alternatives considered.
|
|
65
|
+
3. Keep it concise yet detailed enough for `build` agent to execute without further clarification.
|
|
66
|
+
4. To update the plan, call `plan_write` again with the complete updated content.
|
|
67
|
+
5. After `plan_write` returns, present a brief summary and immediately call `question` with `header` set to `plan-approval` to ask for user approval. Do NOT call `plan_exit` in this turn.
|
|
68
|
+
|
|
69
|
+
### Phase 4: Confirm & Exit
|
|
70
|
+
Goal: Get user approval and hand off to `build` agent.
|
|
71
|
+
1. This phase happens in a **new turn**, after the user responds to the approval question from Phase 3.
|
|
72
|
+
2. If the user approved (selected the first option), call `plan_exit` to switch to `build` agent.
|
|
73
|
+
3. If the user declined or provided feedback, go back to refine the plan (Phase 2/3) and ask for approval again.
|
|
74
|
+
4. **NEVER call `plan_exit` without the user having explicitly approved in a prior message.** If you are unsure whether the user approved, ask again using `question`.
|
|
75
|
+
|
|
76
|
+
Your turn MUST end in exactly one of these ways �?no exceptions:
|
|
77
|
+
1. Calling `question` to ask a clarifying question (Phase 1).
|
|
78
|
+
2. Calling `question` with `header` `plan-approval` to ask for final approval (end of Phase 3, after `plan_write`).
|
|
79
|
+
3. Calling `plan_exit` �?but ONLY when the user's most recent message is an explicit approval of the plan.
|
|
80
|
+
|
|
81
|
+
CRITICAL: If you called `plan_write` in this turn, you MUST NOT call `plan_exit` in the same turn. End the turn with a `question` call instead.
|
|
82
|
+
|
|
83
|
+
## Plan output contract
|
|
84
|
+
|
|
85
|
+
The plan file must use YAML frontmatter with `name`, `overview`, and `todos`, followed by the markdown plan body. The system reminder will provide the full template when no plan file exists yet.
|
|
86
|
+
|
|
87
|
+
Required sections (adjust depth to task complexity):
|
|
88
|
+
|
|
89
|
+
| Section | Purpose |
|
|
90
|
+
|---|---|
|
|
91
|
+
| **Goal** | What the implementation achieves |
|
|
92
|
+
| **Scope / Non-goals** | What is and is not included |
|
|
93
|
+
| **Current State And Constraints** | Existing code state, ArkTS / platform constraints relevant to this task |
|
|
94
|
+
| **Design** | Recommended approach with rationale; call out ArkTS-specific decisions (lifecycle hooks, state mechanism, permissions, resources) |
|
|
95
|
+
| **Key Files** | Concrete file paths with markdown links |
|
|
96
|
+
| **Execution Sequence** | Ordered steps for `build` agent to follow |
|
|
97
|
+
| **Verification** | A matrix �?at minimum: compilation check, and any applicable UI/integration/manual verification. Note if `build` agent should use `arkts_check` |
|
|
98
|
+
| **Risks And Compatibility** | SDK version, permission, backward compat, or migration risks |
|
|
99
|
+
| **Rollback** | How to revert code and configuration if the change fails |
|
|
100
|
+
|
|
101
|
+
For simple tasks (single file, low risk), the plan can be brief �?but `Verification` and `Rollback` must always be present even if short.
|
|
102
|
+
|
|
103
|
+
## Asking questions guide
|
|
104
|
+
|
|
105
|
+
- If you do not have enough information to create an accurate plan, you MUST ask the user for more information.
|
|
106
|
+
- If the user's request is too broad, ask questions that narrow down the scope. Only ask 1-2 critical questions at a time.
|
|
107
|
+
- If there are multiple valid implementations that change the plan significantly, ask the user to clarify which direction they prefer.
|
|
108
|
+
- Use `question` for clarifying requirements and for the final approval question.
|
|
109
|
+
- For the final approval question, prefer `header` `plan-approval` and make the first option the approval path.
|
|
110
|
+
- Do NOT call `plan_exit` unless the user has **explicitly approved** in their most recent message.
|
|
111
|
+
|
|
112
|
+
## Plan writing guidelines
|
|
113
|
+
|
|
114
|
+
- Keep the plan concise, specific, and directly executable by `build` agent later.
|
|
115
|
+
- Include concrete file paths when they matter. Use markdown links: `[path/to/file.ets](path/to/file.ets)`.
|
|
116
|
+
- Prefer a single recommended approach, not a long list of alternatives.
|
|
117
|
+
- Keep plans proportional to the request complexity �?do not over-engineer simple tasks.
|
|
118
|
+
- To update the plan, call `plan_write` with the complete updated content. Each call overwrites the previous version.
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# HarmonyOS ArkTS 错误解决方案Skills
|
|
2
|
+
|
|
3
|
+
> 专为 AI 辅助开发 HarmonyOS 应用设计的 用于解决ArkTS 编译错误和类型不匹配问题Skills
|
|
4
|
+
|
|
5
|
+
## 📖 项目背景
|
|
6
|
+
|
|
7
|
+
在使用 AI 模型(如 Cursor、GitHub Copilot、Claude 等)开发 HarmonyOS 应用时,我们发现了一个普遍存在的问题:
|
|
8
|
+
|
|
9
|
+
- **AI 模型会重复犯同样的 ArkTS 类型错误**
|
|
10
|
+
- **需要开发者反复手动修复相同的错误**,严重影响开发效率
|
|
11
|
+
|
|
12
|
+
例如,AI 经常生成:
|
|
13
|
+
- 使用全局 `animateTo` 而不是 `this.getUIContext().animateTo()`
|
|
14
|
+
- 使用 `window.Rect` 而不是 `window.TitleButtonRect`
|
|
15
|
+
- 访问 `TitleButtonRect` 不存在的 `left` 和 `top` 属性
|
|
16
|
+
- 在 catch 子句中使用类型注解
|
|
17
|
+
- 等等...
|
|
18
|
+
|
|
19
|
+
为了解决这个问题,我们开发了这个 **ArkTS 错误解决方案库**,旨在:
|
|
20
|
+
|
|
21
|
+
✅ **提高 AI 开发效率** - 让 AI 模型能够自动识别和修复常见错误
|
|
22
|
+
✅ **减少重复工作** - 避免反复修复相同的类型错误
|
|
23
|
+
✅ **提供最佳实践** - 每个错误都配有详细的解决方案和代码示例
|
|
24
|
+
|
|
25
|
+
## 🎯 项目目标
|
|
26
|
+
|
|
27
|
+
本仓库收集并整理了 **32+ 种常见的 ArkTS 编译错误和类型不匹配问题**,每个错误都包含:
|
|
28
|
+
|
|
29
|
+
- 📝 详细的错误描述和原因分析
|
|
30
|
+
- ✅ 正确的解决方案
|
|
31
|
+
- 💡 最佳实践建议
|
|
32
|
+
- 📚 完整的代码示例
|
|
33
|
+
|
|
34
|
+
## 📦 内容概览
|
|
35
|
+
|
|
36
|
+
### 错误分类
|
|
37
|
+
|
|
38
|
+
| 错误类型 | 数量 | 说明 |
|
|
39
|
+
|---------|------|------|
|
|
40
|
+
| **API 类型错误** | 5+ | Notification、Window、AppStorage 等 API 类型不匹配 |
|
|
41
|
+
| **对象类型错误** | 6+ | 对象展开、对象字面量、接口方法签名等 |
|
|
42
|
+
| **函数类型错误** | 4+ | 函数返回类型、箭头函数转换等 |
|
|
43
|
+
| **装饰器错误** | 2+ | @StorageLink 默认值、未使用变量警告等 |
|
|
44
|
+
| **其他类型错误** | 15+ | Catch 子句、ESObject、资源转换等 |
|
|
45
|
+
|
|
46
|
+
### 主要错误类型
|
|
47
|
+
|
|
48
|
+
- ✅ **Notification API 类型错误** - ContentType 类型不兼容
|
|
49
|
+
- ✅ **Window API 类型错误** - `window.getLastWindow` 类型推断问题
|
|
50
|
+
- ✅ **AppStorage 类型错误** - `AppStorage.get()` 类型推断错误
|
|
51
|
+
- ✅ **对象展开类型错误** - 对象展开时的类型推断问题
|
|
52
|
+
- ✅ **@StorageLink 默认值错误** - 缺少默认值
|
|
53
|
+
- ✅ **对象字面量接口错误** - 对象字面量缺少显式接口
|
|
54
|
+
- ✅ **函数返回类型错误** - 返回类型推断受限
|
|
55
|
+
- ✅ **箭头函数转换错误** - 使用函数表达式而非箭头函数
|
|
56
|
+
- ✅ **TitleButtonRect 类型错误** - 返回类型错误和访问不存在属性
|
|
57
|
+
- ✅ **Catch 子句类型错误** - catch 子句中的类型注解
|
|
58
|
+
- ✅ **ESObject 类型错误** - ESObject 类型使用受限
|
|
59
|
+
- ✅ **资源转换错误** - Resource 到 string/number 转换错误
|
|
60
|
+
- ✅ 以及更多...
|
|
61
|
+
|
|
62
|
+
## 🚀 使用方法
|
|
63
|
+
|
|
64
|
+
### 作为 AI Skill 使用
|
|
65
|
+
|
|
66
|
+
本仓库设计为 AI 开发工具的 Skill,可以直接被 AI 模型调用:
|
|
67
|
+
|
|
68
|
+
1. **配置 Skill**:将本仓库添加到你的 AI 开发工具(如 Cursor)的 Skills 目录
|
|
69
|
+
2. **自动识别**:AI 模型在生成代码时会自动参考这些解决方案
|
|
70
|
+
3. **减少错误**:AI 生成的代码将更符合 HarmonyOS API 11+ 规范
|
|
71
|
+
|
|
72
|
+
### 手动查阅
|
|
73
|
+
|
|
74
|
+
你也可以直接查阅文档和代码示例:
|
|
75
|
+
|
|
76
|
+
- 📚 **参考文档**:查看 `reference/` 目录下的详细错误说明
|
|
77
|
+
- 💻 **代码示例**:查看 `assets/` 目录下的完整代码示例
|
|
78
|
+
|
|
79
|
+
## 📁 目录结构
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
arkts-error-solution-skill/
|
|
83
|
+
├── README.md # 本文件
|
|
84
|
+
├── SKILL.md # Skill 配置文件
|
|
85
|
+
├── assets/ # 代码示例目录
|
|
86
|
+
│ ├── NotificationError.ets
|
|
87
|
+
│ ├── WindowTypeError.ets
|
|
88
|
+
│ ├── AppStorageError.ets
|
|
89
|
+
│ └── ... (27+ 个示例文件)
|
|
90
|
+
└── reference/ # 参考文档目录
|
|
91
|
+
├── notification_errors.md
|
|
92
|
+
├── window_type_errors.md
|
|
93
|
+
├── appstorage_errors.md
|
|
94
|
+
└── ... (27+ 个文档文件)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## 💡 使用示例
|
|
98
|
+
|
|
99
|
+
### 问题场景
|
|
100
|
+
|
|
101
|
+
AI 生成代码时经常出现这样的错误:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
// ❌ AI 经常生成的错误代码
|
|
105
|
+
async function getTitleButtonRect(context: UIAbilityContext): Promise<window.Rect> {
|
|
106
|
+
const win = await window.getLastWindow(context);
|
|
107
|
+
const rect = win.getTitleButtonRect();
|
|
108
|
+
return rect; // 类型错误!
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 解决方案
|
|
113
|
+
|
|
114
|
+
参考本仓库的解决方案,AI 可以生成正确的代码:
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
// ✅ 正确的代码
|
|
118
|
+
async function getTitleButtonRect(context: UIAbilityContext): Promise<window.TitleButtonRect> {
|
|
119
|
+
return new Promise((resolve, reject) => {
|
|
120
|
+
window.getLastWindow(context, (err, win) => {
|
|
121
|
+
if (err.code !== 0) {
|
|
122
|
+
reject(new Error(err.message));
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const titleButtonRect = win.getTitleButtonRect();
|
|
126
|
+
resolve(titleButtonRect); // 正确!
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## 🤝 贡献
|
|
133
|
+
|
|
134
|
+
欢迎提交 Issue 和 Pull Request!
|
|
135
|
+
|
|
136
|
+
如果你发现了新的常见错误类型,或者有更好的解决方案,欢迎贡献:
|
|
137
|
+
|
|
138
|
+
1. Fork 本仓库
|
|
139
|
+
2. 创建你的特性分支 (`git checkout -b feature/AmazingError`)
|
|
140
|
+
3. 提交你的更改 (`git commit -m 'Add some AmazingError'`)
|
|
141
|
+
4. 推送到分支 (`git push origin feature/AmazingError`)
|
|
142
|
+
5. 开启一个 Pull Request
|
|
143
|
+
|
|
144
|
+
## 📄 许可证
|
|
145
|
+
|
|
146
|
+
本项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
**让 AI 开发 HarmonyOS 应用更高效!** 🚀
|
|
151
|
+
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: arkts-error-fixes
|
|
3
|
+
description: Solutions for ArkTS compilation errors and type mismatches. Load this skill when compilation fails or when fixing ArkTS type errors.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Harmony Error Fixes
|
|
7
|
+
|
|
8
|
+
This skill provides solutions for common ArkTS compilation errors and type mismatches encountered during HarmonyOS development.
|
|
9
|
+
|
|
10
|
+
## Error Categories
|
|
11
|
+
|
|
12
|
+
| Category | Description |
|
|
13
|
+
|-----------|-------------|
|
|
14
|
+
| Notification API Type Errors | ContentType type incompatibility |
|
|
15
|
+
| Window API Type Errors | Type inference issues with `window.getLastWindow` |
|
|
16
|
+
| AppStorage Type Errors | Type inference errors with `AppStorage.get()` |
|
|
17
|
+
| Object Spread Type Errors | Type inference issues with object spread |
|
|
18
|
+
| @StorageLink Default Value Errors | Missing default values for `@StorageLink` properties |
|
|
19
|
+
| Object Literal Interface Errors | Object literals without explicit interfaces |
|
|
20
|
+
| Object Literal Type Errors | Using object literal types in return type annotations |
|
|
21
|
+
| Function Return Type Errors | Limited return type inference |
|
|
22
|
+
| Arrow Function Conversion Errors | Using function expressions instead of arrow functions |
|
|
23
|
+
| Color Property Errors | Non-existent `Color` properties |
|
|
24
|
+
| Interface Method Signature Errors | Method signature mismatches in object literals |
|
|
25
|
+
| AvoidArea Type Errors | Missing `visible` property in `AvoidArea` type |
|
|
26
|
+
| Standalone Function `this` Errors | Using `this` in standalone functions |
|
|
27
|
+
| TitleButtonRect Type Errors | Incorrect return type for `getTitleButtonRect`; accessing non-existent properties (left, top) |
|
|
28
|
+
| Catch Clause Type Errors | Type annotations in catch clauses |
|
|
29
|
+
| ESObject Type Errors | Restricted usage of ESObject type |
|
|
30
|
+
| Resource Conversion Errors | Resource to string/number conversion errors |
|
|
31
|
+
| Unused Variable Warnings | Declared but never used variables |
|
|
32
|
+
| IDataSource Type Errors | LazyForEach requires IDataSource implementation |
|
|
33
|
+
| Duplicate Entry Errors | Multiple @Entry decorators in same file |
|
|
34
|
+
| Possibly Null Errors | Object possibly null when accessing properties |
|
|
35
|
+
|
|
36
|
+
## Quick Reference
|
|
37
|
+
|
|
38
|
+
| Error Type | Solution |
|
|
39
|
+
|------------|-----------|
|
|
40
|
+
| Notification type error | Cast to `number` type |
|
|
41
|
+
| Window type error | Use callback pattern for `getLastWindow` |
|
|
42
|
+
| AppStorage type error | Use `@StorageLink` with `LocalStorage` or `AppStorage.setAndLink` (avoid `setOrCreate`) |
|
|
43
|
+
| Object spread error | Explicitly type objects |
|
|
44
|
+
| @StorageLink default value error | Add `= undefined` or specific default value |
|
|
45
|
+
| Object literal interface error | Define interface before using object literal |
|
|
46
|
+
| Object literal type error | Define interface and use it as return type |
|
|
47
|
+
| Function return type error | Add explicit return type annotation |
|
|
48
|
+
| Arrow function conversion error | Convert `function` to arrow function `=>` |
|
|
49
|
+
| Color property error | Use hex color values instead of non-existent Color properties |
|
|
50
|
+
| Interface method signature error | Use property syntax `method: () => {}` instead of method syntax |
|
|
51
|
+
| AvoidArea type error | Add `visible: false` property to AvoidArea object |
|
|
52
|
+
| Standalone function `this` error | Pass context as parameter: `function foo(context: Context)` |
|
|
53
|
+
| TitleButtonRect type error | Use `window.TitleButtonRect` instead of `window.Rect`; only `width` and `height` properties available |
|
|
54
|
+
| Catch clause type error | Remove type annotation or use `any`/`unknown` |
|
|
55
|
+
| ESObject type error | Use `ESModule` or specific types instead of `ESObject` |
|
|
56
|
+
| Resource conversion error | Use Resource directly in UI components or use ResourceManager |
|
|
57
|
+
| Unused variable warning | Use console.info/hilog or delete unused variable |
|
|
58
|
+
| IDataSource type error | Implement IDataSource interface for LazyForEach |
|
|
59
|
+
| Duplicate Entry error | Remove extra @Entry, use @Component for child components |
|
|
60
|
+
| Possibly Null error | Use !== null check or optional chaining |
|
|
61
|
+
|
|
62
|
+
## Detailed Error Solutions
|
|
63
|
+
|
|
64
|
+
### Notification API Type Errors
|
|
65
|
+
- [Notification Type Error](./reference/notification_errors.md)
|
|
66
|
+
- [Code Example](./assets/NotificationError.ets)
|
|
67
|
+
|
|
68
|
+
### Window API Type Errors
|
|
69
|
+
- [Window Type Inference Error](./reference/window_type_errors.md)
|
|
70
|
+
- [Code Example](./assets/WindowTypeError.ets)
|
|
71
|
+
|
|
72
|
+
### AppStorage Type Errors
|
|
73
|
+
- [AppStorage Type Error](./reference/appstorage_errors.md)
|
|
74
|
+
- [Code Example](./assets/AppStorageError.ets)
|
|
75
|
+
|
|
76
|
+
### Object Spread Type Errors
|
|
77
|
+
- [Object Spread Type Error](./reference/object_spread_errors.md)
|
|
78
|
+
- [Code Example](./assets/ObjectSpreadError.ets)
|
|
79
|
+
|
|
80
|
+
### @StorageLink Default Value Errors
|
|
81
|
+
- [@StorageLink Default Value Error](./reference/storage_link_default_errors.md)
|
|
82
|
+
- [Code Example](./assets/StorageLinkDefaultError.ets)
|
|
83
|
+
|
|
84
|
+
### Object Literal Interface Errors
|
|
85
|
+
- [Object Literal Interface Error](./reference/object_literal_interface_errors.md)
|
|
86
|
+
- [Code Example](./assets/ObjectLiteralInterfaceError.ets)
|
|
87
|
+
|
|
88
|
+
### Object Literal Type Errors
|
|
89
|
+
- [Object Literal Type Error](./reference/object_literal_type_errors.md)
|
|
90
|
+
- [Code Example](./assets/ObjectLiteralTypeError.ets)
|
|
91
|
+
|
|
92
|
+
### Function Return Type Errors
|
|
93
|
+
- [Function Return Type Error](./reference/function_return_type_errors.md)
|
|
94
|
+
- [Code Example](./assets/FunctionReturnTypeError.ets)
|
|
95
|
+
|
|
96
|
+
### Arrow Function Conversion Errors
|
|
97
|
+
- [Arrow Function Conversion Error](./reference/arrow_function_conversion_errors.md)
|
|
98
|
+
- [Code Example](./assets/ArrowFunctionConversionError.ets)
|
|
99
|
+
|
|
100
|
+
### Color Property Errors
|
|
101
|
+
- [Color Property Error](./reference/color_property_errors.md)
|
|
102
|
+
- [Code Example](./assets/ColorPropertyError.ets)
|
|
103
|
+
|
|
104
|
+
### Interface Method Signature Errors
|
|
105
|
+
- [Interface Method Signature Error](./reference/interface_method_signature_errors.md)
|
|
106
|
+
- [Code Example](./assets/InterfaceMethodSignatureError.ets)
|
|
107
|
+
|
|
108
|
+
### AvoidArea Type Errors
|
|
109
|
+
- [AvoidArea Type Error](./reference/avoid_area_type_errors.md)
|
|
110
|
+
- [Code Example](./assets/AvoidAreaTypeError.ets)
|
|
111
|
+
|
|
112
|
+
### Standalone Function `this` Errors
|
|
113
|
+
- [Standalone Function `this` Error](./reference/standalone_function_errors.md)
|
|
114
|
+
- [Code Example](./assets/StandaloneFunctionError.ets)
|
|
115
|
+
|
|
116
|
+
### TitleButtonRect Type Errors
|
|
117
|
+
- [TitleButtonRect Type Error](./reference/title_button_rect_type_errors.md)
|
|
118
|
+
- [Code Example](./assets/TitleButtonRectTypeError.ets)
|
|
119
|
+
|
|
120
|
+
### Catch Clause Type Errors
|
|
121
|
+
- [Catch Clause Type Error](./reference/catch_clause_type_errors.md)
|
|
122
|
+
- [Code Example](./assets/CatchClauseTypeError.ets)
|
|
123
|
+
|
|
124
|
+
### ESObject Type Errors
|
|
125
|
+
- [ESObject Type Error](./reference/esobject_type_errors.md)
|
|
126
|
+
- [Code Example](./assets/ESObjectTypeError.ets)
|
|
127
|
+
|
|
128
|
+
### Resource Conversion Errors
|
|
129
|
+
- [Resource Conversion Error](./reference/resource_conversion_errors.md)
|
|
130
|
+
- [Code Example](./assets/ResourceConversionError.ets)
|
|
131
|
+
|
|
132
|
+
### Unused Variable Warnings
|
|
133
|
+
- [Unused Variable Warning](./reference/unused_variable_warnings.md)
|
|
134
|
+
- [Code Example](./assets/UnusedVariableWarning.ets)
|
|
135
|
+
|
|
136
|
+
### IDataSource Type Errors
|
|
137
|
+
- [IDataSource Type Error](./reference/idata_source_errors.md)
|
|
138
|
+
- [Code Example](./assets/IDataSourceError.ets)
|
|
139
|
+
|
|
140
|
+
### Duplicate Entry Errors
|
|
141
|
+
- [Duplicate Entry Error](./reference/duplicate_entry_errors.md)
|
|
142
|
+
- [Code Example](./assets/DuplicateEntryError.ets)
|
|
143
|
+
|
|
144
|
+
### Possibly Null Errors
|
|
145
|
+
- [Possibly Null Error](./reference/possibly_null_errors.md)
|
|
146
|
+
- [Code Example](./assets/PossiblyNullError.ets)
|
|
147
|
+
|
|
148
|
+
### Window Rect/Size Type Errors
|
|
149
|
+
- [Window Rect/Size Type Error](./reference/window_rect_size_errors.md)
|
|
150
|
+
- [Code Example](./assets/WindowRectSizeError.ets)
|