@rootnative/loupe 0.0.0-alpha.1 → 0.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -1
- package/README.md +15 -2
- package/dist/bin.js +2 -2
- package/dist/{chunk-JDX6L5K6.js → chunk-HWVQXYQ3.js} +1361 -326
- package/dist/index.d.ts +10 -2
- package/dist/index.js +1 -1
- package/dist/{server-BTS4TOGF.js → server-567FSCAH.js} +2 -2
- package/package.json +1 -1
- package/skills/loupe/SKILL.md +47 -11
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,11 @@ interface ProgressUpdate {
|
|
|
37
37
|
interface CommandContext {
|
|
38
38
|
exec: Exec;
|
|
39
39
|
env: Readonly<Record<string, string | undefined>>;
|
|
40
|
+
/**
|
|
41
|
+
* HTTP to a server on this machine, such as Metro. `createContext` gives
|
|
42
|
+
* `localFetch`, which refuses every other host.
|
|
43
|
+
*/
|
|
44
|
+
fetch: typeof fetch;
|
|
40
45
|
/**
|
|
41
46
|
* Aborts when the caller cancels the call: Ctrl-C in the CLI, or a
|
|
42
47
|
* cancel from the MCP client. A long command stops at its next safe
|
|
@@ -46,7 +51,10 @@ interface CommandContext {
|
|
|
46
51
|
/** Takes the progress of a long command, for the caller to show. */
|
|
47
52
|
progress?: (update: ProgressUpdate) => void;
|
|
48
53
|
}
|
|
49
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* The real context: child processes, the environment of this process, and
|
|
56
|
+
* HTTP to this machine.
|
|
57
|
+
*/
|
|
50
58
|
declare function createContext(): CommandContext;
|
|
51
59
|
|
|
52
60
|
/**
|
|
@@ -143,7 +151,7 @@ declare const displaySchema: z.ZodObject<{
|
|
|
143
151
|
}, z.core.$strip>;
|
|
144
152
|
type DisplayState = z.infer<typeof displaySchema>;
|
|
145
153
|
|
|
146
|
-
declare const ERROR_CODES: readonly ["unknown_command", "invalid_input", "invalid_output", "tool_missing", "tool_failed", "timeout", "no_device", "device_ambiguous", "device_unavailable", "unsupported", "orientation_locked", "app_not_in_front", "not_idle", "element_not_found", "element_ambiguous", "no_handler", "cancelled", "internal"];
|
|
154
|
+
declare const ERROR_CODES: readonly ["unknown_command", "invalid_input", "invalid_output", "tool_missing", "tool_failed", "timeout", "no_device", "device_ambiguous", "device_unavailable", "unsupported", "orientation_locked", "app_not_in_front", "not_idle", "element_not_found", "element_ambiguous", "no_handler", "no_server", "cancelled", "internal"];
|
|
147
155
|
type ErrorCode = (typeof ERROR_CODES)[number];
|
|
148
156
|
/** An error that a caller can act on by its code. */
|
|
149
157
|
declare class LoupeError extends Error {
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
round2,
|
|
7
7
|
runCommand,
|
|
8
8
|
version
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-HWVQXYQ3.js";
|
|
10
10
|
|
|
11
11
|
// src/mcp/server.ts
|
|
12
12
|
import { existsSync } from "fs";
|
|
@@ -103,7 +103,7 @@ var INSTRUCTIONS = [
|
|
|
103
103
|
"loupe checks the layout of a mobile app on an Android emulator or device. Its tools give numbers in dp.",
|
|
104
104
|
"Ask the user before you start an emulator, and before you open an app or a link on a device.",
|
|
105
105
|
"On a real phone, give `app` in each call.",
|
|
106
|
-
"Put back the orientation
|
|
106
|
+
"Put back what you change: the orientation, the theme, and RTL (`expo-rtl off`). A sweep puts back the orientation and the theme itself.",
|
|
107
107
|
"Decide pass or fail with `check` or `sweep`, not from a screenshot alone.",
|
|
108
108
|
"The loupe skill (skills/loupe/SKILL.md in the package) has the workflow, the rules, and what to do for each error code."
|
|
109
109
|
].join(" ");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rootnative/loupe",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.2",
|
|
4
4
|
"description": "loupe by Root Native: layout checks for iOS and Android, built for AI agents. Drive simulators and emulators, and measure every screen to the point.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Root Native",
|
package/skills/loupe/SKILL.md
CHANGED
|
@@ -21,8 +21,9 @@ schema, so this skill doesn't repeat them. loupe works on Android 11
|
|
|
21
21
|
- On a real phone, give `app` in each call. loupe then reads the screen
|
|
22
22
|
only while that app is in front, so it never shows you another app.
|
|
23
23
|
- Don't change a setting that the user didn't ask for. `rotate` and
|
|
24
|
-
`theme` change the device
|
|
25
|
-
|
|
24
|
+
`theme` change the device, and `expo-rtl` changes the app.json of the
|
|
25
|
+
app. Put back what you changed: after `expo-rtl on`, run `expo-rtl off`.
|
|
26
|
+
`sweep` puts the orientation and the theme back itself.
|
|
26
27
|
|
|
27
28
|
## Before the first check
|
|
28
29
|
|
|
@@ -34,6 +35,32 @@ schema, so this skill doesn't repeat them. loupe works on Android 11
|
|
|
34
35
|
4. Run one loupe call at a time on a device. Two touches at the same time
|
|
35
36
|
lose events. The MCP server already runs its calls one after the other.
|
|
36
37
|
|
|
38
|
+
## An app in Expo Go
|
|
39
|
+
|
|
40
|
+
1. The user runs `npx expo start` in the folder of the app. loupe doesn't
|
|
41
|
+
start Metro. Give `port` when Metro doesn't use 8081.
|
|
42
|
+
2. Open the app with `expo-open` and a route, for example `/settings`. It
|
|
43
|
+
warms the bundle, closes Expo Go's onboarding sheet and developer menu,
|
|
44
|
+
and waits until the app shows: on the route when the app has the probe,
|
|
45
|
+
else until the screen has text, a label or a touch and keeps still.
|
|
46
|
+
Then give `app` `host.exp.exponent` in each call. An animation that
|
|
47
|
+
never stops, or a long one, hides a screen from loupe: `expo-open`
|
|
48
|
+
then gives `not_idle`. A link to the root can start the animation
|
|
49
|
+
again, so open another route.
|
|
50
|
+
3. After an edit of the app's code, run `expo-warm`, and compare its
|
|
51
|
+
`sha256` with the one before the edit. The same hash means that Metro
|
|
52
|
+
didn't see the edit. Ask the user to restart Metro with
|
|
53
|
+
`npx expo start --clear`.
|
|
54
|
+
4. To start the app again from a clean state, run `expo-reload`. It stops
|
|
55
|
+
Expo Go and opens the app again, on the route that the probe shows.
|
|
56
|
+
With no probe, it opens the root: give `route` for another screen.
|
|
57
|
+
Run it also after a Metro restart or a new package: until then, Expo Go
|
|
58
|
+
keeps the old JavaScript.
|
|
59
|
+
5. To see the app in RTL, run `expo-rtl on`. It writes `supportsRTL` and
|
|
60
|
+
`forcesRTL` in the app's app.json, keeps the file as it was, and opens
|
|
61
|
+
the app again in RTL. When you're done, run `expo-rtl off`: it puts
|
|
62
|
+
app.json back.
|
|
63
|
+
|
|
37
64
|
## Units
|
|
38
65
|
|
|
39
66
|
- Each position and size is in dp, from the top-left corner of the
|
|
@@ -43,9 +70,9 @@ schema, so this skill doesn't repeat them. loupe works on Android 11
|
|
|
43
70
|
|
|
44
71
|
## Check one screen
|
|
45
72
|
|
|
46
|
-
1. Open the screen with `open-url` and its deep link
|
|
47
|
-
text on that screen) or `waitStill`, so
|
|
48
|
-
there.
|
|
73
|
+
1. Open the screen with `open-url` and its deep link (in Expo Go, with
|
|
74
|
+
`expo-open`). Give `waitText` (a text on that screen) or `waitStill`, so
|
|
75
|
+
the call ends when the screen is there.
|
|
49
76
|
2. Run `check`. Read `passed`, then the findings of each rule that failed.
|
|
50
77
|
3. Run `rotate` with `landscape-left`, then `check` again.
|
|
51
78
|
4. Run `rotate` with `landscape-right`, then `check` again. A cutout on one
|
|
@@ -61,7 +88,13 @@ Take a `screenshot` when you want to see the screen, but decide with
|
|
|
61
88
|
Give `sweep` one `url` for each screen. Add `orientation`
|
|
62
89
|
(`portrait,landscape-left`) and `theme` (`light,dark`) to check each
|
|
63
90
|
screen in each of them. Add `scroll` to check each screen again after one
|
|
64
|
-
scroll down.
|
|
91
|
+
scroll down. For a long list, add `reloadEvery` (for example 10) with
|
|
92
|
+
`app`: loupe stops the app before each 10th link, so stacked screens
|
|
93
|
+
don't slow it down. A restarted screen has `reloaded` in the report. In
|
|
94
|
+
Expo Go, add `direction` (`ltr,rtl`) to check each screen in both layout
|
|
95
|
+
directions. loupe sets each direction once, in app.json, and puts app.json
|
|
96
|
+
back at the end. Each variant name then ends with its direction:
|
|
97
|
+
`portrait-light-rtl`.
|
|
65
98
|
|
|
66
99
|
- The result lists each screen that failed, with each finding and its
|
|
67
100
|
numbers. You don't need to check those screens again.
|
|
@@ -91,8 +124,10 @@ fewer.
|
|
|
91
124
|
To check `mirrored`:
|
|
92
125
|
|
|
93
126
|
1. Show the screen in LTR. Run `ui` with `out` set to a file.
|
|
94
|
-
2. Show the same screen in RTL, in the same orientation.
|
|
127
|
+
2. Show the same screen in RTL, in the same orientation. In Expo Go, run
|
|
128
|
+
`expo-rtl on` with the route of the screen.
|
|
95
129
|
3. Run `check` with `mirrorOf` set to that file.
|
|
130
|
+
4. In Expo Go, run `expo-rtl off` when you're done.
|
|
96
131
|
|
|
97
132
|
## Read a result
|
|
98
133
|
|
|
@@ -123,16 +158,17 @@ to do. The codes:
|
|
|
123
158
|
| `device_ambiguous` | Run `devices`, then give `device`. |
|
|
124
159
|
| `device_unavailable` | The device is offline, not authorized, or still booting. Wait, or ask the user. |
|
|
125
160
|
| `tool_missing` | loupe can't find adb. Ask the user to set `ANDROID_HOME`. |
|
|
126
|
-
| `tool_failed` | adb failed. Read the message. |
|
|
161
|
+
| `tool_failed` | adb or Metro failed. Read the message: for a bundle, it gives Metro's error. |
|
|
127
162
|
| `app_not_in_front` | Another app or a dialog is in front. Run `dismiss` for a dialog or a sheet, or `foreground` for the app. |
|
|
128
|
-
| `not_idle` | The screen didn't keep still long enough to read it. Run `wait` with `still`, then try again. |
|
|
163
|
+
| `not_idle` | The screen didn't keep still long enough to read it. Run `wait` with `still`, then try again. An animation that never stops, or a long one, keeps a screen from loupe: take a screenshot, wait until it ends, or open another route. |
|
|
129
164
|
| `element_not_found` | Run `ui`, find the element, and give its exact text, label, or id. |
|
|
130
165
|
| `element_ambiguous` | More than one element matches. Give its `id`. |
|
|
131
166
|
| `orientation_locked` | The app sets its own orientation. Check the orientations it allows. |
|
|
132
167
|
| `timeout` | The screen didn't get there in time. The message says whether the action ran. |
|
|
133
|
-
| `no_handler` | No app on the device opens that link. |
|
|
168
|
+
| `no_handler` | No app on the device opens that link. With no Expo Go, ask the user to install it: press "a" in `npx expo start`. |
|
|
169
|
+
| `no_server` | Nothing answers on the port, or it isn't Metro. Ask the user to run `npx expo start`, or give `port`. |
|
|
134
170
|
| `invalid_input` | Fix the input. The message names the field. |
|
|
135
|
-
| `unsupported` | loupe can't do this on this device or API level. |
|
|
171
|
+
| `unsupported` | loupe can't do this on this device or API level, or with this server. The message says why. |
|
|
136
172
|
| `cancelled` | The call was cancelled. loupe stopped at a safe point. |
|
|
137
173
|
|
|
138
174
|
## The CLI
|