@rt-tools/agent-kit 0.31.0 → 0.33.1

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 (46) hide show
  1. package/assets/checks/board.github.mjs +27 -0
  2. package/assets/checks/spec-anchors.mjs +13 -0
  3. package/assets/checks/task-new.github.mjs +24 -0
  4. package/assets/checks/tree-assignment.mjs +11 -3
  5. package/assets/defaults/gate-map.sh +4 -0
  6. package/assets/defaults/shell.sh +18 -5
  7. package/assets/hooks/dispatch.sh +8 -4
  8. package/assets/hooks/epic-stop-guard.sh +1 -1
  9. package/assets/hooks/git-guard-delivery-epic.sh +21 -0
  10. package/assets/hooks/git-guard-delivery-merged.sh +65 -0
  11. package/assets/hooks/git-guard-delivery.sh +8 -1
  12. package/assets/hooks/git-guard-tree-assignment.sh +1 -1
  13. package/assets/hooks/grill-gate-options.sh +50 -0
  14. package/assets/hooks/grill-gate.sh +9 -1
  15. package/assets/hooks/skill-gate-rearm.sh +18 -2
  16. package/assets/hooks/skill-gate.sh +10 -5
  17. package/assets/laws/mockups.needs-mockups.md +28 -0
  18. package/assets/patterns/dependencies-upgrade.md +5 -1
  19. package/assets/patterns/git-workflow-commit.azure.md +5 -1
  20. package/assets/patterns/git-workflow-commit.github.md +8 -1
  21. package/assets/patterns/git-workflow-commit.gitlab.md +5 -1
  22. package/assets/patterns/git-workflow-merge.md +12 -0
  23. package/assets/patterns/git-workflow-pr.azure.md +2 -0
  24. package/assets/patterns/git-workflow-pr.github.md +4 -0
  25. package/assets/patterns/git-workflow-pr.gitlab.md +2 -0
  26. package/assets/patterns/lib-layers-new.md +4 -0
  27. package/assets/patterns/mockups-measure.needs-mockups.md +28 -0
  28. package/assets/patterns/reuse-first-extend.md +5 -0
  29. package/assets/patterns/spec-driven-domain.md +4 -0
  30. package/assets/patterns/task-flow-archive.md +4 -1
  31. package/assets/patterns/task-flow-resume.md +6 -0
  32. package/assets/patterns/task-flow-start.md +32 -31
  33. package/assets/patterns/testing-e2e.md +15 -1
  34. package/assets/pitfalls/task-flow.md +4 -0
  35. package/assets/rules/component-structure.md +3 -0
  36. package/assets/rules/dependencies.md +3 -1
  37. package/assets/rules/deploy-flow.azure.md +4 -0
  38. package/assets/rules/deploy-flow.github.md +4 -0
  39. package/assets/rules/deploy-flow.gitlab.md +4 -0
  40. package/assets/rules/mockups.needs-mockups.md +80 -0
  41. package/assets/rules/reuse-first.md +3 -0
  42. package/assets/rules/task-flow.md +11 -12
  43. package/assets/rules/testing.md +5 -0
  44. package/assets/rules/typescript-conventions.md +9 -0
  45. package/assets/traits.json +15 -12
  46. package/package.json +1 -1
@@ -221,6 +221,19 @@ export function pullState(ref, options) {
221
221
  };
222
222
  }
223
223
 
