@rt-tools/agent-kit 0.37.1 → 0.38.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.
Files changed (357) hide show
  1. package/README.md +5 -5
  2. package/assets/checks/action-of.mjs +154 -0
  3. package/assets/checks/board-runs.github.mjs +40 -5
  4. package/assets/checks/check-board.github.mjs +38 -7
  5. package/assets/checks/check-state-next.mjs +22 -10
  6. package/assets/checks/check-turn-map.mjs +26 -6
  7. package/assets/checks/check-work-steps.mjs +4 -173
  8. package/assets/checks/decide.mjs +285 -0
  9. package/assets/checks/decision-table.json +21365 -0
  10. package/assets/checks/decision-table.mjs +495 -0
  11. package/assets/checks/epic-window.mjs +98 -0
  12. package/assets/checks/flow-condition.mjs +64 -0
  13. package/assets/checks/flow-data.mjs +136 -0
  14. package/assets/checks/flow-forecast.mjs +330 -0
  15. package/assets/checks/flow-guard-run.mjs +90 -0
  16. package/assets/checks/flow-guard.mjs +294 -0
  17. package/assets/checks/flow-model.mjs +271 -0
  18. package/assets/checks/flow-override.mjs +130 -0
  19. package/assets/checks/flow-plan.mjs +206 -0
  20. package/assets/checks/flow-scaffold.mjs +224 -0
  21. package/assets/checks/flow-step.mjs +365 -0
  22. package/assets/checks/flow-sync.mjs +296 -0
  23. package/assets/checks/flow-syntax.mjs +292 -0
  24. package/assets/checks/flow-verdict.mjs +112 -0
  25. package/assets/checks/merge-read.mjs +239 -0
  26. package/assets/checks/owner-nudges.mjs +389 -0
  27. package/assets/checks/push-inputs.mjs +59 -16
  28. package/assets/checks/record-count.mjs +410 -0
  29. package/assets/checks/record-recount.mjs +187 -0
  30. package/assets/checks/record-turn.mjs +155 -0
  31. package/assets/checks/task-flow-script.mjs +292 -0
  32. package/assets/checks/tree-assignment.mjs +26 -7
  33. package/assets/checks/work-result.mjs +281 -0
  34. package/assets/checks/work-steps-lib.mjs +205 -0
  35. package/assets/commands/night.md +6 -6
  36. package/assets/defaults/gate-map.sh +39 -12
  37. package/assets/defaults/merges.sh +48 -0
  38. package/assets/defaults/project.sh +6 -5
  39. package/assets/defaults/turn-map.md +21 -22
  40. package/assets/docs/GLOSSARY.md +5 -1
  41. package/assets/hooks/ask-judge.md +65 -0
  42. package/assets/hooks/browser-guard-device-id.sh +11 -9
  43. package/assets/hooks/browser-guard-no-asking.sh +12 -6
  44. package/assets/hooks/browser-guard-no-listing.sh +13 -7
  45. package/assets/hooks/browser-guard-no-other-drivers.sh +25 -17
  46. package/assets/hooks/browser-guard-require-select.sh +15 -15
  47. package/assets/hooks/commit-msg.sh +13 -3
  48. package/assets/hooks/conscience-guard.sh +9 -25
  49. package/assets/hooks/decide.sh +141 -0
  50. package/assets/hooks/deny-tail.sh +16 -11
  51. package/assets/hooks/dev-server-guard.sh +27 -20
  52. package/assets/hooks/dispatch.sh +47 -4
  53. package/assets/hooks/docs-guard.sh +31 -200
  54. package/assets/hooks/end-conversation-guard.sh +12 -21
  55. package/assets/hooks/epic-stop-guard.sh +54 -152
  56. package/assets/hooks/exam-guard.sh +32 -65
  57. package/assets/hooks/facts-docs.sh +221 -0
  58. package/assets/hooks/facts-flow.sh +173 -0
  59. package/assets/hooks/facts.sh +308 -0
  60. package/assets/hooks/flow-step-guard.sh +93 -0
  61. package/assets/hooks/git-guard-delivery-body.sh +4 -4
  62. package/assets/hooks/git-guard-delivery-conflict.sh +16 -10
  63. package/assets/hooks/git-guard-delivery-draft.sh +3 -3
  64. package/assets/hooks/git-guard-delivery-epic.sh +18 -9
  65. package/assets/hooks/git-guard-delivery-folder.sh +32 -7
  66. package/assets/hooks/git-guard-delivery-merge.sh +2 -2
  67. package/assets/hooks/git-guard-delivery-merged.sh +12 -1
  68. package/assets/hooks/git-guard-delivery-pipeline.sh +1 -1
  69. package/assets/hooks/git-guard-delivery-rerun.sh +32 -0
  70. package/assets/hooks/git-guard-delivery-signature.sh +82 -45
  71. package/assets/hooks/git-guard-delivery-task.sh +47 -0
  72. package/assets/hooks/git-guard-delivery.sh +112 -101
  73. package/assets/hooks/git-guard-discard.sh +8 -18
  74. package/assets/hooks/git-guard-main.sh +13 -19
  75. package/assets/hooks/git-guard-no-verify.sh +56 -16
  76. package/assets/hooks/git-guard-push-ahead.sh +15 -4
  77. package/assets/hooks/git-guard-push-marks.sh +53 -1
  78. package/assets/hooks/git-guard-push-tests.sh +30 -51
  79. package/assets/hooks/git-guard-tree-assignment.sh +7 -4
  80. package/assets/hooks/guard-note.sh +8 -6
  81. package/assets/hooks/handoff-entry-guard.sh +19 -38
  82. package/assets/hooks/handoff-write.sh +3 -1
  83. package/assets/hooks/hook-input.sh +0 -41
  84. package/assets/hooks/metric-marks.sh +19 -7
  85. package/assets/hooks/observe.sh +1 -1
  86. package/assets/hooks/override-write-guard.sh +27 -9
  87. package/assets/hooks/pre-push.sh +14 -10
  88. package/assets/hooks/prose-style-guard.sh +6 -19
  89. package/assets/hooks/pull-merges.sh +76 -0
  90. package/assets/hooks/push-set.sh +11 -4
  91. package/assets/hooks/qa-dataid-guard.sh +7 -17
  92. package/assets/hooks/record-turn.sh +52 -0
  93. package/assets/hooks/rerun-guard.sh +11 -16
  94. package/assets/hooks/reuse-first-guard.sh +7 -21
  95. package/assets/hooks/role-calls.sh +25 -3
  96. package/assets/hooks/rule-source-guard.sh +54 -21
  97. package/assets/hooks/skill-gate-rearm.sh +18 -5
  98. package/assets/hooks/skill-gate.sh +156 -20
  99. package/assets/hooks/skill-loaded.sh +18 -3
  100. package/assets/hooks/sql-guard-target.sh +2 -2
  101. package/assets/hooks/sql-guard-write.sh +12 -12
  102. package/assets/hooks/sql-guard.sh +58 -16
  103. package/assets/hooks/task-context-load.sh +3 -1
  104. package/assets/hooks/task-flow-context.sh +5 -18
  105. package/assets/hooks/task-flow-draft-guard.sh +25 -74
  106. package/assets/hooks/task-flow-guard.sh +28 -130
  107. package/assets/hooks/tree-assignment-guard.sh +25 -14
  108. package/assets/hooks/turn-entry-load.sh +3 -1
  109. package/assets/hooks/turn-exit-guard.sh +92 -452
  110. package/assets/hooks/turn-exit-role.sh +3 -1
  111. package/assets/hooks/turn-judge.md +103 -0
  112. package/assets/hooks/window-fill-guard.sh +22 -41
  113. package/assets/patterns/git-workflow-commit.azure.md +9 -155
  114. package/assets/patterns/git-workflow-commit.github.md +11 -269
  115. package/assets/patterns/git-workflow-commit.gitlab.md +9 -161
  116. package/assets/patterns/git-workflow-docker.md +8 -231
  117. package/assets/patterns/git-workflow-freshness.md +8 -56
  118. package/assets/patterns/git-workflow-merge.md +6 -176
  119. package/assets/patterns/git-workflow-migration.md +5 -75
  120. package/assets/patterns/git-workflow-pr-body.github.md +6 -159
  121. package/assets/patterns/git-workflow-pr-ready.md +9 -70
  122. package/assets/patterns/git-workflow-pr.azure.md +13 -285
  123. package/assets/patterns/git-workflow-pr.github.md +13 -251
  124. package/assets/patterns/git-workflow-pr.gitlab.md +13 -286
  125. package/assets/patterns/git-workflow-restart.md +5 -42
  126. package/assets/patterns/git-workflow-secrets.md +10 -76
  127. package/assets/patterns/git-workflow-stack.md +7 -207
  128. package/assets/patterns/status-report-table.github.md +1 -1
  129. package/assets/patterns/task-flow-archive.md +12 -233
  130. package/assets/patterns/task-flow-close.md +16 -292
  131. package/assets/patterns/task-flow-cycle.md +13 -39
  132. package/assets/patterns/task-flow-graph.needs-graph.md +8 -62
  133. package/assets/patterns/task-flow-handoff.md +13 -161
  134. package/assets/patterns/task-flow-resume.md +18 -218
  135. package/assets/patterns/task-flow-start.md +9 -247
  136. package/assets/patterns/turn-entry-map.md +2 -2
  137. package/assets/pitfalls/agent-kit-extend.md +200 -0
  138. package/assets/pitfalls/agent-kit.2.md +323 -0
  139. package/assets/pitfalls/angular-patterns.md +98 -0
  140. package/assets/pitfalls/browser-verification.md +265 -0
  141. package/assets/pitfalls/component-structure.md +98 -0
  142. package/assets/pitfalls/dependencies.md +92 -0
  143. package/assets/pitfalls/deploy-flow.azure.md +171 -0
  144. package/assets/pitfalls/deploy-flow.github.md +211 -0
  145. package/assets/pitfalls/deploy-flow.gitlab.md +173 -0
  146. package/assets/pitfalls/doc-style.2.md +286 -0
  147. package/assets/pitfalls/entity-conventions.needs-admin.md +96 -0
  148. package/assets/pitfalls/entity-models.md +89 -0
  149. package/assets/pitfalls/git-workflow-commit.azure.md +190 -0
  150. package/assets/pitfalls/git-workflow-commit.github.md +307 -0
  151. package/assets/pitfalls/git-workflow-commit.gitlab.md +196 -0
  152. package/assets/pitfalls/git-workflow-docker.md +275 -0
  153. package/assets/pitfalls/git-workflow-freshness.md +88 -0
  154. package/assets/pitfalls/git-workflow-hosting.azure.md +31 -0
  155. package/assets/pitfalls/git-workflow-hosting.github.md +32 -0
  156. package/assets/pitfalls/git-workflow-hosting.gitlab.md +31 -0
  157. package/assets/pitfalls/git-workflow-merge.md +220 -0
  158. package/assets/pitfalls/git-workflow-migration.md +103 -0
  159. package/assets/pitfalls/git-workflow-pr-body.github.md +185 -0
  160. package/assets/pitfalls/git-workflow-pr-ready.md +104 -0
  161. package/assets/pitfalls/git-workflow-pr.2.azure.md +172 -0
  162. package/assets/pitfalls/git-workflow-pr.2.github.md +184 -0
  163. package/assets/pitfalls/git-workflow-pr.2.gitlab.md +180 -0
  164. package/assets/pitfalls/git-workflow-pr.azure.md +159 -0
  165. package/assets/pitfalls/git-workflow-pr.github.md +107 -0
  166. package/assets/pitfalls/git-workflow-pr.gitlab.md +151 -0
  167. package/assets/pitfalls/git-workflow-push.azure.md +30 -0
  168. package/assets/pitfalls/git-workflow-push.github.md +30 -0
  169. package/assets/pitfalls/git-workflow-push.gitlab.md +30 -0
  170. package/assets/pitfalls/git-workflow-queue.azure.md +30 -0
  171. package/assets/pitfalls/git-workflow-queue.github.md +30 -0
  172. package/assets/pitfalls/git-workflow-queue.gitlab.md +30 -0
  173. package/assets/pitfalls/git-workflow-restart.md +72 -0
  174. package/assets/pitfalls/git-workflow-secrets.md +114 -0
  175. package/assets/pitfalls/git-workflow-stack.md +254 -0
  176. package/assets/pitfalls/git-workflow.2.azure.md +291 -0
  177. package/assets/pitfalls/git-workflow.2.github.md +294 -0
  178. package/assets/pitfalls/git-workflow.2.gitlab.md +278 -0
  179. package/assets/pitfalls/lib-layers.md +114 -0
  180. package/assets/pitfalls/lists.md +117 -0
  181. package/assets/pitfalls/navigation.md +94 -0
  182. package/assets/pitfalls/reuse-first.md +201 -0
  183. package/assets/pitfalls/spec-driven.2.md +318 -0
  184. package/assets/pitfalls/styling-bem.2.md +125 -0
  185. package/assets/pitfalls/task-flow-archive.md +264 -0
  186. package/assets/pitfalls/task-flow-close.2.md +165 -0
  187. package/assets/pitfalls/task-flow-close.md +167 -0
  188. package/assets/pitfalls/task-flow-cycle.md +73 -0
  189. package/assets/pitfalls/task-flow-graph.needs-graph.md +98 -0
  190. package/assets/pitfalls/task-flow-handoff.md +200 -0
  191. package/assets/pitfalls/task-flow-handover.md +30 -0
  192. package/assets/pitfalls/task-flow-owner.md +29 -0
  193. package/assets/pitfalls/task-flow-plan.md +29 -0
  194. package/assets/pitfalls/task-flow-resume.md +257 -0
  195. package/assets/pitfalls/task-flow-start.md +287 -0
  196. package/assets/pitfalls/task-flow.2.md +303 -0
  197. package/assets/pitfalls/task-flow.md +4 -4
  198. package/assets/pitfalls/testing.2.md +279 -0
  199. package/assets/pitfalls/turn-conduct.md +16 -17
  200. package/assets/pitfalls/typescript-conventions.md +161 -0
  201. package/assets/pitfalls/write-a-skill.md +128 -0
  202. package/assets/rules/angular-patterns.md +21 -86
  203. package/assets/rules/autonomous-work.md +2 -2
  204. package/assets/rules/browser-verification.md +28 -256
  205. package/assets/rules/component-structure.md +25 -87
  206. package/assets/rules/dependencies.md +20 -78
  207. package/assets/rules/deploy-flow.azure.md +26 -156
  208. package/assets/rules/deploy-flow.github.md +34 -200
  209. package/assets/rules/deploy-flow.gitlab.md +27 -159
  210. package/assets/rules/doc-style.md +32 -286
  211. package/assets/rules/entity-conventions.needs-admin.md +26 -82
  212. package/assets/rules/entity-models.md +14 -63
  213. package/assets/rules/git-workflow-hosting.azure.md +26 -0
  214. package/assets/rules/git-workflow-hosting.github.md +38 -0
  215. package/assets/rules/git-workflow-hosting.gitlab.md +27 -0
  216. package/assets/rules/git-workflow-push.azure.md +28 -0
  217. package/assets/rules/git-workflow-push.github.md +28 -0
  218. package/assets/rules/git-workflow-push.gitlab.md +28 -0
  219. package/assets/rules/git-workflow-queue.azure.md +23 -0
  220. package/assets/rules/git-workflow-queue.github.md +30 -0
  221. package/assets/rules/git-workflow-queue.gitlab.md +23 -0
  222. package/assets/rules/git-workflow.azure.md +21 -282
  223. package/assets/rules/git-workflow.github.md +24 -284
  224. package/assets/rules/git-workflow.gitlab.md +21 -269
  225. package/assets/rules/lib-layers.md +30 -103
  226. package/assets/rules/lists.md +21 -105
  227. package/assets/rules/navigation.md +10 -69
  228. package/assets/rules/reuse-first.md +20 -195
  229. package/assets/rules/spec-driven.md +35 -308
  230. package/assets/rules/styling-bem.md +20 -117
  231. package/assets/rules/task-flow-handover.md +24 -0
  232. package/assets/rules/task-flow-owner.md +34 -0
  233. package/assets/rules/task-flow-plan.md +38 -0
  234. package/assets/rules/task-flow.md +22 -300
  235. package/assets/rules/testing.md +32 -273
  236. package/assets/rules/turn-conduct.md +100 -104
  237. package/assets/rules/turn-entry.md +2 -2
  238. package/assets/rules/typescript-conventions.md +41 -147
  239. package/assets/samples/tasks/_template/plan.md +30 -6
  240. package/assets/samples/tasks/_template/progress.md +0 -1
  241. package/assets/skills/agent-kit-extend.md +25 -168
  242. package/assets/skills/agent-kit.md +27 -299
  243. package/assets/skills/write-a-skill.md +20 -106
  244. package/assets/task-flow/flow.js +188 -0
  245. package/assets/task-flow/flow.md +102 -0
  246. package/assets/task-flow/measure/agreement.mjs +24 -0
  247. package/assets/task-flow/measure/copy.mjs +22 -0
  248. package/assets/task-flow/measure/epic-of.mjs +50 -0
  249. package/assets/task-flow/measure/epic-text.mjs +35 -0
  250. package/assets/task-flow/measure/epic.mjs +114 -0
  251. package/assets/task-flow/measure/folder.mjs +16 -0
  252. package/assets/task-flow/measure/footprint.mjs +28 -0
  253. package/assets/task-flow/measure/grill.mjs +21 -0
  254. package/assets/task-flow/measure/host.mjs +8 -0
  255. package/assets/task-flow/measure/owner.mjs +20 -0
  256. package/assets/task-flow/measure/plan.mjs +27 -0
  257. package/assets/task-flow/measure/pr.mjs +20 -0
  258. package/assets/task-flow/measure/progress.mjs +50 -0
  259. package/assets/task-flow/measure/session.mjs +175 -0
  260. package/assets/task-flow/measure/task.mjs +23 -0
  261. package/assets/task-flow/measure/text.mjs +77 -0
  262. package/assets/task-flow/source/git.mjs +86 -0
  263. package/assets/task-flow/source/host.mjs +172 -0
  264. package/assets/task-flow/source/marks.mjs +56 -0
  265. package/assets/task-flow/source/owner.mjs +74 -0
  266. package/assets/task-flow/source/records.mjs +116 -0
  267. package/assets/task-flow/source/session.mjs +232 -0
  268. package/assets/task-flow/source/steps.mjs +28 -0
  269. package/assets/task-flow/source/tree.mjs +42 -0
  270. package/bin/agent-kit.d.ts.map +1 -1
  271. package/bin/agent-kit.js +30 -0
  272. package/bin/agent-kit.js.map +1 -1
  273. package/lib/agent-checks.d.ts +55 -0
  274. package/lib/agent-checks.d.ts.map +1 -0
  275. package/lib/agent-checks.js +209 -0
  276. package/lib/agent-checks.js.map +1 -0
  277. package/lib/assets.d.ts.map +1 -1
  278. package/lib/assets.js +7 -2
  279. package/lib/assets.js.map +1 -1
  280. package/lib/cargo.d.ts +29 -0
  281. package/lib/cargo.d.ts.map +1 -1
  282. package/lib/cargo.js +27 -1
  283. package/lib/cargo.js.map +1 -1
  284. package/lib/cascade.d.ts.map +1 -1
  285. package/lib/cascade.js +3 -1
  286. package/lib/cascade.js.map +1 -1
  287. package/lib/commands.d.ts.map +1 -1
  288. package/lib/commands.js +78 -2
  289. package/lib/commands.js.map +1 -1
  290. package/lib/config.d.ts +18 -0
  291. package/lib/config.d.ts.map +1 -1
  292. package/lib/config.js +18 -1
  293. package/lib/config.js.map +1 -1
  294. package/lib/epic-window-send.d.ts +74 -0
  295. package/lib/epic-window-send.d.ts.map +1 -0
  296. package/lib/epic-window-send.js +166 -0
  297. package/lib/epic-window-send.js.map +1 -0
  298. package/lib/hooks-map.d.ts +4 -0
  299. package/lib/hooks-map.d.ts.map +1 -1
  300. package/lib/hooks-map.js +2 -2
  301. package/lib/hooks-map.js.map +1 -1
  302. package/lib/integrity.d.ts +3 -0
  303. package/lib/integrity.d.ts.map +1 -1
  304. package/lib/integrity.js +7 -0
  305. package/lib/integrity.js.map +1 -1
  306. package/lib/metric-lines.d.ts +2 -1
  307. package/lib/metric-lines.d.ts.map +1 -1
  308. package/lib/metric-lines.js +49 -1
  309. package/lib/metric-lines.js.map +1 -1
  310. package/lib/metric-send-mark.d.ts +6 -3
  311. package/lib/metric-send-mark.d.ts.map +1 -1
  312. package/lib/metric-send-mark.js +15 -5
  313. package/lib/metric-send-mark.js.map +1 -1
  314. package/lib/metric-send.d.ts +6 -2
  315. package/lib/metric-send.d.ts.map +1 -1
  316. package/lib/metric-send.js +47 -13
  317. package/lib/metric-send.js.map +1 -1
  318. package/lib/metrics.d.ts +17 -0
  319. package/lib/metrics.d.ts.map +1 -1
  320. package/lib/metrics.js +26 -15
  321. package/lib/metrics.js.map +1 -1
  322. package/lib/observations.js +3 -3
  323. package/lib/observations.js.map +1 -1
  324. package/lib/outcomes.d.ts +5 -2
  325. package/lib/outcomes.d.ts.map +1 -1
  326. package/lib/outcomes.js +5 -4
  327. package/lib/outcomes.js.map +1 -1
  328. package/lib/push-gate.d.ts +13 -0
  329. package/lib/push-gate.d.ts.map +1 -1
  330. package/lib/push-gate.js +11 -7
  331. package/lib/push-gate.js.map +1 -1
  332. package/lib/push-set-usefulness.d.ts +78 -0
  333. package/lib/push-set-usefulness.d.ts.map +1 -0
  334. package/lib/push-set-usefulness.js +225 -0
  335. package/lib/push-set-usefulness.js.map +1 -0
  336. package/lib/sync.d.ts +10 -0
  337. package/lib/sync.d.ts.map +1 -1
  338. package/lib/sync.js +14 -1
  339. package/lib/sync.js.map +1 -1
  340. package/lib/work-result.d.ts +43 -0
  341. package/lib/work-result.d.ts.map +1 -0
  342. package/lib/work-result.js +39 -0
  343. package/lib/work-result.js.map +1 -0
  344. package/package.json +1 -1
  345. package/assets/hooks/claim-guard.sh +0 -212
  346. package/assets/hooks/grill-gate-ask.sh +0 -26
  347. package/assets/hooks/grill-gate-bypass.sh +0 -61
  348. package/assets/hooks/grill-gate-options.sh +0 -50
  349. package/assets/hooks/grill-gate.sh +0 -482
  350. package/assets/hooks/postmortem-guard.sh +0 -124
  351. package/assets/hooks/proposal-guard.sh +0 -154
  352. package/assets/hooks/stand-login-guard.sh +0 -107
  353. package/assets/hooks/turn-exit-epic.sh +0 -173
  354. package/assets/hooks/turn-exit-patterns.sh +0 -123
  355. package/assets/hooks/turn-exit-verdict.sh +0 -149
  356. package/assets/hooks/waiting-turn-guard.sh +0 -320
  357. package/assets/hooks/work-start-guard.sh +0 -175
