@rt-tools/agent-kit 0.26.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) 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-epics.github.mjs +239 -36
  4. package/assets/checks/board-long-work.github.mjs +5 -1
  5. package/assets/checks/board-pull-state.github.mjs +168 -0
  6. package/assets/checks/board-task-dirs.github.mjs +98 -0
  7. package/assets/checks/board.github.mjs +8 -91
  8. package/assets/checks/check-board.github.mjs +25 -165
  9. package/assets/checks/check-prose-style.mjs +19 -3
  10. package/assets/checks/check-schema-drift.mjs +19 -3
  11. package/assets/checks/epic-table.github.mjs +268 -0
  12. package/assets/checks/rt-kit-checks.config.mjs +13 -0
  13. package/assets/checks/specs-for.mjs +214 -0
  14. package/assets/checks/task-new.github.mjs +231 -6
  15. package/assets/commands/night.md +115 -0
  16. package/assets/defaults/project.sh +7 -0
  17. package/assets/defaults/turn-map.md +3 -1
  18. package/assets/docs/GLOSSARY.md +22 -22
  19. package/assets/hooks/browser-device-id.sh +4 -0
  20. package/assets/hooks/browser-guard-device-id.sh +4 -0
  21. package/assets/hooks/commit-msg.sh +3 -0
  22. package/assets/hooks/dev-server-guard.sh +4 -0
  23. package/assets/hooks/epic-over.sh +49 -0
  24. package/assets/hooks/epic-stop-guard.sh +108 -0
  25. package/assets/hooks/git-guard-delivery-conflict.sh +3 -0
  26. package/assets/hooks/git-guard-delivery-draft.sh +3 -0
  27. package/assets/hooks/git-guard-delivery-epic.sh +167 -0
  28. package/assets/hooks/git-guard-delivery-signature.sh +32 -2
  29. package/assets/hooks/git-guard-delivery.sh +28 -4
  30. package/assets/hooks/handoff-entry-guard.sh +20 -2
  31. package/assets/hooks/prose-style-guard.sh +31 -8
  32. package/assets/hooks/qa-dataid-guard.sh +33 -11
  33. package/assets/hooks/rule-article.sh +3 -0
  34. package/assets/hooks/skill-gate-layers.sh +4 -0
  35. package/assets/hooks/skill-loaded.sh +4 -0
  36. package/assets/hooks/sql-guard-parse.sh +3 -0
  37. package/assets/hooks/sql-guard-request.sh +3 -0
  38. package/assets/hooks/sql-guard-target.sh +3 -0
  39. package/assets/hooks/sql-guard-write.sh +3 -0
  40. package/assets/hooks/stand-login-guard.sh +3 -0
  41. package/assets/hooks/turn-exit-guard.sh +5 -1
  42. package/assets/hooks/turn-exit-patterns.sh +10 -0
  43. package/assets/hooks/utf8.sh +3 -0
  44. package/assets/hooks/waiting-turn-guard.sh +11 -1
  45. package/assets/hooks/write-targets.sh +3 -0
  46. package/assets/laws/delivery.md +23 -1
  47. package/assets/patterns/git-workflow-commit.azure.md +1 -1
  48. package/assets/patterns/git-workflow-commit.github.md +9 -2
  49. package/assets/patterns/git-workflow-commit.gitlab.md +1 -1
  50. package/assets/patterns/git-workflow-merge.md +8 -5
  51. package/assets/patterns/git-workflow-pr.azure.md +1 -1
  52. package/assets/patterns/git-workflow-pr.github.md +8 -3
  53. package/assets/patterns/git-workflow-pr.gitlab.md +1 -1
  54. package/assets/patterns/git-workflow-stack.md +13 -9
  55. package/assets/patterns/status-report-table.github.md +11 -0
  56. package/assets/patterns/task-flow-close.md +40 -21
  57. package/assets/patterns/task-flow-start.md +40 -26
  58. package/assets/pitfalls/agent-kit.md +19 -0
  59. package/assets/pitfalls/git-workflow.github.md +6 -0
  60. package/assets/rules/autonomous-work.md +15 -3
  61. package/assets/rules/doc-style.md +7 -4
  62. package/assets/rules/git-workflow.github.md +41 -23
  63. package/assets/rules/spec-driven.md +7 -0
  64. package/assets/rules/status-report.md +7 -0
  65. package/assets/rules/task-flow.md +31 -10
  66. package/assets/rules/turn-conduct.md +7 -0
  67. package/assets/skills/agent-kit.md +23 -21
  68. package/bin/agent-kit.d.ts.map +1 -1
  69. package/bin/agent-kit.js +8 -1
  70. package/bin/agent-kit.js.map +1 -1
  71. package/lib/cargo-prose.d.ts +41 -0
  72. package/lib/cargo-prose.d.ts.map +1 -0
  73. package/lib/cargo-prose.js +88 -0
  74. package/lib/cargo-prose.js.map +1 -0
  75. package/lib/cargo.d.ts +12 -1
  76. package/lib/cargo.d.ts.map +1 -1
  77. package/lib/cargo.js +8 -2
  78. package/lib/cargo.js.map +1 -1
  79. package/lib/fate.d.ts +29 -0
  80. package/lib/fate.d.ts.map +1 -0
  81. package/lib/fate.js +147 -0
  82. package/lib/fate.js.map +1 -0
  83. package/lib/override-marks.d.ts +7 -0
  84. package/lib/override-marks.d.ts.map +1 -1
  85. package/lib/override-marks.js +14 -0
  86. package/lib/override-marks.js.map +1 -1
  87. package/lib/ship.d.ts +29 -2
  88. package/lib/ship.d.ts.map +1 -1
  89. package/lib/ship.js +34 -0
  90. package/lib/ship.js.map +1 -1
  91. package/lib/shipment.d.ts.map +1 -1
  92. package/lib/shipment.fixture.d.ts +8 -1
  93. package/lib/shipment.fixture.d.ts.map +1 -1
  94. package/lib/shipment.fixture.js +9 -0
  95. package/lib/shipment.fixture.js.map +1 -1
  96. package/lib/shipment.js +32 -3
  97. package/lib/shipment.js.map +1 -1
  98. package/package.json +1 -1
  99. package/rt-tools-agent-kit-0.27.0.tgz +0 -0
  100. package/rt-tools-agent-kit-0.26.0.tgz +0 -0
