spana-test 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/.agents/skills/spana-testing/SKILL.md +0 -0
- package/LICENSE +0 -0
- package/README.md +199 -68
- package/dist/{accessibility-audit-RS3VIWRT.js → accessibility-audit-YZOPUY3D.js} +7 -3
- package/dist/accessibility-audit-YZOPUY3D.js.map +1 -0
- package/dist/agent/index.d.ts +3 -84
- package/dist/agent/index.js +12 -11
- package/dist/agent/index.js.map +0 -0
- package/dist/allure-RNMEYTXS.js +0 -0
- package/dist/allure-RNMEYTXS.js.map +0 -0
- package/dist/{android-PAPJJWVN.js → android-4NVTZMHL.js} +20 -2
- package/dist/{android-PAPJJWVN.js.map → android-4NVTZMHL.js.map} +0 -0
- package/dist/appium-server-66GVUL24.js +0 -0
- package/dist/appium-server-66GVUL24.js.map +0 -0
- package/dist/baseline-manager-5TIUCNP5.js +0 -0
- package/dist/baseline-manager-5TIUCNP5.js.map +0 -0
- package/dist/chunk-3FSZNKEF.js +0 -0
- package/dist/chunk-3FSZNKEF.js.map +0 -0
- package/dist/chunk-3TRMQCUT.js +0 -0
- package/dist/chunk-3TRMQCUT.js.map +0 -0
- package/dist/chunk-3YE2POGD.js +471 -0
- package/dist/chunk-3YE2POGD.js.map +1 -0
- package/dist/chunk-5245YBLL.js +0 -0
- package/dist/chunk-5245YBLL.js.map +0 -0
- package/dist/{chunk-3J4NG7JU.js → chunk-CY3DKTBZ.js} +8 -2
- package/dist/chunk-CY3DKTBZ.js.map +1 -0
- package/dist/chunk-DGUM43GV.js +0 -0
- package/dist/chunk-DGUM43GV.js.map +0 -0
- package/dist/chunk-DTNK54C2.js +127 -0
- package/dist/chunk-DTNK54C2.js.map +1 -0
- package/dist/{chunk-GZK22EIE.js → chunk-H27IBIGA.js} +71 -1
- package/dist/chunk-H27IBIGA.js.map +1 -0
- package/dist/chunk-H3RWZCID.js +439 -0
- package/dist/chunk-H3RWZCID.js.map +1 -0
- package/dist/{chunk-DSTUWLSW.js → chunk-HCG4CJKR.js} +24 -6
- package/dist/chunk-HCG4CJKR.js.map +1 -0
- package/dist/{chunk-QPIE3IMG.js → chunk-HYSTRWYN.js} +143 -42
- package/dist/chunk-HYSTRWYN.js.map +1 -0
- package/dist/chunk-IHVZKQQW.js +0 -0
- package/dist/chunk-IHVZKQQW.js.map +0 -0
- package/dist/chunk-KJPHH2TW.js +0 -0
- package/dist/chunk-KJPHH2TW.js.map +0 -0
- package/dist/chunk-LAMTF4LX.js +89 -0
- package/dist/chunk-LAMTF4LX.js.map +1 -0
- package/dist/chunk-LRGT342X.js +2300 -0
- package/dist/chunk-LRGT342X.js.map +1 -0
- package/dist/chunk-OBCFACUW.js +0 -0
- package/dist/chunk-OBCFACUW.js.map +0 -0
- package/dist/chunk-PJKIXVSO.js +5019 -0
- package/dist/chunk-PJKIXVSO.js.map +1 -0
- package/dist/{chunk-4OHBO7LD.js → chunk-S5JNNDXS.js} +44 -1
- package/dist/{chunk-4OHBO7LD.js.map → chunk-S5JNNDXS.js.map} +1 -1
- package/dist/{chunk-7VOWF42B.js → chunk-SQL3YRR5.js} +74 -8
- package/dist/chunk-SQL3YRR5.js.map +1 -0
- package/dist/{chunk-7IA2XG3G.js → chunk-UJQ7PID5.js} +47 -15
- package/dist/chunk-UJQ7PID5.js.map +1 -0
- package/dist/{chunk-FJAJ4YNC.js → chunk-WSA5QPTA.js} +2 -2
- package/dist/{chunk-FJAJ4YNC.js.map → chunk-WSA5QPTA.js.map} +0 -0
- package/dist/chunk-X2TJP7LB.js +0 -0
- package/dist/chunk-X2TJP7LB.js.map +0 -0
- package/dist/chunk-XENRC3YO.js +2486 -0
- package/dist/chunk-XENRC3YO.js.map +1 -0
- package/dist/cli.js +60 -20
- package/dist/cli.js.map +1 -1
- package/dist/compiler-X6WTFMYF.js +0 -0
- package/dist/compiler-X6WTFMYF.js.map +0 -0
- package/dist/config-loader-XGDDJGVY.js +9 -0
- package/dist/{config-loader-QM72GKEL.js.map → config-loader-XGDDJGVY.js.map} +0 -0
- package/dist/{console-7UW7VROK.js → console-MI2XB5RG.js} +8 -2
- package/dist/console-MI2XB5RG.js.map +1 -0
- package/dist/daemon-manager-FBISTX24.js +28 -0
- package/dist/{discover-NPNF6SWQ.js.map → daemon-manager-FBISTX24.js.map} +0 -0
- package/dist/{discover-NPNF6SWQ.js → discover-LHEBSUIP.js} +4 -4
- package/dist/{installer-W5DITECS.js.map → discover-LHEBSUIP.js.map} +0 -0
- package/dist/doctor-command-WB3O2H64.js +378 -0
- package/dist/doctor-command-WB3O2H64.js.map +1 -0
- package/dist/filters-Q3ALKWZ5.js +24 -0
- package/dist/{ios-3GRECXAP.js.map → filters-Q3ALKWZ5.js.map} +0 -0
- package/dist/{flow-CW0_j7tw.d.ts → flow-CyRC-tTc.d.ts} +37 -7
- package/dist/gherkin/steps.d.ts +2 -2
- package/dist/gherkin/steps.js +0 -0
- package/dist/gherkin/steps.js.map +0 -0
- package/dist/github-pr-YMWIPCCZ.js +10 -0
- package/dist/{session-3UZ5WAAD.js.map → github-pr-YMWIPCCZ.js.map} +0 -0
- package/dist/html-F3X3XPSX.js +0 -0
- package/dist/html-F3X3XPSX.js.map +0 -0
- package/dist/index.d.ts +1129 -6
- package/dist/index.js +575 -6
- package/dist/index.js.map +1 -1
- package/dist/{init-command-U66XCM66.js → init-command-Z3QREABL.js} +60 -1
- package/dist/init-command-Z3QREABL.js.map +1 -0
- package/dist/{init-flow-command-PR7J5FBM.js → init-flow-command-4EKRVTNT.js} +2 -2
- package/dist/{init-flow-command-PR7J5FBM.js.map → init-flow-command-4EKRVTNT.js.map} +0 -0
- package/dist/{installer-W5DITECS.js → installer-VUPFWP5X.js} +7 -2
- package/dist/installer-VUPFWP5X.js.map +1 -0
- package/dist/{ios-3GRECXAP.js → ios-JPK43TFZ.js} +10 -2
- package/dist/ios-JPK43TFZ.js.map +1 -0
- package/dist/json-JMRPUVY2.js +0 -0
- package/dist/json-JMRPUVY2.js.map +0 -0
- package/dist/junit-HLC62MK6.js +0 -0
- package/dist/junit-HLC62MK6.js.map +0 -0
- package/dist/machine-6H25TRTU.js +0 -0
- package/dist/machine-6H25TRTU.js.map +0 -0
- package/dist/provider-YIPU5K42.js +0 -0
- package/dist/provider-YIPU5K42.js.map +0 -0
- package/dist/redact-U72BUBBR.js +0 -0
- package/dist/redact-U72BUBBR.js.map +0 -0
- package/dist/runner-6HK62Q7B.js +0 -0
- package/dist/runner-6HK62Q7B.js.map +0 -0
- package/dist/screenshot-compare-3QRHHSFZ.js +116 -0
- package/dist/screenshot-compare-3QRHHSFZ.js.map +1 -0
- package/dist/{server-MZERO364.js → server-PRM7BVVD.js} +14 -13
- package/dist/{server-MZERO364.js.map → server-PRM7BVVD.js.map} +1 -1
- package/dist/server-QWJJB3WG.js +14 -0
- package/dist/server-QWJJB3WG.js.map +1 -0
- package/dist/session-2E6OK6BH.js +18 -0
- package/dist/session-2E6OK6BH.js.map +1 -0
- package/dist/session-Ddem-Q5n.d.ts +119 -0
- package/dist/{storybook-BK2JE4ld.d.ts → storybook-CxaP3YDz.d.ts} +271 -6
- package/dist/{studio-command-5BUER2RH.js → studio-command-O3NN5BCG.js} +2 -2
- package/dist/{studio-command-5BUER2RH.js.map → studio-command-O3NN5BCG.js.map} +0 -0
- package/dist/{test-command-2PXTHASW.js → test-command-FYOZ6QAE.js} +275 -1314
- package/dist/test-command-FYOZ6QAE.js.map +1 -0
- package/dist/validator-HZ2A3NEI.js +0 -0
- package/dist/validator-HZ2A3NEI.js.map +0 -0
- package/package.json +7 -3
- package/studio-dist/assets/index-C-Io44gy.js +0 -0
- package/studio-dist/assets/index-DfM9lK4p.css +0 -0
- package/studio-dist/index.html +0 -0
- package/dist/accessibility-audit-RS3VIWRT.js.map +0 -1
- package/dist/chunk-24KSKK2I.js +0 -1289
- package/dist/chunk-24KSKK2I.js.map +0 -1
- package/dist/chunk-3J4NG7JU.js.map +0 -1
- package/dist/chunk-7IA2XG3G.js.map +0 -1
- package/dist/chunk-7VOWF42B.js.map +0 -1
- package/dist/chunk-DSTUWLSW.js.map +0 -1
- package/dist/chunk-GZK22EIE.js.map +0 -1
- package/dist/chunk-KAKHFSVA.js +0 -2580
- package/dist/chunk-KAKHFSVA.js.map +0 -1
- package/dist/chunk-QPIE3IMG.js.map +0 -1
- package/dist/chunk-YXQEPVEW.js +0 -372
- package/dist/chunk-YXQEPVEW.js.map +0 -1
- package/dist/config-loader-QM72GKEL.js +0 -9
- package/dist/console-7UW7VROK.js.map +0 -1
- package/dist/doctor-command-C3SEQGRQ.js +0 -71
- package/dist/doctor-command-C3SEQGRQ.js.map +0 -1
- package/dist/element-DZ0HyJ3C.d.ts +0 -25
- package/dist/init-command-U66XCM66.js.map +0 -1
- package/dist/screenshot-compare-JFHH2WR4.js +0 -75
- package/dist/screenshot-compare-JFHH2WR4.js.map +0 -1
- package/dist/session-3UZ5WAAD.js +0 -17
- package/dist/test-command-2PXTHASW.js.map +0 -1
|
File without changes
|
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
// src/core/filters.ts
|
|
2
|
+
import { execFileSync } from "child_process";
|
|
3
|
+
import { readFileSync, existsSync } from "fs";
|
|
4
|
+
import { basename, relative, resolve } from "path";
|
|
5
|
+
var DEFAULT_LOCKFILES = /* @__PURE__ */ new Set([
|
|
6
|
+
"bun.lock",
|
|
7
|
+
"bun.lockb",
|
|
8
|
+
"package.json",
|
|
9
|
+
"package-lock.json",
|
|
10
|
+
"pnpm-lock.yaml",
|
|
11
|
+
"yarn.lock"
|
|
12
|
+
]);
|
|
13
|
+
var DEFAULT_MAX_DIFF_BYTES = 60 * 1024;
|
|
14
|
+
function normalizePath(p) {
|
|
15
|
+
return p.replaceAll("\\", "/").replace(/^\.\//, "");
|
|
16
|
+
}
|
|
17
|
+
function isConfigOrLockfile(filePath, configPath) {
|
|
18
|
+
const norm = normalizePath(filePath);
|
|
19
|
+
const name = basename(norm);
|
|
20
|
+
if (DEFAULT_LOCKFILES.has(name)) return true;
|
|
21
|
+
if (/^spana\.config(\.[^.]+)?\.(ts|mts|js|mjs|cjs)$/.test(name)) return true;
|
|
22
|
+
if (configPath && normalizePath(configPath).endsWith(norm)) return true;
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
function collectGitChanges(baseRef, cwd = process.cwd(), maxDiffBytes = DEFAULT_MAX_DIFF_BYTES, runGit) {
|
|
26
|
+
const execGit = runGit ?? ((args, workdir) => execFileSync("git", args, {
|
|
27
|
+
cwd: workdir,
|
|
28
|
+
encoding: "utf-8",
|
|
29
|
+
maxBuffer: 16 * 1024 * 1024,
|
|
30
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
31
|
+
}));
|
|
32
|
+
let mergeBase;
|
|
33
|
+
try {
|
|
34
|
+
mergeBase = execGit(["merge-base", baseRef, "HEAD"], cwd).trim() || void 0;
|
|
35
|
+
} catch {
|
|
36
|
+
mergeBase = void 0;
|
|
37
|
+
}
|
|
38
|
+
const diffRange = mergeBase ? `${mergeBase}...HEAD` : baseRef;
|
|
39
|
+
const nameStatusRaw = execGit(["diff", "--name-status", diffRange], cwd);
|
|
40
|
+
const entries = [];
|
|
41
|
+
const files = [];
|
|
42
|
+
for (const line of nameStatusRaw.split("\n")) {
|
|
43
|
+
const trimmed = line.trim();
|
|
44
|
+
if (!trimmed) continue;
|
|
45
|
+
const parts = trimmed.split(/\t+/);
|
|
46
|
+
const status = parts[0]?.[0] ?? "M";
|
|
47
|
+
const filePath = normalizePath(parts[parts.length - 1] ?? "");
|
|
48
|
+
if (!filePath) continue;
|
|
49
|
+
entries.push({ path: filePath, status });
|
|
50
|
+
files.push(filePath);
|
|
51
|
+
}
|
|
52
|
+
const rawDiff = execGit(["diff", "--unified=3", diffRange], cwd);
|
|
53
|
+
const diffBytes = Buffer.byteLength(rawDiff, "utf-8");
|
|
54
|
+
const truncated = diffBytes > maxDiffBytes;
|
|
55
|
+
const diff = truncated ? rawDiff.slice(0, maxDiffBytes) : rawDiff;
|
|
56
|
+
return {
|
|
57
|
+
baseRef,
|
|
58
|
+
mergeBase,
|
|
59
|
+
files,
|
|
60
|
+
entries,
|
|
61
|
+
diff,
|
|
62
|
+
diffBytes,
|
|
63
|
+
truncated
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function buildFilterCandidates(loaded, cwd = process.cwd()) {
|
|
67
|
+
const sourceCache = /* @__PURE__ */ new Map();
|
|
68
|
+
return loaded.map((entry, idx) => {
|
|
69
|
+
const rel = normalizePath(relative(cwd, resolve(cwd, entry.sourcePath)));
|
|
70
|
+
if (!sourceCache.has(entry.sourcePath)) {
|
|
71
|
+
let src;
|
|
72
|
+
if (existsSync(entry.sourcePath)) {
|
|
73
|
+
try {
|
|
74
|
+
src = readFileSync(entry.sourcePath, "utf-8");
|
|
75
|
+
} catch {
|
|
76
|
+
src = void 0;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
sourceCache.set(entry.sourcePath, src);
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
id: `${rel}::${entry.flow.name}#${idx}`,
|
|
83
|
+
name: entry.flow.name,
|
|
84
|
+
file: rel,
|
|
85
|
+
tags: entry.flow.config.tags ?? [],
|
|
86
|
+
platforms: entry.flow.config.platforms,
|
|
87
|
+
source: sourceCache.get(entry.sourcePath)
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function decisionFilter(options) {
|
|
92
|
+
const filterName = options.name ?? "decision";
|
|
93
|
+
const threshold = options.threshold ?? 0.2;
|
|
94
|
+
const maxDiffBytes = options.maxDiffBytes ?? DEFAULT_MAX_DIFF_BYTES;
|
|
95
|
+
const maxFileBytes = options.maxFileBytes ?? 32 * 1024;
|
|
96
|
+
const alwaysRunTags = new Set(options.alwaysRunTags ?? []);
|
|
97
|
+
const runAllOnPaths = (options.runAllOnPaths ?? []).map(normalizePath);
|
|
98
|
+
return {
|
|
99
|
+
name: filterName,
|
|
100
|
+
async filter(flows, context) {
|
|
101
|
+
const { changes, configPath } = context;
|
|
102
|
+
if (changes.files.length === 0) {
|
|
103
|
+
return { exclude: {}, note: "no git changes detected" };
|
|
104
|
+
}
|
|
105
|
+
if (changes.files.some((f) => isConfigOrLockfile(f, configPath))) {
|
|
106
|
+
return { exclude: {}, note: "config or lockfile changed \u2014 running all flows" };
|
|
107
|
+
}
|
|
108
|
+
const matchedGlobalPath = changes.files.find(
|
|
109
|
+
(f) => runAllOnPaths.some((prefix) => normalizePath(f).startsWith(prefix))
|
|
110
|
+
);
|
|
111
|
+
if (matchedGlobalPath) {
|
|
112
|
+
return {
|
|
113
|
+
exclude: {},
|
|
114
|
+
note: `global path changed (${matchedGlobalPath}) \u2014 running all flows`
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
if (changes.truncated || changes.diffBytes > maxDiffBytes) {
|
|
118
|
+
return {
|
|
119
|
+
exclude: {},
|
|
120
|
+
note: `diff exceeds ${Math.round(maxDiffBytes / 1024)}kB cap \u2014 failing open`
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const changedSet = new Set(changes.files.map(normalizePath));
|
|
124
|
+
const exclude = {};
|
|
125
|
+
let calls = 0;
|
|
126
|
+
let tokens = 0;
|
|
127
|
+
let costUsd = 0;
|
|
128
|
+
const eligible = [];
|
|
129
|
+
for (const candidate of flows) {
|
|
130
|
+
if (changedSet.has(normalizePath(candidate.file))) continue;
|
|
131
|
+
if (candidate.tags.some((t) => alwaysRunTags.has(t))) continue;
|
|
132
|
+
if (candidate.source && Buffer.byteLength(candidate.source, "utf-8") > maxFileBytes) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
eligible.push(candidate);
|
|
136
|
+
}
|
|
137
|
+
if (eligible.length === 0) {
|
|
138
|
+
return { exclude };
|
|
139
|
+
}
|
|
140
|
+
if (options.batchJudge) {
|
|
141
|
+
try {
|
|
142
|
+
const batch = await options.batchJudge({ candidates: eligible, changes });
|
|
143
|
+
calls += batch.usage?.calls ?? 1;
|
|
144
|
+
tokens += batch.usage?.tokens ?? 0;
|
|
145
|
+
costUsd += batch.usage?.costUsd ?? 0;
|
|
146
|
+
for (const candidate of eligible) {
|
|
147
|
+
const prob = batch.probabilities[candidate.id];
|
|
148
|
+
if (typeof prob === "number" && !Number.isNaN(prob) && prob >= 0 && prob < threshold) {
|
|
149
|
+
const pct = Math.round(prob * 100);
|
|
150
|
+
exclude[candidate.id] = batch.reasons?.[candidate.id] ?? `rated ${pct}% likely affected (< ${Math.round(threshold * 100)}%)`;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
} catch {
|
|
154
|
+
return { exclude: {}, note: "decision model error \u2014 failed open" };
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
exclude,
|
|
158
|
+
usage: calls > 0 ? { calls, tokens, costUsd } : void 0
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
if (!options.judge) {
|
|
162
|
+
return { exclude: {}, note: "no judge configured \u2014 failed open" };
|
|
163
|
+
}
|
|
164
|
+
for (const candidate of eligible) {
|
|
165
|
+
try {
|
|
166
|
+
const verdict = await options.judge({ candidate, changes });
|
|
167
|
+
calls += verdict.usage?.calls ?? 1;
|
|
168
|
+
tokens += verdict.usage?.tokens ?? 0;
|
|
169
|
+
costUsd += verdict.usage?.costUsd ?? 0;
|
|
170
|
+
if (typeof verdict.probability === "number" && !Number.isNaN(verdict.probability) && verdict.probability >= 0 && verdict.probability < threshold) {
|
|
171
|
+
const pct = Math.round(verdict.probability * 100);
|
|
172
|
+
exclude[candidate.id] = verdict.reason ?? `rated ${pct}% likely affected (< ${Math.round(threshold * 100)}%)`;
|
|
173
|
+
}
|
|
174
|
+
} catch {
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
exclude,
|
|
180
|
+
usage: calls > 0 ? { calls, tokens, costUsd } : void 0
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function createOllamaDecisionJudge(options) {
|
|
186
|
+
const baseUrl = (options.baseUrl ?? "http://127.0.0.1:11434").replace(/\/$/, "");
|
|
187
|
+
const timeoutMs = options.timeoutMs ?? 15e3;
|
|
188
|
+
const fetchFn = options.fetchFn ?? fetch;
|
|
189
|
+
return async ({ candidates, changes }) => {
|
|
190
|
+
const flowList = candidates.map((c, i) => `${i}: file="${c.file}", name="${c.name}", tags=[${c.tags.join(",")}]`).join("\n");
|
|
191
|
+
const prompt = [
|
|
192
|
+
"You are a conservative CI test-impact classifier. Err on the side of RUNNING tests (high recall).",
|
|
193
|
+
"For each E2E flow below, output a probability from 0.0 to 1.0 that the git diff could affect it.",
|
|
194
|
+
"Rules:",
|
|
195
|
+
"- If a flow's file path, name, or tags share the same feature/module/domain as ANY changed file, rate it 0.9.",
|
|
196
|
+
"- If unsure or possibly connected via shared UI/state/API, rate it 0.5.",
|
|
197
|
+
"- Rate 0.05 ONLY if the flow is clearly in a completely unrelated module.",
|
|
198
|
+
`Changed files: ${changes.files.join(", ")}`,
|
|
199
|
+
`Diff:
|
|
200
|
+
${changes.diff.slice(0, 3e3)}`,
|
|
201
|
+
`Flows:
|
|
202
|
+
${flowList}`,
|
|
203
|
+
'Output compact single-line JSON mapping each index string to a number, e.g. {"0":0.9,"1":0.05}'
|
|
204
|
+
].join("\n");
|
|
205
|
+
const res = await fetchFn(`${baseUrl}/api/generate`, {
|
|
206
|
+
method: "POST",
|
|
207
|
+
headers: { "Content-Type": "application/json" },
|
|
208
|
+
body: JSON.stringify({
|
|
209
|
+
model: options.model,
|
|
210
|
+
prompt,
|
|
211
|
+
format: "json",
|
|
212
|
+
stream: false,
|
|
213
|
+
options: { temperature: 0, num_predict: 256 }
|
|
214
|
+
}),
|
|
215
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
216
|
+
});
|
|
217
|
+
if (!res.ok) {
|
|
218
|
+
throw new Error(`Ollama returned HTTP ${res.status}`);
|
|
219
|
+
}
|
|
220
|
+
const payload = await res.json();
|
|
221
|
+
const rawJson = (payload.response ?? "{}").trim();
|
|
222
|
+
const parsed = JSON.parse(rawJson);
|
|
223
|
+
const probabilities = {};
|
|
224
|
+
for (let i = 0; i < candidates.length; i++) {
|
|
225
|
+
const cand = candidates[i];
|
|
226
|
+
const val = parsed[String(i)] ?? parsed[cand.id] ?? parsed[cand.name];
|
|
227
|
+
if (typeof val === "number" && !Number.isNaN(val)) {
|
|
228
|
+
probabilities[cand.id] = Math.max(0, Math.min(1, val));
|
|
229
|
+
} else {
|
|
230
|
+
probabilities[cand.id] = 1;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return {
|
|
234
|
+
probabilities,
|
|
235
|
+
usage: {
|
|
236
|
+
calls: 1,
|
|
237
|
+
tokens: (payload.prompt_eval_count ?? 0) + (payload.eval_count ?? 0),
|
|
238
|
+
costUsd: 0
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
function probabilityFromTopLogprobs(topLogprobs) {
|
|
244
|
+
let yesProb = 0;
|
|
245
|
+
let noProb = 0;
|
|
246
|
+
for (const entry of topLogprobs) {
|
|
247
|
+
const norm = entry.token.trim().toLowerCase();
|
|
248
|
+
const p = Math.exp(entry.logprob);
|
|
249
|
+
if (norm === "yes" || norm === "y" || norm === "true" || norm === "1") {
|
|
250
|
+
yesProb += p;
|
|
251
|
+
} else if (norm === "no" || norm === "n" || norm === "false" || norm === "0") {
|
|
252
|
+
noProb += p;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
const total = yesProb + noProb;
|
|
256
|
+
if (total <= 0) return null;
|
|
257
|
+
return Math.max(0, Math.min(1, yesProb / total));
|
|
258
|
+
}
|
|
259
|
+
function createLogprobDecisionJudge(options) {
|
|
260
|
+
const baseUrl = (options.baseUrl ?? (options.provider === "ollama" ? "http://127.0.0.1:11434" : "http://127.0.0.1:8000/v1")).replace(/\/$/, "");
|
|
261
|
+
const timeoutMs = options.timeoutMs ?? 15e3;
|
|
262
|
+
const fetchFn = options.fetchFn ?? fetch;
|
|
263
|
+
return async ({ candidate, changes }) => {
|
|
264
|
+
const prompt = [
|
|
265
|
+
"You are a binary CI test-impact classifier. Answer strictly YES or NO.",
|
|
266
|
+
`Changed files: ${changes.files.join(", ")}`,
|
|
267
|
+
`Git diff:
|
|
268
|
+
${changes.diff.slice(0, 3500)}`,
|
|
269
|
+
`Question: Could this change affect or break the E2E flow below?`,
|
|
270
|
+
`Flow file: ${candidate.file}`,
|
|
271
|
+
`Flow name: ${candidate.name}`,
|
|
272
|
+
`Flow tags: ${candidate.tags.join(", ") || "(none)"}`,
|
|
273
|
+
"Answer (YES or NO):"
|
|
274
|
+
].join("\n");
|
|
275
|
+
if (options.provider === "ollama") {
|
|
276
|
+
const res2 = await fetchFn(`${baseUrl}/api/generate`, {
|
|
277
|
+
method: "POST",
|
|
278
|
+
headers: { "Content-Type": "application/json" },
|
|
279
|
+
body: JSON.stringify({
|
|
280
|
+
model: options.model,
|
|
281
|
+
prompt,
|
|
282
|
+
stream: false,
|
|
283
|
+
logprobs: true,
|
|
284
|
+
top_logprobs: 10,
|
|
285
|
+
options: { temperature: 0, num_predict: 1 }
|
|
286
|
+
}),
|
|
287
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
288
|
+
});
|
|
289
|
+
if (!res2.ok) throw new Error(`Ollama returned HTTP ${res2.status}`);
|
|
290
|
+
const data2 = await res2.json();
|
|
291
|
+
const top2 = data2.logprobs?.[0]?.top_logprobs;
|
|
292
|
+
let probability2 = top2 ? probabilityFromTopLogprobs(top2) : null;
|
|
293
|
+
if (probability2 === null) {
|
|
294
|
+
const tok = (data2.response ?? "").trim().toLowerCase();
|
|
295
|
+
if (tok.startsWith("n") || tok === "0" || tok === "false") probability2 = 0.05;
|
|
296
|
+
else probability2 = 0.95;
|
|
297
|
+
}
|
|
298
|
+
return {
|
|
299
|
+
probability: probability2,
|
|
300
|
+
usage: {
|
|
301
|
+
calls: 1,
|
|
302
|
+
tokens: (data2.prompt_eval_count ?? 0) + (data2.eval_count ?? 0),
|
|
303
|
+
costUsd: 0
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
const res = await fetchFn(`${baseUrl}/chat/completions`, {
|
|
308
|
+
method: "POST",
|
|
309
|
+
headers: {
|
|
310
|
+
"Content-Type": "application/json",
|
|
311
|
+
...options.apiKey ? { Authorization: `Bearer ${options.apiKey}` } : {}
|
|
312
|
+
},
|
|
313
|
+
body: JSON.stringify({
|
|
314
|
+
model: options.model,
|
|
315
|
+
temperature: 0,
|
|
316
|
+
max_tokens: 1,
|
|
317
|
+
logprobs: true,
|
|
318
|
+
top_logprobs: 10,
|
|
319
|
+
messages: [{ role: "user", content: prompt }]
|
|
320
|
+
}),
|
|
321
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
322
|
+
});
|
|
323
|
+
if (!res.ok) throw new Error(`Decision endpoint returned HTTP ${res.status}`);
|
|
324
|
+
const data = await res.json();
|
|
325
|
+
const top = data.choices?.[0]?.logprobs?.content?.[0]?.top_logprobs;
|
|
326
|
+
let probability = top ? probabilityFromTopLogprobs(top) : null;
|
|
327
|
+
if (probability === null) {
|
|
328
|
+
const tok = (data.choices?.[0]?.message?.content ?? "").trim().toLowerCase();
|
|
329
|
+
if (tok.startsWith("n") || tok === "0" || tok === "false") probability = 0.05;
|
|
330
|
+
else probability = 0.95;
|
|
331
|
+
}
|
|
332
|
+
return {
|
|
333
|
+
probability,
|
|
334
|
+
usage: {
|
|
335
|
+
calls: 1,
|
|
336
|
+
tokens: (data.usage?.prompt_tokens ?? 0) + (data.usage?.completion_tokens ?? 0),
|
|
337
|
+
costUsd: 0
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
function pathRuleFilter(options) {
|
|
343
|
+
const filterName = options.name ?? "path-rules";
|
|
344
|
+
const alwaysRunTags = new Set(options.alwaysRunTags ?? []);
|
|
345
|
+
const runAllOnPaths = (options.runAllOnPaths ?? []).map(normalizePath);
|
|
346
|
+
return {
|
|
347
|
+
name: filterName,
|
|
348
|
+
filter(flows, context) {
|
|
349
|
+
const { changes, configPath } = context;
|
|
350
|
+
if (changes.files.length === 0) {
|
|
351
|
+
return { exclude: {}, note: "no git changes detected" };
|
|
352
|
+
}
|
|
353
|
+
if (changes.files.some((f) => isConfigOrLockfile(f, configPath))) {
|
|
354
|
+
return { exclude: {}, note: "config or lockfile changed \u2014 running all flows" };
|
|
355
|
+
}
|
|
356
|
+
const matchedGlobal = changes.files.find(
|
|
357
|
+
(f) => runAllOnPaths.some((prefix) => normalizePath(f).startsWith(prefix))
|
|
358
|
+
);
|
|
359
|
+
if (matchedGlobal) {
|
|
360
|
+
return { exclude: {}, note: `global path changed (${matchedGlobal}) \u2014 running all flows` };
|
|
361
|
+
}
|
|
362
|
+
const changedFiles = changes.files.map(normalizePath);
|
|
363
|
+
const changedSet = new Set(changedFiles);
|
|
364
|
+
const exclude = {};
|
|
365
|
+
for (const candidate of flows) {
|
|
366
|
+
if (changedSet.has(normalizePath(candidate.file))) continue;
|
|
367
|
+
if (candidate.tags.some((t) => alwaysRunTags.has(t))) continue;
|
|
368
|
+
const matchedRules = options.rules.filter((rule) => {
|
|
369
|
+
const tagOk = rule.matchFlow.tag ? candidate.tags.includes(rule.matchFlow.tag) : true;
|
|
370
|
+
const fileOk = rule.matchFlow.filePrefix ? normalizePath(candidate.file).startsWith(normalizePath(rule.matchFlow.filePrefix)) : true;
|
|
371
|
+
return (rule.matchFlow.tag || rule.matchFlow.filePrefix) && tagOk && fileOk;
|
|
372
|
+
});
|
|
373
|
+
if (matchedRules.length === 0) continue;
|
|
374
|
+
const watchedPrefixes = matchedRules.flatMap((r) => r.watchPaths.map(normalizePath));
|
|
375
|
+
const affected = changedFiles.some(
|
|
376
|
+
(cf) => watchedPrefixes.some((prefix) => cf.startsWith(prefix))
|
|
377
|
+
);
|
|
378
|
+
if (!affected) {
|
|
379
|
+
exclude[candidate.id] = `no changed files matched [${watchedPrefixes.join(", ")}]`;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return { exclude };
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
async function applyTestFilters(items, candidates, filters, context) {
|
|
387
|
+
let remainingIndices = items.map((_, i) => i);
|
|
388
|
+
const excluded = [];
|
|
389
|
+
const reports = [];
|
|
390
|
+
for (const filter of filters) {
|
|
391
|
+
const activeCandidates = remainingIndices.map((idx) => candidates[idx]);
|
|
392
|
+
const totalBefore = activeCandidates.length;
|
|
393
|
+
try {
|
|
394
|
+
const output = await filter.filter(activeCandidates, context);
|
|
395
|
+
const excludeMap = output.exclude ?? {};
|
|
396
|
+
const nextRemaining = [];
|
|
397
|
+
let excludedCount = 0;
|
|
398
|
+
for (const idx of remainingIndices) {
|
|
399
|
+
const cand = candidates[idx];
|
|
400
|
+
const reason = excludeMap[cand.id];
|
|
401
|
+
if (reason !== void 0) {
|
|
402
|
+
excludedCount += 1;
|
|
403
|
+
excluded.push({
|
|
404
|
+
item: items[idx],
|
|
405
|
+
candidate: cand,
|
|
406
|
+
filterName: filter.name,
|
|
407
|
+
reason
|
|
408
|
+
});
|
|
409
|
+
} else {
|
|
410
|
+
nextRemaining.push(idx);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
remainingIndices = nextRemaining;
|
|
414
|
+
reports.push({
|
|
415
|
+
filterName: filter.name,
|
|
416
|
+
total: totalBefore,
|
|
417
|
+
kept: remainingIndices.length,
|
|
418
|
+
excluded: excludedCount,
|
|
419
|
+
note: output.note,
|
|
420
|
+
usage: output.usage
|
|
421
|
+
});
|
|
422
|
+
} catch (err) {
|
|
423
|
+
reports.push({
|
|
424
|
+
filterName: filter.name,
|
|
425
|
+
total: totalBefore,
|
|
426
|
+
kept: totalBefore,
|
|
427
|
+
excluded: 0,
|
|
428
|
+
failedOpen: true,
|
|
429
|
+
note: `filter error (${err instanceof Error ? err.message : String(err)}) \u2014 failed open`
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
return {
|
|
434
|
+
kept: remainingIndices.map((idx) => items[idx]),
|
|
435
|
+
excluded,
|
|
436
|
+
reports
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
function formatFilterSummary(reports) {
|
|
440
|
+
return reports.map((r) => {
|
|
441
|
+
const parts = [];
|
|
442
|
+
if (r.usage?.calls) {
|
|
443
|
+
parts.push(`${r.usage.calls} call${r.usage.calls === 1 ? "" : "s"}`);
|
|
444
|
+
}
|
|
445
|
+
if (r.usage?.tokens) {
|
|
446
|
+
const tok = r.usage.tokens >= 1e3 ? `${(r.usage.tokens / 1e3).toFixed(1)}k` : String(r.usage.tokens);
|
|
447
|
+
parts.push(`${tok} tokens`);
|
|
448
|
+
}
|
|
449
|
+
if (r.usage?.costUsd !== void 0 && r.usage.costUsd > 0) {
|
|
450
|
+
parts.push(`$${r.usage.costUsd.toFixed(4)}`);
|
|
451
|
+
}
|
|
452
|
+
if (r.note) {
|
|
453
|
+
parts.push(r.note);
|
|
454
|
+
}
|
|
455
|
+
const detail = parts.length > 0 ? ` (${parts.join(", ")})` : "";
|
|
456
|
+
return `${r.filterName} kept ${r.kept} of ${r.total} flows, left out ${r.excluded}${detail}`;
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
export {
|
|
461
|
+
collectGitChanges,
|
|
462
|
+
buildFilterCandidates,
|
|
463
|
+
decisionFilter,
|
|
464
|
+
createOllamaDecisionJudge,
|
|
465
|
+
probabilityFromTopLogprobs,
|
|
466
|
+
createLogprobDecisionJudge,
|
|
467
|
+
pathRuleFilter,
|
|
468
|
+
applyTestFilters,
|
|
469
|
+
formatFilterSummary
|
|
470
|
+
};
|
|
471
|
+
//# sourceMappingURL=chunk-3YE2POGD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/filters.ts"],"sourcesContent":["import { execFileSync } from \"node:child_process\";\nimport { readFileSync, existsSync } from \"node:fs\";\nimport { basename, relative, resolve } from \"node:path\";\nimport type { FlowDefinition } from \"../api/flow.js\";\nimport type { Platform } from \"../schemas/selector.js\";\n\n/** A file changed between `baseRef` and `HEAD` (or working tree). */\nexport interface ChangedFile {\n path: string;\n status: \"A\" | \"M\" | \"D\" | \"R\" | \"C\" | string;\n}\n\n/** Git diff snapshot provided to test filters when `--changed-since <ref>` is active. */\nexport interface GitChanges {\n baseRef: string;\n mergeBase?: string;\n files: string[];\n entries: ChangedFile[];\n /** Unified diff text (truncated when exceeding `maxDiffBytes`). */\n diff: string;\n /** Full byte length of the raw diff before truncation. */\n diffBytes: number;\n /** True when the diff exceeded the configured safety cap. */\n truncated: boolean;\n}\n\n/** Descriptor for a candidate flow passed into a `TestFilter`. */\nexport interface FilterCandidate {\n id: string;\n name: string;\n file: string;\n tags: string[];\n platforms?: Platform[];\n source?: string;\n}\n\n/** Context supplied to every `TestFilter.filter()` invocation. */\nexport interface FilterContext {\n cwd: string;\n changes: GitChanges;\n configPath?: string;\n platforms: Platform[];\n}\n\nexport interface FilterUsage {\n calls?: number;\n tokens?: number;\n costUsd?: number;\n}\n\nexport interface FilterDecisionOutput {\n /** Map of candidate `id` -> human-readable skip reason. Any ID not present is kept. */\n exclude: Record<string, string>;\n /** Optional summary note displayed next to the filter output. */\n note?: string;\n /** Optional model/API usage metrics for summary logging. */\n usage?: FilterUsage;\n}\n\n/**\n * Pluggable CI test filter inspired by `e2e-inc/e2e`'s Filters API.\n * Compose deterministic path/tag rules or plug in a decision model / LLM.\n */\nexport interface TestFilter {\n name: string;\n filter(\n flows: FilterCandidate[],\n context: FilterContext,\n ): Promise<FilterDecisionOutput> | FilterDecisionOutput;\n}\n\nexport interface AppliedFilterReport {\n filterName: string;\n total: number;\n kept: number;\n excluded: number;\n note?: string;\n usage?: FilterUsage;\n failedOpen?: boolean;\n}\n\nexport interface ApplyFiltersResult<T> {\n kept: T[];\n excluded: Array<{ item: T; candidate: FilterCandidate; filterName: string; reason: string }>;\n reports: AppliedFilterReport[];\n}\n\nconst DEFAULT_LOCKFILES = new Set([\n \"bun.lock\",\n \"bun.lockb\",\n \"package.json\",\n \"package-lock.json\",\n \"pnpm-lock.yaml\",\n \"yarn.lock\",\n]);\n\nconst DEFAULT_MAX_DIFF_BYTES = 60 * 1024; // 60 kB fail-open safety ceiling\n\nfunction normalizePath(p: string): string {\n return p.replaceAll(\"\\\\\", \"/\").replace(/^\\.\\//, \"\");\n}\n\nfunction isConfigOrLockfile(filePath: string, configPath?: string): boolean {\n const norm = normalizePath(filePath);\n const name = basename(norm);\n if (DEFAULT_LOCKFILES.has(name)) return true;\n if (/^spana\\.config(\\.[^.]+)?\\.(ts|mts|js|mjs|cjs)$/.test(name)) return true;\n if (configPath && normalizePath(configPath).endsWith(norm)) return true;\n return false;\n}\n\n/**\n * Collect changed files and unified diff relative to `baseRef` using `git merge-base`.\n * Fails cleanly if git is unavailable or `baseRef` does not exist (shallow checkout).\n */\nexport function collectGitChanges(\n baseRef: string,\n cwd: string = process.cwd(),\n maxDiffBytes: number = DEFAULT_MAX_DIFF_BYTES,\n runGit?: (args: string[], workdir: string) => string,\n): GitChanges {\n const execGit =\n runGit ??\n ((args: string[], workdir: string) =>\n execFileSync(\"git\", args, {\n cwd: workdir,\n encoding: \"utf-8\",\n maxBuffer: 16 * 1024 * 1024,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n }));\n\n let mergeBase: string | undefined;\n try {\n mergeBase = execGit([\"merge-base\", baseRef, \"HEAD\"], cwd).trim() || undefined;\n } catch {\n mergeBase = undefined;\n }\n\n const diffRange = mergeBase ? `${mergeBase}...HEAD` : baseRef;\n const nameStatusRaw = execGit([\"diff\", \"--name-status\", diffRange], cwd);\n const entries: ChangedFile[] = [];\n const files: string[] = [];\n\n for (const line of nameStatusRaw.split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed) continue;\n const parts = trimmed.split(/\\t+/);\n const status = parts[0]?.[0] ?? \"M\";\n // For renames (R100 old new), include the destination path\n const filePath = normalizePath(parts[parts.length - 1] ?? \"\");\n if (!filePath) continue;\n entries.push({ path: filePath, status });\n files.push(filePath);\n }\n\n const rawDiff = execGit([\"diff\", \"--unified=3\", diffRange], cwd);\n const diffBytes = Buffer.byteLength(rawDiff, \"utf-8\");\n const truncated = diffBytes > maxDiffBytes;\n const diff = truncated ? rawDiff.slice(0, maxDiffBytes) : rawDiff;\n\n return {\n baseRef,\n mergeBase,\n files,\n entries,\n diff,\n diffBytes,\n truncated,\n };\n}\n\n/** Build filter candidates from loaded Spana flows (including source file content when readable). */\nexport function buildFilterCandidates(\n loaded: Array<{ sourcePath: string; flow: FlowDefinition }>,\n cwd: string = process.cwd(),\n): FilterCandidate[] {\n const sourceCache = new Map<string, string | undefined>();\n return loaded.map((entry, idx) => {\n const rel = normalizePath(relative(cwd, resolve(cwd, entry.sourcePath)));\n if (!sourceCache.has(entry.sourcePath)) {\n let src: string | undefined;\n if (existsSync(entry.sourcePath)) {\n try {\n src = readFileSync(entry.sourcePath, \"utf-8\");\n } catch {\n src = undefined;\n }\n }\n sourceCache.set(entry.sourcePath, src);\n }\n return {\n id: `${rel}::${entry.flow.name}#${idx}`,\n name: entry.flow.name,\n file: rel,\n tags: entry.flow.config.tags ?? [],\n platforms: entry.flow.config.platforms,\n source: sourceCache.get(entry.sourcePath),\n };\n });\n}\n\n// ── Built-in Decision-Model Filter ──────────────────────────────────────────\n\nexport interface DecisionJudgeInput {\n candidate: FilterCandidate;\n changes: GitChanges;\n}\n\nexport interface DecisionJudgeResult {\n /** Probability [0..1] that the PR changes can affect this flow. */\n probability: number;\n reason?: string;\n usage?: FilterUsage;\n}\n\nexport type DecisionModelJudge = (\n input: DecisionJudgeInput,\n) => Promise<DecisionJudgeResult> | DecisionJudgeResult;\n\nexport interface DecisionBatchJudgeResult {\n /** Map of candidate `id` -> probability `[0, 1]` that the PR changes affect it. */\n probabilities: Record<string, number>;\n reasons?: Record<string, string>;\n usage?: FilterUsage;\n}\n\nexport type DecisionBatchJudge = (input: {\n candidates: FilterCandidate[];\n changes: GitChanges;\n}) => Promise<DecisionBatchJudgeResult> | DecisionBatchJudgeResult;\n\nexport interface DecisionFilterOptions {\n /** Optional custom name (default: \"decision\") */\n name?: string;\n /**\n * Per-flow model judge function returning an impact probability in `[0, 1]`.\n * Provide either `judge` or `batchJudge` (batched evaluates all flows in 1 LLM call).\n */\n judge?: DecisionModelJudge;\n /**\n * Batched model judge evaluating all candidate flows in a single model call\n * (dramatically faster for local Ollama/MLX models and cloud decision models).\n */\n batchJudge?: DecisionBatchJudge;\n /**\n * Skip a flow only when `probability < threshold`.\n * Default: `0.20` (fail-open safety bias — runs anything >= 20% likely affected).\n */\n threshold?: number;\n /** Max diff size in bytes before failing open and running everything. Default: 60 kB. */\n maxDiffBytes?: number;\n /** Max single flow file size in bytes before failing open for that flow. Default: 32 kB. */\n maxFileBytes?: number;\n /** Tags that are NEVER excluded (e.g. `[\"smoke\"]`). */\n alwaysRunTags?: string[];\n /** Path prefixes that force the entire suite to run (e.g. `[\"infra/\", \"db/migrations/\"]`). */\n runAllOnPaths?: string[];\n}\n\n/**\n * Create a fail-open decision-model filter for `--changed-since`:\n *\n * Safety invariants (never skip important tests):\n * 1. Changed flow files always run.\n * 2. Config or lockfile changes run the entire suite.\n * 3. Diffs over `maxDiffBytes` (default 60 kB) run the entire suite.\n * 4. Flows tagged in `alwaysRunTags` always run.\n * 5. Any judge error or invalid probability fails open (flow runs).\n * 6. A flow is excluded only when `probability < threshold` (default 0.20).\n */\nexport function decisionFilter(options: DecisionFilterOptions): TestFilter {\n const filterName = options.name ?? \"decision\";\n const threshold = options.threshold ?? 0.2;\n const maxDiffBytes = options.maxDiffBytes ?? DEFAULT_MAX_DIFF_BYTES;\n const maxFileBytes = options.maxFileBytes ?? 32 * 1024;\n const alwaysRunTags = new Set(options.alwaysRunTags ?? []);\n const runAllOnPaths = (options.runAllOnPaths ?? []).map(normalizePath);\n\n return {\n name: filterName,\n async filter(flows, context): Promise<FilterDecisionOutput> {\n const { changes, configPath } = context;\n\n if (changes.files.length === 0) {\n return { exclude: {}, note: \"no git changes detected\" };\n }\n\n if (changes.files.some((f) => isConfigOrLockfile(f, configPath))) {\n return { exclude: {}, note: \"config or lockfile changed — running all flows\" };\n }\n\n const matchedGlobalPath = changes.files.find((f) =>\n runAllOnPaths.some((prefix) => normalizePath(f).startsWith(prefix)),\n );\n if (matchedGlobalPath) {\n return {\n exclude: {},\n note: `global path changed (${matchedGlobalPath}) — running all flows`,\n };\n }\n\n if (changes.truncated || changes.diffBytes > maxDiffBytes) {\n return {\n exclude: {},\n note: `diff exceeds ${Math.round(maxDiffBytes / 1024)}kB cap — failing open`,\n };\n }\n\n const changedSet = new Set(changes.files.map(normalizePath));\n const exclude: Record<string, string> = {};\n let calls = 0;\n let tokens = 0;\n let costUsd = 0;\n\n // Filter down to flows eligible for model judgment (safety rules always keep the rest)\n const eligible: FilterCandidate[] = [];\n for (const candidate of flows) {\n if (changedSet.has(normalizePath(candidate.file))) continue;\n if (candidate.tags.some((t) => alwaysRunTags.has(t))) continue;\n if (candidate.source && Buffer.byteLength(candidate.source, \"utf-8\") > maxFileBytes) {\n continue;\n }\n eligible.push(candidate);\n }\n\n if (eligible.length === 0) {\n return { exclude };\n }\n\n // Fast path: evaluate all eligible flows in ONE batched model call\n if (options.batchJudge) {\n try {\n const batch = await options.batchJudge({ candidates: eligible, changes });\n calls += batch.usage?.calls ?? 1;\n tokens += batch.usage?.tokens ?? 0;\n costUsd += batch.usage?.costUsd ?? 0;\n for (const candidate of eligible) {\n const prob = batch.probabilities[candidate.id];\n if (typeof prob === \"number\" && !Number.isNaN(prob) && prob >= 0 && prob < threshold) {\n const pct = Math.round(prob * 100);\n exclude[candidate.id] =\n batch.reasons?.[candidate.id] ??\n `rated ${pct}% likely affected (< ${Math.round(threshold * 100)}%)`;\n }\n }\n } catch {\n // Fail open on batch judge error\n return { exclude: {}, note: \"decision model error — failed open\" };\n }\n return {\n exclude,\n usage: calls > 0 ? { calls, tokens, costUsd } : undefined,\n };\n }\n\n if (!options.judge) {\n return { exclude: {}, note: \"no judge configured — failed open\" };\n }\n\n for (const candidate of eligible) {\n try {\n const verdict = await options.judge({ candidate, changes });\n calls += verdict.usage?.calls ?? 1;\n tokens += verdict.usage?.tokens ?? 0;\n costUsd += verdict.usage?.costUsd ?? 0;\n\n if (\n typeof verdict.probability === \"number\" &&\n !Number.isNaN(verdict.probability) &&\n verdict.probability >= 0 &&\n verdict.probability < threshold\n ) {\n const pct = Math.round(verdict.probability * 100);\n exclude[candidate.id] =\n verdict.reason ?? `rated ${pct}% likely affected (< ${Math.round(threshold * 100)}%)`;\n }\n } catch {\n // Fail open on any model/network error\n continue;\n }\n }\n\n return {\n exclude,\n usage: calls > 0 ? { calls, tokens, costUsd } : undefined,\n };\n },\n };\n}\n\nexport interface OllamaDecisionJudgeOptions {\n /** Ollama model tag, e.g. `\"qwen2.5:1.5b\"` or `\"qwen2.5:0.5b\"`. */\n model: string;\n /** Ollama HTTP endpoint (default: `\"http://127.0.0.1:11434\"`). */\n baseUrl?: string;\n /** Request timeout in ms (default: 15000). */\n timeoutMs?: number;\n /** Optional custom fetch implementation for testing. */\n fetchFn?: typeof fetch;\n}\n\n/**\n * Built-in local batched decision judge for Ollama (Apple Silicon / local GPU).\n * Evaluates all candidate flows against a PR diff in ONE structured JSON call\n * with `temperature: 0` and zero cloud token cost ($0.0000).\n */\nexport function createOllamaDecisionJudge(options: OllamaDecisionJudgeOptions): DecisionBatchJudge {\n const baseUrl = (options.baseUrl ?? \"http://127.0.0.1:11434\").replace(/\\/$/, \"\");\n const timeoutMs = options.timeoutMs ?? 15_000;\n const fetchFn = options.fetchFn ?? fetch;\n\n return async ({ candidates, changes }): Promise<DecisionBatchJudgeResult> => {\n const flowList = candidates\n .map((c, i) => `${i}: file=\"${c.file}\", name=\"${c.name}\", tags=[${c.tags.join(\",\")}]`)\n .join(\"\\n\");\n\n const prompt = [\n \"You are a conservative CI test-impact classifier. Err on the side of RUNNING tests (high recall).\",\n \"For each E2E flow below, output a probability from 0.0 to 1.0 that the git diff could affect it.\",\n \"Rules:\",\n \"- If a flow's file path, name, or tags share the same feature/module/domain as ANY changed file, rate it 0.9.\",\n \"- If unsure or possibly connected via shared UI/state/API, rate it 0.5.\",\n \"- Rate 0.05 ONLY if the flow is clearly in a completely unrelated module.\",\n `Changed files: ${changes.files.join(\", \")}`,\n `Diff:\\n${changes.diff.slice(0, 3000)}`,\n `Flows:\\n${flowList}`,\n 'Output compact single-line JSON mapping each index string to a number, e.g. {\"0\":0.9,\"1\":0.05}',\n ].join(\"\\n\");\n\n const res = await fetchFn(`${baseUrl}/api/generate`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n model: options.model,\n prompt,\n format: \"json\",\n stream: false,\n options: { temperature: 0, num_predict: 256 },\n }),\n signal: AbortSignal.timeout(timeoutMs),\n });\n\n if (!res.ok) {\n throw new Error(`Ollama returned HTTP ${res.status}`);\n }\n\n const payload = (await res.json()) as {\n response?: string;\n prompt_eval_count?: number;\n eval_count?: number;\n };\n\n const rawJson = (payload.response ?? \"{}\").trim();\n const parsed = JSON.parse(rawJson) as Record<string, unknown>;\n const probabilities: Record<string, number> = {};\n\n for (let i = 0; i < candidates.length; i++) {\n const cand = candidates[i]!;\n const val = parsed[String(i)] ?? parsed[cand.id] ?? parsed[cand.name];\n if (typeof val === \"number\" && !Number.isNaN(val)) {\n probabilities[cand.id] = Math.max(0, Math.min(1, val));\n } else {\n // Missing index -> fail open (1.0)\n probabilities[cand.id] = 1;\n }\n }\n\n return {\n probabilities,\n usage: {\n calls: 1,\n tokens: (payload.prompt_eval_count ?? 0) + (payload.eval_count ?? 0),\n costUsd: 0,\n },\n };\n };\n}\n\nexport interface LogprobDecisionJudgeOptions {\n /** Model identifier (e.g. `\"hf.co/apus-ailab/APUS-OpenJev-v1-9B-GGUF:Q8_0\"`, `\"jevk5-4b-v0.3:q8_0\"`, `\"decider4b-v2:bf16\"`, `\"plumb-4b\"`). */\n model: string;\n /** Protocol backend: `\"openai\"` (vLLM / SGLang / llama-server / OpenRouter / Typesafe AI) or `\"ollama\"`. */\n provider: \"openai\" | \"ollama\";\n /** Base URL (default: `http://127.0.0.1:8000/v1` for openai, `http://127.0.0.1:11434` for ollama). */\n baseUrl?: string;\n /** Optional Bearer API key for hosted OpenAI-compatible endpoints. */\n apiKey?: string;\n /** Request timeout per flow judgment in ms (default: 15000). */\n timeoutMs?: number;\n /** Injectable fetch for unit tests. */\n fetchFn?: typeof fetch;\n}\n\n/**\n * Compute calibrated binary YES probability from OpenAI-style `top_logprobs`\n * on a 1-token decision model response (`max_tokens: 1`, `logprobs: true`).\n * Returns `null` when neither YES nor NO tokens appeared in top_logprobs.\n */\nexport function probabilityFromTopLogprobs(\n topLogprobs: Array<{ token: string; logprob: number }>,\n): number | null {\n let yesProb = 0;\n let noProb = 0;\n\n for (const entry of topLogprobs) {\n const norm = entry.token.trim().toLowerCase();\n const p = Math.exp(entry.logprob);\n if (norm === \"yes\" || norm === \"y\" || norm === \"true\" || norm === \"1\") {\n yesProb += p;\n } else if (norm === \"no\" || norm === \"n\" || norm === \"false\" || norm === \"0\") {\n noProb += p;\n }\n }\n\n const total = yesProb + noProb;\n if (total <= 0) return null;\n return Math.max(0, Math.min(1, yesProb / total));\n}\n\n/**\n * Native 1-Token Logprob Decision Judge for System-1 decision models\n * (OpenJev, JevK5, Decider-4B, Plumb-4B, Winnow-12B, Typesafe AI Jev).\n *\n * Places the shared git diff prefix at the start of every prompt so vLLM,\n * SGLang, and llama.cpp automatically reuse the KV cache across all flows in a PR,\n * generating only **1 single token** (`YES` / `NO`) with exact calibrated probabilities.\n */\nexport function createLogprobDecisionJudge(\n options: LogprobDecisionJudgeOptions,\n): DecisionModelJudge {\n const baseUrl = (\n options.baseUrl ??\n (options.provider === \"ollama\" ? \"http://127.0.0.1:11434\" : \"http://127.0.0.1:8000/v1\")\n ).replace(/\\/$/, \"\");\n const timeoutMs = options.timeoutMs ?? 15_000;\n const fetchFn = options.fetchFn ?? fetch;\n\n return async ({ candidate, changes }): Promise<DecisionJudgeResult> => {\n // Shared prefix FIRST to maximize automatic KV-cache prefix hits across flows\n const prompt = [\n \"You are a binary CI test-impact classifier. Answer strictly YES or NO.\",\n `Changed files: ${changes.files.join(\", \")}`,\n `Git diff:\\n${changes.diff.slice(0, 3500)}`,\n `Question: Could this change affect or break the E2E flow below?`,\n `Flow file: ${candidate.file}`,\n `Flow name: ${candidate.name}`,\n `Flow tags: ${candidate.tags.join(\", \") || \"(none)\"}`,\n \"Answer (YES or NO):\",\n ].join(\"\\n\");\n\n if (options.provider === \"ollama\") {\n const res = await fetchFn(`${baseUrl}/api/generate`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n model: options.model,\n prompt,\n stream: false,\n logprobs: true,\n top_logprobs: 10,\n options: { temperature: 0, num_predict: 1 },\n }),\n signal: AbortSignal.timeout(timeoutMs),\n });\n if (!res.ok) throw new Error(`Ollama returned HTTP ${res.status}`);\n const data = (await res.json()) as {\n response?: string;\n prompt_eval_count?: number;\n eval_count?: number;\n logprobs?: Array<{ top_logprobs?: Array<{ token: string; logprob: number }> }>;\n };\n\n const top = data.logprobs?.[0]?.top_logprobs;\n let probability = top ? probabilityFromTopLogprobs(top) : null;\n if (probability === null) {\n const tok = (data.response ?? \"\").trim().toLowerCase();\n if (tok.startsWith(\"n\") || tok === \"0\" || tok === \"false\") probability = 0.05;\n else probability = 0.95; // fail open on ambiguous token\n }\n\n return {\n probability,\n usage: {\n calls: 1,\n tokens: (data.prompt_eval_count ?? 0) + (data.eval_count ?? 0),\n costUsd: 0,\n },\n };\n }\n\n // OpenAI-compatible 1-token logprob endpoint (vLLM / SGLang / llama-server / Typesafe AI / OpenRouter)\n const res = await fetchFn(`${baseUrl}/chat/completions`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...(options.apiKey ? { Authorization: `Bearer ${options.apiKey}` } : {}),\n },\n body: JSON.stringify({\n model: options.model,\n temperature: 0,\n max_tokens: 1,\n logprobs: true,\n top_logprobs: 10,\n messages: [{ role: \"user\", content: prompt }],\n }),\n signal: AbortSignal.timeout(timeoutMs),\n });\n if (!res.ok) throw new Error(`Decision endpoint returned HTTP ${res.status}`);\n const data = (await res.json()) as {\n choices?: Array<{\n message?: { content?: string };\n logprobs?: {\n content?: Array<{ top_logprobs?: Array<{ token: string; logprob: number }> }>;\n };\n }>;\n usage?: { prompt_tokens?: number; completion_tokens?: number };\n };\n\n const top = data.choices?.[0]?.logprobs?.content?.[0]?.top_logprobs;\n let probability = top ? probabilityFromTopLogprobs(top) : null;\n if (probability === null) {\n const tok = (data.choices?.[0]?.message?.content ?? \"\").trim().toLowerCase();\n if (tok.startsWith(\"n\") || tok === \"0\" || tok === \"false\") probability = 0.05;\n else probability = 0.95;\n }\n\n return {\n probability,\n usage: {\n calls: 1,\n tokens: (data.usage?.prompt_tokens ?? 0) + (data.usage?.completion_tokens ?? 0),\n costUsd: 0,\n },\n };\n };\n}\n\n// ── Built-in Deterministic Path-Rule Filter ─────────────────────────────────\n\nexport interface PathRule {\n /** Flow tag or path prefix this rule owns. */\n matchFlow: { tag?: string; filePrefix?: string };\n /** Source path prefixes that can affect matching flows. */\n watchPaths: string[];\n}\n\nexport interface PathRuleFilterOptions {\n name?: string;\n rules: PathRule[];\n alwaysRunTags?: string[];\n runAllOnPaths?: string[];\n}\n\n/**\n * 100% deterministic zero-LLM filter mapping repo path prefixes to flow tags/files.\n * Flows not matched by any rule fail open and run automatically.\n */\nexport function pathRuleFilter(options: PathRuleFilterOptions): TestFilter {\n const filterName = options.name ?? \"path-rules\";\n const alwaysRunTags = new Set(options.alwaysRunTags ?? []);\n const runAllOnPaths = (options.runAllOnPaths ?? []).map(normalizePath);\n\n return {\n name: filterName,\n filter(flows, context): FilterDecisionOutput {\n const { changes, configPath } = context;\n\n if (changes.files.length === 0) {\n return { exclude: {}, note: \"no git changes detected\" };\n }\n\n if (changes.files.some((f) => isConfigOrLockfile(f, configPath))) {\n return { exclude: {}, note: \"config or lockfile changed — running all flows\" };\n }\n\n const matchedGlobal = changes.files.find((f) =>\n runAllOnPaths.some((prefix) => normalizePath(f).startsWith(prefix)),\n );\n if (matchedGlobal) {\n return { exclude: {}, note: `global path changed (${matchedGlobal}) — running all flows` };\n }\n\n const changedFiles = changes.files.map(normalizePath);\n const changedSet = new Set(changedFiles);\n const exclude: Record<string, string> = {};\n\n for (const candidate of flows) {\n if (changedSet.has(normalizePath(candidate.file))) continue;\n if (candidate.tags.some((t) => alwaysRunTags.has(t))) continue;\n\n const matchedRules = options.rules.filter((rule) => {\n const tagOk = rule.matchFlow.tag ? candidate.tags.includes(rule.matchFlow.tag) : true;\n const fileOk = rule.matchFlow.filePrefix\n ? normalizePath(candidate.file).startsWith(normalizePath(rule.matchFlow.filePrefix))\n : true;\n return (rule.matchFlow.tag || rule.matchFlow.filePrefix) && tagOk && fileOk;\n });\n\n // No rule owns this flow -> fail open (keep it)\n if (matchedRules.length === 0) continue;\n\n const watchedPrefixes = matchedRules.flatMap((r) => r.watchPaths.map(normalizePath));\n const affected = changedFiles.some((cf) =>\n watchedPrefixes.some((prefix) => cf.startsWith(prefix)),\n );\n\n if (!affected) {\n exclude[candidate.id] = `no changed files matched [${watchedPrefixes.join(\", \")}]`;\n }\n }\n\n return { exclude };\n },\n };\n}\n\n/**\n * Run a chain of `TestFilter`s sequentially over candidate flows.\n * Any filter that throws fails open (keeps all remaining flows) and logs a note.\n */\nexport async function applyTestFilters<T>(\n items: T[],\n candidates: FilterCandidate[],\n filters: TestFilter[],\n context: FilterContext,\n): Promise<ApplyFiltersResult<T>> {\n let remainingIndices = items.map((_, i) => i);\n const excluded: ApplyFiltersResult<T>[\"excluded\"] = [];\n const reports: AppliedFilterReport[] = [];\n\n for (const filter of filters) {\n const activeCandidates = remainingIndices.map((idx) => candidates[idx]!);\n const totalBefore = activeCandidates.length;\n\n try {\n const output = await filter.filter(activeCandidates, context);\n const excludeMap = output.exclude ?? {};\n const nextRemaining: number[] = [];\n let excludedCount = 0;\n\n for (const idx of remainingIndices) {\n const cand = candidates[idx]!;\n const reason = excludeMap[cand.id];\n if (reason !== undefined) {\n excludedCount += 1;\n excluded.push({\n item: items[idx]!,\n candidate: cand,\n filterName: filter.name,\n reason,\n });\n } else {\n nextRemaining.push(idx);\n }\n }\n\n remainingIndices = nextRemaining;\n reports.push({\n filterName: filter.name,\n total: totalBefore,\n kept: remainingIndices.length,\n excluded: excludedCount,\n note: output.note,\n usage: output.usage,\n });\n } catch (err) {\n reports.push({\n filterName: filter.name,\n total: totalBefore,\n kept: totalBefore,\n excluded: 0,\n failedOpen: true,\n note: `filter error (${err instanceof Error ? err.message : String(err)}) — failed open`,\n });\n }\n }\n\n return {\n kept: remainingIndices.map((idx) => items[idx]!),\n excluded,\n reports,\n };\n}\n\n/** Format a concise, `e2e`-style CI summary line for each applied filter. */\nexport function formatFilterSummary(reports: AppliedFilterReport[]): string[] {\n return reports.map((r) => {\n const parts: string[] = [];\n if (r.usage?.calls) {\n parts.push(`${r.usage.calls} call${r.usage.calls === 1 ? \"\" : \"s\"}`);\n }\n if (r.usage?.tokens) {\n const tok =\n r.usage.tokens >= 1000 ? `${(r.usage.tokens / 1000).toFixed(1)}k` : String(r.usage.tokens);\n parts.push(`${tok} tokens`);\n }\n if (r.usage?.costUsd !== undefined && r.usage.costUsd > 0) {\n parts.push(`$${r.usage.costUsd.toFixed(4)}`);\n }\n if (r.note) {\n parts.push(r.note);\n }\n const detail = parts.length > 0 ? ` (${parts.join(\", \")})` : \"\";\n return `${r.filterName} kept ${r.kept} of ${r.total} flows, left out ${r.excluded}${detail}`;\n });\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,cAAc,kBAAkB;AACzC,SAAS,UAAU,UAAU,eAAe;AAqF5C,IAAM,oBAAoB,o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AAA,IAC5B;AACA,QAAI,EAAE,OAAO,YAAY,UAAa,EAAE,MAAM,UAAU,GAAG;AACzD,YAAM,KAAK,IAAI,EAAE,MAAM,QAAQ,QAAQ,CAAC,CAAC,EAAE;AAAA,IAC7C;AACA,QAAI,EAAE,MAAM;AACV,YAAM,KAAK,EAAE,IAAI;AAAA,IACnB;AACA,UAAM,SAAS,MAAM,SAAS,IAAI,KAAK,MAAM,KAAK,IAAI,CAAC,MAAM;AAC7D,WAAO,GAAG,EAAE,UAAU,SAAS,EAAE,IAAI,OAAO,EAAE,KAAK,oBAAoB,EAAE,QAAQ,GAAG,MAAM;AAAA,EAC5F,CAAC;AACH;","names":["res","data","top","probability"]}
|
package/dist/chunk-5245YBLL.js
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
// src/cli/scaffolds.ts
|
|
2
|
-
var INIT_PRESETS = [
|
|
2
|
+
var INIT_PRESETS = [
|
|
3
|
+
"local-web",
|
|
4
|
+
"local-react-native",
|
|
5
|
+
"capacitor-web-first",
|
|
6
|
+
"browserstack",
|
|
7
|
+
"saucelabs"
|
|
8
|
+
];
|
|
3
9
|
var FLOW_STUB_PRESETS = ["blank", "smoke", "auth"];
|
|
4
10
|
function isInitPreset(value) {
|
|
5
11
|
return INIT_PRESETS.includes(value);
|
|
@@ -77,4 +83,4 @@ export {
|
|
|
77
83
|
isFlowStubPreset,
|
|
78
84
|
generateFlowStub
|
|
79
85
|
};
|
|
80
|
-
//# sourceMappingURL=chunk-
|
|
86
|
+
//# sourceMappingURL=chunk-CY3DKTBZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/scaffolds.ts"],"sourcesContent":["const INIT_PRESETS = [\n \"local-web\",\n \"local-react-native\",\n \"capacitor-web-first\",\n \"browserstack\",\n \"saucelabs\",\n] as const;\nconst FLOW_STUB_PRESETS = [\"blank\", \"smoke\", \"auth\"] as const;\n\nexport type InitPreset = (typeof INIT_PRESETS)[number];\nexport type FlowStubPreset = (typeof FLOW_STUB_PRESETS)[number];\n\nexport function isInitPreset(value: string): value is InitPreset {\n return (INIT_PRESETS as readonly string[]).includes(value);\n}\n\nexport function isFlowStubPreset(value: string): value is FlowStubPreset {\n return (FLOW_STUB_PRESETS as readonly string[]).includes(value);\n}\n\nexport function generateFlowStub(\n name: string,\n opts: { platforms?: string[]; tags?: string[]; preset?: FlowStubPreset },\n): string {\n const preset = opts.preset ?? \"smoke\";\n const platforms = opts.platforms && opts.platforms.length > 0 ? opts.platforms : undefined;\n const tags = opts.tags && opts.tags.length > 0 ? opts.tags : [\"smoke\"];\n\n const configParts: string[] = [];\n configParts.push(`tags: [${tags.map((t) => `\"${t}\"`).join(\", \")}]`);\n if (platforms) {\n configParts.push(`platforms: [${platforms.map((p) => `\"${p}\"`).join(\", \")}]`);\n }\n const configStr = `{ ${configParts.join(\", \")} }`;\n\n if (preset === \"blank\") {\n return `import { flow } from \"spana-test\";\n\nexport default flow(\n \"${name}\",\n ${configStr},\n async ({ app, expect }) => {\n // Write your test flow here.\n // Run \"spana selectors --platform web\" to discover available selectors.\n },\n);\n`;\n }\n\n if (preset === \"auth\") {\n return `import { flow } from \"spana-test\";\n\nexport default flow(\n \"${name}\",\n ${configStr},\n async ({ app, expect, platform }) => {\n // Navigate to login screen\n await expect({ testID: \"login-email-input\" }).toBeVisible();\n\n // Enter credentials\n await app.tap({ testID: \"login-email-input\" });\n await app.inputText(\"user@example.com\");\n await app.dismissKeyboard();\n\n await app.tap({ testID: \"login-password-input\" });\n await app.inputText(\"password123\");\n await app.dismissKeyboard();\n\n // Submit\n await app.tap({ testID: \"login-submit-button\" });\n\n // Verify logged in\n await expect({ testID: \"home-screen\" }).toBeVisible({ timeout: 10_000 });\n },\n);\n`;\n }\n\n // Default: \"smoke\"\n return `import { flow } from \"spana-test\";\n\nexport default flow(\n \"${name}\",\n ${configStr},\n async ({ app, expect }) => {\n // Verify the app loads and the main screen is visible.\n // Replace with a selector from your app — run \"spana selectors\" to discover them.\n await expect({ testID: \"main-screen\" }).toBeVisible({ timeout: 10_000 });\n },\n);\n`;\n}\n"],"mappings":";AAAA,IAAM,eAAe;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,IAAM,oBAAoB,CAAC,SAAS,SAAS,MAAM;AAK5C,SAAS,aAAa,OAAoC;AAC/D,SAAQ,aAAmC,SAAS,KAAK;AAC3D;AAEO,SAAS,iBAAiB,OAAwC;AACvE,SAAQ,kBAAwC,SAAS,KAAK;AAChE;AAEO,SAAS,iBACd,MACA,MACQ;AACR,QAAM,SAAS,KAAK,UAAU;AAC9B,QAAM,YAAY,KAAK,aAAa,KAAK,UAAU,SAAS,IAAI,KAAK,YAAY;AACjF,QAAM,OAAO,KAAK,QAAQ,KAAK,KAAK,SAAS,IAAI,KAAK,OAAO,CAAC,OAAO;AAErE,QAAM,cAAwB,CAAC;AAC/B,cAAY,KAAK,UAAU,KAAK,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI,CAAC,GAAG;AAClE,MAAI,WAAW;AACb,gBAAY,KAAK,eAAe,UAAU,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI,CAAC,GAAG;AAAA,EAC9E;AACA,QAAM,YAAY,KAAK,YAAY,KAAK,IAAI,CAAC;AAE7C,MAAI,WAAW,SAAS;AACtB,WAAO;AAAA;AAAA;AAAA,KAGN,IAAI;AAAA,IACL,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOX;AAEA,MAAI,WAAW,QAAQ;AACrB,WAAO;AAAA;AAAA;AAAA,KAGN,IAAI;AAAA,IACL,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBX;AAGA,SAAO;AA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