Skip to content

Smart macros — record once, replay many (literal + LLM-adaptive)#4

Merged
jackulau merged 1 commit into
mainfrom
goal/009-macros-rebased
May 26, 2026
Merged

Smart macros — record once, replay many (literal + LLM-adaptive)#4
jackulau merged 1 commit into
mainfrom
goal/009-macros-rebased

Conversation

@jackulau

Copy link
Copy Markdown
Owner

Summary

  • record_replay._ui_fingerprint(helpers) — lightweight screen digest (top-N labels, focused element, app bundle id, ~200 bytes).
  • record_replay.annotate(intent) context manager — attaches intent + fingerprint to journaled actions; backward-compat outside annotate blocks (unchanged behavior).
  • record_replay.replay_smart(script, helpers, llm=None, on_failure='raise') — per-step probe; if fingerprint matches → literal replay, if drift → retarget_action() via LLM → execute adapted action; MacroStepFailed raised (or skipped) with rich context on irrecoverable mismatch.
  • agent_loop.retarget_action(intent, recorded_fp, current_ui, llm) — reuses agent prompt scaffolding; mockable callable LLM.
  • mobile-use macro {record,replay,list,show} CLI subcommand. Flags: --smart/--literal (default literal), --intent <txt> for record, --dir <path> (default ~/.mobile-use/macros/).
  • docs/macros.md — full walkthrough; README + SKILL updated with example.

Test plan

  • python3 -m pytest tests/ -q → 611 passed locally (was 556 → 68 new macros tests)
  • CI matrix (Ubuntu + macOS × py3.11/3.12/3.13)
  • Manual: mobile-use macro record demo, run flow, mobile-use macro replay demo (literal) + mobile-use macro replay demo --smart (LLM-adaptive)

Notes

Adds the macro recording/replay system from goal/009:

- mobile_use/record_replay.py: `_ui_fingerprint(helpers)` digest (top-N
  labels, focused element, app bundle id, ~200 bytes), `annotate(intent)`
  ctx mgr that attaches intent + fingerprint to journal entries, sidecar
  .jsonl alongside the .py script, `replay_smart(script, helpers, llm)`
  literal-first / LLM-fallback engine, `MacroStepFailed` with rich context
  for skip-vs-raise recovery.
- mobile_use/agent_loop.py: `retarget_action(intent, recorded_fp,
  current_ui, llm)` reuses agent prompt scaffolding, mockable callable LLM.
- mobile_use/macro.py + cli.py: `mobile-use macro {record,replay,list,show}`
  CLI. Flags: --smart/--literal (default literal), --intent <txt> for record,
  --dir <path> (default ~/.mobile-use/macros/).
- docs/macros.md: end-to-end walkthrough.
- README + SKILL: smart-macro example + when-to-use vs agent loop guidance.

Tests: 68 new (record_replay + smart_replay + macro_cli). Full suite 611 pass.
@jackulau jackulau merged commit bbb248a into main May 26, 2026
7 checks passed
@jackulau jackulau deleted the goal/009-macros-rebased branch May 26, 2026 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant