@turri-dev/cli 0.4.3-next.8482fed → 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 (531) hide show
  1. package/README.md +22 -2
  2. package/dist/banner.js +248 -0
  3. package/dist/capture-cli.js +4 -4
  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 +21 -9
  8. package/dist/chat-tabs.js +11 -7
  9. package/dist/chat-terminal.js +127 -64
  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 -3344
  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 +43 -13
  27. package/dist/pi-themes.js +21 -0
  28. package/dist/plain-code-blocks.js +1 -1
  29. package/dist/pointer-hover.js +4 -0
  30. package/dist/print-mode.js +20 -0
  31. package/dist/question-dialog.js +26 -3
  32. package/dist/quiet.js +7 -106
  33. package/dist/regenerate/diff-view.js +6 -87
  34. package/dist/regenerate/jobs-tree.js +2 -17
  35. package/dist/regenerate/side-panel.js +32 -5
  36. package/dist/regenerate/spec-map-view.js +3 -68
  37. package/dist/regenerate-cli.js +7 -11
  38. package/dist/reopen.js +40 -7
  39. package/dist/skill-progress.js +25 -0
  40. package/dist/skill-report.js +52 -0
  41. package/dist/terminal-marks.js +21 -0
  42. package/dist/terminal-notifications.js +219 -0
  43. package/dist/terminal-view.js +275 -0
  44. package/dist/turri-versions.js +64 -6
  45. package/docs/README.md +2 -2
  46. package/docs/capture.md +47 -11
  47. package/docs/chats.md +10 -7
  48. package/docs/claude-subscription.md +1 -1
  49. package/docs/config.md +11 -8
  50. package/docs/development.md +30 -64
  51. package/docs/headless.md +3 -1
  52. package/docs/hosting.md +3 -251
  53. package/docs/installation.md +4 -2
  54. package/docs/launch.md +3 -3
  55. package/docs/sandbox.md +2 -0
  56. package/docs/sentinel.md +13 -13
  57. package/docs/theming.md +2 -2
  58. package/docs/using.md +5 -5
  59. package/package.json +10 -28
  60. package/dist/ask.d.ts +0 -90
  61. package/dist/ask.js +0 -170
  62. package/dist/background-skills.d.ts +0 -56
  63. package/dist/background-skills.js +0 -129
  64. package/dist/bedrock-region.d.ts +0 -66
  65. package/dist/bedrock-region.js +0 -144
  66. package/dist/brand.d.ts +0 -13
  67. package/dist/btw.d.ts +0 -69
  68. package/dist/btw.js +0 -174
  69. package/dist/capture/agents.d.ts +0 -361
  70. package/dist/capture/agents.js +0 -332
  71. package/dist/capture/area.d.ts +0 -58
  72. package/dist/capture/area.js +0 -197
  73. package/dist/capture/assemble.d.ts +0 -122
  74. package/dist/capture/assemble.js +0 -452
  75. package/dist/capture/capture.d.ts +0 -116
  76. package/dist/capture/capture.js +0 -1228
  77. package/dist/capture/chat.d.ts +0 -29
  78. package/dist/capture/chat.js +0 -94
  79. package/dist/capture/checks.d.ts +0 -142
  80. package/dist/capture/checks.js +0 -643
  81. package/dist/capture/config.d.ts +0 -13
  82. package/dist/capture/config.js +0 -60
  83. package/dist/capture/interface.d.ts +0 -71
  84. package/dist/capture/interface.js +0 -199
  85. package/dist/capture/map.d.ts +0 -56
  86. package/dist/capture/map.js +0 -530
  87. package/dist/capture/progress.d.ts +0 -108
  88. package/dist/capture/progress.js +0 -234
  89. package/dist/capture/report.d.ts +0 -75
  90. package/dist/capture/report.js +0 -267
  91. package/dist/capture/scripts.d.ts +0 -26
  92. package/dist/capture/scripts.js +0 -33
  93. package/dist/capture/state.d.ts +0 -296
  94. package/dist/capture/state.js +0 -43
  95. package/dist/capture/trial.d.ts +0 -34
  96. package/dist/capture/trial.js +0 -89
  97. package/dist/capture-cli.d.ts +0 -1
  98. package/dist/chat-commands.d.ts +0 -17
  99. package/dist/chat-idle.d.ts +0 -7
  100. package/dist/chat-idle.js +0 -20
  101. package/dist/chat-models.d.ts +0 -22
  102. package/dist/chat-records.d.ts +0 -50
  103. package/dist/chat-records.js +0 -107
  104. package/dist/chat-scope.d.ts +0 -14
  105. package/dist/chat-scope.js +0 -15
  106. package/dist/chat-skills.d.ts +0 -17
  107. package/dist/chat-skills.js +0 -18
  108. package/dist/chat-tab-header.d.ts +0 -15
  109. package/dist/chat-tabs.d.ts +0 -20
  110. package/dist/chat-terminal.d.ts +0 -24
  111. package/dist/chat-ui.d.ts +0 -33
  112. package/dist/chat-waiting.d.ts +0 -67
  113. package/dist/chats.d.ts +0 -340
  114. package/dist/chats.js +0 -996
  115. package/dist/cli-options.d.ts +0 -24
  116. package/dist/cli.d.ts +0 -9
  117. package/dist/config-edit.d.ts +0 -83
  118. package/dist/config-edit.js +0 -391
  119. package/dist/config.d.ts +0 -428
  120. package/dist/config.js +0 -811
  121. package/dist/conform-cli.d.ts +0 -1
  122. package/dist/conformance-switch.d.ts +0 -25
  123. package/dist/conformance-switch.js +0 -86
  124. package/dist/cultivate-cli.d.ts +0 -1
  125. package/dist/doctor-tool.d.ts +0 -11
  126. package/dist/doctor-tool.js +0 -33
  127. package/dist/drift-cli.d.ts +0 -1
  128. package/dist/environment.d.ts +0 -37
  129. package/dist/environment.js +0 -109
  130. package/dist/extension.d.ts +0 -208
  131. package/dist/genome.d.ts +0 -77
  132. package/dist/genome.js +0 -288
  133. package/dist/graph.d.ts +0 -52
  134. package/dist/graph.js +0 -247
  135. package/dist/host-session.d.ts +0 -112
  136. package/dist/host-session.js +0 -103
  137. package/dist/host.d.ts +0 -40
  138. package/dist/host.js +0 -54
  139. package/dist/identity.d.ts +0 -7
  140. package/dist/identity.js +0 -75
  141. package/dist/init-config.d.ts +0 -169
  142. package/dist/init-config.js +0 -841
  143. package/dist/installed-providers.d.ts +0 -40
  144. package/dist/installed-providers.js +0 -98
  145. package/dist/jellyfish.d.ts +0 -40
  146. package/dist/judge.d.ts +0 -25
  147. package/dist/judge.js +0 -62
  148. package/dist/launch-agent.d.ts +0 -62
  149. package/dist/launch-agent.js +0 -339
  150. package/dist/launch-cli.d.ts +0 -1
  151. package/dist/launch-session.d.ts +0 -68
  152. package/dist/launch-session.js +0 -225
  153. package/dist/launch-tools.d.ts +0 -28
  154. package/dist/launch-tools.js +0 -72
  155. package/dist/launch-track.d.ts +0 -175
  156. package/dist/launch-track.js +0 -497
  157. package/dist/lineage-cli.d.ts +0 -1
  158. package/dist/loop-cli.d.ts +0 -35
  159. package/dist/loop-tools.d.ts +0 -103
  160. package/dist/loop-tools.js +0 -361
  161. package/dist/model-check.d.ts +0 -72
  162. package/dist/model-check.js +0 -162
  163. package/dist/module-report.d.ts +0 -9
  164. package/dist/new-project.d.ts +0 -10
  165. package/dist/new-project.js +0 -42
  166. package/dist/notice.d.ts +0 -115
  167. package/dist/notice.js +0 -61
  168. package/dist/parse-cli.d.ts +0 -1
  169. package/dist/parse-tool.d.ts +0 -9
  170. package/dist/parse-tool.js +0 -33
  171. package/dist/pi-launch.d.ts +0 -1
  172. package/dist/pi-settings.d.ts +0 -4
  173. package/dist/pi.d.ts +0 -248
  174. package/dist/pi.js +0 -889
  175. package/dist/picture-row.d.ts +0 -10
  176. package/dist/plain/check.d.ts +0 -63
  177. package/dist/plain/check.js +0 -236
  178. package/dist/plain/concepts.d.ts +0 -37
  179. package/dist/plain/concepts.js +0 -283
  180. package/dist/plain/cycles.d.ts +0 -21
  181. package/dist/plain/cycles.js +0 -190
  182. package/dist/plain/errors.d.ts +0 -26
  183. package/dist/plain/errors.js +0 -50
  184. package/dist/plain/files.d.ts +0 -47
  185. package/dist/plain/files.js +0 -161
  186. package/dist/plain/graph.d.ts +0 -107
  187. package/dist/plain/graph.js +0 -194
  188. package/dist/plain/highlight.d.ts +0 -43
  189. package/dist/plain/highlight.js +0 -196
  190. package/dist/plain/index.d.ts +0 -18
  191. package/dist/plain/index.js +0 -18
  192. package/dist/plain/liquid.d.ts +0 -22
  193. package/dist/plain/liquid.js +0 -124
  194. package/dist/plain/markdown.d.ts +0 -103
  195. package/dist/plain/markdown.js +0 -330
  196. package/dist/plain/module-concepts.d.ts +0 -32
  197. package/dist/plain/module-concepts.js +0 -80
  198. package/dist/plain/parser.d.ts +0 -163
  199. package/dist/plain/parser.js +0 -930
  200. package/dist/plain/plain.tmLanguage.json +0 -150
  201. package/dist/plain/project.d.ts +0 -48
  202. package/dist/plain/project.js +0 -155
  203. package/dist/plain/spec.d.ts +0 -152
  204. package/dist/plain/spec.js +0 -265
  205. package/dist/plain/stdlib.d.ts +0 -16
  206. package/dist/plain/stdlib.js +0 -48
  207. package/dist/plain/test-plain-file.d.ts +0 -59
  208. package/dist/plain/test-plain-file.js +0 -232
  209. package/dist/plain-code-blocks.d.ts +0 -14
  210. package/dist/plain-files.d.ts +0 -21
  211. package/dist/plain-files.js +0 -156
  212. package/dist/pointer-hover.d.ts +0 -12
  213. package/dist/question-dialog.d.ts +0 -55
  214. package/dist/questioning.d.ts +0 -55
  215. package/dist/questioning.js +0 -109
  216. package/dist/quiet.d.ts +0 -34
  217. package/dist/regenerate/activity.d.ts +0 -227
  218. package/dist/regenerate/activity.js +0 -250
  219. package/dist/regenerate/agent-env.d.ts +0 -51
  220. package/dist/regenerate/agent-env.js +0 -311
  221. package/dist/regenerate/agent-shell.d.ts +0 -54
  222. package/dist/regenerate/agent-shell.js +0 -121
  223. package/dist/regenerate/arbiter.d.ts +0 -68
  224. package/dist/regenerate/arbiter.js +0 -133
  225. package/dist/regenerate/audit.d.ts +0 -69
  226. package/dist/regenerate/audit.js +0 -212
  227. package/dist/regenerate/base-folder.d.ts +0 -70
  228. package/dist/regenerate/base-folder.js +0 -186
  229. package/dist/regenerate/cases.d.ts +0 -12
  230. package/dist/regenerate/cases.js +0 -149
  231. package/dist/regenerate/change-view.d.ts +0 -23
  232. package/dist/regenerate/change-view.js +0 -153
  233. package/dist/regenerate/chunk-plan.d.ts +0 -217
  234. package/dist/regenerate/chunk-plan.js +0 -937
  235. package/dist/regenerate/codebase.d.ts +0 -21
  236. package/dist/regenerate/codebase.js +0 -75
  237. package/dist/regenerate/command-check.d.ts +0 -66
  238. package/dist/regenerate/command-check.js +0 -577
  239. package/dist/regenerate/compaction.d.ts +0 -13
  240. package/dist/regenerate/compaction.js +0 -20
  241. package/dist/regenerate/confine.d.ts +0 -69
  242. package/dist/regenerate/confine.js +0 -311
  243. package/dist/regenerate/conform.d.ts +0 -66
  244. package/dist/regenerate/conform.js +0 -132
  245. package/dist/regenerate/conformance-agents.d.ts +0 -388
  246. package/dist/regenerate/conformance-agents.js +0 -1162
  247. package/dist/regenerate/conformance.d.ts +0 -191
  248. package/dist/regenerate/conformance.js +0 -1035
  249. package/dist/regenerate/conversation-writes.d.ts +0 -10
  250. package/dist/regenerate/conversation-writes.js +0 -100
  251. package/dist/regenerate/credentials.d.ts +0 -18
  252. package/dist/regenerate/credentials.js +0 -88
  253. package/dist/regenerate/debug-log.d.ts +0 -56
  254. package/dist/regenerate/debug-log.js +0 -236
  255. package/dist/regenerate/debugger.d.ts +0 -36
  256. package/dist/regenerate/debugger.js +0 -133
  257. package/dist/regenerate/delivery.d.ts +0 -2
  258. package/dist/regenerate/diagnose-job.d.ts +0 -2
  259. package/dist/regenerate/diagnose-job.js +0 -40
  260. package/dist/regenerate/diagnose.d.ts +0 -46
  261. package/dist/regenerate/diagnose.js +0 -92
  262. package/dist/regenerate/diff-view.d.ts +0 -64
  263. package/dist/regenerate/drift.d.ts +0 -120
  264. package/dist/regenerate/drift.js +0 -285
  265. package/dist/regenerate/environment-error.d.ts +0 -167
  266. package/dist/regenerate/environment-error.js +0 -342
  267. package/dist/regenerate/failure-reports.d.ts +0 -28
  268. package/dist/regenerate/failure-reports.js +0 -79
  269. package/dist/regenerate/job-log.d.ts +0 -30
  270. package/dist/regenerate/job-log.js +0 -105
  271. package/dist/regenerate/job-panel.d.ts +0 -122
  272. package/dist/regenerate/job-panel.js +0 -339
  273. package/dist/regenerate/jobs-tree.d.ts +0 -76
  274. package/dist/regenerate/jobs.d.ts +0 -231
  275. package/dist/regenerate/jobs.js +0 -522
  276. package/dist/regenerate/lanes.d.ts +0 -16
  277. package/dist/regenerate/lanes.js +0 -32
  278. package/dist/regenerate/launch.d.ts +0 -256
  279. package/dist/regenerate/launch.js +0 -689
  280. package/dist/regenerate/ledger-view.d.ts +0 -87
  281. package/dist/regenerate/ledger-view.js +0 -325
  282. package/dist/regenerate/ledger.d.ts +0 -368
  283. package/dist/regenerate/ledger.js +0 -357
  284. package/dist/regenerate/lineage.d.ts +0 -105
  285. package/dist/regenerate/lineage.js +0 -485
  286. package/dist/regenerate/list-arguments.d.ts +0 -21
  287. package/dist/regenerate/list-arguments.js +0 -121
  288. package/dist/regenerate/loop.d.ts +0 -423
  289. package/dist/regenerate/loop.js +0 -2087
  290. package/dist/regenerate/masking.d.ts +0 -19
  291. package/dist/regenerate/masking.js +0 -95
  292. package/dist/regenerate/model-names.d.ts +0 -33
  293. package/dist/regenerate/model-names.js +0 -92
  294. package/dist/regenerate/notes.d.ts +0 -159
  295. package/dist/regenerate/notes.js +0 -446
  296. package/dist/regenerate/os-sandbox.d.ts +0 -93
  297. package/dist/regenerate/os-sandbox.js +0 -283
  298. package/dist/regenerate/panel-dock.d.ts +0 -23
  299. package/dist/regenerate/paths.d.ts +0 -110
  300. package/dist/regenerate/paths.js +0 -190
  301. package/dist/regenerate/plain-palette.d.ts +0 -34
  302. package/dist/regenerate/prompt.d.ts +0 -230
  303. package/dist/regenerate/prompt.js +0 -741
  304. package/dist/regenerate/pulse-files.d.ts +0 -14
  305. package/dist/regenerate/pulse-files.js +0 -63
  306. package/dist/regenerate/records.d.ts +0 -132
  307. package/dist/regenerate/records.js +0 -327
  308. package/dist/regenerate/regenerate.d.ts +0 -106
  309. package/dist/regenerate/regenerate.js +0 -660
  310. package/dist/regenerate/regression.d.ts +0 -58
  311. package/dist/regenerate/regression.js +0 -188
  312. package/dist/regenerate/renames.d.ts +0 -42
  313. package/dist/regenerate/renames.js +0 -185
  314. package/dist/regenerate/requires.d.ts +0 -117
  315. package/dist/regenerate/requires.js +0 -377
  316. package/dist/regenerate/resources.d.ts +0 -57
  317. package/dist/regenerate/resources.js +0 -162
  318. package/dist/regenerate/scripts-being-written.d.ts +0 -19
  319. package/dist/regenerate/scripts-being-written.js +0 -30
  320. package/dist/regenerate/self-check.d.ts +0 -29
  321. package/dist/regenerate/self-check.js +0 -119
  322. package/dist/regenerate/services.d.ts +0 -28
  323. package/dist/regenerate/services.js +0 -158
  324. package/dist/regenerate/shell.d.ts +0 -91
  325. package/dist/regenerate/shell.js +0 -320
  326. package/dist/regenerate/side-panel.d.ts +0 -62
  327. package/dist/regenerate/spec-map-view.d.ts +0 -147
  328. package/dist/regenerate/spec-map.d.ts +0 -160
  329. package/dist/regenerate/spec-map.js +0 -596
  330. package/dist/regenerate/spec-steps.d.ts +0 -180
  331. package/dist/regenerate/spec-steps.js +0 -729
  332. package/dist/regenerate/standing.d.ts +0 -28
  333. package/dist/regenerate/standing.js +0 -30
  334. package/dist/regenerate/state.d.ts +0 -21
  335. package/dist/regenerate/state.js +0 -10
  336. package/dist/regenerate/steering.d.ts +0 -56
  337. package/dist/regenerate/steering.js +0 -119
  338. package/dist/regenerate/stop-report.d.ts +0 -43
  339. package/dist/regenerate/stop-report.js +0 -160
  340. package/dist/regenerate/submit-work.d.ts +0 -44
  341. package/dist/regenerate/submit-work.js +0 -76
  342. package/dist/regenerate/test-kinds.d.ts +0 -85
  343. package/dist/regenerate/test-kinds.js +0 -171
  344. package/dist/regenerate/test-scripts.d.ts +0 -240
  345. package/dist/regenerate/test-scripts.js +0 -847
  346. package/dist/regenerate/testing-steps.d.ts +0 -52
  347. package/dist/regenerate/testing-steps.js +0 -129
  348. package/dist/regenerate/testing.d.ts +0 -150
  349. package/dist/regenerate/testing.js +0 -438
  350. package/dist/regenerate/transcript-view.d.ts +0 -21
  351. package/dist/regenerate/unit-gate.d.ts +0 -27
  352. package/dist/regenerate/unit-gate.js +0 -20
  353. package/dist/regenerate/unit-review.d.ts +0 -152
  354. package/dist/regenerate/unit-review.js +0 -361
  355. package/dist/regenerate/web.d.ts +0 -61
  356. package/dist/regenerate/web.js +0 -256
  357. package/dist/regenerate/workspace.d.ts +0 -12
  358. package/dist/regenerate/workspace.js +0 -99
  359. package/dist/regenerate-cli.d.ts +0 -1
  360. package/dist/reopen.d.ts +0 -29
  361. package/dist/resume-line.d.ts +0 -5
  362. package/dist/review/live.d.ts +0 -72
  363. package/dist/review/live.js +0 -166
  364. package/dist/rules.d.ts +0 -20
  365. package/dist/rules.js +0 -47
  366. package/dist/run-report.d.ts +0 -88
  367. package/dist/run-report.js +0 -338
  368. package/dist/screen-padding.d.ts +0 -28
  369. package/dist/self-invocation.d.ts +0 -36
  370. package/dist/self-invocation.js +0 -137
  371. package/dist/sentinel-chat.d.ts +0 -19
  372. package/dist/sentinel-chat.js +0 -221
  373. package/dist/sentinel-check.d.ts +0 -36
  374. package/dist/sentinel-check.js +0 -78
  375. package/dist/sentinel.d.ts +0 -107
  376. package/dist/sentinel.js +0 -599
  377. package/dist/settings.d.ts +0 -45
  378. package/dist/settings.js +0 -378
  379. package/dist/setup.d.ts +0 -97
  380. package/dist/setup.js +0 -436
  381. package/dist/skill-progress.d.ts +0 -46
  382. package/dist/skill.d.ts +0 -102
  383. package/dist/skill.js +0 -147
  384. package/dist/skills.d.ts +0 -54
  385. package/dist/skills.js +0 -111
  386. package/dist/spawn-async.d.ts +0 -18
  387. package/dist/spawn-async.js +0 -35
  388. package/dist/stack.d.ts +0 -80
  389. package/dist/stack.js +0 -206
  390. package/dist/stdlib.d.ts +0 -43
  391. package/dist/stdlib.js +0 -118
  392. package/dist/surface.d.ts +0 -5
  393. package/dist/surface.js +0 -18
  394. package/dist/terminal-images.d.ts +0 -2
  395. package/dist/test-plain-files.d.ts +0 -41
  396. package/dist/test-plain-files.js +0 -172
  397. package/dist/tools.d.ts +0 -101
  398. package/dist/tools.js +0 -242
  399. package/dist/turri-versions.d.ts +0 -71
  400. package/genome/capture/capture.md +0 -26
  401. package/genome/capture/check-conventions.md +0 -5
  402. package/genome/capture/check-reference.md +0 -11
  403. package/genome/capture/concepts.md +0 -3
  404. package/genome/capture/divide.md +0 -9
  405. package/genome/capture/feature.md +0 -45
  406. package/genome/capture/interface.md +0 -9
  407. package/genome/capture/modules.md +0 -23
  408. package/genome/capture/outline.md +0 -11
  409. package/genome/capture/readability.md +0 -12
  410. package/genome/capture/reference.md +0 -10
  411. package/genome/capture/split.md +0 -9
  412. package/genome/capture/survey.md +0 -37
  413. package/genome/capture/trial.md +0 -18
  414. package/genome/capture/verify.md +0 -7
  415. package/genome/rules/bullet-continuation.md +0 -61
  416. package/genome/rules/concise-specs-examples.md +0 -460
  417. package/genome/rules/concise-specs-integration-examples.md +0 -281
  418. package/genome/rules/concise-specs.md +0 -80
  419. package/genome/rules/definitions.md +0 -107
  420. package/genome/rules/examples/integration-embedded-testing/run_conformance_tests_java.sh +0 -161
  421. package/genome/rules/examples/integration-embedded-testing/run_unittests_java.sh +0 -50
  422. package/genome/rules/exported-concepts.md +0 -39
  423. package/genome/rules/func-specs.md +0 -164
  424. package/genome/rules/impl-reqs.md +0 -68
  425. package/genome/rules/import-modules.md +0 -49
  426. package/genome/rules/integration-embedded-testing.md +0 -273
  427. package/genome/rules/integration-embedded.md +0 -171
  428. package/genome/rules/integration-standalone.md +0 -135
  429. package/genome/rules/integrations.md +0 -136
  430. package/genome/rules/linked-resources.md +0 -76
  431. package/genome/rules/module-structure.md +0 -112
  432. package/genome/rules/project-model.md +0 -69
  433. package/genome/rules/required-concepts.md +0 -44
  434. package/genome/rules/requires-modules.md +0 -81
  435. package/genome/rules/semantic-ids.md +0 -49
  436. package/genome/rules/stdlib.md +0 -37
  437. package/genome/rules/test-plain-files.md +0 -138
  438. package/genome/rules/test-reqs.md +0 -57
  439. package/genome/rules/turri-regeneration.md +0 -66
  440. package/genome/skills/analyze-2-func-specs/SKILL.md +0 -116
  441. package/genome/skills/analyze-func-specs/SKILL.md +0 -137
  442. package/genome/skills/break-down-func-spec/SKILL.md +0 -229
  443. package/genome/skills/consolidate-concepts/SKILL.md +0 -192
  444. package/genome/skills/convert-old-syntax/SKILL.md +0 -68
  445. package/genome/skills/convert-old-syntax/references/rubric.md +0 -11
  446. package/genome/skills/debug-specs/SKILL.md +0 -194
  447. package/genome/skills/implement-conformance-testing-script/SKILL.md +0 -247
  448. package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_cypress.ps1 +0 -337
  449. package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_golang.ps1 +0 -111
  450. package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_java.sh +0 -151
  451. package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_python.ps1 +0 -103
  452. package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_python.sh +0 -146
  453. package/genome/skills/implement-unit-testing-script/SKILL.md +0 -171
  454. package/genome/skills/implement-unit-testing-script/assets/run_unittests_flutter.ps1 +0 -87
  455. package/genome/skills/implement-unit-testing-script/assets/run_unittests_golang.ps1 +0 -73
  456. package/genome/skills/implement-unit-testing-script/assets/run_unittests_java.sh +0 -82
  457. package/genome/skills/implement-unit-testing-script/assets/run_unittests_python.ps1 +0 -81
  458. package/genome/skills/implement-unit-testing-script/assets/run_unittests_python.sh +0 -102
  459. package/genome/skills/implement-unit-testing-script/assets/run_unittests_react.ps1 +0 -87
  460. package/genome/skills/refactor-module/SKILL.md +0 -218
  461. package/genome/skills/resolve-section-ownership/SKILL.md +0 -64
  462. package/genome/skills/resolve-spec-conflict/SKILL.md +0 -102
  463. package/stdlib/backend/common.plain +0 -25
  464. package/stdlib/backend/conformance/common.plain +0 -12
  465. package/stdlib/backend/conformance/go-gin.plain +0 -9
  466. package/stdlib/backend/conformance/go-nethttp.plain +0 -9
  467. package/stdlib/backend/conformance/java-springboot.plain +0 -9
  468. package/stdlib/backend/conformance/python-django.plain +0 -9
  469. package/stdlib/backend/conformance/python-fastapi.plain +0 -9
  470. package/stdlib/backend/conformance/python-flask.plain +0 -9
  471. package/stdlib/backend/conformance/rust-axum.plain +0 -9
  472. package/stdlib/backend/conformance/typescript-express.plain +0 -9
  473. package/stdlib/backend/conformance/typescript-fastify.plain +0 -9
  474. package/stdlib/backend/conformance/typescript-nestjs.plain +0 -9
  475. package/stdlib/backend/go-gin.plain +0 -18
  476. package/stdlib/backend/go-nethttp.plain +0 -18
  477. package/stdlib/backend/java-springboot.plain +0 -19
  478. package/stdlib/backend/python-django.plain +0 -19
  479. package/stdlib/backend/python-fastapi.plain +0 -23
  480. package/stdlib/backend/python-flask.plain +0 -23
  481. package/stdlib/backend/rust-axum.plain +0 -17
  482. package/stdlib/backend/typescript-express.plain +0 -19
  483. package/stdlib/backend/typescript-fastify.plain +0 -19
  484. package/stdlib/backend/typescript-nestjs.plain +0 -19
  485. package/stdlib/cli/common.plain +0 -17
  486. package/stdlib/cli/conformance/common.plain +0 -11
  487. package/stdlib/cli/conformance/go-cobra.plain +0 -9
  488. package/stdlib/cli/conformance/go-flag.plain +0 -9
  489. package/stdlib/cli/conformance/java-picocli.plain +0 -9
  490. package/stdlib/cli/conformance/python-argparse.plain +0 -9
  491. package/stdlib/cli/conformance/python-click.plain +0 -9
  492. package/stdlib/cli/conformance/python-typer.plain +0 -9
  493. package/stdlib/cli/conformance/rust-clap.plain +0 -9
  494. package/stdlib/cli/conformance/typescript-commander.plain +0 -9
  495. package/stdlib/cli/go-cobra.plain +0 -14
  496. package/stdlib/cli/go-flag.plain +0 -14
  497. package/stdlib/cli/java-picocli.plain +0 -15
  498. package/stdlib/cli/python-argparse.plain +0 -18
  499. package/stdlib/cli/python-click.plain +0 -16
  500. package/stdlib/cli/python-typer.plain +0 -16
  501. package/stdlib/cli/rust-clap.plain +0 -14
  502. package/stdlib/cli/typescript-commander.plain +0 -17
  503. package/stdlib/frontend/angular.plain +0 -17
  504. package/stdlib/frontend/common.plain +0 -17
  505. package/stdlib/frontend/conformance/angular.plain +0 -5
  506. package/stdlib/frontend/conformance/common.plain +0 -11
  507. package/stdlib/frontend/conformance/react-vite.plain +0 -5
  508. package/stdlib/frontend/conformance/sveltekit-spa.plain +0 -5
  509. package/stdlib/frontend/conformance/vue-vite.plain +0 -5
  510. package/stdlib/frontend/react-vite.plain +0 -16
  511. package/stdlib/frontend/sveltekit-spa.plain +0 -16
  512. package/stdlib/frontend/vue-vite.plain +0 -16
  513. package/stdlib/lang/go.plain +0 -13
  514. package/stdlib/lang/java.plain +0 -12
  515. package/stdlib/lang/python.plain +0 -18
  516. package/stdlib/lang/rust.plain +0 -12
  517. package/stdlib/lang/typescript.plain +0 -13
  518. package/stdlib/library/common.plain +0 -15
  519. package/stdlib/library/conformance/common.plain +0 -9
  520. package/stdlib/library/conformance/go.plain +0 -9
  521. package/stdlib/library/conformance/java-gradle.plain +0 -9
  522. package/stdlib/library/conformance/java-maven.plain +0 -9
  523. package/stdlib/library/conformance/python.plain +0 -9
  524. package/stdlib/library/conformance/rust.plain +0 -9
  525. package/stdlib/library/conformance/typescript.plain +0 -9
  526. package/stdlib/library/go.plain +0 -12
  527. package/stdlib/library/java-gradle.plain +0 -13
  528. package/stdlib/library/java-maven.plain +0 -13
  529. package/stdlib/library/python.plain +0 -13
  530. package/stdlib/library/rust.plain +0 -12
  531. package/stdlib/library/typescript.plain +0 -15
