@rt-tools/agent-kit 0.24.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/business-analyst.md +51 -50
- package/assets/agents/cargo-writer.md +54 -0
- 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-epic-link.github.mjs +29 -0
- package/assets/checks/board-epics.github.mjs +286 -49
- 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 +29 -25
- package/assets/checks/board-paths.github.mjs +21 -16
- package/assets/checks/board-pull-state.github.mjs +168 -0
- package/assets/checks/board-runs.github.mjs +45 -43
- package/assets/checks/board-task-dirs.github.mjs +98 -0
- package/assets/checks/board-titles.github.mjs +19 -17
- package/assets/checks/board.github.mjs +133 -194
- package/assets/checks/check-archive-age.mjs +23 -19
- package/assets/checks/check-board.github.mjs +131 -263
- 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 +138 -39
- package/assets/checks/check-push-gate.mjs +53 -50
- package/assets/checks/check-reuse.mjs +50 -40
- package/assets/checks/check-schema-drift.mjs +104 -84
- 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/epic-table.github.mjs +268 -0
- 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 +187 -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/specs-for.mjs +214 -0
- package/assets/checks/task-new.github.mjs +315 -61
- package/assets/commands/feedback.md +65 -59
- package/assets/commands/next-session.md +64 -57
- package/assets/commands/night.md +115 -0
- package/assets/commands/skill-curator.md +83 -79
- package/assets/defaults/gate-map.sh +108 -97
- package/assets/defaults/project.sh +232 -185
- package/assets/defaults/shell.sh +73 -68
- package/assets/defaults/turn-map.md +47 -44
- package/assets/docs/GLOSSARY.md +142 -65
- package/assets/hooks/browser-device-id.sh +16 -12
- package/assets/hooks/browser-guard-device-id.sh +34 -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 +14 -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 +50 -43
- package/assets/hooks/dispatch.sh +60 -46
- package/assets/hooks/docs-guard.sh +100 -91
- package/assets/hooks/epic-over.sh +49 -0
- package/assets/hooks/epic-stop-guard.sh +108 -0
- package/assets/hooks/exam-guard.sh +105 -93
- package/assets/hooks/git-guard-delivery-conflict.sh +41 -36
- package/assets/hooks/git-guard-delivery-draft.sh +48 -38
- package/assets/hooks/git-guard-delivery-epic.sh +167 -0
- package/assets/hooks/git-guard-delivery-folder.sh +50 -43
- package/assets/hooks/git-guard-delivery-signature.sh +119 -53
- package/assets/hooks/git-guard-delivery.sh +223 -183
- 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 +45 -25
- 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 +49 -24
- package/assets/hooks/qa-dataid-guard.sh +83 -58
- 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 +39 -34
- package/assets/hooks/rule-source-guard.sh +47 -42
- package/assets/hooks/skill-gate-layers.sh +63 -57
- package/assets/hooks/skill-gate-rearm.sh +15 -8
- package/assets/hooks/skill-gate.sh +89 -81
- package/assets/hooks/skill-loaded.sh +10 -6
- package/assets/hooks/sql-guard-parse.sh +71 -66
- package/assets/hooks/sql-guard-request.sh +51 -46
- package/assets/hooks/sql-guard-target.sh +60 -51
- package/assets/hooks/sql-guard-write.sh +87 -79
- package/assets/hooks/sql-guard.sh +52 -47
- package/assets/hooks/stand-login-guard.sh +43 -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 +260 -204
- package/assets/hooks/turn-exit-patterns.sh +63 -0
- package/assets/hooks/utf8.sh +14 -11
- package/assets/hooks/waiting-turn-guard.sh +104 -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 +99 -44
- package/assets/laws/autonomous-work.md +29 -27
- package/assets/laws/code-structure.md +31 -30
- package/assets/laws/delivery.md +170 -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 +94 -87
- package/assets/patterns/git-workflow-commit.github.md +160 -142
- package/assets/patterns/git-workflow-commit.gitlab.md +96 -90
- 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 +102 -94
- 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 +127 -122
- package/assets/patterns/git-workflow-pr.github.md +186 -177
- package/assets/patterns/git-workflow-pr.gitlab.md +139 -132
- 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 +136 -107
- 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 +48 -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 +234 -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 +228 -202
- 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 +172 -142
- package/assets/pitfalls/doc-style.md +96 -91
- package/assets/pitfalls/git-workflow.azure.md +49 -46
- package/assets/pitfalls/git-workflow.github.md +270 -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 +87 -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 +201 -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 +268 -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 +279 -260
- package/assets/rules/status-report.md +62 -58
- package/assets/rules/styling-bem.md +81 -77
- package/assets/rules/task-flow.md +303 -270
- package/assets/rules/testing.md +224 -209
- package/assets/rules/turn-conduct.md +262 -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 +259 -233
- 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/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/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/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/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 +29 -9
- package/lib/ship.d.ts.map +1 -1
- package/lib/ship.js +44 -2
- 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 +38 -5
- 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.27.0.tgz +0 -0
- package/rt-tools-agent-kit-0.24.0.tgz +0 -0
|
@@ -1,23 +1,40 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Creating the task an edit starts with.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Creation is made of four steps, and the edit starts only after all four: the task, the number in
|
|
6
|
+
* its title, adding it to the board, the «Backlog» state. While the steps were rewritten by hand
|
|
7
|
+
* from a pattern, a miss on any of them gave a task that is not in the work queue: two such stood
|
|
8
|
+
* idle for a month.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* The command does not create the branch — it prints the ready line. Creating a branch by a call
|
|
11
|
+
* of its own is demanded by the main branch guard: the compound «create a branch and commit right
|
|
12
|
+
* away» it turns down whole.
|
|
13
13
|
*
|
|
14
|
-
* npm run task:new -- --title '
|
|
15
|
-
* npm run task:new -- --title '…' --slug mail-owner-silence <
|
|
14
|
+
* npm run task:new -- --title 'Letters to the owner are not sent' --label bug --label area:api
|
|
15
|
+
* npm run task:new -- --title '…' --slug mail-owner-silence < description.md
|
|
16
|
+
* npm run task:new -- --epic --title 'Delivery goes by epics' --slug work-by-epics
|
|
17
|
+
* npm run task:new -- --epic-of 1921 --title '…' --slug command-creates-epic
|
|
18
|
+
* npm run task:new -- --outside-epic 'the owner asked for it apart' --title '…'
|
|
16
19
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
20
|
+
* The body is read from standard input. The author and the assignee are the bot account, the same
|
|
21
|
+
* one the commits go from; `--assignee` overrides the assignee.
|
|
22
|
+
*
|
|
23
|
+
* With `--epic` the same four steps create an epic — the card the tasks of a piece of work wider
|
|
24
|
+
* than one branch hang on. Three things are added to them: the epic label, without which the audit
|
|
25
|
+
* has nothing to tell an epic card from an ordinary task by; a draft of the plan in the tree's
|
|
26
|
+
* plans directory, because the card carries neither the makeup of the epic nor the order of its
|
|
27
|
+
* tasks; and the path to that draft in the card body — the audit reads the plan by it, and a card
|
|
28
|
+
* without the path points into emptiness. The branch line printed at the end is taken from the main
|
|
29
|
+
* branch: the branch of an epic is the base for the branches of its tasks.
|
|
30
|
+
*
|
|
31
|
+
* With `--epic-of <number>` the created task is a task of that epic: the body says so in the very
|
|
32
|
+
* shape the audit reads the link by, and the printed branch line takes the branch of the epic as
|
|
33
|
+
* its base. Both are written here and not left to the executor's hand: the shape of the line is
|
|
34
|
+
* read by a machine from two sides at once, and the base of the branch is otherwise taken from the
|
|
35
|
+
* working copy, where at that minute any branch may be checked out.
|
|
19
36
|
*/
|
|
20
|
-
import { cpSync, existsSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
37
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
21
38
|
import { dirname, join, resolve } from 'node:path';
|
|
22
39
|
import { fileURLToPath } from 'node:url';
|
|
23
40
|
|
|
@@ -40,9 +57,18 @@ import {
|
|
|
40
57
|
taskState,
|
|
41
58
|
unstampFolder,
|
|
42
59
|
} from './board.mjs';
|
|
60
|
+
import { CONFIG, ROOT } from './rt-kit-checks.config.mjs';
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* What an epic is created by: the label of its card and the directory its plan is put in. Both are
|
|
64
|
+
* each tree's own words, and neither has a default — a plan laid at a guessed address is found by
|
|
65
|
+
* nobody, and a card without the label is an ordinary task to the audit.
|
|
66
|
+
*/
|
|
67
|
+
const EPIC_LABEL = CONFIG.board?.epicLabel ?? '';
|
|
68
|
+
const PLANS_DIR = CONFIG.plansDir ?? '';
|
|
43
69
|
|
|
44
70
|
function parseArgs(argv) {
|
|
45
|
-
const args = { labels: [], assignee: BOT, title: null, slug: null };
|
|
71
|
+
const args = { labels: [], assignee: BOT, title: null, slug: null, epic: false, epicOf: null, outsideEpic: null };
|
|
46
72
|
for (let index = 0; index < argv.length; index += 1) {
|
|
47
73
|
const value = argv[index + 1];
|
|
48
74
|
switch (argv[index]) {
|
|
@@ -62,8 +88,19 @@ function parseArgs(argv) {
|
|
|
62
88
|
args.slug = value;
|
|
63
89
|
index += 1;
|
|
64
90
|
break;
|
|
91
|
+
case '--epic':
|
|
92
|
+
args.epic = true;
|
|
93
|
+
break;
|
|
94
|
+
case '--epic-of':
|
|
95
|
+
args.epicOf = Number(value);
|
|
96
|
+
index += 1;
|
|
97
|
+
break;
|
|
98
|
+
case '--outside-epic':
|
|
99
|
+
args.outsideEpic = value ?? '';
|
|
100
|
+
index += 1;
|
|
101
|
+
break;
|
|
65
102
|
default:
|
|
66
|
-
fail(
|
|
103
|
+
fail(`unknown flag ${argv[index]}`);
|
|
67
104
|
}
|
|
68
105
|
}
|
|
69
106
|
return args;
|
|
@@ -87,23 +124,139 @@ function readBody() {
|
|
|
87
124
|
|
|
88
125
|
const args = parseArgs(process.argv.slice(2));
|
|
89
126
|
if (!args.title) {
|
|
90
|
-
fail("
|
|
127
|
+
fail("--title '<Что не так>' is required");
|
|
91
128
|
}
|
|
92
129
|
if (numberFromTitle(args.title) !== null || args.title.startsWith(`[${TASK_KEY}-`)) {
|
|
93
|
-
fail('
|
|
130
|
+
fail('the number is not typed into the title by hand: it is known only after the creation and is appended by itself');
|
|
94
131
|
}
|
|
95
132
|
if (args.slug !== null && !/^[a-z0-9][a-z0-9-]*$/.test(args.slug)) {
|
|
96
|
-
fail('slug
|
|
133
|
+
fail('slug is lowercase latin letters, digits and dashes: the branch name is read in a list of fifty lines');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* A task outside an epic is not created — that is the whole of the requirement, and the refusal
|
|
138
|
+
* carries both lawful ways out of it, because in the shape «name the epic» alone it is read as
|
|
139
|
+
* "there is no way out" and gets bypassed by a call to the hosting past this command.
|
|
140
|
+
*
|
|
141
|
+
* The owner's word is the second way, and it goes into the call as text: work outside an epic
|
|
142
|
+
* happens — a one-line fix, a report from the outside — and only the owner names it as such. An
|
|
143
|
+
* empty reason is not a reason: it is indistinguishable from a flag typed to get past a refusal.
|
|
144
|
+
*
|
|
145
|
+
* A tree that has not named the epic label lives as before: there epics do not exist at all, and
|
|
146
|
+
* demanding one of every task would stop the work of every such tree on the day of installation.
|
|
147
|
+
*/
|
|
148
|
+
if (EPIC_LABEL && !args.epic && args.epicOf === null && args.outsideEpic === null) {
|
|
149
|
+
fail(
|
|
150
|
+
'a task outside an epic is not taken. Two ways: name the epic — `--epic-of <number>` — or name the word of the owner about work outside an epic — `--outside-epic "<the reason of the owner>"`'
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
if (args.outsideEpic !== null && args.outsideEpic.trim() === '') {
|
|
154
|
+
fail('--outside-epic "<the reason of the owner>": an empty reason is indistinguishable from a flag typed to get past the refusal');
|
|
155
|
+
}
|
|
156
|
+
if (args.outsideEpic !== null && (args.epic || args.epicOf !== null)) {
|
|
157
|
+
fail('--outside-epic goes with neither --epic nor --epic-of: work is either under an epic or outside one, and the word of the owner is needed only for the second');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (args.epic && args.epicOf !== null) {
|
|
161
|
+
fail('--epic and --epic-of together: an epic is not a task of an epic. An epic inside an epic is not a shape this order knows');
|
|
162
|
+
}
|
|
163
|
+
if (args.epicOf !== null && !Number.isInteger(args.epicOf)) {
|
|
164
|
+
fail('--epic-of <number>: the number of the epic card, as it stands in the work queue');
|
|
97
165
|
}
|
|
98
166
|
|
|
99
167
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
168
|
+
* Everything an epic cannot be created without is asked before the creation, not after it: a card
|
|
169
|
+
* already made cannot be taken off the board by anyone but an administrator, and a refusal after
|
|
170
|
+
* the call leaves an epic without a plan and without a label — that is, invisible to the audit as
|
|
171
|
+
* an epic at all.
|
|
172
|
+
*/
|
|
173
|
+
if (args.epic) {
|
|
174
|
+
if (!EPIC_LABEL) {
|
|
175
|
+
fail('the label of an epic card is not named — `board.epicLabel` in the check settings. Without it the audit has nothing to tell an epic from an ordinary task by');
|
|
176
|
+
}
|
|
177
|
+
if (!PLANS_DIR) {
|
|
178
|
+
fail('the directory of plans is not named — `plansDir` in the check settings. The plan of an epic lies outside the task folder: the folder dies with the merge, the epic outlives it');
|
|
179
|
+
}
|
|
180
|
+
if (!args.slug) {
|
|
181
|
+
fail('--slug <short-slug> is required for an epic: the plan file and the branch of the epic are named by it');
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** The label goes with the card, and the audit finds the epic by it — no second way. */
|
|
186
|
+
const labels = args.epic && !args.labels.includes(EPIC_LABEL) ? [...args.labels, EPIC_LABEL] : args.labels;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* The token of the machine account is optional: a tree that has not named it creates the task
|
|
190
|
+
* under the account the hosting client is logged in as. Demanding the token would hold task
|
|
191
|
+
* creation in a tree that has not created a machine account, and in a tree whose account the
|
|
192
|
+
* hosting has limited — and without creation no work starts at all. Who exactly created the task
|
|
193
|
+
* is read off the task itself.
|
|
104
194
|
*/
|
|
105
195
|
const token = botToken() ?? undefined;
|
|
106
196
|
|
|
197
|
+
/**
|
|
198
|
+
* The plan of the epic and the line about it in the card body.
|
|
199
|
+
*
|
|
200
|
+
* The audit takes the path to the plan from the body: the card has to name it anyway, and a
|
|
201
|
+
* setting read instead would become a second truth about where the plan of this very epic lies. So
|
|
202
|
+
* the path is written into the body by the same call that creates the file.
|
|
203
|
+
*/
|
|
204
|
+
const planPath = args.epic ? `${PLANS_DIR.replace(/\/+$/, '')}/${args.slug}.md` : null;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* The epic the task is created under, read from its card.
|
|
208
|
+
*
|
|
209
|
+
* The link is declared by the task body, and the audit reads exactly one shape of it: the word
|
|
210
|
+
* about the task standing right before the word about the epic. Written by hand, the line comes
|
|
211
|
+
* out in a shape of its own once out of three, and the audit then says the task belongs to no epic
|
|
212
|
+
* while the executor sees the epic named in the body.
|
|
213
|
+
*
|
|
214
|
+
* The path to the plan is taken from the epic card, as the audit takes it — a second address here
|
|
215
|
+
* would diverge from the first one silently. The branch of the epic is read from the plan: the
|
|
216
|
+
* plan names it, and the queue does not know branch names at all.
|
|
217
|
+
*/
|
|
218
|
+
function epicOfCard(epicNumber) {
|
|
219
|
+
const card = ghJson(['issue', 'view', String(epicNumber), '--json', 'number,title,labels,body'], { token });
|
|
220
|
+
const labelled = (card.labels ?? []).some((label) => label.name === EPIC_LABEL);
|
|
221
|
+
if (!labelled) {
|
|
222
|
+
fail(`#${epicNumber} is not an epic: the card carries no label «${EPIC_LABEL}». A task hangs on an epic, and an epic is what the audit reads by that label`);
|
|
223
|
+
}
|
|
224
|
+
const named = String(card.body ?? '').match(/(?:^|[\s(`])([\w.-]+(?:\/[\w.-]+)+\.md)/);
|
|
225
|
+
const plan = named ? named[1] : null;
|
|
226
|
+
if (plan === null) {
|
|
227
|
+
fail(`the card of the epic #${epicNumber} names no path to its plan — there is nowhere to read what the epic holds, and the branch of the epic is named there too`);
|
|
228
|
+
}
|
|
229
|
+
return { plan, branch: epicBranchOf(plan, epicNumber) };
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* The branch of the epic, read from the header of its plan.
|
|
234
|
+
*
|
|
235
|
+
* Three spellings are accepted: the one this command writes, the bare word about a branch and the
|
|
236
|
+
* English one — the plans of a tree are translated one at a time, and a single spelling would take
|
|
237
|
+
* every plan but the freshest out of the reading in silence.
|
|
238
|
+
*/
|
|
239
|
+
function epicBranchOf(plan, epicNumber) {
|
|
240
|
+
const path = join(ROOT, plan);
|
|
241
|
+
if (!existsSync(path)) {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
const named = readFileSync(path, 'utf8').match(
|
|
245
|
+
new RegExp(`\\*\\*(?:Ветка эпика|Ветка|Branch):\\*\\*\\s*\`?(${TASK_KEY}-${epicNumber}-[a-z0-9][a-z0-9-]*)\`?`)
|
|
246
|
+
);
|
|
247
|
+
return named ? named[1] : null;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const epic = args.epicOf === null ? null : epicOfCard(args.epicOf);
|
|
251
|
+
const body = [
|
|
252
|
+
readBody(),
|
|
253
|
+
args.epic ? `Замысел эпика — ${planPath}` : '',
|
|
254
|
+
epic ? `Задача эпика #${args.epicOf}, замысел — ${epic.plan}` : '',
|
|
255
|
+
args.outsideEpic ? `Работа вне эпика — ${args.outsideEpic}` : '',
|
|
256
|
+
]
|
|
257
|
+
.filter((part) => part !== '')
|
|
258
|
+
.join('\n\n');
|
|
259
|
+
|
|
107
260
|
let number = null;
|
|
108
261
|
try {
|
|
109
262
|
const created = gh(
|
|
@@ -115,19 +268,19 @@ try {
|
|
|
115
268
|
'--title',
|
|
116
269
|
args.title,
|
|
117
270
|
'--body',
|
|
118
|
-
|
|
271
|
+
body,
|
|
119
272
|
'--assignee',
|
|
120
273
|
args.assignee,
|
|
121
|
-
...
|
|
274
|
+
...labels.flatMap((label) => ['--label', label]),
|
|
122
275
|
],
|
|
123
276
|
{ token }
|
|
124
277
|
).trim();
|
|
125
278
|
number = Number(created.split('/').pop());
|
|
126
279
|
if (!Number.isInteger(number)) {
|
|
127
|
-
fail(
|
|
280
|
+
fail(`the number of the created task cannot be parsed in the answer: ${created}`);
|
|
128
281
|
}
|
|
129
282
|
|
|
130
|
-
//
|
|
283
|
+
// The number is known only now, so the title is appended by a second call.
|
|
131
284
|
gh(['api', '-X', 'PATCH', `repos/${OWNER}/${REPO}/issues/${number}`, '-f', `title=[${TASK_KEY}-${number}] ${args.title}`], {
|
|
132
285
|
token,
|
|
133
286
|
});
|
|
@@ -141,31 +294,43 @@ try {
|
|
|
141
294
|
`mutation { updateProjectV2ItemFieldValue(input: {projectId: "${PROJECT_ID}", itemId: "${itemId}", fieldId: "${STATUS_FIELD_ID}", value: {singleSelectOptionId: "${BACKLOG_OPTION_ID}"}}) { projectV2Item { id } } }`,
|
|
142
295
|
{ token }
|
|
143
296
|
);
|
|
297
|
+
|
|
298
|
+
// The task of an epic becomes a sub-issue of the epic card. The line in the body says the same
|
|
299
|
+
// thing, but only to whoever opens the task: the board shows neither the makeup of an epic nor
|
|
300
|
+
// how much of it is done, and the count has to be assembled by hand from the list of open
|
|
301
|
+
// tasks. A sub-issue is the hosting's own link — the epic card gets the list and the progress,
|
|
302
|
+
// the task gets the line about its parent, and the board card gets the "done of total" bar.
|
|
303
|
+
//
|
|
304
|
+
// The link is asked by the numeric id of the task, not by its number: the endpoint takes the id.
|
|
305
|
+
if (args.epicOf !== null) {
|
|
306
|
+
const subId = ghJson(['api', `repos/${OWNER}/${REPO}/issues/${number}`, '--jq', '{id:.id}'], { token }).id;
|
|
307
|
+
gh(['api', '-X', 'POST', `repos/${OWNER}/${REPO}/issues/${args.epicOf}/sub_issues`, '-F', `sub_issue_id=${subId}`], { token });
|
|
308
|
+
}
|
|
144
309
|
} catch (error) {
|
|
145
|
-
const reason = error instanceof OfflineError ?
|
|
310
|
+
const reason = error instanceof OfflineError ? `no connection to GitHub: ${error.message}` : String(error.message ?? error);
|
|
146
311
|
if (number === null) {
|
|
147
312
|
fail(reason);
|
|
148
313
|
}
|
|
149
|
-
//
|
|
150
|
-
//
|
|
151
|
-
console.error(`task-new:
|
|
152
|
-
console.error(`task-new:
|
|
314
|
+
// The task already exists, and it may not be on the board — exactly the state tasks were being
|
|
315
|
+
// lost by. Staying silent here is not allowed: the number is printed to finish it by hand.
|
|
316
|
+
console.error(`task-new: the task #${number} is created but not finished — ${reason}`);
|
|
317
|
+
console.error(`task-new: check it and finish it — npm run check:board`);
|
|
153
318
|
process.exit(1);
|
|
154
319
|
}
|
|
155
320
|
|
|
156
|
-
const branch = args.slug ? `${TASK_KEY}-${number}-${args.slug}` : `${TASK_KEY}-${number}
|
|
321
|
+
const branch = args.slug ? `${TASK_KEY}-${number}-${args.slug}` : `${TASK_KEY}-${number}-<short-slug>`;
|
|
157
322
|
|
|
158
323
|
/**
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* `docs/tasks/_draft-<slug>`.
|
|
163
|
-
*
|
|
324
|
+
* The task folder is renamed here, because the number and the branch name are known at this moment
|
|
325
|
+
* for the only time in the whole work. The grill of the owner's request goes before the task is
|
|
326
|
+
* created — until the grill is over it is not even known how many tasks will come out of it — and
|
|
327
|
+
* lies in `docs/tasks/_draft-<slug>`. Left as a draft, it stays outside the history, and the next
|
|
328
|
+
* session does not find it: the startup hook looks for the folder by the branch name.
|
|
164
329
|
*/
|
|
165
330
|
|
|
166
331
|
function adoptDraft() {
|
|
167
332
|
if (!args.slug) {
|
|
168
|
-
console.log(`\
|
|
333
|
+
console.log(`\nThe task folder: --slug is not set, there is nothing to rename the draft by.`);
|
|
169
334
|
return;
|
|
170
335
|
}
|
|
171
336
|
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
@@ -173,66 +338,155 @@ function adoptDraft() {
|
|
|
173
338
|
const target = join(root, 'docs/tasks', branch);
|
|
174
339
|
|
|
175
340
|
if (existsSync(target)) {
|
|
176
|
-
console.log(`\
|
|
341
|
+
console.log(`\nThe task folder is already in place: docs/tasks/${branch}/`);
|
|
177
342
|
} else if (existsSync(draft)) {
|
|
178
343
|
renameSync(draft, target);
|
|
179
|
-
//
|
|
344
|
+
// The draft too is assembled from the sample, and the header in it is the same: it is
|
|
345
|
+
// taken off here as well.
|
|
180
346
|
unstampFolder(target);
|
|
181
|
-
console.log(`\
|
|
347
|
+
console.log(`\nThe task folder: docs/tasks/_draft-${args.slug}/ → docs/tasks/${branch}/`);
|
|
182
348
|
} else {
|
|
183
349
|
const template = join(root, 'docs/tasks/_template');
|
|
184
350
|
|
|
185
351
|
if (!existsSync(template)) {
|
|
186
|
-
console.log(`\
|
|
352
|
+
console.log(`\nThere is no task folder and nothing to assemble it from: the sample ${'docs/tasks/_template'} does not lie in the tree`);
|
|
187
353
|
return;
|
|
188
354
|
}
|
|
189
355
|
|
|
190
356
|
cpSync(template, target, { recursive: true });
|
|
191
357
|
unstampFolder(target);
|
|
192
|
-
console.log(`\
|
|
358
|
+
console.log(`\nThe task folder is assembled from the sample: docs/tasks/${branch}/`);
|
|
193
359
|
}
|
|
194
360
|
|
|
195
|
-
//
|
|
196
|
-
//
|
|
361
|
+
// The header of the plan is read by a guard: by it the guard finds the product agreement. The
|
|
362
|
+
// number in it is set right here — by hand it is copied over from a hint and mistyped.
|
|
197
363
|
const plan = join(target, 'plan.md');
|
|
198
364
|
if (!existsSync(plan)) {
|
|
199
365
|
return;
|
|
200
366
|
}
|
|
201
367
|
const before = readFileSync(plan, 'utf8');
|
|
202
|
-
|
|
368
|
+
// The key is read under two names: the package sample is English, and a tree folder created
|
|
369
|
+
// before the layer was translated is Russian. It is written in English.
|
|
370
|
+
const after = before.replace(/^\*\*(?:Task|Задача):\*\*.*$/m, `**Task:** ${TASK_KEY}-${number} · **Branch:** ${branch}`);
|
|
203
371
|
if (after !== before) {
|
|
204
372
|
writeFileSync(plan, after);
|
|
205
|
-
console.log(
|
|
373
|
+
console.log(`The header of the plan is filled in: docs/tasks/${branch}/plan.md`);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* The draft of the epic plan. It is assembled here and not copied from a sample: the sample would
|
|
379
|
+
* have to be laid out at a fixed address, while the directory of plans is each tree's own — and a
|
|
380
|
+
* draft assembled here comes with the number, the title and the branch already filled in, which a
|
|
381
|
+
* copied one would leave to be typed by hand.
|
|
382
|
+
*
|
|
383
|
+
* An existing file is not overwritten: a plan written before the card is a lawful order — the
|
|
384
|
+
* makeup is thought out first, and the card is created under a ready one.
|
|
385
|
+
*/
|
|
386
|
+
function writeEpicPlan() {
|
|
387
|
+
const path = join(ROOT, planPath);
|
|
388
|
+
if (existsSync(path)) {
|
|
389
|
+
console.log(`\nThe plan of the epic is already in place: ${planPath}`);
|
|
390
|
+
return;
|
|
206
391
|
}
|
|
392
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
393
|
+
writeFileSync(
|
|
394
|
+
path,
|
|
395
|
+
[
|
|
396
|
+
`# ${args.title}`,
|
|
397
|
+
'',
|
|
398
|
+
`**Эпик:** ${TASK_KEY}-${number} · **Ветка эпика:** \`${branch}\``,
|
|
399
|
+
'',
|
|
400
|
+
'## Что даёт',
|
|
401
|
+
'',
|
|
402
|
+
'<Возможность, ради которой эпик заведён: что владелец получит и чего не может сегодня.>',
|
|
403
|
+
'',
|
|
404
|
+
'## Как стоят ветки',
|
|
405
|
+
'',
|
|
406
|
+
`Ветка эпика отведена от главной, ветки задач — от неё, заявки задач идут в неё. <Стопкой`,
|
|
407
|
+
'ветки задач стоят или каждая от ветки эпика — решает этот план, а не тот, кто заводит',
|
|
408
|
+
'ветку.>',
|
|
409
|
+
'',
|
|
410
|
+
'## Состав',
|
|
411
|
+
'',
|
|
412
|
+
'| # | Задача | Состояние |',
|
|
413
|
+
'| --- | ---------------------------------------- | --------- |',
|
|
414
|
+
`| 1 | ${TASK_KEY}-<номер> — <что делает> | впереди |`,
|
|
415
|
+
'',
|
|
416
|
+
'## Чего эпик не делает',
|
|
417
|
+
'',
|
|
418
|
+
'- <Что лежит рядом и в эпик не входит.>',
|
|
419
|
+
'',
|
|
420
|
+
].join('\n')
|
|
421
|
+
);
|
|
422
|
+
console.log(`\nThe draft of the epic plan: ${planPath}`);
|
|
207
423
|
}
|
|
208
424
|
|
|
209
|
-
|
|
425
|
+
if (args.epic) {
|
|
426
|
+
writeEpicPlan();
|
|
427
|
+
} else {
|
|
428
|
+
adoptDraft();
|
|
429
|
+
}
|
|
210
430
|
|
|
211
431
|
console.log(`[${TASK_KEY}-${number}] ${args.title}`);
|
|
212
432
|
console.log(`https://github.com/${OWNER}/${REPO}/issues/${number}`);
|
|
213
433
|
|
|
214
434
|
/**
|
|
215
|
-
*
|
|
435
|
+
* The fifth step: creation is confirmed by the answer of the work queue, not by the output of this
|
|
436
|
+
* command.
|
|
216
437
|
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
438
|
+
* All four steps above answer for their own calls and stay silent about whether the task is visible
|
|
439
|
+
* to whoever comes for it. Sixteen creations in a row printed the number with a link that way, and
|
|
440
|
+
* not one of them landed in the queue: the account was limited by the hosting, and the calls gave
|
|
441
|
+
* no refusal at that.
|
|
220
442
|
*/
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
443
|
+
/**
|
|
444
|
+
* This is read more than once. The queue does not hand back a new card the same second it was
|
|
445
|
+
* created, and the reading goes as the next call after the adding: two creations in a row printed
|
|
446
|
+
* that the task is not in the queue while the card was in place. A false refusal here costs more
|
|
447
|
+
* than a delay — it pushes to create the card a second time, and only an administrator can take it
|
|
448
|
+
* off the board.
|
|
449
|
+
*/
|
|
450
|
+
let unreachable = false;
|
|
451
|
+
|
|
452
|
+
function askQueue() {
|
|
453
|
+
try {
|
|
454
|
+
return describeTaskState(number, taskState(number, { token }));
|
|
455
|
+
} catch (error) {
|
|
456
|
+
// There was nothing to ask with — there is nothing to repeat: the answer is not late,
|
|
457
|
+
// there will be none at all.
|
|
458
|
+
unreachable = true;
|
|
459
|
+
const reason = error instanceof OfflineError ? error.message : String(error.message ?? error);
|
|
460
|
+
return describeTaskState(number, { offline: reason });
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/** How long to wait between readings and how many times to re-read: the queue delay is seconds. */
|
|
465
|
+
const QUEUE_RETRIES = 3;
|
|
466
|
+
const QUEUE_PAUSE_MS = 1500;
|
|
467
|
+
|
|
468
|
+
let answer = askQueue();
|
|
469
|
+
for (let attempt = 1; !answer.ok && !unreachable && attempt < QUEUE_RETRIES; attempt += 1) {
|
|
470
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, QUEUE_PAUSE_MS);
|
|
471
|
+
answer = askQueue();
|
|
227
472
|
}
|
|
228
473
|
for (const line of answer.lines) {
|
|
229
474
|
(answer.ok ? console.log : console.error)(`task-new: ${line}`);
|
|
230
475
|
}
|
|
231
476
|
|
|
232
|
-
|
|
233
|
-
|
|
477
|
+
/**
|
|
478
|
+
* The branch of an epic is taken from the main branch, and the branches of its tasks from it: a
|
|
479
|
+
* base named here saves the executor from taking it from the working copy, where any branch may be
|
|
480
|
+
* checked out at that minute.
|
|
481
|
+
*/
|
|
482
|
+
const base = args.epic ? ` origin/${CONFIG.deploy?.mainBranch || 'main'}` : epic?.branch ? ` ${epic.branch}` : '';
|
|
483
|
+
if (epic && !epic.branch) {
|
|
484
|
+
console.error(`task-new: the plan «${epic.plan}» does not name the branch of the epic — the base of the branch is taken by hand, and it is the branch of the epic, not the main one`);
|
|
485
|
+
}
|
|
486
|
+
console.log(`\nThe branch is created by a separate call:\n git checkout -b ${branch}${base}`);
|
|
487
|
+
console.log(`A task taken into work is moved on the board:\n npm run task:move -- ${number} ${IN_PROGRESS_STATUS}`);
|
|
234
488
|
|
|
235
489
|
if (!answer.ok) {
|
|
236
|
-
console.error(`task-new:
|
|
490
|
+
console.error(`task-new: check the whole work queue — npm run check:board`);
|
|
237
491
|
process.exit(1);
|
|
238
492
|
}
|