@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,40 +1,42 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: PostToolUse Edit|Write|MultiEdit|Bash|mcp__webstorm__create_new_file
|
|
3
|
-
#
|
|
4
|
-
#
|
|
3
|
+
# Requires: hooks/profile-check.sh
|
|
4
|
+
# The linter in the footsteps of an edit. PostToolUse.
|
|
5
5
|
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
6
|
+
# Two entries. A file edit — the one changed file is linted. A shell command — what it wrote is
|
|
7
|
+
# linted: a move changes the lib, and with it the boundaries, and an import lawful in the old
|
|
8
|
+
# place is already forbidden in the new one; a write by redirect, by append or by an interpreter
|
|
9
|
+
# changes the file itself, and before that it never got a linter at all. That is exactly how a
|
|
10
|
+
# forbidden import leaves for the shared lib silently, and an edited check slips out from under
|
|
11
|
+
# the formatter: the rule would have fired — but nobody ran it.
|
|
12
12
|
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
13
|
+
# What a command writes and where, the tree profile knows, and it knows it in one way for all:
|
|
14
|
+
# the rules gate reads the same sign.
|
|
15
15
|
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
16
|
+
# The full suite is run by the guard on push, but that is the end of the work: by the time the
|
|
17
|
+
# rule fires, a dozen edits lie on top of the violation, and the analysis turns into archaeology.
|
|
18
|
+
# Here is the same linter, but over the touched files — seconds, right after the action, while
|
|
19
|
+
# the context is still one's own.
|
|
19
20
|
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
21
|
+
# Findings come back as added context, not as a refusal: the action is already applied, and an
|
|
22
|
+
# unfinished intermediate file has the right to be red. They must be fixed before the end of the
|
|
23
|
+
# task — all of them, including those that lay in the file before.
|
|
23
24
|
#
|
|
24
|
-
#
|
|
25
|
-
# rt_lint_for —
|
|
26
|
-
# rt_shell_writes —
|
|
27
|
-
# rt_shell_paths —
|
|
28
|
-
# rt_is_app_code —
|
|
29
|
-
# RT_LINT_SKIP_RE —
|
|
30
|
-
# rt_push_checks —
|
|
31
|
-
#
|
|
32
|
-
#
|
|
25
|
+
# What is called what here, the tree profile knows:
|
|
26
|
+
# rt_lint_for — what this file is linted with;
|
|
27
|
+
# rt_shell_writes — whether this command writes;
|
|
28
|
+
# rt_shell_paths — which paths it wrote;
|
|
29
|
+
# rt_is_app_code — where the code the linters apply to at all lives;
|
|
30
|
+
# RT_LINT_SKIP_RE — what is excluded from it;
|
|
31
|
+
# rt_push_checks — what the push gate runs. It also decides whether a finding catches up
|
|
32
|
+
# later: a linter that is not in the gate is caught only by this hook.
|
|
33
|
+
# No profile or no function — the hook stays silent.
|
|
33
34
|
#
|
|
34
|
-
#
|
|
35
|
+
# FAIL-OPEN and silent: no linter, a file outside the tree, a green result — empty output.
|
|
35
36
|
|
|
36
|
-
#
|
|
37
|
-
#
|
|
37
|
+
# How many files are linted per move. A lib move touches dozens of files, and a run over each
|
|
38
|
+
# would turn the hook into a minute-long pause; the first ones are enough for a boundary
|
|
39
|
+
# violation.
|
|
38
40
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
39
41
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
40
42
|
|
|
@@ -52,8 +54,9 @@ case "$tool" in
|
|
|
52
54
|
*) exit 0 ;;
|
|
53
55
|
esac
|
|
54
56
|
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
+
# Screening before any work: the hook hangs on every shell command, and a minority of them
|
|
58
|
+
# write. An empty command is screened out right here — there is nothing to ask it the write sign
|
|
59
|
+
# about.
|
|
57
60
|
command_text=""
|
|
58
61
|
if [ "$mode" = "move" ]; then
|
|
59
62
|
command_text="$(printf '%s' "$input" | jq -r '.tool_input.command // empty' 2>/dev/null)"
|
|
@@ -65,22 +68,22 @@ workdir="$(rt_hook_cwd)"
|
|
|
65
68
|
cd "$workdir" 2>/dev/null || exit 0
|
|
66
69
|
[ -f package.json ] || exit 0
|
|
67
70
|
|
|
68
|
-
#
|
|
71
|
+
# The tree profile: the package default first, the project override on top of it if there is one.
|
|
69
72
|
rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
70
73
|
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
|
|
71
74
|
# shellcheck disable=SC1090
|
|
72
75
|
[ -f "$profile" ] && . "$profile" 2>/dev/null
|
|
73
76
|
done
|
|
74
77
|
|
|
75
|
-
#
|
|
76
|
-
#
|
|
78
|
+
# A word about a missing profile function: a hook that exited silently cannot be told from a
|
|
79
|
+
# working one. The file may not be laid out — then the old behaviour, the silent one, stays.
|
|
77
80
|
# shellcheck disable=SC1090
|
|
78
81
|
[ -f "$rt_hooks_dir/profile-check.sh" ] && . "$rt_hooks_dir/profile-check.sh"
|
|
79
82
|
command -v rt_needs >/dev/null 2>&1 || rt_needs() { command -v "$1" >/dev/null 2>&1; }
|
|
80
83
|
rt_needs rt_lint_for lint-after-edit || exit 0
|
|
81
84
|
|
|
82
|
-
#
|
|
83
|
-
#
|
|
85
|
+
# The write sign is asked after the profile: before it there are no functions yet. A tree that
|
|
86
|
+
# has not declared the sign keeps the old behaviour — a single move is parsed.
|
|
84
87
|
if [ "$mode" = "move" ] && rt_needs rt_shell_writes lint-after-edit; then
|
|
85
88
|
case "$command_text" in
|
|
86
89
|
*"git mv "*) ;;
|
|
@@ -88,20 +91,20 @@ if [ "$mode" = "move" ] && rt_needs rt_shell_writes lint-after-edit; then
|
|
|
88
91
|
esac
|
|
89
92
|
fi
|
|
90
93
|
|
|
91
|
-
# ---
|
|
94
|
+
# --- which files are checked -----------------------------------------------------------
|
|
92
95
|
|
|
93
|
-
#
|
|
94
|
-
#
|
|
96
|
+
# The destination paths of all moves in the command. A command can be compound, so it is cut by
|
|
97
|
+
# separators, and each piece is parsed on its own.
|
|
95
98
|
collect_moved() {
|
|
96
|
-
#
|
|
97
|
-
#
|
|
99
|
+
# The trailing newline is mandatory: reading without it loses the last piece, and a command
|
|
100
|
+
# most often consists of exactly one.
|
|
98
101
|
printf '%s\n' "$1" | tr ';&\n' '\n\n\n' | while IFS= read -r segment; do
|
|
99
102
|
case "$segment" in
|
|
100
103
|
*"git mv "*) ;;
|
|
101
104
|
*) continue ;;
|
|
102
105
|
esac
|
|
103
106
|
|
|
104
|
-
# shellcheck disable=SC2086 #
|
|
107
|
+
# shellcheck disable=SC2086 # splitting by spaces is exactly what is wanted here
|
|
105
108
|
set -- ${segment#*git mv }
|
|
106
109
|
args=''
|
|
107
110
|
for arg in "$@"; do
|
|
@@ -118,7 +121,7 @@ collect_moved() {
|
|
|
118
121
|
dest=''
|
|
119
122
|
for arg in "$@"; do dest="$arg"; done
|
|
120
123
|
|
|
121
|
-
#
|
|
124
|
+
# The destination is a directory: the file name stays as it was, only the path changes.
|
|
122
125
|
if [ -d "$dest" ]; then
|
|
123
126
|
for arg in "$@"; do
|
|
124
127
|
[ "$arg" = "$dest" ] && continue
|
|
@@ -130,7 +133,7 @@ collect_moved() {
|
|
|
130
133
|
done
|
|
131
134
|
}
|
|
132
135
|
|
|
133
|
-
#
|
|
136
|
+
# A directory is expanded into the files lying in it: a move can shift whole layers.
|
|
134
137
|
expand() {
|
|
135
138
|
if [ -d "$1" ]; then
|
|
136
139
|
find "$1" -type f \( -name '*.ts' -o -name '*.html' -o -name '*.scss' \) 2>/dev/null
|
|
@@ -142,16 +145,16 @@ expand() {
|
|
|
142
145
|
if [ "$mode" = "edit" ]; then
|
|
143
146
|
path="$(printf '%s' "$input" | jq -r '.tool_input.file_path // .tool_input.pathInProject // empty' 2>/dev/null)"
|
|
144
147
|
[ -z "$path" ] && exit 0
|
|
145
|
-
#
|
|
148
|
+
# A path from the tree root is made absolute once, so that the patterns do not double.
|
|
146
149
|
case "$path" in
|
|
147
150
|
/*) ;;
|
|
148
151
|
*) path="${CLAUDE_PROJECT_DIR:-.}/$path" ;;
|
|
149
152
|
esac
|
|
150
153
|
candidates="$(expand "$path")"
|
|
151
154
|
else
|
|
152
|
-
#
|
|
153
|
-
#
|
|
154
|
-
#
|
|
155
|
+
# A move expands a directory: it shifts whole layers. A write does not: writes always go to
|
|
156
|
+
# a file, and a directory in a write command is the working directory, and expanded it hands
|
|
157
|
+
# the linter half of the tree. So of the written paths only existing files are taken.
|
|
155
158
|
written=""
|
|
156
159
|
if rt_needs rt_shell_paths lint-after-edit; then
|
|
157
160
|
written="$(rt_shell_paths "$command_text" 2>/dev/null | while IFS= read -r path; do
|
|
@@ -164,7 +167,7 @@ fi
|
|
|
164
167
|
|
|
165
168
|
[ -z "$candidates" ] && exit 0
|
|
166
169
|
|
|
167
|
-
# ---
|
|
170
|
+
# --- screening out what the tree's linters do not cover ---------------------------------
|
|
168
171
|
|
|
169
172
|
lintable() {
|
|
170
173
|
if rt_needs rt_is_app_code lint-after-edit; then
|
|
@@ -177,8 +180,8 @@ lintable() {
|
|
|
177
180
|
return 0
|
|
178
181
|
}
|
|
179
182
|
|
|
180
|
-
#
|
|
181
|
-
#
|
|
183
|
+
# The linter name in the command is the first word that is not a launcher. It goes into the
|
|
184
|
+
# heading, and the push gate is searched by it too.
|
|
182
185
|
linter_name() {
|
|
183
186
|
printf '%s' "$1" | awk '{
|
|
184
187
|
for (i = 1; i <= NF; i++) {
|
|
@@ -188,7 +191,7 @@ linter_name() {
|
|
|
188
191
|
}'
|
|
189
192
|
}
|
|
190
193
|
|
|
191
|
-
# ---
|
|
194
|
+
# --- the run ----------------------------------------------------------------------------
|
|
192
195
|
|
|
193
196
|
push_checks="$(rt_needs rt_push_checks lint-after-edit && rt_push_checks 2>/dev/null)"
|
|
194
197
|
|
|
@@ -196,6 +199,7 @@ report=""
|
|
|
196
199
|
linters=""
|
|
197
200
|
covered=1
|
|
198
201
|
checked=0
|
|
202
|
+
path_gap=0
|
|
199
203
|
|
|
200
204
|
while IFS= read -r file; do
|
|
201
205
|
[ -z "$file" ] && continue
|
|
@@ -206,9 +210,19 @@ while IFS= read -r file; do
|
|
|
206
210
|
[ -z "$lint" ] && continue
|
|
207
211
|
checked=$((checked + 1))
|
|
208
212
|
|
|
213
|
+
# A command without the path of the edited file reads as a clean linter, and does one of two
|
|
214
|
+
# things: walks the whole tree or checks nothing. There is nothing to tell it from an honest
|
|
215
|
+
# run over the whole suite, so here is a word, not a refusal; said once per session — like
|
|
216
|
+
# the word about a missing profile function.
|
|
217
|
+
case "$lint" in
|
|
218
|
+
*"$file"*) ;;
|
|
219
|
+
*) path_gap=1 ;;
|
|
220
|
+
esac
|
|
221
|
+
|
|
209
222
|
out="$(eval "$lint" 2>&1)" && continue
|
|
210
223
|
|
|
211
|
-
#
|
|
224
|
+
# There is no linter, or it crashed on its own — that is not a finding about the file, we
|
|
225
|
+
# stay silent.
|
|
212
226
|
printf '%s' "$out" | grep -qiE 'command not found|could not determine executable|Cannot find module' && continue
|
|
213
227
|
|
|
214
228
|
linter="$(linter_name "$lint")"
|
|
@@ -226,32 +240,52 @@ done <<EOF
|
|
|
226
240
|
$candidates
|
|
227
241
|
EOF
|
|
228
242
|
|
|
243
|
+
# The mark lives in the temporary files directory: on every edit the same line would repeat
|
|
244
|
+
# dozens of times per session and would stop being read.
|
|
245
|
+
if [ "$path_gap" = 1 ]; then
|
|
246
|
+
gap_key="$(printf '%s' "$input" | jq -r '.session_id // empty' 2>/dev/null)"
|
|
247
|
+
[ -z "$gap_key" ] && gap_key="$(date +%Y%m%d 2>/dev/null || printf 'nosession')"
|
|
248
|
+
gap_mark="${TMPDIR:-/tmp}/rt-kit-lint-path-gap-$gap_key"
|
|
249
|
+
if [ ! -f "$gap_mark" ]; then
|
|
250
|
+
printf 'the linter on the trail of an edit: the command of the profile did not name the
|
|
251
|
+
' >&2
|
|
252
|
+
printf 'edited file. It either walks the whole tree or checks nothing at all, and in both
|
|
253
|
+
' >&2
|
|
254
|
+
printf 'cases looks like a clean linter. The path is substituted when the command is
|
|
255
|
+
' >&2
|
|
256
|
+
printf 'printed — the sample stands in the default of the profile, the function rt_lint_for.
|
|
257
|
+
' >&2
|
|
258
|
+
: >"$gap_mark" 2>/dev/null || true
|
|
259
|
+
fi
|
|
260
|
+
fi
|
|
261
|
+
|
|
229
262
|
[ -z "$report" ] && exit 0
|
|
230
263
|
|
|
231
|
-
#
|
|
264
|
+
# Long output is cut: the fact and the first violations matter, the rest is visible in a full run.
|
|
232
265
|
report="$(printf '%s' "$report" | head -c 6000)"
|
|
233
266
|
|
|
234
267
|
if [ "$covered" -eq 1 ]; then
|
|
235
|
-
tail_line="
|
|
268
|
+
tail_line="The push will not pass anyway while the suite is red."
|
|
236
269
|
else
|
|
237
|
-
tail_line="
|
|
270
|
+
tail_line="Fix them now: this linter is not part of the push gate, and a postponed finding travels into the main branch in silence."
|
|
238
271
|
fi
|
|
239
272
|
|
|
240
273
|
case "$mode:$command_text" in
|
|
241
|
-
#
|
|
242
|
-
#
|
|
274
|
+
# A move is named separately: a finding after it is explained not by an edit of the file but
|
|
275
|
+
# by a change of its place, and without this line the reader looks for a miss in text that
|
|
276
|
+
# nobody changed.
|
|
243
277
|
move:*"git mv "*)
|
|
244
|
-
head_line="
|
|
278
|
+
head_line="THE LINTER (${linters}) FOUND ISSUES AFTER A MOVE. A move changes the lib, and with it the boundaries: an import lawful in the former place may be forbidden in the new one." ;;
|
|
245
279
|
move:*)
|
|
246
|
-
head_line="
|
|
280
|
+
head_line="THE LINTER (${linters}) FOUND ISSUES AFTER A WRITE BY A COMMAND:" ;;
|
|
247
281
|
*)
|
|
248
|
-
head_line="
|
|
282
|
+
head_line="THE LINTER (${linters}) FOUND ISSUES:" ;;
|
|
249
283
|
esac
|
|
250
284
|
|
|
251
285
|
ctx="${head_line}
|
|
252
286
|
${report}
|
|
253
287
|
|
|
254
|
-
|
|
288
|
+
Fix them before the task ends — ALL the issues in the touched file are fixed, the new ones and those that lay there before: accumulated violations drown the signal about fresh ones. ${tail_line}"
|
|
255
289
|
|
|
256
290
|
jq -n --arg c "$ctx" '{hookSpecificOutput:{hookEventName:"PostToolUse",additionalContext:$c}}' 2>/dev/null
|
|
257
291
|
|
package/assets/hooks/observe.sh
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
#
|
|
2
|
+
# Recording observations about the rules layer. NOT a guard: it has no `rt-hook:` declaration and it
|
|
3
|
+
# hooks into no agent event. The guards source it — the same way the gate sources the map.
|
|
4
4
|
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
5
|
+
# Why it exists. Edits to the package texts came out of the head of whoever writes them: what of the
|
|
6
|
+
# laid-out is used every day, what was never used once and what people stumble over a second time
|
|
7
|
+
# was unknown to the package. Part of the data was already being gathered and thrown away — the
|
|
8
|
+
# record of loads lived in a temporary directory and died with the compaction of the context.
|
|
9
9
|
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
10
|
+
# WHAT IS RECORDED. Only the names of package resources and counters: the name of a rule or a guard,
|
|
11
|
+
# the kind of event, the kind of file, the package version and the sign of a session. No tree paths,
|
|
12
|
+
# no names of its domains, no name of the tree itself — and this rests not on the caller's memory
|
|
13
|
+
# but on `rt_observe_clean`: a value with a slash is not written at all. An observation later
|
|
14
|
+
# travels into someone else's repository, and the ban on naming a foreign tree has to rest on the
|
|
15
|
+
# construction.
|
|
15
16
|
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
17
|
+
# FAIL-OPEN. An observation is a guard's side work, and any breakage of it silently lets the action
|
|
18
|
+
# through: an unavailable directory, a missing `date`, a full disk. A guard that fell over on
|
|
19
|
+
# recording an observation would stop work for the sake of statistics.
|
|
19
20
|
|
|
20
|
-
#
|
|
21
|
-
#
|
|
21
|
+
# A value fit for recording. A path is not carried out under any circumstances, the rest is cleaned
|
|
22
|
+
# down to a name and trimmed: a long value in an observation means nothing but a leak.
|
|
22
23
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
23
24
|
|
|
24
25
|
rt_observe_clean() {
|
|
@@ -28,35 +29,36 @@ rt_observe_clean() {
|
|
|
28
29
|
printf '%s' "$1" | LC_ALL=C tr -cd 'A-Za-z0-9._:-' | cut -c1-48
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
#
|
|
32
|
-
#
|
|
32
|
+
# The sign of a session: it is computed from the session name and cannot be restored back. It is
|
|
33
|
+
# needed so that the digest knows the number of sessions, not only the number of events.
|
|
33
34
|
rt_observe_session() {
|
|
34
35
|
printf '%s' "$1" | cksum 2>/dev/null | cut -d' ' -f1
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
#
|
|
38
|
-
#
|
|
38
|
+
# The version of the package that laid this file out. It stands in the header put there by the
|
|
39
|
+
# layout; in the package sources there is no header, and the version there is `dev`.
|
|
39
40
|
rt_observe_version() {
|
|
40
41
|
local found
|
|
41
42
|
found="$(sed -n 's/^# rt-kit v\([^ ]*\) .*/\1/p' "${BASH_SOURCE[0]}" 2>/dev/null | head -1)"
|
|
42
43
|
printf '%s' "${found:-dev}"
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
#
|
|
46
|
+
# The observations directory of this tree. An empty string — there will be no record.
|
|
46
47
|
rt_observe_dir() {
|
|
47
48
|
local root="${CLAUDE_PROJECT_DIR:-.}" config
|
|
48
49
|
config="$root/.claude/rt-kit.json"
|
|
49
|
-
#
|
|
50
|
-
#
|
|
51
|
-
#
|
|
50
|
+
# The tree's switch kills the recording whole, not in parts: the package is installed by those
|
|
51
|
+
# we know nothing about too. An unreadable setting does not count as switching off — otherwise
|
|
52
|
+
# broken JSON would quietly switch the observations off, and there would be nothing to see it
|
|
53
|
+
# by.
|
|
52
54
|
if [ -f "$config" ] && command -v jq >/dev/null 2>&1; then
|
|
53
55
|
[ "$(jq -r 'if .observe == false then "off" else "on" end' "$config" 2>/dev/null)" = "off" ] && return 0
|
|
54
56
|
fi
|
|
55
57
|
printf '%s' "$root/.claude/rt-kit/observations"
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
#
|
|
59
|
-
#
|
|
60
|
+
# One observation: the kind of event and `key=value` pairs. The `sid` key is hashed, the rest are
|
|
61
|
+
# cleaned. An empty value creates no field.
|
|
60
62
|
#
|
|
61
63
|
# rt_note gate-deny res=styling-bem kind=scss sid="$sid"
|
|
62
64
|
rt_note() {
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: PreToolUse Write|Bash|mcp__webstorm__create_new_file|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
|
|
3
|
-
#
|
|
4
|
-
#
|
|
3
|
+
# Requires: hooks/deny-tail.sh, hooks/guard-note.sh
|
|
4
|
+
# Guard against wiping out an override: writing over is not the same as editing.
|
|
5
5
|
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
6
|
+
# The tree's override merges with the package resource by `## ` section: a section the tree has
|
|
7
|
+
# rewritten replaces the package one, and the rest come from the package. That is why the override
|
|
8
|
+
# file accumulates — sections are appended to it by different branches and different sessions — and
|
|
9
|
+
# it looks like ordinary text that can be put down whole.
|
|
10
10
|
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
11
|
+
# Put down whole, it carries away every section this edit did not touch. There is nothing to see the
|
|
12
|
+
# loss by: the layout converges, the checks are green, and the package section has quietly returned
|
|
13
|
+
# to the place of what the tree said about itself. It is noticed by whoever wonders a month later
|
|
14
|
+
# why the rule again demands foreign names.
|
|
15
15
|
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
16
|
+
# WHAT IS JUDGED. Writing a file whole over an existing non-empty override: the writing tool, a `>`
|
|
17
|
+
# redirection, `tee` without appending, a copy over the top. Appending to the end — `>>`, `tee -a` —
|
|
18
|
+
# and an in-place edit pass: they carry nothing away.
|
|
19
19
|
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
20
|
+
# FAIL-OPEN: no `jq`, broken input, a foreign tool, no file, an empty file — the edit is ALLOWED. A
|
|
21
|
+
# broken guard has no right to jam work.
|
|
22
22
|
|
|
23
|
-
#
|
|
23
|
+
# Its own name in the observations: the refusal is written by the shared deny tail, not by the
|
|
24
|
+
# guard itself.
|
|
24
25
|
RT_GUARD_NAME=override-write-guard
|
|
25
26
|
|
|
26
27
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
@@ -41,12 +42,13 @@ deny() {
|
|
|
41
42
|
|
|
42
43
|
reason="$1 $(rt_deny_tail "$2")"
|
|
43
44
|
jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
|
|
44
|
-
|| printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"
|
|
45
|
+
|| printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"The override overwrite guard."}}\n'
|
|
45
46
|
exit 0
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
#
|
|
49
|
-
#
|
|
49
|
+
# The targets of writing over, named by the command outright. Appending is not included here: `>>`
|
|
50
|
+
# is hidden before the parsing and is not unfolded back, and `tee` is taken only without the
|
|
51
|
+
# appending argument.
|
|
50
52
|
rt_overwrite_targets() {
|
|
51
53
|
tr "\"'\`" ' ' \
|
|
52
54
|
| sed -E 's/>>/\
|
|
@@ -98,8 +100,8 @@ while IFS= read -r candidate; do
|
|
|
98
100
|
sections="$(grep -c '^## ' "$candidate" 2>/dev/null || printf '0')"
|
|
99
101
|
resource="${relative#"$overrides_dir"/}"
|
|
100
102
|
|
|
101
|
-
deny "BLOCKED by override-write-guard: «${relative}»
|
|
102
|
-
"
|
|
103
|
+
deny "BLOCKED by override-write-guard: «${relative}» is an override of this tree, and it already holds ${lines} lines, sections «## » — ${sections}. A whole-file write carries away every section this edit did not touch, and the package text of the resource «${resource}» silently returns in their place: the layout matches after that, the checks are green, and what the tree said about itself is gone. Edit in place — by an edit of a section, not by a write of the file." \
|
|
104
|
+
"a new section is appended at the end: the override merges with the package resource by the heading «## », and the package text is replaced only by the sections the tree named"
|
|
103
105
|
done <<EOF
|
|
104
106
|
$candidates
|
|
105
107
|
EOF
|