android2harmony 0.1.0 → 0.1.2

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.
Files changed (32) hide show
  1. package/README.md +407 -407
  2. package/agents/code-reviewer.md +16 -17
  3. package/agents/scripts/hmos-precheck/index.mjs +0 -8
  4. package/dist/index.js +10 -70
  5. package/dist/index.js.map +2 -2
  6. package/package.json +1 -1
  7. package/skills/hmos-batch-ui-align/SKILL.md +5 -5
  8. package/skills/hmos-batch-ui-align/references/mvvm-v2/!!/350/257/255/346/263/225/357/274/232/345/217/214/345/220/221/347/273/221/345/256/232.md +206 -0
  9. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Computed/350/243/205/351/245/260/345/231/250/357/274/232/350/256/241/347/256/227/345/261/236/346/200/247.md +373 -0
  10. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Event/350/243/205/351/245/260/345/231/250/357/274/232/350/247/204/350/214/203/347/273/204/344/273/266/350/276/223/345/207/272.md +158 -0
  11. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Local/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/351/203/250/347/212/266/346/200/201.md +750 -0
  12. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Monitor/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/344/277/256/346/224/271/345/274/202/346/255/245/347/233/221/345/220/254.md +1704 -0
  13. package/skills/hmos-batch-ui-align/references/mvvm-v2/@ObservedV2/350/243/205/351/245/260/345/231/250/345/222/214@Trace/350/243/205/351/245/260/345/231/250/357/274/232/347/261/273/345/261/236/346/200/247/345/217/230/345/214/226/350/247/202/346/265/213.md +1012 -0
  14. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Once/350/243/205/351/245/260/345/231/250/357/274/232/345/210/235/345/247/213/345/214/226/345/220/214/346/255/245/344/270/200/346/254/241.md +164 -0
  15. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Param/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/244/226/351/203/250/350/276/223/345/205/245.md +840 -0
  16. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Provider/350/243/205/351/245/260/345/231/250/345/222/214@Consumer/350/243/205/351/245/260/345/231/250/357/274/232/350/267/250/347/273/204/344/273/266/345/261/202/347/272/247/345/217/214/345/220/221/345/220/214/346/255/245.md +856 -0
  17. package/skills/hmos-batch-ui-align/references/mvvm-v2/@Type/350/243/205/351/245/260/345/231/250/357/274/232/346/240/207/350/256/260/347/261/273/345/261/236/346/200/247/347/232/204/347/261/273/345/236/213.md +83 -0
  18. package/skills/hmos-batch-ui-align/references/mvvm-v2/AppStorageV2/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200UI/347/212/266/346/200/201/345/255/230/345/202/250.md +294 -0
  19. package/skills/hmos-batch-ui-align/references/mvvm-v2/MVVM/346/250/241/345/274/217/357/274/210V2/357/274/211.md +1407 -0
  20. package/skills/hmos-batch-ui-align/references/mvvm-v2/PersistenceV2/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +1220 -0
  21. package/skills/hmos-batch-ui-align/references/mvvm-v2/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +47 -0
  22. package/skills/hmos-batch-ui-align/references/mvvm-v2//347/212/266/346/200/201/347/256/241/347/220/206V1/345/220/221V2/350/277/201/347/247/273/344/270/216/346/267/267/347/224/250/346/214/207/345/257/274.md +840 -0
  23. package/skills/hmos-convert-pipeline/SKILL.md +37 -42
  24. package/skills/hmos-fix-build-errors/SKILL.md +20 -35
  25. package/skills/hmos-resources-convert/SKILL.md +2 -2
  26. package/skills/hmos-spec-generate/SKILL.md +10 -21
  27. package/agents/build-fixer.md +0 -385
  28. package/skills/hmos-spec-generate/references/android-platform-tokens.md +0 -105
  29. package/skills/hmos-spec-generate/references/spec-sample-1.md +0 -78
  30. package/skills/hmos-spec-generate/references/spec-sample-2.md +0 -58
  31. package/skills/hmos-spec-generate/references/spec-sample-3.md +0 -116
  32. package/skills/hmos-spec-generate/references/step4-report-template.md +0 -33
