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.
- package/bin/create-prizmkit.js +8 -6
- package/bundled/VERSION.json +3 -3
- package/bundled/adapters/codex/agent-adapter.js +38 -0
- package/bundled/adapters/codex/paths.js +27 -0
- package/bundled/adapters/codex/rules-adapter.js +30 -0
- package/bundled/adapters/codex/settings-adapter.js +27 -0
- package/bundled/adapters/codex/skill-adapter.js +65 -0
- package/bundled/adapters/codex/team-adapter.js +37 -0
- package/bundled/dev-pipeline/.env.example +2 -1
- package/bundled/dev-pipeline/README.md +10 -7
- package/bundled/dev-pipeline/lib/common.sh +278 -37
- package/bundled/dev-pipeline/run-bugfix.sh +10 -61
- package/bundled/dev-pipeline/run-feature.sh +10 -78
- package/bundled/dev-pipeline/run-recovery.sh +10 -46
- package/bundled/dev-pipeline/run-refactor.sh +10 -61
- package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +17 -7
- package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +9 -3
- package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +9 -3
- package/bundled/dev-pipeline/scripts/utils.py +6 -4
- package/bundled/dev-pipeline-windows/.env.example +28 -0
- package/bundled/dev-pipeline-windows/README.md +30 -0
- package/bundled/dev-pipeline-windows/SCHEMA_ANALYSIS.md +525 -0
- package/bundled/dev-pipeline-windows/assets/feature-list-example.json +146 -0
- package/bundled/dev-pipeline-windows/assets/prizm-dev-team-integration.md +138 -0
- package/bundled/dev-pipeline-windows/launch-bugfix-daemon.ps1 +9 -0
- package/bundled/dev-pipeline-windows/launch-feature-daemon.ps1 +9 -0
- package/bundled/dev-pipeline-windows/launch-refactor-daemon.ps1 +9 -0
- package/bundled/dev-pipeline-windows/lib/common.ps1 +432 -0
- package/bundled/dev-pipeline-windows/lib/daemon.ps1 +140 -0
- package/bundled/dev-pipeline-windows/lib/pipeline.ps1 +446 -0
- package/bundled/dev-pipeline-windows/lib/reset.ps1 +87 -0
- package/bundled/dev-pipeline-windows/reset-bug.ps1 +9 -0
- package/bundled/dev-pipeline-windows/reset-feature.ps1 +9 -0
- package/bundled/dev-pipeline-windows/reset-refactor.ps1 +9 -0
- package/bundled/dev-pipeline-windows/run-bugfix.ps1 +9 -0
- package/bundled/dev-pipeline-windows/run-feature.ps1 +9 -0
- package/bundled/dev-pipeline-windows/run-recovery.ps1 +76 -0
- package/bundled/dev-pipeline-windows/run-refactor.ps1 +9 -0
- package/bundled/dev-pipeline-windows/scripts/check-session-status.py +228 -0
- package/bundled/dev-pipeline-windows/scripts/cleanup-logs.py +192 -0
- package/bundled/dev-pipeline-windows/scripts/detect-stuck.py +530 -0
- package/bundled/dev-pipeline-windows/scripts/generate-bootstrap-prompt.py +1737 -0
- package/bundled/dev-pipeline-windows/scripts/generate-bugfix-prompt.py +685 -0
- package/bundled/dev-pipeline-windows/scripts/generate-recovery-prompt.py +805 -0
- package/bundled/dev-pipeline-windows/scripts/generate-refactor-prompt.py +763 -0
- package/bundled/dev-pipeline-windows/scripts/init-bugfix-pipeline.py +316 -0
- package/bundled/dev-pipeline-windows/scripts/init-dev-team.py +134 -0
- package/bundled/dev-pipeline-windows/scripts/init-pipeline.py +380 -0
- package/bundled/dev-pipeline-windows/scripts/init-refactor-pipeline.py +399 -0
- package/bundled/dev-pipeline-windows/scripts/parse-stream-progress.py +388 -0
- package/bundled/dev-pipeline-windows/scripts/patch-completion-notes.py +191 -0
- package/bundled/dev-pipeline-windows/scripts/update-bug-status.py +864 -0
- package/bundled/dev-pipeline-windows/scripts/update-checkpoint.py +173 -0
- package/bundled/dev-pipeline-windows/scripts/update-feature-status.py +1501 -0
- package/bundled/dev-pipeline-windows/scripts/update-refactor-status.py +1073 -0
- package/bundled/dev-pipeline-windows/scripts/utils.py +542 -0
- package/bundled/dev-pipeline-windows/templates/agent-prompts/critic-plan-challenge.md +7 -0
- package/bundled/dev-pipeline-windows/templates/agent-prompts/dev-fix.md +7 -0
- package/bundled/dev-pipeline-windows/templates/agent-prompts/dev-implement.md +30 -0
- package/bundled/dev-pipeline-windows/templates/agent-prompts/dev-resume.md +5 -0
- package/bundled/dev-pipeline-windows/templates/agent-prompts/reviewer-review.md +7 -0
- package/bundled/dev-pipeline-windows/templates/bootstrap-prompt.md +46 -0
- package/bundled/dev-pipeline-windows/templates/bootstrap-tier1.md +43 -0
- package/bundled/dev-pipeline-windows/templates/bootstrap-tier2.md +43 -0
- package/bundled/dev-pipeline-windows/templates/bootstrap-tier3.md +43 -0
- package/bundled/dev-pipeline-windows/templates/bug-fix-list-schema.json +263 -0
- package/bundled/dev-pipeline-windows/templates/bugfix-bootstrap-prompt.md +320 -0
- package/bundled/dev-pipeline-windows/templates/feature-list-schema.json +237 -0
- package/bundled/dev-pipeline-windows/templates/refactor-bootstrap-prompt.md +331 -0
- package/bundled/dev-pipeline-windows/templates/refactor-list-schema.json +270 -0
- package/bundled/dev-pipeline-windows/templates/sections/ac-verification-checklist.md +13 -0
- package/bundled/dev-pipeline-windows/templates/sections/checkpoint-system.md +91 -0
- package/bundled/dev-pipeline-windows/templates/sections/context-budget-rules.md +33 -0
- package/bundled/dev-pipeline-windows/templates/sections/critical-paths-agent.md +10 -0
- package/bundled/dev-pipeline-windows/templates/sections/critical-paths-full.md +12 -0
- package/bundled/dev-pipeline-windows/templates/sections/critical-paths-lite.md +7 -0
- package/bundled/dev-pipeline-windows/templates/sections/directory-convention-agent.md +8 -0
- package/bundled/dev-pipeline-windows/templates/sections/directory-convention-full.md +9 -0
- package/bundled/dev-pipeline-windows/templates/sections/directory-convention-lite.md +6 -0
- package/bundled/dev-pipeline-windows/templates/sections/failure-capture.md +21 -0
- package/bundled/dev-pipeline-windows/templates/sections/feature-context.md +31 -0
- package/bundled/dev-pipeline-windows/templates/sections/phase-browser-verification-auto.md +72 -0
- package/bundled/dev-pipeline-windows/templates/sections/phase-browser-verification-opencli.md +63 -0
- package/bundled/dev-pipeline-windows/templates/sections/phase-browser-verification.md +62 -0
- package/bundled/dev-pipeline-windows/templates/sections/phase-commit-full.md +71 -0
- package/bundled/dev-pipeline-windows/templates/sections/phase-commit.md +64 -0
- package/bundled/dev-pipeline-windows/templates/sections/phase-context-snapshot-agent-suffix.md +23 -0
- package/bundled/dev-pipeline-windows/templates/sections/phase-context-snapshot-base.md +24 -0
- package/bundled/dev-pipeline-windows/templates/sections/phase-context-snapshot-lite-suffix.md +12 -0
- package/bundled/dev-pipeline-windows/templates/sections/phase-critic-plan-full.md +53 -0
- package/bundled/dev-pipeline-windows/templates/sections/phase-critic-plan.md +32 -0
- package/bundled/dev-pipeline-windows/templates/sections/phase-implement-agent.md +37 -0
- package/bundled/dev-pipeline-windows/templates/sections/phase-implement-full.md +50 -0
- package/bundled/dev-pipeline-windows/templates/sections/phase-implement-lite.md +52 -0
- package/bundled/dev-pipeline-windows/templates/sections/phase-plan-agent.md +27 -0
- package/bundled/dev-pipeline-windows/templates/sections/phase-plan-lite.md +27 -0
- package/bundled/dev-pipeline-windows/templates/sections/phase-review-agent.md +27 -0
- package/bundled/dev-pipeline-windows/templates/sections/phase-review-full.md +29 -0
- package/bundled/dev-pipeline-windows/templates/sections/phase-specify-plan-full.md +77 -0
- package/bundled/dev-pipeline-windows/templates/sections/phase0-init.md +13 -0
- package/bundled/dev-pipeline-windows/templates/sections/phase0-test-baseline.md +23 -0
- package/bundled/dev-pipeline-windows/templates/sections/session-context.md +5 -0
- package/bundled/dev-pipeline-windows/templates/sections/subagent-timeout-recovery.md +6 -0
- package/bundled/dev-pipeline-windows/templates/sections/test-failure-recovery-agent.md +67 -0
- package/bundled/dev-pipeline-windows/templates/sections/test-failure-recovery-lite.md +58 -0
- package/bundled/dev-pipeline-windows/templates/session-status-schema.json +83 -0
- package/bundled/skills/_metadata.json +1 -1
- package/bundled/skills/app-planner/SKILL.md +26 -18
- package/bundled/skills/app-planner/references/architecture-decisions.md +9 -5
- package/bundled/skills/app-planner/references/frontend-design-guide.md +1 -1
- package/bundled/skills/feature-planner/SKILL.md +9 -2
- package/bundled/skills/prizmkit-init/SKILL.md +7 -6
- package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +2 -0
- package/bundled/skills-windows/app-planner/SKILL.md +639 -0
- package/bundled/skills-windows/app-planner/assets/app-design-guide.md +101 -0
- package/bundled/skills-windows/app-planner/references/architecture-decisions.md +52 -0
- package/bundled/skills-windows/app-planner/references/brainstorm-guide.md +101 -0
- package/bundled/skills-windows/app-planner/references/frontend-design-guide.md +71 -0
- package/bundled/skills-windows/app-planner/references/project-brief-guide.md +82 -0
- package/bundled/skills-windows/app-planner/references/red-team-checklist.md +40 -0
- package/bundled/skills-windows/app-planner/references/rules/backend/derivation-rules.md +609 -0
- package/bundled/skills-windows/app-planner/references/rules/backend/fixed-rules.md +285 -0
- package/bundled/skills-windows/app-planner/references/rules/backend/question-bank.md +249 -0
- package/bundled/skills-windows/app-planner/references/rules/backend/template.md +173 -0
- package/bundled/skills-windows/app-planner/references/rules/database/derivation-rules.md +373 -0
- package/bundled/skills-windows/app-planner/references/rules/database/fixed-rules.md +211 -0
- package/bundled/skills-windows/app-planner/references/rules/database/question-bank.md +184 -0
- package/bundled/skills-windows/app-planner/references/rules/database/template.md +158 -0
- package/bundled/skills-windows/app-planner/references/rules/frontend/derivation-rules.md +810 -0
- package/bundled/skills-windows/app-planner/references/rules/frontend/fixed-rules.md +188 -0
- package/bundled/skills-windows/app-planner/references/rules/frontend/question-bank.md +302 -0
- package/bundled/skills-windows/app-planner/references/rules/frontend/template.md +320 -0
- package/bundled/skills-windows/app-planner/references/rules/mobile/derivation-rules.md +639 -0
- package/bundled/skills-windows/app-planner/references/rules/mobile/fixed-rules.md +290 -0
- package/bundled/skills-windows/app-planner/references/rules/mobile/question-bank.md +232 -0
- package/bundled/skills-windows/app-planner/references/rules/mobile/template.md +175 -0
- package/bundled/skills-windows/bug-fix-workflow/SKILL.md +415 -0
- package/bundled/skills-windows/bug-planner/SKILL.md +395 -0
- package/bundled/skills-windows/bug-planner/assets/bug-confirmation-template.md +43 -0
- package/bundled/skills-windows/bug-planner/references/critic-and-verification.md +44 -0
- package/bundled/skills-windows/bug-planner/references/error-recovery.md +73 -0
- package/bundled/skills-windows/bug-planner/references/input-formats.md +53 -0
- package/bundled/skills-windows/bug-planner/references/schema-validation.md +25 -0
- package/bundled/skills-windows/bug-planner/references/severity-rules.md +16 -0
- package/bundled/skills-windows/bug-planner/scripts/validate-bug-list.py +322 -0
- package/bundled/skills-windows/bugfix-pipeline-launcher/SKILL.md +380 -0
- package/bundled/skills-windows/feature-pipeline-launcher/SKILL.md +441 -0
- package/bundled/skills-windows/feature-pipeline-launcher/scripts/preflight-check.py +462 -0
- package/bundled/skills-windows/feature-planner/SKILL.md +401 -0
- package/bundled/skills-windows/feature-planner/assets/evaluation-guide.md +64 -0
- package/bundled/skills-windows/feature-planner/assets/planning-guide.md +214 -0
- package/bundled/skills-windows/feature-planner/references/browser-interaction.md +59 -0
- package/bundled/skills-windows/feature-planner/references/completeness-review.md +57 -0
- package/bundled/skills-windows/feature-planner/references/decomposition-patterns.md +75 -0
- package/bundled/skills-windows/feature-planner/references/error-recovery.md +90 -0
- package/bundled/skills-windows/feature-planner/references/incremental-feature-planning.md +112 -0
- package/bundled/skills-windows/feature-planner/references/new-project-planning.md +85 -0
- package/bundled/skills-windows/feature-planner/scripts/validate-and-generate.py +1029 -0
- package/bundled/skills-windows/feature-workflow/SKILL.md +531 -0
- package/bundled/skills-windows/prizmkit-init/SKILL.md +356 -0
- package/bundled/skills-windows/prizmkit-init/assets/project-brief-template.md +82 -0
- package/bundled/skills-windows/prizmkit-init/references/config-schema.md +68 -0
- package/bundled/skills-windows/prizmkit-init/references/rules/layer-detection.md +41 -0
- package/bundled/skills-windows/prizmkit-init/references/tech-stack-catalog.md +13 -0
- package/bundled/skills-windows/prizmkit-init/references/update-supplement.md +9 -0
- package/bundled/skills-windows/recovery-workflow/SKILL.md +456 -0
- package/bundled/skills-windows/recovery-workflow/evals/evals.json +46 -0
- package/bundled/skills-windows/recovery-workflow/scripts/detect-recovery-state.py +544 -0
- package/bundled/skills-windows/refactor-pipeline-launcher/SKILL.md +406 -0
- package/bundled/skills-windows/refactor-planner/SKILL.md +540 -0
- package/bundled/skills-windows/refactor-planner/assets/planning-guide.md +292 -0
- package/bundled/skills-windows/refactor-planner/references/behavior-preservation.md +301 -0
- package/bundled/skills-windows/refactor-planner/references/refactor-scoping-guide.md +221 -0
- package/bundled/skills-windows/refactor-planner/scripts/validate-and-generate-refactor.py +858 -0
- package/bundled/skills-windows/refactor-workflow/SKILL.md +503 -0
- package/package.json +3 -2
- package/src/clean.js +73 -2
- package/src/config.js +159 -50
- package/src/detect-platform.js +16 -8
- package/src/external-skills.js +26 -19
- package/src/index.js +31 -9
- package/src/manifest.js +6 -2
- package/src/metadata.js +43 -5
- package/src/platforms.js +36 -0
- package/src/prompts.js +31 -6
- package/src/runtimes.js +20 -0
- package/src/scaffold.js +314 -110
- package/src/upgrade.js +81 -41
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "refactor-workflow"
|
|
3
|
+
description: "One-stop entry point for code refactoring. Brainstorms refactoring goals with the user until fully clarified, then orchestrates refactor-planner → refactor-pipeline-launcher → execution. Handles multi-refactor batch development from a single request. Use this skill whenever the user wants to restructure, clean up, or optimize code without changing behavior. Trigger on: 'refactor', 'clean up code', 'restructure', 'optimize code structure', 'extract module', 'code refactoring', 'batch refactor'."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Refactor Workflow
|
|
7
|
+
|
|
8
|
+
One-stop entry point for code refactoring. Covers the complete journey from a rough refactoring idea to verified, behavior-preserving code changes: deep goal clarification → structured planning → autonomous pipeline execution.
|
|
9
|
+
|
|
10
|
+
## When to Use
|
|
11
|
+
|
|
12
|
+
User says:
|
|
13
|
+
- "Refactor the auth module", "Clean up this code", "Restructure the payment service"
|
|
14
|
+
- "Extract shared logic into a separate module", "Optimize code structure"
|
|
15
|
+
- "Batch refactor these modules", "Code refactoring across multiple files"
|
|
16
|
+
- Code has accumulated tech debt that needs structural improvement
|
|
17
|
+
- Module needs to be split, merged, or reorganized
|
|
18
|
+
|
|
19
|
+
**Do NOT use this skill when:**
|
|
20
|
+
- User only wants to plan refactoring (use `refactor-planner` directly)
|
|
21
|
+
- User only wants to launch pipeline for existing .prizmkit/plans/refactor-list.json (use `refactor-pipeline-launcher`)
|
|
22
|
+
- User wants to add features (use `feature-workflow`)
|
|
23
|
+
- User wants to fix bugs (use `bug-planner` + `bugfix-pipeline-launcher`)
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Overview
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
refactor-workflow <target / goals>
|
|
31
|
+
│
|
|
32
|
+
├── Phase 1: Brainstorm → clarify type → collect materials → parallel deep read → discuss plan
|
|
33
|
+
│
|
|
34
|
+
├── Phase 2: Plan → refactor-planner → .prizmkit/plans/refactor-list.json
|
|
35
|
+
│
|
|
36
|
+
├── Phase 3: Launch → refactor-pipeline-launcher → pipeline execution
|
|
37
|
+
│
|
|
38
|
+
└── Phase 4: Monitor → track progress → report results
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### What This Skill Does
|
|
42
|
+
|
|
43
|
+
| Phase | Action | Result |
|
|
44
|
+
|-------|--------|--------|
|
|
45
|
+
| 1 | **Brainstorm** — clarify type, collect reference materials, parallel deep read code & docs, discuss plan grounded in real code | Fully clarified refactoring goals |
|
|
46
|
+
| 2 | Call `refactor-planner` with clarified goals | `.prizmkit/plans/refactor-list.json` with N refactor items |
|
|
47
|
+
| 3 | Call `refactor-pipeline-launcher` | Pipeline started (execution mode chosen by user via launcher) |
|
|
48
|
+
| 4 | Monitor progress | Status updates, completion report |
|
|
49
|
+
|
|
50
|
+
### Why This Skill Exists
|
|
51
|
+
|
|
52
|
+
Without this skill, users must:
|
|
53
|
+
1. Figure out all refactoring goals and scope themselves
|
|
54
|
+
2. Invoke `refactor-planner` → wait for .prizmkit/plans/refactor-list.json
|
|
55
|
+
3. Invoke `refactor-pipeline-launcher` → wait for pipeline start
|
|
56
|
+
4. Manually check progress
|
|
57
|
+
|
|
58
|
+
With this skill, users can:
|
|
59
|
+
1. Say "Refactor the auth module to extract shared middleware" with a rough idea
|
|
60
|
+
2. The skill brainstorms to fill in all gaps (scope, risks, behavior contracts)
|
|
61
|
+
3. All planning + execution happens automatically
|
|
62
|
+
|
|
63
|
+
### Branch Management
|
|
64
|
+
|
|
65
|
+
The dev-pipeline handles branch management per-refactor automatically:
|
|
66
|
+
- Each refactor item is implemented on its own branch by the pipeline
|
|
67
|
+
- Branches are created, committed, and managed by the pipeline session
|
|
68
|
+
- This workflow does NOT create a top-level branch — the pipeline manages granular per-refactor branches
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Input Modes
|
|
73
|
+
|
|
74
|
+
**Mode A: From natural language description** (default)
|
|
75
|
+
|
|
76
|
+
Natural language description of the refactoring goals. Can be:
|
|
77
|
+
- A module target: "Refactor the auth module — extract shared middleware, simplify the token flow"
|
|
78
|
+
- A batch of refactors: "Clean up the payment service, decouple the notification module, and extract common utilities"
|
|
79
|
+
- An incremental request: "Also refactor the logging layer to use structured logging"
|
|
80
|
+
|
|
81
|
+
Flow: brainstorm → refactor-planner → refactor-pipeline-launcher → monitor
|
|
82
|
+
|
|
83
|
+
**Mode B: From existing .prizmkit/plans/refactor-list.json**
|
|
84
|
+
|
|
85
|
+
When user says "run pipeline from existing file" or .prizmkit/plans/refactor-list.json already exists:
|
|
86
|
+
- Skip brainstorm and `refactor-planner` (file already exists)
|
|
87
|
+
- Invoke `refactor-pipeline-launcher` directly
|
|
88
|
+
- Monitor and report progress
|
|
89
|
+
|
|
90
|
+
**Mode C: Incremental (add to existing refactor plan)**
|
|
91
|
+
|
|
92
|
+
When user says "add more refactors" or the project already has a .prizmkit/plans/refactor-list.json:
|
|
93
|
+
- Brainstorm new refactoring goals with the user
|
|
94
|
+
- Invoke `refactor-planner` in incremental mode (reads existing .prizmkit/plans/refactor-list.json)
|
|
95
|
+
- Append new refactor items to existing list
|
|
96
|
+
- Invoke `refactor-pipeline-launcher`
|
|
97
|
+
- Monitor and report progress
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Phase 1: Brainstorm — Deep Refactoring Goal Clarification
|
|
102
|
+
|
|
103
|
+
**Goal**: Through interactive Q&A and deep code reading, transform the user's rough refactoring idea into fully clarified, implementation-ready refactoring goals. This phase is the foundation for safe, behavior-preserving code changes — vague goals produce risky refactors.
|
|
104
|
+
|
|
105
|
+
**CRITICAL RULE**: The number of questions is **unlimited**. Do NOT rush through this phase. Ask as many rounds as needed until every aspect is clear. Refactoring is inherently risky — thorough understanding prevents broken behavior.
|
|
106
|
+
|
|
107
|
+
### Step 1.1: Clarify Refactoring Type
|
|
108
|
+
|
|
109
|
+
**First question** — ask the user to classify the refactoring approach:
|
|
110
|
+
|
|
111
|
+
| Type | Description | Example |
|
|
112
|
+
|------|-------------|---------|
|
|
113
|
+
| **Incremental** | Piece-by-piece restructuring, each step independently safe | "Gradually extract shared utilities over several PRs" |
|
|
114
|
+
| **Comprehensive** | Full rewrite of a module/area in one pass | "Rewrite the auth module with new architecture" |
|
|
115
|
+
| **Targeted** | Specific, focused change to a particular part | "Extract the validation logic from the controller" |
|
|
116
|
+
|
|
117
|
+
Then ask:
|
|
118
|
+
- **What** code needs restructuring (modules, files, patterns)
|
|
119
|
+
- **Why** it needs refactoring (tech debt, coupling, complexity, readability, performance structure)
|
|
120
|
+
- **What outcome** they want (target architecture, desired structure, quality goals)
|
|
121
|
+
|
|
122
|
+
### Step 1.2: Collect Reference Materials
|
|
123
|
+
|
|
124
|
+
**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:
|
|
125
|
+
1. Acknowledge what was received: "I received the following materials: [list]"
|
|
126
|
+
2. Read/fetch all provided materials immediately
|
|
127
|
+
3. You MUST still ask: "Are there any additional materials you'd like to provide?"
|
|
128
|
+
4. NEVER skip this collection step just because the user already provided some materials
|
|
129
|
+
|
|
130
|
+
**If the user has NOT provided any materials upfront**, ask the user explicitly what resources they have. Do NOT skip this step — user-provided materials are far more valuable than blind directory scanning.
|
|
131
|
+
|
|
132
|
+
Ask:
|
|
133
|
+
1. **Code paths** — "Which files or directories are the main targets? Any specific files I should look at?"
|
|
134
|
+
2. **Design documents** — "Do you have any design docs, architecture diagrams, or refactoring proposals I should read?"
|
|
135
|
+
3. **Knowledge docs** — "Are there related `.prizmkit/prizm-docs/`, README files, or internal wiki pages for the target area?"
|
|
136
|
+
4. **Related issues/PRs** — "Any related issues, PRs, or previous refactoring attempts I should be aware of?"
|
|
137
|
+
|
|
138
|
+
Record everything the user provides — these become inputs for Step 1.3.
|
|
139
|
+
|
|
140
|
+
### Step 1.3: Parallel Deep Reading
|
|
141
|
+
|
|
142
|
+
**Goal**: Build comprehensive understanding of the target code and context before discussing plans. Spawn multiple agents in parallel to read all relevant materials simultaneously.
|
|
143
|
+
|
|
144
|
+
**Parallel reading tasks** (launch concurrently):
|
|
145
|
+
|
|
146
|
+
| Agent | What to read | Purpose |
|
|
147
|
+
|-------|-------------|---------|
|
|
148
|
+
| Agent A | User-provided code paths — read full source files | Understand current structure, interfaces, dependencies |
|
|
149
|
+
| Agent B | User-provided documents — design docs, proposals, wiki pages | Understand intended direction and constraints |
|
|
150
|
+
| Agent C | `.prizmkit/prizm-docs/` for affected modules — L1/L2 docs, TRAPS, RULES | Understand existing architecture knowledge and known pitfalls |
|
|
151
|
+
| Agent D | Test files for the target area — find and read existing tests | Understand current test coverage and behavior contracts |
|
|
152
|
+
|
|
153
|
+
**Also gather** (can be included in any agent's task):
|
|
154
|
+
- `.prizmkit/config.json` → tech stack preferences
|
|
155
|
+
- Directory structure of the target area
|
|
156
|
+
- Dependency relationships (imports/exports between target and other modules)
|
|
157
|
+
|
|
158
|
+
**After all agents complete**: Synthesize findings into a coherent understanding before proceeding to discussion.
|
|
159
|
+
|
|
160
|
+
### Step 1.4: Discuss Refactoring Plan
|
|
161
|
+
|
|
162
|
+
**Now** — with deep knowledge of the actual code and documents — discuss the refactoring plan with the user. This discussion is grounded in real code, not abstract questions.
|
|
163
|
+
|
|
164
|
+
Present what you learned from the parallel reading:
|
|
165
|
+
- Current code structure and its problems (with specific file/function references)
|
|
166
|
+
- Existing test coverage status (which areas are safe, which are risky)
|
|
167
|
+
- Known TRAPS and pitfalls from `.prizmkit/prizm-docs/`
|
|
168
|
+
- Dependencies and potential impact on other modules
|
|
169
|
+
|
|
170
|
+
Then ask targeted questions based on what you read. **Adapt question depth to the refactoring complexity** — a simple extract-method refactor needs fewer questions than a full module decomposition.
|
|
171
|
+
|
|
172
|
+
**Code Structure:**
|
|
173
|
+
- "I see the current structure does X — is the target state Y, or something different?"
|
|
174
|
+
- What's the target state? What should the code look like after refactoring?
|
|
175
|
+
- Are there specific code smells you've noticed? (duplication, deep nesting, god classes, tight coupling)
|
|
176
|
+
|
|
177
|
+
**Scope:**
|
|
178
|
+
- Based on the code I read, these modules are affected: [list]. Anything else in/out of scope?
|
|
179
|
+
- For incremental refactoring: what's the order of priority?
|
|
180
|
+
|
|
181
|
+
**Behavior Preservation:**
|
|
182
|
+
- "These public APIs/interfaces exist: [list]. Which must remain unchanged?"
|
|
183
|
+
- "I found these tests: [list]. Are they passing currently?"
|
|
184
|
+
- Any undocumented behavior that callers depend on?
|
|
185
|
+
|
|
186
|
+
**Risk Assessment:**
|
|
187
|
+
- "I found these TRAPS in .prizmkit/prizm-docs/: [list]. Any other known gotchas?"
|
|
188
|
+
- Does this code have external consumers (other teams, published APIs)?
|
|
189
|
+
- Any concurrent development happening in the target area?
|
|
190
|
+
|
|
191
|
+
**Constraints:**
|
|
192
|
+
- Timeline or urgency? (affects whether to do incremental vs comprehensive)
|
|
193
|
+
- Team coordination needed? (other developers working in the same area)
|
|
194
|
+
- Deployment concerns? (feature flags, backward compatibility, migration)
|
|
195
|
+
|
|
196
|
+
### Step 1.5: Confirm and Supplement
|
|
197
|
+
|
|
198
|
+
After the discussion:
|
|
199
|
+
|
|
200
|
+
1. **Summarize** the refactoring plan — present it back to the user
|
|
201
|
+
2. **Ask explicitly**: "Is there anything else you'd like to discuss or supplement before we proceed to formal planning?"
|
|
202
|
+
3. **Identify gaps** — if any areas are still unclear, list them explicitly and ask follow-up questions
|
|
203
|
+
4. **Repeat** until the user confirms: "That covers everything" or "Let's proceed"
|
|
204
|
+
|
|
205
|
+
**Signs that brainstorming is complete:**
|
|
206
|
+
- All refactoring goals have concrete target state descriptions
|
|
207
|
+
- Scope boundaries are clearly defined (in/out)
|
|
208
|
+
- Behavior preservation contracts are identified
|
|
209
|
+
- Risk areas are acknowledged and mitigation is discussed
|
|
210
|
+
- The user has confirmed the summary is accurate
|
|
211
|
+
|
|
212
|
+
**Signs that more questions are needed:**
|
|
213
|
+
- User's answers contain vague terms ("clean it up", "make it better", "fix the structure")
|
|
214
|
+
- Scope is undefined ("refactor everything" without specifics)
|
|
215
|
+
- No awareness of test coverage for the target area
|
|
216
|
+
- Risk areas are handwaved ("it should be fine")
|
|
217
|
+
- User says "I'm not sure" — help them think through it with concrete options
|
|
218
|
+
|
|
219
|
+
### Step 1.6: Requirements Summary
|
|
220
|
+
|
|
221
|
+
Once brainstorming is complete, produce a structured goals summary:
|
|
222
|
+
|
|
223
|
+
```markdown
|
|
224
|
+
## Refactoring Goals Summary
|
|
225
|
+
|
|
226
|
+
### Target: [Module/area name]
|
|
227
|
+
|
|
228
|
+
### Refactoring Type: [Incremental / Comprehensive / Targeted]
|
|
229
|
+
|
|
230
|
+
### Refactoring Objectives
|
|
231
|
+
- [Bullet list of what structural changes are needed and why]
|
|
232
|
+
|
|
233
|
+
### Current Problems
|
|
234
|
+
- [What's wrong with the current structure — with specific code references]
|
|
235
|
+
|
|
236
|
+
### Target State
|
|
237
|
+
- [What the code should look like after refactoring]
|
|
238
|
+
|
|
239
|
+
### Scope
|
|
240
|
+
- **In scope**: [files, modules, directories]
|
|
241
|
+
- **Out of scope**: [explicitly excluded areas]
|
|
242
|
+
|
|
243
|
+
### Behavior Preservation Contracts
|
|
244
|
+
- [What behavior must remain unchanged]
|
|
245
|
+
- [Key APIs/interfaces that must be preserved]
|
|
246
|
+
- [Existing test coverage status]
|
|
247
|
+
|
|
248
|
+
### Risk Assessment
|
|
249
|
+
- [Risk]: [Mitigation strategy]
|
|
250
|
+
|
|
251
|
+
### Reference Materials Reviewed
|
|
252
|
+
- [List of code paths, documents, .prizmkit/prizm-docs/ files that were read]
|
|
253
|
+
|
|
254
|
+
### Constraints
|
|
255
|
+
- [Timeline, coordination, deployment concerns]
|
|
256
|
+
|
|
257
|
+
### Confirmed by user: ✓
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Present this summary to the user and get explicit confirmation before proceeding.
|
|
261
|
+
|
|
262
|
+
**CHECKPOINT CP-RW-0**: Refactoring goals fully clarified and confirmed by user.
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
### Step 1.7: Complexity Assessment & Approach Selection
|
|
267
|
+
|
|
268
|
+
After confirming refactoring goals, assess whether this refactor needs the full pipeline or can be done directly in the current session.
|
|
269
|
+
|
|
270
|
+
**Simple refactor → Fast Path candidate** (ALL must be true):
|
|
271
|
+
- Single module, no cross-module impact
|
|
272
|
+
- ≤3 files affected
|
|
273
|
+
- No public API or interface changes
|
|
274
|
+
- Straightforward transformation (extract method, rename, move file, simplify logic)
|
|
275
|
+
- Existing tests fully cover the affected code paths
|
|
276
|
+
- No risk of behavior change
|
|
277
|
+
|
|
278
|
+
**User choice required (mandatory)** — Use `AskUserQuestion` to present interactive selectable options:
|
|
279
|
+
|
|
280
|
+
```
|
|
281
|
+
AskUserQuestion:
|
|
282
|
+
question: "This refactoring appears straightforward. How would you like to proceed?"
|
|
283
|
+
header: "Approach"
|
|
284
|
+
options:
|
|
285
|
+
- label: "Refactor now (fast path)"
|
|
286
|
+
description: "Plan and refactor directly in this session using /prizmkit-plan + /prizmkit-implement"
|
|
287
|
+
- label: "Add to refactor list (pipeline)"
|
|
288
|
+
description: "Generate .prizmkit/plans/refactor-list.json via refactor-planner, then launch pipeline for autonomous execution"
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
- **Refactor now** → Fast Path Workflow:
|
|
292
|
+
1. Invoke `/prizmkit-plan` with the refactoring goals → generates `spec.md` + `plan.md`
|
|
293
|
+
2. Invoke `/prizmkit-implement` to execute the plan (behavior preservation verified by tests)
|
|
294
|
+
3. After implementation, run `/prizmkit-code-review` for quality check
|
|
295
|
+
4. Commit via `/prizmkit-committer` with `refactor(<scope>):` prefix
|
|
296
|
+
5. Run `/prizmkit-retrospective` to sync `.prizmkit/prizm-docs/`
|
|
297
|
+
6. **End workflow** — skip Phase 2/3/4
|
|
298
|
+
- **Add to refactor list** → Continue to Phase 2 (Plan via pipeline)
|
|
299
|
+
|
|
300
|
+
**Complex refactor → Planning Path** (ANY is true):
|
|
301
|
+
- Cross-module impact (>2 modules affected)
|
|
302
|
+
- Public API or interface changes required
|
|
303
|
+
- Multiple interrelated refactoring steps with dependency ordering
|
|
304
|
+
- Comprehensive rewrite of a module
|
|
305
|
+
- Insufficient test coverage in target area (risk of hidden behavior changes)
|
|
306
|
+
- Requires coordination with other ongoing work
|
|
307
|
+
|
|
308
|
+
**User choice required (mandatory)** — Use `AskUserQuestion` to present interactive selectable options:
|
|
309
|
+
|
|
310
|
+
```
|
|
311
|
+
AskUserQuestion:
|
|
312
|
+
question: "This refactoring is complex and will benefit from structured planning. How would you like to proceed?"
|
|
313
|
+
header: "Approach"
|
|
314
|
+
options:
|
|
315
|
+
- label: "Plan and refactor now"
|
|
316
|
+
description: "Create a plan and refactor in this session using /prizmkit-plan + /prizmkit-implement"
|
|
317
|
+
- label: "Add to refactor list (pipeline)"
|
|
318
|
+
description: "Generate .prizmkit/plans/refactor-list.json via refactor-planner, then launch pipeline for autonomous execution"
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
- **Plan and refactor now** → Invoke `/prizmkit-plan` with goals → `/prizmkit-implement` → `/prizmkit-code-review` → `/prizmkit-committer` → `/prizmkit-retrospective`. **End workflow** — skip Phase 2/3/4.
|
|
322
|
+
- **Add to refactor list** → Continue to Phase 2 (Plan via pipeline)
|
|
323
|
+
|
|
324
|
+
**NEVER proceed without explicit user confirmation via `AskUserQuestion`. Do NOT render options as plain text — the user must be able to click/select.**
|
|
325
|
+
|
|
326
|
+
**CHECKPOINT CP-RW-0.5**: Approach selected by user (fast path or pipeline).
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## Phase 2: Plan
|
|
331
|
+
|
|
332
|
+
**Goal**: Generate structured .prizmkit/plans/refactor-list.json from the clarified refactoring goals.
|
|
333
|
+
|
|
334
|
+
**STEPS**:
|
|
335
|
+
|
|
336
|
+
1. **Invoke `refactor-planner` skill** with the full goals summary from Phase 1:
|
|
337
|
+
- Pass the structured goals summary as input — NOT the raw user conversation
|
|
338
|
+
- For new refactoring: standard planning mode
|
|
339
|
+
- For existing projects with `--incremental`: incremental planning mode
|
|
340
|
+
- **Input**: Markdown goals summary (refactor targets, scope, behavior preservation strategy)
|
|
341
|
+
- **Output**: `.prizmkit/plans/refactor-list.json` (schema: `dev-pipeline-refactor-list-v1`) containing `project_name`, `refactors[]` with id (R-NNN), title, description, scope, type, priority, complexity, behavior_preservation, acceptance_criteria, dependencies, status
|
|
342
|
+
|
|
343
|
+
2. **Interactive planning** (if refactor-planner requires clarification):
|
|
344
|
+
- Because Phase 1 was thorough, refactor-planner should need minimal clarification
|
|
345
|
+
- If questions arise, answer from the Phase 1 context or pass through to user
|
|
346
|
+
|
|
347
|
+
3. **Validate output**:
|
|
348
|
+
- Confirm `.prizmkit/plans/refactor-list.json` exists
|
|
349
|
+
- Show summary: total refactor items, complexity distribution, dependencies
|
|
350
|
+
|
|
351
|
+
**CHECKPOINT CP-RW-1**: `.prizmkit/plans/refactor-list.json` generated and validated.
|
|
352
|
+
|
|
353
|
+
**If user says `--from <file>`**: Skip Phase 1 and Phase 2 entirely.
|
|
354
|
+
|
|
355
|
+
---
|
|
356
|
+
|
|
357
|
+
## Phase 3: Launch
|
|
358
|
+
|
|
359
|
+
**Goal**: Start the refactoring pipeline.
|
|
360
|
+
|
|
361
|
+
**STEPS**:
|
|
362
|
+
|
|
363
|
+
1. **Show refactor summary** before launching:
|
|
364
|
+
```
|
|
365
|
+
Ready to launch pipeline with N refactor items:
|
|
366
|
+
R-001: Extract auth middleware (medium complexity)
|
|
367
|
+
R-002: Decouple notification service (high complexity)
|
|
368
|
+
R-003: Simplify token flow (low complexity)
|
|
369
|
+
|
|
370
|
+
Proceed? (Y/n)
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
2. **Invoke `refactor-pipeline-launcher` skill**:
|
|
374
|
+
- **Input**: Path to validated `.prizmkit/plans/refactor-list.json`
|
|
375
|
+
- The launcher handles all prerequisites checks
|
|
376
|
+
- The launcher presents execution mode choices to the user (foreground/background/manual)
|
|
377
|
+
- Do NOT duplicate execution mode selection here — let the launcher handle it
|
|
378
|
+
- **Output**: PID/status, log file path, execution mode selected
|
|
379
|
+
- Returns PID/status and log file location
|
|
380
|
+
|
|
381
|
+
3. **Verify launch success**:
|
|
382
|
+
- Confirm pipeline is running
|
|
383
|
+
- Record PID and log path for Phase 4
|
|
384
|
+
|
|
385
|
+
**CHECKPOINT CP-RW-2**: Pipeline launched successfully.
|
|
386
|
+
|
|
387
|
+
---
|
|
388
|
+
|
|
389
|
+
## Phase 4: Monitor
|
|
390
|
+
|
|
391
|
+
**Goal**: Track pipeline progress and report to user.
|
|
392
|
+
|
|
393
|
+
**STEPS**:
|
|
394
|
+
|
|
395
|
+
1. **Initial status check**:
|
|
396
|
+
```powershell
|
|
397
|
+
.\.prizmkit\dev-pipeline\launch-refactor-daemon.ps1 status
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
2. **Offer monitoring options**:
|
|
401
|
+
- "I'll check progress periodically. Say 'status' anytime for an update."
|
|
402
|
+
- "Say 'logs' to see recent activity."
|
|
403
|
+
- "Say 'stop' to pause the pipeline."
|
|
404
|
+
|
|
405
|
+
3. **Periodic progress reports** (when user asks):
|
|
406
|
+
```powershell
|
|
407
|
+
function Invoke-PrizmPython {
|
|
408
|
+
param([Parameter(ValueFromRemainingArguments = $true)][string[]]$Arguments)
|
|
409
|
+
$python = Get-Command python -ErrorAction SilentlyContinue
|
|
410
|
+
if ($python) {
|
|
411
|
+
& $python.Source -c 'import sys; raise SystemExit(0 if sys.version_info[0] == 3 else 1)' *> $null
|
|
412
|
+
if ($LASTEXITCODE -eq 0) {
|
|
413
|
+
& $python.Source @Arguments
|
|
414
|
+
return
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
$py = Get-Command py -ErrorAction SilentlyContinue
|
|
418
|
+
if ($py) {
|
|
419
|
+
& $py.Source -3 -c 'import sys; raise SystemExit(0 if sys.version_info[0] == 3 else 1)' *> $null
|
|
420
|
+
if ($LASTEXITCODE -eq 0) {
|
|
421
|
+
& $py.Source -3 @Arguments
|
|
422
|
+
return
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
throw "Python 3 is required. Install Python and ensure python or py is in PATH."
|
|
426
|
+
}
|
|
427
|
+
Invoke-PrizmPython .prizmkit/dev-pipeline/scripts/update-refactor-status.py `
|
|
428
|
+
--refactor-list .prizmkit/plans/refactor-list.json `
|
|
429
|
+
--state-dir .prizmkit/state/refactor `
|
|
430
|
+
--action status
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
4. **Completion report** (when pipeline finishes all refactor items):
|
|
434
|
+
```
|
|
435
|
+
Pipeline completed: 3/3 refactor items
|
|
436
|
+
|
|
437
|
+
Summary:
|
|
438
|
+
- R-001: Extract auth middleware → COMMITTED (refactor(auth): extract shared middleware)
|
|
439
|
+
- R-002: Decouple notification service → COMMITTED (refactor(notifications): decouple from core)
|
|
440
|
+
- R-003: Simplify token flow → COMMITTED (refactor(auth): simplify token refresh)
|
|
441
|
+
|
|
442
|
+
Next steps:
|
|
443
|
+
- Review changes: git log --oneline -5
|
|
444
|
+
- Run tests: npm test
|
|
445
|
+
- Push when ready: git push
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
**CHECKPOINT CP-RW-3**: All refactor items completed or user stopped pipeline.
|
|
449
|
+
|
|
450
|
+
---
|
|
451
|
+
|
|
452
|
+
## Resume — Interruption Recovery
|
|
453
|
+
|
|
454
|
+
The workflow supports resuming by detecting existing state:
|
|
455
|
+
|
|
456
|
+
| State Found | Resume From |
|
|
457
|
+
|-------------|------------|
|
|
458
|
+
| No `.prizmkit/plans/refactor-list.json` | Phase 1: Brainstorm |
|
|
459
|
+
| `.prizmkit/plans/refactor-list.json` exists, no pipeline state | Phase 3: Launch |
|
|
460
|
+
| `.prizmkit/plans/refactor-list.json` + pipeline state exists | Phase 4: Monitor (check status) |
|
|
461
|
+
| All refactors completed | Report completion, suggest next steps |
|
|
462
|
+
|
|
463
|
+
**Resume**: If `.prizmkit/plans/refactor-list.json` exists, ask user: "Existing refactor plan found with N items. Resume pipeline or re-plan?"
|
|
464
|
+
|
|
465
|
+
---
|
|
466
|
+
|
|
467
|
+
## Interaction During Pipeline
|
|
468
|
+
|
|
469
|
+
While the pipeline runs, the user can continue the conversation:
|
|
470
|
+
|
|
471
|
+
| User says | Action |
|
|
472
|
+
|-----------|--------|
|
|
473
|
+
| "status" / "progress" | Show current progress |
|
|
474
|
+
| "logs" | Show recent log activity |
|
|
475
|
+
| "stop" | Stop the pipeline (state preserved) |
|
|
476
|
+
| "show R-002 logs" | Show specific refactor item's session log |
|
|
477
|
+
|
|
478
|
+
---
|
|
479
|
+
|
|
480
|
+
## Error Handling
|
|
481
|
+
|
|
482
|
+
| Error | Action |
|
|
483
|
+
|-------|--------|
|
|
484
|
+
| User's refactoring goal is too vague | Ask for more context: "Can you describe what's wrong with the current code structure?" |
|
|
485
|
+
| Brainstorming stalls | Offer concrete options: "Would you prefer incremental or comprehensive refactoring?" |
|
|
486
|
+
| No tests exist for target module | WARN user, recommend writing tests first before refactoring |
|
|
487
|
+
| `refactor-planner` cannot parse goals | Refine the goals summary and retry |
|
|
488
|
+
| `.prizmkit/plans/refactor-list.json` generation failed | Show error, retry with refined input |
|
|
489
|
+
| Pipeline launch failed | Show daemon log, suggest manual start |
|
|
490
|
+
| All refactor items blocked/failed | Show status, suggest retrying specific items |
|
|
491
|
+
| User wants to cancel mid-brainstorming | Save conversation context, offer to resume later |
|
|
492
|
+
| Behavior regression detected during pipeline | Pipeline handles per-item — failed items are retried or reported |
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
## Output
|
|
497
|
+
|
|
498
|
+
- Structured refactoring goals summary (Phase 1 artifact)
|
|
499
|
+
- `.prizmkit/plans/refactor-list.json` (Phase 2 artifact)
|
|
500
|
+
- Pipeline execution (Phase 3)
|
|
501
|
+
- Progress updates (Phase 4)
|
|
502
|
+
- Multiple git commits with `refactor(<scope>):` prefix
|
|
503
|
+
- Updated `.prizmkit/prizm-docs/` (via prizmkit-retrospective per refactor item)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prizmkit",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.60",
|
|
4
4
|
"description": "Create a new PrizmKit-powered project with clean initialization — no framework dev files, just what you need.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
"development",
|
|
36
36
|
"framework",
|
|
37
37
|
"codebuddy",
|
|
38
|
-
"claude-code"
|
|
38
|
+
"claude-code",
|
|
39
|
+
"codex"
|
|
39
40
|
],
|
|
40
41
|
"author": "PrizmKit",
|
|
41
42
|
"license": "MIT"
|
package/src/clean.js
CHANGED
|
@@ -70,6 +70,55 @@ async function cleanGitignore(projectRoot, dryRun) {
|
|
|
70
70
|
return { updated: true };
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
async function cleanMarkedProjectMemory(projectRoot, fileName, dryRun) {
|
|
74
|
+
const filePath = path.join(projectRoot, fileName);
|
|
75
|
+
if (!await fs.pathExists(filePath)) {
|
|
76
|
+
return { path: filePath, removed: false, reason: 'not_found' };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const content = await fs.readFile(filePath, 'utf8');
|
|
80
|
+
const next = content.replace(
|
|
81
|
+
/<!-- PRIZMKIT:START[\s\S]*?<!-- PRIZMKIT:END -->\n?/g,
|
|
82
|
+
''
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
if (next === content) {
|
|
86
|
+
return { path: filePath, removed: false, reason: 'no_prizmkit_section' };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (dryRun) {
|
|
90
|
+
return { path: filePath, removed: false, reason: 'dry_run' };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const trimmed = next.trim();
|
|
94
|
+
if (!trimmed) {
|
|
95
|
+
await fs.remove(filePath);
|
|
96
|
+
return { path: filePath, removed: true };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
await fs.writeFile(filePath, next.replace(/\n{3,}/g, '\n\n').trimEnd() + '\n');
|
|
100
|
+
return { path: filePath, removed: true, note: '(PrizmKit section)' };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async function removeGeneratedCodexConfig(projectRoot, dryRun) {
|
|
104
|
+
const configPath = path.join(projectRoot, '.codex', 'config.toml');
|
|
105
|
+
if (!await fs.pathExists(configPath)) {
|
|
106
|
+
return { path: configPath, removed: false, reason: 'not_found' };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const content = await fs.readFile(configPath, 'utf8');
|
|
110
|
+
if (!content.includes('Generated by PrizmKit for Codex CLI project configuration')) {
|
|
111
|
+
return { path: configPath, removed: false, reason: 'user_config' };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (dryRun) {
|
|
115
|
+
return { path: configPath, removed: false, reason: 'dry_run' };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
await fs.remove(configPath);
|
|
119
|
+
return { path: configPath, removed: true };
|
|
120
|
+
}
|
|
121
|
+
|
|
73
122
|
export async function runClean(directory, options = {}) {
|
|
74
123
|
const projectRoot = path.resolve(directory || '.');
|
|
75
124
|
const dryRun = Boolean(options.dryRun);
|
|
@@ -103,6 +152,7 @@ export async function runClean(directory, options = {}) {
|
|
|
103
152
|
];
|
|
104
153
|
const manifestAgentFiles = manifest?.files?.agents || [];
|
|
105
154
|
const agentFiles = [...new Set([...knownAgentFiles, ...manifestAgentFiles])];
|
|
155
|
+
const codexAgentFiles = [...new Set(agentFiles.flatMap(f => [f, f.replace(/\.md$/, '.toml')]))];
|
|
106
156
|
|
|
107
157
|
// Rule file names installed by PrizmKit (union of metadata + manifest)
|
|
108
158
|
const metadataRuleFileNames = Object.keys(metadata_rules_to_filenames(rulesMeta));
|
|
@@ -115,20 +165,21 @@ export async function runClean(directory, options = {}) {
|
|
|
115
165
|
const fullRemoveTargets = [
|
|
116
166
|
'.prizmkit',
|
|
117
167
|
'.dev-team',
|
|
118
|
-
'CODEBUDDY.md',
|
|
119
|
-
'CLAUDE.md',
|
|
120
168
|
path.join('.prizmkit', 'plans', 'feature-list.json'), // feature-planner output
|
|
121
169
|
path.join('.prizmkit', 'plans', 'bug-fix-list.json'), // bug-planner output
|
|
122
170
|
path.join('.prizmkit', 'plans', 'project-brief.md'), // feature-planner project brief
|
|
123
171
|
path.join('.codebuddy', 'settings.json'),
|
|
124
172
|
path.join('.claude', 'settings.json'),
|
|
125
173
|
path.join('.claude', 'team-info.json'),
|
|
174
|
+
path.join('.codex', 'prizmkit-settings.json'), // legacy Codex metadata
|
|
175
|
+
path.join('.codex', 'team-info.json'),
|
|
126
176
|
];
|
|
127
177
|
|
|
128
178
|
for (const rel of fullRemoveTargets) {
|
|
129
179
|
const abs = path.join(projectRoot, rel);
|
|
130
180
|
results.push(await removePath(abs, dryRun));
|
|
131
181
|
}
|
|
182
|
+
results.push(await removeGeneratedCodexConfig(projectRoot, dryRun));
|
|
132
183
|
|
|
133
184
|
// ── Selective removes (shared dirs — only remove PrizmKit-known entries) ──
|
|
134
185
|
|
|
@@ -145,6 +196,10 @@ export async function runClean(directory, options = {}) {
|
|
|
145
196
|
const cbSkillsDir = path.join(projectRoot, '.codebuddy', 'skills');
|
|
146
197
|
results.push(...await removeKnownEntries(cbSkillsDir, allSkillNames, dryRun));
|
|
147
198
|
|
|
199
|
+
// .agents/skills/ — Codex repository skills
|
|
200
|
+
const codexSkillsDir = path.join(projectRoot, '.agents', 'skills');
|
|
201
|
+
results.push(...await removeKnownEntries(codexSkillsDir, allSkillNames, dryRun));
|
|
202
|
+
|
|
148
203
|
// .claude/agents/ — PrizmKit agent files
|
|
149
204
|
const claudeAgentsDir = path.join(projectRoot, '.claude', 'agents');
|
|
150
205
|
results.push(...await removeKnownEntries(claudeAgentsDir, agentFiles, dryRun));
|
|
@@ -153,6 +208,10 @@ export async function runClean(directory, options = {}) {
|
|
|
153
208
|
const cbAgentsDir = path.join(projectRoot, '.codebuddy', 'agents');
|
|
154
209
|
results.push(...await removeKnownEntries(cbAgentsDir, agentFiles, dryRun));
|
|
155
210
|
|
|
211
|
+
// .codex/agents/ — same agent reference files
|
|
212
|
+
const codexAgentsDir = path.join(projectRoot, '.codex', 'agents');
|
|
213
|
+
results.push(...await removeKnownEntries(codexAgentsDir, codexAgentFiles, dryRun));
|
|
214
|
+
|
|
156
215
|
// .claude/rules/ — PrizmKit rule .md files
|
|
157
216
|
const claudeRulesDir = path.join(projectRoot, '.claude', 'rules');
|
|
158
217
|
results.push(...await removeKnownEntries(claudeRulesDir, ruleFileNames.map(n => `${n}.md`), dryRun));
|
|
@@ -161,6 +220,18 @@ export async function runClean(directory, options = {}) {
|
|
|
161
220
|
const cbRulesDir = path.join(projectRoot, '.codebuddy', 'rules');
|
|
162
221
|
results.push(...await removeKnownEntries(cbRulesDir, ruleFileNames.map(n => `${n}.mdc`), dryRun));
|
|
163
222
|
|
|
223
|
+
// .agents/rules/ — Codex PrizmKit behavioral guidance Markdown files
|
|
224
|
+
const codexRulesDir = path.join(projectRoot, '.agents', 'rules');
|
|
225
|
+
results.push(...await removeKnownEntries(codexRulesDir, ruleFileNames.map(n => `${n}.md`), dryRun));
|
|
226
|
+
|
|
227
|
+
// .codex/rules/ — legacy PrizmKit-owned rule files from older Codex installs
|
|
228
|
+
const legacyCodexRulesDir = path.join(projectRoot, '.codex', 'rules');
|
|
229
|
+
results.push(...await removeKnownEntries(legacyCodexRulesDir, ruleFileNames.map(n => `${n}.md`), dryRun));
|
|
230
|
+
|
|
231
|
+
for (const memoryFile of ['CODEBUDDY.md', 'CLAUDE.md', 'AGENTS.md']) {
|
|
232
|
+
results.push(await cleanMarkedProjectMemory(projectRoot, memoryFile, dryRun));
|
|
233
|
+
}
|
|
234
|
+
|
|
164
235
|
// ── .gitignore cleanup ────────────────────────────────────────────────────
|
|
165
236
|
const gitignoreResult = await cleanGitignore(projectRoot, dryRun);
|
|
166
237
|
|