@rt-tools/agent-kit 0.37.1 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/assets/checks/action-of.mjs +154 -0
- package/assets/checks/board-runs.github.mjs +40 -5
- package/assets/checks/check-board.github.mjs +38 -7
- package/assets/checks/check-state-next.mjs +22 -10
- package/assets/checks/check-turn-map.mjs +26 -6
- package/assets/checks/check-work-steps.mjs +4 -173
- package/assets/checks/decide.mjs +285 -0
- package/assets/checks/decision-table.json +21432 -0
- package/assets/checks/decision-table.mjs +495 -0
- package/assets/checks/epic-window.mjs +98 -0
- package/assets/checks/flow-condition.mjs +64 -0
- package/assets/checks/flow-data.mjs +135 -0
- package/assets/checks/flow-forecast.mjs +334 -0
- package/assets/checks/flow-guard-run.mjs +90 -0
- package/assets/checks/flow-guard.mjs +496 -0
- package/assets/checks/flow-model.mjs +271 -0
- package/assets/checks/flow-override.mjs +130 -0
- package/assets/checks/flow-plan.mjs +206 -0
- package/assets/checks/flow-scaffold.mjs +224 -0
- package/assets/checks/flow-step.mjs +495 -0
- package/assets/checks/flow-sync.mjs +296 -0
- package/assets/checks/flow-syntax.mjs +292 -0
- package/assets/checks/flow-verdict.mjs +227 -0
- package/assets/checks/merge-read.mjs +239 -0
- package/assets/checks/owner-nudges.mjs +389 -0
- package/assets/checks/push-inputs.mjs +59 -16
- package/assets/checks/record-count.mjs +437 -0
- package/assets/checks/record-recount.mjs +187 -0
- package/assets/checks/record-turn.mjs +155 -0
- package/assets/checks/task-flow-script.mjs +318 -0
- package/assets/checks/tree-assignment.mjs +26 -7
- package/assets/checks/work-result.mjs +362 -0
- package/assets/checks/work-steps-lib.mjs +205 -0
- package/assets/commands/night.md +6 -6
- package/assets/defaults/gate-map.sh +39 -12
- package/assets/defaults/merges.sh +48 -0
- package/assets/defaults/project.sh +6 -5
- package/assets/defaults/turn-map.md +23 -22
- package/assets/docs/GLOSSARY.md +5 -1
- package/assets/hooks/ask-judge.md +67 -0
- package/assets/hooks/browser-guard-device-id.sh +11 -9
- package/assets/hooks/browser-guard-no-asking.sh +12 -6
- package/assets/hooks/browser-guard-no-listing.sh +13 -7
- package/assets/hooks/browser-guard-no-other-drivers.sh +25 -17
- package/assets/hooks/browser-guard-require-select.sh +15 -15
- package/assets/hooks/commit-msg.sh +13 -3
- package/assets/hooks/conscience-guard.sh +9 -25
- package/assets/hooks/decide.sh +141 -0
- package/assets/hooks/deny-tail.sh +16 -11
- package/assets/hooks/dev-server-guard.sh +27 -20
- package/assets/hooks/dispatch.sh +47 -4
- package/assets/hooks/docs-guard.sh +31 -200
- package/assets/hooks/end-conversation-guard.sh +12 -21
- package/assets/hooks/epic-stop-guard.sh +54 -152
- package/assets/hooks/exam-guard.sh +32 -65
- package/assets/hooks/facts-docs.sh +221 -0
- package/assets/hooks/facts-flow.sh +173 -0
- package/assets/hooks/facts.sh +374 -0
- package/assets/hooks/flow-step-guard.sh +93 -0
- package/assets/hooks/git-guard-delivery-body.sh +4 -4
- package/assets/hooks/git-guard-delivery-conflict.sh +16 -10
- package/assets/hooks/git-guard-delivery-draft.sh +3 -3
- package/assets/hooks/git-guard-delivery-epic.sh +18 -9
- package/assets/hooks/git-guard-delivery-folder.sh +32 -7
- package/assets/hooks/git-guard-delivery-merge.sh +2 -2
- package/assets/hooks/git-guard-delivery-merged.sh +12 -1
- package/assets/hooks/git-guard-delivery-pipeline.sh +1 -1
- package/assets/hooks/git-guard-delivery-rerun.sh +44 -0
- package/assets/hooks/git-guard-delivery-signature.sh +82 -45
- package/assets/hooks/git-guard-delivery-task.sh +47 -0
- package/assets/hooks/git-guard-delivery.sh +112 -101
- package/assets/hooks/git-guard-discard.sh +8 -18
- package/assets/hooks/git-guard-main.sh +13 -19
- package/assets/hooks/git-guard-no-verify.sh +56 -16
- package/assets/hooks/git-guard-push-ahead.sh +39 -6
- package/assets/hooks/git-guard-push-marks.sh +262 -13
- package/assets/hooks/git-guard-push-tests.sh +58 -52
- package/assets/hooks/git-guard-tree-assignment.sh +7 -4
- package/assets/hooks/guard-note.sh +8 -6
- package/assets/hooks/handoff-entry-guard.sh +19 -38
- package/assets/hooks/handoff-write.sh +3 -1
- package/assets/hooks/hook-input.sh +0 -41
- package/assets/hooks/metric-marks.sh +19 -7
- package/assets/hooks/observe.sh +1 -1
- package/assets/hooks/override-write-guard.sh +27 -9
- package/assets/hooks/pre-push.sh +40 -12
- package/assets/hooks/prose-style-guard.sh +6 -19
- package/assets/hooks/pull-merges.sh +76 -0
- package/assets/hooks/push-ahead-call-guard.sh +447 -0
- package/assets/hooks/push-set.sh +38 -8
- package/assets/hooks/qa-dataid-guard.sh +7 -17
- package/assets/hooks/record-turn.sh +52 -0
- package/assets/hooks/rerun-guard.sh +11 -16
- package/assets/hooks/reuse-first-guard.sh +7 -21
- package/assets/hooks/role-calls.sh +25 -3
- package/assets/hooks/rule-source-guard.sh +54 -21
- package/assets/hooks/skill-gate-rearm.sh +18 -5
- package/assets/hooks/skill-gate.sh +156 -20
- package/assets/hooks/skill-loaded.sh +18 -3
- package/assets/hooks/sql-guard-target.sh +2 -2
- package/assets/hooks/sql-guard-write.sh +12 -12
- package/assets/hooks/sql-guard.sh +58 -16
- package/assets/hooks/task-context-load.sh +3 -1
- package/assets/hooks/task-flow-context.sh +5 -18
- package/assets/hooks/task-flow-draft-guard.sh +25 -74
- package/assets/hooks/task-flow-guard.sh +28 -130
- package/assets/hooks/tree-assignment-guard.sh +25 -14
- package/assets/hooks/turn-entry-load.sh +3 -1
- package/assets/hooks/turn-exit-guard.sh +92 -452
- package/assets/hooks/turn-exit-role.sh +3 -1
- package/assets/hooks/turn-judge.md +113 -0
- package/assets/hooks/window-fill-guard.sh +22 -41
- package/assets/patterns/doc-style-human.md +36 -76
- package/assets/patterns/git-workflow-commit.azure.md +9 -155
- package/assets/patterns/git-workflow-commit.github.md +11 -269
- package/assets/patterns/git-workflow-commit.gitlab.md +9 -161
- package/assets/patterns/git-workflow-docker.md +8 -231
- package/assets/patterns/git-workflow-freshness.md +8 -56
- package/assets/patterns/git-workflow-merge.md +6 -176
- package/assets/patterns/git-workflow-migration.md +5 -75
- package/assets/patterns/git-workflow-pr-body.github.md +6 -159
- package/assets/patterns/git-workflow-pr-ready.md +9 -70
- package/assets/patterns/git-workflow-pr.azure.md +13 -285
- package/assets/patterns/git-workflow-pr.github.md +13 -251
- package/assets/patterns/git-workflow-pr.gitlab.md +13 -286
- package/assets/patterns/git-workflow-restart.md +5 -42
- package/assets/patterns/git-workflow-secrets.md +10 -76
- package/assets/patterns/git-workflow-stack.md +7 -207
- package/assets/patterns/status-report-table.github.md +1 -1
- package/assets/patterns/task-flow-archive.md +12 -233
- package/assets/patterns/task-flow-close.md +16 -292
- package/assets/patterns/task-flow-cycle.md +13 -39
- package/assets/patterns/task-flow-graph.needs-graph.md +8 -62
- package/assets/patterns/task-flow-handoff.md +13 -161
- package/assets/patterns/task-flow-resume.md +18 -218
- package/assets/patterns/task-flow-start.md +9 -247
- package/assets/patterns/turn-entry-map.md +2 -2
- package/assets/pitfalls/agent-kit-extend.md +200 -0
- package/assets/pitfalls/agent-kit.2.md +323 -0
- package/assets/pitfalls/angular-patterns.md +98 -0
- package/assets/pitfalls/browser-verification.md +265 -0
- package/assets/pitfalls/component-structure.md +98 -0
- package/assets/pitfalls/dependencies.md +92 -0
- package/assets/pitfalls/deploy-flow.azure.md +171 -0
- package/assets/pitfalls/deploy-flow.github.md +211 -0
- package/assets/pitfalls/deploy-flow.gitlab.md +173 -0
- package/assets/pitfalls/doc-style-human.md +112 -0
- package/assets/pitfalls/doc-style.2.md +286 -0
- package/assets/pitfalls/entity-conventions.needs-admin.md +96 -0
- package/assets/pitfalls/entity-models.md +89 -0
- package/assets/pitfalls/epic-flow.md +92 -0
- package/assets/pitfalls/git-workflow-commit.azure.md +190 -0
- package/assets/pitfalls/git-workflow-commit.github.md +307 -0
- package/assets/pitfalls/git-workflow-commit.gitlab.md +196 -0
- package/assets/pitfalls/git-workflow-docker.md +275 -0
- package/assets/pitfalls/git-workflow-freshness.md +88 -0
- package/assets/pitfalls/git-workflow-hosting.azure.md +31 -0
- package/assets/pitfalls/git-workflow-hosting.github.md +32 -0
- package/assets/pitfalls/git-workflow-hosting.gitlab.md +31 -0
- package/assets/pitfalls/git-workflow-merge.md +220 -0
- package/assets/pitfalls/git-workflow-migration.md +103 -0
- package/assets/pitfalls/git-workflow-pr-body.github.md +185 -0
- package/assets/pitfalls/git-workflow-pr-ready.md +104 -0
- package/assets/pitfalls/git-workflow-pr.2.azure.md +172 -0
- package/assets/pitfalls/git-workflow-pr.2.github.md +184 -0
- package/assets/pitfalls/git-workflow-pr.2.gitlab.md +180 -0
- package/assets/pitfalls/git-workflow-pr.azure.md +159 -0
- package/assets/pitfalls/git-workflow-pr.github.md +107 -0
- package/assets/pitfalls/git-workflow-pr.gitlab.md +151 -0
- package/assets/pitfalls/git-workflow-push.azure.md +30 -0
- package/assets/pitfalls/git-workflow-push.github.md +30 -0
- package/assets/pitfalls/git-workflow-push.gitlab.md +30 -0
- package/assets/pitfalls/git-workflow-queue.azure.md +30 -0
- package/assets/pitfalls/git-workflow-queue.github.md +30 -0
- package/assets/pitfalls/git-workflow-queue.gitlab.md +30 -0
- package/assets/pitfalls/git-workflow-restart.md +72 -0
- package/assets/pitfalls/git-workflow-secrets.md +114 -0
- package/assets/pitfalls/git-workflow-stack.md +254 -0
- package/assets/pitfalls/git-workflow.2.azure.md +291 -0
- package/assets/pitfalls/git-workflow.2.github.md +294 -0
- package/assets/pitfalls/git-workflow.2.gitlab.md +278 -0
- package/assets/pitfalls/lib-layers.md +114 -0
- package/assets/pitfalls/lists.md +117 -0
- package/assets/pitfalls/mockups.needs-mockups.md +87 -0
- package/assets/pitfalls/navigation.md +94 -0
- package/assets/pitfalls/observability.needs-app.md +186 -0
- package/assets/pitfalls/platform-access.md +94 -0
- package/assets/pitfalls/queue-audit.github.md +78 -0
- package/assets/pitfalls/reuse-first.md +201 -0
- package/assets/pitfalls/spec-driven.2.md +318 -0
- package/assets/pitfalls/styling-bem.2.md +125 -0
- package/assets/pitfalls/task-flow-archive.md +265 -0
- package/assets/pitfalls/task-flow-close.2.md +166 -0
- package/assets/pitfalls/task-flow-close.md +167 -0
- package/assets/pitfalls/task-flow-cycle.md +73 -0
- package/assets/pitfalls/task-flow-graph.needs-graph.md +98 -0
- package/assets/pitfalls/task-flow-handoff.md +200 -0
- package/assets/pitfalls/task-flow-handover.md +30 -0
- package/assets/pitfalls/task-flow-owner.md +58 -0
- package/assets/pitfalls/task-flow-plan.md +29 -0
- package/assets/pitfalls/task-flow-resume.md +257 -0
- package/assets/pitfalls/task-flow-start.md +287 -0
- package/assets/pitfalls/task-flow.2.md +303 -0
- package/assets/pitfalls/task-flow.md +4 -4
- package/assets/pitfalls/testing.2.md +279 -0
- package/assets/pitfalls/turn-conduct.md +16 -17
- package/assets/pitfalls/typescript-conventions.md +161 -0
- package/assets/pitfalls/write-a-skill.md +128 -0
- package/assets/rules/angular-patterns.md +21 -86
- package/assets/rules/autonomous-work.md +2 -2
- package/assets/rules/browser-verification.md +28 -256
- package/assets/rules/component-structure.md +25 -87
- package/assets/rules/dependencies.md +20 -78
- package/assets/rules/deploy-flow.azure.md +26 -156
- package/assets/rules/deploy-flow.github.md +34 -200
- package/assets/rules/deploy-flow.gitlab.md +27 -159
- package/assets/rules/doc-style.md +32 -286
- package/assets/rules/entity-conventions.needs-admin.md +26 -82
- package/assets/rules/entity-models.md +14 -63
- package/assets/rules/epic-flow.md +24 -63
- package/assets/rules/git-workflow-hosting.azure.md +26 -0
- package/assets/rules/git-workflow-hosting.github.md +38 -0
- package/assets/rules/git-workflow-hosting.gitlab.md +27 -0
- package/assets/rules/git-workflow-push.azure.md +28 -0
- package/assets/rules/git-workflow-push.github.md +28 -0
- package/assets/rules/git-workflow-push.gitlab.md +28 -0
- package/assets/rules/git-workflow-queue.azure.md +23 -0
- package/assets/rules/git-workflow-queue.github.md +30 -0
- package/assets/rules/git-workflow-queue.gitlab.md +23 -0
- package/assets/rules/git-workflow.azure.md +21 -282
- package/assets/rules/git-workflow.github.md +24 -284
- package/assets/rules/git-workflow.gitlab.md +21 -269
- package/assets/rules/lib-layers.md +30 -103
- package/assets/rules/lists.md +21 -105
- package/assets/rules/mockups.needs-mockups.md +25 -64
- package/assets/rules/navigation.md +10 -69
- package/assets/rules/observability.needs-app.md +43 -172
- package/assets/rules/platform-access.md +28 -75
- package/assets/rules/queue-audit.github.md +25 -52
- package/assets/rules/reuse-first.md +20 -195
- package/assets/rules/spec-driven.md +35 -308
- package/assets/rules/styling-bem.md +20 -117
- package/assets/rules/task-flow-handover.md +24 -0
- package/assets/rules/task-flow-owner.md +34 -0
- package/assets/rules/task-flow-plan.md +38 -0
- package/assets/rules/task-flow.md +22 -300
- package/assets/rules/testing.md +32 -273
- package/assets/rules/turn-conduct.md +105 -106
- package/assets/rules/turn-entry.md +2 -2
- package/assets/rules/typescript-conventions.md +41 -147
- package/assets/samples/tasks/_template/plan.md +30 -6
- package/assets/samples/tasks/_template/progress.md +0 -1
- package/assets/skills/agent-kit-extend.md +25 -168
- package/assets/skills/agent-kit.md +27 -299
- package/assets/skills/write-a-skill.md +20 -106
- package/assets/task-flow/flow.js +184 -0
- package/assets/task-flow/flow.md +101 -0
- package/assets/task-flow/measure/agreement.mjs +24 -0
- package/assets/task-flow/measure/ci.mjs +184 -0
- package/assets/task-flow/measure/copy.mjs +22 -0
- package/assets/task-flow/measure/epic-of.mjs +50 -0
- package/assets/task-flow/measure/epic-text.mjs +35 -0
- package/assets/task-flow/measure/epic.mjs +114 -0
- package/assets/task-flow/measure/folder.mjs +16 -0
- package/assets/task-flow/measure/footprint.mjs +28 -0
- package/assets/task-flow/measure/grill.mjs +21 -0
- package/assets/task-flow/measure/host.mjs +8 -0
- package/assets/task-flow/measure/owner.mjs +27 -0
- package/assets/task-flow/measure/plan.mjs +27 -0
- package/assets/task-flow/measure/pr.mjs +20 -0
- package/assets/task-flow/measure/progress.mjs +50 -0
- package/assets/task-flow/measure/session.mjs +252 -0
- package/assets/task-flow/measure/task.mjs +23 -0
- package/assets/task-flow/measure/text.mjs +77 -0
- package/assets/task-flow/source/git.mjs +254 -0
- package/assets/task-flow/source/host.mjs +277 -0
- package/assets/task-flow/source/marks.mjs +56 -0
- package/assets/task-flow/source/owner.mjs +94 -0
- package/assets/task-flow/source/records.mjs +116 -0
- package/assets/task-flow/source/session.mjs +269 -0
- package/assets/task-flow/source/steps.mjs +28 -0
- package/assets/task-flow/source/tree.mjs +42 -0
- package/bin/agent-kit.d.ts.map +1 -1
- package/bin/agent-kit.js +30 -0
- package/bin/agent-kit.js.map +1 -1
- package/lib/agent-checks.d.ts +55 -0
- package/lib/agent-checks.d.ts.map +1 -0
- package/lib/agent-checks.js +221 -0
- package/lib/agent-checks.js.map +1 -0
- package/lib/assets.d.ts.map +1 -1
- package/lib/assets.js +7 -2
- package/lib/assets.js.map +1 -1
- package/lib/cargo.d.ts +29 -0
- package/lib/cargo.d.ts.map +1 -1
- package/lib/cargo.js +27 -1
- package/lib/cargo.js.map +1 -1
- package/lib/cascade.d.ts.map +1 -1
- package/lib/cascade.js +3 -1
- package/lib/cascade.js.map +1 -1
- package/lib/commands.d.ts.map +1 -1
- package/lib/commands.js +78 -2
- package/lib/commands.js.map +1 -1
- package/lib/config.d.ts +18 -0
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +18 -1
- package/lib/config.js.map +1 -1
- package/lib/epic-window-send.d.ts +74 -0
- package/lib/epic-window-send.d.ts.map +1 -0
- package/lib/epic-window-send.js +166 -0
- package/lib/epic-window-send.js.map +1 -0
- package/lib/hooks-map.d.ts +4 -0
- package/lib/hooks-map.d.ts.map +1 -1
- package/lib/hooks-map.js +2 -2
- package/lib/hooks-map.js.map +1 -1
- package/lib/integrity.d.ts +3 -0
- package/lib/integrity.d.ts.map +1 -1
- package/lib/integrity.js +7 -0
- package/lib/integrity.js.map +1 -1
- package/lib/metric-lines.d.ts +2 -1
- package/lib/metric-lines.d.ts.map +1 -1
- package/lib/metric-lines.js +49 -1
- package/lib/metric-lines.js.map +1 -1
- package/lib/metric-send-mark.d.ts +6 -3
- package/lib/metric-send-mark.d.ts.map +1 -1
- package/lib/metric-send-mark.js +15 -5
- package/lib/metric-send-mark.js.map +1 -1
- package/lib/metric-send.d.ts +6 -2
- package/lib/metric-send.d.ts.map +1 -1
- package/lib/metric-send.js +47 -13
- package/lib/metric-send.js.map +1 -1
- package/lib/metrics.d.ts +17 -0
- package/lib/metrics.d.ts.map +1 -1
- package/lib/metrics.js +26 -15
- package/lib/metrics.js.map +1 -1
- package/lib/observations.js +3 -3
- package/lib/observations.js.map +1 -1
- package/lib/outcomes.d.ts +5 -2
- package/lib/outcomes.d.ts.map +1 -1
- package/lib/outcomes.js +5 -4
- package/lib/outcomes.js.map +1 -1
- package/lib/push-gate.d.ts +13 -0
- package/lib/push-gate.d.ts.map +1 -1
- package/lib/push-gate.js +11 -7
- package/lib/push-gate.js.map +1 -1
- package/lib/push-set-usefulness.d.ts +78 -0
- package/lib/push-set-usefulness.d.ts.map +1 -0
- package/lib/push-set-usefulness.js +225 -0
- package/lib/push-set-usefulness.js.map +1 -0
- package/lib/sync.d.ts +10 -0
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +14 -1
- package/lib/sync.js.map +1 -1
- package/lib/work-result.d.ts +43 -0
- package/lib/work-result.d.ts.map +1 -0
- package/lib/work-result.js +39 -0
- package/lib/work-result.js.map +1 -0
- package/package.json +1 -1
- package/assets/hooks/claim-guard.sh +0 -212
- package/assets/hooks/grill-gate-ask.sh +0 -26
- package/assets/hooks/grill-gate-bypass.sh +0 -61
- package/assets/hooks/grill-gate-options.sh +0 -50
- package/assets/hooks/grill-gate.sh +0 -482
- package/assets/hooks/postmortem-guard.sh +0 -124
- package/assets/hooks/proposal-guard.sh +0 -154
- package/assets/hooks/stand-login-guard.sh +0 -107
- package/assets/hooks/turn-exit-epic.sh +0 -173
- package/assets/hooks/turn-exit-patterns.sh +0 -123
- package/assets/hooks/turn-exit-verdict.sh +0 -149
- package/assets/hooks/waiting-turn-guard.sh +0 -320
- package/assets/hooks/work-start-guard.sh +0 -175
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Результат работы в отчёте метрик: строки считает `checks/work-result.mjs` теми же функциями, что
|
|
3
|
+
* хук конца хода и чтение слияний. Отчёт только зовёт его и вставляет строку, которую считают итоги
|
|
4
|
+
* заявок.
|
|
5
|
+
*/
|
|
6
|
+
import { execFileSync } from 'node:child_process';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { OBSERVATIONS_DIR } from './observations.js';
|
|
9
|
+
/** Строка, которую считают итоги заявок: без главного числа она печатает «0 из 0». */
|
|
10
|
+
export const FIRST_PASS_NONE = ' Принято с первого раза: 0 из 0';
|
|
11
|
+
/** Сколько строк заголовка стоит до строк чисел: пустая и «результат работы:». */
|
|
12
|
+
const HEAD_LINES = 2;
|
|
13
|
+
/** Ответ сценария больше любого дня записи: один день весит до десятков мегабайт. */
|
|
14
|
+
const MAX_BUFFER = 256 * 1024 * 1024;
|
|
15
|
+
/**
|
|
16
|
+
* Результат за отрезок. `firstPass` — своя строка «Принято с первого раза» или `null`, когда её
|
|
17
|
+
* уже напечатали итоги заявок.
|
|
18
|
+
*/
|
|
19
|
+
export function workResultOf(root, assetsDir, until, days, firstPass) {
|
|
20
|
+
try {
|
|
21
|
+
const out = execFileSync(process.execPath, [
|
|
22
|
+
join(assetsDir, 'checks', 'work-result.mjs'),
|
|
23
|
+
'--observations',
|
|
24
|
+
join(root, OBSERVATIONS_DIR),
|
|
25
|
+
'--until',
|
|
26
|
+
until,
|
|
27
|
+
'--days',
|
|
28
|
+
String(days),
|
|
29
|
+
], { encoding: 'utf8', maxBuffer: MAX_BUFFER, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
30
|
+
const answer = JSON.parse(out);
|
|
31
|
+
const head = answer.lines.slice(0, HEAD_LINES);
|
|
32
|
+
const rest = answer.lines.slice(HEAD_LINES);
|
|
33
|
+
return { days: answer.result.days, lines: [...head, ...(firstPass === null ? [] : [firstPass]), ...rest] };
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return { days: null, lines: ['', 'результат работы: подсчёт оборвался, числа результата не показаны'] };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=work-result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"work-result.js","sourceRoot":"","sources":["../../../projects/agent-kit/src/lib/work-result.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAwCrD,sFAAsF;AACtF,MAAM,CAAC,MAAM,eAAe,GAAW,kCAAkC,CAAC;AAE1E,kFAAkF;AAClF,MAAM,UAAU,GAAW,CAAC,CAAC;AAE7B,qFAAqF;AACrF,MAAM,UAAU,GAAW,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAO7C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,SAAiB,EAAE,KAAa,EAAE,IAAY,EAAE,SAAwB;IAC/G,IAAI,CAAC;QACD,MAAM,GAAG,GAAW,YAAY,CAC5B,OAAO,CAAC,QAAQ,EAChB;YACI,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,iBAAiB,CAAC;YAC5C,gBAAgB;YAChB,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC;YAC5B,SAAS;YACT,KAAK;YACL,QAAQ;YACR,MAAM,CAAC,IAAI,CAAC;SACf,EACD,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CACjF,CAAC;QACF,MAAM,MAAM,GAAkB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9C,MAAM,IAAI,GAAsB,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;QAClE,MAAM,IAAI,GAAsB,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAE/D,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;IAC/G,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,mEAAmE,CAAC,EAAE,CAAC;IAC5G,CAAC;AACL,CAAC","sourcesContent":["/**\n * Результат работы в отчёте метрик: строки считает `checks/work-result.mjs` теми же функциями, что\n * хук конца хода и чтение слияний. Отчёт только зовёт его и вставляет строку, которую считают итоги\n * заявок.\n */\nimport { execFileSync } from 'node:child_process';\nimport { join } from 'node:path';\n\nimport { OBSERVATIONS_DIR } from './observations.js';\n\n/** Отказы одной проверки за день. */\nexport interface IWorkResultCheck {\n readonly refusals: number;\n readonly per100: number;\n}\n\n/**\n * Числа одного дня: их несёт JSON отчёта и строка дня. Числа записи хода есть только у дня с записью:\n * ноль там читался бы как спокойный день.\n */\nexport interface IWorkResultDay {\n readonly day: string;\n readonly recorded: boolean;\n readonly beforeCounter: boolean;\n readonly skipped: number;\n readonly goalNotMet: number;\n readonly tasksMerged: number;\n readonly tasksTimed: number;\n readonly takenMinutes: number;\n readonly calls?: number;\n readonly refusals?: number;\n readonly byKind?: Readonly<Record<string, number>>;\n readonly byCheck?: Readonly<Record<string, IWorkResultCheck>>;\n /** Пары отказов под ключом `первая → вторая`. */\n readonly pairs?: Readonly<Record<string, number>>;\n readonly idleMinutes?: number;\n readonly reasks?: number;\n readonly interrupts?: number;\n readonly ownerWords?: number;\n readonly deadEnds?: number;\n}\n\nexport interface IWorkResult {\n /** Числа по дням. `null`: подсчёт оборвался, и строки говорят об этом. */\n readonly days: readonly IWorkResultDay[] | null;\n readonly lines: readonly string[];\n}\n\n/** Строка, которую считают итоги заявок: без главного числа она печатает «0 из 0». */\nexport const FIRST_PASS_NONE: string = ' Принято с первого раза: 0 из 0';\n\n/** Сколько строк заголовка стоит до строк чисел: пустая и «результат работы:». */\nconst HEAD_LINES: number = 2;\n\n/** Ответ сценария больше любого дня записи: один день весит до десятков мегабайт. */\nconst MAX_BUFFER: number = 256 * 1024 * 1024;\n\ninterface IScriptAnswer {\n readonly result: { readonly days: readonly IWorkResultDay[] };\n readonly lines: readonly string[];\n}\n\n/**\n * Результат за отрезок. `firstPass` — своя строка «Принято с первого раза» или `null`, когда её\n * уже напечатали итоги заявок.\n */\nexport function workResultOf(root: string, assetsDir: string, until: string, days: number, firstPass: string | null): IWorkResult {\n try {\n const out: string = execFileSync(\n process.execPath,\n [\n join(assetsDir, 'checks', 'work-result.mjs'),\n '--observations',\n join(root, OBSERVATIONS_DIR),\n '--until',\n until,\n '--days',\n String(days),\n ],\n { encoding: 'utf8', maxBuffer: MAX_BUFFER, stdio: ['ignore', 'pipe', 'pipe'] }\n );\n const answer: IScriptAnswer = JSON.parse(out);\n const head: readonly string[] = answer.lines.slice(0, HEAD_LINES);\n const rest: readonly string[] = answer.lines.slice(HEAD_LINES);\n\n return { days: answer.result.days, lines: [...head, ...(firstPass === null ? [] : [firstPass]), ...rest] };\n } catch {\n return { days: null, lines: ['', 'результат работы: подсчёт оборвался, числа результата не показаны'] };\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# rt-hook: Stop
|
|
3
|
-
# The claim guard: what is said to the owner about the state of the tree carries the command that
|
|
4
|
-
# showed it. Stop.
|
|
5
|
-
#
|
|
6
|
-
# Why exactly this way. The rule of texts itself says that no check reads the reply to the owner:
|
|
7
|
-
# a file is answered for by the gate, a reply by its author, and the price of a mistake in a reply
|
|
8
|
-
# is paid by the owner. Eight analyses in a row about one and the same thing — what lay on the disk
|
|
9
|
-
# was called ready, only local branches were called removed, a set narrower than the pipeline was
|
|
10
|
-
# called checked, a local reference that had fallen behind was called the state of the tree. Each
|
|
11
|
-
# time an article was added to the rule, and each time the miss repeated: the text is read at the
|
|
12
|
-
# start of the session, and the claim is said at its end.
|
|
13
|
-
#
|
|
14
|
-
# What is judged: the text said to the owner within this turn. Tool output and what was written
|
|
15
|
-
# into a file do not go here — those are read by the gate and by the checks.
|
|
16
|
-
#
|
|
17
|
-
# How it is judged: each claim word has a command kind of its own named for it. A claim about a
|
|
18
|
-
# green set is confirmed by a run of the set, about a pushed branch by a push call, about a removed
|
|
19
|
-
# one by a delete call. The command is looked for within this same turn: the state of the tree
|
|
20
|
-
# changes, and the output of a past turn no longer speaks about the present one.
|
|
21
|
-
#
|
|
22
|
-
# What the guard does not judge. A wrong conclusion: about a pattern judged by one of its files,
|
|
23
|
-
# and about a path a person will not take, a machine has nothing to judge by — there is neither a
|
|
24
|
-
# claim word there nor a command to check against. Those cases are held by the work-conduct rule,
|
|
25
|
-
# and that is a known boundary of the guard, not a promise.
|
|
26
|
-
#
|
|
27
|
-
# Someone else's word is not judged either: a quotation in quotes, an examiner's question, a
|
|
28
|
-
# retelling of someone else's text, a line of code and a sentence in the conditional are not claims
|
|
29
|
-
# about the tree. Turns refused for them cost more than the ones let through: a guard that refuses
|
|
30
|
-
# a quotation teaches not to check the tree but not to write quotes. So before the parse, quotes,
|
|
31
|
-
# code, quoting lines and sentences with a word of condition are taken out of what was said.
|
|
32
|
-
#
|
|
33
|
-
# FAIL-OPEN: on any error, a missing `jq`, no turn record or empty text the turn is ALLOWED
|
|
34
|
-
# (exit 0). A broken guard has no right to jam the conversation.
|
|
35
|
-
|
|
36
|
-
# Its own name in the observations: the refusal is written by the shared deny tail, not by the guard.
|
|
37
|
-
RT_GUARD_NAME=claim-guard
|
|
38
|
-
RT_GUARD_RULE=turn-conduct
|
|
39
|
-
|
|
40
|
-
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
41
|
-
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
42
|
-
|
|
43
|
-
rt_hook_read
|
|
44
|
-
input="$RT_HOOK_INPUT"
|
|
45
|
-
[ -z "$input" ] && exit 0
|
|
46
|
-
command -v jq >/dev/null 2>&1 || exit 0
|
|
47
|
-
|
|
48
|
-
# A repeat pass over the same turn is not judged: the guard said its piece once and lets go.
|
|
49
|
-
active="$(printf '%s' "$input" | jq -r '.stop_hook_active // false' 2>/dev/null)"
|
|
50
|
-
[ "$active" = "true" ] && exit 0
|
|
51
|
-
|
|
52
|
-
transcript="$(printf '%s' "$input" | jq -r '.transcript_path // empty' 2>/dev/null)"
|
|
53
|
-
[ -z "$transcript" ] && exit 0
|
|
54
|
-
[ -f "$transcript" ] || exit 0
|
|
55
|
-
|
|
56
|
-
# The text of the reply lands in the turn record no earlier than the host calls the hook: a guard
|
|
57
|
-
# that read the file first judges a turn that has nothing said in it at all — and stays silent,
|
|
58
|
-
# indistinguishable from a guard that looked and let it through. We wait for it to appear, and
|
|
59
|
-
# failing to see it, we return the turn: an empty record means not "nothing was said to the owner"
|
|
60
|
-
# but "there is nothing to read".
|
|
61
|
-
#
|
|
62
|
-
# This refusal belongs to one guard on purpose. Three of them judge the text, and were they to
|
|
63
|
-
# print their objects one after another, the output would stop being parsed whole — that is, the
|
|
64
|
-
# refusal would be lost entirely.
|
|
65
|
-
if ! rt_turn_has_text "$transcript"; then
|
|
66
|
-
reason="BLOCKED by claim-guard: the record of the turn gave back no reply text at all, and there is nothing to judge what was said to the owner by.
|
|
67
|
-
|
|
68
|
-
The text lands in the record no earlier than the host calls the hook. A record read too early looks like a turn in which nothing was said to the owner — and every guard that judges what was said passes by in silence.
|
|
69
|
-
|
|
70
|
-
Repeat the ending of the turn: by this minute the text is already in the record. The turn loses nothing by it — what was said to the owner stays the same.
|
|
71
|
-
|
|
72
|
-
The guard judges one turn: the next session is not refused."
|
|
73
|
-
|
|
74
|
-
# shellcheck disable=SC1090
|
|
75
|
-
[ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
|
|
76
|
-
&& . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
|
|
77
|
-
command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
|
|
78
|
-
deny_tail_text="$(rt_deny_tail "")"
|
|
79
|
-
[ -n "$deny_tail_text" ] && reason="${reason}
|
|
80
|
-
|
|
81
|
-
${deny_tail_text}"
|
|
82
|
-
|
|
83
|
-
jq -n --arg r "$reason" '{decision:"block",reason:$r}' 2>/dev/null \
|
|
84
|
-
|| printf '{"decision":"block","reason":"claim-guard: the record of the turn gave back no reply text — repeat the ending of the turn."}\n'
|
|
85
|
-
exit 0
|
|
86
|
-
fi
|
|
87
|
-
|
|
88
|
-
# A turn is everything recorded after the owner's last real reply: a tool answer comes in under
|
|
89
|
-
# the same role and does not count as a reply.
|
|
90
|
-
turn="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r '
|
|
91
|
-
def is_input:
|
|
92
|
-
.type == "user"
|
|
93
|
-
and ((.isCompactSummary // false) | not)
|
|
94
|
-
and (((.message.content // []) | if type == "array"
|
|
95
|
-
then ([.[] | select(.type == "tool_result")] | length)
|
|
96
|
-
else 0 end) == 0);
|
|
97
|
-
|
|
98
|
-
(map(is_input) | rindex(true)) as $i
|
|
99
|
-
| (if $i == null then [] else .[$i:] end) as $turn
|
|
100
|
-
| [$turn[] | select(.type == "assistant") | (.message.content // [])[]
|
|
101
|
-
| select(.type == "text") | (.text // "")] as $said
|
|
102
|
-
| [$turn[] | select(.type == "assistant") | (.message.content // [])[]
|
|
103
|
-
| select(.type == "tool_use") | (.input.command // "")] as $ran
|
|
104
|
-
| { said: ($said | join("\n")), ran: ($ran | join("\n")) }
|
|
105
|
-
' 2>/dev/null)"
|
|
106
|
-
|
|
107
|
-
[ -z "$turn" ] && exit 0
|
|
108
|
-
|
|
109
|
-
said="$(printf '%s' "$turn" | jq -r '.said // ""' 2>/dev/null)"
|
|
110
|
-
ran="$(printf '%s' "$turn" | jq -r '.ran // ""' 2>/dev/null)"
|
|
111
|
-
[ -z "$said" ] && exit 0
|
|
112
|
-
|
|
113
|
-
# Someone else's word is taken out before the parse. A quoting line and a code block go whole,
|
|
114
|
-
# quotes and inline code are blanked with a space, and sentences with a word of condition are
|
|
115
|
-
# dropped: "would have run" and "if the lint were green" say nothing about the state of the tree.
|
|
116
|
-
judged="$(printf '%s\n' "$said" \
|
|
117
|
-
| awk 'BEGIN { code = 0 }
|
|
118
|
-
/^[[:space:]]*```/ { code = !code; next }
|
|
119
|
-
!code && !/^[[:space:]]*>/' \
|
|
120
|
-
| sed -E 's/`[^`]*`/ /g; s/«[^»]*»/ /g; s/"[^"]*"/ /g' \
|
|
121
|
-
| sed -E 's/([.!?])[[:space:]]+/\1\'$'\n''/g' \
|
|
122
|
-
| grep -viE '(^|[[:space:]])(бы|если|разве|неужели|ли)([[:space:]]|[,.]|$)' 2>/dev/null \
|
|
123
|
-
| sed -E 's/^/ /; s/([[:space:]])не[[:space:]]+/\1не~/g')"
|
|
124
|
-
[ -z "$judged" ] && exit 0
|
|
125
|
-
said="$judged"
|
|
126
|
-
# Every sentence starts with a space, and a negation is glued to the word after it by `~`. The
|
|
127
|
-
# space is the word boundary: an anchor inside a group and a class with a negation do not hold one
|
|
128
|
-
# — `^` in a group under `grep -o` is true at any position where PATH leads to ugrep, and a class
|
|
129
|
-
# like `[^а-яё]` matches half of a two-byte letter. Without the boundary «слит» was found inside
|
|
130
|
-
# «числит», and a sentence about counting was read as merged work.
|
|
131
|
-
|
|
132
|
-
# The claims map: what is said about the tree | what shows it | what to name in the refusal.
|
|
133
|
-
#
|
|
134
|
-
# The word is taken in the form it is said to the owner in. The future tense does not go here:
|
|
135
|
-
# "I will check" and "I will start" are not claims — they are a promise, and there is nothing in
|
|
136
|
-
# them to lie with.
|
|
137
|
-
#
|
|
138
|
-
# `@` stands before a claim word: it reads as the word boundary for the claim and as «не» before
|
|
139
|
-
# the word for its negation. A done action is named by a past form: «удаляет» and «удалить» describe
|
|
140
|
-
# what a command does, not what was done.
|
|
141
|
-
claims=(
|
|
142
|
-
'@проверено|@прогнал[а]?|@тесты (зелёные|прошли)|@линт(ер)? (зелёный|прошёл|чистый)|@сборка (зелёная|прошла)|@набор зелёный|@проверки зелёные|@спеки зелёные|@всё зелен(о|ое)§nx (test|lint|build|run|affected|run-many)|npm (run|test)|pnpm (run|exec|test)|jest|vitest|playwright|check:|run\.sh§команду набора — прогон тестов, линта или сборки'
|
|
143
|
-
# A gate called fixed is a claim about a run: the fix is shown by the gate passing, and the
|
|
144
|
-
# phrase was once said with not one run behind it.
|
|
145
|
-
'@проверк[аи] перед (push|пушем|отправкой)[^.]{0,30}(починен|исправлен)§git push|check:all|pnpm (run|exec)§прогон набора перед push — `git push` или `pnpm run check:all`'
|
|
146
|
-
'@запушен[аоы]?|@запушил[а]?|@пуш прошёл|@ветка уехала§git push§`git push`'
|
|
147
|
-
'(PR|правка|ветка|работа)[^.]{0,20}@(влит|слит|смержен)|@влит[оа] в|@слит[оа] в§git merge|gh pr merge|glab mr merge§`git merge`, `gh pr merge` или `glab mr merge`'
|
|
148
|
-
'(ветки|ветка|файлы|файл|папка|каталог)[^.]{0,40}@(снят|удал[её]н|удалил|почищен|почистил|вычищен|вычистил)|@снят[оыа] с§git branch|git push .*--delete|git rm|gh api|rm §команду удаления — `git branch -d`, `git push --delete` или `git rm`'
|
|
149
|
-
'@прогон (зелёный|прошёл|кончился)|@конвейер зелёный|@проверки на PR зелёные§gh run|glab ci§`gh run list`, `gh run view` или `glab ci status`'
|
|
150
|
-
'@(работа|правка|задача) готова|@можно вливать|@PR открыт|@черновик снят§gh pr |glab mr §`gh pr create`, `gh pr view`, `gh pr ready` или `glab mr`'
|
|
151
|
-
# Waiting for someone else's step is a claim about the state too, and there is something in it
|
|
152
|
-
# to lie with: a run is green for an hour, and sometimes never starts at all. Said without a
|
|
153
|
-
# command, it leaves finished work a draft, and the owner learns of it last — that is exactly
|
|
154
|
-
# how it went twice in one day.
|
|
155
|
-
'@жд[уёя][^.]{0,20}прогон|@дожида[ею][^.]{0,20}прогон|@прогон[^.]{0,20}(ещё идёт|не встал|не кончился|не дошёл)|@черновик[^.]{0,30}(не снимаю|сниму|снимется)§gh run|gh pr checks|glab ci|check-runs|check:board|board\.mjs§команду о прогоне — `gh run list`, `gh pr checks` или сверку очереди работ'
|
|
156
|
-
'@задача заведена|@задача (в|переведена в) колонк|@колонка переведена§gh issue|gh api|glab issue|glab api|task:new|task:move|board\.mjs§команду очереди работ — заведение задачи или перевод колонки'
|
|
157
|
-
'(в дереве|в репозитории|здесь|такого файла|такой команды)[^.]{0,30}(нет|не бывает)|@не заводили|@нигде не встречается§grep|rg |ls |find |git ls-files|git grep|git log|cat §команду поиска — `grep`, `git ls-files` или обход каталога'
|
|
158
|
-
)
|
|
159
|
-
|
|
160
|
-
# A negated claim is a statement about the tree too, but the action command cannot show it: «not
|
|
161
|
-
# pushed» is shown by a read of the branch state, not by a push.
|
|
162
|
-
read_proof='git (status|log|ls-remote|branch|show|rev-parse|fetch|diff)|gh (pr|run|api|issue)|glab (mr|ci|api|issue)|ls |grep|board\.mjs'
|
|
163
|
-
|
|
164
|
-
for row in "${claims[@]}"; do
|
|
165
|
-
words="${row%%§*}"
|
|
166
|
-
rest="${row#*§}"
|
|
167
|
-
proof="${rest%%§*}"
|
|
168
|
-
name="${rest#*§}"
|
|
169
|
-
|
|
170
|
-
# The text glues «не» to the next word, so the row does the same with its own «не».
|
|
171
|
-
words="${words//не /не~}"
|
|
172
|
-
claim_re="${words//@/ }"
|
|
173
|
-
negated_re="${words//@/ не~}"
|
|
174
|
-
|
|
175
|
-
found="$(printf '%s' "$said" | grep -oiE "$claim_re" 2>/dev/null | head -1)"
|
|
176
|
-
if [ -n "$found" ]; then
|
|
177
|
-
printf '%s' "$ran" | grep -qiE "$proof" 2>/dev/null && continue
|
|
178
|
-
else
|
|
179
|
-
found="$(printf '%s' "$said" | grep -oiE "$negated_re" 2>/dev/null | head -1)"
|
|
180
|
-
[ -z "$found" ] && continue
|
|
181
|
-
printf '%s' "$ran" | grep -qiE "$proof|$read_proof" 2>/dev/null && continue
|
|
182
|
-
name="команду чтения — \`git status\`, \`git log\` или \`git ls-remote\`"
|
|
183
|
-
fi
|
|
184
|
-
found="$(printf '%s' "$found" | sed -E 's/~/ /g; s/^[[:space:]]+//')"
|
|
185
|
-
|
|
186
|
-
reason="BLOCKED by claim-guard: the owner was told «${found}» — that is a statement about the state of the tree, and there was no command showing it in this turn.
|
|
187
|
-
|
|
188
|
-
A statement about the tree is worth exactly as much as the command that showed it: what is said without a command the owner reads as a verified fact and learns of the divergence last.
|
|
189
|
-
|
|
190
|
-
The first way out is to remove the statement from the reply and speak of what was done without it. It is the right one wherever the owner asked for no command: a run made to lift a refusal is sometimes more dangerous than what the guard watches — that is how a turn with nothing to deliver reached a push.
|
|
191
|
-
|
|
192
|
-
The second is to run ${name} in this same turn and name its output.
|
|
193
|
-
|
|
194
|
-
The guard judges one turn: the next session is not refused."
|
|
195
|
-
|
|
196
|
-
# The shared deny tail: the two lawful moves. The file may not be laid out — then there is no
|
|
197
|
-
# tail, and the reason for the refusal stays as it was.
|
|
198
|
-
# shellcheck disable=SC1090
|
|
199
|
-
[ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
|
|
200
|
-
&& . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
|
|
201
|
-
command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
|
|
202
|
-
deny_tail_text="$(rt_deny_tail "")"
|
|
203
|
-
[ -n "$deny_tail_text" ] && reason="${reason}
|
|
204
|
-
|
|
205
|
-
${deny_tail_text}"
|
|
206
|
-
|
|
207
|
-
jq -n --arg r "$reason" '{decision:"block",reason:$r}' 2>/dev/null \
|
|
208
|
-
|| printf '{"decision":"block","reason":"claim-guard: a statement about the tree is not backed by a command."}\n'
|
|
209
|
-
exit 0
|
|
210
|
-
done
|
|
211
|
-
|
|
212
|
-
exit 0
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# rt-hook: PreToolUse AskUserQuestion
|
|
3
|
-
# Requires: hooks/grill-gate.sh
|
|
4
|
-
# The half of the conversation guard that stands on the question tool: the menu is judged before it
|
|
5
|
-
# is sent.
|
|
6
|
-
#
|
|
7
|
-
# A resource of its own, not a line in the neighbour's header, because the question tool is the
|
|
8
|
-
# only way to ask the owner, and the tree may already have its own guard on it with its own refusal
|
|
9
|
-
# reason. A second refusal on the same tool makes the question unavailable altogether, and the tree
|
|
10
|
-
# drops the guard whole instead of taking its half. Split over two resources, the halves are
|
|
11
|
-
# cancelled separately: a refusal line removes one and leaves the other.
|
|
12
|
-
#
|
|
13
|
-
# The call is judged by the same body as the turn end: the requirement is one, and its two editions
|
|
14
|
-
# must not diverge. Here only the event declaration and passing the input on.
|
|
15
|
-
#
|
|
16
|
-
# FAIL-OPEN: no neighbouring file — the turn is ALLOWED. A half of the guard that has lost its body
|
|
17
|
-
# has no right to jam the conversation.
|
|
18
|
-
|
|
19
|
-
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utf8.sh" 2>/dev/null || true
|
|
20
|
-
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hook-input.sh" 2>/dev/null || true
|
|
21
|
-
|
|
22
|
-
rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
23
|
-
[ -f "$rt_hooks_dir/grill-gate.sh" ] || exit 0
|
|
24
|
-
|
|
25
|
-
rt_hook_read
|
|
26
|
-
printf '%s' "$RT_HOOK_INPUT" | "$rt_hooks_dir/grill-gate.sh"
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# The fifth sign of the conversation guard: a question that offers to walk around a check does not
|
|
3
|
-
# leave. NOT a guard: it has no `rt-hook:` declaration and hooks into no agent event. The
|
|
4
|
-
# conversation guard sources it — it was moved out when the guard crossed the file length limit.
|
|
5
|
-
#
|
|
6
|
-
# A red set was explained by a "foreign" cause, and the owner was asked whether to send it past the
|
|
7
|
-
# check. Such a question is a miss by itself, even when the owner answers "yes": a check is fixed at
|
|
8
|
-
# its cause or fixed itself, and a third option is not named. The sign reads the text the owner
|
|
9
|
-
# reads — the menu with its options, or the last reply when it ends with a question — and looks for
|
|
10
|
-
# the forms of a bypass: past the check, a bypass line, a disabled rule, a hook switched off.
|
|
11
|
-
#
|
|
12
|
-
# It expects `$tool`, `$asked_text`, `$transcript` and `$rt_hooks_dir` to be set; it prints the
|
|
13
|
-
# refusal and returns zero when the question offers a bypass, and stays silent otherwise.
|
|
14
|
-
#
|
|
15
|
-
# FAIL-OPEN: no text of a question — the sign stays silent.
|
|
16
|
-
|
|
17
|
-
rt_grill_bypass() {
|
|
18
|
-
local bypass_re offered_text reason deny_tail_text
|
|
19
|
-
bypass_re='мимо (проверк|гейт|хук)|в обход (проверк|гейт|хук)|обойти (проверк|гейт|хук)|bypass|--no-verify|Epic-stop-skip|Docs-skip|Task-folder-skip|# discard:|eslint-disable|stylelint-disable|отключ[а-я]* (проверк|правил|линтер|хук)|в список известных|allowlist'
|
|
20
|
-
if [ -n "$tool" ]; then
|
|
21
|
-
offered_text="$asked_text"
|
|
22
|
-
else
|
|
23
|
-
offered_text="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r '
|
|
24
|
-
def is_input:
|
|
25
|
-
.type == "user"
|
|
26
|
-
and ((.isCompactSummary // false) | not)
|
|
27
|
-
and ((.isMeta // false) | not)
|
|
28
|
-
and (((.message.content // []) | if type == "array"
|
|
29
|
-
then ([.[] | select(.type == "tool_result")] | length)
|
|
30
|
-
else 0 end) == 0);
|
|
31
|
-
(map(is_input) | rindex(true)) as $i
|
|
32
|
-
| (if $i == null then . else .[$i + 1:] end)
|
|
33
|
-
| [.[] | select(.type == "assistant") | (.message.content // [])[] | select(.type == "text") | .text]
|
|
34
|
-
| last // ""
|
|
35
|
-
| if test("\\?[[:space:]]*$") then . else "" end
|
|
36
|
-
' 2>/dev/null)"
|
|
37
|
-
fi
|
|
38
|
-
[ -n "$offered_text" ] || return 1
|
|
39
|
-
printf '%s' "$offered_text" | grep -qiE "$bypass_re" 2>/dev/null || return 1
|
|
40
|
-
|
|
41
|
-
reason="BLOCKED by grill-gate: the question offers the owner to walk around a check.
|
|
42
|
-
|
|
43
|
-
A question about a bypass is a miss by itself, even when the owner answers «yes». A red check is fixed at its cause — on the machine and in the tree — or the check itself is fixed when it is wrong. A third option is not named, and handing the owner a command to run by hand instead is the same bypass. Ask only the decision the fix needs."
|
|
44
|
-
|
|
45
|
-
# shellcheck disable=SC1090
|
|
46
|
-
[ -f "$rt_hooks_dir/deny-tail.sh" ] && . "$rt_hooks_dir/deny-tail.sh" 2>/dev/null
|
|
47
|
-
command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
|
|
48
|
-
deny_tail_text="$(rt_deny_tail "")"
|
|
49
|
-
[ -n "$deny_tail_text" ] && reason="${reason}
|
|
50
|
-
|
|
51
|
-
${deny_tail_text}"
|
|
52
|
-
|
|
53
|
-
if [ -n "$tool" ]; then
|
|
54
|
-
jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
|
|
55
|
-
|| printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"grill-gate: a question does not offer a bypass of a check."}}\n'
|
|
56
|
-
else
|
|
57
|
-
jq -n --arg r "$reason" '{decision:"block",reason:$r}' 2>/dev/null \
|
|
58
|
-
|| printf '{"decision":"block","reason":"grill-gate: a question does not offer a bypass of a check."}\n'
|
|
59
|
-
fi
|
|
60
|
-
return 0
|
|
61
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# A part of the fourth sign of the conversation guard: after a refused menu a list of options in
|
|
3
|
-
# prose is a question too. NOT a guard: it has no `rt-hook:` declaration and hooks into no agent
|
|
4
|
-
# event. The conversation guard sources it — it was moved out when the guard crossed the file
|
|
5
|
-
# length limit.
|
|
6
|
-
#
|
|
7
|
-
# After a refused menu the executor gave the same options as a numbered list with no question mark
|
|
8
|
-
# and ended the turn: the sign knew prose only by «?», and the list went out as an ordinary reply.
|
|
9
|
-
# In a turn where the menu was refused, a numbered list of two or more items under a line ending
|
|
10
|
-
# with a colon is a question too. Outside such a turn a list is not judged: many ordinary reports
|
|
11
|
-
# carry one, and a refusal on each would teach to strip lists from replies.
|
|
12
|
-
#
|
|
13
|
-
# It expects `$transcript` and `$question_text` to be set; it returns zero when the turn ends with
|
|
14
|
-
# such a list after a refused menu, and non-zero otherwise.
|
|
15
|
-
#
|
|
16
|
-
# FAIL-OPEN: no turn record, no parser — the list is not a question.
|
|
17
|
-
|
|
18
|
-
rt_grill_options_asked() {
|
|
19
|
-
local menu_refused options_re
|
|
20
|
-
menu_refused="$(tail -n 400 "$transcript" 2>/dev/null | jq -s -r '
|
|
21
|
-
def is_input:
|
|
22
|
-
.type == "user"
|
|
23
|
-
and ((.isCompactSummary // false) | not)
|
|
24
|
-
and ((.isMeta // false) | not)
|
|
25
|
-
and (((.message.content // []) | if type == "array"
|
|
26
|
-
then ([.[] | select(.type == "tool_result")] | length)
|
|
27
|
-
else 0 end) == 0);
|
|
28
|
-
def asks_menu:
|
|
29
|
-
.type == "assistant" and ((.message.content // []) | any(.[];
|
|
30
|
-
.type == "tool_use" and .name == "AskUserQuestion"));
|
|
31
|
-
def refused:
|
|
32
|
-
.type == "user" and ((.message.content // []) | if type == "array"
|
|
33
|
-
then any(.[]; .type == "tool_result" and (.is_error // false))
|
|
34
|
-
else false end);
|
|
35
|
-
(map(is_input) | rindex(true)) as $i
|
|
36
|
-
| (if $i == null then . else .[$i + 1:] end) as $turn
|
|
37
|
-
| [range(0; ($turn | length) - 1) as $k
|
|
38
|
-
| select(($turn[$k] | asks_menu) and ($turn[$k + 1] | refused))]
|
|
39
|
-
| if length > 0 then "yes" else "no" end
|
|
40
|
-
' 2>/dev/null)"
|
|
41
|
-
[ "$menu_refused" = "yes" ] || return 1
|
|
42
|
-
|
|
43
|
-
options_re='^[[:space:]]*[0-9]+[.)][[:space:]]'
|
|
44
|
-
printf '%s\n' "$question_text" | awk -v re="$options_re" '
|
|
45
|
-
/:[[:space:]]*$/ { lead = 1; items = 0; next }
|
|
46
|
-
lead && $0 ~ re { items++; if (items >= 2) found = 1; next }
|
|
47
|
-
lead && /^[[:space:]]*$/ { next }
|
|
48
|
-
{ lead = 0; items = 0 }
|
|
49
|
-
END { exit found ? 0 : 1 }'
|
|
50
|
-
}
|