@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
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
  # rt-hook: Stop
3
- # Requires: hooks/deny-tail.sh, hooks/turn-exit-patterns.sh
3
+ # Requires: hooks/deny-tail.sh, hooks/epic-over.sh, hooks/turn-exit-patterns.sh
4
4
  # Turn exit guard: a turn in which nothing was done on the work does not end until the work is
5
5
  # handed over. Stop.
6
6
  #
@@ -162,72 +162,12 @@ next_step=""
162
162
  . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/turn-exit-patterns.sh" 2>/dev/null || exit 0
163
163
  [ -n "${work_re:-}" ] || exit 0
164
164
 
165
- verdict="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r --arg work "$work_re" --arg read "$read_re" --arg part "$part_re" --arg wait "$wait_re" --arg handover "$handover_re" --arg started "$started_re" '
166
- def is_input:
167
- .type == "user"
168
- and ((.isCompactSummary // false) | not)
169
- and (((.message.content // []) | if type == "array"
170
- then ([.[] | select(.type == "tool_result")] | length)
171
- else 0 end) == 0);
172
-
173
- (map(is_input) | rindex(true)) as $i
174
- | (if $i == null then [] else .[$i:] end) as $turn
175
- | [$turn[] | select(.type == "assistant") | (.message.content // [])[] | select(.type == "tool_use")] as $uses
176
- # An edit of a file is work by definition, whatever tool it goes through.
177
- | ($uses | map(.name // "") | any(test("^(Edit|Write|MultiEdit|NotebookEdit)$"))) as $edited
178
- | ($uses | map(.name // "") | any(test("AskUserQuestion"))) as $asked
179
- | ($uses | map((.input.command // "")) | join("\n")) as $ran
180
- # Work is a part of the command that matched the work pattern and did not match the exploration
181
- # pattern: switching a branch and reading history in the same turn do not become work.
182
- | ([$ran | splits($part)] | map(test($work) and (test($read) | not)) | any) as $ran_work
183
- # The last action of the turn. Waiting for a step by anyone else is never the end of a turn,
184
- # however much work there was before: the work stays exactly where it stood.
185
- | ([$uses[] | select((.name // "") == "Bash") | (.input.command // "")] | last // "") as $last
186
- | ($last | test($wait)) as $waited
187
- # Handing the work over: the tail of the turn after the PR was opened. Everything before it was
188
- # done on the task handed in and says nothing about the next one.
189
- | ([$uses[] | select((.name // "") == "Bash") | (.input.command // "")]) as $cmds
190
- | (($cmds | map(test($handover)) | index(true))) as $handover_at
191
- | ($handover_at != null) as $handed_over
192
- | (if $handover_at == null then [] else $cmds[$handover_at:] end) as $tail
193
- | (($tail | map(test($started)) | any)
194
- or ($uses | map(.name // "") | any(test("^(Edit|Write|MultiEdit|NotebookEdit)$")))) as $started_next
195
- # THE LAST ACTION OF THE TURN is the shared sign, and the particular tiers below only derive an
196
- # understandable refusal from it. Nine incident analyses in a day describe nine different stops,
197
- # and in all nine the last action of the turn was a text to the owner: a report, a summary, an
198
- # announcement of intent. A tier for every kind of stop is an endless race: there are as many
199
- # kinds as there are reasons to start talking. Hence one sign — the LAST action must be work.
200
- | ([$uses[] | (.name // "")] | last // "") as $last_tool
201
- | (($last_tool | test("^(Edit|Write|MultiEdit|NotebookEdit)$"))
202
- or ([$last | splits($part)] | map(test($work) and (test($read) | not)) | any)) as $ended_working
203
- # A guard refusal and a session handover — both end the turn by the rule.
204
- | ([$turn[] | select(.type == "user") | .message.content // [] | select(type == "array") | .[]
205
- | select(.type == "tool_result") | .content
206
- | if type == "string" then .
207
- elif type == "array" then (map(if type == "object" then (.text // "") else tostring end) | join("\n"))
208
- else tostring end] | join("\n")) as $out
209
- | (($out | test("BLOCKED by|Refused by the rules gate|Отбито гейтом")) or ($ran | test("BLOCKED by"))) as $denied
210
- | ($ran | test("handoff")) as $handed
211
- # The word of the owner about stopping: the reply itself is judged, not its retelling.
212
- | ([$turn[] | select(.type == "user") | .message.content
213
- | if type == "string" then . elif type == "array"
214
- then (map(if type == "object" then (.text // "") else "" end) | join("\n")) else "" end] | join("\n")) as $said
215
- | ($said | test("останов|стоп|хватит|подожди|не надо|прерв|отложи")) as $told_stop
216
- # A question refused by the conversation guard, and a question appended as prose at the end of
217
- # the reply. The conversation guard judges the call of the question tool and does not see prose
218
- # at all: a refused question came back in the same wording one turn later and passed freely.
219
- | ($out | test("BLOCKED by grill-gate")) as $ask_denied
220
- | ([$turn[] | select(.type == "assistant") | (.message.content // [])[]
221
- | select(.type == "text") | (.text // "")] | last // "") as $last_say
222
- | (($last_say | test("\\?[[:space:]]*$")) and $ask_denied) as $asked_in_prose
223
- # Waiting for the word of the owner, announced by the executor. That word is read from
224
- # the owner: without his word in the turn and without a question to him through the tool, the
225
- # phrase "waiting for your word" is a stop announced by the one it suits. The set of patterns is
226
- # named and closed.
227
- | (($last_say | test("[Жж]ду (твоего|вашего|его|её) (слова|указани|решени|ответа|команды|отмашки)|[Жж]ду слова владельца|[Жж]ду, что скаж|[Оо]стаюсь ждать|[Бб]уду ждать (твоего|вашего)"))
228
- and (($asked or $told_stop or $handed) | not)) as $awaits_word
229
- | { worked: ($edited or $ran_work), released: ($asked or $denied or $handed or $told_stop), waited: $waited, handed_over: $handed_over, started_next: $started_next, ended_working: $ended_working, asked_in_prose: $asked_in_prose, awaits_word: $awaits_word, ran: $ran }
230
- ' 2>/dev/null)"
165
+ # The parsing of the turn record lies in a neighbouring file: the guard crossed the file length
166
+ # limit, and the parsing reads apart from the tiers that apply its answer. Without the file the
167
+ # guard stays silent — fail-open, as on any breakage of its own.
168
+ . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/turn-exit-verdict.sh" 2>/dev/null || exit 0
169
+ command -v rt_te_verdict >/dev/null 2>&1 || exit 0
170
+ rt_te_verdict
231
171
 
232
172
  [ -z "$verdict" ] && exit 0
233
173
 
@@ -261,6 +201,54 @@ fi
261
201
  # Incident analysis — the record
262
202
  # "2026-09-04-hod-konchalsya-ozhidaniem-pri-deystvuyushchem-ukazanii" in the intake.
263
203
  awaits_word="$(printf '%s' "$verdict" | jq -r '.awaits_word // false' 2>/dev/null)"
204
+ standing_work="$(printf '%s' "$verdict" | jq -r '.standing_work // false' 2>/dev/null)"
205
+ promised="$(printf '%s' "$verdict" | jq -r '.promised // false' 2>/dev/null)"
206
+ only_took="$(printf '%s' "$verdict" | jq -r '.only_took // false' 2>/dev/null)"
207
+
208
+ # A promise to do the work in the next turn. The same announcement of intent as a command named and
209
+ # not run: the tier stands before the lawful exits, because the promise most often stands next to a
210
+ # report about what was done, and by the fullness of the turn it is indistinguishable from a finish.
211
+ if [ "$promised" = "true" ] && [ "$released" != "true" ]; then
212
+ rt_te_deny "BLOCKED by turn-exit-guard: the reply ends with a promise to do the work in the next turn.
213
+
214
+ A promise is the same announcement of intent as a command named and not run, and it only sounds politer. An offer to the owner to object to the announced intent is part of the promise, not a question: a turn ends with a question when the work does not go without the answer.
215
+
216
+ Do the promised in this same turn, and the account of it can come after.
217
+
218
+ The next step is written in the progress: ${next_step}
219
+
220
+ The guard judges one turn: the next session is not refused." "the turn ended with a promise to do the work in the next turn."
221
+ fi
222
+
223
+ # Taking a task as the last action of the turn. Creating the task, the branch and the move of the
224
+ # column is preparation, and the work of the taken task did not begin. Taking it after handed-over
225
+ # work is a lawful end: there the taking answers for the handed-over one.
226
+ if [ "$only_took" = "true" ] && [ "$released" != "true" ]; then
227
+ rt_te_deny "BLOCKED by turn-exit-guard: the last action of the turn is taking a task, and the work of the taken task was not begun.
228
+
229
+ Creating the task, the branch and moving the column is preparation for work, not work. To the owner a report about a taken task is indistinguishable from a stop: they see the executor standing still.
230
+
231
+ Write the plan and begin its first stage in this same turn.
232
+
233
+ The guard judges one turn: the next session is not refused." "the turn ended with taking a task."
234
+ fi
235
+ # At the end of an epic waiting for the word of the owner is the work itself: the reading of that
236
+ # lies with the patterns and is shared with the guard of the stop.
237
+ [ "$awaits_word" = "true" ] && rt_te_epic_over && awaits_word=false
238
+
239
+ # The owner said to work without stops and did not cancel it. Their word holds until they cancel
240
+ # it, and a turn ending with waiting for that same word invents the cancellation. Judged whether or
241
+ # not there was work in the turn: the work stood three turns in a row, and each of them was full.
242
+ if [ "$standing_work" = "true" ] && [ "$awaits_word" = "true" ]; then
243
+ rt_te_deny "BLOCKED by turn-exit-guard: the turn ended with waiting for the word of the owner, and the owner said in this session to work without stops and did not cancel it.
244
+
245
+ Their word holds until they cancel it themselves, and a new fact against it is a line about the price in the reply, not waiting. A decision the tree does not hold is needed — then ask the question by the tool.
246
+
247
+ The next step is written in the progress: ${next_step}
248
+
249
+ The guard judges one turn: the next session is not refused." "the turn ended with waiting under the standing word of the owner to work."
250
+ fi
251
+
264
252
  if [ "$awaits_word" = "true" ]; then
265
253
  rt_te_deny "BLOCKED by turn-exit-guard: the turn ended with words about waiting for the word of the owner, and the word about stopping the guard reads from the owner: in this turn they announced no stop, and no question was put to them by the tool.
266
254
 
@@ -45,9 +45,36 @@ part_re='&&|\|\||;|\n'
45
45
  # resolved, a commit and a push were made, and the last action became a loop until the run was ready
46
46
  # passed it whole — there was work, and plenty. It is exactly that fullness that deceives: the
47
47
  # emptiness behind such a turn is not visible.
48
- wait_re='gh[[:space:]]+(run[[:space:]]+watch|pr[[:space:]]+checks[^|]*--watch)|until[[:space:]].*sleep|while[[:space:]].*sleep|^[[:space:]]*sleep[[:space:]]'
48
+ # Two more kinds of last action were added after an analysis. The first is a run of the checks
49
+ # started in the background: the guard is given the background sign appended to the command, and on
50
+ # the foreground the same command stays work — it holds the turn to its own end. The second is a
51
+ # read of a background task's log: the run was started, the log was read, a report was written, and
52
+ # the tree did not change by a single sign; such a turn stands exactly as long as an empty one.
53
+ wait_re='gh[[:space:]]+(run[[:space:]]+watch|pr[[:space:]]+checks[^|]*--watch)|until[[:space:]].*sleep|while[[:space:]].*sleep|^[[:space:]]*sleep[[:space:]]|(nx[[:space:]]+(affected|run-many|test|build|lint|e2e)|npm[[:space:]]+run[[:space:]]+(lint|test|check:|e2e)|pnpm[[:space:]]+run|playwright[[:space:]]+test|vitest|jest|bash[[:space:]].*tests?/)[^&]*&[[:space:]]*$|(cat|tail|head|less|grep)[^|]*\.(log|output)([[:space:]]|$)|tasks/[A-Za-z0-9]+\.output'
54
+
55
+ # A promise to do the work in the next turn. The same announcement of intent as a command named and
56
+ # not run, only it sounds politer and is therefore recognised as a stop less often. An offer to the
57
+ # owner to object to the announced intent is part of the promise, not a question: a turn ends with a
58
+ # question when the work does not go without the answer, and here it did go.
59
+ promise_re='следующим ходом|в следующий раз|дальше возьму|дальше допишу|допишу остальн|доделаю остальн|доделаю в следующ|продолжу в следующ|беру[^.]{0,40}следующим|возьму[^.]{0,40}следующим'
60
+
61
+ # The owner's standing word to work without stops. It holds until they cancel it, and a turn that
62
+ # ended with waiting for their word invents that cancellation. Without this the word about a stop
63
+ # was read out of it by the piece «останов» in «без остановок» — the instruction to work was taken
64
+ # for its opposite.
65
+ standing_work_re='работай[^.]{0,40}(без остановок|без пауз|сам)|не останавливайся|продолжай[^.]{0,40}(без остановок|без пауз)|работай дальше'
49
66
 
50
67
  # Handing work over and starting the next. The rule calls handed-over work a lawful end of a turn —
51
68
  # but on a condition: the next one is started, and an ACTION has been done on it, not spoken.
52
69
  handover_re='gh[[:space:]]+pr[[:space:]]+create'
53
70
  started_re='task:new|task:move|board\.mjs[[:space:]]+move|git[[:space:]]+checkout([[:space:]]+-[A-Za-z-]+)*[[:space:]]+-b|git[[:space:]]+switch([[:space:]]+-[A-Za-z-]+)*[[:space:]]+-c'
71
+
72
+ # The end of an epic: there waiting for the word of the owner is the work itself, and the guard of
73
+ # the stop refuses taking the next task. The reading lies apart and is shared by the three guards;
74
+ # it goes to the hosting, so the guard asks it right before a refusal, not on every turn.
75
+ rt_te_epic_over() {
76
+ # shellcheck disable=SC1090
77
+ . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/epic-over.sh" 2>/dev/null || return 1
78
+ command -v rt_epic_over >/dev/null 2>&1 || return 1
79
+ rt_epic_over
80
+ }
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env bash
2
+ # The parsing of the turn record for the turn-exit guard. NOT a guard: it has no `rt-hook:`
3
+ # declaration and hooks into no agent event. The guard sources it right after the patterns —
4
+ # it was moved out when the guard crossed the file length limit, and the parsing reads apart
5
+ # from the tiers that apply its answer.
6
+ #
7
+ # It expects the patterns to be sourced already and `$transcript` to be set; it prints nothing
8
+ # and leaves the answer in `$verdict`.
9
+
10
+ rt_te_verdict() {
11
+ verdict="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r --arg work "$work_re" --arg read "$read_re" --arg part "$part_re" --arg wait "$wait_re" --arg handover "$handover_re" --arg started "$started_re" --arg promise "$promise_re" --arg standing "$standing_work_re" '
12
+ def is_input:
13
+ .type == "user"
14
+ and ((.isCompactSummary // false) | not)
15
+ and (((.message.content // []) | if type == "array"
16
+ then ([.[] | select(.type == "tool_result")] | length)
17
+ else 0 end) == 0);
18
+
19
+ (map(is_input) | rindex(true)) as $i
20
+ | (if $i == null then [] else .[$i:] end) as $turn
21
+ | [$turn[] | select(.type == "assistant") | (.message.content // [])[] | select(.type == "tool_use")] as $uses
22
+ # An edit of a file is work by definition, whatever tool it goes through.
23
+ | ($uses | map(.name // "") | any(test("^(Edit|Write|MultiEdit|NotebookEdit)$"))) as $edited
24
+ | ($uses | map(.name // "") | any(test("AskUserQuestion"))) as $asked
25
+ | ($uses | map((.input.command // "")) | join("\n")) as $ran
26
+ # Work is a part of the command that matched the work pattern and did not match the exploration
27
+ # pattern: switching a branch and reading history in the same turn do not become work.
28
+ | ([$ran | splits($part)] | map(test($work) and (test($read) | not)) | any) as $ran_work
29
+ # The last action of the turn. Waiting for a step by anyone else is never the end of a turn,
30
+ # however much work there was before: the work stays exactly where it stood.
31
+ | ([$uses[] | select((.name // "") == "Bash") | ((.input.command // "") + (if (.input.run_in_background // false) then " &" else "" end))] | last // "") as $last
32
+ | ([$uses[] | (.name // "")] | last // "") as $last_name
33
+ | (($last_name == "Bash") and ($last | test($wait))) as $waited
34
+ # Handing the work over: the tail of the turn after the PR was opened. Everything before it was
35
+ # done on the task handed in and says nothing about the next one.
36
+ | ([$uses[] | select((.name // "") == "Bash") | (.input.command // "")]) as $cmds
37
+ | (($cmds | map(test($handover)) | index(true))) as $handover_at
38
+ | ($handover_at != null) as $handed_over
39
+ | (if $handover_at == null then [] else $cmds[$handover_at:] end) as $tail
40
+ | (($tail | map(test($started)) | any)
41
+ or ($uses | map(.name // "") | any(test("^(Edit|Write|MultiEdit|NotebookEdit)$")))) as $started_next
42
+ # THE LAST ACTION OF THE TURN is the shared sign, and the particular tiers below only derive an
43
+ # understandable refusal from it. Nine incident analyses in a day describe nine different stops,
44
+ # and in all nine the last action of the turn was a text to the owner: a report, a summary, an
45
+ # announcement of intent. A tier for every kind of stop is an endless race: there are as many
46
+ # kinds as there are reasons to start talking. Hence one sign — the LAST action must be work.
47
+ | ([$uses[] | (.name // "")] | last // "") as $last_tool
48
+ | (($last_tool | test("^(Edit|Write|MultiEdit|NotebookEdit)$"))
49
+ or ([$last | splits($part)] | map(test($work) and (test($read) | not)) | any)) as $ended_working
50
+ # A guard refusal and a session handover — both end the turn by the rule.
51
+ | ([$turn[] | select(.type == "user") | .message.content // [] | select(type == "array") | .[]
52
+ | select(.type == "tool_result") | .content
53
+ | if type == "string" then .
54
+ elif type == "array" then (map(if type == "object" then (.text // "") else tostring end) | join("\n"))
55
+ else tostring end] | join("\n")) as $out
56
+ | (($out | test("BLOCKED by|Refused by the rules gate|Отбито гейтом")) or ($ran | test("BLOCKED by"))) as $denied
57
+ | ($ran | test("handoff")) as $handed
58
+ # The word of the owner about stopping: the reply itself is judged, not its retelling.
59
+ | ([$turn[] | select(.type == "user") | .message.content
60
+ | if type == "string" then . elif type == "array"
61
+ then (map(if type == "object" then (.text // "") else "" end) | join("\n")) else "" end] | join("\n")) as $said
62
+ | ([.[] | select(.type == "user") | .message.content
63
+ | if type == "string" then . elif type == "array"
64
+ then (map(if type == "object" then (.text // "") else "" end) | join("\n")) else "" end] | join("\n")) as $session_said
65
+ | ($session_said | test($standing)) as $standing_work
66
+ | (($said | test("останов|стоп|хватит|подожди|не надо|прерв|отложи")) and ($said | test($standing) | not)) as $told_stop
67
+ # A question refused by the conversation guard, and a question appended as prose at the end of
68
+ # the reply. The conversation guard judges the call of the question tool and does not see prose
69
+ # at all: a refused question came back in the same wording one turn later and passed freely.
70
+ | ($out | test("BLOCKED by grill-gate")) as $ask_denied
71
+ | ([$turn[] | select(.type == "assistant") | (.message.content // [])[]
72
+ | select(.type == "text") | (.text // "")] | last // "") as $last_say
73
+ | (($last_say | test("\\?[[:space:]]*$")) and $ask_denied) as $asked_in_prose
74
+ # Waiting for the word of the owner, announced by the executor. That word is read from
75
+ # the owner: without his word in the turn and without a question to him through the tool, the
76
+ # phrase "waiting for your word" is a stop announced by the one it suits. The set of patterns is
77
+ # named and closed.
78
+ | (($last_say | test("[Жж]ду (твоего|вашего|его|её) (слова|указани|решени|ответа|команды|отмашки)|[Жж]ду слова владельца|[Жж]ду, что скаж|[Оо]стаюсь ждать|[Бб]уду ждать (твоего|вашего)"))
79
+ and (($asked or $told_stop or $handed) | not)) as $awaits_word
80
+ | ($last_say | test($promise)) as $promised
81
+ | (($last_name == "Bash") and ($last | test($started)) and ($handed_over | not)) as $only_took
82
+ | { promised: $promised, only_took: $only_took, standing_work: $standing_work, worked: ($edited or $ran_work), released: ($asked or $denied or $handed or $told_stop), waited: $waited, handed_over: $handed_over, started_next: $started_next, ended_working: $ended_working, asked_in_prose: $asked_in_prose, awaits_word: $awaits_word, ran: $ran }
83
+ ' 2>/dev/null)"
84
+ }
@@ -1,6 +1,9 @@
1
1
  #!/usr/bin/env bash
2
2
  # The locale a guard runs in. Sourced as the first line of the body: `. "<guards directory>/utf8.sh"`.
3
3
  #
4
+ # NOT a guard: it has no `rt-hook:` declaration and hooks into no agent event. The guards source it
5
+ # as the first line of their body: the locale is one for all of them.
6
+ #
4
7
  # Guard patterns are written in the words of the language the tree speaks, and matching against
5
8
  # them depends on the process locale. In the C locale case folding works only for Latin letters:
6
9
  # «В дереве этого нет» is not found under the pattern `(в дереве|здесь)…` at all, the guard exits
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
  # rt-hook: Stop
3
- # Requires: hooks/deny-tail.sh
3
+ # Requires: hooks/deny-tail.sh, hooks/epic-over.sh
4
4
  # Waiting guard: a turn that tells the owner about someone else's step does not end until it holds
5
5
  # at least one action on the next task. Stop.
6
6
  #
@@ -223,6 +223,16 @@ case "$verdict" in
223
223
  *) exit 0 ;;
224
224
  esac
225
225
 
226
+ # The end of an epic: there the next task is exactly what is not taken — the guard of the stop
227
+ # refuses taking it — and demanding it here would leave the turn with no lawful end. The reading is
228
+ # shared with that guard and is asked right before the refusal: it goes to the hosting, and every
229
+ # turn must not pay for it.
230
+ # shellcheck disable=SC1090
231
+ . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/epic-over.sh" 2>/dev/null || true
232
+ if command -v rt_epic_over >/dev/null 2>&1 && rt_epic_over; then
233
+ exit 0
234
+ fi
235
+
226
236
  reason="BLOCKED by waiting-turn-guard: ${said}, and there is not a single action about the next task in it. Waiting for someone else's step is not what a session is spent on: the run, the review and the merge go on elsewhere and do not get faster from being watched.
227
237
 
228
238
  Saying «беру следующую задачу» is not the same as taking it: the phrase lives to the end of the turn while the work does not move, and only the owner can notice that.
@@ -2,6 +2,9 @@
2
2
  # Write targets named by the shell command outright: redirection, `tee`, an in-place edit, a copy
3
3
  # over the top, and for an interpreter — the paths from its body. Prints one per line.
4
4
  #
5
+ # NOT a guard: it has no `rt-hook:` declaration and hooks into no agent event. The guards that judge
6
+ # a shell command source it: the paths a command writes to are read one way by all of them.
7
+ #
5
8
  # There is deliberately no `# rt-hook:` line here: this is a helper, not a hook. It decides nothing
6
9
  # by itself and is called from where an edit of a file is judged — by the guard of the place of the
7
10
  # edit and by the exam guard. It is shared because the sign of a write is one and the same for both:
@@ -9,6 +9,27 @@ application stops responding, and the reason is found from the history.
9
9
  did not reach the queue is seen by no one, and no work was planned behind it.
10
10
  - **A change reaches the main branch only through a separate branch.** A direct write to main takes
11
11
  away both the discussion and the chance to roll the change back in one move.
12
+ - **A change belongs to an epic, and the epic is the unit of delivery.** One task changes the
13
+ application no less than a series of them, and merged on its own it reaches the main branch as
14
+ half of a thought: the rest of the series arrives later, or never, and the main branch holds a
15
+ state nobody planned. An epic names what the whole is, so that the main branch takes it whole or
16
+ does not take it. Work outside an epic exists only by the owner's word about that work.
17
+ - **An epic has a branch of its own, and it is taken from the main branch.** Without it the epic
18
+ lives as a plan alone, and a plan is not merged: its tasks stand on the main branch apart from one
19
+ another, half a finished epic is already rolled out while the rest is being written, and a
20
+ rollback goes task by task.
21
+ - **The branch of a task is taken from the branch of its epic, and the PR of the task goes there.**
22
+ Taken from the main branch, a task branch carries into the main branch what the epic has not
23
+ finished; opened into the main branch, its PR makes the epic branch a copy nobody merges.
24
+ - **The PR of an epic into the main branch opens after the folders of all its tasks are taken
25
+ apart.** What lies in them explains the decisions of one piece of work and dies with it: what is
26
+ worth keeping leaves for the description of the past by that same moment. An epic branch that
27
+ reaches the main branch with those folders in it carries into the whole tree what one branch
28
+ needed.
29
+ - **The main branch is merged into the branch of the epic, and the branch of the epic into the
30
+ branches of its tasks.** An epic outlives one task, and by its end its branch has fallen behind
31
+ everything the neighbours merged; a task branch that took the epic branch before that never sees
32
+ the lag. Both merges go while the work runs, not before the hand-over.
12
33
  - **The work queue holds tasks, not PRs about them.** A task and its PR share one number and one
13
34
  fate, so a second card about the same work adds nothing — it doubles the queue and lies about its
14
35
  length. The queue is read to see what is done and what remains; a PR answers a different question
@@ -35,7 +56,8 @@ application stops responding, and the reason is found from the history.
35
56
  the more surely, the closer the work is by subject. It is not the changes that diverge but the
36
57
  lines both wrote to. The cost does not vanish but moves: the one who branches pays it once,
37
58
  instead of the one who merges paying it as many times as there are open PRs. The first work of a
38
- series branches from main, and so does any work not connected to the previous one.
59
+ series branches from the branch of its epic, and so does any work not connected to the previous
60
+ one.
39
61
  - **A series of branches is handed over bottom up, and the order is named to the owner.** The PR of
40
62
  each stands on the previous one, not on main, so one merged out of order drags along everything
41
63
  beneath it. The order is known to the one who branched and invisible to the one who merges:
@@ -113,16 +135,24 @@ application stops responding, and the reason is found from the history.
113
135
  PR is open, the work does not count as done: there is no review of it, and the person does not
114
136
  know about it. The PR is opened in the same turn in which the executor says the work is handed
115
137
  over — not in the next session and not on a reminder.
116
- - **A PR not ready to merge is marked as a draft.** An open PR reads as an invitation to merge, and
117
- a person presses merge without asking whether the work is finished. The draft separates two states
118
- that otherwise look the same: the change is put up for viewing — and the change is ready to go to
119
- the main branch. Everything that waits for a run, for rework or for an answer to a question is
120
- marked with it; the question is asked in the PR itself, not kept in the executor's head.
138
+ - **A PR that waits for something is marked as a draft, and one that waits for nothing opens
139
+ ready.** An open PR reads as an invitation to merge, and a person presses merge without asking
140
+ whether the work is finished. The draft separates two states that otherwise look the same: the
141
+ change is put up for viewing — and the change is ready to go to the main branch. It is set on
142
+ what waits for a run, for rework or for an answer to a question; the question is asked in the PR
143
+ itself, not kept in the executor's head. Where there is nothing to wait for, a draft costs an
144
+ extra turn and a locked button, and it shows the owner work in progress where the work is done.
145
+ - **Where the run comes from is part of the order of handing in, and the tree names it.** The
146
+ draft holds because the run is had on the PR itself: to get it the PR must be opened, and an
147
+ opened one already reads as an invitation. A tree whose pipeline wakes earlier — or does not wake
148
+ on this kind of PR at all — has nothing for the draft to wait for there, and the PR opens ready.
149
+ A law that named one source of the run would promise the other tree an order it cannot carry out.
121
150
  - **Lifting the draft is a separate turn, and with it the executor answers for readiness.** The
122
151
  draft is lifted when the checks have passed, no rework remains and the work matches what the task
123
152
  was created for. While it stands, the executor's silence means "not ready yet", and the person has
124
153
  to ask nothing; after it is lifted, silence means "can be merged", and the price of a mistake here
125
- is a change in the main branch.
154
+ is a change in the main branch. A PR opened ready carries the same answer, given at the minute of
155
+ opening.
126
156
  - **A PR about what was done stays true until the merge itself.** It describes the tree on the day
127
157
  it was written, and waits for review for days. In that time the main branch is merged into the
128
158
  branch, and the PR's statement about neighbouring files becomes false silently — no check reads PR
@@ -78,11 +78,18 @@ that "should work" and code that was checked look the same in the history.
78
78
  tool's settings, not bypassed in every place.** The bypass has to be repeated as many times as
79
79
  there are such places, and none of them says why: from outside it looks like the author's mistake,
80
80
  not a decision.
81
+ - **A check and a guard outrank the executor's judgement of their own work.** The executor judges
82
+ their own code with an interest: they remember the intent and see it instead of the result, while
83
+ the check reads only the result. A divergence is closed by an edit of the code, and the
84
+ executor's argument that the check is wrong is no argument at all — neither in their own decision
85
+ nor in a question to the owner.
81
86
  - **A red check means wrong code, not a wrong check.** A place taken out from under the check so
82
87
  that it goes quiet fixes the reading, not what the check pointed at: the code stays the same, and
83
- nobody has a signal about it any more. The known list is accumulated by the day the check is
84
- created and only shrinks; disagreement with the check itself is a question to the owner, not a
85
- line in the list.
88
+ nobody has a signal about it any more. There is one move out of a red check — fix what it pointed
89
+ at. Stopping the work and a question to the owner are not a move: the question names them a
90
+ choice that does not exist, and it costs as much as the fix. The known list is accumulated by the
91
+ day the check is created and only shrinks — it is not added to by the executor's decision, nor by
92
+ the word of the owner: a line in it silences the signal about code that stayed the same.
86
93
  - **The usefulness of a rule is confirmed by observing how it is used, not by an opinion about it.**
87
94
  A rule that was never opened and a rule half the work rests on look the same in the text — and
88
95
  what gets edited first is usually what was remembered, not what gets in the way. Observation is
@@ -98,6 +105,16 @@ that "should work" and code that was checked look the same in the history.
98
105
  the analysis — how many lines, of what kind, how their falsity is proven — and fixes the check
99
106
  itself. The known list is not used for this: it holds what was accepted, not the results of a
100
107
  broken check.
108
+ - **A check that did not find what to compare says so and does not count as matched.** An empty
109
+ input is three different states — there is no subject at all, the subject is declared and not
110
+ found, the declaration was not parsed — and merged into one they give a green where nothing was
111
+ compared. The lawful answer "there is nothing to compare" is said by a word in the text being
112
+ checked, not derived from an empty parse.
113
+ - **A declaration read by a check as text is written as a literal in the place of the
114
+ declaration.** What is moved into a constant or assembled by an expression such a check does not
115
+ see at all: the application works, the check is silent, and the miss shows itself by nothing.
116
+ Where a value has to be a literal, that is said in the same place where it is said what declares
117
+ it.
101
118
  - **A decision that depends on the current moment gets the moment from outside.** Otherwise it can
102
119
  be checked only by turning the clock, and a turned clock acts on everything that happens to be
103
120
  nearby: the check starts depending on what has no relation to it.
@@ -124,7 +141,8 @@ that "should work" and code that was checked look the same in the history.
124
141
  indistinguishable from one the tree never had at all: the run is green because nobody called it.
125
142
  The neighbouring article judges a place taken out from under the check — here it is not a place
126
143
  that is taken out but the whole check, and no trace remains in the code. The discrepancy is closed
127
- by what the check pointed at, and disagreement with the check itself is a question to the owner.
144
+ by what the check pointed at: the check is returned to the set, and the discrepancy under it is
145
+ fixed.
128
146
  - **A change to the look is checked at every layout threshold, not at one width.** Thresholds are
129
147
  the places where the layout changes, and a slip lives exactly there: on either side of the
130
148
  threshold the layout is assembled differently, and in the middle it looks correct. A change
@@ -96,7 +96,7 @@ command is rejected whole — the branch does not exist in it yet:
96
96
 
97
97
  ```bash
98
98
  ✗ git checkout -b 85-guest-token && git commit -m 'feat(admin): …'
99
- ✓ git checkout -b 85-guest-token
99
+ ✓ git checkout -b 85-guest-token <ветка эпика>
100
100
  ✓ git commit -F -
101
101
  ```
102
102
 
@@ -63,12 +63,15 @@ and merging two tasks into one afterwards is done by hand.
63
63
 
64
64
 
65
65
  ```bash
66
- npm run task:new -- --title 'Письма владельцу не уходят молча' \
66
+ npm run task:new -- --epic-of <номер эпика> --title 'Письма владельцу не уходят молча' \
67
67
  --label bug --label area:api --slug mail-owner-silence < описание.md
68
68
  ```
69
69
 
70
70
  The body is read from standard input, `--slug` is optional and goes only into the hint with the
71
- branch name. Author and assignee — the machine account; the command reads the token itself, from
71
+ branch name. The epic is named by `--epic-of`, and the command writes the line about it into the
72
+ body itself and prints the branch line from the branch of the epic; work outside an epic goes by
73
+ `--outside-epic '<слово владельца>'`, and without either of the two the call is refused before the
74
+ card is created. The epic itself is created by the same command with `--epic`. Author and assignee — the machine account; the command reads the token itself, from
72
75
  a file outside the repository.
73
76
 
74
77
  The script under this command is created by the project — the package does not ship it. What it
@@ -147,6 +150,10 @@ command is rejected whole — the branch does not exist in it yet:
147
150
  ✓ git commit -F -
148
151
  ```
149
152
 
153
+ The base is the epic branch, not the main branch — `git checkout -b <КЛЮЧ>-85-guest-token
154
+ <ветка эпика>`. From the main branch only the epic branch itself is taken: a task branched from it
155
+ carries into it what the epic has not finished.
156
+
150
157
  The name — `<КЛЮЧ>-<номер задачи>-<короткий-slug>`, the slug in lowercase Latin letters joined by
151
158
  hyphens. The delivery guard parses it on the spot and refuses a miss in the form before the first
152
159
  commit, and by the number it asks the board: the task must exist, be open, stand in the queue and
@@ -99,7 +99,7 @@ command is rejected whole — the branch does not exist in it yet:
99
99
 
100
100
  ```bash
101
101
  ✗ git checkout -b <КЛЮЧ>-85-guest-token && git commit -m 'feat(admin): …'
102
- ✓ git checkout -b <КЛЮЧ>-85-guest-token
102
+ ✓ git checkout -b <КЛЮЧ>-85-guest-token <ветка эпика>
103
103
  ✓ git commit -F -
104
104
  ```
105
105
 
@@ -2,10 +2,10 @@
2
2
  name: git-workflow-merge
3
3
  kind: pattern
4
4
  rule: git-workflow
5
- description: Pattern of rule git-workflow. Load when the main branch is merged into a task branch and a conflict is resolved — the merge order, handling by file kind, checking what was appended against the work queue, re-reading the body of the open PR. Branch and commit — pattern git-workflow-commit.
5
+ description: Pattern of rule git-workflow. Load when the base of a branch is merged into it and a conflict is resolved — the merge order, handling by file kind, checking what was appended against the work queue, re-reading the body of the open request. Branch and commit — pattern git-workflow-commit.
6
6
  ---
7
7
 
8
- # Merging the main branch into the task branch
8
+ # Merging the base of a branch into it
9
9
 
10
10
  Pattern of the rule `git-workflow`. What must be true — the law
11
11
  `docs/constitution/delivery.md`.
@@ -18,7 +18,10 @@ out in that tree.
18
18
  ## When to use
19
19
 
20
20
  - The PR is marked conflicting, and it must be brought back to a mergeable state.
21
- - The main branch moved ahead, and the task branch must be caught up before the checks.
21
+ - The base of the branch moved ahead, and the branch must be caught up before the checks: for a
22
+ task branch the base is the branch of its epic, for an epic branch the main one.
23
+ - The main branch moved ahead, and the whole epic must be caught up: the main branch is merged
24
+ into the epic branch, and the epic branch into the branches of its unfinished tasks.
22
25
  - A commit is carried over by a cherry-pick.
23
26
 
24
27
  ## Order
@@ -27,7 +30,7 @@ out in that tree.
27
30
  git fetch origin
28
31
  GIT_AUTHOR_NAME="<бот>" GIT_AUTHOR_EMAIL="<номер>+<бот>@users.noreply.github.com" \
29
32
  GIT_COMMITTER_NAME="<бот>" GIT_COMMITTER_EMAIL="<номер>+<бот>@users.noreply.github.com" \
30
- git merge origin/main --no-edit
33
+ git merge origin/<база> --no-edit
31
34
  git diff --name-only --diff-filter=U # what ended up in conflict
32
35
  ```
33
36
 
@@ -89,7 +92,7 @@ The task carries the same content — the branch's side is not carried over:
89
92
  git checkout --theirs docs/BACKLOG.md && git add docs/BACKLOG.md
90
93
  ```
91
94
 
92
- In a merge `--theirs` is the merged-in main branch and `--ours` is the task branch; in a rebase
95
+ In a merge `--theirs` is the merged-in base and `--ours` is the branch standing on it; in a rebase
93
96
  the sides swap. The wrong side taken erases work silently.
94
97
 
95
98
  ## Checks after the resolution
@@ -74,7 +74,7 @@ else's work item, and the second command goes by silently, leaving the PR bound
74
74
  ```bash
75
75
  AZURE_DEVOPS_EXT_PAT="$TOKEN" az repos pr create \
76
76
  --title '[86] Письмо владельцу с незаполненным адресом попадает в логи' \
77
- --source-branch 86-mail-owner-silence --target-branch main \
77
+ --source-branch 86-mail-owner-silence --target-branch <ветка эпика> \
78
78
  --work-items 86 --reviewers <владелец> --delete-source-branch true \
79
79
  --description 'Закрывает рабочий элемент 86.'
80
80
  ```