@turri-dev/cli 0.4.3-next.7ada234 → 0.4.3-next.8c1b0fa

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 (538) hide show
  1. package/README.md +22 -2
  2. package/dist/banner.js +248 -0
  3. package/dist/capture-cli.js +1 -1
  4. package/dist/capture-view.js +99 -0
  5. package/dist/chat-commands.js +6 -6
  6. package/dist/chat-models.js +17 -15
  7. package/dist/chat-tab-header.js +0 -1
  8. package/dist/chat-tabs.js +1 -1
  9. package/dist/chat-terminal.js +115 -73
  10. package/dist/chat-waiting.js +0 -20
  11. package/dist/cli-options.js +11 -7
  12. package/dist/cli-root.js +101 -0
  13. package/dist/cli.js +20 -26
  14. package/dist/conform-cli.js +4 -6
  15. package/dist/cultivate-cli.js +65 -97
  16. package/dist/doctor-cli.js +99 -0
  17. package/dist/drift-cli.js +2 -7
  18. package/dist/entry-renderers.js +107 -0
  19. package/dist/extension.js +14 -3379
  20. package/dist/init-config-cli.js +209 -0
  21. package/dist/launch-cli.js +55 -91
  22. package/dist/lineage-cli.js +2 -4
  23. package/dist/loop-cli.js +118 -237
  24. package/dist/panel-view.js +409 -0
  25. package/dist/parse-cli.js +5 -2
  26. package/dist/pi-launch.js +41 -13
  27. package/dist/pi-themes.js +2 -2
  28. package/dist/plain-code-blocks.js +1 -1
  29. package/dist/print-mode.js +20 -0
  30. package/dist/quiet.js +7 -106
  31. package/dist/regenerate/diff-view.js +6 -87
  32. package/dist/regenerate/jobs-tree.js +2 -17
  33. package/dist/regenerate/spec-map-view.js +3 -68
  34. package/dist/regenerate-cli.js +7 -11
  35. package/dist/reopen.js +40 -7
  36. package/dist/skill-progress.js +25 -0
  37. package/dist/skill-report.js +52 -0
  38. package/dist/terminal-marks.js +21 -0
  39. package/dist/terminal-notifications.js +74 -19
  40. package/dist/terminal-view.js +275 -0
  41. package/dist/turri-versions.js +64 -6
  42. package/docs/README.md +2 -2
  43. package/docs/chats.md +4 -4
  44. package/docs/claude-subscription.md +1 -1
  45. package/docs/config.md +5 -4
  46. package/docs/development.md +30 -64
  47. package/docs/headless.md +3 -1
  48. package/docs/hosting.md +3 -251
  49. package/docs/installation.md +4 -2
  50. package/docs/launch.md +1 -1
  51. package/docs/sentinel.md +3 -3
  52. package/docs/using.md +3 -3
  53. package/package.json +10 -28
  54. package/dist/ask.d.ts +0 -90
  55. package/dist/ask.js +0 -170
  56. package/dist/background-skills.d.ts +0 -56
  57. package/dist/background-skills.js +0 -129
  58. package/dist/bedrock-region.d.ts +0 -66
  59. package/dist/bedrock-region.js +0 -144
  60. package/dist/brand.d.ts +0 -13
  61. package/dist/btw.d.ts +0 -69
  62. package/dist/btw.js +0 -174
  63. package/dist/capture/agents.d.ts +0 -406
  64. package/dist/capture/agents.js +0 -379
  65. package/dist/capture/area.d.ts +0 -58
  66. package/dist/capture/area.js +0 -197
  67. package/dist/capture/assemble.d.ts +0 -112
  68. package/dist/capture/assemble.js +0 -453
  69. package/dist/capture/capture.d.ts +0 -116
  70. package/dist/capture/capture.js +0 -1315
  71. package/dist/capture/chat.d.ts +0 -29
  72. package/dist/capture/chat.js +0 -94
  73. package/dist/capture/checks.d.ts +0 -142
  74. package/dist/capture/checks.js +0 -649
  75. package/dist/capture/config.d.ts +0 -13
  76. package/dist/capture/config.js +0 -66
  77. package/dist/capture/interface.d.ts +0 -71
  78. package/dist/capture/interface.js +0 -199
  79. package/dist/capture/map.d.ts +0 -56
  80. package/dist/capture/map.js +0 -530
  81. package/dist/capture/models.d.ts +0 -4
  82. package/dist/capture/models.js +0 -16
  83. package/dist/capture/plan.d.ts +0 -7
  84. package/dist/capture/plan.js +0 -13
  85. package/dist/capture/progress.d.ts +0 -111
  86. package/dist/capture/progress.js +0 -266
  87. package/dist/capture/python-interface.d.ts +0 -3
  88. package/dist/capture/python-interface.js +0 -17
  89. package/dist/capture/report.d.ts +0 -75
  90. package/dist/capture/report.js +0 -268
  91. package/dist/capture/runners.d.ts +0 -6
  92. package/dist/capture/runners.js +0 -59
  93. package/dist/capture/scripts.d.ts +0 -26
  94. package/dist/capture/scripts.js +0 -38
  95. package/dist/capture/state.d.ts +0 -310
  96. package/dist/capture/state.js +0 -43
  97. package/dist/capture/trial.d.ts +0 -34
  98. package/dist/capture/trial.js +0 -89
  99. package/dist/capture-cli.d.ts +0 -1
  100. package/dist/chat-commands.d.ts +0 -17
  101. package/dist/chat-idle.d.ts +0 -7
  102. package/dist/chat-idle.js +0 -20
  103. package/dist/chat-models.d.ts +0 -22
  104. package/dist/chat-records.d.ts +0 -50
  105. package/dist/chat-records.js +0 -107
  106. package/dist/chat-scope.d.ts +0 -14
  107. package/dist/chat-scope.js +0 -15
  108. package/dist/chat-skills.d.ts +0 -17
  109. package/dist/chat-skills.js +0 -18
  110. package/dist/chat-tab-header.d.ts +0 -16
  111. package/dist/chat-tabs.d.ts +0 -26
  112. package/dist/chat-terminal.d.ts +0 -24
  113. package/dist/chat-ui.d.ts +0 -33
  114. package/dist/chat-waiting.d.ts +0 -67
  115. package/dist/chats.d.ts +0 -346
  116. package/dist/chats.js +0 -1022
  117. package/dist/cli-options.d.ts +0 -24
  118. package/dist/cli.d.ts +0 -9
  119. package/dist/config-edit.d.ts +0 -83
  120. package/dist/config-edit.js +0 -393
  121. package/dist/config.d.ts +0 -428
  122. package/dist/config.js +0 -816
  123. package/dist/conform-cli.d.ts +0 -1
  124. package/dist/conformance-switch.d.ts +0 -25
  125. package/dist/conformance-switch.js +0 -86
  126. package/dist/cultivate-cli.d.ts +0 -1
  127. package/dist/doctor-tool.d.ts +0 -11
  128. package/dist/doctor-tool.js +0 -33
  129. package/dist/drift-cli.d.ts +0 -1
  130. package/dist/environment.d.ts +0 -37
  131. package/dist/environment.js +0 -109
  132. package/dist/extension.d.ts +0 -209
  133. package/dist/genome.d.ts +0 -77
  134. package/dist/genome.js +0 -288
  135. package/dist/graph.d.ts +0 -52
  136. package/dist/graph.js +0 -247
  137. package/dist/host-session.d.ts +0 -112
  138. package/dist/host-session.js +0 -103
  139. package/dist/host.d.ts +0 -40
  140. package/dist/host.js +0 -54
  141. package/dist/identity.d.ts +0 -7
  142. package/dist/identity.js +0 -75
  143. package/dist/init-config.d.ts +0 -172
  144. package/dist/init-config.js +0 -867
  145. package/dist/installed-providers.d.ts +0 -40
  146. package/dist/installed-providers.js +0 -98
  147. package/dist/jellyfish.d.ts +0 -40
  148. package/dist/judge.d.ts +0 -25
  149. package/dist/judge.js +0 -62
  150. package/dist/launch-agent.d.ts +0 -62
  151. package/dist/launch-agent.js +0 -339
  152. package/dist/launch-cli.d.ts +0 -1
  153. package/dist/launch-session.d.ts +0 -68
  154. package/dist/launch-session.js +0 -225
  155. package/dist/launch-tools.d.ts +0 -28
  156. package/dist/launch-tools.js +0 -72
  157. package/dist/launch-track.d.ts +0 -175
  158. package/dist/launch-track.js +0 -497
  159. package/dist/lineage-cli.d.ts +0 -1
  160. package/dist/loop-cli.d.ts +0 -35
  161. package/dist/loop-tools.d.ts +0 -103
  162. package/dist/loop-tools.js +0 -361
  163. package/dist/model-check.d.ts +0 -72
  164. package/dist/model-check.js +0 -162
  165. package/dist/module-report.d.ts +0 -9
  166. package/dist/new-project.d.ts +0 -10
  167. package/dist/new-project.js +0 -42
  168. package/dist/notice.d.ts +0 -115
  169. package/dist/notice.js +0 -61
  170. package/dist/parse-cli.d.ts +0 -1
  171. package/dist/parse-tool.d.ts +0 -9
  172. package/dist/parse-tool.js +0 -33
  173. package/dist/pi-launch.d.ts +0 -1
  174. package/dist/pi-settings.d.ts +0 -4
  175. package/dist/pi-themes.d.ts +0 -3
  176. package/dist/pi.d.ts +0 -248
  177. package/dist/pi.js +0 -889
  178. package/dist/picture-row.d.ts +0 -10
  179. package/dist/plain/check.d.ts +0 -63
  180. package/dist/plain/check.js +0 -236
  181. package/dist/plain/concepts.d.ts +0 -37
  182. package/dist/plain/concepts.js +0 -283
  183. package/dist/plain/cycles.d.ts +0 -21
  184. package/dist/plain/cycles.js +0 -190
  185. package/dist/plain/errors.d.ts +0 -26
  186. package/dist/plain/errors.js +0 -50
  187. package/dist/plain/files.d.ts +0 -47
  188. package/dist/plain/files.js +0 -161
  189. package/dist/plain/graph.d.ts +0 -107
  190. package/dist/plain/graph.js +0 -194
  191. package/dist/plain/highlight.d.ts +0 -43
  192. package/dist/plain/highlight.js +0 -196
  193. package/dist/plain/index.d.ts +0 -18
  194. package/dist/plain/index.js +0 -18
  195. package/dist/plain/liquid.d.ts +0 -22
  196. package/dist/plain/liquid.js +0 -124
  197. package/dist/plain/markdown.d.ts +0 -103
  198. package/dist/plain/markdown.js +0 -330
  199. package/dist/plain/module-concepts.d.ts +0 -32
  200. package/dist/plain/module-concepts.js +0 -80
  201. package/dist/plain/parser.d.ts +0 -163
  202. package/dist/plain/parser.js +0 -930
  203. package/dist/plain/plain.tmLanguage.json +0 -150
  204. package/dist/plain/project.d.ts +0 -48
  205. package/dist/plain/project.js +0 -155
  206. package/dist/plain/spec.d.ts +0 -152
  207. package/dist/plain/spec.js +0 -265
  208. package/dist/plain/stdlib.d.ts +0 -16
  209. package/dist/plain/stdlib.js +0 -48
  210. package/dist/plain/test-plain-file.d.ts +0 -59
  211. package/dist/plain/test-plain-file.js +0 -232
  212. package/dist/plain-code-blocks.d.ts +0 -14
  213. package/dist/plain-files.d.ts +0 -21
  214. package/dist/plain-files.js +0 -156
  215. package/dist/pointer-hover.d.ts +0 -12
  216. package/dist/question-dialog.d.ts +0 -60
  217. package/dist/questioning.d.ts +0 -55
  218. package/dist/questioning.js +0 -109
  219. package/dist/quiet.d.ts +0 -34
  220. package/dist/regenerate/activity.d.ts +0 -227
  221. package/dist/regenerate/activity.js +0 -250
  222. package/dist/regenerate/agent-env.d.ts +0 -51
  223. package/dist/regenerate/agent-env.js +0 -315
  224. package/dist/regenerate/agent-shell.d.ts +0 -54
  225. package/dist/regenerate/agent-shell.js +0 -121
  226. package/dist/regenerate/arbiter.d.ts +0 -68
  227. package/dist/regenerate/arbiter.js +0 -133
  228. package/dist/regenerate/audit.d.ts +0 -69
  229. package/dist/regenerate/audit.js +0 -212
  230. package/dist/regenerate/base-folder.d.ts +0 -70
  231. package/dist/regenerate/base-folder.js +0 -186
  232. package/dist/regenerate/cases.d.ts +0 -12
  233. package/dist/regenerate/cases.js +0 -149
  234. package/dist/regenerate/change-view.d.ts +0 -23
  235. package/dist/regenerate/change-view.js +0 -153
  236. package/dist/regenerate/chunk-plan.d.ts +0 -217
  237. package/dist/regenerate/chunk-plan.js +0 -937
  238. package/dist/regenerate/codebase.d.ts +0 -21
  239. package/dist/regenerate/codebase.js +0 -75
  240. package/dist/regenerate/command-check.d.ts +0 -66
  241. package/dist/regenerate/command-check.js +0 -577
  242. package/dist/regenerate/compaction.d.ts +0 -13
  243. package/dist/regenerate/compaction.js +0 -20
  244. package/dist/regenerate/confine.d.ts +0 -69
  245. package/dist/regenerate/confine.js +0 -311
  246. package/dist/regenerate/conform.d.ts +0 -66
  247. package/dist/regenerate/conform.js +0 -132
  248. package/dist/regenerate/conformance-agents.d.ts +0 -388
  249. package/dist/regenerate/conformance-agents.js +0 -1162
  250. package/dist/regenerate/conformance.d.ts +0 -191
  251. package/dist/regenerate/conformance.js +0 -1035
  252. package/dist/regenerate/conversation-writes.d.ts +0 -10
  253. package/dist/regenerate/conversation-writes.js +0 -100
  254. package/dist/regenerate/credentials.d.ts +0 -18
  255. package/dist/regenerate/credentials.js +0 -88
  256. package/dist/regenerate/debug-log.d.ts +0 -56
  257. package/dist/regenerate/debug-log.js +0 -236
  258. package/dist/regenerate/debugger.d.ts +0 -36
  259. package/dist/regenerate/debugger.js +0 -133
  260. package/dist/regenerate/delivery.d.ts +0 -2
  261. package/dist/regenerate/diagnose-job.d.ts +0 -2
  262. package/dist/regenerate/diagnose-job.js +0 -40
  263. package/dist/regenerate/diagnose.d.ts +0 -46
  264. package/dist/regenerate/diagnose.js +0 -92
  265. package/dist/regenerate/diff-view.d.ts +0 -64
  266. package/dist/regenerate/drift.d.ts +0 -120
  267. package/dist/regenerate/drift.js +0 -285
  268. package/dist/regenerate/environment-error.d.ts +0 -167
  269. package/dist/regenerate/environment-error.js +0 -342
  270. package/dist/regenerate/failure-reports.d.ts +0 -28
  271. package/dist/regenerate/failure-reports.js +0 -79
  272. package/dist/regenerate/job-log.d.ts +0 -30
  273. package/dist/regenerate/job-log.js +0 -105
  274. package/dist/regenerate/job-panel.d.ts +0 -20
  275. package/dist/regenerate/job-panel.js +0 -54
  276. package/dist/regenerate/jobs-tree.d.ts +0 -76
  277. package/dist/regenerate/jobs.d.ts +0 -231
  278. package/dist/regenerate/jobs.js +0 -522
  279. package/dist/regenerate/lanes.d.ts +0 -16
  280. package/dist/regenerate/lanes.js +0 -32
  281. package/dist/regenerate/launch.d.ts +0 -256
  282. package/dist/regenerate/launch.js +0 -689
  283. package/dist/regenerate/ledger-view.d.ts +0 -87
  284. package/dist/regenerate/ledger-view.js +0 -325
  285. package/dist/regenerate/ledger.d.ts +0 -368
  286. package/dist/regenerate/ledger.js +0 -357
  287. package/dist/regenerate/lineage.d.ts +0 -105
  288. package/dist/regenerate/lineage.js +0 -485
  289. package/dist/regenerate/list-arguments.d.ts +0 -21
  290. package/dist/regenerate/list-arguments.js +0 -121
  291. package/dist/regenerate/loop.d.ts +0 -423
  292. package/dist/regenerate/loop.js +0 -2087
  293. package/dist/regenerate/masking.d.ts +0 -19
  294. package/dist/regenerate/masking.js +0 -95
  295. package/dist/regenerate/model-names.d.ts +0 -33
  296. package/dist/regenerate/model-names.js +0 -92
  297. package/dist/regenerate/notes.d.ts +0 -159
  298. package/dist/regenerate/notes.js +0 -446
  299. package/dist/regenerate/os-sandbox.d.ts +0 -93
  300. package/dist/regenerate/os-sandbox.js +0 -283
  301. package/dist/regenerate/panel-dock.d.ts +0 -23
  302. package/dist/regenerate/paths.d.ts +0 -110
  303. package/dist/regenerate/paths.js +0 -190
  304. package/dist/regenerate/plain-palette.d.ts +0 -34
  305. package/dist/regenerate/prompt.d.ts +0 -230
  306. package/dist/regenerate/prompt.js +0 -741
  307. package/dist/regenerate/pulse-files.d.ts +0 -14
  308. package/dist/regenerate/pulse-files.js +0 -63
  309. package/dist/regenerate/records.d.ts +0 -132
  310. package/dist/regenerate/records.js +0 -327
  311. package/dist/regenerate/regenerate.d.ts +0 -106
  312. package/dist/regenerate/regenerate.js +0 -660
  313. package/dist/regenerate/regression.d.ts +0 -58
  314. package/dist/regenerate/regression.js +0 -188
  315. package/dist/regenerate/renames.d.ts +0 -42
  316. package/dist/regenerate/renames.js +0 -185
  317. package/dist/regenerate/requires.d.ts +0 -117
  318. package/dist/regenerate/requires.js +0 -377
  319. package/dist/regenerate/resources.d.ts +0 -57
  320. package/dist/regenerate/resources.js +0 -162
  321. package/dist/regenerate/scripts-being-written.d.ts +0 -19
  322. package/dist/regenerate/scripts-being-written.js +0 -30
  323. package/dist/regenerate/self-check.d.ts +0 -29
  324. package/dist/regenerate/self-check.js +0 -119
  325. package/dist/regenerate/services.d.ts +0 -28
  326. package/dist/regenerate/services.js +0 -158
  327. package/dist/regenerate/shell.d.ts +0 -91
  328. package/dist/regenerate/shell.js +0 -320
  329. package/dist/regenerate/side-panel.d.ts +0 -64
  330. package/dist/regenerate/spec-map-view.d.ts +0 -147
  331. package/dist/regenerate/spec-map.d.ts +0 -160
  332. package/dist/regenerate/spec-map.js +0 -596
  333. package/dist/regenerate/spec-steps.d.ts +0 -180
  334. package/dist/regenerate/spec-steps.js +0 -729
  335. package/dist/regenerate/standing.d.ts +0 -28
  336. package/dist/regenerate/standing.js +0 -30
  337. package/dist/regenerate/state.d.ts +0 -21
  338. package/dist/regenerate/state.js +0 -10
  339. package/dist/regenerate/steering.d.ts +0 -56
  340. package/dist/regenerate/steering.js +0 -119
  341. package/dist/regenerate/stop-report.d.ts +0 -43
  342. package/dist/regenerate/stop-report.js +0 -160
  343. package/dist/regenerate/submit-work.d.ts +0 -44
  344. package/dist/regenerate/submit-work.js +0 -76
  345. package/dist/regenerate/test-kinds.d.ts +0 -85
  346. package/dist/regenerate/test-kinds.js +0 -171
  347. package/dist/regenerate/test-scripts.d.ts +0 -240
  348. package/dist/regenerate/test-scripts.js +0 -847
  349. package/dist/regenerate/testing-steps.d.ts +0 -52
  350. package/dist/regenerate/testing-steps.js +0 -129
  351. package/dist/regenerate/testing.d.ts +0 -150
  352. package/dist/regenerate/testing.js +0 -438
  353. package/dist/regenerate/transcript-view.d.ts +0 -21
  354. package/dist/regenerate/unit-gate.d.ts +0 -27
  355. package/dist/regenerate/unit-gate.js +0 -20
  356. package/dist/regenerate/unit-review.d.ts +0 -152
  357. package/dist/regenerate/unit-review.js +0 -361
  358. package/dist/regenerate/web.d.ts +0 -61
  359. package/dist/regenerate/web.js +0 -256
  360. package/dist/regenerate/workspace.d.ts +0 -12
  361. package/dist/regenerate/workspace.js +0 -99
  362. package/dist/regenerate-cli.d.ts +0 -1
  363. package/dist/reopen.d.ts +0 -29
  364. package/dist/resume-line.d.ts +0 -5
  365. package/dist/review/live.d.ts +0 -72
  366. package/dist/review/live.js +0 -166
  367. package/dist/rules.d.ts +0 -20
  368. package/dist/rules.js +0 -47
  369. package/dist/run-report.d.ts +0 -88
  370. package/dist/run-report.js +0 -338
  371. package/dist/screen-padding.d.ts +0 -28
  372. package/dist/self-invocation.d.ts +0 -36
  373. package/dist/self-invocation.js +0 -137
  374. package/dist/sentinel-chat.d.ts +0 -19
  375. package/dist/sentinel-chat.js +0 -226
  376. package/dist/sentinel-check.d.ts +0 -36
  377. package/dist/sentinel-check.js +0 -78
  378. package/dist/sentinel.d.ts +0 -107
  379. package/dist/sentinel.js +0 -601
  380. package/dist/settings.d.ts +0 -45
  381. package/dist/settings.js +0 -378
  382. package/dist/setup.d.ts +0 -97
  383. package/dist/setup.js +0 -436
  384. package/dist/skill-progress.d.ts +0 -46
  385. package/dist/skill.d.ts +0 -102
  386. package/dist/skill.js +0 -147
  387. package/dist/skills.d.ts +0 -54
  388. package/dist/skills.js +0 -111
  389. package/dist/spawn-async.d.ts +0 -18
  390. package/dist/spawn-async.js +0 -35
  391. package/dist/stack.d.ts +0 -80
  392. package/dist/stack.js +0 -206
  393. package/dist/stdlib.d.ts +0 -43
  394. package/dist/stdlib.js +0 -118
  395. package/dist/surface.d.ts +0 -5
  396. package/dist/surface.js +0 -18
  397. package/dist/terminal-images.d.ts +0 -2
  398. package/dist/terminal-notifications.d.ts +0 -37
  399. package/dist/test-plain-files.d.ts +0 -41
  400. package/dist/test-plain-files.js +0 -172
  401. package/dist/tools.d.ts +0 -101
  402. package/dist/tools.js +0 -242
  403. package/dist/turri-versions.d.ts +0 -71
  404. package/genome/capture/capture.md +0 -26
  405. package/genome/capture/check-conventions.md +0 -5
  406. package/genome/capture/check-reference.md +0 -12
  407. package/genome/capture/compact.md +0 -7
  408. package/genome/capture/concepts.md +0 -3
  409. package/genome/capture/divide.md +0 -9
  410. package/genome/capture/feature.md +0 -45
  411. package/genome/capture/interface.md +0 -9
  412. package/genome/capture/modules.md +0 -25
  413. package/genome/capture/outline.md +0 -11
  414. package/genome/capture/python-interface.py +0 -111
  415. package/genome/capture/readability.md +0 -12
  416. package/genome/capture/reference.md +0 -10
  417. package/genome/capture/runners/python-requirements.sh +0 -67
  418. package/genome/capture/split.md +0 -9
  419. package/genome/capture/survey.md +0 -39
  420. package/genome/capture/trial.md +0 -18
  421. package/genome/capture/verify.md +0 -7
  422. package/genome/rules/bullet-continuation.md +0 -61
  423. package/genome/rules/concise-specs-examples.md +0 -460
  424. package/genome/rules/concise-specs-integration-examples.md +0 -281
  425. package/genome/rules/concise-specs.md +0 -80
  426. package/genome/rules/definitions.md +0 -107
  427. package/genome/rules/examples/integration-embedded-testing/run_conformance_tests_java.sh +0 -161
  428. package/genome/rules/examples/integration-embedded-testing/run_unittests_java.sh +0 -50
  429. package/genome/rules/exported-concepts.md +0 -39
  430. package/genome/rules/func-specs.md +0 -164
  431. package/genome/rules/impl-reqs.md +0 -68
  432. package/genome/rules/import-modules.md +0 -49
  433. package/genome/rules/integration-embedded-testing.md +0 -273
  434. package/genome/rules/integration-embedded.md +0 -171
  435. package/genome/rules/integration-standalone.md +0 -135
  436. package/genome/rules/integrations.md +0 -136
  437. package/genome/rules/linked-resources.md +0 -76
  438. package/genome/rules/module-structure.md +0 -112
  439. package/genome/rules/project-model.md +0 -69
  440. package/genome/rules/required-concepts.md +0 -44
  441. package/genome/rules/requires-modules.md +0 -81
  442. package/genome/rules/semantic-ids.md +0 -49
  443. package/genome/rules/stdlib.md +0 -37
  444. package/genome/rules/test-plain-files.md +0 -138
  445. package/genome/rules/test-reqs.md +0 -57
  446. package/genome/rules/turri-regeneration.md +0 -66
  447. package/genome/skills/analyze-2-func-specs/SKILL.md +0 -116
  448. package/genome/skills/analyze-func-specs/SKILL.md +0 -137
  449. package/genome/skills/break-down-func-spec/SKILL.md +0 -229
  450. package/genome/skills/consolidate-concepts/SKILL.md +0 -192
  451. package/genome/skills/convert-old-syntax/SKILL.md +0 -68
  452. package/genome/skills/convert-old-syntax/references/rubric.md +0 -11
  453. package/genome/skills/debug-specs/SKILL.md +0 -194
  454. package/genome/skills/implement-conformance-testing-script/SKILL.md +0 -247
  455. package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_cypress.ps1 +0 -337
  456. package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_golang.ps1 +0 -111
  457. package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_java.sh +0 -151
  458. package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_python.ps1 +0 -103
  459. package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_python.sh +0 -146
  460. package/genome/skills/implement-unit-testing-script/SKILL.md +0 -171
  461. package/genome/skills/implement-unit-testing-script/assets/run_unittests_flutter.ps1 +0 -87
  462. package/genome/skills/implement-unit-testing-script/assets/run_unittests_golang.ps1 +0 -73
  463. package/genome/skills/implement-unit-testing-script/assets/run_unittests_java.sh +0 -82
  464. package/genome/skills/implement-unit-testing-script/assets/run_unittests_python.ps1 +0 -81
  465. package/genome/skills/implement-unit-testing-script/assets/run_unittests_python.sh +0 -102
  466. package/genome/skills/implement-unit-testing-script/assets/run_unittests_react.ps1 +0 -87
  467. package/genome/skills/refactor-module/SKILL.md +0 -218
  468. package/genome/skills/resolve-section-ownership/SKILL.md +0 -64
  469. package/genome/skills/resolve-spec-conflict/SKILL.md +0 -102
  470. package/stdlib/backend/common.plain +0 -25
  471. package/stdlib/backend/conformance/common.plain +0 -12
  472. package/stdlib/backend/conformance/go-gin.plain +0 -9
  473. package/stdlib/backend/conformance/go-nethttp.plain +0 -9
  474. package/stdlib/backend/conformance/java-springboot.plain +0 -9
  475. package/stdlib/backend/conformance/python-django.plain +0 -9
  476. package/stdlib/backend/conformance/python-fastapi.plain +0 -9
  477. package/stdlib/backend/conformance/python-flask.plain +0 -9
  478. package/stdlib/backend/conformance/rust-axum.plain +0 -9
  479. package/stdlib/backend/conformance/typescript-express.plain +0 -9
  480. package/stdlib/backend/conformance/typescript-fastify.plain +0 -9
  481. package/stdlib/backend/conformance/typescript-nestjs.plain +0 -9
  482. package/stdlib/backend/go-gin.plain +0 -18
  483. package/stdlib/backend/go-nethttp.plain +0 -18
  484. package/stdlib/backend/java-springboot.plain +0 -19
  485. package/stdlib/backend/python-django.plain +0 -19
  486. package/stdlib/backend/python-fastapi.plain +0 -23
  487. package/stdlib/backend/python-flask.plain +0 -23
  488. package/stdlib/backend/rust-axum.plain +0 -17
  489. package/stdlib/backend/typescript-express.plain +0 -19
  490. package/stdlib/backend/typescript-fastify.plain +0 -19
  491. package/stdlib/backend/typescript-nestjs.plain +0 -19
  492. package/stdlib/cli/common.plain +0 -17
  493. package/stdlib/cli/conformance/common.plain +0 -11
  494. package/stdlib/cli/conformance/go-cobra.plain +0 -9
  495. package/stdlib/cli/conformance/go-flag.plain +0 -9
  496. package/stdlib/cli/conformance/java-picocli.plain +0 -9
  497. package/stdlib/cli/conformance/python-argparse.plain +0 -9
  498. package/stdlib/cli/conformance/python-click.plain +0 -9
  499. package/stdlib/cli/conformance/python-typer.plain +0 -9
  500. package/stdlib/cli/conformance/rust-clap.plain +0 -9
  501. package/stdlib/cli/conformance/typescript-commander.plain +0 -9
  502. package/stdlib/cli/go-cobra.plain +0 -14
  503. package/stdlib/cli/go-flag.plain +0 -14
  504. package/stdlib/cli/java-picocli.plain +0 -15
  505. package/stdlib/cli/python-argparse.plain +0 -18
  506. package/stdlib/cli/python-click.plain +0 -16
  507. package/stdlib/cli/python-typer.plain +0 -16
  508. package/stdlib/cli/rust-clap.plain +0 -14
  509. package/stdlib/cli/typescript-commander.plain +0 -17
  510. package/stdlib/frontend/angular.plain +0 -17
  511. package/stdlib/frontend/common.plain +0 -17
  512. package/stdlib/frontend/conformance/angular.plain +0 -5
  513. package/stdlib/frontend/conformance/common.plain +0 -11
  514. package/stdlib/frontend/conformance/react-vite.plain +0 -5
  515. package/stdlib/frontend/conformance/sveltekit-spa.plain +0 -5
  516. package/stdlib/frontend/conformance/vue-vite.plain +0 -5
  517. package/stdlib/frontend/react-vite.plain +0 -16
  518. package/stdlib/frontend/sveltekit-spa.plain +0 -16
  519. package/stdlib/frontend/vue-vite.plain +0 -16
  520. package/stdlib/lang/go.plain +0 -13
  521. package/stdlib/lang/java.plain +0 -12
  522. package/stdlib/lang/python.plain +0 -18
  523. package/stdlib/lang/rust.plain +0 -12
  524. package/stdlib/lang/typescript.plain +0 -13
  525. package/stdlib/library/common.plain +0 -15
  526. package/stdlib/library/conformance/common.plain +0 -9
  527. package/stdlib/library/conformance/go.plain +0 -9
  528. package/stdlib/library/conformance/java-gradle.plain +0 -9
  529. package/stdlib/library/conformance/java-maven.plain +0 -9
  530. package/stdlib/library/conformance/python.plain +0 -9
  531. package/stdlib/library/conformance/rust.plain +0 -9
  532. package/stdlib/library/conformance/typescript.plain +0 -9
  533. package/stdlib/library/go.plain +0 -12
  534. package/stdlib/library/java-gradle.plain +0 -13
  535. package/stdlib/library/java-maven.plain +0 -13
  536. package/stdlib/library/python.plain +0 -13
  537. package/stdlib/library/rust.plain +0 -12
  538. package/stdlib/library/typescript.plain +0 -15