@@ -5,122 +5,36 @@ description: Creating a new skill — one with no law above it — a showcase, a
5
5
 
6
6
  # How a skill is created
7
7
 
8
- A skill is what the agent loads before work and reads in full. Everything else follows: it is
9
- short, it declares when to load it, and it does not retell what is already written in the
10
- neighbouring one.
8
+ Cold part: `pitfalls.md` — the whole text with samples and reasons.
11
9
 
12
10
  ## When to use
13
11
 
14
- - A skill with no law above it is being created: a showcase, a generator, work with a
15
- third-party service, a technique adopted in this tree.
16
- - A skill has grown, and it is time to split it.
17
- - The skill exists, but nobody loads it — the declaration needs fixing.
18
-
19
- **A rule and a pattern do not go here.** A rule stands under a law, a pattern next to a rule,
20
- and the shape of both is held by the pattern `spec-driven-rule`. A skill without a law is the
21
- third case, and only it is here.
12
+ - A skill with no law above it is created, has grown, or is not loaded. A rule and a pattern —
13
+ pattern `spec-driven-rule`.
22
14
 
23
15
  ## Order
24
16
 
25
- 1. **Ask what is missing.** What work the skill covers, where people stumbled without it,
26
- whether ready-made commands are needed or an order of actions is enough. A skill written
27
- without this retells the tool's documentation — and the agent knows that anyway.
28
- 2. **Write a draft.** One file. Additional ones — only when the first stops being readable in
29
- full.
30
- 3. **Show the owner.** A skill acts on all future sessions, and creating it silently is not
31
- allowed.
32
-
33
- ## When the owner hands over the text
34
-
35
- A text the owner wrote is carried, not rewritten. Before the first split it lands whole in the
36
- task folder: a request cut with `[…]` leaves nothing to compare against. Headings keep their case
37
- and wording, sentences their words, code samples stay whole. What the shape of a skill forces —
38
- the declaration, "When to use", a link in place of "above" — goes into a list of deviations, one
39
- line each. Before the first commit a script compares every heading and paragraph of the source
40
- with the skill files and prints what is missing or changed. A size limit the text does not fit
41
- splits the text into files, never shortens it.
42
-
43
- ## What is in the file
44
-
45
- ```
46
- <skill-name>/
47
- ├── SKILL.md # mandatory, and usually the only one
48
- ├── <SOMETHING>.md # a separate file — when SKILL.md stopped being readable in full
49
- └── scripts/ # ready-made scripts, if the operation is deterministic
50
- ```
51
-
52
- The preamble between `---` is `name` and `description`, then the title and the sections. The
53
- first section is "When to use": the agent decides by it, not by the title.
54
-
55
- ## The declaration decides everything
56
-
57
- `description` is **the only thing the agent sees** when it decides whether to load the skill or
58
- not. It stands in the system prompt next to the descriptions of all the others, and the choice
59
- goes by them.
60
-
61
- It answers two questions: what the skill gives and when to load it. Write in the third person,
62
- up to three hundred characters: the first sentence — what it does, the second — "Load when…", the
63
- third — what is not in it and where to look for that. Where the tree has the descriptions check
64
- laid out, it refuses a longer declaration.
65
-
66
- ```
67
- ✓ Creating a new skill — one with no law above it. Load when asked to create, write or
68
- rewrite a skill. The shape of a rule and a pattern is not here — that is pattern
69
- spec-driven-rule.
17
+ 1. Ask what is missing. 2. Write one file. 3. Show the owner. An owner's text is carried, not
18
+ rewritten: it lands whole in the task folder, deviations are listed, a script compares it.
70
19
 
71
- ✗ Helps with skills.
72
- ```
20
+ ## The file
73
21
 
