prizmkit 1.1.57 → 1.1.60

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 (188) hide show
  1. package/bin/create-prizmkit.js +8 -6
  2. package/bundled/VERSION.json +3 -3
  3. package/bundled/adapters/codex/agent-adapter.js +38 -0
  4. package/bundled/adapters/codex/paths.js +27 -0
  5. package/bundled/adapters/codex/rules-adapter.js +30 -0
  6. package/bundled/adapters/codex/settings-adapter.js +27 -0
  7. package/bundled/adapters/codex/skill-adapter.js +65 -0
  8. package/bundled/adapters/codex/team-adapter.js +37 -0
  9. package/bundled/dev-pipeline/.env.example +2 -1
  10. package/bundled/dev-pipeline/README.md +10 -7
  11. package/bundled/dev-pipeline/lib/common.sh +278 -37
  12. package/bundled/dev-pipeline/run-bugfix.sh +10 -61
  13. package/bundled/dev-pipeline/run-feature.sh +10 -78
  14. package/bundled/dev-pipeline/run-recovery.sh +10 -46
  15. package/bundled/dev-pipeline/run-refactor.sh +10 -61
  16. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +17 -7
  17. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +9 -3
  18. package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +9 -3
  19. package/bundled/dev-pipeline/scripts/utils.py +6 -4
  20. package/bundled/dev-pipeline-windows/.env.example +28 -0
  21. package/bundled/dev-pipeline-windows/README.md +30 -0
  22. package/bundled/dev-pipeline-windows/SCHEMA_ANALYSIS.md +525 -0
  23. package/bundled/dev-pipeline-windows/assets/feature-list-example.json +146 -0
  24. package/bundled/dev-pipeline-windows/assets/prizm-dev-team-integration.md +138 -0
  25. package/bundled/dev-pipeline-windows/launch-bugfix-daemon.ps1 +9 -0
  26. package/bundled/dev-pipeline-windows/launch-feature-daemon.ps1 +9 -0
  27. package/bundled/dev-pipeline-windows/launch-refactor-daemon.ps1 +9 -0
  28. package/bundled/dev-pipeline-windows/lib/common.ps1 +432 -0
  29. package/bundled/dev-pipeline-windows/lib/daemon.ps1 +140 -0
  30. package/bundled/dev-pipeline-windows/lib/pipeline.ps1 +446 -0
  31. package/bundled/dev-pipeline-windows/lib/reset.ps1 +87 -0
  32. package/bundled/dev-pipeline-windows/reset-bug.ps1 +9 -0
  33. package/bundled/dev-pipeline-windows/reset-feature.ps1 +9 -0
  34. package/bundled/dev-pipeline-windows/reset-refactor.ps1 +9 -0
  35. package/bundled/dev-pipeline-windows/run-bugfix.ps1 +9 -0
  36. package/bundled/dev-pipeline-windows/run-feature.ps1 +9 -0
  37. package/bundled/dev-pipeline-windows/run-recovery.ps1 +76 -0
  38. package/bundled/dev-pipeline-windows/run-refactor.ps1 +9 -0
  39. package/bundled/dev-pipeline-windows/scripts/check-session-status.py +228 -0
  40. package/bundled/dev-pipeline-windows/scripts/cleanup-logs.py +192 -0
  41. package/bundled/dev-pipeline-windows/scripts/detect-stuck.py +530 -0
  42. package/bundled/dev-pipeline-windows/scripts/generate-bootstrap-prompt.py +1737 -0
  43. package/bundled/dev-pipeline-windows/scripts/generate-bugfix-prompt.py +685 -0
  44. package/bundled/dev-pipeline-windows/scripts/generate-recovery-prompt.py +805 -0
  45. package/bundled/dev-pipeline-windows/scripts/generate-refactor-prompt.py +763 -0
  46. package/bundled/dev-pipeline-windows/scripts/init-bugfix-pipeline.py +316 -0
  47. package/bundled/dev-pipeline-windows/scripts/init-dev-team.py +134 -0
  48. package/bundled/dev-pipeline-windows/scripts/init-pipeline.py +380 -0
  49. package/bundled/dev-pipeline-windows/scripts/init-refactor-pipeline.py +399 -0
  50. package/bundled/dev-pipeline-windows/scripts/parse-stream-progress.py +388 -0
  51. package/bundled/dev-pipeline-windows/scripts/patch-completion-notes.py +191 -0
  52. package/bundled/dev-pipeline-windows/scripts/update-bug-status.py +864 -0
  53. package/bundled/dev-pipeline-windows/scripts/update-checkpoint.py +173 -0
  54. package/bundled/dev-pipeline-windows/scripts/update-feature-status.py +1501 -0
  55. package/bundled/dev-pipeline-windows/scripts/update-refactor-status.py +1073 -0
  56. package/bundled/dev-pipeline-windows/scripts/utils.py +542 -0
  57. package/bundled/dev-pipeline-windows/templates/agent-prompts/critic-plan-challenge.md +7 -0
  58. package/bundled/dev-pipeline-windows/templates/agent-prompts/dev-fix.md +7 -0
  59. package/bundled/dev-pipeline-windows/templates/agent-prompts/dev-implement.md +30 -0
  60. package/bundled/dev-pipeline-windows/templates/agent-prompts/dev-resume.md +5 -0
  61. package/bundled/dev-pipeline-windows/templates/agent-prompts/reviewer-review.md +7 -0
  62. package/bundled/dev-pipeline-windows/templates/bootstrap-prompt.md +46 -0
  63. package/bundled/dev-pipeline-windows/templates/bootstrap-tier1.md +43 -0
  64. package/bundled/dev-pipeline-windows/templates/bootstrap-tier2.md +43 -0
  65. package/bundled/dev-pipeline-windows/templates/bootstrap-tier3.md +43 -0
  66. package/bundled/dev-pipeline-windows/templates/bug-fix-list-schema.json +263 -0
  67. package/bundled/dev-pipeline-windows/templates/bugfix-bootstrap-prompt.md +320 -0
  68. package/bundled/dev-pipeline-windows/templates/feature-list-schema.json +237 -0
  69. package/bundled/dev-pipeline-windows/templates/refactor-bootstrap-prompt.md +331 -0
  70. package/bundled/dev-pipeline-windows/templates/refactor-list-schema.json +270 -0
  71. package/bundled/dev-pipeline-windows/templates/sections/ac-verification-checklist.md +13 -0
  72. package/bundled/dev-pipeline-windows/templates/sections/checkpoint-system.md +91 -0
  73. package/bundled/dev-pipeline-windows/templates/sections/context-budget-rules.md +33 -0
  74. package/bundled/dev-pipeline-windows/templates/sections/critical-paths-agent.md +10 -0
  75. package/bundled/dev-pipeline-windows/templates/sections/critical-paths-full.md +12 -0
  76. package/bundled/dev-pipeline-windows/templates/sections/critical-paths-lite.md +7 -0
  77. package/bundled/dev-pipeline-windows/templates/sections/directory-convention-agent.md +8 -0
  78. package/bundled/dev-pipeline-windows/templates/sections/directory-convention-full.md +9 -0
  79. package/bundled/dev-pipeline-windows/templates/sections/directory-convention-lite.md +6 -0
  80. package/bundled/dev-pipeline-windows/templates/sections/failure-capture.md +21 -0
  81. package/bundled/dev-pipeline-windows/templates/sections/feature-context.md +31 -0
  82. package/bundled/dev-pipeline-windows/templates/sections/phase-browser-verification-auto.md +72 -0
  83. package/bundled/dev-pipeline-windows/templates/sections/phase-browser-verification-opencli.md +63 -0
  84. package/bundled/dev-pipeline-windows/templates/sections/phase-browser-verification.md +62 -0
  85. package/bundled/dev-pipeline-windows/templates/sections/phase-commit-full.md +71 -0
  86. package/bundled/dev-pipeline-windows/templates/sections/phase-commit.md +64 -0
  87. package/bundled/dev-pipeline-windows/templates/sections/phase-context-snapshot-agent-suffix.md +23 -0
  88. package/bundled/dev-pipeline-windows/templates/sections/phase-context-snapshot-base.md +24 -0
  89. package/bundled/dev-pipeline-windows/templates/sections/phase-context-snapshot-lite-suffix.md +12 -0
  90. package/bundled/dev-pipeline-windows/templates/sections/phase-critic-plan-full.md +53 -0
  91. package/bundled/dev-pipeline-windows/templates/sections/phase-critic-plan.md +32 -0
  92. package/bundled/dev-pipeline-windows/templates/sections/phase-implement-agent.md +37 -0
  93. package/bundled/dev-pipeline-windows/templates/sections/phase-implement-full.md +50 -0
  94. package/bundled/dev-pipeline-windows/templates/sections/phase-implement-lite.md +52 -0
  95. package/bundled/dev-pipeline-windows/templates/sections/phase-plan-agent.md +27 -0
  96. package/bundled/dev-pipeline-windows/templates/sections/phase-plan-lite.md +27 -0
  97. package/bundled/dev-pipeline-windows/templates/sections/phase-review-agent.md +27 -0
  98. package/bundled/dev-pipeline-windows/templates/sections/phase-review-full.md +29 -0
  99. package/bundled/dev-pipeline-windows/templates/sections/phase-specify-plan-full.md +77 -0
  100. package/bundled/dev-pipeline-windows/templates/sections/phase0-init.md +13 -0
  101. package/bundled/dev-pipeline-windows/templates/sections/phase0-test-baseline.md +23 -0
  102. package/bundled/dev-pipeline-windows/templates/sections/session-context.md +5 -0
  103. package/bundled/dev-pipeline-windows/templates/sections/subagent-timeout-recovery.md +6 -0
  104. package/bundled/dev-pipeline-windows/templates/sections/test-failure-recovery-agent.md +67 -0
  105. package/bundled/dev-pipeline-windows/templates/sections/test-failure-recovery-lite.md +58 -0
  106. package/bundled/dev-pipeline-windows/templates/session-status-schema.json +83 -0
  107. package/bundled/skills/_metadata.json +1 -1
  108. package/bundled/skills/app-planner/SKILL.md +26 -18
  109. package/bundled/skills/app-planner/references/architecture-decisions.md +9 -5
  110. package/bundled/skills/app-planner/references/frontend-design-guide.md +1 -1
  111. package/bundled/skills/feature-planner/SKILL.md +9 -2
  112. package/bundled/skills/prizmkit-init/SKILL.md +7 -6
  113. package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +2 -0
  114. package/bundled/skills-windows/app-planner/SKILL.md +639 -0
  115. package/bundled/skills-windows/app-planner/assets/app-design-guide.md +101 -0
  116. package/bundled/skills-windows/app-planner/references/architecture-decisions.md +52 -0
  117. package/bundled/skills-windows/app-planner/references/brainstorm-guide.md +101 -0
  118. package/bundled/skills-windows/app-planner/references/frontend-design-guide.md +71 -0
  119. package/bundled/skills-windows/app-planner/references/project-brief-guide.md +82 -0
  120. package/bundled/skills-windows/app-planner/references/red-team-checklist.md +40 -0
  121. package/bundled/skills-windows/app-planner/references/rules/backend/derivation-rules.md +609 -0
  122. package/bundled/skills-windows/app-planner/references/rules/backend/fixed-rules.md +285 -0
  123. package/bundled/skills-windows/app-planner/references/rules/backend/question-bank.md +249 -0
  124. package/bundled/skills-windows/app-planner/references/rules/backend/template.md +173 -0
  125. package/bundled/skills-windows/app-planner/references/rules/database/derivation-rules.md +373 -0
  126. package/bundled/skills-windows/app-planner/references/rules/database/fixed-rules.md +211 -0
  127. package/bundled/skills-windows/app-planner/references/rules/database/question-bank.md +184 -0
  128. package/bundled/skills-windows/app-planner/references/rules/database/template.md +158 -0
  129. package/bundled/skills-windows/app-planner/references/rules/frontend/derivation-rules.md +810 -0
  130. package/bundled/skills-windows/app-planner/references/rules/frontend/fixed-rules.md +188 -0
  131. package/bundled/skills-windows/app-planner/references/rules/frontend/question-bank.md +302 -0
  132. package/bundled/skills-windows/app-planner/references/rules/frontend/template.md +320 -0
  133. package/bundled/skills-windows/app-planner/references/rules/mobile/derivation-rules.md +639 -0
  134. package/bundled/skills-windows/app-planner/references/rules/mobile/fixed-rules.md +290 -0
  135. package/bundled/skills-windows/app-planner/references/rules/mobile/question-bank.md +232 -0
  136. package/bundled/skills-windows/app-planner/references/rules/mobile/template.md +175 -0
  137. package/bundled/skills-windows/bug-fix-workflow/SKILL.md +415 -0
  138. package/bundled/skills-windows/bug-planner/SKILL.md +395 -0
  139. package/bundled/skills-windows/bug-planner/assets/bug-confirmation-template.md +43 -0
  140. package/bundled/skills-windows/bug-planner/references/critic-and-verification.md +44 -0
  141. package/bundled/skills-windows/bug-planner/references/error-recovery.md +73 -0
  142. package/bundled/skills-windows/bug-planner/references/input-formats.md +53 -0
  143. package/bundled/skills-windows/bug-planner/references/schema-validation.md +25 -0
  144. package/bundled/skills-windows/bug-planner/references/severity-rules.md +16 -0
  145. package/bundled/skills-windows/bug-planner/scripts/validate-bug-list.py +322 -0
  146. package/bundled/skills-windows/bugfix-pipeline-launcher/SKILL.md +380 -0
  147. package/bundled/skills-windows/feature-pipeline-launcher/SKILL.md +441 -0
  148. package/bundled/skills-windows/feature-pipeline-launcher/scripts/preflight-check.py +462 -0
  149. package/bundled/skills-windows/feature-planner/SKILL.md +401 -0
  150. package/bundled/skills-windows/feature-planner/assets/evaluation-guide.md +64 -0
  151. package/bundled/skills-windows/feature-planner/assets/planning-guide.md +214 -0
  152. package/bundled/skills-windows/feature-planner/references/browser-interaction.md +59 -0
  153. package/bundled/skills-windows/feature-planner/references/completeness-review.md +57 -0
  154. package/bundled/skills-windows/feature-planner/references/decomposition-patterns.md +75 -0
  155. package/bundled/skills-windows/feature-planner/references/error-recovery.md +90 -0
  156. package/bundled/skills-windows/feature-planner/references/incremental-feature-planning.md +112 -0
  157. package/bundled/skills-windows/feature-planner/references/new-project-planning.md +85 -0
  158. package/bundled/skills-windows/feature-planner/scripts/validate-and-generate.py +1029 -0
  159. package/bundled/skills-windows/feature-workflow/SKILL.md +531 -0
  160. package/bundled/skills-windows/prizmkit-init/SKILL.md +356 -0
  161. package/bundled/skills-windows/prizmkit-init/assets/project-brief-template.md +82 -0
  162. package/bundled/skills-windows/prizmkit-init/references/config-schema.md +68 -0
  163. package/bundled/skills-windows/prizmkit-init/references/rules/layer-detection.md +41 -0
  164. package/bundled/skills-windows/prizmkit-init/references/tech-stack-catalog.md +13 -0
  165. package/bundled/skills-windows/prizmkit-init/references/update-supplement.md +9 -0
  166. package/bundled/skills-windows/recovery-workflow/SKILL.md +456 -0
  167. package/bundled/skills-windows/recovery-workflow/evals/evals.json +46 -0
  168. package/bundled/skills-windows/recovery-workflow/scripts/detect-recovery-state.py +544 -0
  169. package/bundled/skills-windows/refactor-pipeline-launcher/SKILL.md +406 -0
  170. package/bundled/skills-windows/refactor-planner/SKILL.md +540 -0
  171. package/bundled/skills-windows/refactor-planner/assets/planning-guide.md +292 -0
  172. package/bundled/skills-windows/refactor-planner/references/behavior-preservation.md +301 -0
  173. package/bundled/skills-windows/refactor-planner/references/refactor-scoping-guide.md +221 -0
  174. package/bundled/skills-windows/refactor-planner/scripts/validate-and-generate-refactor.py +858 -0
  175. package/bundled/skills-windows/refactor-workflow/SKILL.md +503 -0
  176. package/package.json +3 -2
  177. package/src/clean.js +73 -2
  178. package/src/config.js +159 -50
  179. package/src/detect-platform.js +16 -8
  180. package/src/external-skills.js +26 -19
  181. package/src/index.js +31 -9
  182. package/src/manifest.js +6 -2
  183. package/src/metadata.js +43 -5
  184. package/src/platforms.js +36 -0
  185. package/src/prompts.js +31 -6
  186. package/src/runtimes.js +20 -0
  187. package/src/scaffold.js +314 -110
  188. package/src/upgrade.js +81 -41
