dsh-desktop-kit 2.24.1 → 2.30.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/CHANGELOG.md +71 -10
- package/README.md +193 -262
- package/client.js +1 -1
- package/docs/ARCHITECTURE.md +9 -6
- package/docs/PROPOSAL-2.25-quality-pipeline.md +435 -0
- package/docs/PROPOSAL-NEXUM-FINDINGS.md +259 -0
- package/docs/TEST-2.30.0.md +83 -0
- package/docs/images/capability-map-2.30.png +0 -0
- package/docs/images/hero-2.30.png +0 -0
- package/docs/images/quality-pipeline-2.30.png +0 -0
- package/docs/preview/capability-map-2.30.html +106 -0
- package/docs/preview/hero-2.30.html +133 -0
- package/docs/preview/quality-pipeline-2.30.html +142 -0
- package/docs/preview/readme-visuals.css +111 -0
- package/index.js +6 -0
- package/package.json +11 -4
- package/plugins/dsh-agent-extensions/lib/routing.js +4 -0
- package/plugins/dsh-agent-extensions/lib/scaffold.js +152 -27
- package/plugins/dsh-agent-extensions/lib/settings.js +19 -0
- package/plugins/dsh-agent-extensions/lib/swarm.js +6 -2
- package/plugins/dsh-browser-qa/index.js +202 -9
- package/plugins/dsh-browser-qa/lib/design-more.js +688 -0
- package/plugins/dsh-browser-qa/lib/extras.js +1313 -0
- package/plugins/dsh-browser-qa/lib/pages.js +4 -3
- package/plugins/dsh-browser-qa/lib/png.js +190 -0
- package/plugins/dsh-browser-qa/lib/ui-gate.js +171 -31
- package/plugins/dsh-i18n/README.md +36 -0
- package/plugins/dsh-i18n/cordis.patch.yml +3 -0
- package/plugins/dsh-i18n/index.js +294 -0
- package/plugins/dsh-i18n/lib/lang.js +179 -0
- package/plugins/dsh-i18n/package.json +29 -0
- package/plugins/dsh-quality-pipeline/README.md +53 -0
- package/plugins/dsh-quality-pipeline/cordis.patch.yml +3 -0
- package/plugins/dsh-quality-pipeline/index.js +647 -0
- package/plugins/dsh-quality-pipeline/lib/acceptance.js +132 -0
- package/plugins/dsh-quality-pipeline/lib/autostart.js +159 -0
- package/plugins/dsh-quality-pipeline/lib/design.js +123 -0
- package/plugins/dsh-quality-pipeline/lib/machine.js +312 -0
- package/plugins/dsh-quality-pipeline/lib/prework.js +215 -0
- package/plugins/dsh-quality-pipeline/lib/release.js +53 -0
- package/plugins/dsh-quality-pipeline/lib/schema.js +256 -0
- package/plugins/dsh-quality-pipeline/lib/store.js +114 -0
- package/plugins/dsh-quality-pipeline/lib/text.js +109 -0
- package/plugins/dsh-quality-pipeline/package.json +33 -0
- package/plugins/dsh-remote-ops/README.md +38 -0
- package/plugins/dsh-remote-ops/cordis.patch.yml +3 -0
- package/plugins/dsh-remote-ops/index.js +268 -0
- package/plugins/dsh-remote-ops/lib/hosts.js +118 -0
- package/plugins/dsh-remote-ops/lib/ssh.js +96 -0
- package/plugins/dsh-remote-ops/lib/state.js +66 -0
- package/plugins/dsh-remote-ops/package.json +31 -0
- package/plugins/dsh-skill-autopilot/index.js +204 -15
- package/skills/a11y-audit/SKILL.md +67 -0
- package/skills/cms-ops/SKILL.md +74 -0
- package/skills/design-system/SKILL.md +100 -0
- package/skills/legal-ru-web/SKILL.md +68 -0
- package/skills/manifest.json +38 -18
- package/skills/release-pipeline/SKILL.md +67 -0
- package/skills/ui-batch/SKILL.md +60 -0
- package/skills/web-build/SKILL.md +106 -0
- package/skills/web-build/recipes/form.md +16 -0
- package/skills/web-build/recipes/payment.md +16 -0
- package/skills/web-build/recipes/review.md +16 -0
- package/skills-baseline.json +192 -0
- package/skills/ui-design-system/references/accessibility-and-responsive.md +0 -50
- package/skills/ui-design-system/references/tokens-and-components.md +0 -67
- package/skills/ui-design-system/references/visual-qa.md +0 -44
- package/skills/visual-qa/references/commands.md +0 -32
- /package/skills/{ui-craft/SKILL.md → design-system/references/ui-craft.md} +0 -0
- /package/skills/{ui-design-system/SKILL.md → design-system/references/ui-design-system.md} +0 -0
- /package/skills/{visual-qa/SKILL.md → ui-batch/references/visual-qa.md} +0 -0
|
@@ -86,7 +86,7 @@ class ConsoleCollector {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
class PageSession {
|
|
89
|
+
export class PageSession {
|
|
90
90
|
constructor(cdp) {
|
|
91
91
|
this.cdp = cdp;
|
|
92
92
|
this.console = new ConsoleCollector(cdp);
|
|
@@ -285,7 +285,7 @@ class PageSession {
|
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
-
async function writeScreenshot(file, base64) {
|
|
288
|
+
export async function writeScreenshot(file, base64) {
|
|
289
289
|
await fsp.mkdir(path.dirname(file), { recursive: true });
|
|
290
290
|
const buffer = Buffer.from(base64, "base64");
|
|
291
291
|
await fsp.writeFile(file, buffer);
|
|
@@ -310,7 +310,7 @@ function signalCleanupAttach(signal, callback) {
|
|
|
310
310
|
* Run `fn` with a booted Chrome session. Always kills Chrome and removes the
|
|
311
311
|
* temp profile afterwards; cleanup warnings are appended to the result.
|
|
312
312
|
*/
|
|
313
|
-
async function withSession(options, fn) {
|
|
313
|
+
export async function withSession(options, fn) {
|
|
314
314
|
if (options.signal?.aborted) throw abortError();
|
|
315
315
|
const detected = options.executablePath
|
|
316
316
|
? { found: true, path: options.executablePath, kind: options.kind ?? "custom", source: "explicit" }
|
|
@@ -571,3 +571,4 @@ export async function statusReport(options = {}) {
|
|
|
571
571
|
status.text = formatStatusText(status);
|
|
572
572
|
return status;
|
|
573
573
|
}
|
|
574
|
+
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal PNG decode/encode for visual comparison.
|
|
3
|
+
*
|
|
4
|
+
* Only what Chrome emits and what we need: 8-bit, colour types 0 (gray),
|
|
5
|
+
* 2 (RGB), 6 (RGBA), non-interlaced. Everything else is reported as
|
|
6
|
+
* unsupported instead of being guessed.
|
|
7
|
+
*/
|
|
8
|
+
import { deflateSync, inflateSync } from "node:zlib";
|
|
9
|
+
|
|
10
|
+
const SIGNATURE = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
|
|
11
|
+
|
|
12
|
+
function crc32(buffer) {
|
|
13
|
+
let table = crc32.table;
|
|
14
|
+
if (!table) {
|
|
15
|
+
table = new Int32Array(256);
|
|
16
|
+
for (let index = 0; index < 256; index += 1) {
|
|
17
|
+
let value = index;
|
|
18
|
+
for (let bit = 0; bit < 8; bit += 1) value = value & 1 ? 0xedb88320 ^ (value >>> 1) : value >>> 1;
|
|
19
|
+
table[index] = value;
|
|
20
|
+
}
|
|
21
|
+
crc32.table = table;
|
|
22
|
+
}
|
|
23
|
+
let crc = -1;
|
|
24
|
+
for (const byte of buffer) crc = (crc >>> 8) ^ table[(crc ^ byte) & 0xff];
|
|
25
|
+
return (crc ^ -1) >>> 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function chunk(type, data) {
|
|
29
|
+
const length = Buffer.alloc(4);
|
|
30
|
+
length.writeUInt32BE(data.length, 0);
|
|
31
|
+
const name = Buffer.from(type, "ascii");
|
|
32
|
+
const crc = Buffer.alloc(4);
|
|
33
|
+
crc.writeUInt32BE(crc32(Buffer.concat([name, data])), 0);
|
|
34
|
+
return Buffer.concat([length, name, data, crc]);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Decode a PNG into {width, height, rgba}. Throws when unsupported. */
|
|
38
|
+
export function decodePng(buffer) {
|
|
39
|
+
if (!Buffer.isBuffer(buffer) || buffer.length < 8 || !buffer.subarray(0, 8).equals(SIGNATURE)) {
|
|
40
|
+
throw new Error("not a PNG");
|
|
41
|
+
}
|
|
42
|
+
let offset = 8;
|
|
43
|
+
let header = null;
|
|
44
|
+
const idat = [];
|
|
45
|
+
while (offset + 8 <= buffer.length) {
|
|
46
|
+
const length = buffer.readUInt32BE(offset);
|
|
47
|
+
const type = buffer.toString("ascii", offset + 4, offset + 8);
|
|
48
|
+
const data = buffer.subarray(offset + 8, offset + 8 + length);
|
|
49
|
+
offset += 12 + length;
|
|
50
|
+
if (type === "IHDR") {
|
|
51
|
+
header = {
|
|
52
|
+
width: data.readUInt32BE(0),
|
|
53
|
+
height: data.readUInt32BE(4),
|
|
54
|
+
bitDepth: data[8],
|
|
55
|
+
colorType: data[9],
|
|
56
|
+
interlace: data[12],
|
|
57
|
+
};
|
|
58
|
+
} else if (type === "IDAT") idat.push(data);
|
|
59
|
+
else if (type === "IEND") break;
|
|
60
|
+
}
|
|
61
|
+
if (!header) throw new Error("PNG without IHDR");
|
|
62
|
+
if (header.bitDepth !== 8) throw new Error(`unsupported bit depth ${header.bitDepth}`);
|
|
63
|
+
if (header.interlace !== 0) throw new Error("interlaced PNG is not supported");
|
|
64
|
+
const channels = header.colorType === 6 ? 4 : header.colorType === 2 ? 3 : header.colorType === 0 ? 1 : 0;
|
|
65
|
+
if (channels === 0) throw new Error(`unsupported colour type ${header.colorType}`);
|
|
66
|
+
const raw = inflateSync(Buffer.concat(idat));
|
|
67
|
+
const stride = header.width * channels;
|
|
68
|
+
const out = Buffer.alloc(header.width * header.height * 4);
|
|
69
|
+
let previous = Buffer.alloc(stride);
|
|
70
|
+
let position = 0;
|
|
71
|
+
for (let y = 0; y < header.height; y += 1) {
|
|
72
|
+
const filter = raw[position];
|
|
73
|
+
position += 1;
|
|
74
|
+
const line = Buffer.from(raw.subarray(position, position + stride));
|
|
75
|
+
position += stride;
|
|
76
|
+
for (let x = 0; x < stride; x += 1) {
|
|
77
|
+
const left = x >= channels ? line[x - channels] : 0;
|
|
78
|
+
const up = previous[x];
|
|
79
|
+
const upLeft = x >= channels ? previous[x - channels] : 0;
|
|
80
|
+
if (filter === 1) line[x] = (line[x] + left) & 0xff;
|
|
81
|
+
else if (filter === 2) line[x] = (line[x] + up) & 0xff;
|
|
82
|
+
else if (filter === 3) line[x] = (line[x] + ((left + up) >> 1)) & 0xff;
|
|
83
|
+
else if (filter === 4) {
|
|
84
|
+
const p = left + up - upLeft;
|
|
85
|
+
const pa = Math.abs(p - left);
|
|
86
|
+
const pb = Math.abs(p - up);
|
|
87
|
+
const pc = Math.abs(p - upLeft);
|
|
88
|
+
line[x] = (line[x] + (pa <= pb && pa <= pc ? left : pb <= pc ? up : upLeft)) & 0xff;
|
|
89
|
+
} else if (filter !== 0) throw new Error(`unknown PNG filter ${filter}`);
|
|
90
|
+
}
|
|
91
|
+
for (let x = 0; x < header.width; x += 1) {
|
|
92
|
+
const source = x * channels;
|
|
93
|
+
const target = (y * header.width + x) * 4;
|
|
94
|
+
if (channels === 4) {
|
|
95
|
+
out[target] = line[source];
|
|
96
|
+
out[target + 1] = line[source + 1];
|
|
97
|
+
out[target + 2] = line[source + 2];
|
|
98
|
+
out[target + 3] = line[source + 3];
|
|
99
|
+
} else if (channels === 3) {
|
|
100
|
+
out[target] = line[source];
|
|
101
|
+
out[target + 1] = line[source + 1];
|
|
102
|
+
out[target + 2] = line[source + 2];
|
|
103
|
+
out[target + 3] = 255;
|
|
104
|
+
} else {
|
|
105
|
+
out[target] = line[source];
|
|
106
|
+
out[target + 1] = line[source];
|
|
107
|
+
out[target + 2] = line[source];
|
|
108
|
+
out[target + 3] = 255;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
previous = line;
|
|
112
|
+
}
|
|
113
|
+
return { width: header.width, height: header.height, rgba: out };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Encode RGBA as a non-interlaced 8-bit PNG. */
|
|
117
|
+
export function encodePng({ width, height, rgba }) {
|
|
118
|
+
const stride = width * 4;
|
|
119
|
+
const raw = Buffer.alloc((stride + 1) * height);
|
|
120
|
+
for (let y = 0; y < height; y += 1) {
|
|
121
|
+
raw[y * (stride + 1)] = 0;
|
|
122
|
+
rgba.copy(raw, y * (stride + 1) + 1, y * stride, (y + 1) * stride);
|
|
123
|
+
}
|
|
124
|
+
const header = Buffer.alloc(13);
|
|
125
|
+
header.writeUInt32BE(width, 0);
|
|
126
|
+
header.writeUInt32BE(height, 4);
|
|
127
|
+
header[8] = 8;
|
|
128
|
+
header[9] = 6;
|
|
129
|
+
header[10] = 0;
|
|
130
|
+
header[11] = 0;
|
|
131
|
+
header[12] = 0;
|
|
132
|
+
return Buffer.concat([
|
|
133
|
+
SIGNATURE,
|
|
134
|
+
chunk("IHDR", header),
|
|
135
|
+
chunk("IDAT", deflateSync(raw, { level: 6 })),
|
|
136
|
+
chunk("IEND", Buffer.alloc(0)),
|
|
137
|
+
]);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Compare two decoded images. A pixel counts as changed when any of R/G/B
|
|
142
|
+
* differs by more than `tolerance` (antialiasing noise stays below it).
|
|
143
|
+
*/
|
|
144
|
+
export function compareImages(baseline, current, tolerance = 24) {
|
|
145
|
+
const width = Math.max(baseline.width, current.width);
|
|
146
|
+
const height = Math.max(baseline.height, current.height);
|
|
147
|
+
const diff = Buffer.alloc(width * height * 4);
|
|
148
|
+
let changed = 0;
|
|
149
|
+
let minX = width;
|
|
150
|
+
let minY = height;
|
|
151
|
+
let maxX = -1;
|
|
152
|
+
let maxY = -1;
|
|
153
|
+
for (let y = 0; y < height; y += 1) {
|
|
154
|
+
for (let x = 0; x < width; x += 1) {
|
|
155
|
+
const target = (y * width + x) * 4;
|
|
156
|
+
const inside = x < baseline.width && x < current.width && y < baseline.height && y < current.height;
|
|
157
|
+
let isChanged = !inside;
|
|
158
|
+
if (inside) {
|
|
159
|
+
const a = (y * baseline.width + x) * 4;
|
|
160
|
+
const b = (y * current.width + x) * 4;
|
|
161
|
+
isChanged =
|
|
162
|
+
Math.abs(baseline.rgba[a] - current.rgba[b]) > tolerance ||
|
|
163
|
+
Math.abs(baseline.rgba[a + 1] - current.rgba[b + 1]) > tolerance ||
|
|
164
|
+
Math.abs(baseline.rgba[a + 2] - current.rgba[b + 2]) > tolerance;
|
|
165
|
+
}
|
|
166
|
+
if (isChanged) {
|
|
167
|
+
changed += 1;
|
|
168
|
+
if (x < minX) minX = x;
|
|
169
|
+
if (y < minY) minY = y;
|
|
170
|
+
if (x > maxX) maxX = x;
|
|
171
|
+
if (y > maxY) maxY = y;
|
|
172
|
+
diff[target] = 255;
|
|
173
|
+
diff[target + 1] = 0;
|
|
174
|
+
diff[target + 2] = 0;
|
|
175
|
+
diff[target + 3] = 255;
|
|
176
|
+
} else {
|
|
177
|
+
const a = (y * baseline.width + x) * 4;
|
|
178
|
+
const gray = Math.round((baseline.rgba[a] * 299 + baseline.rgba[a + 1] * 587 + baseline.rgba[a + 2] * 114) / 1000);
|
|
179
|
+
const faded = Math.min(255, Math.round(gray * 0.35 + 160));
|
|
180
|
+
diff[target] = faded;
|
|
181
|
+
diff[target + 1] = faded;
|
|
182
|
+
diff[target + 2] = faded;
|
|
183
|
+
diff[target + 3] = 255;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const total = width * height;
|
|
188
|
+
const box = changed === 0 ? null : { x: minX, y: minY, width: maxX - minX + 1, height: maxY - minY + 1 };
|
|
189
|
+
return { width, height, changed, ratio: total === 0 ? 0 : changed / total, box, diff };
|
|
190
|
+
}
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hard UI gate for browser_qa.
|
|
3
3
|
*
|
|
4
|
-
* It observes UI file writes and browser_qa
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* It observes UI file writes and browser_qa results. At `agent/turn-stopping`
|
|
5
|
+
* a dirty session gets a steer message instead of being allowed to close: the
|
|
6
|
+
* model must run `audit matrix=full` until overflow, console errors and markup
|
|
7
|
+
* issues are zero.
|
|
8
|
+
*
|
|
9
|
+
* 2.24: when the project has a quality mission (`.dsh/quality/mission.json`)
|
|
10
|
+
* with a `standard` or `turnkey` profile, the gate is strict — a clean audit is
|
|
11
|
+
* no longer enough. The session must also have a fresh `a11y` run with zero
|
|
12
|
+
* serious issues, and a failing `interact` scenario keeps the turn open. That
|
|
13
|
+
* closes the "green audit, broken menu" hole: geometry is not behaviour.
|
|
14
|
+
*
|
|
15
|
+
* A bounded number of reminders prevents an accidental infinite turn.
|
|
9
16
|
*/
|
|
10
17
|
import crypto from "node:crypto";
|
|
18
|
+
import fs from "node:fs";
|
|
19
|
+
import os from "node:os";
|
|
20
|
+
import path from "node:path";
|
|
21
|
+
|
|
11
22
|
import { REQUIRED_ORIENTATIONS } from "./qa.js";
|
|
12
23
|
|
|
13
24
|
const UI_FILE = /\.(?:html?|xhtml|css|scss|sass|less|jsx|tsx|vue|svelte|astro|mdx)$/iu;
|
|
@@ -37,6 +48,50 @@ function sessionIdOf(ctx, actor, agent) {
|
|
|
37
48
|
}
|
|
38
49
|
}
|
|
39
50
|
|
|
51
|
+
function cwdOf(ctx, actor, agent) {
|
|
52
|
+
const direct = actor?.session?.header?.cwd ?? agent?.session?.header?.cwd;
|
|
53
|
+
if (typeof direct === "string" && direct.length > 0) return direct;
|
|
54
|
+
try {
|
|
55
|
+
const current = ctx.get?.("agents")?.currentInitiator?.();
|
|
56
|
+
return typeof current?.session?.header?.cwd === "string" ? current.session.header.cwd : "";
|
|
57
|
+
} catch {
|
|
58
|
+
return "";
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Kit-wide quality defaults, read straight from `~/.dsh/kit.settings.json`.
|
|
64
|
+
* The gate is strict out of the box (`profile: "standard"`), so a fresh
|
|
65
|
+
* install checks accessibility without any setup step.
|
|
66
|
+
*/
|
|
67
|
+
export function qualityDefaults() {
|
|
68
|
+
try {
|
|
69
|
+
const home = process.env.DSH_HOME || path.join(os.homedir(), ".dsh");
|
|
70
|
+
const raw = JSON.parse(fs.readFileSync(path.join(home, "kit.settings.json"), "utf8"));
|
|
71
|
+
const quality = raw?.quality ?? {};
|
|
72
|
+
const profile = ["fast", "standard", "turnkey"].includes(String(quality.profile)) ? String(quality.profile) : "standard";
|
|
73
|
+
return { enabled: quality.enabled !== false, profile };
|
|
74
|
+
} catch {
|
|
75
|
+
return { enabled: true, profile: "standard" };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Mission profile wins when a mission exists; otherwise the kit default. */
|
|
80
|
+
export function strictModeFor(cwd) {
|
|
81
|
+
if (!cwd) return false;
|
|
82
|
+
const settings = qualityDefaults();
|
|
83
|
+
if (!settings.enabled) return false;
|
|
84
|
+
try {
|
|
85
|
+
const raw = fs.readFileSync(path.join(cwd, ".dsh", "quality", "mission.json"), "utf8");
|
|
86
|
+
const mission = JSON.parse(raw);
|
|
87
|
+
if (mission?.profile === "standard" || mission?.profile === "turnkey") return true;
|
|
88
|
+
if (mission?.profile === "fast") return false;
|
|
89
|
+
} catch {
|
|
90
|
+
/* no mission: fall through to the kit default */
|
|
91
|
+
}
|
|
92
|
+
return settings.profile !== "fast";
|
|
93
|
+
}
|
|
94
|
+
|
|
40
95
|
function findAudit(value, depth = 0) {
|
|
41
96
|
if (!value || typeof value !== "object" || depth > 4) return null;
|
|
42
97
|
if (value.summary && (Array.isArray(value.reports) || value.summary.widthsChecked !== undefined || value.summary.markupIssues !== undefined)) {
|
|
@@ -99,6 +154,27 @@ function auditFromText(result) {
|
|
|
99
154
|
};
|
|
100
155
|
}
|
|
101
156
|
|
|
157
|
+
/** `serious 0 · moderate 2 · minor 1 · фокус: невидим 0, перекрыт 0` */
|
|
158
|
+
function a11yFromText(result) {
|
|
159
|
+
const text = resultText(result);
|
|
160
|
+
if (!text.includes("browser_qa a11y:")) return null;
|
|
161
|
+
const counts = text.match(/serious (\d+) · moderate (\d+) · minor (\d+)/u);
|
|
162
|
+
if (!counts) return null;
|
|
163
|
+
return {
|
|
164
|
+
serious: Number(counts[1]),
|
|
165
|
+
moderate: Number(counts[2]),
|
|
166
|
+
minor: Number(counts[3]),
|
|
167
|
+
pass: /Итог: PASS/u.test(text),
|
|
168
|
+
focusObscured: Number((text.match(/перекрыт (\d+)/u) ?? [])[1] ?? 0),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function interactFromText(result) {
|
|
173
|
+
const text = resultText(result);
|
|
174
|
+
if (!text.includes("browser_qa interact:")) return null;
|
|
175
|
+
return { pass: /Итог: PASS/u.test(text), text: text.slice(0, 400) };
|
|
176
|
+
}
|
|
177
|
+
|
|
102
178
|
/**
|
|
103
179
|
* A clean audit means zero overflow, console and markup issues *and* coverage
|
|
104
180
|
* of every required orientation. Phones and tablets in both orientations are
|
|
@@ -131,7 +207,19 @@ export function createUiGate(ctx) {
|
|
|
131
207
|
function stateFor(sessionId) {
|
|
132
208
|
let state = states.get(sessionId);
|
|
133
209
|
if (!state) {
|
|
134
|
-
state = {
|
|
210
|
+
state = {
|
|
211
|
+
dirty: false,
|
|
212
|
+
lastEditAt: 0,
|
|
213
|
+
auditAt: 0,
|
|
214
|
+
clean: false,
|
|
215
|
+
summary: null,
|
|
216
|
+
a11yAt: 0,
|
|
217
|
+
a11y: null,
|
|
218
|
+
interactAt: 0,
|
|
219
|
+
interact: null,
|
|
220
|
+
paths: new Set(),
|
|
221
|
+
reminders: 0,
|
|
222
|
+
};
|
|
135
223
|
states.set(sessionId, state);
|
|
136
224
|
if (states.size > 200) states.delete(states.keys().next().value);
|
|
137
225
|
}
|
|
@@ -145,6 +233,11 @@ export function createUiGate(ctx) {
|
|
|
145
233
|
if (!sessionId) return;
|
|
146
234
|
const state = stateFor(sessionId);
|
|
147
235
|
state.dirty = true;
|
|
236
|
+
/* Any new UI write invalidates earlier evidence: a stale green audit is
|
|
237
|
+
* exactly how "done" used to be claimed before the change was checked. */
|
|
238
|
+
state.clean = false;
|
|
239
|
+
state.a11y = null;
|
|
240
|
+
state.interact = null;
|
|
148
241
|
state.lastEditAt = Date.now();
|
|
149
242
|
state.reminders = 0;
|
|
150
243
|
state.paths.add(file);
|
|
@@ -154,23 +247,71 @@ export function createUiGate(ctx) {
|
|
|
154
247
|
function onToolResult(exec, result) {
|
|
155
248
|
if (exec?.name !== "browser_qa") return;
|
|
156
249
|
const action = exec?.arguments?.action ?? exec?.args?.action ?? exec?.input?.action;
|
|
157
|
-
if (
|
|
158
|
-
const payload = findAudit(result) ?? auditFromText(result);
|
|
159
|
-
if (!payload) return;
|
|
250
|
+
if (!["audit", "a11y", "interact"].includes(String(action))) return;
|
|
160
251
|
const sessionId = sessionIdOf(ctx, exec?.agent, exec?.agent);
|
|
161
252
|
if (!sessionId) return;
|
|
162
253
|
const state = stateFor(sessionId);
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
state.
|
|
168
|
-
state.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
254
|
+
if (action === "audit") {
|
|
255
|
+
const payload = findAudit(result) ?? auditFromText(result);
|
|
256
|
+
if (!payload) return;
|
|
257
|
+
state.auditAt = Date.now();
|
|
258
|
+
state.clean = cleanAudit(payload.summary);
|
|
259
|
+
state.summary = payload.summary ?? null;
|
|
260
|
+
logger?.debug?.(`[ui-gate] ${sessionId}: ${summaryText(payload.summary)}`);
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (action === "a11y") {
|
|
264
|
+
const parsed = a11yFromText(result);
|
|
265
|
+
if (!parsed) return;
|
|
266
|
+
state.a11yAt = Date.now();
|
|
267
|
+
state.a11y = parsed;
|
|
268
|
+
logger?.debug?.(`[ui-gate] ${sessionId}: a11y serious ${parsed.serious}`);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const parsed = interactFromText(result);
|
|
272
|
+
if (!parsed) return;
|
|
273
|
+
state.interactAt = Date.now();
|
|
274
|
+
state.interact = parsed;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** What still blocks the turn, in the order the model should fix it. */
|
|
278
|
+
function unmetChecks(state, strict) {
|
|
279
|
+
const missing = [];
|
|
280
|
+
if (!state.auditAt || !state.clean) missing.push("audit");
|
|
281
|
+
else if (state.summary && !state.summary.matrixComplete) missing.push("matrix");
|
|
282
|
+
if (!strict) return missing;
|
|
283
|
+
if (!state.a11yAt || state.a11yAt < state.lastEditAt) missing.push("a11y-missing");
|
|
284
|
+
else if (Number(state.a11y?.serious ?? 0) > 0) missing.push("a11y-issues");
|
|
285
|
+
if (state.interactAt >= state.lastEditAt && state.interact && state.interact.pass !== true) missing.push("interact-fail");
|
|
286
|
+
return missing;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function steerText(state, strict, missing) {
|
|
290
|
+
const files = [...state.paths].slice(0, 6).join(", ") || "UI-файлы";
|
|
291
|
+
const lines = [
|
|
292
|
+
"<ui-gate>",
|
|
293
|
+
`Изменены UI-файлы: ${files}.`,
|
|
294
|
+
`Последний ${summaryText(state.summary)}.`,
|
|
295
|
+
];
|
|
296
|
+
if (missing.includes("audit")) {
|
|
297
|
+
lines.push("Ход не закрыт: запусти browser_qa action=audit matrix=full (телефон 390×844 и 844×390, планшет 768×1024 и 1024×768, десктоп 1440×900; лучше с outDir).");
|
|
298
|
+
lines.push("Overflow проверяй отдельно на каждой ширине и ориентации: назови элементы-виновники, почини, прогони audit заново.");
|
|
299
|
+
lines.push("Исправь также console errors и markup (alt, label, duplicate id, heading order). Не заявляй «готово», пока audit не чистый и покрытие не 4/4.");
|
|
300
|
+
}
|
|
301
|
+
if (missing.includes("matrix")) {
|
|
302
|
+
lines.push("Аудит чистый, но покрытие неполное: прогони browser_qa action=audit matrix=full (нужно 4/4: phone/tablet × portrait/landscape).");
|
|
303
|
+
}
|
|
304
|
+
if (missing.includes("a11y-missing")) {
|
|
305
|
+
lines.push("Гейт качества (профиль standard/turnkey) требует доступность: запусти browser_qa action=a11y на том же URL и почини всё serious (контраст, имена, label, тап-таргеты).");
|
|
172
306
|
}
|
|
173
|
-
|
|
307
|
+
if (missing.includes("a11y-issues")) {
|
|
308
|
+
lines.push(`browser_qa a11y нашёл serious ${state.a11y?.serious ?? "?"}: почини и прогони a11y заново — порог 0.`);
|
|
309
|
+
}
|
|
310
|
+
if (missing.includes("interact-fail")) {
|
|
311
|
+
lines.push("Сценарий browser_qa action=interact упал: элемент перекрыт, невидим или не прошло ожидание. Почини и прогони сценарий заново.");
|
|
312
|
+
}
|
|
313
|
+
lines.push("</ui-gate>");
|
|
314
|
+
return lines.join("\n");
|
|
174
315
|
}
|
|
175
316
|
|
|
176
317
|
async function turnStopping(payload) {
|
|
@@ -179,22 +320,21 @@ export function createUiGate(ctx) {
|
|
|
179
320
|
if (!sessionId) return;
|
|
180
321
|
const state = states.get(sessionId);
|
|
181
322
|
if (!state?.dirty) return;
|
|
323
|
+
const strict = strictModeFor(cwdOf(ctx, agent, agent));
|
|
324
|
+
const missing = unmetChecks(state, strict);
|
|
325
|
+
if (missing.length === 0) {
|
|
326
|
+
state.dirty = false;
|
|
327
|
+
state.reminders = 0;
|
|
328
|
+
state.paths.clear();
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
182
331
|
if (state.reminders >= MAX_REMINDERS) {
|
|
183
|
-
logger?.warn?.(`[ui-gate] ${sessionId}: ${MAX_REMINDERS} reminders without
|
|
332
|
+
logger?.warn?.(`[ui-gate] ${sessionId}: ${MAX_REMINDERS} reminders without clean checks (${missing.join(", ")}); allowing the turn to close`);
|
|
184
333
|
state.dirty = false;
|
|
185
334
|
return;
|
|
186
335
|
}
|
|
187
336
|
state.reminders += 1;
|
|
188
|
-
const
|
|
189
|
-
const text = [
|
|
190
|
-
"<ui-gate>",
|
|
191
|
-
`Изменены UI-файлы: ${files}.`,
|
|
192
|
-
`Последний ${summaryText(state.summary)}.`,
|
|
193
|
-
"Ход не закрыт: запусти browser_qa action=audit matrix=full (телефон 390×844 и 844×390, планшет 768×1024 и 1024×768, десктоп 1440×900; лучше с outDir).",
|
|
194
|
-
"Overflow проверяй отдельно на каждой ширине и ориентации: назови элементы-виновники, почини, прогони audit заново.",
|
|
195
|
-
"Исправь также console errors и markup (alt, label, duplicate id, heading order). Не заявляй «готово», пока audit не чистый и покрытие не 4/4.",
|
|
196
|
-
"</ui-gate>",
|
|
197
|
-
].join("\n");
|
|
337
|
+
const text = steerText(state, strict, missing);
|
|
198
338
|
try {
|
|
199
339
|
agent.steer({
|
|
200
340
|
id: crypto.randomUUID(),
|
|
@@ -202,7 +342,7 @@ export function createUiGate(ctx) {
|
|
|
202
342
|
content: [{ type: "text", text }],
|
|
203
343
|
source: { kind: "user" },
|
|
204
344
|
});
|
|
205
|
-
logger?.info?.(`[ui-gate] ${sessionId}: steered
|
|
345
|
+
logger?.info?.(`[ui-gate] ${sessionId}: steered (${missing.join(", ")})`);
|
|
206
346
|
} catch (error) {
|
|
207
347
|
logger?.warn?.(`[ui-gate] ${sessionId}: steer failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
208
348
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# dsh-i18n
|
|
2
|
+
|
|
3
|
+
Перевод интерфейса как процесс, а не 53 чата.
|
|
4
|
+
|
|
5
|
+
## Действия
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
i18n_sync action=coverage base=lang/ru
|
|
9
|
+
→ ключей 412 · в коде 455 · missing-in-dict 43 · unused 21
|
|
10
|
+
|
|
11
|
+
i18n_sync action=diff base=lang/ru extra=en,zh-CN,ar
|
|
12
|
+
→ en: missing 120 · extra 3 · untranslated 8 · placeholder-mismatch 1
|
|
13
|
+
|
|
14
|
+
i18n_sync action=plan lang=zh-CN # список порций
|
|
15
|
+
i18n_sync action=plan lang=zh-CN batch=1 # JSON для перевода: .dsh/i18n-zh-CN-batch-1.json
|
|
16
|
+
|
|
17
|
+
i18n_sync action=apply lang=zh-CN file=.dsh/i18n-zh-CN-batch-1.json
|
|
18
|
+
→ проверка плейсхолдеров, запись, бэкап <file>.php.bak
|
|
19
|
+
|
|
20
|
+
i18n_sync action=check lang=ar # плейсхолдеры + эвристика RTL
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Форматы
|
|
24
|
+
|
|
25
|
+
Laravel: `lang/<locale>/<file>.php` (`return ['key' => 'value'];`) и плоский JSON
|
|
26
|
+
`lang/<locale>/<file>.json`. Полный ключ — `<file>.<key>`, как в `__('admin.title')`.
|
|
27
|
+
|
|
28
|
+
## Правила
|
|
29
|
+
|
|
30
|
+
- `apply` не пишет перевод, если набор плейсхолдеров (`:count`, `{name}`, `%s`) не совпадает с базой,
|
|
31
|
+
и не пишет пустые значения. Перед записью создаётся `.bak`.
|
|
32
|
+
- `coverage` ищет вызовы `__()`, `@lang`, `trans()`, `Lang::get()` в `resources/views`,
|
|
33
|
+
`resources/js`, `app`, `src`, `templates`.
|
|
34
|
+
- `check lang=ar` дополнительно предупреждает о значениях без арабских символов (признак непереведённого).
|
|
35
|
+
- Вложенные PHP-массивы читаются плоско; для Laravel это норма (ключи и так плоские), для
|
|
36
|
+
вложенных словарей используйте JSON.
|