@tangle-network/agent-runtime 0.44.0 → 0.45.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/README.md +95 -203
- package/dist/agent.d.ts +5 -4
- package/dist/agent.js +5 -7
- package/dist/agent.js.map +1 -1
- package/dist/analyst-loop.d.ts +65 -4
- package/dist/analyst-loop.js +6 -1
- package/dist/audit.d.ts +93 -0
- package/dist/audit.js +312 -0
- package/dist/audit.js.map +1 -0
- package/dist/chunk-4B6U4CVQ.js +15 -0
- package/dist/chunk-4B6U4CVQ.js.map +1 -0
- package/dist/chunk-FK53TXOP.js +603 -0
- package/dist/chunk-FK53TXOP.js.map +1 -0
- package/dist/{chunk-SKUZZCHE.js → chunk-IJ6FGOPO.js} +5 -5
- package/dist/chunk-IJ6FGOPO.js.map +1 -0
- package/dist/{chunk-HVYOHJHK.js → chunk-IJGS6J7X.js} +2 -2
- package/dist/chunk-IJGS6J7X.js.map +1 -0
- package/dist/chunk-KEWO4KI6.js +3599 -0
- package/dist/chunk-KEWO4KI6.js.map +1 -0
- package/dist/{chunk-NRZOXCJK.js → chunk-KSMX62JF.js} +2 -2
- package/dist/{chunk-GFKVVRQ7.js → chunk-NYN5RTLP.js} +11 -10
- package/dist/chunk-NYN5RTLP.js.map +1 -0
- package/dist/chunk-PRX45WE2.js +264 -0
- package/dist/chunk-PRX45WE2.js.map +1 -0
- package/dist/{chunk-3HMHSN22.js → chunk-QR4UUC5P.js} +6 -6
- package/dist/chunk-QR4UUC5P.js.map +1 -0
- package/dist/chunk-WIR4HOOJ.js +27 -0
- package/dist/chunk-WIR4HOOJ.js.map +1 -0
- package/dist/{chunk-KDMRUD2P.js → chunk-Z2QXVBA6.js} +296 -8
- package/dist/chunk-Z2QXVBA6.js.map +1 -0
- package/dist/coder-CczgMqFx.d.ts +114 -0
- package/dist/dynamic-BvllHV6M.d.ts +221 -0
- package/dist/{improvement-adapter-BC4HhuAR.d.ts → improvement-adapter-CWegd3vw.d.ts} +1 -1
- package/dist/improvement.d.ts +2 -3
- package/dist/improvement.js +0 -5
- package/dist/improvement.js.map +1 -1
- package/dist/index.d.ts +123 -10
- package/dist/index.js +398 -10
- package/dist/index.js.map +1 -1
- package/dist/{kb-gate-D0ZIhFOU.d.ts → kb-gate-D9GBocLN.d.ts} +82 -5
- package/dist/{loop-runner-bin-BLMa8He3.d.ts → loop-runner-bin-CPrCoKqC.d.ts} +14 -10
- package/dist/loop-runner-bin.d.ts +9 -7
- package/dist/loop-runner-bin.js +6 -8
- package/dist/loops.d.ts +7 -393
- package/dist/loops.js +94 -25
- package/dist/mcp/bin.js +7 -7
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/index.d.ts +284 -11
- package/dist/mcp/index.js +341 -9
- package/dist/mcp/index.js.map +1 -1
- package/dist/{otel-export-wFDmmurL.d.ts → otel-export-Dy2DyUCU.d.ts} +1 -1
- package/dist/profiles.d.ts +385 -86
- package/dist/profiles.js +549 -4
- package/dist/profiles.js.map +1 -1
- package/dist/{run-loop-C4L1Sted.d.ts → run-loop--hSoIknW.d.ts} +35 -12
- package/dist/runtime-hooks-C7JwKb9E.d.ts +70 -0
- package/dist/runtime.d.ts +1860 -0
- package/dist/runtime.js +114 -0
- package/dist/runtime.js.map +1 -0
- package/dist/substrate-CUgk7F7s.d.ts +77 -0
- package/dist/topology.d.ts +73 -0
- package/dist/topology.js +111 -0
- package/dist/topology.js.map +1 -0
- package/dist/types-1HbsFa7H.d.ts +438 -0
- package/dist/{types-p8dWBIXL.d.ts → types-BtRLF2U3.d.ts} +1 -1
- package/dist/{types-DbJzz2uf.d.ts → types-DdzkffAm.d.ts} +95 -1
- package/dist/workflow.d.ts +3 -2
- package/dist/workflow.js +4 -5
- package/dist/workflow.js.map +1 -1
- package/package.json +26 -6
- package/skills/agent-runtime-adoption/SKILL.md +29 -26
- package/dist/chunk-3HMHSN22.js.map +0 -1
- package/dist/chunk-GFKVVRQ7.js.map +0 -1
- package/dist/chunk-HVYOHJHK.js.map +0 -1
- package/dist/chunk-KDMRUD2P.js.map +0 -1
- package/dist/chunk-PY6NMZYX.js +0 -52
- package/dist/chunk-PY6NMZYX.js.map +0 -1
- package/dist/chunk-S7JXV32P.js +0 -947
- package/dist/chunk-S7JXV32P.js.map +0 -1
- package/dist/chunk-SKUZZCHE.js.map +0 -1
- package/dist/chunk-SQSCRJ7U.js +0 -65
- package/dist/chunk-SQSCRJ7U.js.map +0 -1
- package/dist/chunk-VOX6Z3II.js +0 -90
- package/dist/chunk-VOX6Z3II.js.map +0 -1
- package/dist/chunk-XBUG326M.js +0 -261
- package/dist/chunk-XBUG326M.js.map +0 -1
- package/dist/dynamic-wUgp6UKs.d.ts +0 -108
- package/dist/optimize-prompt-D-urF2wW.d.ts +0 -129
- /package/dist/{chunk-NRZOXCJK.js.map → chunk-KSMX62JF.js.map} +0 -0
package/dist/profiles.js
CHANGED
|
@@ -1,14 +1,559 @@
|
|
|
1
|
+
import {
|
|
2
|
+
slugify
|
|
3
|
+
} from "./chunk-4B6U4CVQ.js";
|
|
4
|
+
import {
|
|
5
|
+
UI_FINDING_SEVERITIES,
|
|
6
|
+
UI_LENSES
|
|
7
|
+
} from "./chunk-WIR4HOOJ.js";
|
|
1
8
|
import {
|
|
2
9
|
coderProfile,
|
|
3
10
|
createCoderValidator,
|
|
4
11
|
multiHarnessCoderFanout
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-PY6NMZYX.js";
|
|
7
|
-
import "./chunk-SQSCRJ7U.js";
|
|
12
|
+
} from "./chunk-QR4UUC5P.js";
|
|
8
13
|
import "./chunk-DGUM43GV.js";
|
|
14
|
+
|
|
15
|
+
// src/profiles/ui-auditor/prompt.ts
|
|
16
|
+
var ENVELOPE_BEGIN = "<<UI_AUDIT_TASK>>";
|
|
17
|
+
var ENVELOPE_END = "<<UI_AUDIT_TASK_END>>";
|
|
18
|
+
function encodeAuditTaskEnvelope(task) {
|
|
19
|
+
return `${ENVELOPE_BEGIN}${JSON.stringify(task)}${ENVELOPE_END}`;
|
|
20
|
+
}
|
|
21
|
+
function decodeAuditTaskEnvelope(prompt) {
|
|
22
|
+
const start = prompt.indexOf(ENVELOPE_BEGIN);
|
|
23
|
+
if (start === -1) return void 0;
|
|
24
|
+
const payloadStart = start + ENVELOPE_BEGIN.length;
|
|
25
|
+
const end = prompt.indexOf(ENVELOPE_END, payloadStart);
|
|
26
|
+
if (end === -1) return void 0;
|
|
27
|
+
const payload = prompt.slice(payloadStart, end);
|
|
28
|
+
try {
|
|
29
|
+
const parsed = JSON.parse(payload);
|
|
30
|
+
if (!parsed || typeof parsed !== "object") return void 0;
|
|
31
|
+
const t = parsed;
|
|
32
|
+
if (typeof t.lens !== "string" || !Array.isArray(t.captures)) return void 0;
|
|
33
|
+
return t;
|
|
34
|
+
} catch {
|
|
35
|
+
return void 0;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function formatAuditorPrompt(task) {
|
|
39
|
+
const lines = [];
|
|
40
|
+
lines.push(`# UI audit iteration \u2014 lens: ${task.lens}`);
|
|
41
|
+
lines.push("");
|
|
42
|
+
if (task.productContext && task.productContext.trim().length > 0) {
|
|
43
|
+
lines.push("## Product context");
|
|
44
|
+
lines.push(task.productContext.trim());
|
|
45
|
+
lines.push("");
|
|
46
|
+
}
|
|
47
|
+
lines.push("## Captures to take");
|
|
48
|
+
task.captures.forEach((cap, i) => {
|
|
49
|
+
const vp = cap.viewport ? `${cap.viewport.width}x${cap.viewport.height}` : "1280x800 (default)";
|
|
50
|
+
const detail = [
|
|
51
|
+
`viewport=${vp}`,
|
|
52
|
+
cap.fullPage ? "fullPage=true" : null,
|
|
53
|
+
cap.elementSelector ? `selector=\`${cap.elementSelector}\`` : null,
|
|
54
|
+
cap.waitFor ? `waitFor=\`${cap.waitFor}\`` : null,
|
|
55
|
+
cap.waitMs !== void 0 ? `waitMs=${cap.waitMs}` : null,
|
|
56
|
+
cap.label ? `label=${cap.label}` : null
|
|
57
|
+
].filter((s) => s !== null).join(" \xB7 ");
|
|
58
|
+
lines.push(`${i + 1}. route=\`${cap.route}\` url=${cap.url} ${detail ? `(${detail})` : ""}`);
|
|
59
|
+
});
|
|
60
|
+
lines.push("");
|
|
61
|
+
if (task.knownFindingIds && task.knownFindingIds.length > 0) {
|
|
62
|
+
lines.push("## Known findings (link via similarTo, do not refile)");
|
|
63
|
+
lines.push(task.knownFindingIds.map((n) => `#${String(n).padStart(3, "0")}`).join(", "));
|
|
64
|
+
lines.push("");
|
|
65
|
+
}
|
|
66
|
+
lines.push("## Output format");
|
|
67
|
+
lines.push(
|
|
68
|
+
"Emit a single JSON object with the shape `{ findings: UiFinding[], notes?: string }` where every finding has the fields enumerated in your system prompt. The screenshots field on each finding must reference the captures above by path. Do not emit findings outside the lens."
|
|
69
|
+
);
|
|
70
|
+
return lines.join("\n");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/profiles/ui-auditor/in-process-client.ts
|
|
74
|
+
function asSandboxEvent(type, data) {
|
|
75
|
+
return { type, data };
|
|
76
|
+
}
|
|
77
|
+
var DEFAULT_VIEWPORT = { width: 1280, height: 800 };
|
|
78
|
+
var NAV_TIMEOUT_MS = 3e4;
|
|
79
|
+
async function defaultLaunch() {
|
|
80
|
+
const mod = await import("playwright");
|
|
81
|
+
if (!mod?.chromium || typeof mod.chromium.launch !== "function") {
|
|
82
|
+
throw new Error(
|
|
83
|
+
"ui-auditor: playwright is not installed. Install `playwright` (and run `playwright install chromium`) or pass a custom `launchBrowser` to createInProcessUiAuditClient."
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
return mod.chromium.launch({ headless: true });
|
|
87
|
+
}
|
|
88
|
+
function nowStamp() {
|
|
89
|
+
const d = /* @__PURE__ */ new Date();
|
|
90
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
91
|
+
return `${d.getUTCFullYear()}${pad(d.getUTCMonth() + 1)}${pad(d.getUTCDate())}-${pad(d.getUTCHours())}${pad(d.getUTCMinutes())}${pad(d.getUTCSeconds())}-${String(d.getUTCMilliseconds()).padStart(3, "0")}`;
|
|
92
|
+
}
|
|
93
|
+
function viewportOf(req) {
|
|
94
|
+
return req.viewport ?? DEFAULT_VIEWPORT;
|
|
95
|
+
}
|
|
96
|
+
function captureFilename(req) {
|
|
97
|
+
const vp = viewportOf(req);
|
|
98
|
+
const labelPart = req.label ? `--${slugify(req.label, "label")}` : "";
|
|
99
|
+
return `${slugify(req.route, "route")}--${vp.width}x${vp.height}${labelPart}--${nowStamp()}.png`;
|
|
100
|
+
}
|
|
101
|
+
function assertHttpUrl(url) {
|
|
102
|
+
let parsed;
|
|
103
|
+
try {
|
|
104
|
+
parsed = new URL(url);
|
|
105
|
+
} catch {
|
|
106
|
+
throw new Error(`ui-auditor: capture url is not parseable (got ${JSON.stringify(url)})`);
|
|
107
|
+
}
|
|
108
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
109
|
+
throw new Error(
|
|
110
|
+
`ui-auditor: capture url must use http or https (got ${parsed.protocol} in ${JSON.stringify(url)})`
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async function captureOne(page, req, outAbsPath, signal, navPolicy) {
|
|
115
|
+
signal.throwIfAborted();
|
|
116
|
+
assertHttpUrl(req.url);
|
|
117
|
+
await page.setViewportSize(viewportOf(req));
|
|
118
|
+
const waitUntil = navPolicy === "spa" ? "domcontentloaded" : "networkidle";
|
|
119
|
+
await page.goto(req.url, { waitUntil, timeout: NAV_TIMEOUT_MS });
|
|
120
|
+
if (req.waitFor) {
|
|
121
|
+
await page.waitForSelector(req.waitFor, { timeout: 15e3 });
|
|
122
|
+
}
|
|
123
|
+
const extra = req.waitMs ?? 500;
|
|
124
|
+
if (extra > 0) await page.waitForTimeout(extra);
|
|
125
|
+
signal.throwIfAborted();
|
|
126
|
+
if (req.elementSelector) {
|
|
127
|
+
await page.locator(req.elementSelector).first().screenshot({ path: outAbsPath });
|
|
128
|
+
} else {
|
|
129
|
+
await page.screenshot({ path: outAbsPath, fullPage: req.fullPage === true });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function makeSandboxId() {
|
|
133
|
+
const rand = () => Math.random().toString(16).slice(2, 10);
|
|
134
|
+
return `ui-audit-${rand()}${rand()}`;
|
|
135
|
+
}
|
|
136
|
+
function createInProcessUiAuditClient(options) {
|
|
137
|
+
const launch = options.launchBrowser ?? defaultLaunch;
|
|
138
|
+
const navPolicy = options.navPolicy ?? "strict";
|
|
139
|
+
let browserPromise;
|
|
140
|
+
let closed = false;
|
|
141
|
+
async function getBrowser() {
|
|
142
|
+
if (closed) {
|
|
143
|
+
throw new Error("ui-auditor: client is closed; create a new client to run another iteration");
|
|
144
|
+
}
|
|
145
|
+
if (!browserPromise) browserPromise = launch();
|
|
146
|
+
return browserPromise;
|
|
147
|
+
}
|
|
148
|
+
async function* runIteration(promptText, signal) {
|
|
149
|
+
const task = decodeAuditTaskEnvelope(promptText);
|
|
150
|
+
if (!task) {
|
|
151
|
+
throw new Error(
|
|
152
|
+
"ui-auditor: prompt is missing a UI_AUDIT_TASK envelope. Use uiAuditorProfile().taskToPrompt to format prompts, or pass an envelope-prefixed prompt manually."
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
if (task.captures.length === 0) {
|
|
156
|
+
throw new Error("ui-auditor: task has zero captures; nothing to audit.");
|
|
157
|
+
}
|
|
158
|
+
yield asSandboxEvent("audit.lens", { lens: task.lens });
|
|
159
|
+
const browser = await getBrowser();
|
|
160
|
+
const context = await browser.newContext({ viewport: DEFAULT_VIEWPORT });
|
|
161
|
+
let primaryError;
|
|
162
|
+
let closeError;
|
|
163
|
+
try {
|
|
164
|
+
const page = await context.newPage();
|
|
165
|
+
const captures = [];
|
|
166
|
+
const fs = await import("fs/promises");
|
|
167
|
+
const path = await import("path");
|
|
168
|
+
const shotsDir = path.join(options.workspaceDir, "screenshots");
|
|
169
|
+
await fs.mkdir(shotsDir, { recursive: true });
|
|
170
|
+
for (const req of task.captures) {
|
|
171
|
+
signal.throwIfAborted();
|
|
172
|
+
const filename = captureFilename(req);
|
|
173
|
+
const absPath = path.join(shotsDir, filename);
|
|
174
|
+
const relPath = `screenshots/${filename}`;
|
|
175
|
+
await captureOne(page, req, absPath, signal, navPolicy);
|
|
176
|
+
const vp = viewportOf(req);
|
|
177
|
+
const cap = {
|
|
178
|
+
path: relPath,
|
|
179
|
+
viewport: `${vp.width}x${vp.height}`,
|
|
180
|
+
fullPage: req.fullPage === true,
|
|
181
|
+
route: req.route,
|
|
182
|
+
url: req.url,
|
|
183
|
+
capturedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
184
|
+
};
|
|
185
|
+
if (req.elementSelector) cap.elementSelector = req.elementSelector;
|
|
186
|
+
if (req.label) cap.label = req.label;
|
|
187
|
+
captures.push(cap);
|
|
188
|
+
yield asSandboxEvent("audit.capture", cap);
|
|
189
|
+
}
|
|
190
|
+
const judgeOut = await options.judge({
|
|
191
|
+
lens: task.lens,
|
|
192
|
+
captures,
|
|
193
|
+
productContext: task.productContext,
|
|
194
|
+
knownFindingIds: task.knownFindingIds,
|
|
195
|
+
promptText,
|
|
196
|
+
signal
|
|
197
|
+
});
|
|
198
|
+
for (const finding of judgeOut.findings) {
|
|
199
|
+
yield asSandboxEvent("audit.finding", finding);
|
|
200
|
+
}
|
|
201
|
+
if (judgeOut.notes && judgeOut.notes.trim().length > 0) {
|
|
202
|
+
yield asSandboxEvent("audit.notes", { notes: judgeOut.notes });
|
|
203
|
+
}
|
|
204
|
+
const usage = judgeOut.tokenUsage ?? { input: 0, output: 0 };
|
|
205
|
+
yield asSandboxEvent("done", {
|
|
206
|
+
tokenUsage: {
|
|
207
|
+
inputTokens: usage.input,
|
|
208
|
+
outputTokens: usage.output
|
|
209
|
+
},
|
|
210
|
+
totalCostUsd: judgeOut.costUsd ?? 0
|
|
211
|
+
});
|
|
212
|
+
} catch (err) {
|
|
213
|
+
primaryError = err;
|
|
214
|
+
} finally {
|
|
215
|
+
try {
|
|
216
|
+
await context.close();
|
|
217
|
+
} catch (err) {
|
|
218
|
+
closeError = err;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (primaryError !== void 0 && closeError !== void 0) {
|
|
222
|
+
throw new AggregateError(
|
|
223
|
+
[primaryError, closeError],
|
|
224
|
+
"ui-auditor: iteration failed AND context.close() failed; both errors attached."
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
if (primaryError !== void 0) throw primaryError;
|
|
228
|
+
if (closeError !== void 0) throw closeError;
|
|
229
|
+
}
|
|
230
|
+
function makeSyntheticSandbox() {
|
|
231
|
+
const id = makeSandboxId();
|
|
232
|
+
const instance = {
|
|
233
|
+
id,
|
|
234
|
+
streamPrompt(message, opts) {
|
|
235
|
+
const signal = opts?.signal ?? new AbortController().signal;
|
|
236
|
+
return runIteration(message, signal);
|
|
237
|
+
},
|
|
238
|
+
async delete() {
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
return instance;
|
|
242
|
+
}
|
|
243
|
+
return {
|
|
244
|
+
async create(_options) {
|
|
245
|
+
return makeSyntheticSandbox();
|
|
246
|
+
},
|
|
247
|
+
describePlacement(box) {
|
|
248
|
+
const id = box.id;
|
|
249
|
+
return { kind: "sibling", sandboxId: typeof id === "string" ? id : void 0 };
|
|
250
|
+
},
|
|
251
|
+
async close() {
|
|
252
|
+
closed = true;
|
|
253
|
+
const pending = browserPromise;
|
|
254
|
+
browserPromise = void 0;
|
|
255
|
+
if (pending) {
|
|
256
|
+
const browser = await pending;
|
|
257
|
+
await browser.close();
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// src/profiles/ui-auditor/lens-prompts.ts
|
|
264
|
+
var SHARED_AUDITOR_RULES = `
|
|
265
|
+
You are auditing a UI for a specific class of problems. Stay strictly in your assigned lens \u2014 do not file issues that belong to another lens (a separate iteration will catch those).
|
|
266
|
+
|
|
267
|
+
A finding is only valid if a thoughtful product designer would agree the screenshot shows something that should change. Avoid:
|
|
268
|
+
- Personal taste ("I'd prefer brand blue").
|
|
269
|
+
- Hallucinated text or controls you cannot actually see in the screenshot.
|
|
270
|
+
- Suggestions that depend on requirements you don't have access to.
|
|
271
|
+
- Pile-on findings about the same root cause \u2014 file ONE finding and use \`similarTo\` to link the rest.
|
|
272
|
+
|
|
273
|
+
Required for every finding:
|
|
274
|
+
- title: concrete, names the offending element AND what's wrong (NOT "improve UX").
|
|
275
|
+
- severity: critical=blocks a core task or accessibility blocker; high=noticeable friction; med=visible polish issue; low=nitpick.
|
|
276
|
+
- observation: 1\u20133 sentences describing exactly what you see that is wrong.
|
|
277
|
+
- impact: who is affected and how (concrete).
|
|
278
|
+
- suggestedFix: a specific change a developer could apply without asking you back.
|
|
279
|
+
- screenshots: refer to the captures attached to this iteration by path.
|
|
280
|
+
- selector: when you can pin the offending element with a CSS selector.
|
|
281
|
+
|
|
282
|
+
Most findings are med or low. Reserve high/critical for genuine blockers.
|
|
283
|
+
`.trim();
|
|
284
|
+
var LENS_BRIEFS = {
|
|
285
|
+
consistency: `
|
|
286
|
+
LENS: consistency
|
|
287
|
+
Look for inconsistencies in the design system \u2014 things that look like they came from different products glued together.
|
|
288
|
+
Signals: multiple font families, inconsistent weights/sizes for the same role, two shades of "primary", arbitrary paddings/margins that don't snap to a scale (4/8/12/16/24), same control with different border-radius or shadow on different pages, mixed icon styles (filled vs outlined), inconsistent button heights/padding for the same variant, inconsistent capitalization (Title Case vs sentence case) for the same role.
|
|
289
|
+
NOT this lens: layout misalignment (use \`layout\`), confusing user flow (use \`ux-flow\`), contrast/keyboard issues (use \`accessibility\`).
|
|
290
|
+
Title format: \`Inconsistent <thing> between <A> and <B>\`.
|
|
291
|
+
`.trim(),
|
|
292
|
+
hierarchy: `
|
|
293
|
+
LENS: hierarchy
|
|
294
|
+
Look for broken visual hierarchy \u2014 places where the eye does not land on what matters most.
|
|
295
|
+
Signals: primary CTA same weight as secondary/tertiary controls, headings (H1/H2/H3) nearly the same size, important data buried (headline number smaller than its label), decoration outshining content, too many emphases competing, wrong scan order, missing or overly heavy section dividers.
|
|
296
|
+
NOT this lens: same-role styled differently (\`consistency\`), grid/alignment (\`layout\`), contrast-failing text (\`accessibility\`).
|
|
297
|
+
Title format: \`Weak hierarchy: <element> does not read as the <intended-role>\`.
|
|
298
|
+
`.trim(),
|
|
299
|
+
layout: `
|
|
300
|
+
LENS: layout
|
|
301
|
+
Look for layout and organization problems \u2014 alignment, grouping, whitespace, structural choices that hurt scannability.
|
|
302
|
+
Signals: misalignment within rows, inconsistent gutters in grids, orphan whitespace next to crammed regions, poor grouping (related fields separated, unrelated fields adjacent), no visual sections (long wall of content), container overflow (text/content punching out of card boundaries), cramped or oversized hit targets, sidebars/headers sized wrong relative to main content.
|
|
303
|
+
NOT this lens: same-role styled differently (\`consistency\`), click-distance/friction (\`ux-flow\`), overflow specifically at small viewports (\`responsive\`).
|
|
304
|
+
Title format: \`<Region> alignment/spacing problem\` or \`<Region> grouping unclear\`.
|
|
305
|
+
`.trim(),
|
|
306
|
+
"ux-flow": `
|
|
307
|
+
LENS: ux-flow
|
|
308
|
+
Look for interaction-flow friction \u2014 action sequences that are slower, more annoying, or more error-prone than necessary.
|
|
309
|
+
Signals: sequential clicks far apart (e.g. Next top-right while user is bottom-left), destructive action adjacent to primary with same weight, confirmations that don't say what's being confirmed, primary CTA below the fold or hidden in a kebab menu, silent state changes (toggle gives no feedback), form ordering that fights real-world order, dead-end states after submit, lost inputs on back-navigation, hidden pre-selected options.
|
|
310
|
+
NOT this lens: visual style only (\`consistency\`), component arrangement without a flow problem (\`layout\`), microcopy clarity (\`content\`).
|
|
311
|
+
Title format: \`<Action A> \u2192 <Action B> friction: <root cause>\`.
|
|
312
|
+
`.trim(),
|
|
313
|
+
duplication: `
|
|
314
|
+
LENS: duplication
|
|
315
|
+
Look for redundancy \u2014 the same control, link, or piece of content appearing more than once with no good reason.
|
|
316
|
+
Signals: two ways to do the same action on the same screen with no difference, repeated nav (same links in sidebar AND top nav), drifted duplicates (two copies that have diverged), content repeated verbatim, icon + label saying the same thing twice in one row, per-row + bulk actions that overlap confusingly, multiple status indicators conveying the same status.
|
|
317
|
+
NOT this lens: inconsistent styling of duplicates (\`consistency\`) \u2014 this lens is about the existence of duplicates.
|
|
318
|
+
Title format: \`Duplicate <thing> in <location A> and <location B>\`.
|
|
319
|
+
`.trim(),
|
|
320
|
+
accessibility: `
|
|
321
|
+
LENS: accessibility
|
|
322
|
+
Look for accessibility blockers and degradations. Be conservative \u2014 do not assume violations you cannot see.
|
|
323
|
+
Signals: insufficient contrast on body text or controls, missing/invisible focus styles, tiny tap targets (<24px on mobile), color as sole signal (red border with no message), form labels missing or not associated (placeholders standing in for labels), broken heading order (H1 \u2192 H4), modals that don't trap focus, decorative elements that take focus, errors not announced, important text rendered inside images.
|
|
324
|
+
NOT this lens: generic "looks confusing" (\`hierarchy\` or \`content\`), layout overflow at small viewports (\`responsive\`).
|
|
325
|
+
Title format: \`Accessibility: <specific blocker> in <element>\`.
|
|
326
|
+
`.trim(),
|
|
327
|
+
responsive: `
|
|
328
|
+
LENS: responsive
|
|
329
|
+
Look for layout breakage across viewport sizes \u2014 content that works at one width but degrades at another. This iteration's captures should include the same surface at >=2 viewports; compare across them.
|
|
330
|
+
Signals: horizontal scroll where content should reflow, overlapping elements (header overlaps content, fixed footer covers inputs), desktop nav crammed into mobile without collapsing, table columns that don't truncate, tap targets too close at touch sizes, controls vanishing at certain widths, layout flips that break grouping order, modals exceeding viewport height (confirm button unreachable).
|
|
331
|
+
NOT this lens: issues present at every viewport (\`consistency\` / \`hierarchy\` instead).
|
|
332
|
+
Title format: \`<Element/Region> breaks at <viewport>\`.
|
|
333
|
+
`.trim(),
|
|
334
|
+
states: `
|
|
335
|
+
LENS: states
|
|
336
|
+
Look for missing or broken UI states \u2014 the not-happy-paths that make a product feel finished or unfinished. The iteration's captures should depict at least one non-default state.
|
|
337
|
+
Signals: empty lists with no guidance, skeletons that don't match final layout (CLS on settle), error states with no message or recovery action, disabled buttons with no explanation, toasts that disappear before being read, success states that don't confirm, missing hover/focus/active/disabled variants on primary controls, no long-content view, no-permission state broken.
|
|
338
|
+
NOT this lens: generic polish on the happy path (other lenses), missing focus rings specifically (\`accessibility\`).
|
|
339
|
+
Title format: \`Missing/broken <state> state on <surface>\`.
|
|
340
|
+
`.trim(),
|
|
341
|
+
content: `
|
|
342
|
+
LENS: content
|
|
343
|
+
Look for microcopy and content problems \u2014 text that is unclear, inconsistent, condescending, jargon-heavy, or wrong.
|
|
344
|
+
Signals: jargon/internal language leaking ("Provisioning a Tenant" instead of "Setting up your account"), inconsistent terminology (workspace vs team), verbose button labels, empty-state copy that's just "No results", error messages blaming the user, tone inconsistency, truncation without affordance, mixed date/number formats on one page, placeholder used as a label, "Saved!" toast appearing before save completes, typos and grammar errors.
|
|
345
|
+
NOT this lens: visual treatment of text (\`hierarchy\` / \`consistency\`), missing labels for a11y (\`accessibility\`).
|
|
346
|
+
Title format: \`Copy: "<actual text>" in <location>\` or \`Inconsistent term: "<A>" vs "<B>"\`.
|
|
347
|
+
`.trim(),
|
|
348
|
+
interaction: `
|
|
349
|
+
LENS: interaction
|
|
350
|
+
Look for interaction quality problems \u2014 affordances, feedback, and micro-interactions.
|
|
351
|
+
Signals: no affordance (clickable areas not looking clickable, non-clickable areas looking clickable), missing feedback (>100ms click with no progress), hover surprises (whole row highlights but only title clickable), cursor inconsistency, animations that block input, missing transitions where they're needed (accordion snaps open), drag-and-drop without indicators, scroll-jacking, click-through bugs (card click handler firing alongside button), hover-only revelations on touch.
|
|
352
|
+
NOT this lens: position of controls (\`layout\` / \`ux-flow\`), missing focus styles (\`accessibility\`).
|
|
353
|
+
Title format: \`<Action> on <element>: <missing/wrong> feedback\`.
|
|
354
|
+
`.trim(),
|
|
355
|
+
"performance-perceived": `
|
|
356
|
+
LENS: performance-perceived
|
|
357
|
+
Look for perceived-performance problems \u2014 visible jank a real user would notice, not benchmark numbers. This iteration's captures should include >=2 frames during load to show shift.
|
|
358
|
+
Signals: layout shift (CLS) when late-arriving images/fonts/banners settle, FOUC (flash of unstyled content), font swap jumps, late-loading hero images that shift everything, skeletons that don't match final shape, spinners on instant local actions, loading state reappearing after content paints (refetch on focus), modal open animation longer than the operation it precedes.
|
|
359
|
+
NOT this lens: slow API calls (file separately), stale data after navigation (\`states\`).
|
|
360
|
+
Title format: \`Layout shift / late paint on <route>: <root cause>\`.
|
|
361
|
+
`.trim(),
|
|
362
|
+
other: `
|
|
363
|
+
LENS: other
|
|
364
|
+
Use ONLY when a finding is clearly a UI quality issue but does not fit any other lens. Strongly prefer a specific lens \u2014 \`other\` should be rare. Title must still be concrete.
|
|
365
|
+
`.trim()
|
|
366
|
+
};
|
|
367
|
+
function buildAuditorSystemPrompt(lens) {
|
|
368
|
+
const brief = LENS_BRIEFS[lens];
|
|
369
|
+
return `${SHARED_AUDITOR_RULES}
|
|
370
|
+
|
|
371
|
+
${brief}`;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// src/profiles/ui-auditor/output-adapter.ts
|
|
375
|
+
var KNOWN_LENS_VALUES = new Set(UI_LENSES);
|
|
376
|
+
function isUiLens(v) {
|
|
377
|
+
return typeof v === "string" && KNOWN_LENS_VALUES.has(v);
|
|
378
|
+
}
|
|
379
|
+
function parseAuditorEvents(events) {
|
|
380
|
+
const findings = [];
|
|
381
|
+
const captures = [];
|
|
382
|
+
let lens;
|
|
383
|
+
let notes;
|
|
384
|
+
for (const evt of events) {
|
|
385
|
+
if (!evt || typeof evt !== "object") continue;
|
|
386
|
+
const type = String(evt.type ?? "");
|
|
387
|
+
const data = evt.data && typeof evt.data === "object" ? evt.data : void 0;
|
|
388
|
+
if (!data) continue;
|
|
389
|
+
switch (type) {
|
|
390
|
+
case "audit.lens": {
|
|
391
|
+
const v = data.lens;
|
|
392
|
+
if (isUiLens(v)) lens = v;
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
case "audit.capture": {
|
|
396
|
+
const cap = data;
|
|
397
|
+
if (typeof cap.path === "string" && typeof cap.viewport === "string" && typeof cap.fullPage === "boolean" && typeof cap.route === "string" && typeof cap.url === "string" && typeof cap.capturedAt === "string") {
|
|
398
|
+
const out2 = {
|
|
399
|
+
path: cap.path,
|
|
400
|
+
viewport: cap.viewport,
|
|
401
|
+
fullPage: cap.fullPage,
|
|
402
|
+
route: cap.route,
|
|
403
|
+
url: cap.url,
|
|
404
|
+
capturedAt: cap.capturedAt
|
|
405
|
+
};
|
|
406
|
+
if (cap.elementSelector) out2.elementSelector = cap.elementSelector;
|
|
407
|
+
if (cap.label) out2.label = cap.label;
|
|
408
|
+
captures.push(out2);
|
|
409
|
+
}
|
|
410
|
+
break;
|
|
411
|
+
}
|
|
412
|
+
case "audit.finding": {
|
|
413
|
+
const f = data;
|
|
414
|
+
if (typeof f.title === "string" && f.title.trim().length > 0 && isUiLens(f.lens) && typeof f.severity === "string" && ["low", "med", "high", "critical"].includes(f.severity) && typeof f.route === "string" && typeof f.observation === "string" && typeof f.impact === "string" && typeof f.suggestedFix === "string" && Array.isArray(f.screenshots)) {
|
|
415
|
+
findings.push(f);
|
|
416
|
+
}
|
|
417
|
+
break;
|
|
418
|
+
}
|
|
419
|
+
case "audit.notes": {
|
|
420
|
+
const n = data.notes;
|
|
421
|
+
if (typeof n === "string" && n.trim().length > 0) notes = n;
|
|
422
|
+
break;
|
|
423
|
+
}
|
|
424
|
+
default:
|
|
425
|
+
break;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
const out = { lens: lens ?? "other", findings, captures };
|
|
429
|
+
if (notes) out.notes = notes;
|
|
430
|
+
return out;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// src/profiles/ui-auditor/validator.ts
|
|
434
|
+
var GENERIC_TITLE_PATTERNS = [
|
|
435
|
+
/^improve\s/i,
|
|
436
|
+
/^fix\s/i,
|
|
437
|
+
/^update\s/i,
|
|
438
|
+
/^better\s/i,
|
|
439
|
+
/^bad\s/i,
|
|
440
|
+
/^make\s.+\sbetter/i,
|
|
441
|
+
/\bUX\b\s*$/i,
|
|
442
|
+
/\bUI\b\s*$/i
|
|
443
|
+
];
|
|
444
|
+
function isGenericTitle(title) {
|
|
445
|
+
const t = title.trim();
|
|
446
|
+
if (t.length < 16) return true;
|
|
447
|
+
return GENERIC_TITLE_PATTERNS.some((re) => re.test(t));
|
|
448
|
+
}
|
|
449
|
+
function createUiAuditorValidator(task) {
|
|
450
|
+
return {
|
|
451
|
+
async validate(output) {
|
|
452
|
+
const findings = output.findings;
|
|
453
|
+
const captures = output.captures;
|
|
454
|
+
const capturePaths = new Set(captures.map((c) => c.path));
|
|
455
|
+
const offLens = findings.filter((f) => f.lens !== task.lens);
|
|
456
|
+
if (offLens.length > 0) {
|
|
457
|
+
const verdict2 = {
|
|
458
|
+
valid: false,
|
|
459
|
+
score: 0,
|
|
460
|
+
notes: `${offLens.length} finding(s) filed under wrong lens (expected ${task.lens}; got ${offLens.map((f) => f.lens).join(", ")})`,
|
|
461
|
+
scores: { offLens: 0 }
|
|
462
|
+
};
|
|
463
|
+
return verdict2;
|
|
464
|
+
}
|
|
465
|
+
const missingEvidence = findings.filter(
|
|
466
|
+
(f) => !Array.isArray(f.screenshots) || f.screenshots.length === 0
|
|
467
|
+
);
|
|
468
|
+
if (missingEvidence.length > 0) {
|
|
469
|
+
const verdict2 = {
|
|
470
|
+
valid: false,
|
|
471
|
+
score: 0,
|
|
472
|
+
notes: `${missingEvidence.length} finding(s) have no screenshot evidence`,
|
|
473
|
+
scores: { evidence: 0 }
|
|
474
|
+
};
|
|
475
|
+
return verdict2;
|
|
476
|
+
}
|
|
477
|
+
const unresolvedShot = findings.filter(
|
|
478
|
+
(f) => f.screenshots.some((s) => !capturePaths.has(s.path))
|
|
479
|
+
);
|
|
480
|
+
if (unresolvedShot.length > 0) {
|
|
481
|
+
const verdict2 = {
|
|
482
|
+
valid: false,
|
|
483
|
+
score: 0,
|
|
484
|
+
notes: `${unresolvedShot.length} finding(s) reference screenshot paths not captured this iteration`,
|
|
485
|
+
scores: { evidence: 0 }
|
|
486
|
+
};
|
|
487
|
+
return verdict2;
|
|
488
|
+
}
|
|
489
|
+
if (findings.length === 0) {
|
|
490
|
+
const verdict2 = {
|
|
491
|
+
valid: true,
|
|
492
|
+
score: 0.5,
|
|
493
|
+
notes: "No findings reported. Neither a confident pass nor a failure.",
|
|
494
|
+
scores: { specificity: 0, evidence: 1, titles: 1 }
|
|
495
|
+
};
|
|
496
|
+
return verdict2;
|
|
497
|
+
}
|
|
498
|
+
const withSelector = findings.filter((f) => typeof f.selector === "string").length;
|
|
499
|
+
const specificity = withSelector / findings.length;
|
|
500
|
+
const generic = findings.filter((f) => isGenericTitle(f.title)).length;
|
|
501
|
+
const titles = 1 - generic / findings.length;
|
|
502
|
+
const withFullEvidence = findings.filter(
|
|
503
|
+
(f) => Array.isArray(f.screenshots) && f.screenshots.length > 0 && f.screenshots.every((s) => capturePaths.has(s.path))
|
|
504
|
+
).length;
|
|
505
|
+
const evidence = withFullEvidence / findings.length;
|
|
506
|
+
const score = Number((0.4 * specificity + 0.4 * evidence + 0.2 * titles).toFixed(4));
|
|
507
|
+
const verdict = {
|
|
508
|
+
valid: true,
|
|
509
|
+
score,
|
|
510
|
+
notes: `${findings.length} finding(s) \u2014 specificity=${specificity.toFixed(2)} evidence=${evidence.toFixed(2)} titles=${titles.toFixed(2)}`,
|
|
511
|
+
scores: { specificity, evidence, titles }
|
|
512
|
+
};
|
|
513
|
+
return verdict;
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
// src/profiles/ui-auditor/profile.ts
|
|
519
|
+
function uiAuditorProfile(options = {}) {
|
|
520
|
+
const name = options.name ?? "ui-auditor";
|
|
521
|
+
const profile = {
|
|
522
|
+
name,
|
|
523
|
+
description: "Vision-driven UI auditor. One lens per iteration.",
|
|
524
|
+
prompt: { systemPrompt: "" },
|
|
525
|
+
model: options.model ? { default: options.model } : void 0,
|
|
526
|
+
tools: { browser: true, vision: true },
|
|
527
|
+
metadata: { role: "ui-auditor" }
|
|
528
|
+
};
|
|
529
|
+
const output = { parse: parseAuditorEvents };
|
|
530
|
+
const validator = options.task ? createUiAuditorValidator(options.task) : createUiAuditorValidator({ lens: "other", captures: [] });
|
|
531
|
+
const taskToPrompt = (task) => `${encodeAuditTaskEnvelope(task)}
|
|
532
|
+
${buildAuditorSystemPrompt(task.lens)}
|
|
533
|
+
|
|
534
|
+
${formatAuditorPrompt(task)}`;
|
|
535
|
+
const agentRunSpec = {
|
|
536
|
+
name,
|
|
537
|
+
profile,
|
|
538
|
+
taskToPrompt
|
|
539
|
+
};
|
|
540
|
+
return { profile, taskToPrompt, output, validator, agentRunSpec };
|
|
541
|
+
}
|
|
9
542
|
export {
|
|
543
|
+
LENS_BRIEFS,
|
|
544
|
+
SHARED_AUDITOR_RULES,
|
|
545
|
+
UI_FINDING_SEVERITIES,
|
|
546
|
+
UI_LENSES,
|
|
547
|
+
buildAuditorSystemPrompt,
|
|
10
548
|
coderProfile,
|
|
11
549
|
createCoderValidator,
|
|
12
|
-
|
|
550
|
+
createInProcessUiAuditClient,
|
|
551
|
+
createUiAuditorValidator,
|
|
552
|
+
decodeAuditTaskEnvelope,
|
|
553
|
+
encodeAuditTaskEnvelope,
|
|
554
|
+
formatAuditorPrompt,
|
|
555
|
+
multiHarnessCoderFanout,
|
|
556
|
+
parseAuditorEvents,
|
|
557
|
+
uiAuditorProfile
|
|
13
558
|
};
|
|
14
559
|
//# sourceMappingURL=profiles.js.map
|