74
- The second declaration gives the agent no way to tell this skill from the neighbouring one —
75
- and it loads neither.
76
-
77
- The line "what is not here" is not decoration: there are dozens of skills in the tree, and half
78
- of the wrong choices are the neighbour taken instead. Name it by name.
79
-
80
- ## Ready-made commands instead of a description
81
-
82
- A script is put next to the skill when the operation is deterministic — a check, bringing to a
83
- form, parsing output. Such a thing is cheaper to call than to generate anew, and an error in it
84
- is seen once, not in every generation.
85
-
86
- An order of actions that depends on what was found does not become a script: it stays text.
87
-
88
- ## When to split
89
-
90
- Split when:
91
-
92
- - the file stopped being readable in full — by experience, that is around a hundred lines;
93
- - it holds two different subjects, and the second is needed once a month;
94
- - ready-made code took more room than the explanation of what it is for.
95
-
96
- Do not split for beauty: two files instead of one cost one extra hop at every reading, and a
97
- link deeper than one level is not followed at all.
22
+ - **`name` and `description`, then "When to use" first.**
23
+ - **`description` is all the agent sees:** what it gives, "Load when…", which neighbour not to
24
+ load — third person, up to 300 characters.
25
+ - **A deterministic operation becomes a script next to it.**
26
+ - **Split when not readable in full (about a hundred lines); links go one level deep.**
27
+ - **It is named in the gate map or called by another skill or role.**
98
28
 
