@buaa_smat/hometrans 26.0.0 → 26.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +11 -82
- package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/ets/pages/Index.ets +2 -2
- package/skills/a2h-arch-generate/scripts/module_create/har/src/main/ets/components/MainPage.ets +2 -2
- package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/ets/pages/Index.ets +2 -2
- package/skills/a2h-batch-ui-align/references/conversion-procedure.md +1 -1
- package/skills/a2h-batch-ui-align/references/state-mgmt/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +1 -1
- package/skills/a2h-batch-ui-align/references/step3-capture.md +3 -3
- package/skills/a2h-batch-ui-align/references/step4-prepare.md +1 -1
- package/skills/a2h-batch-ui-align/scripts/detect_paradigm.mjs +11 -6
- package/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +59 -21
- package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +3 -3
- package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +1 -1
- package/skills/a2h-batch-ui-align/scripts/static_check/core/scan.ts +1 -1
- package/skills/a2h-utg-explorer/SKILL.md +1 -1
- package/skills/a2h-utg-explorer/references/architecture.md +2 -2
- package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +36 -11
- package/skills/a2h-utg-explorer/scripts/device_health.mjs +91 -6
- package/skills/a2h-utg-explorer/scripts/final_utg.mjs +20 -2
- package/skills/a2h-utg-explorer/scripts/hint_check.mjs +64 -8
- package/skills/a2h-utg-explorer/scripts/hint_source.mjs +119 -0
- package/skills/a2h-utg-explorer/scripts/recover.mjs +7 -1
- package/skills/a2h-utg-explorer/scripts/recover_b.mjs +8 -1
- package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +89 -7
- package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +173 -4
- package/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +82 -14
- package/skills/a2h-utg-static/SKILL.md +1 -1
- package/skills/a2h-utg-static/references/view-interactions.md +1 -1
- package/skills/a2h-utg-static/scripts/assemble.mjs +6 -3
- package/skills/a2h-utg-static/scripts/compose_body_text.mjs +23 -5
- package/skills/a2h-utg-static/scripts/compose_overlay.mjs +29 -3
- package/skills/a2h-utg-static/scripts/compose_titles.mjs +10 -1
- package/skills/a2h-utg-static/scripts/label_resolve.mjs +51 -2
- package/skills/a2h-utg-static/scripts/static_prior.mjs +2 -1
- package/skills/a2h-utg-static/scripts/tests/_zipw.mjs +28 -0
- package/skills/a2h-utg-static/scripts/tests/probe_autoload.mjs +108 -0
- package/skills/a2h-utg-static/scripts/tests/probe_layout_fragments.mjs +90 -0
- package/skills/a2h-utg-static/scripts/tests/probe_unknown_scope.mjs +61 -0
- package/skills/a2h-utg-static/scripts/tests/regression_matrix.mjs +1261 -0
- package/skills/a2h-utg-static/scripts/tests/test_activity_alias_launcher.mjs +135 -0
- package/skills/a2h-utg-static/scripts/tests/test_activity_supertype_chain.mjs +106 -0
- package/skills/a2h-utg-static/scripts/tests/test_bottom_sheet_container.mjs +58 -0
- package/skills/a2h-utg-static/scripts/tests/test_branch_guard.mjs +19 -0
- package/skills/a2h-utg-static/scripts/tests/test_callee_string_default.mjs +30 -0
- package/skills/a2h-utg-static/scripts/tests/test_carry_answers.mjs +103 -0
- package/skills/a2h-utg-static/scripts/tests/test_chrome_tokens.mjs +60 -0
- package/skills/a2h-utg-static/scripts/tests/test_commented_out_trigger.mjs +111 -0
- package/skills/a2h-utg-static/scripts/tests/test_commit_scope.mjs +113 -0
- package/skills/a2h-utg-static/scripts/tests/test_compose_file_private_route.mjs +117 -0
- package/skills/a2h-utg-static/scripts/tests/test_compose_nested_graph.mjs +166 -0
- package/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +108 -0
- package/skills/a2h-utg-static/scripts/tests/test_compose_route_holder_collision.mjs +112 -0
- package/skills/a2h-utg-static/scripts/tests/test_compose_vm_nav.mjs +289 -0
- package/skills/a2h-utg-static/scripts/tests/test_custom_source_root.mjs +71 -0
- package/skills/a2h-utg-static/scripts/tests/test_defensive_null_guard.mjs +77 -0
- package/skills/a2h-utg-static/scripts/tests/test_dialog_orphan_entries.mjs +99 -0
- package/skills/a2h-utg-static/scripts/tests/test_dialog_page_owner.mjs +69 -0
- package/skills/a2h-utg-static/scripts/tests/test_dialogshow_builder_forms.mjs +96 -0
- package/skills/a2h-utg-static/scripts/tests/test_dialogshow_java_factory.mjs +37 -0
- package/skills/a2h-utg-static/scripts/tests/test_disabled_guard.mjs +42 -0
- package/skills/a2h-utg-static/scripts/tests/test_drawer_panel_gesture.mjs +140 -0
- package/skills/a2h-utg-static/scripts/tests/test_edge_dedupe_by_gesture.mjs +111 -0
- package/skills/a2h-utg-static/scripts/tests/test_edge_provenance_lint.mjs +70 -0
- package/skills/a2h-utg-static/scripts/tests/test_enclosing_gesture.mjs +69 -0
- package/skills/a2h-utg-static/scripts/tests/test_external_surface_roots.mjs +43 -0
- package/skills/a2h-utg-static/scripts/tests/test_find_package_indirect.mjs +67 -0
- package/skills/a2h-utg-static/scripts/tests/test_forwarding_wrapper.mjs +38 -0
- package/skills/a2h-utg-static/scripts/tests/test_fragment_containment.mjs +85 -0
- package/skills/a2h-utg-static/scripts/tests/test_fragment_helper_trigger.mjs +92 -0
- package/skills/a2h-utg-static/scripts/tests/test_fresh_branch_guard.mjs +49 -0
- package/skills/a2h-utg-static/scripts/tests/test_graph.mjs +55 -0
- package/skills/a2h-utg-static/scripts/tests/test_guard_clause.mjs +86 -0
- package/skills/a2h-utg-static/scripts/tests/test_hint_language.mjs +136 -0
- package/skills/a2h-utg-static/scripts/tests/test_host_kind_by_chain.mjs +68 -0
- package/skills/a2h-utg-static/scripts/tests/test_hybrid_bundle_attribution.mjs +74 -0
- package/skills/a2h-utg-static/scripts/tests/test_hybrid_bundled_pages.mjs +181 -0
- package/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +293 -0
- package/skills/a2h-utg-static/scripts/tests/test_hybrid_title_renders.mjs +118 -0
- package/skills/a2h-utg-static/scripts/tests/test_i18n_term.mjs +155 -0
- package/skills/a2h-utg-static/scripts/tests/test_interaction_sites.mjs +272 -0
- package/skills/a2h-utg-static/scripts/tests/test_item_data_instance.mjs +51 -0
- package/skills/a2h-utg-static/scripts/tests/test_kotlin_fn_spans.mjs +69 -0
- package/skills/a2h-utg-static/scripts/tests/test_label_accessor_forms.mjs +187 -0
- package/skills/a2h-utg-static/scripts/tests/test_label_source.mjs +70 -0
- package/skills/a2h-utg-static/scripts/tests/test_launch_intent_guard.mjs +67 -0
- package/skills/a2h-utg-static/scripts/tests/test_layout_declared_fragment.mjs +103 -0
- package/skills/a2h-utg-static/scripts/tests/test_listener_call_forms.mjs +79 -0
- package/skills/a2h-utg-static/scripts/tests/test_listener_receiver_binding.mjs +47 -0
- package/skills/a2h-utg-static/scripts/tests/test_login_interceptor.mjs +328 -0
- package/skills/a2h-utg-static/scripts/tests/test_manifest_exported_default.mjs +40 -0
- package/skills/a2h-utg-static/scripts/tests/test_manifest_filters_modules.mjs +84 -0
- package/skills/a2h-utg-static/scripts/tests/test_manifest_srcfile.mjs +68 -0
- package/skills/a2h-utg-static/scripts/tests/test_mode_and_cb_param.mjs +172 -0
- package/skills/a2h-utg-static/scripts/tests/test_module_namespace.mjs +83 -0
- package/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +44 -0
- package/skills/a2h-utg-static/scripts/tests/test_multiple_entry_contracts.mjs +80 -0
- package/skills/a2h-utg-static/scripts/tests/test_nav_graph_xml.mjs +35 -0
- package/skills/a2h-utg-static/scripts/tests/test_nl_hint_grammar.mjs +42 -0
- package/skills/a2h-utg-static/scripts/tests/test_nl_hints_gate.mjs +85 -0
- package/skills/a2h-utg-static/scripts/tests/test_nl_hints_off_path.mjs +67 -0
- package/skills/a2h-utg-static/scripts/tests/test_node_id_collision.mjs +57 -0
- package/skills/a2h-utg-static/scripts/tests/test_non_gesture_step_flag.mjs +62 -0
- package/skills/a2h-utg-static/scripts/tests/test_out_of_scope_and_settings.mjs +72 -0
- package/skills/a2h-utg-static/scripts/tests/test_overload_and_climb.mjs +86 -0
- package/skills/a2h-utg-static/scripts/tests/test_pager_page_source.mjs +78 -0
- package/skills/a2h-utg-static/scripts/tests/test_pager_position_zero.mjs +65 -0
- package/skills/a2h-utg-static/scripts/tests/test_pager_variant_guard.mjs +172 -0
- package/skills/a2h-utg-static/scripts/tests/test_pipeline_llm_phases.mjs +107 -0
- package/skills/a2h-utg-static/scripts/tests/test_plain_dialog_nodes.mjs +167 -0
- package/skills/a2h-utg-static/scripts/tests/test_plaindialog_shared_anchor.mjs +117 -0
- package/skills/a2h-utg-static/scripts/tests/test_preference_click_nav.mjs +98 -0
- package/skills/a2h-utg-static/scripts/tests/test_preference_host_binding.mjs +87 -0
- package/skills/a2h-utg-static/scripts/tests/test_preference_nesting.mjs +183 -0
- package/skills/a2h-utg-static/scripts/tests/test_preference_widgets.mjs +48 -0
- package/skills/a2h-utg-static/scripts/tests/test_read_text_crlf.mjs +41 -0
- package/skills/a2h-utg-static/scripts/tests/test_resolver_tier_parity.mjs +126 -0
- package/skills/a2h-utg-static/scripts/tests/test_result_launcher.mjs +142 -0
- package/skills/a2h-utg-static/scripts/tests/test_review_fixes.mjs +135 -0
- package/skills/a2h-utg-static/scripts/tests/test_route_token_words.mjs +66 -0
- package/skills/a2h-utg-static/scripts/tests/test_same_name_decl_scope.mjs +236 -0
- package/skills/a2h-utg-static/scripts/tests/test_scope_utils.mjs +85 -0
- package/skills/a2h-utg-static/scripts/tests/test_sealed_dialog_state.mjs +148 -0
- package/skills/a2h-utg-static/scripts/tests/test_shared_overlay_split.mjs +63 -0
- package/skills/a2h-utg-static/scripts/tests/test_slug_parity.mjs +58 -0
- package/skills/a2h-utg-static/scripts/tests/test_starter_node_id.mjs +41 -0
- package/skills/a2h-utg-static/scripts/tests/test_state_guard_arity.mjs +109 -0
- package/skills/a2h-utg-static/scripts/tests/test_state_guard_commented_candidates.mjs +68 -0
- package/skills/a2h-utg-static/scripts/tests/test_state_guard_model_gates.mjs +127 -0
- package/skills/a2h-utg-static/scripts/tests/test_state_specific_hop.mjs +130 -0
- package/skills/a2h-utg-static/scripts/tests/test_synthetic_label_identity.mjs +51 -0
- package/skills/a2h-utg-static/scripts/tests/test_template_method_layout.mjs +81 -0
- package/skills/a2h-utg-static/scripts/tests/test_template_title.mjs +61 -0
- package/skills/a2h-utg-static/scripts/tests/test_trigger_id_spelling.mjs +68 -0
- package/skills/a2h-utg-static/scripts/tests/test_ui_elements_action_override.mjs +91 -0
- package/skills/a2h-utg-static/scripts/tests/test_ui_elements_flow_filter.mjs +110 -0
- package/skills/a2h-utg-static/scripts/tests/test_ui_elements_nl_hint_key.mjs +89 -0
- package/skills/a2h-utg-static/scripts/tests/test_uiless_host_fold.mjs +98 -0
- package/skills/a2h-utg-static/scripts/tests/test_uniapp_data_table.mjs +340 -0
- package/skills/a2h-utg-static/scripts/tests/test_uniapp_relative_url.mjs +125 -0
- package/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +231 -0
- package/skills/a2h-utg-static/scripts/tests/test_view_click_refs.mjs +104 -0
- package/skills/a2h-utg-static/scripts/tests/test_view_id_label.mjs +69 -0
- package/skills/a2h-utg-static/scripts/tests/test_view_interactions.mjs +346 -0
- package/skills/a2h-utg-static/scripts/tests/test_viewpage_nav.mjs +340 -0
- package/skills/a2h-utg-static/scripts/tests/test_vm_nav_helper_navigate.mjs +98 -0
- package/skills/a2h-utg-static/scripts/tests/test_widget_class_scope.mjs +92 -0
- package/skills/a2h-utg-static/scripts/tests/test_window_nav_kotlin.mjs +158 -0
- package/skills/a2h-utg-static/scripts/tests/test_worklist_parts.mjs +65 -0
|
@@ -224,13 +224,35 @@ const PARENS = '([^)]*)|\\([^)]*\\)';
|
|
|
224
224
|
const CLAUSE_SPLIT = '[,,;;。]|→|然后|再|and then';
|
|
225
225
|
const quotedOf = (s) => reFindall(_QUOTED, s).map(([a, b]) => a || b);
|
|
226
226
|
|
|
227
|
-
|
|
227
|
+
// An "or" alternative inside parentheses -- 点击「开始体验」(或点击「跳过」) -- names another on-screen
|
|
228
|
+
// target that reaches the same page. Parentheses are otherwise explanation and stripped, which
|
|
229
|
+
// dropped it (measured: coolmall Guide -> Main; 「开始体验」 exists only on the guide's last page,
|
|
230
|
+
// 「跳过」 on every page, so every replay from a fresh install failed at that hop).
|
|
231
|
+
// The "or" must be followed by at most a tap verb and then the quote: (或许需要先登录「账号」) and
|
|
232
|
+
// (original label “X”) are explanation, not alternatives.
|
|
233
|
+
const _ALT_PAREN = /[((]\s*(?:(?:或者?|或是|也可以?)\s*(?:点击|点按|轻触|单击|长按|按|点)?|or\s+(?:(?:tap|click|press)(?:ing)?\s+)?)\s*[「『“"][^))]*[))]/gi;
|
|
234
|
+
const ALT_MARK = '';
|
|
235
|
+
/** Keep the quoted targets of an "or" parenthesis, as `「x」`, so PARENS stripping leaves them. */
|
|
236
|
+
const markAlternatives = (hint) => pyStr(hint || '').replace(_ALT_PAREN, (m) =>
|
|
237
|
+
quotedOf(m).map((q) => `${ALT_MARK}「${q}」${ALT_MARK}`).join(''));
|
|
238
|
+
const _ALT_RUN = new RegExp(`${ALT_MARK}「([^」]+)」${ALT_MARK}`, 'g');
|
|
239
|
+
/** [clause without alternative marks, alternative texts]. */
|
|
240
|
+
const splitAlternatives = (clause) => {
|
|
241
|
+
const alts = [...clause.matchAll(_ALT_RUN)].map((m) => m[1]);
|
|
242
|
+
return [clause.replace(_ALT_RUN, ''), alts];
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* hint_steps(hint) -> [steps|null, reason|null]; steps are [kind, text|null] or, when the hint
|
|
247
|
+
* names "or" alternatives in parentheses, [kind, text, [alternative texts]].
|
|
248
|
+
*/
|
|
228
249
|
export function hintSteps(hint) {
|
|
229
250
|
if (reSearch(_NO_GESTURE, hint || '')) { return [[], 'hint-no-gesture']; }
|
|
230
|
-
const text = reSub(PARENS, '', hint
|
|
251
|
+
const text = reSub(PARENS, '', markAlternatives(hint));
|
|
231
252
|
const steps = [];
|
|
232
|
-
for (let
|
|
233
|
-
|
|
253
|
+
for (let raw of reSplit(CLAUSE_SPLIT, text)) {
|
|
254
|
+
const [bare, alts] = splitAlternatives(raw);
|
|
255
|
+
let clause = pyStrip(bare);
|
|
234
256
|
if (!clause) { continue; }
|
|
235
257
|
const ids = reFindall('〔id:(\\w+)〕', clause);
|
|
236
258
|
const quoted = quotedOf(clause);
|
|
@@ -248,7 +270,9 @@ export function hintSteps(hint) {
|
|
|
248
270
|
}
|
|
249
271
|
const kind = long ? 'long_click_candidates' : 'click_candidates';
|
|
250
272
|
if (ids.length) { steps.push([kind, 'id:' + ids[ids.length - 1]]); continue; }
|
|
251
|
-
|
|
273
|
+
const main = quoted[quoted.length - 1];
|
|
274
|
+
const others = alts.filter((a) => a !== main);
|
|
275
|
+
steps.push(others.length ? [kind, main, others] : [kind, main]);
|
|
252
276
|
}
|
|
253
277
|
return steps.length ? [steps, null] : [null, 'hint-has-no-quoted-tap'];
|
|
254
278
|
}
|
|
@@ -256,7 +280,7 @@ export function hintSteps(hint) {
|
|
|
256
280
|
/** _strip_reached_context(hint, prev_hint). */
|
|
257
281
|
export function _stripReachedContext(hint, prevHint) {
|
|
258
282
|
if (!truthy(prevHint)) { return hint; }
|
|
259
|
-
const parts = reSplitKeep('(,|,|;|;|然后|再)', reSub(PARENS, '', hint));
|
|
283
|
+
const parts = reSplitKeep('(,|,|;|;|然后|再)', reSub(PARENS, '', markAlternatives(hint)));
|
|
260
284
|
const clauses = parts.filter((_, i) => i % 2 === 0);
|
|
261
285
|
const kept = [];
|
|
262
286
|
clauses.forEach((c, i) => {
|
|
@@ -339,19 +363,20 @@ export function hintedPrefix(step) {
|
|
|
339
363
|
const [steps, reason] = hintSteps(_stripReachedContext(hint, get(step, '_prev_hint')));
|
|
340
364
|
if (reason === 'hint-no-gesture') { return [[], ['automatic', null], null]; }
|
|
341
365
|
if (truthy(reason)) { return [[], null, reason]; }
|
|
342
|
-
const prefix = steps.slice(0, -1).map(([kind, text]) => compiledHintStep(kind, text, null, true));
|
|
366
|
+
const prefix = steps.slice(0, -1).map(([kind, text, alts]) => compiledHintStep(kind, text, null, true, alts));
|
|
343
367
|
return [prefix, steps[steps.length - 1], null];
|
|
344
368
|
}
|
|
345
369
|
|
|
346
370
|
/** compiled_hint_step(kind, text, target_id, intermediate=False). */
|
|
347
|
-
export function compiledHintStep(kind, text, targetId, intermediate = false) {
|
|
371
|
+
export function compiledHintStep(kind, text, targetId, intermediate = false, alts = []) {
|
|
348
372
|
let step;
|
|
349
373
|
if (kind === 'click_list_item' || kind === 'long_click_list_item') {
|
|
350
374
|
step = { type: kind, static_label: null, target_id: targetId };
|
|
351
375
|
} else if (pyStr(text).startsWith('id:')) {
|
|
352
376
|
step = { type: kind, selectors: [{ resource_name: text.slice(3) }], static_label: null, target_id: targetId };
|
|
353
377
|
} else {
|
|
354
|
-
step = { type: kind, selectors: selectorCandidates(text), static_label: text, target_id: targetId };
|
|
378
|
+
step = { type: kind, selectors: selectorCandidates(text, alts ?? []), static_label: text, target_id: targetId };
|
|
379
|
+
if ((alts ?? []).length) { step.static_label_alt = [...alts]; }
|
|
355
380
|
}
|
|
356
381
|
if (truthy(intermediate)) { step.intermediate = true; }
|
|
357
382
|
return step;
|
|
@@ -382,7 +407,7 @@ export function compileReplayStep(step, catalog) {
|
|
|
382
407
|
const [prefix, last, reason] = hinted;
|
|
383
408
|
if (truthy(reason)) { return [null, reason]; }
|
|
384
409
|
if (last[0] === 'automatic') { return [null, null]; }
|
|
385
|
-
const final = compiledHintStep(last[0], last[1], get(step, 'target_id'));
|
|
410
|
+
const final = compiledHintStep(last[0], last[1], get(step, 'target_id'), false, last[2]);
|
|
386
411
|
return [prefix.length ? [...prefix, final] : final, null];
|
|
387
412
|
}
|
|
388
413
|
const label = hintLabel(step);
|
|
@@ -709,7 +734,7 @@ function compileEdgeTail(ctx, s) {
|
|
|
709
734
|
} else if (pyStr(last[1]).startsWith('id:')) {
|
|
710
735
|
label = null; selectors = [{ resource_name: last[1].slice(3) }];
|
|
711
736
|
} else {
|
|
712
|
-
label = last[1]; selectors = selectorCandidates(label);
|
|
737
|
+
label = last[1]; selectors = selectorCandidates(label, last[2] ?? []);
|
|
713
738
|
}
|
|
714
739
|
}
|
|
715
740
|
}
|
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
* 3. adb kill-server / start-server -- only when `adb devices` lists no other online device
|
|
15
15
|
* (kill-server drops every host session), or `config.watchdog.allow_kill_server: true`;
|
|
16
16
|
* otherwise skipped and recorded as a step
|
|
17
|
-
* 4. emulator only,
|
|
17
|
+
* 4. emulator only, with an AVD name -- `config.emulator.avd`, or, only when
|
|
18
|
+
* `config.emulator.auto_avd: true`, `adb emu avd name` else the name learnt by an earlier
|
|
19
|
+
* healthy probe (emulator_avd.json next to the config; a hung emulator no longer answers).
|
|
20
|
+
* Without either the emulator is left alone: kill the emulator (adb emu
|
|
18
21
|
* kill, then the process listening on its console port: netstat + taskkill on Windows,
|
|
19
22
|
* lsof + kill elsewhere), start it DETACHED with `-no-snapshot-load`, wait for
|
|
20
23
|
* sys.boot_completed within `boot_timeout_s`. A port that cannot be freed is reported,
|
|
@@ -116,6 +119,84 @@ export function emulatorBinary(config) {
|
|
|
116
119
|
return null;
|
|
117
120
|
}
|
|
118
121
|
|
|
122
|
+
/** Name of the AVD behind an emulator serial (`adb emu avd name`), or null. */
|
|
123
|
+
export function liveAvdName(config) {
|
|
124
|
+
if (!isEmulator(config.serial)) return null;
|
|
125
|
+
const r = deps.run([...adbOf(config), '-s', config.serial, 'emu', 'avd', 'name'], 15);
|
|
126
|
+
if (r.status !== 0) return null;
|
|
127
|
+
const name = String(r.stdout ?? '').split(/\r?\n/).map((l) => l.trim())
|
|
128
|
+
.find((l) => l && l !== 'OK' && /^[\w.-]+$/.test(l));
|
|
129
|
+
return name ?? null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const avdCacheFile = (logDir) => path.join(logDir, 'emulator_avd.json');
|
|
133
|
+
|
|
134
|
+
// Per serial: {boot, avd, misses} -- the AVD name learnt for one boot of the emulator on that port.
|
|
135
|
+
// A port can host another AVD after a reboot, so a name is trusted only for the boot it was read
|
|
136
|
+
// on (/proc/sys/kernel/random/boot_id, new on every boot): a healthy probe that sees a new boot
|
|
137
|
+
// learns again. A miss is often transient (the console busy, a slow answer): asked again, up to
|
|
138
|
+
// AVD_LEARN_TRIES times per boot.
|
|
139
|
+
const AVD_LEARN_TRIES = 3;
|
|
140
|
+
|
|
141
|
+
function readAvdCacheAll(logDir) {
|
|
142
|
+
try { return JSON.parse(fs.readFileSync(avdCacheFile(logDir), 'utf8')); } catch { return {}; }
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function readAvdCache(logDir, serial) {
|
|
146
|
+
const v = readAvdCacheAll(logDir)[serial];
|
|
147
|
+
return typeof v?.avd === 'string' ? v.avd : null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** The emulator's current boot id, or null when it does not answer. */
|
|
151
|
+
function bootId(config) {
|
|
152
|
+
const r = deps.run([...adbOf(config), '-s', config.serial, 'shell', 'cat', '/proc/sys/kernel/random/boot_id'], 10);
|
|
153
|
+
const id = r.status === 0 ? String(r.stdout ?? '').trim() : '';
|
|
154
|
+
return /^[\w-]+$/.test(id) ? id : null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** True once the name is learnt for this boot, or every allowed try for it missed. */
|
|
158
|
+
function avdLearnt(logDir, serial, boot) {
|
|
159
|
+
const v = readAvdCacheAll(logDir)[serial];
|
|
160
|
+
return v?.boot === boot && (typeof v.avd === 'string' || (v.misses ?? 0) >= AVD_LEARN_TRIES);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function writeAvdCache(logDir, serial, avd, boot = null) {
|
|
164
|
+
const all = readAvdCacheAll(logDir);
|
|
165
|
+
const cur = all[serial] ?? {};
|
|
166
|
+
const b = boot ?? cur.boot ?? null;
|
|
167
|
+
const same = cur.boot === b;
|
|
168
|
+
if (avd === null && same && typeof cur.avd === 'string') return; // a later miss never forgets this boot's name
|
|
169
|
+
const next = avd !== null ? { boot: b, avd } : { boot: b, avd: null, misses: (same ? cur.misses ?? 0 : 0) + 1 };
|
|
170
|
+
if (JSON.stringify(cur) === JSON.stringify(next)) return;
|
|
171
|
+
all[serial] = next;
|
|
172
|
+
try { fs.mkdirSync(logDir, { recursive: true }); fs.writeFileSync(avdCacheFile(logDir), JSON.stringify(all, null, 1)); } catch { /* best effort */ }
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** True when the AVD name may be detected instead of configured (`config.emulator.auto_avd`). */
|
|
176
|
+
const autoAvd = (config) => config.emulator?.auto_avd === true;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* The AVD to restart: config.emulator.avd; else, only with `config.emulator.auto_avd: true`, the
|
|
180
|
+
* live emulator's own name, else the name learnt while it was healthy (a hung emulator no longer
|
|
181
|
+
* answers `emu avd name`). Without either, an emulator someone else started is never killed.
|
|
182
|
+
*/
|
|
183
|
+
export function resolveAvd(config, logDir) {
|
|
184
|
+
if (config.emulator?.avd) return { avd: config.emulator.avd, source: 'config' };
|
|
185
|
+
if (!autoAvd(config)) return { avd: null, source: null };
|
|
186
|
+
const live = liveAvdName(config);
|
|
187
|
+
if (live) { writeAvdCache(logDir, String(config.serial), live, bootId(config)); return { avd: live, source: 'emulator' }; }
|
|
188
|
+
const cached = readAvdCache(logDir, String(config.serial));
|
|
189
|
+
return cached ? { avd: cached, source: 'cache' } : { avd: null, source: null };
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** While the emulator is healthy, learn its AVD name (auto_avd only) so a later restart can use it. */
|
|
193
|
+
export function learnAvd(config, logDir) {
|
|
194
|
+
if (config.emulator?.avd || !autoAvd(config) || !isEmulator(config.serial)) return;
|
|
195
|
+
const boot = bootId(config);
|
|
196
|
+
if (!boot || avdLearnt(logDir, String(config.serial), boot)) return;
|
|
197
|
+
writeAvdCache(logDir, String(config.serial), liveAvdName(config), boot);
|
|
198
|
+
}
|
|
199
|
+
|
|
119
200
|
/** Wait (bounded) for the emulator to be listed and booted. */
|
|
120
201
|
function waitBoot(config, timeoutS) {
|
|
121
202
|
const end = deps.now() + timeoutS;
|
|
@@ -128,13 +209,17 @@ function waitBoot(config, timeoutS) {
|
|
|
128
209
|
}
|
|
129
210
|
|
|
130
211
|
/**
|
|
131
|
-
* Kill and cold-start the emulator, detached. Needs `config.emulator.avd
|
|
132
|
-
* caller does not know how the device was started, so it is left alone.
|
|
212
|
+
* Kill and cold-start the emulator, detached. Needs `config.emulator.avd` (or `auto_avd: true`):
|
|
213
|
+
* without it the caller does not know how the device was started, so it is left alone.
|
|
133
214
|
*/
|
|
134
215
|
export function restartEmulator(config, logDir) {
|
|
135
216
|
const emu = config.emulator ?? {};
|
|
136
217
|
if (!isEmulator(config.serial)) return { ok: false, why: `${config.serial} is not an emulator: not restarted` };
|
|
137
|
-
|
|
218
|
+
const { avd } = resolveAvd(config, logDir);
|
|
219
|
+
if (!avd) {
|
|
220
|
+
return { ok: false, why: autoAvd(config) ? 'config.emulator.avd not set and the AVD name could not be detected: emulator not restarted'
|
|
221
|
+
: 'config.emulator.avd not set (auto_avd off): emulator not restarted' };
|
|
222
|
+
}
|
|
138
223
|
const bin = emulatorBinary(config);
|
|
139
224
|
if (!bin) return { ok: false, why: 'emulator binary not found (set config.emulator.binary)' };
|
|
140
225
|
deps.run([...adbOf(config), '-s', config.serial, 'emu', 'kill'], 15);
|
|
@@ -152,7 +237,7 @@ export function restartEmulator(config, logDir) {
|
|
|
152
237
|
return { ok: false, killed, why: `console port ${port} still held by pid ${held.join(',')}: emulator not restarted` };
|
|
153
238
|
}
|
|
154
239
|
}
|
|
155
|
-
const args = ['-avd',
|
|
240
|
+
const args = ['-avd', avd, '-port', port, '-no-snapshot-load', ...(emu.args ?? [])];
|
|
156
241
|
fs.mkdirSync(logDir, { recursive: true });
|
|
157
242
|
const pid = deps.detach([bin, ...args], path.join(logDir, 'emulator.log'));
|
|
158
243
|
const booted = waitBoot(config, Number(emu.boot_timeout_s ?? 300));
|
|
@@ -169,7 +254,7 @@ export function ensure(config, { restart = false, logDir = '.' } = {}) {
|
|
|
169
254
|
if (!restart) {
|
|
170
255
|
const p = probe(config);
|
|
171
256
|
steps.push({ step: 'probe', ...p });
|
|
172
|
-
if (p.ok) return { ok: true, steps };
|
|
257
|
+
if (p.ok) { learnAvd(config, logDir); return { ok: true, steps }; }
|
|
173
258
|
}
|
|
174
259
|
// Another explorer holds the device (task_runner deviceLock): every step below is destructive
|
|
175
260
|
// to its run, so report busy and leave the device to it.
|
|
@@ -144,6 +144,7 @@ export function buildFinal(doc, root, staticDoc = null) {
|
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
const captures = {}; const observationLookup = new Map(); const nodeLookup = new Map(); const variantLookup = new Map();
|
|
147
|
+
const foreign = new Map();
|
|
147
148
|
const viewportLookup = new Map(); const issues = [];
|
|
148
149
|
const actionToAfter = new Map();
|
|
149
150
|
for (const event of doc.events) {
|
|
@@ -192,9 +193,23 @@ export function buildFinal(doc, root, staticDoc = null) {
|
|
|
192
193
|
const cid = 'capture:' + digest([env, oid]);
|
|
193
194
|
if (Object.hasOwn(captures, cid)) { return; }
|
|
194
195
|
const resolution = get(o, 'static_resolution', {});
|
|
195
|
-
|
|
196
|
+
// Another app's window (the launcher after clear/restore app data, the IME, systemui) is no page
|
|
197
|
+
// of this app: kept for chain validation, counted in one issue, never a node. Measured (coolmall):
|
|
198
|
+
// 16 of 51 "unmapped dynamic nodes" were launcher / systemui screens.
|
|
199
|
+
// A sweep frame stays its page's even under a foreign top window (the IME, a systemui shade):
|
|
200
|
+
// dropping it would leave a gap in evidence.scroll.frames that Phase 4.2 merges as contiguous.
|
|
196
201
|
const sweep = mg(sweepFrames, key);
|
|
197
|
-
|
|
202
|
+
const swept = truthy(sweep) && nodes.has(vk(sweep.static_id));
|
|
203
|
+
if (get(resolution, 'status') === 'foreign-package' && !swept) {
|
|
204
|
+
// the same observation emitted twice (a retry, a re-merge) is one foreign capture
|
|
205
|
+
if (observationLookup.has(key)) { return; }
|
|
206
|
+
observationLookup.set(key, o);
|
|
207
|
+
const pkg = pyStr(get(resolution, 'package', '') ?? '');
|
|
208
|
+
foreign.set(pkg, (foreign.get(pkg) ?? 0) + 1);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
let ident = get(resolution, 'status') === 'verified' ? get(resolution, 'static_id') : null;
|
|
212
|
+
if (swept) { ident = sweep.static_id; }
|
|
198
213
|
if (!nodes.has(vk(ident))) { ident = null; }
|
|
199
214
|
if (ident === null || ident === undefined) {
|
|
200
215
|
ident = 'dynamic:' + digest([env, observationKey(o)]);
|
|
@@ -240,6 +255,9 @@ export function buildFinal(doc, root, staticDoc = null) {
|
|
|
240
255
|
if (byHost.size) { stateCandidates.push({ cid, byHost }); }
|
|
241
256
|
}
|
|
242
257
|
});
|
|
258
|
+
for (const [pkg, count] of [...foreign].sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0))) {
|
|
259
|
+
issues.push({ kind: 'foreign-package-observations', package: pkg, count });
|
|
260
|
+
}
|
|
243
261
|
assignUiStates({ nodes, captures, stateCandidates, sweeps, nodeLookup, issues, stateCatalog });
|
|
244
262
|
return buildFinalTail(doc, { baseline, staticDoc, nodes, links, edgeLookup, captures, observationLookup, nodeLookup, issues, sweeps });
|
|
245
263
|
}
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
import * as fs from 'node:fs';
|
|
20
20
|
import * as path from 'node:path';
|
|
21
21
|
import { pathToFileURL } from 'node:url';
|
|
22
|
-
import { hintSteps } from './compile_tasks.mjs';
|
|
22
|
+
import { _QUOTED, hintSteps } from './compile_tasks.mjs';
|
|
23
|
+
import { sourceTextIndex, onlyInComment } from './hint_source.mjs';
|
|
23
24
|
import { term } from './i18n-term.mjs';
|
|
24
25
|
|
|
25
26
|
// Quoted targets stay in the app's UI language; the no-gesture marker follows the install
|
|
@@ -28,7 +29,46 @@ export const RULES = 'Every clause with a tap/long-press verb must quote its on-
|
|
|
28
29
|
'(「设置」, “Settings”, \'Settings\') or name it as 〔id:resource_name〕, or be an any-row phrase ' +
|
|
29
30
|
'(任意一个…条目 / the first row). Swipe/drag/type clauses need a quoted target. Start a hint with ' +
|
|
30
31
|
`${term('(无需点击)')} when the page opens without a gesture. Put extra explanation in parentheses, ` +
|
|
31
|
-
'which the compiler strips.'
|
|
32
|
+
'which the compiler strips. A quoted target is the EXACT text or contentDescription the user ' +
|
|
33
|
+
'sees (a string resource value or a string literal in code), never a KDoc/comment description ' +
|
|
34
|
+
'(contentDescription = "Logo" is quoted 「Logo」, not 「应用Logo」). A target shown only after ' +
|
|
35
|
+
'paging/scrolling to a position (最后一页 / last page) is unreachable from a fresh launch: name ' +
|
|
36
|
+
'one that works from the first position as an alternative, 点击「开始体验」(或点击「跳过」).';
|
|
37
|
+
|
|
38
|
+
// A tap gated on a pager position the replay never pages to (measured: coolmall Guide, 「开始体验」
|
|
39
|
+
// shows only on the last of three guide pages; every fresh-install task failed at that hop).
|
|
40
|
+
const _POSITIONAL = /(最后一页|末页|最后一屏|最后一张|last (?:page|slide|screen|step))/i;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Targets of the clauses that name a pager position. Parentheses are explanation (「跳过」(任意页均有,
|
|
44
|
+
* 无需翻到最后一页)) and do not gate anything; a clause's target is its last quote, as in hintSteps.
|
|
45
|
+
*/
|
|
46
|
+
function positionalTargets(hint) {
|
|
47
|
+
const quoted = new RegExp(_QUOTED, 'g');
|
|
48
|
+
return String(hint ?? '').replace(/([^)]*)|\([^)]*\)/g, '').split(/[,,;;。]|→|然后|再|and then/)
|
|
49
|
+
.filter((c) => _POSITIONAL.test(c))
|
|
50
|
+
.map((c) => [...c.matchAll(quoted)].map((m) => m[1] ?? m[2]).at(-1))
|
|
51
|
+
.filter(Boolean);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Extra review findings for a hint that compiles: [reason, detail] or null. */
|
|
55
|
+
export function hintFindings(hint, steps, index) {
|
|
56
|
+
const gated = positionalTargets(hint);
|
|
57
|
+
if (gated.length && steps.some((s) => gated.includes(s[1]) && !(s[2] ?? []).length)) {
|
|
58
|
+
return ['hint-target-needs-unreached-position', 'name an alternative visible from the first position: (或点击「…」)'];
|
|
59
|
+
}
|
|
60
|
+
if (index) {
|
|
61
|
+
// Only a target the source writes in a comment and in no literal is a misquote: one found
|
|
62
|
+
// nowhere may be framework, system-dialog or server text (「确定」, 「允许」, a city name).
|
|
63
|
+
const missing = steps.flatMap((s) => (s[1] && !pyId(s[1]) ? [s[1], ...(s[2] ?? [])] : []))
|
|
64
|
+
.filter((t) => onlyInComment(index, t));
|
|
65
|
+
if (missing.length) {
|
|
66
|
+
return ['hint-target-not-in-source', `found only in a code comment, not in a string resource value or literal: ${missing.join(', ')}`];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const pyId = (t) => String(t).startsWith('id:');
|
|
32
72
|
|
|
33
73
|
/**
|
|
34
74
|
* The items of an answers file: `{items: [...]}` or a bare array (the shape split parts and the
|
|
@@ -42,13 +82,16 @@ export function answerItems(answers) {
|
|
|
42
82
|
}
|
|
43
83
|
|
|
44
84
|
/** -> [{key, reason, nl_hint}] for every hint of one answers object that does not compile. */
|
|
45
|
-
export function badHints(answers) {
|
|
85
|
+
export function badHints(answers, { index = null } = {}) {
|
|
46
86
|
const bad = [];
|
|
47
87
|
let ok = 0;
|
|
48
88
|
const one = (key, hint, at) => {
|
|
49
|
-
const [, reason] = hintSteps(hint);
|
|
50
|
-
|
|
51
|
-
|
|
89
|
+
const [steps, reason] = hintSteps(hint);
|
|
90
|
+
const where = at ? { at } : {};
|
|
91
|
+
if (reason && reason !== 'hint-no-gesture') { bad.push({ key, reason, nl_hint: hint, ...where }); return; }
|
|
92
|
+
const found = steps?.length ? hintFindings(hint, steps, index) : null;
|
|
93
|
+
if (found) { bad.push({ key, reason: found[0], detail: found[1], nl_hint: hint, ...where }); return; }
|
|
94
|
+
ok += 1;
|
|
52
95
|
};
|
|
53
96
|
for (const it of answerItems(answers) ?? []) {
|
|
54
97
|
// view_interactions answers: each transition's `instruction` is compiled by the same grammar
|
|
@@ -64,9 +107,22 @@ export function badHints(answers) {
|
|
|
64
107
|
|
|
65
108
|
export function main(argv = process.argv.slice(2)) {
|
|
66
109
|
if (!argv.length || argv.includes('-h') || argv.includes('--help')) {
|
|
67
|
-
process.stdout.write('usage: hint_check.mjs <nl_hints_answers.json> [...]\n\n' +
|
|
110
|
+
process.stdout.write('usage: hint_check.mjs [--project <android source root>] <nl_hints_answers.json> [...]\n\n' +
|
|
111
|
+
'With --project, a quoted target written only in a code comment (in no string resource value or\n' +
|
|
112
|
+
'literal) is rejected; text the project never writes (framework, system, server) passes.\n\n' + RULES + '\n');
|
|
68
113
|
return argv.length ? 0 : 2;
|
|
69
114
|
}
|
|
115
|
+
let index = null;
|
|
116
|
+
const pi = argv.indexOf('--project');
|
|
117
|
+
if (pi >= 0) {
|
|
118
|
+
const root = argv[pi + 1];
|
|
119
|
+
if (!root || !fs.existsSync(root)) {
|
|
120
|
+
process.stdout.write(JSON.stringify({ reason: 'project-not-found', project: root ?? null }) + '\n');
|
|
121
|
+
return 2;
|
|
122
|
+
}
|
|
123
|
+
index = sourceTextIndex(root);
|
|
124
|
+
argv = [...argv.slice(0, pi), ...argv.slice(pi + 2)];
|
|
125
|
+
}
|
|
70
126
|
let ok = 0;
|
|
71
127
|
let bad = 0;
|
|
72
128
|
let invalid = 0;
|
|
@@ -77,7 +133,7 @@ export function main(argv = process.argv.slice(2)) {
|
|
|
77
133
|
process.stdout.write(JSON.stringify({ file: f, reason: 'not-an-answers-file', expected: '{"items": [...]} or [...]' }) + '\n');
|
|
78
134
|
continue;
|
|
79
135
|
}
|
|
80
|
-
const r = badHints(doc);
|
|
136
|
+
const r = badHints(doc, { index });
|
|
81
137
|
ok += r.ok;
|
|
82
138
|
bad += r.bad.length;
|
|
83
139
|
for (const b of r.bad) process.stdout.write(JSON.stringify({ file: f, ...b }) + '\n');
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hint_source.mjs -- the on-screen texts a project can show, for checking nl_hint targets.
|
|
3
|
+
*
|
|
4
|
+
* A quoted hint target must be something the device can display: a string-resource value, an
|
|
5
|
+
* XML attribute/text, or a string literal in code. Comments never reach the screen, so they are
|
|
6
|
+
* blanked first. Measured (coolmall): the reviewer quoted 「应用Logo」 from the KDoc
|
|
7
|
+
* `* 应用Logo图标组件`; the control's contentDescription is "Logo", so the replay scrolled the
|
|
8
|
+
* home page 14 times and every task routed through the About page failed.
|
|
9
|
+
* Comment texts are kept apart. A target is a misquote when it is written only in a comment and a
|
|
10
|
+
* project literal is a proper part of it: the quote added description words to the real label
|
|
11
|
+
* (「应用Logo」 around "Logo"). A comment that merely names system text (// 权限弹窗点允许) does
|
|
12
|
+
* not reject 「允许」, and a target found nowhere (framework, system, server text) passes.
|
|
13
|
+
*
|
|
14
|
+
* Exports: sourceTextIndex(root) -> {texts, comments}, inSource(index, text) -> boolean,
|
|
15
|
+
* onlyInComment(index, text) -> boolean, codeLiterals(text, comments?), xmlTexts(text, comments?)
|
|
16
|
+
*/
|
|
17
|
+
import * as fs from 'node:fs';
|
|
18
|
+
import * as path from 'node:path';
|
|
19
|
+
|
|
20
|
+
const PRUNE = new Set(['build', '.git', '.gradle', '.idea', 'node_modules', '.cxx', 'unpackage', 'dist']);
|
|
21
|
+
const CODE = new Set(['.kt', '.kts', '.java', '.js', '.ts', '.vue', '.nvue', '.dart']);
|
|
22
|
+
const MAX_FILE = 2 * 1024 * 1024;
|
|
23
|
+
const squash = (s) => String(s).replace(/\s+/g, ' ').trim();
|
|
24
|
+
|
|
25
|
+
/** String literals of C-like source, comments pushed to `comments` (one pass, quote/escape aware). */
|
|
26
|
+
export function codeLiterals(src, comments = []) {
|
|
27
|
+
const out = [];
|
|
28
|
+
let i = 0;
|
|
29
|
+
const n = src.length;
|
|
30
|
+
while (i < n) {
|
|
31
|
+
const c = src[i];
|
|
32
|
+
const d = src[i + 1];
|
|
33
|
+
if (c === '/' && d === '/') { const e = src.indexOf('\n', i); comments.push(src.slice(i + 2, e < 0 ? n : e)); i = e < 0 ? n : e; continue; }
|
|
34
|
+
if (c === '/' && d === '*') {
|
|
35
|
+
const e = src.indexOf('*/', i + 2);
|
|
36
|
+
comments.push(src.slice(i + 2, e < 0 ? n : e).replace(/^\s*\*/gm, ' '));
|
|
37
|
+
i = e < 0 ? n : e + 2;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (c === '"' && src.startsWith('"""', i)) {
|
|
41
|
+
const e = src.indexOf('"""', i + 3);
|
|
42
|
+
out.push(src.slice(i + 3, e < 0 ? n : e));
|
|
43
|
+
i = e < 0 ? n : e + 3;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (c === '"' || c === "'" || c === '`') {
|
|
47
|
+
let j = i + 1;
|
|
48
|
+
let buf = '';
|
|
49
|
+
while (j < n && src[j] !== c && src[j] !== '\n') {
|
|
50
|
+
if (src[j] === '\\' && j + 1 < n) { buf += src[j + 1]; j += 2; continue; }
|
|
51
|
+
buf += src[j];
|
|
52
|
+
j += 1;
|
|
53
|
+
}
|
|
54
|
+
out.push(buf);
|
|
55
|
+
i = j + 1;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
i += 1;
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const decodeXml = (s) => s.replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"')
|
|
64
|
+
.replace(/'/g, "'").replace(/&/g, '&').replace(/\\'/g, "'").replace(/\\"/g, '"');
|
|
65
|
+
|
|
66
|
+
/** Attribute values and element text of XML / a Vue template, comments pushed to `comments`. */
|
|
67
|
+
export function xmlTexts(src, comments = []) {
|
|
68
|
+
const body = src.replace(/<!--([\s\S]*?)-->/g, (_, c) => { comments.push(c); return ' '; });
|
|
69
|
+
const out = [];
|
|
70
|
+
for (const m of body.matchAll(/=\s*"([^"]*)"/g)) out.push(decodeXml(m[1]));
|
|
71
|
+
for (const m of body.matchAll(/>([^<>]+)</g)) out.push(decodeXml(m[1]));
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Every displayable text of the project under `root` (build outputs pruned). */
|
|
76
|
+
export function sourceTextIndex(root) {
|
|
77
|
+
const texts = new Set();
|
|
78
|
+
const comments = [];
|
|
79
|
+
const stack = [root];
|
|
80
|
+
while (stack.length) {
|
|
81
|
+
const cur = stack.pop();
|
|
82
|
+
let entries;
|
|
83
|
+
try { entries = fs.readdirSync(cur, { withFileTypes: true }); } catch { continue; }
|
|
84
|
+
for (const e of entries) {
|
|
85
|
+
const p = path.join(cur, e.name);
|
|
86
|
+
if (e.isDirectory()) { if (!PRUNE.has(e.name)) stack.push(p); continue; }
|
|
87
|
+
const ext = path.extname(e.name).toLowerCase();
|
|
88
|
+
if (!CODE.has(ext) && ext !== '.xml' && ext !== '.json') continue;
|
|
89
|
+
let src;
|
|
90
|
+
try { if (fs.statSync(p).size > MAX_FILE) continue; src = fs.readFileSync(p, 'utf8'); } catch { continue; }
|
|
91
|
+
const notes = [];
|
|
92
|
+
const found = ext === '.xml' ? xmlTexts(src, notes)
|
|
93
|
+
: ext === '.vue' || ext === '.nvue' ? [...xmlTexts(src, notes), ...codeLiterals(src, notes)]
|
|
94
|
+
: codeLiterals(src, ext === '.json' ? [] : notes);
|
|
95
|
+
for (const t of found) { const s = squash(t); if (s) texts.add(s); }
|
|
96
|
+
for (const t of notes) { const s = squash(t); if (s) comments.push(s); }
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return { texts: [...texts], comments };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* True when `text` is shown by some literal: equal to one, or inside one (a literal that holds
|
|
104
|
+
* a template such as "已售${n}件" or a longer label still shows the quoted run).
|
|
105
|
+
*/
|
|
106
|
+
export function inSource(index, text) {
|
|
107
|
+
const t = squash(text);
|
|
108
|
+
if (!t) return true;
|
|
109
|
+
if (!index.set) index.set = new Set(index.texts);
|
|
110
|
+
if (index.set.has(t)) return true;
|
|
111
|
+
return index.texts.some((s) => s.includes(t));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** True when `text` is quoted from a description: comment-only, wrapped around a shorter literal. */
|
|
115
|
+
export function onlyInComment(index, text) {
|
|
116
|
+
const t = squash(text);
|
|
117
|
+
if (!t || inSource(index, t) || !(index.comments ?? []).some((c) => c.includes(t))) return false;
|
|
118
|
+
return index.texts.some((s) => s.length >= 2 && s.length < t.length && t.includes(s));
|
|
119
|
+
}
|
|
@@ -215,7 +215,13 @@ export function extract(doc, graph, project, pkg, root, unmapped = false) {
|
|
|
215
215
|
'If it does, propose the smallest rule (resource ids and/or UI text visible in ' +
|
|
216
216
|
'the tree) that identifies the page, and cite where each anchor is declared ' +
|
|
217
217
|
'in the project (layout XML line, string resource line, source line). Never use ' +
|
|
218
|
-
'runtime data (item titles, dates, counts) as an anchor.
|
|
218
|
+
'runtime data (item titles, dates, counts) as an anchor. Each item is judged for ' +
|
|
219
|
+
"its OWN `page` only: take anchors from that item's `static.files` (its " +
|
|
220
|
+
'declaration, layout, or the string resource those lines reference), never from ' +
|
|
221
|
+
'a neighbouring item or the page that opens it -- a sheet opened by a settings ' +
|
|
222
|
+
'row titled like the sheet shows the title in both, so cite the line in the ' +
|
|
223
|
+
"sheet's own file and pick a text only the sheet's window shows (its options) " +
|
|
224
|
+
'as a second anchor. When the screenshot ' +
|
|
219
225
|
'clearly shows the page but NO source-owned rule can separate it (a twin ' +
|
|
220
226
|
"layout, a page whose only text is data), answer verdict 'attest' with the " +
|
|
221
227
|
'examples and a one-sentence visible reason: it is recorded as attested ' +
|
|
@@ -142,8 +142,15 @@ export function collect(doc) {
|
|
|
142
142
|
} else if (good.length) {
|
|
143
143
|
beforeId = good[good.length - 1].payload.after;
|
|
144
144
|
}
|
|
145
|
+
const before = obs.get(beforeId) ?? null;
|
|
146
|
+
// A hop that started on its own target needs no gesture: a first-run page (Guide 「跳过」 → Main)
|
|
147
|
+
// was already passed, and Runner.replayStepPassed skips it now. A replacement gesture learnt on
|
|
148
|
+
// that screen breaks the fresh start instead (measured, coolmall 2026-11-08: 「主页」 replaced
|
|
149
|
+
// 「跳过」, the recB phase restored fresh data, landed on the Guide and failed 20 tasks there).
|
|
150
|
+
if (fs[0] === 'source' && T(get(fs[2], 'target_id')) && before !== null
|
|
151
|
+
&& observationMatchesStatic(before, fs[2].target_id, get(doc, 'page_catalog', {}))[0]) { continue; }
|
|
145
152
|
out.push({ base, task: t, result: p, stage: fs[0], index: fs[1], step: fs[2],
|
|
146
|
-
before
|
|
153
|
+
before, failure: obs.get(get(p, 'observation_id')) ?? null,
|
|
147
154
|
phase: (tasks.get(base) ?? t).phase });
|
|
148
155
|
}
|
|
149
156
|
return out;
|