dsh-desktop-kit 2.24.0 → 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 +74 -6
- package/README.md +192 -291
- package/client.js +1 -1
- package/cordis.patch.yml +5 -151
- package/docs/ARCHITECTURE.md +10 -16
- package/docs/COMPATIBILITY.md +1 -1
- package/docs/DEVELOPMENT.md +0 -1
- package/docs/PROPOSAL-2.25-quality-pipeline.md +435 -0
- package/docs/PROPOSAL-NEXUM-FINDINGS.md +259 -0
- package/docs/TEST-2.24.1.md +66 -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/docs/TEST-2.24.0.md +0 -123
- 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
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase machine and gate evaluation for a quality mission.
|
|
3
|
+
*
|
|
4
|
+
* The rules are deliberately boring and deterministic: a phase can be entered
|
|
5
|
+
* only when every required gate of the previous phases is passed, and a gate
|
|
6
|
+
* can be passed only with a non-empty evidence string. No LLM decides whether
|
|
7
|
+
* a gate is green — the tool does.
|
|
8
|
+
*/
|
|
9
|
+
import { briefGateCheck } from "./design.js";
|
|
10
|
+
import { preworkGateCheck } from "./prework.js";
|
|
11
|
+
import {
|
|
12
|
+
GATES,
|
|
13
|
+
PHASES,
|
|
14
|
+
PROFILE_GATES,
|
|
15
|
+
QUALITY_PROFILES,
|
|
16
|
+
gateById,
|
|
17
|
+
phaseIndex,
|
|
18
|
+
pushHistory,
|
|
19
|
+
requiredGates,
|
|
20
|
+
touch,
|
|
21
|
+
} from "./schema.js";
|
|
22
|
+
|
|
23
|
+
export const EVIDENCE_MIN_CHARS = 12;
|
|
24
|
+
export const MAX_REMINDERS = 3;
|
|
25
|
+
|
|
26
|
+
export function profileOf(mission) {
|
|
27
|
+
const profile = String(mission?.profile ?? "");
|
|
28
|
+
return QUALITY_PROFILES.includes(profile) ? profile : "standard";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function requiredFor(mission) {
|
|
32
|
+
return requiredGates(profileOf(mission));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function gateState(mission, gateId) {
|
|
36
|
+
const gate = gateById(gateId);
|
|
37
|
+
if (!gate) return null;
|
|
38
|
+
const state = mission?.gates?.[gate.id] ?? { status: "pending" };
|
|
39
|
+
if (!gate.unitScoped) return state;
|
|
40
|
+
const units = state.units && typeof state.units === "object" ? Object.values(state.units) : [];
|
|
41
|
+
const passedUnits = units.filter((unit) => unit?.status === "passed").length;
|
|
42
|
+
const status = units.length > 0 && passedUnits === units.length ? "passed" : state.status === "failed" ? "failed" : "pending";
|
|
43
|
+
return { ...state, status, passedUnits, totalUnits: units.length };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function gateIsPassed(mission, gateId) {
|
|
47
|
+
return gateState(mission, gateId)?.status === "passed";
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function phaseRequiredGates(phase) {
|
|
51
|
+
return GATES.filter((gate) => gate.phase === phase).map((gate) => gate.id);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Gates that must be green before `target` can be entered. */
|
|
55
|
+
export function blockingGates(mission, target) {
|
|
56
|
+
const targetIndex = phaseIndex(target);
|
|
57
|
+
if (targetIndex < 0) return [];
|
|
58
|
+
const required = new Set(requiredFor(mission));
|
|
59
|
+
return GATES.filter((gate) => required.has(gate.id) && phaseIndex(gate.phase) < targetIndex).map((gate) => gate.id);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function canEnterPhase(mission, target) {
|
|
63
|
+
const targetIndex = phaseIndex(target);
|
|
64
|
+
if (targetIndex < 0) return { ok: false, reason: `неизвестная фаза: ${target}` };
|
|
65
|
+
if (target === "fix") return { ok: true, reason: "" };
|
|
66
|
+
const missing = blockingGates(mission, target).filter((id) => !gateIsPassed(mission, id));
|
|
67
|
+
if (missing.length === 0) return { ok: true, reason: "" };
|
|
68
|
+
const titles = missing.map((id) => `${id} ${gateById(id)?.title ?? ""}`.trim());
|
|
69
|
+
return { ok: false, reason: `сначала закройте гейты: ${titles.join("; ")}`, missing };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Move to the next phase; `handoff` additionally requires the acceptance PASS. */
|
|
73
|
+
export function advancePhase(mission, target) {
|
|
74
|
+
const wanted = target ?? PHASES[phaseIndex(mission.phase) + 1];
|
|
75
|
+
if (!wanted) return { ok: false, reason: "миссия уже в последней фазе" };
|
|
76
|
+
if (!PHASES.includes(wanted)) return { ok: false, reason: `неизвестная фаза: ${wanted}` };
|
|
77
|
+
const check = canEnterPhase(mission, wanted);
|
|
78
|
+
if (!check.ok) return { ok: false, reason: check.reason, missing: check.missing };
|
|
79
|
+
if (wanted === "handoff") {
|
|
80
|
+
const acceptance = acceptanceVerdict(mission);
|
|
81
|
+
if (acceptance.required > 0 && !acceptance.pass) {
|
|
82
|
+
return { ok: false, reason: `приёмка не пройдена: ${acceptance.failed} из ${acceptance.required} проверок не PASS (quality_gate action=accept run=true)`, missing: ["G11"] };
|
|
83
|
+
}
|
|
84
|
+
const needsRelease = requiredFor(mission).includes("G13");
|
|
85
|
+
if (needsRelease) {
|
|
86
|
+
const release = releaseVerdict(mission);
|
|
87
|
+
if (release.total === 0) {
|
|
88
|
+
return { ok: false, reason: "профиль turnkey требует релиза: добавьте шаги в release (quality_gate action=release run=true)", missing: ["G13"] };
|
|
89
|
+
}
|
|
90
|
+
if (!release.pass) {
|
|
91
|
+
return { ok: false, reason: `релиз не пройден: ${release.failed} из ${release.required} шагов не PASS (quality_gate action=release run=true)`, missing: ["G13"] };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const from = mission.phase;
|
|
96
|
+
mission.phase = wanted;
|
|
97
|
+
pushHistory(mission, `phase ${from} -> ${wanted}`);
|
|
98
|
+
return { ok: true, reason: "", mission: touch(mission) };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function acceptanceVerdict(mission) {
|
|
102
|
+
const items = Array.isArray(mission?.acceptance) ? mission.acceptance : [];
|
|
103
|
+
const withCommand = items.filter((item) => typeof item.command === "string" && item.command.length > 0);
|
|
104
|
+
const passed = withCommand.filter((item) => item.status === "pass").length;
|
|
105
|
+
const failed = withCommand.filter((item) => item.status !== "pass").length;
|
|
106
|
+
return { required: withCommand.length, passed, failed, pass: withCommand.length > 0 && failed === 0 };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function releaseVerdict(mission) {
|
|
110
|
+
const steps = Array.isArray(mission?.release?.steps) ? mission.release.steps : [];
|
|
111
|
+
const withCommand = steps.filter((step) => typeof step.command === "string" && step.command.length > 0);
|
|
112
|
+
const passed = withCommand.filter((step) => step.status === "pass").length;
|
|
113
|
+
return { total: steps.length, required: withCommand.length, passed, failed: withCommand.length - passed, pass: withCommand.length > 0 && passed === withCommand.length };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function passGate(mission, gateId, options = {}) {
|
|
117
|
+
const gate = gateById(gateId);
|
|
118
|
+
if (!gate) return { ok: false, reason: `неизвестный гейт: ${gateId}` };
|
|
119
|
+
if (["G0", "G1", "G2"].includes(gate.id)) {
|
|
120
|
+
const check = preworkGateCheck(mission, gate.id);
|
|
121
|
+
if (!check.ok) {
|
|
122
|
+
return { ok: false, reason: `${gate.id} не закрывается: ${check.missing.join("; ")}` };
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (gate.id === "G4" && String(mission.profile) !== "fast") {
|
|
126
|
+
const unit = (mission.units ?? []).find((item) => item.id === String(options.unit ?? ""));
|
|
127
|
+
if (!unit && !options.unit) return { ok: false, reason: "G4 привязан к единице: передайте unit=u1" };
|
|
128
|
+
if (!unit) return { ok: false, reason: `единица не найдена: ${options.unit}` };
|
|
129
|
+
if ((unit.dod ?? []).length === 0) return { ok: false, reason: `G4 требует DoD единицы ${unit.id}: добавьте dod=[…] действие plan/unit` };
|
|
130
|
+
}
|
|
131
|
+
if (gate.id === "G3") {
|
|
132
|
+
const check = briefGateCheck(mission);
|
|
133
|
+
if (!check.ok) {
|
|
134
|
+
return { ok: false, reason: `G3 не закрывается без направления: ${check.missing.join("; ")}. Заполните: quality_gate action=brief …` };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const evidence = String(options.evidence ?? "").trim();
|
|
138
|
+
if (evidence.length < EVIDENCE_MIN_CHARS) {
|
|
139
|
+
return {
|
|
140
|
+
ok: false,
|
|
141
|
+
reason: `гейт ${gate.id} требует доказательство ≥${EVIDENCE_MIN_CHARS} символов: команда, метрика или путь к отчёту`,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
const state = mission.gates[gate.id] ?? { status: "pending", units: {} };
|
|
145
|
+
const at = new Date().toISOString();
|
|
146
|
+
if (gate.unitScoped) {
|
|
147
|
+
const unitId = String(options.unit ?? "").trim();
|
|
148
|
+
if (!unitId) return { ok: false, reason: `гейт ${gate.id} привязан к единице: передайте unit=u1` };
|
|
149
|
+
const unit = (mission.units ?? []).find((item) => item.id === unitId);
|
|
150
|
+
if (!unit) return { ok: false, reason: `единица не найдена: ${unitId}` };
|
|
151
|
+
state.units = { ...(state.units ?? {}), [unitId]: { status: "passed", at, evidence } };
|
|
152
|
+
const units = Object.values(state.units);
|
|
153
|
+
state.status = units.length > 0 && units.every((item) => item.status === "passed") ? "passed" : "pending";
|
|
154
|
+
if (!unit.evidence.includes(evidence)) unit.evidence = [...unit.evidence, evidence].slice(-20);
|
|
155
|
+
} else {
|
|
156
|
+
state.status = "passed";
|
|
157
|
+
}
|
|
158
|
+
state.at = at;
|
|
159
|
+
state.attempts = 0;
|
|
160
|
+
state.evidence = evidence;
|
|
161
|
+
state.note = String(options.note ?? "").slice(0, 400);
|
|
162
|
+
mission.gates[gate.id] = state;
|
|
163
|
+
pushHistory(mission, `gate ${gate.id} passed${options.unit ? ` (${options.unit})` : ""}`);
|
|
164
|
+
touch(mission);
|
|
165
|
+
return { ok: true, reason: "", gate: state };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export function failGate(mission, gateId, options = {}) {
|
|
169
|
+
const gate = gateById(gateId);
|
|
170
|
+
if (!gate) return { ok: false, reason: `неизвестный гейт: ${gateId}` };
|
|
171
|
+
const state = mission.gates[gate.id] ?? { status: "pending", units: {} };
|
|
172
|
+
const at = new Date().toISOString();
|
|
173
|
+
state.attempts = (Number(state.attempts) || 0) + 1;
|
|
174
|
+
if (gate.unitScoped && options.unit) {
|
|
175
|
+
state.units = { ...(state.units ?? {}), [String(options.unit)]: { status: "failed", at, evidence: String(options.evidence ?? "").slice(0, 400) } };
|
|
176
|
+
state.status = "failed";
|
|
177
|
+
} else {
|
|
178
|
+
state.status = "failed";
|
|
179
|
+
}
|
|
180
|
+
state.at = at;
|
|
181
|
+
state.evidence = String(options.evidence ?? "").slice(0, 400);
|
|
182
|
+
mission.gates[gate.id] = state;
|
|
183
|
+
pushHistory(mission, `gate ${gate.id} failed (attempt ${state.attempts})`);
|
|
184
|
+
touch(mission);
|
|
185
|
+
const escalate = state.attempts >= 2;
|
|
186
|
+
return {
|
|
187
|
+
ok: true,
|
|
188
|
+
reason: "",
|
|
189
|
+
gate: state,
|
|
190
|
+
escalate,
|
|
191
|
+
hint: escalate ? `${gate.id} упал ${state.attempts} раз(а): тот же подход не работает — смените способ, разделите задачу или спросите владельца` : "",
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export function unitById(mission, idOrName) {
|
|
196
|
+
const key = String(idOrName ?? "").trim().toLowerCase();
|
|
197
|
+
if (!key) return null;
|
|
198
|
+
return (
|
|
199
|
+
(mission.units ?? []).find((unit) => unit.id.toLowerCase() === key) ??
|
|
200
|
+
(mission.units ?? []).find((unit) => unit.name.toLowerCase() === key) ??
|
|
201
|
+
null
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export function setUnitStatus(mission, idOrName, status, options = {}) {
|
|
206
|
+
const unit = unitById(mission, idOrName);
|
|
207
|
+
if (!unit) return { ok: false, reason: `единица не найдена: ${idOrName}` };
|
|
208
|
+
if (!["todo", "doing", "done", "blocked"].includes(status)) {
|
|
209
|
+
return { ok: false, reason: `неизвестный статус: ${status}` };
|
|
210
|
+
}
|
|
211
|
+
if (status === "done") {
|
|
212
|
+
const missing = requiredFor(mission)
|
|
213
|
+
.map((id) => gateById(id))
|
|
214
|
+
.filter((gate) => gate?.unitScoped)
|
|
215
|
+
.filter((gate) => gateState(mission, gate.id)?.units?.[unit.id]?.status !== "passed");
|
|
216
|
+
if (missing.length > 0) {
|
|
217
|
+
return {
|
|
218
|
+
ok: false,
|
|
219
|
+
reason: `единица ${unit.id} не может быть done: не пройдены ${missing.map((gate) => gate.id).join(", ")} — закройте их с evidence`,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
unit.status = status;
|
|
224
|
+
if (typeof options.evidence === "string" && options.evidence.trim().length > 0) {
|
|
225
|
+
unit.evidence = [...unit.evidence, options.evidence.trim()].slice(-20);
|
|
226
|
+
}
|
|
227
|
+
pushHistory(mission, `unit ${unit.id} -> ${status}`);
|
|
228
|
+
touch(mission);
|
|
229
|
+
return { ok: true, reason: "", unit };
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export function planUnit(mission, raw) {
|
|
233
|
+
const name = String(raw?.name ?? "").trim();
|
|
234
|
+
if (!name) return { ok: false, reason: "нужно имя единицы (name)" };
|
|
235
|
+
const existing = (mission.units ?? []).find((unit) => unit.name.toLowerCase() === name.toLowerCase());
|
|
236
|
+
if (existing) return { ok: true, reason: "уже есть", unit: existing, duplicate: true };
|
|
237
|
+
if ((mission.units ?? []).length >= 40) return { ok: false, reason: "лимит 40 единиц" };
|
|
238
|
+
const index = (mission.units ?? []).length;
|
|
239
|
+
const unit = {
|
|
240
|
+
id: `u${index + 1}`,
|
|
241
|
+
name: name.slice(0, 120),
|
|
242
|
+
kind: ["page", "form", "admin", "component", "doc", "api"].includes(String(raw?.kind ?? "")) ? String(raw.kind) : "page",
|
|
243
|
+
status: "todo",
|
|
244
|
+
dod: Array.isArray(raw?.dod) ? raw.dod.map((item) => String(item).slice(0, 200)).slice(0, 12) : [],
|
|
245
|
+
evidence: [],
|
|
246
|
+
};
|
|
247
|
+
mission.units = [...(mission.units ?? []), unit];
|
|
248
|
+
pushHistory(mission, `unit ${unit.id} planned`);
|
|
249
|
+
touch(mission);
|
|
250
|
+
return { ok: true, reason: "", unit };
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** Compact progress used by the status text and the prompt line. */
|
|
254
|
+
export function progress(mission) {
|
|
255
|
+
const required = requiredFor(mission);
|
|
256
|
+
const passed = required.filter((id) => gateIsPassed(mission, id));
|
|
257
|
+
const units = mission.units ?? [];
|
|
258
|
+
return {
|
|
259
|
+
profile: profileOf(mission),
|
|
260
|
+
phase: mission.phase,
|
|
261
|
+
required,
|
|
262
|
+
passed,
|
|
263
|
+
missing: required.filter((id) => !gateIsPassed(mission, id)),
|
|
264
|
+
units: units.length,
|
|
265
|
+
unitsDone: units.filter((unit) => unit.status === "done").length,
|
|
266
|
+
percent: required.length === 0 ? 0 : Math.round((passed.length / required.length) * 100),
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** Everything that blocks a handoff, in priority order. */
|
|
271
|
+
export function blockingWork(mission) {
|
|
272
|
+
const result = [];
|
|
273
|
+
const current = progress(mission);
|
|
274
|
+
for (const id of current.missing) {
|
|
275
|
+
const gate = gateById(id);
|
|
276
|
+
if (!gate) continue;
|
|
277
|
+
const state = gateState(mission, id);
|
|
278
|
+
if (gate.unitScoped && state?.units) {
|
|
279
|
+
const pending = (mission.units ?? []).filter((unit) => state.units?.[unit.id]?.status !== "passed");
|
|
280
|
+
if (pending.length > 0) {
|
|
281
|
+
result.push(`${id} ${gate.title}: осталось единиц ${pending.length} (${pending.slice(0, 4).map((unit) => unit.id).join(", ")})`);
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
result.push(`${id} ${gate.title}: ${gate.metric}`);
|
|
286
|
+
}
|
|
287
|
+
const verdict = acceptanceVerdict(mission);
|
|
288
|
+
if (verdict.required === 0) result.push("G11 приёмка: в миссии нет ни одной проверки с командой — добавьте acceptance");
|
|
289
|
+
if (requiredFor(mission).includes("G13")) {
|
|
290
|
+
const release = releaseVerdict(mission);
|
|
291
|
+
if (release.total === 0) result.push("G13 релиз: шаги не заданы (quality_gate action=start release=[…])");
|
|
292
|
+
else if (!release.pass) result.push(`G13 релиз: ${release.failed} из ${release.required} шагов не PASS`);
|
|
293
|
+
}
|
|
294
|
+
return result.slice(0, 10);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export function describeGate(mission, id) {
|
|
298
|
+
const gate = gateById(id);
|
|
299
|
+
if (!gate) return null;
|
|
300
|
+
const state = gateState(mission, id);
|
|
301
|
+
return {
|
|
302
|
+
id: gate.id,
|
|
303
|
+
title: gate.title,
|
|
304
|
+
phase: gate.phase,
|
|
305
|
+
metric: gate.metric,
|
|
306
|
+
status: state?.status ?? "pending",
|
|
307
|
+
evidence: state?.evidence ?? "",
|
|
308
|
+
unitScoped: gate.unitScoped === true,
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export { GATES, PHASES, PROFILE_GATES };
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pre-work: what must be decided before the first line of code.
|
|
3
|
+
*
|
|
4
|
+
* product — users, pages, success metrics, non-goals, constraints
|
|
5
|
+
* plan — steps with dependencies, risks, blockers
|
|
6
|
+
* ia — page map with template and content status (generates units)
|
|
7
|
+
* decisions— dated ADR-lite entries
|
|
8
|
+
*/
|
|
9
|
+
import fs from "node:fs";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
|
|
12
|
+
export const CONTENT_STATUS = ["ready", "todo", "move", "photo"];
|
|
13
|
+
|
|
14
|
+
export function normalizeProduct(raw = {}) {
|
|
15
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
16
|
+
const list = (value) => (Array.isArray(value) ? value.map((item) => String(item).slice(0, 200)).filter(Boolean).slice(0, 20) : []);
|
|
17
|
+
return {
|
|
18
|
+
audience: Array.isArray(raw.audience)
|
|
19
|
+
? raw.audience
|
|
20
|
+
.filter((item) => item && typeof item === "object")
|
|
21
|
+
.map((item) => ({ who: String(item.who ?? "").slice(0, 120), job: String(item.job ?? "").slice(0, 200) }))
|
|
22
|
+
.filter((item) => item.who)
|
|
23
|
+
.slice(0, 8)
|
|
24
|
+
: [],
|
|
25
|
+
pages: list(raw.pages),
|
|
26
|
+
success: Array.isArray(raw.success)
|
|
27
|
+
? raw.success
|
|
28
|
+
.filter((item) => item && typeof item === "object")
|
|
29
|
+
.map((item) => ({ metric: String(item.metric ?? "").slice(0, 120), target: String(item.target ?? "").slice(0, 80) }))
|
|
30
|
+
.filter((item) => item.metric)
|
|
31
|
+
.slice(0, 8)
|
|
32
|
+
: [],
|
|
33
|
+
nonGoals: list(raw.nonGoals),
|
|
34
|
+
constraints: list(raw.constraints),
|
|
35
|
+
updatedAt: new Date().toISOString(),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function productMissing(product) {
|
|
40
|
+
if (!product) return ["продуктовый бриф не заполнен"];
|
|
41
|
+
const missing = [];
|
|
42
|
+
if ((product.audience ?? []).length < 1) missing.push("пользователи и их задачи (audience)");
|
|
43
|
+
if ((product.pages ?? []).length < 1) missing.push("список страниц (pages)");
|
|
44
|
+
if ((product.success ?? []).length < 1) missing.push("метрика успеха (success)");
|
|
45
|
+
if ((product.constraints ?? []).length < 1) missing.push("ограничения (constraints: закон, бренд, доступы)");
|
|
46
|
+
return missing;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function normalizePlan(raw = {}) {
|
|
50
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
51
|
+
const steps = Array.isArray(raw.steps)
|
|
52
|
+
? raw.steps
|
|
53
|
+
.filter((item) => item && typeof item === "object")
|
|
54
|
+
.map((item, index) => ({
|
|
55
|
+
id: typeof item.id === "string" && /^[a-z0-9-]{1,20}$/u.test(item.id) ? item.id : `s${index + 1}`,
|
|
56
|
+
title: String(item.title ?? "").slice(0, 160),
|
|
57
|
+
unit: String(item.unit ?? "").slice(0, 20),
|
|
58
|
+
dependsOn: Array.isArray(item.dependsOn) ? item.dependsOn.map((dep) => String(dep).slice(0, 20)).slice(0, 10) : [],
|
|
59
|
+
size: ["S", "M", "L"].includes(String(item.size)) ? String(item.size) : "M",
|
|
60
|
+
done: item.done === true,
|
|
61
|
+
}))
|
|
62
|
+
.filter((item) => item.title.length > 0)
|
|
63
|
+
.slice(0, 60)
|
|
64
|
+
: [];
|
|
65
|
+
const risks = Array.isArray(raw.risks)
|
|
66
|
+
? raw.risks
|
|
67
|
+
.filter((item) => item && typeof item === "object")
|
|
68
|
+
.map((item) => ({
|
|
69
|
+
id: String(item.id ?? "").slice(0, 20),
|
|
70
|
+
title: String(item.title ?? "").slice(0, 160),
|
|
71
|
+
likelihood: ["low", "medium", "high"].includes(String(item.likelihood)) ? String(item.likelihood) : "medium",
|
|
72
|
+
impact: ["low", "medium", "high"].includes(String(item.impact)) ? String(item.impact) : "medium",
|
|
73
|
+
mitigation: String(item.mitigation ?? "").slice(0, 300),
|
|
74
|
+
}))
|
|
75
|
+
.filter((item) => item.title.length > 0)
|
|
76
|
+
.slice(0, 20)
|
|
77
|
+
: [];
|
|
78
|
+
const blockers = Array.isArray(raw.blockers)
|
|
79
|
+
? raw.blockers
|
|
80
|
+
.filter((item) => item && typeof item === "object")
|
|
81
|
+
.map((item) => ({
|
|
82
|
+
id: String(item.id ?? "").slice(0, 20),
|
|
83
|
+
title: String(item.title ?? "").slice(0, 160),
|
|
84
|
+
severity: ["P0", "P1", "P2"].includes(String(item.severity)) ? String(item.severity) : "P1",
|
|
85
|
+
owner: String(item.owner ?? "").slice(0, 80),
|
|
86
|
+
open: item.open !== false,
|
|
87
|
+
}))
|
|
88
|
+
.filter((item) => item.title.length > 0)
|
|
89
|
+
.slice(0, 20)
|
|
90
|
+
: [];
|
|
91
|
+
return { steps, risks, blockers, updatedAt: new Date().toISOString() };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function planMissing(plan, units = []) {
|
|
95
|
+
if (!plan) return ["план не заполнен"];
|
|
96
|
+
const missing = [];
|
|
97
|
+
if ((plan.steps ?? []).length === 0) missing.push("шаги плана (steps с dependsOn)");
|
|
98
|
+
else if (!plan.steps.some((step) => step.dependsOn.length > 0)) missing.push("зависимости между шагами (dependsOn)");
|
|
99
|
+
if ((plan.risks ?? []).length < 3) missing.push("риск-регистр (минимум 3 риска с мерой)");
|
|
100
|
+
const openP0 = (plan.blockers ?? []).filter((blocker) => blocker.open && blocker.severity === "P0");
|
|
101
|
+
if (openP0.length > 0) missing.push(`закрыть блокеры P0: ${openP0.map((blocker) => blocker.title).join(", ")}`);
|
|
102
|
+
if (units.length > 0 && plan.steps.length < Math.min(units.length, 3)) missing.push("шаги покрывают меньше трёх единиц работы");
|
|
103
|
+
return missing;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function normalizeInventory(raw = {}) {
|
|
107
|
+
const pages = Array.isArray(raw.pages) ? raw.pages : [];
|
|
108
|
+
return pages
|
|
109
|
+
.filter((page) => page && typeof page === "object")
|
|
110
|
+
.map((page) => ({
|
|
111
|
+
url: String(page.url ?? "").slice(0, 200),
|
|
112
|
+
template: String(page.template ?? "").slice(0, 80),
|
|
113
|
+
sections: Array.isArray(page.sections) ? page.sections.map((item) => String(item).slice(0, 120)).filter(Boolean).slice(0, 30) : [],
|
|
114
|
+
content: CONTENT_STATUS.includes(String(page.content)) ? String(page.content) : "todo",
|
|
115
|
+
}))
|
|
116
|
+
.filter((page) => page.url.length > 0)
|
|
117
|
+
.slice(0, 60);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function iaMarkdown(inventory) {
|
|
121
|
+
const lines = [
|
|
122
|
+
"# Карта сайта и контент",
|
|
123
|
+
"",
|
|
124
|
+
"| Страница | Шаблон | Секции | Контент |",
|
|
125
|
+
"|---|---|---|---|",
|
|
126
|
+
...inventory.map((page) => `| ${page.url} | ${page.template || "—"} | ${page.sections.join(", ") || "—"} | ${page.content} |`),
|
|
127
|
+
"",
|
|
128
|
+
`Страниц: ${inventory.length} · контент готов ${inventory.filter((page) => page.content === "ready").length} · писать ${inventory.filter((page) => page.content === "todo").length} · перенести ${inventory.filter((page) => page.content === "move").length} · нужно фото ${inventory.filter((page) => page.content === "photo").length}`,
|
|
129
|
+
"",
|
|
130
|
+
"Сгенерировано dsh-quality-pipeline (action=ia). Правьте таблицу и повторяйте: единицы работы создаются из строк.",
|
|
131
|
+
"",
|
|
132
|
+
];
|
|
133
|
+
return lines.join("\n");
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function appendDecision(cwd, text) {
|
|
137
|
+
const entry = String(text ?? "").replace(/\s+/gu, " ").trim();
|
|
138
|
+
if (entry.length < 8) return { ok: false, error: "решение слишком короткое" };
|
|
139
|
+
const file = path.join(cwd, ".dsh", "design", "decisions.md");
|
|
140
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
141
|
+
const header = fs.existsSync(file) ? "" : "# Решения (ADR-lite)\n\n| Дата | Решение |\n|---|---|\n";
|
|
142
|
+
const line = `| ${new Date().toISOString().slice(0, 10)} | ${entry} |\n`;
|
|
143
|
+
fs.appendFileSync(file, header + line, "utf8");
|
|
144
|
+
const count = (fs.readFileSync(file, "utf8").match(/^\| \d{4}-/gmu) ?? []).length;
|
|
145
|
+
return { ok: true, file, count, text: `Решение записано (${count}): ${entry}` };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** G0 needs a product brief; G1 needs measured reference cards; G2 needs the plan; G4 needs unit DoD. */
|
|
149
|
+
export function preworkGateCheck(mission, gateId) {
|
|
150
|
+
const profile = String(mission?.profile ?? "standard");
|
|
151
|
+
if (profile === "fast") return { ok: true, missing: [] };
|
|
152
|
+
if (gateId === "G0") {
|
|
153
|
+
const missing = productMissing(mission?.design?.product);
|
|
154
|
+
return { ok: missing.length === 0, missing };
|
|
155
|
+
}
|
|
156
|
+
if (gateId === "G1") {
|
|
157
|
+
const refs = mission?.design?.references ?? [];
|
|
158
|
+
const measured = refs.filter((ref) => ref && typeof ref.metrics === "object" && ref.metrics !== null);
|
|
159
|
+
const withTake = measured.filter((ref) => String(ref.take ?? "").trim().length >= 3);
|
|
160
|
+
if (withTake.length < 2) {
|
|
161
|
+
return { ok: false, missing: ["2+ карточки референсов с измерениями И «что берём» (browser_qa action=benchmark, затем action=reference take=…)"] };
|
|
162
|
+
}
|
|
163
|
+
return { ok: true, missing: [] };
|
|
164
|
+
}
|
|
165
|
+
if (gateId === "G2") {
|
|
166
|
+
const missing = planMissing(mission?.plan, mission?.units ?? []);
|
|
167
|
+
return { ok: missing.length === 0, missing };
|
|
168
|
+
}
|
|
169
|
+
return { ok: true, missing: [] };
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Mechanical blockers the kit can see without asking: accesses, content, legal, junk. */
|
|
173
|
+
export function scanBlockers(cwd) {
|
|
174
|
+
const found = [];
|
|
175
|
+
const exists = (rel) => fs.existsSync(path.join(cwd, rel));
|
|
176
|
+
const add = (title, severity, hint) => found.push({ title, severity, hint, open: true });
|
|
177
|
+
if (!exists(path.join(".dsh", "hosts.json"))) add("нет профилей хостов (.dsh/hosts.json) — доступы к серверу не заданы", "P1", "remote_ops action=hosts");
|
|
178
|
+
if (!exists(path.join("docs", "ia.md")) && !exists(".dsh")) add("нет карты сайта (docs/ia.md) — состав страниц не зафиксирован", "P1", "quality_gate action=ia pages=[…]");
|
|
179
|
+
const walk = (dir, depth = 0, out = []) => {
|
|
180
|
+
if (depth > 4 || out.length > 400) return out;
|
|
181
|
+
let entries = [];
|
|
182
|
+
try {
|
|
183
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
184
|
+
} catch {
|
|
185
|
+
return out;
|
|
186
|
+
}
|
|
187
|
+
for (const entry of entries) {
|
|
188
|
+
if (["node_modules", ".git", "vendor", "storage", "dist", "build"].includes(entry.name)) continue;
|
|
189
|
+
const full = path.join(dir, entry.name);
|
|
190
|
+
if (entry.isDirectory()) walk(full, depth + 1, out);
|
|
191
|
+
else if (/\.(?:php|html|htm|blade|twig|jsx?|tsx?|vue|md)$/u.test(entry.name)) out.push(full);
|
|
192
|
+
}
|
|
193
|
+
return out;
|
|
194
|
+
};
|
|
195
|
+
const files = walk(cwd);
|
|
196
|
+
const junk = [];
|
|
197
|
+
const todos = [];
|
|
198
|
+
const legal = [];
|
|
199
|
+
for (const file of files) {
|
|
200
|
+
let text = "";
|
|
201
|
+
try {
|
|
202
|
+
text = fs.readFileSync(file, "utf8").slice(0, 20_000);
|
|
203
|
+
} catch {
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
const rel = path.relative(cwd, file);
|
|
207
|
+
if (/(?:пример\s+отзыв|lorem ipsum|todo|fixme)/iu.test(text)) junk.push(rel);
|
|
208
|
+
if (/TODO|FIXME/u.test(text)) todos.push(rel);
|
|
209
|
+
if (/политик[аи]\s+(?:конфиденциальности|обработки)|privacy\s+policy/iu.test(text)) legal.push(rel);
|
|
210
|
+
}
|
|
211
|
+
if (junk.length > 0) add(`демо-текст или TODO в ${junk.length} файлах (например ${junk[0]})`, "P1", "browser_qa action=content");
|
|
212
|
+
if (todos.length > 5) add(`${todos.length} файлов с TODO/FIXME`, "P2", "разобрать до сборки");
|
|
213
|
+
if (legal.length === 0 && exists("templates") || legal.length === 0 && exists("public")) add("не найдена политика обработки данных / согласие 152-ФЗ", "P1", "legal-ru-web");
|
|
214
|
+
return found;
|
|
215
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Release action: run the mission's release steps and close G13.
|
|
3
|
+
*
|
|
4
|
+
* Steps are ordinary commands (no shell, same runner as acceptance), so a
|
|
5
|
+
* signed-package release becomes evidence instead of a memory exercise.
|
|
6
|
+
*/
|
|
7
|
+
const MAX_OUT = 1600;
|
|
8
|
+
|
|
9
|
+
export async function releaseAction({ cwd, args, deps }) {
|
|
10
|
+
const { readMission, writeMission, appendEvidence, passGate, failGate, runAcceptance, applyAcceptanceRows, formatAcceptance, parseList } = deps;
|
|
11
|
+
const mission = readMission(cwd);
|
|
12
|
+
if (!mission) return { ok: false, text: 'Миссии нет: quality_gate action=start task="…"' };
|
|
13
|
+
const steps = mission.release?.steps ?? [];
|
|
14
|
+
if (steps.length === 0) {
|
|
15
|
+
return {
|
|
16
|
+
ok: false,
|
|
17
|
+
mission,
|
|
18
|
+
text:
|
|
19
|
+
"Шаги релиза не заданы. Добавьте их при старте: " +
|
|
20
|
+
'release=[{"title":"build+sign","command":"php artisan release:build 3.10.79 …"},{"title":"publish","command":"…"}] ' +
|
|
21
|
+
"или через action=start с полем release.",
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
if (args?.run !== true) {
|
|
25
|
+
const lines = ["Релиз: " + steps.length + " шагов (dry-run)"];
|
|
26
|
+
for (const step of steps) {
|
|
27
|
+
lines.push("- " + step.id + " " + step.title + (step.command ? " :: " + step.command : " (нет команды)") + " [" + step.status + "]");
|
|
28
|
+
}
|
|
29
|
+
lines.push("Запуск: action=release run=true");
|
|
30
|
+
return { ok: true, mission, text: lines.join("\n") };
|
|
31
|
+
}
|
|
32
|
+
const shim = { acceptance: steps.map((step) => ({ ...step })) };
|
|
33
|
+
const rows = await runAcceptance({ cwd, mission: shim, only: parseList(args?.only) });
|
|
34
|
+
applyAcceptanceRows(shim, rows);
|
|
35
|
+
mission.release = { steps: shim.acceptance };
|
|
36
|
+
writeMission(cwd, mission);
|
|
37
|
+
for (const row of rows) {
|
|
38
|
+
appendEvidence(cwd, { kind: "release", gate: "G13", value: row.status, note: (row.id + " " + row.title).slice(0, 300) });
|
|
39
|
+
}
|
|
40
|
+
const passed = rows.filter((row) => row.status === "pass").length;
|
|
41
|
+
const allPass = rows.length > 0 && passed === rows.length;
|
|
42
|
+
const evidence = "release " + passed + "/" + rows.length + " PASS (" + rows.map((row) => row.id).join(",") + ")";
|
|
43
|
+
if (allPass) passGate(mission, "G13", { evidence });
|
|
44
|
+
else failGate(mission, "G13", { evidence });
|
|
45
|
+
writeMission(cwd, mission);
|
|
46
|
+
const summary = formatAcceptance(rows).slice(0, MAX_OUT * 4);
|
|
47
|
+
return {
|
|
48
|
+
ok: allPass,
|
|
49
|
+
mission,
|
|
50
|
+
release: rows,
|
|
51
|
+
text: summary + (allPass ? "\nГейт G13 закрыт автоматически." : "\nG13 остаётся открытым."),
|
|
52
|
+
};
|
|
53
|
+
}
|