@rt-tools/agent-kit 0.37.0 → 0.37.1
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/checks/board-pull-state.github.mjs +82 -13
- package/assets/checks/board.github.mjs +1 -1
- package/assets/checks/check-board.github.mjs +20 -12
- package/assets/checks/check-specs.mjs +2 -2
- package/assets/checks/epic-table.github.mjs +4 -3
- package/assets/checks/lib-common.mjs +10 -2
- package/assets/checks/lib-domains.mjs +1 -1
- package/assets/checks/lib-manifests.mjs +34 -2
- package/assets/checks/push-inputs.mjs +401 -0
- package/assets/checks/push-trace.mjs +108 -0
- package/assets/checks/rt-kit-checks.config.mjs +17 -2
- package/assets/checks/spec-anchors.mjs +4 -4
- package/assets/checks/spec-contract.mjs +5 -5
- package/assets/commands/next-session.md +3 -1
- package/assets/commands/night.md +28 -18
- package/assets/defaults/project.sh +37 -8
- package/assets/defaults/push.sh +23 -0
- package/assets/defaults/turn-map.md +10 -6
- package/assets/docs/GLOSSARY.md +1 -1
- package/assets/hooks/epic-stop-guard.sh +62 -15
- package/assets/hooks/git-guard-push-ahead.sh +31 -1
- package/assets/hooks/git-guard-push-marks.sh +173 -29
- package/assets/hooks/git-guard-push-tests.sh +22 -3
- package/assets/hooks/handoff-entry-guard.sh +2 -2
- package/assets/hooks/pre-push.sh +6 -0
- package/assets/hooks/push-set.sh +29 -4
- package/assets/hooks/task-flow-context.sh +15 -4
- package/assets/hooks/task-flow-guard.sh +4 -3
- package/assets/hooks/turn-exit-epic.sh +1 -1
- package/assets/hooks/turn-exit-guard.sh +8 -8
- package/assets/hooks/turn-exit-role.sh +45 -0
- package/assets/laws/work-conduct.md +9 -8
- package/assets/patterns/autonomous-work-run.md +35 -10
- package/assets/patterns/browser-verification-measure.md +10 -20
- package/assets/patterns/browser-verification-stand.md +30 -42
- package/assets/patterns/doc-style-human.md +0 -6
- package/assets/patterns/doc-style-sweep.md +7 -7
- package/assets/patterns/doc-style-trace.md +5 -4
- package/assets/patterns/doc-style-write.md +7 -7
- package/assets/patterns/epic-flow-declare.md +15 -8
- package/assets/patterns/git-workflow-commit.github.md +1 -1
- package/assets/patterns/git-workflow-freshness.md +12 -11
- package/assets/patterns/git-workflow-merge.md +14 -11
- package/assets/patterns/git-workflow-migration.md +4 -2
- package/assets/patterns/git-workflow-pr-body.github.md +1 -1
- package/assets/patterns/git-workflow-pr-ready.md +5 -4
- package/assets/patterns/git-workflow-pr.azure.md +91 -25
- package/assets/patterns/git-workflow-pr.github.md +17 -19
- package/assets/patterns/git-workflow-pr.gitlab.md +75 -29
- package/assets/patterns/git-workflow-restart.md +3 -2
- package/assets/patterns/git-workflow-stack.md +25 -21
- package/assets/patterns/lib-layers-new.md +7 -3
- package/assets/patterns/queue-audit-read.github.md +9 -3
- package/assets/patterns/spec-driven-domain.md +50 -48
- package/assets/patterns/spec-driven-rule.md +18 -19
- package/assets/patterns/status-report-table.github.md +1 -1
- package/assets/patterns/task-flow-archive.md +14 -34
- package/assets/patterns/task-flow-close.md +3 -2
- package/assets/patterns/task-flow-graph.needs-graph.md +4 -0
- package/assets/patterns/task-flow-handoff.md +4 -4
- package/assets/patterns/task-flow-resume.md +56 -20
- package/assets/patterns/task-flow-start.md +3 -4
- package/assets/patterns/testing-e2e.md +14 -18
- package/assets/patterns/testing-unit.md +9 -13
- package/assets/patterns/turn-entry-map.md +13 -3
- package/assets/pitfalls/autonomous-work.md +15 -0
- package/assets/pitfalls/doc-style.md +3 -3
- package/assets/pitfalls/git-workflow.github.md +5 -9
- package/assets/pitfalls/spec-driven.md +9 -7
- package/assets/pitfalls/task-flow.md +14 -25
- package/assets/pitfalls/testing.md +11 -12
- package/assets/pitfalls/turn-conduct.md +6 -6
- package/assets/rules/autonomous-work.md +37 -29
- package/assets/rules/browser-verification.md +27 -22
- package/assets/rules/dependencies.md +3 -3
- package/assets/rules/deploy-flow.azure.md +35 -12
- package/assets/rules/deploy-flow.github.md +10 -6
- package/assets/rules/deploy-flow.gitlab.md +40 -17
- package/assets/rules/doc-style.md +21 -17
- package/assets/rules/epic-flow.md +5 -3
- package/assets/rules/git-workflow.azure.md +140 -122
- package/assets/rules/git-workflow.github.md +7 -8
- package/assets/rules/git-workflow.gitlab.md +128 -117
- package/assets/rules/queue-audit.github.md +5 -3
- package/assets/rules/spec-driven.md +17 -25
- package/assets/rules/status-report.md +5 -3
- package/assets/rules/task-flow.md +26 -15
- package/assets/rules/testing.md +35 -32
- package/assets/rules/turn-conduct.md +26 -24
- package/assets/templates/rule.md +2 -2
- package/lib/cargo-prose.d.ts +2 -1
- package/lib/cargo-prose.d.ts.map +1 -1
- package/lib/cargo-prose.js.map +1 -1
- package/lib/companion.d.ts +0 -5
- package/lib/companion.d.ts.map +1 -1
- package/lib/companion.js +1 -1
- package/lib/companion.js.map +1 -1
- package/lib/cost.d.ts +0 -8
- package/lib/cost.d.ts.map +1 -1
- package/lib/cost.js +4 -4
- package/lib/cost.js.map +1 -1
- package/lib/hooks-map.d.ts +0 -12
- package/lib/hooks-map.d.ts.map +1 -1
- package/lib/hooks-map.js +2 -25
- package/lib/hooks-map.js.map +1 -1
- package/lib/observations-cargo.d.ts +1 -5
- package/lib/observations-cargo.d.ts.map +1 -1
- package/lib/observations-cargo.js +2 -2
- package/lib/observations-cargo.js.map +1 -1
- package/lib/observations.d.ts +0 -2
- package/lib/observations.d.ts.map +1 -1
- package/lib/observations.js.map +1 -1
- package/lib/order.d.ts +0 -2
- package/lib/order.d.ts.map +1 -1
- package/lib/order.js +0 -4
- package/lib/order.js.map +1 -1
- package/lib/outcomes.d.ts +2 -7
- package/lib/outcomes.d.ts.map +1 -1
- package/lib/outcomes.js +3 -3
- package/lib/outcomes.js.map +1 -1
- package/lib/proposals.d.ts +0 -1
- package/lib/proposals.d.ts.map +1 -1
- package/lib/proposals.js +1 -1
- package/lib/proposals.js.map +1 -1
- package/lib/shipment.d.ts +2 -11
- package/lib/shipment.d.ts.map +1 -1
- package/lib/shipment.fixture.d.ts +0 -3
- package/lib/shipment.fixture.d.ts.map +1 -1
- package/lib/shipment.fixture.js +3 -3
- package/lib/shipment.fixture.js.map +1 -1
- package/lib/shipment.js +2 -2
- package/lib/shipment.js.map +1 -1
- package/lib/traits.d.ts +0 -3
- package/lib/traits.d.ts.map +1 -1
- package/lib/traits.js +2 -2
- package/lib/traits.js.map +1 -1
- package/lib/variants.d.ts +0 -1
- package/lib/variants.d.ts.map +1 -1
- package/lib/variants.js +1 -1
- package/lib/variants.js.map +1 -1
- package/package.json +1 -1
- package/assets/checks/signals/ui-kit.json +0 -11
|
@@ -27,10 +27,11 @@ with a guard does.
|
|
|
27
27
|
| understanding written where the work goes | `docs/tasks/<ветка>/grill.md` — the request verbatim, the owner's answers in their words, decisions with reasons |
|
|
28
28
|
| the plan | `docs/tasks/<ветка>/plan.md` — the task footprint and stages with readiness signs; not edited after it is written |
|
|
29
29
|
| the progress | `docs/tasks/<ветка>/progress.md` — "Where we stand", decisions along the way, session entries; the only place where done work is marked |
|
|
30
|
-
| the product agreement written before the code | `docs/specs/<домен>/proposed/<фича>/` — the feature spec;
|
|
30
|
+
| the product agreement written before the code | `docs/specs/<домен>/proposed/<фича>/` — the feature spec; merges into the domain spec before the PR opens |
|
|
31
31
|
| the task folder before the task is created | `docs/tasks/_draft-<slug>/` — outside history while there is no number |
|
|
32
32
|
| exploration | an `Explore` or `general-purpose` session before the first question to the owner |
|
|
33
33
|
| the plan review by roles | `.claude/workflows/plan.js` — need, points, agreement, critique, plan, goal |
|
|
34
|
+
| a large edit carried by roles | `.claude/workflows/feature.js` — plan, implementation, check, acceptance, points, goal |
|
|
34
35
|
|
|
35
36
|
## Where it lives
|
|
36
37
|
|
|
@@ -57,20 +58,20 @@ The state is declared in the "Where we stand" section of the progress by the mac
|
|
|
57
58
|
| `этап-идёт` | a stage is begun | finish the stage and mark it in the progress | `task-flow-resume` |
|
|
58
59
|
| `этапы-кончились` | all stages are marked | merge the agreement, bring texts up to date, run the suite | `task-flow-close` |
|
|
59
60
|
| `разбор-кончился` | the suite is green, texts are up to date | take the folder apart by the last commit | `task-flow-archive` |
|
|
60
|
-
| `папка-разобрана` | no folder in the branch, a record in the archive | open the PR: a draft where a run is waited for, ready where the pipeline does not wake | `task-flow-close` |
|
|
61
|
-
| `работа-отдана` | the PR is open into the epic branch, with a reviewer | take the next task of the epic | `task-flow-
|
|
62
|
-
| `влито` | the PR merged by a person |
|
|
61
|
+
| `папка-разобрана` | no folder in the branch, a record in the archive | the work queue audit, then open the PR: a draft where a run is waited for, ready where the pipeline does not wake | `task-flow-close` |
|
|
62
|
+
| `работа-отдана` | the PR is open into the epic branch, with a reviewer | the rules review of the work goes to the background, then take the next task of the epic | `task-flow-archive` |
|
|
63
|
+
| `влито` | the PR merged by a person | the epic plan marks the task merged by the next task's branch | `task-flow-resume` |
|
|
63
64
|
| `задачи-эпика-кончились` | every task of the epic is merged and its folder taken apart | open the PR of the epic into the main branch | `task-flow-close` |
|
|
64
65
|
|
|
65
66
|
No state has a mandatory action that sounds like "wait": waiting for someone else's step is not a
|
|
66
67
|
work state, so in `работа-отдана` the mandatory action is the next task, not the open PR. A blocked
|
|
67
68
|
task does not count as next: the same waiting under the name of work. The next is taken from the
|
|
68
|
-
|
|
69
|
-
output, not by the executor's memory. A filled session window is no state either: the session ends
|
|
69
|
+
epic plan; outside an epic the owner names it, and the queue, asked by a command, goes into the
|
|
70
|
+
question: "no tasks" is a statement about the tree, backed by output, not by the executor's memory. A filled session window is no state either: the session ends
|
|
70
71
|
with a handover, and the work stays where it stood. **An open card says nothing about whether the
|
|
71
72
|
work is taken.** A card is closed by the merge, and in a session that opens no PRs the list of open
|
|
72
73
|
ones does not shrink. A task is untaken when the tree holds no trace of it: open numbers are checked
|
|
73
|
-
against the archive
|
|
74
|
+
against the archive and its history — a record past its expiry stays in `git log -- docs/archive/`.
|
|
74
75
|
|
|
75
76
|
What a turn ends with — rule `turn-conduct` under the same law.
|
|
76
77
|
|
|
@@ -96,6 +97,8 @@ flowchart TD
|
|
|
96
97
|
F --> Z
|
|
97
98
|
Z -->|No| Y[The epic is declared: a card, all its tasks and a plan — then its branch from the main branch]
|
|
98
99
|
Z -->|Yes| G[Task, branch from the epic branch, task folder by branch name; the epic card moves with its first task]
|
|
100
|
+
Z -->|The owner's word about work outside an epic| X[Task, branch from the main branch, task folder by branch name]
|
|
101
|
+
X --> H
|
|
99
102
|
Y --> G
|
|
100
103
|
G --> H[A plan with stages; not edited after it is written]
|
|
101
104
|
H --> I{Stage done}
|
|
@@ -122,8 +125,8 @@ flowchart TD
|
|
|
122
125
|
declared state. The agreement has a guard of its own on the same events.
|
|
123
126
|
- **The guard judges the declared transition, not the presence of files.** The refusal is lifted
|
|
124
127
|
by the declared state — `этап-идёт`,
|
|
125
|
-
`этапы-кончились`,
|
|
126
|
-
means handed-in work.
|
|
128
|
+
`этапы-кончились`, `разбор-кончился`, `работа-отдана`. The fifth road is the branch history: a
|
|
129
|
+
folder taken apart means handed-in work.
|
|
127
130
|
- **A state line moved forward is the same declaration of intent, only machine-readable.** It is
|
|
128
131
|
declared by the turn in which its mandatory action is begun by deed.
|
|
129
132
|
- **A refusal by state names the mandatory action of that state.** Hearing only "wrong state", the
|
|
@@ -163,6 +166,10 @@ flowchart TD
|
|
|
163
166
|
- **The owner's word about the design is a task setting, not a decision.** What they named is
|
|
164
167
|
usually in the tree under that word — a name on a screen, a spec section, a model field — and is
|
|
165
168
|
checked against it before the edit. Diverged — the owner is asked.
|
|
169
|
+
- **A tool the owner named is used, and a substitute is named in the same reply.** A command, a
|
|
170
|
+
role or a browser named in the request is part of it; the reply says what was used instead and why.
|
|
171
|
+
- **A rule of the tree outweighs a standing instruction of the host.** The host describes its own
|
|
172
|
+
default; where the two differ, the tree's text is carried out.
|
|
166
173
|
- **A task folder is created for any work, no exceptions.** An exception with even one lawful form
|
|
167
174
|
is executed as permission. It goes in before the first edit.
|
|
168
175
|
- **The task folder goes into the branch by a commit, not lives in one working tree.** Uncommitted,
|
|
@@ -237,9 +244,11 @@ flowchart TD
|
|
|
237
244
|
graph is checked against the head before the first exploration, and a turn that does not use it
|
|
238
245
|
names the reason. Relations are taken from the graph; numbers, behaviour and texts — from the code
|
|
239
246
|
and the documents.
|
|
240
|
-
- **
|
|
241
|
-
|
|
242
|
-
|
|
247
|
+
- **The path to a sample lies outside the history, the permission to work outside the epic — in
|
|
248
|
+
the main branch.** The path names another tree and lives among the records that belong to no
|
|
249
|
+
branch; the progress names the sample by a reference to that place. The permission is a row of
|
|
250
|
+
the table of assignments, read from the main branch by every branch; it repeats the owner's word,
|
|
251
|
+
not replaces it.
|
|
243
252
|
- **Closed work is reviewed by the rules in the background, right after the PR, and its findings
|
|
244
253
|
wait for the owner.** Only the session that led the work sees what was loaded and what was
|
|
245
254
|
missing, and it takes the next task meanwhile. A proposal sent unreviewed becomes the work of
|
|
@@ -270,8 +279,9 @@ trace. The owner judges both.
|
|
|
270
279
|
The guard judges by the edit paths, not by whether the work changes behaviour. A refactoring gets no
|
|
271
280
|
sign of its own: the appraisal "behaviour does not change" would be assigned by whoever it hinders.
|
|
272
281
|
|
|
273
|
-
|
|
274
|
-
exploration, the six questions
|
|
282
|
+
Of the grill itself only the menus are checked: the conversation guard refuses a third menu after
|
|
283
|
+
the owner took the recommended option twice in a row. The exploration, the six questions and the
|
|
284
|
+
answers are checked by nothing.
|
|
275
285
|
|
|
276
286
|
The conversation guard judges shared words between the question's topic and the owner's last
|
|
277
287
|
message, not meaning; its refusal names the lawful move.
|
|
@@ -296,7 +306,8 @@ nothing counts; it is held by reading both texts in a row on every such edit.
|
|
|
296
306
|
|
|
297
307
|
- `task-flow-start` — exploration, grill, agreement, plan, task and branch.
|
|
298
308
|
- `task-flow-resume` — returning to unfinished work in a new session.
|
|
299
|
-
- `task-flow-close` —
|
|
309
|
+
- `task-flow-close` — merging the agreement, bringing the texts up to date, opening the PR and
|
|
310
|
+
lifting the draft.
|
|
300
311
|
- `task-flow-archive` — taking the task folder apart, the move to the archive, review by the rules.
|
|
301
312
|
- `task-flow-cycle` — an edit chosen by the report and judged by the next one.
|
|
302
313
|
- `task-flow-graph` — where the tree names the trait `graph`: the freshness check, the domain inventory and
|
package/assets/rules/testing.md
CHANGED
|
@@ -22,8 +22,8 @@ together with the rule.
|
|
|
22
22
|
| scenario | `SC-<PREFIX>-<NUMBER>` in `docs/specs/<domain>/scenarios.md` |
|
|
23
23
|
| test | `it(...)` in `*.spec.ts` next to the source — Vitest; an end-to-end test — Playwright |
|
|
24
24
|
| coverage digest | the output of `npm run check:specs`: covered, partial, without tests |
|
|
25
|
-
| uncovered mark | the line
|
|
26
|
-
| partial-coverage mark | the line
|
|
25
|
+
| uncovered mark | the line `Not covered: <reason>` inside the scenario block; legacy `Не покрыто:` |
|
|
26
|
+
| partial-coverage mark | the line `Coverage: partial — <what is missing>`; legacy `Покрытие: частичное —` |
|
|
27
27
|
|
|
28
28
|
## Where it lives
|
|
29
29
|
|
|
@@ -47,29 +47,30 @@ flowchart TD
|
|
|
47
47
|
F --> H[The moment in time is taken as a parameter, not read from the machine clock]
|
|
48
48
|
G --> H
|
|
49
49
|
C --> I{The test is switched off by an environment variable}
|
|
50
|
-
I -->|Yes| J[Does not count as coverage:
|
|
50
|
+
I -->|Yes| J[Does not count as coverage: the scenario carries a partial-coverage mark with a reason]
|
|
51
51
|
I -->|No| K[The test title carries the scenario number]
|
|
52
52
|
H --> K
|
|
53
53
|
K --> P{A scenario with that number exists in the specs}
|
|
54
54
|
P -->|No| Q[The check turns red: the test refers to a scenario that does not exist]
|
|
55
|
-
P -->|Yes| R{The
|
|
56
|
-
R -->|
|
|
57
|
-
R -->|
|
|
55
|
+
P -->|Yes| R{The scenario promises a person something, and the test does not follow their path}
|
|
56
|
+
R -->|Yes| S[Marked as partial coverage: goes into the digest as debt]
|
|
57
|
+
R -->|No| L{The scenario is left without a test}
|
|
58
58
|
L -->|Yes| M[Carries a mark with a reason: an empty one is not accepted]
|
|
59
59
|
L -->|No| N[Done]
|
|
60
60
|
S --> N
|
|
61
61
|
M --> N
|
|
62
|
-
J -->
|
|
62
|
+
J --> K
|
|
63
63
|
```
|
|
64
64
|
|
|
65
65
|
## How the law applies here
|
|
66
|
+
|
|
66
67
|
- **The scenario id stands at the start of the test title, followed by a dash.** One scenario is
|
|
67
68
|
checked by several tests, one test closes several scenarios.
|
|
68
69
|
- **A scenario without a test carries a mark with a reason.** An empty mark is not accepted, and
|
|
69
70
|
a mark next to an existing test is a refusal: it means the debt was closed and the mark not
|
|
70
71
|
removed.
|
|
71
|
-
- **A test that does not follow the user's path is marked as partial coverage.**
|
|
72
|
-
digest as debt, not as coverage.
|
|
72
|
+
- **A test that does not follow the user's path is marked as partial coverage.** This holds for a
|
|
73
|
+
scenario that promises a person something; it goes into the digest as debt, not as coverage.
|
|
73
74
|
- **A scenario whose "Then" names a person and what they see is closed by an end-to-end test.**
|
|
74
75
|
A unit test on the same computation stays debt: between a right decision and a person seeing
|
|
75
76
|
it lies everything the unit test did not touch.
|
|
@@ -96,9 +97,7 @@ flowchart TD
|
|
|
96
97
|
- **A procedure is also called by the end-to-end suite, not only by the test next to it.** The
|
|
97
98
|
end-to-end suite has its own direct-call helper, and the test takes the server's answer from
|
|
98
99
|
there instead of raising a screen for one field. So "there are no tests for the procedure" is
|
|
99
|
-
stated after a search for its name across the whole tree, end-to-end
|
|
100
|
-
included, not after no test file was found next to its file: six coverage marks in a row
|
|
101
|
-
declared closed work uncovered.
|
|
100
|
+
stated after a search for its name across the whole tree, end-to-end suites included.
|
|
102
101
|
- **The seed creates what a screen cannot open without, and nothing a guest would take for
|
|
103
102
|
real.** Content with an author — reviews, questions, discussions — a guest reads as written by
|
|
104
103
|
people, and the stand is assembled from the same database as the check by eye. The owner's
|
|
@@ -116,17 +115,15 @@ flowchart TD
|
|
|
116
115
|
gate, declaring in their own known lists that they fail on new code.
|
|
117
116
|
- **A check that arrives by layout arrives with its place too.** The place is the name of the
|
|
118
117
|
command that calls it and the line of the suite it stands in. A check without a place is
|
|
119
|
-
recognised only by the layout having put a new file, and the article above
|
|
120
|
-
it has nowhere to stand. That is how the length check arrived — by the same edition as the
|
|
121
|
-
article on its mandatory place.
|
|
118
|
+
recognised only by the layout having put a new file, and the article above has nowhere to put it.
|
|
122
119
|
- **A test that irreversibly changes stand data is switched off by default.** `BASE_URL`
|
|
123
120
|
redirects the run with one variable, and without the switch such a test would edit the data of
|
|
124
121
|
someone else's stand.
|
|
125
122
|
- **Tests that need nginx in front of the application wake together with `BASE_URL`.** A bare
|
|
126
123
|
page server does not pass them: the redirects live in the proxy config.
|
|
127
124
|
- **A linter rule that forbids a technique accepted here is switched off in the config, not
|
|
128
|
-
bypassed in every test.**
|
|
129
|
-
|
|
125
|
+
bypassed in every test.** Where a suite uses test switches, the linter rule
|
|
126
|
+
against skipped tests would forbid all of them at once. The reason is
|
|
130
127
|
written next to the disabling line, and a targeted `eslint-disable` stays for what is forbidden
|
|
131
128
|
for good reason.
|
|
132
129
|
- **A guard lets the action through when it is itself broken.** No input parser, empty input,
|
|
@@ -141,11 +138,9 @@ flowchart TD
|
|
|
141
138
|
once and fixed, one that failed to recognise is never seen. And the tree's accepted way of
|
|
142
139
|
calling the command — by full path, through a wrapper, with variable substitution — goes into
|
|
143
140
|
the sign alongside the bare name: the bypass the command is called by every day is exactly
|
|
144
|
-
where the guard
|
|
145
|
-
- **A test file is edited by the edit tool, the same as a document.** A
|
|
146
|
-
|
|
147
|
-
writes nothing while the reply looks like a done edit: the file is reread before the next step.
|
|
148
|
-
The article in full is in the rule `doc-style`.
|
|
141
|
+
where the guard sees nothing.
|
|
142
|
+
- **A test file is edited by the edit tool, the same as a document.** A refused shell command
|
|
143
|
+
writes nothing while the reply looks like a done edit; the article in full is in `doc-style`.
|
|
149
144
|
- **A check's known list is named and explains itself.** The first field of the list is the
|
|
150
145
|
check's name and a word that what is listed does not count as a refusal. Then either two keys —
|
|
151
146
|
the accepted stays forever, the debt was gathered when the check was created and only shrinks —
|
|
@@ -158,9 +153,9 @@ flowchart TD
|
|
|
158
153
|
- **Every entry carries its own reason and the number of the task that added it.** A prose reason
|
|
159
154
|
for the whole list explains any of its lines and therefore explains none, and an entry without
|
|
160
155
|
a number cannot be asked of anyone: whoever added it remembers by that day neither the occasion
|
|
161
|
-
nor their decision. An entry without a reason or a number makes the check refuse
|
|
162
|
-
|
|
163
|
-
|
|
156
|
+
nor their decision. An entry without a reason or a number makes the check refuse. Entries are
|
|
157
|
+
written when the check is created and are not added later — neither by the executor's decision
|
|
158
|
+
nor by the owner's word.
|
|
164
159
|
- **A list entry nothing calls any more is removed together with what called it.** Such a line
|
|
165
160
|
silently allows what the tree does not have, and the next reader takes it for a current
|
|
166
161
|
explanation. Not every list has a dead-entry check, so it is removed by the same change that
|
|
@@ -176,9 +171,10 @@ flowchart TD
|
|
|
176
171
|
the output of that step, then the decision. A rerun repeated before reading the output fixes
|
|
177
172
|
not the cause but its symptom, and in history looks like work.
|
|
178
173
|
- **A line is not added to the known list for a red check.** The list was gathered by the day the
|
|
179
|
-
check was created and has only shrunk since: an added line
|
|
180
|
-
and in history looks the same as a fix. A place where the check
|
|
181
|
-
wrong in substance is
|
|
174
|
+
check was created and has only shrunk since: an added line hides the signal, not the cause,
|
|
175
|
+
and in history looks the same as a fix. A place where the check looks right by the letter and
|
|
176
|
+
wrong in substance is fixed in the code; a check that is itself wrong is fixed in the check, by
|
|
177
|
+
the analysis the law names — not by a question to the owner. An inline
|
|
182
178
|
mark that switches a check off for one place is the same line, written into the file instead of
|
|
183
179
|
the list. It is not placed even for a moment.
|
|
184
180
|
- **An exchange counts as read on both sides, not by the success of calls.** Sending and editing
|
|
@@ -260,14 +256,21 @@ flowchart TD
|
|
|
260
256
|
|
|
261
257
|
Test completeness is not checked: the audit judges the path — end-to-end or unit — but not how
|
|
262
258
|
much of the promise the test closed on that path. The path sign is read from the word "Then" and
|
|
263
|
-
is deliberately
|
|
259
|
+
is deliberately narrow: a scenario whose promise does not name a person does not fall under it
|
|
264
260
|
at all, and the incompleteness mark there is still placed by hand.
|
|
265
261
|
|
|
266
|
-
A coverage mark goes
|
|
262
|
+
A coverage mark goes out of date, and no check says so. The audit knows the scenario id against
|
|
263
|
+
the test title, and
|
|
267
264
|
the mark text under it is prose to it: it reads as a current description half a year after the
|
|
268
265
|
debt was closed. The mark is re-read with the edit that touches its subject — otherwise nobody
|
|
269
|
-
re-reads it.
|
|
270
|
-
|
|
266
|
+
re-reads it. Module substitution has no package agreement: whether the tree writes doubles by
|
|
267
|
+
hand is named by the companion.
|
|
268
|
+
|
|
269
|
+
The author alone holds these articles of the law: a test written before the code and red before
|
|
270
|
+
the change; a change with nothing to show red saying so; a test returning the shared state; an
|
|
271
|
+
empty input tested as three states; a declaration read as text written as a literal; a list of
|
|
272
|
+
checks read from output, not from memory; the analysis of a broken check shown to the owner. The
|
|
273
|
+
push set and a check removed from it are `git-workflow`; layout thresholds — `browser-verification`.
|
|
271
274
|
|
|
272
275
|
Observations of how the rules are used this rule does not keep at all: the kind of event, the
|
|
273
276
|
place of writing and what goes outside are the subject of the observability law and the rule
|
|
@@ -19,19 +19,19 @@ demand, not with the rule.
|
|
|
19
19
|
| In the law | Here |
|
|
20
20
|
| --- | --- |
|
|
21
21
|
| turn | one pass of the agent: from the owner's message to the reply |
|
|
22
|
-
| a turn exit | one of the
|
|
22
|
+
| a turn exit | one of the ways to end a turn listed below; what confirms each — the turn map |
|
|
23
23
|
| the guard of turn exits | a guard at the turn's end: reads the declared work state and what the turn did in the tree |
|
|
24
24
|
| a statement about the state of the tree | a word in the reply to the owner backed by a command of the same turn and its output |
|
|
25
|
-
| the session handover | a
|
|
25
|
+
| the session handover | a section of the progress retelling it for a new session; a file outside the tree where there is no task folder |
|
|
26
26
|
| the compaction threshold and the stop threshold | two window-fill numbers the tree sets itself; the first stands below the second |
|
|
27
27
|
|
|
28
28
|
## Turn exits
|
|
29
29
|
|
|
30
|
-
A turn ends in four ways
|
|
31
|
-
|
|
30
|
+
A turn ends in four ways: a question to the owner the rules do not answer **and no task of the epic plan
|
|
31
|
+
to take without the answer**; a guard's refusal; a
|
|
32
32
|
filled window where there is no compaction; work handed in, with the next begun. What confirms
|
|
33
|
-
each, the turn map lists where the tree laid it out. While an epic has an unfinished task,
|
|
34
|
-
|
|
33
|
+
each, the turn map lists where the tree laid it out. While an epic has an unfinished task, the
|
|
34
|
+
fourth does not end a turn: the next task is worked on in it. The end of the epic is the fifth.
|
|
35
35
|
|
|
36
36
|
The queue is asked by a command in the same turn: "there are no tasks" is a statement about the
|
|
37
37
|
tree, and the executor's memory does not confirm it. A turn where the owner's answer holds one
|
|
@@ -46,8 +46,7 @@ turn, and a state boundary looks like a finished piece better than any milestone
|
|
|
46
46
|
Four ways to end a turn look like work and are not: a summary of someone else's step, a menu under
|
|
47
47
|
an assigned order, a declaration of intent, and a command named but not run.
|
|
48
48
|
|
|
49
|
-
A turn ending while an epic runs shows the owner their position by the table the
|
|
50
|
-
the order is written down, and the one it is followed for cannot otherwise see the queue's state.
|
|
49
|
+
A turn ending while an epic runs shows the owner their position by the epic's table: otherwise they cannot see the queue's state.
|
|
51
50
|
|
|
52
51
|
## Where it lives
|
|
53
52
|
|
|
@@ -61,7 +60,9 @@ One turn: what it ends with, what is checked before its end and what the owner i
|
|
|
61
60
|
```mermaid
|
|
62
61
|
flowchart TD
|
|
63
62
|
A[The turn is going] --> B{What happened}
|
|
64
|
-
B -->|A question to the owner| C[Laws and rules read in the same turn]
|
|
63
|
+
B -->|A question to the owner, and no queue task free of its answer| C[Laws and rules read in the same turn]
|
|
64
|
+
B -->|The epic ended| L[Its task table shown, orders awaited]
|
|
65
|
+
L --> I
|
|
65
66
|
B -->|A guard refused an edit| D[The refusal named to the owner, no bypass sought]
|
|
66
67
|
B -->|The window is filled| E{The tree declared compaction}
|
|
67
68
|
B -->|Work handed in by a PR| F[An action done on the next task, not spoken]
|
|
@@ -80,12 +81,10 @@ flowchart TD
|
|
|
80
81
|
|
|
81
82
|
## How the law applies here
|
|
82
83
|
|
|
83
|
-
- **A promise to do the work in the next turn is an announcement of intent.** It
|
|
84
|
-
command named and not run
|
|
85
|
-
a stop less often.
|
|
84
|
+
- **A promise to do the work in the next turn is an announcement of intent.** It sounds politer than
|
|
85
|
+
a command named and not run, and so is recognised as a stop less often.
|
|
86
86
|
- **An order named by a number or by the word "all" is counted aloud before the turn ends.** The reply carries the count — how many out of how many. A turn where the count did
|
|
87
|
-
not add up does not end: it goes on with the next item of the order.
|
|
88
|
-
holds is written nowhere in the tree — only whoever read the order knows it.
|
|
87
|
+
not add up does not end: it goes on with the next item of the order.
|
|
89
88
|
- **The owner's word to work without stops holds until they cancel it themselves.** A turn ending
|
|
90
89
|
with waiting for that same word invents the cancellation. A new fact against the instruction is a
|
|
91
90
|
line about the price in the reply, not waiting; a decision the tree does not hold is asked as a
|
|
@@ -102,11 +101,13 @@ flowchart TD
|
|
|
102
101
|
lawful only where neither the rules nor the tree answer it; the list is written after all the
|
|
103
102
|
executor could close is struck out.
|
|
104
103
|
- **A menu under an assigned order.** A choice offered to the owner before the epic is over asks to
|
|
105
|
-
assign the order anew. No work left in the epic — say so
|
|
104
|
+
assign the order anew. No work left in the epic — say so, show its table and ask for the next
|
|
105
|
+
work.
|
|
106
106
|
- **No order at all is a lawful state, and it is said, not filled.** A queue card is not an order.
|
|
107
107
|
The turn names that there is no order and asks for one.
|
|
108
108
|
- **A standing order is written into the progress in the owner's words.** Read once, «merge every
|
|
109
|
-
PR» is lost at the first refusal;
|
|
109
|
+
PR» is lost at the first refusal; a decision along the way carries it. Not the waiting line:
|
|
110
|
+
the exit guard reads any quote there as a word about a stop.
|
|
110
111
|
- **Done work is shown on the running application built from it.** Host pages show delivery, not
|
|
111
112
|
«what did you do».
|
|
112
113
|
- **A declaration of intent.** "Taking the next task" is not taking it: the phrase lives to the end
|
|
@@ -168,13 +169,13 @@ flowchart TD
|
|
|
168
169
|
- **A next step written into the progress is begun by the same turn.** The guard reads the order
|
|
169
170
|
of actions: after the last edit of the progress it wants work other than the commit and the push
|
|
170
171
|
of it. A full report and a moved stage number do not replace the step.
|
|
171
|
-
- **A plan stage is declared closed only after its check command has passed.** The "
|
|
172
|
+
- **A plan stage is declared closed only after its check command has passed.** The "Verified by"
|
|
172
173
|
(`Чем проверяется`) line carries the command in backticks and what in its output means "matches".
|
|
173
174
|
The guard reads the previous stage number from the branch history and holds a turn where the
|
|
174
175
|
number grew and the command did not run.
|
|
175
176
|
- **The end of an epic is a stop, and it is the one lawful waiting for a word.** The turn shows
|
|
176
|
-
the
|
|
177
|
-
session waits for orders. On the main branch the epic is not read
|
|
177
|
+
the epic's tasks in the table of rule `status-report`, not the handover's, and says that the
|
|
178
|
+
session waits for orders. On the main branch the epic is not read.
|
|
178
179
|
<!-- rt-when: ответ владельцу о состоянии работы -->
|
|
179
180
|
|
|
180
181
|
- **A step of the plan that is not done forbids a stop, and a report about the done is not an
|
|
@@ -182,9 +183,10 @@ flowchart TD
|
|
|
182
183
|
task. The count is read from the progress; lawful exits stay as they were.
|
|
183
184
|
- **The word about a stop the guard reads from the owner, not from the executor.** Otherwise the
|
|
184
185
|
stop is declared by whoever finds it convenient, and the ban holds until the first inconvenience.
|
|
185
|
-
- **Until the epic is closed a turn ends only by
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
- **Until the epic is closed a turn ends only by a question, a refusal, the window or the owner's
|
|
187
|
+
word.** A turn that ended with
|
|
188
|
+
work is a stop all the same, and so is a second pass over the same turn: the exit guard returns
|
|
189
|
+
both with the next step named.
|
|
188
190
|
- **The owner's standing word about a stop is quoted in the progress, in « », in the line «Waiting
|
|
189
191
|
for the owner».** The guard reads their word, not a retelling: a line without a quote releases
|
|
190
192
|
nothing, and a quote holds until the owner cancels it. A word said in this turn releases by itself.
|
|
@@ -236,7 +238,7 @@ flowchart TD
|
|
|
236
238
|
wait runs in the background, next to the next work.
|
|
237
239
|
- **Waiting for one's own measurement is done with one wait, not a notification on every step.** A
|
|
238
240
|
notification is for where every event is acted on; where the outcome matters — one wait.
|
|
239
|
-
- **A guard's refusal
|
|
241
|
+
- **A guard's refusal closes every other road to the refused edit.** None is sought: not a shell
|
|
240
242
|
command, not a neighbouring tool, not an edit of the guard itself. The edit is done once the
|
|
241
243
|
refusal's condition is met, or not at all — then the owner is told the refusal, not a result.
|
|
242
244
|
- **A command refused by a gate is repeated whole, not by its tail.** A gate refuses the call before
|
|
@@ -275,7 +277,7 @@ flowchart TD
|
|
|
275
277
|
the miss, the form — the layout template. The admission is caught by a set of samples: a miss
|
|
276
278
|
admitted in words outside the set the guard lets through.
|
|
277
279
|
- **A session begun from a handover enters the work by the same rule as any other.** The handover
|
|
278
|
-
|
|
280
|
+
was written by a past session, no check reads it, and it describes yesterday: everything in it is
|
|
279
281
|
checked against the tree. The entry order is four steps in the resume pattern; a guard watches it,
|
|
280
282
|
not memory.
|
|
281
283
|
- **The state of unfinished work comes into the context at session start.** The plan and the
|
package/assets/templates/rule.md
CHANGED
|
@@ -44,8 +44,8 @@ current, and the first to notice is whoever followed the graph.
|
|
|
44
44
|
## How the law applies here
|
|
45
45
|
|
|
46
46
|
Every item starts with a bold article, and every article has a line in `implementation.md` next
|
|
47
|
-
to it. A statement that found no place in the code
|
|
48
|
-
|
|
47
|
+
to it. A statement that found no place in the code keeps its article and gets a verdict line
|
|
48
|
+
naming who holds it; a statement nobody holds goes as a question to the law.
|
|
49
49
|
|
|
50
50
|
- **<The article in one sentence.>** <What breaks otherwise — at most two sentences.>
|
|
51
51
|
|
package/lib/cargo-prose.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IPostmortemItem } from './cargo.js';
|
|
2
2
|
/** Одна находка проверки: строка текста, что найдено и чем это заменить. */
|
|
3
|
-
|
|
3
|
+
interface IProseFinding {
|
|
4
4
|
readonly line: number;
|
|
5
5
|
readonly what: string;
|
|
6
6
|
readonly fix: string;
|
|
@@ -38,4 +38,5 @@ export interface IRefusedAnalysis {
|
|
|
38
38
|
* рядом с ним читался бы как другое решение. Дерево без проверки не отбивает ни одного.
|
|
39
39
|
*/
|
|
40
40
|
export declare function refusedAnalysesOf(check: TProseCheck, analyses: readonly IPostmortemItem[]): readonly IRefusedAnalysis[];
|
|
41
|
+
export {};
|
|
41
42
|
//# sourceMappingURL=cargo-prose.d.ts.map
|
package/lib/cargo-prose.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cargo-prose.d.ts","sourceRoot":"","sources":["../../../projects/agent-kit/src/lib/cargo-prose.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAQ7C,4EAA4E;AAC5E,
|
|
1
|
+
{"version":3,"file":"cargo-prose.d.ts","sourceRoot":"","sources":["../../../projects/agent-kit/src/lib/cargo-prose.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAQ7C,4EAA4E;AAC5E,UAAU,aAAa;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACxB;AAED,+DAA+D;AAC/D,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,aAAa,EAAE,CAAC,GAAG,IAAI,CAAC;AAS9E;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,WAAW,CAkBzE;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAgBjE;AAED,4GAA4G;AAC5G,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,QA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oF;QACpF,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAkB,EAAE,IAAY;IACrD,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACjB,OAAO,EAAE,CAAC;IACd,CAAC;IAED,MAAM,KAAK,GAA6B,KAAK,CAAC,IAAI,CAAC,CAAC;IAEpD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,EAAE,CAAC;IACd,CAAC;IAED,MAAM,KAAK,GAAkB,KAAK,CAAC,CAAC,CAAC,CAAC;IAEtC,MAAM,IAAI,GAAW,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,mBAAmB,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAEnF,OAAO,gBAAgB,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,GAAG,GAAG,IAAI,EAAE,CAAC;AAChF,CAAC;AAQD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAkB,EAAE,QAAoC;IACtF,OAAO,QAAQ;SACV,GAAG,CAAC,CAAC,GAAoB,EAAoB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACrG,MAAM,CAAC,CAAC,GAAqB,EAAW,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AACtE,CAAC","sourcesContent":["/**\n * Слог записи, уезжающей в приём: судится он до отправки, а не после неё.\n *\n * Запись груза читает человек, а пишет её заход — словами слоя правил. Проверка слога в дереве\n * есть, и гард зовёт её на правке всякого документа; груз уезжает командой, то есть мимо гарда.\n * Оттого требование обычных слов держалось над текстами дерева и не держалось над тем, что\n * уезжает соседу.\n *\n * Проверка берётся разложенной в дерево, а не из пакета: её признаки — словарь и запреты — лежат\n * в настройке дерева, и копия, запущенная из каталога пакета, считала бы по умолчаниям, а не по\n * тому, о чём дерево договорилось.\n *\n * Зовётся она запуском, а не ввозом в свой модуль: разложенный файл — модуль, а сборка прогона\n * спек переписывает ввоз в требование и роняет его на первой строке. Запуском проверка идёт под\n * тем же узлом, каким её зовёт гард правки, и отвечает находками разбором.\n *\n * Дерево, не разложившее проверку, отправляет как прежде: судить нечем, и молчание об этом\n * читалось бы как проверка, ничего не нашедшая.\n */\nimport { execFileSync } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { join } from 'node:path';\n\nimport { IPostmortemItem } from './cargo.js';\n\n/** Имя разложенного файла проверки. Одно на все деревья: его даёт раскладка, а не дерево. */\nconst PROSE_CHECK: string = 'check-prose-style.mjs';\n\n/** Довод, которым у проверки просят находки данными: текст уходит ей на вход. */\nconst JSON_FLAG: string = '--json';\n\n/** Одна находка проверки: строка текста, что найдено и чем это заменить. */\
|
|
1
|
+
{"version":3,"file":"cargo-prose.js","sourceRoot":"","sources":["../../../projects/agent-kit/src/lib/cargo-prose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,6FAA6F;AAC7F,MAAM,WAAW,GAAW,uBAAuB,CAAC;AAEpD,iFAAiF;AACjF,MAAM,SAAS,GAAW,QAAQ,CAAC;AAYnC,yFAAyF;AACzF,SAAS,QAAQ,CAAC,IAAY,EAAE,IAAY;IACxC,MAAM,IAAI,GAAW,YAAY,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,I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C;AAChF,CAAC;AAQD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAkB,EAAE,QAAoC;IACtF,OAAO,QAAQ;SACV,GAAG,CAAC,CAAC,GAAoB,EAAoB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACrG,MAAM,CAAC,CAAC,GAAqB,EAAW,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AACtE,CAAC","sourcesContent":["/**\n * Слог записи, уезжающей в приём: судится он до отправки, а не после неё.\n *\n * Запись груза читает человек, а пишет её заход — словами слоя правил. Проверка слога в дереве\n * есть, и гард зовёт её на правке всякого документа; груз уезжает командой, то есть мимо гарда.\n * Оттого требование обычных слов держалось над текстами дерева и не держалось над тем, что\n * уезжает соседу.\n *\n * Проверка берётся разложенной в дерево, а не из пакета: её признаки — словарь и запреты — лежат\n * в настройке дерева, и копия, запущенная из каталога пакета, считала бы по умолчаниям, а не по\n * тому, о чём дерево договорилось.\n *\n * Зовётся она запуском, а не ввозом в свой модуль: разложенный файл — модуль, а сборка прогона\n * спек переписывает ввоз в требование и роняет его на первой строке. Запуском проверка идёт под\n * тем же узлом, каким её зовёт гард правки, и отвечает находками разбором.\n *\n * Дерево, не разложившее проверку, отправляет как прежде: судить нечем, и молчание об этом\n * читалось бы как проверка, ничего не нашедшая.\n */\nimport { execFileSync } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { join } from 'node:path';\n\nimport { IPostmortemItem } from './cargo.js';\n\n/** Имя разложенного файла проверки. Одно на все деревья: его даёт раскладка, а не дерево. */\nconst PROSE_CHECK: string = 'check-prose-style.mjs';\n\n/** Довод, которым у проверки просят находки данными: текст уходит ей на вход. */\nconst JSON_FLAG: string = '--json';\n\n/** Одна находка проверки: строка текста, что найдено и чем это заменить. */\ninterface IProseFinding {\n readonly line: number;\n readonly what: string;\n readonly fix: string;\n}\n\n/** Проверка слога либо пусто, когда дерево её не разложило. */\nexport type TProseCheck = ((text: string) => readonly IProseFinding[]) | null;\n\n/** Спросить у разложенной проверки находки одного текста: запуском, текстом на входе. */\nfunction askCheck(path: string, text: string): readonly IProseFinding[] {\n const said: string = execFileSync(process.execPath, [path, JSON_FLAG], { input: text, encoding: 'utf8' });\n\n return JSON.parse(said) as readonly IProseFinding[];\n}\n\n/**\n * Разложенная проверка слога либо пусто.\n *\n * Путь собирается из раскладки дерева: каталог проверок объявлен настройкой, а имя файла —\n * пакетом. Собранный по умолчанию, он промахнулся бы мимо дерева, положившего проверки иначе.\n *\n * Найденный файл зовётся пустым текстом сразу: проверка, которая не отвечает разбором, обязана\n * сказать это здесь. Отдай она себя непроверенной — груз отбивался бы её поломкой на каждой\n * записи, и отказ говорил бы о слоге, а не о ней.\n */\nexport function proseCheckOf(root: string, checksDir: string): TProseCheck {\n const path: string = join(root, checksDir, PROSE_CHECK);\n\n if (!existsSync(path)) {\n return null;\n }\n\n const check: TProseCheck = (text: string): readonly IProseFinding[] => askCheck(path, text);\n\n try {\n check('');\n } catch {\n // Сломанная проверка отпускает груз: отправку она задержать не вправе, а о том, что\n // судить было нечем, скажет строка вывода — та же, что у дерева без проверки вовсе.\n return null;\n }\n\n return check;\n}\n\n/**\n * Чем запись отбита по слогу либо пустая строка, когда находок нет.\n *\n * Называется первая находка, а не все: строка вывода читается заходом, и список из десяти\n * находок в ней теряет ту одну, с которой начинают чинить. Остальные видны, когда позовут саму\n * проверку на файле.\n */\nexport function proseWhy(check: TProseCheck, text: string): string {\n if (check === null) {\n return '';\n }\n\n const found: readonly IProseFinding[] = check(text);\n\n if (found.length === 0) {\n return '';\n }\n\n const first: IProseFinding = found[0];\n\n const rest: string = found.length > 1 ? `, и ещё находок ${found.length - 1}` : '';\n\n return `слог: строка ${first.line} — «${first.what}» → ${first.fix}${rest}`;\n}\n\n/** Отбитый разбор происшествия: имя файла и причина. Отметки на диске у него нет — файл лежит как лежал. */\nexport interface IRefusedAnalysis {\n readonly file: string;\n readonly why: string;\n}\n\n/**\n * Разборы происшествия, отбитые по слогу.\n *\n * Стоит здесь, а не при отправке: у предложения отбой уже собран своим отбором, и второй такой же\n * рядом с ним читался бы как другое решение. Дерево без проверки не отбивает ни одного.\n */\nexport function refusedAnalysesOf(check: TProseCheck, analyses: readonly IPostmortemItem[]): readonly IRefusedAnalysis[] {\n return analyses\n .map((one: IPostmortemItem): IRefusedAnalysis => ({ file: one.file, why: proseWhy(check, one.text) }))\n .filter((one: IRefusedAnalysis): boolean => Boolean(one.why));\n}\n"]}
|
package/lib/companion.d.ts
CHANGED
|
@@ -45,11 +45,6 @@ export interface ICompanion {
|
|
|
45
45
|
}
|
|
46
46
|
/** Путь компаньона: рядом с самим правилом, в каталоге его имени. */
|
|
47
47
|
export declare const pathOf: (asset: IAsset) => string;
|
|
48
|
-
/**
|
|
49
|
-
* Место имени правила в шаблоне. Угловые скобки, а не `{{дырка}}`: дырка без значения отказывает
|
|
50
|
-
* раскладке, а шаблон компаньона пакет кладёт проекту и сам — на нём раскладка и споткнулась бы.
|
|
51
|
-
*/
|
|
52
|
-
export declare const RULE_SLOT: string;
|
|
53
48
|
/**
|
|
54
49
|
* Черновик по шаблону пакета. Имя правила подставляется, чтобы заполняющий не гадал, к чему
|
|
55
50
|
* файл относится, — открывают его обычно из гейта, а не из правила.
|
package/lib/companion.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"companion.d.ts","sourceRoot":"","sources":["../../../projects/agent-kit/src/lib/companion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,MAAoC,CAAC;AAElE,MAAM,MAAM,eAAe;AACvB,wEAAwE;AACtE,SAAS;AACX,8CAA8C;GA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EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,MAgBxE,CAAC;AAEF,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CAclG;AAED,2FAA2F;AAC3F,eAAO,MAAM,UAAU,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,OAA0E,CAAC;AAE/H,+FAA+F;AAC/F,MAAM,WAAW,YAAY;IACzB,yCAAyC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,sCAAsC;IACtC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,wCAAwC;IACxC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,YAAY,CAY/F;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,GAAG,MAAM,GAAG,IAAI,CAWtE"}
|
package/lib/companion.js
CHANGED
|
@@ -11,7 +11,7 @@ export const pathOf = (asset) => asset.target.slice(0, asset.target.lastIndexOf(
|
|
|
11
11
|
* Место имени правила в шаблоне. Угловые скобки, а не `{{дырка}}`: дырка без значения отказывает
|
|
12
12
|
* раскладке, а шаблон компаньона пакет кладёт проекту и сам — на нём раскладка и споткнулась бы.
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
const RULE_SLOT = '<имя-правила>';
|
|
15
15
|
/** Строка таблицы «Где исполняются статьи»: статья дословно и пустое место под путь. */
|
|
16
16
|
const STATEMENT_ROW = '| <статья дословно> | `<путь>:<символ>` <!-- заполняет проект --> |';
|
|
17
17
|
/**
|
package/lib/companion.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"companion.js","sourceRoot":"","sources":["../../../projects/agent-kit/src/lib/companion.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAW,2BAA2B,CAAC;AA2BlE,qEAAqE;AACrE,MAAM,CAAC,MAAM,MAAM,GAA8B,CAAC,KAAa,EAAU,EAAE,CACvE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,cAAc,CAAC;AAE9E;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAW,eAAe,CAAC;AAEjD,wFAAwF;AACxF,MAAM,aAAa,GAAW,qEAAqE,CAAC;AAEpG;;;;GAIG;AACH,SAAS,YAAY,CAAC,IAAY;IAC9B,MAAM,OAAO,GACT,kHAAkH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClI,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,OAAO,EAAE,CAAC;IACd,CAAC;IAED,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAuB,EAAU,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AACpH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,OAAO,GAA8D,CAC9E,QAAgB,EAChB,IAAY,EACZ,OAAe,EAAE,EACX,EAAE;IACR,MAAM,KAAK,GAAW,QAAQ,CAAC,KAAK,CAAC,SA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AAC,CAAC,EAAE,CAAC;IAE7E,OAAO,sBAAsB,UAAU,MAAM,QAAQ,CAAC,MAAM,eAAe,IAAI,EAAE,CAAC;AACtF,CAAC","sourcesContent":["/**\n * Файл-компаньон правила: чем названо в этом дереве то, о чём правило говорит приёмом.\n *\n * Правило пакета переносимо ровно потому, что не знает ни путей, ни имён: оно говорит, какой\n * приём здесь действует и что сломается без него. Но правило без имён дерева — это закон, и\n * агент по нему работать не может: ему нужно знать, как называется здесь то, о чём идёт речь,\n * и где оно лежит.\n *\n * Поэтому имена живут рядом с правилом, в отдельном файле, и пишет его проект. Пакет кладёт\n * черновик один раз и больше к нему не возвращается: сверять его нечем — своего текста у пакета\n * там нет, а перекладывать значило бы стирать написанное проектом.\n *\n * Отсюда и три состояния вместо двух. Черновик, который никто не заполнил, — не то же самое,\n * что заполненный компаньон, и не то же самое, что пропавший: он выглядит рабочим файлом, но\n * правило при нём остаётся указанием без адресата.\n */\nimport { IAsset } from './assets.js';\nimport { COMPANION_FILE } from './config.js';\nimport { requirementOf } from './traits.js';\n\n/**\n * Метка незаполненного места. Стоит в каждой строке черновика, которую должен заменить проект,\n * и снимается вместе с ней: пока метка на месте, компаньон не заполнен.\n */\nexport const COMPANION_MARK: string = '<!-- заполняет проект -->';\n\nexport type TCompanionState =\n /** Файла нет: правило разложено, а имён дерева при нём не оказалось. */\n | 'missing'\n /** Черновик лежит, но остался как положен. */\n | 'draft'\n /** Проект его заполнил. */\n | 'filled';\n\nexport interface ICompanion {\n /** Правило, при котором стоит компаньон. */\n readonly rule: string;\n readonly path: string;\n readonly state: TCompanionState;\n /** Что записать; `null` — писать нечего, файл уже лежит. */\n readonly content: string | null;\n /**\n * Свойство дерева, которого требует правило, — `null`, если не требует ничего.\n *\n * Нужно ровно на отказе: пустой компаньон правила, которому дерево не отвечает, — не долг, а\n * лишний файл, и предлагать его заполнить значит звать на работу, которой нет. Такое правило\n * доезжает до дерева только выбором поимённо: требование само по себе его не кладёт.\n */\n readonly needs: string | null;\n}\n\n/** Путь компаньона: рядом с самим правилом, в каталоге его имени. */\nexport const pathOf: (asset: IAsset) => string = (asset: IAsset): string =>\n asset.target.slice(0, asset.target.lastIndexOf('/') + 1) + COMPANION_FILE;\n\n/**\n * Место имени правила в шаблоне. Угловые скобки, а не `{{дырка}}`: дырка без значения отказывает\n * раскладке, а шаблон компаньона пакет кладёт проекту и сам — на нём раскладка и споткнулась бы.\n */\nexport const RULE_SLOT: string = '<имя-правила>';\n\n/** Строка таблицы «Где исполняются статьи»: статья дословно и пустое место под путь. */\nconst STATEMENT_ROW: string = '| <статья дословно> | `<путь>:<символ>` <!-- заполняет проект --> |';\n\n/**\n * Статьи правила — жирные фразы, которыми начинается каждый пункт раздела о применении закона.\n * Раздел называется по-разному у правила пакета и у развёрнутого в дереве, поэтому берутся оба;\n * у правила пакета имя английское, у правила, написанного деревом до перевода слоя, — русское.\n */\nfunction statementsOf(rule: string): readonly string[] {\n const section: RegExpExecArray | null =\n /^## (?:How the law applies here|Как закон применяется здесь|Что здесь действует)$([\\s\\S]*?)(?=^## |$(?![\\s\\S]))/m.exec(rule);\n if (!section) {\n return [];\n }\n\n return [...section[1].matchAll(/^- \\*\\*(.+?)\\*\\*/gm)].map((found: RegExpMatchArray): string => found[1].trim());\n}\n\n/**\n * Черновик по шаблону пакета. Имя правила подставляется, чтобы заполняющий не гадал, к чему\n * файл относится, — открывают его обычно из гейта, а не из правила.\n *\n * Статьи правила переносятся в таблицу заранее: их текст — ключ связи, и переписанный руками он\n * расходится с правилом молча. Проекту остаётся вторая колонка, а не перепечатывание первой:\n * двадцать пять компаньонов на первой установке — это работа, и половина её механическая.\n */\nexport const draftOf: (template: string, rule: string, text?: string) => string = (\n template: string,\n rule: string,\n text: string = ''\n): string => {\n const draft: string = template.split(RULE_SLOT).join(rule);\n const statements: readonly string[] = statementsOf(text);\n if (!statements.length) {\n return draft;\n }\n\n const rows: string = statements\n .map((statement: string): string => `| ${statement} | \\`<путь>:<символ>\\` ${COMPANION_MARK} |`)\n .join('\\n');\n\n return draft.includes(STATEMENT_ROW) ? draft.replace(STATEMENT_ROW, rows) : draft;\n};\n\nexport function planCompanion(asset: IAsset, existing: string | null, template: string): ICompanion {\n const path: string = pathOf(asset);\n const needs: string | null = requirementOf(asset.id);\n if (existing === null) {\n return { path, needs, rule: asset.name, state: 'missing', content: draftOf(template, asset.name, asset.text) };\n }\n\n return {\n path,\n needs,\n rule: asset.name,\n state: existing.includes(COMPANION_MARK) ? 'draft' : 'filled',\n content: null,\n };\n}\n\n/** Что `sync --check` считает недоделанным: правило при пустом компаньоне не действует. */\nexport const isUnfilled: (companion: ICompanion) => boolean = (companion: ICompanion): boolean => companion.state !== 'filled';\n\n/** Долг, добавленный обновлением: статьи правила, у которых в компаньоне дерева нет адреса. */\nexport interface IUnaddressed {\n /** Имя правила, чьи статьи считались. */\n readonly rule: string;\n /** Сколько статей у правила всего. */\n readonly total: number;\n /** Статьи, которых в компаньоне нет. */\n readonly missing: readonly string[];\n /** Компаньона рядом с правилом нет вовсе: долг здесь — все статьи разом. */\n readonly absent: boolean;\n}\n\n/**\n * Счёт статей без адреса. Отделён от записи файлов намеренно: раскладка кладёт их на диск, а\n * решение о том, что назвать добавленным долгом, к записи не привязано и проверяется без\n * файловой системы.\n *\n * Статья ищется в компаньоне дословно — её текст и есть ключ связи, тот же, которым сверяются\n * привязки. Переписанная руками, она расходится с правилом молча, и здесь это видно сразу:\n * такая статья считается ненайденной.\n */\nexport function unaddressedOf(rule: string, text: string, existing: string | null): IUnaddressed {\n const statements: readonly string[] = statementsOf(text);\n if (existing === null) {\n return { rule, total: statements.length, missing: statements, absent: true };\n }\n\n return {\n rule,\n total: statements.length,\n missing: statements.filter((statement: string): boolean => !existing.includes(statement)),\n absent: false,\n };\n}\n\n/**\n * Строка о добавленном долге для вывода раскладки. Молчит, когда долга нет: строка «статей без\n * адреса: 0» приходила бы при каждой раскладке и перестала бы читаться.\n *\n * Долг называется числом, а не списком: двадцать девять строк в выводе не читают, а сами статьи\n * стоят в компаньоне, куда за ними и идут.\n */\nexport function debtLine(found: readonly IUnaddressed[]): string | null {\n const withDebt: readonly IUnaddressed[] = found.filter((entry: IUnaddressed): boolean => entry.missing.length > 0);\n if (!withDebt.length) {\n return null;\n }\n\n const statements: number = withDebt.reduce((sum: number, entry: IUnaddressed): number => sum + entry.missing.length, 0);\n const absent: number = withDebt.filter((entry: IUnaddressed): boolean => entry.absent).length;\n const tail: string = absent ? `, из них ${absent} без компаньона вовсе` : '';\n\n return `статей без адреса: ${statements} в ${withDebt.length} компаньонах${tail}`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"companion.js","sourceRoot":"","sources":["../../../projects/agent-kit/src/lib/companion.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAW,2BAA2B,CAAC;AA2BlE,qEAAqE;AACrE,MAAM,CAAC,MAAM,MAAM,GAA8B,CAAC,KAAa,EAAU,EAAE,CACvE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,cAAc,CAAC;AAE9E;;;GAGG;AACH,MAAM,SAAS,GAAW,eAAe,CAAC;AAE1C,wFAAwF;AACxF,MAAM,aAAa,GAAW,qEAAqE,CAAC;AAEpG;;;;GAIG;AACH,SAAS,YAAY,CAAC,IAAY;IAC9B,MAAM,OAAO,GACT,kHAAkH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClI,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,OAAO,EAAE,CAAC;IACd,CAAC;IAED,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC,CAA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KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACxH,MAAM,MAAM,GAAW,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAmB,EAAW,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;IAC9F,MAAM,IAAI,GAAW,MAAM,CAAC,CAAC,CAAC,YAAY,MAAM,uBAAuB,CAAC,CAAC,CAAC,EAAE,CAAC;IAE7E,OAAO,sBAAsB,UAAU,MAAM,QAAQ,CAAC,MAAM,eAAe,IAAI,EAAE,CAAC;AACtF,CAAC","sourcesContent":["/**\n * Файл-компаньон правила: чем названо в этом дереве то, о чём правило говорит приёмом.\n *\n * Правило пакета переносимо ровно потому, что не знает ни путей, ни имён: оно говорит, какой\n * приём здесь действует и что сломается без него. Но правило без имён дерева — это закон, и\n * агент по нему работать не может: ему нужно знать, как называется здесь то, о чём идёт речь,\n * и где оно лежит.\n *\n * Поэтому имена живут рядом с правилом, в отдельном файле, и пишет его проект. Пакет кладёт\n * черновик один раз и больше к нему не возвращается: сверять его нечем — своего текста у пакета\n * там нет, а перекладывать значило бы стирать написанное проектом.\n *\n * Отсюда и три состояния вместо двух. Черновик, который никто не заполнил, — не то же самое,\n * что заполненный компаньон, и не то же самое, что пропавший: он выглядит рабочим файлом, но\n * правило при нём остаётся указанием без адресата.\n */\nimport { IAsset } from './assets.js';\nimport { COMPANION_FILE } from './config.js';\nimport { requirementOf } from './traits.js';\n\n/**\n * Метка незаполненного места. Стоит в каждой строке черновика, которую должен заменить проект,\n * и снимается вместе с ней: пока метка на месте, компаньон не заполнен.\n */\nexport const COMPANION_MARK: string = '<!-- заполняет проект -->';\n\nexport type TCompanionState =\n /** Файла нет: правило разложено, а имён дерева при нём не оказалось. */\n | 'missing'\n /** Черновик лежит, но остался как положен. */\n | 'draft'\n /** Проект его заполнил. */\n | 'filled';\n\nexport interface ICompanion {\n /** Правило, при котором стоит компаньон. */\n readonly rule: string;\n readonly path: string;\n readonly state: TCompanionState;\n /** Что записать; `null` — писать нечего, файл уже лежит. */\n readonly content: string | null;\n /**\n * Свойство дерева, которого требует правило, — `null`, если не требует ничего.\n *\n * Нужно ровно на отказе: пустой компаньон правила, которому дерево не отвечает, — не долг, а\n * лишний файл, и предлагать его заполнить значит звать на работу, которой нет. Такое правило\n * доезжает до дерева только выбором поимённо: требование само по себе его не кладёт.\n */\n readonly needs: string | null;\n}\n\n/** Путь компаньона: рядом с самим правилом, в каталоге его имени. */\nexport const pathOf: (asset: IAsset) => string = (asset: IAsset): string =>\n asset.target.slice(0, asset.target.lastIndexOf('/') + 1) + COMPANION_FILE;\n\n/**\n * Место имени правила в шаблоне. Угловые скобки, а не `{{дырка}}`: дырка без значения отказывает\n * раскладке, а шаблон компаньона пакет кладёт проекту и сам — на нём раскладка и споткнулась бы.\n */\nconst RULE_SLOT: string = '<имя-правила>';\n\n/** Строка таблицы «Где исполняются статьи»: статья дословно и пустое место под путь. */\nconst STATEMENT_ROW: string = '| <статья дословно> | `<путь>:<символ>` <!-- заполняет проект --> |';\n\n/**\n * Статьи правила — жирные фразы, которыми начинается каждый пункт раздела о применении закона.\n * Раздел называется по-разному у правила пакета и у развёрнутого в дереве, поэтому берутся оба;\n * у правила пакета имя английское, у правила, написанного деревом до перевода слоя, — русское.\n */\nfunction statementsOf(rule: string): readonly string[] {\n const section: RegExpExecArray | null =\n /^## (?:How the law applies here|Как закон применяется здесь|Что здесь действует)$([\\s\\S]*?)(?=^## |$(?![\\s\\S]))/m.exec(rule);\n if (!section) {\n return [];\n }\n\n return [...section[1].matchAll(/^- \\*\\*(.+?)\\*\\*/gm)].map((found: RegExpMatchArray): string => found[1].trim());\n}\n\n/**\n * Черновик по шаблону пакета. Имя правила подставляется, чтобы заполняющий не гадал, к чему\n * файл относится, — открывают его обычно из гейта, а не из правила.\n *\n * Статьи правила переносятся в таблицу заранее: их текст — ключ связи, и переписанный руками он\n * расходится с правилом молча. Проекту остаётся вторая колонка, а не перепечатывание первой:\n * двадцать пять компаньонов на первой установке — это работа, и половина её механическая.\n */\nexport const draftOf: (template: string, rule: string, text?: string) => string = (\n template: string,\n rule: string,\n text: string = ''\n): string => {\n const draft: string = template.split(RULE_SLOT).join(rule);\n const statements: readonly string[] = statementsOf(text);\n if (!statements.length) {\n return draft;\n }\n\n const rows: string = statements\n .map((statement: string): string => `| ${statement} | \\`<путь>:<символ>\\` ${COMPANION_MARK} |`)\n .join('\\n');\n\n return draft.includes(STATEMENT_ROW) ? draft.replace(STATEMENT_ROW, rows) : draft;\n};\n\nexport function planCompanion(asset: IAsset, existing: string | null, template: string): ICompanion {\n const path: string = pathOf(asset);\n const needs: string | null = requirementOf(asset.id);\n if (existing === null) {\n return { path, needs, rule: asset.name, state: 'missing', content: draftOf(template, asset.name, asset.text) };\n }\n\n return {\n path,\n needs,\n rule: asset.name,\n state: existing.includes(COMPANION_MARK) ? 'draft' : 'filled',\n content: null,\n };\n}\n\n/** Что `sync --check` считает недоделанным: правило при пустом компаньоне не действует. */\nexport const isUnfilled: (companion: ICompanion) => boolean = (companion: ICompanion): boolean => companion.state !== 'filled';\n\n/** Долг, добавленный обновлением: статьи правила, у которых в компаньоне дерева нет адреса. */\nexport interface IUnaddressed {\n /** Имя правила, чьи статьи считались. */\n readonly rule: string;\n /** Сколько статей у правила всего. */\n readonly total: number;\n /** Статьи, которых в компаньоне нет. */\n readonly missing: readonly string[];\n /** Компаньона рядом с правилом нет вовсе: долг здесь — все статьи разом. */\n readonly absent: boolean;\n}\n\n/**\n * Счёт статей без адреса. Отделён от записи файлов намеренно: раскладка кладёт их на диск, а\n * решение о том, что назвать добавленным долгом, к записи не привязано и проверяется без\n * файловой системы.\n *\n * Статья ищется в компаньоне дословно — её текст и есть ключ связи, тот же, которым сверяются\n * привязки. Переписанная руками, она расходится с правилом молча, и здесь это видно сразу:\n * такая статья считается ненайденной.\n */\nexport function unaddressedOf(rule: string, text: string, existing: string | null): IUnaddressed {\n const statements: readonly string[] = statementsOf(text);\n if (existing === null) {\n return { rule, total: statements.length, missing: statements, absent: true };\n }\n\n return {\n rule,\n total: statements.length,\n missing: statements.filter((statement: string): boolean => !existing.includes(statement)),\n absent: false,\n };\n}\n\n/**\n * Строка о добавленном долге для вывода раскладки. Молчит, когда долга нет: строка «статей без\n * адреса: 0» приходила бы при каждой раскладке и перестала бы читаться.\n *\n * Долг называется числом, а не списком: двадцать девять строк в выводе не читают, а сами статьи\n * стоят в компаньоне, куда за ними и идут.\n */\nexport function debtLine(found: readonly IUnaddressed[]): string | null {\n const withDebt: readonly IUnaddressed[] = found.filter((entry: IUnaddressed): boolean => entry.missing.length > 0);\n if (!withDebt.length) {\n return null;\n }\n\n const statements: number = withDebt.reduce((sum: number, entry: IUnaddressed): number => sum + entry.missing.length, 0);\n const absent: number = withDebt.filter((entry: IUnaddressed): boolean => entry.absent).length;\n const tail: string = absent ? `, из них ${absent} без компаньона вовсе` : '';\n\n return `статей без адреса: ${statements} в ${withDebt.length} компаньонах${tail}`;\n}\n"]}
|
package/lib/cost.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/** Чем считано. Стоит рядом с числами: снятое иначе с этим несравнимо. */
|
|
2
|
-
export declare const COUNTED_BY: string;
|
|
3
1
|
export interface IWeighed {
|
|
4
2
|
/** Что взвешено — строкой для человека. */
|
|
5
3
|
readonly what: string;
|
|
@@ -24,12 +22,6 @@ export declare class CostUnavailableError extends Error {
|
|
|
24
22
|
}
|
|
25
23
|
/** Что заход получает до первой правки: описания всех правил и вывод хуков старта. */
|
|
26
24
|
export declare function entryTexts(root: string): readonly string[];
|
|
27
|
-
/** Правило вместе со спутником — столько стоит одна его загрузка. */
|
|
28
|
-
export declare function ruleTexts(root: string, rule: string): readonly string[];
|
|
29
|
-
/** Весь слой разом: законы, правила и паттерны. Ни один заход столько не грузит. */
|
|
30
|
-
export declare function layerTexts(root: string): readonly string[];
|
|
31
|
-
/** Правило с самым тяжёлым файлом — то, что берётся, когда имя не названо. */
|
|
32
|
-
export declare function heaviestRule(root: string): string;
|
|
33
25
|
/** Вес набора текстов: символы и байты. Байты считаются кодировкой, в которой файлы и лежат. */
|
|
34
26
|
export declare function weigh(what: string, texts: readonly string[]): IWeighed;
|
|
35
27
|
/**
|