@@ -13,11 +13,28 @@
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
 
@@ -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,6 +88,17 @@ 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
103
  fail(`unknown flag ${argv[index]}`);
67
104
  }
@@ -96,6 +133,58 @@ if (args.slug !== null && !/^[a-z0-9][a-z0-9-]*$/.test(args.slug)) {
96
133
  fail('slug is lowercase latin letters, digits and dashes: the branch name is read in a list of fifty lines');
97
134
  }
98
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');
165
+ }
166
+
167
+ /**
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
+
99
188
  /**
100
189
  * The token of the machine account is optional: a tree that has not named it creates the task
101
190
  * under the account the hosting client is logged in as. Demanding the token would hold task
@@ -105,6 +194,69 @@ if (args.slug !== null && !/^[a-z0-9][a-z0-9-]*$/.test(args.slug)) {
105
194
  */
106
195
  const token = botToken() ?? undefined;
107
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
+
108
260
  let number = null;
109
261
  try {
110
262
  const created = gh(
@@ -116,10 +268,10 @@ try {
116
268
  '--title',
117
269
  args.title,
118
270
  '--body',
119
- readBody(),
271
+ body,
120
272
  '--assignee',
121
273
  args.assignee,
122
- ...args.labels.flatMap((label) => ['--label', label]),
274
+ ...labels.flatMap((label) => ['--label', label]),
123
275
  ],
124
276
  { token }
125
277
  ).trim();
@@ -142,6 +294,18 @@ try {
142
294
  `mutation { updateProjectV2ItemFieldValue(input: {projectId: "${PROJECT_ID}", itemId: "${itemId}", fieldId: "${STATUS_FIELD_ID}", value: {singleSelectOptionId: "${BACKLOG_OPTION_ID}"}}) { projectV2Item { id } } }`,
143
295
  { token }
144
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
+ }
145
309
  } catch (error) {
146
310
  const reason = error instanceof OfflineError ? `no connection to GitHub: ${error.message}` : String(error.message ?? error);
147
311
  if (number === null) {
@@ -210,7 +374,59 @@ function adoptDraft() {
210
374
  }
211
375
  }
212
376
 
213
- adoptDraft();
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;
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}`);
423
+ }
424
+
425
+ if (args.epic) {
426
+ writeEpicPlan();
427
+ } else {
428
+ adoptDraft();
429
+ }
214
430
 
215
431
  console.log(`[${TASK_KEY}-${number}] ${args.title}`);
216
432
  console.log(`https://github.com/${OWNER}/${REPO}/issues/${number}`);
@@ -258,7 +474,16 @@ for (const line of answer.lines) {
258
474
  (answer.ok ? console.log : console.error)(`task-new: ${line}`);
259
475
  }
260
476
 
