dsh-desktop-kit 2.24.1 → 2.31.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.
Files changed (86) hide show
  1. package/CHANGELOG.md +85 -10
  2. package/README.en.md +102 -0
  3. package/README.md +223 -256
  4. package/client.js +1 -1
  5. package/docs/ARCHITECTURE.md +9 -6
  6. package/docs/COMPATIBILITY.md +2 -1
  7. package/docs/LAPTOP-INSTALL.md +9 -5
  8. package/docs/MEASURED.md +25 -0
  9. package/docs/PROPOSAL-2.25-quality-pipeline.md +435 -0
  10. package/docs/PROPOSAL-NEXUM-FINDINGS.md +259 -0
  11. package/docs/TEST-2.30.0.md +83 -0
  12. package/docs/TEST-2.31.0.md +61 -0
  13. package/docs/UPGRADING.md +3 -1
  14. package/docs/images/capability-map-2.30.png +0 -0
  15. package/docs/images/hero-2.30.png +0 -0
  16. package/docs/images/hero-2.31.png +0 -0
  17. package/docs/images/quality-pipeline-2.30.png +0 -0
  18. package/docs/measured.json +30 -0
  19. package/docs/preview/capability-map-2.30.html +106 -0
  20. package/docs/preview/hero-2.30.html +133 -0
  21. package/docs/preview/hero-2.31.html +133 -0
  22. package/docs/preview/quality-pipeline-2.30.html +142 -0
  23. package/docs/preview/readme-visuals.css +111 -0
  24. package/doctor.ps1 +161 -142
  25. package/index.js +82 -5
  26. package/install.ps1 +178 -99
  27. package/lib/kit-diagnostics.js +780 -0
  28. package/package.json +15 -5
  29. package/plugins/dsh-agent-extensions/lib/routing.js +4 -0
  30. package/plugins/dsh-agent-extensions/lib/scaffold.js +152 -27
  31. package/plugins/dsh-agent-extensions/lib/settings.js +19 -0
  32. package/plugins/dsh-agent-extensions/lib/swarm.js +6 -2
  33. package/plugins/dsh-browser-qa/index.js +202 -9
  34. package/plugins/dsh-browser-qa/lib/design-more.js +688 -0
  35. package/plugins/dsh-browser-qa/lib/extras.js +1313 -0
  36. package/plugins/dsh-browser-qa/lib/pages.js +4 -3
  37. package/plugins/dsh-browser-qa/lib/png.js +190 -0
  38. package/plugins/dsh-browser-qa/lib/ui-gate.js +171 -31
  39. package/plugins/dsh-i18n/README.md +36 -0
  40. package/plugins/dsh-i18n/cordis.patch.yml +3 -0
  41. package/plugins/dsh-i18n/index.js +294 -0
  42. package/plugins/dsh-i18n/lib/lang.js +179 -0
  43. package/plugins/dsh-i18n/package.json +29 -0
  44. package/plugins/dsh-integrations/lib/job-sandbox.ps1 +1 -1
  45. package/plugins/dsh-profile-transfer/bootstrap/install-on-clean-machine.ps1 +1 -1
  46. package/plugins/dsh-quality-pipeline/README.md +53 -0
  47. package/plugins/dsh-quality-pipeline/cordis.patch.yml +3 -0
  48. package/plugins/dsh-quality-pipeline/index.js +647 -0
  49. package/plugins/dsh-quality-pipeline/lib/acceptance.js +132 -0
  50. package/plugins/dsh-quality-pipeline/lib/autostart.js +159 -0
  51. package/plugins/dsh-quality-pipeline/lib/design.js +123 -0
  52. package/plugins/dsh-quality-pipeline/lib/machine.js +312 -0
  53. package/plugins/dsh-quality-pipeline/lib/prework.js +215 -0
  54. package/plugins/dsh-quality-pipeline/lib/release.js +53 -0
  55. package/plugins/dsh-quality-pipeline/lib/schema.js +256 -0
  56. package/plugins/dsh-quality-pipeline/lib/store.js +114 -0
  57. package/plugins/dsh-quality-pipeline/lib/text.js +109 -0
  58. package/plugins/dsh-quality-pipeline/package.json +33 -0
  59. package/plugins/dsh-remote-ops/README.md +38 -0
  60. package/plugins/dsh-remote-ops/cordis.patch.yml +3 -0
  61. package/plugins/dsh-remote-ops/index.js +268 -0
  62. package/plugins/dsh-remote-ops/lib/hosts.js +118 -0
  63. package/plugins/dsh-remote-ops/lib/ssh.js +96 -0
  64. package/plugins/dsh-remote-ops/lib/state.js +66 -0
  65. package/plugins/dsh-remote-ops/package.json +31 -0
  66. package/plugins/dsh-skill-autopilot/index.js +204 -15
  67. package/skills/a11y-audit/SKILL.md +67 -0
  68. package/skills/cms-ops/SKILL.md +74 -0
  69. package/skills/design-system/SKILL.md +100 -0
  70. package/skills/legal-ru-web/SKILL.md +68 -0
  71. package/skills/manifest.json +38 -18
  72. package/skills/release-pipeline/SKILL.md +67 -0
  73. package/skills/ui-batch/SKILL.md +60 -0
  74. package/skills/web-build/SKILL.md +106 -0
  75. package/skills/web-build/recipes/form.md +16 -0
  76. package/skills/web-build/recipes/payment.md +16 -0
  77. package/skills/web-build/recipes/review.md +16 -0
  78. package/skills-baseline.json +201 -5
  79. package/uninstall.ps1 +1 -1
  80. package/skills/ui-design-system/references/accessibility-and-responsive.md +0 -50
  81. package/skills/ui-design-system/references/tokens-and-components.md +0 -67
  82. package/skills/ui-design-system/references/visual-qa.md +0 -44
  83. package/skills/visual-qa/references/commands.md +0 -32
  84. /package/skills/{ui-craft/SKILL.md → design-system/references/ui-craft.md} +0 -0
  85. /package/skills/{ui-design-system/SKILL.md → design-system/references/ui-design-system.md} +0 -0
  86. /package/skills/{visual-qa/SKILL.md → ui-batch/references/visual-qa.md} +0 -0
