steroids-cli 0.4.47

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 (395) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +640 -0
  3. package/dist/cli/colors.d.ts +110 -0
  4. package/dist/cli/colors.d.ts.map +1 -0
  5. package/dist/cli/colors.js +228 -0
  6. package/dist/cli/colors.js.map +1 -0
  7. package/dist/cli/env.d.ts +159 -0
  8. package/dist/cli/env.d.ts.map +1 -0
  9. package/dist/cli/env.js +227 -0
  10. package/dist/cli/env.js.map +1 -0
  11. package/dist/cli/errors.d.ts +166 -0
  12. package/dist/cli/errors.d.ts.map +1 -0
  13. package/dist/cli/errors.js +244 -0
  14. package/dist/cli/errors.js.map +1 -0
  15. package/dist/cli/flags.d.ts +75 -0
  16. package/dist/cli/flags.d.ts.map +1 -0
  17. package/dist/cli/flags.js +232 -0
  18. package/dist/cli/flags.js.map +1 -0
  19. package/dist/cli/help.d.ts +97 -0
  20. package/dist/cli/help.d.ts.map +1 -0
  21. package/dist/cli/help.js +275 -0
  22. package/dist/cli/help.js.map +1 -0
  23. package/dist/cli/index.d.ts +13 -0
  24. package/dist/cli/index.d.ts.map +1 -0
  25. package/dist/cli/index.js +29 -0
  26. package/dist/cli/index.js.map +1 -0
  27. package/dist/cli/interactive.d.ts +58 -0
  28. package/dist/cli/interactive.d.ts.map +1 -0
  29. package/dist/cli/interactive.js +127 -0
  30. package/dist/cli/interactive.js.map +1 -0
  31. package/dist/cli/output.d.ts +116 -0
  32. package/dist/cli/output.d.ts.map +1 -0
  33. package/dist/cli/output.js +178 -0
  34. package/dist/cli/output.js.map +1 -0
  35. package/dist/commands/about.d.ts +7 -0
  36. package/dist/commands/about.d.ts.map +1 -0
  37. package/dist/commands/about.js +259 -0
  38. package/dist/commands/about.js.map +1 -0
  39. package/dist/commands/ai.d.ts +6 -0
  40. package/dist/commands/ai.d.ts.map +1 -0
  41. package/dist/commands/ai.js +382 -0
  42. package/dist/commands/ai.js.map +1 -0
  43. package/dist/commands/backup.d.ts +3 -0
  44. package/dist/commands/backup.d.ts.map +1 -0
  45. package/dist/commands/backup.js +528 -0
  46. package/dist/commands/backup.js.map +1 -0
  47. package/dist/commands/completion.d.ts +3 -0
  48. package/dist/commands/completion.d.ts.map +1 -0
  49. package/dist/commands/completion.js +405 -0
  50. package/dist/commands/completion.js.map +1 -0
  51. package/dist/commands/config.d.ts +3 -0
  52. package/dist/commands/config.d.ts.map +1 -0
  53. package/dist/commands/config.js +665 -0
  54. package/dist/commands/config.js.map +1 -0
  55. package/dist/commands/disputes.d.ts +3 -0
  56. package/dist/commands/disputes.d.ts.map +1 -0
  57. package/dist/commands/disputes.js +499 -0
  58. package/dist/commands/disputes.js.map +1 -0
  59. package/dist/commands/gc.d.ts +3 -0
  60. package/dist/commands/gc.d.ts.map +1 -0
  61. package/dist/commands/gc.js +300 -0
  62. package/dist/commands/gc.js.map +1 -0
  63. package/dist/commands/git.d.ts +3 -0
  64. package/dist/commands/git.d.ts.map +1 -0
  65. package/dist/commands/git.js +458 -0
  66. package/dist/commands/git.js.map +1 -0
  67. package/dist/commands/health.d.ts +3 -0
  68. package/dist/commands/health.d.ts.map +1 -0
  69. package/dist/commands/health.js +604 -0
  70. package/dist/commands/health.js.map +1 -0
  71. package/dist/commands/hooks.d.ts +6 -0
  72. package/dist/commands/hooks.d.ts.map +1 -0
  73. package/dist/commands/hooks.js +529 -0
  74. package/dist/commands/hooks.js.map +1 -0
  75. package/dist/commands/init.d.ts +6 -0
  76. package/dist/commands/init.d.ts.map +1 -0
  77. package/dist/commands/init.js +200 -0
  78. package/dist/commands/init.js.map +1 -0
  79. package/dist/commands/llm.d.ts +7 -0
  80. package/dist/commands/llm.d.ts.map +1 -0
  81. package/dist/commands/llm.js +285 -0
  82. package/dist/commands/llm.js.map +1 -0
  83. package/dist/commands/locks.d.ts +3 -0
  84. package/dist/commands/locks.d.ts.map +1 -0
  85. package/dist/commands/locks.js +431 -0
  86. package/dist/commands/locks.js.map +1 -0
  87. package/dist/commands/logs.d.ts +3 -0
  88. package/dist/commands/logs.d.ts.map +1 -0
  89. package/dist/commands/logs.js +487 -0
  90. package/dist/commands/logs.js.map +1 -0
  91. package/dist/commands/loop-phases.d.ts +11 -0
  92. package/dist/commands/loop-phases.d.ts.map +1 -0
  93. package/dist/commands/loop-phases.js +204 -0
  94. package/dist/commands/loop-phases.js.map +1 -0
  95. package/dist/commands/loop.d.ts +3 -0
  96. package/dist/commands/loop.d.ts.map +1 -0
  97. package/dist/commands/loop.js +396 -0
  98. package/dist/commands/loop.js.map +1 -0
  99. package/dist/commands/projects.d.ts +6 -0
  100. package/dist/commands/projects.d.ts.map +1 -0
  101. package/dist/commands/projects.js +362 -0
  102. package/dist/commands/projects.js.map +1 -0
  103. package/dist/commands/purge.d.ts +3 -0
  104. package/dist/commands/purge.d.ts.map +1 -0
  105. package/dist/commands/purge.js +516 -0
  106. package/dist/commands/purge.js.map +1 -0
  107. package/dist/commands/runners.d.ts +3 -0
  108. package/dist/commands/runners.d.ts.map +1 -0
  109. package/dist/commands/runners.js +1076 -0
  110. package/dist/commands/runners.js.map +1 -0
  111. package/dist/commands/scan.d.ts +3 -0
  112. package/dist/commands/scan.d.ts.map +1 -0
  113. package/dist/commands/scan.js +291 -0
  114. package/dist/commands/scan.js.map +1 -0
  115. package/dist/commands/sections-commands.d.ts +9 -0
  116. package/dist/commands/sections-commands.d.ts.map +1 -0
  117. package/dist/commands/sections-commands.js +282 -0
  118. package/dist/commands/sections-commands.js.map +1 -0
  119. package/dist/commands/sections-graph.d.ts +25 -0
  120. package/dist/commands/sections-graph.d.ts.map +1 -0
  121. package/dist/commands/sections-graph.js +180 -0
  122. package/dist/commands/sections-graph.js.map +1 -0
  123. package/dist/commands/sections.d.ts +3 -0
  124. package/dist/commands/sections.d.ts.map +1 -0
  125. package/dist/commands/sections.js +376 -0
  126. package/dist/commands/sections.js.map +1 -0
  127. package/dist/commands/stats.d.ts +6 -0
  128. package/dist/commands/stats.d.ts.map +1 -0
  129. package/dist/commands/stats.js +324 -0
  130. package/dist/commands/stats.js.map +1 -0
  131. package/dist/commands/tasks.d.ts +3 -0
  132. package/dist/commands/tasks.d.ts.map +1 -0
  133. package/dist/commands/tasks.js +1115 -0
  134. package/dist/commands/tasks.js.map +1 -0
  135. package/dist/commands/web.d.ts +7 -0
  136. package/dist/commands/web.d.ts.map +1 -0
  137. package/dist/commands/web.js +204 -0
  138. package/dist/commands/web.js.map +1 -0
  139. package/dist/config/ai-setup.d.ts +27 -0
  140. package/dist/config/ai-setup.d.ts.map +1 -0
  141. package/dist/config/ai-setup.js +432 -0
  142. package/dist/config/ai-setup.js.map +1 -0
  143. package/dist/config/browser.d.ts +9 -0
  144. package/dist/config/browser.d.ts.map +1 -0
  145. package/dist/config/browser.js +200 -0
  146. package/dist/config/browser.js.map +1 -0
  147. package/dist/config/json-schema.d.ts +28 -0
  148. package/dist/config/json-schema.d.ts.map +1 -0
  149. package/dist/config/json-schema.js +84 -0
  150. package/dist/config/json-schema.js.map +1 -0
  151. package/dist/config/loader.d.ts +152 -0
  152. package/dist/config/loader.d.ts.map +1 -0
  153. package/dist/config/loader.js +270 -0
  154. package/dist/config/loader.js.map +1 -0
  155. package/dist/config/schema.d.ts +34 -0
  156. package/dist/config/schema.d.ts.map +1 -0
  157. package/dist/config/schema.js +437 -0
  158. package/dist/config/schema.js.map +1 -0
  159. package/dist/config/validator.d.ts +32 -0
  160. package/dist/config/validator.d.ts.map +1 -0
  161. package/dist/config/validator.js +187 -0
  162. package/dist/config/validator.js.map +1 -0
  163. package/dist/database/connection.d.ts +35 -0
  164. package/dist/database/connection.d.ts.map +1 -0
  165. package/dist/database/connection.js +208 -0
  166. package/dist/database/connection.js.map +1 -0
  167. package/dist/database/queries.d.ts +218 -0
  168. package/dist/database/queries.d.ts.map +1 -0
  169. package/dist/database/queries.js +613 -0
  170. package/dist/database/queries.js.map +1 -0
  171. package/dist/database/schema.d.ts +8 -0
  172. package/dist/database/schema.d.ts.map +1 -0
  173. package/dist/database/schema.js +160 -0
  174. package/dist/database/schema.js.map +1 -0
  175. package/dist/disputes/behavior.d.ts +106 -0
  176. package/dist/disputes/behavior.d.ts.map +1 -0
  177. package/dist/disputes/behavior.js +150 -0
  178. package/dist/disputes/behavior.js.map +1 -0
  179. package/dist/disputes/create.d.ts +59 -0
  180. package/dist/disputes/create.d.ts.map +1 -0
  181. package/dist/disputes/create.js +222 -0
  182. package/dist/disputes/create.js.map +1 -0
  183. package/dist/disputes/index.d.ts +21 -0
  184. package/dist/disputes/index.d.ts.map +1 -0
  185. package/dist/disputes/index.js +76 -0
  186. package/dist/disputes/index.js.map +1 -0
  187. package/dist/disputes/markdown.d.ts +41 -0
  188. package/dist/disputes/markdown.d.ts.map +1 -0
  189. package/dist/disputes/markdown.js +261 -0
  190. package/dist/disputes/markdown.js.map +1 -0
  191. package/dist/disputes/queries.d.ts +83 -0
  192. package/dist/disputes/queries.d.ts.map +1 -0
  193. package/dist/disputes/queries.js +180 -0
  194. package/dist/disputes/queries.js.map +1 -0
  195. package/dist/disputes/resolve.d.ts +57 -0
  196. package/dist/disputes/resolve.d.ts.map +1 -0
  197. package/dist/disputes/resolve.js +171 -0
  198. package/dist/disputes/resolve.js.map +1 -0
  199. package/dist/disputes/stale.d.ts +98 -0
  200. package/dist/disputes/stale.d.ts.map +1 -0
  201. package/dist/disputes/stale.js +205 -0
  202. package/dist/disputes/stale.js.map +1 -0
  203. package/dist/disputes/types.d.ts +92 -0
  204. package/dist/disputes/types.d.ts.map +1 -0
  205. package/dist/disputes/types.js +100 -0
  206. package/dist/disputes/types.js.map +1 -0
  207. package/dist/git/push.d.ts +26 -0
  208. package/dist/git/push.d.ts.map +1 -0
  209. package/dist/git/push.js +97 -0
  210. package/dist/git/push.js.map +1 -0
  211. package/dist/git/status.d.ts +61 -0
  212. package/dist/git/status.d.ts.map +1 -0
  213. package/dist/git/status.js +251 -0
  214. package/dist/git/status.js.map +1 -0
  215. package/dist/hooks/events.d.ts +72 -0
  216. package/dist/hooks/events.d.ts.map +1 -0
  217. package/dist/hooks/events.js +120 -0
  218. package/dist/hooks/events.js.map +1 -0
  219. package/dist/hooks/index.d.ts +19 -0
  220. package/dist/hooks/index.d.ts.map +1 -0
  221. package/dist/hooks/index.js +48 -0
  222. package/dist/hooks/index.js.map +1 -0
  223. package/dist/hooks/integration.d.ts +69 -0
  224. package/dist/hooks/integration.d.ts.map +1 -0
  225. package/dist/hooks/integration.js +179 -0
  226. package/dist/hooks/integration.js.map +1 -0
  227. package/dist/hooks/merge.d.ts +115 -0
  228. package/dist/hooks/merge.d.ts.map +1 -0
  229. package/dist/hooks/merge.js +161 -0
  230. package/dist/hooks/merge.js.map +1 -0
  231. package/dist/hooks/orchestrator.d.ts +115 -0
  232. package/dist/hooks/orchestrator.d.ts.map +1 -0
  233. package/dist/hooks/orchestrator.js +226 -0
  234. package/dist/hooks/orchestrator.js.map +1 -0
  235. package/dist/hooks/payload.d.ts +294 -0
  236. package/dist/hooks/payload.d.ts.map +1 -0
  237. package/dist/hooks/payload.js +267 -0
  238. package/dist/hooks/payload.js.map +1 -0
  239. package/dist/hooks/script-runner.d.ts +63 -0
  240. package/dist/hooks/script-runner.d.ts.map +1 -0
  241. package/dist/hooks/script-runner.js +221 -0
  242. package/dist/hooks/script-runner.js.map +1 -0
  243. package/dist/hooks/templates.d.ts +104 -0
  244. package/dist/hooks/templates.d.ts.map +1 -0
  245. package/dist/hooks/templates.js +327 -0
  246. package/dist/hooks/templates.js.map +1 -0
  247. package/dist/hooks/webhook-runner.d.ts +69 -0
  248. package/dist/hooks/webhook-runner.d.ts.map +1 -0
  249. package/dist/hooks/webhook-runner.js +208 -0
  250. package/dist/hooks/webhook-runner.js.map +1 -0
  251. package/dist/index.d.ts +7 -0
  252. package/dist/index.d.ts.map +1 -0
  253. package/dist/index.js +281 -0
  254. package/dist/index.js.map +1 -0
  255. package/dist/locking/cleanup.d.ts +70 -0
  256. package/dist/locking/cleanup.d.ts.map +1 -0
  257. package/dist/locking/cleanup.js +157 -0
  258. package/dist/locking/cleanup.js.map +1 -0
  259. package/dist/locking/queries.d.ts +116 -0
  260. package/dist/locking/queries.d.ts.map +1 -0
  261. package/dist/locking/queries.js +255 -0
  262. package/dist/locking/queries.js.map +1 -0
  263. package/dist/locking/section-lock.d.ts +74 -0
  264. package/dist/locking/section-lock.d.ts.map +1 -0
  265. package/dist/locking/section-lock.js +207 -0
  266. package/dist/locking/section-lock.js.map +1 -0
  267. package/dist/locking/task-lock.d.ts +92 -0
  268. package/dist/locking/task-lock.d.ts.map +1 -0
  269. package/dist/locking/task-lock.js +246 -0
  270. package/dist/locking/task-lock.js.map +1 -0
  271. package/dist/migrations/index.d.ts +7 -0
  272. package/dist/migrations/index.d.ts.map +1 -0
  273. package/dist/migrations/index.js +37 -0
  274. package/dist/migrations/index.js.map +1 -0
  275. package/dist/migrations/manifest.d.ts +92 -0
  276. package/dist/migrations/manifest.d.ts.map +1 -0
  277. package/dist/migrations/manifest.js +270 -0
  278. package/dist/migrations/manifest.js.map +1 -0
  279. package/dist/migrations/runner.d.ts +84 -0
  280. package/dist/migrations/runner.d.ts.map +1 -0
  281. package/dist/migrations/runner.js +351 -0
  282. package/dist/migrations/runner.js.map +1 -0
  283. package/dist/orchestrator/coder.d.ts +32 -0
  284. package/dist/orchestrator/coder.d.ts.map +1 -0
  285. package/dist/orchestrator/coder.js +174 -0
  286. package/dist/orchestrator/coder.js.map +1 -0
  287. package/dist/orchestrator/coordinator.d.ts +28 -0
  288. package/dist/orchestrator/coordinator.d.ts.map +1 -0
  289. package/dist/orchestrator/coordinator.js +256 -0
  290. package/dist/orchestrator/coordinator.js.map +1 -0
  291. package/dist/orchestrator/reviewer.d.ts +35 -0
  292. package/dist/orchestrator/reviewer.d.ts.map +1 -0
  293. package/dist/orchestrator/reviewer.js +241 -0
  294. package/dist/orchestrator/reviewer.js.map +1 -0
  295. package/dist/orchestrator/task-selector.d.ts +102 -0
  296. package/dist/orchestrator/task-selector.d.ts.map +1 -0
  297. package/dist/orchestrator/task-selector.js +341 -0
  298. package/dist/orchestrator/task-selector.js.map +1 -0
  299. package/dist/prompts/coder.d.ts +36 -0
  300. package/dist/prompts/coder.d.ts.map +1 -0
  301. package/dist/prompts/coder.js +315 -0
  302. package/dist/prompts/coder.js.map +1 -0
  303. package/dist/prompts/prompt-helpers.d.ts +51 -0
  304. package/dist/prompts/prompt-helpers.d.ts.map +1 -0
  305. package/dist/prompts/prompt-helpers.js +312 -0
  306. package/dist/prompts/prompt-helpers.js.map +1 -0
  307. package/dist/prompts/reviewer.d.ts +40 -0
  308. package/dist/prompts/reviewer.d.ts.map +1 -0
  309. package/dist/prompts/reviewer.js +438 -0
  310. package/dist/prompts/reviewer.js.map +1 -0
  311. package/dist/providers/api-models.d.ts +65 -0
  312. package/dist/providers/api-models.d.ts.map +1 -0
  313. package/dist/providers/api-models.js +323 -0
  314. package/dist/providers/api-models.js.map +1 -0
  315. package/dist/providers/claude.d.ts +53 -0
  316. package/dist/providers/claude.d.ts.map +1 -0
  317. package/dist/providers/claude.js +229 -0
  318. package/dist/providers/claude.js.map +1 -0
  319. package/dist/providers/codex.d.ts +53 -0
  320. package/dist/providers/codex.d.ts.map +1 -0
  321. package/dist/providers/codex.js +214 -0
  322. package/dist/providers/codex.js.map +1 -0
  323. package/dist/providers/gemini.d.ts +58 -0
  324. package/dist/providers/gemini.d.ts.map +1 -0
  325. package/dist/providers/gemini.js +242 -0
  326. package/dist/providers/gemini.js.map +1 -0
  327. package/dist/providers/index.d.ts +13 -0
  328. package/dist/providers/index.d.ts.map +1 -0
  329. package/dist/providers/index.js +49 -0
  330. package/dist/providers/index.js.map +1 -0
  331. package/dist/providers/interface.d.ts +173 -0
  332. package/dist/providers/interface.d.ts.map +1 -0
  333. package/dist/providers/interface.js +96 -0
  334. package/dist/providers/interface.js.map +1 -0
  335. package/dist/providers/invocation-logger.d.ts +114 -0
  336. package/dist/providers/invocation-logger.d.ts.map +1 -0
  337. package/dist/providers/invocation-logger.js +298 -0
  338. package/dist/providers/invocation-logger.js.map +1 -0
  339. package/dist/providers/openai.d.ts +53 -0
  340. package/dist/providers/openai.d.ts.map +1 -0
  341. package/dist/providers/openai.js +232 -0
  342. package/dist/providers/openai.js.map +1 -0
  343. package/dist/providers/registry.d.ts +100 -0
  344. package/dist/providers/registry.d.ts.map +1 -0
  345. package/dist/providers/registry.js +178 -0
  346. package/dist/providers/registry.js.map +1 -0
  347. package/dist/runners/activity-log.d.ts +65 -0
  348. package/dist/runners/activity-log.d.ts.map +1 -0
  349. package/dist/runners/activity-log.js +148 -0
  350. package/dist/runners/activity-log.js.map +1 -0
  351. package/dist/runners/cron.d.ts +26 -0
  352. package/dist/runners/cron.d.ts.map +1 -0
  353. package/dist/runners/cron.js +176 -0
  354. package/dist/runners/cron.js.map +1 -0
  355. package/dist/runners/daemon.d.ts +71 -0
  356. package/dist/runners/daemon.d.ts.map +1 -0
  357. package/dist/runners/daemon.js +245 -0
  358. package/dist/runners/daemon.js.map +1 -0
  359. package/dist/runners/global-db.d.ts +31 -0
  360. package/dist/runners/global-db.d.ts.map +1 -0
  361. package/dist/runners/global-db.js +230 -0
  362. package/dist/runners/global-db.js.map +1 -0
  363. package/dist/runners/hang-detector.d.ts +38 -0
  364. package/dist/runners/hang-detector.d.ts.map +1 -0
  365. package/dist/runners/hang-detector.js +136 -0
  366. package/dist/runners/hang-detector.js.map +1 -0
  367. package/dist/runners/heartbeat.d.ts +39 -0
  368. package/dist/runners/heartbeat.d.ts.map +1 -0
  369. package/dist/runners/heartbeat.js +79 -0
  370. package/dist/runners/heartbeat.js.map +1 -0
  371. package/dist/runners/lock.d.ts +47 -0
  372. package/dist/runners/lock.d.ts.map +1 -0
  373. package/dist/runners/lock.js +150 -0
  374. package/dist/runners/lock.js.map +1 -0
  375. package/dist/runners/orchestrator-loop.d.ts +20 -0
  376. package/dist/runners/orchestrator-loop.d.ts.map +1 -0
  377. package/dist/runners/orchestrator-loop.js +285 -0
  378. package/dist/runners/orchestrator-loop.js.map +1 -0
  379. package/dist/runners/projects.d.ts +96 -0
  380. package/dist/runners/projects.d.ts.map +1 -0
  381. package/dist/runners/projects.js +255 -0
  382. package/dist/runners/projects.js.map +1 -0
  383. package/dist/runners/wakeup.d.ts +34 -0
  384. package/dist/runners/wakeup.d.ts.map +1 -0
  385. package/dist/runners/wakeup.js +291 -0
  386. package/dist/runners/wakeup.js.map +1 -0
  387. package/migrations/001_initial_schema.sql +106 -0
  388. package/migrations/002_add_commit_sha.sql +12 -0
  389. package/migrations/003_add_section_priority.sql +13 -0
  390. package/migrations/004_add_section_dependencies.sql +18 -0
  391. package/migrations/005_add_audit_actor_model.sql +10 -0
  392. package/migrations/006_add_task_invocations.sql +33 -0
  393. package/migrations/007_add_file_anchor.sql +14 -0
  394. package/migrations/manifest.json +62 -0
  395. package/package.json +49 -0
