@rt-tools/agent-kit 0.34.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/assets/agents/goal-critic.md +9 -0
- package/assets/agents/product-strategist.md +5 -0
- package/assets/defaults/project.sh +39 -0
- package/assets/hooks/browser-guard-device-id.sh +1 -0
- package/assets/hooks/browser-guard-no-asking.sh +1 -0
- package/assets/hooks/browser-guard-no-listing.sh +1 -0
- package/assets/hooks/browser-guard-no-other-drivers.sh +1 -0
- package/assets/hooks/browser-guard-require-select.sh +1 -0
- package/assets/hooks/claim-guard.sh +1 -0
- package/assets/hooks/dev-server-guard.sh +1 -0
- package/assets/hooks/docs-guard.sh +1 -0
- package/assets/hooks/end-conversation-guard.sh +1 -0
- package/assets/hooks/epic-stop-guard.sh +1 -0
- package/assets/hooks/exam-guard.sh +5 -0
- package/assets/hooks/git-guard-delivery-draft.sh +23 -0
- package/assets/hooks/git-guard-delivery-folder.sh +25 -4
- package/assets/hooks/git-guard-delivery-signature.sh +19 -0
- package/assets/hooks/git-guard-delivery.sh +7 -18
- package/assets/hooks/git-guard-discard.sh +1 -0
- package/assets/hooks/git-guard-main.sh +1 -0
- package/assets/hooks/git-guard-no-verify.sh +1 -0
- package/assets/hooks/git-guard-push-ahead.sh +9 -0
- package/assets/hooks/git-guard-push-tests.sh +1 -0
- package/assets/hooks/grill-gate.sh +1 -0
- package/assets/hooks/guard-note.sh +11 -3
- package/assets/hooks/handover-mark.sh +37 -0
- package/assets/hooks/metric-marks.sh +233 -0
- package/assets/hooks/metric-send-start.sh +38 -0
- package/assets/hooks/observe.sh +103 -0
- package/assets/hooks/owner-corrections.sh +36 -0
- package/assets/hooks/prose-style-guard.sh +1 -0
- package/assets/hooks/pull-outcomes.sh +59 -0
- package/assets/hooks/push-set.sh +11 -1
- package/assets/hooks/qa-dataid-guard.sh +1 -0
- package/assets/hooks/rerun-guard.sh +1 -0
- package/assets/hooks/reuse-first-guard.sh +1 -0
- package/assets/hooks/role-calls.sh +120 -0
- package/assets/hooks/rule-source-guard.sh +16 -0
- package/assets/hooks/skill-gate.sh +11 -0
- package/assets/hooks/task-flow-draft-guard.sh +1 -0
- package/assets/hooks/task-flow-guard.sh +1 -0
- package/assets/hooks/tree-assignment-guard.sh +1 -0
- package/assets/hooks/turn-exit-epic.sh +24 -0
- package/assets/hooks/turn-exit-guard.sh +1 -21
- package/assets/hooks/waiting-turn-guard.sh +1 -0
- package/assets/hooks/window-fill-guard.sh +1 -0
- package/assets/hooks/work-start-guard.sh +1 -0
- package/assets/patterns/git-workflow-commit.azure.md +5 -3
- package/assets/patterns/git-workflow-commit.github.md +5 -3
- package/assets/patterns/git-workflow-commit.gitlab.md +5 -3
- package/assets/patterns/task-flow-close.md +5 -6
- package/assets/patterns/task-flow-cycle.md +72 -0
- package/assets/rules/task-flow.md +10 -9
- package/assets/samples/tasks/_template/plan.md +1 -0
- package/assets/templates/postmortem.md +2 -0
- package/bin/agent-kit.d.ts.map +1 -1
- package/bin/agent-kit.js +28 -0
- package/bin/agent-kit.js.map +1 -1
- package/lib/cargo.d.ts +35 -0
- package/lib/cargo.d.ts.map +1 -1
- package/lib/cargo.js +76 -0
- package/lib/cargo.js.map +1 -1
- package/lib/commands.d.ts +9 -0
- package/lib/commands.d.ts.map +1 -1
- package/lib/commands.js +32 -19
- package/lib/commands.js.map +1 -1
- package/lib/config.d.ts +5 -0
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +1 -0
- package/lib/config.js.map +1 -1
- package/lib/file-lock.d.ts +4 -0
- package/lib/file-lock.d.ts.map +1 -0
- package/lib/file-lock.js +23 -0
- package/lib/file-lock.js.map +1 -0
- package/lib/metric-lines.d.ts +20 -0
- package/lib/metric-lines.d.ts.map +1 -0
- package/lib/metric-lines.js +117 -0
- package/lib/metric-lines.js.map +1 -0
- package/lib/metric-send-mark.d.ts +52 -0
- package/lib/metric-send-mark.d.ts.map +1 -0
- package/lib/metric-send-mark.js +69 -0
- package/lib/metric-send-mark.js.map +1 -0
- package/lib/metric-send.d.ts +18 -0
- package/lib/metric-send.d.ts.map +1 -0
- package/lib/metric-send.js +226 -0
- package/lib/metric-send.js.map +1 -0
- package/lib/metric-usage.d.ts +34 -0
- package/lib/metric-usage.d.ts.map +1 -0
- package/lib/metric-usage.js +111 -0
- package/lib/metric-usage.js.map +1 -0
- package/lib/metrics.d.ts +92 -0
- package/lib/metrics.d.ts.map +1 -0
- package/lib/metrics.js +263 -0
- package/lib/metrics.js.map +1 -0
- package/lib/observations-cargo.d.ts +2 -0
- package/lib/observations-cargo.d.ts.map +1 -1
- package/lib/observations-cargo.js +1 -1
- package/lib/observations-cargo.js.map +1 -1
- package/lib/observations.d.ts +22 -2
- package/lib/observations.d.ts.map +1 -1
- package/lib/observations.js +40 -13
- package/lib/observations.js.map +1 -1
- package/lib/outcomes.d.ts +89 -0
- package/lib/outcomes.d.ts.map +1 -0
- package/lib/outcomes.js +274 -0
- package/lib/outcomes.js.map +1 -0
- package/lib/ship.js +1 -1
- package/lib/ship.js.map +1 -1
- package/lib/shipment.d.ts.map +1 -1
- package/lib/shipment.js +7 -1
- package/lib/shipment.js.map +1 -1
- package/lib/snapshot.d.ts +2 -0
- package/lib/snapshot.d.ts.map +1 -1
- package/lib/snapshot.js +6 -0
- package/lib/snapshot.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,6 +27,8 @@ npx agent-kit sync # разложить выбранное в docs/constitu
|
|
|
27
27
|
npx agent-kit doctor # что разложено, что отстало, чего не хватает
|
|
28
28
|
npx agent-kit adopt # отдать пакету файлы, лежащие на его путях не от него
|
|
29
29
|
npx agent-kit stats # чем пользовались, чем ни разу, обо что спотыкались
|
|
30
|
+
npx agent-kit metrics # отказы, повторы, мёртвые правила и вес входа за месяц
|
|
31
|
+
npx agent-kit send # отправить числа по дням: проверки и сессии делают это сами
|
|
30
32
|
npx agent-kit cost # сколько весит вход в работу, одно правило и весь слой
|
|
31
33
|
```
|
|
32
34
|
|
|
@@ -268,8 +270,7 @@ npx agent-kit init --laws access,delivery,verifiability
|
|
|
268
270
|
самого в ней нет — значение со слэшем не пишется вовсе.
|
|
269
271
|
|
|
270
272
|
```bash
|
|
271
|
-
npx agent-kit stats --days 3
|
|
272
|
-
npx agent-kit stats --json # то же машиночитаемо
|
|
273
|
+
npx agent-kit stats --days 3 --json # за отрезок, машиночитаемо; без довода — за три дня
|
|
273
274
|
```
|
|
274
275
|
|
|
275
276
|
Самая ценная строка сводки — не «чем пользовались», а **что разложено и не загружено ни разу**:
|
|
@@ -352,8 +353,7 @@ npx agent-kit enroll --token <токен> # положить токе
|
|
|
352
353
|
|
|
353
354
|
### Что для этого нужно
|
|
354
355
|
|
|
355
|
-
Наблюдения и сводка живут
|
|
356
|
-
человека. Приём — своя служба, а не чужая: она поднимается там, где решит владелец пакета.
|
|
356
|
+
Наблюдения и сводка живут на машине. Текст уходит по команде человека, числа дерево шлёт само (выключает `send: false`).
|
|
357
357
|
|
|
358
358
|
| Где | Что нужно |
|
|
359
359
|
| --- | --- |
|
|
@@ -372,8 +372,8 @@ npx agent-kit enroll --token <токен> # положить токе
|
|
|
372
372
|
репозитория: адрес по нему не восстанавливается, а у двух рабочих копий одного репозитория он
|
|
373
373
|
один. Репозитория нет — признак называется ключом `tree`.
|
|
374
374
|
|
|
375
|
-
Адреса нет, токена нет, токен отозван —
|
|
376
|
-
|
|
375
|
+
Адреса нет, токена нет, токен отозван — команда человека отказывает ненулевым кодом и называет, чего
|
|
376
|
+
не хватило. Тихий запуск пишет сбой в метку, его называют `agent-kit doctor` и начало сессии.
|
|
377
377
|
|
|
378
378
|
## Роли и конвейеры
|
|
379
379
|
|
|
@@ -9,6 +9,11 @@ You judge whether what was built is what the owner asked for. You answer **in th
|
|
|
9
9
|
You have neither `Write` nor `Edit`, and you change neither the code nor the texts. `Bash` is for
|
|
10
10
|
reading and for running what the result claims to do.
|
|
11
11
|
|
|
12
|
+
A copy a check needs goes into a directory named after you under the session's scratchpad, and
|
|
13
|
+
nothing is removed — neither by `rm` nor by a cleanup at the end: the scratchpad is shared with the
|
|
14
|
+
session that called you, and a removing command waits in the background for a permission nobody
|
|
15
|
+
answers.
|
|
16
|
+
|
|
12
17
|
A session writes its own plan, points and signs and then checks itself against them. Everything can
|
|
13
18
|
turn green while the goal stays unchecked. You are the check that does not stand on what the session
|
|
14
19
|
wrote.
|
|
@@ -43,6 +48,10 @@ own? What does it add that the owner did not ask for?
|
|
|
43
48
|
**Result.** For every requirement, what can the owner do now that they could not before, shown from
|
|
44
49
|
their side? What stands only in a branch, only in a text, or only on this machine?
|
|
45
50
|
|
|
51
|
+
**Cycle.** The prompt gives the metric of an edit, its direction, baseline and noise, and the report
|
|
52
|
+
after it. Over the same trees, did the number move past the noise in that direction? If not, the
|
|
53
|
+
verdict is «не сдвинулось», with both numbers. The executor's explanation of why is not evidence.
|
|
54
|
+
|
|
46
55
|
**PR description.** The prompt gives the description and the replies of the roles. Every "done" and
|
|
47
56
|
"reached" in the description is tried against the result. A word of a role that differs from its
|
|
48
57
|
reply is a miss, whatever the session's reason was.
|
|
@@ -11,6 +11,11 @@ You have neither `Write` nor `Edit`, and you change neither the code nor the tex
|
|
|
11
11
|
reading and for running the sign of a point: `git log`, `ls`, `grep`, `find`, `gh` reads, the tree's
|
|
12
12
|
read commands and the command a sign names.
|
|
13
13
|
|
|
14
|
+
A copy a sign needs goes into a directory named after you under the session's scratchpad, and
|
|
15
|
+
nothing is removed — neither by `rm` nor by a cleanup at the end: the scratchpad is shared with the
|
|
16
|
+
session that called you, and a removing command waits in the background for a permission nobody
|
|
17
|
+
answers.
|
|
18
|
+
|
|
14
19
|
## The points
|
|
15
20
|
|
|
16
21
|
- **A** — where the product stands now, by what the tree and the host show today.
|
|
@@ -361,6 +361,44 @@ rt_conflicting_pulls_default() {
|
|
|
361
361
|
printf '%s' "$state" | jq -r '.conflicting[]? | "#\(.number) \(.branch)"'
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
+
# The requests merged or closed since a day, for the package metrics: one JSON object per line. The
|
|
365
|
+
# default asks GitHub, and another hosting declares the function by the same shape, which is named in
|
|
366
|
+
# `hooks/pull-outcomes.sh`. A failing exit code means «nobody to ask», and such a tree is counted
|
|
367
|
+
# apart. The task comes from the title: the head of a revert request names the request, not the task.
|
|
368
|
+
# An epic is told by the label of its card, as the delivery guard tells it: a request carries none.
|
|
369
|
+
# A request never handed over counts apart, so the hosting is asked no more about it: one call per
|
|
370
|
+
# request made a first read of a busy tree outlive the report.
|
|
371
|
+
rt_pull_outcomes_default() {
|
|
372
|
+
command -v gh >/dev/null 2>&1 || return 3
|
|
373
|
+
command -v jq >/dev/null 2>&1 || return 3
|
|
374
|
+
list="$(gh pr list --state all --limit 1000 --search "closed:>=$1" \
|
|
375
|
+
--json number,state,headRefName,title,closedAt 2>/dev/null)" || return 4
|
|
376
|
+
printf '%s' "$list" | jq -c '.[] | select(.state != "OPEN")' | while IFS= read -r pull; do
|
|
377
|
+
number="$(printf '%s' "$pull" | jq -r '.number')"
|
|
378
|
+
head="$(printf '%s' "$pull" | jq -r '.headRefName')"
|
|
379
|
+
task="$(printf '%s' "$pull" | jq -r '(.title | capture("\\[[A-Za-z]+-(?<n>[0-9]+)\\]").n)? // empty')"
|
|
380
|
+
commits='[]'
|
|
381
|
+
labels='[]'
|
|
382
|
+
if ! command -v rt_handover_known >/dev/null 2>&1 || rt_handover_known "$head"; then
|
|
383
|
+
commits="$(gh api "repos/{owner}/{repo}/pulls/$number/commits?per_page=100" \
|
|
384
|
+
--jq '[.[] | {sha, tree: .commit.tree.sha, parents: (.parents | length)}]' 2>/dev/null)"
|
|
385
|
+
[ -n "$commits" ] || return 4
|
|
386
|
+
[ -z "$task" ] || labels="$(gh api "repos/{owner}/{repo}/issues/$task" --jq '[.labels[].name]' 2>/dev/null)"
|
|
387
|
+
fi
|
|
388
|
+
printf '%s' "$pull" | jq -c --argjson commits "$commits" --argjson labels "${labels:-[]}" \
|
|
389
|
+
--arg task "$task" --arg epic "${RT_BOARD_EPIC_LABEL:-}" '{
|
|
390
|
+
number,
|
|
391
|
+
commits: $commits,
|
|
392
|
+
head: .headRefName,
|
|
393
|
+
merged: (.state == "MERGED"),
|
|
394
|
+
closed: (.closedAt // "" | .[0:10]),
|
|
395
|
+
task: (if $task == "" then null else ($task | tonumber) end),
|
|
396
|
+
revert: (.title | startswith("Revert")),
|
|
397
|
+
epic: ($epic != "" and ($labels | index($epic) != null))
|
|
398
|
+
}'
|
|
399
|
+
done
|
|
400
|
+
}
|
|
401
|
+
|
|
364
402
|
# What counts as reinvention in this tree. One line per "pattern<tab>replacement". The patterns are
|
|
365
403
|
# narrow on purpose: the guard checks only NEW text, and a wide pattern would refuse an edit that
|
|
366
404
|
# creates nothing new.
|
|
@@ -408,6 +446,7 @@ rt_docs_pair_for() { rt_docs_pair_for_default "$@"; }
|
|
|
408
446
|
rt_lint_for() { rt_lint_for_default "$@"; }
|
|
409
447
|
rt_task_branch_ok() { rt_task_branch_ok_default "$@"; }
|
|
410
448
|
rt_task_branch_number() { rt_task_branch_number_default "$@"; }
|
|
449
|
+
rt_pull_outcomes() { rt_pull_outcomes_default "$@"; }
|
|
411
450
|
rt_reinvented_in() { rt_reinvented_in_default "$@"; }
|
|
412
451
|
rt_is_app_code() { rt_is_app_code_default "$@"; }
|
|
413
452
|
# The directory of the rules package sources in this tree, from the root. Empty — the tree does not
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
# The guard's name for the observations: it is written by the shared deny tail.
|
|
29
29
|
RT_GUARD_NAME=browser-guard-device-id
|
|
30
|
+
RT_GUARD_RULE=browser-verification
|
|
30
31
|
|
|
31
32
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
32
33
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
# Its own name in the observations: the refusal is recorded by the shared deny tail, not by the
|
|
22
22
|
# guard itself.
|
|
23
23
|
RT_GUARD_NAME=browser-guard-no-asking
|
|
24
|
+
RT_GUARD_RULE=browser-verification
|
|
24
25
|
|
|
25
26
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
26
27
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
# Its own name in the observations: the refusal is recorded by the shared deny tail, not by the
|
|
14
14
|
# guard itself.
|
|
15
15
|
RT_GUARD_NAME=browser-guard-no-listing
|
|
16
|
+
RT_GUARD_RULE=browser-verification
|
|
16
17
|
|
|
17
18
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
18
19
|
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
# Own name in the observations: the refusal is written by the shared refusal tail, not by the
|
|
24
24
|
# guard itself.
|
|
25
25
|
RT_GUARD_NAME=browser-guard-no-other-drivers
|
|
26
|
+
RT_GUARD_RULE=browser-verification
|
|
26
27
|
|
|
27
28
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
28
29
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
# Its own name in the observations: the refusal is written by the shared deny tail, not by the
|
|
24
24
|
# guard itself.
|
|
25
25
|
RT_GUARD_NAME=browser-guard-require-select
|
|
26
|
+
RT_GUARD_RULE=browser-verification
|
|
26
27
|
|
|
27
28
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
28
29
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
|
|
36
36
|
# Its own name in the observations: the refusal is written by the shared deny tail, not by the guard.
|
|
37
37
|
RT_GUARD_NAME=claim-guard
|
|
38
|
+
RT_GUARD_RULE=turn-conduct
|
|
38
39
|
|
|
39
40
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
40
41
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
# Its own name in the observations: the refusal is written by the shared deny tail, not by the
|
|
33
33
|
# guard itself.
|
|
34
34
|
RT_GUARD_NAME=dev-server-guard
|
|
35
|
+
RT_GUARD_RULE=browser-verification
|
|
35
36
|
|
|
36
37
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
37
38
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
# Its own name in the observations: the refusal is written by the shared deny tail, not by the
|
|
31
31
|
# guard itself.
|
|
32
32
|
RT_GUARD_NAME=docs-guard
|
|
33
|
+
RT_GUARD_RULE=doc-style
|
|
33
34
|
|
|
34
35
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
35
36
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
# Its own name in the observations: the refusal is recorded by the shared deny tail.
|
|
20
20
|
RT_GUARD_NAME=end-conversation-guard
|
|
21
|
+
RT_GUARD_RULE=turn-conduct
|
|
21
22
|
|
|
22
23
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
23
24
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
# Its own name in the observations: the refusal is written by the shared deny tail, not by the
|
|
25
25
|
# guard itself.
|
|
26
26
|
RT_GUARD_NAME=epic-stop-guard
|
|
27
|
+
RT_GUARD_RULE=task-flow
|
|
27
28
|
|
|
28
29
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
29
30
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
@@ -252,6 +252,11 @@ if [ "$ready" = "1" ]; then
|
|
|
252
252
|
esac
|
|
253
253
|
fi
|
|
254
254
|
|
|
255
|
+
# The verdict for the metrics. No mark file — nothing is recorded, and the guard judges as before.
|
|
256
|
+
# shellcheck disable=SC1091
|
|
257
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/metric-marks.sh" 2>/dev/null \
|
|
258
|
+
&& rt_exam_note "$verdict" "$(printf '%s' "$RT_HOOK_INPUT" | jq -r '.session_id // empty' 2>/dev/null)"
|
|
259
|
+
|
|
255
260
|
case "$verdict" in
|
|
256
261
|
passed) exit 0 ;;
|
|
257
262
|
failed)
|
|
@@ -16,6 +16,27 @@
|
|
|
16
16
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
17
17
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
18
18
|
|
|
19
|
+
# The handover for the metrics: the call passed every condition here. The next guard in the row may
|
|
20
|
+
# still refuse it, so the branch is only announced: `handover-mark.sh` keeps the sign after the call.
|
|
21
|
+
# No mark file — nothing is kept.
|
|
22
|
+
rt_delivery_handover() {
|
|
23
|
+
local pending
|
|
24
|
+
# shellcheck disable=SC1091
|
|
25
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/metric-marks.sh" 2>/dev/null || return 0
|
|
26
|
+
pending="$(rt_handover_pending_file "$(printf '%s' "$RT_HOOK_INPUT" | jq -r '.session_id // empty' 2>/dev/null)" "$cmd")"
|
|
27
|
+
[ -z "$pending" ] || printf '%s' "$1" > "$pending" 2>/dev/null
|
|
28
|
+
return 0
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
# A request that opens ready and names a reviewer is handed over at once. A draft is handed over when
|
|
32
|
+
# it leaves draft, and that guard demands a reviewer itself.
|
|
33
|
+
rt_delivery_open_handover() {
|
|
34
|
+
printf '%s' "$1" | grep -qE '[[:space:]](--draft|-d)([[:space:]=]|$)' && return 0
|
|
35
|
+
printf '%s' "$1" | grep -qE '[[:space:]](--reviewer|-r)([[:space:]=])' || return 0
|
|
36
|
+
rt_delivery_handover "$2"
|
|
37
|
+
return 0
|
|
38
|
+
}
|
|
39
|
+
|
|
19
40
|
rt_delivery_draft_ready() {
|
|
20
41
|
# --- leaving draft ----------------------------------------------------------------------
|
|
21
42
|
#
|
|
@@ -88,5 +109,7 @@ rt_delivery_draft_ready() {
|
|
|
88
109
|
command -v rt_delivery_ready_folder >/dev/null 2>&1 && rt_delivery_ready_folder "$pull_head"
|
|
89
110
|
|
|
90
111
|
deny_faults
|
|
112
|
+
# The head comes from the hosting: without its answer the number may name another branch.
|
|
113
|
+
[ -z "$pull_head" ] || rt_delivery_handover "$pull_head"
|
|
91
114
|
fi
|
|
92
115
|
}
|
|
@@ -71,10 +71,21 @@ rt_delivery_open_folder() {
|
|
|
71
71
|
_base="$(git merge-base "$main_branch" HEAD 2>/dev/null)"
|
|
72
72
|
[ -z "$_base" ] && return 0
|
|
73
73
|
|
|
74
|
-
# SC-AK-1249:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
# SC-AK-1249: a draft a plan of the branch named, still lying in the branch, would reach main
|
|
75
|
+
# unmerged. SC-AK-1296: a request into an epic or into a lower branch does not reach main, and
|
|
76
|
+
# the draft of an epic lives until its last task. The request of the epic is judged by the plans
|
|
77
|
+
# of all its tasks.
|
|
78
|
+
_into="$(rt_delivery_open_base)"
|
|
79
|
+
if [ "${_into:-$main_branch}" = "$main_branch" ]; then
|
|
80
|
+
while IFS= read -r _plan; do
|
|
81
|
+
[ -n "$_plan" ] || continue
|
|
82
|
+
_draft="$(rt_branch_plan_draft "${_plan%/plan.md}" "$_base")"
|
|
83
|
+
[ -n "$_draft" ] && [ -n "$(git ls-tree -d --name-only HEAD -- "${_draft%/}" 2>/dev/null)" ] \
|
|
84
|
+
&& fault "the branch carries the unmerged agreement «${_draft}» its plan named — merge its rules and scenarios into the domain spec, remove the directory by a commit and repeat. If the work is merged in parts, put the comment «# Task-folder-skip: <reason>» into the command."
|
|
85
|
+
done <<EOF
|
|
86
|
+
$(git log --format= --name-only "$_base..HEAD" -- "$tasks_dir/*/plan.md" 2>/dev/null | sort -u)
|
|
87
|
+
EOF
|
|
88
|
+
fi
|
|
78
89
|
|
|
79
90
|
[ -n "$archive_dir" ] || return 0
|
|
80
91
|
rt_folder_was_in_branch "$_base" "$_folder" || return 0
|
|
@@ -84,6 +95,16 @@ rt_delivery_open_folder() {
|
|
|
84
95
|
&& fault "the task folder was deleted, but the branch added nothing to «${archive_dir}». Deleting is cheaper than taking apart — and together with the folder the analysis of the request is gone, the only record of the words of the owner. Move what explains the decisions taken as one file with a telling name and repeat."
|
|
85
96
|
}
|
|
86
97
|
|
|
98
|
+
# The base the opening command names. Absent — the host takes the default branch: an empty answer.
|
|
99
|
+
rt_delivery_open_base() {
|
|
100
|
+
command -v perl >/dev/null 2>&1 || return 0
|
|
101
|
+
printf '%s' "$cmd" | perl -0ne '
|
|
102
|
+
if (/(?:^|\s)(?:--base|-B)(?:=|\s+)(?:"((?:[^"\\]|\\.)*)"|\x27([^\x27]*)\x27|(\S+))/s) {
|
|
103
|
+
print defined $1 ? $1 : (defined $2 ? $2 : $3);
|
|
104
|
+
}
|
|
105
|
+
' 2>/dev/null
|
|
106
|
+
}
|
|
107
|
+
|
|
87
108
|
# The draft agreement the plan of the branch named by the line `**Draft:** \`path\``. The plan is
|
|
88
109
|
# read from the history: by the time the PR opens the folder is taken apart, and the last commit
|
|
89
110
|
# touching the plan is the one that removed it — then its parent still holds the plan.
|
|
@@ -20,6 +20,25 @@
|
|
|
20
20
|
# for a word over the whole line, that is, into a refusal on every mention of the command.
|
|
21
21
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
22
22
|
|
|
23
|
+
rt_delivery_branch_signature() {
|
|
24
|
+
# The signature: the address of the machine account is declared by the tree, and the working
|
|
25
|
+
# copy does not know it — which means the very first commit will travel under someone else's
|
|
26
|
+
# signature, and after the push that is fixed only by a force push.
|
|
27
|
+
#
|
|
28
|
+
# A person the tree named in RT_HUMAN_EMAILS signs with their own mail lawfully: the push
|
|
29
|
+
# accepts it, and refusing it here left such a person no way to start a branch at all.
|
|
30
|
+
if [ -n "$commit_email" ]; then
|
|
31
|
+
tree_email="$(git config user.email 2>/dev/null)"
|
|
32
|
+
human_email=''
|
|
33
|
+
for one in ${RT_HUMAN_EMAILS:-}; do
|
|
34
|
+
[ "$tree_email" = "$one" ] && human_email=1 && break
|
|
35
|
+
done
|
|
36
|
+
[ -n "$tree_email" ] && [ "$tree_email" != "$commit_email" ] && [ -z "$human_email" ] \
|
|
37
|
+
&& fault "the working copy signs commits as «${tree_email}», while the tree declared the email of the machine account «${commit_email}». The very first commit leaves under a foreign signature: git config user.email \"${commit_email}\"."
|
|
38
|
+
fi
|
|
39
|
+
return 0
|
|
40
|
+
}
|
|
41
|
+
|
|
23
42
|
rt_delivery_signature() {
|
|
24
43
|
# --- the signature of a machine commit ----------------------------------------------------
|
|
25
44
|
#
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
|
|
41
41
|
# Its own name in the observations: the refusal is written by the shared deny tail, not here.
|
|
42
42
|
RT_GUARD_NAME=git-guard-delivery
|
|
43
|
+
RT_GUARD_RULE=git-workflow
|
|
43
44
|
|
|
44
45
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
45
46
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
@@ -243,6 +244,10 @@ check_task() {
|
|
|
243
244
|
return 0
|
|
244
245
|
}
|
|
245
246
|
|
|
247
|
+
# The signature of a new branch and of a push live in one helper, so it is sourced before both.
|
|
248
|
+
# shellcheck disable=SC1090
|
|
249
|
+
[ -f "$rt_hooks_dir/git-guard-delivery-signature.sh" ] && . "$rt_hooks_dir/git-guard-delivery-signature.sh" 2>/dev/null
|
|
250
|
+
|
|
246
251
|
# --- creating a branch -------------------------------------------------------------------
|
|
247
252
|
branch_arg=''
|
|
248
253
|
if printf '%s' "$cmd" | grep -qE '(^|[;&|[:space:]])git[[:space:]]+(checkout([[:space:]]+-[A-Za-z-]+)*[[:space:]]+-b|switch([[:space:]]+-[A-Za-z-]+)*[[:space:]]+-c)[[:space:]]'; then
|
|
@@ -296,21 +301,7 @@ if [ -n "$branch_arg" ]; then
|
|
|
296
301
|
fault "your ref origin/${main_branch} lags behind the remote one — ${local_head:0:8} against ${remote_head:0:8}. The branch will grow from yesterday tree, and the owner sees that at the opening of the request. Pull and repeat: git fetch origin."
|
|
297
302
|
fi
|
|
298
303
|
|
|
299
|
-
|
|
300
|
-
# copy does not know it — which means the very first commit will travel under someone else's
|
|
301
|
-
# signature, and after the push that is fixed only by a force push.
|
|
302
|
-
#
|
|
303
|
-
# A person the tree named in RT_HUMAN_EMAILS signs with their own mail lawfully: the push
|
|
304
|
-
# accepts it, and refusing it here left such a person no way to start a branch at all.
|
|
305
|
-
if [ -n "$commit_email" ]; then
|
|
306
|
-
tree_email="$(git config user.email 2>/dev/null)"
|
|
307
|
-
human_email=''
|
|
308
|
-
for one in ${RT_HUMAN_EMAILS:-}; do
|
|
309
|
-
[ "$tree_email" = "$one" ] && human_email=1 && break
|
|
310
|
-
done
|
|
311
|
-
[ -n "$tree_email" ] && [ "$tree_email" != "$commit_email" ] && [ -z "$human_email" ] \
|
|
312
|
-
&& fault "the working copy signs commits as «${tree_email}», while the tree declared the email of the machine account «${commit_email}». The very first commit leaves under a foreign signature: git config user.email \"${commit_email}\"."
|
|
313
|
-
fi
|
|
304
|
+
command -v rt_delivery_branch_signature >/dev/null 2>&1 && rt_delivery_branch_signature
|
|
314
305
|
|
|
315
306
|
deny_faults
|
|
316
307
|
fi
|
|
@@ -322,8 +313,6 @@ fi
|
|
|
322
313
|
# The subject lives in a helper next door — `git-guard-delivery-signature.sh`: the guard grew up to
|
|
323
314
|
# the length limit, and the signature is the most separate of its subjects. No helper — the
|
|
324
315
|
# signature is not judged, and the work goes on: the same fail-open as with the other conditions.
|
|
325
|
-
# shellcheck disable=SC1090
|
|
326
|
-
[ -f "$rt_hooks_dir/git-guard-delivery-signature.sh" ] && . "$rt_hooks_dir/git-guard-delivery-signature.sh" 2>/dev/null
|
|
327
316
|
command -v rt_delivery_signature >/dev/null 2>&1 && rt_delivery_signature
|
|
328
317
|
|
|
329
318
|
# --- the push into a merged branch -----------------------------------------------------------
|
|
@@ -484,7 +473,6 @@ fi
|
|
|
484
473
|
[ -f "$rt_hooks_dir/git-guard-delivery-body.sh" ] && . "$rt_hooks_dir/git-guard-delivery-body.sh" 2>/dev/null
|
|
485
474
|
command -v rt_delivery_pull_body >/dev/null 2>&1 && rt_delivery_pull_body
|
|
486
475
|
|
|
487
|
-
|
|
488
476
|
# The task folder is taken apart before the PR opens, not after the approval: the owner merges as
|
|
489
477
|
# soon as he sees green, and no room is left for a closing commit — three times in a row the folder
|
|
490
478
|
# travelled into the main branch without being taken apart. After the cleanup the progress guard
|
|
@@ -494,5 +482,6 @@ rt_delivery_open_folder
|
|
|
494
482
|
# Everything that did not come together is named here, all at once: up to this line the conditions
|
|
495
483
|
# were being collected, each of which used to refuse the call on its own.
|
|
496
484
|
deny_faults
|
|
485
|
+
command -v rt_delivery_open_handover >/dev/null 2>&1 && rt_delivery_open_handover "$cmd" "$branch"
|
|
497
486
|
|
|
498
487
|
exit 0
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
# in the way of work.
|
|
20
20
|
|
|
21
21
|
RT_GUARD_NAME=git-guard-discard
|
|
22
|
+
RT_GUARD_RULE=git-workflow
|
|
22
23
|
|
|
23
24
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
24
25
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
# Its own name in the observations: the refusal is written by the shared deny tail, not by the
|
|
18
18
|
# guard itself.
|
|
19
19
|
RT_GUARD_NAME=git-guard-main
|
|
20
|
+
RT_GUARD_RULE=git-workflow
|
|
20
21
|
|
|
21
22
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
22
23
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
# in the way of work.
|
|
27
27
|
|
|
28
28
|
RT_GUARD_NAME=git-guard-no-verify
|
|
29
|
+
RT_GUARD_RULE=git-workflow
|
|
29
30
|
|
|
30
31
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
31
32
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
@@ -38,6 +38,11 @@ command -v rt_push_checks >/dev/null 2>&1 || {
|
|
|
38
38
|
exit "$not_started"
|
|
39
39
|
}
|
|
40
40
|
command -v rt_push_check_heavy >/dev/null 2>&1 || rt_push_check_heavy() { return 1; }
|
|
41
|
+
# The line of a run for the metrics. No file — the checks run and record nothing.
|
|
42
|
+
# shellcheck disable=SC1091
|
|
43
|
+
[ -f "$rt_hooks_dir/metric-marks.sh" ] && . "$rt_hooks_dir/metric-marks.sh" 2>/dev/null
|
|
44
|
+
command -v rt_run_note >/dev/null 2>&1 || rt_run_note() { return 0; }
|
|
45
|
+
command -v rt_tree_sign >/dev/null 2>&1 || rt_tree_sign() { return 0; }
|
|
41
46
|
|
|
42
47
|
# A mark vouches for the tree of the head, and the checks run over the working copy: with edits
|
|
43
48
|
# outside the index the run would write marks for content that does not leave.
|
|
@@ -49,6 +54,7 @@ rt_push_mark_clean || {
|
|
|
49
54
|
base="$(rt_push_base "${RT_MAIN_BRANCH:-main}")"
|
|
50
55
|
skip_code="${RT_SKIP_CODE:-7}"
|
|
51
56
|
printf 'push ahead: base %s, tree %s\n' "${base:-none}" "$(git rev-parse --short 'HEAD^{tree}')"
|
|
57
|
+
sign="$(rt_tree_sign .)"
|
|
52
58
|
|
|
53
59
|
red=""
|
|
54
60
|
while IFS= read -r check; do
|
|
@@ -68,11 +74,14 @@ while IFS= read -r check; do
|
|
|
68
74
|
status=$?
|
|
69
75
|
took=$(($(date +%s) - started))
|
|
70
76
|
if [ "$status" -eq 0 ]; then
|
|
77
|
+
rt_run_note "$sign" "$started" green "$check"
|
|
71
78
|
rt_push_mark_put "$check" "$base" "$key_before"
|
|
72
79
|
printf '+ green in %ss: %s\n' "$took" "$check"
|
|
73
80
|
elif [ "$status" -eq "$skip_code" ]; then
|
|
81
|
+
rt_run_note "$sign" "$started" skipped "$check"
|
|
74
82
|
printf '~ nothing to look at: %s\n' "$check"
|
|
75
83
|
else
|
|
84
|
+
rt_run_note "$sign" "$started" red "$check"
|
|
76
85
|
red="${red}${red:+
|
|
77
86
|
}${check}"
|
|
78
87
|
printf '✗ red in %ss: %s\n%s\n' "$took" "$check" "$(printf '%s' "$out" | tail -n 25)"
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
|
|
36
36
|
# Its own name in the observations: the refusal is written by the shared deny tail, not by the guard.
|
|
37
37
|
RT_GUARD_NAME=git-guard-push-tests
|
|
38
|
+
RT_GUARD_RULE=git-workflow
|
|
38
39
|
|
|
39
40
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
40
41
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
|
|
37
37
|
# Its own name in the observations: the refusal is written by the shared deny tail, not by the guard.
|
|
38
38
|
RT_GUARD_NAME=grill-gate
|
|
39
|
+
RT_GUARD_RULE=task-flow
|
|
39
40
|
|
|
40
41
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
41
42
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
@@ -13,7 +13,10 @@
|
|
|
13
13
|
# voluntary and exact: a hook that counts its own refusals by itself — like the rules gate — does
|
|
14
14
|
# not set it, and the same event is not counted a second time.
|
|
15
15
|
#
|
|
16
|
-
#
|
|
16
|
+
# THE RULE. A line `RT_GUARD_RULE=<rule>` next to the name says which rule the guard enforces. A
|
|
17
|
+
# refusal after that rule was loaded in the session counts against the rule: its text taught nothing.
|
|
18
|
+
#
|
|
19
|
+
# WHAT IS RECORDED. The guard name, its rule and the session id. Cleaning the values and deciding whether to
|
|
17
20
|
# write at all is done by the observation record itself; here only the call is assembled.
|
|
18
21
|
#
|
|
19
22
|
# FAIL-OPEN. There may be no record at all — no file, the tree switched observations off, the
|
|
@@ -23,7 +26,7 @@
|
|
|
23
26
|
# A guard refusal into the observations. The name is taken from `RT_GUARD_NAME`, the session id
|
|
24
27
|
# from the hook input; without a name nothing is written.
|
|
25
28
|
rt_guard_note() {
|
|
26
|
-
local rt_gn_dir rt_gn_sid rt_gn_name
|
|
29
|
+
local rt_gn_dir rt_gn_sid rt_gn_name rt_gn_empty=''
|
|
27
30
|
# A default, not a bare read: a guard may be written to abort on an undeclared variable, and a
|
|
28
31
|
# record that reads it bare brings such a guard down whole — on every call, not on a refusal.
|
|
29
32
|
rt_gn_name="${RT_GUARD_NAME:-}"
|
|
@@ -37,7 +40,12 @@ rt_guard_note() {
|
|
|
37
40
|
rt_gn_sid="$(printf '%s' "${RT_HOOK_INPUT:-}" | jq -r '.session_id // empty' 2>/dev/null)"
|
|
38
41
|
|
|
39
42
|
if [ -n "$rt_gn_sid" ]; then
|
|
40
|
-
|
|
43
|
+
# shellcheck disable=SC1090
|
|
44
|
+
[ -f "$rt_gn_dir/metric-marks.sh" ] && . "$rt_gn_dir/metric-marks.sh" 2>/dev/null
|
|
45
|
+
command -v rt_refusal_empty >/dev/null 2>&1 \
|
|
46
|
+
&& rt_gn_empty="$(rt_refusal_empty "$rt_gn_name" "$rt_gn_sid" \
|
|
47
|
+
"$(printf '%s' "${RT_HOOK_INPUT:-}" | jq -c '.tool_input // empty' 2>/dev/null)")"
|
|
48
|
+
rt_note guard-deny "res=$rt_gn_name" "sid=$rt_gn_sid" "empty=$rt_gn_empty" "rule=${RT_GUARD_RULE:-}"
|
|
41
49
|
else
|
|
42
50
|
rt_note guard-deny "res=$rt_gn_name"
|
|
43
51
|
fi
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# rt-hook: PostToolUse Bash
|
|
3
|
+
# Requires: hooks/hook-input.sh, hooks/metric-marks.sh, hooks/git-guard-delivery.sh
|
|
4
|
+
#
|
|
5
|
+
# Keeps the sign of a handover after the call really ran. The delivery guard stands before the call,
|
|
6
|
+
# and a guard after it in the row may still refuse the request, so the guard only announces the
|
|
7
|
+
# branch. This hook turns the announcement into the sign. A call that failed leaves no sign.
|
|
8
|
+
#
|
|
9
|
+
# FAIL-OPEN: no input, no parser, no announcement — exit with zero and no output. This hook never
|
|
10
|
+
# refuses.
|
|
11
|
+
|
|
12
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
13
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || exit 0
|
|
14
|
+
|
|
15
|
+
rt_hook_read
|
|
16
|
+
[ -n "$RT_HOOK_INPUT" ] || exit 0
|
|
17
|
+
command -v jq >/dev/null 2>&1 || exit 0
|
|
18
|
+
|
|
19
|
+
cmd="$(rt_hook_cmd)"
|
|
20
|
+
case "$cmd" in
|
|
21
|
+
*pr*create* | *pr*ready* | *mr*create* | *mr*update*) ;;
|
|
22
|
+
*) exit 0 ;;
|
|
23
|
+
esac
|
|
24
|
+
|
|
25
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/metric-marks.sh" 2>/dev/null || exit 0
|
|
26
|
+
|
|
27
|
+
session="$(printf '%s' "$RT_HOOK_INPUT" | jq -r '.session_id // empty' 2>/dev/null)"
|
|
28
|
+
pending="$(rt_handover_pending_file "$session" "$cmd")"
|
|
29
|
+
[ -n "$pending" ] && [ -f "$pending" ] || exit 0
|
|
30
|
+
|
|
31
|
+
failed="$(printf '%s' "$RT_HOOK_INPUT" | jq -r '
|
|
32
|
+
(.tool_response | type) == "object"
|
|
33
|
+
and ((.tool_response.is_error // false) or (.tool_response.interrupted // false)
|
|
34
|
+
or ((.tool_response.exit_code // 0) != 0))' 2>/dev/null)"
|
|
35
|
+
[ "$failed" = true ] || rt_handover_mark "$(cat "$pending" 2>/dev/null)"
|
|
36
|
+
rm -f "$pending" 2>/dev/null
|
|
37
|
+
exit 0
|