@alan-ai-hq/agent-manager-linux-arm64 0.1.199 → 0.1.201

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.
Files changed (96) hide show
  1. package/alan-agent.cjs +8928 -5241
  2. package/alan-holder.cjs +5364 -3401
  3. package/alan-lease.cjs +808 -200
  4. package/builtin-skills/agent-desktop/SKILL.md +94 -0
  5. package/builtin-skills/alan-artifact/SKILL.md +128 -0
  6. package/builtin-skills/alan-artifact/examples/interactive-diagram.md +50 -0
  7. package/builtin-skills/alan-artifact/examples/prototype.md +53 -0
  8. package/builtin-skills/alan-artifact/examples/test-report.md +55 -0
  9. package/builtin-skills/alan-artifact/references/design.md +39 -0
  10. package/builtin-skills/alan-artifact/references/diagrams.md +20 -0
  11. package/builtin-skills/alan-deck/SKILL.md +189 -0
  12. package/builtin-skills/alan-diagrams/SKILL.md +105 -0
  13. package/builtin-skills/alan-diagrams/references/diagram-catalogue.md +847 -0
  14. package/builtin-skills/alan-docs/SKILL.md +143 -0
  15. package/builtin-skills/alan-docs/references/administration/members-and-teams.md +48 -0
  16. package/builtin-skills/alan-docs/references/administration/org-dashboard.md +19 -0
  17. package/builtin-skills/alan-docs/references/administration/organisation-settings.md +41 -0
  18. package/builtin-skills/alan-docs/references/agents-and-sessions/code-context.md +60 -0
  19. package/builtin-skills/alan-docs/references/agents-and-sessions/coding-agents-and-models.md +78 -0
  20. package/builtin-skills/alan-docs/references/agents-and-sessions/session-lifecycle.md +62 -0
  21. package/builtin-skills/alan-docs/references/agents-and-sessions/start-a-session.md +110 -0
  22. package/builtin-skills/alan-docs/references/automations/automation-runs.md +69 -0
  23. package/builtin-skills/alan-docs/references/automations/create-an-automation.md +143 -0
  24. package/builtin-skills/alan-docs/references/automations/overview.md +77 -0
  25. package/builtin-skills/alan-docs/references/cloud-and-local/cloud-images.md +64 -0
  26. package/builtin-skills/alan-docs/references/cloud-and-local/cloud-sessions-and-execution.md +89 -0
  27. package/builtin-skills/alan-docs/references/cloud-and-local/cloud-setup.md +128 -0
  28. package/builtin-skills/alan-docs/references/cloud-and-local/codex-cli-connector.md +92 -0
  29. package/builtin-skills/alan-docs/references/cloud-and-local/local-execution.md +213 -0
  30. package/builtin-skills/alan-docs/references/cloud-and-local/runtime-recovery.md +60 -0
  31. package/builtin-skills/alan-docs/references/cloud-and-local/sandboxes.md +74 -0
  32. package/builtin-skills/alan-docs/references/cloud-and-local/troubleshooting-and-faq.md +102 -0
  33. package/builtin-skills/alan-docs/references/get-started/connect-azure-devops.md +89 -0
  34. package/builtin-skills/alan-docs/references/get-started/connect-bitbucket.md +86 -0
  35. package/builtin-skills/alan-docs/references/get-started/connect-github.md +114 -0
  36. package/builtin-skills/alan-docs/references/get-started/join-a-team.md +114 -0
  37. package/builtin-skills/alan-docs/references/get-started/product-map.md +96 -0
  38. package/builtin-skills/alan-docs/references/get-started/quickstart.md +158 -0
  39. package/builtin-skills/alan-docs/references/get-started/set-up-your-team.md +200 -0
  40. package/builtin-skills/alan-docs/references/get-started/sign-in.md +104 -0
  41. package/builtin-skills/alan-docs/references/get-started/welcome.md +39 -0
  42. package/builtin-skills/alan-docs/references/integrations/connect-microsoft-teams.md +116 -0
  43. package/builtin-skills/alan-docs/references/integrations/connect-slack.md +164 -0
  44. package/builtin-skills/alan-docs/references/integrations/import-from-linear.md +172 -0
  45. package/builtin-skills/alan-docs/references/plans-and-billing/plans-and-limits.md +115 -0
  46. package/builtin-skills/alan-docs/references/plans-and-billing/usage-and-credits.md +47 -0
  47. package/builtin-skills/alan-docs/references/reference/documents-and-artifacts.md +52 -0
  48. package/builtin-skills/alan-docs/references/reference/faq.md +89 -0
  49. package/builtin-skills/alan-docs/references/reference/feature-catalog.md +89 -0
  50. package/builtin-skills/alan-docs/references/reference/glossary.md +96 -0
  51. package/builtin-skills/alan-docs/references/reference/links-and-ids.md +80 -0
  52. package/builtin-skills/alan-docs/references/reference/roles-and-permissions.md +64 -0
  53. package/builtin-skills/alan-docs/references/reference/statuses.md +86 -0
  54. package/builtin-skills/alan-docs/references/reviews-testing-deploys/deployments.md +28 -0
  55. package/builtin-skills/alan-docs/references/reviews-testing-deploys/pull-requests.md +85 -0
  56. package/builtin-skills/alan-docs/references/reviews-testing-deploys/review-work.md +55 -0
  57. package/builtin-skills/alan-docs/references/reviews-testing-deploys/testing-evidence.md +52 -0
  58. package/builtin-skills/alan-docs/references/skills/plugins-and-mcp.md +24 -0
  59. package/builtin-skills/alan-docs/references/skills/skills.md +103 -0
  60. package/builtin-skills/alan-docs/references/tasks/complete-a-task.md +79 -0
  61. package/builtin-skills/alan-docs/references/tasks/create-a-task.md +67 -0
  62. package/builtin-skills/alan-docs/references/tasks/subtasks-and-status.md +55 -0
  63. package/builtin-skills/alan-docs/references/tasks/task-artifacts.md +56 -0
  64. package/builtin-skills/alan-docs/references/tasks/task-detail.md +65 -0
  65. package/builtin-skills/alan-docs/references/teams-and-planning/cycles.md +93 -0
  66. package/builtin-skills/alan-docs/references/teams-and-planning/documents.md +66 -0
  67. package/builtin-skills/alan-docs/references/teams-and-planning/epics.md +95 -0
  68. package/builtin-skills/alan-docs/references/teams-and-planning/whiteboard.md +52 -0
  69. package/builtin-skills/alan-docs/references/troubleshooting/agent-blocked.md +38 -0
  70. package/builtin-skills/alan-docs/references/troubleshooting/common-problems.md +118 -0
  71. package/builtin-skills/alan-docs/references/troubleshooting/github-access.md +41 -0
  72. package/builtin-skills/alan-docs/references/troubleshooting/missing-artifact.md +47 -0
  73. package/builtin-skills/alan-docs/references/troubleshooting/report-an-issue.md +74 -0
  74. package/builtin-skills/alan-docs/references/troubleshooting/runtime-unavailable.md +49 -0
  75. package/builtin-skills/alan-docs/scripts/generate-references.mjs +363 -0
  76. package/builtin-skills/alan-environment-setup/SKILL.md +368 -0
  77. package/builtin-skills/alan-environment-setup/references/android.md +118 -0
  78. package/builtin-skills/alan-environment-setup/references/troubleshooting.md +38 -0
  79. package/builtin-skills/alan-skill-authoring/SKILL.md +83 -0
  80. package/builtin-skills/alan-tasks/SKILL.md +195 -0
  81. package/builtin-skills/alan-test-android/SKILL.md +224 -0
  82. package/builtin-skills/alan-test-android/scripts/android-up.sh +227 -0
  83. package/builtin-skills/alan-test-android/scripts/install-launch.sh +38 -0
  84. package/builtin-skills/alan-test-android/scripts/record.sh +64 -0
  85. package/builtin-skills/alan-test-android/scripts/ui.py +367 -0
  86. package/builtin-skills/alan-test-desktop/SKILL.md +107 -0
  87. package/builtin-skills/alan-test-desktop/references/linux-recording.md +31 -0
  88. package/builtin-skills/alan-test-feature/SKILL.md +243 -0
  89. package/builtin-skills/alan-test-mobile/SKILL.md +65 -0
  90. package/builtin-skills/alan-test-web/SKILL.md +113 -0
  91. package/builtin-skills/alan-walkthrough/SKILL.md +152 -0
  92. package/builtin-skills/alan-walkthrough/scripts/mark-changes.js +419 -0
  93. package/builtin-skills/alan-walkthrough/scripts/publish-capture.mjs +288 -0
  94. package/builtin-skills/alan-workflows/SKILL.md +235 -0
  95. package/builtin-skills/manifest.json +19 -0
  96. package/package.json +3 -2