@@ -0,0 +1,315 @@
1
+ "use strict";
2
+ /**
3
+ * Coder prompt templates
4
+ * Following the exact templates from PROMPTS.md
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.generateCoderPrompt = generateCoderPrompt;
8
+ exports.generateBatchCoderPrompt = generateBatchCoderPrompt;
9
+ exports.generateResumingCoderPrompt = generateResumingCoderPrompt;
10
+ const prompt_helpers_js_1 = require("./prompt-helpers.js");
11
+ /**
12
+ * Generate the coder prompt for a new task
13
+ */
14
+ function generateCoderPrompt(context) {
15
+ const { task, projectPath, previousStatus, rejectionNotes, rejectionHistory, coordinatorGuidance } = context;
16
+ const agentsMd = (0, prompt_helpers_js_1.getAgentsMd)(projectPath);
17
+ const sourceContent = (0, prompt_helpers_js_1.getSourceFileContent)(projectPath, task.source_file);
18
+ // Build rejection section with full history and coordinator guidance
19
+ const rejectionSection = (0, prompt_helpers_js_1.formatRejectionHistoryForCoder)(task.id, rejectionHistory, rejectionNotes, coordinatorGuidance);
20
+ // Build file scope section
21
+ const fileScopeSection = (0, prompt_helpers_js_1.buildFileScopeSection)(task, sourceContent);
22
+ const fileAnchorSection = (0, prompt_helpers_js_1.buildFileAnchorSection)(task);
23
+ return `# TASK: ${task.id.substring(0, 8)} - ${task.title}
24
+ # Status: ${previousStatus} → in_progress | Rejections: ${task.rejection_count}/15
25
+
26
+ You are a CODER in an automated task execution system. Your job is to implement the task below according to the specification.
27
+
28
+ **Follow the project's existing architecture and patterns.** Read AGENTS.md and existing code to understand how things are structured before making changes.
29
+
30
+ ---
31
+
32
+ ## Task Information
33
+
34
+ **Task ID:** ${task.id}
35
+ **Title:** ${task.title}
36
+ **Rejection Count:** ${task.rejection_count}/15
37
+ **Project:** ${projectPath}
38
+ ${fileScopeSection}${fileAnchorSection}
39
+ ---
40
+
41
+ ## Specification
42
+
43
+ The full specification is in: ${task.source_file ?? '(not specified)'}
44
+
45
+ ${sourceContent}
46
+
47
+ ---
48
+
49
+ ## Project Guidelines
50
+
51
+ ${agentsMd}
52
+
53
+ ---
54
+
55
+ ## Existing Code Context
56
+
57
+ Review relevant project files as needed for your implementation.
58
+ ${rejectionSection}
59
+ ---
60
+
61
+ ## FIRST: Check If Work Is Already Done
62
+
63
+ **Before implementing anything, check if the work already exists:**
64
+
65
+ 1. Search for files/code that match the specification requirements
66
+ 2. Run \`git log --oneline -20\` to see recent commits
67
+ 3. If the implementation already exists:
68
+ - Identify which commit contains the work (you NEED the hash)
69
+ - Verify it matches the specification with \`git show <hash>\`
70
+ - **Do NOT create duplicate code**
71
+ - Submit for review with a note including the commit hash AND file list
72
+
73
+ \`\`\`bash
74
+ # Example: If work exists in commit abc1234
75
+ git log --oneline -20 # Find commits
76
+ git show abc1234 --stat # Verify it matches spec, note the files
77
+
78
+ # IMPORTANT: Include commit hash and files in your notes
79
+ steroids tasks update ${task.id} --status review --notes "Work exists in commit abc1234. Files: src/foo.ts, src/bar.ts. Verified against spec."
80
+ \`\`\`
81
+
82
+ The reviewer will check the commit you reference. Be precise about the hash and files.
83
+
84
+ ---
85
+
86
+ ## Your Instructions (If Work Is NOT Already Done)
87
+
88
+ 1. Read the specification carefully
89
+ 2. Implement the feature/fix as specified
90
+ 3. Write tests if the project has a test directory
91
+ 4. Keep files under 500 lines
92
+ 5. Follow the coding standards in AGENTS.md
93
+
94
+ ### Security Notes
95
+
96
+ - When executing shell commands with user-controlled arguments, use array-based APIs (e.g., \`execFileSync(cmd, [args])\`). Add a comment like \`// hardcoded command, no user input\` when using \`execSync\` intentionally for fixed commands or shell features.
97
+ - If you make a security-relevant decision (e.g., choosing \`execSync\` over \`execFileSync\` because you need pipes), explain your reasoning in your submission notes with \`--notes\`.
98
+ - If you notice a pre-existing security concern or something a human should review, create a feedback task:
99
+ \`\`\`bash
100
+ steroids tasks add "Description of the concern" --feedback
101
+ \`\`\`
102
+ This goes to a skipped section for human review and will NOT block the pipeline.
103
+
104
+ ---
105
+
106
+ ## Attempt Before Skip (IMPORTANT)
107
+
108
+ **You MUST attempt any task that can be run locally, even if it might fail.**
109
+
110
+ Many tasks look like they need external setup, but they're actually runnable commands. Your job is to TRY them first.
111
+
112
+ **The rule is simple:** If you can type a command and hit Enter, ATTEMPT IT.
113
+
114
+ Even if it fails, that failure is valuable information. The reviewer wants to see that you tried.
115
+
116
+ **Only skip when the task TRULY requires external action you cannot perform** (e.g., cloud console access, DNS configuration, account creation).
117
+
118
+ **BEFORE skipping, check the spec section for:**
119
+ - \`> SKIP\` markers, "manual setup", "handled manually", "external setup"
120
+ - Cloud infrastructure tasks with NO automation scripts provided
121
+
122
+ **If you must skip:**
123
+ \`\`\`bash
124
+ steroids tasks skip ${task.id} --notes "SKIP REASON: <why>. WHAT'S NEEDED: <human action>. BLOCKING: <dependent tasks>."
125
+ \`\`\`
126
+
127
+ ---
128
+
129
+ ## CRITICAL RULES
130
+
131
+ 1. **NEVER touch .steroids/ directory** (no .db, .yaml, .yml files)
132
+ 2. **BUILD MUST PASS before submitting** (run build and tests, fix errors)
133
+ 3. **Use CLI for status updates:** \`steroids tasks update ${task.id} --status review\`
134
+ 4. **Commit your work** with a meaningful message before submitting
135
+ 5. **Never modify TODO.md directly** - the CLI manages task status
136
+
137
+ ---
138
+
139
+ ## When You Are Done
140
+
141
+ **Verify the project builds AND tests pass, then:**
142
+
143
+ \`\`\`bash
144
+ git add <your-changed-files>
145
+ git commit -m "<type>: <descriptive message>"
146
+ steroids tasks update ${task.id} --status review
147
+ \`\`\`
148
+
149
+ If you do NOT run \`steroids tasks update\`, your work will not be submitted.
150
+
151
+ ---
152
+ ${task.rejection_count > 0 ? `
153
+ ## THIS TASK HAS BEEN REJECTED ${task.rejection_count} TIME(S)
154
+
155
+ **You MUST address the reviewer's feedback before submitting again.**
156
+ Extract every test case from the rejection notes, run each one, fix issues at the source, then test again.
157
+
158
+ ` : ''}---
159
+
160
+ ## Start Now
161
+
162
+ Begin by reading ${task.source_file ?? 'the specification above'} and implementing the task.
163
+ `;
164
+ }
165
+ /**
166
+ * Generate the coder prompt for a batch of tasks
167
+ */
168
+ function generateBatchCoderPrompt(context) {
169
+ const { tasks, projectPath, sectionName } = context;
170
+ const agentsMd = (0, prompt_helpers_js_1.getAgentsMd)(projectPath);
171
+ // Build task specs for each task
172
+ const taskSpecs = tasks.map((task, index) => {
173
+ const sourceContent = (0, prompt_helpers_js_1.getSourceFileContent)(projectPath, task.source_file);
174
+ return `
175
+ ### Task ${index + 1}: ${task.title}
176
+ **Task ID:** ${task.id}
177
+ **Spec File:** ${task.source_file ?? '(not specified)'}
178
+
179
+ ${sourceContent}
180
+ `;
181
+ }).join('\n---\n');
182
+ const taskIds = tasks.map(t => t.id);
183
+ return `# STEROIDS BATCH CODER TASK
184
+
185
+ You are a CODER assigned MULTIPLE tasks from section "${sectionName}".
186
+
187
+ **IMPORTANT:** Implement each task IN ORDER, committing after each one.
188
+
189
+ ## Section: ${sectionName}
190
+ **Total Tasks:** ${tasks.length}
191
+ **Project:** ${projectPath}
192
+
193
+ ---
194
+
195
+ ## Project Guidelines
196
+
197
+ ${agentsMd}
198
+
199
+ ---
200
+
201
+ ## TASKS TO IMPLEMENT
202
+
203
+ ${taskSpecs}
204
+
205
+ ---
206
+
207
+ ## YOUR WORKFLOW
208
+
209
+ For EACH task:
210
+ 1. Read the specification
211
+ 2. Implement the feature/fix
212
+ 3. Run tests if applicable
213
+ 4. Commit: \`git add <files> && git commit -m "<type>: <message>"\`
214
+ 5. Update status: \`steroids tasks update <task-id> --status review\`
215
+ 6. Move to next task
216
+
217
+ **CRITICAL:** Each task MUST have its own commit and status update.
218
+
219
+ ---
220
+
221
+ ## CRITICAL RULES
222
+
223
+ 1. **NEVER touch .steroids/ directory**
224
+ 2. **BUILD MUST PASS after each task**
225
+ 3. **Commit after EACH task** with a descriptive message
226
+ 4. **Update status after EACH commit**
227
+
228
+ ---
229
+
230
+ ## TASK IDS
231
+
232
+ ${taskIds.map((id, i) => `- Task ${i + 1}: ${id}`).join('\n')}
233
+
234
+ ---
235
+
236
+ ## Start Now
237
+
238
+ Begin with Task 1 and work through each task in order.
239
+ `;
240
+ }
241
+ /**
242
+ * Generate the coder prompt for resuming partial work
243
+ */
244
+ function generateResumingCoderPrompt(context) {
245
+ const { task, projectPath, gitStatus, gitDiff, rejectionHistory, coordinatorGuidance } = context;
246
+ const sourceContent = (0, prompt_helpers_js_1.getSourceFileContent)(projectPath, task.source_file);
247
+ const fileAnchorSection = (0, prompt_helpers_js_1.buildFileAnchorSection)(task);
248
+ // Build rejection section with full history and coordinator guidance (same as normal prompt)
249
+ const rejectionSection = (0, prompt_helpers_js_1.formatRejectionHistoryForCoder)(task.id, rejectionHistory, undefined, coordinatorGuidance);
250
+ return `# TASK: ${task.id.substring(0, 8)} - ${task.title} (RESUMING)
251
+ # Status: resuming | Rejections: ${task.rejection_count}/15
252
+
253
+ You are a CODER resuming work on a partially completed task.
254
+
255
+ ---
256
+
257
+ ## Task Information
258
+
259
+ **Task ID:** ${task.id}
260
+ **Title:** ${task.title}
261
+ **Status:** in_progress (resuming)
262
+ **Rejection Count:** ${task.rejection_count}/15
263
+ **Project:** ${projectPath}
264
+ ${fileAnchorSection}
265
+ ---
266
+
267
+ ## Previous Work Detected
268
+
269
+ A previous coder started this task but did not complete it. You may find:
270
+ - Uncommitted changes in the working directory
271
+ - Partial implementations in progress
272
+
273
+ **Git Status:**
274
+ \`\`\`
275
+ ${gitStatus ?? 'No uncommitted changes'}
276
+ \`\`\`
277
+
278
+ **Uncommitted Changes:**
279
+ \`\`\`diff
280
+ ${gitDiff ?? 'No changes'}
281
+ \`\`\`
282
+
283
+ ---
284
+
285
+ ## Your Instructions
286
+
287
+ 1. Review what the previous coder did
288
+ 2. If the work looks good, complete it
289
+ 3. If the work looks wrong, you may start fresh
290
+ 4. Commit all changes when done
291
+ ${rejectionSection}
292
+ ---
293
+
294
+ ## Specification
295
+
296
+ ${sourceContent}
297
+
298
+ ---
299
+
300
+ ## CRITICAL RULES
301
+
302
+ 1. **NEVER touch .steroids/ directory**
303
+ 2. **Commit your work before submitting**
304
+ 3. **Run \`steroids tasks update ${task.id} --status review\` when done**
305
+
306
+ If you do NOT update the task status, you will be restarted.
307
+
308
+ ---
309
+
310
+ ## Complete the Task Now
311
+
312
+ Review the existing work and finish the implementation.
313
+ `;
314
+ }
315
+ //# sourceMappingURL=coder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coder.js","sourceRoot":"","sources":["../../src/prompts/coder.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Shared prompt helper functions
3
+ * Used by coder, reviewer, and coordinator prompts
4
+ */
5
+ import type { Task, RejectionEntry } from '../database/queries.js';
6
+ /**
7
+ * Read AGENTS.md content if present
8
+ */
9
+ export declare function getAgentsMd(projectPath: string): string;
10
+ /**
11
+ * Read source file content if specified
12
+ */
13
+ export declare function getSourceFileContent(projectPath: string, sourceFile?: string | null): string;
14
+ /**
15
+ * Extract first line of rejection notes as a title/summary
16
+ */
17
+ export declare function extractRejectionTitle(notes: string | null | undefined): string;
18
+ /**
19
+ * Detect repeated patterns in rejection history
20
+ * Uses normalized fuzzy matching to catch similar (not just identical) issues
21
+ */
22
+ export declare function detectRejectionPatterns(rejectionHistory: RejectionEntry[]): string;
23
+ /**
24
+ * Extract file paths mentioned in text (task title, spec content)
25
+ * Language-agnostic: matches any path-like pattern with directory separators and file extensions
26
+ */
27
+ export declare function extractFileHints(title: string, specContent: string): string[];
28
+ /**
29
+ * Build a file scope section for the prompt
30
+ */
31
+ export declare function buildFileScopeSection(task: Task, specContent: string): string;
32
+ /**
33
+ * Format rejection history for coder prompt
34
+ * Shows ALL rejection titles for pattern visibility, full details of last 3
35
+ */
36
+ export declare function formatRejectionHistoryForCoder(taskId: string, rejectionHistory?: RejectionEntry[], latestNotes?: string, coordinatorGuidance?: string): string;
37
+ /**
38
+ * Build a file anchor section for the prompt
39
+ * Directs the coder/reviewer to a specific file and line
40
+ */
41
+ export declare function buildFileAnchorSection(task: Task): string;
42
+ export interface SectionTask {
43
+ id: string;
44
+ title: string;
45
+ status: string;
46
+ }
47
+ /**
48
+ * Format other tasks in the same section for context
49
+ */
50
+ export declare function formatSectionTasks(currentTaskId: string, sectionTasks?: SectionTask[]): string;
51
+ //# sourceMappingURL=prompt-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-helpers.d.ts","sourceRoot":"","sources":["../../src/prompts/prompt-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEnE;;GAEG;AACH,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAWvD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GACzB,MAAM,CAgBR;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAK9E;AAUD;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,gBAAgB,EAAE,cAAc,EAAE,GAAG,MAAM,CA6DlF;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAgB7E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAe7E;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,MAAM,EACd,gBAAgB,CAAC,EAAE,cAAc,EAAE,EACnC,WAAW,CAAC,EAAE,MAAM,EACpB,mBAAmB,CAAC,EAAE,MAAM,GAC3B,MAAM,CAqFR;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAkBzD;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAID;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,WAAW,EAAE,GAAG,MAAM,CAwC9F"}
@@ -0,0 +1,312 @@
1
+ "use strict";
2
+ /**
3
+ * Shared prompt helper functions
4
+ * Used by coder, reviewer, and coordinator prompts
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.getAgentsMd = getAgentsMd;
8
+ exports.getSourceFileContent = getSourceFileContent;
9
+ exports.extractRejectionTitle = extractRejectionTitle;
10
+ exports.detectRejectionPatterns = detectRejectionPatterns;
11
+ exports.extractFileHints = extractFileHints;
12
+ exports.buildFileScopeSection = buildFileScopeSection;
13
+ exports.formatRejectionHistoryForCoder = formatRejectionHistoryForCoder;
14
+ exports.buildFileAnchorSection = buildFileAnchorSection;
15
+ exports.formatSectionTasks = formatSectionTasks;
16
+ const node_fs_1 = require("node:fs");
17
+ const node_path_1 = require("node:path");
18
+ /**
19
+ * Read AGENTS.md content if present
20
+ */
21
+ function getAgentsMd(projectPath) {
22
+ const agentsPath = (0, node_path_1.join)(projectPath, 'AGENTS.md');
23
+ if ((0, node_fs_1.existsSync)(agentsPath)) {
24
+ const content = (0, node_fs_1.readFileSync)(agentsPath, 'utf-8');
25
+ // Truncate if too long (max 5000 chars per spec)
26
+ if (content.length > 5000) {
27
+ return content.substring(0, 5000) + '\n\n[Content truncated]';
28
+ }
29
+ return content;
30
+ }
31
+ return 'No AGENTS.md found. Follow standard coding practices.';
32
+ }
33
+ /**
34
+ * Read source file content if specified
35
+ */
36
+ function getSourceFileContent(projectPath, sourceFile) {
37
+ if (!sourceFile) {
38
+ return 'No specification file linked.';
39
+ }
40
+ const fullPath = (0, node_path_1.join)(projectPath, sourceFile);
41
+ if (!(0, node_fs_1.existsSync)(fullPath)) {
42
+ return `Specification file not found: ${sourceFile}`;
43
+ }
44
+ const content = (0, node_fs_1.readFileSync)(fullPath, 'utf-8');
45
+ // Truncate if too long (max 10000 chars per spec)
46
+ if (content.length > 10000) {
47
+ return content.substring(0, 10000) + `\n\n[Content truncated. Full file at: ${sourceFile}]`;
48
+ }
49
+ return content;
50
+ }
51
+ /**
52
+ * Extract first line of rejection notes as a title/summary
53
+ */
54
+ function extractRejectionTitle(notes) {
55
+ if (!notes)
56
+ return '(no notes)';
57
+ const firstLine = notes.split('\n').find(l => l.trim().length > 0) || '(no notes)';
58
+ // Strip markdown formatting for summary
59
+ return firstLine.replace(/^[-*#\s[\]]+/, '').trim().substring(0, 100);
60
+ }
61
+ /**
62
+ * Normalize text for fuzzy comparison
63
+ * Strips punctuation, lowercases, collapses whitespace
64
+ */
65
+ function normalizeForComparison(text) {
66
+ return text.toLowerCase().replace(/[^a-z0-9\s]/g, '').replace(/\s+/g, ' ').trim();
67
+ }
68
+ /**
69
+ * Detect repeated patterns in rejection history
70
+ * Uses normalized fuzzy matching to catch similar (not just identical) issues
71
+ */
72
+ function detectRejectionPatterns(rejectionHistory) {
73
+ if (rejectionHistory.length < 3)
74
+ return '';
75
+ // Extract titles and normalize for comparison
76
+ const entries = rejectionHistory.map(r => ({
77
+ title: extractRejectionTitle(r.notes),
78
+ normalized: normalizeForComparison(extractRejectionTitle(r.notes)),
79
+ }));
80
+ // Group by normalized title (catches minor wording variations)
81
+ const groups = new Map();
82
+ for (const entry of entries) {
83
+ const existing = groups.get(entry.normalized);
84
+ if (existing) {
85
+ existing.count++;
86
+ }
87
+ else {
88
+ groups.set(entry.normalized, { title: entry.title, count: 1 });
89
+ }
90
+ }
91
+ // Also check for keyword-level overlap between non-identical entries
92
+ // If 3+ rejections share significant keywords, flag it
93
+ const allNotes = rejectionHistory.map(r => r.notes || '');
94
+ const keywordCounts = new Map();
95
+ for (const note of allNotes) {
96
+ // Extract significant words (4+ chars, not common words)
97
+ const words = new Set(normalizeForComparison(note)
98
+ .split(' ')
99
+ .filter(w => w.length >= 4));
100
+ for (const word of words) {
101
+ keywordCounts.set(word, (keywordCounts.get(word) || 0) + 1);
102
+ }
103
+ }
104
+ const hotKeywords = [...keywordCounts.entries()]
105
+ .filter(([, count]) => count >= 3)
106
+ .filter(([word]) => !['task', 'file', 'code', 'this', 'that', 'should', 'must', 'need'].includes(word))
107
+ .map(([word]) => word);
108
+ const repeated = [...groups.values()].filter(g => g.count >= 3);
109
+ if (repeated.length === 0 && hotKeywords.length === 0)
110
+ return '';
111
+ const lines = [];
112
+ for (const { title, count } of repeated) {
113
+ lines.push(`- "${title}" - raised ${count} times`);
114
+ }
115
+ if (hotKeywords.length > 0 && repeated.length === 0) {
116
+ lines.push(`- Recurring themes: ${hotKeywords.slice(0, 5).join(', ')}`);
117
+ }
118
+ return `
119
+ **PATTERN DETECTED - The following issues keep repeating:**
120
+
121
+ ${lines.join('\n')}
122
+
123
+ If you cannot resolve these, DISPUTE the task instead of resubmitting the same work:
124
+ \`\`\`bash
125
+ steroids dispute create <task-id> --reason "Cannot resolve: <explain why>" --type coder
126
+ \`\`\`
127
+ `;
128
+ }
129
+ /**
130
+ * Extract file paths mentioned in text (task title, spec content)
131
+ * Language-agnostic: matches any path-like pattern with directory separators and file extensions
132
+ */
133
+ function extractFileHints(title, specContent) {
134
+ const combined = `${title}\n${specContent}`;
135
+ // Match any path with at least one directory separator and a file extension (1-10 chars)
136
+ // Examples: src/foo.ts, lib/utils/helpers.py, app/models/user.rb, pkg/api/handler.go
137
+ const filePattern = /(?:^|\s|`|"|'|\()([\w][\w.-]*(?:\/[\w.-]+)+\.\w{1,10})/gm;
138
+ const matches = new Set();
139
+ let match;
140
+ while ((match = filePattern.exec(combined)) !== null) {
141
+ const path = match[1];
142
+ // Filter out URLs, version numbers, and common false positives
143
+ if (path.includes('://') || /^\d+\.\d+\.\d+/.test(path) || path.includes('node_modules/')) {
144
+ continue;
145
+ }
146
+ matches.add(path);
147
+ }
148
+ return [...matches];
149
+ }
150
+ /**
151
+ * Build a file scope section for the prompt
152
+ */
153
+ function buildFileScopeSection(task, specContent) {
154
+ const fileHints = extractFileHints(task.title, specContent);
155
+ if (fileHints.length === 0)
156
+ return '';
157
+ return `
158
+ ---
159
+
160
+ ## FILE SCOPE
161
+
162
+ Based on the task specification, these files are likely relevant:
163
+ ${fileHints.map(f => `- \`${f}\``).join('\n')}
164
+
165
+ **Focus your changes on these files.** If you find yourself modifying unrelated files, STOP and re-read the specification.
166
+
167
+ `;
168
+ }
169
+ /**
170
+ * Format rejection history for coder prompt
171
+ * Shows ALL rejection titles for pattern visibility, full details of last 3
172
+ */
173
+ function formatRejectionHistoryForCoder(taskId, rejectionHistory, latestNotes, coordinatorGuidance) {
174
+ if (!rejectionHistory || rejectionHistory.length === 0) {
175
+ return '';
176
+ }
177
+ const latest = rejectionHistory[rejectionHistory.length - 1];
178
+ const latestCommitRef = latest.commit_sha ? ` (commit: ${latest.commit_sha.substring(0, 7)})` : '';
179
+ // Show ALL rejection titles for pattern visibility
180
+ const rejectionTitlesList = rejectionHistory.map(r => `${r.rejection_number}. ${extractRejectionTitle(r.notes)}`).join('\n');
181
+ // Show full details of last 3 rejections
182
+ const detailedRejections = rejectionHistory.length > 3
183
+ ? rejectionHistory.slice(-3)
184
+ : rejectionHistory;
185
+ const detailedLines = detailedRejections.map(r => {
186
+ const commitRef = r.commit_sha ? ` (commit: ${r.commit_sha.substring(0, 7)})` : '';
187
+ return `### Rejection #${r.rejection_number}${commitRef}
188
+ ${r.notes || '(no detailed notes)'}
189
+ `;
190
+ });
191
+ // Detect patterns
192
+ const patternWarning = detectRejectionPatterns(rejectionHistory);
193
+ // Coordinator guidance section (injected after 2nd rejection)
194
+ const coordinatorSection = coordinatorGuidance ? `
195
+ ---
196
+
197
+ ## COORDINATOR GUIDANCE
198
+
199
+ A coordinator has reviewed the rejection history and provides this guidance:
200
+
201
+ ${coordinatorGuidance}
202
+
203
+ **Follow the coordinator's guidance above. It takes priority over conflicting reviewer feedback.**
204
+
205
+ ` : '';
206
+ return `
207
+ ---
208
+
209
+ ## REJECTION HISTORY (${rejectionHistory.length} total, max 15)
210
+
211
+ ${rejectionTitlesList}
212
+
213
+ ${patternWarning}
214
+ ---
215
+
216
+ ## LATEST REJECTION${latestCommitRef}
217
+
218
+ **ADDRESS EACH CHECKBOX BELOW:**
219
+
220
+ ${latest.notes || '(no notes)'}
221
+
222
+ ---
223
+ ${detailedLines.length > 1 ? `## Previous Rejections (for context)\n\n${detailedLines.slice(0, -1).join('\n---\n')}` : ''}
224
+ ${coordinatorSection}---
225
+
226
+ ## BEFORE SUBMITTING
227
+
228
+ 1. For each \`- [ ]\` item in the rejection:
229
+ - Open the file mentioned
230
+ - Make the exact change requested
231
+ - Verify the fix works
232
+
233
+ 2. Run the build and tests:
234
+ - The project must build successfully
235
+ - Tests must pass (if the project has tests)
236
+
237
+ 3. Only THEN submit for review:
238
+ \`\`\`bash
239
+ steroids tasks update ${taskId} --status review
240
+ \`\`\`
241
+
242
+ **DO NOT submit until you have addressed EVERY checkbox in the rejection notes.**
243
+
244
+ If you believe the reviewer is wrong or the requirement is impossible, dispute:
245
+ \`\`\`bash
246
+ steroids dispute create ${taskId} --reason "explanation" --type coder
247
+ \`\`\`
248
+ `;
249
+ }
250
+ /**
251
+ * Build a file anchor section for the prompt
252
+ * Directs the coder/reviewer to a specific file and line
253
+ */
254
+ function buildFileAnchorSection(task) {
255
+ if (!task.file_path)
256
+ return '';
257
+ const lineRef = task.file_line ? `:${task.file_line}` : '';
258
+ const commitShort = task.file_commit_sha?.substring(0, 7) ?? 'unknown';
259
+ return `
260
+ ## FILE ANCHOR
261
+
262
+ **This task is anchored to a specific location in the codebase:**
263
+
264
+ - **File:** \`${task.file_path}${lineRef}\`
265
+ ${task.file_line ? `- **Line:** ${task.file_line}\n` : ''}- **Commit:** \`${commitShort}\`
266
+
267
+ Start your investigation at this file${task.file_line ? ' and line' : ''}. Use \`git show ${commitShort}:${task.file_path}\` to see the version when this task was created.
268
+
269
+ ---
270
+ `;
271
+ }
272
+ const MAX_SECTION_TASKS = 15;
273
+ /**
274
+ * Format other tasks in the same section for context
275
+ */
276
+ function formatSectionTasks(currentTaskId, sectionTasks) {
277
+ if (!sectionTasks || sectionTasks.length <= 1) {
278
+ return '';
279
+ }
280
+ const statusEmoji = {
281
+ 'pending': '\u23F3',
282
+ 'in_progress': '\uD83D\uDD04',
283
+ 'review': '\uD83D\uDC40',
284
+ 'completed': '\u2705',
285
+ };
286
+ const otherTasks = sectionTasks.filter(t => t.id !== currentTaskId);
287
+ const tasksToShow = otherTasks.slice(0, MAX_SECTION_TASKS);
288
+ const remainingCount = otherTasks.length - tasksToShow.length;
289
+ const lines = tasksToShow.map(t => {
290
+ const emoji = statusEmoji[t.status] || '\u2753';
291
+ const marker = t.status === 'completed' ? ' (done)' : t.status === 'pending' ? ' (pending)' : '';
292
+ return `- ${emoji} ${t.title}${marker}`;
293
+ });
294
+ if (remainingCount > 0) {
295
+ lines.push(`- ... and ${remainingCount} more task${remainingCount > 1 ? 's' : ''}`);
296
+ }
297
+ if (lines.length === 0)
298
+ return '';
299
+ return `
300
+ ---
301
+
302
+ ## Other Tasks in This Section
303
+
304
+ **IMPORTANT:** The task you are reviewing is ONE of several tasks implementing this feature.
305
+ Do NOT reject this task for issues that are explicitly listed as separate tasks below.
306
+ Focus ONLY on whether THIS task's scope is correctly implemented.
307
+
308
+ ${lines.join('\n')}
309
+
310
+ `;
311
+ }
312
+ //# sourceMappingURL=prompt-helpers.js.map