ohos-devloop 0.1.2__py3-none-any.whl

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 (58) hide show
  1. ohos_devloop/__init__.py +2 -0
  2. ohos_devloop/_version.py +24 -0
  3. ohos_devloop/agents/skills/collab-delegate/SKILL.md +79 -0
  4. ohos_devloop/agents/skills/loop-iterate/SKILL.md +54 -0
  5. ohos_devloop/agents/skills/openharmony-ci/SKILL.md +71 -0
  6. ohos_devloop/agents/skills/openharmony-ci/agents/openai.yaml +4 -0
  7. ohos_devloop/agents/skills/openharmony-ci/scripts/openharmony_ci.py +520 -0
  8. ohos_devloop/agents/skills/pool-status/SKILL.md +47 -0
  9. ohos_devloop/config/e2e-cases.yaml +31 -0
  10. ohos_devloop/config/e2e-hap.yaml +54 -0
  11. ohos_devloop/config/inventory-template.yaml +35 -0
  12. ohos_devloop/config/inventory.yaml +68 -0
  13. ohos_devloop/config/report-templates/analysis-report.md +48 -0
  14. ohos_devloop/config/report-templates/impl-report.md +47 -0
  15. ohos_devloop/config/task-template.md +21 -0
  16. ohos_devloop/config/tdd-board.yaml +31 -0
  17. ohos_devloop/config/tdd-coverage.yaml +47 -0
  18. ohos_devloop/config/tdd-emulator.yaml +36 -0
  19. ohos_devloop/config/tdd-host.yaml +26 -0
  20. ohos_devloop/config/tdd-suites.yaml +34 -0
  21. ohos_devloop/config/templates/agents-user.md +11 -0
  22. ohos_devloop/config/templates/quickstart.md +82 -0
  23. ohos_devloop/config/verify.yaml +45 -0
  24. ohos_devloop/examples/anchor-e2e.yaml +55 -0
  25. ohos_devloop/examples/assert-smoke.yaml +33 -0
  26. ohos_devloop/examples/diffcov-fixture/cov.json +6688 -0
  27. ohos_devloop/examples/diffcov-fixture/diff.txt +24 -0
  28. ohos_devloop/examples/diffcov-smoke.yaml +32 -0
  29. ohos_devloop/examples/e2e-emu-smoke.yaml +45 -0
  30. ohos_devloop/examples/layout-fixture.norm.json +1 -0
  31. ohos_devloop/examples/smoke.yaml +27 -0
  32. ohos_devloop/ohos_cli.py +131 -0
  33. ohos_devloop/scripts/agent-run-v3.sh +149 -0
  34. ohos_devloop/scripts/apply.py +1448 -0
  35. ohos_devloop/scripts/check_env.py +284 -0
  36. ohos_devloop/scripts/collab.py +303 -0
  37. ohos_devloop/scripts/diffcov.py +211 -0
  38. ohos_devloop/scripts/flash.py +511 -0
  39. ohos_devloop/scripts/mount_ws.py +192 -0
  40. ohos_devloop/scripts/release.py +2645 -0
  41. ohos_devloop/scripts/release_audit.py +260 -0
  42. ohos_devloop/scripts/release_metadata.py +397 -0
  43. ohos_devloop/scripts/release_smoke.py +287 -0
  44. ohos_devloop/scripts/report_draft.py +234 -0
  45. ohos_devloop/scripts/server_init.py +310 -0
  46. ohos_devloop/scripts/sgrep.py +82 -0
  47. ohos_devloop/scripts/sign_hap.py +256 -0
  48. ohos_devloop/scripts/telemetry.py +260 -0
  49. ohos_devloop/scripts/ui_probe.py +396 -0
  50. ohos_devloop/scripts/verify_frame_diff.py +138 -0
  51. ohos_devloop/scripts/ws_init.py +131 -0
  52. ohos_devloop/scripts/wsroot.py +192 -0
  53. ohos_devloop-0.1.2.dist-info/METADATA +177 -0
  54. ohos_devloop-0.1.2.dist-info/RECORD +58 -0
  55. ohos_devloop-0.1.2.dist-info/WHEEL +5 -0
  56. ohos_devloop-0.1.2.dist-info/entry_points.txt +2 -0
  57. ohos_devloop-0.1.2.dist-info/licenses/LICENSE +202 -0
  58. ohos_devloop-0.1.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,24 @@
