@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,33 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: PreCompact .*
|
|
3
|
-
#
|
|
4
|
-
#
|
|
3
|
+
# Requires: hooks/profile-check.sh
|
|
4
|
+
# The session handover is written before the context is compacted, not by the hand of the executor.
|
|
5
5
|
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
6
|
+
# A session ends in two ways: the executor brings the work to a point and writes the handover
|
|
7
|
+
# himself — or the context overflows and the compaction comes from the tool. The second case used to
|
|
8
|
+
# lose the handover entirely: at that moment there is nobody left to write it, and after the
|
|
9
|
+
# compaction there is nothing to retell. At night, when there is nobody to remind, every session
|
|
10
|
+
# ends that way.
|
|
10
11
|
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
12
|
+
# The hook assembles the handover from what lies on disk: the progress gives the state and the next
|
|
13
|
+
# step, the tree gives the branch, the uncommitted and the commits over the main one. It adds
|
|
14
|
+
# nothing of its own: a handover retells what is written down, it does not replace it.
|
|
14
15
|
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
16
|
+
# It is put as a section into the progress of the task — where the state lies too. A file of its own
|
|
17
|
+
# outside the tree loses the handover on a move to another machine: the directory is closed off from
|
|
18
|
+
# the history, and work broken off by a filled window cannot be picked up from there — the state is
|
|
19
|
+
# in the progress, while the particulars of the session, the next step and what must not be done
|
|
20
|
+
# stay on the previous machine. No second record about one and the same thing appears: the section
|
|
21
|
+
# lives in the same file as "Where we stand" and travels into the branch with the same commit. The
|
|
22
|
+
# executor commits it — the hook does not know what else lies in the index.
|
|
21
23
|
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
+
# A file outside the tree stays the fallback path: for work without a task folder — on a detached
|
|
25
|
+
# head, on a branch without a created task — there is nowhere for the section to lie, while silence
|
|
26
|
+
# here costs a whole session.
|
|
24
27
|
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
+
# What is written by hand is not overwritten silently: there is one file, and the last write wins.
|
|
29
|
+
# An executor who closes the session by the rule writes over it — his handover is fuller, because he
|
|
30
|
+
# knows what is not on disk.
|
|
28
31
|
#
|
|
29
|
-
# FAIL-OPEN:
|
|
30
|
-
#
|
|
32
|
+
# FAIL-OPEN: no parser, empty input, not a repository, no handover directory — the hook exits with
|
|
33
|
+
# zero and stays silent. It never refuses the compaction: a stopped compaction leaves the session
|
|
34
|
+
# without room.
|
|
31
35
|
|
|
32
36
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
33
37
|
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
@@ -50,9 +54,10 @@ workdir="$(rt_hook_cwd)"
|
|
|
50
54
|
cd "$workdir" 2>/dev/null || exit 0
|
|
51
55
|
git rev-parse --is-inside-work-tree >/dev/null 2>&1 || exit 0
|
|
52
56
|
|
|
53
|
-
#
|
|
54
|
-
#
|
|
55
|
-
#
|
|
57
|
+
# An empty branch name does not stop the hook. On a detached head there is no name, and everything
|
|
58
|
+
# that goes into the handover lies in the tree and is available in full: the name is needed only by
|
|
59
|
+
# the file. The former exit with zero was complete silence — the compaction came without a handover,
|
|
60
|
+
# and the session after it started from an empty place.
|
|
56
61
|
branch="$(git branch --show-current 2>/dev/null)"
|
|
57
62
|
head_name=""
|
|
58
63
|
if [ -z "$branch" ]; then
|
|
@@ -70,93 +75,95 @@ tasks_dir="${RT_TASKS_DIR:-docs/tasks}"
|
|
|
70
75
|
mkdir -p "$root/$handoff_dir" 2>/dev/null || exit 0
|
|
71
76
|
[ -d "$root/$handoff_dir" ] || exit 0
|
|
72
77
|
|
|
73
|
-
#
|
|
74
|
-
#
|
|
75
|
-
#
|
|
78
|
+
# Manual compaction differs from automatic in one thing: at a manual one the executor is at the
|
|
79
|
+
# keyboard and can add to the handover himself. It is written in both cases — a session compacted by
|
|
80
|
+
# hand loses the context in exactly the same way.
|
|
76
81
|
trigger="$(printf '%s' "$input" | jq -r '.trigger // "auto"' 2>/dev/null)"
|
|
77
82
|
[ -z "$trigger" ] && trigger='auto'
|
|
78
83
|
|
|
79
|
-
#
|
|
84
|
+
# The handover file is looked for by the branch name; for a head without a name it is named by its
|
|
85
|
+
# short snapshot.
|
|
80
86
|
handoff_name="$branch"
|
|
81
87
|
[ -z "$handoff_name" ] && handoff_name="$head_name"
|
|
82
88
|
|
|
83
89
|
progress=""
|
|
84
90
|
[ -n "$branch" ] && progress="$root/$tasks_dir/$branch/progress.md"
|
|
85
91
|
|
|
86
|
-
#
|
|
87
|
-
#
|
|
92
|
+
# A line of the "Where we stand" section by its name. Empty — the work goes outside a task folder,
|
|
93
|
+
# and the state must not be invented for it: the handover then holds what the tree knows.
|
|
88
94
|
line_of() {
|
|
89
95
|
[ -f "$progress" ] || return 0
|
|
90
|
-
sed -
|
|
96
|
+
sed -nE "s/^[[:space:]]*[-*][[:space:]]*\*\*($1):\*\*[[:space:]]*(.*)/\2/p" "$progress" 2>/dev/null | head -1
|
|
91
97
|
}
|
|
92
98
|
|
|
93
|
-
state="$(line_of '
|
|
94
|
-
stage="$(line_of '
|
|
95
|
-
next_step="$(line_of '
|
|
99
|
+
state="$(line_of 'State|Состояние')"
|
|
100
|
+
stage="$(line_of 'Stage|Этап')"
|
|
101
|
+
next_step="$(line_of 'Next step|Следующий шаг')"
|
|
96
102
|
pull="$(line_of 'PR')"
|
|
97
103
|
|
|
98
104
|
uncommitted="$(git status --short 2>/dev/null | head -20)"
|
|
99
|
-
[ -z "$uncommitted" ] && uncommitted='
|
|
105
|
+
[ -z "$uncommitted" ] && uncommitted='none'
|
|
100
106
|
|
|
101
107
|
ahead="$(git log --oneline origin/main..HEAD 2>/dev/null | head -20)"
|
|
102
|
-
[ -z "$ahead" ] && ahead='
|
|
108
|
+
[ -z "$ahead" ] && ahead='no commits over the main branch'
|
|
103
109
|
|
|
104
110
|
target="$root/$handoff_dir/$handoff_name.md"
|
|
105
111
|
|
|
106
|
-
#
|
|
107
|
-
section='##
|
|
112
|
+
# The heading of the section in the progress: the previous handover is found by it.
|
|
113
|
+
section='## Handover of the session'
|
|
108
114
|
|
|
109
|
-
#
|
|
110
|
-
#
|
|
115
|
+
# The handover is assembled into a temporary file: the section and the fallback path write one and
|
|
116
|
+
# the same thing, and no second assembly is made for the second place.
|
|
111
117
|
scratch="$(mktemp 2>/dev/null)" || exit 0
|
|
112
118
|
|
|
113
119
|
{
|
|
114
|
-
printf '
|
|
115
|
-
printf '
|
|
120
|
+
printf 'Put together by a hook before the compaction of the context (%s).\n\n' "$trigger"
|
|
121
|
+
printf '**Working tree:** %s\n' "$root"
|
|
116
122
|
if [ -n "$branch" ]; then
|
|
117
|
-
printf '
|
|
123
|
+
printf '**Branch:** %s\n\n' "$branch"
|
|
118
124
|
else
|
|
119
|
-
printf '
|
|
125
|
+
printf '**Branch:** no name — a detached head %s\n\n' "$head_name"
|
|
120
126
|
fi
|
|
121
127
|
|
|
122
128
|
if [ -n "$state" ]; then
|
|
123
|
-
printf '###
|
|
124
|
-
printf -- '-
|
|
125
|
-
[ -n "$stage" ] && printf -- '-
|
|
126
|
-
[ -n "$next_step" ] && printf -- '-
|
|
129
|
+
printf '### Where we stand at the minute of the compaction\n\n'
|
|
130
|
+
printf -- '- **State:** %s\n' "$state"
|
|
131
|
+
[ -n "$stage" ] && printf -- '- **Stage:** %s\n' "$stage"
|
|
132
|
+
[ -n "$next_step" ] && printf -- '- **Next step:** %s\n' "$next_step"
|
|
127
133
|
[ -n "$pull" ] && printf -- '- **PR:** %s\n' "$pull"
|
|
128
|
-
printf '\
|
|
134
|
+
printf '\nThe progress in full — `%s/%s/progress.md`; the plan lies next to it.\n\n' "$tasks_dir" "$branch"
|
|
129
135
|
elif [ -z "$branch" ]; then
|
|
130
|
-
printf '###
|
|
136
|
+
printf '### Where we stand at the minute of the compaction\n\nThe head has no name and no task folder next to it: there is nowhere to take the state of the work from. The reading side looks for the handover by the branch name, and failing that — by the last record of the directory.\n\n'
|
|
131
137
|
else
|
|
132
|
-
printf '###
|
|
138
|
+
printf '### Where we stand at the minute of the compaction\n\nThis branch has no task folder: there is nowhere to take the state of the work from.\n\n'
|
|
133
139
|
fi
|
|
134
140
|
|
|
135
|
-
printf '###
|
|
136
|
-
printf '###
|
|
137
|
-
printf '
|
|
138
|
-
printf '
|
|
141
|
+
printf '### Uncommitted\n\n```\n%s\n```\n\n' "$uncommitted"
|
|
142
|
+
printf '### Commits over the main branch\n\n```\n%s\n```\n\n' "$ahead"
|
|
143
|
+
printf 'Written by a hook before the compaction of the context. Everything standing here is checked\n'
|
|
144
|
+
printf 'against the tree: a handover retells what was written and describes the minute it was put together.\n'
|
|
139
145
|
} > "$scratch" 2>/dev/null
|
|
140
146
|
|
|
141
147
|
[ -s "$scratch" ] || exit 0
|
|
142
148
|
|
|
143
|
-
#
|
|
144
|
-
#
|
|
149
|
+
# There is a progress — the handover lies as its section, and a previous section of that kind is
|
|
150
|
+
# replaced entirely: appended as a second one, it would leave two truths about one work in one file.
|
|
145
151
|
if [ -n "$progress" ] && [ -f "$progress" ]; then
|
|
146
152
|
kept="$scratch.kept"
|
|
147
|
-
#
|
|
148
|
-
#
|
|
149
|
-
#
|
|
150
|
-
#
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
153
|
+
# The comparison goes by bytes. Under a locale with national settings the `awk` of this system
|
|
154
|
+
# counts different Cyrillic strings equal — the heading of "Where we stand" matched the heading
|
|
155
|
+
# of the handover section — and cutting out the previous section removed the work state along
|
|
156
|
+
# with it. The miss is visible only where the locale is declared: for an executor with `C.UTF-8`
|
|
157
|
+
# the suite is green, on the pipeline run — red.
|
|
158
|
+
LC_ALL=C awk -v mark="$section" -v old='## Передача захода' '
|
|
159
|
+
$0 == mark || $0 == old { skip = 1; next }
|
|
160
|
+
skip && /^## / && $0 != mark && $0 != old { skip = 0 }
|
|
154
161
|
!skip { print }
|
|
155
162
|
' "$progress" > "$kept" 2>/dev/null || { rm -f "$scratch" "$kept"; exit 0; }
|
|
156
163
|
|
|
157
164
|
{
|
|
158
|
-
#
|
|
159
|
-
#
|
|
165
|
+
# The trailing blank lines of the previous text are removed: the section is appended to it
|
|
166
|
+
# through one blank line, not through however many were left there.
|
|
160
167
|
awk 'BEGIN { blanks = 0 }
|
|
161
168
|
{ if ($0 ~ /^[[:space:]]*$/) { blanks++; next }
|
|
162
169
|
while (blanks > 0) { print ""; blanks-- }
|
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
#
|
|
2
|
+
# Shared reading of the hook input. NOT a guard: it has no `rt-hook:` declaration and does not
|
|
3
|
+
# subscribe to the agent events. The guards source it themselves — by the same technique they source
|
|
4
|
+
# the shared refusal tail.
|
|
4
5
|
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
6
|
+
# Why it exists. The input arrives as one object, and every guard needs the same fields from it: the
|
|
7
|
+
# tool name, the command line, the edit path, the working directory. While each of them pulled these
|
|
8
|
+
# out on its own, one agent call cost more than a hundred parses of one and the same text — six or
|
|
9
|
+
# seven per guard, eighteen guards per event. A parse costs six milliseconds, a shell start — five.
|
|
9
10
|
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
11
|
+
# How it works. The dispatcher parses the input once and puts the fields into the environment. The
|
|
12
|
+
# guard asks for them here: present in the environment — it takes what is ready, absent — it parses
|
|
13
|
+
# itself. The second is the direct call: that is how the guards are called by the scenario suites,
|
|
14
|
+
# and they must work without the dispatcher too.
|
|
13
15
|
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
16
|
+
# WHY READING THE STREAM IS A SEPARATE COMMAND AND NOT A VALUE. Command substitution runs in a
|
|
17
|
+
# subshell, and everything it remembered dies with it: the first call would read the stream out, and
|
|
18
|
+
# the second would get emptiness — and the guard would let through a call it was obliged to refuse.
|
|
19
|
+
# So the stream is read by the command `rt_hook_read`, which puts the input into a variable of the
|
|
20
|
+
# current shell, not by a function that returns it through substitution.
|
|
19
21
|
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
+
# FAIL-OPEN, IN FAVOUR OF WORK: no parser, broken input, an empty field — an empty string. Broken
|
|
23
|
+
# reading has no right to jam the work: on an empty field the guard exits with zero.
|
|
22
24
|
|
|
23
|
-
#
|
|
25
|
+
# Reads the input into `RT_HOOK_INPUT`, if it is not there yet. Called as a command, not as a
|
|
26
|
+
# substitution.
|
|
24
27
|
rt_hook_read() {
|
|
25
28
|
[ -n "${RT_HOOK_INPUT:-}" ] && return 0
|
|
26
29
|
|
|
@@ -29,15 +32,17 @@ rt_hook_read() {
|
|
|
29
32
|
return 0
|
|
30
33
|
}
|
|
31
34
|
|
|
32
|
-
#
|
|
33
|
-
#
|
|
35
|
+
# An input field by variable name and path in the object: `rt_hook_field RT_HOOK_TOOL '.tool_name'`.
|
|
36
|
+
# The environment variable outranks parsing — it is put there by the dispatcher, which parsed the
|
|
37
|
+
# input once.
|
|
34
38
|
rt_hook_field() {
|
|
35
39
|
local name="$1" path="$2"
|
|
36
40
|
|
|
37
|
-
#
|
|
38
|
-
#
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
+
# What is ready is trusted only by the sign of parsing, not by the fact that the variable is
|
|
42
|
+
# declared. An empty variable in the environment means "there is no field", and without the sign
|
|
43
|
+
# it is indistinguishable from "the field is there and it is empty": the guard stopped parsing
|
|
44
|
+
# the input and let through calls it was obliged to refuse. The suites caught this with sixteen
|
|
45
|
+
# failures — the run environment carried empty values.
|
|
41
46
|
if [ "${RT_HOOK_PARSED:-}" = '1' ] && [ -n "${!name+x}" ]; then
|
|
42
47
|
printf '%s' "${!name}"
|
|
43
48
|
return 0
|
|
@@ -47,55 +52,59 @@ rt_hook_field() {
|
|
|
47
52
|
printf '%s' "$RT_HOOK_INPUT" | jq -r "${path} // empty" 2>/dev/null
|
|
48
53
|
}
|
|
49
54
|
|
|
50
|
-
#
|
|
51
|
-
#
|
|
52
|
-
#
|
|
55
|
+
# THE START OF A CALL IN THE COMMAND LINE. The prefix of the pattern by which a guard recognises its
|
|
56
|
+
# own call: the command stands at the start of the line, after a separator — and after any number of
|
|
57
|
+
# environment variable assignments before its name.
|
|
53
58
|
#
|
|
54
|
-
#
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
-
#
|
|
58
|
-
#
|
|
59
|
-
#
|
|
59
|
+
# Assignments belong here because a call with them is the ordinary form, and part of the suite
|
|
60
|
+
# demands it outright: the identity of the call that opens a PR is visible from the command only by
|
|
61
|
+
# an explicit substitution of the token. A sign that knew nothing of assignments went blind on this
|
|
62
|
+
# form silently — it did not refuse and did not warn, it did not count the call as a call, and the
|
|
63
|
+
# whole subject of the guard stayed unjudged. That is how the push, the opening of a PR, taking off
|
|
64
|
+
# the draft and the merge went past their own guards: a commit with a foreign signature went into
|
|
65
|
+
# the main branch, and the ban on a merge by the agent was lifted by substituting the token.
|
|
60
66
|
#
|
|
61
|
-
#
|
|
62
|
-
#
|
|
63
|
-
# create …` —
|
|
64
|
-
#
|
|
65
|
-
#
|
|
67
|
+
# The value of an assignment comes in three kinds: without spaces, as a substitution `$( … )` and in
|
|
68
|
+
# quotes. Before, only the first was accepted, while PRs are opened by the command
|
|
69
|
+
# `GH_TOKEN=$(cat <file>) gh pr create …` — the path in the substitution holds a space, and the
|
|
70
|
+
# delivery guard did not check such a command: neither the branch number, nor the body of the PR,
|
|
71
|
+
# nor the taking apart of the task folder. The silence of a guard is indistinguishable from a
|
|
72
|
+
# permission.
|
|
66
73
|
#
|
|
67
|
-
#
|
|
68
|
-
#
|
|
69
|
-
#
|
|
70
|
-
#
|
|
74
|
+
# A substitution is taken up to the first closing bracket, a quoted string — up to the closing quote
|
|
75
|
+
# of the same kind. Nested brackets and quotes the pattern does not parse: the sign stays a pattern,
|
|
76
|
+
# not a shell parser. The sign must err on the side of firing too often: a guard that did not
|
|
77
|
+
# recognise a call stays silent and looks sound; one that fired an extra time is visible at once and
|
|
78
|
+
# gets fixed.
|
|
71
79
|
#
|
|
72
|
-
#
|
|
80
|
+
# An assignment by itself does not count as a call: a command name must stand after it.
|
|
73
81
|
#
|
|
74
|
-
#
|
|
75
|
-
#
|
|
76
|
-
#
|
|
77
|
-
#
|
|
78
|
-
#
|
|
82
|
+
# A directory before the name is the same command. A client whose own name is taken by a shell alias
|
|
83
|
+
# is called by the full path, and a sign that knew only the bare name did not recognise such a call
|
|
84
|
+
# at all: the guard exited with zero, and its silence is indistinguishable from a permission. That
|
|
85
|
+
# is how PRs went out opened not by the machine record. A path part does not cross a space, so it
|
|
86
|
+
# stays inside one word and glues nothing extra to the call.
|
|
79
87
|
#
|
|
80
|
-
#
|
|
81
|
-
#
|
|
88
|
+
# This is declared in a SINGLE place, not as a literal in every guard: having diverged, the copies
|
|
89
|
+
# are fixed one at a time and say nothing about the rest staying blind.
|
|
82
90
|
RT_CMD_BOUND='(^|[;&|(]|&&|\|\|)[[:space:]]*([A-Za-z_][A-Za-z0-9_]*=([^[:space:]]*|\$\([^)]*\)|"[^"]*"|'"'"'[^'"'"']*'"'"')[[:space:]]+)*([^[:space:]]*/)?'
|
|
83
91
|
|
|
84
|
-
#
|
|
92
|
+
# The fields that all guards ask for.
|
|
85
93
|
rt_hook_tool() { rt_hook_field RT_HOOK_TOOL '.tool_name'; }
|
|
86
94
|
rt_hook_cmd() { rt_hook_field RT_HOOK_CMD '.tool_input.command'; }
|
|
87
95
|
rt_hook_file() { rt_hook_field RT_HOOK_FILE '.tool_input.file_path'; }
|
|
88
96
|
rt_hook_cwd() { rt_hook_field RT_HOOK_CWD '.cwd'; }
|
|
89
97
|
|
|
90
|
-
#
|
|
91
|
-
#
|
|
92
|
-
#
|
|
93
|
-
#
|
|
94
|
-
#
|
|
95
|
-
#
|
|
98
|
+
# WAITS FOR THE LAST TEXT OF THE TURN IN THE RECORD. The guards of the ending judge what was said
|
|
99
|
+
# to the owner, while the record of the turn at that moment happens to be incomplete: the text of
|
|
100
|
+
# the reply lands in the file no earlier than the host calls the hook, and the guard reads a turn
|
|
101
|
+
# that has no text at all. It stays silent honestly — and from the outside it is indistinguishable
|
|
102
|
+
# from a guard that looked and let through. Exactly so a turn that put the work into dependence on
|
|
103
|
+
# the word of the owner went past three guards at once, while the same turn, fed to them a second
|
|
104
|
+
# time, was refused.
|
|
96
105
|
#
|
|
97
|
-
#
|
|
98
|
-
#
|
|
106
|
+
# We wait in short attempts: the file is written up in milliseconds, and a turn does not end
|
|
107
|
+
# instantly anyway. Waited it out — zero; still no text — one, and the guard decides from there.
|
|
99
108
|
rt_turn_has_text() {
|
|
100
109
|
local transcript="$1" tries="${2:-20}" got
|
|
101
110
|
|