@rt-tools/agent-kit 0.24.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/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 +149 -127
- package/assets/checks/check-archive-age.mjs +23 -19
- package/assets/checks/check-board.github.mjs +172 -164
- 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 +120 -37
- 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 +108 -97
- package/assets/defaults/project.sh +225 -185
- package/assets/defaults/shell.sh +73 -68
- 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 +30 -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 +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 +60 -46
- package/assets/hooks/docs-guard.sh +100 -91
- package/assets/hooks/exam-guard.sh +105 -93
- package/assets/hooks/git-guard-delivery-conflict.sh +38 -36
- package/assets/hooks/git-guard-delivery-draft.sh +45 -38
- 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 +196 -180
- 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 +26 -24
- 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 +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 +47 -42
- 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 +40 -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 +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 +96 -44
- 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 -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 +93 -86
- package/assets/patterns/git-workflow-commit.github.md +152 -141
- package/assets/patterns/git-workflow-commit.gitlab.md +95 -89
- 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 +98 -93
- 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 +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 +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 -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 +198 -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 +250 -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 +272 -260
- package/assets/rules/status-report.md +55 -58
- package/assets/rules/styling-bem.md +81 -77
- package/assets/rules/task-flow.md +282 -270
- package/assets/rules/testing.md +224 -209
- 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 +235 -211
- 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 +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/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 +6 -2
- 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.24.0.tgz +0 -0
|
@@ -1,32 +1,34 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: PreToolUse Edit|Write|MultiEdit|NotebookEdit|Bash|mcp__webstorm__create_new_file|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
|
|
3
|
-
#
|
|
4
|
-
#
|
|
3
|
+
# Requires: hooks/profile-check.sh, hooks/deny-tail.sh, hooks/guard-note.sh
|
|
4
|
+
# Guard of the pair "an edit and its document". PreToolUse.
|
|
5
5
|
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
6
|
+
# A divergence of the code from the text is soundless. Neither the linter, nor the build, nor the
|
|
7
|
+
# tests read the rules, the specs and the READMEs, so a text describing the previous arrangement
|
|
8
|
+
# lives on and looks like a working reference — the more convincingly, the older it is. It is
|
|
9
|
+
# caught only by reading, and it is usually the owner who catches it, not a check.
|
|
10
10
|
#
|
|
11
|
-
#
|
|
11
|
+
# The guard demands exactly those pairs where the link is mechanical and there is nothing to argue
|
|
12
|
+
# about:
|
|
12
13
|
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
14
|
+
# a rule and its companion — when the section with the statements is edited, not "Pitfalls";
|
|
15
|
+
# creating and removing a lib — the README of that lib;
|
|
16
|
+
# moving a file between libs — the READMEs of both;
|
|
17
|
+
# the rest of the pairs — named by the tree profile, the function `rt_docs_pair_for <file>`.
|
|
17
18
|
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
19
|
+
# Apart from them — the laws. Whether the code came together with a law, a machine does not know:
|
|
20
|
+
# an edit of a file a law points to by an anchor is therefore not rejected but put to the owner as
|
|
21
|
+
# a question. The same question meets an edit of the law itself — both in place and through an
|
|
22
|
+
# override over it: a law describes a product agreement, and the guard does not let it be changed
|
|
23
|
+
# silently.
|
|
22
24
|
#
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
+
# The bypass is the line `Docs-skip: <reason>` in the commit body. The reason stays in the history
|
|
26
|
+
# and is visible when the branch is reviewed; an empty one is not accepted.
|
|
25
27
|
#
|
|
26
|
-
#
|
|
27
|
-
# пропуск.
|
|
28
|
+
# FAIL-OPEN: not a repository, no parser, broken input, an empty list of files — let through.
|
|
28
29
|
|
|
29
|
-
#
|
|
30
|
+
# Its own name in the observations: the refusal is written by the shared deny tail, not by the
|
|
31
|
+
# guard itself.
|
|
30
32
|
RT_GUARD_NAME=docs-guard
|
|
31
33
|
|
|
32
34
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
@@ -48,27 +50,27 @@ decide() {
|
|
|
48
50
|
if command -v rt_deny_tail >/dev/null 2>&1; then
|
|
49
51
|
reason="$2
|
|
50
52
|
|
|
51
|
-
$(rt_deny_tail "
|
|
53
|
+
$(rt_deny_tail "the line \`Docs-skip: <reason>\` in the commit body; an empty reason is not accepted")"
|
|
52
54
|
fi
|
|
53
55
|
fi
|
|
54
56
|
|
|
55
57
|
jq -n --arg d "$1" --arg r "$reason" \
|
|
56
58
|
'{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:$d,permissionDecisionReason:$r}}' 2>/dev/null \
|
|
57
|
-
|| printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"
|
|
59
|
+
|| printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"The document goes by the same commit."}}\n'
|
|
58
60
|
exit 0
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
#
|
|
62
|
-
#
|
|
63
|
-
#
|
|
63
|
+
# The tree profile: first the package default, and the project override on top of it, if there is
|
|
64
|
+
# one. A function declared in the override replaces the default whole and may call it back through
|
|
65
|
+
# the `_default` suffix.
|
|
64
66
|
rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
65
67
|
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
|
|
66
68
|
# shellcheck disable=SC1090
|
|
67
69
|
[ -f "$profile" ] && . "$profile" 2>/dev/null
|
|
68
70
|
done
|
|
69
71
|
|
|
70
|
-
#
|
|
71
|
-
#
|
|
72
|
+
# A word about a missing profile function: a hook that left silently is indistinguishable from a
|
|
73
|
+
# working one. The file may be not laid out — then the previous behaviour stays, the silent one.
|
|
72
74
|
# shellcheck disable=SC1090
|
|
73
75
|
[ -f "$rt_hooks_dir/profile-check.sh" ] && . "$rt_hooks_dir/profile-check.sh"
|
|
74
76
|
command -v rt_needs >/dev/null 2>&1 || rt_needs() { command -v "$1" >/dev/null 2>&1; }
|
|
@@ -77,36 +79,37 @@ laws_dir="${RT_LAWS_DIR:-docs/constitution}"
|
|
|
77
79
|
lib_marker="${RT_LIB_MARKER:-project.json}"
|
|
78
80
|
overrides_dir="${RT_OVERRIDES_DIR:-.claude/rt-kit/overrides}"
|
|
79
81
|
|
|
80
|
-
# ──
|
|
82
|
+
# ── An edit of a law asks the owner ───────────────────────────────────────────
|
|
81
83
|
#
|
|
82
|
-
#
|
|
83
|
-
#
|
|
84
|
+
# The companion next to a law is the binding of the articles to the code; it goes stale on every
|
|
85
|
+
# rename and is edited freely. Only the text of the law itself is asked about.
|
|
84
86
|
#
|
|
85
|
-
#
|
|
86
|
-
#
|
|
87
|
-
#
|
|
88
|
-
#
|
|
89
|
-
#
|
|
87
|
+
# There are two paths to the text of a law, and the second is walked more often. A laid-out law is
|
|
88
|
+
# not edited in place at all: the edit is lost on the next layout, and the layout itself refuses it
|
|
89
|
+
# — so the override is edited, and the file of the law is rewritten by the layout. A guard that
|
|
90
|
+
# knows one laws directory watches exactly the path by which nobody goes to a law: the more
|
|
91
|
+
# involved the tree's override, the more rarely a law is edited in place. The override is asked
|
|
92
|
+
# about too — by its content it is an edit of the law, not of the wrapping.
|
|
90
93
|
case "$tool" in
|
|
91
94
|
Edit | Write | MultiEdit | NotebookEdit | mcp__webstorm__create_new_file)
|
|
92
95
|
target="$(printf '%s' "$input" | jq -r '.tool_input.file_path // .tool_input.filePath // .tool_input.path // .tool_input.pathInProject // empty' 2>/dev/null)"
|
|
93
96
|
case "$target" in
|
|
94
97
|
*/"$laws_dir"/*.implementation.md | "$laws_dir"/*.implementation.md) exit 0 ;;
|
|
95
98
|
*/"$laws_dir"/*.md | "$laws_dir"/*.md)
|
|
96
|
-
decide ask "
|
|
99
|
+
decide ask "An edit of a law: \`${target##*/}\`. A law describes an agreement about the product, not the layout of the code — name to the owner what you are changing and why, and wait for the answer. If the edit is already agreed, confirm the call."
|
|
97
100
|
;;
|
|
98
101
|
*/"$overrides_dir"/laws/*.implementation.md | "$overrides_dir"/laws/*.implementation.md) exit 0 ;;
|
|
99
102
|
*/"$overrides_dir"/laws/*.md | "$overrides_dir"/laws/*.md)
|
|
100
|
-
decide ask "
|
|
103
|
+
decide ask "An edit of a law by an override: \`${target##*/}\`. A laid-out file is rewritten by the layout, so an edit of the override is an edit of the law itself: name to the owner what you are changing and why, and wait for the answer. If the edit is already agreed, confirm the call."
|
|
101
104
|
;;
|
|
102
105
|
esac
|
|
103
106
|
exit 0
|
|
104
107
|
;;
|
|
105
108
|
esac
|
|
106
109
|
|
|
107
|
-
# ──
|
|
110
|
+
# ── The commit ────────────────────────────────────────────────────────────────
|
|
108
111
|
|
|
109
|
-
#
|
|
112
|
+
# The environment terminal and the universal executor put the command in the same field.
|
|
110
113
|
case "$tool" in
|
|
111
114
|
Bash | mcp__webstorm__execute_terminal_command | mcp__webstorm__execute_tool) ;;
|
|
112
115
|
*) exit 0 ;;
|
|
@@ -114,8 +117,8 @@ esac
|
|
|
114
117
|
|
|
115
118
|
cmd="$(rt_hook_cmd)"
|
|
116
119
|
|
|
117
|
-
#
|
|
118
|
-
#
|
|
120
|
+
# The universal executor passes the real command as a nested string. It is that string that has to
|
|
121
|
+
# be parsed, otherwise the command name stands right after a quote and no rule reaches it.
|
|
119
122
|
if [ "$tool" = "mcp__webstorm__execute_tool" ] && command -v perl >/dev/null 2>&1; then
|
|
120
123
|
inner="$(printf '%s' "$cmd" | perl -0ne '
|
|
121
124
|
if (/--command(?:=|\s+)(?:"((?:[^"\\]|\\.)*)"|\x27([^\x27]*)\x27|(.+))/s) {
|
|
@@ -130,13 +133,14 @@ case "$cmd" in
|
|
|
130
133
|
*) exit 0 ;;
|
|
131
134
|
esac
|
|
132
135
|
|
|
133
|
-
#
|
|
134
|
-
#
|
|
136
|
+
# The reason for the bypass stays in the history, so the bypass is lawful. An empty line does not
|
|
137
|
+
# count as a bypass: "Docs-skip:" without a reason is the same silent skip, only with a colon.
|
|
135
138
|
#
|
|
136
|
-
#
|
|
137
|
-
#
|
|
138
|
-
#
|
|
139
|
-
#
|
|
139
|
+
# The line starts a line — its own in the commit body, or a comment at the end of the command — and
|
|
140
|
+
# takes no substitutions. The same condition as for the bypass at the merge: otherwise a text that
|
|
141
|
+
# EXPLAINS the bypass lifts the requirement all by itself. A commit body about an edit of the guard
|
|
142
|
+
# names exactly this line, and without the binding to the start the guard would let such a commit
|
|
143
|
+
# through silently.
|
|
140
144
|
if printf '%s' "$cmd" | grep -qiE '(^|#)[[:space:]]*Docs-skip:[[:space:]]*[^[:space:]<"'"'"'][^[:space:]"'"'"']{2,}'; then
|
|
141
145
|
exit 0
|
|
142
146
|
fi
|
|
@@ -146,8 +150,8 @@ workdir="$(rt_hook_cwd)"
|
|
|
146
150
|
cd "$workdir" 2>/dev/null || exit 0
|
|
147
151
|
git rev-parse --is-inside-work-tree >/dev/null 2>&1 || exit 0
|
|
148
152
|
|
|
149
|
-
# `-a`
|
|
150
|
-
#
|
|
153
|
+
# `-a` takes all tracked edits, `--amend` takes the files of the rewritten commit as well. Always
|
|
154
|
+
# counting by the index would mean checking a set other than the one that travels into the history.
|
|
151
155
|
changes=''
|
|
152
156
|
source_mode='index'
|
|
153
157
|
case "$cmd" in
|
|
@@ -164,15 +168,16 @@ esac
|
|
|
164
168
|
changes="$(printf '%s\n' "$changes" | grep -v '^[[:space:]]*$')"
|
|
165
169
|
[ -z "$changes" ] && exit 0
|
|
166
170
|
|
|
167
|
-
#
|
|
171
|
+
# The paths of the commit without the statuses. A rename comes as three fields — we take both sides.
|
|
168
172
|
paths="$(printf '%s\n' "$changes" | awk -F'\t' '{ for (i = 2; i <= NF; i++) if ($i != "") print $i }' | sort -u)"
|
|
169
173
|
|
|
170
174
|
has_path() { printf '%s\n' "$paths" | grep -qxF "$1"; }
|
|
171
175
|
|
|
172
|
-
#
|
|
173
|
-
#
|
|
174
|
-
#
|
|
175
|
-
#
|
|
176
|
+
# The content as it will travel into the commit. The source is the same one the list of edits was
|
|
177
|
+
# collected by: `-a` takes the working tree, an ordinary commit takes the index. Always reading the
|
|
178
|
+
# index is not allowed — under `-a` the previous edition lies there, and the guard would hold the
|
|
179
|
+
# very commit that fixes the divergence; always reading the working tree is not allowed either — an
|
|
180
|
+
# unstaged edit will not get into the commit.
|
|
176
181
|
content_of() {
|
|
177
182
|
if [ "$source_mode" = 'worktree' ]; then
|
|
178
183
|
cat "$1" 2>/dev/null
|
|
@@ -185,15 +190,17 @@ problems=''
|
|
|
185
190
|
add() { problems="${problems}
|
|
186
191
|
• $1"; }
|
|
187
192
|
|
|
188
|
-
# ── 1.
|
|
193
|
+
# ── 1. A rule and its companion ───────────────────────────────────────────────
|
|
189
194
|
#
|
|
190
|
-
#
|
|
191
|
-
#
|
|
192
|
-
#
|
|
195
|
+
# The statements of a rule are keyed by their own text, and a rewording without an edit of the
|
|
196
|
+
# companion breaks the link silently. The spec audit catches this, but it is run at the push gate —
|
|
197
|
+
# here the same pair meets a commit earlier, while the edit is still in the author's head.
|
|
193
198
|
#
|
|
194
|
-
#
|
|
195
|
-
#
|
|
196
|
-
|
|
199
|
+
# The section with the statements is the only thing linked to the companion; an edit of "Pitfalls"
|
|
200
|
+
# or of the "Where it lives" table does not touch it, so only this section is compared. The name of
|
|
201
|
+
# the section is double: English in a package rule, Russian in a rule written by the tree before the
|
|
202
|
+
# layer was translated. The end of the range is any heading not starting with their first letter.
|
|
203
|
+
STATEMENTS='/^## (How the law applies here|Как закон применяется здесь)$/,/^## [^КH]/'
|
|
197
204
|
statements_of() { content_of "$1" | awk "$STATEMENTS"; }
|
|
198
205
|
|
|
199
206
|
for rule in $(printf '%s\n' "$paths" | grep -E '/SKILL\.md$'); do
|
|
@@ -204,38 +211,39 @@ for rule in $(printf '%s\n' "$paths" | grep -E '/SKILL\.md$'); do
|
|
|
204
211
|
has_path "$companion" && continue
|
|
205
212
|
|
|
206
213
|
if [ "$(statements_of "$rule")" != "$(git show "HEAD:$rule" 2>/dev/null | awk "$STATEMENTS")" ]; then
|
|
207
|
-
add "
|
|
214
|
+
add "the statements of \`$rule\` are edited without the companion — add \`$companion\` to the commit"
|
|
208
215
|
fi
|
|
209
216
|
done
|
|
210
217
|
|
|
211
|
-
# ── 2.
|
|
218
|
+
# ── 2. The pairs the tree names ───────────────────────────────────────────────
|
|
212
219
|
#
|
|
213
|
-
#
|
|
214
|
-
#
|
|
220
|
+
# The contract and the domain spec, a guard and its scenarios — which exactly, the profile knows:
|
|
221
|
+
# every tree has a link of its own, and the mechanics are one.
|
|
215
222
|
if rt_needs rt_docs_pair_for docs-guard; then
|
|
216
223
|
while IFS= read -r file; do
|
|
217
224
|
[ -z "$file" ] && continue
|
|
218
225
|
|
|
219
|
-
#
|
|
220
|
-
#
|
|
221
|
-
#
|
|
222
|
-
#
|
|
223
|
-
#
|
|
226
|
+
# A file put in place by the layout demands no pair: it has one author in a consuming tree
|
|
227
|
+
# — the package, and the document about it lies there as well. Otherwise the very first
|
|
228
|
+
# layout demands a bypass over its whole volume, and a bypass declared over a hundred files
|
|
229
|
+
# lifts the requirement from future hand edits of those files too. The sign is the layout
|
|
230
|
+
# header: it stands in every laid-out file and tells it apart more reliably than any list
|
|
231
|
+
# of paths.
|
|
224
232
|
if [ -f "$file" ] && head -12 "$file" 2>/dev/null | grep -qE 'rt-kit v[^ ]+ · [^ ]+ · [0-9a-f]+'; then
|
|
225
233
|
continue
|
|
226
234
|
fi
|
|
227
235
|
|
|
228
236
|
want="$(rt_docs_pair_for "$file" 2>/dev/null)"
|
|
229
237
|
[ -z "$want" ] && continue
|
|
230
|
-
#
|
|
238
|
+
# The pair counts as arrived if at least one file of the commit fits the pattern.
|
|
231
239
|
printf '%s\n' "$paths" | grep -qE "$want" && continue
|
|
232
|
-
add "\`$file\`
|
|
240
|
+
add "\`$file\` is edited without its document — the same commit awaits \`$want\`"
|
|
233
241
|
done <<EOF
|
|
234
242
|
$paths
|
|
235
243
|
EOF
|
|
236
244
|
fi
|
|
237
245
|
|
|
238
|
-
# ── 3.
|
|
246
|
+
# ── 3. A lib and its README ───────────────────────────────────────────────────
|
|
239
247
|
|
|
240
248
|
lib_root() {
|
|
241
249
|
dir="${1%/*}"
|
|
@@ -255,16 +263,16 @@ want_readme() {
|
|
|
255
263
|
need_readme="$need_readme $root"
|
|
256
264
|
}
|
|
257
265
|
|
|
258
|
-
#
|
|
259
|
-
#
|
|
266
|
+
# Creating and removing a lib: the README is the only place where it is written what lies in it and
|
|
267
|
+
# who calls it, and it survives the layout only together with an edit of that text.
|
|
260
268
|
while IFS="$(printf '\t')" read -r status first second; do
|
|
261
269
|
case "$status" in
|
|
262
270
|
A* | D*)
|
|
263
271
|
case "$first" in */"$lib_marker") want_readme "${first%/"$lib_marker"}" ;; esac
|
|
264
272
|
;;
|
|
265
273
|
R*)
|
|
266
|
-
#
|
|
267
|
-
#
|
|
274
|
+
# A move of a file changes both sides: from one lib it disappeared, in the other it
|
|
275
|
+
# appeared.
|
|
268
276
|
from="$(lib_root "$first")" && to="$(lib_root "$second")"
|
|
269
277
|
if [ -n "$from" ] && [ -n "$to" ] && [ "$from" != "$to" ]; then
|
|
270
278
|
want_readme "$from"
|
|
@@ -276,8 +284,8 @@ done <<EOF
|
|
|
276
284
|
$changes
|
|
277
285
|
EOF
|
|
278
286
|
|
|
279
|
-
#
|
|
280
|
-
#
|
|
287
|
+
# A move given as the pair "deleted there, added here": not everything that is a rename counts as
|
|
288
|
+
# one — an edit of the content while moving throws the search off.
|
|
281
289
|
moved_added="$(printf '%s\n' "$changes" | awk -F'\t' '$1 ~ /^A/ { n = split($2, p, "/"); print p[n] "\t" $2 }' | sort -u)"
|
|
282
290
|
moved_deleted="$(printf '%s\n' "$changes" | awk -F'\t' '$1 ~ /^D/ { n = split($2, p, "/"); print p[n] "\t" $2 }' | sort -u)"
|
|
283
291
|
if [ -n "$moved_added" ] && [ -n "$moved_deleted" ]; then
|
|
@@ -296,25 +304,26 @@ EOF
|
|
|
296
304
|
fi
|
|
297
305
|
|
|
298
306
|
for root in $need_readme; do
|
|
299
|
-
[ -d "$root" ] || continue #
|
|
300
|
-
has_path "$root/README.md" || add "
|
|
307
|
+
[ -d "$root" ] || continue # the lib was deleted whole — there is nothing to edit in it
|
|
308
|
+
has_path "$root/README.md" || add "the content of the lib \`$root\` changed without an edit of \`$root/README.md\`"
|
|
301
309
|
done
|
|
302
310
|
|
|
303
311
|
if [ -n "$problems" ]; then
|
|
304
|
-
decide deny "BLOCKED:
|
|
312
|
+
decide deny "BLOCKED: the commit edits code but not the document that describes it.
|
|
305
313
|
${problems}
|
|
306
314
|
|
|
307
|
-
|
|
315
|
+
Text is edited in the same branch as the code: a document that has drifted from the tree looks like a current reference and leads the next reader astray. If an edit of the document really is not needed here — name the reason by the line \`Docs-skip: <reason>\` in the commit body, it stays in the history."
|
|
308
316
|
fi
|
|
309
317
|
|
|
310
|
-
# ── 4.
|
|
318
|
+
# ── 4. The laws ───────────────────────────────────────────────────────────────
|
|
311
319
|
#
|
|
312
|
-
#
|
|
313
|
-
#
|
|
314
|
-
#
|
|
320
|
+
# There is nothing to reject: whether the edit came together with a law is visible only by reading.
|
|
321
|
+
# But the place where an article of a law is carried out is named by an anchor, and an edit of
|
|
322
|
+
# exactly that file is the only moment when the audit is still cheap to do.
|
|
315
323
|
#
|
|
316
|
-
#
|
|
317
|
-
#
|
|
324
|
+
# There are two layers of laws: the shared one in the root, an application law in a directory under
|
|
325
|
+
# it. The pattern accepts both, otherwise an edit of a subject law would count as an edit past the
|
|
326
|
+
# laws.
|
|
318
327
|
if [ -d "$laws_dir" ] && ! printf '%s\n' "$paths" | grep -qE "^${laws_dir}/([^/]+/)?[^/]+\.md$"; then
|
|
319
328
|
touched=''
|
|
320
329
|
for anchor in $(grep -ohE '`[A-Za-z0-9_./@-]+\.(ts|mjs|html|scss|prisma|proto|json)(:[A-Za-z0-9_#.-]+)?`' "$laws_dir"/*.implementation.md 2>/dev/null \
|
|
@@ -324,10 +333,10 @@ if [ -d "$laws_dir" ] && ! printf '%s\n' "$paths" | grep -qE "^${laws_dir}/([^/]
|
|
|
324
333
|
done
|
|
325
334
|
|
|
326
335
|
if [ -n "$touched" ]; then
|
|
327
|
-
decide ask "
|
|
336
|
+
decide ask "The edit touches the places where articles of laws are carried out:
|
|
328
337
|
${touched}
|
|
329
338
|
|
|
330
|
-
|
|
339
|
+
The laws lie in \`${laws_dir}/\`, the binding — in the companions next to them. Read the law and tell the owner whether the edit agrees with it: if the edit refines it or contradicts it, the law is edited in this same branch, but only with their knowledge. If the law has not changed — confirm the call."
|
|
331
340
|
fi
|
|
332
341
|
fi
|
|
333
342
|
|