@turri-dev/cli 0.4.2 → 0.4.3-next.4908c8d

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 (484) hide show
  1. package/README.md +24 -3
  2. package/dist/banner.js +259 -0
  3. package/dist/capture-cli.js +77 -0
  4. package/dist/capture-view.js +99 -0
  5. package/dist/chat-commands.js +9 -63
  6. package/dist/chat-models.js +17 -15
  7. package/dist/chat-tab-header.js +90 -0
  8. package/dist/chat-tabs.js +100 -0
  9. package/dist/chat-terminal.js +170 -61
  10. package/dist/chat-waiting.js +7 -24
  11. package/dist/cli-options.js +11 -7
  12. package/dist/cli-root.js +141 -0
  13. package/dist/cli.js +48 -36
  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 -3211
  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 -233
  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 +56 -0
  29. package/dist/pointer-hover.js +48 -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 +7 -18
  35. package/dist/regenerate/side-panel.js +158 -22
  36. package/dist/regenerate/spec-map-view.js +25 -70
  37. package/dist/regenerate-cli.js +7 -11
  38. package/dist/reopen.js +80 -0
  39. package/dist/resume-line.js +5 -2
  40. package/dist/skill-progress.js +25 -0
  41. package/dist/skill-report.js +52 -0
  42. package/dist/terminal-marks.js +21 -0
  43. package/dist/terminal-notifications.js +219 -0
  44. package/dist/terminal-view.js +275 -0
  45. package/dist/turri-versions.js +64 -6
  46. package/docs/README.md +4 -2
  47. package/docs/capture.md +227 -0
  48. package/docs/chats.md +14 -10
  49. package/docs/claude-subscription.md +1 -1
  50. package/docs/config.md +23 -8
  51. package/docs/development.md +30 -61
  52. package/docs/headless.md +3 -1
  53. package/docs/hosting.md +3 -251
  54. package/docs/installation.md +5 -3
  55. package/docs/launch.md +3 -3
  56. package/docs/regenerating.md +1 -1
  57. package/docs/sandbox.md +4 -2
  58. package/docs/sentinel.md +13 -13
  59. package/docs/theming.md +3 -3
  60. package/docs/using.md +14 -6
  61. package/package.json +15 -33
  62. package/dist/ask.d.ts +0 -90
  63. package/dist/ask.js +0 -170
  64. package/dist/background-skills.d.ts +0 -53
  65. package/dist/background-skills.js +0 -121
  66. package/dist/bedrock-region.d.ts +0 -66
  67. package/dist/bedrock-region.js +0 -144
  68. package/dist/brand.d.ts +0 -13
  69. package/dist/btw.d.ts +0 -69
  70. package/dist/btw.js +0 -174
  71. package/dist/chat-commands.d.ts +0 -25
  72. package/dist/chat-idle.d.ts +0 -7
  73. package/dist/chat-idle.js +0 -20
  74. package/dist/chat-models.d.ts +0 -22
  75. package/dist/chat-records.d.ts +0 -50
  76. package/dist/chat-records.js +0 -107
  77. package/dist/chat-scope.d.ts +0 -14
  78. package/dist/chat-scope.js +0 -15
  79. package/dist/chat-skills.d.ts +0 -17
  80. package/dist/chat-skills.js +0 -18
  81. package/dist/chat-terminal.d.ts +0 -24
  82. package/dist/chat-ui.d.ts +0 -33
  83. package/dist/chat-waiting.d.ts +0 -64
  84. package/dist/chats.d.ts +0 -338
  85. package/dist/chats.js +0 -996
  86. package/dist/cli-options.d.ts +0 -24
  87. package/dist/cli.d.ts +0 -9
  88. package/dist/config-edit.d.ts +0 -83
  89. package/dist/config-edit.js +0 -390
  90. package/dist/config.d.ts +0 -415
  91. package/dist/config.js +0 -757
  92. package/dist/conform-cli.d.ts +0 -1
  93. package/dist/conformance-switch.d.ts +0 -25
  94. package/dist/conformance-switch.js +0 -86
  95. package/dist/cultivate-cli.d.ts +0 -1
  96. package/dist/doctor-tool.d.ts +0 -11
  97. package/dist/doctor-tool.js +0 -33
  98. package/dist/drift-cli.d.ts +0 -1
  99. package/dist/environment.d.ts +0 -37
  100. package/dist/environment.js +0 -109
  101. package/dist/extension.d.ts +0 -208
  102. package/dist/genome.d.ts +0 -77
  103. package/dist/genome.js +0 -288
  104. package/dist/graph.d.ts +0 -52
  105. package/dist/graph.js +0 -247
  106. package/dist/host-session.d.ts +0 -112
  107. package/dist/host-session.js +0 -103
  108. package/dist/host.d.ts +0 -40
  109. package/dist/host.js +0 -54
  110. package/dist/identity.d.ts +0 -7
  111. package/dist/identity.js +0 -74
  112. package/dist/init-config.d.ts +0 -169
  113. package/dist/init-config.js +0 -840
  114. package/dist/installed-providers.d.ts +0 -40
  115. package/dist/installed-providers.js +0 -98
  116. package/dist/jellyfish.d.ts +0 -40
  117. package/dist/judge.d.ts +0 -25
  118. package/dist/judge.js +0 -62
  119. package/dist/launch-agent.d.ts +0 -62
  120. package/dist/launch-agent.js +0 -339
  121. package/dist/launch-cli.d.ts +0 -1
  122. package/dist/launch-session.d.ts +0 -68
  123. package/dist/launch-session.js +0 -225
  124. package/dist/launch-tools.d.ts +0 -28
  125. package/dist/launch-tools.js +0 -72
  126. package/dist/launch-track.d.ts +0 -175
  127. package/dist/launch-track.js +0 -497
  128. package/dist/lineage-cli.d.ts +0 -1
  129. package/dist/loop-cli.d.ts +0 -35
  130. package/dist/loop-tools.d.ts +0 -103
  131. package/dist/loop-tools.js +0 -357
  132. package/dist/model-check.d.ts +0 -72
  133. package/dist/model-check.js +0 -162
  134. package/dist/module-report.d.ts +0 -9
  135. package/dist/new-project.d.ts +0 -5
  136. package/dist/new-project.js +0 -31
  137. package/dist/notice.d.ts +0 -115
  138. package/dist/notice.js +0 -61
  139. package/dist/parse-cli.d.ts +0 -1
  140. package/dist/parse-tool.d.ts +0 -9
  141. package/dist/parse-tool.js +0 -33
  142. package/dist/pi-launch.d.ts +0 -1
  143. package/dist/pi-settings.d.ts +0 -4
  144. package/dist/pi.d.ts +0 -248
  145. package/dist/pi.js +0 -889
  146. package/dist/picture-row.d.ts +0 -10
  147. package/dist/plain/check.d.ts +0 -63
  148. package/dist/plain/check.js +0 -236
  149. package/dist/plain/concepts.d.ts +0 -37
  150. package/dist/plain/concepts.js +0 -283
  151. package/dist/plain/cycles.d.ts +0 -21
  152. package/dist/plain/cycles.js +0 -190
  153. package/dist/plain/errors.d.ts +0 -26
  154. package/dist/plain/errors.js +0 -50
  155. package/dist/plain/files.d.ts +0 -47
  156. package/dist/plain/files.js +0 -161
  157. package/dist/plain/graph.d.ts +0 -107
  158. package/dist/plain/graph.js +0 -194
  159. package/dist/plain/highlight.d.ts +0 -43
  160. package/dist/plain/highlight.js +0 -196
  161. package/dist/plain/index.d.ts +0 -18
  162. package/dist/plain/index.js +0 -18
  163. package/dist/plain/liquid.d.ts +0 -22
  164. package/dist/plain/liquid.js +0 -124
  165. package/dist/plain/markdown.d.ts +0 -103
  166. package/dist/plain/markdown.js +0 -330
  167. package/dist/plain/module-concepts.d.ts +0 -32
  168. package/dist/plain/module-concepts.js +0 -80
  169. package/dist/plain/parser.d.ts +0 -163
  170. package/dist/plain/parser.js +0 -930
  171. package/dist/plain/plain.tmLanguage.json +0 -150
  172. package/dist/plain/project.d.ts +0 -48
  173. package/dist/plain/project.js +0 -155
  174. package/dist/plain/spec.d.ts +0 -152
  175. package/dist/plain/spec.js +0 -265
  176. package/dist/plain/stdlib.d.ts +0 -16
  177. package/dist/plain/stdlib.js +0 -48
  178. package/dist/plain/test-plain-file.d.ts +0 -59
  179. package/dist/plain/test-plain-file.js +0 -232
  180. package/dist/plain-files.d.ts +0 -21
  181. package/dist/plain-files.js +0 -156
  182. package/dist/question-dialog.d.ts +0 -55
  183. package/dist/questioning.d.ts +0 -55
  184. package/dist/questioning.js +0 -109
  185. package/dist/quiet.d.ts +0 -34
  186. package/dist/regenerate/activity.d.ts +0 -227
  187. package/dist/regenerate/activity.js +0 -250
  188. package/dist/regenerate/agent-env.d.ts +0 -51
  189. package/dist/regenerate/agent-env.js +0 -311
  190. package/dist/regenerate/agent-shell.d.ts +0 -54
  191. package/dist/regenerate/agent-shell.js +0 -121
  192. package/dist/regenerate/arbiter.d.ts +0 -68
  193. package/dist/regenerate/arbiter.js +0 -133
  194. package/dist/regenerate/audit.d.ts +0 -69
  195. package/dist/regenerate/audit.js +0 -212
  196. package/dist/regenerate/base-folder.d.ts +0 -70
  197. package/dist/regenerate/base-folder.js +0 -186
  198. package/dist/regenerate/cases.d.ts +0 -12
  199. package/dist/regenerate/cases.js +0 -149
  200. package/dist/regenerate/change-view.d.ts +0 -23
  201. package/dist/regenerate/change-view.js +0 -153
  202. package/dist/regenerate/chunk-plan.d.ts +0 -217
  203. package/dist/regenerate/chunk-plan.js +0 -937
  204. package/dist/regenerate/codebase.d.ts +0 -21
  205. package/dist/regenerate/codebase.js +0 -75
  206. package/dist/regenerate/command-check.d.ts +0 -66
  207. package/dist/regenerate/command-check.js +0 -508
  208. package/dist/regenerate/compaction.d.ts +0 -13
  209. package/dist/regenerate/compaction.js +0 -20
  210. package/dist/regenerate/confine.d.ts +0 -69
  211. package/dist/regenerate/confine.js +0 -311
  212. package/dist/regenerate/conform.d.ts +0 -66
  213. package/dist/regenerate/conform.js +0 -132
  214. package/dist/regenerate/conformance-agents.d.ts +0 -388
  215. package/dist/regenerate/conformance-agents.js +0 -1162
  216. package/dist/regenerate/conformance.d.ts +0 -191
  217. package/dist/regenerate/conformance.js +0 -1035
  218. package/dist/regenerate/conversation-writes.d.ts +0 -10
  219. package/dist/regenerate/conversation-writes.js +0 -100
  220. package/dist/regenerate/credentials.d.ts +0 -18
  221. package/dist/regenerate/credentials.js +0 -88
  222. package/dist/regenerate/debug-log.d.ts +0 -56
  223. package/dist/regenerate/debug-log.js +0 -236
  224. package/dist/regenerate/debugger.d.ts +0 -36
  225. package/dist/regenerate/debugger.js +0 -133
  226. package/dist/regenerate/delivery.d.ts +0 -2
  227. package/dist/regenerate/diagnose-job.d.ts +0 -2
  228. package/dist/regenerate/diagnose-job.js +0 -40
  229. package/dist/regenerate/diagnose.d.ts +0 -46
  230. package/dist/regenerate/diagnose.js +0 -92
  231. package/dist/regenerate/diff-view.d.ts +0 -64
  232. package/dist/regenerate/drift.d.ts +0 -120
  233. package/dist/regenerate/drift.js +0 -285
  234. package/dist/regenerate/environment-error.d.ts +0 -167
  235. package/dist/regenerate/environment-error.js +0 -342
  236. package/dist/regenerate/failure-reports.d.ts +0 -28
  237. package/dist/regenerate/failure-reports.js +0 -79
  238. package/dist/regenerate/job-log.d.ts +0 -30
  239. package/dist/regenerate/job-log.js +0 -105
  240. package/dist/regenerate/job-panel.d.ts +0 -122
  241. package/dist/regenerate/job-panel.js +0 -339
  242. package/dist/regenerate/jobs-tree.d.ts +0 -75
  243. package/dist/regenerate/jobs.d.ts +0 -231
  244. package/dist/regenerate/jobs.js +0 -522
  245. package/dist/regenerate/lanes.d.ts +0 -16
  246. package/dist/regenerate/lanes.js +0 -32
  247. package/dist/regenerate/launch.d.ts +0 -256
  248. package/dist/regenerate/launch.js +0 -689
  249. package/dist/regenerate/ledger-view.d.ts +0 -87
  250. package/dist/regenerate/ledger-view.js +0 -325
  251. package/dist/regenerate/ledger.d.ts +0 -368
  252. package/dist/regenerate/ledger.js +0 -357
  253. package/dist/regenerate/lineage.d.ts +0 -105
  254. package/dist/regenerate/lineage.js +0 -485
  255. package/dist/regenerate/list-arguments.d.ts +0 -21
  256. package/dist/regenerate/list-arguments.js +0 -121
  257. package/dist/regenerate/loop.d.ts +0 -423
  258. package/dist/regenerate/loop.js +0 -2079
  259. package/dist/regenerate/masking.d.ts +0 -19
  260. package/dist/regenerate/masking.js +0 -95
  261. package/dist/regenerate/model-names.d.ts +0 -33
  262. package/dist/regenerate/model-names.js +0 -92
  263. package/dist/regenerate/notes.d.ts +0 -159
  264. package/dist/regenerate/notes.js +0 -446
  265. package/dist/regenerate/os-sandbox.d.ts +0 -93
  266. package/dist/regenerate/os-sandbox.js +0 -283
  267. package/dist/regenerate/panel-dock.d.ts +0 -23
  268. package/dist/regenerate/paths.d.ts +0 -110
  269. package/dist/regenerate/paths.js +0 -190
  270. package/dist/regenerate/plain-palette.d.ts +0 -34
  271. package/dist/regenerate/prompt.d.ts +0 -230
  272. package/dist/regenerate/prompt.js +0 -741
  273. package/dist/regenerate/pulse-files.d.ts +0 -14
  274. package/dist/regenerate/pulse-files.js +0 -63
  275. package/dist/regenerate/records.d.ts +0 -132
  276. package/dist/regenerate/records.js +0 -327
  277. package/dist/regenerate/regenerate.d.ts +0 -106
  278. package/dist/regenerate/regenerate.js +0 -660
  279. package/dist/regenerate/regression.d.ts +0 -58
  280. package/dist/regenerate/regression.js +0 -188
  281. package/dist/regenerate/renames.d.ts +0 -42
  282. package/dist/regenerate/renames.js +0 -185
  283. package/dist/regenerate/requires.d.ts +0 -117
  284. package/dist/regenerate/requires.js +0 -377
  285. package/dist/regenerate/resources.d.ts +0 -57
  286. package/dist/regenerate/resources.js +0 -162
  287. package/dist/regenerate/scripts-being-written.d.ts +0 -19
  288. package/dist/regenerate/scripts-being-written.js +0 -30
  289. package/dist/regenerate/self-check.d.ts +0 -29
  290. package/dist/regenerate/self-check.js +0 -119
  291. package/dist/regenerate/services.d.ts +0 -28
  292. package/dist/regenerate/services.js +0 -158
  293. package/dist/regenerate/shell.d.ts +0 -91
  294. package/dist/regenerate/shell.js +0 -320
  295. package/dist/regenerate/side-panel.d.ts +0 -59
  296. package/dist/regenerate/spec-map-view.d.ts +0 -139
  297. package/dist/regenerate/spec-map.d.ts +0 -160
  298. package/dist/regenerate/spec-map.js +0 -596
  299. package/dist/regenerate/spec-steps.d.ts +0 -180
  300. package/dist/regenerate/spec-steps.js +0 -729
  301. package/dist/regenerate/standing.d.ts +0 -28
  302. package/dist/regenerate/standing.js +0 -30
  303. package/dist/regenerate/state.d.ts +0 -21
  304. package/dist/regenerate/state.js +0 -10
  305. package/dist/regenerate/steering.d.ts +0 -56
  306. package/dist/regenerate/steering.js +0 -119
  307. package/dist/regenerate/stop-report.d.ts +0 -43
  308. package/dist/regenerate/stop-report.js +0 -160
  309. package/dist/regenerate/submit-work.d.ts +0 -44
  310. package/dist/regenerate/submit-work.js +0 -76
  311. package/dist/regenerate/test-kinds.d.ts +0 -85
  312. package/dist/regenerate/test-kinds.js +0 -171
  313. package/dist/regenerate/test-scripts.d.ts +0 -235
  314. package/dist/regenerate/test-scripts.js +0 -843
  315. package/dist/regenerate/testing-steps.d.ts +0 -52
  316. package/dist/regenerate/testing-steps.js +0 -129
  317. package/dist/regenerate/testing.d.ts +0 -150
  318. package/dist/regenerate/testing.js +0 -438
  319. package/dist/regenerate/transcript-view.d.ts +0 -21
  320. package/dist/regenerate/unit-gate.d.ts +0 -27
  321. package/dist/regenerate/unit-gate.js +0 -20
  322. package/dist/regenerate/unit-review.d.ts +0 -152
  323. package/dist/regenerate/unit-review.js +0 -361
  324. package/dist/regenerate/web.d.ts +0 -61
  325. package/dist/regenerate/web.js +0 -256
  326. package/dist/regenerate/workspace.d.ts +0 -12
  327. package/dist/regenerate/workspace.js +0 -99
  328. package/dist/regenerate-cli.d.ts +0 -1
  329. package/dist/resume-line.d.ts +0 -2
  330. package/dist/review/live.d.ts +0 -72
  331. package/dist/review/live.js +0 -166
  332. package/dist/rules.d.ts +0 -20
  333. package/dist/rules.js +0 -47
  334. package/dist/run-report.d.ts +0 -88
  335. package/dist/run-report.js +0 -338
  336. package/dist/screen-padding.d.ts +0 -28
  337. package/dist/self-invocation.d.ts +0 -36
  338. package/dist/self-invocation.js +0 -137
  339. package/dist/sentinel-chat.d.ts +0 -19
  340. package/dist/sentinel-chat.js +0 -221
  341. package/dist/sentinel-check.d.ts +0 -36
  342. package/dist/sentinel-check.js +0 -78
  343. package/dist/sentinel.d.ts +0 -107
  344. package/dist/sentinel.js +0 -599
  345. package/dist/settings.d.ts +0 -45
  346. package/dist/settings.js +0 -378
  347. package/dist/setup.d.ts +0 -97
  348. package/dist/setup.js +0 -428
  349. package/dist/skill-progress.d.ts +0 -46
  350. package/dist/skill.d.ts +0 -102
  351. package/dist/skill.js +0 -147
  352. package/dist/skills.d.ts +0 -54
  353. package/dist/skills.js +0 -111
  354. package/dist/spawn-async.d.ts +0 -18
  355. package/dist/spawn-async.js +0 -35
  356. package/dist/stack.d.ts +0 -80
  357. package/dist/stack.js +0 -206
  358. package/dist/stdlib.d.ts +0 -43
  359. package/dist/stdlib.js +0 -118
  360. package/dist/surface.d.ts +0 -5
  361. package/dist/surface.js +0 -18
  362. package/dist/terminal-images.d.ts +0 -2
  363. package/dist/test-plain-files.d.ts +0 -41
  364. package/dist/test-plain-files.js +0 -172
  365. package/dist/tools.d.ts +0 -101
  366. package/dist/tools.js +0 -242
  367. package/dist/turri-versions.d.ts +0 -71
  368. package/genome/rules/bullet-continuation.md +0 -61
  369. package/genome/rules/concise-specs-examples.md +0 -460
  370. package/genome/rules/concise-specs-integration-examples.md +0 -281
  371. package/genome/rules/concise-specs.md +0 -80
  372. package/genome/rules/definitions.md +0 -107
  373. package/genome/rules/examples/integration-embedded-testing/run_conformance_tests_java.sh +0 -161
  374. package/genome/rules/examples/integration-embedded-testing/run_unittests_java.sh +0 -50
  375. package/genome/rules/exported-concepts.md +0 -39
  376. package/genome/rules/func-specs.md +0 -164
  377. package/genome/rules/impl-reqs.md +0 -68
  378. package/genome/rules/import-modules.md +0 -49
  379. package/genome/rules/integration-embedded-testing.md +0 -273
  380. package/genome/rules/integration-embedded.md +0 -171
  381. package/genome/rules/integration-standalone.md +0 -135
  382. package/genome/rules/integrations.md +0 -136
  383. package/genome/rules/linked-resources.md +0 -76
  384. package/genome/rules/module-structure.md +0 -112
  385. package/genome/rules/project-model.md +0 -69
  386. package/genome/rules/required-concepts.md +0 -44
  387. package/genome/rules/requires-modules.md +0 -81
  388. package/genome/rules/semantic-ids.md +0 -49
  389. package/genome/rules/stdlib.md +0 -37
  390. package/genome/rules/test-plain-files.md +0 -138
  391. package/genome/rules/test-reqs.md +0 -57
  392. package/genome/rules/turri-regeneration.md +0 -66
  393. package/genome/skills/analyze-2-func-specs/SKILL.md +0 -116
  394. package/genome/skills/analyze-func-specs/SKILL.md +0 -137
  395. package/genome/skills/break-down-func-spec/SKILL.md +0 -229
  396. package/genome/skills/consolidate-concepts/SKILL.md +0 -192
  397. package/genome/skills/convert-old-syntax/SKILL.md +0 -68
  398. package/genome/skills/convert-old-syntax/references/rubric.md +0 -11
  399. package/genome/skills/debug-specs/SKILL.md +0 -194
  400. package/genome/skills/implement-conformance-testing-script/SKILL.md +0 -247
  401. package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_cypress.ps1 +0 -337
  402. package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_golang.ps1 +0 -111
  403. package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_java.sh +0 -151
  404. package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_python.ps1 +0 -103
  405. package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_python.sh +0 -146
  406. package/genome/skills/implement-unit-testing-script/SKILL.md +0 -171
  407. package/genome/skills/implement-unit-testing-script/assets/run_unittests_flutter.ps1 +0 -87
  408. package/genome/skills/implement-unit-testing-script/assets/run_unittests_golang.ps1 +0 -73
  409. package/genome/skills/implement-unit-testing-script/assets/run_unittests_java.sh +0 -82
  410. package/genome/skills/implement-unit-testing-script/assets/run_unittests_python.ps1 +0 -81
  411. package/genome/skills/implement-unit-testing-script/assets/run_unittests_python.sh +0 -102
  412. package/genome/skills/implement-unit-testing-script/assets/run_unittests_react.ps1 +0 -87
  413. package/genome/skills/refactor-module/SKILL.md +0 -218
  414. package/genome/skills/resolve-section-ownership/SKILL.md +0 -64
  415. package/genome/skills/resolve-spec-conflict/SKILL.md +0 -102
  416. package/stdlib/backend/common.plain +0 -25
  417. package/stdlib/backend/conformance/common.plain +0 -12
  418. package/stdlib/backend/conformance/go-gin.plain +0 -9
  419. package/stdlib/backend/conformance/go-nethttp.plain +0 -9
  420. package/stdlib/backend/conformance/java-springboot.plain +0 -9
  421. package/stdlib/backend/conformance/python-django.plain +0 -9
  422. package/stdlib/backend/conformance/python-fastapi.plain +0 -9
  423. package/stdlib/backend/conformance/python-flask.plain +0 -9
  424. package/stdlib/backend/conformance/rust-axum.plain +0 -9
  425. package/stdlib/backend/conformance/typescript-express.plain +0 -9
  426. package/stdlib/backend/conformance/typescript-fastify.plain +0 -9
  427. package/stdlib/backend/conformance/typescript-nestjs.plain +0 -9
  428. package/stdlib/backend/go-gin.plain +0 -18
  429. package/stdlib/backend/go-nethttp.plain +0 -18
  430. package/stdlib/backend/java-springboot.plain +0 -19
  431. package/stdlib/backend/python-django.plain +0 -19
  432. package/stdlib/backend/python-fastapi.plain +0 -23
  433. package/stdlib/backend/python-flask.plain +0 -23
  434. package/stdlib/backend/rust-axum.plain +0 -17
  435. package/stdlib/backend/typescript-express.plain +0 -19
  436. package/stdlib/backend/typescript-fastify.plain +0 -19
  437. package/stdlib/backend/typescript-nestjs.plain +0 -19
  438. package/stdlib/cli/common.plain +0 -17
  439. package/stdlib/cli/conformance/common.plain +0 -11
  440. package/stdlib/cli/conformance/go-cobra.plain +0 -9
  441. package/stdlib/cli/conformance/go-flag.plain +0 -9
  442. package/stdlib/cli/conformance/java-picocli.plain +0 -9
  443. package/stdlib/cli/conformance/python-argparse.plain +0 -9
  444. package/stdlib/cli/conformance/python-click.plain +0 -9
  445. package/stdlib/cli/conformance/python-typer.plain +0 -9
  446. package/stdlib/cli/conformance/rust-clap.plain +0 -9
  447. package/stdlib/cli/conformance/typescript-commander.plain +0 -9
  448. package/stdlib/cli/go-cobra.plain +0 -14
  449. package/stdlib/cli/go-flag.plain +0 -14
  450. package/stdlib/cli/java-picocli.plain +0 -15
  451. package/stdlib/cli/python-argparse.plain +0 -18
  452. package/stdlib/cli/python-click.plain +0 -16
  453. package/stdlib/cli/python-typer.plain +0 -16
  454. package/stdlib/cli/rust-clap.plain +0 -14
  455. package/stdlib/cli/typescript-commander.plain +0 -17
  456. package/stdlib/frontend/angular.plain +0 -17
  457. package/stdlib/frontend/common.plain +0 -17
  458. package/stdlib/frontend/conformance/angular.plain +0 -5
  459. package/stdlib/frontend/conformance/common.plain +0 -11
  460. package/stdlib/frontend/conformance/react-vite.plain +0 -5
  461. package/stdlib/frontend/conformance/sveltekit-spa.plain +0 -5
  462. package/stdlib/frontend/conformance/vue-vite.plain +0 -5
  463. package/stdlib/frontend/react-vite.plain +0 -16
  464. package/stdlib/frontend/sveltekit-spa.plain +0 -16
  465. package/stdlib/frontend/vue-vite.plain +0 -16
  466. package/stdlib/lang/go.plain +0 -13
  467. package/stdlib/lang/java.plain +0 -12
  468. package/stdlib/lang/python.plain +0 -18
  469. package/stdlib/lang/rust.plain +0 -12
  470. package/stdlib/lang/typescript.plain +0 -13
  471. package/stdlib/library/common.plain +0 -15
  472. package/stdlib/library/conformance/common.plain +0 -9
  473. package/stdlib/library/conformance/go.plain +0 -9
  474. package/stdlib/library/conformance/java-gradle.plain +0 -9
  475. package/stdlib/library/conformance/java-maven.plain +0 -9
  476. package/stdlib/library/conformance/python.plain +0 -9
  477. package/stdlib/library/conformance/rust.plain +0 -9
  478. package/stdlib/library/conformance/typescript.plain +0 -9
  479. package/stdlib/library/go.plain +0 -12
  480. package/stdlib/library/java-gradle.plain +0 -13
  481. package/stdlib/library/java-maven.plain +0 -13
  482. package/stdlib/library/python.plain +0 -13
  483. package/stdlib/library/rust.plain +0 -12
  484. package/stdlib/library/typescript.plain +0 -15
