@rootnative/loupe 0.0.0-alpha.3 → 0.0.0-alpha.4

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/dist/index.d.ts CHANGED
@@ -23,6 +23,24 @@ interface ExecResult {
23
23
  * the caller decides what it means.
24
24
  */
25
25
  type Exec = (file: string, args: readonly string[], options?: ExecOptions) => Promise<ExecResult>;
26
+ /** A tool that keeps running after the command that started it. */
27
+ interface DetachedRun {
28
+ pid: number;
29
+ /** The exit code (null for a signal) when the tool ended; else undefined. */
30
+ exitCode(): number | null | undefined;
31
+ kill(): void;
32
+ }
33
+ interface DetachedOptions {
34
+ /** Added to the environment of this process. */
35
+ env: Readonly<Record<string, string>>;
36
+ /** The tool writes its output here. An old file is replaced. */
37
+ logFile: string;
38
+ }
39
+ /**
40
+ * Starts a tool with no shell that lives on when this process ends. It
41
+ * fails with `tool_missing` when the tool doesn't exist.
42
+ */
43
+ type SpawnDetached = (file: string, args: readonly string[], options: DetachedOptions) => Promise<DetachedRun>;
26
44
 
27
45
  /** How far a long command is. `progress` grows with each update. */
28
46
  interface ProgressUpdate {
@@ -36,6 +54,8 @@ interface ProgressUpdate {
36
54
  */
37
55
  interface CommandContext {
38
56
  exec: Exec;
57
+ /** Starts a tool that stays after the command: the iOS runner. */
58
+ spawnDetached: SpawnDetached;
39
59
  env: Readonly<Record<string, string | undefined>>;
40
60
  /**
41
61
  * HTTP to a server on this machine, such as Metro. `createContext` gives
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  toPixels,
19
19
  unitOf,
20
20
  version
21
- } from "./chunk-7ALG5744.js";
21
+ } from "./chunk-ROE4FVE2.js";
22
22
  export {
23
23
  ERROR_CODES,
24
24
  LoupeError,
@@ -2,16 +2,15 @@ import {
2
2
  createContext,
3
3
  inputJsonSchema,
4
4
  outputJsonSchema,
5
+ packageFolder,
5
6
  registry,
6
7
  round2,
7
8
  runCommand,
8
9
  version
9
- } from "./chunk-7ALG5744.js";
10
+ } from "./chunk-ROE4FVE2.js";
10
11
 
11
12
  // src/mcp/server.ts
12
- import { existsSync } from "fs";
13
13
  import path from "path";
14
- import { fileURLToPath } from "url";
15
14
  import {
16
15
  McpServer,
17
16
  ProtocolError,
@@ -102,7 +101,7 @@ function toolResult(result) {
102
101
  var INSTRUCTIONS = [
103
102
  "loupe checks the layout of a mobile app on an Android emulator or device. Its tools give numbers in dp.",
104
103
  "Ask the user before you start an emulator, and before you open an app or a link on a device.",
105
- "On a real phone, give `app` in each call.",
104
+ "On a real phone and on an iOS simulator, give `app` in each call.",
106
105
  "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
106
  "Decide pass or fail with `check` or `sweep`, not from a screenshot alone.",
108
107
  "The loupe skill (skills/loupe/SKILL.md in the package) has the workflow, the rules, and what to do for each error code."
@@ -116,15 +115,7 @@ function serial() {
116
115
  };
117
116
  }
118
117
  function skillsFolder() {
119
- let dir = path.dirname(fileURLToPath(import.meta.url));
120
- for (; ; ) {
121
- if (existsSync(path.join(dir, "package.json"))) {
122
- return path.join(dir, "skills");
123
- }
124
- const up = path.dirname(dir);
125
- if (up === dir) throw new Error("loupe can't find its package folder.");
126
- dir = up;
127
- }
118
+ return path.join(packageFolder(), "skills");
128
119
  }
129
120
  function createMcpServer(registry2, context, { oneAtATime = serial(), skills } = {}) {
130
121
  const tools = toolsOf(registry2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rootnative/loupe",
3
- "version": "0.0.0-alpha.3",
3
+ "version": "0.0.0-alpha.4",
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",
@@ -29,11 +29,20 @@ schema, so this skill doesn't repeat them. loupe works on Android 11
29
29
 
30
30
  1. Run `devices`. Only a device in the state `ready` takes commands.
31
31
  2. When two or more devices are ready, give `device` in each call: the
32
- serial or the AVD name of an Android device. loupe lists the iOS
33
- simulators, but it doesn't drive one yet: a command on a simulator
34
- gives `unsupported`.
32
+ serial or the AVD name of an Android device. On an iOS simulator (its
33
+ UDID or its name), each command works but `pinch` and `drag --shot`,
34
+ which give `unsupported`. The first command on a simulator starts
35
+ loupe's runner there, which can take more than 5 minutes on a busy Mac.
36
+ loupe waits up to 10 minutes for it. `insets` on iOS reads only the
37
+ app's probe. In the iOS tree, a static text has its words in `text`,
38
+ `id` is the testID, and a touchable view with no role (a plain
39
+ `Pressable`) isn't `clickable`. On iOS, `dismiss` closes an alert only
40
+ with a button that cancels it (Cancel, Close, Not Now, Don’t Allow), and
41
+ stops at the keyboard.
35
42
  3. Give `app` in each call that reads or touches the screen. For Expo Go,
36
- it's `host.exp.exponent`.
43
+ it's `host.exp.exponent` on Android and `host.exp.Exponent` on iOS. On
44
+ an iOS simulator, loupe needs it, and `com.apple.springboard` is the
45
+ home screen: loupe reads the orientation of the screen from that app.
37
46
  4. Run one loupe call at a time on a device. Two touches at the same time
38
47
  lose events. The MCP server already runs its calls one after the other.
39
48
 
@@ -45,10 +54,11 @@ schema, so this skill doesn't repeat them. loupe works on Android 11
45
54
  warms the bundle, closes Expo Go's onboarding sheet and developer menu,
46
55
  and waits until the app shows: on the route when the app has the probe,
47
56
  else until the screen has text, a label or a touch and keeps still.
48
- Then give `app` `host.exp.exponent` in each call. An animation that
49
- never stops, or a long one, hides a screen from loupe: `expo-open`
50
- then gives `not_idle`. A link to the root can start the animation
51
- again, so open another route.
57
+ On iOS it also answers the "Open in “Expo Go”?" of iOS with Open.
58
+ Then give `app` in each call: `host.exp.exponent` on Android,
59
+ `host.exp.Exponent` on iOS. An animation that never stops, or a long
60
+ one, hides a screen from loupe: `expo-open` then gives `not_idle`. A
61
+ link to the root can start the animation again, so open another route.
52
62
  3. After an edit of the app's code, run `expo-warm`, and compare its
53
63
  `sha256` with the one before the edit. The same hash means that Metro
54
64
  didn't see the edit. Ask the user to restart Metro with
@@ -117,10 +127,10 @@ fewer.
117
127
 
118
128
  | Rule | Fails when | What to look at |
119
129
  |---|---|---|
120
- | `inset` | An element with text, a label, or a touch sits under a system bar or the cutout, or outside the safe area. | The edge in the finding. In landscape, the left and the right insets can differ. A full-screen scrim doesn't count. |
130
+ | `inset` | An element with text, a label, or a touch sits under a system bar or the cutout, or outside the safe area. | The edge in the finding. In landscape, the left and the right insets can differ. A full-screen scrim doesn't count. On iOS it runs only with the probe: with none, it gives a warning and no findings. |
121
131
  | `overflow` | An element at a screen edge is shorter than the elements like it in its row or column: the edge cuts it. | The row or the column of the element. Let it wrap or scroll, or make its items smaller. |
122
132
  | `centred` | A text with an element on each side is more than 4 dp from the centre of its container. | Centre the text in the whole bar, not in the space between the side items. Name a text with `centred`, `centredLabel`, or `centredId` to check it. |
123
- | `touch-target` | An element that you can press is smaller than 48 × 48 dp. | From 40 dp, loupe gives a warning, not a finding: the tree doesn't show `hitSlop`. Look in the code for a `hitSlop` that makes it 48 dp. |
133
+ | `touch-target` | An element that you can press is smaller than 48 × 48 dp (44 × 44 pt on iOS). | From 40 dp, loupe gives a warning, not a finding: the tree doesn't show `hitSlop`. Look in the code for a `hitSlop` that makes it 48 dp. |
124
134
  | `mirrored` | In RTL, an element sits where LTR puts it. | It runs only with `mirrorOf` (see below). |
125
135
 
126
136
  To check `mirrored`: