android2harmony 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.
Files changed (82) hide show
  1. package/README.md +407 -0
  2. package/agents/build-fixer.md +385 -0
  3. package/agents/code-reviewer.md +478 -0
  4. package/agents/logic-coder.md +212 -0
  5. package/agents/logic-context-builder.md +199 -0
  6. package/agents/scripts/hmos-precheck/arkts.mjs +534 -0
  7. package/agents/scripts/hmos-precheck/codelinter.mjs +362 -0
  8. package/agents/scripts/hmos-precheck/index.mjs +926 -0
  9. package/agents/scripts/platform_query.mjs +535 -0
  10. package/dist/index.js +179 -0
  11. package/dist/index.js.map +7 -0
  12. package/package.json +29 -0
  13. package/skills/hmos-batch-ui-align/SKILL.md +141 -0
  14. package/skills/hmos-batch-ui-align/references/conversion-procedure.md +217 -0
  15. package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -0
  16. package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -0
  17. package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -0
  18. package/skills/hmos-batch-ui-align/references/mvvm/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +648 -0
  19. package/skills/hmos-batch-ui-align/references/mvvm/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +2089 -0
  20. package/skills/hmos-batch-ui-align/references/mvvm/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +1033 -0
  21. package/skills/hmos-batch-ui-align/references/mvvm/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +1183 -0
  22. package/skills/hmos-batch-ui-align/references/mvvm/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +576 -0
  23. package/skills/hmos-batch-ui-align/references/mvvm/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +297 -0
  24. package/skills/hmos-batch-ui-align/references/mvvm/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +395 -0
  25. package/skills/hmos-batch-ui-align/references/mvvm/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +903 -0
  26. package/skills/hmos-batch-ui-align/references/mvvm/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +106 -0
  27. package/skills/hmos-batch-ui-align/references/mvvm/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +1178 -0
  28. package/skills/hmos-batch-ui-align/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -0
  29. package/skills/hmos-batch-ui-align/references/mvvm/PersistentStorage/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 +355 -0
  30. package/skills/hmos-batch-ui-align/references/mvvm//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +11 -0
  31. package/skills/hmos-batch-ui-align/scripts/android_parse_fast.ts +1750 -0
  32. package/skills/hmos-convert-pipeline/SKILL.md +446 -0
  33. package/skills/hmos-fix-build-errors/SKILL.md +281 -0
  34. package/skills/hmos-fix-build-errors/references/arkts-strict-patterns.md +219 -0
  35. package/skills/hmos-fix-build-errors/references/known-patterns.md +157 -0
  36. package/skills/hmos-fix-build-errors/references/rdb-entity-pattern.md +131 -0
  37. package/skills/hmos-resources-convert/SKILL.md +654 -0
  38. package/skills/hmos-resources-convert/references/conversion-rules.md +663 -0
  39. package/skills/hmos-resources-convert/references/dependency-analysis-rules.md +388 -0
  40. package/skills/hmos-resources-convert/references/resource-mapping-rules.md +457 -0
  41. package/skills/hmos-resources-convert/references/xml-drawable-to-svg-rules.md +513 -0
  42. package/skills/hmos-resources-convert/template/AppScope/app.json5 +10 -0
  43. package/skills/hmos-resources-convert/template/AppScope/resources/base/element/string.json +8 -0
  44. package/skills/hmos-resources-convert/template/AppScope/resources/base/media/background.png +0 -0
  45. package/skills/hmos-resources-convert/template/AppScope/resources/base/media/foreground.png +0 -0
  46. package/skills/hmos-resources-convert/template/AppScope/resources/base/media/layered_image.json +7 -0
  47. package/skills/hmos-resources-convert/template/build-profile.json5 +42 -0
  48. package/skills/hmos-resources-convert/template/code-linter.json5 +32 -0
  49. package/skills/hmos-resources-convert/template/entry/build-profile.json5 +33 -0
  50. package/skills/hmos-resources-convert/template/entry/hvigorfile.ts +6 -0
  51. package/skills/hmos-resources-convert/template/entry/obfuscation-rules.txt +23 -0
  52. package/skills/hmos-resources-convert/template/entry/oh-package.json5 +10 -0
  53. package/skills/hmos-resources-convert/template/entry/src/main/ets/entryability/EntryAbility.ets +48 -0
  54. package/skills/hmos-resources-convert/template/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +16 -0
  55. package/skills/hmos-resources-convert/template/entry/src/main/ets/pages/Index.ets +23 -0
  56. package/skills/hmos-resources-convert/template/entry/src/main/module.json5 +55 -0
  57. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/color.json +8 -0
  58. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/float.json +8 -0
  59. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/string.json +16 -0
  60. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/background.png +0 -0
  61. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/foreground.png +0 -0
  62. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/layered_image.json +7 -0
  63. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/startIcon.png +0 -0
  64. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/backup_config.json +3 -0
  65. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/main_pages.json +5 -0
  66. package/skills/hmos-resources-convert/template/entry/src/main/resources/dark/element/color.json +8 -0
  67. package/skills/hmos-resources-convert/template/entry/src/mock/mock-config.json5 +2 -0
  68. package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/Ability.test.ets +35 -0
  69. package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/List.test.ets +5 -0
  70. package/skills/hmos-resources-convert/template/entry/src/ohosTest/module.json5 +16 -0
  71. package/skills/hmos-resources-convert/template/entry/src/test/List.test.ets +5 -0
  72. package/skills/hmos-resources-convert/template/entry/src/test/LocalUnit.test.ets +33 -0
  73. package/skills/hmos-resources-convert/template/hvigor/hvigor-config.json5 +23 -0
  74. package/skills/hmos-resources-convert/template/hvigorfile.ts +6 -0
  75. package/skills/hmos-resources-convert/template/oh-package-lock.json5 +28 -0
  76. package/skills/hmos-resources-convert/template/oh-package.json5 +10 -0
  77. package/skills/hmos-spec-generate/SKILL.md +413 -0
  78. package/skills/hmos-spec-generate/references/android-platform-tokens.md +105 -0
  79. package/skills/hmos-spec-generate/references/spec-sample-1.md +78 -0
  80. package/skills/hmos-spec-generate/references/spec-sample-2.md +58 -0
  81. package/skills/hmos-spec-generate/references/spec-sample-3.md +116 -0
  82. package/skills/hmos-spec-generate/references/step4-report-template.md +33 -0
