Set up Visor in this mobile app repository and complete the initial agent-driven discovery phase. Do the work instead of only giving me instructions.
Work from the repository root, preserve existing changes, and use the existing package manager when possible.
1. Verify Node.js 20.19+, 22.12+, or 24+, and npm 10+. If this repository already has a Node package manifest, install `visor-ai@latest` as a local development dependency with its package manager. Otherwise install it into an isolated ignored runtime with `npm install --prefix .visor/runtime visor-ai@latest`. Use the resulting local `visor` binary for every command; do not depend on a global installation.
2. Install the Visor repository skill for the current agent and other agents that share the canonical project skill directory:
`npx --yes skills@latest add AleksKapera/visor --skill visor-discovery --copy --yes`
Verify that `.agents/skills/visor-discovery/SKILL.md` and `skills-lock.json` exist. Read that SKILL.md completely now and follow it for the rest of this task.
3. Locate the installed package and copy its Navigator definitions for both Codex and Claude Code:
`VISOR_PACKAGE_DIR="$(node -e 'const path = require("node:path"); process.stdout.write(path.dirname(require.resolve("visor-ai/package.json", { paths: [path.resolve("."), path.resolve(".visor/runtime")] })));')"`
`mkdir -p .codex/agents .claude/agents`
`test -e .codex/agents/navigator.toml || cp "$VISOR_PACKAGE_DIR/docs/agents/navigator/codex/navigator.toml" .codex/agents/navigator.toml`
`test -e .claude/agents/navigator.md || cp "$VISOR_PACKAGE_DIR/docs/agents/navigator/claude-code/navigator.md" .claude/agents/navigator.md`
If either destination already exists and differs, preserve its project-specific guidance and merge the Navigator requirements instead of overwriting it blindly. Verify both files exist and read the definition for the active client completely.
4. Add or merge a short `Mobile device interaction` rule in the repository's root `AGENTS.md` and `CLAUDE.md`: delegate every observation or action on a simulator, emulator, or connected device to the `navigator` agent; the parent agent must not operate the device directly. Preserve all existing repository guidance. If this running client cannot load a newly installed agent until restart, follow its definition inline for this initial run and tell me to restart the client before later device tasks.
5. Add `.visor/` to `.gitignore` if it is not already ignored. Ensure ignore rules allow the installed skill, `skills-lock.json`, both Navigator definitions, and the root agent-routing guidance to be committed; use precise negations instead of exposing unrelated local agent state. Keep maps and runtime artifacts local.
6. Inspect the project and local machine to determine whether this run targets iOS or Android. Check installed Appium drivers with the local Appium CLI and install the required `xcuitest` or `uiautomator2` driver if it is missing. Do not replace a working compatible driver unnecessarily.
7. Find or boot exactly one simulator, emulator, or connected device. Determine the installed app's real bundle id or package id from the project and device. Build or install the app using this repository's normal workflow if needed. Ask me only if the target, app id, authentication state, or a required manual choice cannot be determined safely.
8. Before interacting with the app, ask me one concise permission question. Ask whether I want: (a) safe-only discovery, (b) scoped discovery with specific allowed or forbidden actions, or (c) full access in this specific test app and account, including risky, destructive, dangerous, and input-dependent actions. Default to safe-only if I do not answer. Also ask how to handle authentication: I can sign in manually, provide a dedicated test account through an approved secret-sharing method, or authorize you to register a new test account. Wait for my answer before app interaction unless I already supplied these choices.
9. Use `.visor/maps` as the persistent map directory. If it already contains a map, preserve and reuse it; do not delete it. If it is new, confirm that discovery starts without prior map knowledge.
10. Delegate all remaining device work to Navigator. Start Visor, keep the daemon and app session warm, and use explicit `--device`, `--app-id`, `--attach`, and `--map-dir .visor/maps` values on runtime commands.
11. Populate the map with the AI-assisted Visor discovery flow. Never run generic `discover --crawl`, even if I grant full access. Run `visor discover`, reason over compact `data.memory`, annotate the exact `data.observation_token` without another device read, choose the next action under the agreed permission policy, execute it, observe the resulting stable state, and annotate it immediately. Repeat screen by screen.
12. Discover global navigation, reliable back or close behavior, and one representative nested route per major hub. Under safe-only discovery, do not execute `risky`, `needs-input`, or `unknown` actions. Under scoped or full access, execute only what I explicitly authorized and keep the factual risk classification in the map. Execute authorized dangerous or destructive actions directly one at a time and checkpoint immediately; do not disguise them as safe route steps. Use screenshots or UI source only when compact memory is genuinely ambiguous.
13. If login blocks discovery, pause and use the authentication option I selected. Never guess credentials or persist secrets in annotations, route plans, maps, screenshots, source dumps, or reports. If registration is authorized, create only a test account for this environment.
14. Verify at least one known safe multi-step or alternate path with a single deterministic `visor route` request. If an unknown state appears, use `needs_discovery`, annotate its exact token, add a safe recovery path, and retry gracefully. Update the map whenever this run uncovers a new or changed screen, action, selector, transition, or recovery route.
15. Leave the app on a stable known screen and keep the daemon available for the next Navigator task. Finish only after reporting: the agreed permission policy, device and app id, authentication method, installed skill and Navigator paths, map and agent-memory paths, semantic screens and routes learned or updated, route timing/outcomes, recovery attempts, actions exercised by risk class, unresolved gaps, and actions you intentionally did not execute.
Do not commit or publish changes unless I ask. Tell me which setup files should be committed so future agents inherit the Visor skill and Navigator.