@@ -0,0 +1,406 @@
1
+ ---
2
+ name: "refactor-pipeline-launcher"
3
+ description: "Launch and manage the refactor pipeline from within an AI CLI session. Start pipeline in background, monitor logs, check status, stop pipeline. Use this skill whenever the user wants to start refactoring, run the refactor pipeline, check refactor progress, retry refactors, or stop the pipeline. Trigger on: 'run refactor pipeline', 'start refactoring', 'refactor pipeline status', 'stop refactor pipeline', 'retry refactor', 'launch refactor pipeline'. (project)"
4
+ ---
5
+
6
+ # Refactor Pipeline Launcher
7
+
8
+ Launch the autonomous refactor pipeline from within an AI CLI conversation. The pipeline runs as a fully detached background process -- closing the AI CLI session does NOT stop the pipeline.
9
+
10
+ ### Execution Mode
11
+
12
+ Three execution modes are available. The user chooses one before configuring other options:
13
+
14
+ 1. **Foreground** (recommended) — `.\.prizmkit\dev-pipeline\run-refactor.ps1 run`. Visible output, direct error feedback, no orphaned processes.
15
+ 2. **Background daemon** — `.\.prizmkit\dev-pipeline\launch-refactor-daemon.ps1`. Runs fully detached, survives AI CLI session closure.
16
+ 3. **Manual** — Display the assembled command(s) only. Do not execute anything. User runs them on their own.
17
+
18
+ ### When to Use
19
+
20
+ **Start pipeline** -- User says:
21
+ - "run refactor pipeline", "start refactoring", "launch refactor pipeline"
22
+ - "execute refactor list", "refactor all", "start refactoring tasks"
23
+ - After refactor-planner completes: "refactor it", "start refactoring from the list"
24
+
25
+ **Check status** -- User says:
26
+ - "refactor pipeline status", "refactor progress", "check refactoring"
27
+ - "how's the refactoring going", "refactor status"
28
+
29
+ **Stop pipeline** -- User says:
30
+ - "stop refactor pipeline", "stop refactoring", "halt refactor", "pause refactoring"
31
+
32
+ **Show logs** -- User says:
33
+ - "refactor logs", "show refactor logs", "what's being refactored"
34
+ - "view refactor logs"
35
+
36
+ **Retry single refactor** -- User says:
37
+ - "retry R-001", "retry this refactor", "re-run R-001"
38
+
39
+ **Do NOT use this skill when:**
40
+ - User wants to plan refactoring (use `refactor-planner` instead)
41
+ - User wants a single interactive refactor in current session (use `refactor-workflow` — but note it will delegate back here for batch execution)
42
+ - User wants to implement features (use `feature-pipeline-launcher`)
43
+
44
+ ### Prerequisites
45
+
46
+ Before any action, validate:
47
+
48
+ 1. **refactor pipeline exists**: Confirm `.\.prizmkit\dev-pipeline\launch-refactor-daemon.ps1` and `.\.prizmkit\dev-pipeline\run-refactor.ps1` are present and executable
49
+ 2. **For start**: `.prizmkit/plans/refactor-list.json` must exist in `.prizmkit/plans/` (or user-specified path)
50
+ 3. **Dependencies**: `python` or the Windows `py` launcher, `git`, and one AI CLI (`codex`, `claude`, or `cbc`) must be in PATH
51
+ 4. **Python version**: Requires Python 3.8+ for dev-pipeline scripts
52
+ 5. **Browser tools** (optional): If any refactor has `browser_interaction` field, check the corresponding tool is available. Refactors may specify `tool: "playwright-cli"`, `tool: "opencli"`, or `tool: "auto"` (AI chooses at runtime).
53
+
54
+ Quick check:
55
+ ```powershell
56
+ function Invoke-PrizmPython {
57
+ param([Parameter(ValueFromRemainingArguments = $true)][string[]]$Arguments)
58
+ $python = Get-Command python -ErrorAction SilentlyContinue
59
+ if ($python) {
60
+ & $python.Source -c 'import sys; raise SystemExit(0 if sys.version_info[0] == 3 else 1)' *> $null
61
+ if ($LASTEXITCODE -eq 0) {
62
+ & $python.Source @Arguments
63
+ return
64
+ }
65
+ }
66
+ $py = Get-Command py -ErrorAction SilentlyContinue
67
+ if ($py) {
68
+ & $py.Source -3 -c 'import sys; raise SystemExit(0 if sys.version_info[0] == 3 else 1)' *> $null
69
+ if ($LASTEXITCODE -eq 0) {
70
+ & $py.Source -3 @Arguments
71
+ return
72
+ }
73
+ }
74
+ throw "Python 3 is required. Install Python and ensure python or py is in PATH."
75
+ }
76
+ try {
77
+ $prizmPythonPath = Invoke-PrizmPython -c "import sys; print(sys.executable)"
78
+ "Python OK: $prizmPythonPath"
79
+ } catch {
80
+ "Missing Python: install Python 3 and ensure python or py is in PATH"
81
+ }
82
+ Get-Command git
83
+ $aiCli = @("codex", "claude", "cbc") | Where-Object { Get-Command $_ -ErrorAction SilentlyContinue } | Select-Object -First 1
84
+ if ($aiCli) { "AI CLI OK: $aiCli" } else { "Missing AI CLI: install codex, claude, or cbc" }
85
+ # Optional: browser interaction support (check both tools — refactors may use either)
86
+ if (Get-Command playwright-cli -ErrorAction SilentlyContinue) { "playwright-cli OK" } else { "playwright-cli not found (playwright browser verification will be skipped)" }
87
+ if (Get-Command opencli -ErrorAction SilentlyContinue) { "opencli OK" } else { "opencli not found (opencli browser verification will be skipped)" }
88
+ ```
89
+
90
+ If `.prizmkit/plans/refactor-list.json` is missing, inform user:
91
+ > "No .prizmkit/plans/refactor-list.json found. Run the `refactor-planner` skill first to generate one, or provide a path to your refactor list."
92
+
93
+ ### Workflow
94
+
95
+ Detect user intent from their message, then follow the corresponding workflow:
96
+
97
+ ---
98
+
99
+ #### Intent A: Start Pipeline
100
+
101
+ > **Execution model**: The pipeline processes refactor tasks **sequentially** (one at a time, in priority order). The `dependencies` field in refactor-list.json is reserved for future parallel execution support and does NOT affect current execution order.
102
+
103
+ 1. **Check prerequisites**:
104
+ ```powershell
105
+ if (Test-Path .prizmkit/plans/refactor-list.json) { "Found" } else { "Missing" }
106
+ ```
107
+
108
+ 2. **Check not already running**:
109
+ ```powershell
110
+ .\.prizmkit\dev-pipeline\launch-refactor-daemon.ps1 status
111
+ ```
112
+ If running, inform user and ask: "Refactor pipeline is already running. Want to restart it, check status, or view logs?"
113
+
114
+ 3. **Show refactor summary** (so user knows what will be refactored):
115
+ ```powershell
116
+ $data = Get-Content .prizmkit\plans\refactor-list.json -Raw | ConvertFrom-Json
117
+ $refactors = @($data.refactors)
118
+ "Total refactor tasks: $($refactors.Count)"
119
+ $refactors | Group-Object type | ForEach-Object { " $($_.Name): $($_.Count)" }
120
+ ""
121
+ $priorityOrder = @{ critical = 0; high = 1; medium = 2; low = 3 }
122
+ $refactorsSorted = $refactors | Sort-Object `
123
+ @{ Expression = { if ($priorityOrder.ContainsKey($_.priority)) { $priorityOrder[$_.priority] } else { 2 } } }, `
124
+ @{ Expression = { $_.id } }
125
+ foreach ($refactor in $refactorsSorted) {
126
+ $priority = if ($refactor.priority) { $refactor.priority.ToUpperInvariant() } else { "MEDIUM" }
127
+ $type = if ($refactor.type) { $refactor.type } else { "?" }
128
+ $title = if ($refactor.title) { $refactor.title } else { "untitled" }
129
+ " $($refactor.id): [$priority] [$type] $title"
130
+ }
131
+ ```
132
+ If pipeline state already exists, use the status command instead:
133
+ ```powershell
134
+ Invoke-PrizmPython .prizmkit/dev-pipeline/scripts/update-refactor-status.py `
135
+ --refactor-list .prizmkit/plans/refactor-list.json `
136
+ --state-dir .prizmkit/state/refactor `
137
+ --action status
138
+ ```
139
+
140
+ 4. **Run preflight checks** (behavior-preservation baseline):
141
+
142
+ Before refactoring, verify the codebase is in a clean, testable state:
143
+ ```powershell
144
+ # Check git working tree is clean
145
+ git status --porcelain | Select-Object -First 5
146
+ # Run existing test suite to establish baseline
147
+ npm test 2>&1 | Select-Object -Last 20
148
+ if ($LASTEXITCODE -ne 0) { "Test command failed or not configured" }
149
+ ```
150
+
151
+ If git working tree is dirty, warn the user:
152
+ > "Working tree has uncommitted changes. It's recommended to commit or stash changes before starting refactoring so each refactor task has a clean baseline. Continue anyway?"
153
+
154
+ If test baseline fails, warn the user:
155
+ > "Test suite is not passing. Refactoring relies on tests to verify behavior preservation. Fix failing tests before starting the refactor pipeline, or continue at your own risk."
156
+
157
+ Wait for user confirmation before proceeding.
158
+
159
+ 5. **Ask execution mode** (first user decision — SEPARATE `AskUserQuestion` call):
160
+
161
+ ⛔ **This MUST be its own standalone `AskUserQuestion` call.** Do NOT combine execution mode with step 6 config questions. The execution mode question is asked ALONE, user responds, THEN you proceed to step 6.
162
+
163
+ Use `AskUserQuestion` with exactly 1 question:
164
+
165
+ **Question 1 — Execution mode** (multiSelect: false):
166
+ - Foreground (Recommended) — pipeline runs in the current session via `run-refactor.ps1 run`. Visible output and direct error feedback.
167
+ - Background daemon — pipeline runs fully detached via `launch-refactor-daemon.ps1`. Survives AI CLI session closure.
168
+ - Manual — display the final assembled commands only. Do not execute anything. User runs them on their own.
169
+
170
+ ⚠️ STOP HERE and wait for user response before continuing to step 6.
171
+
172
+ 6. **Ask configuration options** ⚠️ MANDATORY INTERACTIVE STEP — applies to ALL execution modes (Foreground, Background, AND Manual). This is a SEPARATE `AskUserQuestion` call from step 5. You MUST ask the user to configure options and WAIT for their response BEFORE proceeding to step 7.
173
+
174
+ ⛔ **HARD STOP**: You MUST call `AskUserQuestion` with the 3 questions below and WAIT for the user's response. You MUST NOT:
175
+ - Combine step 5 and step 6 into one `AskUserQuestion` call (this is the most common violation — execution mode MUST be asked separately in step 5)
176
+ - Skip this step and jump to step 7
177
+ - Merge step 6 and step 7 into one response
178
+ - Assume default values and show the command without asking
179
+ - Show the command as text and ask "ready?" without presenting the options
180
+ If you find yourself writing the final command before the user has answered these 3 questions, STOP — you are violating this rule.
181
+
182
+ Use `AskUserQuestion` to present ALL 3 configuration choices (the full 3-question budget goes to config, NOT shared with execution mode):
183
+
184
+ **Question 1 — Verbose logging** (multiSelect: false):
185
+ - On (default) — Detailed AI session logs including tool calls and subagent activity
186
+ - Off — Minimal logging
187
+
188
+ **Question 2 — Max retries** (multiSelect: false):
189
+ - 3 (default)
190
+ - 1
191
+ - 5
192
+
193
+ **Question 3 — Advanced config?** (multiSelect: false):
194
+ - No (default) — Use defaults for critic review, session timeout, and failure behavior
195
+ - Yes — Configure critic review, session timeout, and stop-on-failure options
196
+
197
+ Note: Refactor filter defaults to all refactor items (by priority order). If the user selects "Other" on any option, handle their custom input.
198
+
199
+ **If user chose "Yes" to Advanced config**, ask a second round of `AskUserQuestion`:
200
+
201
+ **Question 1 — Session timeout** (multiSelect: false):
202
+ - None (default) — No timeout
203
+ - 30 min — `SESSION_TIMEOUT=1800`
204
+ - 1 hour — `SESSION_TIMEOUT=3600`
205
+ - 2 hours — `SESSION_TIMEOUT=7200`
206
+
207
+ **Question 2 — Stop on failure** (multiSelect: false):
208
+ - Off (default) — Pipeline continues to next task after failure
209
+ - On — Pipeline halts immediately when a task exhausts all retries (`STOP_ON_FAILURE=1`)
210
+
211
+ **Question 3 — Critic review** (multiSelect: false):
212
+ - Off (default) — Skip adversarial review
213
+ - On — Enable adversarial critic review: an independent AI agent reviews the refactor plan for completeness and the implementation for regressions, missing edge cases, and behavior violations. Adds ~5-10 min per refactor task.
214
+
215
+ Default Critic to Off unless refactor items have `priority: "critical"` (in which case default to On).
216
+
217
+ **Environment variable mapping** (for translating user responses → env vars):
218
+
219
+ | Config choice | Environment variable |
220
+ |-----------|---------------------|
221
+ | Verbose: On | `VERBOSE=1` |
222
+ | Verbose: Off | `VERBOSE=0` |
223
+ | Max retries: N | `MAX_RETRIES=N` |
224
+ | Critic: On | `ENABLE_CRITIC=true` |
225
+ | Timeout: value | `SESSION_TIMEOUT=<seconds>` |
226
+ | Stop on failure: On | `STOP_ON_FAILURE=1` |
227
+
228
+ **Advanced environment variables** (not exposed in interactive menu, pass via `--env`):
229
+
230
+ | Variable | Default | Purpose |
231
+ |----------|---------|---------|
232
+ | `MODEL` | (none) | AI model override (e.g. `claude-opus-4.6`) |
233
+
234
+ ⚠️ STOP HERE and wait for user response before continuing to step 7.
235
+
236
+ 7. **Show final command**: After user confirms configuration in step 6, assemble the complete command from execution mode + user-confirmed configuration, and present it to the user.
237
+
238
+ **Foreground command:**
239
+ ```powershell
240
+ $env:VERBOSE = "1"; .\.prizmkit\dev-pipeline\run-refactor.ps1 run .prizmkit/plans/refactor-list.json
241
+ ```
242
+ With all options:
243
+ ```powershell
244
+ $env:VERBOSE = "1"; $env:MAX_RETRIES = "5"; $env:SESSION_TIMEOUT = "3600"
245
+ .\.prizmkit\dev-pipeline\run-refactor.ps1 run .prizmkit/plans/refactor-list.json
246
+ ```
247
+
248
+ **Background daemon command:**
249
+ ```powershell
250
+ .\.prizmkit\dev-pipeline\launch-refactor-daemon.ps1 start .prizmkit/plans/refactor-list.json --env "VERBOSE=1"
251
+ ```
252
+ With all options:
253
+ ```powershell
254
+ .\.prizmkit\dev-pipeline\launch-refactor-daemon.ps1 start .prizmkit/plans/refactor-list.json `
255
+ --env "VERBOSE=1 MAX_RETRIES=5"
256
+ ```
257
+
258
+ **Manual mode**: Print the assembled command(s) and **stop here**. Do not execute anything. Do not proceed to step 8.
259
+ ```
260
+ # To run in foreground:
261
+ $env:VERBOSE = "1"; .\.prizmkit\dev-pipeline\run-refactor.ps1 run .prizmkit/plans/refactor-list.json
262
+
263
+ # To run in background (detached):
264
+ .\.prizmkit\dev-pipeline\launch-refactor-daemon.ps1 start .prizmkit/plans/refactor-list.json --env "VERBOSE=1"
265
+
266
+ # To check status:
267
+ .\.prizmkit\dev-pipeline\run-refactor.ps1 status .prizmkit/plans/refactor-list.json
268
+ ```
269
+
270
+ 8. **Confirm and launch** (Foreground and Background only — Manual mode ends at step 7):
271
+
272
+ Ask: "Ready to launch the refactor pipeline with the above command?"
273
+
274
+ After user confirms, execute the command from step 7.
275
+
276
+ 9. **Post-launch** (depends on execution mode):
277
+
278
+ **If foreground**: Pipeline runs to completion in the terminal. After it finishes:
279
+ - Summarize results: total refactors, succeeded, failed, skipped
280
+ - If all succeeded: each refactor session has already run `prizmkit-retrospective` internally. Ask user what's next.
281
+ - If some failed: show failed refactor IDs and suggest `reset-refactor.ps1 <R-XXX> --clean --run` for a fresh retry
282
+
283
+ **If background daemon**:
284
+ 1. Verify launch:
285
+ ```powershell
286
+ .\.prizmkit\dev-pipeline\launch-refactor-daemon.ps1 status
287
+ ```
288
+ 2. Start log monitoring — Use the PowerShell terminal with `run_in_background: true`:
289
+ ```powershell
290
+ Get-Content -Wait -Tail 50 .prizmkit/state/daemon/refactor-daemon.log
291
+ ```
292
+ 3. Report to user:
293
+ - Pipeline PID
294
+ - Log file location
295
+ - "You can ask me 'refactor status' or 'show refactor logs' at any time"
296
+ - "Closing this session will NOT stop the pipeline"
297
+
298
+ ---
299
+
300
+ #### Intent B: Check Status
301
+
302
+ 1. **Check daemon status**:
303
+ ```powershell
304
+ .\.prizmkit\dev-pipeline\launch-refactor-daemon.ps1 status
305
+ ```
306
+
307
+ 2. **Show refactor-level progress**:
308
+ ```powershell
309
+ Invoke-PrizmPython .prizmkit/dev-pipeline/scripts/update-refactor-status.py `
310
+ --refactor-list .prizmkit/plans/refactor-list.json `
311
+ --state-dir .prizmkit/state/refactor `
312
+ --action status
313
+ ```
314
+
315
+ 3. **Show recent log activity** (last 20 lines):
316
+ ```powershell
317
+ Get-Content -Tail 20 .prizmkit/state/daemon/refactor-daemon.log
318
+ ```
319
+
320
+ 4. **Summarize** to user: total refactors, completed, in-progress, failed, pending.
321
+
322
+ ---
323
+
324
+ #### Intent C: Stop Pipeline
325
+
326
+ 1. **Stop the daemon**:
327
+ ```powershell
328
+ .\.prizmkit\dev-pipeline\launch-refactor-daemon.ps1 stop
329
+ ```
330
+
331
+ 2. **Verify stopped**:
332
+ ```powershell
333
+ .\.prizmkit\dev-pipeline\launch-refactor-daemon.ps1 status
334
+ ```
335
+
336
+ 3. **Inform user**: "Refactor pipeline stopped. State is preserved -- you can resume later with 'start refactoring' and it will pick up where it left off."
337
+
338
+ ---
339
+
340
+ #### Intent D: Show Logs
341
+
342
+ 1. **Check if running**:
343
+ ```powershell
344
+ .\.prizmkit\dev-pipeline\launch-refactor-daemon.ps1 status
345
+ ```
346
+
347
+ 2. **If running** -- Start live tail with PowerShell terminal `run_in_background: true`:
348
+ ```powershell
349
+ Get-Content -Wait -Tail 50 .prizmkit/state/daemon/refactor-daemon.log
350
+ ```
351
+
352
+ 3. **If not running** -- Show last 50 lines:
353
+ ```powershell
354
+ Get-Content -Tail 50 .prizmkit/state/daemon/refactor-daemon.log
355
+ ```
356
+
357
+ 4. **For per-refactor session logs** (when user asks about a specific refactor):
358
+ ```powershell
359
+ # Check refactor status for last session ID
360
+ Get-Content .prizmkit/state/refactor/refactors/<REFACTOR_ID>/status.json -ErrorAction SilentlyContinue
361
+ # Then tail that refactor's session log
362
+ Get-Content -Tail 100 .prizmkit/state/refactor/refactors/<REFACTOR_ID>/sessions/<SESSION_ID>/logs/session.log
363
+ ```
364
+
365
+ ---
366
+
367
+ #### Intent E: Retry Single Refactor
368
+
369
+ When user says "retry R-001" or "clean retry R-001":
370
+
371
+ ```powershell
372
+ .\.prizmkit\dev-pipeline\reset-refactor.ps1 R-001 --clean --run .prizmkit/plans/refactor-list.json
373
+ ```
374
+
375
+ Notes:
376
+ - `reset-refactor.ps1 R-001 --clean --run` performs a clean reset for `R-001` before retrying that refactor — this gives a fresh start.
377
+ - Keep pipeline daemon mode for main run management (`launch-refactor-daemon.ps1`).
378
+
379
+ ---
380
+
381
+ ### Error Handling
382
+
383
+ | Error | Action |
384
+ |-------|--------|
385
+ | `.prizmkit/plans/refactor-list.json` not found | Tell user to run `refactor-planner` skill first |
386
+ | Circular dependencies in refactor list | Fix dependency graph in `.prizmkit/plans/refactor-list.json` before launching |
387
+ | Test baseline failing | Fix failing tests before starting refactoring -- behavior preservation requires a green baseline |
388
+ | JSON parsing failed | Use the bundled Python validation/status scripts instead of external JSON tools |
389
+ | AI CLI not in PATH | Check Codex (`codex`), Claude (`claude`), or CodeBuddy (`cbc`) installation |
390
+ | Refactor pipeline already running | Show status, ask if user wants to stop and restart |
391
+ | PID file stale (process dead) | `launch-refactor-daemon.ps1` auto-cleans, retry start |
392
+ | Launch failed (process died immediately) | Show last 20 lines of log: `Get-Content -Tail 20 .prizmkit/state/daemon/refactor-daemon.log` |
393
+ | Refactor stuck/blocked | Use `reset-refactor.ps1 <R-XXX> --clean --run` for a fresh retry |
394
+ | All refactors blocked/failed | Show status, suggest recovery: `.\.prizmkit\dev-pipeline\reset-refactor.ps1 <R-XXX> --clean --run .prizmkit/plans/refactor-list.json` |
395
+ | `playwright-cli` not installed | Browser verification skipped for playwright refactors (non-blocking). Suggest: `npm install -g @playwright/cli@latest; playwright-cli install --skills` |
396
+ | `opencli` not installed | Browser verification skipped for opencli refactors (non-blocking). Install opencli for Chrome session-based browser verification |
397
+ | PowerShell execution policy blocks script | Run `Set-ExecutionPolicy -Scope Process Bypass` for the current terminal |
398
+
399
+ ### Integration Notes
400
+
401
+ - **After refactor-planner**: This is the natural next step. When user finishes refactor planning and has `.prizmkit/plans/refactor-list.json`, suggest launching the refactor pipeline.
402
+ - **Session independence**: The pipeline runs completely detached. User can close the AI CLI session, open a new session later, and use this skill to check progress or stop the pipeline.
403
+ - **Single instance**: Only one refactor pipeline can run at a time. The PID file prevents duplicates.
404
+ - **Pipeline coexistence**: Refactor pipeline uses `.prizmkit/state/refactor/` separate from `.prizmkit/state/features/` (features) and `.prizmkit/state/bugfix/` (bugs), so all three pipelines can run simultaneously without conflict.
405
+ - **State preservation**: Stopping and restarting the pipeline resumes from where it left off -- completed refactors are not re-run.
406
+ - **HANDOFF**: After pipeline completes all refactors, each session has already run `prizmkit-retrospective` internally. Ask user what's next.