@@ -0,0 +1,131 @@
1
+ # RDB Entity 确定性修复 Pattern
2
+ # 适用于: ArkTS 严格模式 + @kit.ArkData relationalStore
3
+ # 触发场景: 迁移 Android RDB 实体类到 ArkTS 时
4
+ # 经验来源: EinkBro 迁移 (2026-03-26)
5
+
6
+ ---
7
+
8
+ ## Pattern 1: ValuesBucket 正确用法
9
+
10
+ ### 错误写法 (编译报错)
11
+ ```typescript
12
+ import { relationalStore, ValuesBucket } from '@kit.ArkData';
13
+
14
+ toValuesBucket(): ValuesBucket {
15
+ const bucket = new ValuesBucket(); // ERROR: 'ValuesBucket' only refers to a type
16
+ bucket.put('key', value); // ERROR: ValuesBucket has no .put() method
17
+ return bucket;
18
+ }
19
+ ```
20
+
21
+ ### 正确写法
22
+ ```typescript
23
+ type EntityValuesBucket = Record<string, number | string | boolean | Uint8Array | null>;
24
+
25
+ toValuesBucket(): EntityValuesBucket {
26
+ const bucket: EntityValuesBucket = {};
27
+ bucket['key'] = value;
28
+ return bucket;
29
+ }
30
+ ```
31
+
32
+ **原因**: `ValuesBucket` 在 SDK 中是 type alias (`Record<string, ValueType>`),不是可实例化的类。
33
+
34
+ ---
35
+
36
+ ## Pattern 2: fromResultSet 参数类型 (禁止 any)
37
+
38
+ ### 错误写法 (编译报错)
39
+ ```typescript
40
+ // ArkTS 严格模式禁止 any
41
+ static fromResultSet(resultSet: any): EntityName { // ERROR: arkts-no-any-unknown
42
+ ```
43
+
44
+ ### 正确写法
45
+ ```typescript
46
+ static fromResultSet(resultSet: Object): EntityName {
47
+ const rs = resultSet as Record<string, Object>;
48
+ const colIndex = (name: string): number =>
49
+ (rs['getColumnIndex'] as Function)(name) as number;
50
+
51
+ entity.field = (rs['getLong'] as Function)(colIndex('field_name')) as number;
52
+ entity.name = (rs['getString'] as Function)(colIndex('name')) as string;
53
+ return entity;
54
+ }
55
+ ```
56
+
57
+ **替代方案** (更简洁但运行时开销略高):
58
+ ```typescript
59
+ // 使用类型断言避免 any,运行时通过 Record<string, Function> 调用
60
+ static fromResultSet(resultSet: Object): EntityName {
61
+ const getCol = (name: string): number =>
62
+ (resultSet as Record<string, Function>)['getColumnIndex'](name) as number;
63
+ const getLong = (name: string): number =>
64
+ (resultSet as Record<string, Function>)['getLong'](getCol(name)) as number;
65
+ const getStr = (name: string): string =>
66
+ (resultSet as Record<string, Function>)['getString'](getCol(name)) as string;
67
+
68
+ const entity = new EntityName();
69
+ entity.id = getLong('id');
70
+ entity.name = getStr('name');
71
+ return entity;
72
+ }
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Pattern 3: // @ts-ignore 不可用
78
+
79
+ ### 错误尝试
80
+ ```typescript
81
+ // @ts-ignore // ERROR: Switching off type checks with in-place comments is not allowed
82
+ static fromResultSet(resultSet: any): EntityName {
83
+ ```
84
+
85
+ ### 必须用 Pattern 2 替代
86
+
87
+ ---
88
+
89
+ ## Pattern 4: toValuesBucket() 返回类型注解
90
+
91
+ ```typescript
92
+ type EntityValuesBucket = Record<string, number | string | boolean | Uint8Array | null>;
93
+
94
+ toValuesBucket(): EntityValuesBucket {
95
+ const bucket: EntityValuesBucket = {} as EntityValuesBucket;
96
+ // ...
97
+ return bucket;
98
+ }
99
+ ```
100
+
101
+ ---
102
+
103
+ ## 完整 Entity 模板
104
+
105
+ ```typescript
106
+ type EntityValuesBucket = Record<string, number | string | boolean | Uint8Array | null>;
107
+
108
+ export class MyEntity {
109
+ id: number = 0;
110
+ name: string = '';
111
+ value: number = 0;
112
+
113
+ static fromResultSet(resultSet: Object): MyEntity {
114
+ const rs = resultSet as Record<string, Object>;
115
+ const col = (n: string): number => (rs['getColumnIndex'] as Function)(n) as number;
116
+ const entity = new MyEntity();
117
+ entity.id = (rs['getLong'] as Function)(col('id')) as number;
118
+ entity.name = (rs['getString'] as Function)(col('name')) as string;
119
+ entity.value = (rs['getLong'] as Function)(col('value')) as number;
120
+ return entity;
121
+ }
122
+
123
+ toValuesBucket(): EntityValuesBucket {
124
+ const bucket: EntityValuesBucket = {} as EntityValuesBucket;
125
+ if (this.id > 0) { bucket['id'] = this.id; }
126
+ bucket['name'] = this.name;
127
+ bucket['value'] = this.value;
128
+ return bucket;
129
+ }
130
+ }
131
+ ```