@@ -0,0 +1,195 @@
1
+ ---
2
+ name: alan-tasks
3
+ version: 1.0.0
4
+ description: Use when filing, wording, moving, assigning, linking, or closing an Alan task, deciding whether a piece of work deserves a task, or coordinating that work across sessions and pilots. Covers find_records, list_tasks, create_task, update_task, create_subtask, add_task_relation, add_task_comment, add_task_decision, and list_task_suggestions. Do not use for documents or artifacts on their own, for git delivery mechanics such as branching and pull requests, or for non-Alan issue trackers.
5
+ ---
6
+
7
+ # Tasks in Alan
8
+
9
+ A task is the shared record of work in a team. People read it on the board and
10
+ in their Assigned to me view, and sessions work from it, so leave every task you
11
+ touch true before your turn ends.
12
+
13
+ This is a default way of working with tasks, not a set of hard rules. The person
14
+ can change any part of it by asking, and an in-scope AGENTS.md or another
15
+ instruction wins. Team statuses and labels are shared configuration: read them,
16
+ and change them only when a person asks.
17
+
18
+ ## When to file
19
+
20
+ - A task is a unit of work, not a session. A task can be worked by more than one
21
+ session, and a session belongs to one task at a time.
22
+ - File a task when the work outlives this turn or someone other than you must
23
+ act: a person's decision, approval, access, or merge, or another session's
24
+ work. Work that finishes in this turn needs no task.
25
+ - A finding or follow-up the current owner will handle is a comment on that
26
+ work's task. Only separate work gets a new task, with the fix and its source in
27
+ the description.
28
+ - To propose work without creating anything, use `suggest_task`: it puts the
29
+ idea in the session's side panel for the person to accept. Check
30
+ `list_task_suggestions` first so you do not repeat an open suggestion, and
31
+ withdraw one that no longer applies.
32
+
33
+ ## Find the task before you file
34
+
35
+ - Resolve a named or referenced task with `find_records` (`kinds: ["task"]`,
36
+ plus `teamId` and a `limit`). It takes a readable id (`AL-5068`), a number
37
+ (`2980` or `#45`), a title, or a keyword, and returns ranked matches — confirm
38
+ the number or title before acting. `get_task` takes the readable id directly.
39
+ - Browse a board with `list_tasks` (`status`, `assigneeId` or `mine`, `cycleId`,
40
+ `epicId`, `limit`/`offset`). Never use it to locate a task you were already
41
+ given an identifier or title for.
42
+ - Read one in full with `get_task` when you need its description, comments, or
43
+ subtasks before acting.
44
+ - A task named in your first message, or already assigned to the person you work
45
+ for, is your record — do not file a second one.
46
+ - Give each write that creates or changes a record an `idempotencyKey` naming the
47
+ change, reusing it only for the same input, so a retry cannot duplicate it.
48
+
49
+ ## Title and description
50
+
51
+ - Title by topic, a few words: "Retry backoff on webhook delivery". Keep status,
52
+ dates, questions, ticket codes, and PR numbers out of the title — the status
53
+ holds status, and the comments hold links.
54
+ - Write the description as the final state: the problem, what done looks like,
55
+ and the evidence. Rewrite it when scope changes instead of appending a status
56
+ log. It is Markdown shown to people, so lead with the outcome in one sentence
57
+ and keep commit hashes, ids, and migration numbers in a trailing References
58
+ list.
59
+ - Attach screenshots and files, and place each inline with a caption.
60
+
61
+ ## Subtasks
62
+
63
+ - Subtasks are one level deep. The parent task is the outcome; each subtask is
64
+ one unit of work with one owner. Check `list_subtasks` before adding so you do
65
+ not duplicate one. Add one with `create_subtask` (parent `taskId` and a
66
+ `title` — a subtask carries a title only, so keep the detail in the parent
67
+ description); give it an owner and move it with `update_subtask`
68
+ (`addAssigneeIds`, `status: "todo" | "done"`).
69
+ - New work discovered under a subtask goes under the same parent task, as a
70
+ sibling subtask or a related task.
71
+ - When a task holds about twenty open subtasks, or the work enters a new phase,
72
+ file a new task and relate it to the old one.
73
+ - Close the parent when its last subtask closes, unless work remains on the
74
+ parent itself.
75
+
76
+ ## Status
77
+
78
+ - Read the team's statuses with `list_teams` before you set one. Every team
79
+ configures its own; the built-in ids are `backlog`, `todo`, `in_progress`,
80
+ `running`, `waiting`, `in_review`, `done`, and `cancelled`, but a team may add,
81
+ rename, or repurpose them. An id is not its label: choose the status whose
82
+ `label` and `group` fit the change, not the id you expected — a team can label
83
+ its paused status `in_progress`, for example.
84
+ - Move the status in the same call as the change it records: you start work →
85
+ the team's status for started work; you open a pull request → its review
86
+ status, with the link in a comment; only a person can unblock → its waiting or
87
+ paused status (`paused: true`) with the ask below; work lands → `done`; work is
88
+ dropped → `cancelled` with a comment saying why. Only `done` and `cancelled`
89
+ are terminal by default; a team can add terminal statuses, and a `done`-group
90
+ status is not necessarily one, so judge by what the status means.
91
+ - Set it with `update_task`'s `status` (or `create_task`'s `status`); omit it on
92
+ `create_task` to use its default (`todo`). Never invent a status id; use one
93
+ `list_teams` returns.
94
+ - A request to close a task means a terminal status: `done` when the work
95
+ shipped, `cancelled` when it will not be, with a comment saying which and why.
96
+
97
+ ## Priority
98
+
99
+ - `create_task` and `update_task` accept `urgent`, `high`, `medium`, `low`, or
100
+ `none` and normalize them to the team's codes.
101
+ - `urgent` blocks people now, `high` is next up, `medium` is the default, `low`
102
+ can wait, and `none` is unset.
103
+
104
+ ## Labels
105
+
106
+ - Labels group tasks across statuses — a customer, an area, a kind of work. Pass
107
+ them by name; `update_task` replaces the whole set, so include the labels you
108
+ want to keep.
109
+ - Labels are shared across the team. Call `list_teams` and match its existing
110
+ labels, case-insensitively, before adding; add, rename, or delete a label only
111
+ when a person asks or no existing label fits.
112
+
113
+ ## Epics and cycles
114
+
115
+ - An epic groups tasks toward one outcome. Set it with `create_task` or
116
+ `update_task`'s `epicId`, resolved from `list_epics`; pass `null` to detach.
117
+ - A cycle is the team's time bucket. Omit `cycleId` to use the current active
118
+ cycle, pass `null` for Backlog, or pass an id from `list_cycles`.
119
+
120
+ ## Who acts next
121
+
122
+ - The assignee is whoever acts next. Set it with `create_task`'s `assigneeIds`,
123
+ one user resolved with `list_team_members`, or with `update_task`'s
124
+ `addAssigneeIds` / `removeAssigneeIds`. A new task is assigned to you unless
125
+ you pass `assigneeIds` explicitly (pass `[]` to leave it unassigned). Clear the
126
+ assignee when nobody should act.
127
+ - Assignees organise work; they do not decide who wakes. In Alan a session is
128
+ what wakes — a message, a subscription, or a returned notice — and the task is
129
+ the record it works from. Reassign when the next actor changes.
130
+
131
+ ## Comments, events, and decisions
132
+
133
+ - `add_task_comment` carries progress and discussion for people: what changed,
134
+ what comes next, what blocks it, with the number or file behind each claim.
135
+ One comment per real change beats one per step. It is not for Agent Log events,
136
+ decisions, or agent memory.
137
+ - Record structured decisions with `add_task_decision` (`decision` plus
138
+ `reasoning`, including the tradeoff or the option you rejected), and general
139
+ checkpoints and outcomes with `add_task_event`. Supersede a decision you have
140
+ replaced with `supersede_task_decision` rather than appending a contradiction.
141
+ - When a decision needs a person, assign them, set the waiting status if the team
142
+ has one, and open the comment with what you need: the options, your
143
+ recommendation, and what happens after they answer.
144
+
145
+ ## Links
146
+
147
+ - Link two tasks with `add_task_relation` (`taskId`, `relatedTaskId`); both must
148
+ be in the same team. On create, `relatedTaskIds` links up to five tasks as
149
+ `relates_to`.
150
+ - Cite the readable id (`AL-5068`) instead of restating the work, and record a
151
+ pull request's link in a comment, not in the title.
152
+
153
+ ## Sessions, pilots, and orchestration
154
+
155
+ - Start the work's session only after the task exists. `start_task_session`
156
+ creates a session linked to the task and dispatches an agent on it with a
157
+ kickoff `message`.
158
+ `spawn_session` starts a child session below you for one unit of work, without
159
+ its own task, and returns immediately — the child's result arrives later as a
160
+ notice, so end your turn instead of polling.
161
+ - A batch of independent units is one task each, each with its own session; use a
162
+ parent task with `spawn_session` children only when the units share one outcome.
163
+ - Record that unit as a subtask on the parent task, and fold the child's result
164
+ back as one comment or event plus the status change. `list_my_sessions` shows
165
+ the tree and each child's activity; `message_session` nudges an idle child or
166
+ asks its owner a question; `stop_session_tree` stops work that is wrong or no
167
+ longer needed.
168
+ - When a child is archived or cannot finish, move the task back to the team's
169
+ open status, or close it with a comment saying why.
170
+ - A pilot is a separate agent identity with its own session tree; find who you
171
+ can reach with `list_pilots` and message one with `message_session`. The
172
+ task, not the session, is the shared record.
173
+
174
+ ## Failure handling
175
+
176
+ - A status the team does not have: re-read `list_teams` and use a returned id, or
177
+ omit the change and ask.
178
+ - A task you cannot resolve: retry `find_records` with fewer kinds or a shorter
179
+ query, then try `list_tasks`. Never guess an id.
180
+ - A record that does not match the request — an id that resolves to different
181
+ work, or a claim the record contradicts: stop and ask which is meant. Never act
182
+ on the wrong record.
183
+ - An underspecified request: describe only what the person said and ask one
184
+ targeted question for the missing scope or owner. Never invent repro steps,
185
+ causes, or acceptance criteria to fill the gap.
186
+ - An ask that blocks on a person: assign them, set the waiting status if there is
187
+ one, comment the ask, and re-ask or close after a few days of silence.
188
+ - A missing Alan task tool: keep the work in the conversation and say which
189
+ action is unavailable. Do not invent a record or mirror the board elsewhere.
190
+
191
+ For adjacent work, follow your session's installed skills — for example
192
+ `alan-plan` for a plan, `alan-testing` or `alan-test-feature` for verification,
193
+ `alan-orchestrator` for a batch of tasks, `alan-workflow-creator` for automation.
194
+ If one is not installed, continue with the task tools above and say what you
195
+ could not do.
@@ -0,0 +1,224 @@
1
+ ---
2
+ name: alan-test-android
3
+ version: 0.9.0
4
+ description: "This skill should be used when a test charter targets a native Android app (APK, Gradle, React Native, Expo, Flutter, or Kotlin Multiplatform build) in an Alan cloud sandbox. It brings up or attaches to an Android device, builds and installs the app, drives it through ADB and the accessibility tree, records the flow, and returns observations, findings, gaps, and sandbox capture paths. Do not use it for mobile web or PWAs, iOS, publishing evidence, or writing the test report."
5
+ ---
6
+
7
+ # Run a charter on a native Android app
8
+
9
+ Run this workflow only in an Alan cloud sandbox. If the cloud session or a
10
+ required capability is unavailable, report the blocker; do not switch to a
11
+ developer machine, local container, or CI runner.
12
+
13
+ This is a surface driver. It receives one charter, runs it on a real Android
14
+ runtime, and returns a short result. It never calls `create_test_report`,
15
+ never publishes captures, and never decides the overall run status.
16
+
17
+ Scripts live next to this file in `scripts/`. Run them with `bash` or
18
+ `python3 -I`; each prints what it did and exits non-zero on failure.
19
+
20
+ ## Input
21
+
22
+ The caller hands over a charter:
23
+
24
+ - **mission** and **app**: the repository path or a prebuilt APK, plus the
25
+ application id if known;
26
+ - **risks**, each with a one-line oracle;
27
+ - **backend**: the local port(s) the app calls, if any, and how to start them;
28
+ - **authentication**: test account or seeded state;
29
+ - **evidence directory**, such as `/tmp/alan-captures/<charter-slug>/`.
30
+
31
+ ## Step 1 · Device readiness
32
+
33
+ ```bash
34
+ bash scripts/android-up.sh --api <level>
35
+ ```
36
+
37
+ The script reuses an attached device first (`ANDROID_SERIAL` or the only
38
+ entry in `adb devices`). Otherwise it boots the Android emulator from the
39
+ image's SDK, using the installed system image closest to `--api`.
40
+
41
+ The environment image provides the toolchain; this skill never installs it,
42
+ changes device permissions, or retries variations. Exit 3 lists every missing
43
+ prerequisite in two groups. Return `blocked` for this charter with both lists
44
+ verbatim, then:
45
+
46
+ - **toolchain** items are a discovered system requirement. Persist them through
47
+ `/alan-environment-setup` maintenance; its android reference holds the
48
+ recipe. The charter can run in a session on the rebuilt image.
49
+ - **environment** items are not repository changes. A missing `/dev/kvm` needs
50
+ a Freestyle environment, set by an Alan admin. Too little memory needs stopped
51
+ services or Extra large in the environment's machine picker. Name the setting
52
+ in the result so the user can change it.
53
+
54
+ A cold-booted emulator plus a Gradle build uses about 5.5 GB of memory. An
55
+ emulator that exits during boot fails at once with its last log lines; quote
56
+ them in the result.
57
+
58
+ Pass `--api` from the app's `targetSdk` (`grep -rn targetSdk --include='*.gradle*' .`).
59
+ Without a Gradle project, omit it.
60
+
61
+ Exit 0 means the script verified boot, a stable `device` state, a resumed
62
+ launcher (not `FallbackHome`), and a non-blank screenshot. Open the
63
+ `SCREENSHOT=` file once yourself: it must show rendered UI at readable
64
+ density. The script prints `SERIAL=<serial>`. Pin it on every command:
65
+ `adb -s <serial> ...`. A second listed device makes unpinned commands fail.
66
+ When the sandbox has a streamed desktop, the script also opens a live mirror
67
+ (scrcpy >= 2) on `$DISPLAY` so the user can watch; a missing mirror is a
68
+ viewing gap, not a reason to stop.
69
+
70
+ ## Step 2 · Backend
71
+
72
+ Start the backend the charter names in the background and wait for a real
73
+ health check. Then make it reachable from the device without changing the
74
+ app's configured host:
75
+
76
+ ```bash
77
+ adb -s $SERIAL reverse tcp:<port> tcp:<port>
78
+ ```
79
+
80
+ This works for `localhost:<port>` in the app. If the app hardcodes `10.0.2.2`
81
+ (the emulator's host alias), reverse is not needed on the SDK emulator. Change
82
+ app configuration only when neither applies, and say what you changed.
83
+
84
+ Reversed traffic rides the adb connection, not the device network. Two
85
+ consequences: a stopped backend looks like an accepted-then-dropped
86
+ connection ("unexpected end of stream"), not "connection refused"; and
87
+ turning off wifi and data does not cut the app off (see offline below).
88
+
89
+ ## Step 3 · Build and install
90
+
91
+ Build a debug APK with the repository's own command. Do not filter ABIs:
92
+
93
+ | Stack | Build |
94
+ | --- | --- |
95
+ | Gradle (Kotlin/Java, KMP) | `./gradlew assembleDebug` |
96
+ | React Native / Expo | bundle JS first (see gotchas), then `cd android && ./gradlew assembleDebug` |
97
+ | Flutter | `flutter build apk --debug` |
98
+
99
+ ```bash
100
+ bash scripts/install-launch.sh $SERIAL <path-to.apk> [<applicationId>]
101
+ ```
102
+
103
+ It installs with `-r -t -g` (keeping data, granting runtime permissions),
104
+ resolves the launcher activity, starts it, and fails unless the process is
105
+ still alive 5 seconds later. Copy its whole output line into your
106
+ observations; the version, `apk_sha256`, and `apk_built` identify the build
107
+ under test. An up-to-date Gradle build reuses the existing APK; that is fine
108
+ when `apk_built` is after the change you are testing, otherwise rebuild with
109
+ `clean`.
110
+
111
+ ## Step 4 · Drive the charter
112
+
113
+ Read the screen before every action. Never tap coordinates guessed from a
114
+ screenshot.
115
+
116
+ ```bash
117
+ python3 -I scripts/ui.py $SERIAL dump # interactive elements with ids
118
+ python3 -I scripts/ui.py $SERIAL tap --text "Sign in" # or --id, --desc, --index
119
+ python3 -I scripts/ui.py $SERIAL type --id email "a@b.co" # focuses, clears, types (spaces ok)
120
+ python3 -I scripts/ui.py $SERIAL wait --text '^\d+ items$' --regex # or --exact; default is substring
121
+ python3 -I scripts/ui.py $SERIAL state <pkg> # the app-health check, see below
122
+ python3 -I scripts/ui.py $SERIAL relaunch <pkg> # force-stop + cold start
123
+ python3 -I scripts/ui.py $SERIAL shot <evidence-dir>/<name>.png
124
+ ```
125
+
126
+ `tap` and `type` fail when the selector matches nothing or more than one
127
+ element; refine with `--index` from `dump`, never with raw coordinates.
128
+ `type` sends ASCII through `adb input text`; it cannot enter emoji or
129
+ non-Latin text, so list those inputs as unverified rather than skipping
130
+ them silently.
131
+ Use `adb -s $SERIAL shell input keyevent KEYCODE_BACK` for the system back
132
+ button, and `adb -s $SERIAL shell input swipe` for lists that need scrolling;
133
+ re-dump after each.
134
+
135
+ Record the flow, starting right before the first interaction:
136
+
137
+ ```bash
138
+ bash scripts/record.sh $SERIAL start <evidence-dir>/<charter-slug>.mp4
139
+ # ... interactions ...
140
+ bash scripts/record.sh $SERIAL stop
141
+ ```
142
+
143
+ One recording is capped at 3 minutes by Android. Check `record.sh $SERIAL
144
+ status` before each new attempt and start a new file when less than 30 seconds
145
+ remain; crash-repro cycles use the time quickly.
146
+ `stop` fails if the file has no video stream and writes the last frame next
147
+ to it; open that frame and confirm it shows the app, not a black screen.
148
+
149
+ While driving:
150
+
151
+ - After each user-visible action, run `ui.py $SERIAL state <pkg>`. It is the
152
+ single source of truth for app health: `foreground: no` or `new_crashes`
153
+ above 0 is a finding, with the printed stack as its evidence. `dialog:` is
154
+ informational; Android often skips the crash dialog.
155
+ It clears the crash buffer, so each call reports only what happened since
156
+ the last one. Do not judge health from `pidof` or `mCurrentFocus`: a
157
+ crashed app can keep its pid behind the "keeps stopping" dialog, and the
158
+ focus line can keep a dismissed dialog.
159
+ - Reproduce from a fresh launch with `ui.py relaunch <pkg>`. Apps that keep
160
+ the session only in memory return to sign-in; that is a separate
161
+ observation, not a crash. Relaunching is also how to leave a crash dialog.
162
+ When every repro needs the same relaunch, sign-in, and wait, put those
163
+ `ui.py` calls in a small script in the evidence directory and reuse it.
164
+ - Reading the app's source to learn when a screen reloads or what a field
165
+ accepts is fine; findings still come from driving the app.
166
+ - Verify writes against the backend when it is cheap (an API read or DB row).
167
+ "The toast appeared" is not "it saved".
168
+ - Exercise Android-specific risks the change can reach: rotation
169
+ (`settings put system accelerometer_rotation 0` then `user_rotation 1`),
170
+ back from a nested screen, app restart (`ui.py relaunch`) to prove
171
+ persistence, and denied permissions (`pm revoke`). `android-up.sh` resets
172
+ network and rotation, so re-run it rather than restoring by hand.
173
+ - Offline: for a backend reached through `adb reverse`, the outage is
174
+ `adb -s $SERIAL reverse --remove tcp:<port>`; `svc wifi disable; svc data
175
+ disable` cuts only real network traffic (third-party APIs, the internet).
176
+ Either change affects new connections only, so relaunch or trigger one
177
+ throwaway request before judging the result.
178
+ - Reproduce a finding once from a known state before reporting it.
179
+
180
+ For a UI-change charter, capture the same screen on the base build and the
181
+ changed build at the same device size. The page overlay does not exist on a
182
+ native screen: return the pair with the numbered changed regions listed and
183
+ name the gap.
184
+
185
+ ## Gotchas
186
+
187
+ - **React Native / Expo blank screen.** A debug APK expects Metro. Either
188
+ run Metro and `adb reverse tcp:8081 tcp:8081`, or embed the bundle:
189
+ `npx expo export --platform android` (or `npx react-native bundle
190
+ --platform android --dev false --entry-file index.js --bundle-output
191
+ android/app/src/main/assets/index.android.bundle`) before building.
192
+ - **Keyboard covers the target.** `KEYCODE_BACK` hides it; re-dump before tapping.
193
+ - **BACK follows the back stack.** To close a popup without leaving its
194
+ screen, tap outside it instead.
195
+ - **"System UI isn't responding" after install.** A freshly booted emulator
196
+ under load can raise this for `com.android.systemui`. Run
197
+ `ui.py $SERIAL dismiss-anr`; it taps Wait only for System UI and leaves any
198
+ dialog from the app under test open, because that one is a finding.
199
+ - **Gradle needs the SDK path.** If the build cannot find the SDK, write
200
+ `sdk.dir=$ANDROID_HOME` to `android/local.properties` (or the project root).
201
+
202
+ ## Output
203
+
204
+ Return only this, as a short note:
205
+
206
+ - **outcome**: `completed`, `partial`, or `blocked`;
207
+ - **observations**: runtime (Android version, API, ABI),
208
+ build under test, backend wiring, and what you did in replayable sentences;
209
+ - **findings**: each with severity in words, screen, observed vs expected,
210
+ exact reproduction from a fresh launch, times reproduced out of attempts,
211
+ confidence, and the capture paths that support it;
212
+ - **unverified**: what you could not reach and why, including physical-device
213
+ behavior (camera, push, biometrics, real network) that this runtime cannot
214
+ prove;
215
+ - **capture paths**: recordings, screenshots, and the APK path.
216
+
217
+ Label results "Android emulator (API <n>)". Never
218
+ call them physical-device results.
219
+
220
+ ## Cleanup
221
+
222
+ Stop only what you started: `bash scripts/record.sh $SERIAL stop` if still
223
+ running, `adb -s $SERIAL reverse --remove-all`, and any backend process by
224
+ its PID. Leave the device running for other charters; the session owns it.
@@ -0,0 +1,227 @@
1
+ #!/usr/bin/env bash
2
+ # Attach to or start an Android emulator and prove it is usable. Installs nothing.
3
+ # Usage: android-up.sh [--api <level>] [--no-mirror]
4
+ # Exit 0: ready, prints SERIAL=<serial>. Exit 2: bring-up failed. Exit 3: the image lacks a prerequisite.
5
+ set -uo pipefail
6
+
7
+ API=""
8
+ MIRROR=1
9
+ while [ $# -gt 0 ]; do
10
+ case "$1" in
11
+ --api) API="$2"; shift 2 ;;
12
+ --no-mirror) MIRROR=0; shift ;;
13
+ *) echo "unknown argument: $1" >&2; exit 64 ;;
14
+ esac
15
+ done
16
+
17
+ STATE_DIR=/tmp/alan-android
18
+ MIN_AVAILABLE_MB=3072
19
+ STARTED=0
20
+ mkdir -p "$STATE_DIR"
21
+
22
+ log() { printf '[android-up] %s\n' "$*" >&2; }
23
+ fail() { log "FAILED: $*"; exit 2; }
24
+
25
+ find_sdk() {
26
+ for dir in "${ANDROID_HOME:-}" "${ANDROID_SDK_ROOT:-}" /opt/android-sdk "$HOME/Android/Sdk"; do
27
+ if [ -n "$dir" ] && [ -x "$dir/platform-tools/adb" ]; then echo "$dir"; return 0; fi
28
+ done
29
+ return 1
30
+ }
31
+
32
+ host_arch() { case "$(uname -m)" in aarch64|arm64) echo arm64-v8a ;; *) echo x86_64 ;; esac; }
33
+
34
+ SDK="$(find_sdk || true)"
35
+ ADB="${SDK:+$SDK/platform-tools/adb}"
36
+ [ -z "$ADB" ] && command -v adb >/dev/null 2>&1 && ADB="$(command -v adb)"
37
+ export ADB
38
+
39
+ online_devices() { "$ADB" devices | awk 'NR>1 && $2=="device" {print $1}'; }
40
+
41
+ installed_apis() {
42
+ local arch; arch="$(host_arch)"
43
+ ls -d "$SDK"/system-images/android-*/google_apis/"$arch" 2>/dev/null \
44
+ | sed -E 's#.*/android-([0-9]+)/.*#\1#' | sort -n
45
+ }
46
+
47
+ # Picks the newest installed system image at or below the requested API.
48
+ pick_api() {
49
+ local want="${API:-}" apis best=""
50
+ apis="$(installed_apis)"
51
+ [ -n "$apis" ] || return 1
52
+ [ -z "$want" ] && { echo "$apis" | tail -1; return 0; }
53
+ for api in $apis; do [ "$api" -le "$want" ] && best="$api"; done
54
+ echo "${best:-$(echo "$apis" | head -1)}"
55
+ }
56
+
57
+ # Lists every missing prerequisite at once, split by who can provide it: the repository's
58
+ # environment setup persists the toolchain, while KVM and memory come from the environment.
59
+ preflight() {
60
+ local toolchain=() environment=()
61
+ [ -n "$ADB" ] || toolchain+=("adb (Android platform-tools; set ANDROID_HOME)")
62
+ if [ -z "$SERIAL" ]; then
63
+ { [ -n "$SDK" ] && [ -x "$SDK/emulator/emulator" ]; } || toolchain+=("Android emulator under \$ANDROID_HOME/emulator")
64
+ { [ -n "$SDK" ] && [ -x "$SDK/cmdline-tools/latest/bin/avdmanager" ]; } \
65
+ || toolchain+=("cmdline-tools (avdmanager) under \$ANDROID_HOME/cmdline-tools/latest")
66
+ { [ -n "$SDK" ] && [ -n "$(installed_apis)" ]; } || toolchain+=("a system image: system-images;android-<api>;google_apis;$(host_arch)")
67
+ { [ -n "${JAVA_HOME:-}" ] || command -v java >/dev/null 2>&1; } || toolchain+=("JDK 17 (avdmanager needs Java)")
68
+ if [ ! -e /dev/kvm ]; then
69
+ environment+=("/dev/kvm: this provider cannot run the emulator; native Android needs a Freestyle environment")
70
+ elif [ ! -r /dev/kvm ] || [ ! -w /dev/kvm ]; then
71
+ environment+=("read/write access to /dev/kvm for $(id -un) (currently $(ls -l /dev/kvm | awk '{print $1, $3, $4}'))")
72
+ fi
73
+ # Below this the emulator dies mid-boot or starves the agent's link (measured on an 8 GB VM).
74
+ local available_mb
75
+ available_mb=$(awk '/MemAvailable/ {print int($2 / 1024)}' /proc/meminfo 2>/dev/null)
76
+ if [ -n "$available_mb" ] && [ "$available_mb" -lt "$MIN_AVAILABLE_MB" ]; then
77
+ environment+=("${MIN_AVAILABLE_MB} MB of available memory (have ${available_mb} MB): stop unused services, or pick Extra large in the environment's machine picker")
78
+ fi
79
+ fi
80
+ if [ ${#toolchain[@]} -eq 0 ] && [ ${#environment[@]} -eq 0 ]; then return 0; fi
81
+ log "this sandbox is missing Android prerequisites:"
82
+ if [ ${#toolchain[@]} -gt 0 ]; then
83
+ log " toolchain (persist with /alan-environment-setup maintenance, references/android.md):"
84
+ for item in "${toolchain[@]}"; do log " - $item"; done
85
+ fi
86
+ if [ ${#environment[@]} -gt 0 ]; then
87
+ log " environment (not a repository change):"
88
+ for item in "${environment[@]}"; do log " - $item"; done
89
+ fi
90
+ exit 3
91
+ }
92
+
93
+ wait_boot() {
94
+ local serial="$1" deadline=$((SECONDS + ${2:-300})) pid=""
95
+ [ "$STARTED" -eq 1 ] && pid="$(cat "$STATE_DIR/emulator.pid")"
96
+ while [ $SECONDS -lt $deadline ]; do
97
+ [ "$("$ADB" -s "$serial" shell getprop sys.boot_completed 2>/dev/null | tr -d '\r')" = "1" ] && return 0
98
+ if [ -n "$pid" ] && ! kill -0 "$pid" 2>/dev/null; then
99
+ log "emulator exited during boot; last log lines:"
100
+ tail -15 "$STATE_DIR/emulator.log" >&2
101
+ return 1
102
+ fi
103
+ sleep 3
104
+ done
105
+ return 1
106
+ }
107
+
108
+ # mCurrentFocus can keep a dismissed crash dialog; topResumedActivity is what the user sees.
109
+ resumed_activity() {
110
+ "$ADB" -s "$1" shell dumpsys activity activities 2>/dev/null | grep -m1 -E 'topResumedActivity|mResumedActivity' | tr -d '\r'
111
+ }
112
+
113
+ home_package() {
114
+ "$ADB" -s "$1" shell cmd package resolve-activity --brief -a android.intent.action.MAIN \
115
+ -c android.intent.category.HOME 2>/dev/null | tr -d '\r' | tail -1 | grep / | cut -d/ -f1
116
+ }
117
+
118
+ # First boot passes through FallbackHome and setup activities before the real launcher.
119
+ wait_home() {
120
+ local serial="$1" deadline=$((SECONDS + 120)) focus="" home=""
121
+ "$ADB" -s "$serial" shell input keyevent KEYCODE_WAKEUP >/dev/null 2>&1
122
+ "$ADB" -s "$serial" shell wm dismiss-keyguard >/dev/null 2>&1
123
+ while [ $SECONDS -lt $deadline ]; do
124
+ # Early boot resolves HOME to Settings' FallbackHome; re-resolve until the real launcher owns it.
125
+ home="$(home_package "$serial")"
126
+ focus="$(resumed_activity "$serial")"
127
+ case "$focus" in
128
+ *FallbackHome*) ;;
129
+ *" u0 $home/"*) [ -n "$home" ] && [ "$home" != "android" ] && { echo "$focus"; return 0; } ;;
130
+ esac
131
+ "$ADB" -s "$serial" shell input keyevent KEYCODE_HOME >/dev/null 2>&1
132
+ sleep 3
133
+ done
134
+ echo "$focus"
135
+ return 1
136
+ }
137
+
138
+ start_emulator() {
139
+ local api avd image arch
140
+ api="$(pick_api)" || fail "no system image installed"
141
+ arch="$(host_arch)"
142
+ image="system-images;android-${api};google_apis;${arch}"
143
+ avd="alan-api${api}"
144
+ [ -n "$API" ] && [ "$api" != "$API" ] && log "API $API image not installed; using API $api"
145
+ if ! "$SDK/emulator/emulator" -list-avds 2>/dev/null | grep -qx "$avd"; then
146
+ echo no | "$SDK/cmdline-tools/latest/bin/avdmanager" create avd -n "$avd" -k "$image" -d pixel_6 --force \
147
+ >"$STATE_DIR/avdmanager.log" 2>&1 || fail "avdmanager could not create $avd: $(tail -2 "$STATE_DIR/avdmanager.log")"
148
+ fi
149
+ log "booting emulator $avd (API $api, $arch)"
150
+ nohup "$SDK/emulator/emulator" -avd "$avd" -no-window -no-audio -no-boot-anim -no-snapshot-save \
151
+ -gpu swiftshader_indirect -port 5554 >"$STATE_DIR/emulator.log" 2>&1 &
152
+ echo $! >"$STATE_DIR/emulator.pid"
153
+ STARTED=1
154
+ SERIAL=emulator-5554
155
+ }
156
+
157
+ SERIAL="${ANDROID_SERIAL:-}"
158
+ if [ -z "$SERIAL" ] && [ -n "$ADB" ]; then
159
+ DEVICES="$(online_devices)"
160
+ COUNT=$(printf '%s' "$DEVICES" | grep -c . || true)
161
+ if [ "$COUNT" -eq 1 ]; then
162
+ SERIAL="$DEVICES"
163
+ log "attaching to existing device $SERIAL"
164
+ elif [ "$COUNT" -gt 1 ]; then
165
+ fail "several devices attached ($(echo $DEVICES)); set ANDROID_SERIAL"
166
+ fi
167
+ fi
168
+
169
+ preflight
170
+ [ -n "$SERIAL" ] || start_emulator
171
+
172
+ wait_boot "$SERIAL" 300 || fail "$SERIAL did not finish booting (log: $STATE_DIR/emulator.log)"
173
+ sleep 5
174
+ [ "$("$ADB" -s "$SERIAL" get-state 2>/dev/null)" = "device" ] || fail "$SERIAL went offline after boot"
175
+
176
+ FOCUS="$(wait_home "$SERIAL")" || fail "$SERIAL never reached a usable home screen (focus: $FOCUS)"
177
+ for setting in window_animation_scale transition_animation_scale animator_duration_scale; do
178
+ "$ADB" -s "$SERIAL" shell settings put global "$setting" 0 >/dev/null 2>&1
179
+ done
180
+ "$ADB" -s "$SERIAL" shell svc power stayon true >/dev/null 2>&1
181
+ # A previous charter may have left the device offline or rotated.
182
+ "$ADB" -s "$SERIAL" shell svc wifi enable >/dev/null 2>&1
183
+ "$ADB" -s "$SERIAL" shell svc data enable >/dev/null 2>&1
184
+ "$ADB" -s "$SERIAL" shell settings put system accelerometer_rotation 0 >/dev/null 2>&1
185
+ "$ADB" -s "$SERIAL" shell settings put system user_rotation 0 >/dev/null 2>&1
186
+
187
+ # The launcher reports resumed before its first frame is drawn, so allow it time to paint.
188
+ SHOT="$STATE_DIR/ready.png"
189
+ SHOT_BYTES=0
190
+ SHOT_DEADLINE=$((SECONDS + 60))
191
+ while [ $SECONDS -lt $SHOT_DEADLINE ]; do
192
+ "$ADB" -s "$SERIAL" exec-out screencap -p >"$SHOT" 2>/dev/null
193
+ SHOT_BYTES=$(wc -c <"$SHOT" | tr -d ' ')
194
+ [ "$SHOT_BYTES" -gt 20000 ] && break
195
+ sleep 3
196
+ done
197
+ [ "$SHOT_BYTES" -gt 20000 ] || fail "screenshot is still ${SHOT_BYTES} bytes after 60s; the display is probably black ($SHOT)"
198
+
199
+ if [ "$MIRROR" -eq 1 ]; then
200
+ [ -z "${DISPLAY:-}" ] && [ -S /tmp/.X11-unix/X0 ] && DISPLAY=:0
201
+ MAJOR="$(scrcpy --version 2>/dev/null | awk 'NR==1 {split($2, v, "."); print v[1]+0}')"
202
+ if [ -z "${DISPLAY:-}" ]; then
203
+ log "no X display; live mirror skipped"
204
+ elif [ "${MAJOR:-0}" -lt 2 ]; then
205
+ # scrcpy 1.x renders but cannot inject input on Android 12+.
206
+ log "scrcpy >= 2 not installed; live mirror skipped"
207
+ elif pgrep -f "scrcpy.*-s $SERIAL" >/dev/null; then
208
+ log "live mirror already running on $DISPLAY"
209
+ else
210
+ DISPLAY="$DISPLAY" ADB="$ADB" nohup scrcpy -s "$SERIAL" --no-audio --window-title "Android $SERIAL" \
211
+ --stay-awake --max-size 1200 >"$STATE_DIR/scrcpy.log" 2>&1 &
212
+ echo $! >"$STATE_DIR/scrcpy.pid"
213
+ sleep 3
214
+ if kill -0 "$(cat "$STATE_DIR/scrcpy.pid")" 2>/dev/null; then
215
+ log "live mirror on $DISPLAY"
216
+ else
217
+ log "live mirror failed to start: $(tail -2 "$STATE_DIR/scrcpy.log")"
218
+ fi
219
+ fi
220
+ fi
221
+
222
+ log "ready: $(echo "$FOCUS" | sed 's/.* u0 //;s/ t[0-9]*}.*//;s/}.*//')"
223
+ echo "SERIAL=$SERIAL"
224
+ echo "ANDROID=$("$ADB" -s "$SERIAL" shell getprop ro.build.version.release | tr -d '\r') API=$("$ADB" -s "$SERIAL" shell getprop ro.build.version.sdk | tr -d '\r') ABI=$("$ADB" -s "$SERIAL" shell getprop ro.product.cpu.abi | tr -d '\r')"
225
+ echo "SCREENSHOT=$SHOT"
226
+ echo "ANDROID_HOME=$SDK"
227
+ echo "ADB=$ADB"