lynkeus 0.3.0 → 0.5.0
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/lib/cases/coverage.d.ts +31 -0
- package/lib/cases/coverage.js +82 -0
- package/lib/cases/draft.d.ts +21 -0
- package/lib/cases/draft.js +53 -0
- package/lib/cases/fixtures.d.ts +11 -0
- package/lib/cases/fixtures.js +59 -8
- package/lib/cases/frames.d.ts +6 -0
- package/lib/cases/frames.js +28 -0
- package/lib/cases/nativeLogs.d.ts +14 -0
- package/lib/cases/nativeLogs.js +111 -0
- package/lib/cases/runDirs.d.ts +13 -0
- package/lib/cases/runDirs.js +48 -0
- package/lib/cases/runfile.d.ts +5 -1
- package/lib/cases/runfile.js +67 -4
- package/lib/cases/runner.d.ts +58 -1
- package/lib/cases/runner.js +322 -39
- package/lib/cases/templates.d.ts +2 -2
- package/lib/cases/templates.js +20 -2
- package/lib/cases/traces.js +4 -1
- package/lib/cli.js +27 -4
- package/lib/commands/cases.d.ts +8 -0
- package/lib/commands/cases.js +154 -25
- package/lib/commands/ci.d.ts +13 -0
- package/lib/commands/ci.js +184 -0
- package/lib/commands/coverage.d.ts +1 -0
- package/lib/commands/coverage.js +151 -0
- package/lib/commands/device.js +32 -2
- package/lib/commands/doctor.js +8 -2
- package/lib/commands/drive.js +3 -1
- package/lib/commands/fixtures.d.ts +7 -0
- package/lib/commands/fixtures.js +94 -0
- package/lib/commands/headless.d.ts +11 -0
- package/lib/commands/headless.js +189 -9
- package/lib/commands/init.d.ts +23 -0
- package/lib/commands/init.js +231 -26
- package/lib/commands/map.d.ts +2 -0
- package/lib/commands/map.js +18 -14
- package/lib/commands/os.js +43 -10
- package/lib/commands/report.d.ts +4 -0
- package/lib/commands/report.js +156 -20
- package/lib/config.d.ts +41 -0
- package/lib/config.js +30 -0
- package/lib/device/agentVersion.d.ts +7 -0
- package/lib/device/agentVersion.js +14 -0
- package/lib/device/devices.js +6 -0
- package/lib/device/driver.js +2 -2
- package/lib/knowledge/analyticsTraffic.d.ts +10 -0
- package/lib/knowledge/analyticsTraffic.js +109 -0
- package/lib/knowledge/errors.js +6 -0
- package/lib/knowledge/events.d.ts +2 -0
- package/lib/knowledge/why.d.ts +2 -0
- package/lib/knowledge/why.js +1 -1
- package/lib/mcp/server.js +45 -4
- package/lib/runtime.d.ts +9 -1
- package/lib/runtime.js +25 -3
- package/package.json +7 -4
- package/src/cases/coverage.ts +99 -0
- package/src/cases/draft.ts +75 -0
- package/src/cases/fixtures.ts +57 -8
- package/src/cases/frames.ts +30 -0
- package/src/cases/nativeLogs.ts +112 -0
- package/src/cases/runDirs.ts +48 -0
- package/src/cases/runfile.ts +64 -4
- package/src/cases/runner.ts +372 -42
- package/src/cases/templates.ts +20 -2
- package/src/cases/traces.ts +3 -1
- package/src/cli.ts +27 -4
- package/src/commands/cases.ts +165 -23
- package/src/commands/ci.ts +189 -0
- package/src/commands/coverage.ts +147 -0
- package/src/commands/device.ts +27 -2
- package/src/commands/doctor.ts +9 -2
- package/src/commands/drive.ts +3 -1
- package/src/commands/fixtures.ts +102 -0
- package/src/commands/headless.ts +197 -9
- package/src/commands/init.ts +270 -26
- package/src/commands/map.ts +20 -15
- package/src/commands/os.ts +38 -10
- package/src/commands/report.ts +162 -18
- package/src/config.ts +48 -0
- package/src/device/agentVersion.ts +17 -0
- package/src/device/devices.ts +5 -0
- package/src/device/driver.ts +2 -2
- package/src/knowledge/analyticsTraffic.ts +142 -0
- package/src/knowledge/errors.ts +6 -0
- package/src/knowledge/events.ts +2 -1
- package/src/knowledge/why.ts +3 -1
- package/src/mcp/server.ts +45 -4
- package/src/runtime.ts +24 -3
package/src/runtime.ts
CHANGED
|
@@ -11,18 +11,38 @@ import { type Expected, expectedOf } from './targets.js';
|
|
|
11
11
|
export type Outcome = { text?: string; json?: unknown; code: number; error?: string; why?: string };
|
|
12
12
|
|
|
13
13
|
/** The screen, requests and trace after a failure, read as rules; empty when there is nothing to read. */
|
|
14
|
-
export const whyFor = async (base: Base, expected?: Expected): Promise<string> => {
|
|
14
|
+
export const whyFor = async (base: Base, expected?: Expected, startedAt?: number): Promise<string> => {
|
|
15
15
|
try {
|
|
16
16
|
const device = await base.device();
|
|
17
17
|
const [screen, requests, trace] = await Promise.all([device.screen(), device.requests(), device.trace()]);
|
|
18
|
+
const during = duringCommand(requests.requests, startedAt);
|
|
18
19
|
return describeWhy(
|
|
19
|
-
explain({
|
|
20
|
+
explain({
|
|
21
|
+
screen,
|
|
22
|
+
requests: during.slice(-40),
|
|
23
|
+
inFlight: requests.inFlight,
|
|
24
|
+
trace: trace.events.slice(-40),
|
|
25
|
+
target: expected,
|
|
26
|
+
fetchedBefore: during.length < requests.requests.length,
|
|
27
|
+
}),
|
|
20
28
|
);
|
|
21
29
|
} catch {
|
|
22
30
|
return '';
|
|
23
31
|
}
|
|
24
32
|
};
|
|
25
33
|
|
|
34
|
+
/**
|
|
35
|
+
* The requests made while the failed command ran, and a little before: a 403 from minutes ago is not why a wait
|
|
36
|
+
* failed now. Only when the app's clock reads like this machine's (a simulator, an emulator); a host on a clock of
|
|
37
|
+
* its own keeps them all.
|
|
38
|
+
*/
|
|
39
|
+
export const duringCommand = <R extends { startedAt: number }>(requests: R[], startedAt: number | undefined, now = Date.now()): R[] => {
|
|
40
|
+
if (startedAt === undefined || requests.length === 0) return requests;
|
|
41
|
+
const latest = Math.max(...requests.map((r) => r.startedAt));
|
|
42
|
+
if (Math.abs(latest - now) > 10 * 60_000) return requests;
|
|
43
|
+
return requests.filter((r) => r.startedAt >= startedAt - 3000);
|
|
44
|
+
};
|
|
45
|
+
|
|
26
46
|
const TARGET_ARG: Record<string, number> = { press: 0, see: 0, wait: 0, swipe: 1, nav: 0, type: 1 };
|
|
27
47
|
|
|
28
48
|
export const execute = async (argv: string[], base: Base): Promise<Outcome> => {
|
|
@@ -37,6 +57,7 @@ export const execute = async (argv: string[], base: Base): Promise<Outcome> => {
|
|
|
37
57
|
throw error;
|
|
38
58
|
}
|
|
39
59
|
if (parsed.flags.help) return { code: 0, text: helpFor(command) };
|
|
60
|
+
const startedAt = Date.now();
|
|
40
61
|
try {
|
|
41
62
|
const result = await command.run({ ...base, ...parsed });
|
|
42
63
|
if (result === undefined) return { code: 0 };
|
|
@@ -46,7 +67,7 @@ export const execute = async (argv: string[], base: Base): Promise<Outcome> => {
|
|
|
46
67
|
const out: Outcome = { code: 1, error: error instanceof Error ? error.message : String(error) };
|
|
47
68
|
const at = TARGET_ARG[command.name];
|
|
48
69
|
if (at !== undefined) {
|
|
49
|
-
const why = await whyFor(base, expectedOf(parsed.args[at]));
|
|
70
|
+
const why = await whyFor(base, expectedOf(parsed.args[at]), startedAt);
|
|
50
71
|
if (why) out.why = why;
|
|
51
72
|
}
|
|
52
73
|
return out;
|