opencode-agent-harness 0.0.0-stage → 0.2.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.
- package/CHANGELOG.md +23 -0
- package/LICENSE +21 -0
- package/README.md +590 -2
- package/bin/agent-harness.js +3059 -0
- package/contrib/global-plugins/README.md +49 -0
- package/contrib/global-plugins/harness-freshness.ts +355 -0
- package/package.json +48 -4
- package/templates/.agents/AGENTS.md +204 -0
- package/templates/.agents/features/INDEX.md +10 -0
- package/templates/.agents/handoffs/README.md +87 -0
- package/templates/.agents/memory/dev-loop.md +59 -0
- package/templates/.agents/memory/domain-map.md +29 -0
- package/templates/.agents/memory/environments.md +35 -0
- package/templates/.agents/memory/flow-map.md +23 -0
- package/templates/.agents/memory/history.md +7 -0
- package/templates/.agents/memory/locations.md +14 -0
- package/templates/.agents/memory/model-routing.md +261 -0
- package/templates/.agents/memory/orchestration.md +183 -0
- package/templates/.agents/memory/owned-files.md +19 -0
- package/templates/.agents/memory/product-principles.md +37 -0
- package/templates/.agents/memory/quality-parameters.md +37 -0
- package/templates/.agents/memory/stack-versions.md +35 -0
- package/templates/.agents/memory/test-design-parameters.md +36 -0
- package/templates/.agents/nightly.json +17 -0
- package/templates/.agents/qa-plans/README.md +70 -0
- package/templates/.agents/qa-runs/README.md +21 -0
- package/templates/.agents/reviews/README.md +47 -0
- package/templates/.agents/rules/00-operating.md +199 -0
- package/templates/.agents/skills/data-engineer/SKILL.md +31 -0
- package/templates/.agents/skills/devops-engineer/SKILL.md +50 -0
- package/templates/.agents/skills/diagnostics-expert/SKILL.md +44 -0
- package/templates/.agents/skills/docs/SKILL.md +140 -0
- package/templates/.agents/skills/features/SKILL.md +187 -0
- package/templates/.agents/skills/frontend-engineer/SKILL.md +81 -0
- package/templates/.agents/skills/handoff/SKILL.md +85 -0
- package/templates/.agents/skills/mobile-engineer/SKILL.md +101 -0
- package/templates/.agents/skills/planner/SKILL.md +112 -0
- package/templates/.agents/skills/product-manager/SKILL.md +115 -0
- package/templates/.agents/skills/qa-architect/SKILL.md +224 -0
- package/templates/.agents/skills/qa-runner/SKILL.md +64 -0
- package/templates/.agents/skills/security-engineer/SKILL.md +53 -0
- package/templates/.agents/skills/system-architect/SKILL.md +42 -0
- package/templates/.agents/skills/ui-designer/SKILL.md +71 -0
- package/templates/.github/workflows/ci.yml +148 -0
- package/templates/.github/workflows/deploy-uat.yml +95 -0
- package/templates/.github/workflows/nightly.yml +83 -0
- package/templates/.github/workflows/uat-health.yml +41 -0
- package/templates/.husky/pre-push +23 -0
- package/templates/.ignore +28 -0
- package/templates/.opencode/agents/data-engineer.md +37 -0
- package/templates/.opencode/agents/devops-engineer.md +37 -0
- package/templates/.opencode/agents/diagnostics-expert.md +37 -0
- package/templates/.opencode/agents/docs.md +37 -0
- package/templates/.opencode/agents/features.md +21 -0
- package/templates/.opencode/agents/frontend-engineer.md +37 -0
- package/templates/.opencode/agents/handoff.md +21 -0
- package/templates/.opencode/agents/mobile-engineer.md +37 -0
- package/templates/.opencode/agents/planner.md +34 -0
- package/templates/.opencode/agents/product-manager.md +29 -0
- package/templates/.opencode/agents/qa-architect.md +27 -0
- package/templates/.opencode/agents/qa-runner.md +17 -0
- package/templates/.opencode/agents/security-engineer.md +37 -0
- package/templates/.opencode/agents/system-architect.md +37 -0
- package/templates/.opencode/agents/ui-designer.md +37 -0
- package/templates/.opencode/commands/board.md +15 -0
- package/templates/.opencode/commands/checkpoint.md +25 -0
- package/templates/.opencode/commands/feature.md +56 -0
- package/templates/.opencode/commands/finish.md +36 -0
- package/templates/.opencode/commands/next.md +49 -0
- package/templates/.opencode/commands/report.md +55 -0
- package/templates/.opencode/commands/resume.md +39 -0
- package/templates/.opencode/commands/switch-model.md +34 -0
- package/templates/.opencode/commands/tidy.md +49 -0
- package/templates/.opencode/plugins/backlog-notify.ts +57 -0
- package/templates/.opencode/plugins/backlog.ts +272 -0
- package/templates/.opencode/plugins/checkpoint.ts +160 -0
- package/templates/.opencode/plugins/context-guard.ts +1164 -0
- package/templates/.opencode/plugins/diff.ts +85 -0
- package/templates/.opencode/plugins/gates.ts +71 -0
- package/templates/.opencode/plugins/job-notify.ts +241 -0
- package/templates/.opencode/plugins/orient.ts +67 -0
- package/templates/.opencode/plugins/session.ts +89 -0
- package/templates/.opencode/plugins/wait.ts +101 -0
- package/templates/.opencode/plugins/where.ts +70 -0
- package/templates/.opencode/skills/bounded-explore/SKILL.md +38 -0
- package/templates/.opencode/skills/dev-loop/SKILL.md +87 -0
- package/templates/.vercelignore +16 -0
- package/templates/AGENTS.md +27 -0
- package/templates/BACKLOG.md +95 -0
- package/templates/docs/ci-cd-pipeline.md +81 -0
- package/templates/docs/gates.md +128 -0
- package/templates/docs/mcp-integrations.md +97 -0
- package/templates/docs/mobile-testing.md +555 -0
- package/templates/docs/nightly-testing.md +106 -0
- package/templates/docs/wsl-optimizations.md +290 -0
- package/templates/opencode.json +188 -0
- package/templates/scripts/agent-report.js +541 -0
- package/templates/scripts/agent-search.sh +117 -0
- package/templates/scripts/backlog.js +1864 -0
- package/templates/scripts/board-service.sh +207 -0
- package/templates/scripts/checkpoint.js +290 -0
- package/templates/scripts/finalize.js +277 -0
- package/templates/scripts/nightly.js +913 -0
- package/templates/scripts/orient.js +514 -0
- package/templates/scripts/qa/board-client.js +260 -0
- package/templates/scripts/qa/board-lib.js +96 -0
- package/templates/scripts/qa/board-sync.js +469 -0
- package/templates/scripts/qa/capacity-lib.js +916 -0
- package/templates/scripts/qa/check-backlog.js +427 -0
- package/templates/scripts/qa/check-capacity.js +85 -0
- package/templates/scripts/qa/check-ci-policy.js +164 -0
- package/templates/scripts/qa/check-concurrency.js +344 -0
- package/templates/scripts/qa/check-dispatch-config.js +296 -0
- package/templates/scripts/qa/check-docs.js +284 -0
- package/templates/scripts/qa/check-integrate.js +98 -0
- package/templates/scripts/qa/check-linger.js +160 -0
- package/templates/scripts/qa/check-prefix-stability.js +183 -0
- package/templates/scripts/qa/check-product.js +177 -0
- package/templates/scripts/qa/check-qa-plan.js +378 -0
- package/templates/scripts/qa/check-qa-scripts.js +85 -0
- package/templates/scripts/qa/check-quality.js +249 -0
- package/templates/scripts/qa/check-test-wiring.js +253 -0
- package/templates/scripts/qa/ci-triage.js +346 -0
- package/templates/scripts/qa/ci-usage-lib.js +185 -0
- package/templates/scripts/qa/ci-wait-lib.js +294 -0
- package/templates/scripts/qa/command-classifier.js +552 -0
- package/templates/scripts/qa/context-guard-core.js +1618 -0
- package/templates/scripts/qa/diff.js +174 -0
- package/templates/scripts/qa/feature-scaffold.js +224 -0
- package/templates/scripts/qa/fixtures/backlog.md +104 -0
- package/templates/scripts/qa/governance.js +174 -0
- package/templates/scripts/qa/hash-file.js +32 -0
- package/templates/scripts/qa/lease-lib.js +263 -0
- package/templates/scripts/qa/merge-backlog.js +324 -0
- package/templates/scripts/qa/mobile-e2e/analyze-timings.js +300 -0
- package/templates/scripts/qa/mobile-e2e/apk-cache.js +420 -0
- package/templates/scripts/qa/mobile-e2e/backend-build-cache.js +203 -0
- package/templates/scripts/qa/mobile-e2e/boot-emulator.sh +432 -0
- package/templates/scripts/qa/mobile-e2e/build-apk.sh +210 -0
- package/templates/scripts/qa/mobile-e2e/check-flows.js +453 -0
- package/templates/scripts/qa/mobile-e2e/config.yaml +18 -0
- package/templates/scripts/qa/mobile-e2e/device-down.sh +88 -0
- package/templates/scripts/qa/mobile-e2e/device-up.sh +258 -0
- package/templates/scripts/qa/mobile-e2e/ios-simulator-down.sh +72 -0
- package/templates/scripts/qa/mobile-e2e/ios-simulator-up.sh +153 -0
- package/templates/scripts/qa/mobile-e2e/job-events.js +181 -0
- package/templates/scripts/qa/mobile-e2e/prewarm.sh +56 -0
- package/templates/scripts/qa/mobile-e2e/run-detached.sh +222 -0
- package/templates/scripts/qa/mobile-e2e/run-maestro.js +1543 -0
- package/templates/scripts/qa/mobile-e2e/ui-dump.js +327 -0
- package/templates/scripts/qa/models.allowlist.txt +32 -0
- package/templates/scripts/qa/provider-stats.js +878 -0
- package/templates/scripts/qa/run-clean.js +83 -0
- package/templates/scripts/qa/run-gates.js +212 -0
- package/templates/scripts/qa/run-loop.js +220 -0
- package/templates/scripts/qa/session-recon.js +512 -0
- package/templates/scripts/qa/store-lib.js +324 -0
- package/templates/scripts/qa/tool-lib.js +134 -0
- package/templates/scripts/qa/where.js +214 -0
- package/templates/scripts/qa/wslconfig-merge.js +157 -0
- package/templates/scripts/serve.js +1328 -0
- package/templates/scripts/setup-nightly.sh +185 -0
- package/templates/scripts/setup-tmpfs.sh +374 -0
- package/templates/scripts/ship.js +586 -0
- package/templates/scripts/switch-reasoning-model.ps1 +101 -0
- package/templates/scripts/switch-reasoning-model.sh +104 -0
- package/templates/scripts/wait-for.js +342 -0
- package/templates/scripts/wsl-gpu.sh +180 -0
- package/templates/scripts/wsl-tune.sh +261 -0
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* mobile E2E — inspect a UI hierarchy, live on the device or from a saved
|
|
6
|
+
* Maestro failure artifact. Harness-owned; project values come from `local.json`.
|
|
7
|
+
*
|
|
8
|
+
* Why this exists: diagnosing a failed Maestro step means reading the on-screen
|
|
9
|
+
* hierarchy (which testIDs / text / bounds were actually present), but
|
|
10
|
+
* hand-rolling that — `adb -s emulator-5554 shell uiautomator dump …`, `python3`
|
|
11
|
+
* parsing `~/.maestro/tests/.../screen-hierarchy/*.json`, `ls ~/.maestro/...` —
|
|
12
|
+
* trips two guards: the capacity classifier mis-read the device serial /
|
|
13
|
+
* `.maestro` path as launching an emulator/Maestro, and the tool guard blocks
|
|
14
|
+
* `ls`/`grep`/`find` inspection. This is the blessed, lightweight path: it never
|
|
15
|
+
* launches a heavy tier, and it lists the artifacts for you (`--list-artifacts`)
|
|
16
|
+
* so you never shell into `~/.maestro`.
|
|
17
|
+
*
|
|
18
|
+
* Usage:
|
|
19
|
+
* node scripts/qa/mobile-e2e/ui-dump.js --live [--serial <s>] [--filter <re>] [--json]
|
|
20
|
+
* node scripts/qa/mobile-e2e/ui-dump.js [--latest | --file <path>] [--flow <name>] [--step <substr>]
|
|
21
|
+
* node scripts/qa/mobile-e2e/ui-dump.js --list-artifacts [--flow <name>]
|
|
22
|
+
*
|
|
23
|
+
* Options:
|
|
24
|
+
* --live dump the hierarchy from the running device (adb)
|
|
25
|
+
* --serial <s> device serial for --live (default: first adb device)
|
|
26
|
+
* --file <path> a Maestro screen-hierarchy JSON file
|
|
27
|
+
* --latest newest Maestro screen-hierarchy JSON (default offline mode)
|
|
28
|
+
* --flow <name> restrict artifacts to this flow dir
|
|
29
|
+
* --step <substr> restrict artifacts to files containing this substring
|
|
30
|
+
* --list-artifacts print candidate hierarchy/screenshot files and exit
|
|
31
|
+
* --filter <re> only print nodes whose id/text/desc/class matches <re>
|
|
32
|
+
* --json print the normalized tree as JSON
|
|
33
|
+
* --max <n> cap printed lines (default 300)
|
|
34
|
+
* -h, --help print this usage and exit 0
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
const fs = require('fs');
|
|
38
|
+
const os = require('os');
|
|
39
|
+
const path = require('path');
|
|
40
|
+
const { spawnSync } = require('node:child_process');
|
|
41
|
+
|
|
42
|
+
const DEFAULT_MAX = 300;
|
|
43
|
+
|
|
44
|
+
function usage() {
|
|
45
|
+
return [
|
|
46
|
+
'mobile E2E — UI hierarchy dump (live device, or a Maestro failure artifact)',
|
|
47
|
+
'',
|
|
48
|
+
'Usage:',
|
|
49
|
+
' node scripts/qa/mobile-e2e/ui-dump.js --live [--serial <s>] [--filter <re>] [--json]',
|
|
50
|
+
' node scripts/qa/mobile-e2e/ui-dump.js [--latest|--file <path>] [--flow <name>] [--step <substr>]',
|
|
51
|
+
' node scripts/qa/mobile-e2e/ui-dump.js --list-artifacts [--flow <name>]',
|
|
52
|
+
'',
|
|
53
|
+
'This is the sanctioned, lightweight way to read a hierarchy — never shell',
|
|
54
|
+
'into ~/.maestro or hand-roll an adb uiautomator probe.',
|
|
55
|
+
].join('\n');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function parseArgs(argv) {
|
|
59
|
+
const o = { live: false, latest: false, file: null, flow: null, step: null, list: false, filter: null, json: false, max: DEFAULT_MAX, serial: null, help: false };
|
|
60
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
61
|
+
const a = argv[i];
|
|
62
|
+
if (a === '--live') o.live = true;
|
|
63
|
+
else if (a === '--latest') o.latest = true;
|
|
64
|
+
else if (a === '--list-artifacts') o.list = true;
|
|
65
|
+
else if (a === '--json') o.json = true;
|
|
66
|
+
else if (a === '--help' || a === '-h') o.help = true;
|
|
67
|
+
else if (a === '--file' && argv[i + 1]) o.file = path.resolve(argv[++i]);
|
|
68
|
+
else if (a.startsWith('--file=')) o.file = path.resolve(a.slice(7));
|
|
69
|
+
else if (a === '--flow' && argv[i + 1]) o.flow = argv[++i];
|
|
70
|
+
else if (a.startsWith('--flow=')) o.flow = a.slice(7);
|
|
71
|
+
else if (a === '--step' && argv[i + 1]) o.step = argv[++i];
|
|
72
|
+
else if (a.startsWith('--step=')) o.step = a.slice(7);
|
|
73
|
+
else if (a === '--filter' && argv[i + 1]) o.filter = argv[++i];
|
|
74
|
+
else if (a.startsWith('--filter=')) o.filter = a.slice(9);
|
|
75
|
+
else if (a === '--serial' && argv[i + 1]) o.serial = argv[++i];
|
|
76
|
+
else if (a.startsWith('--serial=')) o.serial = a.slice(9);
|
|
77
|
+
else if (a === '--max' && argv[i + 1]) o.max = Number(argv[++i]) || DEFAULT_MAX;
|
|
78
|
+
else if (a.startsWith('--max=')) o.max = Number(a.slice(6)) || DEFAULT_MAX;
|
|
79
|
+
}
|
|
80
|
+
return o;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Maestro's per-run artifact root (see run-maestro.js / docs/mobile-testing.md). */
|
|
84
|
+
function maestroTestsDir() {
|
|
85
|
+
return process.env.MOBILE_E2E_MAESTRO_TESTS || path.join(os.homedir(), '.maestro', 'tests');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function listRuns(root) {
|
|
89
|
+
try {
|
|
90
|
+
return fs
|
|
91
|
+
.readdirSync(root)
|
|
92
|
+
.map((name) => path.join(root, name))
|
|
93
|
+
.filter((p) => {
|
|
94
|
+
try {
|
|
95
|
+
return fs.statSync(p).isDirectory();
|
|
96
|
+
} catch {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
.sort()
|
|
101
|
+
.reverse();
|
|
102
|
+
} catch {
|
|
103
|
+
return [];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Candidate `screen-hierarchy` JSON files (newest first), optionally scoped. */
|
|
108
|
+
function hierarchyFiles(opts) {
|
|
109
|
+
const root = maestroTestsDir();
|
|
110
|
+
const out = [];
|
|
111
|
+
for (const run of listRuns(root)) {
|
|
112
|
+
let flows = [];
|
|
113
|
+
try {
|
|
114
|
+
flows = fs.readdirSync(run).map((n) => path.join(run, n)).filter((p) => { try { return fs.statSync(p).isDirectory(); } catch { return false; } });
|
|
115
|
+
} catch {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
for (const flowDir of flows) {
|
|
119
|
+
const flowName = path.basename(flowDir);
|
|
120
|
+
if (opts && opts.flow && flowName !== opts.flow) continue;
|
|
121
|
+
const hierDir = path.join(flowDir, 'screen-hierarchy');
|
|
122
|
+
let files = [];
|
|
123
|
+
try {
|
|
124
|
+
files = fs.readdirSync(hierDir).filter((f) => f.endsWith('.json')).sort().map((f) => path.join(hierDir, f));
|
|
125
|
+
} catch {
|
|
126
|
+
/* this flow has no hierarchy dump */
|
|
127
|
+
}
|
|
128
|
+
for (const f of files) {
|
|
129
|
+
if (opts && opts.step && !path.basename(f).includes(opts.step)) continue;
|
|
130
|
+
out.push({ run, flow: flowName, file: f });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return out;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Sibling screenshots for a hierarchy file (Maestro writes `<flow>/screenshots`). */
|
|
138
|
+
function screenshotsFor(hierarchyFile) {
|
|
139
|
+
const flowDir = path.dirname(path.dirname(hierarchyFile));
|
|
140
|
+
const dir = path.join(flowDir, 'screenshots');
|
|
141
|
+
try {
|
|
142
|
+
return fs.readdirSync(dir).filter((f) => /\.(png|jpg)$/i.test(f)).sort().map((f) => path.join(dir, f));
|
|
143
|
+
} catch {
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* --------------------------------------------------------------- parsers */
|
|
149
|
+
function node(id, text, desc, cls, bounds, children) {
|
|
150
|
+
return { id: id || '', text: text || '', desc: desc || '', cls: cls || '', bounds: bounds || '', children: children || [] };
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** UIAutomator XML (`uiautomator dump`) -> normalized tree. `node` tags only. */
|
|
154
|
+
function parseUiAutomatorXml(xml) {
|
|
155
|
+
const root = node('', '', '', 'hierarchy', '', []);
|
|
156
|
+
const stack = [root];
|
|
157
|
+
const tag = /<node\b([^>]*?)(\/?)>|<\/node>/g;
|
|
158
|
+
let m;
|
|
159
|
+
while ((m = tag.exec(xml)) !== null) {
|
|
160
|
+
if (m[0].startsWith('</')) {
|
|
161
|
+
if (stack.length > 1) stack.pop();
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
const attrs = {};
|
|
165
|
+
const attrRe = /([\w-]+)="([^"]*)"/g;
|
|
166
|
+
let a;
|
|
167
|
+
while ((a = attrRe.exec(m[1])) !== null) attrs[a[1]] = a[2];
|
|
168
|
+
const child = node(
|
|
169
|
+
attrs['resource-id'],
|
|
170
|
+
attrs.text,
|
|
171
|
+
attrs['content-desc'],
|
|
172
|
+
attrs.class,
|
|
173
|
+
attrs.bounds,
|
|
174
|
+
[]
|
|
175
|
+
);
|
|
176
|
+
stack[stack.length - 1].children.push(child);
|
|
177
|
+
if (!m[2]) stack.push(child);
|
|
178
|
+
}
|
|
179
|
+
return root;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Maestro screen-hierarchy JSON -> normalized tree (tolerant of key shapes). */
|
|
183
|
+
function normalizeMaestro(n) {
|
|
184
|
+
if (!n || typeof n !== 'object') return null;
|
|
185
|
+
const id = n['resource-id'] != null ? n['resource-id'] : n.resourceId;
|
|
186
|
+
const desc = n['content-desc'] != null ? n['content-desc'] : n.contentDescription;
|
|
187
|
+
const rawChildren = Array.isArray(n.children) ? n.children : [];
|
|
188
|
+
const kids = [];
|
|
189
|
+
for (const c of rawChildren) {
|
|
190
|
+
const k = normalizeMaestro(c);
|
|
191
|
+
if (k) kids.push(k);
|
|
192
|
+
}
|
|
193
|
+
const self = node(id, n.text, desc, n.class || n.cls, n.bounds, kids);
|
|
194
|
+
return self;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/* --------------------------------------------------------------- output */
|
|
198
|
+
function line(n, depth) {
|
|
199
|
+
return `${' '.repeat(depth)}${n.id || '-'} | ${n.text} | ${n.desc} | ${n.cls || ''} | ${n.bounds}`;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function printTree(root, opts) {
|
|
203
|
+
const re = opts.filter ? new RegExp(opts.filter, 'i') : null;
|
|
204
|
+
const lines = [];
|
|
205
|
+
let truncated = false;
|
|
206
|
+
const walk = (n, depth) => {
|
|
207
|
+
const matches =
|
|
208
|
+
!re || re.test(n.id || '') || re.test(n.text || '') || re.test(n.desc || '') || re.test(n.cls || '');
|
|
209
|
+
if (matches) {
|
|
210
|
+
if (lines.length >= opts.max) {
|
|
211
|
+
truncated = true;
|
|
212
|
+
} else {
|
|
213
|
+
lines.push(line(n, depth));
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
for (const c of n.children) walk(c, depth + 1);
|
|
217
|
+
};
|
|
218
|
+
walk(root, 0);
|
|
219
|
+
console.log(lines.join('\n'));
|
|
220
|
+
if (truncated) console.log(`… output capped at ${opts.max} lines (raise --max or narrow --filter)`);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function countNodes(n) {
|
|
224
|
+
return 1 + n.children.reduce((sum, c) => sum + countNodes(c), 0);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/* --------------------------------------------------------------- live */
|
|
228
|
+
function resolveAdb() {
|
|
229
|
+
const sdk = process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT;
|
|
230
|
+
const exe = process.platform === 'win32' ? 'adb.exe' : 'adb';
|
|
231
|
+
if (sdk) {
|
|
232
|
+
const candidate = path.join(sdk, 'platform-tools', exe);
|
|
233
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
234
|
+
}
|
|
235
|
+
return exe;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function liveDump(serial) {
|
|
239
|
+
const adb = resolveAdb();
|
|
240
|
+
const base = serial ? [adb, '-s', serial] : [adb];
|
|
241
|
+
if (!serial) {
|
|
242
|
+
const devices = spawnSync(adb, ['devices'], { encoding: 'utf8', timeout: 10000 });
|
|
243
|
+
const deviceLines = String((devices.stdout || '') + (devices.stderr || '')).match(/^\S+\s+device\b/gm) || [];
|
|
244
|
+
if (deviceLines.length === 0) {
|
|
245
|
+
console.error('FAIL — no ready adb device (run: bash scripts/qa/mobile-e2e/boot-emulator.sh).');
|
|
246
|
+
process.exit(2);
|
|
247
|
+
}
|
|
248
|
+
serial = deviceLines[0].split(/\s+/)[0];
|
|
249
|
+
}
|
|
250
|
+
const dump = spawnSync(adb, ['-s', serial, 'shell', 'uiautomator', 'dump', '/sdcard/window_dump.xml'], { encoding: 'utf8', timeout: 30000 });
|
|
251
|
+
if (dump.status !== 0) {
|
|
252
|
+
console.error(`FAIL — uiautomator dump failed: ${(dump.stderr || dump.stdout || '').trim()}`);
|
|
253
|
+
process.exit(2);
|
|
254
|
+
}
|
|
255
|
+
const cat = spawnSync(adb, ['-s', serial, 'exec-out', 'cat', '/sdcard/window_dump.xml'], { encoding: 'utf8', timeout: 30000 });
|
|
256
|
+
const xml = cat.stdout || '';
|
|
257
|
+
if (!xml.includes('<hierarchy')) {
|
|
258
|
+
console.error('FAIL — could not read the dumped hierarchy (device offline?).');
|
|
259
|
+
process.exit(2);
|
|
260
|
+
}
|
|
261
|
+
return parseUiAutomatorXml(xml);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/* --------------------------------------------------------------- main */
|
|
265
|
+
function main() {
|
|
266
|
+
const opts = parseArgs(process.argv.slice(2));
|
|
267
|
+
if (opts.help) {
|
|
268
|
+
console.log(usage());
|
|
269
|
+
process.exit(0);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (opts.list) {
|
|
273
|
+
const files = hierarchyFiles(opts);
|
|
274
|
+
if (files.length === 0) {
|
|
275
|
+
console.log('No Maestro hierarchy artifacts found (run a device tier first).');
|
|
276
|
+
process.exit(0);
|
|
277
|
+
}
|
|
278
|
+
console.log(`Maestro artifacts under ${maestroTestsDir()}:`);
|
|
279
|
+
for (const f of files) {
|
|
280
|
+
console.log(` ${f.flow.padEnd(24)} ${f.file}`);
|
|
281
|
+
for (const s of screenshotsFor(f.file)) console.log(` ${''.padEnd(24)} ${s}`);
|
|
282
|
+
}
|
|
283
|
+
process.exit(0);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (opts.live) {
|
|
287
|
+
const root = liveDump(opts.serial);
|
|
288
|
+
if (opts.json) console.log(JSON.stringify(root, null, 2));
|
|
289
|
+
else printTree(root, opts);
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
let file = opts.file;
|
|
294
|
+
if (!file) {
|
|
295
|
+
const files = hierarchyFiles(opts);
|
|
296
|
+
if (files.length === 0) {
|
|
297
|
+
console.error('FAIL — no Maestro hierarchy artifact found. Use --live, or check --flow/--step.');
|
|
298
|
+
console.error(' List candidates with: node scripts/qa/mobile-e2e/ui-dump.js --list-artifacts');
|
|
299
|
+
process.exit(2);
|
|
300
|
+
}
|
|
301
|
+
file = files[0].file;
|
|
302
|
+
console.error(`# ${file}`);
|
|
303
|
+
}
|
|
304
|
+
let parsed;
|
|
305
|
+
try {
|
|
306
|
+
parsed = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
307
|
+
} catch (error) {
|
|
308
|
+
console.error(`FAIL — could not read ${file}: ${error.message}`);
|
|
309
|
+
process.exit(2);
|
|
310
|
+
}
|
|
311
|
+
const root = normalizeMaestro(parsed) || node('', '', '', '', '', []);
|
|
312
|
+
if (opts.json) console.log(JSON.stringify(root, null, 2));
|
|
313
|
+
else {
|
|
314
|
+
printTree(root, opts);
|
|
315
|
+
console.error(`# ${countNodes(root)} nodes`);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (require.main === module) main();
|
|
320
|
+
|
|
321
|
+
module.exports = {
|
|
322
|
+
parseArgs,
|
|
323
|
+
parseUiAutomatorXml,
|
|
324
|
+
normalizeMaestro,
|
|
325
|
+
hierarchyFiles,
|
|
326
|
+
maestroTestsDir,
|
|
327
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
deepseek/deepseek-flash
|
|
2
|
+
deepseek/deepseek-v4-pro
|
|
3
|
+
opencode-go/beam-free
|
|
4
|
+
opencode-go/claude-haiku-5-5
|
|
5
|
+
opencode-go/deepseek-v4-pro
|
|
6
|
+
opencode-go/deepseek-v4.1-flash
|
|
7
|
+
opencode-go/gemini-4-argon-contributor
|
|
8
|
+
opencode-go/glm-5.2
|
|
9
|
+
opencode-go/glm-5.3
|
|
10
|
+
opencode-go/glm-5.3-flash
|
|
11
|
+
opencode-go/gpt-5.6-luna
|
|
12
|
+
opencode-go/gpt-6-luna
|
|
13
|
+
opencode-go/grok-4.7
|
|
14
|
+
opencode-go/hy3
|
|
15
|
+
opencode-go/hy4-preview
|
|
16
|
+
opencode-go/kimi-k2.7-code
|
|
17
|
+
opencode-go/kimi-k3
|
|
18
|
+
opencode-go/longcat-2.0
|
|
19
|
+
opencode-go/longcat-2.5-preview-free
|
|
20
|
+
opencode-go/mimo-v2.5
|
|
21
|
+
opencode-go/mimo-v2.5-pro
|
|
22
|
+
opencode-go/mimo-v2.6-flash
|
|
23
|
+
opencode-go/mimo-v2.6-pro
|
|
24
|
+
opencode-go/minimax-m3
|
|
25
|
+
opencode-go/muse-spark-1.2-contributor
|
|
26
|
+
opencode-go/muse-spark-1.3-contributor
|
|
27
|
+
opencode-go/qwen3.7-plus
|
|
28
|
+
opencode-go/qwen3.8-flash
|
|
29
|
+
opencode-go/qwen3.8-max
|
|
30
|
+
opencode-go/space-bunny
|
|
31
|
+
opencode-go/step-5-preview
|
|
32
|
+
nvidia/moonshotai/kimi-k3
|