224
+ /**
225
+ * Whether the branch has a merged PR and no open one: `{merged: <number> | null}`. The host deletes
226
+ * the branch of a merged PR, and a push into it recreates the branch with the commit nobody will
227
+ * merge. A branch reopened by a new PR after the merge is lawful work, so an open PR clears it.
228
+ */
229
+ export function pullMerged(branch, options) {
230
+ const pulls = ghJson(['pr', 'list', '--head', `${branch}`, '--state', 'all', '--limit', '20', '--json', 'number,state'], options) ?? [];
231
+ if (pulls.some((pull) => pull.state === 'OPEN')) {
232
+ return { merged: null };
233
+ }
234
+ return { merged: pulls.find((pull) => pull.state === 'MERGED')?.number ?? null };
235
+ }
236
+
224
237
  /**
225
238
  * How many commits the PR branch is behind main. The guard judges the base at the minute of
226
239
  * opening, and a PR stands for days: what was merged in that time is seen neither by it nor by a
@@ -401,6 +414,20 @@ if (isEntryPoint && process.argv[2] === 'pr') {
401
414
  }
402
415
  }
403
416
 
417
+ // The merged PR of a branch as one line of JSON, for the push refusal of the delivery guard.
418
+ if (isEntryPoint && process.argv[2] === 'merged' && process.argv[3]) {
419
+ try {
420
+ process.stdout.write(`${JSON.stringify(pullMerged(process.argv[3], { token: botToken() ?? undefined }))}\n`);
421
+ } catch (error) {
422
+ if (error instanceof OfflineError) {
423
+ process.stdout.write('{"offline":true}\n');
424
+ } else {
425
+ process.stdout.write(`${JSON.stringify({ error: String(error.message ?? error) })}\n`);
426
+ process.exit(1);
427
+ }
428
+ }
429
+ }
430
+
404
431
  // Own conflicting PRs as one line of JSON: `{"conflicting":[{"number":…,"branch":…}]}`.
405
432
  // The delivery guard calls it before letting new work be taken. A tree without a machine account
406
433
  // answers with an empty list: there is nobody to ask about.
@@ -151,6 +151,11 @@ function checkRuleImplementation(specFile, text, mapFile, heading = ['## Rules',
151
151
  const cell = cells[2].trim();
152
152
  rows.set(head, {
153
153
  anchors: [...cells[2].matchAll(ANCHOR)],
154
+ // A path-like token in backticks — a slash and an extension — whose symbol follows it
155
+ // without the colon inside the backticks: `file.ts` `symbol`, or `file.ts`:symbol. A
156
+ // bare path alone is lawful: prose names files in the same cell, and the whole tree
157
+ // turned red on such mentions when every one of them was judged.
158
+ bare: [...cells[2].matchAll(/`([\w./-]*\/[\w./-]*\.[A-Za-z]{2,10})`(?::[\p{L}_#]|\s*`#?[\p{L}_][\p{L}\p{N}_-]*`)/gu)],
154
159
  verdict: VERDICT.test(cell) && cell.length >= VERDICT_MIN,
155
160
  used: false,
156
161
  });
@@ -179,6 +184,14 @@ function checkRuleImplementation(specFile, text, mapFile, heading = ['## Rules',
179
184
  'or the verdict «Not carried out», «Not applicable», «Not checked» with a reason'
180
185
  );
181
186
  }
187
+ // A binding that lost the colon between the file and the symbol is not read as an anchor,
188
+ // and a row that still has other anchors passed in silence. Judged only in a row that has an
189
+ // anchor: a verdict row names files in prose, and there a bare path is lawful.
190
+ if (row.anchors.length) {
191
+ for (const [, token] of row.bare) {
192
+ report(mapFile, `the colon between the file and the symbol is lost: \`${token}\``);
193
+ }
194
+ }
182
195
  for (const [, path, symbol] of row.anchors) {
183
196
  if (!exists(path)) {
184
197
  report(mapFile, `the binding leads nowhere: there is no file \`${path}\``);
@@ -194,6 +194,30 @@ const labels = args.epic && !args.labels.includes(EPIC_LABEL) ? [...args.labels,
194
194
  */
195
195
  const token = botToken() ?? undefined;
196
196
 