@@ -1,339 +0,0 @@
1
- import { existsSync, readdirSync, readFileSync } from "node:fs";
2
- import { isAbsolute, join, relative, resolve, sep } from "node:path";
3
- import { createBashToolDefinition, createEditToolDefinition, createFindToolDefinition, createGrepToolDefinition, createLsToolDefinition, createReadToolDefinition, createWriteToolDefinition, defineTool, } from "@earendil-works/pi-coding-agent";
4
- import { Type } from "typebox";
5
- import { describeExport, describeFreed, describeHolder, freeHeld, howToFree, launchLogDir, listenersOf, runningLaunched, shortPath, startLaunched, turriFrees, whoHolds, } from "./regenerate/launch.js";
6
- import { machineChange, machineChangeReason } from "./regenerate/command-check.js";
7
- import { projectDirOf } from "./regenerate/paths.js";
8
- import { ask, BEGIN, createExecutor } from "./pi.js";
9
- /**
10
- * The person's own shell, in the host codebase: it installs what the launch needs into the project, and runs it. It
11
- * changes nothing of the machine's - no toolchain installed, no system setting changed: a command that would is refused.
12
- */
13
- export function launchShell(dir) {
14
- const bash = createBashToolDefinition(dir);
15
- return {
16
- ...bash,
17
- description: `${bash.description}\n\nIt runs on the person's own machine, in ${shortPath(dir)}. Never start a server here: activate does. It installs nothing on the machine and changes none of its settings: what the machine lacks, the person installs.`,
18
- async execute(toolCallId, params, signal, onUpdate, ctx) {
19
- const changes = machineChange(String(params.command ?? ""));
20
- if (changes !== undefined)
21
- throw new Error(machineChangeReason(changes));
22
- return bash.execute(toolCallId, params, signal, onUpdate, ctx);
23
- },
24
- };
25
- }
26
- /** A file tool that writes, refused inside plain_modules: the built code is the ***plain's to change, never a launch's. */
27
- function outsideBuiltCode(tool, dir) {
28
- return {
29
- ...tool,
30
- async execute(toolCallId, params, signal, onUpdate, ctx) {
31
- const path = resolve(dir, String(params.path ?? ""));
32
- if (relative(dir, path).split(sep).includes("plain_modules")) {
33
- throw new Error(`Not written: ${shortPath(path)} is built code. A launch never changes it - a fix belongs in the ***plain.`);
34
- }
35
- // The ***plain - a module, a test plain file - is the person's: a launch that finds it wrong says so, never rewrites it.
36
- if (path.endsWith(".plain")) {
37
- throw new Error(`Not written: ${shortPath(path)} is ***plain. A launch never changes it - say what is wrong with it instead.`);
38
- }
39
- return tool.execute(toolCallId, params, signal, onUpdate, ctx);
40
- },
41
- };
42
- }
43
- function shown(file, max = 40_000) {
44
- const text = readFileSync(file, "utf8");
45
- const body = text.length > max ? `${text.slice(0, max)}\n… [the rest of ${shortPath(file)} is not shown]` : text;
46
- return `<file path="${shortPath(file)}">\n${body.trimEnd()}\n</file>`;
47
- }
48
- /**
49
- * What the project says of itself, for the agent to find launch guidance in: its AGENTS.md and its skills
50
- * (`.agents/skills`, `.pi/skills`, `.claude/skills`), where turri runs and in the host codebase - once each, whole.
51
- */
52
- export function projectNotes(dirs) {
53
- const roots = [...new Set(dirs.map((dir) => resolve(dir)))];
54
- const files = new Set();
55
- for (const root of roots) {
56
- const agents = join(root, "AGENTS.md");
57
- if (existsSync(agents))
58
- files.add(agents);
59
- for (const skills of [".agents/skills", ".pi/skills", ".claude/skills"].map((folder) => join(root, folder))) {
60
- if (!existsSync(skills))
61
- continue;
62
- for (const name of readdirSync(skills)) {
63
- const skill = join(skills, name, "SKILL.md");
64
- if (existsSync(skill))
65
- files.add(skill);
66
- }
67
- }
68
- }
69
- return [...files].map((file) => shown(file));
70
- }
71
- function text(value, details = {}) {
72
- return { content: [{ type: "text", text: value }], details };
73
- }
74
- /** The folder a command runs in: in dist, or - `from: host` - in the host codebase; a folder inside either. */
75
- function inside(root, dir) {
76
- const target = resolve(root, dir ?? ".");
77
- const rel = relative(root, target);
78
- if (rel.startsWith("..") || isAbsolute(rel))
79
- throw new Error(`${dir} is outside ${shortPath(root)}: what activate starts runs from there, or a folder inside it.`);
80
- return target;
81
- }
82
- const launchOf = (launch) => (launch.id !== undefined && launch.short !== undefined ? { launch: { id: launch.id, commit: launch.short } } : {});
83
- /**
84
- * activate: start what keeps running - a backend, a frontend's dev server - owned by the harness: in its own process
85
- * group, its output kept, stopped on the codebase's next launch, on /halt and when turri exits. A port held by what
86
- * turri's own launches started is taken - what held it stopped, and `freed` told.
87
- */
88
- export function activateTool(launch, code, freed) {
89
- return defineTool({
90
- name: "activate",
91
- label: "Activate",
92
- description: "Start something that keeps running - a backend, a frontend's dev server - on this machine: in the background, its " +
93
- "output kept, stopped on the next launch, on /halt and when turri exits. With `url`, waits until something answers " +
94
- "there and says so, or shows the end of its output. A port held by a server turri's own launches started - another " +
95
- "module's, an earlier session's - is taken: turri stops that server and says so. A port anything else holds is said - " +
96
- "what holds it, whose it is, how to free it - and nothing is started.",
97
- promptSnippet: "start a server of the launched code, and wait for it to answer",
98
- parameters: Type.Object({
99
- name: Type.String({ description: "A short name for it: backend, frontend, app" }),
100
- command: Type.String({ description: "The command that starts it, as run from its folder" }),
101
- url: Type.Optional(Type.String({ description: "Where it serves, e.g. http://localhost:5173 - it is ready once this answers" })),
102
- from: Type.Optional(Type.Union([Type.Literal("dist"), Type.Literal("host")], {
103
- description: `Where dir is named from: dist, the launched code (${shortPath(code.dir)}) - the default; host, the host codebase (${shortPath(launch.hostDir)}), when guidance says to start it there.`,
104
- })),
105
- dir: Type.Optional(Type.String({ description: "The folder to run it in, inside the one `from` names - e.g. frontend. Default: that folder itself." })),
106
- }),
107
- async execute(_id, params) {
108
- const root = params.from === "host" ? launch.hostDir : code.dir;
109
- const started = await startLaunched({
110
- name: params.name,
111
- command: params.command,
112
- dir: inside(root, params.dir),
113
- root,
114
- moduleName: launch.codebase,
115
- logDir: launchLogDir(projectDirOf(launch.plainFile)),
116
- ...(params.url !== undefined ? { url: params.url } : {}),
117
- ...launchOf(launch),
118
- ...(freed !== undefined ? { freed } : {}),
119
- });
120
- return text(started.text, { ok: started.ok, ...(started.process !== undefined ? { pid: started.process.pid, log: started.process.log } : {}) });
121
- },
122
- });
123
- }
124
- /**
125
- * stop_launched: free what a server turri's own launches started holds that this launch needs - a socket, a lock or pid
126
- * file, a container name, a port - by any process of it. Stopped only when turri's records say a launch of turri started
127
- * it - this session's for another module, or a turri that has ended; anything else is refused, saying whose it is.
128
- */
129
- export function stopLaunchedTool(launch, freed) {
130
- return defineTool({
131
- name: "stop_launched",
132
- label: "Stop launched",
133
- description: "Stop a server an earlier launch of turri's started - another module's, an earlier session's - that holds something " +
134
- "this launch needs: a socket, a lock or pid file, a container name, a database it keeps open. Give any pid of it - " +
135
- "from the error, lsof, ps - and what it holds. turri stops it only when its records say a launch of turri's " +
136
- "started it, and says so in the launch's summary itself; a process turri did not start, or another turri's still " +
137
- "running, is never stopped: you are told whose it is and how the person frees it. A port activate takes itself.",
138
- promptSnippet: "stop an earlier launch's server that holds what this launch needs",
139
- parameters: Type.Object({
140
- pid: Type.Integer({ description: "A process of the server that holds it" }),
141
- holds: Type.String({ description: "What it holds that this launch needs, in a few words: the socket /tmp/app.sock, the lock on data/app.db" }),
142
- }),
143
- async execute(_id, params) {
144
- const holder = whoHolds(params.pid, launchLogDir(projectDirOf(launch.plainFile)));
145
- if (holder.kind === "this" && holder.process.launch !== undefined && holder.process.launch === launch.id) {
146
- throw new Error(`Not stopped: ${describeHolder(holder)} - this launch started it itself. activate it again under the same name to restart it.`);
147
- }
148
- if (!turriFrees(holder))
149
- throw new Error(`Not stopped: ${describeHolder(holder)}. ${howToFree(holder)} Say so in submit_launch.`);
150
- const stopped = await freeHeld([holder], params.holds.trim() || "what this launch needs");
151
- freed?.(stopped);
152
- if (stopped.length === 0)
153
- return text(`Nothing stopped: ${describeHolder(holder)} has ended already.`);
154
- return text(`${stopped.map((each) => describeFreed(each, launch.codebase)).join("\n")}\nturri says so in the launch's summary: start what needs it now.`);
155
- },
156
- });
157
- }
158
- /** What holds each port a summary names, said with whose it is - none for a port nothing listens on. */
159
- function heldPorts(ports, logDir) {
160
- const lines = [];
161
- for (const port of ports) {
162
- const pids = listenersOf(port);
163
- if (pids === undefined || pids.length === 0)
164
- continue;
165
- for (const pid of pids) {
166
- const holder = whoHolds(pid, logDir);
167
- lines.push(`port ${port}: ${describeHolder(holder)}. ${howToFree(holder)}`);
168
- }
169
- }
170
- return lines;
171
- }
172
- /** The ports of the URLs a summary names. */
173
- function portsIn(summary) {
174
- const ports = new Set();
175
- for (const match of summary.matchAll(/\bhttps?:\/\/[^\s/"'`)<>]+/g)) {
176
- try {
177
- const url = new URL(match[0]);
178
- ports.add(url.port !== "" ? Number(url.port) : url.protocol === "https:" ? 443 : 80);
179
- }
180
- catch {
181
- /* not a URL after all */
182
- }
183
- }
184
- return [...ports];
185
- }
186
- /**
187
- * Why a launch said to be up is not: it says something serves - `serves`, or a URL in its summary - and nothing this
188
- * launch started with activate still runs. Something else answering there - an earlier build left running, another
189
- * program - is not this launch. Undefined when it holds.
190
- */
191
- export function notBacked(launch, outcome) {
192
- if (!outcome.launched)
193
- return undefined;
194
- const ports = portsIn(outcome.summary);
195
- if (outcome.serves !== true && ports.length === 0)
196
- return undefined;
197
- const since = launch.serversSince ?? 0;
198
- if (runningLaunched(launch.codebase).some((item) => item.startedAt >= since))
199
- return undefined;
200
- const held = heldPorts(ports, launchLogDir(projectDirOf(launch.plainFile)));
201
- return [
202
- `nothing this launch started with activate is running, so what answers${ports.length > 0 ? ` at port ${ports.join(", ")}` : ""} is not this launch's code${held.length > 0 ? " - it is held by:" : "."}`,
203
- ...held,
204
- ].join("\n");
205
- }
206
- /** submit_launch: how the launch went, once, last - the harness reads its arguments, never the agent's prose. */
207
- function submitLaunchTool(launch, submitted) {
208
- return defineTool({
209
- name: "submit_launch",
210
- label: "Submit launch",
211
- description: "Say how the launch went - once, last. launched: true when it is running, or in place for the person to try - a CLI " +
212
- "or a library ready to run from its folder; false when it is not. The summary is what the person is told: where to " +
213
- "open it, or what to run - or why it did not come up, and what they can do. Something that serves counts as running " +
214
- "only when you started it with activate and it still runs: something else answering at its port - an earlier build, " +
215
- "another program - is not it, and is refused.",
216
- parameters: Type.Object({
217
- launched: Type.Boolean({ description: "true: it runs, or is in place to try; false: it did not come up" }),
218
- serves: Type.Boolean({ description: "true: something keeps running for the person to open or call - a backend, a frontend; false: a CLI or a library, tried from its folder" }),
219
- summary: Type.String({ description: "In a line or three: where it runs - the URL to open, the API's in a line - or the commands to try it; or why it did not come up" }),
220
- }),
221
- async execute(_id, params) {
222
- const why = notBacked(launch, params);
223
- if (why !== undefined) {
224
- throw new Error(`Not taken: you say it runs, but ${why}\nStart it with activate - stopping nothing turri did not start - or call submit_launch with launched false, saying what holds the port and whose it is, as said here.`);
225
- }
226
- submitted.outcome = { launched: params.launched, summary: params.summary, serves: params.serves };
227
- return text("Taken. You are done: end your turn.");
228
- },
229
- });
230
- }
231
- /** What the agent does once the code is in dist: find guidance and follow it from the host, or start it from dist. */
232
- export function launchGuide(code, hostDir) {
233
- const dist = shortPath(code.dir);
234
- const host = shortPath(hostDir);
235
- const built = shortPath(code.buildDir);
236
- return [
237
- "First ask yourself: is there guidance for how this project launches it - what the person said, the project's notes and",
238
- "skills below, or anything else you find? An integration a host application loads, say, put in place with the host's own",
239
- "scripts. Then:",
240
- "",
241
- `Without guidance - start it from ${dist}, as best it can be:`,
242
- `1. Find out how it runs: its README, its manifests (package.json, pyproject.toml, requirements.txt, go.mod, Cargo.toml, pom.xml, build.gradle, docker-compose.yml) and entry points, in ${dist}.`,
243
- "2. Check the toolchains it needs are on this machine (`command -v node`, `python3 --version`, `go version`, ...) - under another name too: python where python3 is not, of the version it needs. One missing: you install nothing on the machine and change none of its settings - stop, and say exactly what to install, the command the person runs themselves (`brew install node`), and that launching again picks it up.",
244
- "3. Install what it needs into the project yourself, in your shell - dependencies into a virtual environment or node_modules, a build that fetches packages, an image pull. Do not ask: do it, and fix what fails - within the project: never a global install, never a system setting.",
245
- "4. Start anything that keeps running - a backend, a frontend's dev server - with activate, with the URL it serves at: never in the shell with & or nohup. An app with a backend and a frontend: start both, the backend first.",
246
- "",
247
- `With guidance - follow it, on this machine, from the host codebase ${host}:`,
248
- `1. The code to launch is in ${dist}: the commit, whole. Take it from there, never from ${built}, where a pulse may be writing - always: where the guidance's own tooling reads ${built}, point it at ${dist} if it can take another source; if it cannot, do by hand, from ${dist}, what it does.`,
249
- `2. Read what the guidance leaves open - the scripts, files and commands it names, in ${host} - then do what it says, in its order. Where it says to change the host - a registration, an import, a config entry - change it.`,
250
- "3. Run the project's scripts and install what it needs into the project yourself, in your shell. A toolchain or system tool the machine lacks you never install, nor change a setting of the machine's: say the command the person runs themselves.",
251
- "4. Start what keeps running - a start script, a dev server - with activate (from: host when it runs in the host codebase), with the URL it serves at - never in the shell with & or nohup.",
252
- "",
253
- `Either way, never change ${built} or ${dist}: they are what was built, and a fix belongs in the ***plain. A config file it needs made from its example (a .env from .env.example) is fine.`,
254
- "",
255
- "Something it needs held already: a port, activate takes itself when a server turri's own launches started holds it, and",
256
- "says so. Anything else - a socket, a lock or pid file, a container name - held by a server one of turri's launches",
257
- "started (listed below, when any runs): free it with stop_launched. This launch is the newest: it always takes what",
258
- "turri's own earlier launches hold - never leave it unstarted to keep one of theirs running, whatever the reason, even",
259
- "to compare the two; turri tells the person what it stopped. Never decide from lsof yourself: call activate, and it says",
260
- "what holds the port and whose it is. What turri did not start, or another turri still",
261
- "running started, is never stopped and the app is never moved to another port: say what holds it, whose it is and how",
262
- "the person frees it, as the tools said it - never that turri did not start something its tools say it did.",
263
- "",
264
- "Last, call submit_launch once: launched, whether it serves, and in a line or three where to open it - the frontend's URL,",
265
- "and the API's in one line when there is one - or, a CLI or a library, a few commands to paste, run from its folder, with",
266
- "what they print; or why it did not come up. Where the guidance does not fit what you find, say so, and do not guess past it.",
267
- "Something answering at the app's port that this launch did not start with activate is not this launch: it is not",
268
- "launched, and you say what holds the port and whose it is. Stop a process only with activate or stop_launched, never in",
269
- "your shell.",
270
- ].join("\n");
271
- }
272
- /** What turri's launches of other modules run now, a line each with its pid - what stop_launched frees. */
273
- function otherLaunches(codebase) {
274
- return runningLaunched()
275
- .filter((item) => item.moduleName !== codebase)
276
- .map((item) => `- ${item.name}: pid ${item.pid}, ${item.moduleName}'s launch${item.launch !== undefined ? ` ${item.launch}` : ""}${item.commit !== undefined ? ` at ${item.commit}` : ""} - ${item.url ?? item.command}, in ${shortPath(item.dir)}`);
277
- }
278
- /** Run the launch agent to its end: how it went, as it submitted it - or, never submitted, its last words as a failure. */
279
- export async function runLaunchAgent(input) {
280
- const { launch, code } = input;
281
- const dir = launch.hostDir;
282
- const notes = projectNotes([input.cwd, dir, projectDirOf(launch.plainFile)]);
283
- const fileTools = [
284
- createReadToolDefinition(dir),
285
- createLsToolDefinition(dir),
286
- createGrepToolDefinition(dir),
287
- createFindToolDefinition(dir),
288
- // Guidance may say to change the host - a registration, an import.
289
- outsideBuiltCode(createEditToolDefinition(dir), dir),
290
- outsideBuiltCode(createWriteToolDefinition(dir), dir),
291
- ];
292
- const submitted = {};
293
- const tools = [activateTool(launch, code, input.freed), stopLaunchedTool(launch, input.freed), submitLaunchTool(launch, submitted)];
294
- const others = otherLaunches(launch.codebase);
295
- const executor = await createExecutor({
296
- // Its sessions are kept in the project, not in the folder it launches.
297
- cwd: projectDirOf(launch.plainFile),
298
- customTools: [...fileTools, launchShell(dir), ...tools],
299
- tools: [...fileTools.map((tool) => tool.name), "bash", ...tools.map((tool) => tool.name)],
300
- ...(input.model !== undefined ? { model: input.model } : {}),
301
- role: "launch",
302
- system: [
303
- "You get software that was just built running on the person's own machine, so they and turri's sentinel can try it. You ask no one: do it.",
304
- `Your file tools and your shell start in ${dir}. Your shell is the person's own - not a sandbox.`,
305
- ].join("\n"),
306
- task: [
307
- "pulse" in launch.cause
308
- ? `A pulse of ${launch.codebase} just landed: ${launch.cause.title}. The project launches what every pulse lands: launch it now, whether or not the guidance speaks of launching after a build - what the guidance says is how.`
309
- : `Launch ${launch.codebase} for the person to try.`,
310
- "",
311
- describeExport(code),
312
- "",
313
- launchGuide(code, dir),
314
- ...(launch.inModule !== undefined ? ["", `It is the codebase of module ${launch.inModule}.`] : []),
315
- ...(launch.guidance !== undefined ? ["", "What the person said of how to launch it:", launch.guidance] : []),
316
- ...(others.length > 0 ? ["", "What turri's launches of other modules run now - each its own module's, left running unless it holds what this launch needs:", ...others] : []),
317
- ...(notes.length > 0 ? ["", "The project's notes and skills:", ...notes] : []),
318
- ].join("\n"),
319
- });
320
- const stop = () => void executor.abort();
321
- input.signal?.addEventListener("abort", stop, { once: true });
322
- // What it said is checked again as it ends: a server it started may have exited since.
323
- const checked = (outcome) => {
324
- const why = notBacked(launch, outcome);
325
- return why !== undefined ? { launched: false, summary: `Not launched: the launch agent said it runs, but ${why}` } : { launched: outcome.launched, summary: outcome.summary };
326
- };
327
- try {
328
- const said = await ask(executor, BEGIN, input.onDelta);
329
- if (submitted.outcome !== undefined)
330
- return checked(submitted.outcome);
331
- // Ended without saying how it went: asked once more, then taken as not launched.
332
- const again = await ask(executor, "Call submit_launch now: launched or not, and in a line or three where it runs or why it did not come up.", input.onDelta);
333
- return submitted.outcome !== undefined ? checked(submitted.outcome) : { launched: false, summary: (again.trim() || said.trim() || "The launch agent ended without saying how it went.") };
334
- }
335
- finally {
336
- input.signal?.removeEventListener("abort", stop);
337
- executor.dispose();
338
- }
339
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,68 +0,0 @@
1
- import type { SentinelLaunches } from "./chats.ts";
2
- import { type Launch, type LaunchTrack } from "./launch-track.ts";
3
- import { type LaunchedProcess } from "./regenerate/launch.ts";
4
- import { type Job, type JobRegistry, type PulseSpec } from "./regenerate/jobs.ts";
5
- import type { SentinelCheck } from "./notice.ts";
6
- /** What runs for a pulse, as the sentinel is told it. */
7
- export interface PulseLaunch {
8
- /** The commit the pulse landed - none when it did not land. */
9
- commit?: string;
10
- /** launch-after-pulse was off as it landed: nothing launched for it. */
11
- off?: boolean;
12
- /** Its launch could not be asked for, and why. */
13
- notAsked?: string;
14
- /** The launch whose commit holds it - what runs. */
15
- launch?: Launch;
16
- /** The person stopped the launch: nothing runs to test. */
17
- stopped?: boolean;
18
- /** The pulses that landed after it which the launch holds too, oldest first. */
19
- later: Job[];
20
- /** Its functional specs a later pulse in the launch changed too: those pulses' checks test them. */
21
- laterSpecs: PulseSpec[];
22
- running: LaunchedProcess[];
23
- }
24
- export interface SessionLaunches extends SentinelLaunches {
25
- track: LaunchTrack;
26
- /** A pulse landed, its commit final: kept - and, under launch-after-pulse, its launch asked for. */
27
- landed(input: {
28
- job: Job;
29
- plainFile: string;
30
- moduleName: string;
31
- commit: string;
32
- title: string;
33
- }): void;
34
- /** What runs for a pulse, once `readyFor` resolved. */
35
- forPulse(job: Job): PulseLaunch;
36
- /** What the sentinel is told to carry on with a paused check: throws when what runs no longer holds it. */
37
- resumeText(work: {
38
- job: Job;
39
- } | {
40
- check: SentinelCheck;
41
- }): string;
42
- }
43
- export declare function createSessionLaunches(options: {
44
- cwd: string;
45
- jobs: JobRegistry;
46
- /** The launch agent's model: the coding model of the codebase. */
47
- model: (plainFile: string) => string | undefined;
48
- onChange: (launch: Launch) => void;
49
- }): SessionLaunches;
50
- /**
51
- * What the sentinel tests in, whatever is launched: what turri launched, and nothing it starts itself. Said in every
52
- * brief - a server it starts from plain_modules would pass on code nobody launched.
53
- */
54
- export declare const LAUNCHED_ONLY = "Never run the code in plain_modules, where a pulse may be writing, nor start a server of your own - not in your shell, not with a host's terminal: what would pass there is not what the person tries. A server that should run and does not is your finding.";
55
- /** The folder a launch's code is in: dist/<module>, where it is tried from. */
56
- export declare function launchedDir(launch: Pick<Launch, "code" | "plainFile" | "codebase">): string;
57
- /**
58
- * What runs of a launch, a line each: where, from where, its output - or that nothing was left running, and the folder it
59
- * is tried from.
60
- */
61
- export declare function whatRuns(running: LaunchedProcess[], from?: string): string[];
62
- /**
63
- * What the chat that asked for a launch is told when a newer one takes its place - superseded as it waited, or ended with
64
- * the newer one waiting, which stops what it started: it is told the newer one's end instead.
65
- */
66
- export declare function replacedNote(launch: Launch, next: Launch, job?: Job): string;
67
- /** What a chat is told of a launch that ended - one it asked for, or one after a pulse with the sentinel off. */
68
- export declare function launchedNote(launch: Launch, job?: Job): string;
@@ -1,225 +0,0 @@
1
- import { dirname, join } from "node:path";
2
- import { configForSpec, readProjectConfig } from "./config.js";
3
- import { createLaunchTrack, launchText } from "./launch-track.js";
4
- import { runLaunchAgent } from "./launch-agent.js";
5
- import { holdsAcross, runningLaunched } from "./regenerate/launch.js";
6
- import { distDirFor, projectDirOf } from "./regenerate/paths.js";
7
- import { pulseName } from "./regenerate/jobs.js";
8
- /** How long a pulse that landed is waited for to say its commit: the loop says it as the pulse settles. */
9
- const COMMIT_WAIT_MS = 10_000;
10
- export function createSessionLaunches(options) {
11
- const landedPulses = new Map();
12
- const waiters = new Map();
13
- const track = createLaunchTrack({
14
- cwd: options.cwd,
15
- run: (launch, code, signal, freed) => {
16
- const model = options.model(launch.plainFile);
17
- return runLaunchAgent({ launch, code, cwd: options.cwd, signal, freed, ...(model !== undefined ? { model } : {}) });
18
- },
19
- onChange: options.onChange,
20
- });
21
- // What an earlier session's launches left running holds the ports this one's need: stopped as the session starts.
22
- void track.sweep().catch(() => undefined);
23
- /** Whether the pulse's module launches what lands: its config as the pulse was queued with it. */
24
- const launchesAfter = (job) => {
25
- try {
26
- return readProjectConfig(options.cwd, job.configModule).launchAfterPulse === true;
27
- }
28
- catch {
29
- return false;
30
- }
31
- };
32
- const landedJob = (job) => job.status === "succeeded" && job.details?.landed === true && job.module !== undefined;
33
- /** The pulse's landing, once the loop has said its commit - none for one that did not land, or never said. */
34
- const landingOf = async (job) => {
35
- if (!landedJob(job))
36
- return undefined;
37
- const known = landedPulses.get(job.id);
38
- if (known !== undefined)
39
- return known;
40
- await new Promise((resolve) => {
41
- const timer = setTimeout(resolve, COMMIT_WAIT_MS);
42
- const list = waiters.get(job.id) ?? [];
43
- list.push(() => (clearTimeout(timer), resolve()));
44
- waiters.set(job.id, list);
45
- });
46
- return landedPulses.get(job.id);
47
- };
48
- const short = (commit) => commit.slice(0, 7);
49
- /** The last launch that took the codebase's code on - its own, or one of a module built on it - none superseded. */
50
- const lastFor = (codebase) => [...track.list()].reverse().find((launch) => launch.status !== "superseded" && track.replacing(launch).includes(codebase));
51
- /** The person stopped the last launch of the codebase's code: nothing of it runs. */
52
- const stoppedLast = (codebase) => lastFor(codebase)?.status === "stopped";
53
- /** Throws when what runs of the codebase's code does not hold the pulse's commit. */
54
- const mustHold = (job, landing) => {
55
- const runs = track.runs(landing.codebase);
56
- if (runs === undefined) {
57
- const last = lastFor(landing.codebase);
58
- const by = last?.replacedBy !== undefined ? track.list().find((launch) => launch.id === last.replacedBy) : undefined;
59
- if (last !== undefined && by !== undefined && by.codebase !== last.codebase) {
60
- throw new Error(`what ${last.codebase}'s launch ${last.id} started was stopped for ${by.codebase}'s launch ${by.id}, which needed what it held - nothing of ${landing.codebase} runs to test pulse ${job.id} in.`);
61
- }
62
- throw new Error(`nothing of ${landing.codebase} runs - no launch holds pulse ${job.id}'s commit ${short(landing.commit)}, and none that would is waiting.`);
63
- }
64
- if (!track.holds(landing.codebase, landing.commit)) {
65
- throw new Error(`what runs of ${landing.codebase} is ${runs.codebase === landing.codebase ? "its" : `${runs.codebase}'s`} commit ${runs.short}, which does not hold pulse ${job.id}'s commit ${short(landing.commit)} - and no launch that would is waiting.`);
66
- }
67
- return runs;
68
- };
69
- return {
70
- track,
71
- landed({ job, plainFile, moduleName, commit, title }) {
72
- const landing = { commit, plainFile, codebase: moduleName };
73
- if (configForSpec(plainFile).launchAfterPulse === true) {
74
- try {
75
- const { launch } = track.request({ plainFile, commit, cause: { pulse: job.id, title } });
76
- landing.codebase = launch.codebase;
77
- landing.launch = launch.id;
78
- }
79
- catch (error) {
80
- landing.notAsked = error instanceof Error ? error.message : String(error);
81
- }
82
- }
83
- landedPulses.set(job.id, landing);
84
- for (const resolve of waiters.get(job.id) ?? [])
85
- resolve();
86
- waiters.delete(job.id);
87
- },
88
- async readyFor(job) {
89
- // Nothing is launched for it: there is nothing to wait for.
90
- if (!launchesAfter(job))
91
- return;
92
- const landing = await landingOf(job);
93
- if (landing === undefined || landing.launch === undefined)
94
- return;
95
- await track.settled(landing.codebase);
96
- if (stoppedLast(landing.codebase))
97
- return;
98
- mustHold(job, landing);
99
- },
100
- async readyForCheck(check) {
101
- await track.settled(check.module);
102
- if (track.runs(check.module) === undefined && runningLaunched(check.module).length === 0) {
103
- throw new Error(`nothing of ${check.module} is launched to test it in - ask the chat to try it first, which launches it.`);
104
- }
105
- },
106
- settled: (codebase) => track.settled(codebase),
107
- replacing: (launch) => track.replacing(launch),
108
- forPulse(job) {
109
- const landing = landedPulses.get(job.id);
110
- if (landing === undefined)
111
- return { later: [], laterSpecs: [], running: [], ...(landedJob(job) && !launchesAfter(job) ? { off: true } : {}) };
112
- const launch = track.runs(landing.codebase);
113
- const base = { commit: landing.commit, running: runningLaunched(launch?.codebase ?? landing.codebase), later: [], laterSpecs: [] };
114
- if (landing.notAsked !== undefined)
115
- return { ...base, notAsked: landing.notAsked };
116
- if (landing.launch === undefined)
117
- return { ...base, off: true };
118
- if (launch === undefined || !track.holds(landing.codebase, landing.commit))
119
- return { ...base, stopped: true };
120
- // The pulses that landed after it, which what runs holds too - of its codebase, or of one built on it: what they
121
- // changed is theirs to test.
122
- const at = (codebase) => join(dirname(launch.moduleDir), codebase);
123
- const later = options.jobs
124
- .list()
125
- .filter((other) => {
126
- const theirs = landedPulses.get(other.id);
127
- return (other.id !== job.id &&
128
- theirs !== undefined &&
129
- theirs.commit !== landing.commit &&
130
- holdsAcross({ codebase: landing.codebase, commit: landing.commit }, { codebase: theirs.codebase, moduleDir: at(theirs.codebase), commit: theirs.commit }) &&
131
- holdsAcross({ codebase: theirs.codebase, commit: theirs.commit }, { codebase: launch.codebase, moduleDir: launch.moduleDir, commit: launch.commit }));
132
- })
133
- .sort((a, b) => a.sequence - b.sequence);
134
- const key = (spec) => `${spec.module}:${spec.funcId}`;
135
- const theirs = new Set(later.flatMap((other) => specsOf(other).map(key)));
136
- return { ...base, launch, later, laterSpecs: specsOf(job).filter((spec) => theirs.has(key(spec))) };
137
- },
138
- resumeText(work) {
139
- if ("job" in work) {
140
- const landing = landedPulses.get(work.job.id);
141
- if (landing === undefined)
142
- throw new Error(`turri has no commit for pulse ${work.job.id}.`);
143
- const launch = mustHold(work.job, landing);
144
- return [
145
- `What you were testing was launched again: ${launch.codebase} at ${launch.short} (${launch.id}${launch.status === "failed" ? ", which did not come up" : ""}). It still holds pulse ${work.job.id}'s commit, ${short(landing.commit)}${launch.codebase !== landing.codebase ? ` - built on ${landing.codebase}, it holds its code` : ""}.`,
146
- launch.status === "failed" ? `It did not come up: ${launchText(launch) || "the launch agent did not say why"}. That is what you find out about now.` : "What runs now:",
147
- ...(launch.status === "failed" ? [] : whatRuns(runningLaunched(launch.codebase), launchedDir(launch))),
148
- "",
149
- LAUNCHED_ONLY,
150
- "Carry on the check where you were. Do again what you were doing as it restarted: what failed then may have failed for that alone.",
151
- ].join("\n");
152
- }
153
- const runs = track.runs(work.check.module);
154
- const running = runningLaunched(runs?.codebase ?? work.check.module);
155
- if (runs === undefined && running.length === 0)
156
- throw new Error(`nothing of ${work.check.module} runs any more to test check ${work.check.id} in.`);
157
- return [
158
- `What you were testing was launched again: ${runs !== undefined ? `${runs.codebase} at ${runs.short}${runs.codebase !== work.check.module ? `, built on ${work.check.module} and holding its code` : ""}` : work.check.module}. What runs now:`,
159
- ...whatRuns(running, runs !== undefined ? launchedDir(runs) : undefined),
160
- "",
161
- LAUNCHED_ONLY,
162
- "Carry on the check where you were. Do again what you were doing as it restarted: what failed then may have failed for that alone.",
163
- ].join("\n");
164
- },
165
- };
166
- }
167
- /** A pulse's functional specs, every case. */
168
- function specsOf(job) {
169
- const cases = job.cases;
170
- return cases === undefined ? [] : [...cases.add, ...cases.patch, ...cases.again, ...cases.delete];
171
- }
172
- /**
173
- * What the sentinel tests in, whatever is launched: what turri launched, and nothing it starts itself. Said in every
174
- * brief - a server it starts from plain_modules would pass on code nobody launched.
175
- */
176
- export const LAUNCHED_ONLY = "Never run the code in plain_modules, where a pulse may be writing, nor start a server of your own - not in your shell, not with a host's terminal: what would pass there is not what the person tries. A server that should run and does not is your finding.";
177
- /** The folder a launch's code is in: dist/<module>, where it is tried from. */
178
- export function launchedDir(launch) {
179
- return launch.code?.dir ?? distDirFor(projectDirOf(launch.plainFile), launch.codebase);
180
- }
181
- /**
182
- * What runs of a launch, a line each: where, from where, its output - or that nothing was left running, and the folder it
183
- * is tried from.
184
- */
185
- export function whatRuns(running, from) {
186
- if (running.length === 0) {
187
- return [
188
- from !== undefined
189
- ? ` nothing is left running. It is in place in ${from}: try it from there - a CLI or a library as its README and entry points say. Something there that should serve and does not is what you find out about.`
190
- : " nothing is left running.",
191
- ];
192
- }
193
- return running.map((item) => ` ${item.name}: ${item.url ?? item.command} - in ${item.dir}, its output in ${item.log}`);
194
- }
195
- /** Why a launch was asked for, as the chat is told it: after which pulse landed - nothing for one a chat asked for. */
196
- const afterPulse = (launch, job) => ("pulse" in launch.cause ? ` after ${job !== undefined ? pulseName(job) : `pulse ${launch.cause.pulse}`} landed` : "");
197
- /**
198
- * What the chat that asked for a launch is told when a newer one takes its place - superseded as it waited, or ended with
199
- * the newer one waiting, which stops what it started: it is told the newer one's end instead.
200
- */
201
- export function replacedNote(launch, next, job) {
202
- const how = launch.status === "superseded" ? "never started" : launch.status === "launched" ? "came up, but not for long" : "ended";
203
- return [
204
- `The launch of ${launch.codebase} at ${launch.short} you asked for (${launch.id}) ${how}: a newer launch of it, ${next.id} at ${next.short}${afterPulse(next, job)}, takes its place${launch.status === "superseded" ? "" : " and stops what it started"}.`,
205
- "You are told where that one runs, or why it did not come up, once it ends. Say so in a line, if the person is waiting for it; open nothing and start nothing for it now.",
206
- ].join("\n");
207
- }
208
- /** What a chat is told of a launch that ended - one it asked for, or one after a pulse with the sentinel off. */
209
- export function launchedNote(launch, job) {
210
- const after = afterPulse(launch, job);
211
- if (launch.status === "stopped")
212
- return `The launch of ${launch.codebase} at ${launch.short}${after} was stopped on request: nothing of it runs. Say so in a line.`;
213
- const head = launch.status === "launched"
214
- ? `${launch.codebase} at ${launch.short} is launched${after}${launch.already === true ? " - out already" : ""}.`
215
- : `The launch of ${launch.codebase} at ${launch.short}${after} did not come up.`;
216
- return [
217
- head,
218
- "",
219
- launchText(launch),
220
- "",
221
- launch.status === "launched"
222
- ? "Tell the person in a line or two where it runs - what the summary says to open or run - then do what you were told to do once something is launched (opening it where the person can watch it, saying what to test), if anything. Start no other work."
223
- : "Tell the person in a line or two why it did not come up and what they can do - what the machine lacks they install themselves. Do not launch it again unless they ask.",
224
- ].join("\n");
225
- }