@harmonyos-arkts/d2h 0.1.29 → 0.1.32
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/plugin.json +1 -1
- package/README.md +6 -2
- package/agents/d2h.md +23 -14
- package/dist/bin/install-opencode.js +17 -4
- package/dist/src/install-opencode.js +6 -4
- package/dist/src/install-tui-extension.js +1 -1
- package/dist/src/metrics-plugin.js +4 -3
- package/dist/src/poc.js +53 -0
- package/docs/architecture-plan-guide.zh-CN.md +30 -46
- package/docs/poc-rule-evaluation.md +38 -0
- package/package.json +3 -2
- package/schemas/code-stats.schema.json +245 -0
- package/skills/android2hmos_resources_convert/SKILL.md +1 -9
- package/skills/d2h-app-solution/SKILL.md +3 -3
- package/skills/d2h-app-solution/references/inventory-schema.md +2 -2
- package/skills/d2h-architecture-plan/SKILL.md +23 -22
- package/skills/d2h-architecture-plan/references/architecture-plan.example.json +650 -76
- package/skills/d2h-architecture-plan/references/directory-creation.md +7 -7
- package/skills/d2h-architecture-plan/references/hybrid-design.md +63 -63
- package/skills/d2h-architecture-plan/references/json-contract.md +42 -27
- package/skills/d2h-architecture-plan/references/layout-reference.md +25 -72
- package/skills/d2h-architecture-plan/references/plan-contract.md +24 -34
- package/skills/d2h-architecture-plan/references/source-review.md +10 -7
- package/skills/d2h-architecture-plan/scripts/architecture_plan.py +50 -16
- package/skills/d2h-code-audit/SKILL.md +68 -0
- package/skills/d2h-code-audit/references/code-stats-schema.md +260 -0
- package/skills/d2h-code-audit/references/metrics.md +94 -0
- package/skills/d2h-code-audit/scripts/code_stats.py +600 -0
- package/skills/d2h-code-audit/scripts/validate_code_stats.py +446 -0
- package/skills/d2h-dashboard/SKILL.md +59 -33
- package/skills/d2h-dashboard/app/assets/Analysis-9GrmuIjp.css +1 -0
- package/skills/d2h-dashboard/app/assets/Analysis-Dj-4QEJi.js +1 -0
- package/skills/d2h-dashboard/app/assets/CodeAudit-Ctt3XEec.css +1 -0
- package/skills/d2h-dashboard/app/assets/CodeAudit-TcIcLwQL.js +1 -0
- package/skills/d2h-dashboard/app/assets/FeaturesList-C5yGUbRo.js +1 -0
- package/skills/d2h-dashboard/app/assets/FeaturesList-CZ40orVY.css +1 -0
- package/skills/d2h-dashboard/app/assets/Overview-CNkA3J9F.js +1 -0
- package/skills/d2h-dashboard/app/assets/Overview-Cmz8yjX-.css +1 -0
- package/skills/d2h-dashboard/app/assets/PageHeading-B5I3tpO8.js +1 -0
- package/skills/d2h-dashboard/app/assets/PageHeading-BIDu_a9G.css +1 -0
- package/skills/d2h-dashboard/app/assets/Project-BC9Tz1WY.js +1 -0
- package/skills/d2h-dashboard/app/assets/Project-BRyXCzsB.css +1 -0
- package/skills/d2h-dashboard/app/assets/Review-BfWvqlU9.js +1 -0
- package/skills/d2h-dashboard/app/assets/SpecDetail-BHB6smtT.css +1 -0
- package/skills/d2h-dashboard/app/assets/SpecDetail-DguVmqAE.js +1 -0
- package/skills/d2h-dashboard/app/assets/SpecItemDetail-7s7SaF3O.js +69 -0
- package/skills/d2h-dashboard/app/assets/SpecItemDetail-Bf4pGDEN.css +1 -0
- package/skills/d2h-dashboard/app/assets/_plugin-vue_export-helper-B9l48Cov.js +1 -0
- package/skills/d2h-dashboard/app/assets/batchReport-B3IzPnHF.js +1 -0
- package/skills/d2h-dashboard/app/assets/datetime-CHrzCsjX.js +1 -0
- package/skills/d2h-dashboard/app/assets/index-B3nfIPBm.js +3 -0
- package/skills/d2h-dashboard/app/assets/index-CnjP19Vs.css +1 -0
- package/skills/d2h-dashboard/app/assets/navigation-d1Uf6TR4.js +1 -0
- package/skills/d2h-dashboard/app/dataApi.mjs +387 -0
- package/skills/d2h-dashboard/app/index.html +14 -0
- package/skills/d2h-dashboard/app/package.json +12 -0
- package/skills/d2h-dashboard/app/serve.mjs +310 -0
- package/skills/d2h-hypium-forge/SKILL.md +6 -1
- package/skills/d2h-spec-develop/SKILL.md +24 -25
- package/skills/d2h-spec-develop/scripts/__pycache__/check_acceptance.cpython-313.pyc +0 -0
- package/skills/d2h-spec-develop/scripts/check_acceptance.py +66 -0
- package/skills/d2h-spec-generate/SKILL.md +2 -0
- package/skills/d2h-spec-plan/SKILL.md +6 -0
- package/skills/{cpp → language/cpp}/d2h-native-library-verify/scripts/__pycache__/native_common.cpython-313.pyc +0 -0
- package/skills/d2h-architecture-plan/scripts/test_architecture_plan.py +0 -241
- package/skills/d2h-spec-generate/assets/spec-template.md +0 -109
- package/skills/d2h-spec-generate/references/from-plan.md +0 -27
- package/skills/d2h-spec-generate/references/spec-content.md +0 -32
- package/skills/maintaining-migration-report/SKILL.md +0 -144
- package/skills/maintaining-migration-report/references/final-acceptance.md +0 -48
- package/skills/maintaining-migration-report/references/source-provenance.md +0 -66
- /package/skills/{cpp → language/cpp}/d2h-native-library-analyse/SKILL.md +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-analyse/scripts/analyse-android-so.py +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-build/SKILL.md +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-build/references/build-config-mapping.md +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-build/references/jni-to-napi-mapping.md +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-build/scripts/check-android-so.py +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/SKILL.md +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/demo-build-sign-run.md +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/demo-project-template/AppScope/app.json5 +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/demo-project-template/AppScope/resources/base/element/string.json +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/demo-project-template/README.md +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/demo-project-template/build-profile.json5 +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/demo-project-template/entry/build-profile.json5 +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/demo-project-template/entry/hvigorfile.ts +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/demo-project-template/entry/oh-package.json5 +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/demo-project-template/entry/src/main/ets/entryability/EntryAbility.ets +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/demo-project-template/entry/src/main/ets/pages/Index.ets +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/demo-project-template/entry/src/main/ets/pages/NativeVerifyDemo.ets +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/demo-project-template/entry/src/main/module.json5 +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/demo-project-template/entry/src/main/resources/base/element/color.json +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/demo-project-template/entry/src/main/resources/base/element/string.json +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/demo-project-template/entry/src/main/resources/base/profile/main_pages.json +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/demo-project-template/entry/src/ohosTest/ets/test/FFmpegVerify.test.ets +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/demo-project-template/entry/src/ohosTest/ets/test/List.test.ets +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/demo-project-template/entry/src/ohosTest/module.json5 +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/demo-project-template/hvigor/hvigor-config.json5 +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/demo-project-template/hvigorfile.ts +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/demo-project-template/oh-package.json5 +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/demo-template.md +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/references/hypium-test-template.md +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/scripts/device-verify.py +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/scripts/native_common.py +0 -0
- /package/skills/{cpp → language/cpp}/d2h-native-library-verify/scripts/verify-ohos-native.py +0 -0
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// 独立迁移看板服务器(零依赖,Node >= 18):
|
|
3
|
+
// node server/serve.mjs --dataDir <project>/.migration [--port 8080] [--host 127.0.0.1] [--dir ../web]
|
|
4
|
+
// node server/serve.mjs --dataDir <project>/.migration --detach [--log-file <path>]
|
|
5
|
+
// --detach:自守护启动——父进程 spawn 分离子进程(stdout/stderr 直写日志文件),
|
|
6
|
+
// 轮询日志直到子进程就绪后原样打印 stdout 契约并退出;调用方无需 shell 重定向/引号转义。
|
|
7
|
+
// 默认日志 %TEMP%/d2h-dashboard-<dataDir哈希8位>.log(每次启动截断重写,跨项目天然隔离)。
|
|
8
|
+
// stdout 契约(供 skill 解析):
|
|
9
|
+
// [dashboard] dataDir=<绝对路径>
|
|
10
|
+
// [dashboard] http://<host>:<实际端口>
|
|
11
|
+
import http from 'node:http'
|
|
12
|
+
import fs from 'node:fs'
|
|
13
|
+
import os from 'node:os'
|
|
14
|
+
import path from 'node:path'
|
|
15
|
+
import { spawn } from 'node:child_process'
|
|
16
|
+
import { createHash } from 'node:crypto'
|
|
17
|
+
import { fileURLToPath } from 'node:url'
|
|
18
|
+
import { createDataApi } from './dataApi.mjs'
|
|
19
|
+
|
|
20
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
21
|
+
const __dirname = path.dirname(__filename)
|
|
22
|
+
|
|
23
|
+
function argValue(name) {
|
|
24
|
+
const argv = process.argv
|
|
25
|
+
for (let i = 0; i < argv.length; i++) {
|
|
26
|
+
const a = argv[i]
|
|
27
|
+
if (a === `--${name}`) return argv[i + 1]
|
|
28
|
+
if (a.startsWith(`--${name}=`)) return a.slice(name.length + 3)
|
|
29
|
+
}
|
|
30
|
+
return undefined
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const dataDir =
|
|
34
|
+
argValue('dataDir') ??
|
|
35
|
+
argValue('data-dir') ??
|
|
36
|
+
process.env.npm_config_dataDir ??
|
|
37
|
+
process.env.DASHBOARD_DATA_DIR
|
|
38
|
+
if (!dataDir) {
|
|
39
|
+
console.error('[dashboard] 缺少 --dataDir 参数(指向迁移工程的 .migration 目录)')
|
|
40
|
+
process.exit(1)
|
|
41
|
+
}
|
|
42
|
+
if (!fs.existsSync(dataDir)) {
|
|
43
|
+
console.error(`[dashboard] 数据目录不存在: ${dataDir}`)
|
|
44
|
+
process.exit(1)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ---- --detach:spawn 分离子进程并等待就绪,然后父进程退出 ----
|
|
48
|
+
const isDetach = process.argv.includes('--detach')
|
|
49
|
+
if (isDetach) {
|
|
50
|
+
const root = path.resolve(dataDir)
|
|
51
|
+
const logFile =
|
|
52
|
+
argValue('log-file') ??
|
|
53
|
+
path.join(os.tmpdir(), `d2h-dashboard-${createHash('sha1').update(root).digest('hex').slice(0, 8)}.log`)
|
|
54
|
+
const errFile = `${logFile}.err`
|
|
55
|
+
const forward = []
|
|
56
|
+
const argv = process.argv.slice(2)
|
|
57
|
+
for (let i = 0; i < argv.length; i++) {
|
|
58
|
+
const a = argv[i]
|
|
59
|
+
if (a === '--detach') continue
|
|
60
|
+
if (a === '--log-file') { i += 1; continue }
|
|
61
|
+
if (a.startsWith('--log-file=')) continue
|
|
62
|
+
forward.push(a)
|
|
63
|
+
}
|
|
64
|
+
// 'w' 截断:每次启动重写日志,杜绝读到上一轮/其他项目的残留内容
|
|
65
|
+
const out = fs.openSync(logFile, 'w')
|
|
66
|
+
const err = fs.openSync(errFile, 'w')
|
|
67
|
+
const child = spawn(process.execPath, [__filename, ...forward], {
|
|
68
|
+
detached: true,
|
|
69
|
+
stdio: ['ignore', out, err],
|
|
70
|
+
windowsHide: true,
|
|
71
|
+
})
|
|
72
|
+
child.unref()
|
|
73
|
+
fs.closeSync(out)
|
|
74
|
+
fs.closeSync(err)
|
|
75
|
+
let spawnError = null
|
|
76
|
+
child.on('error', (e) => { spawnError = e })
|
|
77
|
+
const tail = (file) => {
|
|
78
|
+
try {
|
|
79
|
+
return fs.readFileSync(file, 'utf8').trim().split(/\r?\n/).slice(-15).join('\n')
|
|
80
|
+
} catch {
|
|
81
|
+
return ''
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const deadline = Date.now() + 20000
|
|
85
|
+
const poll = setInterval(() => {
|
|
86
|
+
let ready = null
|
|
87
|
+
try {
|
|
88
|
+
ready = fs.readFileSync(logFile, 'utf8').match(/^\[dashboard\] http:\/\/\S+/m)
|
|
89
|
+
} catch {
|
|
90
|
+
/* 日志尚未写入,继续等待 */
|
|
91
|
+
}
|
|
92
|
+
if (ready) {
|
|
93
|
+
clearInterval(poll)
|
|
94
|
+
console.log(`[dashboard] dataDir=${root}`)
|
|
95
|
+
console.log(ready[0])
|
|
96
|
+
console.log(`[dashboard] detached pid=${child.pid} log=${logFile}`)
|
|
97
|
+
process.exit(0)
|
|
98
|
+
}
|
|
99
|
+
if (spawnError || child.exitCode !== null || Date.now() > deadline) {
|
|
100
|
+
clearInterval(poll)
|
|
101
|
+
try { child.kill() } catch { /* 已退出 */ }
|
|
102
|
+
console.error(`[dashboard] detach 启动失败${spawnError ? `: ${spawnError.message}` : ''}`)
|
|
103
|
+
if (tail(errFile)) console.error(`--- ${errFile} ---\n${tail(errFile)}`)
|
|
104
|
+
if (tail(logFile)) console.error(`--- ${logFile} ---\n${tail(logFile)}`)
|
|
105
|
+
process.exit(1)
|
|
106
|
+
}
|
|
107
|
+
}, 150)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
// --sessionDir 可选:显式指定会话目录;未传则自动探测(数据目录同级/父级 .harmonybot)
|
|
112
|
+
const sessionDirArg = argValue('sessionDir') ?? argValue('session-dir')
|
|
113
|
+
const api = createDataApi(dataDir, sessionDirArg ? { sessionDir: sessionDirArg } : {})
|
|
114
|
+
// 默认依次探测:单目录布局 '.'(app 内 serve.mjs 与前端同级)→ ../web(旧 skill 布局)→ ../dist(本仓库)
|
|
115
|
+
const defaultDir = ['.', '../web', '../dist']
|
|
116
|
+
.map((d) => path.resolve(__dirname, d))
|
|
117
|
+
.find((d) => fs.existsSync(path.join(d, 'index.html')))
|
|
118
|
+
const distDir = path.resolve(argValue('dir') ?? defaultDir ?? path.join(__dirname, '..', 'web'))
|
|
119
|
+
const host = argValue('host') ?? '127.0.0.1'
|
|
120
|
+
const basePort = Number(argValue('port') ?? 8080)
|
|
121
|
+
const MAX_PORT_RETRY = 10
|
|
122
|
+
|
|
123
|
+
if (!fs.existsSync(path.join(distDir, 'index.html'))) {
|
|
124
|
+
console.error(`[dashboard] 前端产物缺失: ${distDir} 下没有 index.html(请先构建或用 --dir 指定)`)
|
|
125
|
+
process.exit(1)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const STATIC_MIME = {
|
|
129
|
+
'.html': 'text/html; charset=utf-8',
|
|
130
|
+
'.js': 'text/javascript; charset=utf-8',
|
|
131
|
+
'.mjs': 'text/javascript; charset=utf-8',
|
|
132
|
+
'.css': 'text/css; charset=utf-8',
|
|
133
|
+
'.json': 'application/json; charset=utf-8',
|
|
134
|
+
'.svg': 'image/svg+xml',
|
|
135
|
+
'.png': 'image/png',
|
|
136
|
+
'.ico': 'image/x-icon',
|
|
137
|
+
'.woff': 'font/woff',
|
|
138
|
+
'.woff2': 'font/woff2',
|
|
139
|
+
'.map': 'application/json',
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// 服务器脚本与包描述不作为静态资源对外暴露
|
|
143
|
+
const BLOCKED_STATIC = new Set(['/serve.mjs', '/dataApi.mjs', '/package.json'])
|
|
144
|
+
|
|
145
|
+
// ---- SSE 实时推送:文件变化 → /api/data/events 广播 ----
|
|
146
|
+
const sseClients = new Set()
|
|
147
|
+
const sseBroadcast = (files) => {
|
|
148
|
+
const msg = `data: ${JSON.stringify({ files })}\n\n`
|
|
149
|
+
for (const res of sseClients) {
|
|
150
|
+
try {
|
|
151
|
+
res.write(msg)
|
|
152
|
+
} catch {
|
|
153
|
+
sseClients.delete(res)
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const heartbeat = isDetach ? null : setInterval(() => {
|
|
158
|
+
for (const res of sseClients) {
|
|
159
|
+
try {
|
|
160
|
+
res.write(': ping\n\n')
|
|
161
|
+
} catch {
|
|
162
|
+
sseClients.delete(res)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}, 30000)
|
|
166
|
+
const dataWatcher = isDetach ? null : api.watch(sseBroadcast)
|
|
167
|
+
|
|
168
|
+
// --icon 可选:应用图标(本地 png/svg/jpg 路径或 http(s) URL),未传则 /app-icon 返回 404(前端回退文字品牌)
|
|
169
|
+
const iconArg = argValue('icon')
|
|
170
|
+
const ICON_MIME = { '.png': 'image/png', '.svg': 'image/svg+xml', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.gif': 'image/gif' }
|
|
171
|
+
const iconAbs = iconArg && !/^https?:\/\//i.test(iconArg) ? path.resolve(iconArg) : null
|
|
172
|
+
if (iconArg && !iconAbs && !/^https?:\/\//i.test(iconArg)) {
|
|
173
|
+
console.error(`[dashboard] --icon 仅支持本地文件路径或 http(s) URL: ${iconArg}`)
|
|
174
|
+
process.exit(1)
|
|
175
|
+
}
|
|
176
|
+
if (iconAbs && !fs.existsSync(iconAbs)) {
|
|
177
|
+
console.error(`[dashboard] --icon 文件不存在: ${iconAbs}`)
|
|
178
|
+
process.exit(1)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const server = http.createServer((req, res) => {
|
|
182
|
+
const sseUrl = new URL(req.url ?? '/', 'http://localhost')
|
|
183
|
+
if (sseUrl.pathname === '/app-icon') {
|
|
184
|
+
if (!iconArg) {
|
|
185
|
+
res.statusCode = 404
|
|
186
|
+
res.end('not found')
|
|
187
|
+
return
|
|
188
|
+
}
|
|
189
|
+
if (iconAbs) {
|
|
190
|
+
fs.readFile(iconAbs, (err, data) => {
|
|
191
|
+
if (err) {
|
|
192
|
+
res.statusCode = 500
|
|
193
|
+
res.end('error')
|
|
194
|
+
return
|
|
195
|
+
}
|
|
196
|
+
res.statusCode = 200
|
|
197
|
+
res.setHeader('Content-Type', ICON_MIME[path.extname(iconAbs).toLowerCase()] ?? 'application/octet-stream')
|
|
198
|
+
res.setHeader('Cache-Control', 'no-store')
|
|
199
|
+
res.end(data)
|
|
200
|
+
})
|
|
201
|
+
} else {
|
|
202
|
+
res.statusCode = 302
|
|
203
|
+
res.setHeader('Location', iconArg)
|
|
204
|
+
res.end()
|
|
205
|
+
}
|
|
206
|
+
return
|
|
207
|
+
}
|
|
208
|
+
if (sseUrl.pathname === '/api/data/events') {
|
|
209
|
+
res.writeHead(200, {
|
|
210
|
+
'Content-Type': 'text/event-stream',
|
|
211
|
+
'Cache-Control': 'no-cache',
|
|
212
|
+
Connection: 'keep-alive',
|
|
213
|
+
})
|
|
214
|
+
res.write(': connected\n\n')
|
|
215
|
+
sseClients.add(res)
|
|
216
|
+
req.on('close', () => sseClients.delete(res))
|
|
217
|
+
return
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (api.handle(req, res)) return
|
|
221
|
+
|
|
222
|
+
const url = new URL(req.url ?? '/', 'http://localhost')
|
|
223
|
+
if (BLOCKED_STATIC.has(url.pathname)) {
|
|
224
|
+
res.statusCode = 404
|
|
225
|
+
res.end('not found')
|
|
226
|
+
return
|
|
227
|
+
}
|
|
228
|
+
let rel = decodeURIComponent(url.pathname)
|
|
229
|
+
if (rel.endsWith('/')) rel += 'index.html'
|
|
230
|
+
const abs = path.join(distDir, rel)
|
|
231
|
+
|
|
232
|
+
const sendFile = (file) => {
|
|
233
|
+
fs.readFile(file, (err, data) => {
|
|
234
|
+
if (err) {
|
|
235
|
+
res.statusCode = 500
|
|
236
|
+
res.end('error')
|
|
237
|
+
return
|
|
238
|
+
}
|
|
239
|
+
res.statusCode = 200
|
|
240
|
+
res.setHeader('Content-Type', STATIC_MIME[path.extname(file).toLowerCase()] ?? 'application/octet-stream')
|
|
241
|
+
res.end(data)
|
|
242
|
+
})
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// 路径穿越防护
|
|
246
|
+
if (abs !== distDir && !abs.startsWith(distDir + path.sep)) {
|
|
247
|
+
res.statusCode = 403
|
|
248
|
+
res.end('forbidden')
|
|
249
|
+
return
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
fs.stat(abs, (err, stat) => {
|
|
253
|
+
if (!err && stat.isFile()) {
|
|
254
|
+
sendFile(abs)
|
|
255
|
+
} else if (path.extname(rel)) {
|
|
256
|
+
// 带扩展名的资源缺失 → 404
|
|
257
|
+
res.statusCode = 404
|
|
258
|
+
res.end('not found')
|
|
259
|
+
} else {
|
|
260
|
+
// SPA 回退到 index.html
|
|
261
|
+
sendFile(path.join(distDir, 'index.html'))
|
|
262
|
+
}
|
|
263
|
+
})
|
|
264
|
+
})
|
|
265
|
+
|
|
266
|
+
// listening 只注册一次,避免端口重试导致重复输出
|
|
267
|
+
server.once('listening', () => {
|
|
268
|
+
server.on('error', (err) => {
|
|
269
|
+
console.error(`[dashboard] 服务器错误: ${err.message}`)
|
|
270
|
+
})
|
|
271
|
+
console.log(`[dashboard] dataDir=${api.root}`)
|
|
272
|
+
console.log(`[dashboard] http://${host}:${server.address().port}`)
|
|
273
|
+
})
|
|
274
|
+
|
|
275
|
+
server.on('close', () => {
|
|
276
|
+
dataWatcher?.close()
|
|
277
|
+
clearInterval(heartbeat)
|
|
278
|
+
for (const res of sseClients) {
|
|
279
|
+
try {
|
|
280
|
+
res.end()
|
|
281
|
+
} catch {
|
|
282
|
+
/* ignore */
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
sseClients.clear()
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
const listen = (port, attemptsLeft) => {
|
|
289
|
+
const onError = (err) => {
|
|
290
|
+
if (err.code === 'EADDRINUSE' && attemptsLeft > 0) {
|
|
291
|
+
listen(port + 1, attemptsLeft - 1)
|
|
292
|
+
} else if (err.code === 'EADDRINUSE') {
|
|
293
|
+
console.error(`[dashboard] 端口 ${port} 起连续 ${MAX_PORT_RETRY + 1} 个均被占用,请用 --port 指定其他端口`)
|
|
294
|
+
process.exit(1)
|
|
295
|
+
} else {
|
|
296
|
+
console.error(`[dashboard] 启动失败: ${err.message}`)
|
|
297
|
+
process.exit(1)
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
server.once('error', onError)
|
|
301
|
+
// 成功后移除本轮重试 handler,运行期错误走统一日志
|
|
302
|
+
server.once('listening', () => server.removeListener('error', onError))
|
|
303
|
+
server.listen(port, host)
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (isDetach) {
|
|
307
|
+
// detach 模式:父进程不启动服务器,生命周期由上方 poll 接管(成功/失败都会 process.exit)
|
|
308
|
+
} else {
|
|
309
|
+
listen(basePort, MAX_PORT_RETRY)
|
|
310
|
+
}
|
|
@@ -118,10 +118,13 @@ python3 $F/preinject_ids.py --features features.json --out ids.json # 交互
|
|
|
118
118
|
### 3.5 输入契约与空库守卫(宿主 agent ↔ 本 skill 的稳定边界)
|
|
119
119
|
|
|
120
120
|
**只接受以下输入**:scenarios.json / features.json / ids.json / runtime_pages.json /
|
|
121
|
-
_common_template.py / ArkTS
|
|
121
|
+
_common_template.py / ArkTS 源码路径;按需接收迁移工作区 `.migration/private/test-credentials.json`、
|
|
122
|
+
`test-environment.json` 的绝对路径和账号标识。**场景库为空或全部 converted=false 时直接报错
|
|
122
123
|
退出,不生成空用例集**(空跑=伪覆盖)。生成规则见步骤 4;执行后必须产出:
|
|
123
124
|
testcases/*.py、results.json、coverage.md、summary.json、test-report.html、失败截图与 hilog 片段。
|
|
124
125
|
|
|
126
|
+
凭据和环境配置由测试准备或登录用例在本地运行时按需读取,复用开发阶段的同一文件;不输出原文,不把凭据值写入提示词、代码、日志、报告、截图或账本。已有有效登录态先复用;需要登录时执行真实登录并断言结果,验证码或扫码在执行时请求用户配合。文件不存在、空文件、空对象或空字段均视为未配置,不作为流程启动失败;不依赖配置的用例正常执行,可选项允许留空。仅在没有可用登录态且实际依赖必需配置时阻塞相关用例,继续其他可执行用例;未执行或受阻项不得标记通过,不得用固定成功或伪造登录态代替验收。
|
|
127
|
+
|
|
125
128
|
### 4. LLM 白盒精写 testcases/*.py(核心)
|
|
126
129
|
|
|
127
130
|
从 `$F/_common_template.py` 复制为 `testcases/_common.py`(launch 带 `--ps k v` 空格分隔、
|
|
@@ -206,6 +209,8 @@ python3 $F/forge_report.py # 产出 test-report.html(Allure 风格:概况
|
|
|
206
209
|
```
|
|
207
210
|
铁律:修 1 个用例 ≠ 重跑 24 个。run_direct 汇总后 FAIL>0 会直接打印下一步命令——照抄执行。
|
|
208
211
|
|
|
212
|
+
**调用契约(Windows 管道悬挂防护)**:run_direct/probe 与 `droid2hmos test harmony` 派生的 hdc 常驻服务持有会话输出管道——CLI 已打印结果退出,工具调用却等到自身超时(结果其实已成功)。Windows 下命令末尾一律追加 `; $rc=$LASTEXITCODE; hdc kill; exit $rc`(杀掉持有者即返回,保留退出码;PowerShell 原生 `>` 重定向无效);hdc 不在 PATH 或仍悬挂时用 `cmd /c "… > <log> 2>&1"` 兜底。工具调用超时须大于 runner/CLI 总超时;`timedOut` ≠ 失败——先读落盘 `results.json`/报告定性,仅在证明本次未跑或失败时才重跑(盲目重跑会重复安装 HAP、重复设备测试)。
|
|
213
|
+
|
|
209
214
|
**范围回归(touched,产品代码变更后的默认门禁策略)**:
|
|
210
215
|
`--retry-failed` 检测到产品代码变更时不再一律全量——按 `results.meta.json` 的**逐文件指纹**
|
|
211
216
|
diff 出改动集,若全部是 ids.json 可定位的 UI 文件,则只重跑 `FAIL/SKIP + 引用这些文件的用例`
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: d2h-spec-develop
|
|
3
|
-
description: Implement ordered Android-to-HarmonyOS page tasks from pages.json, batch_report.json, and page-scoped spec.md files. Use during page development when a dedicated page-worker must complete one page's ArkTS implementation and managed build; the parent
|
|
3
|
+
description: Implement ordered Android-to-HarmonyOS page tasks from pages.json, batch_report.json, and page-scoped spec.md files. Use during page development when a dedicated page-worker must complete one page's ArkTS implementation and managed build; the worker runs fast page tests; the parent reviews development checks and owns fixes, evidence, commits, and final review before the next page starts.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Page development loop
|
|
7
7
|
|
|
8
|
-
Each page-worker implements only the selected page and brings its build to a pass. After development is complete, the parent agent
|
|
8
|
+
Each page-worker implements only the selected page and brings its build to a pass. After development is complete, the parent agent reviews development checks, defect fixes, and acceptance for the current task. A worker may be reused for a fixed ordered group of up to three related Specs. Implement one assigned task per handoff; the parent accepts it before authorizing the same worker to continue with the next member. Task identities, states, evidence and acceptance remain separate. Reuse is conditional on the host supporting child-session continuation and the parent confirming that the next task shares relevant context, the worker can use the refreshed baseline and interfaces, and no unresolved task or ownership conflict remains. Otherwise, explicitly revise the group and dispatch a fresh worker for the remaining scope.
|
|
9
9
|
|
|
10
10
|
## Inputs and boundaries
|
|
11
11
|
|
|
@@ -15,6 +15,7 @@ Each page-worker implements only the selected page and brings its build to a pas
|
|
|
15
15
|
- Read `.migration/utg/page.json` when the Spec references a UTG node or the arrival path needs clarification. Read cited Android source before implementing or fixing behavior.
|
|
16
16
|
- Each `page_NNNN_<name>-<id>/` directory contains only `spec.md`. Do not add `ui-design.md`, copied screenshots, copied `view.xml`, or test/build evidence to page packages. Keep evidence in the resolved task evidence directory.
|
|
17
17
|
- Do not regenerate `pages.json`, page Specs, or `batch_report.json` during ordinary development. Correct an owning artifact only when current source proves it wrong, record the reason, and preserve execution history.
|
|
18
|
+
- When the current task needs external credentials or environment settings, the worker or parent may use `<migration-root>/private/test-credentials.json` and `test-environment.json` for implementation checks or testing. Read only needed values through local execution, without printing their contents or passing secrets in prompts, handoffs, code, logs, Specs or the ledger. Reuse valid configuration or an existing valid login session. Missing files, empty files/objects or blank fields mean unconfigured, not a startup failure; optional values may remain unset, and missing required values block only checks that actually depend on them. Continue other eligible work and keep blocked or unexecuted checks distinct from passed. Development checks do not replace parent acceptance.
|
|
18
19
|
- Use `droid2hmos` managed build and test entry points. Do not use task-planning commands or static scripts to choose or execute page work.
|
|
19
20
|
- Preserve unrelated user changes throughout implementation, parent fixes, and commits. Never reset, discard, or include them in a page commit.
|
|
20
21
|
|
|
@@ -23,8 +24,8 @@ Each page-worker implements only the selected page and brings its build to a pas
|
|
|
23
24
|
1. Read `pages.json` and `batch_report.json`; verify task identities, Spec paths and dependencies against pages.json, and use ledger planning for development scope and execution order. Verify planning references, counts and states. Reject missing, stale or invalid planning instead of falling back to all tasks when a selected scope or planning is present.
|
|
24
25
|
2. Select the earliest eligible task in planning milestone/wave order (or legacy ledger tasks order when allowed) whose development/build/validation states are not `implemented/passed/passed` and whose declared dependencies are satisfied. When bound planning is present, the parent may group it with adjacent unfinished tasks in the same wave that share page, module or component context, normally two or three tasks and never more than three. Fix the ordered task IDs before dispatch; keep complex or unclear work as a single task and verify dependencies again before each member starts.
|
|
25
26
|
3. Resolve the page package, Android root, HarmonyOS root, repository root, current `HEAD`, Git status, device target, and task evidence directory.
|
|
26
|
-
4. Dispatch exactly one page-worker with absolute paths, the current task ID, ordered group task IDs when present, dispatch baseline, device target, and task evidence directory. Do not run page-workers in parallel. Wait for its result before the parent begins
|
|
27
|
-
5. After the worker returns, the parent takes ownership of the current page and
|
|
27
|
+
4. Dispatch exactly one page-worker with absolute paths, the current task ID, ordered group task IDs when present, dispatch baseline, device target, and task evidence directory. Do not run page-workers in parallel. Wait for its result before the parent begins review and fixes. Preserve the returned child-session identifier for possible continuation; use the host's actual resume parameter and confirm that the continuation returns the same session ID. A new child session is a fresh dispatch, not context reuse.
|
|
28
|
+
5. After the worker returns, the parent takes ownership of the current page and reviews the worker's necessary checks and fixes according to **Development checks and fixes** below until the current build and necessary checks pass.
|
|
28
29
|
6. Execute **Parent report and commits** below.
|
|
29
30
|
7. Apply **Parent verification** below. Only after the current page reaches `implemented/passed/passed`, evidence is current, and all page-owned changes are committed may the parent authorize the same worker to implement the next group member. Refresh its task package, baseline, permitted paths, dependency evidence and evidence directory. If continuation is unsupported or reuse review fails, explicitly revise the group and dispatch a fresh worker for the next eligible task with these refreshed inputs; lack of reuse support must not block normal serial development. If a member is blocked or the group becomes invalid, return to the parent with remaining tasks unchanged; do not skip members or expand the group. Dispatch a worker for a new group only after the current group closes or is explicitly revised.
|
|
30
31
|
|
|
@@ -47,7 +48,7 @@ Evidence directory: <absolute task/run directory>
|
|
|
47
48
|
Own the complete page loop: read spec.md, UTG evidence and cited Android source;
|
|
48
49
|
implement the page; run managed build; update the migration report and batch_report.json in place;
|
|
49
50
|
create scoped commits; Do not start another page.
|
|
50
|
-
After handoff, the parent
|
|
51
|
+
After handoff, the parent reviews development checks and owns remaining fixes, rebuilding, and acceptance.
|
|
51
52
|
```
|
|
52
53
|
|
|
53
54
|
If independent page-worker execution is unavailable, return that the required mode cannot run. Do not silently implement multiple pages in the parent agent.
|
|
@@ -61,7 +62,7 @@ If independent page-worker execution is unavailable, return that the required mo
|
|
|
61
62
|
- Mark only the selected task `in_progress` in `batch_report.json`.
|
|
62
63
|
- Read the complete `spec.md`, the referenced `.migration/utg/page.json` node, every cited Fact, and every cited Android source file. Follow handlers, state transitions, repositories, navigation, persistence, error paths, and platform side effects far enough to establish the observable result.
|
|
63
64
|
- Inspect the HarmonyOS architecture, routes, resources, shared components, tests, and current implementation. Load `arkts-mvvm-architecture` before planning or writing ArkTS.
|
|
64
|
-
- Build a private checklist mapping every `F-xxx` to reachable code, a stable semantic locator, an
|
|
65
|
+
- Build a private checklist mapping every `F-xxx` to reachable code, a stable semantic locator, an appropriate development check, and an observable result. Do not create another planning file.
|
|
65
66
|
- Resume valid existing work for this same task instead of duplicating it.
|
|
66
67
|
|
|
67
68
|
### 2. Implement
|
|
@@ -77,39 +78,37 @@ If independent page-worker execution is unavailable, return that the required mo
|
|
|
77
78
|
### 3. Managed build
|
|
78
79
|
|
|
79
80
|
- Run a fresh, non-interactive, bounded build through `droid2hmos build harmony <ANDROID_PROJECT>` using the resolved project configuration.
|
|
81
|
+
- Bound the invocation: tool-call `timeout` > CLI `--timeout-ms` > per-case watchdog; never rely on the tool default (suggested: build 15 min / `--timeout-ms 780000`, test 20 min / `--timeout-ms 1080000`).
|
|
82
|
+
- On Windows the CLI's lingering hdc server holds the session pipes after the CLI exits, hanging the tool call despite a printed result. Invoke `droid2hmos.cmd` (the `.ps1` shim is policy-blocked) with the kill suffix: `droid2hmos.cmd build harmony <ANDROID_PROJECT> --timeout-ms 780000; $rc=$LASTEXITCODE; hdc kill; exit $rc`. If hdc is not on PATH or the call still hangs, fall back to `cmd /c "droid2hmos.cmd ... > <evidence>/build.log 2>&1"` and read the file back (PowerShell-native redirection does not help). A tool timeout is not a failure verdict: read the on-disk JSON result/report before re-running.
|
|
80
83
|
- Save the exact command, exit status, timestamps, relevant log, produced HAP path, and HAP SHA-256 in the task evidence directory.
|
|
81
84
|
- Fix compilation errors caused or exposed by the implementation within this worker until the build passes.
|
|
82
85
|
- An older HAP, static analysis result, direct Hvigor run, or previous log is not current build evidence.
|
|
83
86
|
|
|
84
87
|
### 4. Worker report and commits
|
|
85
88
|
|
|
86
|
-
- Load `maintaining-migration-report` while evidence is fresh. Record real HarmonyOS files, Android source provenance, current managed evidence, differences, and source-proven discoveries; run report validation.
|
|
87
89
|
- After a successful build, inspect Git status and diff and create a scoped initial implementation commit containing only this page's implementation, resources, required shared files, and source-proven Spec corrections. Do not commit unrelated changes.
|
|
88
90
|
- Update the existing `batch_report.json` task object, summary, evidence, files, implementation commit, timestamps, blockers, and append-only history in place. Do not rerun `build_batch_report.py`. When planning is present, record planning_ref with revision, sha256, milestone_id and wave_id in this run's task history. Preserve planning and planning_history when updating task results.
|
|
89
91
|
- Set `implemented/passed/not_run` only when all three states are supported by current evidence. Use AI inspection to confirm task/summary/history consistency and preserve all prior history.
|
|
90
|
-
-
|
|
92
|
+
- Run planned fast tests and include their evidence in the handoff. Then stop modifying this page; do not select the next page. Parent owns independent verification.
|
|
91
93
|
|
|
92
|
-
##
|
|
94
|
+
## Check-level acceptance in batch_report.json
|
|
93
95
|
|
|
94
|
-
|
|
95
|
-
- Cover navigation or overlay lifecycle, state changes, data effects, and error behavior required by the Spec. Assertions must prove the declared result, not merely that a page or button exists.
|
|
96
|
-
- Run only the current page's test lists (the `pageNNNN_*` lists owned by this task) through the managed entry point. Do not append regression lists from other pages.
|
|
96
|
+
Record acceptance items in `tasks[].checks[]` in the existing ledger. Map every Spec acceptance item to a stable `spec_id` and `check_id`; preserve separate results for independent Specs, task fields, evidence and history. Each check has `description`, `expected`, `risk`, `risk_reason`, `level`, `timing`, and `status` as defined by d2h-spec-plan. Keep `not_run`, `failed`, `blocked`, and `manual_pending` distinct; do not turn manual or deferred checks into passed. For passed checks record `test_ref`, the actual `assertion`, immutable `evidence`, and current `candidate` identity (HAP/source as appropriate). Planning records rationale and timing; execution records outcomes. Verify evidence contents and freshness and review completeness against the original Spec, including every step and error branch.
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
droid2hmos test harmony <ANDROID_PROJECT> \
|
|
100
|
-
--runner python --hypium-project <HARMONY_PROJECT>/.hypium_forge \
|
|
101
|
-
--test-list <THIS_PAGE_LIST> --target <DEVICE> \
|
|
102
|
-
--ref <ACTUALLY_ASSERTED_REF>...
|
|
103
|
-
```
|
|
98
|
+
The worker runs necessary focused checks during development; the parent reviews their scope, results and evidence. Task validation covers these development checks, not full device acceptance. Keep unexecuted device or end-to-end checks as `not_run` or `manual_pending`, state the limitation in the handoff, and do not block the next task solely because optional device tests were not requested.
|
|
104
99
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
-
|
|
100
|
+
## Development checks and fixes
|
|
101
|
+
|
|
102
|
+
- During implementation, the worker runs the managed build and focused static, logic or integration checks needed for changed behavior and likely regressions. Reuse existing tests; add tests only where they provide useful verification.
|
|
103
|
+
- The parent reviews the implementation and current check evidence; rerun or add focused checks only for a failure, a material evidence gap, or a subsequent code change.
|
|
104
|
+
- Do not load `d2h-hypium-forge`, generate Python Hypium test assets, or start a separate page test cycle by default. Run device/end-to-end tests only when the user explicitly requests them; then load the applicable testing Skill and use managed test entry points.
|
|
105
|
+
- Record actual commands, results and evidence in the task evidence directory. A build pass does not prove runtime behavior; unexecuted checks are not passed.
|
|
106
|
+
- Apply the same timeout ladder and Windows kill-suffix rule to `droid2hmos test harmony`; treat a tool timeout as unverified and read the on-disk Hypium results before re-running.
|
|
107
|
+
- Fix failures in the current implementation and repeat the affected checks and managed build as needed before handoff or parent approval.
|
|
108
108
|
|
|
109
109
|
## Parent report and commits
|
|
110
110
|
|
|
111
|
-
-
|
|
112
|
-
- Inspect the final diff. After current build and tests pass, commit the parent's page fixes, test files, and necessary shared changes.
|
|
111
|
+
- Inspect the final diff. After the current build and necessary development checks pass, commit the parent's page fixes, test files, and necessary shared changes.
|
|
113
112
|
- Update the existing `batch_report.json` task object, summary, evidence, files, implementation commit, timestamps, blockers, and append-only history in place. Do not rerun `build_batch_report.py`. When planning is present, record planning_ref with revision, sha256, milestone_id and wave_id in this run's task history. Preserve planning and planning_history when updating task results.
|
|
114
113
|
- Set `implemented/passed/passed` only when all three states are supported by current evidence. Use AI inspection to confirm task/summary/history consistency and preserve all prior history.
|
|
115
114
|
- Commit the ledger and immutable task evidence separately from the implementation commit. Do not create a self-referential commit field.
|
|
@@ -118,7 +117,7 @@ If independent page-worker execution is unavailable, return that the required mo
|
|
|
118
117
|
|
|
119
118
|
Before dispatching a worker for the next page, the parent confirms:
|
|
120
119
|
|
|
121
|
-
- every dispatched `F-xxx` has reachable implementation
|
|
120
|
+
- every dispatched `F-xxx` has reachable implementation and appropriate development verification; unverified runtime behavior is explicitly recorded;
|
|
122
121
|
- the page is reachable from the real app entry without a test-only route or replacement control;
|
|
123
122
|
- final build logs, installed HAP hash, source snapshot, test reports, managed evidence, migration-report refs, and recorded implementation commit correspond to the final tested application;
|
|
124
123
|
- `batch_report.json` is internally consistent and the selected task row is `implemented/passed/passed`;
|
|
@@ -129,7 +128,7 @@ If any check fails, the parent continues fixing the issues and repeats the neces
|
|
|
129
128
|
|
|
130
129
|
## Batch regression
|
|
131
130
|
|
|
132
|
-
Run
|
|
131
|
+
Run batch regression or device/end-to-end testing only when the user explicitly requests it. During ordinary page development, run only necessary focused development checks.
|
|
133
132
|
|
|
134
133
|
## Worker result
|
|
135
134
|
|
|
Binary file
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Validate one task's optional check records without changing the ledger."""
|
|
3
|
+
import argparse
|
|
4
|
+
import json
|
|
5
|
+
import sys
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def inspect_task(task):
|
|
10
|
+
checks = task.get('checks')
|
|
11
|
+
if checks is None:
|
|
12
|
+
return {'status': 'unmapped', 'errors': ['checks missing; map Spec acceptance items first']}
|
|
13
|
+
if not isinstance(checks, list) or not checks:
|
|
14
|
+
return {'status': 'unmapped', 'errors': ['checks must be a non-empty list']}
|
|
15
|
+
errors, seen = [], set()
|
|
16
|
+
for index, check in enumerate(checks):
|
|
17
|
+
if not isinstance(check, dict):
|
|
18
|
+
errors.append(f'checks[{index}] must be an object')
|
|
19
|
+
continue
|
|
20
|
+
cid = check.get('check_id')
|
|
21
|
+
identity = (check.get('spec_id'), cid)
|
|
22
|
+
if not isinstance(cid, str) or not cid.strip() or identity in seen:
|
|
23
|
+
errors.append(f'checks[{index}]: missing or duplicate check_id')
|
|
24
|
+
else:
|
|
25
|
+
seen.add(identity)
|
|
26
|
+
for key in ('spec_id', 'description', 'expected', 'risk_reason'):
|
|
27
|
+
if not isinstance(check.get(key), str) or not check[key].strip():
|
|
28
|
+
errors.append(f'{cid}: missing {key}')
|
|
29
|
+
for key, values in (('risk', ('low', 'medium', 'high')), ('level', ('static', 'logic', 'integration', 'device')),
|
|
30
|
+
('timing', ('after_task', 'after_prerequisites', 'wave', 'final')),
|
|
31
|
+
('status', ('not_run', 'passed', 'failed', 'blocked', 'manual_pending'))):
|
|
32
|
+
if check.get(key) not in values:
|
|
33
|
+
errors.append(f'{cid}: invalid {key}')
|
|
34
|
+
if check.get('timing') == 'after_prerequisites':
|
|
35
|
+
prerequisites = check.get('prerequisites')
|
|
36
|
+
if not isinstance(prerequisites, list) or not prerequisites or not all(isinstance(v, str) and v.strip() for v in prerequisites):
|
|
37
|
+
errors.append(f'{cid}: after_prerequisites requires prerequisites')
|
|
38
|
+
if not isinstance(check.get('deadline'), str) or not check['deadline'].strip():
|
|
39
|
+
errors.append(f'{cid}: after_prerequisites requires deadline')
|
|
40
|
+
if check.get('status') != 'passed':
|
|
41
|
+
errors.append(f'{cid}: not passed ({check.get("status")})')
|
|
42
|
+
elif not all(isinstance(check.get(k), str) and check[k].strip() for k in ('test_ref', 'assertion', 'evidence', 'candidate')):
|
|
43
|
+
errors.append(f'{cid}: passed requires test_ref, assertion, evidence and candidate')
|
|
44
|
+
return {'status': 'incomplete' if errors else 'ready_for_review', 'errors': errors}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def main():
|
|
48
|
+
p = argparse.ArgumentParser(description=__doc__)
|
|
49
|
+
p.add_argument('--report', type=Path, required=True)
|
|
50
|
+
p.add_argument('--task', required=True)
|
|
51
|
+
args = p.parse_args()
|
|
52
|
+
try:
|
|
53
|
+
data = json.loads(args.report.read_text(encoding='utf-8'))
|
|
54
|
+
tasks = [t for t in data['tasks'] if t.get('task_id') == args.task]
|
|
55
|
+
if len(tasks) != 1:
|
|
56
|
+
raise ValueError('task_id must identify exactly one task')
|
|
57
|
+
result = inspect_task(tasks[0])
|
|
58
|
+
except (OSError, ValueError, KeyError, TypeError) as exc:
|
|
59
|
+
print(json.dumps({'status': 'error', 'errors': [str(exc)]}, ensure_ascii=False))
|
|
60
|
+
return 2
|
|
61
|
+
print(json.dumps({'task_id': args.task, **result}, ensure_ascii=False, indent=2))
|
|
62
|
+
return 0 if result['status'] == 'ready_for_review' else 1
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
if __name__ == '__main__':
|
|
66
|
+
sys.exit(main())
|
|
@@ -102,6 +102,8 @@ Use these headings in every page Spec, preserving complete behavior, exception p
|
|
|
102
102
|
|
|
103
103
|
## UI 操作与验收
|
|
104
104
|
|
|
105
|
+
为每个独立可观察验收结果提供稳定的 `spec_id` 和 `check_id`(包含前置、动作、预期及源码依据);不得将多个开关或失败分支合并为一个笼统检查。规划与执行在现有 batch_report.json 的任务 `checks[]` 关联这些 ID,不把 Spec 本文当作执行通过证据。
|
|
106
|
+
|
|
105
107
|
### F-001
|
|
106
108
|
|
|
107
109
|
1. <从真实应用入口进入当前页面。>
|
|
@@ -23,6 +23,12 @@ description: 基于已确认功能范围、选定架构和已有页面规格规
|
|
|
23
23
|
|
|
24
24
|
记录波次成本、风险、外部条件及结束时需要核对的页面验收结果,不改变逐页构建、测试、提交和验收要求。页面未完成不能因波次收尾而跳过;阶段完成必须引用执行账本和当前证据。
|
|
25
25
|
|
|
26
|
+
### 逐项验证安排
|
|
27
|
+
|
|
28
|
+
在已有 `tasks[]` 对象增量维护可选 `checks[]`,不改变原任务 ID、现有状态、证据或历史。每个 Spec 验收结果都需有稳定 `spec_id` / `check_id`;以来源明确检查范围,不凭页面名称猜测覆盖。逐项记录 `description`、`expected`、`risk`(low/medium/high)、`risk_reason`、`level`(static/logic/integration/device)、`timing`(after_task/after_prerequisites/wave/final)和 `status`(not_run/passed/failed/blocked/manual_pending)。用户范围和优先级优先;默认只安排开发阶段必要的快速检查;设备和端到端测试仅在用户明确要求时安排,未执行项如实保留状态,不因未请求的专项测试阻塞后续开发;依赖尚未满足时使用 `prerequisites` 非空数组及 `deadline` 记录前置和最晚验证点。只计划,不把待测项写成通过。
|
|
29
|
+
|
|
30
|
+
`checks[]` 的执行字段由开发与验收原位维护;调整策略保留既有证据和历史,涉及风险或范围变化时重新评估其适用性。不得将缺失或不适用的证据冒充当前通过。结构校验不证明 Spec 语义覆盖完整,必须逐条人工或 Agent 审查。
|
|
31
|
+
|
|
26
32
|
## 交付与记录
|
|
27
33
|
|
|
28
34
|
里程碑、波次、排序和纳入/排除任务统一保存到 `batch_report.json.planning`,由主 Agent 核对后原位写入;修订前将旧规划完整追加到 planning_history。开发与恢复只读取该账本,不维护独立的当前 plan.json。
|