197
+ /**
198
+ * A label that is not in the repository breaks the creation whole: the hosting refuses the call
199
+ * with one line about a label that could not be added, and neither a card nor a number exists. The
200
+ * labels are asked before the creation, and the refusal names the missing ones, the existing ones
201
+ * and the fact that no task was created. The list that cannot be read — offline, no right — does
202
+ * not hold the creation: the hosting will refuse by itself if the label is really missing.
203
+ */
204
+ if (labels.length > 0) {
205
+ let existing = null;
206
+ try {
207
+ existing = ghJson(['label', 'list', '--repo', `${OWNER}/${REPO}`, '--limit', '200', '--json', 'name'], { token }).map(
208
+ (label) => label.name
209
+ );
210
+ } catch {
211
+ existing = null;
212
+ }
213
+ const missing = existing === null ? [] : labels.filter((label) => !existing.includes(label));
214
+ if (missing.length > 0) {
215
+ fail(
216
+ `no task was created: the labels ${missing.map((label) => `«${label}»`).join(', ')} are not in the repository. Existing: ${existing.join(', ')}`
217
+ );
218
+ }
219
+ }
220
+
197
221
  /**
198
222
  * The plan of the epic and the line about it in the card body.
199
223
  *
@@ -80,6 +80,14 @@ export function assignmentOf(root = ROOT) {
80
80
  return name === null ? null : (assignments(root).find((row) => row.tree === name) ?? null);
81
81
  }
82
82
 
83
+ /**
84
+ * What lifts the refusal, said in the refusal itself. Told only «the owner moves the assignment»,
85
+ * the executor stopped after a direct order and asked the owner a second time: the order already
86
+ * was that move.
87
+ */
88
+ const OWNER_WORD =
89
+ "A message of the owner in this conversation that names this work is that move: write the row with their words and go on; ask only when no message of theirs names it";
90
+
83
91
  /**
84
92
  * What is wrong with taking work under this epic — or an empty string where nothing is.
85
93
  *
@@ -105,15 +113,15 @@ export function assignmentFault(epic, root = ROOT) {
105
113
  const row = assignmentOf(root);
106
114
 
107
115
  if (row === null) {
108
- return `the table ${CONFIG.assignmentsFile} holds no row for the copy «${name}». Ask the owner what this copy leads; work is not taken by guesswork`;
116
+ return `the table ${CONFIG.assignmentsFile} holds no row for the copy «${name}». Ask the owner what this copy leads; work is not taken by guesswork. ${OWNER_WORD}`;
109
117
  }
110
118
 
111
119
  if (row.epic === null) {
112
- return `no epic is assigned to the copy «${name}» — the row in ${CONFIG.assignmentsFile} holds a dash. Ask the owner what to take; an epic chosen by oneself is not an order`;
120
+ return `no epic is assigned to the copy «${name}» — the row in ${CONFIG.assignmentsFile} holds a dash. Ask the owner what to take; an epic chosen by oneself is not an order. ${OWNER_WORD}`;
113
121
  }
114
122
 
115
123
  if (epic !== null && epic !== undefined && String(epic) !== '' && Number(epic) !== row.epic) {
116
- return `the copy «${name}» leads the epic ${key}-${row.epic}, and this work belongs to ${key}-${epic}. Someone else's epic is not taken by one's own decision: the owner moves the assignment`;
124
+ return `the copy «${name}» leads the epic ${key}-${row.epic}, and this work belongs to ${key}-${epic}. Someone else's epic is not taken by one's own decision: the owner moves the assignment. ${OWNER_WORD}`;
117
125
  }
118
126
 
119
127
  return '';
@@ -235,6 +235,10 @@ skill_for_default() {
235
235
  # The check through the browser is the only area where the rule is needed not for a file
236
236
  # edit but for a tool: what lies there is not the files but the stand and the coordinates.
237
237
  browser) printf '%s\n' 'browser-verification' ;;
238
+ # A call of the design tool needs the rule of mockups for the same reason: what lies there
239
+ # is a sheet, not a file. A tree without the rule is not refused: the gate skips a missing
240
+ # one.
241
+ design) printf '%s\n' 'mockups' ;;
238
242
  esac
239
243
 
240
244
  return 0
@@ -14,8 +14,11 @@
14
14
  # from one laid down by the tool. The analysis — `2026-08-15-guard-denied-shell-wrote-anyway.md`.
15
15
  #
16
16
  # The list is wide on purpose, and the price of that is named: a read command that carries the name
17
- # of an interpreter will be refused on a par with an edit command. A narrow list would cost more — a
18
- # missed form of writing brings back the whole bypass, and it can be found only by a miss.
17
+ # of an interpreter with a document on input will be refused on a par with an edit command. A narrow
18
+ # list would cost more — a missed form of writing brings back the whole bypass, and it can be found
19
+ # only by a miss. Code given to an interpreter as an argument is narrowed: it is a write only when
20
+ # it holds a call that writes, and the price there is the opposite one — a write by a rarer call
21
+ # passes unseen.
19
22
  #
20
23
  # Deletion and moving stand in the list on purpose, not by oversight. Removing a file is an edit
21
24
  # more destructive than any write. What was written is visible in the tree and rolls back, while
@@ -56,11 +59,21 @@ rt_shell_writes_default() {
56
59
  # demand for the shared-code rule without editing anything in it. Over two tasks such refusals
57
60
  # came to about fifteen, and part of them fell on commands that wrote nothing.
58
61
  #
59
- # An interpreter's body comes in two kinds, and both remain a write: a document on input and
60
- # code as an argument.
62
+ # An interpreter's body comes in two kinds. A document on input stays a write: it is a script
63
+ # nobody has read. Code as an argument is a write only when the code holds a call that writes —
64
+ # `writeFile`, `appendFile`, `fs.write`, a stream opened for writing, an opening for `w` or `a`,
65
+ # `write_text`, `write_bytes`, a rename, a copy or a removal. Code without one is a read, and
66
+ # the paths it names are not judged as write targets: a read of one script from the package
67
+ # manifest by `node -e` demanded the dependencies rule. The price of this is named: a write by a
68
+ # call that is not in the list passes unseen, and the list can only grow by a miss.
61
69
  interp='(^|[|;&(]|[[:space:]])(python3?|node|ruby|deno|bun|php|perl)'
70
+ if printf '%s' "$cleaned" | grep -Eq "${interp}([[:space:]][^|]*)?<<"; then
71
+ return 0
72
+ fi
62
73
  if printf '%s' "$cleaned" | grep -Eq \
63
- "${interp}([[:space:]][^|]*)?<<|${interp}([[:space:]]+-[^[:space:]]*)*[[:space:]]+(-e|--eval|-c|-p|--print)([[:space:]]|\$)"; then
74
+ "${interp}([[:space:]]+-[^[:space:]]*)*[[:space:]]+(-e|--eval|-c|-p|--print)([[:space:]]|\$)" \
75
+ && printf '%s' "$cleaned" | grep -Eq \
76
+ 'writeFile|appendFile|fs\.write|createWriteStream|\.write\(|write_text|write_bytes|open\([^)]*,[[:space:]]*["'"'"'][wa]|renameSync|copyFile|cpSync|unlinkSync|rmSync|os\.(rename|remove|unlink)|shutil\.|File\.(write|open)'; then
64
77
  return 0
65
78
  fi
66
79
 
@@ -107,17 +107,21 @@ EOF
107
107
  fi
108
108
  if [ "$code" -ne 0 ]; then
109
109
  if [ -n "$branch_out" ]; then
110
- printf '%s\n' "$branch_out"
110
+ refusal="$branch_out"
111
111
  elif [ -n "$said_err" ]; then
112
- printf '%s\n' "$said_err"
112
+ refusal="$said_err"
113
113
  else
114
114
  # The branch exited non-zero and said nothing by either stream. From the outside that
115
115
  # is indistinguishable from a refusal on the merits, and there is nothing to fix: nobody
116
116
  # knows which file is broken. So the dispatcher names it itself, otherwise nothing says
117
117
  # anything about a broken branch.
118
- printf 'The guard %s exited with code %s and printed nothing: the file looks broken.\n' \
119
- "$(basename "$branch")" "$code"
118
+ refusal="$(printf 'The guard %s exited with code %s and printed nothing: the file looks broken.' \
119
+ "$(basename "$branch")" "$code")"
120
120
  fi
121
+ printf '%s\n' "$refusal"
122
+ # At code 2 the agent is given only the error stream, and the output stream is dropped:
123
+ # a refusal printed only above reached the executor empty. The text goes to both.
124
+ printf '%s\n' "$refusal" >&2
121
125
  exit "$code"
122
126
  fi
123
127
 
@@ -121,7 +121,7 @@ if [ -z "$checks" ] || [ "$checks" = null ]; then
121
121
  checks=tools
122
122
  fi
123
123
 
124
- reason="Refused: the epic is over — every task of it is merged or handed over by a request, and this call takes new work. The end of an epic is a stop: print the table by «npm run epic:table» (or «node $checks/epic-table.mjs»), tell the owner what was done on each task and what confirms it, and say outright that the session waits for their orders. New work is taken by their word, not by the count of what is left: their message or their answer to a menu that names the number of this work releases the call."
124
+ reason="Refused: the epic is over — every task of it is merged or handed over by a request, and this call takes new work. The end of an epic is a stop: print the table by «npm run epic:table» (or «node $checks/epic-table.mjs»), tell the owner what was done on each task and what confirms it, and say outright that the session waits for their orders. New work is taken by their word, not by the count of what is left: their message or their answer to a menu that names the number of this work releases the call. A new epic the owner has declared needs the bypass line in the calls that create its card, its tasks and its branch; once the branch of the new epic is taken, the guard reads that epic and stops refusing."
125
125
 
126
126
  # shellcheck disable=SC1090
127
127
  [ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
@@ -36,6 +36,19 @@ rt_epic_branch() {
36
36
  printf '%s' "$_found"
37
37
  }
38
38
 
39
+ # Whether the epic is already merged into the main branch: a merge commit of the remote main branch
40
+ # names it by the key and the number (`RT-12`) — in the branch name of a merge of the host or in the
41
+ # title of the request. The number is matched whole, so `RT-1` does not match `RT-12`. Success — the
42
+ # epic is merged. No remote main branch, or no such commit, is not merged: the refusal that follows
43
+ # is the former one.
44
+ rt_epic_is_merged() {
45
+ _num="$1"
46
+ [ -n "$_num" ] || return 1
47
+ git rev-parse --verify --quiet "origin/${main_branch}" >/dev/null 2>&1 || return 1
48
+ [ -n "$(git log "origin/${main_branch}" --merges -n 1 -E \
49
+ --grep="(^|[^0-9A-Za-z])[A-Za-z]+-${_num}([^0-9]|\$)" --format=%H 2>/dev/null)" ]
50
+ }
51
+
39
52
  # The base of a new task branch against the branch of its epic.
40
53
  #
41
54
  # The task branch is taken from the branch of the epic, and a branch taken from the main one leaves
@@ -58,6 +71,14 @@ rt_epic_base() {
58
71
  _epic_branch="$(rt_epic_branch "$_epic")"
59
72
  case "$_epic_branch" in
60
73
  '')
74
+ # An epic that is already merged has no branch in the remote: the host deletes it on the
75
+ # merge, and a task left behind in it would be demanded a base nobody has — then a push
76
+ # recreates the branch with a merge nobody reviews. The merge of the epic is recognised
77
+ # by a merge commit of the main branch that names the epic; the task then grows from
78
+ # the main branch.
79
+ if rt_epic_is_merged "$_epic"; then
80
+ return 0
81
+ fi
61
82
  fault "the task belongs to the epic #${_epic}, and no branch of that epic is in the remote. The branch of the epic is taken before the first of its tasks and sent at once — a branch that exists only on one machine is a base nobody else has."
62
83
  return 0
63
84
  ;;
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env bash
2
+ # The push into a branch whose PR is merged, for the delivery guard.
3
+ #
4
+ # NOT a guard: it has no `rt-hook:` declaration and hooks into no agent event. The delivery guard
5
+ # sources it after `deny` — one tier of its verdict, kept apart because the guard is at its length
6
+ # limit.
7
+ #
8
+ # The owner merged a PR, the host deleted its branch, and minutes later the executor committed an
9
+ # incident analysis into the same branch and pushed it. The host answered `new branch`: the branch
10
+ # came back with one commit over the merged work, and no PR would ever merge it. The pattern of the
11
+ # commit already asked for the PR state before such a push, and only memory held it.
12
+ #
13
+ # What is judged is the branch the push sends: the destination of the last refspec, or the checked
14
+ # out branch when the command names none. The branch has a merged PR and no open one — the push is
15
+ # refused. A branch reopened by a new PR after the merge is lawful work and passes.
16
+ #
17
+ # It expects `$cmd` and `$root` to be set and `deny` to be declared.
18
+ #
19
+ # FAIL-OPEN: no profile function, no network, a dry run, a command that is not a push — silence.
20
+
21
+ . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
22
+ . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
23
+
24
+ # The number of the merged PR of a branch that has no open PR; empty output means "not merged". A
25
+ # tree on another host declares the function in its profile; this default asks the work queue
26
+ # helper. It lives here because the defaults file is at its length limit. No node, no helper, no
27
+ # network — a failing exit code, and the push is not judged.
28
+ command -v rt_pull_merged >/dev/null 2>&1 || rt_pull_merged() {
29
+ local _state
30
+ command -v node >/dev/null 2>&1 || return 1
31
+ [ -f "${RT_BOARD_HELPER:-tools/board.mjs}" ] || return 1
32
+ _state="$(node "${RT_BOARD_HELPER:-tools/board.mjs}" merged "$1" 2>/dev/null)" || return 1
33
+ printf '%s' "$_state" | jq -e 'has("merged")' >/dev/null 2>&1 || return 1
34
+ printf '%s' "$_state" | jq -r '.merged // empty'
35
+ }
36
+
37
+ rt_delivery_merged() {
38
+ local _rest _target _merged
39
+ printf '%s' "$cmd" | grep -qE "${RT_CMD_BOUND}git([[:space:]]|\$)" || return 0
40
+ printf '%s' "$cmd" | grep -q -- '--dry-run' && return 0
41
+ _rest="$(printf '%s' "$cmd" | sed -E 's/git[[:space:]]+stash[[:space:]]+push/git stash/g' \
42
+ | sed -nE 's/.*(^|[[:space:]])push([[:space:]]+(.*))?$/\3/p' | head -1)"
43
+ printf '%s' "$cmd" | sed -E 's/git[[:space:]]+stash[[:space:]]+push/git stash/g' \
44
+ | grep -qE '(^|[[:space:]])push([[:space:]]|$)' || return 0
45
+ # The words after `push` up to the end of the call: options are skipped, the first word is the
46
+ # remote, the second — the refspec, whose destination is the branch.
47
+ _target="$(printf '%s' "$_rest" | sed -E 's/[;&|].*$//' | awk '{
48
+ n = 0
49
+ for (i = 1; i <= NF; i++) {
50
+ if ($i ~ /^-/) continue
51
+ n++
52
+ if (n == 2) { spec = $i }
53
+ }
54
+ sub(/^\+/, "", spec); sub(/^.*:/, "", spec); sub(/^refs\/heads\//, "", spec)
55
+ print spec
56
+ }')"
57
+ [ -n "$_target" ] && [ "$_target" != HEAD ] || _target="$(git -C "$root" branch --show-current 2>/dev/null)"
58
+ [ -n "$_target" ] || return 0
59
+ [ "$_target" = "${main_branch:-main}" ] && return 0
60
+
61
+ _merged="$(cd "$root" && rt_pull_merged "$_target" 2>/dev/null)" || return 0
62
+ [ -n "$_merged" ] || return 0
63
+
64
+ deny "BLOCKED: the PR #${_merged} of the branch «${_target}» is merged, and the branch has no open PR. The host deleted the branch with the merge, and this push recreates it with commits nobody will merge. Take a new branch from the fresh base and move the commits there: git fetch origin && git checkout -b <new branch> origin/<base> && git cherry-pick <commits>."
65
+ }
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
  # rt-hook: PreToolUse Bash|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
3
- # Requires: hooks/git-guard-delivery-folder.sh, hooks/git-guard-delivery-epic.sh, hooks/git-guard-tree-assignment.sh, hooks/git-guard-delivery-conflict.sh, hooks/profile-check.sh, hooks/deny-tail.sh, hooks/guard-note.sh
3
+ # Requires: hooks/git-guard-delivery-merged.sh, hooks/git-guard-delivery-folder.sh,hooks/git-guard-delivery-epic.sh, hooks/git-guard-tree-assignment.sh, hooks/git-guard-delivery-conflict.sh, hooks/profile-check.sh, hooks/deny-tail.sh, hooks/guard-note.sh
4
4
  # Delivery guard. PreToolUse on creating a branch, on the push and on opening a PR.
5
5
  #
6
6
  # The delivery law demands three things nothing usually checks: an edit starts from a task visible
@@ -319,6 +319,13 @@ fi
319
319
  && . "$rt_hooks_dir/git-guard-delivery-signature.sh" 2>/dev/null
320
320
  command -v rt_delivery_signature >/dev/null 2>&1 && rt_delivery_signature
321
321
 
322
+ # --- the push into a merged branch -----------------------------------------------------------
323
+ # The helper next door — `git-guard-delivery-merged.sh`. No helper — the push is not judged by it.
324
+ # shellcheck disable=SC1090
325
+ [ -f "$rt_hooks_dir/git-guard-delivery-merged.sh" ] \
326
+ && . "$rt_hooks_dir/git-guard-delivery-merged.sh" 2>/dev/null
327
+ command -v rt_delivery_merged >/dev/null 2>&1 && rt_delivery_merged
328
+
322
329
  # --- leaving draft ---------------------------------------------------------------------------
323
330
  # The subject lives in a helper next door — `git-guard-delivery-draft.sh`, by the same technique as
324
331
  # the signature. No helper — leaving draft is not judged, and the work goes on.
@@ -71,7 +71,7 @@ rt_assignment_stale() {
71
71
  # a missing field and for `false`, that is, exactly for the state this refusal is written for.
72
72
  case "$(printf '%s' "$_state" | jq -r 'if .open == false then "false" else "" end' 2>/dev/null)" in
73
73
  false)
74
- fault "${_what} is not taken: the epic assigned to this copy is closed — the assignment outlived it. Ask the owner for a new one and write it into the table; an epic chosen instead of the closed one is not an order."
74
+ fault "${_what} is not taken: the epic assigned to this copy is closed — the assignment outlived it. Ask the owner for a new one and write it into the table; an epic chosen instead of the closed one is not an order. A message of the owner in this conversation that names this work is that new assignment: write the row with their words and go on; ask only when no message of theirs names it."
75
75
  ;;
76
76
  esac
77
77
  }
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env bash
2
+ # A part of the fourth sign of the conversation guard: after a refused menu a list of options in
3
+ # prose is a question too. NOT a guard: it has no `rt-hook:` declaration and hooks into no agent
4
+ # event. The conversation guard sources it — it was moved out when the guard crossed the file
5
+ # length limit.
6
+ #
7
+ # After a refused menu the executor gave the same options as a numbered list with no question mark
8
+ # and ended the turn: the sign knew prose only by «?», and the list went out as an ordinary reply.
9
+ # In a turn where the menu was refused, a numbered list of two or more items under a line ending
10
+ # with a colon is a question too. Outside such a turn a list is not judged: many ordinary reports
11
+ # carry one, and a refusal on each would teach to strip lists from replies.
12
+ #
13
+ # It expects `$transcript` and `$question_text` to be set; it returns zero when the turn ends with
14
+ # such a list after a refused menu, and non-zero otherwise.
15
+ #
16
+ # FAIL-OPEN: no turn record, no parser — the list is not a question.
17
+
18
+ rt_grill_options_asked() {
19
+ local menu_refused options_re
20
+ menu_refused="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r '
21
+ def is_input:
22
+ .type == "user"
23
+ and ((.isCompactSummary // false) | not)
24
+ and ((.isMeta // false) | not)
25
+ and (((.message.content // []) | if type == "array"
26
+ then ([.[] | select(.type == "tool_result")] | length)
27
+ else 0 end) == 0);
28
+ def asks_menu:
29
+ .type == "assistant" and ((.message.content // []) | any(.[];
30
+ .type == "tool_use" and .name == "AskUserQuestion"));
31
+ def refused:
32
+ .type == "user" and ((.message.content // []) | if type == "array"
33
+ then any(.[]; .type == "tool_result" and (.is_error // false))
34
+ else false end);
35
+ (map(is_input) | rindex(true)) as $i
36
+ | (if $i == null then . else .[$i + 1:] end) as $turn
37
+ | [range(0; ($turn | length) - 1) as $k
38
+ | select(($turn[$k] | asks_menu) and ($turn[$k + 1] | refused))]
39
+ | if length > 0 then "yes" else "no" end
40
+ ' 2>/dev/null)"
41
+ [ "$menu_refused" = "yes" ] || return 1
42
+
43
+ options_re='^[[:space:]]*[0-9]+[.)][[:space:]]'
44
+ printf '%s\n' "$question_text" | awk -v re="$options_re" '
45
+ /:[[:space:]]*$/ { lead = 1; items = 0; next }
46
+ lead && $0 ~ re { items++; if (items >= 2) found = 1; next }
47
+ lead && /^[[:space:]]*$/ { next }
48
+ { lead = 0; items = 0 }
49
+ END { exit found ? 0 : 1 }'
50
+ }
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bash
2
- # Requires: hooks/deny-tail.sh, hooks/turn-exit-patterns.sh, hooks/grill-gate-bypass.sh
2
+ # Requires: hooks/deny-tail.sh, hooks/turn-exit-patterns.sh, hooks/grill-gate-bypass.sh, hooks/grill-gate-options.sh
3
3
  # rt-hook: Stop
4
4
  # The conversation guard: the owner is not asked a question until the laws and rules have been read
5
5
  # within the same turn. It judges two events, and that is not duplication; the second is declared
@@ -388,11 +388,16 @@ if [ -n "$done_marker" ]; then
388
388
  | join("\n")
389
389
  ' 2>/dev/null)"
390
390
  fi
391
+ # After a refused menu a list of options in prose is a question too: the helper next door.
392
+ # shellcheck disable=SC1090
393
+ [ -f "$rt_hooks_dir/grill-gate-options.sh" ] && . "$rt_hooks_dir/grill-gate-options.sh" 2>/dev/null
391
394
  asks="no"
392
395
  if [ -n "$tool" ]; then
393
396
  asks="yes"
394
397
  elif printf '%s\n' "$question_text" | grep -qE '\?[[:space:]]*$'; then
395
398
  asks="yes"
399
+ elif command -v rt_grill_options_asked >/dev/null 2>&1 && rt_grill_options_asked; then
400
+ asks="yes"
396
401
  fi
397
402
  marked="no"
398
403
  case "$question_text" in
@@ -402,6 +407,9 @@ if [ -n "$done_marker" ]; then
402
407
  reason="BLOCKED by grill-gate: a guard refused in this turn, and the question to the owner carries nothing done without the answer.
403
408
 
404
409
  A refusal removes the step, not the task. Do the mechanical part of the blocker first — what the linter's fix mode repairs, what the refusal names as fixable — then ask only the decision that is left. The question leaves with the line «$done_marker …» naming the working commands of this turn after the last refusal: an edit of a file or a command that changes the tree. A read or a status command does not count."
410
+ [ -n "$tool" ] && reason="${reason}
411
+
412
+ The same question in prose does not walk around this refusal: the menu and prose are judged alike, a list of options included. Fix the menu — add the line and a working command — and send it again."
405
413
 
406
414
  # shellcheck disable=SC1090
407
415
  [ -f "$rt_hooks_dir/deny-tail.sh" ] && . "$rt_hooks_dir/deny-tail.sh" 2>/dev/null
@@ -21,7 +21,18 @@ input="$RT_HOOK_INPUT"
21
21
  sid="$(printf '%s' "$input" | jq -r '.session_id // empty' 2>/dev/null)"
22
22
  [ -z "$sid" ] && exit 0
23
23
 
24
- rm -f "${TMPDIR:-/tmp}/claude-skill-gate/${sid}.loaded" 2>/dev/null
24
+ record="${TMPDIR:-/tmp}/claude-skill-gate/${sid}.loaded"
25
+
26
+ # The names the session had loaded are read before the record is removed. The gate asks for one rule
27
+ # per refusal, and a session that does not know which rules it had loaded meets them one refusal at
28
+ # a time: one edit after a compaction went through six refusals in a row. An empty or missing record
29
+ # gives no names, and the line stays as it was.
30
+ loaded=""
31
+ if [ -s "$record" ]; then
32
+ loaded="$(awk 'NF && !seen[$0]++ { printf "%s%s", (n++ ? ", " : ""), $0 }' "$record" 2>/dev/null)"
33
+ fi
34
+
35
+ rm -f "$record" 2>/dev/null
25
36
 
26
37
  # The re-arming is told to the session in words.
27
38
  #
@@ -29,6 +40,11 @@ rm -f "${TMPDIR:-/tmp}/claude-skill-gate/${sid}.loaded" 2>/dev/null
29
40
  # the gate answers that they were not — and the session spends a turn finding out which of the two
30
41
  # is right. A turn was spent that way four times in one session. The line removes the contradiction:
31
42
  # the rule text is no longer in the context, which is why it is asked for again.
32
- jq -n '{hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:"The rules gate is armed anew: the compaction carried the text of the rules themselves out of the session, and every area will ask for its rule once more. The former loading does not count — load the rule and work on."}}' 2>/dev/null
43
+ context="The rules gate is armed anew: the compaction carried the text of the rules themselves out of the session, and every area will ask for its rule once more. The former loading does not count — load the rule and work on."
44
+ if [ -n "$loaded" ]; then
45
+ context="${context} Loaded before the compaction: ${loaded}. Load in one turn every one of them that the current stage touches, before the first edit."
46
+ fi
47
+
48
+ jq -n --arg c "$context" '{hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:$c}}' 2>/dev/null
33
49
 
34
50
  exit 0
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bash
2
- # rt-hook: PreToolUse Edit|Write|MultiEdit|Bash|mcp__webstorm__create_new_file|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool|mcp__claude-in-chrome__.*
2
+ # rt-hook: PreToolUse Edit|Write|MultiEdit|Bash|mcp__webstorm__create_new_file|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool|mcp__claude-in-chrome__.*|mcp__figma__use_figma
3
3
  # Requires: hooks/deny-tail.sh
4
4
  # The rules gate: it does not let a file be edited until the rule it falls under has been loaded.
5
5
  #
@@ -25,9 +25,10 @@
25
25
  # override is loaded second and may call the default back — `skill_for_default`. There is neither
26
26
  # — the gate passes everything: an empty gate is better than a gate that refuses at random.
27
27
  #
28
- # The call kind is `edit`, `bash` or `browser`. Browser verification is the only area where a rule
29
- # is needed not for a file edit but for a tool: what lies there is not the files but the stand and
30
- # the coordinates.
28
+ # The call kind is `edit`, `bash`, `browser` or `design`. Browser verification and the design tool
29
+ # are the areas where a rule is needed not for a file edit but for a tool: what lies there is not
30
+ # the files but the stand and the coordinates, or the sheet of mockups. A rule the tree lacks is not
31
+ # demanded, so the design kind costs a tree without mockups nothing.
31
32
  #
32
33
  # FAIL-OPEN: any error and any unrecognised path let the edit through (exit 0). A broken gate has
33
34
  # no right to stop the work altogether.
@@ -137,6 +138,10 @@ EOF
137
138
  req="$(skill_for browser "$tool" "" 2>/dev/null)"
138
139
  kind="browser"
139
140
  ;;
141
+ mcp__figma__use_figma)
142
+ req="$(skill_for design "$tool" "" 2>/dev/null)"
143
+ kind="design"
144
+ ;;
140
145
  *) exit 0 ;;
141
146
  esac
142
147
 
@@ -214,7 +219,7 @@ fi
214
219
  # itself. The rule whole stays the second move — for whoever finds the article not enough.
215
220
  # shellcheck disable=SC1090
216
221
  [ -f "$rt_hooks_dir/rule-article.sh" ] && . "$rt_hooks_dir/rule-article.sh" 2>/dev/null
217
- if [ "$kind" != "command" ] && [ "$kind" != "browser" ] && command -v rt_rule_article_heads >/dev/null 2>&1; then
222
+ if [ "$kind" != "command" ] && [ "$kind" != "browser" ] && [ "$kind" != "design" ] && command -v rt_rule_article_heads >/dev/null 2>&1; then
218
223
  article="$(rt_rule_article_heads "$root/$rules_dir/${req}/SKILL.md" "$target" 2>/dev/null)"
219
224
  if [ -n "$article" ]; then
220
225
  reason="Refused by the rules gate. This edit falls under the articles of the rule «${req}»:
@@ -0,0 +1,28 @@
1
+ # Law on mockups
2
+
3
+ What the owner sees before the code is written. The owner reads a screen by its picture, and a
4
+ picture that does not match the screen makes every detail of the code read as broken layout.
5
+
6
+ **Revision:** 2026-10-15
7
+
8
+ ## Articles
9
+
10
+ - **An approved mockup is the source of truth for how a screen looks.** Where mockups exist, a
11
+ change of the look starts with a change of the mockup. The changed mockup is shown to the owner,
12
+ and the code is written only after their approval. An agreement in words does not replace the
13
+ mockup: the owner reads the screen by the picture. A detail the code adds past the mockup reads to
14
+ the owner as broken layout, however correct the text behind it.
15
+ - **Mockups are kept in step with the screens they draw.** A mockup that lags behind the code no
16
+ longer says what is right, and the next change is checked against a wrong picture. A finding along
17
+ the way that changes the look goes to the mockup first, and only then into the code.
18
+ - **A mockup makes a layout claim, and the claim is measured.** A frame is checked by numbers, the
19
+ way a page is: what the eye misses on a screenshot — buttons of one row off one line, frames
20
+ overlapping on the sheet — is read from the node coordinates before the owner sees the frames.
21
+ - **A mockup of behaviour the product already has starts from the description of that behaviour.**
22
+ A screen on a sheet looks like work without code, but how a payment is taken or which fields a
23
+ form holds is already written down and carried out. The description is read before the first
24
+ frame.
25
+
26
+ ## Open questions
27
+
28
+ None.
@@ -31,7 +31,11 @@ stop the install.
31
31
  ## Order
32
32
 
33
33
  1. `package.json` — exact numbers, not a single `^` or `~`.
34
- 2. `pnpm install`; the snapshot goes in the same commit.
34
+ 2. `pnpm install`; the snapshot goes in the same commit. Then `pnpm install --frozen-lockfile`, in
35
+ every repository the edit goes to. Tests, the build and the linter run on modules already
36
+ installed and do not read the snapshot: a range in the declaration against an exact number in
37
+ the snapshot is found only by the strict install, and in a release pipeline that is after the
38
+ merge.
35
39
  3. The styling properties the tree reads from the package are checked against the new version by
36
40
  a command, not by a look: a removed property makes the declaration invalid, not wrong, and
37
41
  every check stays green. Every name from `var(--<prefix>-…)` in the tree is searched for in
@@ -147,7 +147,7 @@ GIT_COMMITTER_NAME="<бот>" GIT_COMMITTER_EMAIL="<почта бота>" \
147
147
 
148
148
  The subject — `type(scope): description`. Types: `feat`, `fix`, `refactor`, `docs`, `style`,
149
149
  `test`, `chore`, `perf`. Scopes are the tree's own, listed in `implementation.md`. A full stop
150
- at the end of the subject is not accepted.
150
+ at the end of the subject is not accepted. The letter case is checked as well, by the `subject-case` rule of the commit check: a word in capitals, such as a file name, can trip it, so the allowed case is read in the commit check settings before the subject is written.
151
151
 
152
152
  The line `AB#<номер>` in the commit body attaches it to the work item. It does not replace the
153
153
  attachment of the PR itself: the commit is linked to the item, and the work queue reads the PR's
@@ -162,6 +162,10 @@ is mandatory:
162
162
  Docs-skip: правка только в тестах хука, зеркала у него нет
163
163
  ```
164
164
 
165
+ The guard looks for the `Docs-skip` line in the command text only. A message read from a file by
166
+ `git commit -F <file>` is invisible to it and the commit is refused; the body goes inside the command,
167
+ as in `git commit -F -` with the text after it.
168
+
165
169
  ## Common misses
166
170
 
167
171
  - **An audit right after adding answers "no" when the card already stands.** The work queue gives
@@ -204,7 +204,7 @@ GIT_COMMITTER_NAME="<бот>" GIT_COMMITTER_EMAIL="<номер>+<бот>@users.n
204
204
 
205
205
  The subject — `type(scope): description`. Types: `feat`, `fix`, `refactor`, `docs`, `style`,
206
206
  `test`, `chore`, `perf`. Scopes: `site`, `admin`, `api`, `common`, `proto`, `deploy`. A full stop
207
- at the end of the subject is not accepted; the length — up to 150 characters.
207
+ at the end of the subject is not accepted; the length — up to 150 characters. The letter case is checked as well, by the `subject-case` rule of the commit check: a word in capitals, such as a file name, can trip it, so the allowed case is read in the commit check settings before the subject is written.
208
208
 
209
209
  ```
210
210
  feat(<область>): availability calendar with season prices
@@ -235,6 +235,10 @@ is mandatory:
235
235
  Docs-skip: правка только в тестах хука, зеркала у него нет
236
236
  ```
237
237
 
238
+ The guard looks for the `Docs-skip` line in the command text only. A message read from a file by
239
+ `git commit -F <file>` is invisible to it and the commit is refused; the body goes inside the command,
240
+ as in `git commit -F -` with the text after it.
241
+
238
242
  ## Common misses
239
243
 
240
244
  - **An amend goes through the same hooks as a commit.** The flag that skips the commit hooks is not
@@ -285,3 +289,6 @@ Docs-skip: правка только в тестах хука, зеркала у
285
289
  with a zero exit. The defaults are sourced first, and the line count is compared with the last
286
290
  push before the run.
287
291
  - The owner's edit takes neither the token nor the variables — they are only for machine work.
292
+ - A commit into the branch of a merged PR reaches no one: the host deleted the branch, and a push
293
+ creates it anew with an answer `new branch`. The delivery guard refuses such a push and names the
294
+ merged PR. The commit moves to a new branch from the fresh base by `git cherry-pick`.