@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,46 +1,50 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: PreToolUse Bash|mcp__webstorm__execute_sql_query|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool
|
|
3
|
-
#
|
|
4
|
-
#
|
|
3
|
+
# Requires: hooks/deny-tail.sh
|
|
4
|
+
# Guard of writing queries to the storage. PreToolUse.
|
|
5
5
|
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
6
|
+
# An edit of data is the only action that cannot be undone by an edit of code. A delete by mask
|
|
7
|
+
# one day takes the real records away along with the trial ones: the mask matches wider than the
|
|
8
|
+
# query author expected, and this is learned only from the restore out of a copy.
|
|
9
9
|
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
10
|
+
# Hence the rule: rows are addressed by primary key. A list of identifiers touches exactly as
|
|
11
|
+
# many rows as are listed, and a miss is visible before execution; a selection by substring is
|
|
12
|
+
# never visible.
|
|
13
13
|
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
14
|
+
# Three levels:
|
|
15
|
+
# refusal — drop, truncate, schema edit, delete and update without a condition or with a
|
|
16
|
+
# condition not by identifier;
|
|
17
|
+
# question — the rest of writing: an addressed edit and an insert, the decision is the owner's;
|
|
18
|
+
# pass — reading.
|
|
19
19
|
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
20
|
+
# Each subject of the parsing lives in a helper of its own next door: the query out of the input
|
|
21
|
+
# — `sql-guard-request.sh`, bringing the command to one form and cutting it into segments —
|
|
22
|
+
# `sql-guard-parse.sh`, the target together with the rules of the production database —
|
|
23
|
+
# `sql-guard-target.sh`, the sign of writing, the destructive, migrations and row addressing —
|
|
24
|
+
# `sql-guard-write.sh`. What stays here is the order: it calls them and decides.
|
|
24
25
|
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
26
|
+
# The production storage is separate: its addresses and connections are listed by the tree
|
|
27
|
+
# profile —
|
|
28
|
+
# RT_PROD_DSN — the pattern of the production database address: tunnel port, host,
|
|
29
|
+
# domain;
|
|
30
|
+
# RT_PROD_CONNECTIONS — identifiers of the IDE's production connections;
|
|
31
|
+
# RT_LOCAL_CONNECTIONS — the same for local ones: a recognised local connection outweighs any
|
|
32
|
+
# textual guess;
|
|
33
|
+
# RT_SCRATCH_PORT_RE — ports of throwaway databases, for which no question is asked.
|
|
34
|
+
# At a production address any write is refused without an opt-out: production is edited by a
|
|
35
|
+
# migration through the rollout, not by a query from the editor.
|
|
33
36
|
#
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
+
# The opt-out for the remaining cases: the `destructive-ok` marker in the query text together
|
|
38
|
+
# with an explanation of why addressing by identifier does not fit lowers the refusal to a
|
|
39
|
+
# question. The last word stays with the owner — the guard only does not let it through silently.
|
|
37
40
|
#
|
|
38
|
-
#
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
#
|
|
41
|
+
# FAIL-OPEN: no parser, broken input, foreign tool — pass. Without `perl` there is nothing to cut
|
|
42
|
+
# commit message text out with, so in that case commands that work with history are passed
|
|
43
|
+
# entirely — otherwise the words "drop" and "update" in a commit description would read as a
|
|
44
|
+
# query. A query is never delivered inside such a command, so the concession costs nothing.
|
|
42
45
|
|
|
43
|
-
#
|
|
46
|
+
# Own name in the observations: the refusal is written by the shared refusal tail, not by the
|
|
47
|
+
# guard itself.
|
|
44
48
|
RT_GUARD_NAME=sql-guard
|
|
45
49
|
|
|
46
50
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
@@ -53,22 +57,22 @@ command -v jq >/dev/null 2>&1 || exit 0
|
|
|
53
57
|
|
|
54
58
|
tool="$(rt_hook_tool)"
|
|
55
59
|
|
|
56
|
-
#
|
|
57
|
-
#
|
|
60
|
+
# The working directory is needed by one rule — resolving the migration address: `DATABASE_URL`
|
|
61
|
+
# is usually not named in the command and lies in `.env` next to the project.
|
|
58
62
|
hook_cwd="$(printf '%s' "$input" | jq -r '.cwd // empty' 2>/dev/null)"
|
|
59
63
|
[ -z "$hook_cwd" ] && hook_cwd="${CLAUDE_PROJECT_DIR:-.}"
|
|
60
64
|
|
|
61
|
-
#
|
|
62
|
-
#
|
|
65
|
+
# The tree profile: first the package default, on top of it the project override, if there is
|
|
66
|
+
# one. The default is also looked for next to the hook itself: they travel together.
|
|
63
67
|
rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
64
68
|
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
|
|
65
69
|
# shellcheck disable=SC1090
|
|
66
70
|
[ -f "$profile" ] && . "$profile" 2>/dev/null
|
|
67
71
|
done
|
|
68
72
|
|
|
69
|
-
#
|
|
70
|
-
#
|
|
71
|
-
#
|
|
73
|
+
# The helpers lie next to the guard and travel into the tree with it. If even one is missing,
|
|
74
|
+
# there is nothing to parse the command with, and the guard passes the move: the fail-open here
|
|
75
|
+
# is the same as when `jq` is absent.
|
|
72
76
|
for helper in sql-guard-request.sh sql-guard-parse.sh sql-guard-target.sh sql-guard-write.sh; do
|
|
73
77
|
[ -f "$rt_hooks_dir/$helper" ] || exit 0
|
|
74
78
|
# shellcheck disable=SC1090
|
|
@@ -77,8 +81,9 @@ done
|
|
|
77
81
|
|
|
78
82
|
PROD_DSN="${RT_PROD_DSN:-}"
|
|
79
83
|
|
|
80
|
-
#
|
|
81
|
-
#
|
|
84
|
+
# The shared refusal tail: two lawful moves and the lawful form of bypass, when the refusal has
|
|
85
|
+
# one. The file may not be laid out — then there is no tail, and the reason for the refusal stays
|
|
86
|
+
# as it was.
|
|
82
87
|
# shellcheck disable=SC1090
|
|
83
88
|
[ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
|
|
84
89
|
&& . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
|
|
@@ -117,11 +122,11 @@ sql_check_destructive
|
|
|
117
122
|
sql_check_migrations
|
|
118
123
|
sql_check_addressing
|
|
119
124
|
|
|
120
|
-
# ---
|
|
121
|
-
#
|
|
122
|
-
#
|
|
125
|
+
# --- the rest of writing: the user decides -------------------------------------------------
|
|
126
|
+
# An unknown connection is no reason to pass silently: the target of the query is not recognised,
|
|
127
|
+
# and it may turn out to be the production database under another identifier.
|
|
123
128
|
if [ "$conn_known" = "" ] && [ -n "$conn" ]; then
|
|
124
|
-
ask "
|
|
129
|
+
ask "A write into the database through a CONNECTION UNKNOWN TO THE GUARD (id ${conn}). The guard knows the local connection and the production one; this is neither, so make sure the request does not go to production. If the connection is permanent, write its id into PROD_CONNECTIONS or LOCAL_CONNECTIONS in .claude/hooks/sql-guard.sh."
|
|
125
130
|
fi
|
|
126
131
|
|
|
127
|
-
ask "
|
|
132
|
+
ask "A write into the database (${context}). Check that only the expected rows are touched, and confirm."
|
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: Stop
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
3
|
+
# Requires: hooks/deny-tail.sh
|
|
4
|
+
# Guard of signing in to the stand. The Stop event. It does not let a turn end in which the executor
|
|
5
|
+
# asks the owner to sign in to the stand or to type a password.
|
|
6
6
|
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
7
|
+
# Why. The stand, the sign-in and the accounts for checking are prepared by the agent. That demand
|
|
8
|
+
# rested only on the executor's memory and did not hold: in one session the request "sign in
|
|
9
|
+
# yourself" or "type the password" sounded four times in a row, each time with a new reason — the
|
|
10
|
+
# field does not take input, a foreign extension is installed in the browser, the profile switched
|
|
11
|
+
# off. The reason is real, so the request looks fitting; but the obstacle must be removed by the
|
|
12
|
+
# agent all the same.
|
|
12
13
|
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
14
|
+
# The guard stands at the end of the turn, not at a tool call: the request is written as the text of
|
|
15
|
+
# the reply, and until the turn ends it is not visible.
|
|
15
16
|
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
17
|
+
# The boundary. The guard checks a set of patterns: a verb of asking next to a word about a
|
|
18
|
+
# password, a sign-in or a form. A request in other words, or through a menu of options, the guard
|
|
19
|
+
# does not recognise. The set grows by an edit; its completeness is not guaranteed.
|
|
19
20
|
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
21
|
+
# What is allowed: asking to switch to the ordinary mode of work instead of the automatic one. The
|
|
22
|
+
# typing is done by the agent, only the mode is asked of the owner — the guard tells these requests
|
|
23
|
+
# apart.
|
|
22
24
|
#
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
+
# On an error the guard passes: on a failure, a missing turn record and a repeated call the turn is
|
|
26
|
+
# ALLOWED. A broken guard must not block the conversation.
|
|
25
27
|
|
|
26
|
-
#
|
|
28
|
+
# The guard's name for the observations: it is written by the shared deny tail.
|
|
27
29
|
RT_GUARD_NAME=stand-login-guard
|
|
28
30
|
|
|
29
31
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
@@ -35,7 +37,7 @@ input="$RT_HOOK_INPUT"
|
|
|
35
37
|
|
|
36
38
|
command -v jq >/dev/null 2>&1 || exit 0
|
|
37
39
|
|
|
38
|
-
#
|
|
40
|
+
# A repeated call on the same turn is not judged: the guard says its refusal once.
|
|
39
41
|
active="$(printf '%s' "$input" | jq -r '.stop_hook_active // false' 2>/dev/null)"
|
|
40
42
|
[ "$active" = "true" ] && exit 0
|
|
41
43
|
|
|
@@ -43,16 +45,17 @@ transcript="$(printf '%s' "$input" | jq -r '.transcript_path // empty' 2>/dev/nu
|
|
|
43
45
|
[ -z "$transcript" ] && exit 0
|
|
44
46
|
[ -f "$transcript" ] || exit 0
|
|
45
47
|
|
|
46
|
-
#
|
|
47
|
-
#
|
|
48
|
+
# The patterns of the request. The first group is a request to type instead of the agent, the
|
|
49
|
+
# second a request to sign in oneself. A word about the mode of work is not in the set: asking for
|
|
50
|
+
# it is allowed.
|
|
48
51
|
asked_re='(введи|введите|набери|наберите|вбей|вбейте|заполни|заполните|подставь|вставь)[^.!?\n]{0,40}(пароль|учётн|учетн|логин|креды|форму входа)'
|
|
49
52
|
asked_re="$asked_re"'|(войди|войдите|залогинься|залогиньтесь|авторизуйся|авторизуйтесь)[^.!?\n]{0,40}(сам|сами|рукой|руками|за меня|вместо меня|пожалуйста)?'
|
|
50
53
|
asked_re="$asked_re"'|(нужно|надо|прошу)[^.!?\n]{0,20}(чтобы ты|чтобы вы)?[^.!?\n]{0,20}(ввёл|ввел|ввели|вошёл|вошел|вошли)[^.!?\n]{0,30}(пароль|вход|систему)'
|
|
51
54
|
|
|
52
|
-
#
|
|
53
|
-
#
|
|
55
|
+
# The turn is everything recorded after the owner's last real input. A tool answer arrives under the
|
|
56
|
+
# same role, so lines with `tool_result` do not count as input.
|
|
54
57
|
#
|
|
55
|
-
#
|
|
58
|
+
# The last 400 lines are read: the record grows all session long, and only the last turn is judged.
|
|
56
59
|
verdict="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r --arg re "$asked_re" '
|
|
57
60
|
def is_input:
|
|
58
61
|
.type == "user"
|
|
@@ -64,28 +67,28 @@ verdict="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r --arg re "$asked_re"
|
|
|
64
67
|
(map(is_input) | rindex(true)) as $i
|
|
65
68
|
| (if $i == null then . else .[$i + 1:] end) as $turn
|
|
66
69
|
| [$turn[] | select(.type == "assistant") | (.message.content // [])[] | select(.type == "text") | .text] as $texts
|
|
67
|
-
#
|
|
68
|
-
#
|
|
70
|
+
# Case is ignored by a flag, not by lowercasing: lowercasing works only for the Latin alphabet,
|
|
71
|
+
# and a request written with a capital letter would not match the pattern.
|
|
69
72
|
| if (($texts | join("\n")) | test($re; "i")) then "asked" else "pass" end
|
|
70
73
|
' 2>/dev/null)"
|
|
71
74
|
|
|
72
75
|
[ "$verdict" = "asked" ] || exit 0
|
|
73
76
|
|
|
74
|
-
reason="BLOCKED by stand-login-guard:
|
|
77
|
+
reason="BLOCKED by stand-login-guard: the executor asks the owner to sign in or to enter a password. The stand, the sign-in and the accounts for checking are prepared by the agent. An obstacle before the asking — a field that does not accept input, a foreign extension in the browser, a profile that dropped out — is removed by the agent.
|
|
75
78
|
|
|
76
|
-
|
|
79
|
+
How to remove the obstacle by yourself:
|
|
77
80
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
substitute the value by the form tool through a reference to the element
|
|
82
|
+
switch off the interfering extension in the browser profile
|
|
83
|
+
raise the stand on another address
|
|
84
|
+
sign in with a pair from the seed of the local database instead of a production account
|
|
82
85
|
|
|
83
|
-
|
|
86
|
+
What is asked of the owner is the mode of work, not input: the ordinary mode instead of the automatic one; the sign-in in it is done by the agent, and the automatic mode is returned by the same turn.
|
|
84
87
|
|
|
85
|
-
|
|
88
|
+
The guard checks one turn: the next session is not blocked."
|
|
86
89
|
|
|
87
|
-
#
|
|
88
|
-
#
|
|
90
|
+
# The shared deny tail: two lawful moves. The file may not be laid out — then there is no tail, and
|
|
91
|
+
# the reason for the refusal stays.
|
|
89
92
|
# shellcheck disable=SC1090
|
|
90
93
|
[ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
|
|
91
94
|
&& . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
|
|
@@ -96,6 +99,6 @@ deny_tail_text="$(rt_deny_tail "")"
|
|
|
96
99
|
${deny_tail_text}"
|
|
97
100
|
|
|
98
101
|
jq -n --arg r "$reason" '{decision:"block",reason:$r}' 2>/dev/null \
|
|
99
|
-
|| printf '{"decision":"block","reason":"stand-login-guard:
|
|
102
|
+
|| printf '{"decision":"block","reason":"stand-login-guard: the sign-in to the stand is done by the agent, not by the owner."}\n'
|
|
100
103
|
|
|
101
104
|
exit 0
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: SessionStart startup|resume|compact|clear
|
|
3
|
-
#
|
|
4
|
-
# SessionStart:
|
|
3
|
+
# Requires: hooks/profile-check.sh
|
|
4
|
+
# SessionStart: the state of unfinished work goes into the context at every start of a session.
|
|
5
5
|
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
6
|
+
# It is not held by memory for the same reason as the glossary: the plan is read before a file is
|
|
7
|
+
# edited, and a conversation with the owner starts with a question — and the session answers without
|
|
8
|
+
# knowing that the work is already half done. Here the plan and the progress arrive before the first
|
|
9
|
+
# reply, and the owner does not have to retell what is already written down.
|
|
10
10
|
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
11
|
+
# The grill (`grill.md`) is given as a path, not as text: it does not change, it is bulky and it is
|
|
12
|
+
# needed less often than the rest.
|
|
13
13
|
#
|
|
14
|
-
# FAIL-OPEN:
|
|
15
|
-
#
|
|
14
|
+
# FAIL-OPEN: no `jq`, not a git repository, no task folder — we exit silently. The session matters
|
|
15
|
+
# more than the context.
|
|
16
16
|
|
|
17
17
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
18
18
|
|
|
@@ -24,15 +24,15 @@ git rev-parse --is-inside-work-tree >/dev/null 2>&1 || exit 0
|
|
|
24
24
|
branch="$(git branch --show-current 2>/dev/null)"
|
|
25
25
|
[ -z "$branch" ] && exit 0
|
|
26
26
|
|
|
27
|
-
#
|
|
27
|
+
# The tree profile: first the package default, and over it the project override, if there is one.
|
|
28
28
|
rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
29
29
|
for profile in "$rt_hooks_dir/../rt-kit/defaults/project.sh" "$rt_hooks_dir/../defaults/project.sh" "$ROOT/.claude/rt-kit/defaults/project.sh" "$ROOT/.claude/rt-kit/project.sh"; do
|
|
30
30
|
# shellcheck disable=SC1090
|
|
31
31
|
[ -f "$profile" ] && . "$profile" 2>/dev/null
|
|
32
32
|
done
|
|
33
33
|
|
|
34
|
-
#
|
|
35
|
-
#
|
|
34
|
+
# A word about a missing profile function: a hook that exited silently is indistinguishable from a
|
|
35
|
+
# working one. The file may not be laid out — then the former behaviour stays, the silent one.
|
|
36
36
|
# shellcheck disable=SC1090
|
|
37
37
|
[ -f "$rt_hooks_dir/profile-check.sh" ] && . "$rt_hooks_dir/profile-check.sh"
|
|
38
38
|
command -v rt_needs >/dev/null 2>&1 || rt_needs() { command -v "$1" >/dev/null 2>&1; }
|
|
@@ -49,15 +49,18 @@ emit() {
|
|
|
49
49
|
jq -Rs '{hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:.}}' 2>/dev/null
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
#
|
|
53
|
-
#
|
|
52
|
+
# A branch under a task without a folder — the work goes past the rule. We do not tear the session:
|
|
53
|
+
# a SessionStart that refuses the start leaves the owner without an agent at all, while a code edit
|
|
54
|
+
# will be caught by `task-flow-guard`.
|
|
54
55
|
if [ ! -d "$DIR" ]; then
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
-
#
|
|
56
|
+
# The folder is missing for two different reasons, and different things have to be said about
|
|
57
|
+
# them. The first — the work went past the rule. The second — the folder was taken apart by the
|
|
58
|
+
# branch itself with the last commit before the PR: that is a lawful outcome, and an instruction
|
|
59
|
+
# to build it again takes the session from the tail of the work back to its beginning.
|
|
58
60
|
#
|
|
59
|
-
#
|
|
60
|
-
#
|
|
61
|
+
# The branch history tells them apart: the folder removed by a commit of the branch after the
|
|
62
|
+
# common ancestor with the main one. The progress by that minute has gone with the folder, and
|
|
63
|
+
# the state is held by the PR and the session handover.
|
|
61
64
|
main_branch="${RT_MAIN_BRANCH:-main}"
|
|
62
65
|
base="$(git merge-base "origin/${main_branch}" HEAD 2>/dev/null || git merge-base "$main_branch" HEAD 2>/dev/null)"
|
|
63
66
|
dropped=''
|
|
@@ -65,46 +68,48 @@ if [ ! -d "$DIR" ]; then
|
|
|
65
68
|
|
|
66
69
|
if [ -n "$dropped" ]; then
|
|
67
70
|
{
|
|
68
|
-
printf '
|
|
69
|
-
printf '
|
|
70
|
-
printf '
|
|
71
|
-
printf '
|
|
72
|
-
printf '
|
|
71
|
+
printf 'WORK IS CLOSING — the task folder has been taken apart by this branch.\n\n'
|
|
72
|
+
printf 'The progress was removed with the folder: the state is held by the PR and the session handover.\n'
|
|
73
|
+
printf 'The folder is not rebuilt. A code edit after the folder was taken apart requires restoring it\n'
|
|
74
|
+
printf 'for the time of the edit and taking it apart again in the same commit. The order — skill `task-flow`,\n'
|
|
75
|
+
printf 'patterns `task-flow-close` and `task-flow-archive`.\n'
|
|
73
76
|
} | emit
|
|
74
77
|
exit 0
|
|
75
78
|
fi
|
|
76
79
|
|
|
77
80
|
if rt_needs rt_task_branch_ok task-context-load && rt_task_branch_ok "$branch"; then
|
|
78
81
|
{
|
|
79
|
-
printf '
|
|
80
|
-
printf '
|
|
81
|
-
printf '
|
|
82
|
-
printf '
|
|
83
|
-
#
|
|
84
|
-
#
|
|
85
|
-
#
|
|
86
|
-
#
|
|
82
|
+
printf 'WORK WITHOUT A TASK FOLDER.\n\n'
|
|
83
|
+
printf 'Branch `%s` is named after a task, and `%s/` is missing: there is nowhere to write the progress,\n' "$branch" "$DIR"
|
|
84
|
+
printf 'and the next session will start by questioning the owner.\n\n'
|
|
85
|
+
printf 'Build it from the template:\n\n cp -r %s/_template %s\n\n' "$TASKS_DIR" "$DIR"
|
|
86
|
+
# The folder happens to be named not by the branch name: the stages of one large task
|
|
87
|
+
# go as separate branches with one shared folder. A folder named by name is the only
|
|
88
|
+
# thing by which the session will find it; otherwise it reads the refusal as "there are
|
|
89
|
+
# no records" and answers the owner from the code, bypassing everything decided in those
|
|
90
|
+
# records.
|
|
87
91
|
others="$(find "$TASKS_DIR" -mindepth 1 -maxdepth 1 -type d ! -name '_template' 2>/dev/null | sort)"
|
|
88
92
|
if [ -n "$others" ]; then
|
|
89
|
-
printf '
|
|
90
|
-
printf '
|
|
91
|
-
printf '
|
|
93
|
+
printf 'The tasks directory meanwhile holds:\n\n%s\n\n' "$others"
|
|
94
|
+
printf 'Stages of one task go as separate branches with a shared folder: before\n'
|
|
95
|
+
printf 'concluding that there are no records, look into the folders named above.\n\n'
|
|
92
96
|
fi
|
|
93
|
-
#
|
|
94
|
-
#
|
|
95
|
-
#
|
|
97
|
+
# About a neighbouring resource — conditionally and by name: the package does not know
|
|
98
|
+
# whether it is laid out here, and what is said unconditionally arrives in the context
|
|
99
|
+
# of every session and lies about the tree all the more confidently because the tool
|
|
100
|
+
# prints it itself.
|
|
96
101
|
if [ -f "$rt_hooks_dir/task-flow-guard.sh" ]; then
|
|
97
|
-
printf '
|
|
102
|
+
printf 'Until then, an application code edit is refused by guard `task-flow-guard`. The rule — skill `task-flow`.\n'
|
|
98
103
|
else
|
|
99
|
-
printf '
|
|
104
|
+
printf 'The rule — skill `task-flow`. Guard `task-flow-guard` is not in this tree: nothing refuses a code edit until then.\n'
|
|
100
105
|
fi
|
|
101
106
|
} | emit
|
|
102
107
|
fi
|
|
103
108
|
exit 0
|
|
104
109
|
fi
|
|
105
110
|
|
|
106
|
-
#
|
|
107
|
-
#
|
|
111
|
+
# The size threshold. The progress grows with every session, and by the tenth session it costs more
|
|
112
|
+
# in full than it gives. Past the threshold we give "Where we stand" and the latest entries.
|
|
108
113
|
LIMIT=40000
|
|
109
114
|
size=0
|
|
110
115
|
for file in "$PLAN" "$PROGRESS"; do
|
|
@@ -113,36 +118,36 @@ for file in "$PLAN" "$PROGRESS"; do
|
|
|
113
118
|
done
|
|
114
119
|
|
|
115
120
|
{
|
|
116
|
-
printf '
|
|
117
|
-
printf '
|
|
118
|
-
printf '
|
|
119
|
-
printf '
|
|
121
|
+
printf 'WORK STATE — branch `%s`, folder `%s/`.\n\n' "$branch" "$DIR"
|
|
122
|
+
printf 'This was written by previous sessions. The owner is not asked about what is here.\n'
|
|
123
|
+
printf 'Done work is marked only in `progress.md`; `plan.md` is not edited along the way.\n'
|
|
124
|
+
printf 'How work is conducted — rule `task-flow`; returning to it — pattern `task-flow-resume`.\n\n'
|
|
120
125
|
|
|
121
126
|
if [ -f "$GRILL" ]; then
|
|
122
|
-
printf '
|
|
127
|
+
printf 'The grill of the owner'"'"'s request — `%s`, read when needed.\n\n' "$GRILL"
|
|
123
128
|
fi
|
|
124
129
|
|
|
125
130
|
if [ -f "$PLAN" ]; then
|
|
126
|
-
printf -- '---
|
|
131
|
+
printf -- '--- PLAN (`%s`) ---\n\n' "$PLAN"
|
|
127
132
|
if [ "$size" -le "$LIMIT" ]; then
|
|
128
133
|
cat "$PLAN"
|
|
129
134
|
else
|
|
130
135
|
sed -n '1,60p' "$PLAN"
|
|
131
|
-
printf '\n
|
|
136
|
+
printf '\n<cut for size — read in full: %s>\n' "$PLAN"
|
|
132
137
|
fi
|
|
133
138
|
printf '\n'
|
|
134
139
|
fi
|
|
135
140
|
|
|
136
141
|
if [ -f "$PROGRESS" ]; then
|
|
137
|
-
printf -- '---
|
|
142
|
+
printf -- '--- PROGRESS (`%s`) ---\n\n' "$PROGRESS"
|
|
138
143
|
if [ "$size" -le "$LIMIT" ]; then
|
|
139
144
|
cat "$PROGRESS"
|
|
140
145
|
else
|
|
141
|
-
#
|
|
142
|
-
LC_ALL=C awk '/^##
|
|
143
|
-
printf '\n
|
|
146
|
+
# The "Where we stand" section is rewritten by every session and survives any size.
|
|
147
|
+
LC_ALL=C awk '/^## (Where we stand|Где стоим)/{f=1} f&&/^## /&&!/^## (Where we stand|Где стоим)/{exit} f' "$PROGRESS"
|
|
148
|
+
printf '\n<cut for size. The latest entries:>\n\n'
|
|
144
149
|
tail -40 "$PROGRESS"
|
|
145
|
-
printf '\n
|
|
150
|
+
printf '\n<read in full: %s>\n' "$PROGRESS"
|
|
146
151
|
fi
|
|
147
152
|
fi
|
|
148
153
|
} | emit
|