99
29
  ## How a skill does harm
100
30
 
101
- - **Retelling the tool's documentation.** The agent reads the skill at every piece of work; a
102
- line it knows anyway pushes out the one it does not.
103
- - **Duplicating a neighbour.** Two skills about one thing start to contradict each other, and
104
- the first to notice is whoever has carried out both.
105
- - **What goes stale together with the code.** A skill naming a version, a number or a file name
106
- that is edited more often than once a quarter lies silently.
107
- - **Length.** A skill of three screens stops being read in full and is read up to the first
108
- familiar section.
109
-
110
- ## Before handing it over
111
-
112
- - [ ] the declaration has "Load when…" and names the neighbour not to load;
113
- - [ ] the first section is "When to use";
114
- - [ ] the file is readable in full in one sitting;
115
- - [ ] not one line repeats the neighbouring skill;
116
- - [ ] nothing that goes stale by itself: versions, numbers, dates;
117
- - [ ] at least one ready-made sample, not only an explanation;
118
- - [ ] links go one level deep, no deeper;
119
- - [ ] where the tree has the descriptions check laid out, it is green before the first commit,
120
- not only before the push.
31
+ - **Retelling the tool's documentation.**
32
+ - **Duplicating a neighbour.**
33
+ - **What goes stale together with the code.**
34
+ - **Length.**
121
35
 
