prizmkit 1.1.107 → 1.1.108
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 +4 -0
- package/bundled/VERSION.json +3 -3
- package/bundled/dev-pipeline/prizmkit_runtime/config.py +81 -14
- package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +19 -8
- package/bundled/dev-pipeline/prizmkit_runtime/interoperability.py +0 -1
- package/bundled/dev-pipeline/prizmkit_runtime/launch_profiles.py +18 -0
- package/bundled/dev-pipeline/prizmkit_runtime/runner_bookkeeping.py +22 -2
- package/bundled/dev-pipeline/prizmkit_runtime/runner_recovery.py +3 -1
- package/bundled/dev-pipeline/prizmkit_runtime/runners.py +20 -1
- package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +151 -30
- package/bundled/dev-pipeline/scripts/continuation.py +0 -1
- package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +6 -46
- package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +7 -34
- package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +40 -33
- package/bundled/dev-pipeline/scripts/utils.py +123 -0
- package/bundled/dev-pipeline/templates/agent-prompts/critic-plan-challenge.md +4 -3
- package/bundled/dev-pipeline/templates/bootstrap-prompt.md +1 -1
- package/bundled/dev-pipeline/templates/bootstrap-tier1.md +8 -7
- package/bundled/dev-pipeline/templates/bootstrap-tier2.md +25 -36
- package/bundled/dev-pipeline/templates/bootstrap-tier3.md +16 -31
- package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +4 -16
- package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +3 -15
- package/bundled/dev-pipeline/templates/sections/checkpoint-system.md +14 -48
- package/bundled/dev-pipeline/templates/sections/context-budget-rules.md +7 -13
- package/bundled/dev-pipeline/templates/sections/feature-context.md +0 -4
- package/bundled/dev-pipeline/templates/sections/phase-browser-verification-auto.md +0 -7
- package/bundled/dev-pipeline/templates/sections/phase-browser-verification-opencli.md +0 -7
- package/bundled/dev-pipeline/templates/sections/phase-browser-verification.md +0 -7
- package/bundled/dev-pipeline/templates/sections/phase-commit-full.md +0 -14
- package/bundled/dev-pipeline/templates/sections/phase-commit.md +0 -14
- package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-agent-suffix.md +0 -7
- package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-base.md +0 -2
- package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-lite-suffix.md +0 -7
- package/bundled/dev-pipeline/templates/sections/phase-critic-plan-full.md +6 -8
- package/bundled/dev-pipeline/templates/sections/phase-critic-plan.md +3 -7
- package/bundled/dev-pipeline/templates/sections/phase-implement-agent.md +0 -7
- package/bundled/dev-pipeline/templates/sections/phase-implement-full.md +0 -7
- package/bundled/dev-pipeline/templates/sections/phase-implement-lite.md +0 -7
- package/bundled/dev-pipeline/templates/sections/phase-plan-agent.md +2 -9
- package/bundled/dev-pipeline/templates/sections/phase-plan-lite.md +1 -8
- package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +15 -16
- package/bundled/dev-pipeline/templates/sections/phase-review-agent.md +0 -7
- package/bundled/dev-pipeline/templates/sections/phase-review-full.md +0 -7
- package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +2 -9
- package/bundled/dev-pipeline/templates/sections/phase0-init.md +0 -7
- package/bundled/dev-pipeline/templates/sections/phase0-test-baseline.md +2 -15
- package/bundled/dev-pipeline/tests/conftest.py +0 -1
- package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +350 -23
- package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +36 -17
- package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +117 -14
- package/bundled/dev-pipeline/tests/test_python_runner_parity.py +79 -2
- package/bundled/dev-pipeline/tests/test_unified_cli.py +658 -13
- package/bundled/skills/_metadata.json +4 -4
- package/bundled/skills/app-planner/SKILL.md +1 -1
- package/bundled/skills/app-planner/references/architecture-decisions.md +1 -1
- package/bundled/skills/bug-fix-workflow/SKILL.md +174 -128
- package/bundled/skills/bug-planner/SKILL.md +101 -15
- package/bundled/skills/bug-planner/references/severity-rules.md +20 -8
- package/bundled/skills/feature-planner/SKILL.md +87 -8
- package/bundled/skills/feature-planner/assets/planning-guide.md +34 -10
- package/bundled/skills/feature-workflow/SKILL.md +100 -81
- package/bundled/skills/{prizm-kit → prizmkit}/SKILL.md +1 -1
- package/bundled/skills/prizmkit-code-review/SKILL.md +1 -1
- package/bundled/skills/refactor-planner/SKILL.md +88 -7
- package/bundled/skills/refactor-planner/references/fast-path.md +2 -1
- package/bundled/skills/refactor-planner/references/planning-phases.md +29 -11
- package/bundled/skills/refactor-workflow/SKILL.md +116 -57
- package/bundled/templates/project-memory-template.md +1 -1
- package/package.json +1 -1
- package/src/ai-cli-launch.js +194 -0
- package/src/config.js +26 -14
- package/src/index.js +11 -44
- package/src/platforms.js +10 -3
- package/src/prompts.js +60 -2
- package/src/scaffold.js +26 -14
- package/bundled/dev-pipeline/scripts/prizmkit-test-gate.py +0 -446
- package/bundled/dev-pipeline/templates/sections/log-size-awareness.md +0 -20
- package/bundled/dev-pipeline/tests/test_prizmkit_test_gate.py +0 -107
|
@@ -1,61 +1,90 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: "refactor-workflow"
|
|
3
|
-
description: "
|
|
3
|
+
description: "Triage-based refactor workflow. Clarifies behavior-preserving refactoring goals, then lets the user choose Fast Path for simple current-session/current-workspace refactors or Pipeline Path for complex/batch refactors via refactor-planner → refactor-pipeline-launcher. Use when 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
4
|
---
|
|
5
5
|
|
|
6
6
|
# Refactor Workflow
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Triage-based entry point for code refactoring. The workflow clarifies behavior-preserving goals, assesses risk and scope, asks the user to choose an approach, then follows one of two paths:
|
|
9
|
+
|
|
10
|
+
- **Fast Path** — a simple behavior-preserving refactor is implemented directly in the **current session** and **current workspace** with the normal PrizmKit lifecycle commands.
|
|
11
|
+
- **Pipeline Path** — complex or batch refactors are planned with `refactor-planner`, launched with `refactor-pipeline-launcher`, then monitored.
|
|
12
|
+
|
|
13
|
+
This skill keeps Fast Path and Pipeline Path separate. Pipeline monitoring only happens after the user selects Pipeline Path and the launcher starts execution.
|
|
9
14
|
|
|
10
15
|
## When to Use
|
|
11
16
|
|
|
12
17
|
User says:
|
|
13
18
|
- "Refactor the auth module", "Clean up this code", "Restructure the payment service"
|
|
14
19
|
- "Extract shared logic into a separate module", "Optimize code structure"
|
|
20
|
+
- "Do this small behavior-preserving cleanup now"
|
|
15
21
|
- "Batch refactor these modules", "Code refactoring across multiple files"
|
|
16
22
|
- Code has accumulated tech debt that needs structural improvement
|
|
17
23
|
- Module needs to be split, merged, or reorganized
|
|
18
24
|
|
|
19
25
|
**Do NOT use this skill when:**
|
|
20
|
-
- User only wants to plan refactoring
|
|
21
|
-
- User only wants to launch
|
|
22
|
-
- User wants to add features
|
|
23
|
-
- User wants to fix bugs
|
|
26
|
+
- User only wants to plan refactoring without execution → use `refactor-planner` directly
|
|
27
|
+
- User only wants to launch an existing `.prizmkit/plans/refactor-list.json` → use `refactor-pipeline-launcher`
|
|
28
|
+
- User wants to add features → use `feature-workflow`
|
|
29
|
+
- User wants to fix bugs → use `bug-fix-workflow` or `bug-planner` + `bugfix-pipeline-launcher`
|
|
24
30
|
|
|
25
31
|
---
|
|
26
32
|
|
|
27
33
|
## Overview
|
|
28
34
|
|
|
29
|
-
|
|
35
|
+
The shared contract is:
|
|
36
|
+
|
|
37
|
+
1. **Brainstorm** — clarify refactoring type, collect reference materials, read relevant code/docs/tests, and confirm behavior-preservation requirements.
|
|
38
|
+
2. **Assess difficulty and behavior risk** — decide whether the request is a simple behavior-preserving Fast Path candidate or a complex/batch Pipeline Path candidate.
|
|
39
|
+
3. **AskUserQuestion approach selection** — present selectable options; never silently choose the path.
|
|
40
|
+
4. **Execute selected path**:
|
|
41
|
+
- **Fast Path**: `/prizmkit-plan` → `/prizmkit-implement` with behavior-preservation tests/checks → `/prizmkit-code-review` → `/prizmkit-retrospective` → `/prizmkit-committer` in the current workspace.
|
|
42
|
+
- **Pipeline Path**: `refactor-planner` → `refactor-pipeline-launcher` → monitoring.
|
|
43
|
+
|
|
44
|
+
### Terminology
|
|
30
45
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
46
|
+
| Term | Meaning |
|
|
47
|
+
|------|---------|
|
|
48
|
+
| **Fast Path** | Current-session/current-workspace implementation for simple, behavior-preserving refactors. It does not create or consume `.prizmkit/plans/refactor-list.json` and does not start the refactor pipeline. |
|
|
49
|
+
| **Pipeline Path** | Complex or batch refactor execution. Planner handoff goes to `refactor-planner`; launcher handoff goes to `refactor-pipeline-launcher`; monitoring follows only after launch. |
|
|
50
|
+
| **Current session** | The interactive AI CLI session that is already discussing the refactor with the user. |
|
|
51
|
+
| **Current workspace** | The current git checkout and working tree, not a background pipeline worktree/session. |
|
|
52
|
+
| **Behavior preservation** | External behavior, public contracts, tests, and user-visible outcomes remain unchanged unless the user explicitly approves a behavior change as a feature. |
|
|
53
|
+
| **Monitoring** | Status/log follow-up for a launched refactor pipeline; it is not part of the Fast Path. |
|
|
35
54
|
|
|
36
|
-
### Branch
|
|
55
|
+
### Workspace and Branch Model
|
|
37
56
|
|
|
38
|
-
|
|
39
|
-
-
|
|
40
|
-
- Branches are created, committed, and managed by the pipeline session
|
|
41
|
-
- This workflow does NOT create a top-level branch — the pipeline manages granular per-refactor branches
|
|
57
|
+
- **Fast Path**: work happens in the current workspace and current interactive session. Use the current branch unless the project policy or user explicitly asks to create a branch.
|
|
58
|
+
- **Pipeline Path**: `refactor-pipeline-launcher` and the dev-pipeline manage per-refactor branches/worktrees. This workflow does not create a top-level branch before handing off to the launcher.
|
|
42
59
|
|
|
43
60
|
---
|
|
44
61
|
|
|
45
62
|
## Input Modes
|
|
46
63
|
|
|
47
|
-
**Mode A:
|
|
64
|
+
**Mode A: Natural language refactoring goal** (default)
|
|
48
65
|
|
|
49
66
|
Natural language description of the refactoring goals. Can be:
|
|
67
|
+
- A simple behavior-preserving refactor: "Extract this helper function and keep behavior unchanged"
|
|
50
68
|
- A module target: "Refactor the auth module — extract shared middleware, simplify the token flow"
|
|
51
69
|
- A batch of refactors: "Clean up the payment service, decouple the notification module, and extract common utilities"
|
|
52
70
|
- An incremental request: "Also refactor the logging layer to use structured logging"
|
|
53
71
|
|
|
54
|
-
Flow: brainstorm →
|
|
72
|
+
Flow: brainstorm → complexity/behavior-risk assessment → AskUserQuestion → Fast Path or Pipeline Path.
|
|
55
73
|
|
|
56
|
-
**Mode B:
|
|
74
|
+
**Mode B: Existing `.prizmkit/plans/refactor-list.json`**
|
|
57
75
|
|
|
58
|
-
|
|
76
|
+
When the user says "run pipeline from existing file" or `.prizmkit/plans/refactor-list.json` already exists and should be executed:
|
|
77
|
+
- Skip brainstorm and `refactor-planner`
|
|
78
|
+
- Invoke `refactor-pipeline-launcher` directly
|
|
79
|
+
- Monitor and report progress
|
|
80
|
+
|
|
81
|
+
**Mode C: Incremental refactor request**
|
|
82
|
+
|
|
83
|
+
When user says "add more refactors":
|
|
84
|
+
- Brainstorm only the new refactoring goals
|
|
85
|
+
- Assess whether the new scope is simple and behavior-preserving enough for Fast Path
|
|
86
|
+
- For simple work: use Fast Path in the current workspace
|
|
87
|
+
- For complex or batch work: invoke `refactor-planner` in incremental mode, then `refactor-pipeline-launcher`
|
|
59
88
|
|
|
60
89
|
---
|
|
61
90
|
|
|
@@ -79,6 +108,7 @@ Then ask:
|
|
|
79
108
|
- **What** code needs restructuring (modules, files, patterns)
|
|
80
109
|
- **Why** it needs refactoring (tech debt, coupling, complexity, readability, performance structure)
|
|
81
110
|
- **What outcome** they want (target architecture, desired structure, quality goals)
|
|
111
|
+
- **What behavior must remain unchanged** (public APIs, outputs, workflows, tests, performance-sensitive paths)
|
|
82
112
|
|
|
83
113
|
### Step 1.2: Collect Reference Materials
|
|
84
114
|
|
|
@@ -95,6 +125,7 @@ Ask:
|
|
|
95
125
|
2. **Design documents** — "Do you have any design docs, architecture diagrams, or refactoring proposals I should read?"
|
|
96
126
|
3. **Knowledge docs** — "Are there related `.prizmkit/prizm-docs/`, README files, or internal wiki pages for the target area?"
|
|
97
127
|
4. **Related issues/PRs** — "Any related issues, PRs, or previous refactoring attempts I should be aware of?"
|
|
128
|
+
5. **Behavior checks** — "Which tests, commands, or manual scenarios prove behavior must stay the same?"
|
|
98
129
|
|
|
99
130
|
Record everything the user provides — these become inputs for Step 1.3.
|
|
100
131
|
|
|
@@ -121,23 +152,26 @@ Read `${SKILL_DIR}/references/brainstorm-guide.md` §Completion Signs for the fu
|
|
|
121
152
|
|
|
122
153
|
Once brainstorming is complete, produce a structured goals summary. Read `${SKILL_DIR}/references/brainstorm-guide.md` §Refactoring Goals Summary Template for the structured output format. Present the summary to the user and get explicit confirmation before proceeding.
|
|
123
154
|
|
|
155
|
+
The summary must include behavior-preservation expectations: tests to run, public contracts to keep stable, and any explicitly approved behavior changes. If behavior changes are required, route them as feature work rather than refactoring unless the user explicitly scopes them here.
|
|
156
|
+
|
|
124
157
|
**CHECKPOINT CP-RW-0**: Refactoring goals fully clarified and confirmed by user.
|
|
125
158
|
|
|
126
159
|
---
|
|
127
160
|
|
|
128
161
|
### Step 1.7: Complexity Assessment & Approach Selection
|
|
129
162
|
|
|
130
|
-
After confirming refactoring goals, assess whether this refactor needs the
|
|
163
|
+
After confirming refactoring goals, assess whether this refactor needs the Pipeline Path or can be done directly in the current session/current workspace.
|
|
131
164
|
|
|
132
|
-
**Simple refactor → Fast Path candidate** (ALL must be true):
|
|
165
|
+
**Simple behavior-preserving refactor → Fast Path candidate** (ALL must be true):
|
|
133
166
|
- Single module, no cross-module impact
|
|
134
167
|
- ≤3 files affected
|
|
135
168
|
- No public API or interface changes
|
|
136
169
|
- Straightforward transformation (extract method, rename, move file, simplify logic)
|
|
137
|
-
- Existing tests
|
|
138
|
-
- No risk
|
|
170
|
+
- Existing tests or focused checks cover the affected behavior
|
|
171
|
+
- No behavior change risk beyond what tests/checks can verify
|
|
139
172
|
|
|
140
|
-
**Complex
|
|
173
|
+
**Complex or batch refactors → Pipeline Path candidate** (ANY is true):
|
|
174
|
+
- Multiple refactor items or batch refactoring request
|
|
141
175
|
- Cross-module impact (>2 modules affected)
|
|
142
176
|
- Public API or interface changes required
|
|
143
177
|
- Multiple interrelated refactoring steps with dependency ordering
|
|
@@ -145,48 +179,56 @@ After confirming refactoring goals, assess whether this refactor needs the full
|
|
|
145
179
|
- Insufficient test coverage in target area (risk of hidden behavior changes)
|
|
146
180
|
- Requires coordination with other ongoing work
|
|
147
181
|
|
|
148
|
-
**User choice required (mandatory)** — Use `AskUserQuestion` to present interactive selectable options. Tailor the question text to the assessment
|
|
182
|
+
**User choice required (mandatory)** — Use `AskUserQuestion` to present interactive selectable options. Tailor the question text to the assessment: for a simple refactor, "This refactor appears straightforward and behavior-preserving enough for the current-session Fast Path." For a complex or batch refactor, "This refactor is complex or batch-oriented and should use the Pipeline Path."
|
|
149
183
|
|
|
150
184
|
```
|
|
151
185
|
AskUserQuestion:
|
|
152
|
-
question:
|
|
186
|
+
question: "How would you like to proceed?"
|
|
153
187
|
header: "Approach"
|
|
154
188
|
options:
|
|
155
|
-
- label: "Refactor now (
|
|
156
|
-
description: "
|
|
157
|
-
- label: "
|
|
158
|
-
description: "Generate .prizmkit/plans/refactor-list.json
|
|
189
|
+
- label: "Refactor now (Fast Path — current session/current workspace)"
|
|
190
|
+
description: "Run /prizmkit-plan → /prizmkit-implement → /prizmkit-code-review → /prizmkit-retrospective → /prizmkit-committer directly in this workspace with behavior-preservation checks"
|
|
191
|
+
- label: "Use Pipeline Path (refactor-planner → refactor-pipeline-launcher)"
|
|
192
|
+
description: "Generate .prizmkit/plans/refactor-list.json with refactor-planner, then launch autonomous execution with refactor-pipeline-launcher"
|
|
159
193
|
```
|
|
160
194
|
|
|
161
|
-
- **Refactor now
|
|
162
|
-
-
|
|
195
|
+
- **Refactor now (Fast Path)**:
|
|
196
|
+
1. Invoke `/prizmkit-plan` with the goals summary → generates `spec.md` + `plan.md` including behavior-preservation strategy
|
|
197
|
+
2. Invoke `/prizmkit-implement` to execute the plan in the current workspace and verify behavior stays unchanged
|
|
198
|
+
3. Run `/prizmkit-code-review` for quality and behavior-preservation review
|
|
199
|
+
4. Run `/prizmkit-retrospective` to sync `.prizmkit/prizm-docs/`
|
|
200
|
+
5. Commit via `/prizmkit-committer` with `refactor(<scope>):` prefix
|
|
201
|
+
6. End workflow — do not call `refactor-planner`, do not call `refactor-pipeline-launcher`, and do not enter monitoring
|
|
202
|
+
- **Use Pipeline Path** → Continue to Phase 2 (Planner handoff)
|
|
163
203
|
|
|
164
204
|
**NEVER proceed without explicit user confirmation via `AskUserQuestion`. Do NOT render options as plain text — the user must be able to click/select.**
|
|
165
205
|
|
|
166
|
-
**CHECKPOINT CP-RW-0.5**: Approach selected by user (
|
|
206
|
+
**CHECKPOINT CP-RW-0.5**: Approach selected by user (Fast Path or Pipeline Path).
|
|
167
207
|
|
|
168
208
|
---
|
|
169
209
|
|
|
170
|
-
## Phase 2: Plan
|
|
210
|
+
## Phase 2: Plan — Pipeline Path Only
|
|
171
211
|
|
|
172
|
-
**Goal**: Generate structured
|
|
212
|
+
**Goal**: Generate structured `.prizmkit/plans/refactor-list.json` from the clarified refactoring goals.
|
|
213
|
+
|
|
214
|
+
Run this phase only when the user selected Pipeline Path or provided a batch/complex refactor request that they chose to send through the pipeline.
|
|
173
215
|
|
|
174
216
|
**STEPS**:
|
|
175
217
|
|
|
176
|
-
1. **
|
|
218
|
+
1. **Planner handoff — invoke `refactor-planner`** with the full goals summary from Phase 1:
|
|
177
219
|
- Pass the structured goals summary as input — NOT the raw user conversation
|
|
178
220
|
- For new refactoring: standard planning mode
|
|
179
221
|
- For existing projects with `--incremental`: incremental planning mode
|
|
180
222
|
- **Input**: Markdown goals summary (refactor targets, scope, behavior preservation strategy)
|
|
181
223
|
- **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
|
|
182
224
|
|
|
183
|
-
2. **Interactive planning** (if refactor-planner requires clarification):
|
|
184
|
-
- Because Phase 1 was thorough, refactor-planner should need minimal clarification
|
|
225
|
+
2. **Interactive planning** (if `refactor-planner` requires clarification):
|
|
226
|
+
- Because Phase 1 was thorough, `refactor-planner` should need minimal clarification
|
|
185
227
|
- If questions arise, answer from the Phase 1 context or pass through to user
|
|
186
228
|
|
|
187
229
|
3. **Validate output**:
|
|
188
230
|
- Confirm `.prizmkit/plans/refactor-list.json` exists
|
|
189
|
-
- Show summary: total refactor items, complexity distribution, dependencies
|
|
231
|
+
- Show summary: total refactor items, complexity distribution, dependencies, behavior-preservation coverage
|
|
190
232
|
|
|
191
233
|
**CHECKPOINT CP-RW-1**: `.prizmkit/plans/refactor-list.json` generated and validated.
|
|
192
234
|
|
|
@@ -194,15 +236,15 @@ AskUserQuestion:
|
|
|
194
236
|
|
|
195
237
|
---
|
|
196
238
|
|
|
197
|
-
## Phase 3: Launch
|
|
239
|
+
## Phase 3: Launch — Pipeline Path Only
|
|
198
240
|
|
|
199
|
-
**Goal**: Start the refactoring pipeline.
|
|
241
|
+
**Goal**: Start the refactoring pipeline after planner handoff has produced a validated refactor list.
|
|
200
242
|
|
|
201
243
|
**STEPS**:
|
|
202
244
|
|
|
203
245
|
1. **Show refactor summary** before launching:
|
|
204
246
|
```
|
|
205
|
-
Ready to launch
|
|
247
|
+
Ready to launch Pipeline Path with N refactor items:
|
|
206
248
|
R-001: Extract auth middleware (medium complexity)
|
|
207
249
|
R-002: Decouple notification service (high complexity)
|
|
208
250
|
R-003: Simplify token flow (low complexity)
|
|
@@ -210,10 +252,11 @@ AskUserQuestion:
|
|
|
210
252
|
Proceed? (Y/n)
|
|
211
253
|
```
|
|
212
254
|
|
|
213
|
-
2. **
|
|
255
|
+
2. **Launcher handoff — invoke `refactor-pipeline-launcher`**:
|
|
214
256
|
- **Input**: Path to validated `.prizmkit/plans/refactor-list.json`
|
|
215
257
|
- The launcher handles all prerequisites checks
|
|
216
258
|
- The launcher presents execution mode choices to the user (foreground/background/manual)
|
|
259
|
+
- The launcher preserves strict behavior-check defaults
|
|
217
260
|
- Do NOT duplicate execution mode selection here — let the launcher handle it
|
|
218
261
|
- **Output**: PID/status, log file path, execution mode selected
|
|
219
262
|
- Returns PID/status and log file location
|
|
@@ -226,9 +269,9 @@ AskUserQuestion:
|
|
|
226
269
|
|
|
227
270
|
---
|
|
228
271
|
|
|
229
|
-
## Phase 4: Monitor
|
|
272
|
+
## Phase 4: Monitor — Pipeline Path Only
|
|
230
273
|
|
|
231
|
-
**Goal**: Track pipeline progress and report to user.
|
|
274
|
+
**Goal**: Track pipeline progress and report to user. Monitoring applies only after `refactor-pipeline-launcher` has started a pipeline.
|
|
232
275
|
|
|
233
276
|
**STEPS**:
|
|
234
277
|
|
|
@@ -271,13 +314,14 @@ AskUserQuestion:
|
|
|
271
314
|
The workflow supports resuming by detecting existing state:
|
|
272
315
|
|
|
273
316
|
| State Found | Resume From |
|
|
274
|
-
|
|
275
|
-
|
|
|
317
|
+
|-------------|-------------|
|
|
318
|
+
| Fast Path `spec.md` + `plan.md` exist, code not committed | Resume `/prizmkit-implement` / review / retrospective / commit based on current state |
|
|
319
|
+
| No `.prizmkit/plans/refactor-list.json` and no Fast Path artifacts | Phase 1: Brainstorm |
|
|
276
320
|
| `.prizmkit/plans/refactor-list.json` exists, no pipeline state | Phase 3: Launch |
|
|
277
321
|
| `.prizmkit/plans/refactor-list.json` + pipeline state exists | Phase 4: Monitor (check status) |
|
|
278
322
|
| All refactors completed | Report completion, suggest next steps |
|
|
279
323
|
|
|
280
|
-
**Resume**: If `.prizmkit/plans/refactor-list.json` exists, ask user: "Existing refactor plan found with N items. Resume
|
|
324
|
+
**Resume**: If `.prizmkit/plans/refactor-list.json` exists, ask user: "Existing refactor plan found with N items. Resume Pipeline Path or re-plan?" If Fast Path artifacts exist, ask whether to continue the current-workspace refactor or discard/re-plan.
|
|
281
325
|
|
|
282
326
|
---
|
|
283
327
|
|
|
@@ -300,21 +344,36 @@ While the pipeline runs, the user can continue the conversation:
|
|
|
300
344
|
|-------|--------|
|
|
301
345
|
| User's refactoring goal is too vague | Ask for more context: "Can you describe what's wrong with the current code structure?" |
|
|
302
346
|
| Brainstorming stalls | Offer concrete options: "Would you prefer incremental or comprehensive refactoring?" |
|
|
303
|
-
| No tests exist for target module | WARN user, recommend writing tests
|
|
347
|
+
| No tests exist for target module | WARN user, recommend writing tests/checks before Fast Path; consider Pipeline Path for risky refactors |
|
|
348
|
+
| Fast Path starts risking behavior change | Pause and ask whether to switch to Pipeline Path (`refactor-planner` → `refactor-pipeline-launcher`) |
|
|
304
349
|
| `refactor-planner` cannot parse goals | Refine the goals summary and retry |
|
|
305
350
|
| `.prizmkit/plans/refactor-list.json` generation failed | Show error, retry with refined input |
|
|
306
351
|
| Pipeline launch failed | Show daemon log, suggest manual start with `python3 ./.prizmkit/dev-pipeline/cli.py refactor run .prizmkit/plans/refactor-list.json` or `python3 ./.prizmkit/dev-pipeline/cli.py daemon refactor start .prizmkit/plans/refactor-list.json` |
|
|
307
352
|
| All refactor items blocked/failed | Show status, suggest retrying specific items |
|
|
308
353
|
| User wants to cancel mid-brainstorming | Save conversation context, offer to resume later |
|
|
309
|
-
| Behavior regression detected during
|
|
354
|
+
| Behavior regression detected during Fast Path | Revert or fix immediately before commit; refactoring cannot ship with behavior regression |
|
|
355
|
+
| Behavior regression detected during pipeline | Pipeline handles per-item retries/failures; report failed items and behavior checks |
|
|
356
|
+
|
|
357
|
+
---
|
|
310
358
|
|
|
359
|
+
## HANDOFF
|
|
311
360
|
|
|
361
|
+
| From | To | Condition |
|
|
362
|
+
|------|----|-----------|
|
|
363
|
+
| **this skill** | `/prizmkit-plan` | User selects Fast Path for simple behavior-preserving refactor work in the current workspace |
|
|
364
|
+
| **this skill** | `/prizmkit-implement` | Fast Path plan is ready for current-session implementation with behavior checks |
|
|
365
|
+
| **this skill** | `/prizmkit-code-review` | Fast Path refactor is complete and needs quality/behavior-preservation review |
|
|
366
|
+
| **this skill** | `/prizmkit-retrospective` | Fast Path refactor changes need `.prizmkit/prizm-docs/` sync before commit |
|
|
367
|
+
| **this skill** | `/prizmkit-committer` | Fast Path refactor is reviewed, docs are synced, and behavior preservation is verified |
|
|
368
|
+
| **this skill** | `refactor-planner` | User selects Pipeline Path for complex or batch refactors |
|
|
369
|
+
| `refactor-planner` | `refactor-pipeline-launcher` | Planner handoff produced validated `.prizmkit/plans/refactor-list.json` |
|
|
370
|
+
| `refactor-pipeline-launcher` | **this skill** | Launcher handoff completed and monitoring/status follow-up is needed |
|
|
371
|
+
|
|
372
|
+
---
|
|
312
373
|
|
|
313
374
|
## Output
|
|
314
375
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
-
|
|
318
|
-
-
|
|
319
|
-
- Multiple git commits with `refactor(<scope>):` prefix
|
|
320
|
-
- Updated `.prizmkit/prizm-docs/` (via prizmkit-retrospective per refactor item)
|
|
376
|
+
Output depends on the selected path:
|
|
377
|
+
|
|
378
|
+
- **Fast Path**: `spec.md` + `plan.md`, behavior-preserving current-workspace code changes, behavior test/check evidence, `/prizmkit-code-review` result, updated `.prizmkit/prizm-docs/`, and one `refactor(<scope>):` commit from `/prizmkit-committer`.
|
|
379
|
+
- **Pipeline Path**: structured refactoring goals summary, `.prizmkit/plans/refactor-list.json`, pipeline execution via `refactor-pipeline-launcher`, monitoring updates, and per-refactor commits managed by the dev-pipeline.
|
|
@@ -30,7 +30,7 @@ This project uses PrizmKit with the Prizm documentation system for AI-optimized
|
|
|
30
30
|
3. Add a pointer in the parent L1 doc's SUBDIRS section
|
|
31
31
|
|
|
32
32
|
### Available Commands
|
|
33
|
-
Run `/
|
|
33
|
+
Run `/prizmkit` to see all available PrizmKit commands.
|
|
34
34
|
|
|
35
35
|
### Fast Path for Simple Changes
|
|
36
36
|
Not every change needs the full spec -> plan workflow. Use fast path for:
|
package/package.json
CHANGED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
const BUILT_IN_AI_CLI_NAMES = new Set(['claude', 'cbc', 'codebuddy', 'codex']);
|
|
2
|
+
|
|
3
|
+
function asText(value) {
|
|
4
|
+
return typeof value === 'string' ? value : '';
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function tokenizeCliArgs(value = '') {
|
|
8
|
+
const text = asText(value);
|
|
9
|
+
if (!text.trim()) return [];
|
|
10
|
+
|
|
11
|
+
const tokens = [];
|
|
12
|
+
let current = '';
|
|
13
|
+
let quote = '';
|
|
14
|
+
let escaping = false;
|
|
15
|
+
let started = false;
|
|
16
|
+
|
|
17
|
+
for (const char of text) {
|
|
18
|
+
if (escaping) {
|
|
19
|
+
current += char;
|
|
20
|
+
escaping = false;
|
|
21
|
+
started = true;
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (char === '\\' && quote !== "'") {
|
|
26
|
+
escaping = true;
|
|
27
|
+
started = true;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (quote) {
|
|
32
|
+
if (char === quote) {
|
|
33
|
+
quote = '';
|
|
34
|
+
} else {
|
|
35
|
+
current += char;
|
|
36
|
+
}
|
|
37
|
+
started = true;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (char === "'" || char === '"') {
|
|
42
|
+
quote = char;
|
|
43
|
+
started = true;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (/\s/.test(char)) {
|
|
48
|
+
if (started) {
|
|
49
|
+
tokens.push(current);
|
|
50
|
+
current = '';
|
|
51
|
+
started = false;
|
|
52
|
+
}
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
current += char;
|
|
57
|
+
started = true;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (escaping) {
|
|
61
|
+
throw new Error('Invalid CLI arguments: trailing escape character');
|
|
62
|
+
}
|
|
63
|
+
if (quote) {
|
|
64
|
+
throw new Error(`Invalid CLI arguments: unclosed ${quote} quote`);
|
|
65
|
+
}
|
|
66
|
+
if (started) tokens.push(current);
|
|
67
|
+
|
|
68
|
+
return tokens;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function formatCliArgsForPrompt(args = []) {
|
|
72
|
+
const tokens = Array.isArray(args) ? args : tokenizeCliArgs(asText(args));
|
|
73
|
+
return tokens.map((token) => {
|
|
74
|
+
const value = String(token);
|
|
75
|
+
if (value === '') return "''";
|
|
76
|
+
if (!/[\s'"\\]/.test(value)) return value;
|
|
77
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
78
|
+
}).join(' ');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function normalizeExecutable(aiCli) {
|
|
82
|
+
const trimmed = asText(aiCli).trim();
|
|
83
|
+
if (!trimmed) return '';
|
|
84
|
+
const tokens = tokenizeCliArgs(trimmed);
|
|
85
|
+
if (tokens.length !== 1) {
|
|
86
|
+
throw new Error('自定义 AI CLI 需要把可执行命令和额外参数分开填写;请把额外参数写入无头模式希望添加的参数。');
|
|
87
|
+
}
|
|
88
|
+
return tokens[0];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function executableBasename(aiCli) {
|
|
92
|
+
const executable = normalizeExecutable(aiCli);
|
|
93
|
+
return executable.split(/[\\/]/).pop()?.toLowerCase() || '';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function isBuiltInAiCli(aiCli) {
|
|
97
|
+
if (!asText(aiCli).trim()) return false;
|
|
98
|
+
return BUILT_IN_AI_CLI_NAMES.has(executableBasename(aiCli));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function isCustomAiCli(aiCli) {
|
|
102
|
+
return Boolean(asText(aiCli).trim()) && !isBuiltInAiCli(aiCli);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function normalizePromptArg(value) {
|
|
106
|
+
const raw = asText(value).trim();
|
|
107
|
+
if (!raw) {
|
|
108
|
+
throw new Error('自定义 AI CLI 需要同时填写可执行命令和提示词注入参数。');
|
|
109
|
+
}
|
|
110
|
+
const tokens = tokenizeCliArgs(raw);
|
|
111
|
+
if (tokens.length !== 1 || !tokens[0]) {
|
|
112
|
+
throw new Error('自定义 AI CLI 的提示词注入参数必须是一个 argv token,例如 -p 或 -i。');
|
|
113
|
+
}
|
|
114
|
+
return tokens[0];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function normalizeExtraArgs(value) {
|
|
118
|
+
if (Array.isArray(value)) {
|
|
119
|
+
return value.map((item) => {
|
|
120
|
+
if (typeof item !== 'string') {
|
|
121
|
+
throw new Error('自定义 AI CLI 的额外参数必须是字符串 argv token。');
|
|
122
|
+
}
|
|
123
|
+
return item;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return tokenizeCliArgs(asText(value));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function storedAiCliLaunch(config = {}) {
|
|
130
|
+
const launch = config?.ai_cli_launch;
|
|
131
|
+
if (!launch || typeof launch !== 'object' || launch.profile !== 'custom') {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
profile: 'custom',
|
|
136
|
+
prompt_arg: asText(launch.prompt_arg),
|
|
137
|
+
extra_args: Array.isArray(launch.extra_args) ? [...launch.extra_args] : asText(launch.extra_args),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function resolveAiCliLaunchSelection(aiCli, options = {}) {
|
|
142
|
+
const normalizedAiCli = normalizeExecutable(aiCli);
|
|
143
|
+
if (!normalizedAiCli) {
|
|
144
|
+
return { aiCli: '', aiCliLaunch: null };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (isBuiltInAiCli(normalizedAiCli)) {
|
|
148
|
+
return { aiCli: normalizedAiCli, aiCliLaunch: null };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const existingLaunch = options.aiCliLaunch || options.existingLaunch || {};
|
|
152
|
+
const promptArg = options.headlessPromptArg
|
|
153
|
+
?? options.promptArg
|
|
154
|
+
?? existingLaunch.prompt_arg
|
|
155
|
+
?? existingLaunch.promptArg
|
|
156
|
+
?? '';
|
|
157
|
+
const extraArgs = options.headlessExtraArgs
|
|
158
|
+
?? options.extraArgs
|
|
159
|
+
?? existingLaunch.extra_args
|
|
160
|
+
?? existingLaunch.extraArgs
|
|
161
|
+
?? [];
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
aiCli: normalizedAiCli,
|
|
165
|
+
aiCliLaunch: {
|
|
166
|
+
profile: 'custom',
|
|
167
|
+
prompt_arg: normalizePromptArg(promptArg),
|
|
168
|
+
extra_args: normalizeExtraArgs(extraArgs),
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export function applyAiCliLaunchToConfig(existingConfig = {}, selection = {}) {
|
|
174
|
+
const nextConfig = { ...existingConfig };
|
|
175
|
+
const aiCli = asText(selection.aiCli).trim();
|
|
176
|
+
|
|
177
|
+
if (!aiCli) {
|
|
178
|
+
delete nextConfig.ai_cli;
|
|
179
|
+
delete nextConfig.ai_cli_launch;
|
|
180
|
+
return nextConfig;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
nextConfig.ai_cli = aiCli;
|
|
184
|
+
if (selection.aiCliLaunch) {
|
|
185
|
+
nextConfig.ai_cli_launch = {
|
|
186
|
+
profile: 'custom',
|
|
187
|
+
prompt_arg: selection.aiCliLaunch.prompt_arg,
|
|
188
|
+
extra_args: [...selection.aiCliLaunch.extra_args],
|
|
189
|
+
};
|
|
190
|
+
} else {
|
|
191
|
+
delete nextConfig.ai_cli_launch;
|
|
192
|
+
}
|
|
193
|
+
return nextConfig;
|
|
194
|
+
}
|