@rt-tools/agent-kit 0.26.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/assets/agents/cargo-writer.md +54 -0
  2. package/assets/checks/board-epic-link.github.mjs +29 -0
  3. package/assets/checks/board-epic-plan.github.mjs +86 -0
  4. package/assets/checks/board-epics.github.mjs +217 -69
  5. package/assets/checks/board-long-work.github.mjs +5 -1
  6. package/assets/checks/board-pull-state.github.mjs +163 -0
  7. package/assets/checks/board-task-dirs.github.mjs +98 -0
  8. package/assets/checks/board.github.mjs +8 -91
  9. package/assets/checks/check-board.github.mjs +25 -165
  10. package/assets/checks/check-glossary.mjs +10 -2
  11. package/assets/checks/check-lib-layers.mjs +24 -1
  12. package/assets/checks/check-prose-style.mjs +19 -3
  13. package/assets/checks/check-reuse.mjs +26 -2
  14. package/assets/checks/check-schema-drift.mjs +19 -3
  15. package/assets/checks/check-specs.mjs +8 -1
  16. package/assets/checks/epic-table.github.mjs +268 -0
  17. package/assets/checks/lib-boundaries.mjs +2 -2
  18. package/assets/checks/lib-common.mjs +46 -0
  19. package/assets/checks/lib-manifests.mjs +18 -13
  20. package/assets/checks/rt-kit-checks.config.mjs +19 -0
  21. package/assets/checks/signals.mjs +39 -5
  22. package/assets/checks/spec-anchors.mjs +48 -4
  23. package/assets/checks/spec-common.mjs +40 -6
  24. package/assets/checks/spec-contract.mjs +33 -7
  25. package/assets/checks/spec-scenarios.mjs +24 -1
  26. package/assets/checks/specs-for.mjs +214 -0
  27. package/assets/checks/task-new.github.mjs +237 -6
  28. package/assets/commands/night.md +115 -0
  29. package/assets/defaults/gate-map.sh +20 -5
  30. package/assets/defaults/project.sh +13 -0
  31. package/assets/defaults/turn-map.md +3 -1
  32. package/assets/docs/GLOSSARY.md +22 -22
  33. package/assets/hooks/browser-device-id.sh +4 -0
  34. package/assets/hooks/browser-guard-device-id.sh +4 -0
  35. package/assets/hooks/commit-msg.sh +3 -0
  36. package/assets/hooks/dev-server-guard.sh +64 -31
  37. package/assets/hooks/epic-over.sh +49 -0
  38. package/assets/hooks/epic-stop-guard.sh +108 -0
  39. package/assets/hooks/exam-guard.sh +10 -10
  40. package/assets/hooks/git-guard-delivery-conflict.sh +56 -1
  41. package/assets/hooks/git-guard-delivery-draft.sh +10 -6
  42. package/assets/hooks/git-guard-delivery-epic.sh +167 -0
  43. package/assets/hooks/git-guard-delivery-signature.sh +32 -2
  44. package/assets/hooks/git-guard-delivery-tree.sh +50 -0
  45. package/assets/hooks/git-guard-delivery.sh +71 -27
  46. package/assets/hooks/git-guard-discard.sh +144 -0
  47. package/assets/hooks/git-guard-push-tests.sh +36 -16
  48. package/assets/hooks/handoff-entry-guard.sh +20 -2
  49. package/assets/hooks/prose-style-guard.sh +31 -8
  50. package/assets/hooks/qa-dataid-guard.sh +33 -11
  51. package/assets/hooks/reuse-first-guard.sh +29 -4
  52. package/assets/hooks/rule-article.sh +3 -0
  53. package/assets/hooks/rule-source-guard.sh +17 -2
  54. package/assets/hooks/skill-gate-layers.sh +4 -0
  55. package/assets/hooks/skill-gate.sh +7 -0
  56. package/assets/hooks/skill-loaded.sh +4 -0
  57. package/assets/hooks/sql-guard-parse.sh +3 -0
  58. package/assets/hooks/sql-guard-request.sh +3 -0
  59. package/assets/hooks/sql-guard-target.sh +3 -0
  60. package/assets/hooks/sql-guard-write.sh +21 -2
  61. package/assets/hooks/stand-login-guard.sh +3 -0
  62. package/assets/hooks/turn-exit-guard.sh +55 -67
  63. package/assets/hooks/turn-exit-patterns.sh +28 -1
  64. package/assets/hooks/turn-exit-verdict.sh +84 -0
  65. package/assets/hooks/utf8.sh +3 -0
  66. package/assets/hooks/waiting-turn-guard.sh +11 -1
  67. package/assets/hooks/write-targets.sh +3 -0
  68. package/assets/laws/delivery.md +37 -7
  69. package/assets/laws/verifiability.md +22 -4
  70. package/assets/patterns/git-workflow-commit.azure.md +1 -1
  71. package/assets/patterns/git-workflow-commit.github.md +9 -2
  72. package/assets/patterns/git-workflow-commit.gitlab.md +1 -1
  73. package/assets/patterns/git-workflow-merge.md +8 -5
  74. package/assets/patterns/git-workflow-pr.azure.md +1 -1
  75. package/assets/patterns/git-workflow-pr.github.md +44 -18
  76. package/assets/patterns/git-workflow-pr.gitlab.md +1 -1
  77. package/assets/patterns/git-workflow-stack.md +32 -9
  78. package/assets/patterns/status-report-table.github.md +11 -0
  79. package/assets/patterns/task-flow-close.md +96 -90
  80. package/assets/patterns/task-flow-start.md +40 -26
  81. package/assets/patterns/ts-procedure.md +6 -0
  82. package/assets/pitfalls/agent-kit.md +19 -0
  83. package/assets/pitfalls/git-workflow.github.md +44 -0
  84. package/assets/pitfalls/task-flow.md +25 -23
  85. package/assets/rules/autonomous-work.md +15 -3
  86. package/assets/rules/browser-verification.md +8 -0
  87. package/assets/rules/deploy-flow.github.md +6 -0
  88. package/assets/rules/doc-style.md +13 -4
  89. package/assets/rules/git-workflow.azure.md +10 -0
  90. package/assets/rules/git-workflow.github.md +144 -126
  91. package/assets/rules/git-workflow.gitlab.md +10 -0
  92. package/assets/rules/lib-layers.md +11 -0
  93. package/assets/rules/spec-driven.md +17 -1
  94. package/assets/rules/status-report.md +7 -0
  95. package/assets/rules/task-flow.md +78 -54
  96. package/assets/rules/testing.md +7 -0
  97. package/assets/rules/turn-conduct.md +30 -3
  98. package/assets/samples/tasks/_template/plan.md +4 -1
  99. package/assets/skills/agent-kit.md +40 -25
  100. package/bin/agent-kit.d.ts.map +1 -1
  101. package/bin/agent-kit.js +9 -2
  102. package/bin/agent-kit.js.map +1 -1
  103. package/lib/cargo-prose.d.ts +41 -0
  104. package/lib/cargo-prose.d.ts.map +1 -0
  105. package/lib/cargo-prose.js +88 -0
  106. package/lib/cargo-prose.js.map +1 -0
  107. package/lib/cargo.d.ts +12 -1
  108. package/lib/cargo.d.ts.map +1 -1
  109. package/lib/cargo.js +8 -2
  110. package/lib/cargo.js.map +1 -1
  111. package/lib/commands.d.ts +1 -1
  112. package/lib/commands.d.ts.map +1 -1
  113. package/lib/commands.js +59 -2
  114. package/lib/commands.js.map +1 -1
  115. package/lib/fate.d.ts +29 -0
  116. package/lib/fate.d.ts.map +1 -0
  117. package/lib/fate.js +147 -0
  118. package/lib/fate.js.map +1 -0
  119. package/lib/hooks-map.d.ts +5 -0
  120. package/lib/hooks-map.d.ts.map +1 -1
  121. package/lib/hooks-map.js +9 -3
  122. package/lib/hooks-map.js.map +1 -1
  123. package/lib/override-marks.d.ts +7 -0
  124. package/lib/override-marks.d.ts.map +1 -1
  125. package/lib/override-marks.js +14 -0
  126. package/lib/override-marks.js.map +1 -1
  127. package/lib/plan.d.ts +2 -0
  128. package/lib/plan.d.ts.map +1 -1
  129. package/lib/plan.js +8 -0
  130. package/lib/plan.js.map +1 -1
  131. package/lib/proposals.d.ts +25 -0
  132. package/lib/proposals.d.ts.map +1 -1
  133. package/lib/proposals.js +43 -1
  134. package/lib/proposals.js.map +1 -1
  135. package/lib/ship.d.ts +29 -2
  136. package/lib/ship.d.ts.map +1 -1
  137. package/lib/ship.js +34 -0
  138. package/lib/ship.js.map +1 -1
  139. package/lib/shipment.d.ts.map +1 -1
  140. package/lib/shipment.fixture.d.ts +8 -1
  141. package/lib/shipment.fixture.d.ts.map +1 -1
  142. package/lib/shipment.fixture.js +9 -0
  143. package/lib/shipment.fixture.js.map +1 -1
  144. package/lib/shipment.js +40 -14
  145. package/lib/shipment.js.map +1 -1
  146. package/package.json +1 -1
  147. package/rt-tools-agent-kit-0.28.0.tgz +0 -0
  148. package/rt-tools-agent-kit-0.26.0.tgz +0 -0