261
- console.log(`\nThe branch is created by a separate call:\n git checkout -b ${branch}`);
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}`);
262
487
  console.log(`A task taken into work is moved on the board:\n npm run task:move -- ${number} ${IN_PROGRESS_STATUS}`);
263
488
 
264
489
  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.
@@ -347,6 +347,13 @@ RT_PULL_BODY_SECTION="${RT_PULL_BODY_SECTION:-}"
347
347
  RT_TASK_MOVE_CMD="${RT_TASK_MOVE_CMD:-npm run task:move}"
348
348
  RT_BOARD_BACKLOG="${RT_BOARD_BACKLOG:-}"
349
349
 
350
+ # The label of an epic card: by it the guard tells the branch of an epic from the branch of a task,
351
+ # and the branch of an epic is judged by other conditions — its request goes into the main branch,
352
+ # and it opens only when the folders of all its tasks are taken apart. The word is each tree's own,
353
+ # and the default is empty: a tree that has not named it keeps no epics, and the conditions about
354
+ # them are not judged at all.
355
+ RT_BOARD_EPIC_LABEL="${RT_BOARD_EPIC_LABEL:-}"
356
+
350
357
  # The email the machine account's commit is signed with. As a whole value, not a pattern: the
351
358
  # hosting's service address consists of a number, a login and a domain, and is matched by the number
352
359
  # — 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:
@@ -14,6 +14,10 @@
14
14
  # Where exactly the applications are raised is known to the project profile:
15
15
  # .claude/rt-kit/project.sh, variable RT_STANDS. No profile — the refusal text stays general, the
16
16
  # guard itself works.
17
+ #
18
+ # FAIL-OPEN: an unrecognised command, no way to ask the ports, a raise the tree knows nothing of —
19
+ # the call goes through. The price of a miss here is a second server on a busy port; the price of a
20
+ # wrong refusal is a guard nobody keeps.
17
21
 
18
22
  # Its own name in the observations: the refusal is written by the shared deny tail, not by the
19
23
  # guard itself.
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env bash
2
+ # The reading "the epic is over". NOT a guard: it has no `rt-hook:` declaration and hooks into no
3
+ # agent event. The guards that judge the end of an epic source it themselves.
4
+ #
5
+ # Why it lives apart. Three guards ask one and the same question, and each from its own side: one
6
+ # refuses taking new work after the end of an epic, and two others refuse the very stop that the end
7
+ # of an epic requires — a turn without the next task taken and a turn that says the session waits for
8
+ # a word. Written three times, the reading would diverge three ways, and the guards would refuse each
9
+ # other's lawful moves.
10
+ #
11
+ # The state is asked by the command that prints the table for the owner: a reader of its own would
12
+ # diverge from the printed table in silence. The call is not cheap — it goes to the hosting — so the
13
+ # Stop guards ask it right before a refusal, not on every turn.
14
+ #
15
+ # ZERO means the epic is over: not one of its tasks is left unfinished. Any other answer — a task in
16
+ # work, no epic behind the branch, no way to ask the hosting — is not zero, and the caller works as
17
+ # it did before this reading existed.
18
+
19
+ rt_epic_over() {
20
+ command -v jq >/dev/null 2>&1 || return 1
21
+ command -v node >/dev/null 2>&1 || return 1
22
+
23
+ local here root checks table left
24
+ # The turn names the directory it goes from, and a Stop guard is called from wherever the host
25
+ # stands: taken from the process, the tree would be a foreign one — or none at all.
26
+ here="."
27
+ if command -v rt_hook_cwd >/dev/null 2>&1; then
28
+ here="$(rt_hook_cwd 2>/dev/null)"
29
+ [ -z "$here" ] && here="."
30
+ fi
31
+
32
+ root="$(cd "$here" 2>/dev/null && git rev-parse --show-toplevel 2>/dev/null)"
33
+ [ -z "$root" ] && return 1
34
+
35
+ # Where the checks of the package lie is named by the tree: the directory differs from tree to
36
+ # tree, and a name written here would be right in the first one and wrong in the second.
37
+ checks="$(jq -r '.layout.checks // "tools"' "$root/.claude/rt-kit.json" 2>/dev/null)"
38
+ if [ -z "$checks" ] || [ "$checks" = null ]; then
39
+ checks=tools
40
+ fi
41
+
42
+ table="$root/$checks/epic-table.mjs"
43
+ [ -f "$table" ] || return 1
44
+
45
+ left="$(cd "$root" && node "$table" --unfinished 2>/dev/null)" || return 1
46
+ [ -n "$left" ] && return 1
47
+
48
+ return 0
49
+ }