122
- ## So that the skill gets loaded
36
+ ## Names and techniques
123
37
 
124
- Writing it is not enough: a skill nobody opens does not act. A new skill is either named in the
125
- gate map of this tree, or called by name by another skill or a role. A skill named nowhere stays
126
- a decoration.
38
+ - An owner's text over a size limit is split into files, never shortened.
39
+ - A skill has at least one ready-made sample, not only an explanation.
40
+ - The descriptions check is green before the first commit, not only before push.
@@ -0,0 +1,188 @@
1
+ // The task flow as an executable scenario: the data language of `flow-syntax.mjs`, nothing here runs.
2
+ // A state is left when its exit is measured; the first state whose exit is unmet is where the work
3
+ // stands. A release case says when a turn may end before the scenario does. A new fact is a new
4
+ // measurer in `measure/`; a new combination of facts is a line here.
5
+ ({
6
+ source: {
7
+ git: { open: {} },
8
+ tree: { open: {} },
9
+ host: { open: {} },
10
+ marks: { open: {} },
11
+ owner: { open: {} },
12
+ session: { open: {} },
13
+ steps: { open: {} },
14
+ records: { open: {} },
15
+ },
16
+
17
+ measure: {
18
+ grill: { written: { git: source.git, tree: source.tree } },
19
+ epic: {
20
+ declared: { git: source.git, host: source.host, tree: source.tree },
21
+ nextTaken: { git: source.git, host: source.host, tree: source.tree },
22
+ mergedMarked: { git: source.git, host: source.host, tree: source.tree },
23
+ finished: { git: source.git, host: source.host, tree: source.tree },
24
+ },
25
+ agreement: { named: { git: source.git, tree: source.tree } },
26
+ task: { taken: { git: source.git, host: source.host } },
27
+ plan: { approved: { git: source.git, marks: source.marks, steps: source.steps, records: source.records } },
28
+ progress: {
29
+ mirrors: { git: source.git, steps: source.steps },
30
+ done: { git: source.git, tree: source.tree, marks: source.marks, steps: source.steps },
31
+ },
32
+ footprint: { touched: { git: source.git } },
33
+ folder: { archived: { git: source.git } },
34
+ pr: { handed: { git: source.git, host: source.host } },
35
+ copy: {
36
+ outsideEpic: { git: source.git, host: source.host, tree: source.tree },
37
+ outOfScenario: { git: source.git, host: source.host, tree: source.tree },
38
+ },
39
+ owner: { saidStop: { owner: source.owner }, nudged: { owner: source.owner } },
40
+ session: {
41
+ wrote: { session: source.session },
42
+ role: { session: source.session },
43
+ menuLost: { session: source.session },
44
+ forbidden: { session: source.session },
45
+ idle: { session: source.session },
46
+ unread: { session: source.session },
47
+ waiting: { session: source.session },
48
+ },
49
+ host: { silent: { host: source.host } },
50
+ },
51
+
52
+ state: {
53
+ request: {
54
+ title: 'просьба-не-разобрана',
55
+ action: 'explore the tree, then ask the questions',
56
+ pattern: 'task-flow-start',
57
+ exit: measure.grill.written,
58
+ },
59
+ epic: {
60
+ title: 'эпик-заведён',
61
+ action: 'take the epic branch from the main branch; the epic card moves with the first task',
62
+ pattern: 'epic-flow-declare',
63
+ exit: measure.epic.declared,
64
+ },
65
+ grill: {
66
+ title: 'разбор-закрыт',
67
+ action: 'write the product agreement, or the reason there is none',
68
+ pattern: 'task-flow-start',
69
+ exit: measure.agreement.named,
70
+ },
71
+ agreement: {
72
+ title: 'договорённость-записана',
73
+ action: 'create the task, the branch from the epic branch, and the folder',
74
+ pattern: 'task-flow-start',
75
+ exit: measure.task.taken,
76
+ },
77
+ taken: {
78
+ title: 'задача-взята',
79
+ action: 'write the plan',
80
+ pattern: 'task-flow-start',
81
+ exit: measure.plan.approved,
82
+ },
83
+ planned: {
84
+ title: 'замысел-записан',
85
+ action: 'do the first stage',
86
+ pattern: 'task-flow-start',
87
+ exit: measure.progress.mirrors,
88
+ },
89
+ stage: {
90
+ title: 'этап-идёт',
91
+ action: 'finish the stage: `step N.M` measures each step and marks it done',
92
+ pattern: 'task-flow-resume',
93
+ exit: measure.progress.done,
94
+ },
95
+ stagesOver: {
96
+ title: 'этапы-кончились',
97
+ action: 'merge the agreement, bring the texts up to date, run the suite',
98
+ pattern: 'task-flow-close',
99
+ exit: measure.footprint.touched,
100
+ },
101
+ reviewOver: {
102
+ title: 'разбор-кончился',
103
+ action: 'take the folder apart by the last commit',
104
+ pattern: 'task-flow-archive',
105
+ exit: measure.folder.archived,
106
+ },
107
+ folderGone: {
108
+ title: 'папка-разобрана',
109
+ action: 'the work queue audit, then open the PR',
110
+ pattern: 'task-flow-close',
111
+ exit: measure.pr.handed,
112
+ },
113
+ handed: {
114
+ title: 'работа-отдана',
115
+ action: 'send the rules review to the background, then take the next task of the epic',
116
+ pattern: 'task-flow-archive',
117
+ exit: measure.epic.nextTaken,
118
+ },
119
+ merged: {
120
+ title: 'влито',
121
+ action: 'merge the PRs of the chain bottom-up, mark the merged tasks by the branch of the next one',
122
+ pattern: 'task-flow-resume',
123
+ exit: measure.epic.mergedMarked,
124
+ },
125
+ epicOver: {
126
+ title: 'задачи-эпика-кончились',
127
+ action: 'open the PR of the epic into the main branch',
128
+ pattern: 'task-flow-close',
129
+ exit: measure.epic.finished,
130
+ end: true,
131
+ },
132
+ },
133
+
134
+ release: {
135
+ scenarioEnd: {
136
+ when: { any: [measure.epic.finished, { all: [measure.copy.outsideEpic, measure.pr.handed] }] },
137
+ order: 1,
138
+ log: 'the end of the scenario',
139
+ },
140
+ stopWord: { when: measure.owner.saidStop, order: 2, log: 'a stop word of the owner' },
141
+ // The state «работа-отдана» sends work to the background by its own action and goes on: there
142
+ // the wait releases nothing.
143
+ background: {
144
+ when: { all: [measure.session.waiting, { not: measure.pr.handed }] },
145
+ order: 3,
146
+ log: 'a background task of the session runs',
147
+ },
148
+ noWrite: {
149
+ when: {
150
+ any: [
151
+ measure.copy.outOfScenario,
152
+ { all: [{ not: measure.session.wrote }, { not: measure.owner.nudged }] },
153
+ ],
154
+ },
155
+ order: 4,
156
+ log: 'no write to the tree, or a branch outside the scenario',
157
+ },
158
+ role: { when: measure.session.role, order: 5, log: 'a role session' },
159
+ hostSilent: { when: measure.host.silent, order: 6, log: 'the host did not answer twice' },
160
+ menuLost: { when: measure.session.menuLost, order: 8, log: 'the menu did not reach the owner' },
161
+ },
162
+
163
+ words: {
164
+ stop: [
165
+ 'стоп', 'стой', 'хватит', 'остановись', 'прекрати', 'не сейчас', 'подожди', 'погоди', 'жди',
166
+ 'пауза', 'отбой', 'на сегодня всё', 'stop', 'wait', 'not now', 'pause',
167
+ ],
168
+ stopExcept: [
169
+ 'продолжай', 'делай', 'работай', 'доделывай', 'иди дальше', 'делай дальше', 'сначала', 'спрашивать',
170
+ 'спрашивай', 'asking', 'keep going', 'go on',
171
+ ],
172
+ holdAfter: ['стоять', 'останавлива', 'ждать'],
173
+ nudge: '(?<![\\p{L}])(?<!не )(продолжай|доделывай|работай|делай дальше|работаешь)(?![\\p{L}])|почему (ты )?(стоишь|встал|остановил)|что дальше|дальше\\?|^(ну )?(и )?что там|^ну и\\s*[?!.]|какого .*останов',
174
+ write: [
175
+ 'git commit', 'git push', 'git add', 'git merge', 'git rm', 'git mv', 'sed -i', 'perl -pi', 'gh pr', 'npm run task:new', 'pnpm run task:new', 'npm run task:move',
176
+ 'pnpm run task:move', 'npm run agent-kit:sync', 'pnpm run agent-kit:sync',
177
+ ],
178
+ menu: ['отложить RT-N', 'стоп'],
179
+ legacyBranches: ['RT-3276-conversation-checks', 'RT-3329-task-flow-scenario'],
180
+ },
181
+
182
+ expect: {
183
+ exit: { pattern: '^exit (\\d+)$', compare: 'exit' },
184
+ line: { pattern: '^`(.*)`$', compare: 'line' },
185
+ regex: { pattern: '^/(.*)/$', compare: 'regex' },
186
+ number: { pattern: '^(=|>=|<=) ?(-?\\d+)$', compare: 'number' },
187
+ },
188
+ });
@@ -0,0 +1,102 @@
1
+ # The task flow
2
+
3
+ Generated by `flow-sync.mjs` from `flow.js` next to it. `flow-sync.mjs --check` refuses a hand edit:
4
+ the description is edited, and the generator is run.
5
+
6
+ <!-- flow:description -->
7
+ ## States
8
+
9
+ | State | Exit | Mandatory action | Pattern |
10
+ | --- | --- | --- | --- |
11
+ | `просьба-не-разобрана` | `measure.grill.written` | explore the tree, then ask the questions | `task-flow-start` |
12
+ | `эпик-заведён` | `measure.epic.declared` | take the epic branch from the main branch; the epic card moves with the first task | `epic-flow-declare` |
13
+ | `разбор-закрыт` | `measure.agreement.named` | write the product agreement, or the reason there is none | `task-flow-start` |
14
+ | `договорённость-записана` | `measure.task.taken` | create the task, the branch from the epic branch, and the folder | `task-flow-start` |
15
+ | `задача-взята` | `measure.plan.approved` | write the plan | `task-flow-start` |
16
+ | `замысел-записан` | `measure.progress.mirrors` | do the first stage | `task-flow-start` |
17
+ | `этап-идёт` | `measure.progress.done` | finish the stage: `step N.M` measures each step and marks it done | `task-flow-resume` |
18
+ | `этапы-кончились` | `measure.footprint.touched` | merge the agreement, bring the texts up to date, run the suite | `task-flow-close` |
19
+ | `разбор-кончился` | `measure.folder.archived` | take the folder apart by the last commit | `task-flow-archive` |
20
+ | `папка-разобрана` | `measure.pr.handed` | the work queue audit, then open the PR | `task-flow-close` |
21
+ | `работа-отдана` | `measure.epic.nextTaken` | send the rules review to the background, then take the next task of the epic | `task-flow-archive` |
22
+ | `влито` | `measure.epic.mergedMarked` | merge the PRs of the chain bottom-up, mark the merged tasks by the branch of the next one | `task-flow-resume` |
23
+ | `задачи-эпика-кончились` | `measure.epic.finished` | open the PR of the epic into the main branch | `task-flow-close` |
24
+
25
+ ## Release cases
26
+
27
+ The engine asks the cases in this order, and a met case lets the turn end before the scenario does.
28
+
29
+ | Order | Case | When | Log |
30
+ | --- | --- | --- | --- |
31
+ | 1 | `scenarioEnd` | `any(measure.epic.finished, all(measure.copy.outsideEpic, measure.pr.handed))` | the end of the scenario |
32
+ | 2 | `stopWord` | `measure.owner.saidStop` | a stop word of the owner |
33
+ | 3 | `background` | `all(measure.session.waiting, not(measure.pr.handed))` | a background task of the session runs |
34
+ | 4 | `noWrite` | `any(measure.copy.outOfScenario, all(not(measure.session.wrote), not(measure.owner.nudged)))` | no write to the tree, or a branch outside the scenario |
35
+ | 5 | `role` | `measure.session.role` | a role session |
36
+ | 6 | `hostSilent` | `measure.host.silent` | the host did not answer twice |
37
+ | 8 | `menuLost` | `measure.session.menuLost` | the menu did not reach the owner |
38
+
39
+ ## Measurers
40
+
41
+ | Measurer | Ports |
42
+ | --- | --- |
43
+ | `measure.grill.written` | `source.git`, `source.tree` |
44
+ | `measure.epic.declared` | `source.git`, `source.host`, `source.tree` |
45
+ | `measure.epic.nextTaken` | `source.git`, `source.host`, `source.tree` |
46
+ | `measure.epic.mergedMarked` | `source.git`, `source.host`, `source.tree` |
47
+ | `measure.epic.finished` | `source.git`, `source.host`, `source.tree` |
48
+ | `measure.agreement.named` | `source.git`, `source.tree` |
49
+ | `measure.task.taken` | `source.git`, `source.host` |
50
+ | `measure.plan.approved` | `source.git`, `source.marks`, `source.steps`, `source.records` |
51
+ | `measure.progress.mirrors` | `source.git`, `source.steps` |
52
+ | `measure.progress.done` | `source.git`, `source.tree`, `source.marks`, `source.steps` |
53
+ | `measure.footprint.touched` | `source.git` |
54
+ | `measure.folder.archived` | `source.git` |
55
+ | `measure.pr.handed` | `source.git`, `source.host` |
56
+ | `measure.copy.outsideEpic` | `source.git`, `source.host`, `source.tree` |
57
+ | `measure.copy.outOfScenario` | `source.git`, `source.host`, `source.tree` |
58
+ | `measure.owner.saidStop` | `source.owner` |
59
+ | `measure.owner.nudged` | `source.owner` |
60
+ | `measure.session.wrote` | `source.session` |
61
+ | `measure.session.role` | `source.session` |
62
+ | `measure.session.menuLost` | `source.session` |
63
+ | `measure.session.forbidden` | `source.session` |
64
+ | `measure.session.idle` | `source.session` |
65
+ | `measure.session.unread` | `source.session` |
66
+ | `measure.session.waiting` | `source.session` |
67
+ | `measure.host.silent` | `source.host` |
68
+
69
+ ## Sources
70
+
71
+ | Source | Ports |
72
+ | --- | --- |
73
+ | `source.git.open` | none |
74
+ | `source.tree.open` | none |
75
+ | `source.host.open` | none |
76
+ | `source.marks.open` | none |
77
+ | `source.owner.open` | none |
78
+ | `source.session.open` | none |
79
+ | `source.steps.open` | none |
80
+ | `source.records.open` | none |
81
+
82
+ ## Words
83
+
84
+ | Key | Words |
85
+ | --- | --- |
86
+ | `stop` | стоп, стой, хватит, остановись, прекрати, не сейчас, подожди, погоди, жди, пауза, отбой, на сегодня всё, stop, wait, not now, pause |
87
+ | `stopExcept` | продолжай, делай, работай, доделывай, иди дальше, делай дальше, сначала, спрашивать, спрашивай, asking, keep going, go on |
88
+ | `holdAfter` | стоять, останавлива, ждать |
89
+ | `nudge` | `(?<![\p{L}])(?<!не )(продолжай\|доделывай\|работай\|делай дальше\|работаешь)(?![\p{L}])\|почему (ты )?(стоишь\|встал\|остановил)\|что дальше\|дальше\?\|^(ну )?(и )?что там\|^ну и\s*[?!.]\|какого .*останов` |
90
+ | `write` | git commit, git push, git add, git merge, git rm, git mv, sed -i, perl -pi, gh pr, npm run task:new, pnpm run task:new, npm run task:move, pnpm run task:move, npm run agent-kit:sync, pnpm run agent-kit:sync |
91
+ | `menu` | отложить RT-N, стоп |
92
+ | `legacyBranches` | RT-3276-conversation-checks, RT-3329-task-flow-scenario |
93
+
94
+ ## Expected forms
95
+
96
+ | Form | Expected text | It matches when |
97
+ | --- | --- | --- |
98
+ | `exit` | `^exit (\d+)$` | the command exits with the code of the first group; the output is not compared |
99
+ | `line` | `` ^`(.*)`$ `` | the code is 0 and the last non-empty line of the output equals the first group |
100
+ | `regex` | `^/(.*)/$` | the code is 0 and the last non-empty line matches the first group |
101
+ | `number` | `^(=\|>=\|<=) ?(-?\d+)$` | the code is 0, the last non-empty line is an integer, and its comparison by the first group with the second holds |
102
+ <!-- /flow:description -->
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The measurer «measure.agreement» — exit 3: the grill or the plan of the branch names the directory
3
+ * of the product agreement, found on disk or in the history, or the reason there is none. The forms
4
+ * of the line are those the task folder sample writes: `**Описание фичи:**`, `**Draft:**` and
5
+ * `**Spec:**` with a path, `**Описание фичи:** не нужно — <reason>` and
6
+ * `**Behaviour:** unchanged — <reason>`.
7
+ */
8
+ import { agreementLines, taskFolder } from './text.mjs';
9
+
10
+ export function named({ git, tree }) {
11
+ return () => {
12
+ const branch = git.branch();
13
+ if (!branch) return false;
14
+ for (const file of ['grill.md', 'plan.md']) {
15
+ const path = `${taskFolder(branch)}/${file}`;
16
+ const text = tree.read(path) ?? git.lastVersion(path);
17
+ if (typeof text !== 'string') continue;
18
+ const { paths, reasons } = agreementLines(text);
19
+ if (reasons.length > 0) return true;
20
+ if (paths.some((p) => tree.exists(p) || git.everExisted(p))) return true;
21
+ }
22
+ return false;
23
+ };
24
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The measurer «measure.copy» — where the working copy stands against the scenario.
3
+ *
4
+ * outsideEpic — the work has no epic: the task card names none, or the copy of a branch without a
5
+ * task number leads no live epic. Outside an epic the scenario ends at exit 10.
6
+ *
7
+ * outOfScenario — the branch carries no task number, the copy leads no live epic, and no draft folder
8
+ * lies in the working copy: the engine has nothing to name as the next step. A draft keeps the copy
9
+ * in the scenario, measured by states 1–4.
10
+ */
11
+ import { epicOfWork, workTask } from './epic-of.mjs';
12
+
13
+ export function outsideEpic({ git, host, tree }) {
14
+ return () => epicOfWork({ git, host, tree }) === null;
15
+ }
16
+
17
+ export function outOfScenario({ git, host, tree }) {
18
+ return () =>
19
+ workTask({ git, tree }) === null &&
20
+ epicOfWork({ git, host, tree }) === null &&
21
+ !tree.list('docs/tasks').some((name) => name.startsWith('_draft-'));
22
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * The epic of the work, for the measurers that read it. The task the branch carries names its epic
3
+ * on the card. A branch without a task number takes the epic of the working copy from the assignment
4
+ * table; such an epic merged into the main branch or with its card closed counts as absent — the copy
5
+ * then leads nothing. The plan of the epic lies in the plans directory of the working copy.
6
+ */
7
+ import { findEpicPlan, taskOfBranch } from './epic-text.mjs';
8
+
9
+ /** The plans directory of the tree. */
10
+ export const PLANS = 'docs/plans';
11
+
12
+ const planOf = (tree, number) =>
13
+ findEpicPlan(
14
+ tree
15
+ .list(PLANS)
16
+ .filter((name) => name.endsWith('.md'))
17
+ .map((name) => tree.read(`${PLANS}/${name}`) ?? ''),
18
+ number,
19
+ );
20
+
21
+ /** The epic of the copy is alive: its card is not closed and its PR into the main branch is not merged. */
22
+ const alive = (host, plan) => {
23
+ const card = host.issue(plan.epic);
24
+ if (card && !card.open) return false;
25
+ return !(plan.branch && host.pulls(plan.branch).some((p) => p.base === 'main' && p.state === 'MERGED'));
26
+ };
27
+
28
+ /**
29
+ * The task the branch carries, or null. The epic branch has the same form as a task branch — the key
30
+ * and a number — and reads as a branch without a task number: a plan of the epic with that number
31
+ * names it as its branch.
32
+ */
33
+ export function workTask({ git, tree }) {
34
+ const branch = git.branch();
35
+ const number = taskOfBranch(branch);
36
+ if (number === null) return null;
37
+ return planOf(tree, number)?.branch === branch ? null : number;
38
+ }
39
+
40
+ /** The plan of the epic of the work: { epic, branch, rows }, or null where there is none. */
41
+ export function epicOfWork({ git, host, tree }) {
42
+ const task = workTask({ git, tree });
43
+ if (task === null) {
44
+ const number = tree.copyEpic();
45
+ const plan = number === null ? null : planOf(tree, number);
46
+ return plan && alive(host, plan) ? plan : null;
47
+ }
48
+ const epic = host.issue(task)?.epic;
49
+ return epic === null || epic === undefined ? null : planOf(tree, Number(epic));
50
+ }
@@ -0,0 +1,35 @@
1
+
2
+ /**
3
+ * The plan of an epic: its number, its branch and the rows of its task table, in their order.
4
+ * A row is `| <#> | <KEY>-<n> — <name> | <state> |`; the state «отложено» defers the task,
5
+ * «влито» marks it merged. Any other state, the old mark «шаг владельца» among them, is an ordinary
6
+ * row.
7
+ */
8
+ export function epicPlan(text) {
9
+ const epic = text.match(/\*\*Эпик:\*\*\s+[A-Z]+-(\d+)/)?.[1] ?? null;
10
+ const branch = text.match(/\*\*Ветка эпика:\*\*\s+`([^`]+)`/)?.[1] ?? null;
11
+ const rows = [];
12
+ for (const line of text.split('\n')) {
13
+ const m = line.match(/^\|\s*(?:\d+|—|-)\s*\|\s*[A-Z]+-(\d+)\b[^|]*\|\s*([^|]*?)\s*\|\s*$/);
14
+ if (!m) continue;
15
+ const state = m[2];
16
+ rows.push({
17
+ task: Number(m[1]),
18
+ state,
19
+ deferred: state === 'отложено',
20
+ merged: state === 'влито',
21
+ });
22
+ }
23
+ return { epic: epic === null ? null : Number(epic), branch, rows };
24
+ }
25
+
26
+ /** The plan of the epic numbered so among the texts of the plans directory, or null. */
27
+ export function findEpicPlan(texts, epic) {
28
+ return texts.map(epicPlan).find((p) => p.epic === epic) ?? null;
29
+ }
30
+
31
+ /** The task number a branch name carries, by the key of the plan, or null. */
32
+ export function taskOfBranch(branch) {
33
+ const m = String(branch).match(/^[A-Z]+-(\d+)-[a-z0-9][a-z0-9-]*$/);
34
+ return m ? Number(m[1]) : null;
35
+ }