prizmkit 1.1.100 → 1.1.102

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 (317) 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 +355 -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 +153 -0
  26. package/bundled/dev-pipeline/prizmkit_runtime/runners.py +425 -0
  27. package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +560 -0
  28. package/bundled/dev-pipeline/prizmkit_runtime/status.py +71 -0
  29. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +51 -36
  30. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +20 -5
  31. package/bundled/dev-pipeline/scripts/generate-recovery-prompt.py +2 -2
  32. package/bundled/dev-pipeline/scripts/parse-stream-progress.py +39 -0
  33. package/bundled/dev-pipeline/templates/agent-prompts/dev-implement.md +8 -2
  34. package/bundled/dev-pipeline/templates/agent-prompts/reviewer-review.md +1 -1
  35. package/bundled/dev-pipeline/templates/bootstrap-prompt.md +6 -2
  36. package/bundled/dev-pipeline/templates/bootstrap-tier1.md +14 -6
  37. package/bundled/dev-pipeline/templates/bootstrap-tier2.md +14 -4
  38. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +14 -4
  39. package/bundled/dev-pipeline/templates/sections/context-budget-rules.md +2 -0
  40. package/bundled/dev-pipeline/templates/sections/log-size-awareness.md +9 -30
  41. package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-agent-suffix.md +15 -7
  42. package/bundled/dev-pipeline/templates/sections/phase-implement-agent.md +42 -29
  43. package/bundled/dev-pipeline/templates/sections/phase-implement-full.md +41 -39
  44. package/bundled/dev-pipeline/templates/sections/phase-implement-lite.md +8 -17
  45. package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +2 -2
  46. package/bundled/dev-pipeline/templates/sections/phase-review-agent.md +1 -3
  47. package/bundled/dev-pipeline/templates/sections/phase-review-full.md +1 -3
  48. package/bundled/dev-pipeline/templates/sections/phase0-test-baseline.md +3 -8
  49. package/bundled/dev-pipeline/templates/sections/test-failure-recovery-agent.md +6 -2
  50. package/bundled/dev-pipeline/templates/sections/test-failure-recovery-lite.md +5 -1
  51. package/bundled/dev-pipeline/tests/test_auto_skip.py +436 -14
  52. package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +115 -7
  53. package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +40 -0
  54. package/bundled/dev-pipeline/tests/test_python_runner_parity.py +1226 -0
  55. package/bundled/dev-pipeline/tests/test_unified_cli.py +1045 -0
  56. package/bundled/skills/_metadata.json +1 -1
  57. package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +29 -34
  58. package/bundled/skills/bugfix-pipeline-launcher/references/configuration.md +6 -5
  59. package/bundled/skills/feature-pipeline-launcher/SKILL.md +29 -35
  60. package/bundled/skills/feature-pipeline-launcher/references/configuration.md +7 -6
  61. package/bundled/skills/feature-workflow/SKILL.md +3 -6
  62. package/bundled/skills/recovery-workflow/SKILL.md +23 -32
  63. package/bundled/skills/refactor-pipeline-launcher/SKILL.md +29 -35
  64. package/bundled/skills/refactor-pipeline-launcher/references/configuration.md +7 -6
  65. package/bundled/skills/refactor-workflow/SKILL.md +3 -6
  66. package/bundled/templates/hooks/commit-intent.json +2 -2
  67. package/bundled/templates/hooks/diff-prizm-docs.py +226 -0
  68. package/bundled/templates/hooks/prizm-pre-commit.py +45 -0
  69. package/bundled/templates/hooks/validate-prizm-docs.py +240 -0
  70. package/package.json +1 -1
  71. package/src/config.js +42 -19
  72. package/src/external-skills.js +14 -14
  73. package/src/index.js +3 -6
  74. package/src/manifest.js +11 -5
  75. package/src/metadata.js +7 -18
  76. package/src/platforms.js +25 -0
  77. package/src/prompts.js +0 -12
  78. package/src/runtimes.js +18 -11
  79. package/src/scaffold.js +144 -122
  80. package/src/upgrade.js +12 -3
  81. package/bundled/dev-pipeline/launch-bugfix-daemon.sh +0 -500
  82. package/bundled/dev-pipeline/launch-feature-daemon.sh +0 -657
  83. package/bundled/dev-pipeline/launch-refactor-daemon.sh +0 -502
  84. package/bundled/dev-pipeline/lib/branch.sh +0 -326
  85. package/bundled/dev-pipeline/lib/common.sh +0 -1476
  86. package/bundled/dev-pipeline/lib/heartbeat.sh +0 -469
  87. package/bundled/dev-pipeline/reset-bug.sh +0 -425
  88. package/bundled/dev-pipeline/reset-feature.sh +0 -436
  89. package/bundled/dev-pipeline/reset-refactor.sh +0 -423
  90. package/bundled/dev-pipeline/run-bugfix.sh +0 -1430
  91. package/bundled/dev-pipeline/run-feature.sh +0 -1718
  92. package/bundled/dev-pipeline/run-recovery.sh +0 -648
  93. package/bundled/dev-pipeline/run-refactor.sh +0 -1463
  94. package/bundled/dev-pipeline/tests/test-path-resolution.sh +0 -100
  95. package/bundled/dev-pipeline-windows/.env.example +0 -36
  96. package/bundled/dev-pipeline-windows/README.md +0 -30
  97. package/bundled/dev-pipeline-windows/SCHEMA_ANALYSIS.md +0 -533
  98. package/bundled/dev-pipeline-windows/assets/feature-list-example.json +0 -146
  99. package/bundled/dev-pipeline-windows/assets/prizm-dev-team-integration.md +0 -137
  100. package/bundled/dev-pipeline-windows/launch-bugfix-daemon.ps1 +0 -9
  101. package/bundled/dev-pipeline-windows/launch-feature-daemon.ps1 +0 -9
  102. package/bundled/dev-pipeline-windows/launch-refactor-daemon.ps1 +0 -9
  103. package/bundled/dev-pipeline-windows/lib/branch.ps1 +0 -235
  104. package/bundled/dev-pipeline-windows/lib/common.ps1 +0 -991
  105. package/bundled/dev-pipeline-windows/lib/daemon.ps1 +0 -140
  106. package/bundled/dev-pipeline-windows/lib/pipeline.ps1 +0 -1051
  107. package/bundled/dev-pipeline-windows/lib/reset.ps1 +0 -121
  108. package/bundled/dev-pipeline-windows/reset-bug.ps1 +0 -10
  109. package/bundled/dev-pipeline-windows/reset-feature.ps1 +0 -10
  110. package/bundled/dev-pipeline-windows/reset-refactor.ps1 +0 -10
  111. package/bundled/dev-pipeline-windows/run-bugfix.ps1 +0 -9
  112. package/bundled/dev-pipeline-windows/run-feature.ps1 +0 -9
  113. package/bundled/dev-pipeline-windows/run-recovery.ps1 +0 -179
  114. package/bundled/dev-pipeline-windows/run-refactor.ps1 +0 -9
  115. package/bundled/dev-pipeline-windows/scripts/check-session-status.py +0 -301
  116. package/bundled/dev-pipeline-windows/scripts/continuation.py +0 -374
  117. package/bundled/dev-pipeline-windows/scripts/detect-stuck.py +0 -530
  118. package/bundled/dev-pipeline-windows/scripts/generate-bootstrap-prompt.py +0 -2279
  119. package/bundled/dev-pipeline-windows/scripts/generate-bugfix-prompt.py +0 -763
  120. package/bundled/dev-pipeline-windows/scripts/generate-recovery-prompt.py +0 -805
  121. package/bundled/dev-pipeline-windows/scripts/generate-refactor-prompt.py +0 -841
  122. package/bundled/dev-pipeline-windows/scripts/init-bugfix-pipeline.py +0 -316
  123. package/bundled/dev-pipeline-windows/scripts/init-dev-team.py +0 -134
  124. package/bundled/dev-pipeline-windows/scripts/init-pipeline.py +0 -382
  125. package/bundled/dev-pipeline-windows/scripts/init-refactor-pipeline.py +0 -399
  126. package/bundled/dev-pipeline-windows/scripts/parse-stream-progress.py +0 -1362
  127. package/bundled/dev-pipeline-windows/scripts/patch-completion-notes.py +0 -191
  128. package/bundled/dev-pipeline-windows/scripts/prizmkit-test-gate.py +0 -446
  129. package/bundled/dev-pipeline-windows/scripts/update-bug-status.py +0 -1121
  130. package/bundled/dev-pipeline-windows/scripts/update-checkpoint.py +0 -173
  131. package/bundled/dev-pipeline-windows/scripts/update-feature-status.py +0 -1789
  132. package/bundled/dev-pipeline-windows/scripts/update-refactor-status.py +0 -1327
  133. package/bundled/dev-pipeline-windows/scripts/utils.py +0 -542
  134. package/bundled/dev-pipeline-windows/templates/agent-prompts/critic-plan-challenge.md +0 -7
  135. package/bundled/dev-pipeline-windows/templates/agent-prompts/dev-fix.md +0 -7
  136. package/bundled/dev-pipeline-windows/templates/agent-prompts/dev-implement.md +0 -65
  137. package/bundled/dev-pipeline-windows/templates/agent-prompts/dev-resume.md +0 -5
  138. package/bundled/dev-pipeline-windows/templates/agent-prompts/reviewer-review.md +0 -7
  139. package/bundled/dev-pipeline-windows/templates/bootstrap-prompt.md +0 -73
  140. package/bundled/dev-pipeline-windows/templates/bootstrap-tier1.md +0 -589
  141. package/bundled/dev-pipeline-windows/templates/bootstrap-tier2.md +0 -710
  142. package/bundled/dev-pipeline-windows/templates/bootstrap-tier3.md +0 -791
  143. package/bundled/dev-pipeline-windows/templates/bug-fix-list-schema.json +0 -263
  144. package/bundled/dev-pipeline-windows/templates/bugfix-bootstrap-prompt.md +0 -326
  145. package/bundled/dev-pipeline-windows/templates/feature-list-schema.json +0 -237
  146. package/bundled/dev-pipeline-windows/templates/refactor-bootstrap-prompt.md +0 -340
  147. package/bundled/dev-pipeline-windows/templates/refactor-list-schema.json +0 -270
  148. package/bundled/dev-pipeline-windows/templates/sections/ac-verification-checklist.md +0 -7
  149. package/bundled/dev-pipeline-windows/templates/sections/checkpoint-system.md +0 -91
  150. package/bundled/dev-pipeline-windows/templates/sections/context-budget-rules.md +0 -34
  151. package/bundled/dev-pipeline-windows/templates/sections/critical-paths-agent.md +0 -10
  152. package/bundled/dev-pipeline-windows/templates/sections/critical-paths-full.md +0 -12
  153. package/bundled/dev-pipeline-windows/templates/sections/critical-paths-lite.md +0 -7
  154. package/bundled/dev-pipeline-windows/templates/sections/directory-convention-agent.md +0 -8
  155. package/bundled/dev-pipeline-windows/templates/sections/directory-convention-full.md +0 -9
  156. package/bundled/dev-pipeline-windows/templates/sections/directory-convention-lite.md +0 -6
  157. package/bundled/dev-pipeline-windows/templates/sections/failure-capture.md +0 -21
  158. package/bundled/dev-pipeline-windows/templates/sections/feature-context.md +0 -21
  159. package/bundled/dev-pipeline-windows/templates/sections/log-size-awareness.md +0 -41
  160. package/bundled/dev-pipeline-windows/templates/sections/phase-browser-verification-auto.md +0 -283
  161. package/bundled/dev-pipeline-windows/templates/sections/phase-browser-verification-opencli.md +0 -112
  162. package/bundled/dev-pipeline-windows/templates/sections/phase-browser-verification.md +0 -168
  163. package/bundled/dev-pipeline-windows/templates/sections/phase-commit-full.md +0 -82
  164. package/bundled/dev-pipeline-windows/templates/sections/phase-commit.md +0 -75
  165. package/bundled/dev-pipeline-windows/templates/sections/phase-context-snapshot-agent-suffix.md +0 -23
  166. package/bundled/dev-pipeline-windows/templates/sections/phase-context-snapshot-base.md +0 -14
  167. package/bundled/dev-pipeline-windows/templates/sections/phase-context-snapshot-lite-suffix.md +0 -19
  168. package/bundled/dev-pipeline-windows/templates/sections/phase-critic-plan-full.md +0 -63
  169. package/bundled/dev-pipeline-windows/templates/sections/phase-critic-plan.md +0 -42
  170. package/bundled/dev-pipeline-windows/templates/sections/phase-implement-agent.md +0 -44
  171. package/bundled/dev-pipeline-windows/templates/sections/phase-implement-full.md +0 -59
  172. package/bundled/dev-pipeline-windows/templates/sections/phase-implement-lite.md +0 -39
  173. package/bundled/dev-pipeline-windows/templates/sections/phase-plan-agent.md +0 -27
  174. package/bundled/dev-pipeline-windows/templates/sections/phase-plan-lite.md +0 -27
  175. package/bundled/dev-pipeline-windows/templates/sections/phase-prizmkit-test.md +0 -39
  176. package/bundled/dev-pipeline-windows/templates/sections/phase-review-agent.md +0 -35
  177. package/bundled/dev-pipeline-windows/templates/sections/phase-review-full.md +0 -35
  178. package/bundled/dev-pipeline-windows/templates/sections/phase-specify-plan-full.md +0 -73
  179. package/bundled/dev-pipeline-windows/templates/sections/phase0-init.md +0 -13
  180. package/bundled/dev-pipeline-windows/templates/sections/phase0-test-baseline.md +0 -21
  181. package/bundled/dev-pipeline-windows/templates/sections/session-context.md +0 -5
  182. package/bundled/dev-pipeline-windows/templates/sections/subagent-timeout-recovery.md +0 -6
  183. package/bundled/dev-pipeline-windows/templates/sections/task-contract.md +0 -34
  184. package/bundled/dev-pipeline-windows/templates/sections/test-failure-recovery-agent.md +0 -48
  185. package/bundled/dev-pipeline-windows/templates/sections/test-failure-recovery-lite.md +0 -48
  186. package/bundled/dev-pipeline-windows/templates/session-status-schema.json +0 -83
  187. package/bundled/skills-windows/app-planner/SKILL.md +0 -296
  188. package/bundled/skills-windows/app-planner/assets/app-design-guide.md +0 -101
  189. package/bundled/skills-windows/app-planner/references/architecture-decisions.md +0 -52
  190. package/bundled/skills-windows/app-planner/references/brainstorm-guide.md +0 -101
  191. package/bundled/skills-windows/app-planner/references/frontend-design-guide.md +0 -71
  192. package/bundled/skills-windows/app-planner/references/infrastructure-convention-discovery.md +0 -108
  193. package/bundled/skills-windows/app-planner/references/project-brief-guide.md +0 -82
  194. package/bundled/skills-windows/app-planner/references/project-conventions-discovery.md +0 -59
  195. package/bundled/skills-windows/app-planner/references/project-state-detection.md +0 -90
  196. package/bundled/skills-windows/app-planner/references/red-team-checklist.md +0 -40
  197. package/bundled/skills-windows/app-planner/references/rules/backend/derivation-rules.md +0 -619
  198. package/bundled/skills-windows/app-planner/references/rules/backend/fixed-rules.md +0 -285
  199. package/bundled/skills-windows/app-planner/references/rules/backend/question-bank.md +0 -249
  200. package/bundled/skills-windows/app-planner/references/rules/backend/question-manifest.json +0 -46
  201. package/bundled/skills-windows/app-planner/references/rules/backend/template.md +0 -173
  202. package/bundled/skills-windows/app-planner/references/rules/database/derivation-rules.md +0 -382
  203. package/bundled/skills-windows/app-planner/references/rules/database/fixed-rules.md +0 -211
  204. package/bundled/skills-windows/app-planner/references/rules/database/question-bank.md +0 -184
  205. package/bundled/skills-windows/app-planner/references/rules/database/question-manifest.json +0 -39
  206. package/bundled/skills-windows/app-planner/references/rules/database/template.md +0 -158
  207. package/bundled/skills-windows/app-planner/references/rules/frontend/derivation-rules.md +0 -820
  208. package/bundled/skills-windows/app-planner/references/rules/frontend/fixed-rules.md +0 -188
  209. package/bundled/skills-windows/app-planner/references/rules/frontend/question-bank.md +0 -319
  210. package/bundled/skills-windows/app-planner/references/rules/frontend/question-manifest.json +0 -51
  211. package/bundled/skills-windows/app-planner/references/rules/frontend/template.md +0 -339
  212. package/bundled/skills-windows/app-planner/references/rules/mobile/derivation-rules.md +0 -649
  213. package/bundled/skills-windows/app-planner/references/rules/mobile/fixed-rules.md +0 -290
  214. package/bundled/skills-windows/app-planner/references/rules/mobile/question-bank.md +0 -232
  215. package/bundled/skills-windows/app-planner/references/rules/mobile/question-manifest.json +0 -47
  216. package/bundled/skills-windows/app-planner/references/rules/mobile/template.md +0 -175
  217. package/bundled/skills-windows/app-planner/references/rules-configuration.md +0 -46
  218. package/bundled/skills-windows/bug-fix-workflow/SKILL.md +0 -379
  219. package/bundled/skills-windows/bug-fix-workflow/references/bug-diagnosis.md +0 -41
  220. package/bundled/skills-windows/bug-planner/SKILL.md +0 -402
  221. package/bundled/skills-windows/bug-planner/assets/bug-confirmation-template.md +0 -43
  222. package/bundled/skills-windows/bug-planner/references/critic-and-verification.md +0 -44
  223. package/bundled/skills-windows/bug-planner/references/error-recovery.md +0 -73
  224. package/bundled/skills-windows/bug-planner/references/input-formats.md +0 -53
  225. package/bundled/skills-windows/bug-planner/references/schema-validation.md +0 -25
  226. package/bundled/skills-windows/bug-planner/references/severity-rules.md +0 -16
  227. package/bundled/skills-windows/bug-planner/scripts/validate-bug-list.py +0 -322
  228. package/bundled/skills-windows/bugfix-pipeline-launcher/SKILL.md +0 -304
  229. package/bundled/skills-windows/bugfix-pipeline-launcher/references/configuration.md +0 -84
  230. package/bundled/skills-windows/feature-pipeline-launcher/SKILL.md +0 -381
  231. package/bundled/skills-windows/feature-pipeline-launcher/references/configuration.md +0 -67
  232. package/bundled/skills-windows/feature-pipeline-launcher/scripts/preflight-check.py +0 -462
  233. package/bundled/skills-windows/feature-planner/SKILL.md +0 -397
  234. package/bundled/skills-windows/feature-planner/assets/evaluation-guide.md +0 -64
  235. package/bundled/skills-windows/feature-planner/assets/planning-guide.md +0 -214
  236. package/bundled/skills-windows/feature-planner/references/browser-interaction.md +0 -59
  237. package/bundled/skills-windows/feature-planner/references/completeness-review.md +0 -57
  238. package/bundled/skills-windows/feature-planner/references/decomposition-patterns.md +0 -75
  239. package/bundled/skills-windows/feature-planner/references/error-recovery.md +0 -90
  240. package/bundled/skills-windows/feature-planner/references/incremental-feature-planning.md +0 -112
  241. package/bundled/skills-windows/feature-planner/references/new-project-planning.md +0 -85
  242. package/bundled/skills-windows/feature-planner/scripts/validate-and-generate.py +0 -1020
  243. package/bundled/skills-windows/feature-workflow/SKILL.md +0 -374
  244. package/bundled/skills-windows/feature-workflow/references/brainstorm-guide.md +0 -137
  245. package/bundled/skills-windows/prizm-kit/SKILL.md +0 -93
  246. package/bundled/skills-windows/prizmkit-code-review/SKILL.md +0 -161
  247. package/bundled/skills-windows/prizmkit-code-review/references/dev-agent-prompt.md +0 -30
  248. package/bundled/skills-windows/prizmkit-code-review/references/review-report-template.md +0 -31
  249. package/bundled/skills-windows/prizmkit-code-review/references/reviewer-agent-prompt.md +0 -66
  250. package/bundled/skills-windows/prizmkit-code-review/scripts/check_loop.py +0 -186
  251. package/bundled/skills-windows/prizmkit-committer/SKILL.md +0 -89
  252. package/bundled/skills-windows/prizmkit-deploy/SKILL.md +0 -444
  253. package/bundled/skills-windows/prizmkit-deploy/references/ci-cd-workflows.md +0 -115
  254. package/bundled/skills-windows/prizmkit-deploy/references/cloud-platform-deploy.md +0 -93
  255. package/bundled/skills-windows/prizmkit-deploy/references/data-safety-examples.md +0 -120
  256. package/bundled/skills-windows/prizmkit-deploy/references/database-setup.md +0 -46
  257. package/bundled/skills-windows/prizmkit-deploy/references/deploy-config-schema.md +0 -148
  258. package/bundled/skills-windows/prizmkit-deploy/references/deploy-history-schema.md +0 -62
  259. package/bundled/skills-windows/prizmkit-deploy/references/deployment-modes.md +0 -50
  260. package/bundled/skills-windows/prizmkit-deploy/references/direct-upload.md +0 -26
  261. package/bundled/skills-windows/prizmkit-deploy/references/dns-setup.md +0 -42
  262. package/bundled/skills-windows/prizmkit-deploy/references/docker-deploy.md +0 -31
  263. package/bundled/skills-windows/prizmkit-deploy/references/firewall-setup.md +0 -37
  264. package/bundled/skills-windows/prizmkit-deploy/references/live-validation-notes.md +0 -21
  265. package/bundled/skills-windows/prizmkit-deploy/references/nginx-blue-green.md +0 -59
  266. package/bundled/skills-windows/prizmkit-deploy/references/ssh-bootstrap-flow.md +0 -49
  267. package/bundled/skills-windows/prizmkit-deploy/references/ssh-execution-flow.md +0 -41
  268. package/bundled/skills-windows/prizmkit-deploy/references/ssh-takeover.md +0 -20
  269. package/bundled/skills-windows/prizmkit-deploy/references/ssl-setup.md +0 -56
  270. package/bundled/skills-windows/prizmkit-implement/SKILL.md +0 -71
  271. package/bundled/skills-windows/prizmkit-init/SKILL.md +0 -356
  272. package/bundled/skills-windows/prizmkit-init/assets/project-brief-template.md +0 -82
  273. package/bundled/skills-windows/prizmkit-init/references/config-schema.md +0 -70
  274. package/bundled/skills-windows/prizmkit-init/references/rules/layer-detection.md +0 -41
  275. package/bundled/skills-windows/prizmkit-init/references/tech-stack-catalog.md +0 -13
  276. package/bundled/skills-windows/prizmkit-init/references/update-supplement.md +0 -9
  277. package/bundled/skills-windows/prizmkit-plan/SKILL.md +0 -102
  278. package/bundled/skills-windows/prizmkit-plan/assets/plan-template.md +0 -115
  279. package/bundled/skills-windows/prizmkit-plan/assets/spec-template.md +0 -73
  280. package/bundled/skills-windows/prizmkit-plan/references/clarify-guide.md +0 -67
  281. package/bundled/skills-windows/prizmkit-plan/references/examples.md +0 -85
  282. package/bundled/skills-windows/prizmkit-plan/references/verification-checklist.md +0 -60
  283. package/bundled/skills-windows/prizmkit-prizm-docs/SKILL.md +0 -129
  284. package/bundled/skills-windows/prizmkit-prizm-docs/assets/prizm-docs-format.md +0 -613
  285. package/bundled/skills-windows/prizmkit-prizm-docs/references/op-init.md +0 -45
  286. package/bundled/skills-windows/prizmkit-prizm-docs/references/op-rebuild.md +0 -15
  287. package/bundled/skills-windows/prizmkit-prizm-docs/references/op-status.md +0 -14
  288. package/bundled/skills-windows/prizmkit-prizm-docs/references/op-update.md +0 -19
  289. package/bundled/skills-windows/prizmkit-prizm-docs/references/op-validate.md +0 -17
  290. package/bundled/skills-windows/prizmkit-retrospective/SKILL.md +0 -87
  291. package/bundled/skills-windows/prizmkit-retrospective/references/knowledge-injection-steps.md +0 -50
  292. package/bundled/skills-windows/prizmkit-retrospective/references/structural-sync-steps.md +0 -43
  293. package/bundled/skills-windows/prizmkit-test/SKILL.md +0 -227
  294. package/bundled/skills-windows/prizmkit-test/references/boundary-coverage-protocol.md +0 -220
  295. package/bundled/skills-windows/prizmkit-test/references/examples.md +0 -143
  296. package/bundled/skills-windows/prizmkit-test/references/service-boundary-test-catalog.md +0 -225
  297. package/bundled/skills-windows/prizmkit-test/references/test-generation-steps.md +0 -109
  298. package/bundled/skills-windows/prizmkit-test/references/test-report-template.md +0 -111
  299. package/bundled/skills-windows/prizmkit-test/scripts/validate_boundary_report.py +0 -347
  300. package/bundled/skills-windows/recovery-workflow/SKILL.md +0 -355
  301. package/bundled/skills-windows/recovery-workflow/evals/evals.json +0 -46
  302. package/bundled/skills-windows/recovery-workflow/references/detection.md +0 -58
  303. package/bundled/skills-windows/recovery-workflow/scripts/detect-recovery-state.py +0 -544
  304. package/bundled/skills-windows/refactor-pipeline-launcher/SKILL.md +0 -346
  305. package/bundled/skills-windows/refactor-pipeline-launcher/references/configuration.md +0 -72
  306. package/bundled/skills-windows/refactor-planner/SKILL.md +0 -398
  307. package/bundled/skills-windows/refactor-planner/assets/planning-guide.md +0 -292
  308. package/bundled/skills-windows/refactor-planner/references/behavior-preservation.md +0 -301
  309. package/bundled/skills-windows/refactor-planner/references/fast-path.md +0 -59
  310. package/bundled/skills-windows/refactor-planner/references/planning-phases.md +0 -135
  311. package/bundled/skills-windows/refactor-planner/references/refactor-scoping-guide.md +0 -221
  312. package/bundled/skills-windows/refactor-planner/scripts/validate-and-generate-refactor.py +0 -858
  313. package/bundled/skills-windows/refactor-workflow/SKILL.md +0 -343
  314. package/bundled/skills-windows/refactor-workflow/references/brainstorm-guide.md +0 -116
  315. package/bundled/templates/hooks/diff-prizm-docs.sh +0 -158
  316. package/bundled/templates/hooks/prizm-pre-commit.sh +0 -108
  317. package/bundled/templates/hooks/validate-prizm-docs.sh +0 -139
