prizmkit 1.1.99 → 1.1.101

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 (321) hide show
  1. package/bin/create-prizmkit.js +4 -4
  2. package/bundled/VERSION.json +3 -3
  3. package/bundled/dev-pipeline/.env.example +3 -3
  4. package/bundled/dev-pipeline/README.md +110 -90
  5. package/bundled/dev-pipeline/assets/prizm-dev-team-integration.md +1 -1
  6. package/bundled/dev-pipeline/cli.py +27 -0
  7. package/bundled/dev-pipeline/prizmkit_runtime/__init__.py +13 -0
  8. package/bundled/dev-pipeline/prizmkit_runtime/__main__.py +9 -0
  9. package/bundled/dev-pipeline/prizmkit_runtime/cli.py +193 -0
  10. package/bundled/dev-pipeline/prizmkit_runtime/commands.py +313 -0
  11. package/bundled/dev-pipeline/prizmkit_runtime/compat.py +32 -0
  12. package/bundled/dev-pipeline/prizmkit_runtime/config.py +410 -0
  13. package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +478 -0
  14. package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +734 -0
  15. package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +256 -0
  16. package/bundled/dev-pipeline/prizmkit_runtime/interoperability.py +109 -0
  17. package/bundled/dev-pipeline/prizmkit_runtime/paths.py +110 -0
  18. package/bundled/dev-pipeline/prizmkit_runtime/processes.py +373 -0
  19. package/bundled/dev-pipeline/prizmkit_runtime/reset.py +389 -0
  20. package/bundled/dev-pipeline/prizmkit_runtime/runner_bookkeeping.py +51 -0
  21. package/bundled/dev-pipeline/prizmkit_runtime/runner_classification.py +179 -0
  22. package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +345 -0
  23. package/bundled/dev-pipeline/prizmkit_runtime/runner_prompts.py +118 -0
  24. package/bundled/dev-pipeline/prizmkit_runtime/runner_recovery.py +187 -0
  25. package/bundled/dev-pipeline/prizmkit_runtime/runner_status.py +147 -0
  26. package/bundled/dev-pipeline/prizmkit_runtime/runners.py +422 -0
  27. package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +552 -0
  28. package/bundled/dev-pipeline/prizmkit_runtime/status.py +71 -0
  29. package/bundled/dev-pipeline/scripts/check-session-status.py +74 -1
  30. package/bundled/dev-pipeline/scripts/continuation.py +374 -0
  31. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +64 -52
  32. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +35 -25
  33. package/bundled/dev-pipeline/scripts/generate-recovery-prompt.py +2 -2
  34. package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +15 -20
  35. package/bundled/dev-pipeline/scripts/parse-stream-progress.py +185 -16
  36. package/bundled/dev-pipeline/scripts/update-bug-status.py +214 -6
  37. package/bundled/dev-pipeline/scripts/update-feature-status.py +237 -6
  38. package/bundled/dev-pipeline/scripts/update-refactor-status.py +214 -6
  39. package/bundled/dev-pipeline/templates/agent-prompts/dev-implement.md +8 -2
  40. package/bundled/dev-pipeline/templates/bootstrap-prompt.md +4 -0
  41. package/bundled/dev-pipeline/templates/bootstrap-tier1.md +14 -5
  42. package/bundled/dev-pipeline/templates/bootstrap-tier2.md +16 -6
  43. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +16 -6
  44. package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +1 -1
  45. package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +3 -3
  46. package/bundled/dev-pipeline/templates/sections/context-budget-rules.md +2 -0
  47. package/bundled/dev-pipeline/templates/sections/log-size-awareness.md +13 -69
  48. package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-agent-suffix.md +15 -7
  49. package/bundled/dev-pipeline/templates/sections/phase-implement-agent.md +42 -29
  50. package/bundled/dev-pipeline/templates/sections/phase-implement-full.md +41 -39
  51. package/bundled/dev-pipeline/templates/sections/test-failure-recovery-agent.md +4 -0
  52. package/bundled/dev-pipeline/templates/sections/test-failure-recovery-lite.md +4 -0
  53. package/bundled/dev-pipeline/templates/session-status-schema.json +1 -1
  54. package/bundled/dev-pipeline/tests/conftest.py +1 -0
  55. package/bundled/dev-pipeline/tests/test_auto_skip.py +932 -0
  56. package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +207 -0
  57. package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +100 -0
  58. package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +43 -0
  59. package/bundled/dev-pipeline/tests/test_python_runner_parity.py +1138 -0
  60. package/bundled/dev-pipeline/tests/test_unified_cli.py +1045 -0
  61. package/bundled/skills/_metadata.json +1 -1
  62. package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +29 -34
  63. package/bundled/skills/bugfix-pipeline-launcher/references/configuration.md +6 -5
  64. package/bundled/skills/feature-pipeline-launcher/SKILL.md +29 -35
  65. package/bundled/skills/feature-pipeline-launcher/references/configuration.md +7 -6
  66. package/bundled/skills/feature-workflow/SKILL.md +3 -6
  67. package/bundled/skills/recovery-workflow/SKILL.md +23 -32
  68. package/bundled/skills/refactor-pipeline-launcher/SKILL.md +29 -35
  69. package/bundled/skills/refactor-pipeline-launcher/references/configuration.md +7 -6
  70. package/bundled/skills/refactor-workflow/SKILL.md +3 -6
  71. package/bundled/templates/hooks/commit-intent.json +2 -2
  72. package/bundled/templates/hooks/diff-prizm-docs.py +226 -0
  73. package/bundled/templates/hooks/prizm-pre-commit.py +45 -0
  74. package/bundled/templates/hooks/validate-prizm-docs.py +240 -0
  75. package/package.json +1 -1
  76. package/src/config.js +33 -12
  77. package/src/index.js +3 -6
  78. package/src/manifest.js +3 -2
  79. package/src/metadata.js +7 -18
  80. package/src/prompts.js +0 -12
  81. package/src/runtimes.js +18 -11
  82. package/src/scaffold.js +133 -116
  83. package/src/upgrade.js +1 -1
  84. package/bundled/dev-pipeline/launch-bugfix-daemon.sh +0 -500
  85. package/bundled/dev-pipeline/launch-feature-daemon.sh +0 -657
  86. package/bundled/dev-pipeline/launch-refactor-daemon.sh +0 -502
  87. package/bundled/dev-pipeline/lib/branch.sh +0 -326
  88. package/bundled/dev-pipeline/lib/common.sh +0 -1257
  89. package/bundled/dev-pipeline/lib/heartbeat.sh +0 -469
  90. package/bundled/dev-pipeline/reset-bug.sh +0 -395
  91. package/bundled/dev-pipeline/reset-feature.sh +0 -406
  92. package/bundled/dev-pipeline/reset-refactor.sh +0 -393
  93. package/bundled/dev-pipeline/run-bugfix.sh +0 -1315
  94. package/bundled/dev-pipeline/run-feature.sh +0 -1602
  95. package/bundled/dev-pipeline/run-recovery.sh +0 -648
  96. package/bundled/dev-pipeline/run-refactor.sh +0 -1348
  97. package/bundled/dev-pipeline/scripts/monitor-log.sh +0 -104
  98. package/bundled/dev-pipeline/tests/test-path-resolution.sh +0 -100
  99. package/bundled/dev-pipeline-windows/.env.example +0 -36
  100. package/bundled/dev-pipeline-windows/README.md +0 -30
  101. package/bundled/dev-pipeline-windows/SCHEMA_ANALYSIS.md +0 -533
  102. package/bundled/dev-pipeline-windows/assets/feature-list-example.json +0 -146
  103. package/bundled/dev-pipeline-windows/assets/prizm-dev-team-integration.md +0 -137
  104. package/bundled/dev-pipeline-windows/launch-bugfix-daemon.ps1 +0 -9
  105. package/bundled/dev-pipeline-windows/launch-feature-daemon.ps1 +0 -9
  106. package/bundled/dev-pipeline-windows/launch-refactor-daemon.ps1 +0 -9
  107. package/bundled/dev-pipeline-windows/lib/branch.ps1 +0 -235
  108. package/bundled/dev-pipeline-windows/lib/common.ps1 +0 -829
  109. package/bundled/dev-pipeline-windows/lib/daemon.ps1 +0 -140
  110. package/bundled/dev-pipeline-windows/lib/pipeline.ps1 +0 -967
  111. package/bundled/dev-pipeline-windows/lib/reset.ps1 +0 -87
  112. package/bundled/dev-pipeline-windows/reset-bug.ps1 +0 -9
  113. package/bundled/dev-pipeline-windows/reset-feature.ps1 +0 -9
  114. package/bundled/dev-pipeline-windows/reset-refactor.ps1 +0 -9
  115. package/bundled/dev-pipeline-windows/run-bugfix.ps1 +0 -9
  116. package/bundled/dev-pipeline-windows/run-feature.ps1 +0 -9
  117. package/bundled/dev-pipeline-windows/run-recovery.ps1 +0 -179
  118. package/bundled/dev-pipeline-windows/run-refactor.ps1 +0 -9
  119. package/bundled/dev-pipeline-windows/scripts/check-session-status.py +0 -228
  120. package/bundled/dev-pipeline-windows/scripts/detect-stuck.py +0 -530
  121. package/bundled/dev-pipeline-windows/scripts/generate-bootstrap-prompt.py +0 -2282
  122. package/bundled/dev-pipeline-windows/scripts/generate-bugfix-prompt.py +0 -767
  123. package/bundled/dev-pipeline-windows/scripts/generate-recovery-prompt.py +0 -805
  124. package/bundled/dev-pipeline-windows/scripts/generate-refactor-prompt.py +0 -845
  125. package/bundled/dev-pipeline-windows/scripts/init-bugfix-pipeline.py +0 -316
  126. package/bundled/dev-pipeline-windows/scripts/init-dev-team.py +0 -134
  127. package/bundled/dev-pipeline-windows/scripts/init-pipeline.py +0 -382
  128. package/bundled/dev-pipeline-windows/scripts/init-refactor-pipeline.py +0 -399
  129. package/bundled/dev-pipeline-windows/scripts/monitor-log.ps1 +0 -102
  130. package/bundled/dev-pipeline-windows/scripts/parse-stream-progress.py +0 -1232
  131. package/bundled/dev-pipeline-windows/scripts/patch-completion-notes.py +0 -191
  132. package/bundled/dev-pipeline-windows/scripts/prizmkit-test-gate.py +0 -446
  133. package/bundled/dev-pipeline-windows/scripts/update-bug-status.py +0 -913
  134. package/bundled/dev-pipeline-windows/scripts/update-checkpoint.py +0 -173
  135. package/bundled/dev-pipeline-windows/scripts/update-feature-status.py +0 -1558
  136. package/bundled/dev-pipeline-windows/scripts/update-refactor-status.py +0 -1119
  137. package/bundled/dev-pipeline-windows/scripts/utils.py +0 -542
  138. package/bundled/dev-pipeline-windows/templates/agent-prompts/critic-plan-challenge.md +0 -7
  139. package/bundled/dev-pipeline-windows/templates/agent-prompts/dev-fix.md +0 -7
  140. package/bundled/dev-pipeline-windows/templates/agent-prompts/dev-implement.md +0 -65
  141. package/bundled/dev-pipeline-windows/templates/agent-prompts/dev-resume.md +0 -5
  142. package/bundled/dev-pipeline-windows/templates/agent-prompts/reviewer-review.md +0 -7
  143. package/bundled/dev-pipeline-windows/templates/bootstrap-prompt.md +0 -73
  144. package/bundled/dev-pipeline-windows/templates/bootstrap-tier1.md +0 -589
  145. package/bundled/dev-pipeline-windows/templates/bootstrap-tier2.md +0 -710
  146. package/bundled/dev-pipeline-windows/templates/bootstrap-tier3.md +0 -791
  147. package/bundled/dev-pipeline-windows/templates/bug-fix-list-schema.json +0 -263
  148. package/bundled/dev-pipeline-windows/templates/bugfix-bootstrap-prompt.md +0 -326
  149. package/bundled/dev-pipeline-windows/templates/feature-list-schema.json +0 -237
  150. package/bundled/dev-pipeline-windows/templates/refactor-bootstrap-prompt.md +0 -340
  151. package/bundled/dev-pipeline-windows/templates/refactor-list-schema.json +0 -270
  152. package/bundled/dev-pipeline-windows/templates/sections/ac-verification-checklist.md +0 -7
  153. package/bundled/dev-pipeline-windows/templates/sections/checkpoint-system.md +0 -91
  154. package/bundled/dev-pipeline-windows/templates/sections/context-budget-rules.md +0 -34
  155. package/bundled/dev-pipeline-windows/templates/sections/critical-paths-agent.md +0 -10
  156. package/bundled/dev-pipeline-windows/templates/sections/critical-paths-full.md +0 -12
  157. package/bundled/dev-pipeline-windows/templates/sections/critical-paths-lite.md +0 -7
  158. package/bundled/dev-pipeline-windows/templates/sections/directory-convention-agent.md +0 -8
  159. package/bundled/dev-pipeline-windows/templates/sections/directory-convention-full.md +0 -9
  160. package/bundled/dev-pipeline-windows/templates/sections/directory-convention-lite.md +0 -6
  161. package/bundled/dev-pipeline-windows/templates/sections/failure-capture.md +0 -21
  162. package/bundled/dev-pipeline-windows/templates/sections/feature-context.md +0 -21
  163. package/bundled/dev-pipeline-windows/templates/sections/log-size-awareness.md +0 -78
  164. package/bundled/dev-pipeline-windows/templates/sections/phase-browser-verification-auto.md +0 -283
  165. package/bundled/dev-pipeline-windows/templates/sections/phase-browser-verification-opencli.md +0 -112
  166. package/bundled/dev-pipeline-windows/templates/sections/phase-browser-verification.md +0 -168
  167. package/bundled/dev-pipeline-windows/templates/sections/phase-commit-full.md +0 -82
  168. package/bundled/dev-pipeline-windows/templates/sections/phase-commit.md +0 -75
  169. package/bundled/dev-pipeline-windows/templates/sections/phase-context-snapshot-agent-suffix.md +0 -23
  170. package/bundled/dev-pipeline-windows/templates/sections/phase-context-snapshot-base.md +0 -14
  171. package/bundled/dev-pipeline-windows/templates/sections/phase-context-snapshot-lite-suffix.md +0 -19
  172. package/bundled/dev-pipeline-windows/templates/sections/phase-critic-plan-full.md +0 -63
  173. package/bundled/dev-pipeline-windows/templates/sections/phase-critic-plan.md +0 -42
  174. package/bundled/dev-pipeline-windows/templates/sections/phase-implement-agent.md +0 -44
  175. package/bundled/dev-pipeline-windows/templates/sections/phase-implement-full.md +0 -59
  176. package/bundled/dev-pipeline-windows/templates/sections/phase-implement-lite.md +0 -39
  177. package/bundled/dev-pipeline-windows/templates/sections/phase-plan-agent.md +0 -27
  178. package/bundled/dev-pipeline-windows/templates/sections/phase-plan-lite.md +0 -27
  179. package/bundled/dev-pipeline-windows/templates/sections/phase-prizmkit-test.md +0 -39
  180. package/bundled/dev-pipeline-windows/templates/sections/phase-review-agent.md +0 -35
  181. package/bundled/dev-pipeline-windows/templates/sections/phase-review-full.md +0 -35
  182. package/bundled/dev-pipeline-windows/templates/sections/phase-specify-plan-full.md +0 -73
  183. package/bundled/dev-pipeline-windows/templates/sections/phase0-init.md +0 -13
  184. package/bundled/dev-pipeline-windows/templates/sections/phase0-test-baseline.md +0 -21
  185. package/bundled/dev-pipeline-windows/templates/sections/session-context.md +0 -5
  186. package/bundled/dev-pipeline-windows/templates/sections/subagent-timeout-recovery.md +0 -6
  187. package/bundled/dev-pipeline-windows/templates/sections/task-contract.md +0 -34
  188. package/bundled/dev-pipeline-windows/templates/sections/test-failure-recovery-agent.md +0 -48
  189. package/bundled/dev-pipeline-windows/templates/sections/test-failure-recovery-lite.md +0 -48
  190. package/bundled/dev-pipeline-windows/templates/session-status-schema.json +0 -83
  191. package/bundled/skills-windows/app-planner/SKILL.md +0 -296
  192. package/bundled/skills-windows/app-planner/assets/app-design-guide.md +0 -101
  193. package/bundled/skills-windows/app-planner/references/architecture-decisions.md +0 -52
  194. package/bundled/skills-windows/app-planner/references/brainstorm-guide.md +0 -101
  195. package/bundled/skills-windows/app-planner/references/frontend-design-guide.md +0 -71
  196. package/bundled/skills-windows/app-planner/references/infrastructure-convention-discovery.md +0 -108
  197. package/bundled/skills-windows/app-planner/references/project-brief-guide.md +0 -82
  198. package/bundled/skills-windows/app-planner/references/project-conventions-discovery.md +0 -59
  199. package/bundled/skills-windows/app-planner/references/project-state-detection.md +0 -90
  200. package/bundled/skills-windows/app-planner/references/red-team-checklist.md +0 -40
  201. package/bundled/skills-windows/app-planner/references/rules/backend/derivation-rules.md +0 -619
  202. package/bundled/skills-windows/app-planner/references/rules/backend/fixed-rules.md +0 -285
  203. package/bundled/skills-windows/app-planner/references/rules/backend/question-bank.md +0 -249
  204. package/bundled/skills-windows/app-planner/references/rules/backend/question-manifest.json +0 -46
  205. package/bundled/skills-windows/app-planner/references/rules/backend/template.md +0 -173
  206. package/bundled/skills-windows/app-planner/references/rules/database/derivation-rules.md +0 -382
  207. package/bundled/skills-windows/app-planner/references/rules/database/fixed-rules.md +0 -211
  208. package/bundled/skills-windows/app-planner/references/rules/database/question-bank.md +0 -184
  209. package/bundled/skills-windows/app-planner/references/rules/database/question-manifest.json +0 -39
  210. package/bundled/skills-windows/app-planner/references/rules/database/template.md +0 -158
  211. package/bundled/skills-windows/app-planner/references/rules/frontend/derivation-rules.md +0 -820
  212. package/bundled/skills-windows/app-planner/references/rules/frontend/fixed-rules.md +0 -188
  213. package/bundled/skills-windows/app-planner/references/rules/frontend/question-bank.md +0 -319
  214. package/bundled/skills-windows/app-planner/references/rules/frontend/question-manifest.json +0 -51
  215. package/bundled/skills-windows/app-planner/references/rules/frontend/template.md +0 -339
  216. package/bundled/skills-windows/app-planner/references/rules/mobile/derivation-rules.md +0 -649
  217. package/bundled/skills-windows/app-planner/references/rules/mobile/fixed-rules.md +0 -290
  218. package/bundled/skills-windows/app-planner/references/rules/mobile/question-bank.md +0 -232
  219. package/bundled/skills-windows/app-planner/references/rules/mobile/question-manifest.json +0 -47
  220. package/bundled/skills-windows/app-planner/references/rules/mobile/template.md +0 -175
  221. package/bundled/skills-windows/app-planner/references/rules-configuration.md +0 -46
  222. package/bundled/skills-windows/bug-fix-workflow/SKILL.md +0 -379
  223. package/bundled/skills-windows/bug-fix-workflow/references/bug-diagnosis.md +0 -41
  224. package/bundled/skills-windows/bug-planner/SKILL.md +0 -402
  225. package/bundled/skills-windows/bug-planner/assets/bug-confirmation-template.md +0 -43
  226. package/bundled/skills-windows/bug-planner/references/critic-and-verification.md +0 -44
  227. package/bundled/skills-windows/bug-planner/references/error-recovery.md +0 -73
  228. package/bundled/skills-windows/bug-planner/references/input-formats.md +0 -53
  229. package/bundled/skills-windows/bug-planner/references/schema-validation.md +0 -25
  230. package/bundled/skills-windows/bug-planner/references/severity-rules.md +0 -16
  231. package/bundled/skills-windows/bug-planner/scripts/validate-bug-list.py +0 -322
  232. package/bundled/skills-windows/bugfix-pipeline-launcher/SKILL.md +0 -304
  233. package/bundled/skills-windows/bugfix-pipeline-launcher/references/configuration.md +0 -84
  234. package/bundled/skills-windows/feature-pipeline-launcher/SKILL.md +0 -381
  235. package/bundled/skills-windows/feature-pipeline-launcher/references/configuration.md +0 -67
  236. package/bundled/skills-windows/feature-pipeline-launcher/scripts/preflight-check.py +0 -462
  237. package/bundled/skills-windows/feature-planner/SKILL.md +0 -397
  238. package/bundled/skills-windows/feature-planner/assets/evaluation-guide.md +0 -64
  239. package/bundled/skills-windows/feature-planner/assets/planning-guide.md +0 -214
  240. package/bundled/skills-windows/feature-planner/references/browser-interaction.md +0 -59
  241. package/bundled/skills-windows/feature-planner/references/completeness-review.md +0 -57
  242. package/bundled/skills-windows/feature-planner/references/decomposition-patterns.md +0 -75
  243. package/bundled/skills-windows/feature-planner/references/error-recovery.md +0 -90
  244. package/bundled/skills-windows/feature-planner/references/incremental-feature-planning.md +0 -112
  245. package/bundled/skills-windows/feature-planner/references/new-project-planning.md +0 -85
  246. package/bundled/skills-windows/feature-planner/scripts/validate-and-generate.py +0 -1020
  247. package/bundled/skills-windows/feature-workflow/SKILL.md +0 -374
  248. package/bundled/skills-windows/feature-workflow/references/brainstorm-guide.md +0 -137
  249. package/bundled/skills-windows/prizm-kit/SKILL.md +0 -93
  250. package/bundled/skills-windows/prizmkit-code-review/SKILL.md +0 -161
  251. package/bundled/skills-windows/prizmkit-code-review/references/dev-agent-prompt.md +0 -30
  252. package/bundled/skills-windows/prizmkit-code-review/references/review-report-template.md +0 -31
  253. package/bundled/skills-windows/prizmkit-code-review/references/reviewer-agent-prompt.md +0 -66
  254. package/bundled/skills-windows/prizmkit-code-review/scripts/check_loop.py +0 -186
  255. package/bundled/skills-windows/prizmkit-committer/SKILL.md +0 -89
  256. package/bundled/skills-windows/prizmkit-deploy/SKILL.md +0 -444
  257. package/bundled/skills-windows/prizmkit-deploy/references/ci-cd-workflows.md +0 -115
  258. package/bundled/skills-windows/prizmkit-deploy/references/cloud-platform-deploy.md +0 -93
  259. package/bundled/skills-windows/prizmkit-deploy/references/data-safety-examples.md +0 -120
  260. package/bundled/skills-windows/prizmkit-deploy/references/database-setup.md +0 -46
  261. package/bundled/skills-windows/prizmkit-deploy/references/deploy-config-schema.md +0 -148
  262. package/bundled/skills-windows/prizmkit-deploy/references/deploy-history-schema.md +0 -62
  263. package/bundled/skills-windows/prizmkit-deploy/references/deployment-modes.md +0 -50
  264. package/bundled/skills-windows/prizmkit-deploy/references/direct-upload.md +0 -26
  265. package/bundled/skills-windows/prizmkit-deploy/references/dns-setup.md +0 -42
  266. package/bundled/skills-windows/prizmkit-deploy/references/docker-deploy.md +0 -31
  267. package/bundled/skills-windows/prizmkit-deploy/references/firewall-setup.md +0 -37
  268. package/bundled/skills-windows/prizmkit-deploy/references/live-validation-notes.md +0 -21
  269. package/bundled/skills-windows/prizmkit-deploy/references/nginx-blue-green.md +0 -59
  270. package/bundled/skills-windows/prizmkit-deploy/references/ssh-bootstrap-flow.md +0 -49
  271. package/bundled/skills-windows/prizmkit-deploy/references/ssh-execution-flow.md +0 -41
  272. package/bundled/skills-windows/prizmkit-deploy/references/ssh-takeover.md +0 -20
  273. package/bundled/skills-windows/prizmkit-deploy/references/ssl-setup.md +0 -56
  274. package/bundled/skills-windows/prizmkit-implement/SKILL.md +0 -71
  275. package/bundled/skills-windows/prizmkit-init/SKILL.md +0 -356
  276. package/bundled/skills-windows/prizmkit-init/assets/project-brief-template.md +0 -82
  277. package/bundled/skills-windows/prizmkit-init/references/config-schema.md +0 -70
  278. package/bundled/skills-windows/prizmkit-init/references/rules/layer-detection.md +0 -41
  279. package/bundled/skills-windows/prizmkit-init/references/tech-stack-catalog.md +0 -13
  280. package/bundled/skills-windows/prizmkit-init/references/update-supplement.md +0 -9
  281. package/bundled/skills-windows/prizmkit-plan/SKILL.md +0 -102
  282. package/bundled/skills-windows/prizmkit-plan/assets/plan-template.md +0 -115
  283. package/bundled/skills-windows/prizmkit-plan/assets/spec-template.md +0 -73
  284. package/bundled/skills-windows/prizmkit-plan/references/clarify-guide.md +0 -67
  285. package/bundled/skills-windows/prizmkit-plan/references/examples.md +0 -85
  286. package/bundled/skills-windows/prizmkit-plan/references/verification-checklist.md +0 -60
  287. package/bundled/skills-windows/prizmkit-prizm-docs/SKILL.md +0 -129
  288. package/bundled/skills-windows/prizmkit-prizm-docs/assets/prizm-docs-format.md +0 -613
  289. package/bundled/skills-windows/prizmkit-prizm-docs/references/op-init.md +0 -45
  290. package/bundled/skills-windows/prizmkit-prizm-docs/references/op-rebuild.md +0 -15
  291. package/bundled/skills-windows/prizmkit-prizm-docs/references/op-status.md +0 -14
  292. package/bundled/skills-windows/prizmkit-prizm-docs/references/op-update.md +0 -19
  293. package/bundled/skills-windows/prizmkit-prizm-docs/references/op-validate.md +0 -17
  294. package/bundled/skills-windows/prizmkit-retrospective/SKILL.md +0 -87
  295. package/bundled/skills-windows/prizmkit-retrospective/references/knowledge-injection-steps.md +0 -50
  296. package/bundled/skills-windows/prizmkit-retrospective/references/structural-sync-steps.md +0 -43
  297. package/bundled/skills-windows/prizmkit-test/SKILL.md +0 -227
  298. package/bundled/skills-windows/prizmkit-test/references/boundary-coverage-protocol.md +0 -220
  299. package/bundled/skills-windows/prizmkit-test/references/examples.md +0 -143
  300. package/bundled/skills-windows/prizmkit-test/references/service-boundary-test-catalog.md +0 -225
  301. package/bundled/skills-windows/prizmkit-test/references/test-generation-steps.md +0 -109
  302. package/bundled/skills-windows/prizmkit-test/references/test-report-template.md +0 -111
  303. package/bundled/skills-windows/prizmkit-test/scripts/validate_boundary_report.py +0 -347
  304. package/bundled/skills-windows/recovery-workflow/SKILL.md +0 -355
  305. package/bundled/skills-windows/recovery-workflow/evals/evals.json +0 -46
  306. package/bundled/skills-windows/recovery-workflow/references/detection.md +0 -58
  307. package/bundled/skills-windows/recovery-workflow/scripts/detect-recovery-state.py +0 -544
  308. package/bundled/skills-windows/refactor-pipeline-launcher/SKILL.md +0 -346
  309. package/bundled/skills-windows/refactor-pipeline-launcher/references/configuration.md +0 -72
  310. package/bundled/skills-windows/refactor-planner/SKILL.md +0 -398
  311. package/bundled/skills-windows/refactor-planner/assets/planning-guide.md +0 -292
  312. package/bundled/skills-windows/refactor-planner/references/behavior-preservation.md +0 -301
  313. package/bundled/skills-windows/refactor-planner/references/fast-path.md +0 -59
  314. package/bundled/skills-windows/refactor-planner/references/planning-phases.md +0 -135
  315. package/bundled/skills-windows/refactor-planner/references/refactor-scoping-guide.md +0 -221
  316. package/bundled/skills-windows/refactor-planner/scripts/validate-and-generate-refactor.py +0 -858
  317. package/bundled/skills-windows/refactor-workflow/SKILL.md +0 -343
  318. package/bundled/skills-windows/refactor-workflow/references/brainstorm-guide.md +0 -116
  319. package/bundled/templates/hooks/diff-prizm-docs.sh +0 -158
  320. package/bundled/templates/hooks/prizm-pre-commit.sh +0 -108
  321. package/bundled/templates/hooks/validate-prizm-docs.sh +0 -139
