@rt-tools/agent-kit 0.26.0 → 0.27.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/assets/agents/cargo-writer.md +54 -0
- package/assets/checks/board-epic-link.github.mjs +29 -0
- package/assets/checks/board-epics.github.mjs +239 -36
- package/assets/checks/board-long-work.github.mjs +5 -1
- package/assets/checks/board-pull-state.github.mjs +168 -0
- package/assets/checks/board-task-dirs.github.mjs +98 -0
- package/assets/checks/board.github.mjs +8 -91
- package/assets/checks/check-board.github.mjs +25 -165
- package/assets/checks/check-prose-style.mjs +19 -3
- package/assets/checks/check-schema-drift.mjs +19 -3
- package/assets/checks/epic-table.github.mjs +268 -0
- package/assets/checks/rt-kit-checks.config.mjs +13 -0
- package/assets/checks/specs-for.mjs +214 -0
- package/assets/checks/task-new.github.mjs +231 -6
- package/assets/commands/night.md +115 -0
- package/assets/defaults/project.sh +7 -0
- package/assets/defaults/turn-map.md +3 -1
- package/assets/docs/GLOSSARY.md +22 -22
- package/assets/hooks/browser-device-id.sh +4 -0
- package/assets/hooks/browser-guard-device-id.sh +4 -0
- package/assets/hooks/commit-msg.sh +3 -0
- package/assets/hooks/dev-server-guard.sh +4 -0
- package/assets/hooks/epic-over.sh +49 -0
- package/assets/hooks/epic-stop-guard.sh +108 -0
- package/assets/hooks/git-guard-delivery-conflict.sh +3 -0
- package/assets/hooks/git-guard-delivery-draft.sh +3 -0
- package/assets/hooks/git-guard-delivery-epic.sh +167 -0
- package/assets/hooks/git-guard-delivery-signature.sh +32 -2
- package/assets/hooks/git-guard-delivery.sh +28 -4
- package/assets/hooks/handoff-entry-guard.sh +20 -2
- package/assets/hooks/prose-style-guard.sh +31 -8
- package/assets/hooks/qa-dataid-guard.sh +33 -11
- package/assets/hooks/rule-article.sh +3 -0
- package/assets/hooks/skill-gate-layers.sh +4 -0
- package/assets/hooks/skill-loaded.sh +4 -0
- package/assets/hooks/sql-guard-parse.sh +3 -0
- package/assets/hooks/sql-guard-request.sh +3 -0
- package/assets/hooks/sql-guard-target.sh +3 -0
- package/assets/hooks/sql-guard-write.sh +3 -0
- package/assets/hooks/stand-login-guard.sh +3 -0
- package/assets/hooks/turn-exit-guard.sh +5 -1
- package/assets/hooks/turn-exit-patterns.sh +10 -0
- package/assets/hooks/utf8.sh +3 -0
- package/assets/hooks/waiting-turn-guard.sh +11 -1
- package/assets/hooks/write-targets.sh +3 -0
- package/assets/laws/delivery.md +23 -1
- package/assets/patterns/git-workflow-commit.azure.md +1 -1
- package/assets/patterns/git-workflow-commit.github.md +9 -2
- package/assets/patterns/git-workflow-commit.gitlab.md +1 -1
- package/assets/patterns/git-workflow-merge.md +8 -5
- package/assets/patterns/git-workflow-pr.azure.md +1 -1
- package/assets/patterns/git-workflow-pr.github.md +8 -3
- package/assets/patterns/git-workflow-pr.gitlab.md +1 -1
- package/assets/patterns/git-workflow-stack.md +13 -9
- package/assets/patterns/status-report-table.github.md +11 -0
- package/assets/patterns/task-flow-close.md +40 -21
- package/assets/patterns/task-flow-start.md +40 -26
- package/assets/pitfalls/agent-kit.md +19 -0
- package/assets/pitfalls/git-workflow.github.md +6 -0
- package/assets/rules/autonomous-work.md +15 -3
- package/assets/rules/doc-style.md +7 -4
- package/assets/rules/git-workflow.github.md +41 -23
- package/assets/rules/spec-driven.md +7 -0
- package/assets/rules/status-report.md +7 -0
- package/assets/rules/task-flow.md +31 -10
- package/assets/rules/turn-conduct.md +7 -0
- package/assets/skills/agent-kit.md +23 -21
- package/bin/agent-kit.d.ts.map +1 -1
- package/bin/agent-kit.js +8 -1
- package/bin/agent-kit.js.map +1 -1
- package/lib/cargo-prose.d.ts +41 -0
- package/lib/cargo-prose.d.ts.map +1 -0
- package/lib/cargo-prose.js +88 -0
- package/lib/cargo-prose.js.map +1 -0
- package/lib/cargo.d.ts +12 -1
- package/lib/cargo.d.ts.map +1 -1
- package/lib/cargo.js +8 -2
- package/lib/cargo.js.map +1 -1
- package/lib/fate.d.ts +29 -0
- package/lib/fate.d.ts.map +1 -0
- package/lib/fate.js +147 -0
- package/lib/fate.js.map +1 -0
- package/lib/override-marks.d.ts +7 -0
- package/lib/override-marks.d.ts.map +1 -1
- package/lib/override-marks.js +14 -0
- package/lib/override-marks.js.map +1 -1
- package/lib/ship.d.ts +29 -2
- package/lib/ship.d.ts.map +1 -1
- package/lib/ship.js +34 -0
- package/lib/ship.js.map +1 -1
- package/lib/shipment.d.ts.map +1 -1
- package/lib/shipment.fixture.d.ts +8 -1
- package/lib/shipment.fixture.d.ts.map +1 -1
- package/lib/shipment.fixture.js +9 -0
- package/lib/shipment.fixture.js.map +1 -1
- package/lib/shipment.js +32 -3
- package/lib/shipment.js.map +1 -1
- package/package.json +1 -1
- package/rt-tools-agent-kit-0.27.0.tgz +0 -0
- package/rt-tools-agent-kit-0.26.0.tgz +0 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The task folders of the tree: recognising a number in a name, walking the folders and removing
|
|
3
|
+
* the layout header from a copy of the template.
|
|
4
|
+
*
|
|
5
|
+
* A file of its own because the subject is the tree, not the work queue: these three go to disk
|
|
6
|
+
* and never to the network, and the queue module they lived in stood at the file length limit.
|
|
7
|
+
* The queue module re-exports them under their old names — three neighbouring modules and the
|
|
8
|
+
* tree's commands call them from there, and rewriting them would mean paying for the split twice.
|
|
9
|
+
*/
|
|
10
|
+
import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
|
|
13
|
+
import { CONFIG, ROOT } from './rt-kit-checks.config.mjs';
|
|
14
|
+
|
|
15
|
+
const TASK_KEY = CONFIG.board?.taskKey ?? '';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The task number by the folder name. The key in front is optional: a branch name of the kind
|
|
19
|
+
* `chore/312-slug` is lawful too, and the folder under it is named by the bare number. If the
|
|
20
|
+
* audit does not recognise a number in the name, the folder will lie among the current ones for
|
|
21
|
+
* any length of time — one such was found by grep, not by a check.
|
|
22
|
+
*/
|
|
23
|
+
export function numberFromTaskDir(name) {
|
|
24
|
+
// The key is substituted only if the tree has set it: an empty one would give `^(?:-)?`, and
|
|
25
|
+
// a folder with the key in its name would stop being recognised at all.
|
|
26
|
+
const prefix = TASK_KEY ? `(?:${TASK_KEY}-)?` : '';
|
|
27
|
+
const match = new RegExp(`^${prefix}(\\d+)-`).exec(name ?? '');
|
|
28
|
+
return match ? Number(match[1]) : null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Task folders, including nested ones. The path repeats the branch name in full, slash included,
|
|
33
|
+
* so the folder of branch `chore/312-slug` lies on the second level — a walk over the top level
|
|
34
|
+
* alone does not see it.
|
|
35
|
+
*
|
|
36
|
+
* We descend exactly one level: a branch name has one slash, and anything deeper is no longer a
|
|
37
|
+
* task folder — but the archive would get in there, if the tree keeps it inside.
|
|
38
|
+
*/
|
|
39
|
+
/** The layout header: by it the laid-out copy is recognised, and so is the edit-place guard. */
|
|
40
|
+
const STAMP = /^<!-- rt-kit v[^\n]*-->\n/m;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Remove the layout header from copies of the template.
|
|
44
|
+
*
|
|
45
|
+
* The template carries the header by right: the layout puts it there and updates it. A copy under
|
|
46
|
+
* a task is already the project's text, by the same argument by which the companion draft is laid
|
|
47
|
+
* out without a header: from the first edit there is nothing to audit in it. Left in the copy, the
|
|
48
|
+
* header refuses the very first edit of the grill and sends one to edit the package template
|
|
49
|
+
* instead. It was removed by three lines by hand, anew with every piece of work.
|
|
50
|
+
*
|
|
51
|
+
* Returns the names of the files the header was removed from: by them the scenario judges that
|
|
52
|
+
* the removal works, and the caller that the folder is assembled.
|
|
53
|
+
*/
|
|
54
|
+
export function unstampFolder(folder) {
|
|
55
|
+
const cleaned = [];
|
|
56
|
+
|
|
57
|
+
if (!existsSync(folder)) {
|
|
58
|
+
return cleaned;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
for (const name of readdirSync(folder)) {
|
|
62
|
+
if (!name.endsWith('.md')) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const path = join(folder, name);
|
|
67
|
+
const before = readFileSync(path, 'utf8');
|
|
68
|
+
const after = before.replace(STAMP, '');
|
|
69
|
+
|
|
70
|
+
if (after !== before) {
|
|
71
|
+
writeFileSync(path, after);
|
|
72
|
+
cleaned.push(name);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return cleaned;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function taskDirs(dir = join(ROOT, CONFIG.tasksDir), prefix = '') {
|
|
80
|
+
if (!existsSync(dir)) {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
const found = [];
|
|
84
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
85
|
+
if (!entry.isDirectory() || entry.name === '_template') {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const name = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
89
|
+
if (entry.name.startsWith('_draft-') || numberFromTaskDir(entry.name) !== null) {
|
|
90
|
+
found.push(name);
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (!prefix) {
|
|
94
|
+
found.push(...taskDirs(join(dir, entry.name), name));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return found;
|
|
98
|
+
}
|
|
@@ -12,18 +12,16 @@
|
|
|
12
12
|
* <number>` prints the task state as one line of JSON; `move <number> <column>` moves its column,
|
|
13
13
|
* also `npm run task:move`.
|
|
14
14
|
*
|
|
15
|
-
* No network or no token is
|
|
16
|
-
*
|
|
15
|
+
* No network or no token is an inability to check, not a discrepancy: the functions return `null`,
|
|
16
|
+
* the command mode prints `{"offline":true}`.
|
|
17
17
|
*/
|
|
18
|
-
import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
|
19
|
-
import { join } from 'node:path';
|
|
20
|
-
|
|
21
18
|
import { OfflineError, botToken, gh, ghJson, graphql } from './board-gh.mjs';
|
|
22
|
-
import {
|
|
19
|
+
import { declaredEpicOf } from './board-epic-link.mjs';
|
|
20
|
+
export { numberFromTaskDir, taskDirs, unstampFolder } from './board-task-dirs.mjs';
|
|
21
|
+
import { CONFIG } from './rt-kit-checks.config.mjs';
|
|
23
22
|
|
|
24
23
|
// The client leaves here under its old name: three neighbouring modules and the tree's commands
|
|
25
|
-
// call it from the board module, and rewriting them
|
|
26
|
-
// for the file split twice.
|
|
24
|
+
// call it from the board module, and rewriting them would mean paying for the split twice.
|
|
27
25
|
export { OfflineError, botToken, gh, ghJson, graphql };
|
|
28
26
|
|
|
29
27
|
/**
|
|
@@ -147,7 +145,7 @@ export function fetchIssues(state, options) {
|
|
|
147
145
|
|
|
148
146
|
export function fetchIssue(number, options) {
|
|
149
147
|
try {
|
|
150
|
-
return ghJson(['issue', 'view', String(number), '--json', 'number,title,state,assignees,labels'], options);
|
|
148
|
+
return ghJson(['issue', 'view', String(number), '--json', 'number,title,state,assignees,labels,body'], options);
|
|
151
149
|
} catch (error) {
|
|
152
150
|
if (error instanceof OfflineError) {
|
|
153
151
|
throw error;
|
|
@@ -267,88 +265,6 @@ export function numberFromTitle(title) {
|
|
|
267
265
|
return match ? Number(match[1]) : null;
|
|
268
266
|
}
|
|
269
267
|
|
|
270
|
-
/**
|
|
271
|
-
* The task number by the folder name. The key in front is optional: a branch name of the kind
|
|
272
|
-
* `chore/312-slug` is lawful too, and the folder under it is named by the bare number. If the
|
|
273
|
-
* audit does not recognise a number in the name, the folder will lie among the current ones for
|
|
274
|
-
* any length of time — one such was found by grep, not by a check.
|
|
275
|
-
*/
|
|
276
|
-
export function numberFromTaskDir(name) {
|
|
277
|
-
// The key is substituted only if the tree has set it: an empty one would give `^(?:-)?`, and
|
|
278
|
-
// a folder with the key in its name would stop being recognised at all.
|
|
279
|
-
const prefix = TASK_KEY ? `(?:${TASK_KEY}-)?` : '';
|
|
280
|
-
const match = new RegExp(`^${prefix}(\\d+)-`).exec(name ?? '');
|
|
281
|
-
return match ? Number(match[1]) : null;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Task folders, including nested ones. The path repeats the branch name in full, slash included,
|
|
286
|
-
* so the folder of branch `chore/312-slug` lies on the second level — a walk over the top level
|
|
287
|
-
* alone does not see it.
|
|
288
|
-
*
|
|
289
|
-
* We descend exactly one level: a branch name has one slash, and anything deeper is no longer a
|
|
290
|
-
* task folder — but the archive would get in there, if the tree keeps it inside.
|
|
291
|
-
*/
|
|
292
|
-
/** The layout header: by it the laid-out copy is recognised, and so is the edit-place guard. */
|
|
293
|
-
const STAMP = /^<!-- rt-kit v[^\n]*-->\n/m;
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Remove the layout header from copies of the template.
|
|
297
|
-
*
|
|
298
|
-
* The template carries the header by right: the layout puts it there and updates it. A copy under
|
|
299
|
-
* a task is already the project's text, by the same argument by which the companion draft is laid
|
|
300
|
-
* out without a header: from the first edit there is nothing to audit in it. Left in the copy, the
|
|
301
|
-
* header refuses the very first edit of the grill and sends one to edit the package template
|
|
302
|
-
* instead. It was removed by three lines by hand, anew with every piece of work.
|
|
303
|
-
*
|
|
304
|
-
* Returns the names of the files the header was removed from: by them the scenario judges that
|
|
305
|
-
* the removal works, and the caller that the folder is assembled.
|
|
306
|
-
*/
|
|
307
|
-
export function unstampFolder(folder) {
|
|
308
|
-
const cleaned = [];
|
|
309
|
-
|
|
310
|
-
if (!existsSync(folder)) {
|
|
311
|
-
return cleaned;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
for (const name of readdirSync(folder)) {
|
|
315
|
-
if (!name.endsWith('.md')) {
|
|
316
|
-
continue;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
const path = join(folder, name);
|
|
320
|
-
const before = readFileSync(path, 'utf8');
|
|
321
|
-
const after = before.replace(STAMP, '');
|
|
322
|
-
|
|
323
|
-
if (after !== before) {
|
|
324
|
-
writeFileSync(path, after);
|
|
325
|
-
cleaned.push(name);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
return cleaned;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
export function taskDirs(dir = join(ROOT, CONFIG.tasksDir), prefix = '') {
|
|
333
|
-
if (!existsSync(dir)) {
|
|
334
|
-
return [];
|
|
335
|
-
}
|
|
336
|
-
const found = [];
|
|
337
|
-
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
338
|
-
if (!entry.isDirectory() || entry.name === '_template') {
|
|
339
|
-
continue;
|
|
340
|
-
}
|
|
341
|
-
const name = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
342
|
-
if (entry.name.startsWith('_draft-') || numberFromTaskDir(entry.name) !== null) {
|
|
343
|
-
found.push(name);
|
|
344
|
-
continue;
|
|
345
|
-
}
|
|
346
|
-
if (!prefix) {
|
|
347
|
-
found.push(...taskDirs(join(dir, entry.name), name));
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
return found;
|
|
351
|
-
}
|
|
352
268
|
|
|
353
269
|
export function numberFromBranch(branch) {
|
|
354
270
|
const match = BRANCH_NUMBER.exec(branch ?? '');
|
|
@@ -377,6 +293,7 @@ export function taskState(number, options) {
|
|
|
377
293
|
assignees: issue.assignees.map((assignee) => assignee.login),
|
|
378
294
|
numbered: numberFromTitle(issue.title) === issue.number,
|
|
379
295
|
labels: issue.labels.map((label) => label.name),
|
|
296
|
+
epic: declaredEpicOf(issue.body) ?? null,
|
|
380
297
|
};
|
|
381
298
|
}
|
|
382
299
|
|
|
@@ -48,11 +48,11 @@ import {
|
|
|
48
48
|
numberFromTitle,
|
|
49
49
|
taskDirs,
|
|
50
50
|
} from './board.mjs';
|
|
51
|
-
import { onlyIgnoredPaths } from './board-paths.mjs';
|
|
52
51
|
import { checkBranchFolders } from './board-folders.mjs';
|
|
52
|
+
import { checkConflicting, checkHeadRun } from './board-pull-state.mjs';
|
|
53
53
|
import { checkLongWork } from './board-long-work.mjs';
|
|
54
|
-
import { HAS_PIPELINE, deployLag,
|
|
55
|
-
import { checkEpicLinks } from './board-epics.mjs';
|
|
54
|
+
import { HAS_PIPELINE, deployLag, lastDeploy } from './board-runs.mjs';
|
|
55
|
+
import { checkEpicLinks, checkEpicPullBase, checkEpicState, checkEpicSubIssues } from './board-epics.mjs';
|
|
56
56
|
import { similarTitles } from './board-titles.mjs';
|
|
57
57
|
import { CONFIG, ROOT } from './rt-kit-checks.config.mjs';
|
|
58
58
|
|
|
@@ -60,11 +60,6 @@ const IN_REVIEW = STATUS_OPTIONS[IN_REVIEW_STATUS].name;
|
|
|
60
60
|
const TASKS_DIR = join(ROOT, CONFIG.tasksDir);
|
|
61
61
|
/** Age of an abandoned draft after which it stops looking like one started today. */
|
|
62
62
|
const DRAFT_DAYS = 7;
|
|
63
|
-
/**
|
|
64
|
-
* How long a head is given for a run to start behind it. The event does not reach the hosting
|
|
65
|
-
* instantly, and an audit called right after a push would otherwise go red on a healthy branch.
|
|
66
|
-
*/
|
|
67
|
-
const RUN_GRACE_MINUTES = 10;
|
|
68
63
|
/**
|
|
69
64
|
* The tree's pipeline. Runs are asked for only where they have somewhere to come from: a tree
|
|
70
65
|
* without a pipeline would get a line for every open PR, and about nothing.
|
|
@@ -83,9 +78,21 @@ const RUN_GRACE_MINUTES = 10;
|
|
|
83
78
|
*
|
|
84
79
|
* The label name names the tree: each has its own, and an invented default would match nothing
|
|
85
80
|
* and silently switch the filtering off. A tree that names no label is judged as before.
|
|
81
|
+
*
|
|
82
|
+
* The label alone is not enough to recognise cargo: a tree puts it on the tasks that grew out of
|
|
83
|
+
* cargo too — that is how the reader sees where the work came from. Read by the label alone, such
|
|
84
|
+
* a task fell out of the whole task half at once: neither the executor, nor the board, nor the
|
|
85
|
+
* link with an epic, nor a matching title was asked about it, and a request about it got the line
|
|
86
|
+
* "the task is not among the open ones". So a title with a number outweighs the label: that is
|
|
87
|
+
* what the tree itself tells a task by.
|
|
86
88
|
*/
|
|
87
89
|
const CARGO_LABELS = new Set(CONFIG.board?.cargoLabels ?? []);
|
|
88
90
|
|
|
91
|
+
/** A record of the cargo: the label of one, and no title of a task. */
|
|
92
|
+
function isCargo(issue) {
|
|
93
|
+
return numberFromTitle(issue.title) === null && (issue.labels ?? []).some((label) => CARGO_LABELS.has(label.name));
|
|
94
|
+
}
|
|
95
|
+
|
|
89
96
|
const DEPLOY_WORKFLOW = CONFIG.deploy?.workflow ?? '';
|
|
90
97
|
const MAIN_BRANCH = CONFIG.deploy?.mainBranch ?? 'main';
|
|
91
98
|
|
|
@@ -150,157 +157,6 @@ function folderInBranch(branch, options) {
|
|
|
150
157
|
}
|
|
151
158
|
}
|
|
152
159
|
|
|
153
|
-
/**
|
|
154
|
-
* The run on the head of an open PR.
|
|
155
|
-
*
|
|
156
|
-
* A silent page and a green run read the same, and the event does not always reach the hosting:
|
|
157
|
-
* in the hour of its failures the push went through and no run started behind it. The audit names
|
|
158
|
-
* such a head while the PR is still open — after the merge it is too late to learn about it.
|
|
159
|
-
*
|
|
160
|
-
* What counts is the fact of a run, not its colour. A running and a failed run are both visible
|
|
161
|
-
* on the PR page; only absence is invisible, and the audit speaks of exactly that.
|
|
162
|
-
*
|
|
163
|
-
* A fresh head is not judged: time passes between the push and the run, and a red line in that
|
|
164
|
-
* gap would mean "wait", not "fix".
|
|
165
|
-
*
|
|
166
|
-
* A conflicting PR gets no run at all, and the cause is not a lost event: the pipeline checks the
|
|
167
|
-
* merge of the branch with its base, and under a conflict there is no merge. The advice to bring
|
|
168
|
-
* the event back is followed literally and does not help — in one session a PR was closed and
|
|
169
|
-
* reopened twice in a row, and the run started only after the main branch was merged in. So the
|
|
170
|
-
* line names the cause that can be fixed.
|
|
171
|
-
*/
|
|
172
|
-
function checkHeadRun(pull, options) {
|
|
173
|
-
if (checkEvicted(pull, options)) {
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (runsOnHead(pull.headRefOid, options) > 0) {
|
|
178
|
-
checkReadyDraft(pull, options);
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const minutes = Math.floor((Date.now() - headCommittedAt(pull.headRefOid, options)) / 60000);
|
|
183
|
-
if (minutes < RUN_GRACE_MINUTES) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (onlyIgnoredPaths(pull, options)) {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (pull.mergeable === 'CONFLICTING') {
|
|
192
|
-
report(
|
|
193
|
-
`PR #${pull.number}: there is no run on the tip ${pull.headRefOid.slice(0, 8)} and there will be none while it conflicts — ` +
|
|
194
|
-
`the pipeline checks the merge of the branch with the base, and there is no merge while it conflicts; merge the main branch in and push, ` +
|
|
195
|
-
`reopening the PR does not help here`
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// A PR on top of a neighbouring one gets no run: the workflow listens for PRs into the main
|
|
202
|
-
// branch and does not see events with another base. The line about a lost event is wrong
|
|
203
|
-
// here twice: the event was not lost, and closing and reopening will not bring it back — the
|
|
204
|
-
// advice is followed literally, no run starts, and on the second try the breakage is looked
|
|
205
|
-
// for in the hosting.
|
|
206
|
-
if (pull.baseRefName && pull.baseRefName !== MAIN_BRANCH) {
|
|
207
|
-
report(
|
|
208
|
-
`PR #${pull.number}: there is no run on the tip ${pull.headRefOid.slice(0, 8)} and there will be none — ` +
|
|
209
|
-
`the request is opened into the branch «${pull.baseRefName}», and the workflow listens to requests into the main one; ` +
|
|
210
|
-
`move the base to «${MAIN_BRANCH}» once the lower request is merged`
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
report(
|
|
217
|
-
`PR #${pull.number}: there is no run on the tip ${pull.headRefOid.slice(0, 8)}, and it has lain there ${minutes} min — ` +
|
|
218
|
-
`the pipeline received no event; bring it back by a new commit or by reopening the PR ` +
|
|
219
|
-
`(gh pr close ${pull.number} && gh pr reopen ${pull.number})`
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* A head run evicted from the pipeline queue.
|
|
225
|
-
*
|
|
226
|
-
* The queue group protects a running run and does not protect a waiting one: the hosting keeps
|
|
227
|
-
* one waiting run per group, and the next one to start evicts the previous. The branch behind
|
|
228
|
-
* such a run was not checked by a single line, yet by the work queue it looks checked — there is
|
|
229
|
-
* a run on the head, and the audit counts exactly the fact.
|
|
230
|
-
*
|
|
231
|
-
* Judged before the absence of a run and before the colour: otherwise one head gets two lines
|
|
232
|
-
* about one thing. Returns `true` when the line has been said, and the other head checks are
|
|
233
|
-
* skipped.
|
|
234
|
-
*
|
|
235
|
-
* The line names both commands, in the order they are called. The guard refuses a rerun until the
|
|
236
|
-
* output of that step has been read within the same turn, and the order in the line meets the
|
|
237
|
-
* requirement by itself: the executor calls what is written and does not hit a refusal on the
|
|
238
|
-
* second step.
|
|
239
|
-
*/
|
|
240
|
-
function checkEvicted(pull, options) {
|
|
241
|
-
const evicted = evictedOnHead(pull.headRefOid, options);
|
|
242
|
-
if (evicted.length === 0) {
|
|
243
|
-
return false;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
const run = evicted[0];
|
|
247
|
-
report(
|
|
248
|
-
`PR #${pull.number}: the run ${run} on the tip ${pull.headRefOid.slice(0, 8)} was pushed out of the pipeline queue — ` +
|
|
249
|
-
`it has zero steps, the branch was not checked, and in the list it looks failed; ` +
|
|
250
|
-
`read the run and restart it (gh run view ${run} && gh run rerun ${run})`
|
|
251
|
-
);
|
|
252
|
-
return true;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Finished work left as a draft.
|
|
257
|
-
*
|
|
258
|
-
* On a draft the merge button is blocked by the hosting itself, so a green PR page allows the
|
|
259
|
-
* owner nothing: a list in which everything is grey reads as "the work is not done". The
|
|
260
|
-
* draft-lifting guard does not reach here — it judges one turn and stays silent while the branch
|
|
261
|
-
* carries its task folder; the audit looks at the state of the whole queue.
|
|
262
|
-
*
|
|
263
|
-
* Four PRs stood as drafts for two days — the analysis is the record
|
|
264
|
-
* "2026-08-18-ready-work-left-in-drafts" in the intake.
|
|
265
|
-
*/
|
|
266
|
-
function checkReadyDraft(pull, options) {
|
|
267
|
-
if (pull.isDraft !== true) {
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
if (verdictOnHead(pull.headRefOid, options) !== 'success') {
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
report(
|
|
275
|
-
`PR #${pull.number}: the run on the tip ${pull.headRefOid.slice(0, 8)} is green, and the PR is a draft — ` +
|
|
276
|
-
`take the task folder apart and lift the draft (gh pr ready ${pull.number}) or tell the owner what you are waiting for`
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* A PR that conflicts with the main branch.
|
|
282
|
-
*
|
|
283
|
-
* A conflict arrives in a handed-over PR through someone else's merge, without a single action by
|
|
284
|
-
* its author: the base checked at opening goes stale the minute the owner merges a neighbouring
|
|
285
|
-
* piece of work. The draft-lifting guard does not reach here — it judges one turn, and a PR stands
|
|
286
|
-
* in the queue for days.
|
|
287
|
-
*
|
|
288
|
-
* Only a direct "conflicting" is judged: `UNKNOWN` means the hosting is still computing
|
|
289
|
-
* mergeability, and a line about it would go red on every fresh head. Two PRs went to review with
|
|
290
|
-
* a conflict this way — the analysis is the record
|
|
291
|
-
* "2026-08-20-drafts-cleared-without-re-reading-pr-state" in the intake.
|
|
292
|
-
*/
|
|
293
|
-
function checkConflicting(pull) {
|
|
294
|
-
if (pull.mergeable !== 'CONFLICTING') {
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
report(
|
|
299
|
-
`PR #${pull.number}: it conflicts with the main branch — merge it into the task branch, resolve the conflict and push; ` +
|
|
300
|
-
`the owner cannot merge this request, and on the page that shows only inside it`
|
|
301
|
-
);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
160
|
let checked = { issues: 0, pulls: 0, cargo: 0 };
|
|
305
161
|
|
|
306
162
|
// Drafts are judged by the disk and so are checked always: no connection is needed for that.
|
|
@@ -313,10 +169,11 @@ try {
|
|
|
313
169
|
const board = fetchBoard(options);
|
|
314
170
|
const issues = fetchIssues('all', options);
|
|
315
171
|
const allOpen = issues.filter((issue) => issue.state === 'OPEN');
|
|
316
|
-
// Filtering happens once and before all task checks: a
|
|
317
|
-
//
|
|
318
|
-
//
|
|
319
|
-
|
|
172
|
+
// Filtering happens once and before all task checks: a cargo record is not a task as a whole,
|
|
173
|
+
// not by half — it is judged neither by title, nor by executor, nor by the board, nor by the
|
|
174
|
+
// digest of matching titles, nor by the link to an epic. A card with a title of a task is not
|
|
175
|
+
// such a record, whatever labels it wears.
|
|
176
|
+
const open = CARGO_LABELS.size === 0 ? allOpen : allOpen.filter((issue) => !isCargo(issue));
|
|
320
177
|
const pulls = fetchOpenPulls(options);
|
|
321
178
|
checked = { issues: issues.length, pulls: pulls.length, cargo: allOpen.length - open.length };
|
|
322
179
|
|
|
@@ -340,6 +197,9 @@ try {
|
|
|
340
197
|
|
|
341
198
|
similarTitles(open);
|
|
342
199
|
checkEpicLinks(open, report);
|
|
200
|
+
checkEpicPullBase(open, pulls, report);
|
|
201
|
+
checkEpicState(open, pulls, report);
|
|
202
|
+
checkEpicSubIssues(open, report, options);
|
|
343
203
|
checkLongWork(open, report);
|
|
344
204
|
|
|
345
205
|
const openNumbers = new Set(open.map((issue) => issue.number));
|
|
@@ -368,10 +228,10 @@ try {
|
|
|
368
228
|
// opened past the guard. Said after the merge, this line is no longer fixed by the same
|
|
369
229
|
// PR: the work has moved on, and a second task is created for the clean-up.
|
|
370
230
|
if (HAS_PIPELINE && pull.headRefOid) {
|
|
371
|
-
checkHeadRun(pull, options);
|
|
231
|
+
checkHeadRun(pull, report, MAIN_BRANCH, options);
|
|
372
232
|
}
|
|
373
233
|
|
|
374
|
-
checkConflicting(pull);
|
|
234
|
+
checkConflicting(pull, report);
|
|
375
235
|
|
|
376
236
|
// The PR falling behind the main branch: the guard judges the base once, at the minute of
|
|
377
237
|
// opening, and a PR stands for days. Merged while behind, it carries into main a
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
* by that. This is its boundary, not its promise.
|
|
17
17
|
*
|
|
18
18
|
* A non-zero return code and a list of findings: the file, the line, what was found, what to
|
|
19
|
-
* replace it with.
|
|
19
|
+
* replace it with. Called with `--json`, it reads the text from the input and prints the findings
|
|
20
|
+
* as data with a zero code: a machine decides for itself what to do about them.
|
|
20
21
|
*
|
|
21
22
|
* Word boundaries are written with a look at letters, not `\b`: it counts by ASCII, Cyrillic does
|
|
22
23
|
* not fall under `\w`, and a pattern with it silently never fires once.
|
|
@@ -28,6 +29,9 @@ import { CONFIG } from './rt-kit-checks.config.mjs';
|
|
|
28
29
|
/** The sentence length limit in words. Beyond it the reader loses the beginning. */
|
|
29
30
|
const WORDS_LIMIT = 40;
|
|
30
31
|
|
|
32
|
+
/** The argument by which the check is asked for findings as data: the text comes in on the input. */
|
|
33
|
+
const JSON_FLAG = '--json';
|
|
34
|
+
|
|
31
35
|
/**
|
|
32
36
|
* The signs of officialese. Each is a pattern and what to replace it with: without a replacement
|
|
33
37
|
* a finding reads as a ban on writing.
|
|
@@ -214,8 +218,20 @@ export function checkProse(text) {
|
|
|
214
218
|
);
|
|
215
219
|
}
|
|
216
220
|
|
|
217
|
-
|
|
218
|
-
|
|
221
|
+
// Запуск строкой отличается от вызова из другого модуля именем в строке запуска: без этого
|
|
222
|
+
// условия модуль, который просто позвали, читал бы доводы чужой команды как имена файлов — и
|
|
223
|
+
// падал бы на первом же из них. Тот же приём стоит у команд груза.
|
|
224
|
+
const called = process.argv[1]?.endsWith('check-prose-style.mjs') === true;
|
|
225
|
+
const asked = called ? process.argv.slice(2) : [];
|
|
226
|
+
const files = asked.filter((one) => one !== JSON_FLAG);
|
|
227
|
+
|
|
228
|
+
// Ответ машине: текст приходит на вход, находки уходят разбором. Так проверку зовёт тот, кто
|
|
229
|
+
// держит текст в памяти, а не на диске: уезжающий груз лежит блоками внутри файла дня, и
|
|
230
|
+
// именами файлов его не назвать. Код возврата тут нулевой всегда — находка машине не отказ, а
|
|
231
|
+
// данные: отказ по ней выносит зовущий.
|
|
232
|
+
if (asked.includes(JSON_FLAG)) {
|
|
233
|
+
process.stdout.write(JSON.stringify(checkProse(readFileSync(0, 'utf8'))));
|
|
234
|
+
} else if (files.length > 0) {
|
|
219
235
|
const problems = files.flatMap((file) =>
|
|
220
236
|
checkProse(readFileSync(file, 'utf8')).map((p) => ` ${file}:${p.line} — «${p.what}» → ${p.fix}`)
|
|
221
237
|
);
|
|
@@ -215,13 +215,29 @@ async function main() {
|
|
|
215
215
|
// The identifier is quoted: the database name comes from the address, not from the text of the query
|
|
216
216
|
const quoted = `"${shadowName.replace(/"/g, '""')}"`;
|
|
217
217
|
await client.query(`DROP DATABASE IF EXISTS ${quoted}`);
|
|
218
|
+
// The shadow database is created here rather than left to `migrate deploy`. The seventh
|
|
219
|
+
// edition of the client goes to the storage through an adapter and creates nothing: a
|
|
220
|
+
// missing database it answers with `P1001`, «Can't reach database server», while the server
|
|
221
|
+
// answers and the port is open. Read as it is written, that refusal says the machine has no
|
|
222
|
+
// storage at all — and the check created to catch a migration that falls on a clean database
|
|
223
|
+
// stayed silent about exactly that.
|
|
224
|
+
await client.query(`CREATE DATABASE ${quoted}`);
|
|
218
225
|
|
|
219
226
|
try {
|
|
220
|
-
// `migrate deploy` starts the database itself: no creation command of our own is needed
|
|
221
227
|
const deploy = prisma(['migrate', 'deploy'], shadowUrl);
|
|
222
228
|
if (deploy.status !== 0) {
|
|
223
|
-
|
|
224
|
-
|
|
229
|
+
const said = `${deploy.stdout ?? ''}${deploy.stderr ?? ''}`;
|
|
230
|
+
// `P1001` names an unreachable server, and the client says it about a missing
|
|
231
|
+
// database too — the two are indistinguishable in its answer. The shadow database
|
|
232
|
+
// was created a line above, so here it means the check itself, not the migrations:
|
|
233
|
+
// said as a refusal of the migrations, it sends whoever reads it to look for a
|
|
234
|
+
// divergence that does not exist.
|
|
235
|
+
console.error(
|
|
236
|
+
said.includes('P1001')
|
|
237
|
+
? 'check-schema-drift: the shadow database did not answer, and this is a defect of the check rather than of the migrations\n'
|
|
238
|
+
: 'check-schema-drift: the migrations do not apply to a clean database\n'
|
|
239
|
+
);
|
|
240
|
+
console.error(said);
|
|
225
241
|
|
|
226
242
|
return 1;
|
|
227
243
|
}
|