1
+ diff --git a/frameworks/core/components_ng/manager/scroll_placeholder/scroll_placeholder_manager.cpp b/frameworks/core/components_ng/manager/scroll_placeholder/scroll_placeholder_manager.cpp
2
+ --- a/frameworks/core/components_ng/manager/scroll_placeholder/scroll_placeholder_manager.cpp
3
+ +++ b/frameworks/core/components_ng/manager/scroll_placeholder/scroll_placeholder_manager.cpp
4
+ @@ -56,0 +57,8 @@
5
+ + // diffcov-synth-A: reachable branch (vsyncPeriodNs > 0 holds in every suite case)
6
+ + if (vsyncPeriodNs > 0) {
7
+ + frameAnchored_ = true;
8
+ + }
9
+ + // diffcov-synth-B: unreachable branch (sentinel timestamp never occurs)
10
+ + if (vsyncTimestampNs == 0x7FFFFFFF) {
11
+ + frameAnchored_ = false;
12
+ + }
13
+ diff --git a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/generated/component/span.ets b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/generated/component/span.ets
14
+ --- a/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/generated/component/span.ets
15
+ +++ b/frameworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/generated/component/span.ets
16
+ @@ -10,0 +11,2 @@
17
+ +// build-generated noise line 1 (must be skipped by noise filter)
18
+ +// build-generated noise line 2 (must be skipped by noise filter)
19
+ diff --git a/frameworks/core/components_ng/pattern/list/list_pattern.h b/frameworks/core/components_ng/pattern/list/list_pattern.h
20
+ --- a/frameworks/core/components_ng/pattern/list/list_pattern.h
21
+ +++ b/frameworks/core/components_ng/pattern/list/list_pattern.h
22
+ @@ -300,0 +301,2 @@
23
+ + // header line not compiled into this target (must be reported as no_cov_data)
24
+ + void SomeHelperNotInTarget(int32_t value);
@@ -0,0 +1,32 @@
1
+ # ============================================================================
2
+ # diffcov 步骤自测:不连任何机器,验证差分覆盖判定链与噪音/no_cov_data 过滤语义。
3
+ # fixture = diffcov-20261111 任务真实数据(合成 A/B patch 实际落位 + 真实 gcovr JSON 裁剪):
4
+ # A 分支(可达)应 covered、B 分支(哨兵不可达)应 uncovered —— 判别力锚点。
5
+ # 用法:python scripts/apply.py examples/diffcov-smoke.yaml run
6
+ # ============================================================================
7
+
8
+ job: diffcov-smoke
9
+ description: 差分覆盖判定自测(纯本地:fixture → diffcov → assert 数字/噪音/无数据过滤)
10
+
11
+ resources: {} # 无 server / 无 board
12
+
13
+ params: {}
14
+
15
+ steps:
16
+ - name: diffcov-fixture
17
+ type: diffcov
18
+ cov_json: "../../examples/diffcov-fixture/cov.json"
19
+ diff_file: "../../examples/diffcov-fixture/diff.txt"
20
+ line_min: 50 # fixture 行覆盖 4/6 = 66.7% ≥ 50 → PASS(阈值语义;100 的 FAIL 路径由 CLI/服务器链覆盖)
21
+ - name: assert-diffcov-numbers
22
+ type: assert
23
+ assertions:
24
+ - { kind: text, path: "diffcov/diffcov-list.json", pattern: '"uncovered": 2', expect: match }
25
+ - { kind: text, path: "diffcov/diffcov-list.json", pattern: '"covered": 4', expect: match }
26
+ - { kind: text, path: "diffcov/diffcov-list.json", pattern: '"executable": 6', expect: match }
27
+ # 判别力锚点:可达/不可达分支体都被正确区分(UNCOVERED 行存在且是 B 体)
28
+ - { kind: text, path: "diffcov/diffcov-list.json", pattern: '"status": "UNCOVERED"', expect: match }
29
+ # 噪音剔除:koala 生成物只进 noise_files 清单(不进 rows/判据)
30
+ - { kind: text, path: "diffcov/diffcov-list.json", pattern: "span.ets", expect: match }
31
+ # 未编进 target 的改动 → no_cov_data 报告(不判据)
32
+ - { kind: text, path: "diffcov/diffcov-list.json", pattern: "list_pattern.h", expect: match }
@@ -0,0 +1,45 @@
1
+ # ============================================================================
2
+ # 模拟器 e2e 证据链自测(2026-11-16):预装应用启动 → UI 树/日志取证 → node 断言
3
+ #
4
+ # 背景:x86_64_virt 镜像 hap install 被内核缺口阻断(statx EINVAL → code_sign -256,
5
+ # 见 RUNBOOK「x86 模拟器大循环」坑位 7),hap 全链 e2e 暂走真板;本 spec 验证
6
+ # e2e 后半段机制(aa start → capture → 断言)在模拟器隧道通道上可用。
7
+ # 前置:模拟器实例 00 已启动 + 本机隧道 15555 已起 + 已解锁(uinput 上滑)。
8
+ # ============================================================================
9
+ job: e2e-emu-smoke
10
+ description: 模拟器 e2e 证据链自测——预装 Settings 启动→布局/日志取证→node 断言
11
+
12
+ resources:
13
+ board: x86-emu-01
14
+
15
+ steps:
16
+ - name: launch-settings
17
+ type: shell
18
+ where: board
19
+ command: aa start -a com.ohos.settings.MainAbility -b com.ohos.settings
20
+
21
+ - name: settle # TCG 下 Settings 冷启动慢,静置后再取证
22
+ type: shell
23
+ where: board
24
+ command: sleep 8
25
+
26
+ - name: capture
27
+ type: capture # 截图在模拟器上不可用(RS snapshot 缺口,仅告警);布局/日志为准
28
+ shots: 1
29
+ hilog: true
30
+ layout: true
31
+
32
+ - name: assert
33
+ type: assert
34
+ assertions:
35
+ - name: settings-text-visible
36
+ kind: node # 布局里应出现设置首页文本(WLAN/蓝牙 任一)
37
+ selector: { text_re: "WLAN|蓝牙|Bluetooth" }
38
+ fact: count
39
+ op: ge
40
+ expect: 1
41
+ - name: settings-process
42
+ kind: text # capture 的 hilog 证据里应有 settings 进程活动
43
+ path: evidence/hilog.txt
44
+ pattern: com.ohos.settings
45
+ expect: match
@@ -0,0 +1 @@
1
+ {"head": {"bundle": "com.example.fixture", "page": "pages/Index", "nodes": 6, "dumpedAt": "fixture"}, "tree": [{"t": "root", "c": [{"t": "Button", "x": "Prepend 3 rows", "b": [250, 128, 471, 188], "f": {"clickable": true}}, {"t": "Grid", "b": [22, 200, 699, 1086], "f": {"scrollable": true}, "c": [{"t": "GridItem", "b": [22, 200, 240, 268], "c": [{"t": "Text", "x": "item-0-0", "b": [22, 200, 240, 268], "extra": {"originalText": "item-0-0"}}]}, {"t": "GridItem", "b": [252, 200, 470, 268], "c": [{"t": "Text", "x": "item-0-1", "b": [252, 200, 470, 268]}]}, {"t": "GridItem", "b": [481, 200, 699, 268], "c": [{"t": "Text", "x": "item-0-2", "b": [481, 200, 699, 268]}]}]}]}]}
@@ -0,0 +1,27 @@
1
+ # 调度器自测 job:验证 loader → plan → 执行 → results.json 全链路。
2
+ # 不碰构建、不碰板子:两条本地 shell + 一条服务器只读回显。
3
+ # 新机器/新环境首次接入时先跑:python apply.py examples/smoke.yaml run
4
+ job: smoke
5
+ description: 调度器自测(本地 shell ×2 + 服务器回显 ×1)
6
+
7
+ resources:
8
+ server: build-1
9
+ board: rk3568-01
10
+
11
+ params: {}
12
+
13
+ steps:
14
+ - name: local-echo
15
+ type: shell
16
+ where: local
17
+ command: echo smoke-local-ok && uname -s
18
+
19
+ - name: write-marker
20
+ type: shell
21
+ where: local
22
+ command: echo ok > "{run_dir}/marker.txt" && cat "{run_dir}/marker.txt"
23
+
24
+ - name: server-echo
25
+ type: shell
26
+ where: server
27
+ command: echo smoke-ssh-ok && hostname && nproc
@@ -0,0 +1,131 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """ohos-devloop —— OpenHarmony DevLoop 统一 CLI 入口(ROADMAP M6:CLI 即契约)。
4
+
5
+ 面向 OpenHarmony 的 Agent 驱动设备开发与验证闭环。
6
+ 一切能力以 CLI 命令为稳定出口,agent 层(skills/AGENTS.md/未来 MCP)只是本入口的薄适配。
7
+ 子命令与既有脚本一一映射(双入口等价:python scripts/xxx.py 与 ohos-devloop xxx 行为相同):
8
+
9
+ ohos-devloop apply <spec> [plan|run] ... → scripts/apply.py
10
+ ohos-devloop collab <new|push|run|status|...> ... → scripts/collab.py
11
+ ohos-devloop flash <fetch|extract|sync-repo|...> → scripts/flash.py
12
+ ohos-devloop server init [--server 名] ... → scripts/server_init.py(check = --check)
13
+ ohos-devloop check-env / report / sign / sgrep / ui-probe / diffcov ...
14
+ ohos-devloop release-audit <wheel> → scripts/release_audit.py(发布前审计门,fail-closed)
15
+ ohos-devloop release → scripts/release.py(裸预检:精确 tag/干净树 →
16
+ wheel 构建/归档 → 审计 → 安装态 smoke → 只读双面
17
+ 预检,打印后停止;零上传)
18
+ ohos-devloop release test → scripts/release.py(TestPyPI 演练:A1 写入门 →
19
+ 占用/凭据前门 → 单归档 wheel 上传 → JSON 有界
20
+ 验证 → 脱敏 test receipt)
21
+ ohos-devloop release all [--yes] → scripts/release.py(正式双源发布:A1/A2 门 →
22
+ 公开预检/审批消费 → 确认 → 公开 PyPI verified →
23
+ GitCode 正式 Release → 最终脱敏回执)
24
+ ohos-devloop release resume [--yes] → scripts/release.py(双源崩溃恢复:先远端对账,
25
+ 404/缺失才重试;全部面 verified 幂等打印回执)
26
+
27
+ 安装(当前形态:clone 即工作区;editable 下普通源码变更 git pull 即生效):
28
+ pipx install --editable <本仓路径>
29
+ 入口、包元数据、依赖或仓路径变化时须重新安装。
30
+ """
31
+ import subprocess
32
+ import sys
33
+ from pathlib import Path
34
+
35
+ BASE = Path(__file__).resolve().parent
36
+ SCRIPTS = BASE / "scripts"
37
+
38
+ # 子命令 → (脚本, 预置参数)。server 单独处理(init/check 二级动词)
39
+ MAP = {
40
+ "apply": ("apply.py", []),
41
+ "collab": ("collab.py", []),
42
+ "flash": ("flash.py", []),
43
+ "init": ("ws_init.py", []),
44
+ "check-env": ("check_env.py", []),
45
+ "report": ("report_draft.py", []),
46
+ "sign": ("sign_hap.py", []),
47
+ "sgrep": ("sgrep.py", []),
48
+ "ui-probe": ("ui_probe.py", []),
49
+ "diffcov": ("diffcov.py", []),
50
+ "telemetry": ("telemetry.py", []),
51
+ "release-audit": ("release_audit.py", []),
52
+ "release": ("release.py", []),
53
+ }
54
+
55
+ USAGE = __doc__.split("安装(当前形态")[0] # docstring 到「安装」节前作 usage(05-03 起
56
+ # release 行含「安装态 smoke」字样,切分锚必须用完整节标题,避免 USAGE 被提前截断)
57
+
58
+
59
+ def version() -> str:
60
+ """installed 包版本优先(pipx/wheel 装),仓内 checkout 退化 git describe。"""
61
+ try:
62
+ from importlib.metadata import version as v
63
+ s = v("ohos-devloop")
64
+ if s:
65
+ return s
66
+ except Exception:
67
+ pass
68
+ try:
69
+ p = subprocess.run(["git", "describe", "--tags", "--always", "--dirty"],
70
+ cwd=BASE, capture_output=True, text=True, timeout=15)
71
+ if p.returncode == 0 and p.stdout.strip():
72
+ return p.stdout.strip() + " (repo)"
73
+ except Exception:
74
+ pass
75
+ return "unknown"
76
+
77
+
78
+ def _telemetry_cmd(cmd: str, rc: int, dur_s: float) -> None:
79
+ """命令使用埋点(M6 遥测):只记命令名/退出码/耗时,不记参数。失败静默。"""
80
+ try:
81
+ sys.path.insert(0, str(SCRIPTS))
82
+ import telemetry
83
+ telemetry.emit("cmd_invoked", cmd=cmd, rc=rc, dur_s=round(dur_s, 2))
84
+ except Exception:
85
+ pass
86
+
87
+
88
+ def main() -> int:
89
+ # console script 不经过 __main__ 块;两种入口都先统一 UTF-8,避免 Windows 中文帮助乱码。
90
+ try:
91
+ sys.stdout.reconfigure(encoding="utf-8", errors="replace", line_buffering=True)
92
+ sys.stderr.reconfigure(encoding="utf-8", errors="replace", line_buffering=True)
93
+ except Exception:
94
+ pass
95
+ import time
96
+ t0 = time.time()
97
+ args = sys.argv[1:]
98
+ if not args or args[0] in ("-h", "--help"):
99
+ print(USAGE)
100
+ print(f"version: {version()}")
101
+ return 0
102
+ if args[0] in ("version", "--version", "-V"):
103
+ print(version())
104
+ return 0
105
+ sub, rest = args[0], args[1:]
106
+ if sub == "server":
107
+ if not rest:
108
+ print("用法: ohos-devloop server init|check [server_init.py 的其余参数]")
109
+ return 2
110
+ verb, rest = rest[0], rest[1:]
111
+ script, pre = "server_init.py", (["--check"] if verb == "check" else [])
112
+ if verb not in ("init", "check"):
113
+ print(f"未知 server 动词: {verb}(init | check)")
114
+ return 2
115
+ elif sub in MAP:
116
+ script, pre = MAP[sub]
117
+ else:
118
+ print(f"未知子命令: {sub}\n{USAGE}")
119
+ _telemetry_cmd("unknown", 2, time.time() - t0)
120
+ return 2
121
+ target = SCRIPTS / script
122
+ if not target.is_file():
123
+ print(f"ERROR: {target} 不存在(仓不完整?)", file=sys.stderr)
124
+ return 2
125
+ p = subprocess.run([sys.executable, str(target), *pre, *rest])
126
+ _telemetry_cmd(sub, p.returncode, time.time() - t0)
127
+ return p.returncode
128
+
129
+
130
+ if __name__ == "__main__":
131
+ sys.exit(main())
@@ -0,0 +1,149 @@
1
+ #!/usr/bin/env bash
2
+ # 远端 code-worker(opencode)一次式调用入口 v3
3
+ # 用法: agent-run-v3.sh <task-id> [model] model 默认 bigmodel/glm-5.3
4
+ #
5
+ # v3(2026-11-09 架构回切:本机主 Agent ⇄ 服务器 code-worker)相对 v2 的变更:
6
+ # - 改码纪律移植(原 code-modifier skill 正本):分支 fix/<短描述>、commit 规范
7
+ # (Signed-off-by + AI 采用度 + Change-Id)、禁一切 git push、噪音文件清单、
8
+ # 编译循环预算、TDD 设备版 target 门
9
+ # - worker 自带构建闭环:按 task.md 的 build_targets/tdd_targets 触发 nohup 增量构建并轮询
10
+ # - status.json 扩展 build/tdd/deploy_artifacts 字段;部署产物清单写 artifacts.txt
11
+ # (每行 = out/rk3568/packages/phone/system 子树相对路径,本机 apply.py --params artifacts= 直吃)
12
+ # - AGENT_TIMEOUT 默认 7200s(worker 含构建时间;v2 为 1800)
13
+ # v2 遗产:repo 在 $HOME 外时自动在 repo 内建 .collab-task/ 工作副本(opencode 无头模式
14
+ # external_directory 会拒绝项目外绝对路径),结束后回拷协议目录
15
+ set -uo pipefail
16
+
17
+ TASK_ID="${1:?usage: agent-run-v3.sh <task-id> [model]}"
18
+ MODEL="${2:-bigmodel/glm-5.3}"
19
+ COLLAB="$HOME/collab"
20
+ TASK_DIR="$COLLAB/tasks/$TASK_ID"
21
+ OPENCODE=/root/.local/bin/opencode
22
+ TIMEOUT="${AGENT_TIMEOUT:-7200}"
23
+
24
+ [ -x "$OPENCODE" ] || { echo "ERROR: opencode not found at $OPENCODE" >&2; exit 2; }
25
+ [ -f "$TASK_DIR/task.md" ] || { echo "ERROR: $TASK_DIR/task.md not found" >&2; exit 2; }
26
+
27
+ mkdir -p "$COLLAB/runs/$TASK_ID"
28
+ STAMP="$(date +%Y%m%d-%H%M%S)"
29
+ LOG="$COLLAB/runs/$TASK_ID/$STAMP.log"
30
+
31
+ hdr() { grep -m1 "^$1:" "$TASK_DIR/task.md" | sed "s/^$1:[[:space:]]*//" | tr -d '\r'; }
32
+ REPO_DIR="$(hdr repo)"
33
+ BUILD_TARGETS="$(hdr build_targets)"
34
+ TDD_TARGETS="$(hdr tdd_targets)"
35
+
36
+ # 项目根选择:repo 在 HOME 下沿用旧行为(根=$HOME);否则根=repo 本身,
37
+ # 并在 repo 内同步任务工作副本,Agent 读写全走项目内路径
38
+ TASK_SRC="$TASK_DIR"
39
+ INREPO=""
40
+ case "$REPO_DIR" in
41
+ "$HOME"/*)
42
+ cd "$HOME"
43
+ ;;
44
+ *)
45
+ if [ -n "$REPO_DIR" ] && [ -d "$REPO_DIR" ]; then
46
+ cd "$REPO_DIR"
47
+ INREPO="$REPO_DIR/.collab-task"
48
+ mkdir -p "$INREPO/context"
49
+ # 清掉本工作区上一轮遗留的协议产物——否则陈旧 report/status 会被下方回拷步骤
50
+ # 污染本任务目录并骗过校验(2026-11-09 tdd-boundary 任务实测踩过)
51
+ rm -f "$INREPO/report.md" "$INREPO/report.prev.md" "$INREPO/status.json" \
52
+ "$INREPO/artifacts.txt" "$INREPO"/build-*.log
53
+ rm -rf "$INREPO/artifacts"
54
+ cp -f "$TASK_DIR/task.md" "$INREPO/task.md"
55
+ if [ -d "$TASK_DIR/context" ]; then cp -f "$TASK_DIR"/context/* "$INREPO/context/" 2>/dev/null; fi
56
+ TASK_SRC="$INREPO"
57
+ echo "[agent-run] repo outside HOME, using in-repo task copy: $TASK_SRC" >&2
58
+ else
59
+ cd "$COLLAB"
60
+ fi
61
+ ;;
62
+ esac
63
+
64
+ echo "[agent-run] task=$TASK_ID model=$MODEL cwd=$PWD repo=$REPO_DIR timeout=${TIMEOUT}s log=$LOG"
65
+
66
+ PROMPT="你是双 Agent 协作中的远端 code-worker(服务器端)。任务 ID: $TASK_ID
67
+ 你在构建服务器上直接读写 OHOS 大仓工作区(repo 根: $REPO_DIR),职责:定位/修改代码 → git 提交本地分支 → 触发构建 → 产出结构化报告。不做设备侧操作(推板/装应用/截图由本机主 Agent 负责)。
68
+
69
+ 第一步,读当前项目内的任务书(唯一必读入口):
70
+ 1. $TASK_SRC/task.md —— 任务书全文(含 build_targets / tdd_targets 头字段)
71
+ 2. $TASK_SRC/context/ 下的全部证据文件(如存在)
72
+ 3. repo 内的 AGENTS.md / CLAUDE.md(如存在且在项目内)
73
+
74
+ 硬性规则(内联,无需读任何外部文件):
75
+ - 路径边界:只访问 $REPO_DIR 及其子路径;不要读写、不要在 shell 命令里引用项目外的绝对路径(会被自动拒绝并终止任务)
76
+ - 只读分析类任务(task.md 有标注):不改代码、不 git commit,唯一产出是报告
77
+ - 修改类任务纪律:
78
+ * 分支:如当前不在本次任务的 fix/<短描述> 分支则 git checkout -b fix/<短描述>(基于当前 HEAD);绝不改动已推送的 PR 分支(如 feat/scroll-placeholder-grid-waterflow)
79
+ * 暂存:只 git add 明确修改的目标文件;禁止 git add -A / git add . / git commit -a
80
+ * 提交信息必须带:
81
+ Signed-off-by: guozejun <guozejun@huawei.com>
82
+ AI[100%] Human Fixed[0%] Human[0%] AI Adopted[100%]
83
+ Co-authored-by: agent <noreply@agent.local>
84
+ Change-Id: I\$(git log -1 --format=%T | sha1sum | cut -c1-40)
85
+ * 禁止一切 git push(上游与 fork 都不许)——推送是设备侧验证通过后由主 Agent 执行的独立步骤
86
+ * 禁碰噪音/生成物:frameworks/bridge/arkts_frontend/koala_projects/*/generated/**、frameworks/core/interfaces/native/generated/**;interface/sdk-js 若已对齐 tip,不要 checkout 还原
87
+ - 构建纪律(task.md 的 build_targets / tdd_targets 非空时;所有命令在 $REPO_DIR 下执行):
88
+ * 后台构建:nohup ./build.sh --product-name rk3568 --ccache --build-target <target...> > $TASK_SRC/build-$TASK_ID-$STAMP.log 2>&1 &
89
+ (构建日志必须写在 $TASK_SRC 下——它在项目根之内;写到项目外会被自动拒绝并终止任务)
90
+ * 轮询构建日志 grep 'build success|build failed'(间隔 60s);失败读日志 tail 修码重跑,重试预算 3 轮,仍失败带分析写报告
91
+ * 轮询超时先审工作树 diff(修复常已落树)+ 查构建进程存活,不要静默判败
92
+ * 看到 build success 后核对产物 mtime 为本次构建时间再下结论(构建未完成就取旧产物会假绿)
93
+ * TDD 门:凡修改代码或 TDD 用例,必须构建 tdd_targets 的设备版单测 target;报告 stripped 产物完整路径(out/rk3568/tests/unittest/ace_engine/**/<target>,不要报 700MB 的 exe.unstripped)并附 sha256
94
+ - 部署产物清单:改动若产出部署物(.so / 组件 abc),把 packages/phone/system 子树相对路径写入 $TASK_SRC/artifacts.txt(每行一条,如 lib/platformsdk/libace_compatible.z.so)——本机 apply.py --params artifacts= 直接消费该清单推板
95
+ - 已知雷区(历史上真实踩过,规避):
96
+ * libace.map 导出符号变更必须与依赖组件库原子同推,单推 compatible 会跨界崩
97
+ * brandColor ABI 有毒性,勿引入推板路径
98
+ * Grid/WaterFlow 与 List 存在守卫代码分叉(共用头 vs 副本):改一处必须检查另一处是否需要同步
99
+ * 尺寸语义:NaN/非有限值按维丢弃=未传;selfIdealSize 早退路径不做钳制;\"不显示\"要返回 undefined 而不是 0
100
+ - 报告写到 $TASK_SRC/report.md(如已存在先备份为 report.prev.md),首行必须是 FIXED / PARTIAL / BLOCKED / NEED_INFO 之一
101
+ - 报告结构:根因/分析 → 改动清单或结论清单 → 构建与测试结果 → 遗留风险 → 设备侧验证建议
102
+ - 同步写 $TASK_SRC/status.json:
103
+ {\"id\":\"$TASK_ID\",\"status\":\"FIXED|PARTIAL|BLOCKED|NEED_INFO\",\"commits\":[],\"branch\":\"<fix/... 或 none>\",\"files\":[],\"build\":{\"status\":\"PASS|FAIL|SKIP\",\"log\":\"<构建日志绝对路径>\",\"targets\":[]},\"tdd\":{\"targets\":[],\"artifacts\":[{\"path\":\"<stripped 产物绝对路径>\",\"sha256\":\"...\"}]},\"deploy_artifacts\":[],\"updated\":\"<ISO时间>\",\"iterations\":<轮数>}
104
+ - 信息不足以完成判断时,报告首行写 NEED_INFO 并列出缺失项
105
+
106
+ 现在开始。"
107
+
108
+ set +e
109
+ timeout "$TIMEOUT" "$OPENCODE" run -m "$MODEL" --title "collab-$TASK_ID-$STAMP" "$PROMPT" 2>&1 | tee "$LOG"
110
+ RC=$?
111
+ set -e
112
+
113
+ echo "[agent-run] opencode exit=$RC"
114
+
115
+ # 回拷:repo 内副本的产出 → 协议目录
116
+ if [ -n "${INREPO:-}" ] && [ -d "$INREPO" ]; then
117
+ for f in report.md report.prev.md status.json artifacts.txt; do
118
+ [ -f "$INREPO/$f" ] && cp -f "$INREPO/$f" "$TASK_DIR/$f"
119
+ done
120
+ cp -f "$INREPO"/build-*.log "$TASK_DIR/" 2>/dev/null || true
121
+ if [ -d "$INREPO/artifacts" ]; then mkdir -p "$TASK_DIR/artifacts"; cp -rf "$INREPO/artifacts/." "$TASK_DIR/artifacts/"; fi
122
+ fi
123
+
124
+ # 校验报告产出
125
+ STATUS="MISSING"
126
+ if [ -f "$TASK_DIR/report.md" ]; then
127
+ FIRST="$(head -1 "$TASK_DIR/report.md" | tr -d '\r' | xargs)"
128
+ case "$FIRST" in
129
+ FIXED|PARTIAL|BLOCKED|NEED_INFO) STATUS="$FIRST" ;;
130
+ *) STATUS="INVALID_HEAD" ;;
131
+ esac
132
+ fi
133
+ echo "[agent-run] report-status=$STATUS"
134
+
135
+ if [ "$STATUS" = "MISSING" ] || [ "$STATUS" = "INVALID_HEAD" ]; then
136
+ exit 3
137
+ fi
138
+ # 修改类任务(build_targets 非空)报 FIXED 却没产出部署清单 → 警告(不判败:可能纯 abc/无部署物)
139
+ if [ "$STATUS" = "FIXED" ] && [ -n "$BUILD_TARGETS" ] && [ ! -f "$TASK_DIR/artifacts.txt" ]; then
140
+ echo "[agent-run] WARN: FIXED 但未产出 artifacts.txt(本机 apply.py 推板需要它;若确无部署物请忽略)" >&2
141
+ fi
142
+ # status.json 必须属于本任务(id 匹配)——防陈旧残留文件骗过校验
143
+ if grep -q "\"id\"[[:space:]]*:[[:space:]]*\"$TASK_ID\"" "$TASK_DIR/status.json" 2>/dev/null && \
144
+ grep -q '"status"' "$TASK_DIR/status.json" 2>/dev/null; then
145
+ cat "$TASK_DIR/status.json"
146
+ exit "$RC"
147
+ fi
148
+ echo "ERROR: status.json missing or invalid" >&2
149
+ exit 4