@claude-pw/framework 0.5.0 → 0.5.1
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/install.js
CHANGED
|
@@ -15,7 +15,7 @@ const path = require('path');
|
|
|
15
15
|
const readline = require('readline');
|
|
16
16
|
const { execSync } = require('child_process');
|
|
17
17
|
|
|
18
|
-
const VERSION = '
|
|
18
|
+
const VERSION = require('./package.json').version;
|
|
19
19
|
|
|
20
20
|
// --- Colors ---
|
|
21
21
|
const c = {
|
|
@@ -290,14 +290,18 @@ async function main() {
|
|
|
290
290
|
let projectName = '';
|
|
291
291
|
|
|
292
292
|
// Parse arguments
|
|
293
|
-
|
|
293
|
+
let extractDir = null;
|
|
294
|
+
for (let i = 0; i < args.length; i++) {
|
|
295
|
+
const arg = args[i];
|
|
294
296
|
if (arg === '--update') updateOnly = true;
|
|
297
|
+
else if (arg === '--extract') { extractDir = args[++i]; }
|
|
295
298
|
else if (arg === '--version') { console.log(`claude-pw ${VERSION}`); process.exit(0); }
|
|
296
299
|
else if (arg === '--help' || arg === '-h') {
|
|
297
300
|
console.log('claude-pw — Structured Project Workflow for Claude Code\n');
|
|
298
301
|
console.log('Usage:');
|
|
299
302
|
console.log(' claude-pw [project-name] Create new project');
|
|
300
303
|
console.log(' claude-pw --update Update .claude/ in existing project');
|
|
304
|
+
console.log(' claude-pw --extract <dir> Extract templates to directory (for /cpw-update)');
|
|
301
305
|
console.log(' claude-pw --version Show version');
|
|
302
306
|
process.exit(0);
|
|
303
307
|
} else if (arg.startsWith('-')) {
|
|
@@ -318,6 +322,23 @@ async function main() {
|
|
|
318
322
|
|
|
319
323
|
const date = new Date().toISOString().slice(0, 10);
|
|
320
324
|
|
|
325
|
+
// ============================================================
|
|
326
|
+
// EXTRACT MODE (for /cpw-update command)
|
|
327
|
+
// ============================================================
|
|
328
|
+
if (extractDir) {
|
|
329
|
+
if (!extractDir || typeof extractDir !== 'string') {
|
|
330
|
+
error('Usage: --extract <directory>');
|
|
331
|
+
process.exit(1);
|
|
332
|
+
}
|
|
333
|
+
fs.cpSync(templatesDir, extractDir, { recursive: true });
|
|
334
|
+
const releasesFile = path.join(scriptDir, 'RELEASES.md');
|
|
335
|
+
if (fs.existsSync(releasesFile)) {
|
|
336
|
+
fs.copyFileSync(releasesFile, path.join(extractDir, 'RELEASES.md'));
|
|
337
|
+
}
|
|
338
|
+
fs.writeFileSync(path.join(extractDir, '.version'), VERSION);
|
|
339
|
+
process.exit(0);
|
|
340
|
+
}
|
|
341
|
+
|
|
321
342
|
// ============================================================
|
|
322
343
|
// UPDATE MODE
|
|
323
344
|
// ============================================================
|
|
@@ -372,15 +393,23 @@ async function main() {
|
|
|
372
393
|
console.log(' settings.json (merge, custom hooks preserved)');
|
|
373
394
|
console.log(' config.json (merge new fields)');
|
|
374
395
|
if (allModified.length > 0) {
|
|
375
|
-
console.log(`\n ${c.yellow('Modified
|
|
396
|
+
console.log(`\n ${c.yellow('Modified (differs from new version):')}`);
|
|
376
397
|
for (const f of allModified) console.log(` ${f}`);
|
|
398
|
+
console.log(`\n For intelligent merge of modified files, use ${c.bold('/cpw-update')} inside Claude instead.`);
|
|
377
399
|
}
|
|
378
400
|
console.log(`\n Backup: .claude.backup.* (created before changes)\n`);
|
|
379
401
|
|
|
380
|
-
const confirm = await askQuestion('Apply? [y/N]: ');
|
|
381
|
-
if (
|
|
382
|
-
|
|
383
|
-
|
|
402
|
+
const confirm = await askQuestion(`${allModified.length > 0 ? 'Replace all (r) / Cancel (c): ' : 'Apply? [y/N]: '}`);
|
|
403
|
+
if (allModified.length > 0) {
|
|
404
|
+
if (!/^[rR]$/.test(confirm)) {
|
|
405
|
+
info('Cancelled. Use /cpw-update inside Claude for merge support.');
|
|
406
|
+
process.exit(0);
|
|
407
|
+
}
|
|
408
|
+
} else {
|
|
409
|
+
if (!/^[yYsS]$/.test(confirm)) {
|
|
410
|
+
info('Cancelled.');
|
|
411
|
+
process.exit(0);
|
|
412
|
+
}
|
|
384
413
|
}
|
|
385
414
|
|
|
386
415
|
// Backup
|
package/package.json
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
description: "Load context and execute the next pipeline stage"
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
## Arguments
|
|
6
|
+
- No arguments: normal flow (respects `autoAdvance` from config)
|
|
7
|
+
- `--phase`: auto-advance all steps in the current phase, pause at UAT. Overrides `autoAdvance` to `auto` for this invocation only. Does NOT cross to next phase.
|
|
8
|
+
|
|
5
9
|
## 0. Health check (session start)
|
|
6
10
|
|
|
7
11
|
### Handoff detection
|
|
@@ -25,8 +29,19 @@ Delegate to the session-recovery agent in CHECK mode:
|
|
|
25
29
|
- If INCONSISTENT: show diagnostic. Do NOT continue without user decision.
|
|
26
30
|
|
|
27
31
|
## 1. Load context
|
|
32
|
+
|
|
33
|
+
If STATUS.md does not exist:
|
|
34
|
+
- Report:
|
|
35
|
+
```
|
|
36
|
+
No STATUS.md found — this project hasn't been initialized yet.
|
|
37
|
+
|
|
38
|
+
Next: run `/cpw-startup` to set up the project.
|
|
39
|
+
```
|
|
40
|
+
- STOP. Do not continue.
|
|
41
|
+
|
|
28
42
|
- Read STATUS.md -> phase, step, stage
|
|
29
43
|
- Read indicated sub-plan (plans/phase-N.md)
|
|
44
|
+
- If the file does not exist: report "Sub-plan plans/phase-N.md not found. STATUS.md may be pointing to a non-existent phase. Run `/cpw-health` to diagnose." STOP.
|
|
30
45
|
- If `plans/phase-N-context.md` exists (from /cpw-discuss), load it too
|
|
31
46
|
- Load ONLY files in "Required context" — nothing else
|
|
32
47
|
- Read `.planning/config.json` -> autoAdvance (off | auto | yolo)
|
|
@@ -258,7 +273,7 @@ Then execute the current stage (check docs/tooling.md for tools mapped to this s
|
|
|
258
273
|
Max retries: [from `maxConsecutiveFailures` in config, default: 3]
|
|
259
274
|
Wait for the agent's structured report.
|
|
260
275
|
- If SUCCESS → proceed to ACCEPTANCE with the report as summary
|
|
261
|
-
- If PARTIAL → present partial results to user. Options: continue to ACCEPTANCE / retry / abort
|
|
276
|
+
- If PARTIAL → if autoAdvance is auto/yolo or `--phase`: retry automatically (up to max retries). Otherwise: present partial results to user. Options: continue to ACCEPTANCE / retry / abort
|
|
262
277
|
- If FAILED → present failure details. Options: retry with modified design / abort step
|
|
263
278
|
- Deviations field → included in ACCEPTANCE summary for reviewer visibility
|
|
264
279
|
- **TEST:** The implementer already ran tests. Review its test report.
|
|
@@ -309,7 +324,7 @@ If no self-check triggers or gates don't pass: continue normally.
|
|
|
309
324
|
### Auto-reflect check (CLOSE sub-step 5)
|
|
310
325
|
Read `autoReflect` from `.planning/config.json` (default: "remind").
|
|
311
326
|
If `autoReflect` is `"auto"` AND `.planning/learnings/queue.md` has entries:
|
|
312
|
-
- Run a lightweight reflection
|
|
327
|
+
- Run a lightweight reflection: semantic validation → classify each entry with learning-extractor → apply approved changes → cleanup queue (skip history scan, skip user presentation for confidence ≥ 0.80, skip dedup)
|
|
313
328
|
- Auto-approve entries with confidence ≥ 0.80
|
|
314
329
|
- Present entries with confidence < 0.80 for manual approval
|
|
315
330
|
- `make commit m="learn: auto-reflect session learnings"`
|
|
@@ -319,7 +334,8 @@ Update STATUS.md with the new stage when finished.
|
|
|
319
334
|
|
|
320
335
|
## 2. Advance based on mode
|
|
321
336
|
|
|
322
|
-
|
|
337
|
+
If `--phase` flag was passed, set effective autoAdvance = "auto" for this invocation.
|
|
338
|
+
Otherwise, read `autoAdvance` from `.planning/config.json` (default: "off").
|
|
323
339
|
Read `maxConsecutiveFailures` from config (default: 3 for auto, 5 for yolo).
|
|
324
340
|
|
|
325
341
|
### off (default)
|
|
@@ -348,7 +364,13 @@ In yolo mode, Claude designs, implements, tests, closes, validates phases, and a
|
|
|
348
364
|
- Commit messages are auto-generated in auto and yolo (no pause)
|
|
349
365
|
- Phase validation always runs automatically when last step completes
|
|
350
366
|
- Between phases: auto and yolo continue automatically (run tooling audit → next step); off always stops
|
|
351
|
-
-
|
|
367
|
+
- `--phase` flag: ALWAYS stop between phases, regardless of effective autoAdvance. Report:
|
|
368
|
+
```
|
|
369
|
+
Phase N complete. UAT next.
|
|
370
|
+
|
|
371
|
+
Next: continue with `/cpw-next-step` for UAT.
|
|
372
|
+
```
|
|
373
|
+
- If context fills up (3+ auto-advanced steps), suggest /clear and re-invoke /cpw-next-step (add `--phase` if it was active)
|
|
352
374
|
|
|
353
375
|
## 3. Phase validation (auto-triggered when all steps are done)
|
|
354
376
|
|
|
@@ -267,12 +267,20 @@ Save responses in `.planning/config.json`:
|
|
|
267
267
|
"modelProfile": "quality|balanced|budget",
|
|
268
268
|
"modelOverrides": {},
|
|
269
269
|
"gitStrategy": "trunk-based|feature-branch|gitflow",
|
|
270
|
-
"commitPlanning": false
|
|
270
|
+
"commitPlanning": false,
|
|
271
|
+
"toolingSources": ["skills.sh", "claude-code-templates"],
|
|
272
|
+
"maxConsecutiveFailures": 3,
|
|
273
|
+
"autoReflect": "remind"
|
|
271
274
|
}
|
|
272
275
|
```
|
|
273
276
|
|
|
274
277
|
If the user has no preference, use defaults (off/standard/balanced/no).
|
|
275
278
|
|
|
279
|
+
Advanced settings (not asked during interview — edit `.planning/config.json` directly):
|
|
280
|
+
- `toolingSources`: where to search for skills/MCPs during tooling audit (default: `["skills.sh", "claude-code-templates"]`)
|
|
281
|
+
- `maxConsecutiveFailures`: halt auto-advance after N failures in same stage (default: 3 for auto, 5 for yolo)
|
|
282
|
+
- `autoReflect`: process learning queue automatically (`off` / `remind` / `auto`, default: `remind`)
|
|
283
|
+
|
|
276
284
|
**If `commitPlanning: true`:**
|
|
277
285
|
- Remove `.planning/` from `.gitignore`
|
|
278
286
|
- Planning artifacts (config, learnings, decisions, debug sessions) will be tracked in git
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Update claude-pw framework — diff, merge, apply intelligently"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## 1. Check version
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
INSTALLED=$(cat .claude/.claude-pw-version 2>/dev/null || echo "0.0.0")
|
|
9
|
+
AVAILABLE=$(npx @claude-pw/framework --version 2>/dev/null)
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
If same version: "Already up to date at v${INSTALLED}." STOP.
|
|
13
|
+
If different: show "Update available: v${INSTALLED} → v${AVAILABLE}"
|
|
14
|
+
|
|
15
|
+
## 2. Extract new templates
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
rm -rf /tmp/cpw-update
|
|
19
|
+
npx @claude-pw/framework --extract /tmp/cpw-update
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Read `/tmp/cpw-update/RELEASES.md` and show changelog entries between installed and available versions.
|
|
23
|
+
|
|
24
|
+
## 3. Diff files
|
|
25
|
+
|
|
26
|
+
Compare each file in these categories:
|
|
27
|
+
|
|
28
|
+
| Category | Project path | Template path |
|
|
29
|
+
|----------|-------------|---------------|
|
|
30
|
+
| Commands | `.claude/commands/*.md` | `/tmp/cpw-update/claude/commands/*.md` |
|
|
31
|
+
| Agents | `.claude/agents/*.md` | `/tmp/cpw-update/claude/agents/*.md` |
|
|
32
|
+
| Rules | `.claude/rules/*.md` | `/tmp/cpw-update/claude/rules/*.md` |
|
|
33
|
+
| Hooks | `.claude/hooks/*.js` | `/tmp/cpw-update/claude/hooks/*.js` |
|
|
34
|
+
| Settings | `.claude/settings.json` | `/tmp/cpw-update/claude/settings.json` |
|
|
35
|
+
| Config | `.planning/config.json` | `/tmp/cpw-update/planning/config.json` |
|
|
36
|
+
|
|
37
|
+
For each file, classify:
|
|
38
|
+
- **NEW** — in template only → will be added
|
|
39
|
+
- **UNCHANGED** — identical content → skip
|
|
40
|
+
- **UPDATED** — template changed, user didn't modify → safe overwrite
|
|
41
|
+
- **CONFLICT** — both changed → needs merge
|
|
42
|
+
- **CUSTOM** — in project only → preserve (user's own file)
|
|
43
|
+
|
|
44
|
+
Heuristic for UPDATED vs CONFLICT: if project file differs from new template AND contains sections/lines not present in the new template, it's a CONFLICT. If the new template is a strict superset of the project file (only additions), it's UPDATED.
|
|
45
|
+
|
|
46
|
+
## 4. Present summary
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
Update: v{INSTALLED} → v{AVAILABLE}
|
|
50
|
+
|
|
51
|
+
Commands:
|
|
52
|
+
UPDATED cpw-next-step.md (+25 lines)
|
|
53
|
+
UNCHANGED cpw-startup.md
|
|
54
|
+
NEW cpw-new-command.md
|
|
55
|
+
...
|
|
56
|
+
|
|
57
|
+
Agents:
|
|
58
|
+
UPDATED implementer.md (+20 lines)
|
|
59
|
+
CONFLICT researcher.md — you added custom content
|
|
60
|
+
CUSTOM my-agent.md — your file, preserved
|
|
61
|
+
...
|
|
62
|
+
|
|
63
|
+
Config:
|
|
64
|
+
NEW FIELDS [list of new fields with defaults]
|
|
65
|
+
|
|
66
|
+
Apply? (all / review conflicts first / cancel)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 5. Apply changes
|
|
70
|
+
|
|
71
|
+
### NEW and UPDATED files:
|
|
72
|
+
Copy from `/tmp/cpw-update/` to project. Overwrite safely.
|
|
73
|
+
|
|
74
|
+
### CONFLICT files:
|
|
75
|
+
For each conflicted file:
|
|
76
|
+
1. Read user's version (project file)
|
|
77
|
+
2. Read new template version (`/tmp/cpw-update/`)
|
|
78
|
+
3. Identify user's custom additions (sections, rules, modifications not in template)
|
|
79
|
+
4. Merge: start with new template, re-add user's custom sections at appropriate locations
|
|
80
|
+
5. Show the merged result to user: "Here's the merged version of [file]. OK? (yes / edit / skip)"
|
|
81
|
+
6. If skip: keep user's version unchanged
|
|
82
|
+
|
|
83
|
+
### settings.json:
|
|
84
|
+
Merge: add new hooks from template, preserve user's custom hooks. Do NOT overwrite existing hooks.
|
|
85
|
+
|
|
86
|
+
### config.json:
|
|
87
|
+
Add new fields with defaults. Do NOT overwrite user's existing values.
|
|
88
|
+
|
|
89
|
+
### CUSTOM files:
|
|
90
|
+
Never touch. Report: "[file] is your custom file — preserved."
|
|
91
|
+
|
|
92
|
+
## 6. Finalize
|
|
93
|
+
|
|
94
|
+
Update version:
|
|
95
|
+
```bash
|
|
96
|
+
echo "{AVAILABLE}" > .claude/.claude-pw-version
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Clean up:
|
|
100
|
+
```bash
|
|
101
|
+
rm -rf /tmp/cpw-update
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Commit:
|
|
105
|
+
`make commit m="chore: update claude-pw to v{AVAILABLE}"`
|
|
106
|
+
|
|
107
|
+
Report:
|
|
108
|
+
```
|
|
109
|
+
Updated to v{AVAILABLE}.
|
|
110
|
+
|
|
111
|
+
Next: `/cpw-next-step` to continue with the plan.
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Rollback
|
|
115
|
+
|
|
116
|
+
If the user reports issues after update:
|
|
117
|
+
- Previous state is in git history: `git diff HEAD~1 -- .claude/`
|
|
118
|
+
- Revert: `git checkout HEAD~1 -- .claude/`
|
|
119
|
+
- Or selectively: `git checkout HEAD~1 -- .claude/agents/researcher.md`
|