@rt-tools/agent-kit 0.24.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/agents/business-analyst.md +51 -50
- package/assets/agents/cargo-writer.md +54 -0
- 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-epic-link.github.mjs +29 -0
- package/assets/checks/board-epics.github.mjs +286 -49
- 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 +29 -25
- package/assets/checks/board-paths.github.mjs +21 -16
- package/assets/checks/board-pull-state.github.mjs +168 -0
- package/assets/checks/board-runs.github.mjs +45 -43
- package/assets/checks/board-task-dirs.github.mjs +98 -0
- package/assets/checks/board-titles.github.mjs +19 -17
- package/assets/checks/board.github.mjs +133 -194
- package/assets/checks/check-archive-age.mjs +23 -19
- package/assets/checks/check-board.github.mjs +131 -263
- package/assets/checks/check-descriptions.mjs +30 -29
- package/assets/checks/check-doc-paths.mjs +91 -88
- package/assets/checks/check-dupes.mjs +84 -80
- package/assets/checks/check-file-size.mjs +74 -71
- 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 +138 -39
- package/assets/checks/check-push-gate.mjs +53 -50
- package/assets/checks/check-reuse.mjs +50 -40
- package/assets/checks/check-schema-drift.mjs +104 -84
- 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/epic-table.github.mjs +268 -0
- 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 +187 -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/specs-for.mjs +214 -0
- package/assets/checks/task-new.github.mjs +315 -61
- package/assets/commands/feedback.md +65 -59
- package/assets/commands/next-session.md +64 -57
- package/assets/commands/night.md +115 -0
- package/assets/commands/skill-curator.md +83 -79
- package/assets/defaults/gate-map.sh +108 -97
- package/assets/defaults/project.sh +232 -185
- package/assets/defaults/shell.sh +73 -68
- package/assets/defaults/turn-map.md +47 -44
- package/assets/docs/GLOSSARY.md +142 -65
- package/assets/hooks/browser-device-id.sh +16 -12
- package/assets/hooks/browser-guard-device-id.sh +34 -28
- 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 +14 -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 +50 -43
- package/assets/hooks/dispatch.sh +60 -46
- package/assets/hooks/docs-guard.sh +100 -91
- package/assets/hooks/epic-over.sh +49 -0
- package/assets/hooks/epic-stop-guard.sh +108 -0
- package/assets/hooks/exam-guard.sh +105 -93
- package/assets/hooks/git-guard-delivery-conflict.sh +41 -36
- package/assets/hooks/git-guard-delivery-draft.sh +48 -38
- package/assets/hooks/git-guard-delivery-epic.sh +167 -0
- package/assets/hooks/git-guard-delivery-folder.sh +50 -43
- package/assets/hooks/git-guard-delivery-signature.sh +119 -53
- package/assets/hooks/git-guard-delivery.sh +223 -183
- package/assets/hooks/git-guard-main.sh +38 -34
- package/assets/hooks/git-guard-push-tests.sh +99 -87
- 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 +45 -25
- package/assets/hooks/handoff-write.sh +74 -67
- package/assets/hooks/hook-input.sh +67 -58
- 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 +49 -24
- package/assets/hooks/qa-dataid-guard.sh +83 -58
- 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 +39 -34
- package/assets/hooks/rule-source-guard.sh +47 -42
- package/assets/hooks/skill-gate-layers.sh +63 -57
- package/assets/hooks/skill-gate-rearm.sh +15 -8
- package/assets/hooks/skill-gate.sh +89 -81
- package/assets/hooks/skill-loaded.sh +10 -6
- package/assets/hooks/sql-guard-parse.sh +71 -66
- package/assets/hooks/sql-guard-request.sh +51 -46
- package/assets/hooks/sql-guard-target.sh +60 -51
- package/assets/hooks/sql-guard-write.sh +87 -79
- package/assets/hooks/sql-guard.sh +52 -47
- package/assets/hooks/stand-login-guard.sh +43 -37
- 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 +260 -204
- package/assets/hooks/turn-exit-patterns.sh +63 -0
- package/assets/hooks/utf8.sh +14 -11
- package/assets/hooks/waiting-turn-guard.sh +104 -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 +99 -44
- package/assets/laws/autonomous-work.md +29 -27
- package/assets/laws/code-structure.md +31 -30
- package/assets/laws/delivery.md +170 -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 -124
- package/assets/laws/work-conduct.md +250 -244
- 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 +124 -88
- package/assets/patterns/browser-verification-stand.md +169 -157
- package/assets/patterns/component-structure-new.md +51 -42
- package/assets/patterns/dependencies-upgrade.md +55 -39
- package/assets/patterns/doc-style-human.md +55 -37
- 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 -87
- package/assets/patterns/git-workflow-commit.github.md +160 -142
- package/assets/patterns/git-workflow-commit.gitlab.md +96 -90
- 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 +102 -94
- 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 +127 -122
- package/assets/patterns/git-workflow-pr.github.md +186 -177
- package/assets/patterns/git-workflow-pr.gitlab.md +139 -132
- 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 +136 -107
- 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 +48 -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 +234 -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 +228 -202
- package/assets/patterns/testing-e2e.md +102 -101
- 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 +172 -142
- package/assets/pitfalls/doc-style.md +96 -91
- package/assets/pitfalls/git-workflow.azure.md +49 -46
- package/assets/pitfalls/git-workflow.github.md +270 -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 +87 -74
- package/assets/rules/browser-verification.md +223 -214
- 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 +201 -173
- 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 +268 -239
- 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 -143
- package/assets/rules/shared-code.md +82 -79
- package/assets/rules/spec-driven.md +279 -260
- package/assets/rules/status-report.md +62 -58
- package/assets/rules/styling-bem.md +81 -77
- package/assets/rules/task-flow.md +303 -270
- package/assets/rules/testing.md +224 -209
- package/assets/rules/turn-conduct.md +262 -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 +259 -233
- 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/bin/agent-kit.d.ts.map +1 -1
- package/bin/agent-kit.js +8 -1
- package/bin/agent-kit.js.map +1 -1
- package/lib/cargo-prose.d.ts +41 -0
- package/lib/cargo-prose.d.ts.map +1 -0
- package/lib/cargo-prose.js +88 -0
- package/lib/cargo-prose.js.map +1 -0
- package/lib/cargo.d.ts +12 -1
- package/lib/cargo.d.ts.map +1 -1
- package/lib/cargo.js +8 -2
- package/lib/cargo.js.map +1 -1
- 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 +5 -2
- 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 +12 -3
- package/lib/enroll.js.map +1 -1
- package/lib/fate.d.ts +29 -0
- package/lib/fate.d.ts.map +1 -0
- package/lib/fate.js +147 -0
- package/lib/fate.js.map +1 -0
- package/lib/override-marks.d.ts +7 -0
- package/lib/override-marks.d.ts.map +1 -1
- package/lib/override-marks.js +14 -0
- package/lib/override-marks.js.map +1 -1
- 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 +29 -9
- package/lib/ship.d.ts.map +1 -1
- package/lib/ship.js +44 -2
- package/lib/ship.js.map +1 -1
- package/lib/shipment.d.ts.map +1 -1
- package/lib/shipment.fixture.d.ts +8 -1
- package/lib/shipment.fixture.d.ts.map +1 -1
- package/lib/shipment.fixture.js +9 -0
- package/lib/shipment.fixture.js.map +1 -1
- package/lib/shipment.js +38 -5
- 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.27.0.tgz +0 -0
- package/rt-tools-agent-kit-0.24.0.tgz +0 -0
|
@@ -1,37 +1,39 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: Stop
|
|
3
|
-
#
|
|
3
|
+
# The claim guard: what is said to the owner about the state of the tree carries the command that
|
|
4
|
+
# showed it. Stop.
|
|
4
5
|
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
6
|
+
# Why exactly this way. The rule of texts itself says that no check reads the reply to the owner:
|
|
7
|
+
# a file is answered for by the gate, a reply by its author, and the price of a mistake in a reply
|
|
8
|
+
# is paid by the owner. Eight analyses in a row about one and the same thing — what lay on the disk
|
|
9
|
+
# was called ready, only local branches were called removed, a set narrower than the pipeline was
|
|
10
|
+
# called checked, a local reference that had fallen behind was called the state of the tree. Each
|
|
11
|
+
# time an article was added to the rule, and each time the miss repeated: the text is read at the
|
|
12
|
+
# start of the session, and the claim is said at its end.
|
|
11
13
|
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
+
# What is judged: the text said to the owner within this turn. Tool output and what was written
|
|
15
|
+
# into a file do not go here — those are read by the gate and by the checks.
|
|
14
16
|
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
17
|
+
# How it is judged: each claim word has a command kind of its own named for it. A claim about a
|
|
18
|
+
# green set is confirmed by a run of the set, about a pushed branch by a push call, about a removed
|
|
19
|
+
# one by a delete call. The command is looked for within this same turn: the state of the tree
|
|
20
|
+
# changes, and the output of a past turn no longer speaks about the present one.
|
|
19
21
|
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
22
|
+
# What the guard does not judge. A wrong conclusion: about a pattern judged by one of its files,
|
|
23
|
+
# and about a path a person will not take, a machine has nothing to judge by — there is neither a
|
|
24
|
+
# claim word there nor a command to check against. Those cases are held by the work-conduct rule,
|
|
25
|
+
# and that is a known boundary of the guard, not a promise.
|
|
24
26
|
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
-
#
|
|
27
|
+
# Someone else's word is not judged either: a quotation in quotes, an examiner's question, a
|
|
28
|
+
# retelling of someone else's text, a line of code and a sentence in the conditional are not claims
|
|
29
|
+
# about the tree. Turns refused for them cost more than the ones let through: a guard that refuses
|
|
30
|
+
# a quotation teaches not to check the tree but not to write quotes. So before the parse, quotes,
|
|
31
|
+
# code, quoting lines and sentences with a word of condition are taken out of what was said.
|
|
30
32
|
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
+
# FAIL-OPEN: on any error, a missing `jq`, no turn record or empty text the turn is ALLOWED
|
|
34
|
+
# (exit 0). A broken guard has no right to jam the conversation.
|
|
33
35
|
|
|
34
|
-
#
|
|
36
|
+
# Its own name in the observations: the refusal is written by the shared deny tail, not by the guard.
|
|
35
37
|
RT_GUARD_NAME=claim-guard
|
|
36
38
|
|
|
37
39
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
@@ -42,7 +44,7 @@ input="$RT_HOOK_INPUT"
|
|
|
42
44
|
[ -z "$input" ] && exit 0
|
|
43
45
|
command -v jq >/dev/null 2>&1 || exit 0
|
|
44
46
|
|
|
45
|
-
#
|
|
47
|
+
# A repeat pass over the same turn is not judged: the guard said its piece once and lets go.
|
|
46
48
|
active="$(printf '%s' "$input" | jq -r '.stop_hook_active // false' 2>/dev/null)"
|
|
47
49
|
[ "$active" = "true" ] && exit 0
|
|
48
50
|
|
|
@@ -50,21 +52,23 @@ transcript="$(printf '%s' "$input" | jq -r '.transcript_path // empty' 2>/dev/nu
|
|
|
50
52
|
[ -z "$transcript" ] && exit 0
|
|
51
53
|
[ -f "$transcript" ] || exit 0
|
|
52
54
|
|
|
53
|
-
#
|
|
54
|
-
#
|
|
55
|
-
#
|
|
56
|
-
#
|
|
55
|
+
# The text of the reply lands in the turn record no earlier than the host calls the hook: a guard
|
|
56
|
+
# that read the file first judges a turn that has nothing said in it at all — and stays silent,
|
|
57
|
+
# indistinguishable from a guard that looked and let it through. We wait for it to appear, and
|
|
58
|
+
# failing to see it, we return the turn: an empty record means not "nothing was said to the owner"
|
|
59
|
+
# but "there is nothing to read".
|
|
57
60
|
#
|
|
58
|
-
#
|
|
59
|
-
#
|
|
61
|
+
# This refusal belongs to one guard on purpose. Three of them judge the text, and were they to
|
|
62
|
+
# print their objects one after another, the output would stop being parsed whole — that is, the
|
|
63
|
+
# refusal would be lost entirely.
|
|
60
64
|
if ! rt_turn_has_text "$transcript"; then
|
|
61
|
-
reason="BLOCKED by claim-guard:
|
|
65
|
+
reason="BLOCKED by claim-guard: the record of the turn gave back no reply text at all, and there is nothing to judge what was said to the owner by.
|
|
62
66
|
|
|
63
|
-
|
|
67
|
+
The text lands in the record no earlier than the host calls the hook. A record read too early looks like a turn in which nothing was said to the owner — and every guard that judges what was said passes by in silence.
|
|
64
68
|
|
|
65
|
-
|
|
69
|
+
Repeat the ending of the turn: by this minute the text is already in the record. The turn loses nothing by it — what was said to the owner stays the same.
|
|
66
70
|
|
|
67
|
-
|
|
71
|
+
The guard judges one turn: the next session is not refused."
|
|
68
72
|
|
|
69
73
|
# shellcheck disable=SC1090
|
|
70
74
|
[ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
|
|
@@ -76,12 +80,12 @@ if ! rt_turn_has_text "$transcript"; then
|
|
|
76
80
|
${deny_tail_text}"
|
|
77
81
|
|
|
78
82
|
jq -n --arg r "$reason" '{decision:"block",reason:$r}' 2>/dev/null \
|
|
79
|
-
|| printf '{"decision":"block","reason":"claim-guard:
|
|
83
|
+
|| printf '{"decision":"block","reason":"claim-guard: the record of the turn gave back no reply text — repeat the ending of the turn."}\n'
|
|
80
84
|
exit 0
|
|
81
85
|
fi
|
|
82
86
|
|
|
83
|
-
#
|
|
84
|
-
#
|
|
87
|
+
# A turn is everything recorded after the owner's last real reply: a tool answer comes in under
|
|
88
|
+
# the same role and does not count as a reply.
|
|
85
89
|
turn="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r '
|
|
86
90
|
def is_input:
|
|
87
91
|
.type == "user"
|
|
@@ -105,9 +109,9 @@ said="$(printf '%s' "$turn" | jq -r '.said // ""' 2>/dev/null)"
|
|
|
105
109
|
ran="$(printf '%s' "$turn" | jq -r '.ran // ""' 2>/dev/null)"
|
|
106
110
|
[ -z "$said" ] && exit 0
|
|
107
111
|
|
|
108
|
-
#
|
|
109
|
-
#
|
|
110
|
-
#
|
|
112
|
+
# Someone else's word is taken out before the parse. A quoting line and a code block go whole,
|
|
113
|
+
# quotes and inline code are blanked with a space, and sentences with a word of condition are
|
|
114
|
+
# dropped: "would have run" and "if the lint were green" say nothing about the state of the tree.
|
|
111
115
|
judged="$(printf '%s\n' "$said" \
|
|
112
116
|
| awk 'BEGIN { code = 0 }
|
|
113
117
|
/^[[:space:]]*```/ { code = !code; next }
|
|
@@ -118,10 +122,11 @@ judged="$(printf '%s\n' "$said" \
|
|
|
118
122
|
[ -z "$judged" ] && exit 0
|
|
119
123
|
said="$judged"
|
|
120
124
|
|
|
121
|
-
#
|
|
125
|
+
# The claims map: what is said about the tree | what shows it | what to name in the refusal.
|
|
122
126
|
#
|
|
123
|
-
#
|
|
124
|
-
#
|
|
127
|
+
# The word is taken in the form it is said to the owner in. The future tense does not go here:
|
|
128
|
+
# "I will check" and "I will start" are not claims — they are a promise, and there is nothing in
|
|
129
|
+
# them to lie with.
|
|
125
130
|
claims=(
|
|
126
131
|
'проверено|прогнал[а]?|тесты (зелёные|прошли)|линт(ер)? (зелёный|прошёл|чистый)|сборка (зелёная|прошла)|набор зелёный|проверки зелёные|спеки зелёные|всё зелен(о|ое)§nx (test|lint|build|run|affected|run-many)|npm (run|test)|pnpm (run|exec|test)|jest|vitest|playwright|check:|run\.sh§команду набора — прогон тестов, линта или сборки'
|
|
127
132
|
'запушен[аоы]?|запушил[а]?|пуш прошёл|ветка уехала§git push§`git push`'
|
|
@@ -129,9 +134,10 @@ claims=(
|
|
|
129
134
|
'(ветки|ветка|файлы|файл|папка|каталог)[^.]{0,40}(снят|удал|почищ|вычищ)|снят[оыа] с§git branch|git push .*--delete|git rm|gh api|rm §команду удаления — `git branch -d`, `git push --delete` или `git rm`'
|
|
130
135
|
'прогон (зелёный|прошёл|кончился)|конвейер зелёный|проверки на PR зелёные§gh run§`gh run list` или `gh run view`'
|
|
131
136
|
'(работа|правка|задача) готова|можно вливать|PR открыт|черновик снят§gh pr §`gh pr create`, `gh pr view` или `gh pr ready`'
|
|
132
|
-
#
|
|
133
|
-
#
|
|
134
|
-
#
|
|
137
|
+
# Waiting for someone else's step is a claim about the state too, and there is something in it
|
|
138
|
+
# to lie with: a run is green for an hour, and sometimes never starts at all. Said without a
|
|
139
|
+
# command, it leaves finished work a draft, and the owner learns of it last — that is exactly
|
|
140
|
+
# how it went twice in one day.
|
|
135
141
|
'жд[уёя][^.]{0,20}прогон|дожида[ею][^.]{0,20}прогон|прогон[^.]{0,20}(ещё идёт|не встал|не кончился|не дошёл)|черновик[^.]{0,30}(не снимаю|сниму|снимется)§gh run|gh pr checks|check-runs|check:board|board\.mjs§команду о прогоне — `gh run list`, `gh pr checks` или сверку очереди работ'
|
|
136
142
|
'задача заведена|задача (в|переведена в) колонк|колонка переведена§gh issue|gh api|task:new|task:move|board\.mjs§команду очереди работ — заведение задачи или перевод колонки'
|
|
137
143
|
'(в дереве|в репозитории|здесь|такого файла|такой команды)[^.]{0,30}(нет|не бывает)|не заводили|нигде не встречается§grep|rg |ls |find |git ls-files|git grep|git log|cat §команду поиска — `grep`, `git ls-files` или обход каталога'
|
|
@@ -147,18 +153,18 @@ for row in "${claims[@]}"; do
|
|
|
147
153
|
[ -z "$found" ] && continue
|
|
148
154
|
printf '%s' "$ran" | grep -qiE "$proof" 2>/dev/null && continue
|
|
149
155
|
|
|
150
|
-
reason="BLOCKED by claim-guard:
|
|
156
|
+
reason="BLOCKED by claim-guard: the owner was told «${found}» — that is a statement about the state of the tree, and there was no command showing it in this turn.
|
|
151
157
|
|
|
152
|
-
|
|
158
|
+
A statement about the tree is worth exactly as much as the command that showed it: what is said without a command the owner reads as a verified fact and learns of the divergence last.
|
|
153
159
|
|
|
154
|
-
|
|
160
|
+
The first way out is to remove the statement from the reply and speak of what was done without it. It is the right one wherever the owner asked for no command: a run made to lift a refusal is sometimes more dangerous than what the guard watches — that is how a turn with nothing to deliver reached a push.
|
|
155
161
|
|
|
156
|
-
|
|
162
|
+
The second is to run ${name} in this same turn and name its output.
|
|
157
163
|
|
|
158
|
-
|
|
164
|
+
The guard judges one turn: the next session is not refused."
|
|
159
165
|
|
|
160
|
-
#
|
|
161
|
-
#
|
|
166
|
+
# The shared deny tail: the two lawful moves. The file may not be laid out — then there is no
|
|
167
|
+
# tail, and the reason for the refusal stays as it was.
|
|
162
168
|
# shellcheck disable=SC1090
|
|
163
169
|
[ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
|
|
164
170
|
&& . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
|
|
@@ -169,7 +175,7 @@ for row in "${claims[@]}"; do
|
|
|
169
175
|
${deny_tail_text}"
|
|
170
176
|
|
|
171
177
|
jq -n --arg r "$reason" '{decision:"block",reason:$r}' 2>/dev/null \
|
|
172
|
-
|| printf '{"decision":"block","reason":"claim-guard:
|
|
178
|
+
|| printf '{"decision":"block","reason":"claim-guard: a statement about the tree is not backed by a command."}\n'
|
|
173
179
|
exit 0
|
|
174
180
|
done
|
|
175
181
|
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
2
|
+
# Commit message check. A hook of git itself, not of the agent.
|
|
3
3
|
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
4
|
+
# NOT a guard: it has no `rt-hook:` declaration and hooks into no agent event. The version control
|
|
5
|
+
# calls it as its own hook, not the agent: it judges the message of a commit already written.
|
|
6
|
+
#
|
|
7
|
+
# A versioned template: the git hooks directory of the working copy is not versioned, so the file
|
|
8
|
+
# is put there separately — by the prepare script when dependencies are installed. Reinstall by
|
|
9
|
+
# hand if the prepare step did not run for some reason:
|
|
7
10
|
# cp .claude/hooks/commit-msg.sh .git/hooks/commit-msg && chmod +x .git/hooks/commit-msg
|
|
8
11
|
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
12
|
+
# Deliberately NOT through a wrapper that replaces the hooks path: the replacement takes git into
|
|
13
|
+
# its own directory and breaks the other hooks already lying in the working copy. The native path
|
|
14
|
+
# leaves them untouched.
|
|
11
15
|
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
16
|
+
# A title parsed by type and scope reads as a list, while free text reads only as a whole; that is
|
|
17
|
+
# why the format is checked here, on the spot, and not by eye at review.
|
|
14
18
|
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
19
|
+
# FAIL-OPEN: no checker (a fresh clone without installed dependencies) — pass. The format is not
|
|
20
|
+
# checked then, and that is better than a jammed commit.
|
|
17
21
|
|
|
18
22
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
19
23
|
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: Stop
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
3
|
+
# Requires: agents/conscience.md, hooks/roles.sh, hooks/deny-tail.sh
|
|
4
|
+
# Guard of conscience: a turn in which the conscience role found a repeat of an analysed miss does
|
|
5
|
+
# not end until the repeat has been dealt with or named to the owner.
|
|
6
6
|
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
7
|
+
# Why exactly so. An incident analysis explains the mechanism of a miss, but it is read only by
|
|
8
|
+
# whoever opens the directory himself. The miss that has to be recalled is exactly the one the
|
|
9
|
+
# executor does not remember at this minute, so calling the role is not left to his discretion: it
|
|
10
|
+
# would not happen where it is needed most.
|
|
11
11
|
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
12
|
+
# The role answers with its first line: «СОВЕСТЬ: повтор» or «СОВЕСТЬ: чисто». The guard judges the
|
|
13
|
+
# last answer of the turn and knows nothing about whether the finding is right: that is decided by
|
|
14
|
+
# the executor, and his decision is the work of the next turn, not the silence of this one.
|
|
15
15
|
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
16
|
+
# The turn is released when, after the finding, the executor did at least something about it:
|
|
17
|
+
# started an incident analysis, corrected the work or named the repeat to the owner. This is checked
|
|
18
|
+
# on the same turn.
|
|
18
19
|
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
20
|
+
# FAIL-OPEN: no `jq`, no turn record, the role stays silent or answers out of form — the turn is
|
|
21
|
+
# ALLOWED. A broken conscience has no right to jam the conversation.
|
|
21
22
|
|
|
22
|
-
#
|
|
23
|
+
# Its own name in the observations: the refusal is written by the shared deny tail, not by the
|
|
24
|
+
# guard itself.
|
|
23
25
|
RT_GUARD_NAME=conscience-guard
|
|
24
26
|
|
|
25
27
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
@@ -30,9 +32,9 @@ input="$RT_HOOK_INPUT"
|
|
|
30
32
|
[ -z "$input" ] && exit 0
|
|
31
33
|
command -v jq >/dev/null 2>&1 || exit 0
|
|
32
34
|
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
#
|
|
35
|
+
# A role switched off by the tree does not hold the guard: the list of the switched-off ones lies in
|
|
36
|
+
# the tree setting, and a helper next to it reads that list. An unreadable setting does not count as
|
|
37
|
+
# switching off — the guard works as before.
|
|
36
38
|
rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
37
39
|
# shellcheck disable=SC1090
|
|
38
40
|
[ -f "$rt_hooks_dir/roles.sh" ] && . "$rt_hooks_dir/roles.sh" 2>/dev/null
|
|
@@ -45,9 +47,21 @@ transcript="$(printf '%s' "$input" | jq -r '.transcript_path // empty' 2>/dev/nu
|
|
|
45
47
|
[ -z "$transcript" ] && exit 0
|
|
46
48
|
[ -f "$transcript" ] || exit 0
|
|
47
49
|
|
|
48
|
-
#
|
|
49
|
-
#
|
|
50
|
-
|
|
50
|
+
# The turn is everything recorded after the owner's last real remark. A tool answer arrives under
|
|
51
|
+
# the same role, so lines with `tool_result` do not count as a remark.
|
|
52
|
+
#
|
|
53
|
+
# The verdict of the role and the deed by the finding are read from different halves of the same
|
|
54
|
+
# record. The verdict is looked for only where the role can answer: a marker printed by a tool
|
|
55
|
+
# that reads and writes files, and a marker in the executor's own text, are not a verdict —
|
|
56
|
+
# otherwise reading a file with that line stands for the role having found a repeat. The deed is
|
|
57
|
+
# looked for over the whole record: the analysis is created by a command, and the word to the
|
|
58
|
+
# owner lies in the reply text.
|
|
59
|
+
found="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r '
|
|
60
|
+
def textof:
|
|
61
|
+
if type == "string" then .
|
|
62
|
+
elif type == "array" then (map(if type == "object" then (.text // "") else tostring end) | join("\n"))
|
|
63
|
+
else tostring end;
|
|
64
|
+
|
|
51
65
|
def is_input:
|
|
52
66
|
.type == "user"
|
|
53
67
|
and ((.isCompactSummary // false) | not)
|
|
@@ -57,40 +71,72 @@ verdict="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r '
|
|
|
57
71
|
|
|
58
72
|
(map(is_input) | rindex(true)) as $i
|
|
59
73
|
| (if $i == null then [] else .[$i:] end) as $turn
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
|
|
75
|
+
# Tools that read and write files: their answer is not a verdict of the role. The same set the
|
|
76
|
+
# exam guard mutes — there the marker was forged by an echo, here it arrives by an honest
|
|
77
|
+
# reading of an archive record that names the marker in its list.
|
|
78
|
+
| ["Bash", "Read", "Grep", "Glob", "Edit", "Write", "MultiEdit", "NotebookEdit"] as $mute
|
|
79
|
+
| [ $turn[] | select(.type == "assistant") | (.message.content // [])[]
|
|
80
|
+
| select(.type == "tool_use") | select(.name as $n | $mute | index($n) != null) | (.id // "") ] as $muted
|
|
81
|
+
|
|
82
|
+
| [ $turn[] | {
|
|
83
|
+
say: (if .type == "assistant" then ""
|
|
84
|
+
elif .type == "user" then
|
|
85
|
+
([ ((.message.content // []) | if type == "array" then .[] else empty end
|
|
86
|
+
| select(.type == "tool_result")
|
|
87
|
+
| select(((.tool_use_id // "") | if . == "" then null else . end) as $id
|
|
88
|
+
| $id == null or ($muted | index($id)) == null)
|
|
89
|
+
| .content | textof),
|
|
90
|
+
(. as $rec
|
|
91
|
+
| if ($rec.toolUseResult // null) == null then ""
|
|
92
|
+
elif ([($rec.message.content // []) | if type == "array" then .[] else empty end
|
|
93
|
+
| select(.type == "tool_result") | (.tool_use_id // "")]
|
|
94
|
+
| map(. as $id | $muted | index($id)) | any(. != null)) then ""
|
|
95
|
+
else ($rec.toolUseResult | textof) end)
|
|
96
|
+
] | join("\n"))
|
|
97
|
+
# Host records — the role completion notice and the attachment: the host chooses
|
|
98
|
+
# their form, and they count whole.
|
|
99
|
+
else tostring end),
|
|
100
|
+
act: (if .type == "assistant"
|
|
101
|
+
then ([(.message.content // [])[]
|
|
102
|
+
| if .type == "tool_use" then (.input.command // "") else (.text // "") end] | join("\n"))
|
|
103
|
+
elif .type == "user"
|
|
104
|
+
then ([(.message.content // []) | if type == "array" then .[] else empty end
|
|
105
|
+
| select(.type == "tool_result") | .content | textof] | join("\n"))
|
|
106
|
+
else "" end)
|
|
107
|
+
} ] as $flow
|
|
108
|
+
|
|
109
|
+
| ($flow | map(.say | test("(СОВЕСТЬ|CONSCIENCE):[[:space:]]*(повтор|repeat)")) | index(true)) as $at
|
|
110
|
+
| if $at == null then "no-finding"
|
|
111
|
+
else (($flow[($at + 1):] | map(.act + "\n" + .say) | join("\n"))
|
|
112
|
+
| if test("postmortems|разбор происшествия|analysis of the incident|(СОВЕСТЬ|CONSCIENCE): (разобрано|analysed)")
|
|
113
|
+
then "analysed" else "standing" end)
|
|
114
|
+
# The refusal names the finding, and it is taken from the very answer that was judged:
|
|
115
|
+
# taken by a search over the record it would quote the file that was read.
|
|
116
|
+
+ "\n"
|
|
117
|
+
+ (($flow[$at].say | split("\n")) as $lines
|
|
118
|
+
| ($lines | map(test("(СОВЕСТЬ|CONSCIENCE):[[:space:]]*(повтор|repeat)")) | index(true)) as $line
|
|
119
|
+
| $lines[$line:($line + 4)] | join("\n"))
|
|
75
120
|
end
|
|
76
121
|
' 2>/dev/null)"
|
|
77
122
|
|
|
78
|
-
|
|
123
|
+
verdict="$(printf '%s\n' "$found" | head -1)"
|
|
124
|
+
[ "$verdict" = "standing" ] || exit 0
|
|
79
125
|
|
|
80
|
-
detail="$(
|
|
126
|
+
detail="$(printf '%s\n' "$found" | tail -n +2)"
|
|
81
127
|
|
|
82
|
-
reason="BLOCKED by conscience-guard:
|
|
128
|
+
reason="BLOCKED by conscience-guard: the conscience found in this turn a repeat of a miss already analysed, and nothing was done about it.
|
|
83
129
|
|
|
84
130
|
${detail}
|
|
85
131
|
|
|
86
|
-
|
|
132
|
+
A turn does not end at the finding. Do one of three things in this same turn: fix the work, create an analysis of the incident if the mechanism is new, or name the repeat to the owner in words — what repeats and how it ended last time.
|
|
87
133
|
|
|
88
|
-
|
|
134
|
+
The finding is wrong — then say so to the owner: a false finding also costs a turn, and silence does not fix it.
|
|
89
135
|
|
|
90
|
-
|
|
136
|
+
The guard judges one turn: the next session is not refused."
|
|
91
137
|
|
|
92
|
-
#
|
|
93
|
-
#
|
|
138
|
+
# The shared deny tail: two lawful moves. The file may not be laid out — then there is no tail, and
|
|
139
|
+
# the refusal reason stays as it is.
|
|
94
140
|
# shellcheck disable=SC1090
|
|
95
141
|
[ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
|
|
96
142
|
&& . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
|
|
@@ -101,6 +147,6 @@ deny_tail_text="$(rt_deny_tail "")"
|
|
|
101
147
|
${deny_tail_text}"
|
|
102
148
|
|
|
103
149
|
jq -n --arg r "$reason" '{decision:"block",reason:$r}' 2>/dev/null \
|
|
104
|
-
|| printf '{"decision":"block","reason":"conscience-guard:
|
|
150
|
+
|| printf '{"decision":"block","reason":"conscience-guard: a repeat of an analysed miss is found — analyse it or name it to the owner."}\n'
|
|
105
151
|
|
|
106
152
|
exit 0
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: SessionStart startup|resume|compact|clear
|
|
3
|
-
#
|
|
3
|
+
# Entry into the laws layer. SessionStart.
|
|
4
4
|
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
5
|
+
# A law file by itself brings nothing into the context — it is read only when someone went for it.
|
|
6
|
+
# The hook prints an index (file name and its title) once per session: the layer is known to exist,
|
|
7
|
+
# and it is opened when a decision touches it.
|
|
8
8
|
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
9
|
+
# The index is READ FROM THE DIRECTORY, not written out by hand: a hand-written one would drift from
|
|
10
|
+
# what is actually laid out, and there would be nothing to say so with.
|
|
11
11
|
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
12
|
+
# FAIL-OPEN: any error starts the session without the added context (exit 0). A broken entry has no
|
|
13
|
+
# right to stop the session.
|
|
14
14
|
|
|
15
15
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
16
16
|
|
|
@@ -27,17 +27,17 @@ done
|
|
|
27
27
|
[ -z "$index" ] && exit 0
|
|
28
28
|
|
|
29
29
|
read -r -d '' context <<EOF
|
|
30
|
-
|
|
30
|
+
PROJECT LAWS (the @rt-tools/agent-kit layer, laid out in docs/constitution/).
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
implementation.md
|
|
35
|
-
|
|
32
|
+
A law says WHAT must be true and knows neither paths nor file names. A rule — by which
|
|
33
|
+
technique it is done — lives in .claude/skills/, and the names of this tree next to it are in
|
|
34
|
+
implementation.md alongside. A law does not cancel a rule and is not replaced by it: before a
|
|
35
|
+
decision the law touches, the law is read in full, the rule as usual.
|
|
36
36
|
|
|
37
37
|
${index}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
Laid-out files are edited not by hand but through the override in .claude/rt-kit/overrides/<resource>:
|
|
39
|
+
an in-place edit is lost on the next \`agent-kit sync\`, and sync refuses it. Check the laid-out
|
|
40
|
+
files against the package: \`agent-kit sync --check\`.
|
|
41
41
|
EOF
|
|
42
42
|
|
|
43
43
|
jq -n --arg c "$context" '{hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:$c}}' 2>/dev/null || exit 0
|