@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,34 +1,36 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
2
|
+
# The shared deny tail. NOT a guard: it has no `rt-hook:` declaration and hooks into no agent event.
|
|
3
|
+
# The guards source it themselves — the same way they source the observation record and the word
|
|
4
|
+
# about a missing profile function.
|
|
5
5
|
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
6
|
+
# Why it exists. A guard's refusal names the miss and the way to lift it, and nobody names what to
|
|
7
|
+
# do when lifting it does not work out. The empty place is taken by a third move that is in no rule:
|
|
8
|
+
# bypass silently — by a shell command, by a neighbouring tool, by editing the guard itself. That is
|
|
9
|
+
# what happened: within one hour a refusal was bypassed twice, and both times the edit landed past
|
|
10
|
+
# the guard. There are two lawful moves, and both are named right in the refusal text instead of
|
|
11
|
+
# being left to the reader's guess.
|
|
11
12
|
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
13
|
+
# WHAT IS SAID. Fix what was named and repeat the call — or bring the owner the price of the bypass
|
|
14
|
+
# and wait for their word. Where the bypass has a lawful form — a line in the commit body, a line
|
|
15
|
+
# in the plan, a command flag — the same tail names it: a bypass known to be lawful is looked for by
|
|
16
|
+
# the guard's own words, not past the guard.
|
|
16
17
|
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
18
|
+
# WHAT THE TAIL DOES NOT DO. It does not judge whether the bypass fits this case: the owner decides
|
|
19
|
+
# that. And it does not replace the refusal reason — that stands before it and names the miss by
|
|
20
|
+
# name.
|
|
19
21
|
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
# `RT_GUARD_NAME
|
|
25
|
-
#
|
|
22
|
+
# THE REFUSAL RECORD GOES FROM HERE TOO. The tail is the one place every refusal passes through: the
|
|
23
|
+
# tree's rule demands that the two lawful moves be named at every refusal, and a guard that refuses
|
|
24
|
+
# past the tail breaks that rule before it loses count. Written inside the guard itself, the record
|
|
25
|
+
# stood in five guards out of thirty, and the digest answered by that fifth. A guard declares itself
|
|
26
|
+
# by the line `RT_GUARD_NAME=<name>` at its top; one that has not declared writes nothing — that is
|
|
27
|
+
# how the rules gate counts its own refusals by itself.
|
|
26
28
|
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
+
# The deny tail as a string. The first parameter is the lawful form of bypass, if the refusal has
|
|
30
|
+
# one; empty means there is no lawful form at all, and this is said outright.
|
|
29
31
|
#
|
|
30
|
-
# reason="BLOCKED:
|
|
31
|
-
# reason="BLOCKED:
|
|
32
|
+
# reason="BLOCKED: <reason>. $(rt_deny_tail 'the line `Docs-skip: <reason>` in the commit body')"
|
|
33
|
+
# reason="BLOCKED: <reason>. $(rt_deny_tail)"
|
|
32
34
|
rt_deny_tail() {
|
|
33
35
|
# shellcheck disable=SC1090
|
|
34
36
|
[ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/guard-note.sh" ] \
|
|
@@ -36,9 +38,9 @@ rt_deny_tail() {
|
|
|
36
38
|
command -v rt_guard_note >/dev/null 2>&1 && rt_guard_note
|
|
37
39
|
|
|
38
40
|
if [ -n "$1" ]; then
|
|
39
|
-
printf '
|
|
41
|
+
printf 'Two moves from here: fix what is named and repeat the call, or bring the owner the price of a bypass and wait for their word. The lawful form of bypass: %s. An edit is not laid past the guard in silence: it refuses one call, and a bypassed one lifts the requirement from the whole tree and says nothing about it.' "$1"
|
|
40
42
|
return 0
|
|
41
43
|
fi
|
|
42
44
|
|
|
43
|
-
printf '
|
|
45
|
+
printf 'Two moves from here: fix what is named and repeat the call, or bring the owner the price of a bypass and wait for their word. There is no lawful form of bypass for this refusal. An edit is not laid past the guard in silence: it refuses one call, and a bypassed one lifts the requirement from the whole tree and says nothing about it.'
|
|
44
46
|
}
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: PreToolUse Bash|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_run_configuration|mcp__webstorm__execute_tool
|
|
3
|
-
#
|
|
4
|
-
#
|
|
3
|
+
# Requires: hooks/deny-tail.sh
|
|
4
|
+
# Guard against a second dev server. PreToolUse.
|
|
5
5
|
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
6
|
+
# The applications are already raised by the owner, and every check through the browser goes there.
|
|
7
|
+
# A second instance takes an extra port, serves a different build and leads the investigation
|
|
8
|
+
# astray: a difference between two servers reads as a defect of the edit. On top of that, a build
|
|
9
|
+
# started in passing silently kills the server already raised.
|
|
10
10
|
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
11
|
+
# Everything that RAISES a server is refused. Builds, tests, linters, requests to raised ports and
|
|
12
|
+
# looking at listeners pass.
|
|
13
13
|
#
|
|
14
|
-
#
|
|
15
|
-
# RT_STANDS.
|
|
14
|
+
# Where exactly the applications are raised is known to the project profile:
|
|
15
|
+
# .claude/rt-kit/project.sh, variable RT_STANDS. No profile — the refusal text stays general, the
|
|
16
|
+
# guard itself works.
|
|
17
|
+
#
|
|
18
|
+
# FAIL-OPEN: an unrecognised command, no way to ask the ports, a raise the tree knows nothing of —
|
|
19
|
+
# the call goes through. The price of a miss here is a second server on a busy port; the price of a
|
|
20
|
+
# wrong refusal is a guard nobody keeps.
|
|
16
21
|
|
|
17
|
-
#
|
|
22
|
+
# Its own name in the observations: the refusal is written by the shared deny tail, not by the
|
|
23
|
+
# guard itself.
|
|
18
24
|
RT_GUARD_NAME=dev-server-guard
|
|
19
25
|
|
|
20
26
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
@@ -26,27 +32,27 @@ input="$RT_HOOK_INPUT"
|
|
|
26
32
|
tool="$(rt_hook_tool)"
|
|
27
33
|
case "$tool" in
|
|
28
34
|
Bash | mcp__webstorm__execute_terminal_command | mcp__webstorm__execute_tool) ;;
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
35
|
+
# A ready run configuration does not show the command line — only its name is visible. Hence
|
|
36
|
+
# the rule: "serve", "dev" and "start" in the name are refused, because the guard cannot check
|
|
37
|
+
# what stands behind them, and a second server costs more than an extra refusal.
|
|
32
38
|
mcp__webstorm__execute_run_configuration)
|
|
33
39
|
name="$(printf '%s' "$input" | jq -r '.tool_input.configurationName // empty' 2>/dev/null)"
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
40
|
+
# The tool's second mode is a temporary configuration made of a file and a line: it has
|
|
41
|
+
# no name at all, and the check by name let it through. That is exactly how a script from
|
|
42
|
+
# the package manifest is raised.
|
|
37
43
|
if [ -z "$name" ]; then
|
|
38
44
|
file="$(printf '%s' "$input" | jq -r '.tool_input.filePath // empty' 2>/dev/null)"
|
|
39
45
|
case "$file" in
|
|
40
46
|
*/package.json|package.json)
|
|
41
|
-
echo "
|
|
47
|
+
echo "A launch of a script straight from the manifest: the guard sees only the file and the line, not the script itself, so it cannot tell raising a server from a build. The applications are already raised by the owner — if a build or a test is needed, run them by a command in the terminal." >&2
|
|
42
48
|
exit 2 ;;
|
|
43
49
|
esac
|
|
44
50
|
exit 0
|
|
45
51
|
fi
|
|
46
|
-
#
|
|
52
|
+
# The word "start" without a boundary also caught "restart", which raises no server.
|
|
47
53
|
case "$(printf '%s' "$name" | tr '[:upper:]' '[:lower:]')" in
|
|
48
54
|
*serve*|*dev*|start*|*\ start*|*:start*)
|
|
49
|
-
echo "
|
|
55
|
+
echo "The configuration «${name}» looks like raising a development server, and the applications are already raised by the owner — check those. If the configuration does something else, run it by a command: by the name alone the guard does not see the content." >&2
|
|
50
56
|
exit 2 ;;
|
|
51
57
|
esac
|
|
52
58
|
exit 0 ;;
|
|
@@ -56,9 +62,9 @@ esac
|
|
|
56
62
|
cmd="$(rt_hook_cmd)"
|
|
57
63
|
[ -z "$cmd" ] && exit 0
|
|
58
64
|
|
|
59
|
-
#
|
|
60
|
-
#
|
|
61
|
-
#
|
|
65
|
+
# The universal executor of the environment passes the real command as a nested string. It is the
|
|
66
|
+
# one to parse, not the wrapper: otherwise the runner name stands right after a quote and no rule
|
|
67
|
+
# reaches it.
|
|
62
68
|
if [ "$tool" = "mcp__webstorm__execute_tool" ] && command -v perl >/dev/null 2>&1; then
|
|
63
69
|
inner="$(printf '%s' "$cmd" | perl -0ne '
|
|
64
70
|
if (/--command(?:=|\s+)(?:"((?:[^"\\]|\\.)*)"|\x27([^\x27]*)\x27|(.+))/s) {
|
|
@@ -68,14 +74,14 @@ if [ "$tool" = "mcp__webstorm__execute_tool" ] && command -v perl >/dev/null 2>&
|
|
|
68
74
|
[ -n "$inner" ] && cmd="$inner"
|
|
69
75
|
fi
|
|
70
76
|
|
|
71
|
-
#
|
|
72
|
-
#
|
|
77
|
+
# Git listens on no port, while message and branch texts freely contain words like "serve" —
|
|
78
|
+
# without this branch the guard catches its own commit about itself.
|
|
73
79
|
case "$cmd" in
|
|
74
80
|
git\ *|*/git\ *)
|
|
75
81
|
printf '%s' "$cmd" | grep -qE '(^|[[:space:]])git[[:space:]]+daemon([[:space:]]|$)' || exit 0 ;;
|
|
76
82
|
esac
|
|
77
83
|
|
|
78
|
-
#
|
|
84
|
+
# The tree profile: first the package default, and over it the project override, if there is one.
|
|
79
85
|
rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
80
86
|
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
|
|
81
87
|
# shellcheck disable=SC1090
|
|
@@ -90,39 +96,40 @@ command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
|
|
|
90
96
|
|
|
91
97
|
deny() {
|
|
92
98
|
if [ -n "$stands" ]; then
|
|
93
|
-
echo "$1
|
|
99
|
+
echo "$1 The applications are already raised by the owner: ${stands} — check those. Do not raise an instance of your own; if a port does not answer, tell the owner instead of launching a second one. $(rt_deny_tail)" >&2
|
|
94
100
|
else
|
|
95
|
-
echo "$1
|
|
101
|
+
echo "$1 The applications are already raised by the owner — check those. Do not raise an instance of your own; if a port does not answer, tell the owner instead of launching a second one. $(rt_deny_tail)" >&2
|
|
96
102
|
fi
|
|
97
103
|
exit 2
|
|
98
104
|
}
|
|
99
105
|
|
|
100
|
-
#
|
|
101
|
-
#
|
|
106
|
+
# The runners are listed outright. A group meaning "any word before the name" refused even a note
|
|
107
|
+
# saying that the server is raised by the owner.
|
|
102
108
|
RUNNER='((npx|pnpm|yarn|bun|npm)([[:space:]]+(exec|run|dlx))?[[:space:]]+)?'
|
|
103
109
|
|
|
104
|
-
#
|
|
105
|
-
#
|
|
110
|
+
# The start of a call: the start of the line or a command separator. A quote must not be put into
|
|
111
|
+
# the boundary — then a text search and killing a process by pattern read as a start.
|
|
106
112
|
BOUND="$RT_CMD_BOUND"
|
|
107
113
|
|
|
108
114
|
printf '%s' "$cmd" | grep -qE "${BOUND}${RUNNER}(nx|ng)[[:space:]]+(run[[:space:]]+[^[:space:]]*:)?(serve|dev)" \
|
|
109
|
-
&& deny "
|
|
115
|
+
&& deny "A launch of one more development server through the framework."
|
|
110
116
|
|
|
111
|
-
#
|
|
112
|
-
#
|
|
117
|
+
# Requiring a space right after the name broke the match on a colon: the guard let through scripts
|
|
118
|
+
# like "serve:site" — that is, exactly the commands it is written for.
|
|
113
119
|
printf '%s' "$cmd" | grep -qE "${BOUND}(npm|pnpm|yarn|bun)([[:space:]]+run)?[[:space:]]+(dev|start|serve)([:._-][A-Za-z0-9:._-]*)?([[:space:]]|\$)" \
|
|
114
|
-
&& deny "
|
|
120
|
+
&& deny "A launch of one more development server through the package runner."
|
|
115
121
|
|
|
116
|
-
#
|
|
117
|
-
#
|
|
122
|
+
# The subcommand is mandatory: while it was optional, the bare name of the bundler fell under the
|
|
123
|
+
# rule — that is, any one-liner where it occurs inside the text.
|
|
118
124
|
printf '%s' "$cmd" | grep -qE "${BOUND}${RUNNER}vite([[:space:]]+(dev|serve|preview))?[[:space:]]*(\$|[;&|\"'])" \
|
|
119
|
-
&& deny "
|
|
125
|
+
&& deny "A launch of one more development server."
|
|
120
126
|
printf '%s' "$cmd" | grep -qE "${BOUND}${RUNNER}(next|astro|nuxt)[[:space:]]+(dev|start|preview)([[:space:]]|\$)" \
|
|
121
|
-
&& deny "
|
|
127
|
+
&& deny "A launch of one more development server."
|
|
122
128
|
|
|
123
|
-
#
|
|
124
|
-
#
|
|
129
|
+
# Static files served over a build are the same second instance. Every name sits under the shared
|
|
130
|
+
# anchor of the command start: without it a package listing and a search through documents read as
|
|
131
|
+
# a start.
|
|
125
132
|
printf '%s' "$cmd" | grep -qE "${BOUND}(python3?[[:space:]]+-m[[:space:]]+http\.server|${RUNNER}(http-server|live-server|serve)([[:space:]]|\$))" \
|
|
126
|
-
&& deny "
|
|
133
|
+
&& deny "Raising a static server on top of a build — the same second instance."
|
|
127
134
|
|
|
128
135
|
exit 0
|
package/assets/hooks/dispatch.sh
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
#
|
|
2
|
+
# The dispatcher of agent events. NOT a guard: it has no `rt-hook:` declaration — on the contrary,
|
|
3
|
+
# it reads such declarations in the others. In the agent settings it stands alone on an event
|
|
4
|
+
# instead of a list.
|
|
4
5
|
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
6
|
+
# Why it exists. The agent calls every guard in a process of its own and feeds each of them the same
|
|
7
|
+
# input. There are eighteen guards on a tool call, and each parses the input anew — six or seven
|
|
8
|
+
# calls of the parser. The measurement of this tree: eight hundred and twenty-six milliseconds per
|
|
9
|
+
# call, of which eighty-five are the starting of shells, and the rest is repeated parsing of one
|
|
10
|
+
# text.
|
|
9
11
|
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
12
|
+
# What it does. It reads the input once, parses it once, puts the fields into the environment and
|
|
13
|
+
# calls the branches of the event in order. The first non-zero return code is given to the agent
|
|
14
|
+
# together with the output of the guard — the remaining branches are not called: a refusal ended the
|
|
15
|
+
# call at the very first guard before as well.
|
|
13
16
|
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
17
|
+
# What it does not do. It judges nothing itself and replaces no guard: the files stay as they were,
|
|
18
|
+
# the entry point changes. The event and the call pattern are carried by the guard itself, by the
|
|
19
|
+
# `# rt-hook:` line in its header, and the map is assembled from them — a list written out
|
|
20
|
+
# separately would diverge from the set of files at the very first one added.
|
|
18
21
|
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
22
|
+
# FAIL-OPEN, IN FAVOUR OF WORK: no event in the argument, no guards directory, no parser — exit with
|
|
23
|
+
# zero. A broken dispatcher has no right to jam the work.
|
|
21
24
|
|
|
22
25
|
set -u
|
|
23
26
|
|
|
@@ -30,15 +33,15 @@ event="${1:-}"
|
|
|
30
33
|
input="$(cat 2>/dev/null)"
|
|
31
34
|
[ -z "$input" ] && exit 0
|
|
32
35
|
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
+
# One parse for all the branches: four fields by one call of the parser instead of six per guard.
|
|
37
|
+
# The values arrive already quoted for the shell — that is what `@sh` in the parser is made for: the
|
|
38
|
+
# command line holds both quotes and newlines, and there is no other way to substitute it.
|
|
36
39
|
assignments="$(printf '%s' "$input" | jq -r '@sh "RT_HOOK_TOOL=\(.tool_name // "") RT_HOOK_CMD=\(.tool_input.command // "") RT_HOOK_FILE=\(.tool_input.file_path // "") RT_HOOK_CWD=\(.cwd // "") RT_HOOK_SOURCE=\(.source // "")"' 2>/dev/null)"
|
|
37
40
|
if [ -n "$assignments" ]; then
|
|
38
41
|
eval "$assignments" 2>/dev/null || true
|
|
39
42
|
export RT_HOOK_TOOL RT_HOOK_CMD RT_HOOK_FILE RT_HOOK_CWD RT_HOOK_SOURCE
|
|
40
|
-
#
|
|
41
|
-
#
|
|
43
|
+
# The sign of parsing: by it the branches tell a ready field from an empty variable that ended
|
|
44
|
+
# up in the run environment by chance. Without it an empty value reads as "there is no field".
|
|
42
45
|
export RT_HOOK_PARSED=1
|
|
43
46
|
fi
|
|
44
47
|
export RT_HOOK_INPUT="$input"
|
|
@@ -46,9 +49,10 @@ export RT_HOOK_INPUT="$input"
|
|
|
46
49
|
branches="$(grep -l '^# rt-hook:' "$here"/*.sh 2>/dev/null | sort)"
|
|
47
50
|
[ -z "$branches" ] && exit 0
|
|
48
51
|
|
|
49
|
-
#
|
|
50
|
-
#
|
|
51
|
-
#
|
|
52
|
+
# A file happens to have several declarations: a guard standing both on a tool call and on the end
|
|
53
|
+
# of a turn names both events by lines of its own. Before, only the first was read — and the second
|
|
54
|
+
# branch was never called, silently: from the outside that is indistinguishable from a guard that
|
|
55
|
+
# looked and let through.
|
|
52
56
|
collected=""
|
|
53
57
|
for branch in $branches; do
|
|
54
58
|
matched=0
|
|
@@ -58,15 +62,15 @@ for branch in $branches; do
|
|
|
58
62
|
branch_event="${declaration%% *}"
|
|
59
63
|
[ "$branch_event" = "$event" ] || continue
|
|
60
64
|
|
|
61
|
-
#
|
|
62
|
-
#
|
|
65
|
+
# The call pattern: there is none at all — the guard is called on any; there is one — it is
|
|
66
|
+
# matched in full, not by a piece. A star and a dot with a star mean the same: any call.
|
|
63
67
|
#
|
|
64
|
-
#
|
|
65
|
-
#
|
|
66
|
-
# `resume`, `compact`, `clear`.
|
|
67
|
-
#
|
|
68
|
-
#
|
|
69
|
-
#
|
|
68
|
+
# The subject of the match depends on the event. For a tool call it is the tool name; at the
|
|
69
|
+
# entry into a session there is no tool name, and the pattern there names the kind of start
|
|
70
|
+
# — `startup`, `resume`, `compact`, `clear`. A match against an empty name never coincided,
|
|
71
|
+
# and not a single entry hook was called through the dispatcher: the session began without
|
|
72
|
+
# the body of laws, without the glossary, without the work state and without the handover of
|
|
73
|
+
# the previous session — with a zero code and empty output.
|
|
70
74
|
matcher="${declaration#"$branch_event"}"
|
|
71
75
|
matcher="${matcher#"${matcher%%[![:space:]]*}"}"
|
|
72
76
|
subject="${RT_HOOK_TOOL:-}"
|
|
@@ -81,14 +85,15 @@ for branch in $branches; do
|
|
|
81
85
|
$(sed -n 's/^# rt-hook:[[:space:]]*//p' "$branch" 2>/dev/null)
|
|
82
86
|
EOF
|
|
83
87
|
|
|
84
|
-
#
|
|
85
|
-
#
|
|
88
|
+
# At least one declaration matched — the branch is called once. Two declarations of one event in
|
|
89
|
+
# one file would call the guard twice on one input, and the second call would judge the same
|
|
90
|
+
# thing.
|
|
86
91
|
[ "$matched" = 1 ] || continue
|
|
87
92
|
|
|
88
|
-
#
|
|
89
|
-
#
|
|
90
|
-
#
|
|
91
|
-
#
|
|
93
|
+
# The error stream of a branch is collected separately, not discarded: on a successful turn it
|
|
94
|
+
# is noise and does not go out, and on a refusal it is the reason itself. A guard that prints
|
|
95
|
+
# its refusal there reached the executor as a line about a broken file — with the file whole and
|
|
96
|
+
# the text plain, which nobody saw. In one session two refusals in a row were lost that way.
|
|
92
97
|
branch_err="$(mktemp 2>/dev/null)"
|
|
93
98
|
if [ -n "$branch_err" ]; then
|
|
94
99
|
branch_out="$(printf '%s' "$input" | bash "$branch" 2>"$branch_err")"
|
|
@@ -106,19 +111,28 @@ EOF
|
|
|
106
111
|
elif [ -n "$said_err" ]; then
|
|
107
112
|
printf '%s\n' "$said_err"
|
|
108
113
|
else
|
|
109
|
-
#
|
|
110
|
-
#
|
|
111
|
-
#
|
|
112
|
-
|
|
114
|
+
# The branch exited non-zero and said nothing by either stream. From the outside that
|
|
115
|
+
# is indistinguishable from a refusal on the merits, and there is nothing to fix: nobody
|
|
116
|
+
# knows which file is broken. So the dispatcher names it itself, otherwise nothing says
|
|
117
|
+
# anything about a broken branch.
|
|
118
|
+
printf 'The guard %s exited with code %s and printed nothing: the file looks broken.\n' \
|
|
113
119
|
"$(basename "$branch")" "$code"
|
|
114
120
|
fi
|
|
115
121
|
exit "$code"
|
|
116
122
|
fi
|
|
117
123
|
|
|
118
|
-
#
|
|
119
|
-
#
|
|
120
|
-
#
|
|
121
|
-
|
|
124
|
+
# A refusal from a branch comes not as a return code but as a decision in the output: the guards
|
|
125
|
+
# of the end of a turn print it and exit with zero. Without stopping here, the dispatcher would
|
|
126
|
+
# glue this object to the output of the next branch — and what is glued together is not parsed,
|
|
127
|
+
# so the refusal is lost entirely. There are two forms of a refusal under a zero code: the block
|
|
128
|
+
# decision of the guards of the end of a turn and the call-denied decision of the guards of an
|
|
129
|
+
# edit. The second was not recognised at all — the refusal went into the shared collected output
|
|
130
|
+
# and was glued to the output of a neighbouring branch, and what is glued together is not
|
|
131
|
+
# parsed: a guard called on its own answered with a denial, while through the dispatcher the
|
|
132
|
+
# refusal was lost entirely.
|
|
133
|
+
if [ -n "$branch_out" ] && printf '%s' "$branch_out" | jq -e '
|
|
134
|
+
.decision == "block" or .hookSpecificOutput.permissionDecision == "deny"
|
|
135
|
+
' >/dev/null 2>&1; then
|
|
122
136
|
printf '%s\n' "$branch_out"
|
|
123
137
|
exit 0
|
|
124
138
|
fi
|
|
@@ -127,7 +141,7 @@ EOF
|
|
|
127
141
|
"
|
|
128
142
|
done
|
|
129
143
|
|
|
130
|
-
#
|
|
144
|
+
# Not one branch refused: what they printed is given out — hints and digests.
|
|
131
145
|
[ -n "${collected:-}" ] && printf '%s' "$collected"
|
|
132
146
|
|
|
133
147
|
exit 0
|