@rt-tools/agent-kit 0.24.0 → 0.26.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/business-analyst.md +51 -50
- package/assets/agents/conscience.md +37 -35
- package/assets/agents/project-manager.md +49 -48
- package/assets/agents/prose-editor.md +31 -29
- package/assets/agents/qa-engineer.md +50 -48
- package/assets/agents/rules-reviewer.md +63 -58
- package/assets/agents/skill-curator.md +83 -78
- package/assets/agents/spec-critic.md +34 -29
- package/assets/agents/spec-writer.md +35 -32
- package/assets/agents/strict-teacher.md +39 -37
- package/assets/checks/archive-age.mjs +48 -28
- package/assets/checks/archive-prune.mjs +16 -14
- package/assets/checks/board-epics.github.mjs +75 -41
- package/assets/checks/board-folders.mjs +61 -0
- package/assets/checks/board-gh.github.mjs +35 -26
- package/assets/checks/board-long-work.github.mjs +24 -24
- package/assets/checks/board-paths.github.mjs +21 -16
- package/assets/checks/board-runs.github.mjs +45 -43
- package/assets/checks/board-titles.github.mjs +19 -17
- package/assets/checks/board.github.mjs +149 -127
- package/assets/checks/check-archive-age.mjs +23 -19
- package/assets/checks/check-board.github.mjs +172 -164
- package/assets/checks/check-descriptions.mjs +30 -29
- package/assets/checks/check-doc-paths.mjs +91 -88
- package/assets/checks/check-dupes.mjs +84 -80
- package/assets/checks/check-file-size.mjs +74 -71
- package/assets/checks/check-glossary.mjs +47 -37
- package/assets/checks/check-hook-scope.mjs +30 -27
- package/assets/checks/check-lib-layers.mjs +22 -21
- package/assets/checks/check-profile-drift.mjs +48 -43
- package/assets/checks/check-prose-style.mjs +120 -37
- package/assets/checks/check-push-gate.mjs +53 -50
- package/assets/checks/check-reuse.mjs +50 -40
- package/assets/checks/check-schema-drift.mjs +87 -83
- package/assets/checks/check-specs.mjs +155 -134
- package/assets/checks/check-state-next.mjs +66 -52
- package/assets/checks/check-states.mjs +32 -30
- package/assets/checks/check-styles.mjs +52 -51
- package/assets/checks/check-turn-map.mjs +54 -46
- package/assets/checks/lib-boundaries.mjs +32 -30
- package/assets/checks/lib-common.mjs +30 -29
- package/assets/checks/lib-domains.mjs +34 -34
- package/assets/checks/lib-manifests.mjs +17 -15
- package/assets/checks/lib-reexports.mjs +18 -18
- package/assets/checks/rt-kit-checks.config.mjs +174 -142
- package/assets/checks/signals.mjs +43 -39
- package/assets/checks/spec-anchors.mjs +114 -87
- package/assets/checks/spec-common.mjs +128 -84
- package/assets/checks/spec-contract.mjs +30 -30
- package/assets/checks/spec-proposed.mjs +27 -24
- package/assets/checks/spec-scenarios.mjs +51 -28
- package/assets/checks/task-new.github.mjs +85 -56
- package/assets/commands/feedback.md +65 -59
- package/assets/commands/next-session.md +64 -57
- package/assets/commands/skill-curator.md +83 -79
- package/assets/defaults/gate-map.sh +108 -97
- package/assets/defaults/project.sh +225 -185
- package/assets/defaults/shell.sh +73 -68
- package/assets/defaults/turn-map.md +45 -44
- package/assets/docs/GLOSSARY.md +142 -65
- package/assets/hooks/browser-device-id.sh +12 -12
- package/assets/hooks/browser-guard-device-id.sh +30 -28
- package/assets/hooks/browser-guard-no-asking.sh +5 -4
- package/assets/hooks/browser-guard-no-listing.sh +12 -11
- package/assets/hooks/browser-guard-no-other-drivers.sh +48 -42
- package/assets/hooks/browser-guard-require-select.sh +34 -23
- package/assets/hooks/claim-guard.sh +62 -56
- package/assets/hooks/commit-msg.sh +11 -10
- package/assets/hooks/conscience-guard.sh +91 -45
- package/assets/hooks/constitution-index.sh +16 -16
- package/assets/hooks/deny-tail.sh +28 -26
- package/assets/hooks/dev-server-guard.sh +46 -43
- package/assets/hooks/dispatch.sh +60 -46
- package/assets/hooks/docs-guard.sh +100 -91
- package/assets/hooks/exam-guard.sh +105 -93
- package/assets/hooks/git-guard-delivery-conflict.sh +38 -36
- package/assets/hooks/git-guard-delivery-draft.sh +45 -38
- package/assets/hooks/git-guard-delivery-folder.sh +50 -43
- package/assets/hooks/git-guard-delivery-signature.sh +88 -52
- package/assets/hooks/git-guard-delivery.sh +196 -180
- package/assets/hooks/git-guard-main.sh +38 -34
- package/assets/hooks/git-guard-push-tests.sh +99 -87
- package/assets/hooks/glossary-load.sh +23 -22
- package/assets/hooks/grill-gate-ask.sh +12 -11
- package/assets/hooks/grill-gate.sh +94 -87
- package/assets/hooks/guard-note.sh +20 -19
- package/assets/hooks/handoff-entry-guard.sh +26 -24
- package/assets/hooks/handoff-write.sh +74 -67
- package/assets/hooks/hook-input.sh +67 -58
- package/assets/hooks/lint-after-edit.sh +95 -61
- package/assets/hooks/observe.sh +28 -26
- package/assets/hooks/override-write-guard.sh +23 -21
- package/assets/hooks/postmortem-guard.sh +42 -39
- package/assets/hooks/profile-check.sh +22 -20
- package/assets/hooks/proposal-guard.sh +57 -49
- package/assets/hooks/prose-style-guard.sh +19 -17
- package/assets/hooks/qa-dataid-guard.sh +52 -49
- package/assets/hooks/rerun-guard.sh +31 -30
- package/assets/hooks/reuse-first-guard.sh +108 -87
- package/assets/hooks/roles.sh +14 -14
- package/assets/hooks/rule-article.sh +36 -34
- package/assets/hooks/rule-source-guard.sh +47 -42
- package/assets/hooks/skill-gate-layers.sh +59 -57
- package/assets/hooks/skill-gate-rearm.sh +15 -8
- package/assets/hooks/skill-gate.sh +89 -81
- package/assets/hooks/skill-loaded.sh +6 -6
- package/assets/hooks/sql-guard-parse.sh +68 -66
- package/assets/hooks/sql-guard-request.sh +48 -46
- package/assets/hooks/sql-guard-target.sh +57 -51
- package/assets/hooks/sql-guard-write.sh +84 -79
- package/assets/hooks/sql-guard.sh +52 -47
- package/assets/hooks/stand-login-guard.sh +40 -37
- package/assets/hooks/task-context-load.sh +60 -55
- package/assets/hooks/task-flow-context.sh +87 -69
- package/assets/hooks/task-flow-draft-guard.sh +55 -48
- package/assets/hooks/task-flow-guard.sh +67 -64
- package/assets/hooks/turn-entry-load.sh +39 -32
- package/assets/hooks/turn-exit-guard.sh +256 -204
- package/assets/hooks/turn-exit-patterns.sh +53 -0
- package/assets/hooks/utf8.sh +11 -11
- package/assets/hooks/waiting-turn-guard.sh +94 -94
- package/assets/hooks/window-fill-guard.sh +70 -62
- package/assets/hooks/work-start-guard.sh +52 -49
- package/assets/hooks/write-targets.sh +96 -44
- package/assets/laws/autonomous-work.md +29 -27
- package/assets/laws/code-structure.md +31 -30
- package/assets/laws/delivery.md +148 -137
- package/assets/laws/entity-editing.md +52 -50
- package/assets/laws/entity-models.md +14 -13
- package/assets/laws/frontend-application.md +39 -38
- package/assets/laws/lib-imports.md +27 -27
- package/assets/laws/lists.md +31 -29
- package/assets/laws/navigation.md +37 -37
- package/assets/laws/observability.md +41 -40
- package/assets/laws/project-documentation.md +106 -99
- package/assets/laws/reuse-first.md +31 -29
- package/assets/laws/shared-code.md +27 -27
- package/assets/laws/verifiability.md +131 -124
- package/assets/laws/work-conduct.md +250 -244
- package/assets/patterns/admin-lists-screen.md +72 -69
- package/assets/patterns/admin-nav-item.md +51 -46
- package/assets/patterns/angular-patterns-state.md +32 -31
- package/assets/patterns/api-layer-pair.md +33 -31
- package/assets/patterns/autonomous-work-run.md +50 -49
- package/assets/patterns/browser-verification-measure.md +124 -88
- package/assets/patterns/browser-verification-stand.md +169 -157
- package/assets/patterns/component-structure-new.md +51 -42
- package/assets/patterns/dependencies-upgrade.md +55 -39
- package/assets/patterns/doc-style-human.md +55 -37
- package/assets/patterns/doc-style-sweep.md +82 -79
- package/assets/patterns/doc-style-trace.md +87 -81
- package/assets/patterns/doc-style-write.md +130 -122
- package/assets/patterns/entity-aside.md +77 -63
- package/assets/patterns/entity-models-new.md +37 -37
- package/assets/patterns/entity-store.md +33 -33
- package/assets/patterns/git-workflow-commit.azure.md +93 -86
- package/assets/patterns/git-workflow-commit.github.md +152 -141
- package/assets/patterns/git-workflow-commit.gitlab.md +95 -89
- package/assets/patterns/git-workflow-docker.md +165 -147
- package/assets/patterns/git-workflow-freshness.md +45 -45
- package/assets/patterns/git-workflow-merge.md +98 -93
- package/assets/patterns/git-workflow-migration.md +54 -52
- package/assets/patterns/git-workflow-pr-ready.md +57 -56
- package/assets/patterns/git-workflow-pr.azure.md +126 -121
- package/assets/patterns/git-workflow-pr.github.md +179 -175
- package/assets/patterns/git-workflow-pr.gitlab.md +138 -131
- package/assets/patterns/git-workflow-restart.md +35 -31
- package/assets/patterns/git-workflow-secrets.md +80 -73
- package/assets/patterns/git-workflow-stack.md +131 -106
- package/assets/patterns/lib-layers-move.md +62 -53
- package/assets/patterns/lib-layers-new.md +59 -45
- package/assets/patterns/observability-record.md +72 -67
- package/assets/patterns/platform-access-di.md +31 -29
- package/assets/patterns/reuse-first-extend.md +66 -61
- package/assets/patterns/shared-code-new.md +39 -38
- package/assets/patterns/spec-driven-domain.md +161 -151
- package/assets/patterns/spec-driven-rule.md +179 -168
- package/assets/patterns/spec-driven-sweep.md +41 -39
- package/assets/patterns/status-report-table.github.md +37 -36
- package/assets/patterns/styling-bem-component.md +42 -42
- package/assets/patterns/styling-bem-layout.md +39 -34
- package/assets/patterns/styling-bem-sheet.md +59 -58
- package/assets/patterns/task-flow-archive.md +222 -215
- package/assets/patterns/task-flow-close.md +215 -203
- package/assets/patterns/task-flow-handoff.md +154 -145
- package/assets/patterns/task-flow-resume.md +138 -133
- package/assets/patterns/task-flow-start.md +204 -192
- package/assets/patterns/testing-e2e.md +102 -101
- package/assets/patterns/testing-unit.md +77 -70
- package/assets/patterns/ts-procedure.md +32 -29
- package/assets/patterns/turn-entry-map.md +50 -48
- package/assets/pitfalls/agent-kit.md +152 -141
- package/assets/pitfalls/doc-style.md +96 -91
- package/assets/pitfalls/git-workflow.azure.md +49 -46
- package/assets/pitfalls/git-workflow.github.md +264 -234
- package/assets/pitfalls/git-workflow.gitlab.md +49 -45
- package/assets/pitfalls/spec-driven.md +73 -71
- package/assets/pitfalls/styling-bem.md +46 -40
- package/assets/pitfalls/task-flow.md +262 -246
- package/assets/pitfalls/testing.md +99 -92
- package/assets/pitfalls/turn-conduct.md +96 -81
- package/assets/rules/angular-patterns.md +81 -80
- package/assets/rules/api-layer.md +77 -74
- package/assets/rules/autonomous-work.md +75 -74
- package/assets/rules/browser-verification.md +223 -214
- package/assets/rules/component-structure.md +72 -69
- package/assets/rules/dependencies.md +74 -67
- package/assets/rules/deploy-flow.azure.md +118 -108
- package/assets/rules/deploy-flow.github.md +145 -135
- package/assets/rules/deploy-flow.gitlab.md +120 -110
- package/assets/rules/doc-style.md +198 -173
- package/assets/rules/entity-conventions.needs-admin.md +81 -79
- package/assets/rules/entity-models.md +73 -70
- package/assets/rules/git-workflow.azure.md +224 -228
- package/assets/rules/git-workflow.github.md +250 -239
- package/assets/rules/git-workflow.gitlab.md +218 -217
- package/assets/rules/lib-layers.md +85 -86
- package/assets/rules/lists.md +101 -97
- package/assets/rules/navigation.md +78 -78
- package/assets/rules/observability.needs-app.md +165 -153
- package/assets/rules/platform-access.md +76 -75
- package/assets/rules/reuse-first.md +153 -143
- package/assets/rules/shared-code.md +82 -79
- package/assets/rules/spec-driven.md +272 -260
- package/assets/rules/status-report.md +55 -58
- package/assets/rules/styling-bem.md +81 -77
- package/assets/rules/task-flow.md +282 -270
- package/assets/rules/testing.md +224 -209
- package/assets/rules/turn-conduct.md +255 -258
- package/assets/rules/turn-entry.md +92 -87
- package/assets/rules/typescript-conventions.md +94 -88
- package/assets/samples/specs/_template/spec.md +47 -47
- package/assets/samples/tasks/_template/grill.md +20 -20
- package/assets/samples/tasks/_template/plan.md +32 -30
- package/assets/samples/tasks/_template/progress.md +16 -16
- package/assets/skills/agent-kit-extend.md +129 -113
- package/assets/skills/agent-kit.md +235 -211
- package/assets/skills/write-a-skill.md +76 -71
- package/assets/templates/findings.md +19 -19
- package/assets/templates/gate-map.sh +16 -14
- package/assets/templates/implementation.md +28 -27
- package/assets/templates/pattern.md +17 -17
- package/assets/templates/pitfalls.md +6 -6
- package/assets/templates/postmortem.md +24 -23
- package/assets/templates/project.sh +24 -24
- package/assets/templates/proposal.md +62 -60
- package/assets/templates/rule.md +38 -38
- package/assets/workflows/feature.js +46 -46
- package/assets/workflows/plan.js +54 -54
- package/lib/catalog.d.ts +2 -0
- package/lib/catalog.d.ts.map +1 -1
- package/lib/catalog.js +4 -3
- package/lib/catalog.js.map +1 -1
- package/lib/commands.d.ts.map +1 -1
- package/lib/commands.js +5 -2
- package/lib/commands.js.map +1 -1
- package/lib/companion.js +3 -2
- package/lib/companion.js.map +1 -1
- package/lib/enroll.d.ts +7 -1
- package/lib/enroll.d.ts.map +1 -1
- package/lib/enroll.js +12 -3
- package/lib/enroll.js.map +1 -1
- package/lib/plan.d.ts +11 -0
- package/lib/plan.d.ts.map +1 -1
- package/lib/plan.js +10 -1
- package/lib/plan.js.map +1 -1
- package/lib/ship.d.ts +0 -7
- package/lib/ship.d.ts.map +1 -1
- package/lib/ship.js +10 -2
- package/lib/ship.js.map +1 -1
- package/lib/shipment.d.ts.map +1 -1
- package/lib/shipment.js +6 -2
- package/lib/shipment.js.map +1 -1
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +45 -11
- package/lib/sync.js.map +1 -1
- package/package.json +1 -1
- package/rt-tools-agent-kit-0.26.0.tgz +0 -0
- package/rt-tools-agent-kit-0.24.0.tgz +0 -0
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Shared work with the work queue: the project board, the tasks and their state.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* без добавления на борду, и две задачи так и простояли вне очереди.
|
|
5
|
+
* One question — "is task N in order?" — is asked by three callers: the task creation command
|
|
6
|
+
* (tools/task-new.mjs), the queue audit (tools/check-board.mjs) and the delivery guard
|
|
7
|
+
* (.claude/hooks/git-guard-delivery.sh). While the answer stood as ready-made lines in a pattern,
|
|
8
|
+
* each answered its own way: two tasks were created outside the board that way.
|
|
10
9
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* The board is not bound to the repository — its `projectsV2` is empty — so a task lands on it
|
|
11
|
+
* only by an explicit call. The guard calls this file as a command: `node tools/board.mjs task
|
|
12
|
+
* <number>` prints the task state as one line of JSON; `move <number> <column>` moves its column,
|
|
13
|
+
* also `npm run task:move`.
|
|
13
14
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* `node tools/board.mjs move <номер> <колонка>`, он же `npm run task:move`.
|
|
17
|
-
*
|
|
18
|
-
* Нет сети или нет токена — это не расхождение, а невозможность проверить:
|
|
19
|
-
* функции возвращают `null`, командный режим печатает `{"offline":true}`.
|
|
15
|
+
* No network or no token is not a discrepancy but an inability to check: the functions return
|
|
16
|
+
* `null`, the command mode prints `{"offline":true}`.
|
|
20
17
|
*/
|
|
21
18
|
import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
|
22
19
|
import { join } from 'node:path';
|
|
@@ -24,58 +21,59 @@ import { join } from 'node:path';
|
|
|
24
21
|
import { OfflineError, botToken, gh, ghJson, graphql } from './board-gh.mjs';
|
|
25
22
|
import { CONFIG, ROOT } from './rt-kit-checks.config.mjs';
|
|
26
23
|
|
|
27
|
-
//
|
|
28
|
-
//
|
|
24
|
+
// 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 for the moved declaration would mean paying
|
|
26
|
+
// for the file split twice.
|
|
29
27
|
export { OfflineError, botToken, gh, ghJson, graphql };
|
|
30
28
|
|
|
31
29
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
30
|
+
* The board address and its columns live in `.claude/rt-kit/checks.json`: the identifiers of the
|
|
31
|
+
* project, the fields and the options are issued by GitHub itself when the board is created, and
|
|
32
|
+
* they cannot be guessed. An empty value means the tree has not created a board — then work with
|
|
33
|
+
* it refuses out loud instead of silently editing someone else's.
|
|
36
34
|
*/
|
|
37
35
|
const BOARD = CONFIG.board ?? {};
|
|
38
36
|
|
|
39
37
|
export const OWNER = BOARD.owner ?? '';
|
|
40
38
|
export const REPO = BOARD.repo ?? '';
|
|
41
39
|
export const PROJECT_ID = BOARD.projectId ?? '';
|
|
42
|
-
/**
|
|
40
|
+
/** The board's "Status" field — the column the task stands in now */
|
|
43
41
|
export const STATUS_FIELD_ID = BOARD.statusFieldId ?? '';
|
|
44
42
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
43
|
+
* The board columns under their short names. The progress is read by them, not by whether the
|
|
44
|
+
* task has a branch: branches are not visible on the board at all.
|
|
47
45
|
*/
|
|
48
46
|
export const STATUS_OPTIONS = BOARD.statusOptions ?? {};
|
|
49
|
-
/**
|
|
47
|
+
/** The column of a newly created task */
|
|
50
48
|
export const BACKLOG_OPTION_ID = STATUS_OPTIONS.backlog?.id ?? '';
|
|
51
|
-
/**
|
|
49
|
+
/** The column of a task taken into work, and of a task whose PR waits for review */
|
|
52
50
|
export const IN_PROGRESS_STATUS = 'in-progress';
|
|
53
51
|
export const IN_REVIEW_STATUS = 'in-review';
|
|
54
|
-
/**
|
|
52
|
+
/** The machine account — the same one the commits come from */
|
|
55
53
|
export const BOT = BOARD.bot ?? '';
|
|
56
54
|
/**
|
|
57
|
-
*
|
|
55
|
+
* The task key: gives the branch `<KEY>-<number>-<slug>` and the title `[<KEY>-<number>]`.
|
|
58
56
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
57
|
+
* The only thing in the name form that the tree chooses itself — and so the only thing the
|
|
58
|
+
* delivery law allows to configure. The tree must name it: an empty key assembles into `[-317]`,
|
|
59
|
+
* and such a title matches nothing. The refusal is by name, because silence costs more here: the
|
|
60
|
+
* queue audit does not fail but marks every task as wrongly named, and the real discrepancy drowns
|
|
61
|
+
* among those lines.
|
|
64
62
|
*/
|
|
65
63
|
export const TASK_KEY = BOARD.taskKey ?? '';
|
|
66
64
|
if (PROJECT_ID && !TASK_KEY) {
|
|
67
65
|
console.error(
|
|
68
|
-
'board:
|
|
69
|
-
'
|
|
66
|
+
'board: the task key is not named — set it by the key `board.taskKey` in .claude/rt-kit/checks.json.\n' +
|
|
67
|
+
'The task title `[<KEY>-<number>]` and the branch name `<KEY>-<number>-<short-name>` are assembled from it.'
|
|
70
68
|
);
|
|
71
69
|
process.exit(1);
|
|
72
70
|
}
|
|
73
|
-
/**
|
|
71
|
+
/** Who is requested for review: without a reviewer the PR does not reach the owner's inbox. */
|
|
74
72
|
export const REVIEWER = BOARD.reviewer ?? '';
|
|
75
73
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
74
|
+
* Tasks standing on the board, and board items that are not tasks. Each task has its board item
|
|
75
|
+
* and column: a task can be moved only by the item identifier, not by the task number, and it is
|
|
76
|
+
* taken right here so as not to ask the board twice.
|
|
79
77
|
*/
|
|
80
78
|
export function fetchBoard(options) {
|
|
81
79
|
const items = new Map();
|
|
@@ -95,7 +93,7 @@ export function fetchBoard(options) {
|
|
|
95
93
|
if (content.__typename === 'Issue') {
|
|
96
94
|
items.set(content.number, { itemId: node.id, status: node.status?.name ?? null });
|
|
97
95
|
} else {
|
|
98
|
-
foreign.push(content.__typename === 'PullRequest' ? `PR #${content.number}` :
|
|
96
|
+
foreign.push(content.__typename === 'PullRequest' ? `PR #${content.number}` : `a draft «${content.title}»`);
|
|
99
97
|
}
|
|
100
98
|
}
|
|
101
99
|
if (!page.pageInfo.hasNextPage) {
|
|
@@ -106,17 +104,17 @@ export function fetchBoard(options) {
|
|
|
106
104
|
}
|
|
107
105
|
|
|
108
106
|
/**
|
|
109
|
-
*
|
|
110
|
-
*
|
|
107
|
+
* Moving a task to another column. The task's state on the board is the only thing the progress
|
|
108
|
+
* is visible by: the board does not read the branch or the open PR itself.
|
|
111
109
|
*/
|
|
112
110
|
export function moveTask(number, status, options) {
|
|
113
111
|
const option = STATUS_OPTIONS[status];
|
|
114
112
|
if (!option) {
|
|
115
|
-
throw new Error(
|
|
113
|
+
throw new Error(`an unknown column «${status}» — there are ${Object.keys(STATUS_OPTIONS).join(', ')}`);
|
|
116
114
|
}
|
|
117
115
|
const item = fetchBoard(options).items.get(number);
|
|
118
116
|
if (!item) {
|
|
119
|
-
throw new Error(
|
|
117
|
+
throw new Error(`the task #${number} is not on the board — it is created by the command npm run task:new`);
|
|
120
118
|
}
|
|
121
119
|
graphql(
|
|
122
120
|
`mutation { updateProjectV2ItemFieldValue(input: {projectId: "${PROJECT_ID}", itemId: "${item.itemId}", fieldId: "${STATUS_FIELD_ID}", value: {singleSelectOptionId: "${option.id}"}}) { projectV2Item { id } } }`,
|
|
@@ -125,9 +123,22 @@ export function moveTask(number, status, options) {
|
|
|
125
123
|
return { from: item.status, to: option.name };
|
|
126
124
|
}
|
|
127
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Whose eyes the state was taken with: `machine` — the call went with the machine account's
|
|
128
|
+
* token, `client` — as whoever the hosting client is logged in as. A task is read with the token,
|
|
129
|
+
* a PR without it, and from the output alone this cannot be told apart: a tree whose machine
|
|
130
|
+
* account was restricted by the hosting got a person's picture and took it as checked. The login
|
|
131
|
+
* is not printed here — it would take a second network request, and the guards read the answer
|
|
132
|
+
* without it.
|
|
133
|
+
*/
|
|
134
|
+
export function viewerOf(options) {
|
|
135
|
+
return options?.token ? 'machine' : 'client';
|
|
136
|
+
}
|
|
137
|
+
|
|
128
138
|
export function fetchIssues(state, options) {
|
|
129
|
-
//
|
|
130
|
-
//
|
|
139
|
+
// The body is taken together with the list, not by a call per task: the link to an epic is
|
|
140
|
+
// read exactly there, and four hundred calls of the kind "show one task" would cost more than
|
|
141
|
+
// the whole audit.
|
|
131
142
|
return ghJson(
|
|
132
143
|
['issue', 'list', '--state', state, '--limit', '400', '--json', 'number,title,state,assignees,labels,body'],
|
|
133
144
|
options,
|
|
@@ -146,16 +157,17 @@ export function fetchIssue(number, options) {
|
|
|
146
157
|
}
|
|
147
158
|
|
|
148
159
|
/**
|
|
149
|
-
*
|
|
150
|
-
*
|
|
160
|
+
* The PR state in delivery terms: whether it exists, whether it is a draft and whether it has a
|
|
161
|
+
* review — a requested reviewer or a review already left.
|
|
151
162
|
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
163
|
+
* Before this edit nobody asked about the reviewer: it lived as prose in the pattern about the
|
|
164
|
+
* commit and the PR, and the hosting silently accepts a review request to oneself — the review
|
|
165
|
+
* then looks requested, and there is none.
|
|
155
166
|
*/
|
|
156
167
|
export function pullState(ref, options) {
|
|
157
|
-
//
|
|
158
|
-
//
|
|
168
|
+
// The PR reference is optional: without it the hosting client takes the PR of the current
|
|
169
|
+
// branch, and that is the shortest form of the call. Requiring a number would mean silently
|
|
170
|
+
// skipping it.
|
|
159
171
|
const target = ref === undefined || ref === null || `${ref}`.trim() === '' ? [] : [`${ref}`.trim()];
|
|
160
172
|
let pull;
|
|
161
173
|
try {
|
|
@@ -164,32 +176,34 @@ export function pullState(ref, options) {
|
|
|
164
176
|
if (error instanceof OfflineError) {
|
|
165
177
|
throw error;
|
|
166
178
|
}
|
|
167
|
-
return { exists: false };
|
|
179
|
+
return { exists: false, viewer: viewerOf(options) };
|
|
168
180
|
}
|
|
169
181
|
if (!pull) {
|
|
170
|
-
return { exists: false };
|
|
182
|
+
return { exists: false, viewer: viewerOf(options) };
|
|
171
183
|
}
|
|
172
184
|
const requested = (pull.reviewRequests ?? []).map((entry) => entry.login ?? entry.name ?? '').filter(Boolean);
|
|
173
185
|
const reviewed = (pull.latestReviews ?? []).map((entry) => entry.author?.login ?? '').filter(Boolean);
|
|
174
186
|
const reviewers = [...new Set([...requested, ...reviewed])];
|
|
175
187
|
return {
|
|
176
188
|
exists: true,
|
|
189
|
+
viewer: viewerOf(options),
|
|
177
190
|
number: pull.number ?? null,
|
|
178
191
|
draft: pull.isDraft === true,
|
|
179
192
|
author: pull.author?.login ?? null,
|
|
180
193
|
reviewers,
|
|
181
194
|
reviewed: reviewers.filter((login) => login !== (pull.author?.login ?? null)).length > 0,
|
|
182
|
-
//
|
|
183
|
-
//
|
|
184
|
-
//
|
|
195
|
+
// A conflict arrives through someone else's merge, without a single action by the PR
|
|
196
|
+
// author. Only a direct "conflicting" is judged: `UNKNOWN` means the hosting is still
|
|
197
|
+
// computing, and reading it as a conflict would mean refusing work on every fresh head.
|
|
185
198
|
conflicting: pull.mergeable === 'CONFLICTING',
|
|
186
199
|
};
|
|
187
200
|
}
|
|
188
201
|
|
|
189
202
|
/**
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
203
|
+
* How many commits the PR branch is behind main. The guard judges the base at the minute of
|
|
204
|
+
* opening, and a PR stands for days: what was merged in that time is seen neither by it nor by a
|
|
205
|
+
* green run. Nothing to compare with — zero: an audit without access would refuse work instead
|
|
206
|
+
* of a miss; without network the refusal is thrown, as everywhere.
|
|
193
207
|
*/
|
|
194
208
|
export function behindMain(branch, mainBranch, options) {
|
|
195
209
|
if (!OWNER || !REPO || !branch || !mainBranch) {
|
|
@@ -209,8 +223,8 @@ export function behindMain(branch, mainBranch, options) {
|
|
|
209
223
|
}
|
|
210
224
|
}
|
|
211
225
|
|
|
212
|
-
/**
|
|
213
|
-
*
|
|
226
|
+
/** The head is taken together with the rest: both the task folder and the run are judged by it,
|
|
227
|
+
* and asking for it later would mean a second call per PR. */
|
|
214
228
|
export function fetchOpenPulls(options) {
|
|
215
229
|
return ghJson(
|
|
216
230
|
['pr', 'list', '--state', 'open', '--limit', '200', '--json', 'number,title,headRefName,headRefOid,isDraft,body,mergeable,baseRefName'],
|
|
@@ -219,17 +233,16 @@ export function fetchOpenPulls(options) {
|
|
|
219
233
|
}
|
|
220
234
|
|
|
221
235
|
/**
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
* заявка прибавляет к очереди ещё одну, которую придётся догонять.
|
|
236
|
+
* Own open PRs marked as conflicting. Asked at the minute new work is taken: while what was
|
|
237
|
+
* handed over conflicts, a person cannot merge it, and every next PR adds one more to the queue.
|
|
225
238
|
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
239
|
+
* Own means opened by the tree's machine account. A tree that has not named it is not asked at
|
|
240
|
+
* all: `@me` would answer with the account the hosting client is logged in as — most often the
|
|
241
|
+
* owner, whose PRs are not the executor's to fix.
|
|
229
242
|
*
|
|
230
|
-
*
|
|
231
|
-
* —
|
|
232
|
-
*
|
|
243
|
+
* Only a direct `CONFLICTING` is judged. `UNKNOWN` means the hosting is still computing
|
|
244
|
+
* mergeability — it recomputes it after every edit of the main branch — and reading it as a
|
|
245
|
+
* conflict would refuse work on every fresh head.
|
|
233
246
|
*/
|
|
234
247
|
export function conflictingPulls(options) {
|
|
235
248
|
if (!BOT) {
|
|
@@ -244,9 +257,9 @@ export function conflictingPulls(options) {
|
|
|
244
257
|
.map((pull) => ({ number: pull.number ?? null, branch: pull.headRefName ?? '' }));
|
|
245
258
|
}
|
|
246
259
|
|
|
247
|
-
/** `[
|
|
260
|
+
/** `[<KEY>-<number>]` at the start of the title — the only form of the number in names */
|
|
248
261
|
export const TITLE_NUMBER = new RegExp(`^\\[${TASK_KEY}-(\\d+)\\]\\s+\\S`);
|
|
249
|
-
/**
|
|
262
|
+
/** `<KEY>-<number>-<slug>` — the name of the branch set aside for the task */
|
|
250
263
|
export const BRANCH_NUMBER = new RegExp(`^${TASK_KEY}-(\\d+)-[a-z0-9][a-z0-9-]*$`);
|
|
251
264
|
|
|
252
265
|
export function numberFromTitle(title) {
|
|
@@ -255,42 +268,41 @@ export function numberFromTitle(title) {
|
|
|
255
268
|
}
|
|
256
269
|
|
|
257
270
|
/**
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
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.
|
|
262
275
|
*/
|
|
263
276
|
export function numberFromTaskDir(name) {
|
|
264
|
-
//
|
|
265
|
-
//
|
|
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.
|
|
266
279
|
const prefix = TASK_KEY ? `(?:${TASK_KEY}-)?` : '';
|
|
267
280
|
const match = new RegExp(`^${prefix}(\\d+)-`).exec(name ?? '');
|
|
268
281
|
return match ? Number(match[1]) : null;
|
|
269
282
|
}
|
|
270
283
|
|
|
271
284
|
/**
|
|
272
|
-
*
|
|
273
|
-
*
|
|
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.
|
|
274
288
|
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
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.
|
|
277
291
|
*/
|
|
278
|
-
/**
|
|
292
|
+
/** The layout header: by it the laid-out copy is recognised, and so is the edit-place guard. */
|
|
279
293
|
const STAMP = /^<!-- rt-kit v[^\n]*-->\n/m;
|
|
280
294
|
|
|
281
295
|
/**
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
* Образец разложен пакетом и шапку несёт по праву: его кладёт и обновляет раскладка. Копия под
|
|
285
|
-
* задачу — уже текст проекта, тем же доводом, каким пакет кладёт без шапки черновик компаньона:
|
|
286
|
-
* с первой правки сверять в ней нечего.
|
|
296
|
+
* Remove the layout header from copies of the template.
|
|
287
297
|
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
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.
|
|
291
303
|
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
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.
|
|
294
306
|
*/
|
|
295
307
|
export function unstampFolder(folder) {
|
|
296
308
|
const cleaned = [];
|
|
@@ -344,18 +356,19 @@ export function numberFromBranch(branch) {
|
|
|
344
356
|
}
|
|
345
357
|
|
|
346
358
|
/**
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
359
|
+
* The task state in the law's terms: it exists, it stands in the work queue, it has an executor,
|
|
360
|
+
* it is not yet closed. Closed means the branch under it has already gone into main, and a task
|
|
361
|
+
* has one branch.
|
|
350
362
|
*/
|
|
351
363
|
export function taskState(number, options) {
|
|
352
364
|
const issue = fetchIssue(number, options);
|
|
353
365
|
if (!issue) {
|
|
354
|
-
return { exists: false };
|
|
366
|
+
return { exists: false, viewer: viewerOf(options) };
|
|
355
367
|
}
|
|
356
368
|
const item = fetchBoard(options).items.get(issue.number);
|
|
357
369
|
return {
|
|
358
370
|
exists: true,
|
|
371
|
+
viewer: viewerOf(options),
|
|
359
372
|
title: issue.title,
|
|
360
373
|
open: issue.state === 'OPEN',
|
|
361
374
|
onBoard: item !== undefined,
|
|
@@ -368,50 +381,55 @@ export function taskState(number, options) {
|
|
|
368
381
|
}
|
|
369
382
|
|
|
370
383
|
/**
|
|
371
|
-
*
|
|
372
|
-
* или нет.
|
|
384
|
+
* The work queue's answer about a created task, folded into lines, and the verdict: secured or not.
|
|
373
385
|
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
386
|
+
* Separated from the network calls on purpose. Creation ends not with the command output but with
|
|
387
|
+
* the queue's answer, and the decision of what to print and how to end is exactly where sixteen
|
|
388
|
+
* tasks in a row passed as successful without one reaching the queue. Inside the network calls it
|
|
389
|
+
* is checked only by a live board, that is, never.
|
|
378
390
|
*
|
|
379
|
-
* `state` —
|
|
391
|
+
* `state` — what `taskState` returned, or `{ offline: <reason> }` if asking failed.
|
|
380
392
|
*/
|
|
381
393
|
export function describeTaskState(number, state) {
|
|
382
394
|
if (state?.offline) {
|
|
383
395
|
return {
|
|
384
396
|
ok: false,
|
|
385
397
|
lines: [
|
|
386
|
-
|
|
387
|
-
'
|
|
398
|
+
`in the work queue: could not be asked — ${state.offline}`,
|
|
399
|
+
'the state of the queue is unknown, and that does not count as created',
|
|
388
400
|
],
|
|
389
401
|
};
|
|
390
402
|
}
|
|
391
403
|
if (!state?.exists) {
|
|
392
|
-
return { ok: false, lines: [
|
|
404
|
+
return { ok: false, lines: [`the hosting has no task #${number} — the creation did not happen`] };
|
|
393
405
|
}
|
|
394
406
|
if (!state.onBoard) {
|
|
395
407
|
return {
|
|
396
408
|
ok: false,
|
|
397
|
-
lines: [
|
|
409
|
+
lines: [`in the work queue: NO`, 'a task that is not in the queue is backed by no work — nobody will come for it'],
|
|
398
410
|
};
|
|
399
411
|
}
|
|
400
412
|
|
|
401
|
-
const column = state.status ?
|
|
413
|
+
const column = state.status ? `the column «${state.status}»` : 'there is no column';
|
|
402
414
|
if (!state.assigned) {
|
|
403
415
|
return {
|
|
404
416
|
ok: false,
|
|
405
|
-
lines: [
|
|
417
|
+
lines: [`in the work queue: ${column}, no assignee`, 'a task belonging to nobody stands in the queue invisible to whoever does it'],
|
|
406
418
|
};
|
|
407
419
|
}
|
|
408
|
-
return { ok: true, lines: [
|
|
420
|
+
return { ok: true, lines: [`in the work queue: ${column}, assignee ${state.assignees.join(', ')}`] };
|
|
409
421
|
}
|
|
410
422
|
|
|
411
423
|
const isEntryPoint = process.argv[1] && import.meta.url === `file://${process.argv[1]}`;
|
|
424
|
+
// The machine account's token is substituted here too, as in the column move. Without it the
|
|
425
|
+
// client goes as whoever is logged in, and during a guard's turn nobody is logged in: the hosting
|
|
426
|
+
// answers that the repository does not exist at all, reading the task returns nothing, and "there
|
|
427
|
+
// was nothing to ask with" becomes indistinguishable from "the task does not exist". On such an
|
|
428
|
+
// answer the delivery guard refused opening a PR with five mutually exclusive reasons at once —
|
|
429
|
+
// no task, the task is closed, the task is not in the queue.
|
|
412
430
|
if (isEntryPoint && process.argv[2] === 'task') {
|
|
413
431
|
try {
|
|
414
|
-
process.stdout.write(`${JSON.stringify(taskState(Number(process.argv[3])))}\n`);
|
|
432
|
+
process.stdout.write(`${JSON.stringify(taskState(Number(process.argv[3]), { token: botToken() ?? undefined }))}\n`);
|
|
415
433
|
} catch (error) {
|
|
416
434
|
if (error instanceof OfflineError) {
|
|
417
435
|
process.stdout.write('{"offline":true}\n');
|
|
@@ -424,6 +442,10 @@ if (isEntryPoint && process.argv[2] === 'task') {
|
|
|
424
442
|
|
|
425
443
|
if (isEntryPoint && process.argv[2] === 'pr') {
|
|
426
444
|
try {
|
|
445
|
+
// There is no token here on purpose: the review fields need access to the organisation's
|
|
446
|
+
// accounts, which the machine account was not given, and a request with it is refused on
|
|
447
|
+
// rights entirely. A client without a token goes as whoever is logged in, and for a person
|
|
448
|
+
// it answers.
|
|
427
449
|
process.stdout.write(`${JSON.stringify(pullState(process.argv[3]))}\n`);
|
|
428
450
|
} catch (error) {
|
|
429
451
|
if (error instanceof OfflineError) {
|
|
@@ -435,12 +457,12 @@ if (isEntryPoint && process.argv[2] === 'pr') {
|
|
|
435
457
|
}
|
|
436
458
|
}
|
|
437
459
|
|
|
438
|
-
//
|
|
439
|
-
//
|
|
440
|
-
//
|
|
460
|
+
// Own conflicting PRs as one line of JSON: `{"conflicting":[{"number":…,"branch":…}]}`.
|
|
461
|
+
// The delivery guard calls it before letting new work be taken. A tree without a machine account
|
|
462
|
+
// answers with an empty list: there is nobody to ask about.
|
|
441
463
|
if (isEntryPoint && process.argv[2] === 'conflicts') {
|
|
442
464
|
try {
|
|
443
|
-
process.stdout.write(`${JSON.stringify({ conflicting: conflictingPulls() ?? [] })}\n`);
|
|
465
|
+
process.stdout.write(`${JSON.stringify({ conflicting: conflictingPulls({ token: botToken() ?? undefined }) ?? [] })}\n`);
|
|
444
466
|
} catch (error) {
|
|
445
467
|
if (error instanceof OfflineError) {
|
|
446
468
|
process.stdout.write('{"offline":true}\n');
|
|
@@ -451,26 +473,26 @@ if (isEntryPoint && process.argv[2] === 'conflicts') {
|
|
|
451
473
|
}
|
|
452
474
|
}
|
|
453
475
|
|
|
454
|
-
//
|
|
455
|
-
//
|
|
456
|
-
//
|
|
457
|
-
//
|
|
458
|
-
//
|
|
459
|
-
//
|
|
476
|
+
// The column move edits the board. The machine account's token is optional here: a tree that has
|
|
477
|
+
// not named it edits the board as the account the hosting client is logged in as. Requiring the
|
|
478
|
+
// token would hold the work queue back from a tree that created no machine account, and from a
|
|
479
|
+
// tree whose account the hosting restricted. No connection is still a refusal, not a skip: a task
|
|
480
|
+
// left unmoved silently stays in its old column, and the discrepancy surfaces only through the
|
|
481
|
+
// queue audit.
|
|
460
482
|
if (isEntryPoint && process.argv[2] === 'move') {
|
|
461
483
|
const number = Number(process.argv[3]);
|
|
462
484
|
const status = process.argv[4];
|
|
463
485
|
if (!Number.isInteger(number) || !status) {
|
|
464
|
-
console.error(`board:
|
|
486
|
+
console.error(`board: a task number and a column are needed — node tools/board.mjs move 263 ${IN_PROGRESS_STATUS}`);
|
|
465
487
|
process.exit(1);
|
|
466
488
|
}
|
|
467
489
|
const token = botToken() ?? undefined;
|
|
468
490
|
try {
|
|
469
491
|
const moved = moveTask(number, status, { token });
|
|
470
|
-
console.log(`#${number}: ${moved.from ?? '
|
|
492
|
+
console.log(`#${number}: ${moved.from ?? 'outside the columns'} → ${moved.to}`);
|
|
471
493
|
} catch (error) {
|
|
472
|
-
const reason = error instanceof OfflineError ?
|
|
473
|
-
console.error(`board:
|
|
494
|
+
const reason = error instanceof OfflineError ? `no connection to GitHub: ${error.message}` : String(error.message ?? error);
|
|
495
|
+
console.error(`board: the task #${number} stayed in its former place — ${reason}`);
|
|
474
496
|
process.exit(1);
|
|
475
497
|
}
|
|
476
498
|
}
|