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,540 @@
1
+ ---
2
+ name: "refactor-planner"
3
+ description: "Interactive refactoring planner. Understands refactoring intent through dialogue, analyzes current code structure, produces validated .prizmkit/plans/refactor-list.json for dev-pipeline execution. Use whenever users discuss refactoring planning, code restructuring scope, or preparing .prizmkit/plans/refactor-list.json."
4
+ ---
5
+
6
+ # refactor planner
7
+
8
+ Plan executable refactoring items for dev-pipeline:
9
+ - **Scope Assessment**: analyze current code structure and identify refactoring targets
10
+ - **Item Decomposition**: break refactoring goals into well-ordered, behavior-preserving items
11
+
12
+ Always produce a validated `.prizmkit/plans/refactor-list.json` that conforms to `dev-pipeline-refactor-list-v1`.
13
+
14
+ ## Invocation Commitment (Hard Rule)
15
+
16
+ **When the user invokes `/refactor-planner`, you MUST execute the refactor-planner workflow.** You must NEVER:
17
+ - Decide on the user's behalf that the task "doesn't need refactor-planner"
18
+ - Skip refactor-planner to jump directly to refactor-workflow or any other skill
19
+ - Bypass the interactive phases because you judge the task to be "simple" or "obvious"
20
+
21
+ If you believe the task is better suited for a different workflow (e.g., single-file refactor via `/refactor-workflow`), you MUST:
22
+ 1. **Explain why** you think a different path is more appropriate
23
+ 2. **Ask the user explicitly** whether they want to switch or continue with refactor-planner
24
+ 3. **Only switch if the user confirms** — otherwise proceed with refactor-planner as invoked
25
+
26
+ The user chose this skill intentionally. Respect that choice.
27
+
28
+ ## Scope Boundary (Hard Rule)
29
+
30
+ **This skill is PLANNING ONLY.** You must NEVER:
31
+ - Create, modify, or delete source code files (*.js, *.ts, *.py, *.go, *.html, *.css, etc.)
32
+ - Execute refactoring operations (rename, move, extract, etc.)
33
+ - Run build/install/test commands
34
+ - Execute any implementation action beyond writing `.prizmkit/plans/refactor-list.json`
35
+
36
+ **Your ONLY writable outputs are:**
37
+ 1. `.prizmkit/plans/refactor-list.json` (`.prizmkit/plans/`)
38
+ 2. Draft backups in `.prizmkit/plans/` (e.g., `refactor-list.draft.json`)
39
+
40
+ **After planning is complete**, you MUST:
41
+ 1. Present the summary and recommended next step
42
+ 2. **Ask the user explicitly** whether they want to proceed to execution
43
+ 3. If the user agrees → recommend invoking `refactor-pipeline-launcher` (do NOT execute it yourself)
44
+ 4. If the user wants to adjust → continue refining `.prizmkit/plans/refactor-list.json`
45
+ 5. **NEVER auto-execute** the pipeline, launcher, or any implementation step
46
+
47
+ ## User-Provided Content Priority (Hard Rule)
48
+
49
+ When the user provides detailed specifications, rules, or implementation requirements:
50
+
51
+ 1. **Verbatim preservation**: The user's exact wording MUST be preserved in `description` and `acceptance_criteria` fields. Do NOT paraphrase, summarize, abstract, or simplify.
52
+ 2. **No autonomous simplification**: A 200-word user specification must NOT become a 30-word description. Match the detail level of the user's input.
53
+ 3. **Clarify, don't assume**: If any user-provided rule is ambiguous or potentially conflicts with another, ASK the user to clarify. No limit on clarification rounds. Do NOT proceed with unresolved ambiguities.
54
+ 4. **Populate `user_context`**: ALL user-provided materials (supplementary content, rules, file path references) MUST be written into the `user_context` array of each refactor item in the generated `.prizmkit/plans/refactor-list.json`. Format:
55
+ - Supplementary content or rules → store as-is (verbatim text)
56
+ - File references → store as path string, e.g. `src/auth/login.ts:42-78` or `src/utils/validate.ts — focus on validateEmail function`
57
+
58
+ ## When to Use
59
+ - "Plan refactoring", "Scope a restructuring"
60
+ - "Prepare .prizmkit/plans/refactor-list.json", "Prepare dev-pipeline input for refactoring"
61
+ - "Assess code for refactoring", "Identify refactoring targets"
62
+ - "Plan a code migration", "Decompose a large refactor"
63
+
64
+ Do NOT use this skill when the user wants to:
65
+ - Execute a single refactor directly (use `refactor-workflow`)
66
+ - Plan new features (use `feature-planner`)
67
+ - Fix bugs (use `bug-planner`)
68
+
69
+ ## Resource Loading Rules (Mandatory)
70
+
71
+ 1. **Read decomposition guide**:
72
+ - Read `${SKILL_DIR}/assets/planning-guide.md` for decomposition patterns and description guidelines
73
+
74
+ 2. **Read scope assessment reference**:
75
+ - Read `${SKILL_DIR}/references/refactor-scoping-guide.md` for scope classification and risk assessment
76
+
77
+ 3. **Read behavior preservation reference**:
78
+ - Read `${SKILL_DIR}/references/behavior-preservation.md` for preservation strategy selection
79
+
80
+ 4. **Load on-demand references when triggered**:
81
+ - Validation errors or interrupted session -> read error recovery patterns (similar to feature-planner)
82
+
83
+ 5. **Define the PowerShell Python helper before running validation scripts**:
84
+ ```powershell
85
+ function Invoke-PrizmPython {
86
+ param([Parameter(ValueFromRemainingArguments = $true)][string[]]$Arguments)
87
+ $python = Get-Command python -ErrorAction SilentlyContinue
88
+ if ($python) {
89
+ & $python.Source -c 'import sys; raise SystemExit(0 if sys.version_info[0] == 3 else 1)' *> $null
90
+ if ($LASTEXITCODE -eq 0) {
91
+ & $python.Source @Arguments
92
+ return
93
+ }
94
+ }
95
+ $py = Get-Command py -ErrorAction SilentlyContinue
96
+ if ($py) {
97
+ & $py.Source -3 -c 'import sys; raise SystemExit(0 if sys.version_info[0] == 3 else 1)' *> $null
98
+ if ($LASTEXITCODE -eq 0) {
99
+ & $py.Source -3 @Arguments
100
+ return
101
+ }
102
+ }
103
+ throw "Python 3 is required. Install Python and ensure python or py is in PATH."
104
+ }
105
+ ```
106
+
107
+ 6. **Always validate output via script**:
108
+ - Run:
109
+ ```powershell
110
+ Invoke-PrizmPython ${SKILL_DIR}/scripts/validate-and-generate-refactor.py validate --input <output-path>
111
+ ```
112
+
113
+ 7. **Use script output as source of truth**:
114
+ - If validation fails, **MUST** fix and re-run until pass
115
+
116
+ ## Prerequisites
117
+
118
+ Before questions, check optional context files (never block if absent):
119
+ - `.prizmkit/prizm-docs/root.prizm` (architecture/project context)
120
+ - `.prizmkit/config.json` (existing stack preferences and detected tech stack)
121
+ - Existing test suite (critical for behavior preservation assessment)
122
+ - Existing `.prizmkit/plans/refactor-list.json` (if appending additional items)
123
+ - If `.prizmkit/prizm-docs/root.prizm` is absent and the project has existing source code, scan the directory structure:
124
+ ```powershell
125
+ Get-ChildItem -Path . -Directory -Recurse -Depth 2 -ErrorAction SilentlyContinue |
126
+ Where-Object { $_.FullName -notmatch '\\(node_modules|\.git|dist|build|__pycache__|vendor)(\\|$)' } |
127
+ Select-Object -ExpandProperty FullName
128
+ ```
129
+
130
+ **Test suite detection:**
131
+ - Scan for test runner config files (`jest.config.*`, `vitest.config.*`, `pytest.ini`, `.mocharc.*`, `karma.conf.*`)
132
+ - If no test suite detected, WARN: "No test suite found. Behavior preservation will rely on manual verification. Consider writing tests before refactoring."
133
+ - Record test suite status in planning context for downstream use
134
+
135
+ ## Operation Modes
136
+
137
+ ### Mode A: Interactive (default)
138
+ Full Q&A -> code analysis -> item generation. Useful when starting from scratch or exploring refactoring scope.
139
+
140
+ ### Mode B: From Analysis
141
+ When an existing analysis report (e.g., `refactor-analysis.md`) is available, skip the analysis phase and proceed directly to item decomposition.
142
+
143
+ ### Mode C: Validate
144
+ Validate an existing `.prizmkit/plans/refactor-list.json` without regenerating it:
145
+ ```powershell
146
+ Invoke-PrizmPython ${SKILL_DIR}/scripts/validate-and-generate-refactor.py validate --input .prizmkit/plans/refactor-list.json
147
+ ```
148
+
149
+ ### Mode D: Summary
150
+ Display a human-readable summary of an existing `.prizmkit/plans/refactor-list.json`:
151
+ - Item count, dependency graph, complexity distribution, behavior preservation strategies
152
+
153
+ ## Interactive Mode — Core Workflow
154
+
155
+ Execute the planning workflow in conversation mode with mandatory checkpoints:
156
+
157
+ ### Phase 1: Project Context
158
+
159
+ **Goal**: Understand the current codebase structure and tech stack.
160
+
161
+ 1. Read `.prizmkit/prizm-docs/root.prizm` and relevant L1 docs
162
+ 2. Read `.prizmkit/config.json` for tech stack info
163
+ 3. Identify existing test suite and coverage
164
+ 4. Summarize project context to the user: "Here's what I found about your project..."
165
+ 5. **Collect reference materials** — **Upfront Material Detection (Hard Rule)**: If the user has already provided materials (file paths, URLs, rules, specifications, code snippets) in the same message that invoked this skill: (a) Acknowledge what was received: "I received the following materials: [list]"; (b) Read/fetch all provided materials immediately; (c) You MUST still ask: "Are there any additional materials you'd like to provide?"; (d) NEVER skip this collection step just because the user already provided some materials.
166
+
167
+ If the user has NOT provided any materials upfront, explicitly ask whether they have any supplementary materials for you to review before planning the refactoring:
168
+ > "Do you have any reference materials I should review before planning the refactoring? This can include:
169
+ > - **Code paths** — specific files or directories that are refactoring targets or dependencies
170
+ > - **Documents** — design docs, architecture proposals, refactoring RFCs, or technical debt analyses
171
+ > - **Knowledge docs** — `.prizmkit/prizm-docs/` files, README files, or internal wiki pages for the affected area
172
+ > - **Images** — architecture diagrams, dependency graphs, or whiteboard photos
173
+ > - **Web links** — reference implementations, design pattern articles, or migration guides
174
+ >
175
+ > If none, we'll proceed with what's available in the codebase."
176
+
177
+ If the user provides materials, read/fetch them all before proceeding to Phase 2. For web links, use web fetch to retrieve and analyze the content. For images, read and analyze them visually. This context is critical for refactoring — understanding the target architecture and constraints prevents risky structural changes.
178
+
179
+ **CHECKPOINT CP-RP-0**: Project context loaded, tech stack and test suite status known.
180
+
181
+ ### Phase 2: Refactor Goal Collection
182
+
183
+ **Goal**: Through interactive dialogue, understand what the user wants to refactor and why.
184
+
185
+ Support 4 input formats (users may mix formats):
186
+
187
+ **Format A — Natural language**:
188
+ > "This module is too large and hard to maintain"
189
+ > "The auth logic is scattered across too many files"
190
+
191
+ **Format B — Code smell pointer**:
192
+ > "src/api/handler.js is 800 lines"
193
+ > "There are 5 files that all implement similar validation logic"
194
+
195
+ **Format C — Architecture migration**:
196
+ > "Convert callbacks to async/await"
197
+ > "Migrate from class components to hooks"
198
+ > "Move from monolith to modular architecture"
199
+
200
+ **Format D — Dependency decoupling**:
201
+ > "There's a circular dependency between auth and user modules"
202
+ > "The database layer is tightly coupled to the HTTP layer"
203
+
204
+ For each input, ask clarifying questions:
205
+ - What is the specific target (files, modules, patterns)?
206
+ - What is the desired end state?
207
+ - Are there constraints (must preserve API, must not touch certain files)?
208
+ - What is the motivation (maintainability, performance, testability)?
209
+
210
+ Continue collecting goals until the user says they're done. There is no limit on rounds.
211
+
212
+ **CHECKPOINT CP-RP-1**: All refactoring goals collected and understood.
213
+
214
+ ### Phase 3: Code Analysis
215
+
216
+ **Goal**: Analyze the target code to inform item decomposition.
217
+
218
+ Dispatch **parallel Agent reads** of target files:
219
+ - **Agent A (Structure)**: File inventory, dependency graph, module boundaries, public API surface
220
+ - **Agent B (Quality)**: Code smells, complexity hotspots, duplication, coupling metrics
221
+ - **Agent C (Tests)**: Test coverage of target areas, existing test patterns, behavior contracts
222
+
223
+ Present consolidated findings:
224
+ ```
225
+ ## Code Analysis Results
226
+
227
+ ### Structure
228
+ - [file inventory, dependency graph]
229
+
230
+ ### Quality Issues
231
+ - [code smells, complexity hotspots, duplication]
232
+
233
+ ### Test Coverage
234
+ - [test status for target areas]
235
+ - [behavior contracts that must be preserved]
236
+
237
+ ### Recommended Decomposition
238
+ - [suggested refactoring order based on findings]
239
+ ```
240
+
241
+ Ask: "Based on this analysis, here's how I'd recommend decomposing the refactoring. Does this align with your expectations?"
242
+
243
+ **CHECKPOINT CP-RP-2**: Code analysis complete, user agrees with recommended approach.
244
+
245
+ ### Phase 4: Item Decomposition
246
+
247
+ **Goal**: Split refactoring goals into executable, well-ordered items.
248
+
249
+ Read `${SKILL_DIR}/assets/planning-guide.md` for decomposition patterns and dependency ordering rules.
250
+
251
+ For each refactoring goal:
252
+ 1. Identify atomic refactoring operations
253
+ 2. Determine inter-item dependencies (safe renames first, structural changes later)
254
+ 3. Assess complexity per item (file count, cross-module scope, test coverage)
255
+ 4. Assign behavior preservation strategy per item (read `${SKILL_DIR}/references/behavior-preservation.md`)
256
+
257
+ **CHECKPOINT CP-RP-3**: All items decomposed with dependencies and preservation strategies.
258
+
259
+ ### Phase 5: Per-Item Confirmation
260
+
261
+ **Goal**: Present each item to the user for confirmation, modification, or rejection.
262
+
263
+ For each item, display:
264
+
265
+ ```
266
+ Refactor Item R-001:
267
+ Title: [title]
268
+ Type: [extract/rename/restructure/simplify/decouple/migrate]
269
+ Scope: [files list]
270
+ Priority: [critical/high/medium/low]
271
+ Complexity: [low/medium/high]
272
+ Behavior Preservation: [test-gate/snapshot/manual]
273
+ Acceptance Criteria:
274
+ - [criterion 1]
275
+ - [criterion 2]
276
+ Dependencies: [none / R-002, R-003]
277
+
278
+ Confirm? (Y/modify/skip)
279
+ ```
280
+
281
+ - **Y**: Accept item as-is
282
+ - **modify**: User provides changes, update item, re-display for confirmation
283
+ - **skip**: Remove item from the list
284
+
285
+ Continue until all items are confirmed or skipped.
286
+
287
+ **CHECKPOINT CP-RP-4**: All items confirmed by user.
288
+
289
+ ### Phase 6: Completeness Review
290
+
291
+ **Goal**: Check the full item set for consistency, gaps, and headless execution readiness.
292
+
293
+ 1. **Dependency ordering check**: Verify items form a valid DAG (no cycles). Items should be ordered: safe renames -> extract/inline -> structural changes -> migrations
294
+ 2. **Behavior preservation check**: Every item must have a declared preservation strategy. Flag any item with `manual` strategy and no test coverage.
295
+ 3. **Gap detection**: Are there intermediate steps needed between items? Does item A's output match item B's input assumption?
296
+ 4. **Cross-module impact**: Do any items affect modules outside the declared scope?
297
+ 5. **Headless Execution Readiness**: The refactor pipeline runs each item through an autonomous AI session with NO human interaction. For each item, verify:
298
+ - **Scope clarity**: Are all affected files explicitly listed? The AI must know exactly where to look.
299
+ - **Refactoring instructions**: Is the description specific enough to execute without ambiguity?
300
+ - ❌ "Clean up the utils module" — what exactly should change?
301
+ - ✅ "Extract validation functions (validateEmail, validatePhone, validateUrl) from src/utils/helpers.ts into src/utils/validation.ts. Update all 12 import sites. Preserve existing function signatures."
302
+ - **Behavior preservation**: Is it clear what tests to run and what behavior must be preserved?
303
+ - **Dependency context**: If item depends on earlier refactors, does the description reference what changed?
304
+
305
+ Present review summary:
306
+ ```
307
+ Item | Deps Valid | Preservation | Gaps | Status
308
+ R-001 | OK | test-gate | - | Ready
309
+ R-002 | OK | test-gate | - | Ready
310
+ R-003 | OK | manual | No test coverage| Needs attention
311
+ R-004 | OK | snapshot | - | Ready
312
+ ```
313
+
314
+ If issues found, discuss with user and resolve before proceeding.
315
+
316
+ **CHECKPOINT CP-RP-5**: Completeness review passed, all issues resolved.
317
+
318
+ ### Phase 7: Generate & Validate
319
+
320
+ **Goal**: Produce `.prizmkit/plans/refactor-list.json` and validate it.
321
+
322
+ **IMPORTANT: Do NOT hand-write the final JSON file.** Instead:
323
+ 1. Write a draft JSON to `.prizmkit/plans/refactor-list.draft.json` with all collected refactor data.
324
+ 2. Call the generate script to validate and produce the final file:
325
+ ```powershell
326
+ Invoke-PrizmPython ${SKILL_DIR}/scripts/validate-and-generate-refactor.py generate --input .prizmkit/plans/refactor-list.draft.json --output .prizmkit/plans/refactor-list.json
327
+ ```
328
+ The script fills in defaults (`$schema`, `created_at`, `created_by`), validates all fields, and writes the final file only if validation passes.
329
+ 3. If validation fails -> fix the draft and retry (max 3 attempts)
330
+ 4. If validation passes -> present final summary
331
+
332
+ **CHECKPOINT CP-RP-6**: `.prizmkit/plans/refactor-list.json` generated and validated.
333
+
334
+ ## Checkpoints (Mandatory Gates)
335
+
336
+ | Checkpoint | Artifact/State | Criteria | Phase |
337
+ |-----------|----------------|----------|-------|
338
+ | **CP-RP-0** | Project Context | Tech stack, test suite status, .prizmkit/prizm-docs loaded | 1 |
339
+ | **CP-RP-1** | Goals Collected | All refactoring goals understood, no open ambiguities | 2 |
340
+ | **CP-RP-2** | Code Analyzed | Analysis complete, user agrees with approach | 3 |
341
+ | **CP-RP-3** | Items Decomposed | All items have deps, complexity, preservation strategy | 4 |
342
+ | **CP-RP-4** | Items Confirmed | User confirmed/modified/skipped each item | 5 |
343
+ | **CP-RP-5** | Completeness OK | DAG valid, preservation strategies declared, no gaps | 6 |
344
+ | **CP-RP-6** | Output Valid | `.prizmkit/plans/refactor-list.json` passes validation script | 7 |
345
+
346
+ **Resume Detection**: If existing artifacts found (partial `.prizmkit/plans/refactor-list.json`, draft `refactor-list.draft.json` in `.prizmkit/plans/`), offer to resume from the appropriate checkpoint.
347
+
348
+ ## Output Rules
349
+
350
+ `.prizmkit/plans/refactor-list.json` must satisfy:
351
+ - `$schema` = `dev-pipeline-refactor-list-v1`
352
+ - Non-empty `refactors` array
353
+ - Sequential IDs: `R-001`, `R-002`, ...
354
+ - Valid dependency DAG (no cycles)
355
+ - Each item has a declared `behavior_preservation` object with `strategy` field: `"test-gate"`, `"snapshot"`, or `"manual"`. Optional fields: `existing_tests` (boolean), `new_tests_needed` (string array). See `.prizmkit/dev-pipeline/templates/refactor-list-schema.json` for the full schema.
356
+ - `priority` must be a string: `"critical"`, `"high"`, `"medium"`, or `"low"`
357
+ - New items default `status: "pending"`
358
+ - English titles for stable slug generation
359
+ - `type` field must be one of: `extract`, `rename`, `restructure`, `simplify`, `decouple`, `migrate`
360
+ - Descriptions minimum 15 words (error). Recommended: 30/50/80 words for low/medium/high complexity (warning).
361
+ - `model` field is optional — omitting it means the pipeline uses $MODEL env or CLI default
362
+ - `scope` object with nested structure: `files` array (target file paths) and `modules` array (module names)
363
+
364
+ ## Adversarial Critic Defaults
365
+
366
+ Set default critic fields for each refactor item. The user can override per-item.
367
+
368
+ | Priority | Complexity | `critic` | `critic_count` |
369
+ |----------|-----------|----------|----------------|
370
+ | critical | high | `true` | `3` |
371
+ | critical | medium/low | `true` | `1` |
372
+ | high | high | `true` | `1` |
373
+ | other combinations | any | `false` | (omitted) |
374
+
375
+ ---
376
+
377
+ ## Fast Path
378
+
379
+ For simple refactoring with minimal scope:
380
+
381
+ ### Eligibility Criteria (ALL must apply)
382
+ - 1-2 refactor items only
383
+ - Complexity: `low` or `medium` for all items
384
+ - No cross-module impact (all items within same module)
385
+ - Well-known refactoring pattern (rename, extract method/class, inline)
386
+ - Existing test coverage for target area
387
+
388
+ ### Fast Path Workflow
389
+ 1. Confirm refactoring scope with user
390
+ 2. **User confirmation (mandatory)** — Use `AskUserQuestion` to present interactive selectable options:
391
+
392
+ ```
393
+ AskUserQuestion:
394
+ question: "This qualifies for fast-path (simple refactoring). How would you like to proceed?"
395
+ header: "Approach"
396
+ options:
397
+ - label: "Fast-path"
398
+ description: "Skip detailed analysis, draft refactor items directly and add to refactor-list.json"
399
+ - label: "Full workflow"
400
+ description: "Use the complete planning workflow with detailed code analysis"
401
+ - label: "Implement directly"
402
+ description: "Skip the task list entirely and implement the refactoring right now using /prizmkit-plan + /prizmkit-implement"
403
+ ```
404
+
405
+ - **Fast-path** → Continue with fast-path workflow below
406
+ - **Full workflow** → Exit fast path, use full workflow from Phase 2
407
+ - **Implement directly** → Invoke `/prizmkit-plan` directly to create spec + plan, then `/prizmkit-implement` to execute. Do NOT add to `.prizmkit/plans/refactor-list.json`
408
+
409
+ **NEVER proceed without explicit user selection via `AskUserQuestion`. Do NOT render options as plain text — the user must be able to click/select.**
410
+ 3. Draft items (title + type + scope + description + acceptance_criteria + behavior_preservation + dependencies)
411
+ 4. Write draft to `.prizmkit/plans/refactor-list.draft.json`, then call the generate script:
412
+ ```powershell
413
+ Invoke-PrizmPython ${SKILL_DIR}/scripts/validate-and-generate-refactor.py generate --input .prizmkit/plans/refactor-list.draft.json --output .prizmkit/plans/refactor-list.json
414
+ ```
415
+ 5. If valid -> summarize and recommend next step
416
+ 6. If invalid -> apply fixes to the draft, re-run generate (max 2 attempts, then escalate to full workflow)
417
+
418
+ ### When NOT to Use Fast Path
419
+ - More than 2 refactor items
420
+ - Any item with `high` complexity
421
+ - Cross-module impact
422
+ - Architecture migration patterns (Format C goals)
423
+ - No existing test coverage for target area
424
+
425
+ ### Example Fast Path Session
426
+ ```
427
+ User: "Rename the auth middleware function from checkAuth to requireAuth everywhere."
428
+ AI: [Detects simple rename, single module]
429
+ AI: [Qualifies for fast path: 1 item, low complexity, no cross-module impact]
430
+ AI: [Uses AskUserQuestion with options: "Fast-path", "Full workflow", "Implement directly"]
431
+ User: [Selects "Fast-path"]
432
+ AI: "Drafting R-001..."
433
+ AI: [Validates immediately]
434
+ AI: "Ready to proceed to dev-pipeline."
435
+ ```
436
+
437
+ ## Browser Verification
438
+
439
+ **Browser verification is a feature-pipeline capability only.** Refactors use `behavior_preservation` strategy instead to ensure no external behavior changes:
440
+
441
+ - `strategy: test-gate` — Rely on existing test suite. Pipeline runs tests before and after refactoring.
442
+ - `strategy: snapshot` — Compare behavior before/after refactoring using executable snapshots (outputs, API responses, side effects)
443
+ - `strategy: manual` — Require human verification that behavior is preserved
444
+
445
+ For refactors that modify UI code (e.g., component restructuring), the test-gate or snapshot strategy ensures visual appearance is preserved. You can optionally note browser verification needs in your description or acceptance criteria:
446
+
447
+ Example:
448
+ ```
449
+ Refactor Title: Extract UserProfile component from AccountSettings
450
+ Type: extract
451
+ Strategy: snapshot
452
+ Acceptance Criteria:
453
+ 1. UserProfile component renders identically to inline version (compare snapshots)
454
+ 2. All props are correctly forwarded (unit tests pass)
455
+ 3. No visual regression (screenshot comparison)
456
+ 4. Component is reusable in other views
457
+ ```
458
+
459
+ The refactor pipeline AI will use the snapshot strategy to verify external behavior is preserved during refactoring.
460
+
461
+ ---
462
+
463
+ ## Refactoring-Specific Features
464
+
465
+ ### Behavior Preservation Check
466
+ Every item MUST declare a behavior preservation strategy. Read `${SKILL_DIR}/references/behavior-preservation.md` for strategy details.
467
+
468
+ | Strategy | When to Use |
469
+ |----------|-------------|
470
+ | `test-gate` | Target area has good test coverage. Run full test suite after each change. |
471
+ | `snapshot` | Compare output/state before and after. Useful when tests are insufficient but behavior is observable. |
472
+ | `manual` | Human verification required. Last resort when neither tests nor snapshots are feasible. |
473
+
474
+ Flag items using `manual` strategy prominently — they carry the highest risk of behavior regression.
475
+
476
+ ### Dependency Ordering
477
+ Auto-detect inter-item dependencies and enforce safe ordering:
478
+ 1. **Safe renames** first (lowest risk, no structural change)
479
+ 2. **Extract/inline** operations (moderate risk, changes module boundaries)
480
+ 3. **Structural changes** (higher risk, reorganizes architecture)
481
+ 4. **Migrations** last (highest risk, changes patterns/paradigms)
482
+
483
+ ### Complexity Assessment
484
+ Assess each item's complexity based on:
485
+ - **File count**: 1-2 files = low, 3-5 files = medium, 6+ files = high
486
+ - **Cross-module scope**: same module = low, 2 modules = medium, 3+ modules = high
487
+ - **Test coverage**: high coverage = reduces complexity, low coverage = increases complexity
488
+ - **Pattern familiarity**: well-known pattern = low, novel restructuring = high
489
+
490
+ Take the highest of these individual assessments as the item's complexity.
491
+
492
+ ## Next-Step Execution Policy (after planning)
493
+
494
+ Recommend invoking `refactor-pipeline-launcher` to configure and launch the dev-pipeline. Do NOT recommend running shell scripts directly — that is the launcher's responsibility.
495
+
496
+ ## Error Recovery & Resume
497
+
498
+ Key behaviors:
499
+ - Warnings only -> proceed with user approval
500
+ - Critical errors -> group by type, auto-fix where possible, max 3 total attempts
501
+ - Interrupted session -> detect checkpoint from existing artifacts, offer resume or restart
502
+ - `.prizmkit/plans/refactor-list.json` MUST be written to `.prizmkit/plans/` (project root level: `./{root}/.prizmkit/plans/refactor-list.json`)
503
+
504
+ ### Resume Detection
505
+
506
+ | Artifact Found | Resume From |
507
+ |---------------|------------|
508
+ | Nothing | Phase 1: Project Context |
509
+ | Draft in `.prizmkit/plans/` | Phase matching draft state |
510
+ | Partial `.prizmkit/plans/refactor-list.json` | Phase 6: Completeness Review |
511
+ | Valid `.prizmkit/plans/refactor-list.json` | Mode D: Summary |
512
+
513
+ ## Session Exit Gate
514
+
515
+ Prevent accidental session exit without deliverable completion.
516
+
517
+ ### Trigger Conditions
518
+ Activate exit gate when ALL are true:
519
+ - User invoked `/refactor-planner` (not just mentioned refactoring)
520
+ - Current phase < Phase 7 (validation not yet passed)
521
+ - No valid `.prizmkit/plans/refactor-list.json` has been written in this session
522
+
523
+ ### Gate Behavior
524
+ When the session appears to be ending:
525
+ 1. **Remind**: "You set out to produce `.prizmkit/plans/refactor-list.json` but we haven't completed it yet."
526
+ 2. **Offer 3 options**:
527
+ - **(a) Continue to completion** — resume from current phase
528
+ - **(b) Save draft & exit** — write current progress as draft, exit session
529
+ - **(c) Abandon** — exit without saving
530
+ 3. **If (b)**: Write draft and remind: "This is a draft, not validated. Run `/refactor-planner` again to resume."
531
+ 4. **If (c)**: Accept without further prompting.
532
+
533
+ ## Handoff Message Template
534
+
535
+ After successful validation, report:
536
+ 1. Output file path
537
+ 2. Total refactor items
538
+ 3. Dependency ordering highlights (which items must run first)
539
+ 4. Behavior preservation strategy distribution (N items with test-gate, M with snapshot, etc.)
540
+ 5. Recommended next action: `refactor-pipeline-launcher`