@harmonyos-arkts/d2h 0.0.0-stage → 0.1.1
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/.claude-plugin/marketplace.json +13 -0
- package/.claude-plugin/plugin.json +7 -0
- package/README.md +177 -2
- package/agents/android-to-hmos-00-orchestrator.md +312 -0
- package/agents/d2h.md +168 -0
- package/bin/install-opencode.mjs +57 -0
- package/install-opencode.sh +160 -0
- package/opencode/agents.json +16 -0
- package/package.json +43 -4
- package/schemas/android-source-manifest.schema.json +25 -0
- package/schemas/checkpoint-provenance.schema.json +67 -0
- package/schemas/final-acceptance.schema.json +29 -0
- package/schemas/managed-evidence-index.schema.json +15 -0
- package/schemas/managed-evidence.schema.json +114 -0
- package/schemas/migration-config.schema.json +51 -0
- package/schemas/migration-report-index.schema.json +39 -0
- package/schemas/migration-report-item.schema.json +51 -0
- package/schemas/migration-report-summary.schema.json +25 -0
- package/schemas/migration-status.schema.json +202 -0
- package/schemas/preflight.schema.json +60 -0
- package/schemas/source-order-audit.schema.json +16 -0
- package/schemas/source-provenance-event.schema.json +19 -0
- package/schemas/spec-app-shard.schema.json +45 -0
- package/schemas/spec-fact-corrections-shard.schema.json +13 -0
- package/schemas/spec-features-shard.schema.json +43 -0
- package/schemas/spec-index.schema.json +26 -0
- package/schemas/spec-interactions-shard.schema.json +40 -0
- package/schemas/spec-page.schema.json +98 -0
- package/schemas/spec-pages-index.schema.json +1 -0
- package/schemas/spec-unresolved-shard.schema.json +1 -0
- package/schemas/task-envelope.schema.json +55 -0
- package/schemas/task-plan.schema.json +123 -0
- package/skills/android2hmos_resources_convert/SKILL.md +162 -0
- package/skills/android2hmos_resources_convert/references/image-conversion-rules.md +230 -0
- package/skills/android2hmos_resources_convert/references/svg-fix-patterns.md +175 -0
- package/skills/android2hmos_resources_convert/references/xml-drawable-to-svg-rules.md +513 -0
- package/skills/appgraph-rule-audit/SKILL.md +58 -0
- package/skills/appgraph-rule-audit/references/audit-contract.md +47 -0
- package/skills/appgraph-rule-audit/references/recommendation-schema.md +41 -0
- package/skills/appgraph-rule-audit/schemas/rule-opportunities.schema.json +125 -0
- package/skills/arkts-app-identity/SKILL.md +238 -0
- package/skills/arkts-i18n/SKILL.md +496 -0
- package/skills/arkts-i18n/evals/evals.json +84 -0
- package/skills/arkts-i18n/references/code-examples.md +302 -0
- package/skills/arkts-i18n/references/common-pitfalls.md +391 -0
- package/skills/arkts-i18n/references/dynamic-language-switch.md +604 -0
- package/skills/arkts-i18n/references/hardcoded-string-scanner.md +348 -0
- package/skills/arkts-i18n/references/language-codes.md +104 -0
- package/skills/arkts-i18n/references/resource-file-structure.md +775 -0
- package/skills/arkts-i18n/references/static-vs-dynamic.md +242 -0
- package/skills/arkts-i18n/references/v1-compat.md +244 -0
- package/skills/arkts-i18n/scripts/audit_i18n_completeness.sh +174 -0
- package/skills/arkts-icon-sizing/SKILL.md +211 -0
- package/skills/arkts-icon-sizing/scripts/icon_audit.py +131 -0
- package/skills/arkts-icon-sizing/scripts/icon_autofix.py +88 -0
- package/skills/arkts-icon-sizing/scripts/icon_dims.py +179 -0
- package/skills/arkts-icon-sizing/scripts/icon_fix.py +119 -0
- package/skills/arkts-mvvm-architecture/SKILL.md +613 -0
- package/skills/harmonyos-migration-playbook/SKILL.md +56 -0
- package/skills/harmonyos-migration-playbook/agents/openai.yaml +7 -0
- package/skills/harmonyos-migration-playbook/references/arkts-compile.md +24 -0
- package/skills/harmonyos-migration-playbook/references/harmony-runtime.md +53 -0
- package/skills/harmonyos-migration-playbook/references/lesson-lifecycle.md +45 -0
- package/skills/harmonyos-migration-playbook/references/protocol-e2e.md +23 -0
- package/skills/harmonyos-migration-playbook/references/ui-automation.md +52 -0
- package/skills/harmonyos-migration-playbook/references/windows-environment.md +38 -0
- package/skills/maintaining-migration-report/SKILL.md +155 -0
- package/skills/native-library-substitution/SKILL.md +385 -0
- package/skills/native-library-substitution/references/native-library-substitution.json +56906 -0
- package/skills/native-library-substitution/references/native-library-substitution.md +163 -0
- package/skills/preparing-migration-workspace/SKILL.md +124 -0
- package/skills/preparing-migration-workspace/toolchain.json +43 -0
- package/skills/reviewing-migration-process/SKILL.md +62 -0
- package/src/install-opencode.mjs +110 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""第 3/3 步 —— 把还原出的尺寸插入 .ets 源码。
|
|
4
|
+
|
|
5
|
+
实时重扫(因此对行号位移健壮),对 icon_plan.json 中存在的每个欠约束静态图标:
|
|
6
|
+
- 既无 width 又无 height -> 插入 .width(W) .height(H) (固定标称 vp)
|
|
7
|
+
- 恰好只有一维 -> 插入 .aspectRatio(W/H) (保留有意的那一维,
|
|
8
|
+
如满宽横幅的 width('100%'),只修比例)
|
|
9
|
+
新修饰符插入在 `Image(...)` 开头之后、与原链同缩进,从而与 `.objectFit(...)` 等干净组合。
|
|
10
|
+
|
|
11
|
+
动态源图片(Image(this.foo())、三元 Image(cond ? a : b)、Builder `Image(param)`)
|
|
12
|
+
不自动改 —— 只报告,便于解析底层资源、用 icon_dims.py --icons 查尺寸后手工改。
|
|
13
|
+
|
|
14
|
+
安全
|
|
15
|
+
默认 dry-run(打印将要做的改动)。加 --apply 才落盘。
|
|
16
|
+
调用前记录允许修改的文件范围;需要恢复时只撤销本次输出清单中的修改,
|
|
17
|
+
不得暂存、提交或整体回滚调用方已有改动。
|
|
18
|
+
|
|
19
|
+
用法
|
|
20
|
+
python icon_fix.py --plan icon_plan.json --report icon_report.json # dry-run
|
|
21
|
+
python icon_fix.py --plan icon_plan.json --report icon_report.json --apply # 落盘
|
|
22
|
+
"""
|
|
23
|
+
import os, re, json, argparse
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def chain_end(lines, i):
|
|
27
|
+
base = len(lines[i]) - len(lines[i].lstrip())
|
|
28
|
+
j = i + 1
|
|
29
|
+
while j < len(lines):
|
|
30
|
+
if lines[j].strip() == '':
|
|
31
|
+
j += 1
|
|
32
|
+
continue
|
|
33
|
+
if (len(lines[j]) - len(lines[j].lstrip())) <= base:
|
|
34
|
+
break
|
|
35
|
+
j += 1
|
|
36
|
+
return j
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def apply_fixes(plan, report, apply=True):
|
|
40
|
+
"""对 report 标记的文件实时重扫,按 plan 给欠约束静态图标插入尺寸。
|
|
41
|
+
|
|
42
|
+
被 icon_fix.main() 与 icon_autofix.py 共用。
|
|
43
|
+
plan : {icon: {w,h,...}}(icon_dims.build_plan 产出)
|
|
44
|
+
report : icon_report.json 内容(取 flagged 的文件集合作为作用域)
|
|
45
|
+
apply : True 落盘,False 仅计算(dry-run)
|
|
46
|
+
返回 (applied, dynamic):applied 为修复描述行列表,dynamic 为动态源待手工项。
|
|
47
|
+
"""
|
|
48
|
+
files = sorted({f['file'] for f in report['flagged']}) # 仅针对被标记的文件
|
|
49
|
+
applied, dynamic = [], []
|
|
50
|
+
for path in files:
|
|
51
|
+
if not os.path.exists(path):
|
|
52
|
+
continue
|
|
53
|
+
lines = open(path, encoding='utf-8').read().split('\n')
|
|
54
|
+
edits = []
|
|
55
|
+
for i, ln in enumerate(lines):
|
|
56
|
+
st = ln.lstrip()
|
|
57
|
+
if st.startswith('*') or st.startswith('//') or st.startswith('/*'):
|
|
58
|
+
continue
|
|
59
|
+
code = ln.split('//')[0]
|
|
60
|
+
if not re.search(r'\bImage\(', code):
|
|
61
|
+
continue
|
|
62
|
+
end = chain_end(lines, i)
|
|
63
|
+
win = '\n'.join(lines[i + 1:end])
|
|
64
|
+
has_w, has_h = '.width(' in win, '.height(' in win
|
|
65
|
+
has_size, has_aspect = '.size(' in win, '.aspectRatio(' in win
|
|
66
|
+
has_weight = '.layoutWeight(' in win
|
|
67
|
+
w100, h100 = ".width('100%')" in win, ".height('100%')" in win
|
|
68
|
+
ok = has_size or (has_w and has_h) or ((has_w ^ has_h) and (has_aspect or has_weight))
|
|
69
|
+
if ok or (w100 and h100):
|
|
70
|
+
continue
|
|
71
|
+
m = re.search(r"(?:app|sys)\.media\.([A-Za-z0-9_]+)", code)
|
|
72
|
+
if not m:
|
|
73
|
+
dynamic.append(f'{path}:{i + 1} {st[:55]}')
|
|
74
|
+
continue
|
|
75
|
+
icon = m.group(1)
|
|
76
|
+
if icon not in plan:
|
|
77
|
+
continue
|
|
78
|
+
w, h = plan[icon]['w'], plan[icon]['h']
|
|
79
|
+
ind = ' ' * ((len(lines[i + 1]) - len(lines[i + 1].lstrip())) if i + 1 < end else (len(ln) - len(st)) + 2)
|
|
80
|
+
if not has_w and not has_h:
|
|
81
|
+
ins = [f'{ind}.width({w})', f'{ind}.height({h})']
|
|
82
|
+
kind = f'w/h {w}x{h}'
|
|
83
|
+
else:
|
|
84
|
+
ratio = round(w / h, 4)
|
|
85
|
+
ins = [f'{ind}.aspectRatio({ratio})']
|
|
86
|
+
kind = f'aspectRatio {ratio} ({"W" if has_w else "H"} set)'
|
|
87
|
+
edits.append((i, ins))
|
|
88
|
+
applied.append(f'{os.path.basename(path)}:{i + 1} {icon:34} -> {kind}')
|
|
89
|
+
if edits and apply:
|
|
90
|
+
for i, ins in sorted(edits, reverse=True):
|
|
91
|
+
lines[i + 1:i + 1] = ins
|
|
92
|
+
open(path, 'w', encoding='utf-8').write('\n'.join(lines))
|
|
93
|
+
return applied, dynamic
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def main():
|
|
97
|
+
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
98
|
+
ap.add_argument('--plan', default='icon_plan.json')
|
|
99
|
+
ap.add_argument('--report', default='icon_report.json')
|
|
100
|
+
ap.add_argument('--apply', action='store_true', help='落盘(默认 dry-run)')
|
|
101
|
+
a = ap.parse_args()
|
|
102
|
+
|
|
103
|
+
plan = json.load(open(a.plan, encoding='utf-8'))
|
|
104
|
+
rep = json.load(open(a.report, encoding='utf-8'))
|
|
105
|
+
applied, dynamic = apply_fixes(plan, rep, apply=a.apply)
|
|
106
|
+
|
|
107
|
+
verb = '已落盘' if a.apply else '将要修复(dry-run)'
|
|
108
|
+
print(f'== {verb}:{len(applied)} 处 ==')
|
|
109
|
+
for s in sorted(applied):
|
|
110
|
+
print(' ' + s)
|
|
111
|
+
print(f'\n== 动态源(手工解析,见 SKILL.md):{len(dynamic)} ==')
|
|
112
|
+
for d in dynamic:
|
|
113
|
+
print(' ' + d)
|
|
114
|
+
if not a.apply:
|
|
115
|
+
print('\n仅 dry-run。加 --apply 落盘,然后重跑 icon_audit.py + 编译。')
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
if __name__ == '__main__':
|
|
119
|
+
main()
|