@@ -0,0 +1,256 @@
1
+ /**
2
+ * Mission schema for dsh-quality-pipeline.
3
+ *
4
+ * A mission is the durable state of one quality-critical piece of work:
5
+ * what we build, in which phase we are, which gates are passed and what
6
+ * counts as "done". It lives in `<cwd>/.dsh/quality/mission.json` and is the
7
+ * single source of truth for routing, gating and acceptance.
8
+ */
9
+
10
+ import { normalizeBrief, normalizeVariants } from "./design.js";
11
+ import { normalizePlan, normalizeProduct } from "./prework.js";
12
+
13
+ export const MISSION_VERSION = 1;
14
+
15
+ export const PHASES = Object.freeze([
16
+ "research",
17
+ "plan",
18
+ "system",
19
+ "build",
20
+ "verify",
21
+ "fix",
22
+ "handoff",
23
+ ]);
24
+
25
+ export const WORK_TYPES = Object.freeze([
26
+ "web-site",
27
+ "web-app",
28
+ "cms",
29
+ "api",
30
+ "library",
31
+ "docs",
32
+ "audit",
33
+ "other",
34
+ ]);
35
+
36
+ export const QUALITY_PROFILES = Object.freeze(["fast", "standard", "turnkey"]);
37
+
38
+ export const UNIT_KINDS = Object.freeze(["page", "form", "admin", "component", "doc", "api"]);
39
+
40
+ export const UNIT_STATUSES = Object.freeze(["todo", "doing", "done", "blocked"]);
41
+
42
+ export const PHASE_LABELS = Object.freeze({
43
+ research: "Ресёрч и нормы",
44
+ plan: "План прямой и обратный",
45
+ system: "Дизайн-система и токены",
46
+ build: "Сборка единиц",
47
+ verify: "Проверки и гейты",
48
+ fix: "Фиксы по findings",
49
+ handoff: "Приёмка и сдача",
50
+ });
51
+
52
+ /**
53
+ * Gate registry. `phase` is the phase in which the gate must be passed; a
54
+ * gate with `unitScoped: true` is evaluated per unit, the others once.
55
+ */
56
+ export const GATES = Object.freeze([
57
+ { id: "G0", phase: "research", title: "Миссия и критерии приёмки", metric: "mission + acceptance + units", unitScoped: false },
58
+ { id: "G1", phase: "research", title: "Референсы и нормы с датами", metric: "≥2 источника на рекомендацию", unitScoped: false },
59
+ { id: "G2", phase: "plan", title: "Прямой план, обратный план, пре-мортем", metric: "три артефакта", unitScoped: false },
60
+ { id: "G3", phase: "system", title: "Токены, шкала, слои, состояния", metric: "дублей 0, «магических» px 0", unitScoped: false },
61
+ { id: "G4", phase: "build", title: "Аудит единицы", metric: "overflow 0 · console 0 · markup 0 · матрица 4/4", unitScoped: true },
62
+ { id: "G5", phase: "verify", title: "Интеракции", metric: "100 % сценариев", unitScoped: true },
63
+ { id: "G6", phase: "verify", title: "Доступность", metric: "critical/serious 0", unitScoped: true },
64
+ { id: "G7", phase: "verify", title: "Производительность", metric: "LCP ≤ 2,5 с · INP ≤ 200 мс · CLS ≤ 0,1", unitScoped: false },
65
+ { id: "G8", phase: "verify", title: "SEO и мета", metric: "0 ошибок, 0 дублей", unitScoped: false },
66
+ { id: "G9", phase: "verify", title: "Админка и карта владения", metric: "все поля редактируемы", unitScoped: false },
67
+ { id: "G10", phase: "verify", title: "Право и законодательство", metric: "0 открытых пунктов", unitScoped: false },
68
+ { id: "G11", phase: "handoff", title: "Приёмка", metric: "acceptance PASS", unitScoped: false },
69
+ { id: "G12", phase: "handoff", title: "Отчёт «до/после», runbook", metric: "файлы на месте", unitScoped: false },
70
+ { id: "G13", phase: "handoff", title: "Релиз: сборка, подпись, выкатка, отчёт", metric: "все шаги релиза с evidence", unitScoped: false },
71
+ ]);
72
+
73
+ /**
74
+ * Which gates a profile requires before `handoff` unlocks. `fast` is for a
75
+ * small edit, `standard` for a normal feature, `turnkey` for a deliverable
76
+ * site or a client handover.
77
+ */
78
+ export const PROFILE_GATES = Object.freeze({
79
+ fast: ["G0", "G4", "G11"],
80
+ standard: ["G0", "G1", "G2", "G4", "G5", "G6", "G11"],
81
+ turnkey: GATES.map((gate) => gate.id),
82
+ });
83
+
84
+ const ID_RE = /^[a-z][a-z0-9-]{0,39}$/u;
85
+
86
+ export function gateById(id) {
87
+ const key = String(id ?? "").trim().toUpperCase();
88
+ return GATES.find((gate) => gate.id === key) ?? null;
89
+ }
90
+
91
+ export function requiredGates(profile) {
92
+ const key = QUALITY_PROFILES.includes(String(profile ?? "")) ? String(profile) : "standard";
93
+ return [...PROFILE_GATES[key]];
94
+ }
95
+
96
+ export function phaseIndex(phase) {
97
+ return PHASES.indexOf(String(phase ?? ""));
98
+ }
99
+
100
+ export function unitId(index) {
101
+ return `u${index + 1}`;
102
+ }
103
+
104
+ function cleanString(value, max = 400) {
105
+ if (typeof value !== "string") return "";
106
+ return value.replace(/\s+/gu, " ").trim().slice(0, max);
107
+ }
108
+
109
+ function cleanList(value, max = 24) {
110
+ if (!Array.isArray(value)) return [];
111
+ return value
112
+ .map((item) => cleanString(item, 200))
113
+ .filter((item) => item.length > 0)
114
+ .slice(0, max);
115
+ }
116
+
117
+ export function normalizeUnit(raw = {}, index = 0) {
118
+ const kind = UNIT_KINDS.includes(String(raw.kind ?? "")) ? String(raw.kind) : "page";
119
+ const status = UNIT_STATUSES.includes(String(raw.status ?? "")) ? String(raw.status) : "todo";
120
+ return {
121
+ id: typeof raw.id === "string" && ID_RE.test(raw.id) ? raw.id : unitId(index),
122
+ name: cleanString(raw.name, 120) || `Единица ${index + 1}`,
123
+ kind,
124
+ status,
125
+ dod: cleanList(raw.dod, 12),
126
+ evidence: cleanList(raw.evidence, 20),
127
+ };
128
+ }
129
+
130
+ export function normalizeAcceptanceItem(raw = {}, index = 0) {
131
+ const status = ["unknown", "pass", "fail", "skipped", "error"].includes(String(raw.status ?? ""))
132
+ ? String(raw.status)
133
+ : "unknown";
134
+ return {
135
+ id: typeof raw.id === "string" && ID_RE.test(raw.id) ? raw.id : `a${index + 1}`,
136
+ title: cleanString(raw.title, 160) || `Проверка ${index + 1}`,
137
+ command: typeof raw.command === "string" && raw.command.trim().length > 0 ? raw.command.trim().slice(0, 600) : "",
138
+ threshold: cleanString(raw.threshold, 200),
139
+ status,
140
+ lastRunAt: typeof raw.lastRunAt === "string" ? raw.lastRunAt : "",
141
+ output: typeof raw.output === "string" ? raw.output.slice(0, 2000) : "",
142
+ };
143
+ }
144
+
145
+ export function normalizeGateState(raw = {}) {
146
+ const status = ["pending", "passed", "failed"].includes(String(raw.status ?? "")) ? String(raw.status) : "pending";
147
+ const units = {};
148
+ if (raw.units && typeof raw.units === "object" && !Array.isArray(raw.units)) {
149
+ for (const [id, value] of Object.entries(raw.units)) {
150
+ if (!ID_RE.test(id) && !/^u\d+$/u.test(id)) continue;
151
+ if (!value || typeof value !== "object") continue;
152
+ units[id] = {
153
+ status: ["passed", "failed"].includes(String(value.status ?? "")) ? String(value.status) : "pending",
154
+ at: typeof value.at === "string" ? value.at : "",
155
+ evidence: cleanString(value.evidence, 400),
156
+ };
157
+ }
158
+ }
159
+ return {
160
+ status,
161
+ at: typeof raw.at === "string" ? raw.at : "",
162
+ evidence: cleanString(raw.evidence, 400),
163
+ note: cleanString(raw.note, 400),
164
+ units,
165
+ };
166
+ }
167
+
168
+ export function createMission(input = {}) {
169
+ const now = new Date().toISOString();
170
+ const profile = QUALITY_PROFILES.includes(String(input.profile ?? "")) ? String(input.profile) : "standard";
171
+ const type = WORK_TYPES.includes(String(input.type ?? "")) ? String(input.type) : "web-site";
172
+ const units = Array.isArray(input.units) ? input.units.map(normalizeUnit).slice(0, 40) : [];
173
+ const acceptance = Array.isArray(input.acceptance)
174
+ ? input.acceptance.map(normalizeAcceptanceItem).slice(0, 40)
175
+ : [];
176
+ const gates = {};
177
+ for (const gate of GATES) gates[gate.id] = normalizeGateState({});
178
+ return {
179
+ version: MISSION_VERSION,
180
+ createdAt: now,
181
+ updatedAt: now,
182
+ task: cleanString(input.task, 800) || "Без описания",
183
+ type,
184
+ stack: cleanList(input.stack, 8),
185
+ profile,
186
+ phase: "research",
187
+ gates,
188
+ units,
189
+ acceptance,
190
+ release: { steps: Array.isArray(input.release) ? input.release.map(normalizeAcceptanceItem).slice(0, 30) : [] },
191
+ design: {
192
+ brief: input?.design?.brief ? normalizeBrief(input.design.brief) : null,
193
+ product: input?.design?.product ? normalizeProduct(input.design.product) : null,
194
+ variants: normalizeVariants(input?.design?.variants),
195
+ references: Array.isArray(input?.design?.references) ? input.design.references.slice(0, 10) : [],
196
+ },
197
+ plan: normalizePlan(input?.plan) ?? { steps: [], risks: [], blockers: [] },
198
+ decisions: [],
199
+ invariants: cleanList(input.invariants, 20),
200
+ links: {
201
+ docs: cleanString(input?.links?.docs, 200),
202
+ tokens: cleanString(input?.links?.tokens, 200),
203
+ adminMap: cleanString(input?.links?.adminMap, 200),
204
+ },
205
+ history: [],
206
+ };
207
+ }
208
+
209
+ /** Validate a parsed mission; returns `{ok, errors, mission}` with a normalized copy. */
210
+ export function validateMission(raw) {
211
+ const errors = [];
212
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
213
+ return { ok: false, errors: ["mission is not an object"], mission: null };
214
+ }
215
+ if (Number(raw.version) !== MISSION_VERSION) errors.push(`version must be ${MISSION_VERSION}`);
216
+ if (!PHASES.includes(String(raw.phase ?? ""))) errors.push(`unknown phase: ${raw.phase}`);
217
+ if (!QUALITY_PROFILES.includes(String(raw.profile ?? ""))) errors.push(`unknown profile: ${raw.profile}`);
218
+ if (!WORK_TYPES.includes(String(raw.type ?? ""))) errors.push(`unknown type: ${raw.type}`);
219
+ if (!Array.isArray(raw.units)) errors.push("units must be an array");
220
+ if (!Array.isArray(raw.acceptance)) errors.push("acceptance must be an array");
221
+ if (!raw.gates || typeof raw.gates !== "object") errors.push("gates must be an object");
222
+ if (errors.length > 0) return { ok: false, errors, mission: null };
223
+
224
+ const mission = {
225
+ ...createMission(raw),
226
+ createdAt: typeof raw.createdAt === "string" ? raw.createdAt : new Date().toISOString(),
227
+ phase: String(raw.phase),
228
+ units: raw.units.map(normalizeUnit),
229
+ acceptance: raw.acceptance.map(normalizeAcceptanceItem),
230
+ release: { steps: Array.isArray(raw.release?.steps) ? raw.release.steps.map(normalizeAcceptanceItem) : [] },
231
+ design: {
232
+ brief: raw.design?.brief ? normalizeBrief(raw.design.brief) : null,
233
+ product: raw.design?.product ? normalizeProduct(raw.design.product) : null,
234
+ variants: normalizeVariants(raw.design?.variants),
235
+ references: Array.isArray(raw.design?.references) ? raw.design.references.slice(0, 10) : [],
236
+ },
237
+ plan: normalizePlan(raw.plan) ?? { steps: [], risks: [], blockers: [] },
238
+ decisions: Array.isArray(raw.decisions) ? raw.decisions.slice(-100) : [],
239
+ gates: {},
240
+ history: Array.isArray(raw.history) ? raw.history.slice(-200) : [],
241
+ };
242
+ for (const gate of GATES) mission.gates[gate.id] = normalizeGateState(raw.gates[gate.id]);
243
+ return { ok: true, errors: [], mission };
244
+ }
245
+
246
+ export function touch(mission) {
247
+ mission.updatedAt = new Date().toISOString();
248
+ return mission;
249
+ }
250
+
251
+ export function pushHistory(mission, entry) {
252
+ const line = cleanString(entry, 240);
253
+ if (!line) return mission;
254
+ mission.history = [...(mission.history ?? []), `${new Date().toISOString()} ${line}`].slice(-200);
255
+ return mission;
256
+ }
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Durable storage for the quality mission and its evidence.
3
+ *
4
+ * Everything is written atomically (tmp file + rename) so a killed process
5
+ * never leaves a half-written mission behind. Paths are always derived from
6
+ * the session cwd, never from `process.cwd()`, so parallel sessions in
7
+ * different projects cannot see each other's mission.
8
+ */
9
+ import fs from "node:fs";
10
+ import path from "node:path";
11
+
12
+ export const QUALITY_DIR = path.join(".dsh", "quality");
13
+ export const MISSION_FILE = "mission.json";
14
+ export const EVIDENCE_FILE = "evidence.jsonl";
15
+ export const MAX_EVIDENCE_LINES = 2000;
16
+
17
+ export function qualityDir(cwd) {
18
+ return path.join(cwd || process.cwd(), QUALITY_DIR);
19
+ }
20
+
21
+ export function missionPath(cwd) {
22
+ return path.join(qualityDir(cwd), MISSION_FILE);
23
+ }
24
+
25
+ export function evidencePath(cwd) {
26
+ return path.join(qualityDir(cwd), EVIDENCE_FILE);
27
+ }
28
+
29
+ export function ensureDir(cwd) {
30
+ const dir = qualityDir(cwd);
31
+ fs.mkdirSync(dir, { recursive: true });
32
+ return dir;
33
+ }
34
+
35
+ export function readMission(cwd) {
36
+ const file = missionPath(cwd);
37
+ let text;
38
+ try {
39
+ text = fs.readFileSync(file, "utf8");
40
+ } catch {
41
+ return null;
42
+ }
43
+ try {
44
+ const parsed = JSON.parse(text);
45
+ return parsed && typeof parsed === "object" ? parsed : null;
46
+ } catch {
47
+ return null;
48
+ }
49
+ }
50
+
51
+ export function writeMission(cwd, mission) {
52
+ const dir = ensureDir(cwd);
53
+ const file = path.join(dir, MISSION_FILE);
54
+ const tmp = `${file}.${process.pid}.tmp`;
55
+ fs.writeFileSync(tmp, `${JSON.stringify(mission, null, 2)}\n`, "utf8");
56
+ fs.renameSync(tmp, file);
57
+ return file;
58
+ }
59
+
60
+ export function deleteMission(cwd) {
61
+ const file = missionPath(cwd);
62
+ try {
63
+ fs.unlinkSync(file);
64
+ return true;
65
+ } catch {
66
+ return false;
67
+ }
68
+ }
69
+
70
+ /** Append one evidence record and keep the log bounded. */
71
+ export function appendEvidence(cwd, record) {
72
+ const dir = ensureDir(cwd);
73
+ const file = path.join(dir, EVIDENCE_FILE);
74
+ const entry = {
75
+ at: new Date().toISOString(),
76
+ ...record,
77
+ note: typeof record?.note === "string" ? record.note.slice(0, 600) : "",
78
+ };
79
+ fs.appendFileSync(file, `${JSON.stringify(entry)}\n`, "utf8");
80
+ pruneEvidence(file);
81
+ return entry;
82
+ }
83
+
84
+ function pruneEvidence(file) {
85
+ try {
86
+ const lines = fs.readFileSync(file, "utf8").split("\n").filter(Boolean);
87
+ if (lines.length <= MAX_EVIDENCE_LINES) return;
88
+ const keep = lines.slice(-MAX_EVIDENCE_LINES);
89
+ fs.writeFileSync(file, `${keep.join("\n")}\n`, "utf8");
90
+ } catch {
91
+ /* pruning is best effort */
92
+ }
93
+ }
94
+
95
+ export function readEvidence(cwd, limit = 200) {
96
+ const file = evidencePath(cwd);
97
+ let text;
98
+ try {
99
+ text = fs.readFileSync(file, "utf8");
100
+ } catch {
101
+ return [];
102
+ }
103
+ const rows = [];
104
+ for (const line of text.split("\n")) {
105
+ if (!line.trim()) continue;
106
+ try {
107
+ const parsed = JSON.parse(line);
108
+ if (parsed && typeof parsed === "object") rows.push(parsed);
109
+ } catch {
110
+ /* a corrupt line must not break the whole log */
111
+ }
112
+ }
113
+ return rows.slice(-Math.max(1, Math.min(2000, limit)));
114
+ }
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Human-readable rendering for the quality_gate tool.
3
+ *
4
+ * Kept separate from index.js so tests can assert the exact strings the model
5
+ * sees without booting a plugin context.
6
+ */
7
+ import { PHASE_LABELS, PHASES, phaseIndex } from "./schema.js";
8
+ import { acceptanceVerdict, blockingWork, describeGate, gateState, progress, requiredFor } from "./machine.js";
9
+ import { chosenVariant, variantsRequired } from "./design.js";
10
+
11
+ const MARK = { passed: "PASS", failed: "FAIL", pending: "—" };
12
+
13
+ export function formatStatus(mission) {
14
+ if (!mission) return "миссии нет: quality_gate action=start task=\"…\" создаёт её";
15
+ const current = progress(mission);
16
+ const phaseLabel = PHASE_LABELS[mission.phase] ?? mission.phase;
17
+ const gates = requiredFor(mission)
18
+ .map((id) => describeGate(mission, id))
19
+ .filter(Boolean)
20
+ .map((gate) => `${gate.id} ${MARK[gate.status] ?? "—"}`)
21
+ .join(" · ");
22
+ const unitRows = (mission.units ?? []).map((unit) => {
23
+ const marks = requiredFor(mission)
24
+ .map((id) => describeGate(mission, id))
25
+ .filter((gate) => gate?.unitScoped)
26
+ .map((gate) => `${gate.id}${gateState(mission, gate.id)?.units?.[unit.id]?.status === "passed" ? "+" : "−"}`)
27
+ .join("");
28
+ return ` ${unit.id} ${unit.name} [${unit.status}] ${marks}`;
29
+ });
30
+ const acceptance = acceptanceVerdict(mission);
31
+ const brief = mission.design?.brief ?? null;
32
+ const variants = mission.design?.variants ?? [];
33
+ const chosen = chosenVariant(mission);
34
+ const triggers = variantsRequired(mission);
35
+ const product = mission.design?.product ?? null;
36
+ const references = mission.design?.references ?? [];
37
+ const plan = mission.plan ?? { steps: [], risks: [], blockers: [] };
38
+ const preworkLines = [
39
+ `Продукт: ${product ? `пользователей ${product.audience.length} · страниц ${product.pages.length} · метрик ${product.success.length}` : "не заполнен"} · референсов с измерениями ${references.filter((ref) => ref && ref.metrics).length}`,
40
+ `План: шагов ${(plan.steps ?? []).length} · рисков ${(plan.risks ?? []).length} · блокеров открытых ${(plan.blockers ?? []).filter((blocker) => blocker.open).length} · решений ${(mission.decisions ?? []).length}`,
41
+ ];
42
+ const briefLine = `Направление: ${brief ? `палитра ${brief.palette.length} · шрифты ${brief.typefaces.join(", ") || "—"} · референсов ${brief.references.length}` : "бриф не заполнен"} · вариантов ${variants.length}${chosen ? `, выбран ${chosen.id}` : ""}${triggers.length > 0 ? ` · триггер: ${triggers.join(", ")}` : ""}`;
43
+ const lines = [
44
+ `Миссия: ${mission.task.slice(0, 140)}`,
45
+ `Профиль: ${current.profile} · тип: ${mission.type} · стек: ${(mission.stack ?? []).join(", ") || "не указан"}`,
46
+ `Фаза: ${mission.phase} (${phaseLabel}) · гейтов ${current.passed.length}/${current.required.length} = ${current.percent}%`,
47
+ `Гейты: ${gates}`,
48
+ `Единицы: ${current.unitsDone}/${current.units}`,
49
+ ...unitRows,
50
+ `Приёмка: ${acceptance.passed}/${acceptance.required} PASS${acceptance.required === 0 ? " (проверок с командой нет)" : ""}`,
51
+ ...preworkLines,
52
+ briefLine,
53
+ `Релиз: ${(mission.release?.steps ?? []).length} шагов${(mission.release?.steps ?? []).length > 0 ? ` · PASS ${(mission.release.steps ?? []).filter((step) => step.status === "pass").length}/${(mission.release.steps ?? []).filter((step) => step.command).length}` : ""}`,
54
+ ];
55
+ const blocking = blockingWork(mission);
56
+ if (blocking.length > 0) {
57
+ lines.push("Что мешает сдаче:");
58
+ for (const item of blocking) lines.push(` - ${item}`);
59
+ } else {
60
+ lines.push("Блокеров нет: миссия готова к handoff.");
61
+ }
62
+ const index = phaseIndex(mission.phase);
63
+ const next = PHASES[index + 1];
64
+ if (next) lines.push(`Следующая фаза: ${next} — quality_gate action=phase (закроет переход только при зелёных гейтах)`);
65
+ return lines.join("\n");
66
+ }
67
+
68
+ export function formatGateList(mission) {
69
+ const required = new Set(requiredFor(mission));
70
+ return [
71
+ "Гейты миссии:",
72
+ ...describeGateRows(mission, required),
73
+ "",
74
+ `Обязательны для профиля «${mission.profile}»: ${[...required].join(", ")}`,
75
+ ].join("\n");
76
+ }
77
+
78
+ function describeGateRows(mission, required) {
79
+ return describeGateIds(mission).map((gate) => {
80
+ const state = gateState(mission, gate.id);
81
+ const mark = MARK[state?.status] ?? "—";
82
+ const star = required.has(gate.id) ? "*" : " ";
83
+ const scope = gate.unitScoped ? ` (по единицам: ${state?.passedUnits ?? 0}/${mission.units?.length ?? 0})` : "";
84
+ const evidence = state?.evidence ? ` · evidence: ${state.evidence.slice(0, 80)}` : "";
85
+ return `${star}${gate.id} ${mark} ${gate.title} — ${gate.metric}${scope}${evidence}`;
86
+ });
87
+ }
88
+
89
+ function describeGateIds(mission) {
90
+ return ["G0", "G1", "G2", "G3", "G4", "G5", "G6", "G7", "G8", "G9", "G10", "G11", "G12"]
91
+ .map((id) => describeGate(mission, id))
92
+ .filter(Boolean);
93
+ }
94
+
95
+ /** One line for the system prompt: cheap, stable, no tables. */
96
+ export function formatPromptLine(mission) {
97
+ if (!mission) {
98
+ return "<quality-state>Миссии нет. Для веб-проекта она создаётся автоматически на первом ходе; вручную — tool quality_gate action=start task=\"…\" (профиль fast|standard|turnkey).</quality-state>";
99
+ }
100
+ const current = progress(mission);
101
+ const open = current.missing.slice(0, 6).join(" ");
102
+ return [
103
+ "<quality-state>",
104
+ `phase=${mission.phase} profile=${current.profile} gates=${current.passed.length}/${current.required.length} units=${current.unitsDone}/${current.units}`,
105
+ open ? `open_gates=${open}` : "open_gates=none (готово к handoff)",
106
+ "Правило: не заявляй «готово» без evidence в quality_gate; UI-правки закрываются browser_qa (audit+interact+a11y).",
107
+ "</quality-state>",
108
+ ].join("\n");
109
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "dsh-quality-pipeline",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "description": "Mission state machine for DSH agents: phases, gates G0..G12, units of work, acceptance checks and an evidence trail, persisted in .dsh/quality/.",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "index.js",
9
+ "exports": {
10
+ ".": "./index.js",
11
+ "./lib/schema": "./lib/schema.js",
12
+ "./lib/store": "./lib/store.js",
13
+ "./lib/machine": "./lib/machine.js",
14
+ "./lib/acceptance": "./lib/acceptance.js",
15
+ "./lib/text": "./lib/text.js",
16
+ "./package.json": "./package.json"
17
+ },
18
+ "files": [
19
+ "index.js",
20
+ "lib/**",
21
+ "cordis.patch.yml",
22
+ "README.md"
23
+ ],
24
+ "engines": {
25
+ "node": ">=22.0.0"
26
+ },
27
+ "dsh": {
28
+ "manifestVersion": 1,
29
+ "bundle": {
30
+ "patch": "./cordis.patch.yml"
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,38 @@
1
+ # dsh-remote-ops
2
+
3
+ Типизированные `ssh`/`scp` вместо тысячи собранных вручную команд.
4
+
5
+ ## Профили хостов
6
+
7
+ `.dsh/hosts.json` — только адреса и пути к ключам, **никаких паролей**:
8
+
9
+ ```json
10
+ {
11
+ "hosts": {
12
+ "prod": { "host": "193.111.204.110", "user": "root", "key": "~/.ssh/vps", "root": "/var/www/cms" },
13
+ "demo": { "host": "193.111.204.110", "user": "demo", "key": "~/.ssh/vps", "root": "/var/www/demo",
14
+ "probe": "echo \"php=$(php -v | head -1 | cut -d' ' -f2)\"; echo \"release=$(ls /var/www/updates/download | sort -V | tail -1)\"" }
15
+ }
16
+ }
17
+ ```
18
+
19
+ ## Действия
20
+
21
+ ```
22
+ remote_ops action=hosts
23
+ remote_ops action=state host=prod,demo # версии, git HEAD, ключи .env, канал обновлений
24
+ remote_ops action=diff hosts=prod,demo # «предпросмотр ВАУ, прод ФУ» ловится здесь
25
+ remote_ops action=run host=prod command="php artisan cache:clear"
26
+ remote_ops action=dry-run host=prod command="systemctl reload php8.5-fpm"
27
+ remote_ops action=sync host=prod from=dist to=/var/www/updates/download apply=true
28
+ remote_ops action=logs host=prod unit=php8.5-fpm lines=80
29
+ ```
30
+
31
+ ## Правила
32
+
33
+ - Команда — argv без shell: `;`, `|`, `&`, `>`, `<`, `$`, бэктик запрещены.
34
+ - Деструктивное (`rm`, `dropdb`, `truncate`, `updates:apply`, `systemctl restart|reload|stop`,
35
+ `chmod -R`, `git push --force`) требует `confirm=true`.
36
+ - `sync` сравнивает sha256 и копирует только изменённое (до 50 файлов за вызов).
37
+ - Каждый `run`/`sync`/`diff` пишется в `.dsh/quality/evidence.jsonl` и годится как evidence для гейта G13.
38
+ - Нет `hosts.json` → инструмент подсказывает шаблон. Ключ без `~/` берётся как абсолютный путь.
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: dsh-remote-ops
3
+ name: dsh-remote-ops