@@ -1,937 +0,0 @@
1
- import { defineTool } from "@earendil-works/pi-coding-agent";
2
- import { Type } from "typebox";
3
- import { DEFAULT_CONCEPTS, extractConceptsFromDefinition, extractConceptsFromSpecText } from "../plain/concepts.js";
4
- import { ACCEPTANCE_TESTS, CONFORMANCE_TESTS, DEFINITIONS, FUNCTIONAL_REQUIREMENTS, NON_FUNCTIONAL_REQUIREMENTS, REQUIRED_FUNCTIONAL_SPECS, TEST_REQUIREMENTS } from "../plain/spec.js";
5
- import { ask, BEGIN, createExecutor } from "../pi.js";
6
- import { reportActivity, reportStage } from "./activity.js";
7
- import { firstLine, record } from "./ledger.js";
8
- import { marksRegenerateAgain } from "./records.js";
9
- import { validateConcepts } from "../plain/concepts.js";
10
- import { applyChanges, changesBetween, inconsistencies, layoutOf, makeStep, parseTree, serializeTree } from "./spec-steps.js";
11
- /** The work the queue does: every change from the base to the spec as it is now, numbered. */
12
- export function netChanges(base, current) {
13
- return changesBetween(serializeTree(base), serializeTree(current));
14
- }
15
- /**
16
- * What is wrong with a reworked queue, or nothing: every change in exactly one job, no job without
17
- * one, and each job, applied after the ones before it, leaving a spec that holds together - the last
18
- * exactly the spec as it is now.
19
- */
20
- export function checkDraft(input, draft) {
21
- const net = netChanges(input.base, input.current);
22
- const byId = new Map(net.map((change) => [change.id, change]));
23
- const problems = [];
24
- const seen = new Set();
25
- for (const job of draft) {
26
- if (job.changes.length === 0)
27
- problems.push(`"${job.title}" makes no change - delete it, or give it changes.`);
28
- for (const id of job.changes) {
29
- if (!byId.has(id))
30
- problems.push(`"${job.title}" names ${id}, which is not one of the changes.`);
31
- else if (seen.has(id))
32
- problems.push(`${id} is in more than one job - "${job.title}" and an earlier one.`);
33
- seen.add(id);
34
- }
35
- }
36
- const missing = net.filter((change) => !seen.has(change.id)).map((change) => change.id);
37
- if (missing.length > 0)
38
- problems.push(`No job makes ${missing.join(", ")} - every change has to be made, or the queue does not end on the spec as it is now.`);
39
- if (problems.length > 0)
40
- return problems;
41
- const base = serializeTree(input.base);
42
- const endpoints = new Set([...validateConcepts(input.base), ...validateConcepts(input.current)]);
43
- const sofar = [];
44
- for (const job of draft) {
45
- sofar.push(...job.changes.map((id) => byId.get(id)));
46
- const wrong = inconsistencies(parseTree(applyChanges(base, sofar)), endpoints);
47
- if (wrong.length > 0) {
48
- problems.push(`After "${job.title}" the spec does not hold together - a later job defines what it uses:\n${wrong.map((error) => ` - ${error}`).join("\n")}`);
49
- return problems;
50
- }
51
- }
52
- if (applyChanges(base, sofar) !== serializeTree(input.current)) {
53
- problems.push("Applied in order, the jobs do not end exactly on the spec as it is now.");
54
- }
55
- return problems;
56
- }
57
- /** A checked draft, as the queue runs it: each job's diff and the spec it leaves. */
58
- export function stepsOf(input, draft) {
59
- const byId = new Map(netChanges(input.base, input.current).map((change) => [change.id, change]));
60
- const layout = layoutOf(input.specText);
61
- let before = serializeTree(input.base);
62
- const sofar = [];
63
- return draft.map((job) => {
64
- const changes = job.changes.map((id) => byId.get(id));
65
- sofar.push(...changes);
66
- const after = applyChanges(serializeTree(input.base), sofar);
67
- const testPlain = input.track === "conformance" && input.testPlainPath !== undefined && input.moduleName !== undefined ? { module: input.moduleName, pathOf: input.testPlainPath } : undefined;
68
- const step = makeStep(job.title, job.reason, changes, before, after, input.specFile, layout, testPlain);
69
- before = after;
70
- return { ...job, step };
71
- });
72
- }
73
- export const MAX_SPECS_PER_JOB = 3;
74
- /** The most a pulse's title is - in words, and in characters - however it was made: a host shows it as its heading. */
75
- export const TITLE_WORDS = 10;
76
- export const TITLE_CHARS = 70;
77
- /** Whether a title is within `TITLE_WORDS` and `TITLE_CHARS`. */
78
- function fitsTitle(title) {
79
- return title.trim().split(/\s+/).length <= TITLE_WORDS && title.trim().length <= TITLE_CHARS;
80
- }
81
- /** Whether a title names the act of regenerating - "regenerate", "Regenerate the scenery" - rather than the change. */
82
- function namesTheAct(title) {
83
- return /^regenerat(e|es|ed|ing)\b/i.test(title.trim());
84
- }
85
- /** What is wrong with one title, or nothing: empty, too long, or naming the act rather than the change. */
86
- function titleProblem(title, empty) {
87
- if (title.trim() === "")
88
- return empty;
89
- if (!fitsTitle(title))
90
- return `"${title}" is too long for a title: at most ${TITLE_WORDS} words and ${TITLE_CHARS} characters.`;
91
- if (namesTheAct(title))
92
- return `"${title}" names the act of regenerating: say what the pulse changes in the software.`;
93
- return undefined;
94
- }
95
- /**
96
- * A title held to `TITLE_WORDS` and `TITLE_CHARS` - or less, for room beside it - cut at a word, with an ellipsis. Text
97
- * cut already is cut again without stacking a second: several first lines joined, each cut, end on one ellipsis.
98
- */
99
- export function shortTitle(text, chars = TITLE_CHARS, words = TITLE_WORDS) {
100
- const all = text.trim().split(/\s+/).filter((word) => word !== "");
101
- let cut = all.slice(0, words).join(" ");
102
- if (all.length <= words && cut.length <= chars)
103
- return cut;
104
- cut = cut.replace(/[\s,.;:…-]+$/, "");
105
- if (cut.length > chars - 1)
106
- cut = cut.slice(0, chars - 1).replace(/\s+\S*$/, "") || cut.slice(0, chars - 1);
107
- return `${cut.replace(/[\s,.;:…-]+$/, "")}…`;
108
- }
109
- export const MAX_LINES_PER_JOB = 120;
110
- /** How often an answer that does not hold goes back to its agent before the plan falls back. */
111
- const RETRIES = 2;
112
- /**
113
- * An item's text, from its serialized line: its markdown - a functional spec's body, its func-id given beside it - and
114
- * its scenarios, each under its scenario-id, where the tree has them: the conformance track's.
115
- */
116
- function textOf(change) {
117
- return textOfLine(change.after ?? change.before ?? "");
118
- }
119
- /** An item's text from its line in a tree: its markdown, and its scenarios, if any. */
120
- function textOfLine(line) {
121
- try {
122
- const item = JSON.parse(line);
123
- const scenarios = [...(item[CONFORMANCE_TESTS] ?? []), ...(item[ACCEPTANCE_TESTS] ?? [])].map((scenario) => `# ${scenario.id ?? ""}\n${scenario.text ?? ""}`);
124
- return [item.markdown ?? "", ...scenarios].filter(Boolean).join("\n");
125
- }
126
- catch {
127
- return line;
128
- }
129
- }
130
- /** How many lines a change reads as: what a job's size is counted in. */
131
- function linesOf(change) {
132
- return textOf(change).split("\n").length;
133
- }
134
- /** The concepts a text names, reserved ones left out. */
135
- function namedIn(text) {
136
- return extractConceptsFromSpecText(text).filter((concept) => !DEFAULT_CONCEPTS.has(concept));
137
- }
138
- /** The concept a definition defines, from its text. */
139
- function definedBy(text) {
140
- return extractConceptsFromDefinition(text)[0];
141
- }
142
- /**
143
- * What is wrong with a grouping: every new functional spec once, in order, next to each other, none too big - and
144
- * every change to what is built placed once, with a group or first. A functional spec changed counts in its group: it
145
- * is built as the new ones are. One taken out builds nothing, and does not.
146
- */
147
- export function groupProblems(specs, answer, maxSpecs = MAX_SPECS_PER_JOB, built = []) {
148
- const problems = newSpecProblems(specs, answer, maxSpecs, built);
149
- const placed = new Map();
150
- for (const entry of answer.built ?? []) {
151
- if (!built.some((change) => change.number === entry.change))
152
- problems.push(`There is no change ${entry.change} to what is built.`);
153
- placed.set(entry.change, (placed.get(entry.change) ?? 0) + 1);
154
- const valid = entry.to === "first" || (Number.isInteger(entry.to) && entry.to >= 1 && entry.to <= answer.groups.length);
155
- if (!valid)
156
- problems.push(`Change ${entry.change} to what is built goes to ${entry.to}, which is no group: a group's number, or "first".`);
157
- }
158
- for (const change of built) {
159
- const times = placed.get(change.number) ?? 0;
160
- if (times === 0)
161
- problems.push(`change ${change.number} to what is built is not placed: every one goes with a group, or "first".`);
162
- if (times > 1)
163
- problems.push(`Change ${change.number} to what is built is placed ${times} times: once.`);
164
- }
165
- return problems;
166
- }
167
- /** How many functional specs a group builds: its new ones, and those changed that go with it. */
168
- function builtIn(group, answer, built) {
169
- const changed = new Set(built.filter((change) => change.kind !== "taken out" && change.what === "functional spec").map((change) => change.number));
170
- return (answer.built ?? []).filter((entry) => entry.to === group && changed.has(entry.change)).length;
171
- }
172
- function newSpecProblems(specs, answer, maxSpecs, built) {
173
- const problems = [];
174
- const numbers = specs.map((spec) => spec.number);
175
- const given = answer.groups.flatMap((group) => group.specs);
176
- if (given.join(",") !== numbers.join(","))
177
- problems.push(`The groups must hold every new functional spec once, in the order the spec has them: ${numbers.join(", ")}. They hold ${given.join(", ") || "none"}.`);
178
- // Next to each other: in the same module, one in the place after the other there.
179
- const byNumber = new Map(specs.map((spec) => [spec.number, spec]));
180
- const nextTo = (a, b) => {
181
- const first = byNumber.get(a);
182
- const second = byNumber.get(b);
183
- if (first === undefined || second === undefined)
184
- return b === a + 1;
185
- return first.module === second.module && (second.place ?? second.number) === (first.place ?? first.number) + 1;
186
- };
187
- answer.groups.forEach((group, index) => {
188
- if (group.specs.length === 0)
189
- problems.push(`"${group.title}" has no functional spec.`);
190
- const changed = builtIn(index + 1, answer, built);
191
- if (group.specs.length + changed > maxSpecs) {
192
- problems.push(changed === 0
193
- ? `"${group.title}" has ${group.specs.length} functional specs - at most ${maxSpecs}.`
194
- : `"${group.title}" has ${group.specs.length + changed} functional specs to build - ${group.specs.length} new, ${changed} changed - at most ${maxSpecs}.`);
195
- }
196
- for (let i = 1; i < group.specs.length; i += 1) {
197
- if (!nextTo(group.specs[i - 1], group.specs[i]))
198
- problems.push(`"${group.title}" groups ${group.specs.join(", ")}: only functional specs next to each other in the same module go together.`);
199
- }
200
- const wrong = titleProblem(group.title, "Every group needs a title.");
201
- if (wrong !== undefined)
202
- problems.push(wrong);
203
- });
204
- return problems;
205
- }
206
- /** What is wrong with a titling: every group titled once, by its number, none empty, none too long, none naming the act. */
207
- export function titleProblems(groups, answer) {
208
- const problems = [];
209
- const numbers = groups.map((group) => group.number);
210
- const seen = new Map();
211
- for (const entry of answer.titles) {
212
- if (!numbers.includes(entry.group))
213
- problems.push(`There is no group ${entry.group}.`);
214
- seen.set(entry.group, (seen.get(entry.group) ?? 0) + 1);
215
- const wrong = titleProblem(entry.title, `Group ${entry.group} needs a title.`);
216
- if (wrong !== undefined)
217
- problems.push(wrong);
218
- }
219
- for (const number of numbers) {
220
- const times = seen.get(number) ?? 0;
221
- if (times === 0)
222
- problems.push(`Group ${number} has no title: every group is titled.`);
223
- if (times > 1)
224
- problems.push(`Group ${number} is titled ${times} times: once.`);
225
- }
226
- return problems;
227
- }
228
- /** What is wrong with a placement: every new req once, each where there is such a job. */
229
- export function placeProblems(input, answer) {
230
- const problems = [];
231
- const valid = (to) => to === "all" || (to === "built" ? input.built : Number.isInteger(to) && to >= 1 && to <= input.groups.length);
232
- for (const [kind, reqs, placed] of [
233
- ["implementation req", input.implementationReqs, answer.implementationReqs],
234
- ["test req", input.testReqs, answer.testReqs],
235
- ]) {
236
- const numbers = reqs.map((req) => req.number);
237
- const seen = new Map();
238
- for (const entry of placed) {
239
- if (!numbers.includes(entry.req))
240
- problems.push(`There is no ${kind} ${entry.req}.`);
241
- seen.set(entry.req, (seen.get(entry.req) ?? 0) + 1);
242
- if (!valid(entry.to))
243
- problems.push(`${kind} ${entry.req} goes to ${entry.to}, which is no job: a group's number, "all"${input.built ? ', or "built"' : ""}.`);
244
- }
245
- for (const number of numbers) {
246
- const times = seen.get(number) ?? 0;
247
- if (times === 0)
248
- problems.push(`${kind} ${number} is not placed: every one goes somewhere.`);
249
- if (times > 1)
250
- problems.push(`${kind} ${number} is placed ${times} times: once.`);
251
- }
252
- }
253
- return problems;
254
- }
255
- /** Whether a change is to a functional spec marked to regenerate again: built, and regenerated again - cut into jobs as new work is. */
256
- function regeneratesAgain(change) {
257
- if ((change.section !== FUNCTIONAL_REQUIREMENTS && change.section !== REQUIRED_FUNCTIONAL_SPECS) || change.kind !== "change" || change.before === undefined)
258
- return false;
259
- try {
260
- return marksRegenerateAgain(JSON.parse(change.before));
261
- }
262
- catch {
263
- return false;
264
- }
265
- }
266
- /** The functional specs added at the end: new work. One added anywhere else changes what is built on. */
267
- function newSpecsOf(net, current) {
268
- const count = (current[FUNCTIONAL_REQUIREMENTS] ?? []).length;
269
- const added = net.filter((change) => change.section === FUNCTIONAL_REQUIREMENTS && change.kind === "add").sort((a, b) => a.position - b.position);
270
- const tail = [];
271
- for (let at = count; at >= 1; at -= 1) {
272
- const change = added.find((candidate) => candidate.position === at);
273
- if (change === undefined)
274
- break;
275
- tail.unshift(change);
276
- }
277
- return tail;
278
- }
279
- /**
280
- * The definitions each chunk uses, in order: the concepts its items name, and those its definitions name in turn -
281
- * each definition with the first chunk that uses it. Those nothing uses go with the last.
282
- */
283
- function placeDefinitions(chunks, definitions) {
284
- const byConcept = new Map();
285
- for (const definition of definitions)
286
- for (const concept of definedBy(textOf(definition)))
287
- byConcept.set(concept, definition);
288
- const placed = new Set();
289
- for (const chunk of chunks) {
290
- chunk.definitions = [];
291
- const queue = [...chunk.specs, ...chunk.reqs, ...(chunk.built ?? []), ...(chunk.joined ?? [])].flatMap((change) => namedIn(textOf(change)));
292
- for (let concept = queue.shift(); concept !== undefined; concept = queue.shift()) {
293
- const definition = byConcept.get(concept);
294
- if (definition === undefined || placed.has(definition))
295
- continue;
296
- placed.add(definition);
297
- chunk.definitions.push(definition);
298
- queue.push(...namedIn(textOf(definition)));
299
- }
300
- }
301
- const left = definitions.filter((definition) => !placed.has(definition));
302
- if (left.length > 0 && chunks.length > 0)
303
- chunks.at(-1).definitions.push(...left);
304
- }
305
- /**
306
- * The lines of a chunk that a split can move to a later job: its functional specs and the definitions they bring. Its
307
- * reqs stay with the first job of the split whatever happens, so they never decide one.
308
- */
309
- function movableSize(chunk) {
310
- return [...chunk.specs, ...chunk.definitions].reduce((total, change) => total + linesOf(change), 0);
311
- }
312
- function sizeOf(chunk) {
313
- return [...chunk.specs, ...chunk.definitions, ...chunk.reqs, ...(chunk.built ?? []), ...(chunk.joined ?? [])].reduce((total, change) => total + linesOf(change), 0);
314
- }
315
- /**
316
- * The draft a chunking is: a job per chunk, its changes in the order the net has them. A job runs as the queued job
317
- * whose own change it carries - the first of them not taken by an earlier one - so a job keeps its id, its notes and
318
- * its conformance job where the plan leaves its change where it was.
319
- */
320
- function draftOf(chunks, net) {
321
- return chunks
322
- .map((chunk) => {
323
- const ids = new Set([...chunk.specs, ...chunk.definitions, ...chunk.reqs, ...(chunk.built ?? []), ...(chunk.joined ?? [])].map((change) => change.id));
324
- return { chunk, changes: net.filter((change) => ids.has(change.id)).map((change) => change.id) };
325
- })
326
- .filter((entry) => entry.changes.length > 0)
327
- .map((entry) => ({
328
- // However the title was made - an agent's, a spec's first line, several joined - it is held to the limit.
329
- title: shortTitle(entry.chunk.title),
330
- reason: entry.chunk.built !== undefined
331
- ? "what is built already, changed"
332
- : entry.chunk.specs.length > 0 && entry.chunk.specs.every(regeneratesAgain)
333
- ? "functional specs regenerated again"
334
- : "new work, cut from its functional specs",
335
- changes: entry.changes,
336
- }));
337
- }
338
- /** A spec's first line, as a group's title when no agent gave one. */
339
- function titleOf(change) {
340
- return shortTitle(firstLineOf(change));
341
- }
342
- function firstLineOf(change) {
343
- return textOf(change).split("\n")[0].replace(/^-\s*/, "");
344
- }
345
- const isFunctionalSpec = (change) => change.section === FUNCTIONAL_REQUIREMENTS || change.section === REQUIRED_FUNCTIONAL_SPECS;
346
- /**
347
- * The title of a pulse that makes the whole of an edit, when no agent gave one: the first line of the first functional
348
- * spec it changes - else of its first change - and how many more it makes. Never the bare word.
349
- */
350
- export function editTitle(changes) {
351
- const [first, ...rest] = [...changes.filter(isFunctionalSpec), ...changes.filter((change) => !isFunctionalSpec(change))];
352
- if (first === undefined)
353
- return "No change";
354
- const line = first.kind === "remove" ? `Takes out: ${firstLineOf(first)}` : firstLineOf(first);
355
- if (rest.length === 0)
356
- return shortTitle(line);
357
- const more = `, and ${rest.length} more`;
358
- return `${shortTitle(line, TITLE_CHARS - more.length, TITLE_WORDS - 3).replace(/[.,;:]+$/, "")}${more}`;
359
- }
360
- /**
361
- * The title of the pulse that changes what is built, first: what it changes, by name - the functional specs' func-ids,
362
- * else the kinds of item - so the person reads which, not "changes to what is built".
363
- */
364
- export function builtTitle(changes) {
365
- const ids = [...new Set(changes.filter(isFunctionalSpec).map(funcIdOf).filter((id) => id !== undefined))];
366
- if (ids.length > 0) {
367
- const named = ids.slice(0, 2).join(", ");
368
- const others = changes.length - changes.filter(isFunctionalSpec).length;
369
- const more = ids.length - 2 + others;
370
- return `Changes to ${named}${more > 0 ? `, and ${more} more` : ""}`;
371
- }
372
- const kinds = [...new Set(changes.map((change) => WHAT[change.section] ?? change.section))].map((kind) => `${kind}s`);
373
- return `Changes to the ${kinds.length > 1 ? `${kinds.slice(0, -1).join(", ")} and ${kinds.at(-1)}` : kinds[0]}`;
374
- }
375
- /** A change as the title agent is shown it: what it is, how it changes, its text now - and before, for a change. */
376
- function titleChangeOf(change) {
377
- return {
378
- kind: change.kind === "change" ? "changed" : change.kind === "remove" ? "taken out" : "added",
379
- what: WHAT[change.section] ?? change.section,
380
- text: textOf(change),
381
- ...(change.kind === "change" && change.before !== undefined ? { before: textOfLine(change.before) } : {}),
382
- };
383
- }
384
- /**
385
- * Cut the queue's work - from `input.base` to `input.current` - into jobs, as the three steps say. Returns the draft
386
- * the work loop runs: checked (checkDraft), or, when nothing holds, the whole work as one job. `notes` is given where
387
- * the plan fell back - an answer that was not given or did not hold, a group split for its size - for the conversation
388
- * to say, rather than guess.
389
- */
390
- /** A planner agent that failed: the plan falls back, and the ledger says why. */
391
- function plannerFailed(step, error) {
392
- record({ kind: "planner.failed", step, error: firstLine(error instanceof Error ? error.message : String(error), 300) });
393
- return undefined;
394
- }
395
- export async function planChunks(input, agents, notes) {
396
- if (input.track !== "conformance")
397
- return cut(input, agents, notes);
398
- // The conformance tests are grouped by the harness, as one job as far as the guardrail lets: an agent only titles them.
399
- return anchored(await cut(input, agents, notes), netChanges(input.base, input.current));
400
- }
401
- /**
402
- * A conformance plan, every job of it testing a functional spec: a job that touches none - reqs or definitions alone -
403
- * goes into the next job that does, or, with none after it, the last before it. Work that touches no functional spec
404
- * at all - test reqs changed, say - stays as it is: it is mechanical, and nothing else.
405
- */
406
- function anchored(draft, net) {
407
- const sectionOf = new Map(net.map((change) => [change.id, change.section]));
408
- const testsASpec = (job) => job.changes.some((id) => sectionOf.get(id) === FUNCTIONAL_REQUIREMENTS || sectionOf.get(id) === REQUIRED_FUNCTIONAL_SPECS);
409
- if (!draft.some(testsASpec))
410
- return draft;
411
- const jobs = [];
412
- let carried = [];
413
- for (const job of draft) {
414
- if (!testsASpec(job)) {
415
- carried.push(...job.changes);
416
- continue;
417
- }
418
- jobs.push({ ...job, changes: [...carried, ...job.changes] });
419
- carried = [];
420
- }
421
- if (carried.length > 0)
422
- jobs[jobs.length - 1] = { ...jobs.at(-1), changes: [...jobs.at(-1).changes, ...carried] };
423
- return jobs;
424
- }
425
- /**
426
- * How the conformance tests are cut, with no agent: every functional spec tested in one job - those of the modules below
427
- * and the codebase's own alike, the tip's suite holding the chain's - a new job begun where the next functional spec
428
- * would take the job's functional specs and the definitions they bring past `maxLines`; or, `separately`, a job a
429
- * functional spec, as the person asked.
430
- * `size`: the movable lines of the last group of a grouping, its definitions placed.
431
- */
432
- function conformanceGroups(specs, separately, maxLines, size, titleOfSpec) {
433
- const groups = [];
434
- for (const spec of specs) {
435
- const last = groups.at(-1);
436
- if (!separately && last !== undefined) {
437
- const trial = [...groups.slice(0, -1), { specs: [...last.specs, spec.number] }].map((group) => ({ ...group, title: "" }));
438
- if (size(trial) <= maxLines) {
439
- last.specs.push(spec.number);
440
- continue;
441
- }
442
- }
443
- groups.push({ specs: [spec.number] });
444
- }
445
- return groups.map((group) => ({ specs: group.specs, title: group.specs.map(titleOfSpec).join("; ") }));
446
- }
447
- /** What an item of a section is, in the words the grouping agent is told it in. */
448
- const WHAT = {
449
- [FUNCTIONAL_REQUIREMENTS]: "functional spec",
450
- [REQUIRED_FUNCTIONAL_SPECS]: "functional spec",
451
- [DEFINITIONS]: "definition",
452
- [NON_FUNCTIONAL_REQUIREMENTS]: "implementation req",
453
- [TEST_REQUIREMENTS]: "test req",
454
- };
455
- /** A change to what is built as the grouping agent is shown it: what it is, how it changes, and its text as it is now - or was, taken out. */
456
- function builtChangeOf(change, number, moduleName) {
457
- const id = funcIdOf(change);
458
- let module;
459
- if (change.section === REQUIRED_FUNCTIONAL_SPECS) {
460
- try {
461
- module = JSON.parse(change.after ?? change.before ?? "{}").module;
462
- }
463
- catch {
464
- // Not an item with a module.
465
- }
466
- }
467
- else if (change.section === FUNCTIONAL_REQUIREMENTS)
468
- module = moduleName;
469
- return {
470
- number,
471
- kind: change.kind === "change" ? "changed" : change.kind === "remove" ? "taken out" : "added",
472
- what: WHAT[change.section] ?? change.section,
473
- text: textOf(change),
474
- ...(id !== undefined ? { id } : {}),
475
- ...(module !== undefined ? { module } : {}),
476
- };
477
- }
478
- /** A functional spec's func-id, as the tree it is in has it - or nothing when it says none. */
479
- function funcIdOf(change) {
480
- for (const side of [change.after, change.before]) {
481
- if (side === undefined)
482
- continue;
483
- try {
484
- const id = JSON.parse(side).id;
485
- if (typeof id === "string" && id !== "")
486
- return id;
487
- }
488
- catch {
489
- // Not an item with an id.
490
- }
491
- }
492
- return undefined;
493
- }
494
- async function cut(input, agents, notes) {
495
- // How big a pulse may be: the config's, else the defaults.
496
- const { specs: maxSpecs, lines: maxLines } = input.limits ?? { specs: MAX_SPECS_PER_JOB, lines: MAX_LINES_PER_JOB };
497
- /** Where the plan fell back: in the activity, and in the notes. */
498
- const say = (text) => {
499
- reportActivity(` ${text}`);
500
- notes?.push(text);
501
- };
502
- const net = netChanges(input.base, input.current);
503
- if (net.length === 0)
504
- return [];
505
- // What is grouped into jobs: the functional specs regenerated again - the modules' below first, as the codebase is
506
- // built on them - and the codebase's own, regenerated again or new at the end, in the spec's order.
507
- // The conformance tests are written on the code as built: every functional spec of the chain whose tests are added,
508
- // changed or taken out is tested alike, wherever it is - so one edit, however mixed, is one pulse.
509
- const testedIn = (section) => net.filter((change) => change.section === section).sort((a, b) => a.position - b.position);
510
- const below = input.track === "conformance"
511
- ? testedIn(REQUIRED_FUNCTIONAL_SPECS)
512
- : net.filter((change) => regeneratesAgain(change) && change.section === REQUIRED_FUNCTIONAL_SPECS).sort((a, b) => a.position - b.position);
513
- const own = input.track === "conformance"
514
- ? testedIn(FUNCTIONAL_REQUIREMENTS)
515
- : [...net.filter((change) => regeneratesAgain(change) && change.section === FUNCTIONAL_REQUIREMENTS), ...newSpecsOf(net, input.current)].sort((a, b) => a.position - b.position);
516
- const specs = [...below, ...own];
517
- const inSpecs = new Set(specs);
518
- const isNew = (change, section) => change.section === section && change.kind === "add";
519
- const definitions = net.filter((change) => isNew(change, DEFINITIONS));
520
- const implementationReqs = net.filter((change) => isNew(change, NON_FUNCTIONAL_REQUIREMENTS));
521
- const testReqs = net.filter((change) => isNew(change, TEST_REQUIREMENTS));
522
- const placedByKind = new Set([...definitions, ...implementationReqs, ...testReqs]);
523
- // Added in another section - the required modules' functional specs of a first build: with the first job of the new work.
524
- const otherAdds = net.filter((change) => change.kind === "add" && !inSpecs.has(change) && !placedByKind.has(change) && change.section !== FUNCTIONAL_REQUIREMENTS);
525
- // Anything else changes what is built on - an edit, a removal, a functional spec built changed or put in among them.
526
- const builtChanges = net.filter((change) => !inSpecs.has(change) && !placedByKind.has(change) && !otherAdds.includes(change));
527
- // Shown to the grouping agent, which puts each with the new work it belongs with or first; unplaced, each goes first.
528
- const builtShown = builtChanges.map((change, index) => builtChangeOf(change, index + 1, input.moduleName));
529
- /** Where each change to what is built goes: with the group holding a new functional spec - by that spec's number - or first. */
530
- const builtTo = new Map();
531
- /**
532
- * The whole of the work in one job - an edit that only changes what is built, or one no plan of holds together -
533
- * titled by what the edit does: by the title agent, shown every change, else by what it changes first.
534
- */
535
- const wholeJob = async () => {
536
- const whole = { title: "", reason: "the whole of the work, in one job", changes: net.map((change) => change.id) };
537
- if (checkDraft(input, [whole]).length > 0)
538
- return [];
539
- const fallback = editTitle(net);
540
- if (agents?.title === undefined)
541
- return [{ ...whole, title: fallback }];
542
- reportStage("planning the queue: a title for the pulse");
543
- const toTitle = [{ number: 1, specs: [], changes: net.map(titleChangeOf) }];
544
- const answer = (await agents.title(toTitle, (given) => titleProblems(toTitle, given), input.track === "conformance" ? "conformance" : "code").catch((error) => plannerFailed("title", error))) ?? undefined;
545
- const problems = answer === undefined ? [] : titleProblems(toTitle, answer);
546
- if (answer !== undefined && problems.length === 0)
547
- return [{ ...whole, title: answer.titles[0].title.trim() }];
548
- record({ kind: "planner.fellBack", step: "title", why: answer === undefined ? "no title was given" : firstLine(problems.join(" "), 300) });
549
- say(answer === undefined ? `the title was not given - the pulse titled by what it changes first: "${fallback}"` : `the title did not hold (${problems.join(" ")}) - the pulse titled by what it changes first: "${fallback}"`);
550
- return [{ ...whole, title: fallback }];
551
- };
552
- if (specs.length === 0)
553
- return wholeJob();
554
- // 1. Which functional specs go together.
555
- reportStage(`planning the queue: which of the ${specs.length} functional spec${specs.length === 1 ? "" : "s"} to build go together`);
556
- const numbered = specs.map((change, index) => {
557
- const required = change.section === REQUIRED_FUNCTIONAL_SPECS ? JSON.parse(change.after ?? change.before) : undefined;
558
- return {
559
- number: index + 1,
560
- text: textOf(change),
561
- id: funcIdOf(change) ?? "",
562
- place: change.position,
563
- ...(required?.module !== undefined ? { module: required.module } : input.moduleName !== undefined ? { module: input.moduleName } : {}),
564
- ...(regeneratesAgain(change) ? { again: true } : {}),
565
- };
566
- });
567
- const bySpec = new Map(specs.map((change, index) => [index + 1, change]));
568
- const firstBuilt = () => builtChanges.filter((change) => (builtTo.get(change) ?? "first") === "first");
569
- const chunksFor = (list) => [
570
- ...(firstBuilt().length > 0 ? [{ title: builtTitle(firstBuilt()), specs: [], definitions: [], reqs: [], built: firstBuilt() }] : []),
571
- ...list.map((group) => ({
572
- title: group.title,
573
- specs: group.specs.map((number) => bySpec.get(number)),
574
- definitions: [],
575
- reqs: [],
576
- joined: builtChanges.filter((change) => group.specs.includes(builtTo.get(change))),
577
- })),
578
- ];
579
- const conformance = input.track === "conformance";
580
- // The conformance tests are grouped and their reqs placed by the harness: their agents are only asked for titles.
581
- const planners = conformance ? undefined : agents;
582
- /**
583
- * Groups titled for what their pulses do, by the title agent: those no agent titled - the conformance tests', a
584
- * grouping that fell back. When it fails, or its answer does not hold, they keep their first lines.
585
- */
586
- const titled = async (list) => {
587
- if (agents?.title === undefined || list.length === 0)
588
- return list;
589
- const track = conformance ? "conformance" : "code";
590
- reportStage(`planning the queue: a title for each of the ${list.length} pulse${list.length === 1 ? "" : "s"}`);
591
- const toTitle = list.map((group, index) => ({ number: index + 1, specs: group.specs.map((number) => textOf(bySpec.get(number))) }));
592
- const answer = (await agents.title(toTitle, (given) => titleProblems(toTitle, given), track).catch((error) => plannerFailed("title", error))) ?? undefined;
593
- const problems = answer === undefined ? [] : titleProblems(toTitle, answer);
594
- if (answer !== undefined && problems.length === 0)
595
- return list.map((group, index) => ({ ...group, title: answer.titles.find((entry) => entry.group === index + 1).title.trim() }));
596
- record({ kind: "planner.fellBack", step: "title", why: answer === undefined ? "no titles were given" : firstLine(problems.join(" "), 300) });
597
- say(answer === undefined ? "the titles were not given - each pulse titled by its functional specs' first lines" : `the titles did not hold (${problems.join(" ")}) - each pulse titled by its functional specs' first lines`);
598
- return list;
599
- };
600
- const grouped = conformance ? undefined : ((await agents?.group(numbered, (answer) => groupProblems(numbered, answer, maxSpecs, builtShown), maxSpecs, builtShown.length > 0 ? builtShown : undefined).catch((error) => plannerFailed("group", error))) ?? undefined);
601
- const holds = grouped !== undefined && groupProblems(numbered, grouped, maxSpecs, builtShown).length === 0;
602
- // The grouping holds: each change to what is built goes where it was placed.
603
- if (holds) {
604
- for (const entry of grouped.built ?? []) {
605
- const change = builtChanges[entry.change - 1];
606
- if (change !== undefined)
607
- builtTo.set(change, entry.to === "first" ? "first" : grouped.groups[entry.to - 1].specs[0]);
608
- }
609
- }
610
- const made = conformance
611
- ? conformanceGroups(numbered, input.separately === true, maxLines, (list) => {
612
- const trial = chunksFor(list);
613
- placeDefinitions(trial, definitions);
614
- return movableSize(trial.at(-1));
615
- }, (number) => titleOf(bySpec.get(number)))
616
- : grouped !== undefined && holds
617
- ? grouped.groups
618
- : numbered.map((spec, index) => ({ specs: [spec.number], title: titleOf(specs[index]) }));
619
- if (!conformance && agents !== undefined) {
620
- if (grouped === undefined) {
621
- record({ kind: "planner.fellBack", step: "group", why: "no grouping was given" });
622
- say("the grouping was not given - a functional spec a pulse");
623
- }
624
- else if (groupProblems(numbered, grouped, maxSpecs, builtShown).length > 0) {
625
- record({ kind: "planner.fellBack", step: "group", why: firstLine(groupProblems(numbered, grouped, maxSpecs, builtShown).join(" "), 300) });
626
- say(`the grouping did not hold (${groupProblems(numbered, grouped, maxSpecs, builtShown).join(" ")}) - a functional spec a pulse`);
627
- }
628
- }
629
- // Titled before the chunks are made of them: a group split for its size keeps its title, numbered.
630
- const groups = holds ? made : await titled(made);
631
- let chunks = chunksFor(groups);
632
- // 2. The definitions each group uses.
633
- placeDefinitions(chunks, definitions);
634
- // 3. Where each implementation req and test req goes.
635
- const newChunks = () => chunks.filter((chunk) => chunk.built === undefined);
636
- const builtChunk = () => chunks.find((chunk) => chunk.built !== undefined);
637
- let placement;
638
- if (implementationReqs.length + testReqs.length > 0) {
639
- reportStage(`planning the queue: where each of ${implementationReqs.length + testReqs.length} new req${implementationReqs.length + testReqs.length === 1 ? "" : "s"} goes`);
640
- const placeInput = {
641
- groups: newChunks().map((chunk, index) => ({ number: index + 1, title: chunk.title, specs: chunk.specs.map(textOf), definitions: chunk.definitions.map(textOf) })),
642
- built: chunks.some((chunk) => chunk.built !== undefined),
643
- implementationReqs: implementationReqs.map((change, index) => ({ number: index + 1, text: textOf(change) })),
644
- testReqs: testReqs.map((change, index) => ({ number: index + 1, text: textOf(change) })),
645
- };
646
- const answer = (await planners?.place(placeInput, (given) => placeProblems(placeInput, given)).catch((error) => plannerFailed("place", error))) ?? undefined;
647
- placement = answer !== undefined && placeProblems(placeInput, answer).length === 0 ? answer : undefined;
648
- if (placement === undefined && planners !== undefined)
649
- record({ kind: "planner.fellBack", step: "place", why: answer === undefined ? "no placement was given" : firstLine(placeProblems(placeInput, answer).join(" "), 300) });
650
- if (placement === undefined && planners !== undefined)
651
- say("the placement did not hold - every implementation req with the first pulse, every test req with the first conformance pulse");
652
- }
653
- /** A req's chunk: its group, the built job, or the first job of the new work for "all". */
654
- const chunkOf = (to) => (to === "built" ? builtChunk() : to === "all" ? newChunks()[0] : newChunks()[to - 1]);
655
- const place = () => {
656
- for (const chunk of chunks)
657
- chunk.reqs = [];
658
- implementationReqs.forEach((change, index) => chunkOf(placement?.implementationReqs.find((entry) => entry.req === index + 1)?.to ?? "all").reqs.push(change));
659
- testReqs.forEach((change, index) => chunkOf(placement?.testReqs.find((entry) => entry.req === index + 1)?.to ?? 1).reqs.push(change));
660
- newChunks()[0]?.reqs.push(...otherAdds);
661
- // What the reqs name is defined with them, or before.
662
- placeDefinitions(chunks, definitions);
663
- };
664
- place();
665
- // A group too big to render well is split - into as few pulses as fit, its functional specs kept together in runs as
666
- // long as the limit lets, rather than a functional spec a pulse: most of the grouping holds. Its reqs go with the first.
667
- if (newChunks().some((chunk) => chunk.specs.length > 1 && movableSize(chunk) > maxLines)) {
668
- /** The size of the group starting at `first` in a trial grouping, its definitions placed as they would be. */
669
- const sizeIn = (list, first) => {
670
- const trial = chunksFor(list);
671
- placeDefinitions(trial, definitions);
672
- const chunk = trial.find((candidate) => candidate.specs[0] === bySpec.get(first));
673
- return chunk !== undefined ? movableSize(chunk) : 0;
674
- };
675
- const split = [];
676
- groups.forEach((group, at) => {
677
- const chunk = newChunks().find((candidate) => candidate.specs[0] === bySpec.get(group.specs[0]));
678
- if (chunk === undefined || chunk.specs.length < 2 || movableSize(chunk) <= maxLines) {
679
- split.push(group);
680
- return;
681
- }
682
- const after = groups.slice(at + 1);
683
- const runs = [];
684
- let run = [group.specs[0]];
685
- for (const next of group.specs.slice(1)) {
686
- const longer = [...run, next];
687
- const trial = [...split, ...runs.map((specs) => ({ specs, title: "" })), { specs: longer, title: "" }, ...after];
688
- if (sizeIn(trial, longer[0]) <= maxLines)
689
- run = longer;
690
- else {
691
- runs.push(run);
692
- run = [next];
693
- }
694
- }
695
- runs.push(run);
696
- say(`"${group.title}" is past ${maxLines} lines with its definitions and reqs - split into ${runs.length} pulses`);
697
- runs.forEach((specs, index) => split.push({
698
- specs,
699
- title: `${shortTitle(group.title, TITLE_CHARS - 9, TITLE_WORDS - 3)} (${index + 1} of ${runs.length})`,
700
- }));
701
- });
702
- const before = placement;
703
- // A req placed with a group that split goes with the first functional spec of it.
704
- const groupOfSpec = new Map(split.map((group, index) => [group.specs[0], index + 1]));
705
- const remap = (to) => (typeof to === "number" ? (groupOfSpec.get(groups[to - 1].specs[0]) ?? to) : to);
706
- placement = before !== undefined ? { implementationReqs: before.implementationReqs.map((entry) => ({ ...entry, to: remap(entry.to) })), testReqs: before.testReqs.map((entry) => ({ ...entry, to: remap(entry.to) })) } : undefined;
707
- groups.splice(0, groups.length, ...split);
708
- chunks = chunksFor(groups);
709
- place();
710
- }
711
- // What is about everything, the first group cannot carry within the limit: a job of its own ahead of it, when it holds on its own.
712
- const first = newChunks()[0];
713
- if (first !== undefined && sizeOf(first) > maxLines) {
714
- const everything = implementationReqs.filter((change, index) => (placement?.implementationReqs.find((entry) => entry.req === index + 1)?.to ?? "all") === "all");
715
- const standalone = everything.filter((change) => namedIn(textOf(change)).every((concept) => definitions.every((definition) => !definedBy(textOf(definition)).includes(concept))));
716
- if (standalone.length > 0) {
717
- first.reqs = first.reqs.filter((change) => !standalone.includes(change));
718
- chunks.splice(chunks.indexOf(first), 0, { title: "What the whole of it is built with", specs: [], definitions: [], reqs: standalone });
719
- }
720
- }
721
- const draft = draftOf(chunks, net);
722
- if (checkDraft(input, draft).length === 0)
723
- return draft;
724
- // It does not hold together: a functional spec a job, every req with the first.
725
- say(`the plan did not hold together (${checkDraft(input, draft)[0]?.slice(0, 120)}) - a functional spec a pulse`);
726
- placement = undefined;
727
- builtTo.clear();
728
- groups.splice(0, groups.length, ...(await titled(numbered.map((spec, index) => ({ specs: [spec.number], title: titleOf(specs[index]) })))));
729
- chunks = chunksFor(groups);
730
- place();
731
- const simple = draftOf(chunks, net);
732
- if (checkDraft(input, simple).length === 0)
733
- return simple;
734
- return wholeJob();
735
- }
736
- // ---------------------------------------------------------------------------------------------
737
- // The agents.
738
- export function groupPrompt(specs, maxSpecs = MAX_SPECS_PER_JOB, built = []) {
739
- return [
740
- "You plan how new work on a codebase is built: which of its new functional specs are built together, in one job.",
741
- "",
742
- "Each job is regenerated by a coding agent, reviewed and tested, then the next - fewer, fuller jobs: each job costs a",
743
- "coding session, a test run and a review. So group by default: what builds one feature goes together - the feature,",
744
- `its edge cases, and the functional specs that build on it - up to ${maxSpecs}: a component and the parts only it uses`,
745
- "(a timeout handler, a retry handler and the executor that runs a function through both), an endpoint and the one",
746
- "that undoes it, a record, the list of it and its filters. Keep a functional spec alone only when it is truly",
747
- "independent - nothing next to it builds on it or is part of the same thing - or when it is very large on its own.",
748
- "Never group specs only because they are of the same kind.",
749
- "",
750
- "Only functional specs next to each other in the same module - one in the place after the other there - go together, and they stay in the order given: the",
751
- `order is what each is built on. Give each group a title that says what it builds - at most ${TITLE_WORDS} words and ${TITLE_CHARS}`,
752
- "characters: it heads the group's pulse where the person watches the work, and a longer one is cut short there.",
753
- "",
754
- "The specification is split into modules - a ***plain matter, not how the code is laid out. A functional spec has a",
755
- "func-id, unique in its module: each below is given with its module, its func-id, its place among the module's functional specs, and a number of its own to answer with.",
756
- "",
757
- ...(specs.some((spec) => spec.again === true)
758
- ? [
759
- "Those marked again=\"true\" are built already, and are regenerated again - rewritten, doing what they say. Group them as",
760
- "you would new ones, by what they build.",
761
- "",
762
- ]
763
- : []),
764
- "The functional specs to build:",
765
- "",
766
- ...specs.map((spec) => `<functional spec number="${spec.number}"${spec.module !== undefined ? ` module="${spec.module}"` : ""} id="${spec.id ?? spec.number}"${spec.place !== undefined ? ` place="${spec.place}"` : ""}${spec.again === true ? ' again="true"' : ""}>\n${spec.text.trim()}\n</functional spec>`),
767
- "",
768
- ...(built.length > 0
769
- ? [
770
- "The same work changes what is built already - below. Place each change: with the group of new functional specs",
771
- 'it belongs with, by the group\'s number, or "first" - in a pulse of its own, before the new work.',
772
- "",
773
- "- With a group, by default, when it is about the same thing as the group's new functional specs: one they build",
774
- " on changed, or one of the same feature changed or taken out. One pulse costs less than two.",
775
- '- "first" when it reshapes what the new work is built on - a concept many functional specs use redefined, a',
776
- " functional spec others rely on taken out, a large rewrite - so the new work is built on code already changed and",
777
- ' tested. "first" too when it has nothing to do with any group, or is too large to share a pulse.',
778
- `- A functional spec changed counts toward its group's ${maxSpecs}; one taken out builds nothing, and does not.`,
779
- "",
780
- "The changes to what is built:",
781
- "",
782
- ...built.map((change) => `<change number="${change.number}" kind="${change.kind}" what="${change.what}"${change.module !== undefined ? ` module="${change.module}"` : ""}${change.id !== undefined ? ` id="${change.id}"` : ""}>\n${change.text.trim()}\n</change>`),
783
- "",
784
- ]
785
- : []),
786
- `Call submit_groups once, with every one of them in a group${built.length > 0 ? ", and every change to what is built placed" : ""}.`,
787
- ].join("\n");
788
- }
789
- export function placePrompt(input) {
790
- return [
791
- "You plan how new work on a codebase is built. Its new functional specs are in groups, each a job, built in order,",
792
- "each with the definitions it uses. Place each new implementation req and test req in the job it belongs to.",
793
- "",
794
- "- An implementation req goes with the group it is about - how that part is built, stored, secured. One about",
795
- ' everything - the language, the framework, how every part is laid out - goes to "all": with the first job,',
796
- " where the codebase starts.",
797
- "- A test req goes with the first group whose conformance tests need it; one about all the tests to \"all\".",
798
- ...(input.built ? ['- "built" is the job that changes what is built already, and goes first: a req about the code there already goes there.'] : []),
799
- "",
800
- ...input.groups.map((group) => [
801
- // A title that is only its first spec's first line is not said twice.
802
- group.specs[0] !== undefined && group.specs[0].includes(group.title.trim().replace(/\.$/, "")) ? `<group number="${group.number}">` : `<group number="${group.number}" title="${group.title}">`,
803
- ...group.specs.map((spec) => `<functional spec>\n${spec.trim()}\n</functional spec>`),
804
- ...group.definitions.map((definition) => `<definition>\n${definition.trim()}\n</definition>`),
805
- "</group>",
806
- ].join("\n")),
807
- "",
808
- ...(input.implementationReqs.length > 0 ? ["The new implementation reqs:", ...input.implementationReqs.map((req) => `<implementation req number="${req.number}">\n${req.text.trim()}\n</implementation req>`), ""] : []),
809
- ...(input.testReqs.length > 0 ? ["The new test reqs:", ...input.testReqs.map((req) => `<test req number="${req.number}">\n${req.text.trim()}\n</test req>`), ""] : []),
810
- "Call submit_placement once, with every one of them placed once.",
811
- ].join("\n");
812
- }
813
- export function titlePrompt(groups, track) {
814
- return [
815
- track === "conformance"
816
- ? "You title the pulses that test a codebase. Each group below is a pulse: it writes and runs the conformance tests for its functional specs - black-box tests of the code as built."
817
- : "You title the pulses that build a codebase. Each group below is a pulse: a coding agent builds its functional specs into the code.",
818
- "",
819
- track === "conformance"
820
- ? "Give each group a title that says what its pulse tests - the behaviour, not the spec's wording."
821
- : "Give each group a title that says what its pulse builds - the feature, not the spec's wording.",
822
- `At most ${TITLE_WORDS} words and ${TITLE_CHARS} characters: it heads the pulse where the person watches the work, and a longer one is cut short there.`,
823
- ...(groups.some((group) => group.changes !== undefined)
824
- ? [
825
- "",
826
- "A group of changes is one edit to software already built: its pulse makes the whole of it. Title it by what the",
827
- "edit does to the software, briefly - \"Expired links answer 410 and the stats page goes\", \"Greeter greets by",
828
- "name\". A definition or an implementation req changed is titled by what it changes in what is built - \"Links are",
829
- "kept for 30 days\" - never by the section it is in.",
830
- ]
831
- : []),
832
- "Name the change, never the act: \"regenerate\", \"Regenerate the scenery\" and \"Changes\" are not titles.",
833
- "",
834
- ...groups.map((group) => [
835
- `<group number="${group.number}">`,
836
- ...group.specs.map((spec) => `<functional spec>\n${spec.trim()}\n</functional spec>`),
837
- ...(group.changes ?? []).map((change) => change.before !== undefined
838
- ? `<change kind="${change.kind}" what="${change.what}">\n<before>\n${change.before.trim()}\n</before>\n<now>\n${change.text.trim()}\n</now>\n</change>`
839
- : `<change kind="${change.kind}" what="${change.what}">\n${change.text.trim()}\n</change>`),
840
- "</group>",
841
- ].join("\n")),
842
- "",
843
- "Call submit_titles once, with a title for every group, by its number.",
844
- ].join("\n");
845
- }
846
- const TargetSchema = Type.Union([Type.Number(), Type.Literal("all"), Type.Literal("built")]);
847
- /** Ask one step of an agent, and ask again with what was wrong, until it holds or the retries are spent. */
848
- async function askStep(options) {
849
- let answer;
850
- const tool = options.tool((given) => (answer = given));
851
- const session = await createExecutor({ cwd: options.cwd, customTools: [tool], tools: [tool.name], model: options.model, label: options.label, role: "planner", task: options.task, budget: { calls: 4, finish: [tool.name] } });
852
- try {
853
- await ask(session, BEGIN);
854
- for (let again = 0; again < RETRIES; again += 1) {
855
- if (answer !== undefined && options.check(answer).length === 0)
856
- return answer;
857
- const problems = answer === undefined ? [`You did not call ${tool.name}.`] : options.check(answer);
858
- answer = undefined;
859
- await ask(session, `That does not hold:\n- ${problems.join("\n- ")}\n\nCall ${tool.name} again, with it fixed.`);
860
- }
861
- return answer;
862
- }
863
- finally {
864
- session.dispose();
865
- }
866
- }
867
- /** The chunking's agents, on a model - fresh for every plan. */
868
- export function llmChunkAgents(options) {
869
- const label = options.label ?? "queue planner";
870
- return {
871
- group: (specs, check, maxSpecs, built) => askStep({
872
- cwd: options.cwd,
873
- model: options.model,
874
- label: `${label} grouping`,
875
- task: groupPrompt(specs, maxSpecs, built),
876
- check,
877
- tool: (take) => defineTool({
878
- name: "submit_groups",
879
- label: "Submit the groups",
880
- description: `The new functional specs in groups, in order: each group's spec numbers and a title of at most ${TITLE_WORDS} words and ${TITLE_CHARS} characters.`,
881
- parameters: Type.Object({
882
- groups: Type.Array(Type.Object({ specs: Type.Array(Type.Number()), title: Type.String({ description: `What the group builds: at most ${TITLE_WORDS} words and ${TITLE_CHARS} characters.` }) })),
883
- built: Type.Optional(Type.Array(Type.Object({ change: Type.Number(), to: Type.Union([Type.Number(), Type.Literal("first")]) }), {
884
- description: 'Where each change to what is built goes: with a group, by its number, or "first" - a pulse of its own, before the new work.',
885
- })),
886
- }),
887
- async execute(_id, params) {
888
- take(params);
889
- return { content: [{ type: "text", text: "Recorded." }], details: {}, terminate: true };
890
- },
891
- }),
892
- }),
893
- place: (input, check) => askStep({
894
- cwd: options.cwd,
895
- model: options.model,
896
- label: `${label} placement`,
897
- task: placePrompt(input),
898
- check,
899
- tool: (take) => defineTool({
900
- name: "submit_placement",
901
- label: "Submit the placement",
902
- description: 'Where each new req goes: a group\'s number, "all", or "built".',
903
- parameters: Type.Object({
904
- implementation_reqs: Type.Array(Type.Object({ req: Type.Number(), to: TargetSchema })),
905
- test_reqs: Type.Array(Type.Object({ req: Type.Number(), to: TargetSchema })),
906
- }),
907
- async execute(_id, params) {
908
- const given = params;
909
- take({ implementationReqs: given.implementation_reqs, testReqs: given.test_reqs });
910
- return { content: [{ type: "text", text: "Recorded." }], details: {}, terminate: true };
911
- },
912
- }),
913
- }),
914
- title: (groups, check, track) => askStep({
915
- cwd: options.cwd,
916
- model: options.model,
917
- label: `${label} titles`,
918
- task: titlePrompt(groups, track),
919
- check,
920
- tool: (take) => defineTool({
921
- name: "submit_titles",
922
- label: "Submit the titles",
923
- description: `A title for every group, by its number: at most ${TITLE_WORDS} words and ${TITLE_CHARS} characters each.`,
924
- parameters: Type.Object({
925
- titles: Type.Array(Type.Object({
926
- group: Type.Number(),
927
- title: Type.String({ description: `What the group's pulse ${track === "conformance" ? "tests" : "builds"}: at most ${TITLE_WORDS} words and ${TITLE_CHARS} characters.` }),
928
- })),
929
- }),
930
- async execute(_id, params) {
931
- take(params);
932
- return { content: [{ type: "text", text: "Recorded." }], details: {}, terminate: true };
933
- },
934
- }),
935
- }),
936
- };
937
- }