@@ -1,991 +0,0 @@
1
- Set-StrictMode -Version 2.0
2
- $ErrorActionPreference = 'Stop'
3
-
4
- $script:PrizmAiProcess = $null
5
-
6
- function Initialize-PrizmLineLogBridgeType {
7
- if ('PrizmLineLogBridge' -as [type]) { return }
8
-
9
- Add-Type -TypeDefinition @'
10
- using System;
11
- using System.Diagnostics;
12
- using System.IO;
13
- using System.Text;
14
-
15
- public sealed class PrizmLineLogBridge : IDisposable
16
- {
17
- private readonly StreamWriter writer;
18
- private readonly object sync = new object();
19
- public readonly DataReceivedEventHandler Handler;
20
-
21
- public PrizmLineLogBridge(string logPath)
22
- {
23
- writer = new StreamWriter(logPath, false, new UTF8Encoding(false));
24
- Handler = new DataReceivedEventHandler(OnDataReceived);
25
- }
26
-
27
- private void OnDataReceived(object sender, DataReceivedEventArgs eventArgs)
28
- {
29
- if (eventArgs.Data == null) return;
30
- lock (sync)
31
- {
32
- writer.WriteLine(eventArgs.Data);
33
- writer.Flush();
34
- }
35
- }
36
-
37
- public void Dispose()
38
- {
39
- lock (sync)
40
- {
41
- writer.Flush();
42
- writer.Dispose();
43
- }
44
- }
45
- }
46
- '@
47
- }
48
-
49
- function Write-PrizmInfo { param([string]$Message) Write-Host "[INFO] $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') $Message" -ForegroundColor Blue }
50
- function Write-PrizmWarn { param([string]$Message) Write-Host "[WARN] $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') $Message" -ForegroundColor Yellow }
51
- function Write-PrizmError { param([string]$Message) Write-Host "[ERROR] $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') $Message" -ForegroundColor Red }
52
- function Write-PrizmSuccess { param([string]$Message) Write-Host "[SUCCESS] $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') $Message" -ForegroundColor Green }
53
-
54
- function Get-PrizmHiddenToolWorktreeExcludes {
55
- return @(
56
- ':(top,exclude,glob).*/worktree',
57
- ':(top,exclude,glob).*/worktree/**',
58
- ':(top,exclude,glob).*/worktrees',
59
- ':(top,exclude,glob).*/worktrees/**'
60
- )
61
- }
62
-
63
- function Initialize-PrizmPaths {
64
- param([string]$ScriptRoot)
65
- $pipelineDir = Resolve-Path $ScriptRoot
66
- $pipelineParent = Split-Path $pipelineDir -Parent
67
- if ((Split-Path $pipelineParent -Leaf) -eq '.prizmkit') {
68
- $prizmkitDir = $pipelineParent
69
- $projectRoot = Split-Path $pipelineParent -Parent
70
- } else {
71
- $projectRoot = Split-Path $pipelineDir -Parent
72
- $prizmkitDir = Join-Path $projectRoot '.prizmkit'
73
- }
74
- [pscustomobject]@{
75
- PipelineDir = $pipelineDir.Path
76
- PrizmkitDir = $prizmkitDir
77
- ProjectRoot = $projectRoot
78
- ScriptsDir = Join-Path $pipelineDir.Path 'scripts'
79
- TemplatesDir = Join-Path $pipelineDir.Path 'templates'
80
- }
81
- }
82
-
83
- function Import-PrizmEnv {
84
- param([string]$EnvPath)
85
- if (-not (Test-Path $EnvPath)) { return }
86
- foreach ($line in Get-Content $EnvPath) {
87
- $trimmed = $line.Trim()
88
- if (-not $trimmed -or $trimmed.StartsWith('#')) { continue }
89
- $idx = $trimmed.IndexOf('=')
90
- if ($idx -lt 1) { continue }
91
- $key = $trimmed.Substring(0, $idx).Trim()
92
- $rawValue = $trimmed.Substring($idx + 1).Trim()
93
- $valueBuilder = [System.Text.StringBuilder]::new()
94
- $inSingleQuote = $false
95
- $inDoubleQuote = $false
96
- for ($i = 0; $i -lt $rawValue.Length; $i++) {
97
- $char = $rawValue[$i]
98
- if ($char -eq "'" -and -not $inDoubleQuote) { $inSingleQuote = -not $inSingleQuote }
99
- if ($char -eq '"' -and -not $inSingleQuote) { $inDoubleQuote = -not $inDoubleQuote }
100
- if ($char -eq '#' -and -not $inSingleQuote -and -not $inDoubleQuote) { break }
101
- [void]$valueBuilder.Append($char)
102
- }
103
- $value = $valueBuilder.ToString().Trim().Trim('"').Trim("'")
104
- if (-not [Environment]::GetEnvironmentVariable($key, 'Process')) {
105
- [Environment]::SetEnvironmentVariable($key, $value, 'Process')
106
- }
107
- }
108
- }
109
-
110
- function Resolve-PrizmPython {
111
- $python = Get-Command python -ErrorAction SilentlyContinue
112
- if ($python) {
113
- & $python.Source -c 'import sys; raise SystemExit(0 if sys.version_info[0] == 3 else 1)' *> $null
114
- if ($LASTEXITCODE -eq 0) { return @($python.Source) }
115
- }
116
- $py = Get-Command py -ErrorAction SilentlyContinue
117
- if ($py) {
118
- & $py.Source -3 -c 'import sys; raise SystemExit(0 if sys.version_info[0] == 3 else 1)' *> $null
119
- if ($LASTEXITCODE -eq 0) { return @($py.Source, '-3') }
120
- }
121
- throw 'Python 3 is required. Install Python and ensure python or py is in PATH.'
122
- }
123
-
124
- function Resolve-PrizmPowerShellHost {
125
- $pwsh = Get-Command pwsh -ErrorAction SilentlyContinue
126
- if ($pwsh) { return $pwsh.Source }
127
- $powershell = Get-Command powershell -ErrorAction SilentlyContinue
128
- if ($powershell) { return $powershell.Source }
129
- throw 'PowerShell host not found. Install PowerShell or ensure powershell.exe is in PATH.'
130
- }
131
-
132
- function Invoke-PrizmPythonOutput {
133
- param([string[]]$PythonCommand, [string[]]$Arguments)
134
- $cmd = $PythonCommand[0]
135
- $prefix = @()
136
- if ($PythonCommand.Count -gt 1) { $prefix = $PythonCommand[1..($PythonCommand.Count - 1)] }
137
- $output = & $cmd @prefix @Arguments
138
- if ($LASTEXITCODE -ne 0) { throw "Python command failed: $($Arguments -join ' ')" }
139
- if (-not $output) { return '' }
140
- return ($output -join "`n")
141
- }
142
-
143
- function Invoke-PrizmPythonJson {
144
- param([string[]]$PythonCommand, [string[]]$Arguments)
145
- $text = Invoke-PrizmPythonOutput $PythonCommand $Arguments
146
- if (-not $text) { return $null }
147
- return $text | ConvertFrom-Json
148
- }
149
-
150
- function Invoke-PrizmPythonText {
151
- param([string[]]$PythonCommand, [string[]]$Arguments)
152
- $cmd = $PythonCommand[0]
153
- $prefix = @()
154
- if ($PythonCommand.Count -gt 1) { $prefix = $PythonCommand[1..($PythonCommand.Count - 1)] }
155
- & $cmd @prefix @Arguments
156
- if ($LASTEXITCODE -ne 0) { throw "Python command failed: $($Arguments -join ' ')" }
157
- }
158
-
159
- function Test-PrizmInfraError {
160
- param([string]$SessionLog, [string]$ProgressJson)
161
- $parts = @()
162
- if ($SessionLog -and (Test-Path $SessionLog)) {
163
- try {
164
- $text = Get-Content $SessionLog -Raw -ErrorAction Stop
165
- if ($text.Length -gt 65536) { $text = $text.Substring($text.Length - 65536) }
166
- $parts += $text
167
- } catch {}
168
- }
169
- if ($ProgressJson -and (Test-Path $ProgressJson)) {
170
- try { $parts += (Get-Content $ProgressJson -Raw -ErrorAction Stop) } catch {}
171
- }
172
- if ($parts.Count -eq 0) { return $false }
173
-
174
- $haystack = $parts -join "`n"
175
- return ($haystack -match '(?i)auth_unavailable|no auth available|502 Bad Gateway|503 Service Unavailable|504 Gateway Timeout|gateway timeout|upstream (connect )?error|connection reset|ECONNRESET|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|rate limit|rate_limit|temporarily unavailable|overloaded')
176
- }
177
-
178
- function Test-PrizmContextOverflowError {
179
- param([string]$SessionLog, [string]$ProgressJson)
180
-
181
- $parts = @()
182
- $codeParts = @()
183
- $progressErrorLike = $false
184
-
185
- if ($ProgressJson -and (Test-Path $ProgressJson)) {
186
- try {
187
- $progress = Get-Content $ProgressJson -Raw -ErrorAction Stop | ConvertFrom-Json -ErrorAction Stop
188
- foreach ($name in @('fatal_error_code', 'api_error_code', 'error_code', 'stop_reason')) {
189
- if ($progress.PSObject.Properties[$name] -and $progress.$name) { $codeParts += [string]$progress.$name }
190
- }
191
- if (($progress.PSObject.Properties['last_result_is_error'] -and $progress.last_result_is_error) -or ($progress.PSObject.Properties['api_error_status'] -and $progress.api_error_status)) {
192
- $progressErrorLike = $true
193
- }
194
- $parts += ($progress | ConvertTo-Json -Depth 12 -Compress)
195
- } catch {}
196
- }
197
-
198
- $codeText = $codeParts -join ' '
199
- $codePattern = '(?i)\b(context_overflow|context_too_large|context_length_exceeded|model_context_window_exceeded)\b'
200
- if ($codeText -match $codePattern) { return $true }
201
-
202
- if ($SessionLog -and (Test-Path $SessionLog)) {
203
- try {
204
- $text = Get-Content $SessionLog -Raw -ErrorAction Stop
205
- if ($text.Length -gt 65536) { $text = $text.Substring($text.Length - 65536) }
206
- $parts += $text
207
- } catch {}
208
- }
209
- if ($parts.Count -eq 0) { return $false }
210
-
211
- $haystack = $parts -join "`n"
212
- $wrapperPattern = '(?i)\bPRIZMKIT_FATAL_ERROR\s*=\s*context_overflow\b'
213
- if ($haystack -match $wrapperPattern) { return $true }
214
- if ($haystack -match $codePattern) { return $true }
215
-
216
- $errorPattern = '(?i)\bapi error\b|invalid_request_error|\bbad request\b|\bstatus\s*[:=]?\s*(400|413)\b|\bapi_error_status\b|\bapi_error_code\b|\blast_result_is_error\b\s*["'':=]*\s*true\b|\bis_error\b\s*["'':=]*\s*true\b|\berror\s*[:=]|\bfatal\s*[:=]'
217
- $hasErrorContext = $progressErrorLike -or ($haystack -match $errorPattern)
218
- if (-not $hasErrorContext) { return $false }
219
-
220
- $weakPattern = '(?i)Your input exceeds the context window|input exceeds (?:the )?(?:model )?context window|context window of this model|context window (?:was )?exceeded|exceeded (?:the )?context window|maximum context length exceeded|prompt is too long|too many tokens|input token count exceeds|input tokens? exceeds?|token count exceeds'
221
- if ($haystack -match $weakPattern) { return $true }
222
-
223
- $requestTooLargePattern = '(?i)\brequest (?:is )?too large\b'
224
- $requestSemanticsPattern = '(?i)\b(context|token|tokens|prompt|input|model)\b'
225
- if (($haystack -match $requestTooLargePattern) -and ($haystack -match $requestSemanticsPattern)) { return $true }
226
-
227
- return $false
228
- }
229
-
230
- function Test-PrizmAiRuntimeError {
231
- param([string]$SessionLog, [string]$ProgressJson)
232
-
233
- if (Test-PrizmContextOverflowError -SessionLog $SessionLog -ProgressJson $ProgressJson) { return $false }
234
-
235
- if ($ProgressJson -and (Test-Path $ProgressJson)) {
236
- try {
237
- $progress = Get-Content $ProgressJson -Raw -ErrorAction Stop | ConvertFrom-Json -ErrorAction Stop
238
- if ($progress.PSObject.Properties['fatal_error_code'] -and $progress.fatal_error_code) {
239
- return $true
240
- }
241
- } catch {}
242
- }
243
-
244
- return $false
245
- }
246
-
247
- function Get-PrizmContextProgressFingerprint {
248
- param(
249
- [string]$ProjectRoot,
250
- [string]$TaskType,
251
- [string]$TaskId,
252
- [string]$ArtifactDir = '',
253
- [string]$CheckpointFile = ''
254
- )
255
-
256
- $projectRootResolved = if ($ProjectRoot) { $ProjectRoot } else { (Get-Location).Path }
257
- $artifactArg = if ($ArtifactDir) { $ArtifactDir } else { '' }
258
- $checkpointArg = if ($CheckpointFile) { $CheckpointFile } else { '' }
259
- $python = @'
260
- import hashlib
261
- import json
262
- import os
263
- import subprocess
264
- import sys
265
-
266
- project_root, task_type, task_id, artifact_dir, checkpoint_file = sys.argv[1:6]
267
- project_root = os.path.abspath(project_root or ".")
268
- artifact_dir = os.path.abspath(os.path.join(project_root, artifact_dir)) if artifact_dir and not os.path.isabs(artifact_dir) else artifact_dir
269
- checkpoint_file = os.path.abspath(os.path.join(project_root, checkpoint_file)) if checkpoint_file and not os.path.isabs(checkpoint_file) else checkpoint_file
270
-
271
- def run_git(args):
272
- try:
273
- return subprocess.check_output(["git", "-C", project_root, *args], stderr=subprocess.DEVNULL)
274
- except Exception:
275
- return b""
276
-
277
- def sha_bytes(*parts):
278
- h = hashlib.sha256()
279
- for part in parts:
280
- if isinstance(part, str):
281
- part = part.encode("utf-8", errors="surrogateescape")
282
- h.update(part or b"")
283
- h.update(b"\0")
284
- return h.hexdigest()
285
-
286
- def checkpoint_cursor(path):
287
- if not path or not os.path.exists(path):
288
- return "missing"
289
- try:
290
- with open(path, encoding="utf-8") as fh:
291
- data = json.load(fh)
292
- except Exception as exc:
293
- return "unreadable:{}".format(type(exc).__name__)
294
- steps = data.get("steps") if isinstance(data, dict) else None
295
- if not isinstance(steps, list):
296
- return "no-steps"
297
- counts = {"completed": 0, "skipped": 0, "pending": 0, "in_progress": 0, "failed": 0}
298
- first_open = None
299
- for step in steps:
300
- if not isinstance(step, dict):
301
- continue
302
- status = str(step.get("status", "pending"))
303
- counts[status] = counts.get(status, 0) + 1
304
- if first_open is None and status in ("pending", "in_progress"):
305
- first_open = "{}:{}:{}".format(step.get("id", ""), step.get("skill", ""), status)
306
- return "first_open={};counts={}".format(first_open or "none", ",".join("{}:{}".format(k, counts[k]) for k in sorted(counts)))
307
-
308
- def artifact_fingerprint(path):
309
- if not path or not os.path.isdir(path):
310
- return "missing"
311
- h = hashlib.sha256()
312
- for root, dirs, files in os.walk(path):
313
- dirs[:] = sorted(d for d in dirs if d not in {".git", "node_modules", "__pycache__"})
314
- for name in sorted(files):
315
- file_path = os.path.join(root, name)
316
- rel = os.path.relpath(file_path, path).replace(os.sep, "/")
317
- h.update(rel.encode("utf-8", errors="surrogateescape"))
318
- h.update(b"\0")
319
- try:
320
- with open(file_path, "rb") as fh:
321
- for chunk in iter(lambda: fh.read(65536), b""):
322
- h.update(chunk)
323
- except Exception as exc:
324
- h.update("unreadable:{}".format(type(exc).__name__).encode("utf-8"))
325
- h.update(b"\0")
326
- return h.hexdigest()
327
-
328
- fingerprint = {
329
- "task_type": task_type,
330
- "task_id": task_id,
331
- "git_diff_fingerprint": sha_bytes(run_git(["status", "--porcelain", "--untracked-files=all", "--", "."]), run_git(["diff", "--binary", "HEAD", "--", "."])),
332
- "checkpoint_cursor": checkpoint_cursor(checkpoint_file),
333
- "artifact_fingerprint": artifact_fingerprint(artifact_dir),
334
- "head_commit": run_git(["rev-parse", "HEAD"]).decode("utf-8", errors="ignore").strip(),
335
- }
336
- print(json.dumps(fingerprint, sort_keys=True, ensure_ascii=False))
337
- '@
338
- $scriptPath = [System.IO.Path]::GetTempFileName()
339
- try {
340
- Set-Content -Path $scriptPath -Value $python -Encoding UTF8
341
- $pythonCmd = Get-Command python -ErrorAction SilentlyContinue
342
- if ($pythonCmd) {
343
- $output = & $pythonCmd.Source $scriptPath $projectRootResolved $TaskType $TaskId $artifactArg $checkpointArg
344
- } else {
345
- $pyCmd = Get-Command py -ErrorAction SilentlyContinue
346
- if (-not $pyCmd) { throw 'Python 3 is required for progress fingerprinting.' }
347
- $output = & $pyCmd.Source -3 $scriptPath $projectRootResolved $TaskType $TaskId $artifactArg $checkpointArg
348
- }
349
- if ($LASTEXITCODE -ne 0) { throw 'progress fingerprint python helper failed' }
350
- return ($output -join "`n")
351
- } finally {
352
- Remove-Item -Force $scriptPath -ErrorAction SilentlyContinue
353
- }
354
- }
355
-
356
- function Test-PrizmContextProgressChanged {
357
- param([string]$BeforeJson, [string]$AfterJson)
358
- try {
359
- $before = if ($BeforeJson) { $BeforeJson | ConvertFrom-Json } else { $null }
360
- $after = if ($AfterJson) { $AfterJson | ConvertFrom-Json } else { $null }
361
- } catch {
362
- return $true
363
- }
364
- foreach ($key in @('git_diff_fingerprint', 'checkpoint_cursor', 'artifact_fingerprint', 'head_commit')) {
365
- $beforeValue = if ($before -and $before.PSObject.Properties[$key]) { [string]$before.$key } else { '' }
366
- $afterValue = if ($after -and $after.PSObject.Properties[$key]) { [string]$after.$key } else { '' }
367
- if ($beforeValue -ne $afterValue) { return $true }
368
- }
369
- return $false
370
- }
371
-
372
- function Get-PrizmProgressFatalErrorCode {
373
- param([string]$ProgressFile)
374
- if (-not (Test-Path $ProgressFile)) { return '' }
375
- try {
376
- $progress = Get-Content $ProgressFile -Raw -ErrorAction Stop | ConvertFrom-Json -ErrorAction Stop
377
- if ($progress.PSObject.Properties['fatal_error_code'] -and $progress.fatal_error_code) {
378
- return [string]$progress.fatal_error_code
379
- }
380
- } catch {}
381
- return ''
382
- }
383
-
384
- function Write-PrizmFatalErrorMarker {
385
- param([string]$MarkerPath, [string]$FatalErrorCode, [int]$StaleSeconds, [int]$Threshold)
386
- $markerDir = Split-Path $MarkerPath -Parent
387
- if ($markerDir) { New-Item -ItemType Directory -Force -Path $markerDir | Out-Null }
388
- [ordered]@{
389
- killed_at = (Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
390
- reason = $FatalErrorCode
391
- fatal_error_code = $FatalErrorCode
392
- stale_seconds = $StaleSeconds
393
- threshold = $Threshold
394
- } | ConvertTo-Json -Compress | Set-Content -Path $MarkerPath -Encoding UTF8
395
- }
396
-
397
- function Get-PrizmConfigValue {
398
- param([string]$ConfigPath, [string]$Key)
399
- if (-not (Test-Path $ConfigPath)) { return $null }
400
- try {
401
- $json = Get-Content $ConfigPath -Raw | ConvertFrom-Json
402
- return $json.$Key
403
- } catch { return $null }
404
- }
405
-
406
- function Split-PrizmCommandLine {
407
- param([string]$CommandLine)
408
- $trimmed = if ($CommandLine) { $CommandLine.Trim() } else { '' }
409
- if (-not $trimmed) { throw 'AI CLI command is empty.' }
410
- if (Test-Path $trimmed) {
411
- return [pscustomobject]@{ Command = $trimmed; Arguments = '' }
412
- }
413
- if ($trimmed -match '^"([^"]+)"\s*(.*)$') {
414
- return [pscustomobject]@{ Command = $matches[1]; Arguments = $matches[2].Trim() }
415
- }
416
- if ($trimmed -match "^'([^']+)'\s*(.*)$") {
417
- return [pscustomobject]@{ Command = $matches[1]; Arguments = $matches[2].Trim() }
418
- }
419
- if ($trimmed -match '^(\S+)\s*(.*)$') {
420
- return [pscustomobject]@{ Command = $matches[1]; Arguments = $matches[2].Trim() }
421
- }
422
- throw "Unable to parse AI CLI command: $CommandLine"
423
- }
424
-
425
- function Resolve-PrizmExecutableShim {
426
- param([string]$Source)
427
- if (-not $Source) { return $Source }
428
-
429
- $extension = [System.IO.Path]::GetExtension($Source).ToLowerInvariant()
430
- if ($extension -ne '.ps1') { return $Source }
431
-
432
- $directory = [System.IO.Path]::GetDirectoryName($Source)
433
- $baseName = [System.IO.Path]::GetFileNameWithoutExtension($Source)
434
- if (-not $directory -or -not $baseName) { return $Source }
435
-
436
- foreach ($candidateExtension in @('.cmd', '.bat', '.exe')) {
437
- $candidate = Join-Path $directory ($baseName + $candidateExtension)
438
- if (Test-Path $candidate) { return $candidate }
439
- }
440
-
441
- return $Source
442
- }
443
-
444
- function Resolve-PrizmCommandLine {
445
- param([string]$CommandLine)
446
- $parsed = Split-PrizmCommandLine $CommandLine
447
- $command = @(Get-Command $parsed.Command -ErrorAction SilentlyContinue)[0]
448
- if (-not $command) { return $CommandLine }
449
- $source = if ($command.Source) { $command.Source } else { $command.Definition }
450
- if (-not $source) { return $CommandLine }
451
- $source = Resolve-PrizmExecutableShim $source
452
- if ($source -match '\s') { $source = '"' + $source + '"' }
453
- if ($parsed.Arguments) {
454
- return "$source $($parsed.Arguments)"
455
- }
456
- return $source
457
- }
458
-
459
- function Get-PrizmCliNamesForPlatform {
460
- param([string]$Platform)
461
- $normalized = if ($Platform) { $Platform.ToLowerInvariant() } else { '' }
462
- switch ($normalized) {
463
- 'codex' { return @('codex') }
464
- 'claude' { return @('claude') }
465
- 'codebuddy' { return @('cbc') }
466
- 'both' { return @('claude', 'cbc') }
467
- 'all' { return @('codex', 'claude', 'cbc') }
468
- default { return @() }
469
- }
470
- }
471
-
472
- function Resolve-PrizmCliName {
473
- param([string]$CliName)
474
- if ($CliName -eq 'cbc' -and $env:CODEBUDDY_CLI) {
475
- return Resolve-PrizmCommandLine $env:CODEBUDDY_CLI
476
- }
477
- if (Get-Command $CliName -ErrorAction SilentlyContinue) {
478
- return Resolve-PrizmCommandLine $CliName
479
- }
480
- return ''
481
- }
482
-
483
- function Resolve-PrizmCliForPlatform {
484
- param([string]$Platform)
485
- foreach ($candidate in (Get-PrizmCliNamesForPlatform $Platform)) {
486
- $cli = Resolve-PrizmCliName $candidate
487
- if ($cli) { return $cli }
488
- }
489
- return ''
490
- }
491
-
492
- function Resolve-PrizmCliForPlatformRequirement {
493
- param([string]$Platform, [string]$Source)
494
- $expectedCliNames = @(Get-PrizmCliNamesForPlatform $Platform)
495
- if ($expectedCliNames.Count -eq 0) { return '' }
496
- $cli = Resolve-PrizmCliForPlatform $Platform
497
- if ($cli) { return $cli }
498
- $expectedCliText = $expectedCliNames -join ', '
499
- throw "$Source PrizmKit platform '$Platform' requires one of: $expectedCliText. Install it or set AI_CLI."
500
- }
501
-
502
- function Resolve-PrizmAiCli {
503
- param([string]$ProjectRoot, [string]$PrizmkitDir)
504
- Import-PrizmEnv (Join-Path $PrizmkitDir '.env')
505
- if ($env:AI_CLI) { return Resolve-PrizmCommandLine $env:AI_CLI }
506
- $configured = Get-PrizmConfigValue (Join-Path $PrizmkitDir 'config.json') 'ai_cli'
507
- if ($configured) { return Resolve-PrizmCommandLine $configured }
508
-
509
- $manifestPlatform = Get-PrizmConfigValue (Join-Path $PrizmkitDir 'manifest.json') 'platform'
510
- if ($manifestPlatform) {
511
- $manifestCli = Resolve-PrizmCliForPlatformRequirement ([string]$manifestPlatform) 'Installed'
512
- if ($manifestCli) { return $manifestCli }
513
- }
514
-
515
- $configuredPlatform = Get-PrizmConfigValue (Join-Path $PrizmkitDir 'config.json') 'platform'
516
- if ($configuredPlatform) {
517
- $configuredPlatformCli = Resolve-PrizmCliForPlatformRequirement ([string]$configuredPlatform) 'Configured'
518
- if ($configuredPlatformCli) { return $configuredPlatformCli }
519
- }
520
-
521
- if ($env:CODEBUDDY_CLI) { return Resolve-PrizmCommandLine $env:CODEBUDDY_CLI }
522
-
523
- if (((Test-Path (Join-Path $ProjectRoot '.codex\agents\prizm-dev-team-dev.toml')) -or (Test-Path (Join-Path $ProjectRoot '.agents\skills\prizm-kit\SKILL.md'))) -and (Get-Command codex -ErrorAction SilentlyContinue)) { return Resolve-PrizmCommandLine 'codex' }
524
- if ((Test-Path (Join-Path $ProjectRoot '.claude\commands\prizm-kit.md')) -and (Get-Command claude -ErrorAction SilentlyContinue)) { return Resolve-PrizmCommandLine 'claude' }
525
- if (((Test-Path (Join-Path $ProjectRoot '.codebuddy\agents\prizm-dev-team-dev.md')) -or (Test-Path (Join-Path $ProjectRoot '.codebuddy\skills\prizm-kit\SKILL.md'))) -and (Resolve-PrizmCliName 'cbc')) { return Resolve-PrizmCliName 'cbc' }
526
- foreach ($candidate in @('codex', 'claude', 'cbc')) {
527
- $cli = Resolve-PrizmCliName $candidate
528
- if ($cli) { return $cli }
529
- }
530
- throw 'No AI CLI found. Install Codex (codex), Claude Code (claude), or CodeBuddy (cbc), or set AI_CLI.'
531
- }
532
-
533
- function Get-PrizmConcretePlatform {
534
- param([string]$Platform)
535
- $normalized = if ($Platform) { $Platform.ToLowerInvariant() } else { '' }
536
- if (@('codex', 'claude', 'codebuddy') -contains $normalized) { return $normalized }
537
- return ''
538
- }
539
-
540
- function Get-PrizmKnownPlatformFromCli {
541
- param([string]$CliCommand)
542
- $parsed = Split-PrizmCommandLine $CliCommand
543
- $cliName = [System.IO.Path]::GetFileNameWithoutExtension($parsed.Command).ToLowerInvariant()
544
- if ($cliName -match 'claude') { return 'claude' }
545
- if ($cliName -match 'codex') { return 'codex' }
546
- if ($cliName -match 'cbc|codebuddy') { return 'codebuddy' }
547
- return ''
548
- }
549
-
550
- function ConvertTo-PrizmProcessArgument {
551
- param([string]$Argument)
552
- if ($Argument -eq $null) { return '""' }
553
- if ($Argument -notmatch '[\s"]') { return $Argument }
554
- return '"' + ($Argument -replace '"', '\"') + '"'
555
- }
556
-
557
- function Join-PrizmProcessArguments {
558
- param([string[]]$Arguments)
559
- return (($Arguments | ForEach-Object { ConvertTo-PrizmProcessArgument $_ }) -join ' ')
560
- }
561
-
562
- function Get-PrizmPlatformFromCli {
563
- param([string]$CliCommand)
564
- $platform = Get-PrizmKnownPlatformFromCli $CliCommand
565
- if ($platform) { return $platform }
566
- return 'codebuddy'
567
- }
568
-
569
- function Get-PrizmPlatformFromProject {
570
- param([string]$ProjectRoot, [string]$PrizmkitDir, [string]$CliCommand)
571
- $cliPlatform = Get-PrizmKnownPlatformFromCli $CliCommand
572
- if ($cliPlatform) { return $cliPlatform }
573
- $envPlatform = Get-PrizmConcretePlatform $env:PRIZMKIT_PLATFORM
574
- if ($envPlatform) { return $envPlatform }
575
- $manifestPlatform = Get-PrizmConcretePlatform (Get-PrizmConfigValue (Join-Path $PrizmkitDir 'manifest.json') 'platform')
576
- if ($manifestPlatform) { return $manifestPlatform }
577
- $configuredPlatform = Get-PrizmConcretePlatform (Get-PrizmConfigValue (Join-Path $PrizmkitDir 'config.json') 'platform')
578
- if ($configuredPlatform) { return $configuredPlatform }
579
- return Get-PrizmPlatformFromCli $CliCommand
580
- }
581
-
582
- function Get-PrizmSessionPlatform {
583
- param([string]$CliCommand)
584
- $cliPlatform = Get-PrizmKnownPlatformFromCli $CliCommand
585
- if ($cliPlatform) { return $cliPlatform }
586
- $platform = Get-PrizmConcretePlatform $env:PRIZMKIT_PLATFORM
587
- if ($platform) { return $platform }
588
- return Get-PrizmPlatformFromCli $CliCommand
589
- }
590
-
591
- function Get-PrizmCodexSubagentTimeoutSeconds {
592
- $configuredTimeout = 0
593
- if ([int]::TryParse($env:CODEX_SUBAGENT_TIMEOUT_SECONDS, [ref]$configuredTimeout) -and $configuredTimeout -gt 0) {
594
- return $configuredTimeout
595
- }
596
-
597
- $waitThreshold = 0
598
- $waitThresholdText = if ($env:CODEX_WAIT_STALE_KILL_THRESHOLD) { $env:CODEX_WAIT_STALE_KILL_THRESHOLD } else { '3600' }
599
- if ([int]::TryParse($waitThresholdText, [ref]$waitThreshold) -and $waitThreshold -gt 600) {
600
- return ($waitThreshold - 300)
601
- }
602
-
603
- return 3300
604
- }
605
-
606
- function Get-PrizmEffectiveStaleKillThreshold {
607
- param(
608
- [string]$ProgressFile,
609
- [int]$BaseThreshold
610
- )
611
-
612
- if ($BaseThreshold -le 0) { return $BaseThreshold }
613
- if (-not (Test-Path $ProgressFile)) { return $BaseThreshold }
614
-
615
- try {
616
- $progress = Get-Content $ProgressFile -Raw -ErrorAction Stop | ConvertFrom-Json -ErrorAction Stop
617
- } catch {
618
- return $BaseThreshold
619
- }
620
-
621
- $spawnCount = 0
622
- if ($progress.event_format -eq 'codex-json' -and $progress.current_tool -eq 'wait' -and $progress.tool_calls) {
623
- foreach ($tool in @($progress.tool_calls)) {
624
- if ($tool.name -eq 'spawn_agent') {
625
- $count = 0
626
- if ([int]::TryParse([string]$tool.count, [ref]$count)) { $spawnCount += $count }
627
- }
628
- }
629
- }
630
-
631
- if ($spawnCount -le 0) { return $BaseThreshold }
632
-
633
- $waitThreshold = 0
634
- if ([int]::TryParse($env:CODEX_WAIT_STALE_KILL_THRESHOLD, [ref]$waitThreshold) -and $waitThreshold -gt $BaseThreshold) {
635
- return $waitThreshold
636
- }
637
-
638
- return [Math]::Max($BaseThreshold * 4, 3600)
639
- }
640
-
641
- function Get-PrizmProgressActivity {
642
- param([string]$ProgressFile)
643
-
644
- $empty = [pscustomobject]@{
645
- ChildSignature = ''
646
- ChildTotalBytes = 0
647
- ChildSessionCount = 0
648
- ProgressSignature = ''
649
- }
650
- if (-not (Test-Path $ProgressFile)) { return $empty }
651
-
652
- try {
653
- $progress = Get-Content $ProgressFile -Raw -ErrorAction Stop | ConvertFrom-Json -ErrorAction Stop
654
- } catch {
655
- return $empty
656
- }
657
-
658
- $childSignature = ''
659
- if ($progress.PSObject.Properties['child_activity_signature'] -and $progress.child_activity_signature) {
660
- $childSignature = [string]$progress.child_activity_signature
661
- }
662
-
663
- $childTotalBytes = [int64]0
664
- if ($progress.PSObject.Properties['child_total_bytes']) {
665
- [int64]::TryParse([string]$progress.child_total_bytes, [ref]$childTotalBytes) | Out-Null
666
- }
667
-
668
- $childSessionCount = 0
669
- if ($progress.PSObject.Properties['child_session_files'] -and $progress.child_session_files) {
670
- $childSessionCount = @($progress.child_session_files).Count
671
- }
672
-
673
- $messageCount = 0
674
- if ($progress.PSObject.Properties['message_count']) {
675
- [int]::TryParse([string]$progress.message_count, [ref]$messageCount) | Out-Null
676
- }
677
- $totalToolCalls = 0
678
- if ($progress.PSObject.Properties['total_tool_calls']) {
679
- [int]::TryParse([string]$progress.total_tool_calls, [ref]$totalToolCalls) | Out-Null
680
- }
681
- $activeSubagentCount = 0
682
- if ($progress.PSObject.Properties['active_subagent_count']) {
683
- [int]::TryParse([string]$progress.active_subagent_count, [ref]$activeSubagentCount) | Out-Null
684
- }
685
- $subagentSpawnCount = 0
686
- if ($progress.PSObject.Properties['subagent_spawn_count']) {
687
- [int]::TryParse([string]$progress.subagent_spawn_count, [ref]$subagentSpawnCount) | Out-Null
688
- }
689
- $currentPhase = if ($progress.PSObject.Properties['current_phase'] -and $progress.current_phase) { [string]$progress.current_phase } else { '' }
690
- $currentTool = if ($progress.PSObject.Properties['current_tool'] -and $progress.current_tool) { [string]$progress.current_tool } else { '' }
691
- $fatalErrorCode = if ($progress.PSObject.Properties['fatal_error_code'] -and $progress.fatal_error_code) { [string]$progress.fatal_error_code } else { '' }
692
- $terminalResultText = if ($progress.PSObject.Properties['terminal_result_text'] -and $progress.terminal_result_text) { [string]$progress.terminal_result_text } else { '' }
693
-
694
- $progressSignature = @(
695
- $currentPhase,
696
- $currentTool,
697
- $messageCount,
698
- $totalToolCalls,
699
- $activeSubagentCount,
700
- $subagentSpawnCount,
701
- $childSignature,
702
- $childTotalBytes,
703
- $childSessionCount,
704
- $fatalErrorCode,
705
- $terminalResultText
706
- ) | ConvertTo-Json -Compress
707
-
708
- return [pscustomobject]@{
709
- ChildSignature = $childSignature
710
- ChildTotalBytes = $childTotalBytes
711
- ChildSessionCount = $childSessionCount
712
- ProgressSignature = $progressSignature
713
- }
714
- }
715
-
716
- function Get-PrizmProgressChildActivity {
717
- param([string]$ProgressFile)
718
-
719
- $activity = Get-PrizmProgressActivity -ProgressFile $ProgressFile
720
- return [pscustomobject]@{
721
- Signature = $activity.ChildSignature
722
- TotalBytes = $activity.ChildTotalBytes
723
- SessionCount = $activity.ChildSessionCount
724
- }
725
- }
726
-
727
- function Test-PrizmCodexJsonSupport {
728
- param([string]$CliExecutable)
729
- try {
730
- $helpOutput = & $CliExecutable exec --help 2>&1
731
- return (($helpOutput -join "`n") -match '--json')
732
- } catch {
733
- return $false
734
- }
735
- }
736
-
737
- function Test-PrizmStreamJsonSupport {
738
- param([string]$CliCommand)
739
- $sessionPlatform = Get-PrizmSessionPlatform $CliCommand
740
- $parsedCli = Split-PrizmCommandLine $CliCommand
741
-
742
- if ($sessionPlatform -eq 'codebuddy') { return $true }
743
- if ($sessionPlatform -eq 'codex') { return (Test-PrizmCodexJsonSupport $parsedCli.Command) }
744
-
745
- try {
746
- $helpOutput = & $parsedCli.Command --help 2>&1
747
- return (($helpOutput -join "`n") -match 'stream-json')
748
- } catch {
749
- return $false
750
- }
751
- }
752
-
753
- function Test-PrizmEffort {
754
- param([string]$CliCommand)
755
- if ([string]::IsNullOrEmpty($env:PRIZMKIT_EFFORT)) { return }
756
-
757
- $sessionPlatform = Get-PrizmSessionPlatform $CliCommand
758
- $valid = @{
759
- claude = @('low', 'medium', 'high', 'xhigh', 'max')
760
- codex = @('low', 'medium', 'high', 'xhigh')
761
- codebuddy = @('low', 'medium', 'high', 'xhigh')
762
- }
763
-
764
- $allowed = $valid[$sessionPlatform]
765
- if ($env:PRIZMKIT_EFFORT -notin $allowed) {
766
- Write-Host "ERROR: PRIZMKIT_EFFORT='$env:PRIZMKIT_EFFORT' is not supported by the detected CLI ($sessionPlatform)." -ForegroundColor Red
767
- Write-Host " Supported values for $($sessionPlatform): $($allowed -join ', ')" -ForegroundColor Red
768
- Write-Host " Set `$env:PRIZMKIT_EFFORT to one of the above, or unset it to use the CLI default." -ForegroundColor Red
769
- exit 1
770
- }
771
- }
772
-
773
- function Start-PrizmProgressParser {
774
- param(
775
- [string[]]$PythonCommand,
776
- [string]$ScriptsDir,
777
- [string]$SessionLog,
778
- [string]$ProgressFile,
779
- [string]$CliCommand
780
- )
781
-
782
- if (-not (Test-PrizmStreamJsonSupport $CliCommand)) { return $null }
783
-
784
- $parserScript = Join-Path $ScriptsDir 'parse-stream-progress.py'
785
- if (-not (Test-Path $parserScript)) { return $null }
786
-
787
- $cmd = $PythonCommand[0]
788
- $prefix = @()
789
- if ($PythonCommand.Count -gt 1) { $prefix = $PythonCommand[1..($PythonCommand.Count - 1)] }
790
-
791
- $progressDir = Split-Path $ProgressFile -Parent
792
- if ($progressDir) { New-Item -ItemType Directory -Force -Path $progressDir | Out-Null }
793
-
794
- $psi = [System.Diagnostics.ProcessStartInfo]::new()
795
- $psi.UseShellExecute = $false
796
- $psi.CreateNoWindow = $true
797
- $psi.FileName = $cmd
798
- $psi.Arguments = Join-PrizmProcessArguments ($prefix + @($parserScript, '--session-log', $SessionLog, '--progress-file', $ProgressFile))
799
- return [System.Diagnostics.Process]::Start($psi)
800
- }
801
-
802
- function Stop-PrizmProgressParser {
803
- param($Process)
804
- if ($Process -eq $null) { return }
805
- try {
806
- if (-not $Process.HasExited) {
807
- try {
808
- $Process.Kill($true)
809
- } catch {
810
- Stop-PrizmProcessTreeById -ProcessId ([int]$Process.Id)
811
- }
812
- }
813
- } catch {}
814
- }
815
-
816
- function Stop-PrizmProcessTreeById {
817
- param([int]$ProcessId)
818
- if ($ProcessId -le 0) { return }
819
-
820
- $process = Get-Process -Id $ProcessId -ErrorAction SilentlyContinue
821
- if (-not $process) { return }
822
-
823
- try {
824
- $process.Kill($true)
825
- return
826
- } catch {
827
- try {
828
- $children = Get-CimInstance Win32_Process -Filter "ParentProcessId=$ProcessId" -ErrorAction SilentlyContinue
829
- foreach ($child in $children) {
830
- Stop-PrizmProcessTreeById -ProcessId ([int]$child.ProcessId)
831
- }
832
- } catch {
833
- try {
834
- $children = Get-WmiObject Win32_Process -Filter "ParentProcessId=$ProcessId" -ErrorAction SilentlyContinue
835
- foreach ($child in $children) {
836
- Stop-PrizmProcessTreeById -ProcessId ([int]$child.ProcessId)
837
- }
838
- } catch {}
839
- }
840
- try {
841
- Stop-Process -Id $ProcessId -Force -ErrorAction SilentlyContinue
842
- } catch {}
843
- }
844
- }
845
-
846
- function Stop-PrizmSessionProcess {
847
- param([string]$PidPath)
848
- if (-not (Test-Path $PidPath)) { return }
849
- $rawPid = Get-Content $PidPath -ErrorAction SilentlyContinue | Select-Object -First 1
850
- $aiPid = 0
851
- if ([int]::TryParse($rawPid, [ref]$aiPid)) {
852
- Stop-PrizmProcessTreeById -ProcessId $aiPid
853
- }
854
- }
855
-
856
- function Write-PrizmStaleKillMarker {
857
- param([string]$MarkerPath, [int]$StaleSeconds, [int]$Threshold)
858
- $markerDir = Split-Path $MarkerPath -Parent
859
- if ($markerDir) { New-Item -ItemType Directory -Force -Path $markerDir | Out-Null }
860
- [ordered]@{
861
- killed_at = (Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
862
- reason = 'stale_session'
863
- stale_seconds = $StaleSeconds
864
- threshold = $Threshold
865
- } | ConvertTo-Json -Compress | Set-Content -Path $MarkerPath -Encoding UTF8
866
- }
867
-
868
- function Invoke-PrizmAiSession {
869
- param(
870
- [string]$CliCommand,
871
- [string]$PromptPath,
872
- [string]$LogPath,
873
- [string]$ProjectRoot,
874
- [string]$Model = '',
875
- [string]$PidPath = ''
876
- )
877
- $prompt = Get-Content $PromptPath -Raw
878
- $logDir = Split-Path $LogPath -Parent
879
- New-Item -ItemType Directory -Force -Path $logDir | Out-Null
880
-
881
- $psi = [System.Diagnostics.ProcessStartInfo]::new()
882
- $psi.UseShellExecute = $false
883
- $psi.RedirectStandardInput = $true
884
- $psi.RedirectStandardOutput = $true
885
- $psi.RedirectStandardError = $true
886
- $psi.WorkingDirectory = $ProjectRoot
887
- [void]$psi.Environment.Remove('CLAUDECODE')
888
- $cliArgs = @()
889
- $parsedCli = Split-PrizmCommandLine $CliCommand
890
- $cliExecutable = $parsedCli.Command
891
- $sessionPlatform = Get-PrizmSessionPlatform $CliCommand
892
- $useStreamJson = Test-PrizmStreamJsonSupport $CliCommand
893
-
894
- if ($sessionPlatform -eq 'claude') {
895
- $cliArgs += @('-p', '--dangerously-skip-permissions')
896
- if ($env:VERBOSE -in @('1','true','yes','on') -or $useStreamJson) { $cliArgs += '--verbose' }
897
- if ($useStreamJson) { $cliArgs += @('--output-format', 'stream-json') }
898
- if ($env:PRIZMKIT_EFFORT) { $cliArgs += @('--effort', $env:PRIZMKIT_EFFORT) }
899
- if ($Model) { $cliArgs += @('--model', $Model) }
900
- } elseif ($sessionPlatform -eq 'codex') {
901
- $cliArgs += @('--ask-for-approval', 'never', '--sandbox', 'danger-full-access')
902
- $codexSubagentTimeout = Get-PrizmCodexSubagentTimeoutSeconds
903
- if ($codexSubagentTimeout -gt 0) {
904
- $cliArgs += @('--config', "agents.job_max_runtime_seconds=$codexSubagentTimeout")
905
- }
906
- $cliArgs += @('exec', '--cd', $ProjectRoot, '--skip-git-repo-check')
907
- if ($useStreamJson) { $cliArgs += '--json' }
908
- if ($Model) { $cliArgs += @('--model', $Model) }
909
- if ($env:PRIZMKIT_EFFORT) { $cliArgs += @('--config', "model_reasoning_effort=$env:PRIZMKIT_EFFORT") }
910
- $cliArgs += '-'
911
- } else {
912
- $cliArgs += @('--print', '-y')
913
- if ($env:VERBOSE -in @('1','true','yes','on')) { $cliArgs += '--verbose' }
914
- if ($useStreamJson) { $cliArgs += @('--output-format', 'stream-json') }
915
- if ($env:PRIZMKIT_EFFORT) { $cliArgs += @('--effort', $env:PRIZMKIT_EFFORT) }
916
- if ($Model) { $cliArgs += @('--model', $Model) }
917
- }
918
- $generatedArgs = (($cliArgs | ForEach-Object { ConvertTo-PrizmProcessArgument $_ }) -join ' ')
919
- $fullArgs = @()
920
- if ($parsedCli.Arguments) { $fullArgs += $parsedCli.Arguments }
921
- if ($generatedArgs) { $fullArgs += $generatedArgs }
922
- $argumentString = ($fullArgs -join ' ')
923
-
924
- $cliExtension = [System.IO.Path]::GetExtension($cliExecutable).ToLowerInvariant()
925
-
926
- if ($cliExtension -in @('.cmd', '.bat')) {
927
- $psi.FileName = if ($env:ComSpec) { $env:ComSpec } else { 'cmd.exe' }
928
- $childCommand = (ConvertTo-PrizmProcessArgument $cliExecutable)
929
- if ($argumentString) { $childCommand = "$childCommand $argumentString" }
930
- $psi.Arguments = '/d /s /c "' + $childCommand + '"'
931
- } elseif ($cliExtension -eq '.ps1') {
932
- $psi.FileName = Resolve-PrizmPowerShellHost
933
- $scriptArgs = @('-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', $cliExecutable)
934
- $scriptArgumentString = Join-PrizmProcessArguments $scriptArgs
935
- if ($argumentString) { $scriptArgumentString = "$scriptArgumentString $argumentString" }
936
- $psi.Arguments = $scriptArgumentString
937
- } else {
938
- $psi.FileName = $cliExecutable
939
- $psi.Arguments = $argumentString
940
- }
941
-
942
- Initialize-PrizmLineLogBridgeType
943
- $process = [System.Diagnostics.Process]::Start($psi)
944
- $script:PrizmAiProcess = $process
945
- $logBridge = [PrizmLineLogBridge]::new($LogPath)
946
- $process.add_OutputDataReceived($logBridge.Handler)
947
- $process.add_ErrorDataReceived($logBridge.Handler)
948
- if ($PidPath) {
949
- $pidDir = Split-Path $PidPath -Parent
950
- if ($pidDir) { New-Item -ItemType Directory -Force -Path $pidDir | Out-Null }
951
- Set-Content -Path $PidPath -Value ([string]$process.Id) -Encoding UTF8
952
- }
953
- try {
954
- $process.BeginOutputReadLine()
955
- $process.BeginErrorReadLine()
956
- $process.StandardInput.Write($prompt)
957
- $process.StandardInput.Close()
958
- $process.WaitForExit()
959
- $process.WaitForExit()
960
- return $process.ExitCode
961
- } finally {
962
- $process.remove_OutputDataReceived($logBridge.Handler)
963
- $process.remove_ErrorDataReceived($logBridge.Handler)
964
- $logBridge.Dispose()
965
- }
966
- }
967
-
968
- function New-PrizmSessionId {
969
- param([string]$Prefix)
970
- return "$Prefix-$(Get-Date -Format 'yyyyMMdd-HHmmss')-$([guid]::NewGuid().ToString('N').Substring(0, 8))"
971
- }
972
-
973
- function Get-PrizmListDefault {
974
- param([string]$Kind, [string]$ProjectRoot)
975
- switch ($Kind) {
976
- 'feature' { return Join-Path $ProjectRoot '.prizmkit\plans\feature-list.json' }
977
- 'bugfix' { return Join-Path $ProjectRoot '.prizmkit\plans\bug-fix-list.json' }
978
- 'refactor' { return Join-Path $ProjectRoot '.prizmkit\plans\refactor-list.json' }
979
- default { throw "Unknown pipeline kind: $Kind" }
980
- }
981
- }
982
-
983
- function Get-PrizmStateDir {
984
- param([string]$Kind, [string]$ProjectRoot)
985
- switch ($Kind) {
986
- 'feature' { return Join-Path $ProjectRoot '.prizmkit\state\features' }
987
- 'bugfix' { return Join-Path $ProjectRoot '.prizmkit\state\bugfix' }
988
- 'refactor' { return Join-Path $ProjectRoot '.prizmkit\state\refactor' }
989
- default { throw "Unknown pipeline kind: $Kind" }
990
- }
991
- }