@@ -1,660 +0,0 @@
1
- import { spawnSync } from "node:child_process";
2
- import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
3
- import { tmpdir } from "node:os";
4
- import { basename, dirname, join, relative, resolve } from "node:path";
5
- import { IMPORT_DIRECTIVE, plainFileParser, readPlainSourceMetadata, withParseCache } from "../plain/parser.js";
6
- import { isStdlibModule, STDLIB_ROOT } from "../plain/stdlib.js";
7
- import { CONFORMANCE_TESTS, ACCEPTANCE_TESTS, FUNCTIONAL_REQUIREMENTS, getFrids, getInheritedFunctionalSpecs, getSpecificationsForFrid, TEST_REQUIREMENTS, } from "../plain/spec.js";
8
- import { ask, BEGIN, createExecutor, refuseIfModelIsBlind } from "../pi.js";
9
- import { reportActivity, reportLogNote, reportStage, unitOf } from "./activity.js";
10
- import { debugFailure, diagnosisText } from "./debugger.js";
11
- import { codebaseMap, diffFiles, digestFiles, wroteNothing } from "./codebase.js";
12
- import { confinedTools } from "./confine.js";
13
- import { buildSpecDiffPrompt, describeSpecChange, reviewedSpec, sectionModules } from "./prompt.js";
14
- import { abandonWork, landWork, startWork } from "./lineage.js";
15
- import { healing, record, signatureHash } from "./ledger.js";
16
- import { createWorkLedger, SUBMIT_WORK_NOTE } from "./submit-work.js";
17
- import { CODER_COMPACTION } from "./compaction.js";
18
- import { gapMark, gapsSince, NOTES_TURN, notesForSession, passedOutcome, recordNote, withNotes } from "./notes.js";
19
- import { createLoopWatch, createScriptTool, failureSignature, findTestScripts, projectRootFor, requireTestScripts, runUnitScript, STUCK_ROUNDS, withoutConformance, withTestingScripts, } from "./test-scripts.js";
20
- import { createWebTools, WEB_TOOLS } from "./web.js";
21
- import { createCanItFailTool, createMyDiffTool, selfCheckNote } from "./self-check.js";
22
- import { createServiceTools } from "./services.js";
23
- import { createUnitGate } from "./unit-gate.js";
24
- import { scriptFaultError, timeLimitError, toolchainError } from "./environment-error.js";
25
- import { workspaceBlock } from "./workspace.js";
26
- import { ATTEMPTS, describeStop } from "./stop-report.js";
27
- import { summarizeDiff } from "./job-panel.js";
28
- import { conversationWriting } from "./conversation-writes.js";
29
- import { resolveTemplateDirs } from "./paths.js";
30
- import { copyRequiredCode, findCodebaseTip, newlyRequired } from "./requires.js";
31
- import { baseOfCodebase, inCodebaseOf, seedFromBaseFolder } from "./base-folder.js";
32
- import { createCopyResourceTool, loadLinkedResources, resourceFile, resourceImages } from "./resources.js";
33
- import { markTold, waitingSteer } from "./steering.js";
34
- import { misplacedConformanceTests, misplacedTestsPrompt } from "./test-kinds.js";
35
- import { sectionsOf } from "./state.js";
36
- import { codeTree, inheritedRecord, readRecord, withResourceDigests, writeCodeRecord } from "./records.js";
37
- import { changesBetween, sameSpec, serializeTree } from "./spec-steps.js";
38
- import { untilUnitTestsReviewed } from "./unit-review.js";
39
- import { configForSpec, inheritModel, modelOnly, modelSpec, testDirOf } from "../config.js";
40
- import { findTestRemovals, inventoryTests, listFiles, removalChallengePrompt, AGAIN_ASKS, againPrompt, draftPrompt, DRAFT_ASKS, } from "./testing.js";
41
- /**
42
- * Render a change to the specs, given as a git diff of the .plain files.
43
- *
44
- * The change is whatever the person made - specs added, changed or removed, in any section,
45
- * across any number of them - and it is rendered the way a developer would take a spec
46
- * change: one agent, given the diff and every spec it touches as it now stands, makes the
47
- * code match. Starting from nothing is the same operation, with a diff that adds everything.
48
- *
49
- * It is given two things: the diff, and the whole spec as parsed right after the diff went in.
50
- * The render works from that parse and the build record is written from it - every section,
51
- * not only the functional specs - because that is what the codebase holds once the change is
52
- * built. A change rendered from a queue runs after later ones have gone into the files, so
53
- * the files are not what it is about; the parse taken with the diff is.
54
- *
55
- * After it, the order that makes the result trustworthy: the conformance tests are brought
56
- * in line with the change, the whole suite runs with repairs, and the build record is
57
- * rewritten.
58
- */
59
- const MAX_FOLLOW_UPS = ATTEMPTS["unit tests"];
60
- /**
61
- * Bring the .plain files to the state the diff describes, with git. A diff that is already
62
- * applied is fine - the person may have made the edit themselves and sent its diff - but
63
- * one that fits neither way is refused: rendering it would mean guessing.
64
- */
65
- export function applySpecDiff(diff, cwd) {
66
- // What it writes is the person's side's, not an agent command's: the audit leaves it.
67
- const written = conversationWriting(plainFilesOf(diff).map((file) => resolve(cwd, file)));
68
- const dir = mkdtempSync(join(tmpdir(), "turri-diff-"));
69
- const patch = join(dir, "spec.diff");
70
- writeFileSync(patch, diff.endsWith("\n") ? diff : `${diff}\n`);
71
- // --recount: a diff written by hand, or by a model, rarely has its hunk line counts right,
72
- // and they carry no information the hunk itself does not.
73
- const git = (...args) => spawnSync("git", ["apply", "--recount", ...args, patch], { cwd, encoding: "utf8" });
74
- try {
75
- const forward = git("--check");
76
- if (forward.status === 0) {
77
- const applied = git();
78
- if (applied.status !== 0)
79
- throw new Error(`git apply failed: ${applied.stderr.trim()}`);
80
- return "applied";
81
- }
82
- if (git("--reverse", "--check").status === 0)
83
- return "already applied";
84
- throw new Error(`The spec diff does not apply to the .plain files here, and is not already applied: ${forward.stderr.trim()}`);
85
- }
86
- finally {
87
- rmSync(dir, { recursive: true, force: true });
88
- written();
89
- }
90
- }
91
- /** The .plain files a diff writes to, relative to where it applies. */
92
- export function plainFilesOf(diff) {
93
- const files = new Set();
94
- for (const line of diff.split("\n")) {
95
- const match = /^\+\+\+ (?:b\/)?(.+\.plain)\s*$/.exec(line);
96
- if (match)
97
- files.add(match[1]);
98
- }
99
- return [...files];
100
- }
101
- /** A module's .plain file and every one it imports, transitively - the files its spec is read from. */
102
- export function specFilesOf(plainFile, templateDirs = []) {
103
- const dirs = resolveTemplateDirs(resolve(plainFile), templateDirs);
104
- const files = [];
105
- const visit = (path) => {
106
- if (files.includes(path) || !existsSync(path))
107
- return;
108
- files.push(path);
109
- const imports = readPlainSourceMetadata(readFileSync(path, "utf8")).metadata[IMPORT_DIRECTIVE] ?? [];
110
- for (const name of imports) {
111
- // A standard library template is turri's own, wherever the spec is (see plain/stdlib.ts).
112
- const from = isStdlibModule(name) ? [STDLIB_ROOT] : [dirname(path), ...dirs];
113
- const found = from.map((dir) => join(dir, `${name.replace(/^\.\//, "")}.plain`)).find((candidate) => existsSync(candidate));
114
- if (found !== undefined)
115
- visit(resolve(found));
116
- }
117
- };
118
- visit(resolve(plainFile));
119
- return files;
120
- }
121
- /** A git diff cut into what it does to each file, in order: the file's path (the new side's), and its part of the diff. */
122
- export function diffByFile(diff) {
123
- const lines = diff.split("\n");
124
- const starts = [];
125
- const headed = lines.some((line) => line.startsWith("diff --git "));
126
- lines.forEach((line, index) => {
127
- if (headed ? line.startsWith("diff --git ") : line.startsWith("--- ") && lines[index + 1]?.startsWith("+++ "))
128
- starts.push(index);
129
- });
130
- return starts.map((start, index) => {
131
- const part = lines.slice(start, starts[index + 1] ?? lines.length);
132
- const target = part.map((line) => /^\+\+\+ (?:b\/)?(.+?)\s*$/.exec(line)?.[1]).find((path) => path !== undefined && path !== "/dev/null");
133
- const source = part.map((line) => /^--- (?:a\/)?(.+?)\s*$/.exec(line)?.[1]).find((path) => path !== undefined && path !== "/dev/null");
134
- const text = part.join("\n");
135
- return { file: target ?? source ?? "", diff: text.endsWith("\n") ? text : `${text}\n` };
136
- });
137
- }
138
- /** Parse the spec as it stands now, for a change to `plainFile`'s module. */
139
- export function snapshotSpec(plainFile, options = {}) {
140
- const cwd = resolve(options.cwd ?? process.cwd());
141
- const templateDirs = options.templateDirs ?? [];
142
- // The change lands in the chain's current codebase. A spec change is built whatever it
143
- // touches - a definition, a req, a functional spec - so a module with no functional specs
144
- // yet is still a module to build.
145
- const { tip, chain } = withParseCache(() => findCodebaseTip(resolve(cwd, plainFile), { templateDirs, inModule: options.inModule, allowNoFunctionalities: true }));
146
- const dirs = resolveTemplateDirs(tip.plainFile, templateDirs);
147
- const [moduleName, parsed] = plainFileParser(basename(tip.plainFile), dirs, { allowNoFunctionalities: true, testDir: testDirOf(tip.plainFile) });
148
- // What a linked resource holds is part of the spec: hashed beside its link, as the work loop has it.
149
- return { moduleName, plainFile: tip.plainFile, tree: withResourceDigests(parsed, dirs), chain };
150
- }
151
- export async function renderSpecDiff(options) {
152
- const cwd = resolve(options.cwd ?? process.cwd());
153
- const templateDirs = options.templateDirs ?? [];
154
- const applied = options.applied ?? applySpecDiff(options.diff, cwd);
155
- const spec = options.spec ?? snapshotSpec(options.plainFile, { cwd, templateDirs, inModule: options.inModule });
156
- const { moduleName, tree, chain } = spec;
157
- const tip = chain.at(-1);
158
- const stage = (label) => reportStage(`${unitOf(moduleName)}: ${label}`);
159
- // A module required now that the code was not built on is not something a change to the code can
160
- // bring in: the code has to start again, on that module's.
161
- const fresh = newlyRequired(chain);
162
- if (fresh !== undefined) {
163
- throw new Error(`${tip.moduleName} now requires ${fresh.modules.join(", ")}, which its code was not built on, so a spec diff cannot bring the change in. ` +
164
- `Its code has to be started over on it - ${fresh.rebuild.map((entry) => entry.moduleName).join(", ")} taken out, kept in the history, and built ` +
165
- `again from the bottom of the chain: regenerate it from scratch in the chat, once the user agrees, or turri regenerate ${relative(cwd, tip.plainFile)} --start-over.`);
166
- }
167
- stage(`the spec diff is ${applied === "applied" ? "applied to the .plain files" : "already in the .plain files"} - rendering it in ${moduleName}'s codebase`);
168
- // The change is made to the codebase's last known good state, not to what an interrupted
169
- // run left half-written.
170
- // A dry run only reads: another job may be at work in the codebase.
171
- const dryRun = options.dryRun === true;
172
- if (!dryRun)
173
- stage("starting from the codebase's last commit");
174
- // The change is one unit - its code and its unit tests - landed whole, with the spec it was built from, or
175
- // undone whole. Its conformance tests are a job of their own, after it (docs/regenerating.md).
176
- const unit = dryRun ? undefined : startWork([tip.buildDir], moduleName);
177
- // Only laid out differently - definitions moved to a common module, specs moved between modules
178
- // of the chain: the code already is what the spec says. Nothing to render; the spec is recorded
179
- // as it is now laid out.
180
- const builtBefore = readRecord(tip.buildDir, { onDisk: true });
181
- if (builtBefore !== null && sameSpec(builtBefore, codeTree(tree)) && !dryRun) {
182
- stage("the specs were only restructured - nothing to render; recording the spec as it is now laid out");
183
- writeCodeRecord(tip.buildDir, tree);
184
- landWork(tip.buildDir, `spec restructured: ${summarizeDiff(options.diff)}`, options.diff);
185
- return {
186
- moduleName,
187
- buildDir: tip.buildDir,
188
- diff: applied,
189
- response: "The specs were only restructured: the code is already built from the same spec, so nothing was rendered.",
190
- runs: [],
191
- attempts: 0,
192
- testRemovals: [],
193
- files: { added: [], changed: [], removed: [] },
194
- passed: true,
195
- stoppedAt: null,
196
- restructured: true,
197
- };
198
- }
199
- // Whether the change is done is the project's testing scripts: without them, nothing is built.
200
- stage("finding the project's testing scripts");
201
- const root = projectRootFor(tip.plainFile, tip.buildDir);
202
- // The code is judged by its unit tests alone: the conformance testing script is the conformance job's.
203
- const scripts = withoutConformance(findTestScripts(root, tip.plainFile, tip.buildDir));
204
- requireTestScripts(moduleName, scripts, { conformance: false });
205
- reportLogNote(` unit testing script: ${relative(root, scripts.unit)}`);
206
- const lastFuncId = [...getFrids(tree)].at(-1);
207
- const buildDir = tip.buildDir;
208
- // From scratch there is no build directory yet, and everything the agent runs runs in it.
209
- if (!dryRun)
210
- mkdirSync(buildDir, { recursive: true });
211
- const empty = listFiles(buildDir).length === 0;
212
- const source = empty && tip.requires !== null ? chain.find((entry) => entry.moduleName === tip.requires) : undefined;
213
- if (source !== undefined && !dryRun) {
214
- stage(`no code here yet - starting from ${source.moduleName}'s code`);
215
- copyRequiredCode(source.buildDir, buildDir, moduleName, source.moduleName);
216
- }
217
- // A codebase that requires nothing starts from its base folder, when the config names one: code to build on, files to use.
218
- if (empty && tip.requires === null && !dryRun) {
219
- const seeded = seedFromBaseFolder(buildDir, tip.plainFile, moduleName);
220
- if (seeded !== undefined)
221
- stage(`no code here yet - starting from the base folder ${seeded.folder}, ${seeded.files.length} file${seeded.files.length === 1 ? "" : "s"}`);
222
- }
223
- // What the agent is shown it starts from: a dry run copies nothing, and reads the code it would start from where it is.
224
- const seen = dryRun && source !== undefined ? source.buildDir : buildDir;
225
- stage("mapping the codebase and writing the prompt");
226
- // The agent is given the spec the code is built from - the state before the change - and the change: the spec
227
- // before it, plus the diff, is the spec after it. Read from the codebase as it is now, code copied up from a
228
- // required module included; with nothing built, there is no spec before, and the change is all of it.
229
- const builtNow = (seen === buildDir ? readRecord(buildDir, { onDisk: true }) : (() => {
230
- const below = readRecord(seen);
231
- return below !== null ? inheritedRecord(below, source.moduleName) : null;
232
- })()) ?? {};
233
- // The change as it is to the code - from what it is built from to the spec this job records - section by section:
234
- // what every agent of this change is shown, in place of the raw diff.
235
- const changes = changesBetween(serializeTree(builtNow), serializeTree(tree));
236
- const changeText = changes.length > 0 ? describeSpecChange(changes, moduleName) : undefined;
237
- // The coding agent's view of the change leaves its test reqs out: they say how the conformance tests are written -
238
- // the conformance job's to read, from the whole change (`changeText`), not the code's.
239
- const codingChanges = changes.filter((change) => change.section !== TEST_REQUIREMENTS);
240
- const codingText = codingChanges.length > 0 ? describeSpecChange(codingChanges, moduleName) : undefined;
241
- /** Steered, the change as its agent has it now: from what the code is built from to what it was steered to. */
242
- const steeredChange = () => {
243
- if (options.steering === undefined || options.steering.steers === 0)
244
- return undefined;
245
- const now = changesBetween(serializeTree(builtNow), serializeTree(options.steering.agent)).filter((change) => change.section !== TEST_REQUIREMENTS);
246
- return now.length > 0 ? describeSpecChange(now, moduleName) : undefined;
247
- };
248
- const builtFuncIds = [...getFrids(builtNow)];
249
- const specificationsBefore = builtFuncIds.length > 0
250
- ? getSpecificationsForFrid(builtNow, builtFuncIds.at(-1))[0]
251
- : { ...sectionsOf(builtNow), [FUNCTIONAL_REQUIREMENTS]: [], [CONFORMANCE_TESTS]: [], [ACCEPTANCE_TESTS]: [] };
252
- const resourceDirs = resolveTemplateDirs(tip.plainFile, templateDirs);
253
- // A linked file the base folder held, in the codebase still, is used from there: its path is said, and it is not copied.
254
- const linkedResources = loadLinkedResources(tree, lastFuncId ?? null, resourceDirs).map((resource) => {
255
- const file = resourceFile(resource.target, resourceDirs);
256
- const inCodebase = file === null ? undefined : inCodebaseOf(file, seen, tip.plainFile);
257
- return inCodebase !== undefined ? { ...resource, inCodebase } : resource;
258
- });
259
- const startedFrom = baseOfCodebase(seen);
260
- const prompt = buildSpecDiffPrompt({
261
- moduleName,
262
- diff: options.diff,
263
- // The change as it is to the code: from what it is built from to the spec this job records, section by section.
264
- changes: codingChanges,
265
- specifications: specificationsBefore,
266
- funcIds: builtFuncIds,
267
- modules: sectionModules(builtNow, moduleName),
268
- required: getInheritedFunctionalSpecs(builtNow),
269
- linkedResources,
270
- codebase: codebaseMap(seen),
271
- empty: listFiles(seen).length === 0,
272
- ...(options.cases !== undefined ? { cases: options.cases } : {}),
273
- ...(startedFrom !== undefined ? { base: startedFrom } : {}),
274
- });
275
- const digestsBefore = digestFiles(buildDir);
276
- // The spec gaps its agents report from here on are told with the result.
277
- const gapsFrom = gapMark();
278
- /** What the debugger found, each time it was asked: the pulse's line in the notes says it. */
279
- const diagnosed = [];
280
- const runs = [];
281
- // Its own runs of the unit tests, watched for a loop - edits that go back and forth while the failure stays.
282
- const loop = createLoopWatch(buildDir);
283
- const fence = confinedTools({ workdir: buildDir, reportsEnvironment: true });
284
- const notes = notesForSession(buildDir, `${moduleName} spec change`);
285
- // What it hands over at the end of a turn, for its reviewer.
286
- const work = createWorkLedger();
287
- // What it checks its own work with: the diff its reviewer is shown, and whether a test catches a bug - neither decides anything.
288
- const gate = createUnitGate(buildDir, scripts.unit);
289
- // can_it_fail, for the coding agent and its reviewer: on unless mutation-testing says otherwise.
290
- const mutationTesting = scripts.unit !== undefined && configForSpec(tip.plainFile).mutationTesting !== false;
291
- const selfChecks = [
292
- createMyDiffTool({ dir: buildDir, what: "code" }),
293
- ...(mutationTesting ? [createCanItFailTool({ buildDir, script: scripts.unit })] : []),
294
- ];
295
- // A server it built, it can start and try from outside - stopped when it is done.
296
- const services = createServiceTools({ dir: buildDir });
297
- // The script its work is judged by.
298
- const task = [
299
- withNotes(withTestingScripts(prompt, scripts, ["unit"], root), buildDir),
300
- "",
301
- ...selfCheckNote([...selfChecks.map((tool) => tool.name), "start_service"]),
302
- ...SUBMIT_WORK_NOTE,
303
- ].join("\n");
304
- if (dryRun) {
305
- return { moduleName, buildDir, diff: applied, response: "", runs: [], attempts: 0, testRemovals: [], files: { added: [], changed: [], removed: [] }, passed: false, stoppedAt: null, task };
306
- }
307
- // The spec's images need a model that reads them: refused before the agent starts.
308
- await refuseIfModelIsBlind(options.model, resourceImages(linkedResources).length);
309
- stage(`starting the coding agent${options.model ? ` (${options.model})` : ""}`);
310
- // One session for the whole change: its task is its instructions, its work compacted as it gets longer.
311
- const executor = await createExecutor({
312
- cwd: buildDir,
313
- customTools: [
314
- notes.tool,
315
- notes.gapTool,
316
- work.tool,
317
- ...createWebTools(),
318
- createScriptTool({ kind: "unit", script: scripts.unit, run: () => runUnitScript(buildDir, scripts.unit), runs, watch: loop }),
319
- ...selfChecks,
320
- ...services.tools,
321
- ...fence.tools,
322
- createCopyResourceTool({ resources: linkedResources, dir: buildDir }),
323
- ],
324
- tools: [...fence.names, "run_unit_tests", ...selfChecks.map((tool) => tool.name), ...services.names, "update_notes", "report_spec_gap", "submit_work", "copy_resource", ...WEB_TOOLS],
325
- model: options.model,
326
- label: `${moduleName} spec change coding agent`,
327
- role: "coding",
328
- system: `${fence.note}\n\n${workspaceBlock({ dir: buildDir, hasMyDiff: true })}`,
329
- task,
330
- compaction: { instructions: CODER_COMPACTION },
331
- images: resourceImages(linkedResources),
332
- checkEnvironment: { run: () => runUnitScript(buildDir, scripts.unit), script: scripts.unit },
333
- });
334
- let response;
335
- let verified = false;
336
- let unitReviewStopped = false;
337
- let followUp = 0;
338
- /** The harness's runs of the unit testing script: each is an attempt it judged. */
339
- let attempts = 0;
340
- /** How many times the agent, having written nothing, was asked for a draft. */
341
- let draftAsks = 0;
342
- /** The functional specs this job regenerates again: their code is to be built anew, never left as it was. */
343
- const again = options.cases?.again ?? [];
344
- /** Regenerating again, the agent wrote nothing however it was asked. */
345
- let unchanged = false;
346
- /** What the unit testing script needs and does not find, last run. */
347
- let missing;
348
- /**
349
- * What no round could change, as the debugger found it - the unit testing script needs more time than a test run may
350
- * take, the script itself is wrong, this machine lacks what it runs: the pulse stops on it.
351
- */
352
- let blocked;
353
- /** The last round failed on the script's static checks alone: the unit tests passed. */
354
- let staticOnly = false;
355
- const testRemovals = [];
356
- const steering = options.steering;
357
- // The loop reaches the agent in its turn while there is one; between turns a steer waits for the next.
358
- if (steering !== undefined) {
359
- steering.deliver = (text) => {
360
- if (!executor.isStreaming)
361
- return false;
362
- void Promise.resolve(executor.steer(text)).catch(() => undefined);
363
- stage("the spec changed inside what it regenerates - the coding agent is told, in its turn");
364
- return true;
365
- };
366
- }
367
- /** A steer the agent has not had yet, given as its next turn: true when there was one. */
368
- const steerIfWaiting = async () => {
369
- const text = steering !== undefined ? waitingSteer(steering) : undefined;
370
- if (text === undefined)
371
- return false;
372
- markTold(steering);
373
- stage("the spec changed inside what it regenerates - the coding agent is told");
374
- response = await ask(executor, text, options.onDelta);
375
- return true;
376
- };
377
- try {
378
- stage("turri is implementing the spec change");
379
- let inventory = inventoryTests(buildDir);
380
- response = await ask(executor, BEGIN, options.onDelta);
381
- // Back and forth until the harness's run of the unit testing script passes - whatever the
382
- // agent ran, and whether it ran anything - or the rounds run out. Picks up where it left off
383
- // when called again.
384
- // The same failure, round after round: how many times each has been seen running.
385
- const seenFailures = new Map();
386
- // The debugger's model: its own role's, when the config names one, else a stronger one than the agent it helps -
387
- // the judge model when the config sets it, else the harness model.
388
- const projectConfig = configForSpec(tip.plainFile);
389
- const debuggerModel = modelSpec(inheritModel(projectConfig.judgeModel, inheritModel(projectConfig.harnessModel, modelOnly(options.model))));
390
- const untilPassing = async () => {
391
- for (; followUp < MAX_FOLLOW_UPS; followUp += 1) {
392
- // A steer that came between its turns: its own turn, then the tests run again.
393
- if (await steerIfWaiting())
394
- continue;
395
- const current = inventoryTests(buildDir);
396
- const removals = findTestRemovals(inventory, current);
397
- if (removals.length > 0) {
398
- // A removed spec takes its tests with it; the agent says which and why, as always.
399
- testRemovals.push(...removals);
400
- inventory = current;
401
- stage(`justifying ${removals.length} removed test${removals.length === 1 ? "" : "s"}`);
402
- response = await ask(executor, removalChallengePrompt(removals, "unit tests"), options.onDelta);
403
- continue;
404
- }
405
- // Conformance tests are the conformance step's, in the tests folder: none of them here.
406
- const misplaced = misplacedConformanceTests(buildDir);
407
- if (misplaced.length > 0) {
408
- stage(`conformance tests in the code folder - sending ${misplaced.length === 1 ? "it" : "them"} back`);
409
- response = await ask(executor, misplacedTestsPrompt(misplaced, buildDir), options.onDelta);
410
- continue;
411
- }
412
- // Regenerating functional specs again, nothing written is never the answer: sent back to build them anew, and
413
- // still nothing, the work does not land.
414
- if (again.length > 0 && wroteNothing(buildDir, digestsBefore)) {
415
- if (draftAsks >= AGAIN_ASKS) {
416
- unchanged = true;
417
- stage("the coding agent regenerated nothing again - undoing the change");
418
- return false;
419
- }
420
- draftAsks += 1;
421
- stage("the coding agent has changed nothing yet - sending it back to build what it regenerates again anew");
422
- response = await ask(executor, againPrompt(again), options.onDelta);
423
- continue;
424
- }
425
- // Nothing written - a turn spent planning - leaves nothing to test or review: ask for a best-guess draft, or why none.
426
- if (draftAsks < DRAFT_ASKS && wroteNothing(buildDir, digestsBefore)) {
427
- draftAsks += 1;
428
- stage("the coding agent has changed nothing yet - asking for a best-guess draft, or why the change needs no code");
429
- response = await ask(executor, draftPrompt(), options.onDelta);
430
- continue;
431
- }
432
- stage(`running the unit testing script (attempt ${attempts + 1})`);
433
- attempts += 1;
434
- const verdict = await gate.verify(runs);
435
- if (verdict.ok)
436
- stage(`unit tests pass (attempt ${attempts})`);
437
- staticOnly = !verdict.ok && verdict.staticOnly;
438
- // A toolchain the script cannot find is no failure of the code, and the agents install nothing: the person installs
439
- // it on this machine, so the job stops now and asks them.
440
- missing = verdict.ok ? undefined : verdict.missing;
441
- if (missing !== undefined) {
442
- stage(`the unit testing script cannot run: ${missing.command ?? "a toolchain it needs"} is not installed on this machine - stopping`);
443
- return false;
444
- }
445
- if (!verdict.ok) {
446
- // Failing the same way STUCK_ROUNDS times running, or the agent stopped for going round in circles in its own
447
- // runs: a debugger looks at it with fresh eyes, on a stronger model, and the coding agent is given what it found
448
- // with the failure. The rounds go on as before - and it looks again if it repeats.
449
- const key = failureSignature(verdict.run);
450
- const seen = key !== undefined ? (seenFailures.get(key) ?? 0) + 1 : 0;
451
- seenFailures.clear();
452
- if (key !== undefined)
453
- seenFailures.set(key, seen);
454
- let prompt = verdict.prompt;
455
- const circling = loop.stuck;
456
- // A run the time limit stopped is looked at at once: whether something hangs, or the suite only needs more time.
457
- const timedOut = verdict.run.timedOut === true;
458
- if (circling || timedOut || (key !== undefined && seen >= STUCK_ROUNDS)) {
459
- if (key !== undefined)
460
- seenFailures.delete(key);
461
- const times = circling ? Math.max(seen, loop.failing) : seen;
462
- loop.reset();
463
- stage(circling
464
- ? `the coding agent is going round in circles - ${times} failing runs - a debugger looks at it with fresh eyes`
465
- : timedOut && seen < STUCK_ROUNDS
466
- ? `the unit testing script did not finish in ${Math.round(verdict.run.timeoutMs / 1000)}s - a debugger works out whether something hangs`
467
- : `the same failure ${seen} times - a debugger looks at it with fresh eyes`);
468
- const found = await healing("debugger", () => debugFailure({
469
- buildDir,
470
- failure: verdict.run.output,
471
- times,
472
- task: steeredChange() ?? codingText ?? changeText ?? options.diff ?? "",
473
- script: verdict.script,
474
- run: verdict.run,
475
- label: `${moduleName} spec change`,
476
- ...(debuggerModel !== undefined ? { model: debuggerModel } : {}),
477
- onDelta: options.onDelta,
478
- }), (finding) => finding?.rootCause);
479
- // Nothing hangs: the suite needs more time than a test run may take, and no agent can give it that.
480
- if (found?.tooSlow === true) {
481
- stage(`the unit testing script needs more than the ${Math.round(verdict.run.timeoutMs / 1000)}s a test run may take - stopping`);
482
- blocked = { error: timeLimitError(verdict.run, { moduleName, script: verdict.script, kind: "unit", reason: found.rootCause }), why: "the unit testing script needs more time than a test run may take" };
483
- return false;
484
- }
485
- // Not the code's: no round would pass the script, the coding agent may change neither it nor this machine.
486
- if (found?.atFault !== undefined) {
487
- stage(found.atFault === "script"
488
- ? "the debugger finds the unit testing script itself is wrong - no change to the code would pass it - stopping"
489
- : "the debugger finds this machine lacks what the unit testing script runs - stopping");
490
- const error = scriptFaultError(found.atFault, { moduleName, script: verdict.script, kind: "unit", reason: found.rootCause, fix: found.fix });
491
- blocked = { error, why: found.atFault === "script" ? "the unit testing script itself is wrong" : "this machine lacks what the unit testing script runs" };
492
- return false;
493
- }
494
- if (found !== undefined) {
495
- const cause = found.rootCause.split("\n")[0].slice(0, 240);
496
- reportActivity(` the debugger: ${cause.slice(0, 160)}`);
497
- diagnosed.push(cause);
498
- // A lesson that cost a debugger to learn is kept for every agent after - not left to the coding agent to write down.
499
- recordNote(buildDir, "pitfalls", `the debugger, after ${times} failing runs: ${cause} - the fix: ${found.fix.split("\n")[0].slice(0, 200)}`, `${moduleName} spec change`);
500
- prompt = [
501
- verdict.prompt,
502
- "",
503
- circling
504
- ? `You went round in circles - it has failed ${times} times since it last passed, the code back where it had been -`
505
- : `It has failed this same way ${seen} times in a row,`,
506
- "so a debugger looked at it with fresh eyes - it read the code, the tests, the build files and the testing script.",
507
- "This is what it found. Check it against the code, then make the fix it names, rather than another variation on what",
508
- "you tried before.",
509
- "",
510
- diagnosisText(found),
511
- ].join("\n");
512
- }
513
- }
514
- record({ kind: "gate.round", gate: "unit tests", round: followUp + 1, of: MAX_FOLLOW_UPS, ...(key !== undefined ? { signature: signatureHash(key) } : {}) });
515
- stage(`${verdict.staticOnly ? "static checks" : "unit tests"} not passing - fixing (round ${followUp + 1} of ${MAX_FOLLOW_UPS})`);
516
- response = await ask(executor, prompt, options.onDelta);
517
- continue;
518
- }
519
- // Passing on what it was told before - a steer since, and they run again.
520
- if (await steerIfWaiting())
521
- continue;
522
- return true;
523
- }
524
- return false;
525
- };
526
- verified = await untilPassing();
527
- // The unit tests pass - now whether they test what the change says, so they fail when it breaks.
528
- if (verified && (options.unitReview ?? configForSpec(tip.plainFile).review) === true) {
529
- const reviewed = await untilUnitTestsReviewed({
530
- buildDir,
531
- atStart: digestsBefore,
532
- what: `the spec change to module \`${moduleName}\``,
533
- // As the coding agent had it: the spec the code was built from, and the change.
534
- // Steered before the review, the change as the agent has it now.
535
- spec: reviewedSpec({ moduleName, specifications: specificationsBefore, funcIds: builtFuncIds, modules: sectionModules(builtNow, moduleName), required: getInheritedFunctionalSpecs(builtNow), change: steeredChange() ?? codingText ?? changeText ?? options.diff, ...(startedFrom !== undefined ? { base: startedFrom } : {}) }),
536
- forChange: true,
537
- ...(options.cases !== undefined ? { cases: options.cases } : {}),
538
- label: `${moduleName} spec change`,
539
- ...(mutationTesting ? { unitScript: scripts.unit } : {}),
540
- testingScript: { path: relative(root, scripts.unit), content: readFileSync(scripts.unit, "utf8") },
541
- model: options.judgeModel ?? modelSpec(inheritModel(configForSpec(tip.plainFile).judgeModel, modelOnly(options.model))),
542
- send: async (next) => {
543
- response = await ask(executor, next, options.onDelta);
544
- },
545
- untilPassing,
546
- stage,
547
- onDelta: options.onDelta,
548
- work,
549
- });
550
- stage(`the review took ${reviewed.reviews} review${reviewed.reviews === 1 ? "" : "s"}`);
551
- verified = reviewed.passed;
552
- if (!reviewed.passed)
553
- unitReviewStopped = true;
554
- }
555
- // A steer that came during the review: the agent's turn, and the tests until they pass - within its rounds.
556
- while (verified && steering !== undefined && waitingSteer(steering) !== undefined)
557
- verified = await untilPassing();
558
- // Notes are kept only with work that lands: work that does not is rolled back, notes and all.
559
- if (verified) {
560
- stage("checking the working notes were left");
561
- await notes.ensureWritten((next) => ask(executor, next, options.onDelta, NOTES_TURN), passedOutcome("unit testing script"));
562
- }
563
- }
564
- finally {
565
- if (steering !== undefined)
566
- steering.deliver = undefined;
567
- executor.dispose();
568
- await services.stopAll();
569
- }
570
- // Passing means the harness's own run of the unit testing script passed, last.
571
- const unitPassed = verified;
572
- const files = diffFiles(digestsBefore, digestFiles(buildDir));
573
- // The report is what the agent said it did, handed over with submit_work - not what it said along the way, which reads
574
- // as a plan ("next I'll check...") when its last words came before its last tool calls. Without an account, its words.
575
- const account = work.last()?.summary.trim();
576
- const base = {
577
- moduleName,
578
- buildDir,
579
- diff: applied,
580
- response: account !== undefined && account !== "" ? account : response,
581
- runs,
582
- attempts,
583
- testRemovals,
584
- files,
585
- ...(steering !== undefined && steering.steers > 0 ? { steered: [...steering.notes] } : {}),
586
- // A gap the agent met is the person's to decide, whether it landed or not.
587
- specGaps: gapsSince(gapsFrom, [buildDir]),
588
- diagnosed,
589
- };
590
- /** The change landed: what the code is built from is now the spec with the change in, committed with it. */
591
- const land = () => {
592
- stage("recording what the code is built from, and committing it");
593
- // Steered, it is built from the spec as it was steered to - the record the loop moved with it.
594
- writeCodeRecord(buildDir, steering?.target ?? tree);
595
- landWork(buildDir, `spec diff: ${summarizeDiff(options.diff)}`, options.diff);
596
- };
597
- if (!unitPassed) {
598
- if (!unchanged)
599
- stage(unitReviewStopped ? "the unit tests pass but still leave the change untested - undoing the change" : "unit tests NOT passing - undoing the change");
600
- abandonWork(unit, moduleName, missing !== undefined
601
- ? "the unit testing script could not run"
602
- : unchanged
603
- ? "regenerating again, the coding agent built nothing anew"
604
- : blocked !== undefined
605
- ? blocked.why
606
- : staticOnly
607
- ? "the spec change did not pass its static checks"
608
- : "the spec change did not pass its unit tests");
609
- // The environment lacks what the testing script needs: the pulse stops, rolled back, and the person is told.
610
- if (missing !== undefined) {
611
- throw toolchainError(missing, { moduleName, script: scripts.unit, kind: "unit" });
612
- }
613
- if (blocked !== undefined)
614
- throw blocked.error;
615
- return { ...base, passed: false, stoppedAt: "unit tests", ...(staticOnly && !unitReviewStopped ? { staticChecks: true } : {}) };
616
- }
617
- stage("unit tests pass - landing the change on them");
618
- land();
619
- return { ...base, passed: true, stoppedAt: null };
620
- }
621
- /** Spec gaps a pulse's agents met, as its report says them: for the conversation to put to the person. */
622
- export function specGapsText(gaps) {
623
- if (gaps === undefined || gaps.length === 0)
624
- return [];
625
- return [
626
- "",
627
- "Spec gaps its agents met - the spec does not say, so they decided, each as an assumption in the codebase's notes. Put " +
628
- "each to the user, and write the ones they decide into the spec - the pulse that builds it is told the assumption " +
629
- "it replaces:",
630
- ...gaps.map((gap) => `- ${gap.question} Meanwhile: ${gap.assumption}`),
631
- ];
632
- }
633
- /** What a rendered spec change did, for the agent and the person. */
634
- export function describeSpecDiff(result) {
635
- const { added, changed, removed } = result.files;
636
- if (result.restructured === true) {
637
- return `The specs were only restructured: ${result.moduleName}'s code (${result.buildDir}) is already built from the same spec, so nothing was rendered - the spec is recorded as it is now laid out.`;
638
- }
639
- return [
640
- result.passed
641
- ? `Rendered the spec change in ${result.moduleName}'s codebase (${result.buildDir}).`
642
- : describeStop({
643
- moduleName: result.moduleName,
644
- at: result.stoppedAt,
645
- runs: result.runs,
646
- attempts: result.attempts,
647
- ...(result.missingToolchain !== undefined ? { missingToolchain: result.missingToolchain } : {}),
648
- ...(result.staticChecks === true ? { staticChecks: true } : {}),
649
- }),
650
- result.diff === "applied" ? "The diff was applied to the .plain files." : "The diff was already applied.",
651
- `Files: ${added.length} added, ${changed.length} changed, ${removed.length} removed.`,
652
- result.testRemovals.length > 0 ? `Unit tests removed and justified: ${result.testRemovals.map((r) => r.file).join(", ")}.` : "",
653
- ...(result.steered !== undefined ? [`Steered while it ran - the spec changed inside what it was regenerating, and its agent was told: ${result.steered.join("; ")}.`] : []),
654
- ...specGapsText(result.specGaps),
655
- "",
656
- result.response,
657
- ]
658
- .filter((line) => line !== "")
659
- .join("\n");
660
- }