@@ -13,14 +13,32 @@
13
13
  *
14
14
  * npm run task:new -- --title 'Letters to the owner are not sent' --label bug --label area:api
15
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
20
  * The body is read from standard input. The author and the assignee are the bot account, the same
18
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
 
41
+ import { planPathOf } from './board-epic-plan.mjs';
24
42
  import {
25
43
  BACKLOG_OPTION_ID,
26
44
  BOT,
@@ -40,9 +58,18 @@ import {
40
58
  taskState,
41
59
  unstampFolder,
42
60
  } from './board.mjs';
61
+ import { CONFIG, ROOT } from './rt-kit-checks.config.mjs';
62
+
63
+ /**
64
+ * What an epic is created by: the label of its card and the directory its plan is put in. Both are
65
+ * each tree's own words, and neither has a default — a plan laid at a guessed address is found by
66
+ * nobody, and a card without the label is an ordinary task to the audit.
67
+ */
68
+ const EPIC_LABEL = CONFIG.board?.epicLabel ?? '';
69
+ const PLANS_DIR = CONFIG.plansDir ?? '';
43
70
 
44
71
  function parseArgs(argv) {
45
- const args = { labels: [], assignee: BOT, title: null, slug: null };
72
+ const args = { labels: [], assignee: BOT, title: null, slug: null, epic: false, epicOf: null, outsideEpic: null };
46
73
  for (let index = 0; index < argv.length; index += 1) {
47
74
  const value = argv[index + 1];
48
75
  switch (argv[index]) {
@@ -62,6 +89,17 @@ function parseArgs(argv) {
62
89
  args.slug = value;
63
90
  index += 1;
64
91
  break;
92
+ case '--epic':
93
+ args.epic = true;
94
+ break;
95
+ case '--epic-of':
96
+ args.epicOf = Number(value);
97
+ index += 1;
98
+ break;
99
+ case '--outside-epic':
100
+ args.outsideEpic = value ?? '';
101
+ index += 1;
102
+ break;
65
103
  default:
66
104
  fail(`unknown flag ${argv[index]}`);
67
105
  }
@@ -96,6 +134,58 @@ if (args.slug !== null && !/^[a-z0-9][a-z0-9-]*$/.test(args.slug)) {
96
134
  fail('slug is lowercase latin letters, digits and dashes: the branch name is read in a list of fifty lines');
97
135
  }
98
136
 
137
+ /**
138
+ * A task outside an epic is not created — that is the whole of the requirement, and the refusal
139
+ * carries both lawful ways out of it, because in the shape «name the epic» alone it is read as
140
+ * "there is no way out" and gets bypassed by a call to the hosting past this command.
141
+ *
142
+ * The owner's word is the second way, and it goes into the call as text: work outside an epic
143
+ * happens — a one-line fix, a report from the outside — and only the owner names it as such. An
144
+ * empty reason is not a reason: it is indistinguishable from a flag typed to get past a refusal.
145
+ *
146
+ * A tree that has not named the epic label lives as before: there epics do not exist at all, and
147
+ * demanding one of every task would stop the work of every such tree on the day of installation.
148
+ */
149
+ if (EPIC_LABEL && !args.epic && args.epicOf === null && args.outsideEpic === null) {
150
+ fail(
151
+ '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>"`'
152
+ );
153
+ }
154
+ if (args.outsideEpic !== null && args.outsideEpic.trim() === '') {
155
+ fail('--outside-epic "<the reason of the owner>": an empty reason is indistinguishable from a flag typed to get past the refusal');
156
+ }
157
+ if (args.outsideEpic !== null && (args.epic || args.epicOf !== null)) {
158
+ 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');
159
+ }
160
+
161
+ if (args.epic && args.epicOf !== null) {
162
+ 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');
163
+ }
164
+ if (args.epicOf !== null && !Number.isInteger(args.epicOf)) {
165
+ fail('--epic-of <number>: the number of the epic card, as it stands in the work queue');
166
+ }
167
+
168
+ /**
169
+ * Everything an epic cannot be created without is asked before the creation, not after it: a card
170
+ * already made cannot be taken off the board by anyone but an administrator, and a refusal after
171
+ * the call leaves an epic without a plan and without a label — that is, invisible to the audit as
172
+ * an epic at all.
173
+ */
174
+ if (args.epic) {
175
+ if (!EPIC_LABEL) {
176
+ 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');
177
+ }
178
+ if (!PLANS_DIR) {
179
+ 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');
180
+ }
181
+ if (!args.slug) {
182
+ fail('--slug <short-slug> is required for an epic: the plan file and the branch of the epic are named by it');
183
+ }
184
+ }
185
+
186
+ /** The label goes with the card, and the audit finds the epic by it — no second way. */
187
+ const labels = args.epic && !args.labels.includes(EPIC_LABEL) ? [...args.labels, EPIC_LABEL] : args.labels;
188
+
99
189
  /**
100
190
  * The token of the machine account is optional: a tree that has not named it creates the task
101
191
  * under the account the hosting client is logged in as. Demanding the token would hold task
@@ -105,6 +195,74 @@ if (args.slug !== null && !/^[a-z0-9][a-z0-9-]*$/.test(args.slug)) {
105
195
  */
106
196
  const token = botToken() ?? undefined;
107
197
 
198
+ /**
199
+ * The plan of the epic and the line about it in the card body.
200
+ *
201
+ * The audit takes the path to the plan from the body: the card has to name it anyway, and a
202
+ * setting read instead would become a second truth about where the plan of this very epic lies. So
203
+ * the path is written into the body by the same call that creates the file.
204
+ */
205
+ const planPath = args.epic ? `${PLANS_DIR.replace(/\/+$/, '')}/${args.slug}.md` : null;
206
+
207
+ /**
208
+ * The epic the task is created under, read from its card.
209
+ *
210
+ * The link is declared by the task body, and the audit reads exactly one shape of it: the word
211
+ * about the task standing right before the word about the epic. Written by hand, the line comes
212
+ * out in a shape of its own once out of three, and the audit then says the task belongs to no epic
213
+ * while the executor sees the epic named in the body.
214
+ *
215
+ * The path to the plan is taken from the epic card, as the audit takes it — a second address here
216
+ * would diverge from the first one silently. The branch of the epic is read from the plan: the
217
+ * plan names it, and the queue does not know branch names at all.
218
+ */
219
+ function epicOfCard(epicNumber) {
220
+ const card = ghJson(['issue', 'view', String(epicNumber), '--json', 'number,title,labels,body'], { token });
221
+ const labelled = (card.labels ?? []).some((label) => label.name === EPIC_LABEL);
222
+ if (!labelled) {
223
+ 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`);
224
+ }
225
+ // Which of the paths in the body is the plan is decided by the shared reading, the same one the
226
+ // queue audit calls. Read here by its own way — the first path in the body — the command wrote a
227
+ // law into every task of the epic as its plan, and the branch of the epic was then read from
228
+ // that law and came back empty. Both sides answered as usual, and the miss showed only by
229
+ // reading a created task.
230
+ const found = planPathOf(card.body, { makeupRequired: false });
231
+ const plan = found.path;
232
+ if (plan === null) {
233
+ fail(`the card of the epic #${epicNumber}: ${found.why}. The branch of the epic is named in the plan too`);
234
+ }
235
+ return { plan, branch: epicBranchOf(plan, epicNumber) };
236
+ }
237
+
238
+ /**
239
+ * The branch of the epic, read from the header of its plan.
240
+ *
241
+ * Three spellings are accepted: the one this command writes, the bare word about a branch and the
242
+ * English one — the plans of a tree are translated one at a time, and a single spelling would take
243
+ * every plan but the freshest out of the reading in silence.
244
+ */
245
+ function epicBranchOf(plan, epicNumber) {
246
+ const path = join(ROOT, plan);
247
+ if (!existsSync(path)) {
248
+ return null;
249
+ }
250
+ const named = readFileSync(path, 'utf8').match(
251
+ new RegExp(`\\*\\*(?:Ветка эпика|Ветка|Branch):\\*\\*\\s*\`?(${TASK_KEY}-${epicNumber}-[a-z0-9][a-z0-9-]*)\`?`)
252
+ );
253
+ return named ? named[1] : null;
254
+ }
255
+
256
+ const epic = args.epicOf === null ? null : epicOfCard(args.epicOf);
257
+ const body = [
258
+ readBody(),
259
+ args.epic ? `Замысел эпика — ${planPath}` : '',
260
+ epic ? `Задача эпика #${args.epicOf}, замысел — ${epic.plan}` : '',
261
+ args.outsideEpic ? `Работа вне эпика — ${args.outsideEpic}` : '',
262
+ ]
263
+ .filter((part) => part !== '')
264
+ .join('\n\n');
265
+
108
266
  let number = null;
109
267
  try {
110
268
  const created = gh(
@@ -116,10 +274,10 @@ try {
116
274
  '--title',
117
275
  args.title,
118
276
  '--body',
119
- readBody(),
277
+ body,
120
278
  '--assignee',
121
279
  args.assignee,
122
- ...args.labels.flatMap((label) => ['--label', label]),
280
+ ...labels.flatMap((label) => ['--label', label]),
123
281
  ],
124
282
  { token }
125
283
  ).trim();
@@ -142,6 +300,18 @@ try {
142
300
  `mutation { updateProjectV2ItemFieldValue(input: {projectId: "${PROJECT_ID}", itemId: "${itemId}", fieldId: "${STATUS_FIELD_ID}", value: {singleSelectOptionId: "${BACKLOG_OPTION_ID}"}}) { projectV2Item { id } } }`,
143
301
  { token }
144
302
  );
303
+
304
+ // The task of an epic becomes a sub-issue of the epic card. The line in the body says the same
305
+ // thing, but only to whoever opens the task: the board shows neither the makeup of an epic nor
306
+ // how much of it is done, and the count has to be assembled by hand from the list of open
307
+ // tasks. A sub-issue is the hosting's own link — the epic card gets the list and the progress,
308
+ // the task gets the line about its parent, and the board card gets the "done of total" bar.
309
+ //
310
+ // The link is asked by the numeric id of the task, not by its number: the endpoint takes the id.
311
+ if (args.epicOf !== null) {
312
+ const subId = ghJson(['api', `repos/${OWNER}/${REPO}/issues/${number}`, '--jq', '{id:.id}'], { token }).id;
313
+ gh(['api', '-X', 'POST', `repos/${OWNER}/${REPO}/issues/${args.epicOf}/sub_issues`, '-F', `sub_issue_id=${subId}`], { token });
314
+ }
145
315
  } catch (error) {
146
316
  const reason = error instanceof OfflineError ? `no connection to GitHub: ${error.message}` : String(error.message ?? error);
147
317
  if (number === null) {
@@ -210,7 +380,59 @@ function adoptDraft() {
210
380
  }
211
381
  }
212
382
 
213
- adoptDraft();
383
+ /**
384
+ * The draft of the epic plan. It is assembled here and not copied from a sample: the sample would
385
+ * have to be laid out at a fixed address, while the directory of plans is each tree's own — and a
386
+ * draft assembled here comes with the number, the title and the branch already filled in, which a
387
+ * copied one would leave to be typed by hand.
388
+ *
389
+ * An existing file is not overwritten: a plan written before the card is a lawful order — the
390
+ * makeup is thought out first, and the card is created under a ready one.
391
+ */
392
+ function writeEpicPlan() {
393
+ const path = join(ROOT, planPath);
394
+ if (existsSync(path)) {
395
+ console.log(`\nThe plan of the epic is already in place: ${planPath}`);
396
+ return;
397
+ }
398
+ mkdirSync(dirname(path), { recursive: true });
399
+ writeFileSync(
400
+ path,
401
+ [
402
+ `# ${args.title}`,
403
+ '',
404
+ `**Эпик:** ${TASK_KEY}-${number} · **Ветка эпика:** \`${branch}\``,
405
+ '',
406
+ '## Что даёт',
407
+ '',
408
+ '<Возможность, ради которой эпик заведён: что владелец получит и чего не может сегодня.>',
409
+ '',
410
+ '## Как стоят ветки',
411
+ '',
412
+ `Ветка эпика отведена от главной, ветки задач — от неё, заявки задач идут в неё. <Стопкой`,
413
+ 'ветки задач стоят или каждая от ветки эпика — решает этот план, а не тот, кто заводит',
414
+ 'ветку.>',
415
+ '',
416
+ '## Состав',
417
+ '',
418
+ '| # | Задача | Состояние |',
419
+ '| --- | ---------------------------------------- | --------- |',
420
+ `| 1 | ${TASK_KEY}-<номер> — <что делает> | впереди |`,
421
+ '',
422
+ '## Чего эпик не делает',
423
+ '',
424
+ '- <Что лежит рядом и в эпик не входит.>',
425
+ '',
426
+ ].join('\n')
427
+ );
428
+ console.log(`\nThe draft of the epic plan: ${planPath}`);
429
+ }
430
+
431
+ if (args.epic) {
432
+ writeEpicPlan();
433
+ } else {
434
+ adoptDraft();
435
+ }
214
436
 
215
437
  console.log(`[${TASK_KEY}-${number}] ${args.title}`);
216
438
  console.log(`https://github.com/${OWNER}/${REPO}/issues/${number}`);
@@ -258,7 +480,16 @@ for (const line of answer.lines) {
258
480
  (answer.ok ? console.log : console.error)(`task-new: ${line}`);
259
481
  }
260
482
 
261
- console.log(`\nThe branch is created by a separate call:\n git checkout -b ${branch}`);
483
+ /**
484
+ * The branch of an epic is taken from the main branch, and the branches of its tasks from it: a
485
+ * base named here saves the executor from taking it from the working copy, where any branch may be
486
+ * checked out at that minute.
487
+ */
488
+ const base = args.epic ? ` origin/${CONFIG.deploy?.mainBranch || 'main'}` : epic?.branch ? ` ${epic.branch}` : '';
489
+ if (epic && !epic.branch) {
490
+ 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`);
491
+ }
492
+ console.log(`\nThe branch is created by a separate call:\n git checkout -b ${branch}${base}`);
262
493
  console.log(`A task taken into work is moved on the board:\n npm run task:move -- ${number} ${IN_PROGRESS_STATUS}`);
263
494
 
264
495
  if (!answer.ok) {
@@ -0,0 +1,115 @@
1
+ ---
2
+ description: The start of an autonomous session — the time boundary, the checks before the first work, the cycle until morning and the list the owner reads
3
+ argument-hint: '[until when: «до 8 утра» | «часов шесть» | empty — the boundary is asked]'
4
+ ---
5
+
6
+ Start an autonomous session: the owner is leaving, and the work goes on without them until the
7
+ boundary they named. The boundary from the owner: `$ARGUMENTS`
8
+
9
+ The order of the night itself is not written here. It lies in the rule `autonomous-work` and the
10
+ pattern `autonomous-work-run`, and rewriting it into the command would start a second source that
11
+ diverges from the first silently. The command does four things: it takes the boundary, raises the
12
+ rule, checks the tree before the first work and names where the morning list is written.
13
+
14
+ ## 1. The boundary of time
15
+
16
+ The law says an autonomous session ends by the owner's word or at a named boundary. A session
17
+ without a boundary is work without an end — that is, work the owner did not ask for.
18
+
19
+ The boundary stands in the arguments — take it as it is written. There is none — ask the owner:
20
+ they are still here at the minute of the call, and by morning there will be nobody to ask. The
21
+ question is one, and the work does not start before the answer.
22
+
23
+ Write the boundary down at once: the session will be long, and the first message goes out of the
24
+ window before the night ends.
25
+
26
+ ```bash
27
+ printf 'граница ночи: %s\n' "$ARGUMENTS"
28
+ ```
29
+
30
+ ## 2. Raise the rule and the pattern
31
+
32
+ ```
33
+ Skill: autonomous-work
34
+ Skill: autonomous-work-run
35
+ ```
36
+
37
+ The companion of the rule is read as a file next to it: the rule says what must be true, the
38
+ companion — what it is called in this tree and what here is held by nothing at all.
39
+
40
+ ## 3. Read the tree profile
41
+
42
+ The main branch name, the task folders directory and the handover directory differ from tree to
43
+ tree:
44
+
45
+ ```bash
46
+ for profile in .claude/rt-kit/defaults/project.sh .claude/rt-kit/project.sh; do
47
+ [ -f "$profile" ] && . "$profile"
48
+ done
49
+ printf 'главная: %s · задачи: %s · передача: %s\n' \
50
+ "${RT_MAIN_BRANCH:-main}" "${RT_TASKS_DIR:-docs/tasks}" "${RT_HANDOFF_DIR:-.claude/handoff}"
51
+ ```
52
+
53
+ ## 4. Checks before the first work
54
+
55
+ All four are made before the first task is taken. Each of them by morning costs a whole night: a
56
+ session that runs into them at three o'clock has nobody to ask.
57
+
58
+ ```bash
59
+ git status --short # uncommitted work
60
+ git fetch origin # the tip of the main branch
61
+ git log --oneline -1 origin/main
62
+ ```
63
+
64
+ - **The tree holds uncommitted changes.** Name them to the owner and ask what to do with them:
65
+ they are still here. Work that goes on top of somebody else's edit carries it into a foreign
66
+ branch.
67
+ - **Another session is working in this tree.** Ask the list of sessions: two nights in one working
68
+ copy switch branches under each other.
69
+ - **The tip of the main branch has moved.** The first branch of the night is created from a fresh
70
+ base, not from the local ref: the local one is yesterday's snapshot and is silent about it.
71
+ - **The source of the work is named.** An epic plan if there is one, the work queue otherwise. A
72
+ night that takes tasks by their look at the list takes somebody else's first.
73
+
74
+ ## 5. Name what will not be done
75
+
76
+ Say it to the owner before they leave, in one line: nothing goes outside during the night — no
77
+ push, no request, no publishing, no cargo mark. Everything visible from outside is undone by a
78
+ person, and there is none until morning.
79
+
80
+ There they also hear which tasks the night will not take: the ones that need their word. Read
81
+ from the source of the work, not guessed on the spot.
82
+
83
+ ## 6. The morning list is a file
84
+
85
+ The law demands a trace on disk at every step: a session breaks off without warning — on the
86
+ window, on a refusal, on the network — and what was not written vanishes with it. The last reply
87
+ does not survive such a break.
88
+
89
+ The list lies next to the handover of the session, is created by this command and is appended to
90
+ after each closed piece of work — not assembled at the end:
91
+
92
+ ```bash
93
+ printf '# Список к утру · ночь с %s\n\n' "$(date +%d.%m.%Y)" \
94
+ > "${RT_HANDOFF_DIR:-.claude/handoff}/$(date +%Y-%m-%d)-ночь.md"
95
+ ```
96
+
97
+ A row per closed piece of work, and the row order is the merge order. The shape of the row and
98
+ the line of a postponed task are in the pattern `autonomous-work-run`.
99
+
100
+ ## 7. The cycle
101
+
102
+ Then the work goes by the rule and the pattern: a task from the source of the work, the branch
103
+ from the previous one, the task folder, the plan, the stages, the folder taken apart into the
104
+ description of the past. A default is written where the owner's answer would have been written. A
105
+ guard's refusal is a step of the work, not the end of the night.
106
+
107
+ The night ends at the named boundary, and the last reply gives the list — the same one that lies
108
+ in the file.
109
+
110
+ ## What this command does not do
111
+
112
+ - It does not merge and does not open requests: they are visible from outside.
113
+ - It does not decide what to work on: the source of the work is the epic plan or the queue.
114
+ - It does not tell night from day. There is no such sign in the tree, and the command adds none:
115
+ it is called by the owner's word and by nothing else.
@@ -90,7 +90,11 @@ skill_for_default() {
90
90
  # the signs it judges by are declared in the rule's binding. Editing a sign in a
91
91
  # check, one opens the second place next to it — otherwise they drift apart
92
92
  # silently, and the check counts as a refusal what the rule allows.
93
- */check-specs.mjs) printf '%s\n' 'spec-driven' ;;
93
+ # The parsing of the spec audit lies not in the file with the `check-` prefix but
94
+ # in the helpers next to it: anchors, contract, scenarios, the shared part. They
95
+ # carry out the articles of the rule, and by name alone they matched no branch.
96
+ */check-specs.mjs | */spec-anchors.mjs | */spec-common.mjs | */spec-contract.mjs | */spec-scenarios.mjs | */specs-for.mjs)
97
+ printf '%s\n' 'spec-driven' ;;
94
98
  */check-doc-paths.mjs | */doc-paths-allowlist.json | */check-file-size.mjs)
95
99
  printf '%s\n' 'doc-style' ;;
96
100
  */check-styles.mjs | */styles-allowlist.json | */stylelint-rules/*)
@@ -110,13 +114,24 @@ skill_for_default() {
110
114
  # rule at hand. The rule lives with the delivery.
111
115
  */schema.prisma | */prisma/migrations/* | */prisma.config.ts)
112
116
  printf '%s\n' 'git-workflow' ;;
113
- # The pipeline and the image: the checks decide what runs before the merge at all,
114
- # and the image decides what arrives on production. Both were edited without a
115
- # single delivery rule.
117
+ # The pipeline carries two subjects at once: which checks run before the merge —
118
+ # that is the hand-over rule — and what reaches production after it, which is the
119
+ # rollout rule. Both names are printed, the rollout one first: the set before a push
120
+ # is written by the executor every day, while the rollout steps are read once and
121
+ # are the ones edited blindly.
116
122
  */.github/workflows/*.yml | */.gitlab-ci.yml | */azure-pipelines*.yml)
123
+ printf '%s\n' 'deploy-flow'
117
124
  printf '%s\n' 'git-workflow' ;;
125
+
126
+ # The image, the proxy config and the sample of the production environment are the
127
+ # rollout's own subject, and the branch used to hand them to the rule about tasks
128
+ # and branches: it says nothing about the server, the ports or the variables the
129
+ # image is raised with. What is written into these files is seen by nobody until the
130
+ # rollout, and by then it is production that answers.
118
131
  */Dockerfile | */*.Dockerfile | */docker-compose*.yml | */docker-compose*.yaml)
119
- printf '%s\n' 'git-workflow' ;;
132
+ printf '%s\n' 'deploy-flow' ;;
133
+ */Caddyfile | */nginx.conf | */*.nginx.conf | */nginx/*.conf | */.env.*.example)
134
+ printf '%s\n' 'deploy-flow' ;;
120
135
 
121
136
  # An end-to-end spec checks a running application, not a class: by file name it is
122
137
  # no different from an ordinary module, and without this branch it would go to the
@@ -28,6 +28,12 @@ rt_runner() {
28
28
  # than naming none.
29
29
  RT_STANDS="${RT_STANDS:-}"
30
30
 
31
+ # Who raises those stands. `owner` — the tree's own applications are up and any raise is refused;
32
+ # `session` — nobody raises them here but the session, and only a raise over a taken port is
33
+ # refused. The default is silent, and the guard reads silence as `owner`: a tree that sets nothing
34
+ # keeps the behaviour it has today.
35
+ RT_STANDS_RAISED_BY="${RT_STANDS_RAISED_BY:-}"
36
+
31
37
  # Where the tree's checks and the scenario set of its guards lie. A check the tree does not have is
32
38
  # not called by the push gate: the list is printed from what lies on disk.
33
39
  RT_CHECKS_DIR="${RT_CHECKS_DIR:-tools}"
@@ -347,6 +353,13 @@ RT_PULL_BODY_SECTION="${RT_PULL_BODY_SECTION:-}"
347
353
  RT_TASK_MOVE_CMD="${RT_TASK_MOVE_CMD:-npm run task:move}"
348
354
  RT_BOARD_BACKLOG="${RT_BOARD_BACKLOG:-}"
349
355
 
356
+ # The label of an epic card: by it the guard tells the branch of an epic from the branch of a task,
357
+ # and the branch of an epic is judged by other conditions — its request goes into the main branch,
358
+ # and it opens only when the folders of all its tasks are taken apart. The word is each tree's own,
359
+ # and the default is empty: a tree that has not named it keeps no epics, and the conditions about
360
+ # them are not judged at all.
361
+ RT_BOARD_EPIC_LABEL="${RT_BOARD_EPIC_LABEL:-}"
362
+
350
363
  # The email the machine account's commit is signed with. As a whole value, not a pattern: the
351
364
  # hosting's service address consists of a number, a login and a domain, and is matched by the number
352
365
  # — nobody checks the login next to it. A "number, plus, login" pattern would pass with someone
@@ -10,8 +10,9 @@ mandatory action is done, the work stays in the same state.
10
10
  ## States and mandatory actions
11
11
 
12
12
  - `просьба-не-разобрана` — explore the tree, then ask; leads `task-flow-start`
13
+ - `эпик-заведён` — take the epic branch from the main branch; leads `task-flow-start`
13
14
  - `разбор-закрыт` — the product agreement or the reason there is none; leads `task-flow-start`
14
- - `договорённость-записана` — create the task, the branch and the folder; leads `task-flow-start`
15
+ - `договорённость-записана` — create the task, the branch from the epic branch, and the folder; leads `task-flow-start`
15
16
  - `задача-взята` — write the plan; leads `task-flow-start`
16
17
  - `замысел-записан` — do the first stage; leads `task-flow-start`
17
18
  - `этап-идёт` — finish the stage and mark it in the progress; leads `task-flow-resume`
@@ -20,6 +21,7 @@ mandatory action is done, the work stays in the same state.
20
21
  - `разбор-кончился` — merge the agreement, bring the texts up to date, take the folder apart; leads `task-flow-close`
21
22
  - `папка-разобрана` — leave draft and ask for the merge; leads `task-flow-archive`
22
23
  - `влито` — the rules review of the work and the queue audit; leads `task-flow-archive`
24
+ - `задачи-эпика-кончились` — open the PR of the epic into the main branch; leads `task-flow-close`
23
25
 
24
26
  No state has a mandatory action that sounds like "wait". The run, the owner's review and the
25
27
  merge go on without the executor and do not get faster from being watched.
@@ -70,56 +70,56 @@ one, so that the same notion does not arrive under three names.
70
70
  | ----------------- | ------------------------- |
71
71
  | application laws | законы приложения |
72
72
  | archive | архив |
73
- | audit | сверка |
73
+ | audit | аудит |
74
74
  | binding | привязка |
75
75
  | check | проверка |
76
- | companion | компаньон |
76
+ | companion | файл привязок |
77
77
  | digest | сводка |
78
78
  | disabled role | выключенная роль |
79
79
  | domain | домен |
80
80
  | draft | черновик |
81
81
  | epic | эпик |
82
82
  | executor | исполнитель |
83
- | fail-open | отказ в пользу работы |
84
- | gate | гейт |
85
- | grill | разбор |
86
- | guard | гард |
83
+ | fail-open | пропуск при ошибке |
84
+ | gate | проверка перед push |
85
+ | grill | уточнение задачи |
86
+ | guard | блокирующая проверка |
87
87
  | handover | передача |
88
88
  | hook | хук |
89
- | laid-out file | разложенный файл |
89
+ | laid-out file | файл, установленный из пакета |
90
90
  | law | закон |
91
- | layout | раскладка |
92
- | measurement | замер |
91
+ | layout | установка файлов из пакета |
92
+ | measurement | измерение |
93
93
  | merge | слияние |
94
94
  | observation | наблюдение |
95
- | override | надстройка |
95
+ | override | переопределение |
96
96
  | owner | владелец |
97
97
  | pattern | паттерн |
98
98
  | pipeline, step | конвейер, шаг |
99
- | plan | замысел |
100
- | PR | PR, заявка |
101
- | product agreement | договорённость о продукте |
99
+ | plan | план |
100
+ | PR | PR |
101
+ | product agreement | описание фичи |
102
102
  | progress | ход работы |
103
103
  | proposal | предложение |
104
- | remark | слово |
104
+ | remark | замечание |
105
105
  | resource | ресурс |
106
106
  | role | роль |
107
107
  | rollout | выкатка |
108
108
  | rule | правило |
109
109
  | rules layer | слой правил |
110
- | run | прогон |
110
+ | run | запуск тестов |
111
111
  | scenario | сценарий |
112
- | session | заход |
113
- | sidecar | спутник |
114
- | skill | скил |
115
- | spec | спек |
112
+ | session | сессия |
113
+ | sidecar | соседний файл |
114
+ | skill | навык |
115
+ | spec | описание |
116
116
  | stand | стенд |
117
117
  | task | задача |
118
118
  | task folder | папка задачи |
119
- | task footprint | след задачи |
119
+ | task footprint | что задача затрагивает |
120
120
  | tree | дерево |
121
- | window fill | заполнение окна |
122
- | work queue | очередь работ |
121
+ | window fill | заполнение окна контекста |
122
+ | work queue | список задач |
123
123
  | work state | состояние работы |
124
124
 
125
125
  ## Not written here
@@ -2,6 +2,10 @@
2
2
  # Local value: .claude/rt-kit/browser-device-id — without it the browser guards let any profile through
3
3
  # Shared helper: prints the id of the pinned browser profile.
4
4
  #
5
+ # NOT a guard: it has no `rt-hook:` declaration and hooks into no agent event. The browser guards
6
+ # source it: the pinned device is one for all of them, and read three ways it would diverge three
7
+ # ways.
8
+ #
5
9
  # The id is local to the machine and does not go into the package at all. It is taken from an
6
10
  # environment variable, and if that is missing — from a file next to the layout config. Nothing in
7
11
  # either place — all browser guards pass: a guard that cannot name the wanted profile offers nothing
@@ -20,6 +20,10 @@
20
20
  # On an error the guard passes: the helper did not name a profile — the call is allowed. An answer
21
21
  # without signs of a connection puts down no mark; work does not stop — the next call will be
22
22
  # forbidden by the freshness guard, which will demand choosing the profile again.
23
+ #
24
+ # FAIL-OPEN: no pinned device declared, no answer from the tool, an unrecognised call — the call
25
+ # goes through. A guard that jams the browser when the pin is missing is switched off on the first
26
+ # day, and with it goes the pin itself.
23
27
 
24
28
  # The guard's name for the observations: it is written by the shared deny tail.
25
29
  RT_GUARD_NAME=browser-guard-device-id
@@ -1,6 +1,9 @@
1
1
  #!/usr/bin/env bash
2
2
  # Commit message check. A hook of git itself, not of the agent.
3
3
  #
4
+ # NOT a guard: it has no `rt-hook:` declaration and hooks into no agent event. The version control
5
+ # calls it as its own hook, not the agent: it judges the message of a commit already written.
6
+ #
4
7
  # A versioned template: the git hooks directory of the working copy is not versioned, so the file
5
8
  # is put there separately — by the prepare script when dependencies are installed. Reinstall by
6
9
  # hand if the prepare step did not run for some reason: