@rt-tools/agent-kit 0.23.0 → 0.26.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 +8 -2
- package/assets/agents/business-analyst.md +51 -50
- package/assets/agents/conscience.md +37 -35
- package/assets/agents/project-manager.md +49 -48
- package/assets/agents/prose-editor.md +31 -29
- package/assets/agents/qa-engineer.md +50 -48
- package/assets/agents/rules-reviewer.md +63 -58
- package/assets/agents/skill-curator.md +83 -78
- package/assets/agents/spec-critic.md +34 -29
- package/assets/agents/spec-writer.md +35 -32
- package/assets/agents/strict-teacher.md +39 -37
- package/assets/checks/archive-age.mjs +48 -28
- package/assets/checks/archive-prune.mjs +16 -14
- package/assets/checks/board-epics.github.mjs +75 -41
- package/assets/checks/board-folders.mjs +61 -0
- package/assets/checks/board-gh.github.mjs +35 -26
- package/assets/checks/board-long-work.github.mjs +24 -24
- package/assets/checks/board-paths.github.mjs +21 -16
- package/assets/checks/board-runs.github.mjs +45 -43
- package/assets/checks/board-titles.github.mjs +19 -17
- package/assets/checks/board.github.mjs +150 -128
- package/assets/checks/check-archive-age.mjs +23 -19
- package/assets/checks/check-board.github.mjs +179 -157
- package/assets/checks/check-descriptions.mjs +30 -29
- package/assets/checks/check-doc-paths.mjs +104 -82
- package/assets/checks/check-dupes.mjs +84 -80
- package/assets/checks/check-file-size.mjs +79 -70
- package/assets/checks/check-glossary.mjs +47 -37
- package/assets/checks/check-hook-scope.mjs +30 -27
- package/assets/checks/check-lib-layers.mjs +22 -21
- package/assets/checks/check-profile-drift.mjs +48 -43
- package/assets/checks/check-prose-style.mjs +125 -33
- package/assets/checks/check-push-gate.mjs +53 -50
- package/assets/checks/check-reuse.mjs +50 -40
- package/assets/checks/check-schema-drift.mjs +87 -83
- package/assets/checks/check-specs.mjs +155 -134
- package/assets/checks/check-state-next.mjs +66 -52
- package/assets/checks/check-states.mjs +32 -30
- package/assets/checks/check-styles.mjs +52 -51
- package/assets/checks/check-turn-map.mjs +54 -46
- package/assets/checks/lib-boundaries.mjs +32 -30
- package/assets/checks/lib-common.mjs +30 -29
- package/assets/checks/lib-domains.mjs +34 -34
- package/assets/checks/lib-manifests.mjs +17 -15
- package/assets/checks/lib-reexports.mjs +18 -18
- package/assets/checks/rt-kit-checks.config.mjs +174 -142
- package/assets/checks/signals.mjs +43 -39
- package/assets/checks/spec-anchors.mjs +114 -87
- package/assets/checks/spec-common.mjs +128 -84
- package/assets/checks/spec-contract.mjs +30 -30
- package/assets/checks/spec-proposed.mjs +27 -24
- package/assets/checks/spec-scenarios.mjs +51 -28
- package/assets/checks/task-new.github.mjs +85 -56
- package/assets/commands/feedback.md +65 -59
- package/assets/commands/next-session.md +64 -57
- package/assets/commands/skill-curator.md +83 -79
- package/assets/defaults/gate-map.sh +115 -91
- package/assets/defaults/project.sh +228 -178
- package/assets/defaults/shell.sh +85 -65
- package/assets/defaults/turn-map.md +45 -44
- package/assets/docs/GLOSSARY.md +142 -65
- package/assets/hooks/browser-device-id.sh +12 -12
- package/assets/hooks/browser-guard-device-id.sh +46 -14
- package/assets/hooks/browser-guard-no-asking.sh +5 -4
- package/assets/hooks/browser-guard-no-listing.sh +12 -11
- package/assets/hooks/browser-guard-no-other-drivers.sh +48 -42
- package/assets/hooks/browser-guard-require-select.sh +34 -23
- package/assets/hooks/claim-guard.sh +62 -56
- package/assets/hooks/commit-msg.sh +11 -10
- package/assets/hooks/conscience-guard.sh +91 -45
- package/assets/hooks/constitution-index.sh +16 -16
- package/assets/hooks/deny-tail.sh +28 -26
- package/assets/hooks/dev-server-guard.sh +46 -43
- package/assets/hooks/dispatch.sh +84 -39
- package/assets/hooks/docs-guard.sh +105 -86
- package/assets/hooks/exam-guard.sh +146 -84
- package/assets/hooks/git-guard-delivery-conflict.sh +38 -36
- package/assets/hooks/git-guard-delivery-draft.sh +85 -0
- package/assets/hooks/git-guard-delivery-folder.sh +50 -43
- package/assets/hooks/git-guard-delivery-signature.sh +88 -52
- package/assets/hooks/git-guard-delivery.sh +207 -253
- package/assets/hooks/git-guard-main.sh +65 -26
- package/assets/hooks/git-guard-push-tests.sh +133 -75
- package/assets/hooks/glossary-load.sh +23 -22
- package/assets/hooks/grill-gate-ask.sh +12 -11
- package/assets/hooks/grill-gate.sh +94 -87
- package/assets/hooks/guard-note.sh +20 -19
- package/assets/hooks/handoff-entry-guard.sh +26 -24
- package/assets/hooks/handoff-write.sh +74 -67
- package/assets/hooks/hook-input.sh +70 -50
- package/assets/hooks/lint-after-edit.sh +95 -61
- package/assets/hooks/observe.sh +28 -26
- package/assets/hooks/override-write-guard.sh +23 -21
- package/assets/hooks/postmortem-guard.sh +42 -39
- package/assets/hooks/profile-check.sh +22 -20
- package/assets/hooks/proposal-guard.sh +57 -49
- package/assets/hooks/prose-style-guard.sh +19 -17
- package/assets/hooks/qa-dataid-guard.sh +52 -49
- package/assets/hooks/rerun-guard.sh +31 -30
- package/assets/hooks/reuse-first-guard.sh +108 -87
- package/assets/hooks/roles.sh +14 -14
- package/assets/hooks/rule-article.sh +36 -34
- package/assets/hooks/rule-source-guard.sh +52 -36
- package/assets/hooks/skill-gate-layers.sh +59 -57
- package/assets/hooks/skill-gate-rearm.sh +15 -8
- package/assets/hooks/skill-gate.sh +89 -81
- package/assets/hooks/skill-loaded.sh +6 -6
- package/assets/hooks/sql-guard-parse.sh +68 -66
- package/assets/hooks/sql-guard-request.sh +48 -46
- package/assets/hooks/sql-guard-target.sh +57 -51
- package/assets/hooks/sql-guard-write.sh +84 -79
- package/assets/hooks/sql-guard.sh +52 -47
- package/assets/hooks/stand-login-guard.sh +104 -0
- package/assets/hooks/task-context-load.sh +60 -55
- package/assets/hooks/task-flow-context.sh +87 -69
- package/assets/hooks/task-flow-draft-guard.sh +55 -48
- package/assets/hooks/task-flow-guard.sh +67 -64
- package/assets/hooks/turn-entry-load.sh +39 -32
- package/assets/hooks/turn-exit-guard.sh +256 -204
- package/assets/hooks/turn-exit-patterns.sh +53 -0
- package/assets/hooks/utf8.sh +11 -11
- package/assets/hooks/waiting-turn-guard.sh +94 -94
- package/assets/hooks/window-fill-guard.sh +70 -62
- package/assets/hooks/work-start-guard.sh +52 -49
- package/assets/hooks/write-targets.sh +115 -30
- package/assets/laws/autonomous-work.md +29 -27
- package/assets/laws/code-structure.md +31 -30
- package/assets/laws/delivery.md +148 -137
- package/assets/laws/entity-editing.md +52 -50
- package/assets/laws/entity-models.md +14 -13
- package/assets/laws/frontend-application.md +39 -38
- package/assets/laws/lib-imports.md +27 -27
- package/assets/laws/lists.md +31 -29
- package/assets/laws/navigation.md +37 -37
- package/assets/laws/observability.md +41 -40
- package/assets/laws/project-documentation.md +106 -99
- package/assets/laws/reuse-first.md +31 -29
- package/assets/laws/shared-code.md +27 -27
- package/assets/laws/verifiability.md +131 -114
- package/assets/laws/work-conduct.md +250 -250
- package/assets/patterns/admin-lists-screen.md +72 -69
- package/assets/patterns/admin-nav-item.md +51 -46
- package/assets/patterns/angular-patterns-state.md +32 -31
- package/assets/patterns/api-layer-pair.md +33 -31
- package/assets/patterns/autonomous-work-run.md +50 -49
- package/assets/patterns/browser-verification-measure.md +143 -67
- package/assets/patterns/browser-verification-stand.md +181 -128
- package/assets/patterns/component-structure-new.md +51 -42
- package/assets/patterns/dependencies-upgrade.md +55 -39
- package/assets/patterns/doc-style-human.md +93 -0
- package/assets/patterns/doc-style-sweep.md +82 -79
- package/assets/patterns/doc-style-trace.md +87 -81
- package/assets/patterns/doc-style-write.md +130 -122
- package/assets/patterns/entity-aside.md +77 -63
- package/assets/patterns/entity-models-new.md +37 -37
- package/assets/patterns/entity-store.md +33 -33
- package/assets/patterns/git-workflow-commit.azure.md +94 -75
- package/assets/patterns/git-workflow-commit.github.md +153 -129
- package/assets/patterns/git-workflow-commit.gitlab.md +96 -78
- package/assets/patterns/git-workflow-docker.md +165 -147
- package/assets/patterns/git-workflow-freshness.md +45 -45
- package/assets/patterns/git-workflow-merge.md +99 -86
- package/assets/patterns/git-workflow-migration.md +54 -52
- package/assets/patterns/git-workflow-pr-ready.md +57 -56
- package/assets/patterns/git-workflow-pr.azure.md +126 -121
- package/assets/patterns/git-workflow-pr.github.md +179 -175
- package/assets/patterns/git-workflow-pr.gitlab.md +138 -131
- package/assets/patterns/git-workflow-restart.md +35 -31
- package/assets/patterns/git-workflow-secrets.md +80 -73
- package/assets/patterns/git-workflow-stack.md +131 -106
- package/assets/patterns/lib-layers-move.md +62 -53
- package/assets/patterns/lib-layers-new.md +59 -45
- package/assets/patterns/observability-record.md +72 -67
- package/assets/patterns/platform-access-di.md +31 -29
- package/assets/patterns/reuse-first-extend.md +66 -61
- package/assets/patterns/shared-code-new.md +39 -38
- package/assets/patterns/spec-driven-domain.md +161 -151
- package/assets/patterns/spec-driven-rule.md +179 -168
- package/assets/patterns/spec-driven-sweep.md +41 -39
- package/assets/patterns/status-report-table.github.md +37 -36
- package/assets/patterns/styling-bem-component.md +42 -42
- package/assets/patterns/styling-bem-layout.md +39 -34
- package/assets/patterns/styling-bem-sheet.md +59 -58
- package/assets/patterns/task-flow-archive.md +222 -215
- package/assets/patterns/task-flow-close.md +215 -203
- package/assets/patterns/task-flow-handoff.md +154 -145
- package/assets/patterns/task-flow-resume.md +138 -133
- package/assets/patterns/task-flow-start.md +204 -192
- package/assets/patterns/testing-e2e.md +103 -92
- package/assets/patterns/testing-unit.md +77 -70
- package/assets/patterns/ts-procedure.md +32 -29
- package/assets/patterns/turn-entry-map.md +50 -48
- package/assets/pitfalls/agent-kit.md +152 -141
- package/assets/pitfalls/doc-style.md +96 -91
- package/assets/pitfalls/git-workflow.azure.md +49 -46
- package/assets/pitfalls/git-workflow.github.md +264 -234
- package/assets/pitfalls/git-workflow.gitlab.md +49 -45
- package/assets/pitfalls/spec-driven.md +73 -71
- package/assets/pitfalls/styling-bem.md +46 -40
- package/assets/pitfalls/task-flow.md +262 -246
- package/assets/pitfalls/testing.md +99 -92
- package/assets/pitfalls/turn-conduct.md +96 -81
- package/assets/rules/angular-patterns.md +81 -80
- package/assets/rules/api-layer.md +77 -74
- package/assets/rules/autonomous-work.md +75 -74
- package/assets/rules/browser-verification.md +223 -188
- package/assets/rules/component-structure.md +72 -69
- package/assets/rules/dependencies.md +74 -67
- package/assets/rules/deploy-flow.azure.md +118 -108
- package/assets/rules/deploy-flow.github.md +145 -135
- package/assets/rules/deploy-flow.gitlab.md +120 -110
- package/assets/rules/doc-style.md +209 -148
- package/assets/rules/entity-conventions.needs-admin.md +81 -79
- package/assets/rules/entity-models.md +73 -70
- package/assets/rules/git-workflow.azure.md +224 -228
- package/assets/rules/git-workflow.github.md +250 -242
- package/assets/rules/git-workflow.gitlab.md +218 -217
- package/assets/rules/lib-layers.md +85 -86
- package/assets/rules/lists.md +101 -97
- package/assets/rules/navigation.md +78 -78
- package/assets/rules/observability.needs-app.md +165 -153
- package/assets/rules/platform-access.md +76 -75
- package/assets/rules/reuse-first.md +153 -137
- package/assets/rules/shared-code.md +82 -79
- package/assets/rules/spec-driven.md +272 -260
- package/assets/rules/status-report.md +55 -58
- package/assets/rules/styling-bem.md +83 -72
- package/assets/rules/task-flow.md +282 -270
- package/assets/rules/testing.md +224 -188
- package/assets/rules/turn-conduct.md +255 -258
- package/assets/rules/turn-entry.md +92 -87
- package/assets/rules/typescript-conventions.md +94 -88
- package/assets/samples/specs/_template/spec.md +47 -47
- package/assets/samples/tasks/_template/grill.md +20 -20
- package/assets/samples/tasks/_template/plan.md +32 -30
- package/assets/samples/tasks/_template/progress.md +16 -16
- package/assets/skills/agent-kit-extend.md +129 -113
- package/assets/skills/agent-kit.md +236 -222
- package/assets/skills/write-a-skill.md +76 -71
- package/assets/templates/findings.md +19 -19
- package/assets/templates/gate-map.sh +16 -14
- package/assets/templates/implementation.md +28 -27
- package/assets/templates/pattern.md +17 -17
- package/assets/templates/pitfalls.md +6 -6
- package/assets/templates/postmortem.md +24 -23
- package/assets/templates/project.sh +24 -24
- package/assets/templates/proposal.md +62 -60
- package/assets/templates/rule.md +38 -38
- package/assets/workflows/feature.js +46 -46
- package/assets/workflows/plan.js +54 -54
- package/lib/catalog.d.ts +2 -0
- package/lib/catalog.d.ts.map +1 -1
- package/lib/catalog.js +4 -3
- package/lib/catalog.js.map +1 -1
- package/lib/commands.d.ts.map +1 -1
- package/lib/commands.js +68 -4
- package/lib/commands.js.map +1 -1
- package/lib/companion.js +3 -2
- package/lib/companion.js.map +1 -1
- package/lib/enroll.d.ts +7 -1
- package/lib/enroll.d.ts.map +1 -1
- package/lib/enroll.js +13 -4
- package/lib/enroll.js.map +1 -1
- package/lib/observations.d.ts +10 -1
- package/lib/observations.d.ts.map +1 -1
- package/lib/observations.js +1 -0
- package/lib/observations.js.map +1 -1
- package/lib/override-marks.d.ts +24 -0
- package/lib/override-marks.d.ts.map +1 -0
- package/lib/override-marks.js +98 -0
- package/lib/override-marks.js.map +1 -0
- package/lib/plan.d.ts +11 -0
- package/lib/plan.d.ts.map +1 -1
- package/lib/plan.js +10 -1
- package/lib/plan.js.map +1 -1
- package/lib/ship.d.ts +0 -7
- package/lib/ship.d.ts.map +1 -1
- package/lib/ship.js +10 -2
- package/lib/ship.js.map +1 -1
- package/lib/shipment.d.ts.map +1 -1
- package/lib/shipment.js +7 -3
- package/lib/shipment.js.map +1 -1
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +45 -11
- package/lib/sync.js.map +1 -1
- package/package.json +1 -1
- package/rt-tools-agent-kit-0.26.0.tgz +0 -0
- package/rt-tools-agent-kit-0.23.0.tgz +0 -0
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: PreToolUse AskUserQuestion
|
|
3
|
-
#
|
|
4
|
-
#
|
|
3
|
+
# Requires: hooks/grill-gate.sh
|
|
4
|
+
# The half of the conversation guard that stands on the question tool: the menu is judged before it
|
|
5
|
+
# is sent.
|
|
5
6
|
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
7
|
+
# A resource of its own, not a line in the neighbour's header, because the question tool is the
|
|
8
|
+
# only way to ask the owner, and the tree may already have its own guard on it with its own refusal
|
|
9
|
+
# reason. A second refusal on the same tool makes the question unavailable altogether, and the tree
|
|
10
|
+
# drops the guard whole instead of taking its half. Split over two resources, the halves are
|
|
11
|
+
# cancelled separately: a refusal line removes one and leaves the other.
|
|
11
12
|
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
13
|
+
# The call is judged by the same body as the turn end: the requirement is one, and its two editions
|
|
14
|
+
# must not diverge. Here only the event declaration and passing the input on.
|
|
14
15
|
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
16
|
+
# FAIL-OPEN: no neighbouring file — the turn is ALLOWED. A half of the guard that has lost its body
|
|
17
|
+
# has no right to jam the conversation.
|
|
17
18
|
|
|
18
19
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
19
20
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
2
|
+
# Requires: hooks/deny-tail.sh
|
|
3
3
|
# rt-hook: Stop
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
# `hooks/grill-gate-ask.sh`,
|
|
4
|
+
# The conversation guard: the owner is not asked a question until the laws and rules have been read
|
|
5
|
+
# within the same turn. It judges two events, and that is not duplication; the second is declared
|
|
6
|
+
# by the neighbouring resource `hooks/grill-gate-ask.sh`, which hands the call over here.
|
|
7
7
|
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
8
|
+
# Why exactly this way. The requirement "the rules are read before the conversation" is enforceable
|
|
9
|
+
# right up to the moment the question is sent. A check at the turn end refuses after the fact: by
|
|
10
|
+
# the time of the refusal the question is already with the owner, and the owner sees it together
|
|
11
|
+
# with the refused turn — the requirement fires, but it does not save the work. So a turn with a
|
|
12
|
+
# question is judged on the question tool, before sending.
|
|
12
13
|
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
14
|
+
# This one interception does not close the hole: a question is more often asked in prose, and that
|
|
15
|
+
# is exactly how the one that brought this guard about was asked. A prose question is not a tool,
|
|
16
|
+
# and it can be caught only at the turn end — the event gets the path to the turn record and sees
|
|
17
|
+
# the turn whole. Hence two events: the menu is caught before sending, prose after. They are
|
|
18
|
+
# declared by different resources so that a tree whose question tool is already taken by a guard of
|
|
19
|
+
# its own can take one half instead of dropping the requirement whole.
|
|
19
20
|
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
21
|
+
# Reading the rules counts as any of three paths: loading a rule, reading a file of the laws or the
|
|
22
|
+
# rules, searching through them. To demand loading exactly would drive the executor to it where one
|
|
23
|
+
# search was enough — the guard would hinder the work instead of straightening it.
|
|
23
24
|
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
25
|
+
# But reading anything at all from the rules layer does not close the question: an incident
|
|
26
|
+
# analysis someone else read and a search over the catalog counted on a par with the rule this work
|
|
27
|
+
# actually needs — and the answer to the question put to the owner lay exactly in that rule. So,
|
|
28
|
+
# when the area of this turn's work is known, only the rule of that area counts as reading. The
|
|
29
|
+
# area is taken from where the rules gate takes it: from the paths edited in the turn.
|
|
29
30
|
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
31
|
+
# FAIL-OPEN here too: there are no edits in the turn, there is no gate map, the area did not come
|
|
32
|
+
# out — any reading counts, as before.
|
|
32
33
|
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
34
|
+
# FAIL-OPEN: on any error, with no turn record and on a repeat pass the turn is ALLOWED (exit 0).
|
|
35
|
+
# A broken guard has no right to jam the conversation.
|
|
35
36
|
|
|
36
|
-
#
|
|
37
|
+
# Its own name in the observations: the refusal is written by the shared deny tail, not by the guard.
|
|
37
38
|
RT_GUARD_NAME=grill-gate
|
|
38
39
|
|
|
39
40
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
@@ -45,11 +46,12 @@ input="$RT_HOOK_INPUT"
|
|
|
45
46
|
|
|
46
47
|
command -v jq >/dev/null 2>&1 || exit 0
|
|
47
48
|
|
|
48
|
-
#
|
|
49
|
+
# Which event arrived. A tool call has its name, the turn end does not.
|
|
49
50
|
tool="$(rt_hook_tool)"
|
|
50
51
|
|
|
51
|
-
#
|
|
52
|
-
#
|
|
52
|
+
# A repeat pass over the same turn is not judged: otherwise the turn would never end — the guard
|
|
53
|
+
# said its piece once and lets go. This does not apply to a tool call: there the call itself is
|
|
54
|
+
# judged.
|
|
53
55
|
active="$(printf '%s' "$input" | jq -r '.stop_hook_active // false' 2>/dev/null)"
|
|
54
56
|
[ -z "$tool" ] && [ "$active" = "true" ] && exit 0
|
|
55
57
|
|
|
@@ -57,45 +59,46 @@ transcript="$(printf '%s' "$input" | jq -r '.transcript_path // empty' 2>/dev/nu
|
|
|
57
59
|
[ -z "$transcript" ] && exit 0
|
|
58
60
|
[ -f "$transcript" ] || exit 0
|
|
59
61
|
|
|
60
|
-
#
|
|
61
|
-
#
|
|
62
|
+
# The tree profile: the directories of laws, rules and specs differ from tree to tree, and they are
|
|
63
|
+
# needed both for the sign of reading and for the hint in the refusal.
|
|
62
64
|
rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
63
65
|
for profile in "$rt_hooks_dir/../rt-kit/defaults/project.sh" "$rt_hooks_dir/../defaults/project.sh" "${CLAUDE_PROJECT_DIR:-.}/.claude/rt-kit/defaults/project.sh" "${CLAUDE_PROJECT_DIR:-.}/.claude/rt-kit/project.sh"; do
|
|
64
66
|
# shellcheck disable=SC1090
|
|
65
67
|
[ -f "$profile" ] && . "$profile" 2>/dev/null
|
|
66
68
|
done
|
|
67
69
|
|
|
68
|
-
#
|
|
69
|
-
#
|
|
70
|
-
#
|
|
70
|
+
# Substitution without a colon is deliberate: set to empty means the tree drops the requirement,
|
|
71
|
+
# and that must not be replaced by a default. The default goes only to the one who did not set the
|
|
72
|
+
# variable at all.
|
|
71
73
|
laws_dir="${RT_LAWS_DIR-docs/constitution}"
|
|
72
74
|
rules_dir="${RT_RULES_DIR-.claude/skills}"
|
|
73
75
|
specs_dir="${RT_SPECS_DIR-docs/specs}"
|
|
74
|
-
#
|
|
75
|
-
#
|
|
76
|
-
#
|
|
76
|
+
# The plan of an epic and the archive are read on a par with the laws: the decision that ties the
|
|
77
|
+
# tasks of an epic together lies exactly there. Whoever had read the plan was refused on a par with
|
|
78
|
+
# whoever had read nothing, and that refusal was lifted by a search over three directories among
|
|
79
|
+
# which the needed one was not.
|
|
77
80
|
plans_dir="${RT_PLANS_DIR-docs/plans}"
|
|
78
81
|
archive_dir="${RT_ARCHIVE_DIR-docs/archive}"
|
|
79
82
|
|
|
80
|
-
#
|
|
83
|
+
# A tree that has neither laws nor rules gets no requirement: there is nothing to read.
|
|
81
84
|
[ -z "$laws_dir" ] && [ -z "$rules_dir" ] && exit 0
|
|
82
85
|
|
|
83
|
-
#
|
|
84
|
-
#
|
|
86
|
+
# The gate map: by it the rule name is got from the edit path. There is none — the area does not
|
|
87
|
+
# come out, and everything stays as before.
|
|
85
88
|
rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
86
89
|
for map in "$rt_hooks_dir/../rt-kit/defaults/gate-map.sh" "$rt_hooks_dir/../defaults/gate-map.sh" "${CLAUDE_PROJECT_DIR:-.}/.claude/rt-kit/defaults/gate-map.sh" "${CLAUDE_PROJECT_DIR:-.}/.claude/rt-kit/gate-map.sh"; do
|
|
87
90
|
# shellcheck disable=SC1090
|
|
88
91
|
[ -f "$map" ] && . "$map" 2>/dev/null
|
|
89
92
|
done
|
|
90
93
|
|
|
91
|
-
#
|
|
92
|
-
#
|
|
94
|
+
# The pattern by which a tool call counts as reading the rules. The directories go into it as they
|
|
95
|
+
# are: the dot in `.claude` matches any character and brings nothing extra here.
|
|
93
96
|
read_re="$(printf '%s' "$laws_dir|$rules_dir|$specs_dir|$plans_dir|$archive_dir" | sed 's/^|*//; s/|*$//; s/||*/|/g')"
|
|
94
97
|
[ -z "$read_re" ] && exit 0
|
|
95
98
|
|
|
96
|
-
#
|
|
97
|
-
#
|
|
98
|
-
#
|
|
99
|
+
# The area of this turn's work: the rules the gate demands of the paths edited in the turn. The
|
|
100
|
+
# paths are got by the same parse of the turn as below — by a call of its own, so that the reading
|
|
101
|
+
# pattern is ready for the main parse.
|
|
99
102
|
need_re=''
|
|
100
103
|
if command -v skill_for >/dev/null 2>&1 && [ -n "$rules_dir" ]; then
|
|
101
104
|
edited="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r '
|
|
@@ -122,15 +125,14 @@ if command -v skill_for >/dev/null 2>&1 && [ -n "$rules_dir" ]; then
|
|
|
122
125
|
done
|
|
123
126
|
fi
|
|
124
127
|
|
|
125
|
-
#
|
|
126
|
-
#
|
|
127
|
-
#
|
|
128
|
-
# бы.
|
|
128
|
+
# A turn is everything recorded after the last real input from the owner. A tool answer comes in
|
|
129
|
+
# under the same `user` role, so lines with `tool_result` do not count as input: otherwise the turn
|
|
130
|
+
# would be the piece after the last tool call, and reading the rules at its start would be lost.
|
|
129
131
|
#
|
|
130
|
-
#
|
|
131
|
-
#
|
|
132
|
-
#
|
|
133
|
-
#
|
|
132
|
+
# A tail of 400 lines: the turn record grows all session, and only the last turn is judged.
|
|
133
|
+
# On the tool call event the question is already known — it is the call; only whether the rules
|
|
134
|
+
# were read within this turn is judged. At the turn end the question is looked for in the text of
|
|
135
|
+
# the replies: the menu has by then already been refused earlier.
|
|
134
136
|
verdict="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r --arg re "$read_re" --arg tool "$tool" --arg need "$need_re" --arg rules "$rules_dir" '
|
|
135
137
|
def is_input:
|
|
136
138
|
.type == "user"
|
|
@@ -150,8 +152,8 @@ verdict="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r --arg re "$read_re"
|
|
|
150
152
|
or ((.name == "Bash") and ((.input.command // "") | test($re)))
|
|
151
153
|
) | any
|
|
152
154
|
else
|
|
153
|
-
#
|
|
154
|
-
#
|
|
155
|
+
# The area of the work is known — only the rule of that area counts: an incident
|
|
156
|
+
# analysis someone else read does not answer the question that was asked.
|
|
155
157
|
($need | split("|")) as $rules_needed
|
|
156
158
|
| $uses | map(
|
|
157
159
|
((.name == "Skill") and (((.input.skill // "") | tostring) as $s | $rules_needed | index($s) != null))
|
|
@@ -165,20 +167,22 @@ verdict="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r --arg re "$read_re"
|
|
|
165
167
|
| if ($asked_prose or $asking_now) and ($read | not) then "ask" else "pass" end
|
|
166
168
|
' 2>/dev/null)"
|
|
167
169
|
|
|
168
|
-
#
|
|
170
|
+
# The second sign of the same guard: the owner has already answered this question.
|
|
169
171
|
#
|
|
170
|
-
#
|
|
171
|
-
#
|
|
172
|
-
#
|
|
173
|
-
#
|
|
172
|
+
# The first sign judges whether the rules were read, and stays silent on work that is allowed. But
|
|
173
|
+
# the miss can be another one: the owner gave an instruction in a direct reply, the executor found
|
|
174
|
+
# a fact that changes the price of the instruction but not its meaning — and instead of a line
|
|
175
|
+
# about the price asked a menu where two options out of three offered to cancel the owner's
|
|
176
|
+
# decision. The work stopped until an answer, having been allowed a minute earlier.
|
|
174
177
|
#
|
|
175
|
-
#
|
|
176
|
-
#
|
|
177
|
-
#
|
|
178
|
-
#
|
|
178
|
+
# What is judged is the overlap of words: the question going out now against the owner's last reply
|
|
179
|
+
# — and only where the record already holds a call of the question tool, that is, the owner has
|
|
180
|
+
# answered a question. There is no understanding of the text here and none is needed: three shared
|
|
181
|
+
# significant words mean the same subject, while a grill of six questions runs over different
|
|
182
|
+
# subjects and does not reach the threshold.
|
|
179
183
|
#
|
|
180
|
-
#
|
|
181
|
-
#
|
|
184
|
+
# FAIL-OPEN: no question in the call, no reply from the owner, no earlier question — the sign stays
|
|
185
|
+
# silent.
|
|
182
186
|
if [ -n "$tool" ]; then
|
|
183
187
|
asked_json="$(printf '%s' "$input" | jq -r '(.tool_input.questions // []) | tostring' 2>/dev/null)"
|
|
184
188
|
seen="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r --arg now "$asked_json" '
|
|
@@ -192,27 +196,28 @@ if [ -n "$tool" ]; then
|
|
|
192
196
|
def words: [splits("[^\\p{L}\\p{N}]+")] | map(select(length >= 5)) | unique;
|
|
193
197
|
|
|
194
198
|
(map(is_input) | rindex(true)) as $i
|
|
195
|
-
| if $i == null then "
|
|
199
|
+
| if $i == null then "no" else
|
|
196
200
|
(.[$i] | (.message.content // []) | if type == "array"
|
|
197
201
|
then ([.[] | select(.type == "text") | .text] | join(" "))
|
|
198
202
|
else (. // "") end) as $said
|
|
199
203
|
| ([.[:$i][] | select(.type == "assistant") | (.message.content // [])[]
|
|
200
204
|
| select(.type == "tool_use") | select(.name == "AskUserQuestion")] | length) as $before
|
|
201
|
-
| if $before == 0 or ($said | length) == 0 then "
|
|
205
|
+
| if $before == 0 or ($said | length) == 0 then "no" else
|
|
202
206
|
(($now | words) - (($now | words) - ($said | words))) as $common
|
|
203
|
-
| if ($common | length) >= 3 then "
|
|
207
|
+
| if ($common | length) >= 3 then "answered" else "no" end
|
|
204
208
|
end
|
|
205
209
|
end
|
|
206
210
|
' 2>/dev/null)"
|
|
207
211
|
|
|
208
|
-
if [ "$seen" = "
|
|
209
|
-
reason="BLOCKED by grill-gate:
|
|
212
|
+
if [ "$seen" = "answered" ]; then
|
|
213
|
+
reason="BLOCKED by grill-gate: the owner has already answered this question in this conversation — go on with the work instead of asking again.
|
|
210
214
|
|
|
211
|
-
|
|
215
|
+
An instruction of the owner holds until they cancel it. A new fact against a standing instruction is a line in the reply about the price, not a new question: what is asked again is only what the instruction does not cover. The miss here is not in the form of the question but in stopping work that is already allowed.
|
|
212
216
|
|
|
213
|
-
|
|
217
|
+
The question really is about another matter — then name in it what the former answer of the owner lacks: the sign judges the shared words of the question and of the last message of the owner, not the meaning."
|
|
214
218
|
|
|
215
|
-
#
|
|
219
|
+
# The shared deny tail: the two lawful moves and the lawful form of bypass, if the
|
|
220
|
+
# refusal has one.
|
|
216
221
|
# shellcheck disable=SC1090
|
|
217
222
|
[ -f "$rt_hooks_dir/deny-tail.sh" ] && . "$rt_hooks_dir/deny-tail.sh" 2>/dev/null
|
|
218
223
|
command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
|
|
@@ -222,7 +227,7 @@ if [ -n "$tool" ]; then
|
|
|
222
227
|
${deny_tail_text}"
|
|
223
228
|
|
|
224
229
|
jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
|
|
225
|
-
|| printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"grill-gate:
|
|
230
|
+
|| printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"grill-gate: this question has already been answered."}}\n'
|
|
226
231
|
exit 0
|
|
227
232
|
fi
|
|
228
233
|
fi
|
|
@@ -230,19 +235,20 @@ fi
|
|
|
230
235
|
[ "$verdict" = "ask" ] || exit 0
|
|
231
236
|
|
|
232
237
|
if [ -n "$tool" ]; then
|
|
233
|
-
head="BLOCKED by grill-gate:
|
|
238
|
+
head="BLOCKED by grill-gate: the question to the owner has not left yet, and this is the only moment when the requirement can be met."
|
|
234
239
|
else
|
|
235
|
-
head="BLOCKED by grill-gate:
|
|
240
|
+
head="BLOCKED by grill-gate: the reply carries a question to the owner, and the laws and rules were not read in this turn."
|
|
236
241
|
fi
|
|
237
242
|
|
|
238
|
-
reason="$head
|
|
243
|
+
reason="$head A question whose answer is already written down is not asked of the owner — the rule of work conduct. Run a search by the words of the subject and answer from what is found; ask only what the documents do not cover:
|
|
239
244
|
|
|
240
|
-
grep -rn -i \"
|
|
245
|
+
grep -rn -i \"<a word of the subject>\" $laws_dir $rules_dir $specs_dir $plans_dir $archive_dir
|
|
241
246
|
|
|
242
|
-
|
|
247
|
+
The guard judges one turn: the next session is not refused."
|
|
243
248
|
|
|
244
|
-
#
|
|
245
|
-
#
|
|
249
|
+
# The shared deny tail: the two lawful moves and the lawful form of bypass, if the refusal has one.
|
|
250
|
+
# The file may not be laid out — then there is no tail, and the reason for the refusal stays as it
|
|
251
|
+
# was.
|
|
246
252
|
# shellcheck disable=SC1090
|
|
247
253
|
[ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
|
|
248
254
|
&& . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
|
|
@@ -252,14 +258,15 @@ deny_tail_text="$(rt_deny_tail "")"
|
|
|
252
258
|
|
|
253
259
|
${deny_tail_text}"
|
|
254
260
|
|
|
255
|
-
#
|
|
256
|
-
#
|
|
261
|
+
# The form of the refusal differs between the two events: a tool call is refused by a decision
|
|
262
|
+
# about access, and the turn end by a decision about the turn. One form for both events silently
|
|
263
|
+
# does not fire.
|
|
257
264
|
if [ -n "$tool" ]; then
|
|
258
265
|
jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
|
|
259
|
-
|| printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"grill-gate:
|
|
266
|
+
|| printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"grill-gate: read the laws and rules on the subject before asking the owner."}}\n'
|
|
260
267
|
else
|
|
261
268
|
jq -n --arg r "$reason" '{decision:"block",reason:$r}' 2>/dev/null \
|
|
262
|
-
|| printf '{"decision":"block","reason":"grill-gate:
|
|
269
|
+
|| printf '{"decision":"block","reason":"grill-gate: read the laws and rules on the subject before asking the owner."}\n'
|
|
263
270
|
fi
|
|
264
271
|
|
|
265
272
|
exit 0
|
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
# каждый отказ.
|
|
2
|
+
# The record of a guard refusal. NOT a guard: it has no `rt-hook:` declaration and hooks into no
|
|
3
|
+
# agent event. The shared deny tail sources it — the one place every refusal passes through.
|
|
5
4
|
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
5
|
+
# Why it exists. The refusal record stood inside the guard itself as five lines: sourcing the
|
|
6
|
+
# record, checking the function exists, the call with the name and the session id. Writing them in
|
|
7
|
+
# every guard did not work out — of thirty guards, five had them, and the observation digest
|
|
8
|
+
# answered by that fifth: a guard that can refuse but cannot record is listed in it neither as
|
|
9
|
+
# refusing nor as silent, and the question "it stood there and did not work" cannot be asked about
|
|
10
|
+
# it at all.
|
|
11
11
|
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
12
|
+
# HOW A GUARD DECLARES ITSELF. By one line `RT_GUARD_NAME=<name>` at its top. The declaration is
|
|
13
|
+
# voluntary and exact: a hook that counts its own refusals by itself — like the rules gate — does
|
|
14
|
+
# not set it, and the same event is not counted a second time.
|
|
15
15
|
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
16
|
+
# WHAT IS RECORDED. The guard name and the session id. Cleaning the values and deciding whether to
|
|
17
|
+
# write at all is done by the observation record itself; here only the call is assembled.
|
|
18
18
|
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
19
|
+
# FAIL-OPEN. There may be no record at all — no file, the tree switched observations off, the
|
|
20
|
+
# directory is unavailable. A guard that fell over on recording a refusal would stop work for the
|
|
21
|
+
# sake of statistics.
|
|
21
22
|
|
|
22
|
-
#
|
|
23
|
-
#
|
|
23
|
+
# A guard refusal into the observations. The name is taken from `RT_GUARD_NAME`, the session id
|
|
24
|
+
# from the hook input; without a name nothing is written.
|
|
24
25
|
rt_guard_note() {
|
|
25
26
|
local rt_gn_dir rt_gn_sid rt_gn_name
|
|
26
|
-
#
|
|
27
|
-
#
|
|
27
|
+
# A default, not a bare read: a guard may be written to abort on an undeclared variable, and a
|
|
28
|
+
# record that reads it bare brings such a guard down whole — on every call, not on a refusal.
|
|
28
29
|
rt_gn_name="${RT_GUARD_NAME:-}"
|
|
29
30
|
[ -n "$rt_gn_name" ] || return 0
|
|
30
31
|
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: PreToolUse Edit|Write|MultiEdit
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
3
|
+
# Requires: rules/task-flow.md, hooks/deny-tail.sh
|
|
4
|
+
# Handover entry guard: a session started from a handover edits no file until the work-conduct rule
|
|
5
|
+
# is loaded.
|
|
6
6
|
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
7
|
+
# The handover was written by the previous session, lies outside the tree and is read by no check.
|
|
8
|
+
# It gets read as an assignment, and work begins past the rule: the state is not checked against the
|
|
9
|
+
# tree, the numbers are taken on trust, the entry order is followed from memory. An order written
|
|
10
|
+
# only in words is followed as long as someone remembers it.
|
|
11
11
|
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
12
|
+
# The session is recognised by the owner's first message: it names the handover path or carries its
|
|
13
|
+
# text. The rule load is recognised by a call of the rules tool in the same session.
|
|
14
14
|
#
|
|
15
|
-
# FAIL-OPEN:
|
|
15
|
+
# FAIL-OPEN: no `jq`, no transcript, no handover in the message → pass.
|
|
16
16
|
|
|
17
|
-
#
|
|
17
|
+
# Its own name in the observations: the refusal is recorded by the shared deny tail, not by the
|
|
18
|
+
# guard itself.
|
|
18
19
|
RT_GUARD_NAME=handoff-entry-guard
|
|
19
20
|
|
|
20
21
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
@@ -35,7 +36,8 @@ transcript="$(printf '%s' "$input" | jq -r '.transcript_path // empty' 2>/dev/nu
|
|
|
35
36
|
[ -z "$transcript" ] && exit 0
|
|
36
37
|
[ -f "$transcript" ] || exit 0
|
|
37
38
|
|
|
38
|
-
#
|
|
39
|
+
# The work-conduct rule has its own name in each tree, but the handover directory is shared: the
|
|
40
|
+
# guard looks at both signs.
|
|
39
41
|
rule="${RT_TASK_FLOW_RULE:-task-flow}"
|
|
40
42
|
|
|
41
43
|
verdict="$(jq -s -r --arg rule "$rule" '
|
|
@@ -46,24 +48,24 @@ verdict="$(jq -s -r --arg rule "$rule" '
|
|
|
46
48
|
| ((.name // "") + " " + ((.input.skill // .input.command // "") | tostring))] as $used
|
|
47
49
|
| (($said | join("\n")) | test("handoff|передач[аи][[:space:]]+захода")) as $from_handoff
|
|
48
50
|
| (($used | join("\n")) | test("Skill[[:space:]]+" + $rule + "|skills/" + $rule)) as $loaded
|
|
49
|
-
| if ($from_handoff and ($loaded | not)) then "
|
|
51
|
+
| if ($from_handoff and ($loaded | not)) then "no-rule" else "fine" end
|
|
50
52
|
' "$transcript" 2>/dev/null)"
|
|
51
53
|
|
|
52
|
-
[ "$verdict" = "
|
|
54
|
+
[ "$verdict" = "no-rule" ] || exit 0
|
|
53
55
|
|
|
54
|
-
reason="BLOCKED by handoff-entry-guard:
|
|
56
|
+
reason="BLOCKED by handoff-entry-guard: the session began from a handover, and the rule of work conduct is not loaded for it.
|
|
55
57
|
|
|
56
|
-
|
|
58
|
+
The handover was written by the previous session, lies outside the tree and is read by no check: everything standing in it is verified against the tree. The order of entry is four steps:
|
|
57
59
|
|
|
58
|
-
1.
|
|
59
|
-
2.
|
|
60
|
-
3.
|
|
61
|
-
4.
|
|
60
|
+
1. the rule of work conduct and the pattern of returning — by the first move;
|
|
61
|
+
2. the branch and the state of the work are read in the tree, not in the handover;
|
|
62
|
+
3. the numbers from the handover are recomputed on the current commit;
|
|
63
|
+
4. the next step is taken from the progress.
|
|
62
64
|
|
|
63
|
-
|
|
65
|
+
Load the rule and repeat the edit."
|
|
64
66
|
|
|
65
|
-
#
|
|
66
|
-
#
|
|
67
|
+
# The shared deny tail: the two lawful moves and the lawful form of bypass, if the refusal has one.
|
|
68
|
+
# The file may not be laid out — then there is no tail, and the refusal reason stays as it is.
|
|
67
69
|
# shellcheck disable=SC1090
|
|
68
70
|
[ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
|
|
69
71
|
&& . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
|
|
@@ -74,5 +76,5 @@ deny_tail_text="$(rt_deny_tail "")"
|
|
|
74
76
|
${deny_tail_text}"
|
|
75
77
|
|
|
76
78
|
jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
|
|
77
|
-
|| printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"handoff-entry-guard:
|
|
79
|
+
|| printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"handoff-entry-guard: the rule of work conduct is not loaded."}}\n'
|
|
78
80
|
exit 0
|