@@ -1,1315 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
-
4
- # ============================================================
5
- # dev-pipeline/run-bugfix.sh - Autonomous Bug Fix Pipeline Runner
6
- #
7
- # Drives the prizm-dev-team through iterative AI CLI sessions to
8
- # fix bugs from a .prizmkit/plans/bug-fix-list.json specification.
9
- #
10
- # Usage:
11
- # ./run-bugfix.sh run [.prizmkit/plans/bug-fix-list.json] [options] Run all bugs
12
- # ./run-bugfix.sh run <bug-id> [options] Run a single bug
13
- # ./run-bugfix.sh status [.prizmkit/plans/bug-fix-list.json] Show pipeline status
14
- # ./run-bugfix.sh reset Clear all state
15
- #
16
- # Environment Variables:
17
- # MAX_RETRIES Max code retries per bug (default: 3)
18
- # MAX_INFRA_RETRIES Max infrastructure/provider retries per bug (default: 3)
19
- # AI_CLI AI CLI command name (auto-detected: cbc, claude, or codex)
20
- # CODEBUDDY_CLI Legacy alias for AI_CLI (deprecated, use AI_CLI instead)
21
- # PRIZMKIT_PLATFORM Platform hint for custom AI_CLI wrappers: codebuddy, claude, or codex
22
- # VERBOSE Set to 1 to enable --verbose on AI CLI
23
- # HEARTBEAT_INTERVAL Heartbeat log interval in seconds (default: 30)
24
- # STALE_KILL_THRESHOLD Auto-kill session after N seconds of no progress (default: 900)
25
- # HEARTBEAT_STALE_THRESHOLD Heartbeat stale threshold in seconds (default: 600)
26
- # MAX_LOG_SIZE Session log size threshold for compact warning (default: 2097152 = 2MB, set 0 to disable)
27
- # LOG_MONITOR_POLL_INTERVAL Log monitor poll interval in seconds (default: 30)
28
- # DEV_BRANCH Custom dev branch name (default: auto-generated bugfix/pipeline-{run_id})
29
- # AUTO_PUSH Auto-push to remote after successful bug fix (default: 0). Set to 1 to enable.
30
- # STOP_ON_FAILURE Stop pipeline after a task exhausts all retries (default: 0). Set to 1 to stop.
31
- # ============================================================
32
-
33
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
34
-
35
- # Source shared common helpers (exports PIPELINE_DIR/PRIZMKIT_DIR/PROJECT_ROOT,
36
- # CLI/platform detection, logs, deps)
37
- source "$SCRIPT_DIR/lib/common.sh"
38
-
39
- STATE_DIR="${PRIZMKIT_DIR}/state/bugfix"
40
- SCRIPTS_DIR="$SCRIPT_DIR/scripts"
41
-
42
- # Configuration
43
- MAX_RETRIES=${MAX_RETRIES:-3}
44
- MAX_INFRA_RETRIES=${MAX_INFRA_RETRIES:-3}
45
- HEARTBEAT_STALE_THRESHOLD=${HEARTBEAT_STALE_THRESHOLD:-600}
46
- HEARTBEAT_INTERVAL=${HEARTBEAT_INTERVAL:-30}
47
- STALE_KILL_THRESHOLD=${STALE_KILL_THRESHOLD:-900}
48
- VERBOSE=${VERBOSE:-0}
49
- MODEL=${MODEL:-""}
50
- PRIZMKIT_EFFORT=${PRIZMKIT_EFFORT:-""}
51
- DEV_BRANCH=${DEV_BRANCH:-""}
52
- AUTO_PUSH=${AUTO_PUSH:-0}
53
- STOP_ON_FAILURE=${STOP_ON_FAILURE:-0}
54
- ENABLE_DEPLOY=${ENABLE_DEPLOY:-0}
55
-
56
- # Source shared common helpers (CLI/platform detection + logs + deps)
57
- prizm_detect_cli_and_platform
58
-
59
- # Validate PRIZMKIT_EFFORT early (fail-fast before any sessions are spawned)
60
- prizm_validate_effort
61
-
62
- # Source shared heartbeat library
63
- source "$SCRIPT_DIR/lib/heartbeat.sh"
64
-
65
- # Source shared branch library
66
- source "$SCRIPT_DIR/lib/branch.sh"
67
-
68
- # Detect stream-json support
69
- detect_stream_json_support "$CLI_CMD"
70
-
71
- # Bug list path (set in main, used by cleanup trap)
72
- BUG_LIST=""
73
-
74
- # Branch tracking (for cleanup on interrupt)
75
- _ORIGINAL_BRANCH=""
76
- _DEV_BRANCH_NAME=""
77
-
78
- # ============================================================
79
- # Shared: Spawn AI CLI session and wait for result
80
- # ============================================================
81
-
82
- spawn_and_wait_session() {
83
- local bug_id="$1"
84
- local bug_list="$2"
85
- local session_id="$3"
86
- local bootstrap_prompt="$4"
87
- local session_dir="$5"
88
- local max_retries="$6"
89
- local max_infra_retries="$7"
90
- local item_model="${8:-}"
91
- local base_branch="${9:-main}"
92
-
93
- local session_log="$session_dir/logs/session.log"
94
- local progress_json="$session_dir/logs/progress.json"
95
-
96
- local effective_model=""
97
- if [[ -n "$item_model" ]]; then
98
- effective_model="$item_model"
99
- elif [[ -n "${MODEL:-}" ]]; then
100
- effective_model="$MODEL"
101
- fi
102
-
103
- # Log bootstrap prompt in test mode
104
- prizm_log_bootstrap_prompt "$bootstrap_prompt" "$bug_id"
105
-
106
- local cli_pid
107
- prizm_start_ai_session "$bootstrap_prompt" "$session_log" "$effective_model"
108
- cli_pid="$PRIZM_AI_PID"
109
-
110
- # Start progress parser (no-op if stream-json not supported)
111
- start_progress_parser "$session_log" "$progress_json" "$SCRIPTS_DIR"
112
- local parser_pid="${_PARSER_PID:-}"
113
-
114
- # Heartbeat monitor (with stale-kill protection)
115
- start_heartbeat "$cli_pid" "$session_log" "$progress_json" "$HEARTBEAT_INTERVAL" "$STALE_KILL_THRESHOLD"
116
- local heartbeat_pid="${_HEARTBEAT_PID:-}"
117
-
118
- # Wait for AI CLI to finish
119
- local exit_code=0
120
- if wait "$cli_pid" 2>/dev/null; then
121
- exit_code=0
122
- else
123
- exit_code=$?
124
- fi
125
-
126
- # Clean up heartbeat and parser
127
- stop_heartbeat "$heartbeat_pid"
128
- stop_progress_parser "$parser_pid"
129
-
130
- # Recover session log from backup if truncated by subagent stdout redirection
131
- prizm_recover_session_log "$session_log"
132
-
133
-
134
- # Check for stale-kill marker (heartbeat killed the process due to no progress)
135
- local stale_kill_marker="$session_dir/logs/stale-kill.json"
136
- local was_stale_killed=false
137
- if [[ -f "$stale_kill_marker" ]]; then
138
- was_stale_killed=true
139
- log_warn "Session was stale-killed by heartbeat monitor (no progress for too long)"
140
- fi
141
-
142
- local was_infra_error=false
143
- if [[ $exit_code -ne 0 ]] && prizm_detect_infra_error "$session_log" "$progress_json"; then
144
- was_infra_error=true
145
- fi
146
-
147
- # Session summary
148
- if [[ -f "$session_log" ]]; then
149
- local final_size=$(wc -c < "$session_log" 2>/dev/null | tr -d ' ')
150
- local final_lines=$(wc -l < "$session_log" 2>/dev/null | tr -d ' ')
151
- log_info "Session log: $final_lines lines, $((final_size / 1024))KB"
152
- if [[ "$final_size" -lt 1024 && "$exit_code" -eq 0 ]]; then
153
- log_warn "Session log was truncated during execution (subagent stdout redirection may have severed it)"
154
- log_warn "Proceeding with exit-code-only outcome detection — child transcripts and git state are still valid"
155
- fi
156
- fi
157
- log_info "exit_code=$exit_code"
158
-
159
- # ── Determine session outcome from observable signals ──────────────
160
- local session_status
161
- local project_root
162
- project_root="$PROJECT_ROOT"
163
- local default_branch="$base_branch"
164
-
165
- if [[ "$was_infra_error" == true ]]; then
166
- log_warn "Session failed due to AI CLI/provider infrastructure error"
167
- log_warn "Infrastructure errors are retried without consuming code retry budget"
168
- session_status="infra_error"
169
- elif [[ "$was_stale_killed" == true ]]; then
170
- log_warn "Session stale-killed (no progress for ${STALE_KILL_THRESHOLD}s)"
171
- log_warn "Stale-killed sessions are treated as failed; dev branch is preserved for inspection"
172
- session_status="crashed"
173
- elif [[ $exit_code -ne 0 ]]; then
174
- log_warn "Session exited with code $exit_code"
175
- session_status="crashed"
176
- else
177
- # Exit code 0 — check if the session actually produced commits
178
- local has_commits=""
179
- if git -C "$project_root" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
180
- has_commits=$(git -C "$project_root" log "${default_branch}..HEAD" --oneline 2>/dev/null | head -1)
181
- fi
182
-
183
- if [[ -n "$has_commits" ]]; then
184
- session_status="success"
185
- else
186
- local uncommitted=""
187
- uncommitted=$(prizm_git_status_safe "$project_root" | head -1 || true)
188
- if [[ -n "$uncommitted" ]]; then
189
- log_warn "Session exited cleanly but produced no commits (uncommitted changes found) — auto-committing..."
190
- prizm_git_add_all_safe "$project_root" || true
191
- if git -C "$project_root" commit --no-verify -m "chore($bug_id): auto-commit session work" 2>/dev/null; then
192
- log_info "Auto-commit succeeded"
193
- session_status="success"
194
- else
195
- log_warn "Auto-commit failed — no changes to commit"
196
- session_status="crashed"
197
- fi
198
- else
199
- log_warn "Session exited cleanly but produced no commits and no changes"
200
- session_status="crashed"
201
- fi
202
- fi
203
- fi
204
-
205
- # ── Post-success validation ──────────────────────────────────────────
206
- if [[ "$session_status" == "success" ]]; then
207
- if git -C "$project_root" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
208
- local dirty_files=""
209
- dirty_files=$(prizm_git_status_safe "$project_root" || true)
210
- if [[ -n "$dirty_files" ]]; then
211
- log_info "Auto-committing remaining session artifacts..."
212
- prizm_git_add_all_safe "$project_root" || true
213
- git -C "$project_root" commit --no-verify --amend --no-edit 2>/dev/null \
214
- || git -C "$project_root" commit --no-verify -m "chore($bug_id): include remaining session artifacts" 2>/dev/null \
215
- || true
216
- fi
217
- fi
218
- fi
219
-
220
- log_info "Session result: $session_status"
221
-
222
- # Validate checkpoint completeness after successful session
223
- if [[ "$session_status" == "success" ]]; then
224
- local checkpoint_file="$PRIZMKIT_DIR/bugfix/${bug_id}/workflow-checkpoint.json"
225
- if [[ -f "$checkpoint_file" ]]; then
226
- local checkpoint_result
227
- checkpoint_result=$(python3 -c "
228
- import json, sys
229
- try:
230
- with open(sys.argv[1]) as f:
231
- data = json.load(f)
232
- except json.JSONDecodeError as e:
233
- print('CORRUPTED: {}'.format(e))
234
- sys.exit(2)
235
- incomplete = [s for s in data['steps'] if s['status'] not in ('completed', 'skipped')]
236
- if incomplete:
237
- for s in incomplete:
238
- print('INCOMPLETE: {} {} = {}'.format(s['id'], s['skill'], s['status']))
239
- sys.exit(1)
240
- print('ALL_COMPLETE')
241
- sys.exit(0)
242
- " "$checkpoint_file" 2>&1) || checkpoint_result="CHECK_FAILED"
243
- local check_exit=$?
244
- if [[ "$checkpoint_result" == "CHECK_FAILED" ]]; then
245
- check_exit=2
246
- elif [[ "$checkpoint_result" == *"INCOMPLETE"* ]]; then
247
- check_exit=1
248
- else
249
- check_exit=0
250
- fi
251
- if [[ $check_exit -eq 2 ]]; then
252
- log_warn "CHECKPOINT_CORRUPTED: workflow-checkpoint.json is not valid JSON"
253
- elif [[ $check_exit -eq 1 ]]; then
254
- log_warn "CHECKPOINT_INCOMPLETE: Not all workflow steps completed:"
255
- echo "$checkpoint_result" | while read -r line; do log_warn " $line"; done
256
- else
257
- log_info "CHECKPOINT: All workflow steps completed"
258
- fi
259
- fi
260
- fi
261
-
262
- # Subagent detection
263
- prizm_detect_subagents "$session_log"
264
-
265
- # Final status updates happen after the caller returns to the original branch.
266
- _SPAWN_RESULT="$session_status"
267
- }
268
-
269
- finalize_bug_status_after_branch_return() {
270
- local bug_id="$1"
271
- local bug_list="$2"
272
- local session_id="$3"
273
- local session_status="$4"
274
- local max_retries="$5"
275
- local max_infra_retries="$6"
276
-
277
- # Update bug status on the original branch. The caller commits the resulting
278
- # bug-list diff immediately after this helper returns.
279
- local update_output
280
- update_output=$(python3 "$SCRIPTS_DIR/update-bug-status.py" \
281
- --bug-list "$bug_list" \
282
- --state-dir "$STATE_DIR" \
283
- --bug-id "$bug_id" \
284
- --session-status "$session_status" \
285
- --session-id "$session_id" \
286
- --max-retries "$max_retries" \
287
- --max-infra-retries "$max_infra_retries" \
288
- --action update) || {
289
- log_error "Failed to update bug status: $update_output"
290
- update_output=""
291
- }
292
-
293
- _SPAWN_ITEM_STATUS="$(printf '%s' "$update_output" | prizm_extract_update_new_status)"
294
- }
295
-
296
- # ============================================================
297
- # Graceful Shutdown
298
- # ============================================================
299
-
300
- cleanup() {
301
- echo ""
302
- log_warn "Received interrupt signal. Saving state..."
303
-
304
- # Kill all child processes (claude-internal, heartbeat, progress parser, etc.)
305
- kill 0 2>/dev/null || true
306
-
307
- # Log current branch info for recovery
308
- if [[ -n "$_DEV_BRANCH_NAME" ]]; then
309
- log_info "Development was on branch: $_DEV_BRANCH_NAME"
310
- log_info "Original branch was: $_ORIGINAL_BRANCH"
311
- fi
312
-
313
- # Update status of currently in-progress bug to interrupted
314
- if [[ -n "$BUG_LIST" && -f "$BUG_LIST" ]]; then
315
- # Find any in-progress bug and mark it as failed
316
- local _interrupted_id
317
- _interrupted_id=$(python3 -c "
318
- import json, sys
319
- with open(sys.argv[1]) as f:
320
- data = json.load(f)
321
- for bug in data.get('bugs', []):
322
- if bug.get('status') == 'in_progress':
323
- print(bug['id'])
324
- break
325
- " "$BUG_LIST" 2>/dev/null || echo "")
326
-
327
- if [[ -n "$_interrupted_id" ]]; then
328
- python3 "$SCRIPTS_DIR/update-bug-status.py" \
329
- --bug-list "$BUG_LIST" \
330
- --state-dir "$STATE_DIR" \
331
- --bug-id "$_interrupted_id" \
332
- --session-status "failed" \
333
- --max-retries "$MAX_RETRIES" \
334
- --max-infra-retries "$MAX_INFRA_RETRIES" \
335
- --action update 2>/dev/null || true
336
- log_info "Bug $_interrupted_id marked as failed due to interrupt"
337
- fi
338
-
339
- # Pause the pipeline
340
- python3 "$SCRIPTS_DIR/update-bug-status.py" \
341
- --bug-list "$BUG_LIST" \
342
- --state-dir "$STATE_DIR" \
343
- --action pause 2>/dev/null || true
344
- fi
345
-
346
- # GUARANTEED: always return to original branch (save WIP on dev branch first)
347
- branch_ensure_return "$PROJECT_ROOT" "$_ORIGINAL_BRANCH" "$_DEV_BRANCH_NAME"
348
-
349
- log_info "Bug fix pipeline paused. Run './run-bugfix.sh run' to resume."
350
- exit 130
351
- }
352
- trap cleanup SIGINT SIGTERM
353
-
354
- # ============================================================
355
- # Dependency Check
356
- # ============================================================
357
-
358
- check_dependencies() {
359
- prizm_check_common_dependencies "$CLI_CMD"
360
- local _project_root
361
- _project_root="$PROJECT_ROOT"
362
- prizm_ensure_git_repo "$_project_root"
363
- }
364
-
365
-
366
- # ============================================================
367
- # run-one: Run a single bug fix
368
- # ============================================================
369
-
370
- run_one() {
371
- local bug_id=""
372
- local bug_list=""
373
- local dry_run=false
374
- local do_clean=false
375
- local no_reset=false
376
- local mode_override=""
377
- local critic_override=""
378
-
379
- while [[ $# -gt 0 ]]; do
380
- case "$1" in
381
- --dry-run) dry_run=true; shift ;;
382
- --clean) do_clean=true; shift ;;
383
- --no-reset) no_reset=true; shift ;;
384
- --max-infra-retries)
385
- shift
386
- if [[ $# -eq 0 ]]; then
387
- log_error "--max-infra-retries requires a value"
388
- exit 1
389
- fi
390
- prizm_require_positive_int "--max-infra-retries" "$1"
391
- MAX_INFRA_RETRIES="$1"
392
- shift
393
- ;;
394
- --mode)
395
- shift
396
- if [[ $# -eq 0 ]]; then
397
- log_error "--mode requires a value (lite|standard|full)"
398
- exit 1
399
- fi
400
- case "$1" in
401
- lite|standard|full) mode_override="$1" ;;
402
- *) log_error "Invalid mode: $1 (must be lite, standard, or full)"; exit 1 ;;
403
- esac
404
- shift
405
- ;;
406
- --critic) critic_override="true"; shift ;;
407
- --no-critic) critic_override="false"; shift ;;
408
- B-*|b-*) bug_id="$1"; shift ;;
409
- *) bug_list="$1"; shift ;;
410
- esac
411
- done
412
-
413
- if [[ -z "$bug_id" ]]; then
414
- log_error "Bug ID is required (e.g. B-001)"
415
- echo ""
416
- show_help
417
- exit 1
418
- fi
419
-
420
- if [[ -z "$bug_list" ]]; then
421
- bug_list="$PRIZMKIT_DIR/plans/bug-fix-list.json"
422
- fi
423
- if [[ ! "$bug_list" = /* ]]; then
424
- bug_list="$(pwd)/$bug_list"
425
- fi
426
- BUG_LIST="$bug_list"
427
-
428
- if [[ ! -f "$bug_list" ]]; then
429
- log_error "Bug fix list not found: $bug_list"
430
- exit 1
431
- fi
432
-
433
- check_dependencies
434
-
435
- # Initialize state if needed
436
- if [[ ! -f "$STATE_DIR/pipeline.json" ]]; then
437
- log_info "Initializing bugfix pipeline state..."
438
- local init_result init_stderr init_tmpstderr
439
- init_tmpstderr=$(mktemp)
440
- if ! init_result=$(python3 "$SCRIPTS_DIR/init-bugfix-pipeline.py" \
441
- --bug-list "$bug_list" \
442
- --state-dir "$STATE_DIR" 2>"$init_tmpstderr"); then
443
- init_stderr=$(cat "$init_tmpstderr" 2>/dev/null || true)
444
- rm -f "$init_tmpstderr"
445
- if [[ -n "$init_stderr" ]]; then
446
- log_warn "$init_stderr"
447
- fi
448
- log_error "Bugfix pipeline initialization failed (script error)"
449
- exit 1
450
- fi
451
- init_stderr=$(cat "$init_tmpstderr" 2>/dev/null || true)
452
- rm -f "$init_tmpstderr"
453
-
454
- if [[ -n "$init_stderr" ]]; then
455
- log_warn "$init_stderr"
456
- fi
457
-
458
- local init_valid
459
- init_valid=$(echo "$init_result" | python3 -c "import sys,json; print(json.load(sys.stdin).get('valid', False))" 2>/dev/null || echo "False")
460
-
461
- if [[ "$init_valid" != "True" ]]; then
462
- log_error "Bugfix pipeline initialization failed:"
463
- echo "$init_result"
464
- exit 1
465
- fi
466
-
467
- local bugs_count
468
- bugs_count=$(echo "$init_result" | python3 -c "import sys,json; print(json.load(sys.stdin).get('bugs_count', 0))" 2>/dev/null || echo "0")
469
- log_success "Bugfix pipeline initialized with $bugs_count bugs"
470
- fi
471
-
472
- # Verify bug exists
473
- local bug_title
474
- bug_title=$(python3 -c "
475
- import json, sys
476
- with open(sys.argv[1]) as f:
477
- data = json.load(f)
478
- for bug in data.get('bugs', []):
479
- if bug.get('id') == sys.argv[2]:
480
- print(bug.get('title', ''))
481
- sys.exit(0)
482
- sys.exit(1)
483
- " "$bug_list" "$bug_id" 2>/dev/null) || {
484
- log_error "Bug $bug_id not found in $bug_list"
485
- exit 1
486
- }
487
-
488
- local bug_severity
489
- bug_severity=$(python3 -c "
490
- import json, sys
491
- with open(sys.argv[1]) as f:
492
- data = json.load(f)
493
- for bug in data.get('bugs', []):
494
- if bug.get('id') == sys.argv[2]:
495
- print(bug.get('severity', 'medium'))
496
- sys.exit(0)
497
- sys.exit(1)
498
- " "$bug_list" "$bug_id" 2>/dev/null) || bug_severity="medium"
499
-
500
- # Optional Clean
501
- if [[ "$do_clean" == true ]]; then
502
- if [[ "$dry_run" == true ]]; then
503
- log_warn "Dry-run mode: --clean ignored (no artifacts will be deleted)"
504
- else
505
- log_info "Cleaning artifacts for $bug_id..."
506
-
507
- local project_root
508
- project_root="$PROJECT_ROOT"
509
-
510
- local bugfix_dir="$PRIZMKIT_DIR/bugfix/$bug_id"
511
- if [[ -d "$bugfix_dir" ]]; then
512
- rm -rf "$bugfix_dir"
513
- log_info "Removed $bugfix_dir"
514
- fi
515
-
516
- local dev_team_dir="$project_root/.dev-team"
517
- if [[ -d "$dev_team_dir" ]]; then
518
- rm -rf "$dev_team_dir"
519
- log_info "Removed $dev_team_dir"
520
- fi
521
-
522
- local bug_state_dir="$STATE_DIR/$bug_id"
523
- if [[ -d "$bug_state_dir" ]]; then
524
- rm -rf "$bug_state_dir"
525
- log_info "Removed $bug_state_dir"
526
- fi
527
- fi
528
- fi
529
-
530
- # Reset bug status (conditional)
531
- if [[ "$no_reset" == false && "$dry_run" == false ]]; then
532
- python3 "$SCRIPTS_DIR/update-bug-status.py" \
533
- --bug-list "$bug_list" \
534
- --state-dir "$STATE_DIR" \
535
- --bug-id "$bug_id" \
536
- --action reset >/dev/null 2>&1 || {
537
- log_warn "Failed to reset bug status (may already be pending)"
538
- }
539
- elif [[ "$dry_run" == true && "$no_reset" == false ]]; then
540
- log_info "Dry-run mode: skipping status reset"
541
- fi
542
-
543
- # Generate bootstrap prompt
544
- local run_id session_id session_dir bootstrap_prompt
545
- run_id=$(jq -r '.run_id' "$STATE_DIR/pipeline.json")
546
- session_id="${bug_id}-$(date +%Y%m%d%H%M%S)"
547
- session_dir="$STATE_DIR/$bug_id/sessions/$session_id"
548
- mkdir -p "$session_dir/logs"
549
-
550
- bootstrap_prompt="$session_dir/bootstrap-prompt.md"
551
-
552
- # Read retry count from status.json
553
- local retry_count
554
- retry_count=$(python3 -c "
555
- import json, os
556
- status_path = os.path.join('$STATE_DIR', '$bug_id', 'status.json')
557
- if os.path.isfile(status_path):
558
- with open(status_path) as f:
559
- d = json.load(f)
560
- print(d.get('retry_count', 0))
561
- else:
562
- print(0)
563
- " 2>/dev/null || echo "0")
564
- local resume_phase
565
- resume_phase=$(python3 -c "
566
- import json, os
567
- status_path = os.path.join('$STATE_DIR', '$bug_id', 'status.json')
568
- if os.path.isfile(status_path):
569
- with open(status_path) as f:
570
- d = json.load(f)
571
- print(d.get('resume_from_phase') or 'null')
572
- else:
573
- print('null')
574
- " 2>/dev/null || echo "null")
575
-
576
- log_info "Generating bugfix bootstrap prompt..."
577
- local prompt_args=(
578
- --bug-list "$bug_list"
579
- --bug-id "$bug_id"
580
- --session-id "$session_id"
581
- --run-id "$run_id"
582
- --retry-count "$retry_count"
583
- --resume-phase "$resume_phase"
584
- --state-dir "$STATE_DIR"
585
- --output "$bootstrap_prompt"
586
- )
587
-
588
- if [[ -n "$mode_override" ]]; then
589
- prompt_args+=(--mode "$mode_override")
590
- elif [[ -n "${PIPELINE_MODE:-}" ]]; then
591
- prompt_args+=(--mode "$PIPELINE_MODE")
592
- fi
593
-
594
- if [[ -n "${critic_override:-}" ]]; then
595
- prompt_args+=(--critic "$critic_override")
596
- elif [[ "${ENABLE_CRITIC:-}" == "true" || "${ENABLE_CRITIC:-}" == "1" ]]; then
597
- prompt_args+=(--critic "true")
598
- elif [[ "${ENABLE_CRITIC:-}" == "false" || "${ENABLE_CRITIC:-}" == "0" ]]; then
599
- prompt_args+=(--critic "false")
600
- fi
601
-
602
- local gen_output
603
- gen_output=$(python3 "$SCRIPTS_DIR/generate-bugfix-prompt.py" "${prompt_args[@]}" 2>/dev/null) || {
604
- log_error "Failed to generate bootstrap prompt for $bug_id"
605
- return 1
606
- }
607
- local bug_model pipeline_mode agent_count critic_enabled
608
- bug_model=$(echo "$gen_output" | python3 -c "import json,sys; print(json.load(sys.stdin).get('model',''))" 2>/dev/null || echo "")
609
- pipeline_mode=$(echo "$gen_output" | python3 -c "import json,sys; print(json.load(sys.stdin).get('pipeline_mode','standard'))" 2>/dev/null || echo "standard")
610
- agent_count=$(echo "$gen_output" | python3 -c "import json,sys; print(json.load(sys.stdin).get('agent_count',3))" 2>/dev/null || echo "3")
611
- critic_enabled=$(echo "$gen_output" | python3 -c "import json,sys; print(json.load(sys.stdin).get('critic_enabled','false'))" 2>/dev/null || echo "false")
612
-
613
- if [[ "$dry_run" == true ]]; then
614
- echo ""
615
- echo -e "${BOLD}════════════════════════════════════════════════════${NC}"
616
- echo -e "${BOLD} Dry Run: $bug_id — $bug_title${NC}"
617
- echo -e "${BOLD} Severity: $bug_severity${NC}"
618
- echo -e "${BOLD}════════════════════════════════════════════════════${NC}"
619
- echo ""
620
- log_info "Session ID: $session_id"
621
- if [[ -n "$mode_override" ]]; then
622
- log_info "Mode Override: $mode_override"
623
- fi
624
- log_info "Pipeline mode: $pipeline_mode"
625
- log_info "Agents: $agent_count (critic: $([ "$critic_enabled" = "true" ] && echo "enabled" || echo "disabled"))"
626
- if [[ -n "$bug_model" ]]; then
627
- log_info "Bug Model: $bug_model"
628
- elif [[ -n "$MODEL" ]]; then
629
- log_info "Model (env): $MODEL"
630
- else
631
- log_info "Model: (CLI default)"
632
- fi
633
- echo ""
634
- log_info "Bootstrap prompt written to:"
635
- echo " $bootstrap_prompt"
636
- echo ""
637
- log_success "Dry run complete. Inspect full prompt with:"
638
- echo " cat $bootstrap_prompt"
639
- return 0
640
- fi
641
-
642
- echo ""
643
- echo -e "${BOLD}════════════════════════════════════════════════════${NC}"
644
- echo -e "${BOLD} Bug Fix: $bug_id — $bug_title${NC}"
645
- echo -e "${BOLD} Severity: $bug_severity${NC}"
646
- echo -e "${BOLD}════════════════════════════════════════════════════${NC}"
647
- log_info "Session ID: $session_id"
648
- log_info "Prompt: $bootstrap_prompt"
649
- log_info "Log: $session_dir/logs/session.log"
650
- local _run_one_mode_desc
651
- case "$pipeline_mode" in
652
- lite) _run_one_mode_desc="Tier 1 — Single Agent" ;;
653
- standard) _run_one_mode_desc="Tier 2 — Orchestrator + Dev + Reviewer" ;;
654
- full) _run_one_mode_desc="Tier 3 — Full Team (+ Multi-Critic)" ;;
655
- *) _run_one_mode_desc="$pipeline_mode" ;;
656
- esac
657
- log_info "Pipeline mode: ${BOLD}$pipeline_mode${NC} ($_run_one_mode_desc)"
658
- log_info "Agents: $agent_count (critic: $([ "$critic_enabled" = "true" ] && echo "enabled" || echo "disabled"))"
659
- if [[ -n "$bug_model" ]]; then
660
- log_info "Bug model: $bug_model"
661
- fi
662
- echo -e "${BOLD}════════════════════════════════════════════════════${NC}"
663
- echo ""
664
-
665
- cleanup_single_bug() {
666
- echo ""
667
- log_warn "Interrupted. Killing session..."
668
- kill 0 2>/dev/null || true
669
- # Log current branch info
670
- if [[ -n "$_DEV_BRANCH_NAME" ]]; then
671
- log_info "Development was on branch: $_DEV_BRANCH_NAME"
672
- fi
673
- log_info "Session log: $session_dir/logs/session.log"
674
-
675
- # Update bug status to failed on interrupt
676
- if [[ -n "$bug_list" && -f "$bug_list" ]]; then
677
- python3 "$SCRIPTS_DIR/update-bug-status.py" \
678
- --bug-list "$bug_list" \
679
- --state-dir "$STATE_DIR" \
680
- --bug-id "$bug_id" \
681
- --session-status "failed" \
682
- --max-retries "$MAX_RETRIES" \
683
- --max-infra-retries "$MAX_INFRA_RETRIES" \
684
- --action update 2>/dev/null || true
685
- log_info "Bug $bug_id marked as failed due to interrupt"
686
- fi
687
-
688
- # GUARANTEED: always return to original branch (save WIP on dev branch first)
689
- branch_ensure_return "$PROJECT_ROOT" "$_ORIGINAL_BRANCH" "$_DEV_BRANCH_NAME"
690
- exit 130
691
- }
692
- trap cleanup_single_bug SIGINT SIGTERM
693
-
694
- _SPAWN_RESULT=""
695
- _SPAWN_ITEM_STATUS=""
696
-
697
- # Branch lifecycle: create and checkout bugfix branch
698
- local _proj_root
699
- _proj_root="$PROJECT_ROOT"
700
- local _source_branch
701
- _source_branch=$(git -C "$_proj_root" rev-parse --abbrev-ref HEAD 2>/dev/null || echo "main")
702
- _ORIGINAL_BRANCH="$_source_branch"
703
-
704
- # Mark bug as in-progress (update JSON for runtime monitoring, no commit)
705
- # The status change will be committed together with the final status update
706
- # after the session completes, avoiding an extra noise commit per bug.
707
- python3 "$SCRIPTS_DIR/update-bug-status.py" \
708
- --bug-list "$bug_list" \
709
- --state-dir "$STATE_DIR" \
710
- --bug-id "$bug_id" \
711
- --action start >/dev/null 2>&1 || true
712
-
713
- local _branch_name="${DEV_BRANCH:-bugfix/${bug_id}-$(date +%s)}"
714
- if branch_create "$_proj_root" "$_branch_name" "$_source_branch"; then
715
- _DEV_BRANCH_NAME="$_branch_name"
716
- else
717
- log_error "Failed to create branch: $_branch_name from $_source_branch — aborting to avoid running on $_source_branch"
718
- return 1
719
- fi
720
-
721
- spawn_and_wait_session \
722
- "$bug_id" "$bug_list" "$session_id" \
723
- "$bootstrap_prompt" "$session_dir" "$MAX_RETRIES" "$MAX_INFRA_RETRIES" "$bug_model" "$_ORIGINAL_BRANCH"
724
- local session_status="$_SPAWN_RESULT"
725
-
726
- # Merge dev branch back to original on success
727
- if [[ "$session_status" == "success" && -n "$_DEV_BRANCH_NAME" ]]; then
728
- if branch_merge "$_proj_root" "$_DEV_BRANCH_NAME" "$_ORIGINAL_BRANCH" "$AUTO_PUSH"; then
729
- _DEV_BRANCH_NAME=""
730
- else
731
- log_warn "Auto-merge failed — dev branch preserved: $_DEV_BRANCH_NAME"
732
- log_warn "Merge manually: git checkout $_ORIGINAL_BRANCH && git rebase $_DEV_BRANCH_NAME"
733
- session_status="merge_conflict"
734
- fi
735
- elif [[ -n "$_DEV_BRANCH_NAME" ]]; then
736
- # Session failed — preserve dev branch for inspection
737
- log_warn "Session failed — dev branch preserved for inspection: $_DEV_BRANCH_NAME"
738
- _DEV_BRANCH_NAME=""
739
- fi
740
-
741
- # GUARANTEED: always return to original branch regardless of success/failure/merge outcome
742
- branch_ensure_return "$_proj_root" "$_ORIGINAL_BRANCH"
743
-
744
- finalize_bug_status_after_branch_return \
745
- "$bug_id" "$bug_list" "$session_id" "$session_status" "$MAX_RETRIES" "$MAX_INFRA_RETRIES"
746
-
747
- # Commit bug status update on the original branch (after guaranteed return)
748
- if ! git -C "$_proj_root" diff --quiet "$bug_list" 2>/dev/null; then
749
- prizm_git_commit_paths "$_proj_root" "chore($bug_id): update bug status" "$bug_list"
750
- fi
751
-
752
- echo ""
753
- if [[ "$session_status" == "success" ]]; then
754
- log_success "════════════════════════════════════════════════════"
755
- log_success " $bug_id fixed successfully!"
756
- log_success "════════════════════════════════════════════════════"
757
- else
758
- log_error "════════════════════════════════════════════════════"
759
- log_error " $bug_id result: $session_status"
760
- log_error " Review log: $session_dir/logs/session.log"
761
- log_error "════════════════════════════════════════════════════"
762
- fi
763
- }
764
-
765
- # ============================================================
766
- # Main Loop: Run all bugs
767
- # ============================================================
768
-
769
- main() {
770
- local bug_list="$PRIZMKIT_DIR/plans/bug-fix-list.json"
771
-
772
- while [[ $# -gt 0 ]]; do
773
- case "$1" in
774
- --max-infra-retries)
775
- shift
776
- if [[ $# -eq 0 ]]; then
777
- log_error "--max-infra-retries requires a value"
778
- exit 1
779
- fi
780
- prizm_require_positive_int "--max-infra-retries" "$1"
781
- MAX_INFRA_RETRIES="$1"
782
- shift
783
- ;;
784
- --)
785
- shift
786
- break
787
- ;;
788
- -*)
789
- log_error "Unknown option: $1"
790
- show_help
791
- exit 1
792
- ;;
793
- *)
794
- bug_list="$1"
795
- shift
796
- ;;
797
- esac
798
- done
799
-
800
- if [[ $# -gt 0 ]]; then
801
- log_error "Unexpected arguments: $*"
802
- show_help
803
- exit 1
804
- fi
805
-
806
- if [[ ! "$bug_list" = /* ]]; then
807
- bug_list="$(pwd)/$bug_list"
808
- fi
809
- BUG_LIST="$bug_list"
810
-
811
- if [[ ! -f "$bug_list" ]]; then
812
- log_error "Bug fix list not found: $bug_list"
813
- log_info "Create a bug fix list first using the bug-planner skill,"
814
- log_info "or provide a path: ./run-bugfix.sh run <path-to-.prizmkit/plans/bug-fix-list.json>"
815
- exit 1
816
- fi
817
-
818
- check_dependencies
819
-
820
- # Initialize pipeline state if needed
821
- if [[ ! -f "$STATE_DIR/pipeline.json" ]]; then
822
- log_info "Initializing bugfix pipeline state..."
823
- local init_result init_stderr init_tmpstderr
824
- init_tmpstderr=$(mktemp)
825
- if ! init_result=$(python3 "$SCRIPTS_DIR/init-bugfix-pipeline.py" \
826
- --bug-list "$bug_list" \
827
- --state-dir "$STATE_DIR" 2>"$init_tmpstderr"); then
828
- init_stderr=$(cat "$init_tmpstderr" 2>/dev/null || true)
829
- rm -f "$init_tmpstderr"
830
- if [[ -n "$init_stderr" ]]; then
831
- log_warn "$init_stderr"
832
- fi
833
- log_error "Bugfix pipeline initialization failed (script error)"
834
- exit 1
835
- fi
836
- init_stderr=$(cat "$init_tmpstderr" 2>/dev/null || true)
837
- rm -f "$init_tmpstderr"
838
-
839
- if [[ -n "$init_stderr" ]]; then
840
- log_warn "$init_stderr"
841
- fi
842
-
843
- local init_valid
844
- init_valid=$(echo "$init_result" | python3 -c "import sys,json; print(json.load(sys.stdin).get('valid', False))" 2>/dev/null || echo "False")
845
-
846
- if [[ "$init_valid" != "True" ]]; then
847
- log_error "Bugfix pipeline initialization failed:"
848
- echo "$init_result"
849
- exit 1
850
- fi
851
-
852
- local bugs_count
853
- bugs_count=$(echo "$init_result" | python3 -c "import sys,json; print(json.load(sys.stdin).get('bugs_count', 0))" 2>/dev/null || echo "0")
854
- log_success "Bugfix pipeline initialized with $bugs_count bugs"
855
- else
856
- log_info "Resuming existing bugfix pipeline..."
857
- fi
858
-
859
- # Print header
860
- echo ""
861
- echo -e "${BOLD}════════════════════════════════════════════════════${NC}"
862
- echo -e "${BOLD} Bug-Fix Pipeline Runner Started${NC}"
863
- echo -e "${BOLD}════════════════════════════════════════════════════${NC}"
864
- log_info "Bug fix list: $bug_list"
865
- log_info "Max code retries per bug: $MAX_RETRIES"
866
- log_info "Max infrastructure retries per bug: $MAX_INFRA_RETRIES"
867
- log_info "AI CLI: $CLI_CMD (platform: $PLATFORM)"
868
- if [[ -n "${MODEL:-}" ]]; then
869
- log_info "Default Model: $MODEL"
870
- fi
871
- if [[ "$STOP_ON_FAILURE" == "1" ]]; then
872
- log_info "Stop on failure: enabled"
873
- fi
874
- echo -e "${BOLD}════════════════════════════════════════════════════${NC}"
875
- echo ""
876
-
877
- # Branch lifecycle: per-bug branches (like feature pipeline)
878
- local _proj_root
879
- _proj_root="$PROJECT_ROOT"
880
- local _source_branch
881
- _source_branch=$(git -C "$_proj_root" rev-parse --abbrev-ref HEAD 2>/dev/null || echo "main")
882
- _ORIGINAL_BRANCH="$_source_branch"
883
-
884
- local session_count=0
885
- local total_subagent_calls=0
886
-
887
- while true; do
888
- # Safety net: ensure we're on the original branch at the start of each iteration.
889
- # If a previous iteration's `continue` skipped branch_ensure_return, we could
890
- # still be on a dev branch. This prevents cascading branch confusion.
891
- if [[ -n "$_ORIGINAL_BRANCH" ]]; then
892
- local _cur_branch
893
- _cur_branch=$(git -C "$_proj_root" rev-parse --abbrev-ref HEAD 2>/dev/null || true)
894
- if [[ -n "$_cur_branch" && "$_cur_branch" != "$_ORIGINAL_BRANCH" ]]; then
895
- log_warn "Still on branch $_cur_branch at loop start — returning to $_ORIGINAL_BRANCH"
896
- branch_ensure_return "$_proj_root" "$_ORIGINAL_BRANCH"
897
- fi
898
- fi
899
-
900
- # Find next bug to process
901
- local next_bug
902
- if ! next_bug=$(python3 "$SCRIPTS_DIR/update-bug-status.py" \
903
- --bug-list "$bug_list" \
904
- --state-dir "$STATE_DIR" \
905
- --max-retries "$MAX_RETRIES" \
906
- --max-infra-retries "$MAX_INFRA_RETRIES" \
907
- --action get_next 2>/dev/null); then
908
- log_error "Failed to get next bug"
909
- break
910
- fi
911
-
912
- if [[ "$next_bug" == "PIPELINE_COMPLETE" ]]; then
913
- echo ""
914
- log_success "════════════════════════════════════════════════════"
915
- log_success " All bugs processed! Bug fix pipeline finished."
916
- log_success " Total sessions: $session_count"
917
- log_success " Total subagent calls: $total_subagent_calls"
918
- log_success "════════════════════════════════════════════════════"
919
-
920
- # ── Deploy session (only if ENABLE_DEPLOY=1 and all bugs fixed) ──
921
- if [[ "$ENABLE_DEPLOY" == "1" ]]; then
922
- local incomplete_count
923
- incomplete_count=$({ python3 -c "
924
- import json, sys
925
- with open(sys.argv[1]) as f:
926
- data = json.load(f)
927
- bad = [b for b in data.get('bugs', [])
928
- if b.get('status') not in ('completed', 'skipped', 'needs_info')]
929
- for b in bad:
930
- print(f\" {b['id']}: {b.get('status', 'unknown')} — {b.get('title', '')}\")
931
- print(len(bad))
932
- " "$bug_list" 2>/dev/null || echo "0"; } | tee /dev/stderr | tail -1)
933
-
934
- if [[ "$incomplete_count" -gt 0 ]]; then
935
- echo ""
936
- log_warn "DEPLOY BLOCKED: $incomplete_count bug(s) not fixed successfully."
937
- log_warn "Fix failed bugs and re-run, or manually run /prizmkit-deploy."
938
- else
939
- echo ""
940
- log_info "All bugs fixed — starting deploy session..."
941
- log_info "ENABLE_DEPLOY=1"
942
-
943
- local deploy_session_id="deploy-$(date +%Y%m%d%H%M%S)"
944
- local deploy_session_dir="$STATE_DIR/deploy/$deploy_session_id"
945
- mkdir -p "$deploy_session_dir/logs"
946
-
947
- local deploy_prompt="$deploy_session_dir/bootstrap-prompt.md"
948
- local _deploy_branch _deploy_commit
949
- _deploy_branch=$(git -C "$_proj_root" rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown")
950
- _deploy_commit=$(git -C "$_proj_root" rev-parse --short HEAD 2>/dev/null || echo "unknown")
951
- cat > "$deploy_prompt" << DEPLOY_PROMPT_EOF
952
- ## Deploy
953
-
954
- All bugs have been fixed successfully.
955
-
956
- - Branch: $_deploy_branch
957
- - Commit: $_deploy_commit
958
-
959
- Run /prizmkit-deploy to deploy the project. Read .prizmkit/deploy/deploy.config.json
960
- for deployment configuration. If no deploy config exists, guide the user through
961
- setting one up before deploying.
962
- DEPLOY_PROMPT_EOF
963
-
964
- log_info "Deploy prompt: $deploy_prompt"
965
- log_info "Deploy log: $deploy_session_dir/logs/session.log"
966
-
967
- prizm_run_ai_session "$deploy_prompt" "$deploy_session_dir/logs/session.log"
968
- local deploy_exit=$?
969
-
970
- # Recover log from backup if truncated
971
- prizm_recover_session_log "$deploy_session_dir/logs/session.log"
972
-
973
- if [[ $deploy_exit -eq 0 ]]; then
974
- log_success "Deploy session completed (exit 0)"
975
- else
976
- log_warn "Deploy session exited with code $deploy_exit"
977
- log_warn "Review log: $deploy_session_dir/logs/session.log"
978
- fi
979
- fi
980
- fi
981
-
982
- break
983
- fi
984
-
985
- if [[ "$next_bug" == "PIPELINE_BLOCKED" ]]; then
986
- log_warn "All remaining bugs are blocked (needs_info/failed)."
987
- log_warn "Run './run-bugfix.sh status' to see details."
988
- log_warn "Waiting 60s before re-checking... (Ctrl+C to stop)"
989
- sleep 60
990
- continue
991
- fi
992
-
993
- # Parse bug info
994
- local bug_id bug_title bug_severity retry_count infra_error_count resume_phase
995
- bug_id=$(echo "$next_bug" | jq -r '.bug_id')
996
- bug_title=$(echo "$next_bug" | jq -r '.title')
997
- bug_severity=$(echo "$next_bug" | jq -r '.severity')
998
- retry_count=$(echo "$next_bug" | jq -r '.retry_count // 0')
999
- infra_error_count=$(echo "$next_bug" | jq -r '.infra_error_count // 0')
1000
- resume_phase=$(echo "$next_bug" | jq -r '.resume_from_phase // "null"')
1001
-
1002
- echo ""
1003
- echo -e "${BOLD}────────────────────────────────────────────────────${NC}"
1004
- log_info "Bug: ${BOLD}$bug_id${NC} — $bug_title"
1005
- log_info "Severity: $bug_severity"
1006
- log_info "Code retry: $retry_count / $MAX_RETRIES"
1007
- log_info "Infrastructure retry: $infra_error_count / $MAX_INFRA_RETRIES"
1008
- if [[ "$resume_phase" != "null" ]]; then
1009
- log_info "Resuming from Phase $resume_phase"
1010
- fi
1011
- echo -e "${BOLD}────────────────────────────────────────────────────${NC}"
1012
-
1013
- # Auto-commit any uncommitted workspace changes before starting the pipeline.
1014
- # This ensures a clean baseline without blocking execution.
1015
- local _dirty_files=""
1016
- _dirty_files=$(prizm_git_status_non_bookkeeping "$_proj_root" "$STATE_DIR" "$bug_list" || true)
1017
- if [[ -n "$_dirty_files" ]]; then
1018
- log_info "Auto-committing workspace changes before $bug_id..."
1019
- prizm_git_add_all_safe "$_proj_root"
1020
- git -C "$_proj_root" commit --no-verify -m "chore: workspace snapshot ready for run $bug_id" 2>/dev/null || true
1021
- fi
1022
-
1023
- local _bookkeeping_dirty=""
1024
- _bookkeeping_dirty=$(prizm_git_status_bookkeeping "$_proj_root" "$STATE_DIR" "$bug_list" || true)
1025
- if [[ -n "$_bookkeeping_dirty" ]]; then
1026
- log_info "Committing pending pipeline bookkeeping before $bug_id..."
1027
- prizm_git_commit_paths "$_proj_root" "chore($bug_id): include pipeline bookkeeping" "$bug_list" "$STATE_DIR"
1028
- fi
1029
-
1030
- # Mark bug as in-progress BEFORE creating dev branch
1031
- # This ensures the in_progress status commit lands on the original branch,
1032
- # not the dev branch — preventing rebase conflicts in branch_merge later.
1033
- python3 "$SCRIPTS_DIR/update-bug-status.py" \
1034
- --bug-list "$bug_list" \
1035
- --state-dir "$STATE_DIR" \
1036
- --bug-id "$bug_id" \
1037
- --action start >/dev/null 2>&1 || true
1038
- # Commit the in_progress status on the original branch
1039
- if ! git -C "$_proj_root" diff --quiet "$bug_list" 2>/dev/null; then
1040
- prizm_git_commit_paths "$_proj_root" "chore($bug_id): mark in_progress" "$bug_list"
1041
- fi
1042
-
1043
- # Create per-bug dev branch (from the now-updated original branch)
1044
- local _bug_branch="${DEV_BRANCH:-bugfix/${bug_id}-$(date +%Y%m%d%H%M)}"
1045
- if branch_create "$_proj_root" "$_bug_branch" "$_ORIGINAL_BRANCH"; then
1046
- _DEV_BRANCH_NAME="$_bug_branch"
1047
- log_info "Dev branch: $_bug_branch"
1048
- else
1049
- log_error "Failed to create dev branch: $_bug_branch from $_ORIGINAL_BRANCH — aborting to avoid running on $_ORIGINAL_BRANCH"
1050
- _DEV_BRANCH_NAME=""
1051
- break
1052
- fi
1053
-
1054
- # Generate session
1055
- local session_id run_id
1056
- run_id=$(jq -r '.run_id' "$STATE_DIR/pipeline.json")
1057
- session_id="${bug_id}-$(date +%Y%m%d%H%M%S)"
1058
-
1059
- local session_dir="$STATE_DIR/$bug_id/sessions/$session_id"
1060
- mkdir -p "$session_dir/logs"
1061
-
1062
- local bootstrap_prompt="$session_dir/bootstrap-prompt.md"
1063
-
1064
- local main_prompt_args=(
1065
- --bug-list "$bug_list"
1066
- --bug-id "$bug_id"
1067
- --session-id "$session_id"
1068
- --run-id "$run_id"
1069
- --retry-count "$retry_count"
1070
- --resume-phase "$resume_phase"
1071
- --state-dir "$STATE_DIR"
1072
- --output "$bootstrap_prompt"
1073
- )
1074
-
1075
- # Support PIPELINE_MODE env var (set by launch-bugfix-daemon.sh --mode)
1076
- if [[ -n "${PIPELINE_MODE:-}" ]]; then
1077
- main_prompt_args+=(--mode "$PIPELINE_MODE")
1078
- fi
1079
-
1080
- # Support ENABLE_CRITIC env var (set by launch-bugfix-daemon.sh --critic)
1081
- if [[ "${ENABLE_CRITIC:-}" == "true" || "${ENABLE_CRITIC:-}" == "1" ]]; then
1082
- main_prompt_args+=(--critic "true")
1083
- elif [[ "${ENABLE_CRITIC:-}" == "false" || "${ENABLE_CRITIC:-}" == "0" ]]; then
1084
- main_prompt_args+=(--critic "false")
1085
- fi
1086
-
1087
- local gen_output
1088
- gen_output=$(python3 "$SCRIPTS_DIR/generate-bugfix-prompt.py" "${main_prompt_args[@]}" 2>/dev/null) || {
1089
- log_error "Failed to generate bootstrap prompt for $bug_id"
1090
- branch_ensure_return "$_proj_root" "$_ORIGINAL_BRANCH"
1091
- _DEV_BRANCH_NAME=""
1092
- continue
1093
- }
1094
- local bug_model pipeline_mode agent_count critic_enabled
1095
- bug_model=$(echo "$gen_output" | python3 -c "import json,sys; print(json.load(sys.stdin).get('model',''))" 2>/dev/null || echo "")
1096
- pipeline_mode=$(echo "$gen_output" | python3 -c "import json,sys; print(json.load(sys.stdin).get('pipeline_mode','standard'))" 2>/dev/null || echo "standard")
1097
- agent_count=$(echo "$gen_output" | python3 -c "import json,sys; print(json.load(sys.stdin).get('agent_count',3))" 2>/dev/null || echo "3")
1098
- critic_enabled=$(echo "$gen_output" | python3 -c "import json,sys; print(json.load(sys.stdin).get('critic_enabled','false'))" 2>/dev/null || echo "false")
1099
-
1100
- # Log pipeline mode and agent configuration
1101
- local _mode_desc
1102
- case "$pipeline_mode" in
1103
- lite) _mode_desc="Tier 1 — Single Agent" ;;
1104
- standard) _mode_desc="Tier 2 — Orchestrator + Dev + Reviewer" ;;
1105
- full) _mode_desc="Tier 3 — Full Team (+ Multi-Critic)" ;;
1106
- *) _mode_desc="$pipeline_mode" ;;
1107
- esac
1108
- log_info "Pipeline mode: ${BOLD}$pipeline_mode${NC} ($_mode_desc)"
1109
- log_info "Agents: $agent_count (critic: $([ "$critic_enabled" = "true" ] && echo "enabled" || echo "disabled"))"
1110
- if [[ -n "$bug_model" ]]; then
1111
- log_info "Bug model: $bug_model"
1112
- fi
1113
-
1114
- # Spawn session
1115
- log_info "Spawning AI CLI session: $session_id"
1116
- _SPAWN_RESULT=""
1117
- _SPAWN_ITEM_STATUS=""
1118
-
1119
- spawn_and_wait_session \
1120
- "$bug_id" "$bug_list" "$session_id" \
1121
- "$bootstrap_prompt" "$session_dir" "$MAX_RETRIES" "$MAX_INFRA_RETRIES" "$bug_model" "$_ORIGINAL_BRANCH"
1122
-
1123
- local session_status="$_SPAWN_RESULT"
1124
-
1125
- # Merge per-bug dev branch back to original on success
1126
- if [[ "$session_status" == "success" && -n "$_DEV_BRANCH_NAME" ]]; then
1127
- if branch_merge "$_proj_root" "$_DEV_BRANCH_NAME" "$_ORIGINAL_BRANCH" "$AUTO_PUSH"; then
1128
- _DEV_BRANCH_NAME=""
1129
- else
1130
- log_warn "Auto-merge failed — dev branch preserved: $_DEV_BRANCH_NAME"
1131
- log_warn "Merge manually: git checkout $_ORIGINAL_BRANCH && git rebase $_DEV_BRANCH_NAME"
1132
- session_status="merge_conflict"
1133
- fi
1134
- elif [[ -n "$_DEV_BRANCH_NAME" ]]; then
1135
- # Session failed — preserve dev branch for inspection
1136
- log_warn "Session failed — dev branch preserved for inspection: $_DEV_BRANCH_NAME"
1137
- _DEV_BRANCH_NAME=""
1138
- fi
1139
-
1140
- # GUARANTEED: always return to original branch regardless of success/failure/merge outcome
1141
- branch_ensure_return "$_proj_root" "$_ORIGINAL_BRANCH"
1142
-
1143
- finalize_bug_status_after_branch_return \
1144
- "$bug_id" "$bug_list" "$session_id" "$session_status" "$MAX_RETRIES" "$MAX_INFRA_RETRIES"
1145
- local item_status_after_session="${_SPAWN_ITEM_STATUS:-}"
1146
-
1147
- # Commit bug status update on the original branch (after guaranteed return)
1148
- if ! git -C "$_proj_root" diff --quiet "$bug_list" 2>/dev/null; then
1149
- prizm_git_commit_paths "$_proj_root" "chore($bug_id): update bug status" "$bug_list"
1150
- fi
1151
-
1152
- session_count=$((session_count + 1))
1153
- total_subagent_calls=$((total_subagent_calls + _SUBAGENT_COUNT))
1154
-
1155
- # Stop-on-failure: abort only after the task is actually marked failed.
1156
- # Pending retry outcomes, including infrastructure errors, keep running.
1157
- if [[ "$session_status" != "success" && "$STOP_ON_FAILURE" == "1" && "$item_status_after_session" == "failed" ]]; then
1158
- echo ""
1159
- log_error "════════════════════════════════════════════════════"
1160
- log_error " STOP_ON_FAILURE: Pipeline halted after $bug_id exhausted retries."
1161
- log_error " Total sessions completed: $session_count"
1162
- log_error " Set STOP_ON_FAILURE=0 to continue past failures."
1163
- log_error "════════════════════════════════════════════════════"
1164
- break
1165
- elif [[ "$session_status" != "success" && "$STOP_ON_FAILURE" == "1" ]]; then
1166
- log_info "STOP_ON_FAILURE: $bug_id is ${item_status_after_session:-unknown}; code/infra retry budget not exhausted, continuing."
1167
- fi
1168
-
1169
- # Stuck detection
1170
- if python3 "$SCRIPTS_DIR/detect-stuck.py" \
1171
- --state-dir "$STATE_DIR" \
1172
- --pipeline-type bugfix \
1173
- --bug-list "$bug_list" \
1174
- --max-retries "$MAX_RETRIES" \
1175
- 2>/dev/null | jq -e '.stuck_count > 0' >/dev/null 2>&1; then
1176
- log_warn "STUCK_DETECTED: Some bugs may be stuck — run detect-stuck.py for details"
1177
- fi
1178
-
1179
- # Completion notes propagation (on success)
1180
- if [ "$_SPAWN_RESULT" = "success" ]; then
1181
- local _summary_path="$PRIZMKIT_DIR/bugfix/${bug_id}/completion-summary.json"
1182
- if [ -f "$_summary_path" ]; then
1183
- python3 "$SCRIPTS_DIR/patch-completion-notes.py" \
1184
- --bug-list "$bug_list" \
1185
- --bug-id "$bug_id" \
1186
- --summary "$_summary_path" 2>/dev/null || true
1187
- fi
1188
- fi
1189
-
1190
- log_info "Pausing 5s before next bug..."
1191
- sleep 5
1192
- done
1193
- }
1194
-
1195
- # ============================================================
1196
- # Entry Point
1197
- # ============================================================
1198
-
1199
- show_help() {
1200
- echo "Usage: $0 <command> [options]"
1201
- echo ""
1202
- echo "Commands:"
1203
- echo " run [.prizmkit/plans/bug-fix-list.json] [options] Run all bugs by severity/priority order"
1204
- echo " run <bug-id> [options] Run a single bug fix"
1205
- echo " status [.prizmkit/plans/bug-fix-list.json] Show bug fix pipeline status"
1206
- echo " reset Clear all bugfix state"
1207
- echo " help Show this help message"
1208
- echo ""
1209
- echo "Single Bug Options (run <bug-id>):"
1210
- echo " --dry-run Generate bootstrap prompt only, don't spawn session"
1211
- echo " --clean Delete artifacts and reset before running"
1212
- echo " --no-reset Skip status reset (preserve retry count)"
1213
- echo " --max-infra-retries N Max infrastructure/provider retries (default: 3)"
1214
- echo " --mode <lite|standard|full> Override pipeline mode"
1215
- echo " --critic Enable adversarial critic review"
1216
- echo " --no-critic Disable adversarial critic review"
1217
- echo ""
1218
- echo "Pipeline Options (run all):"
1219
- echo " --max-infra-retries N Max infrastructure/provider retries (default: 3)"
1220
- echo ""
1221
- echo "Environment Variables:"
1222
- echo " MAX_RETRIES Max code retries per bug (default: 3)"
1223
- echo " MAX_INFRA_RETRIES Max infrastructure/provider retries per bug (default: 3)"
1224
- echo " MODEL Default AI model (overridden by per-bug model in bug list)"
1225
- echo " PRIZMKIT_EFFORT AI reasoning effort (low|medium|high|xhigh|max; max is Claude Code only)"
1226
- echo " PIPELINE_MODE Default pipeline mode: lite|standard|full (overridden by --mode)"
1227
- echo " ENABLE_CRITIC Enable/disable critic: true|false|1|0 (overridden by --critic/--no-critic)"
1228
- echo " AI_CLI AI CLI command name (auto-detected: cbc, claude, or codex)"
1229
- echo " VERBOSE Set to 1 for verbose AI CLI output"
1230
- echo " HEARTBEAT_INTERVAL Heartbeat log interval in seconds (default: 30)"
1231
- echo " STALE_KILL_THRESHOLD Auto-kill session after N seconds of no progress (default: 900)"
1232
- echo " MAX_LOG_SIZE Session log size threshold for compact warning (default: 2097152 = 2MB, set 0 to disable)"
1233
- echo " LOG_MONITOR_POLL_INTERVAL Log monitor poll interval in seconds (default: 30)"
1234
- echo " STOP_ON_FAILURE Stop pipeline when a task exhausts retries: 0|1 (default: 0)"
1235
- echo ""
1236
- echo "Examples:"
1237
- echo " ./run-bugfix.sh run # Run all bugs"
1238
- echo " ./run-bugfix.sh run .prizmkit/plans/bug-fix-list.json # Custom bug list"
1239
- echo " ./run-bugfix.sh run B-001 --dry-run # Inspect generated prompt"
1240
- echo " ./run-bugfix.sh run B-001 --clean # Clean artifacts + reset + run"
1241
- echo " ./run-bugfix.sh run B-001 --no-reset # Retry without resetting status"
1242
- echo " ./run-bugfix.sh status # Show status"
1243
- echo " MAX_RETRIES=5 ./run-bugfix.sh run # Custom retries"
1244
- }
1245
-
1246
- case "${1:-run}" in
1247
- run|resume)
1248
- shift || true
1249
- if [[ "${1:-}" =~ ^[Bb]-[0-9]+ ]]; then
1250
- run_one "$@"
1251
- else
1252
- main "$@"
1253
- fi
1254
- ;;
1255
- status)
1256
- check_dependencies
1257
- if [[ ! -f "$STATE_DIR/pipeline.json" ]]; then
1258
- log_error "No bugfix pipeline state found. Run './run-bugfix.sh run' first."
1259
- exit 1
1260
- fi
1261
- python3 "$SCRIPTS_DIR/update-bug-status.py" \
1262
- --bug-list "${2:-$PRIZMKIT_DIR/plans/bug-fix-list.json}" \
1263
- --state-dir "$STATE_DIR" \
1264
- --max-retries "$MAX_RETRIES" \
1265
- --max-infra-retries "$MAX_INFRA_RETRIES" \
1266
- --action status
1267
- ;;
1268
- reset)
1269
- log_warn "Resetting bugfix pipeline state..."
1270
- rm -rf "$STATE_DIR"
1271
- log_success "Bugfix state cleared. Run './run-bugfix.sh run' to start fresh."
1272
- ;;
1273
- unskip)
1274
- check_dependencies
1275
- if [[ ! -f "$STATE_DIR/pipeline.json" ]]; then
1276
- log_error "No bugfix pipeline state found. Run './run-bugfix.sh run' first."
1277
- exit 1
1278
- fi
1279
- _unskip_bug_list="$PRIZMKIT_DIR/plans/bug-fix-list.json"
1280
- _unskip_bug_id=""
1281
- shift || true
1282
- # Parse arguments: optional bug-id and bug-list path
1283
- while [[ $# -gt 0 ]]; do
1284
- if [[ "$1" =~ ^[Bb]-[0-9]+ ]]; then
1285
- _unskip_bug_id="$1"
1286
- else
1287
- _unskip_bug_list="$1"
1288
- fi
1289
- shift
1290
- done
1291
- _unskip_args=(
1292
- --bug-list "$_unskip_bug_list"
1293
- --state-dir "$STATE_DIR"
1294
- --action unskip
1295
- )
1296
- if [[ -n "$_unskip_bug_id" ]]; then
1297
- _unskip_args+=(--bug-id "$_unskip_bug_id")
1298
- fi
1299
- python3 "$SCRIPTS_DIR/update-bug-status.py" "${_unskip_args[@]}"
1300
-
1301
- # Commit the status change
1302
- if ! git diff --quiet "$_unskip_bug_list" 2>/dev/null; then
1303
- git add "$_unskip_bug_list"
1304
- git commit -m "chore: unskip skipped bugs" 2>/dev/null || true
1305
- fi
1306
- ;;
1307
- help|--help|-h)
1308
- show_help
1309
- ;;
1310
- *)
1311
- log_error "Unknown command: $1"
1312
- show_help
1313
- exit 1
1314
- ;;
1315
- esac