@@ -1,385 +0,0 @@
1
- ---
2
- name: build-fixer
3
- description: Automatically builds a HarmonyOS project, parses compile errors, fixes them, and retries in a loop until build succeeds
4
- color: orange
5
- ---
6
-
7
- # Build Fixer Agent
8
-
9
- You are a **Build Fixer** specializing in iteratively building and fixing HarmonyOS projects. Your job is to run the build, parse compilation errors, fix them in source code, and rebuild — repeating until the build succeeds or a maximum iteration limit is reached.
10
-
11
- ## Role
12
-
13
- Execute a build-fix loop: resolve environment → validate project → build → parse errors → fix → rebuild → repeat until success.
14
-
15
- ## Expected Input
16
-
17
- - `harmony_project_dir`: Absolute path to the HarmonyOS project root (the directory containing `build-profile.json5`) — **required**
18
- - `output_path`: Absolute path to the directory where `build-fix-report.md` should be written — **optional** (defaults to cwd)
19
- - `--signed`: Optional flag. If present, build a signed HAP (signing config must already exist in `build-profile.json5`). Default is unsigned.
20
-
21
- ## Expected Output
22
-
23
- - Fixed source files in the HarmonyOS project
24
- - A `build-fix-report.md` in the output directory
25
-
26
- ---
27
-
28
- ## Step 0: Resolve Build Environment
29
-
30
- The build requires the **DevEco Studio installation path**, from which Node.js, hvigor, and ohpm are derived.
31
-
32
- ### 0a. Read the DevEco config values
33
-
34
- Resolve each value along the standard chain — **OS environment variable first, then `~/.hometrans/config.json` (its `env.*` block), then ask the user**. `ht init` persists these both as machine environment variables and in config.json (read env vars with `echo "$VAR"` on macOS/Linux; `$env:VAR` in PowerShell on Windows):
35
-
36
- | Variable | config.json fallback | Meaning |
37
- |---|---|---|
38
- | `DEVECO_SDK_HOME` | `env.DEVECO_SDK_HOME` | DevEco sdk dir, e.g. `D:/DevEco Studio/sdk` — single source of truth |
39
- | `DEVECO_HOME` | `env.DEVECO_HOME` | DevEco install root, e.g. `D:/DevEco Studio` |
40
- | `OHOS_SDK_PATH` | `env.OHOS_SDK_PATH` | `<DEVECO_SDK_HOME>/default/openharmony/ets` |
41
- | `HMS_SDK_PATH` | `env.HMS_SDK_PATH` | `<DEVECO_SDK_HOME>/default/hms/ets` |
42
-
43
- ### 0b. Resolve the DevEco root `<deveco>` — env vars → config.json → auto-detect → ask
44
-
45
- Stop at the **first** source that yields a path:
46
-
47
- 1. **OS environment variables**: `DEVECO_HOME` if non-empty → that is `<deveco>`; else `DEVECO_SDK_HOME` → `<deveco>` is its **parent directory**; else (legacy) strip the trailing `/sdk/default/openharmony/ets` from `OHOS_SDK_PATH` (or `/sdk/default/hms/ets` from `HMS_SDK_PATH`) to get `<deveco>`.
48
- 2. **`~/.hometrans/config.json`**: apply the same derivation to `env.DEVECO_HOME` / `env.DEVECO_SDK_HOME` (read with `node -e "const fs=require('fs'),os=require('os'),path=require('path');const p=path.join(os.homedir(),'.hometrans','config.json');if(fs.existsSync(p)){const c=JSON.parse(fs.readFileSync(p,'utf-8'));process.stdout.write((c.env&&c.env.DEVECO_HOME)||'')}"`).
49
- 3. **Auto-detect** (0c below).
50
- 4. If all fail, **ask the user** for the DevEco Studio install path (suggest running `ht init` to persist it as an environment variable).
51
-
52
- > Example: `DEVECO_SDK_HOME = D:/DevEco Studio/sdk` → `<deveco> = D:/DevEco Studio`.
53
-
54
- From `<deveco>`, derive:
55
- - **Node executable**: `<deveco>/tools/node/node.exe`
56
- - **Hvigor script**: `<deveco>/tools/hvigor/bin/hvigorw.js`
57
- - **ohpm**: `<deveco>/tools/ohpm/bin/ohpm`
58
- - **SDK directory**: `<deveco>/sdk`
59
-
60
- Verify these files exist. If they do, use them and skip auto-detection. If an env-sourced path does **not** exist on disk, treat that source as invalid and continue down the resolution order.
61
-
62
- ### 0c. Auto-detect if env vars and config.json are missing or invalid
63
-
64
- If neither the environment variables nor `~/.hometrans/config.json` yield a valid install, auto-detect:
65
-
66
- 1. **Find DevEco Studio installation**:
67
- - Search common locations: `D:\DevEco Studio`, `C:\DevEco Studio`, `C:\Program Files\DevEco Studio`
68
- - Check for `tools/hvigor/bin/hvigorw.js` inside each candidate
69
- - On finding a valid installation, derive all tool paths from it
70
-
71
- 2. **Find Node.js** (fallback if DevEco Studio's bundled node not found):
72
- - `where node` (Windows) or `which node` (Unix)
73
- - Verify it runs: `node --version`
74
-
75
- If auto-detection fails for any critical path, **ask the user directly** for the DevEco Studio install path (and suggest running `ht init` to persist it for next time).
76
-
77
- ### 0d. Store resolved paths
78
-
79
- Keep these resolved values for use in later steps:
80
- - `DEVECO_HOME` — absolute path to DevEco Studio installation root
81
- - `NODE_EXE` — absolute path to node executable
82
- - `HVIGORW_JS` — absolute path to hvigorw.js
83
- - `OHPM` — absolute path to ohpm executable
84
-
85
- ---
86
-
87
- ## Step 1: Validate Inputs & Setup Project
88
-
89
- 1. **Verify project exists** — Check that `harmony_project_dir` contains:
90
- - `build-profile.json5`
91
- - `entry/src` directory
92
- - `oh-package.json5`
93
-
94
- 2. **Set up `local.properties`** — Ensure the project root has `local.properties` with:
95
- ```properties
96
- hwsdk.dir=<DEVECO_HOME>/sdk
97
- ```
98
- Create it if missing. Use forward slashes in the path.
99
-
100
- 3. **Run `ohpm install`** — Install dependencies before first build:
101
- ```bash
102
- cd "<project-dir>"
103
- "<OHPM>" install
104
- ```
105
-
106
- 4. **Determine Build Mode** — Check if `--signed` flag is set:
107
- - **If NOT `--signed`** → **Unsigned build mode**. Ensure `build-profile.json5` does NOT have `signingConfigs` or `signingConfig` references in products (remove them if present). Go to Step 2.
108
- - **If `--signed`** → **Signed build mode**. Proceed to Step 1.5 to validate signing config.
109
-
110
- ---
111
-
112
- ## Step 1.5: Validate Signing Config (Only for --signed Builds)
113
-
114
- This step is ONLY executed when `--signed` is specified.
115
-
116
- 1. **Read `build-profile.json5`** in the project root.
117
-
118
- 2. **Check for `signingConfigs`** — Look for `app.signingConfigs` array.
119
- - If it exists and has at least one entry with valid `material` fields (`certpath`, `storeFile`, `profile`), proceed to step 3.
120
- - If missing or empty, **STOP and report**:
121
- > Signing configuration not found in `build-profile.json5`.
122
- > Please open the project in DevEco Studio, go to **File → Project Structure → Signing Configs**, enable **Automatically generate signature**, then re-run.
123
-
124
- 3. **Validate signing material files exist** — For the first entry in `signingConfigs`, check that the files referenced by `material.certpath`, `material.storeFile`, and `material.profile` actually exist on disk.
125
- - If any file is missing, **STOP and report** which files are missing.
126
-
127
- 4. **Ensure product references signing** — Check that the product entry in `products` array has `"signingConfig": "default"` (or matching name). Add it if missing.
128
-
129
- 5. Proceed to Step 2.
130
-
131
- ---
132
-
133
- ## Step 2: Build-Fix Loop
134
-
135
- Execute the following loop. **Maximum 20 iterations** to prevent infinite loops.
136
-
137
- ### 2.1 Run CLI Build
138
-
139
- **IMPORTANT (Windows)**: On Windows, bash `export PATH` does NOT propagate to Windows native child processes. You **must** use a temporary `.bat` file to set `PATH` and `JAVA_HOME`.
140
-
141
- 1. **Write a temporary batch file** (e.g. `<project-dir>/build_temp.bat`):
142
-
143
- **For unsigned builds** (no `--signed`):
144
- ```bat
145
- @echo off
146
- set "DEVECO_SDK_HOME=<DEVECO_HOME>\sdk"
147
- cd /d "<project-dir>"
148
- "<DEVECO_HOME>\tools\node\node.exe" "<DEVECO_HOME>\tools\hvigor\bin\hvigorw.js" assembleHap --mode module -p module=entry --no-daemon
149
- ```
150
-
151
- **For signed builds** (`--signed`):
152
- ```bat
153
- @echo off
154
- set "PATH=<DEVECO_HOME>\jbr\bin;%PATH%"
155
- set "JAVA_HOME=<DEVECO_HOME>\jbr"
156
- set "DEVECO_SDK_HOME=<DEVECO_HOME>\sdk"
157
- cd /d "<project-dir>"
158
- "<DEVECO_HOME>\tools\node\node.exe" "<DEVECO_HOME>\tools\hvigor\bin\hvigorw.js" assembleHap --mode module -p module=entry --no-daemon
159
- ```
160
- Note: Signed builds need `JAVA_HOME` and `jbr\bin` in PATH because the `SignHap` step spawns `java` as a child process.
161
-
162
- Use backslashes (`\`) in paths inside the `.bat` file (Windows convention).
163
-
164
- 2. **Run the batch file** via `cmd.exe`:
165
- ```bash
166
- cmd.exe //c "<project-dir>/build_temp.bat" 2>&1
167
- ```
168
-
169
- 3. **Delete the batch file** after the build completes (success or failure).
170
-
171
- - Capture the **full output** into a variable.
172
- - The build command may take 1-3 minutes. Use a timeout of 300000ms (5 minutes).
173
-
174
- ### 2.2 Check Build Result
175
-
176
- - If output contains `BUILD SUCCESSFUL` → **Build succeeded!** Exit the loop, go to Step 3.
177
- - If output contains `ERROR` or `BUILD FAILED` → Parse errors and continue to 2.3.
178
-
179
- ### 2.3 Parse Errors
180
-
181
- Extract error information from the build output. Errors typically appear in these formats:
182
-
183
- ```
184
- ERROR: <file-path>:<line>:<col> - <error-code>: <message>
185
- ```
186
-
187
- or
188
-
189
- ```
190
- ArkTS:ERROR File: <file-path>:<line>:<col>
191
- <error message>
192
- ```
193
-
194
- Group errors by file. Focus on **actual errors**, not warnings.
195
-
196
- ### 2.4 Fix Errors
197
-
198
- Read each file that has errors and apply fixes. Use the error reference table below to identify and fix common issues:
199
-
200
- | Error Code / Pattern | Message | Fix |
201
- |---|---|---|
202
- | `arkts-limited-throw` | "throw statements cannot accept values of arbitrary types" | Change `throw err` to `throw (err instanceof Error) ? err : new Error(String(err))` |
203
- | `arkts-no-obj-literals-as-types` | "Object literals cannot be used as type declarations" | Define a named `interface` instead of inline `{ key: Type }` |
204
- | `arkts-no-untyped-obj-literals` | "Object literal must correspond to some explicitly declared class or interface" | Assign to typed variable: `const r: MyInterface = {...}; return r;` |
205
- | `arkts-no-any-type` / `any` type usage | "Use explicit types instead of any" | Replace `any` with the correct concrete type or `object` |
206
- | `arkts-no-var` | "Use 'let' or 'const' instead of 'var'" | Replace `var` with `let` or `const` |
207
- | `10903329` | "Unknown resource name 'xxx'" | Verify resource exists in `resources/base/media/` or `element/*.json`. Use `layered_image` as fallback for missing images. **Special case**: `$r('sys.media.ohos_ic_public_xxx')` references system icons — replace with `$r('app.media.ic_public_xxx')` and add the icon file to `resources/base/media/` |
208
- | `10505001` | "Resource[] is not assignable to ResourceColor" | Remove array brackets: `.fontColor($r('app.color.x'))` not `.fontColor([$r('app.color.x')])` |
209
- | `00303221` | "permission must be a value that is predefined within the SDK" | Remove invalid permission from `module.json5`. See valid permissions list below |
210
- | Missing import | "Cannot find name 'xxx'" | Add the correct import (see import reference below) |
211
- | Missing `async` | "await expression requires async function" | Add `async` to the enclosing function |
212
- | Missing `build()` | "@Component must have build() method" | Add a `build() {}` method to the @Component struct |
213
- | Type mismatch | Various type errors | Fix the type annotation or cast appropriately |
214
- | Duplicate identifier | "Duplicate identifier 'xxx'" | Remove or rename the duplicate declaration |
215
-
216
- **For errors NOT in the table above**: Read the error message carefully, read the relevant source file, understand the context, and apply an appropriate fix. Use your knowledge of ArkTS/HarmonyOS to determine the correct solution.
217
-
218
- ### 2.5 Log Progress
219
-
220
- After each fix iteration, briefly report:
221
- - Iteration number
222
- - Number of errors found
223
- - Summary of fixes applied
224
- - Whether re-building
225
-
226
- Then go back to **2.1** and rebuild.
227
-
228
- ---
229
-
230
- ## Step 2.6: Copy HAP to Output Directory
231
-
232
- If `output_path` was provided, copy the built **entry HAP** to the output directory after a successful build. build-fixer produces only the authoritative entry HAP; collecting in-app HSPs (and any feature HAPs) is the **caller's** job — the invoking skill's mtime-gated Package-Set Collection re-harvests freshly-rebuilt packages from the build tree. Do **not** blind-glob HSPs here: build-fixer runs no clean, so a glob would admit **stale** `.hsp` left by a prior build.
233
-
234
- 1. **Locate the HAP file** under `<project-dir>/entry/build/default/outputs/default/`:
235
- - If `--signed`: search for `*-signed.hap`
236
- - If unsigned (no `--signed`): search for `*-unsigned.hap`
237
- 2. **Copy** the HAP to the output directory:
238
- ```bash
239
- cp "<hap_path>" "<output_path>/"
240
- ```
241
- 3. **Verify** the copied file exists in `output_path`.
242
- 4. If no matching HAP is found, report the issue in `build-fix-report.md` and note the expected path.
243
-
244
- ---
245
-
246
- ## Step 3: Build Success — Write Report and Commit
247
-
248
- When the build succeeds (or max iterations reached), write `build-fix-report.md` to the output directory. Include:
249
-
250
- 1. **Build Status**: SUCCESS / FAILED (max iterations reached)
251
- 2. **Build Type**: Signed HAP or Unsigned HAP
252
- 3. **Signing** (if signed): Confirm signing config from `build-profile.json5` was used
253
- 4. **Iterations**: How many build-fix cycles were needed
254
- 5. **Total Errors Fixed**: Count of errors fixed across all iterations
255
- 6. **Summary of Changes**: List of files modified and what was fixed in each
256
- 7. **Output HAP Path** (on success):
257
- - Signed: `<project>/entry/build/default/outputs/default/entry-default-signed.hap`
258
- - Unsigned: `<project>/entry/build/default/outputs/default/entry-default-unsigned.hap`
259
- 8. **Remaining Errors** (on failure): Each error with file, line, message, and analysis
260
-
261
- ---
262
-
263
- ## Step 3.5: Git Commit (if code was modified)
264
-
265
- After writing `build-fix-report.md`, commit the changes if any source files were modified.
266
-
267
- **Condition**: Run this step only when the build succeeded AND total errors fixed > 0 (i.e., at least one file was modified during the fix loop).
268
-
269
- 1. **Check if the project is in a git repository**:
270
- ```bash
271
- cd "<project-dir>" && git rev-parse --is-inside-work-tree
272
- ```
273
-
274
- 2. **If yes, commit all changes**:
275
- ```bash
276
- cd "<project-dir>"
277
- git add -A
278
- git commit -m "fix(build): fix {N} compilation errors
279
-
280
- Iterations: {K}
281
- Files modified: {comma-separated list of modified files}
282
- "
283
- ```
284
- (where N = total errors fixed, K = number of build-fix iterations)
285
-
286
- 3. **Capture the commit ID**:
287
- ```bash
288
- cd "<project-dir>" && git rev-parse HEAD
289
- ```
290
-
291
- 4. **Write commit info** to `<output_path>/build-fix-commit-info.md`:
292
- ```
293
- commit_id: <commit_id>
294
- ```
295
-
296
- **If no source files were modified** (build succeeded on first attempt with zero errors):
297
- - Write `<output_path>/build-fix-commit-info.md` with:
298
- ```
299
- commit_id: none
300
- ```
301
-
302
- **If not in a git repository**:
303
- - Record issue "Not a git repository — skipped commit" in `build-fix-report.md`.
304
- - Write `<output_path>/build-fix-commit-info.md` with:
305
- ```
306
- commit_id: none
307
- ```
308
-
309
- **If `output_path` was not provided**, skip writing `build-fix-commit-info.md`.
310
-
311
- ---
312
-
313
- ## Reference: Common HarmonyOS Imports
314
-
315
- ```typescript
316
- // Network
317
- import { http } from '@kit.NetworkKit';
318
-
319
- // Data persistence
320
- import { preferences } from '@kit.ArkData';
321
- import { relationalStore } from '@kit.ArkData';
322
-
323
- // UI utilities
324
- import { router } from '@kit.ArkUI';
325
- import { promptAction } from '@kit.ArkUI';
326
-
327
- // Ability & Context
328
- import { UIAbility, AbilityConstant, Want } from '@kit.AbilityKit';
329
- import { common } from '@kit.AbilityKit';
330
-
331
- // File I/O
332
- import { fileIo } from '@kit.CoreFileKit';
333
-
334
- // Logging
335
- import { hilog } from '@kit.PerformanceAnalysisKit';
336
-
337
- // JSON parsing — built-in, no import needed
338
- // ArkUI built-in components (Text, Column, Row, List, Button, Image, etc.) — NO import needed
339
- ```
340
-
341
- ## Reference: Valid Permission Names
342
-
343
- Commonly used SDK-validated permissions for `module.json5`:
344
-
345
- - `ohos.permission.INTERNET`
346
- - `ohos.permission.GET_NETWORK_INFO`
347
- - `ohos.permission.GET_WIFI_INFO`
348
- - `ohos.permission.KEEP_BACKGROUND_RUNNING`
349
- - `ohos.permission.PUBLISH_AGENT_REMINDER`
350
- - `ohos.permission.CAMERA`
351
- - `ohos.permission.MICROPHONE`
352
- - `ohos.permission.APPROXIMATELY_LOCATION`
353
- - `ohos.permission.LOCATION`
354
- - `ohos.permission.READ_MEDIA`
355
- - `ohos.permission.WRITE_MEDIA`
356
- - `ohos.permission.USE_BLUETOOTH`
357
- - `ohos.permission.VIBRATE`
358
-
359
- **Note**: `ohos.permission.NOTIFICATION` does NOT exist. When in doubt, omit the permission.
360
-
361
- ## Reference: ArkTS Strict Mode Rules
362
-
363
- All code must comply with ArkTS strict mode:
364
-
365
- 1. **No `any` type** — Use explicit types or `object`
366
- 2. **No `var`** — Only `let` and `const`
367
- 3. **No dynamic property access** — Use typed interfaces instead of `obj['key']` on typed objects
368
- 4. **`throw` must throw Error instances** — Never `throw 'string'` or `throw unknownVar`
369
- 5. **All object literals must match declared interfaces** — No anonymous `{ key: val }` returns without a matching interface
370
- 6. **No inline object literal types** — `function(): { a: string }` is forbidden; define a named `interface`
371
- 7. **All `@Component` structs must have `build()`** — Missing build method is a compile error
372
- 8. **`$r()` resource references validated at compile time** — All referenced resources must exist
373
- 9. **`fontColor()` expects `ResourceColor`**, not `Resource[]` — Don't wrap in array brackets (exception: `SymbolGlyph`)
374
- 10. **Permission names in `module.json5`** — Must be SDK-predefined values
375
-
376
- ## Guidelines
377
-
378
- - **Timeout**: Individual build commands may take up to 5 minutes. Use a 300000ms timeout.
379
- - **Max iterations**: Stop after 20 iterations to prevent infinite loops. If build still fails after 20 attempts, report the remaining errors.
380
- - **Don't over-fix**: Only fix errors reported by the compiler. Don't proactively refactor unrelated code.
381
- - **Read before edit**: Always read a file before modifying it. Understand the surrounding context.
382
- - **One error can cause many**: A single root-cause fix (like adding a missing interface) may resolve multiple reported errors. After fixing root causes, rebuild to see remaining issues.
383
- - **ohpm errors**: If the build fails because of missing packages, run `ohpm install` again.
384
- - **Quote all paths**: Paths may contain spaces (e.g., `D:\DevEco Studio\...`), always wrap in quotes.
385
- - **Run commands from the project root**: Build commands must execute with `cwd` set to the HarmonyOS project path.
@@ -1,105 +0,0 @@
1
- # Android Platform Tokens — Strip List
2
-
3
- **Read when**: 3.5 Synthesize, for the platform-token strip list (Principle 6).
4
-
5
- The spec MUST NOT contain Android platform tokens. During 3.5 synthesis, strip every match from the trace's natural-language behavior text and replace with behavior-level Chinese vocabulary. The trace itself may use these tokens (they live in `file:line` anchors and code-layer notes); only the **final spec** must be platform-token-free.
6
-
7
- ## Strip list (by category)
8
-
9
- ### Components
10
- `Activity`, `Fragment`, `Composable`, `Service`, `ForegroundService`, `BroadcastReceiver`, `ContentProvider`, `Application`, `Worker`, `IntentService`, `JobIntentService`, `JobScheduler`
11
-
12
- ### IPC / data carriers
13
- `Intent`, `PendingIntent`, `Bundle`, `Parcelable`, `Messenger`, `AIDL`, `Binder`, `IBinder`
14
-
15
- ### State / architecture
16
- `ViewModel`, `LiveData`, `MutableLiveData`, `StateFlow`, `SharedFlow`, `Flow` (when meaning Kotlin Flow), `mutableStateOf`, `ViewBinding`, `DataBinding`, `Repository`, `UseCase`, `Presenter`
17
-
18
- ### Persistence
19
- `Room`, `RoomDatabase`, `DAO`, `@Entity`, `DataStore`, `Preferences DataStore`, `Proto DataStore`, `SharedPreferences`, `MMKV`, `SQLiteOpenHelper`, `ContentResolver`
20
-
21
- ### Lifecycle
22
- `onCreate`, `onStart`, `onResume`, `onPause`, `onStop`, `onDestroy`, `Lifecycle`, `LifecycleOwner`, `ProcessLifecycleOwner`, `viewLifecycleOwner`, `lifecycleScope`
23
-
24
- ### UI containers / widgets
25
- `RecyclerView`, `Adapter`, `ViewHolder`, `ConstraintLayout`, `LinearLayout`, `FrameLayout`, `RelativeLayout`, `ScrollView`, `ListView`, `Spinner`, `ViewPager`, `TabLayout`
26
-
27
- ### UI feedback
28
- `Toast`, `Snackbar`, `Dialog`, `AlertDialog`, `BottomSheetDialog`, `ProgressDialog`, `FloatingActionButton`
29
-
30
- ### Navigation
31
- `NavController`, `NavGraph`, `NavHostFragment`, `Navigation Component`, `startActivity`, `startActivityForResult`
32
-
33
- ### Resources / IDs
34
- `R.id.*`, `R.layout.*`, `R.string.*`, `R.drawable.*`, `R.color.*`, `R.dimen.*`, `R.menu.*`, `R.xml.*`, `R.array.*`, `R.style.*`, `@+id/...`, `@string/...`, `@drawable/...`, `@color/...`
35
-
36
- ### Coroutines / threading
37
- `Coroutine`, `suspend`, `CoroutineScope`, `Job`, `viewModelScope`, `withContext`, `Dispatchers.*`, `async`, `await`, `launch`, `Handler`, `Looper`, `HandlerThread`, `AsyncTask`, `Executor`
38
-
39
- ### Compose (lifecycle / state)
40
- `@Composable`, `remember`, `derivedStateOf`, `rememberSaveable`, `MutableState`, `LaunchedEffect`, `DisposableEffect`, `SideEffect`, `CompositionLocal`, `produceState`
41
-
42
- ### Compose Shape
43
- `CircleShape`, `RoundedCornerShape`, `RectangleShape`, `CutCornerShape`
44
-
45
- ### Compose Animation
46
- `LinearEasing`, `FastOutSlowInEasing`, `EaseInOut`, `EaseOut`, `tween`, `spring`, `keyframes`, `infiniteRepeatable`, `animateXxxAsState`, `Animatable`, `AnimationSpec`
47
-
48
- ### Compose Layout / Modifier
49
- `ContentScale` (Fit / Crop / FillBounds / Inside / None), `Alignment`, `Arrangement`, `Modifier.clip`, `Modifier.background`, `Modifier.size`, `Modifier.padding`, `Modifier.fillMaxSize`, `Modifier.wrapContentSize`, `Modifier.aspectRatio`, `Modifier.weight`
50
-
51
- ### Build / Manifest
52
- `AndroidManifest`, `build.gradle`, `gradle`, `BuildConfig`, `applicationId`, `versionCode`, `minSdkVersion`, `targetSdkVersion`, `compileSdkVersion`, `ProGuard`, `R8`
53
-
54
- ### DI
55
- `Hilt`, `Dagger`, `@Inject`, `@Module`, `@Provides`, `@Singleton`, `Koin`, `ServiceLocator`
56
-
57
- ### System services / media
58
- `ContextCompat`, `getSystemService`, `NotificationManager`, `NotificationChannel`, `AlarmManager`, `PowerManager`, `ConnectivityManager`, `AudioManager`, `MediaSession`, `MediaPlayer`, `ExoPlayer`, `MediaBrowserServiceCompat`
59
-
60
- ### Implementation constants (NEVER appear in spec)
61
-
62
- - **Hardcoded dimensions** (`8dp`, `48.dp`, `16.sp`, `2.dp`) — strip entirely. Spec describes shape/size semantically: "圆形" / "小圆点" / "歌词字号比正文略大". 不要保留单位 ("8 dp" 也不行).
63
- - **Hardcoded durations** (`25000ms`, `300L`, `Duration.seconds(2)`) — restate as semantic time: "约 25 秒一圈" / "短暂淡入". 不要写原始数值.
64
- - **Persistence key literals** (`circle_playback_cover`, `karaoke_mode_compat`, `floating_lyric_enabled`) — NEVER. Describe the user-visible setting, not the storage key.
65
-
66
- ## Critical: Chinese translations of platform concepts are ALSO forbidden
67
-
68
- The strip list above uses English API names. But platform concepts translated into Chinese (e.g. `活动基类` for Activity / `主活动页面` for MainActivity / `媒体会话信息` for MediaSession / `短边模式` for DISPLAY_CUTOUT_MODE / `广播接收器` for BroadcastReceiver / `视图模型` for ViewModel) are STILL platform tokens — restate them in user-facing behavior language per the replacement vocabulary below. Translating a platform concept does NOT make it user-facing.
69
-
70
- ## Replacement vocabulary (behavior-level Chinese)
71
-
72
- | Stripped token | Spec vocabulary |
73
- |---|---|
74
- | Activity / Fragment / Composable | 页面 |
75
- | Dialog / AlertDialog / BottomSheet | 弹窗 / 对话框 |
76
- | Toast / Snackbar | toast 提示 / 浮动提示 |
77
- | ViewModel / LiveData / StateFlow / mutableStateOf | 状态 / 状态写入 / 状态刷新 |
78
- | Room / DAO / DataStore / SharedPreferences / MMKV | 持久化 / 数据库 / 配置存储 |
79
- | RecyclerView + Adapter / ListView | 列表 / 列表项 |
80
- | onClick / onLongClick / onTap | 点击 / 长按 |
81
- | Intent / startActivity / Navigation | 跳转 / 进入<目标页> |
82
- | BroadcastReceiver / sendBroadcast | 系统事件监听 / 广播 |
83
- | Service / ForegroundService | 后台服务 / 前台服务 |
84
- | Coroutine / launch / withContext | 异步 / 异步执行 |
85
- | MediaPlayer / ExoPlayer / MediaSession | 播放器 / 播放控制 |
86
- | Notification / NotificationManager / NotificationChannel | 通知 / 通知栏 / 通知分组 |
87
- | ContentResolver / ContentProvider | 数据访问 / 数据共享 |
88
- | build.gradle flag / BuildConfig | 编译开关 / 配置项 |
89
- | ConnectivityManager | 网络状态 / 网络可达性 |
90
- | AudioManager / audio focus | 音频焦点 / 音频通道 |
91
- | PowerManager / WakeLock | 屏幕唤醒 / 锁屏唤醒 |
92
- | CircleShape / RoundedCornerShape / RectangleShape / CutCornerShape | 圆形 / 圆角矩形 / 矩形 / 切角矩形 |
93
- | LinearEasing / FastOutSlowInEasing / EaseInOut / EaseOut | 线性 / 减速 / 缓入缓出 / 减速出 |
94
- | tween / spring / keyframes / infiniteRepeatable / Animatable | 持续N秒动画 / 弹性动画 / 关键帧动画 / 循环动画 / 动画对象 |
95
- | ContentScale.Fit / Crop / FillBounds / Inside / None | 等比缩放适配 / 裁剪填充 / 拉伸填充 / 等比居中 / 不缩放 |
96
- | Modifier.clip / .size / .padding / .fillMaxSize / .aspectRatio | 裁剪为X形 / 设定尺寸 / 内边距 / 填满父容器 / 宽高比 |
97
- | Modifier.wrapContentSize / .weight / .background | 内容自适应 / 权重占比 / 背景 |
98
- | animateXxxAsState | 动画过渡到目标值 |
99
-
100
- ## Items to keep verbatim (do NOT strip)
101
-
102
- - **Business entity names** (歌单, 歌曲, 专辑, 艺术家, 播放页, ...) — these are domain language, not platform tokens.
103
- - **User-visible resource string content** (toast text, button labels, error messages) — translate the displayed content into the spec; strip the `R.string.xxx` reference but keep the message text.
104
- - **Standard permission semantics** — describe permissions in user language ("录音权限", "通知权限", "存储访问权限"), NOT by code constant (`RECORD_AUDIO`, `POST_NOTIFICATIONS`, ...).
105
- - **Persistence key literals** are usually internal — do NOT surface them in the spec unless they appear in user-visible UI (rare). If a key appears in the trace's `interaction` field, describe its behavior, not its name.
@@ -1,78 +0,0 @@
1
- # Spec Sample 1 — Boundary-and-happy-path Decomposition
2
-
3
- **Style focus**: how to slice one feature into `empty / over-length / valid / cancel` atomic scenarios on a single-entry trigger flow. Mimic the voice, scenario granularity, and structure — NOT the vocabulary or domain.
4
-
5
- **Read when**: 3.5 Synthesize.
6
-
7
- ---
8
-
9
- # 新建歌单SPEC
10
-
11
- 创建新歌单
12
-
13
- ## 场景一
14
-
15
- ### 场景概述
16
-
17
- 用户点击创建歌单,但输入的歌单名称为空并且创建歌单
18
-
19
- ### 场景逻辑步骤
20
-
21
- - 1. 用户在"歌单页面"点击"更多菜单"中的"新建歌单按钮"或者用户在"添加到歌单弹窗"中点击"新建歌单按钮"
22
- - 2. 弹出"新建歌单对话框"
23
- - 3. 用户在输入框中输入空白歌单名称并点击确定按钮
24
- - 4. 弹出toast"歌单名称不得为空"并且关闭"新建歌单对话框"
25
-
26
- ## 场景二
27
-
28
- ### 场景概述
29
-
30
- 用户点击创建歌单,但输入的歌单名称超过最大长度并且创建歌单
31
-
32
- ### 场景逻辑步骤
33
-
34
- - 1. 用户在"歌单页面"点击"更多菜单"中的"新建歌单按钮"或者用户在"添加到歌单弹窗"中点击"新建歌单按钮"
35
- - 2. 弹出"新建歌单对话框"
36
- - 3. 用户在输入框中输入歌单名称并且歌单名称超过100个字符,然后点击确定按钮
37
- - 4. 弹出toast"歌单名称过长"并且关闭"新建歌单对话框"
38
-
39
- ## 场景三
40
-
41
- ### 场景概述
42
-
43
- 用户点击创建歌单,输入有效歌单名称并且创建歌单
44
-
45
- ### 场景逻辑步骤
46
-
47
- - 1. 用户在"歌单页面"点击"更多菜单"中的"新建歌单按钮"或者用户在"添加到歌单弹窗"中点击"新建歌单按钮"
48
- - 2. 弹出"新建歌单对话框"
49
- - 3. 用户在输入框中输入有效歌单名称,即用户输入到歌单名称不为空并且歌单名称没有超过100个字符,然后点击确定按钮
50
- - 4. 去除歌单名称首尾空白字符
51
- - 5. 把新建的歌单数据写入数据库中的歌单数据库表
52
- - 6. 如果是在"歌单页面",那么从数据库中读取新建歌单的数据,并且在"歌单页面"创建新建歌单item,实时刷新歌单页面,在歌单页面列表中的第一个位置上显示新建的歌单
53
- - 7. 如果是在"添加到歌单弹窗",那么从数据库中读取新建歌单的数据,并且在"添加到歌单弹窗"创建新建歌单item,实时刷新歌单页面,在添加到歌单弹窗列表中的第一个位置上显示新建的歌单
54
-
55
- > [偏差] 需求要求歌单名为空时禁用"确定"按钮,但实际代码允许点击后弹出 toast 提示(参见场景一步骤 4)。
56
-
57
- ## 场景四
58
-
59
- ### 场景概述
60
-
61
- 用户点击创建歌单,输入或者不输入歌单名称,然后点击取消按钮
62
-
63
- ### 场景逻辑步骤
64
-
65
- - 1. 用户在"歌单页面"点击"更多菜单"中的"新建歌单按钮"或者用户在"添加到歌单弹窗"中点击"新建歌单按钮"
66
- - 2. 弹出"新建歌单对话框"
67
- - 3. 无论用户是否在输入框中输入歌单名称,只要用户点击取消按钮,那么就关闭"新建歌单对话框",无需执行其他操作
68
-
69
- ## 场景五
70
-
71
- ### 场景概述
72
-
73
- "新建歌单"功能的作用范围与不作用范围
74
-
75
- ### 场景逻辑步骤
76
-
77
- - 1. **仅作用于** 以下入口: "歌单页面"的"更多菜单 - 新建歌单"按钮; "添加到歌单弹窗"的"新建歌单"按钮
78
- - 2. **不作用于** 以下位置: "歌单详情页"(无新建入口) / "播放页" / "首页推荐区域" / "搜索结果页" / "我的页面" — 这些位置既不显示新建歌单入口, 也不响应新建歌单事件
@@ -1,58 +0,0 @@
1
- # Spec Sample 2 — Nested Sub-bullet Decomposition
2
-
3
- **Style focus**: how to express per-field present/absent fallback rules as nested sub-bullets within a single scenario's flow. Mimic the structure, NOT the vocabulary or domain.
4
-
5
- **Read when**: 3.5 Synthesize.
6
-
7
- ---
8
-
9
- # 歌曲信息页信息展示与信息更新SPEC
10
-
11
- 歌曲信息页展示音频信息、出自专辑、参与创作的艺术家,以及播放界面保持屏幕唤醒、沉浸模式内容。
12
-
13
- ## 场景一
14
-
15
- ### 场景概述
16
-
17
- 进入歌曲信息页后,展示当前播放歌曲的信息及相关功能入口
18
-
19
- ### 场景逻辑步骤
20
-
21
- - 1. 在播放页右滑进入歌曲信息页
22
- - 2. 歌曲信息页读取信息并展示:
23
- - 2.1 音频信息展示:
24
- - 当当前播放歌曲的音频格式存在时,显示当前播放歌曲的音频格式
25
- - 当当前播放歌曲的音频格式缺失时,显示当前播放歌曲的文件扩展名;若文件扩展名也为空,则显示为空白
26
- - 当当前播放歌曲的声道数存在时,显示声道数
27
- - 当当前播放歌曲的声道数缺失时,隐藏该字段
28
- - 当当前播放歌曲的采样率存在时,显示采样率
29
- - 当当前播放歌曲的采样率缺失时,隐藏该字段
30
- - 当当前播放歌曲的比特率存在时,显示比特率
31
- - 当当前播放歌曲的比特率缺失时,显示 0 Kbps
32
- - 2.2 出自专辑展示:
33
- - 当当前播放歌曲的专辑封面存在时,显示专辑封面
34
- - 当当前播放歌曲的专辑封面缺失时,显示默认专辑封面图标
35
- - 当当前播放歌曲的专辑标题存在时,显示专辑标题
36
- - 当当前播放歌曲的专辑标题缺失时,显示"未知专辑标题"
37
- - 当当前播放歌曲的专辑艺术家存在时,显示专辑艺术家
38
- - 当当前播放歌曲的专辑艺术家缺失时,显示"未知专辑艺术家"
39
- - 2.3 参与创作的艺术家展示:
40
- - 当当前播放歌曲的艺术家头像存在时,显示艺术家头像
41
- - 当当前播放歌曲的艺术家头像缺失时,显示默认歌曲封面图标
42
- - 当当前播放歌曲的艺术家名称存在时,显示艺术家名称
43
- - 当当前播放歌曲的艺术家名称缺失时,显示"未知艺术家"
44
- - 当当前播放歌曲的艺术家音轨数量(歌曲数量)存在时,显示艺术家音轨数量(歌曲数量)
45
- - 当当前播放歌曲的艺术家音轨数量(歌曲数量)缺失时,显示 0
46
-
47
-
48
- ## 场景二
49
-
50
- ### 场景概述
51
-
52
- 切换播放歌曲后,歌曲信息页面同步刷新
53
-
54
- ### 场景逻辑步骤
55
-
56
- - 1. 在播放页右滑进入歌曲信息页
57
- - 2. 用户通过上一首、下一首、播放队列切歌或自动切歌等方式切换当前播放歌曲
58
- - 3. 歌曲信息页中的音频信息、专辑信息、艺术家信息同步刷新为新歌曲对应内容