@claude-pw/framework 0.8.0 → 0.9.0

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/README.es.md CHANGED
@@ -169,8 +169,8 @@ Issue capturado. ¿Arreglar ahora? (sí/no)
169
169
  ```
170
170
  mi-proyecto/
171
171
  ├── .claude/
172
- │ ├── commands/ 10 slash commands (/cpw-*)
173
- │ ├── agents/ 11 agentes especializados
172
+ │ ├── commands/ 12 slash commands (/cpw-*)
173
+ │ ├── agents/ 12 agentes especializados (4 con memoria persistente)
174
174
  │ ├── rules/ 3 reglas context-aware (git, interfaces, testing)
175
175
  │ ├── hooks/ Hooks Node.js (statusline, monitor de contexto)
176
176
  │ └── settings.json
package/README.ja.md CHANGED
@@ -169,8 +169,8 @@ Issue captured. Fix now? (yes/no)
169
169
  ```
170
170
  my-project/
171
171
  ├── .claude/
172
- │ ├── commands/ 10個のスラッシュコマンド (/cpw-*)
173
- │ ├── agents/ 11個の専門エージェント
172
+ │ ├── commands/ 12個のスラッシュコマンド (/cpw-*)
173
+ │ ├── agents/ 12個の専門エージェント(4つに永続メモリ)
174
174
  │ ├── rules/ 3つのコンテキスト対応ルール(git、インターフェース、テスト)
175
175
  │ ├── hooks/ Node.js フック(ステータスライン、コンテキストモニター)
176
176
  │ └── settings.json
package/README.md CHANGED
@@ -169,8 +169,8 @@ Issue captured. Fix now? (yes/no)
169
169
  ```
170
170
  my-project/
171
171
  ├── .claude/
172
- │ ├── commands/ 10 slash commands (/cpw-*)
173
- │ ├── agents/ 11 specialized agents
172
+ │ ├── commands/ 12 slash commands (/cpw-*)
173
+ │ ├── agents/ 12 specialized agents (4 with persistent memory)
174
174
  │ ├── rules/ 3 context-aware rules (git, interfaces, testing)
175
175
  │ ├── hooks/ Node.js hooks (statusline, context monitor)
176
176
  │ └── settings.json
package/README.pt-br.md CHANGED
@@ -169,8 +169,8 @@ Issue captured. Fix now? (yes/no)
169
169
  ```
170
170
  my-project/
171
171
  ├── .claude/
172
- │ ├── commands/ 10 slash commands (/cpw-*)
173
- │ ├── agents/ 11 agentes especializados
172
+ │ ├── commands/ 12 slash commands (/cpw-*)
173
+ │ ├── agents/ 12 agentes especializados (4 com memória persistente)
174
174
  │ ├── rules/ 3 regras sensíveis ao contexto (git, interfaces, testes)
175
175
  │ ├── hooks/ Hooks Node.js (statusline, monitor de contexto)
176
176
  │ └── settings.json
package/README.zh-cn.md CHANGED
@@ -169,8 +169,8 @@ UAT 演练:
169
169
  ```
170
170
  my-project/
171
171
  ├── .claude/
172
- │ ├── commands/ 10 个斜杠命令(/cpw-*)
173
- │ ├── agents/ 11 个专用代理
172
+ │ ├── commands/ 12 个斜杠命令(/cpw-*)
173
+ │ ├── agents/ 12 个专用代理(4 个具有持久记忆)
174
174
  │ ├── rules/ 3 个上下文感知规则(git、interfaces、testing)
175
175
  │ ├── hooks/ Node.js 钩子(状态栏、上下文监控)
176
176
  │ └── settings.json
package/RELEASES.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  Formato: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
4
4
 
5
+ ## [0.9.0] - 2026-03-15
6
+
7
+ ### Added
8
+ - `/cpw-cleanup` command — archive completed phase files and clean accumulated state (.planning/archive/)
9
+ - `cleanupPolicy` in config.json — configurable retention for applied learnings, debug sessions, quick log entries
10
+ - Cleanup suggestion in `/cpw-next-step` after phase advancement (when 3+ completed phases unarchived)
11
+
5
12
  ## [0.3.0] - 2026-03-15
6
13
 
7
14
  ### Added
package/install.js CHANGED
@@ -602,7 +602,7 @@ async function main() {
602
602
  header('Listo');
603
603
  console.log('');
604
604
  console.log(` ${projectName}/`);
605
- console.log(' ├── .claude/commands/ 10 commands (/cpw-startup, /cpw-next-step, /cpw-quick, ...)');
605
+ console.log(' ├── .claude/commands/ 12 commands (/cpw-startup, /cpw-next-step, /cpw-quick, ...)');
606
606
  console.log(' ├── .claude/agents/ 11 agentes (plan-checker, debugger, researcher, implementer, ...)');
607
607
  console.log(' ├── .claude/rules/ 3 reglas (interfaces, testing, git)');
608
608
  console.log(' ├── .claude/hooks/ 2 hooks (statusline, context monitor)');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-pw/framework",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Structured Project Workflow for Claude Code — adaptive pipeline, context management, quality gates",
5
5
  "bin": {
6
6
  "claude-pw": "./install.js"
@@ -24,6 +24,7 @@ TODO: Phase 0
24
24
  - Ad-hoc tasks that don't affect the plan -> /cpw-quick
25
25
  - Debug that may take several sessions -> /cpw-debug (persists state)
26
26
  - If something seems broken or inconsistent -> /cpw-health
27
+ - Completed phases accumulating? -> /cpw-cleanup (archive and free context)
27
28
  - If the user corrects you, capture the correction in .planning/learnings/queue.md (include the active command in the Command field)
28
29
  - Learnings are auto-processed based on config (autoReflect: off/remind/auto)
29
30
  - When you discover something non-obvious (debug, workaround), evaluate for skill extraction → .claude/skills/
@@ -37,4 +38,4 @@ TODO: Phase 0
37
38
  - plans/decisions.md — Decisions and RFCs
38
39
  - src/interfaces/ — Contracts (RFC required to modify)
39
40
  - .planning/ — Project state (gitignored by default, set commitPlanning: true to track)
40
- - .planning/config.json — Workflow config (autoAdvance, granularity, modelProfile, modelOverrides, gitStrategy, commitPlanning, toolingSources, maxConsecutiveFailures, autoReflect)
41
+ - .planning/config.json — Workflow config (autoAdvance, granularity, modelProfile, modelOverrides, gitStrategy, commitPlanning, toolingSources, maxConsecutiveFailures, autoReflect, cleanupPolicy)
@@ -0,0 +1,139 @@
1
+ ---
2
+ description: "Archive completed phases and clean accumulated state"
3
+ ---
4
+
5
+ ## Arguments
6
+ - No arguments: dry-run (show what would be cleaned, ask for confirmation)
7
+ - `--execute`: skip confirmation, execute immediately
8
+
9
+ ## 0. Load state
10
+
11
+ Read `.planning/config.json` -> extract `cleanupPolicy` (use defaults if missing):
12
+ - `archiveCompletedPhases`: true
13
+ - `keepAppliedLearnings`: 20
14
+ - `keepResolvedDebug`: 5
15
+ - `keepQuickLogDone`: 10
16
+
17
+ Read PLAN.md -> extract phases table. Identify phases with Status = "done".
18
+ Read STATUS.md -> identify current phase (to avoid archiving it).
19
+
20
+ If no completed phases and no accumulated state to clean:
21
+ ```
22
+ Nothing to clean up. All phases are current or pending.
23
+ ```
24
+ STOP.
25
+
26
+ ## 1. Identify what to clean
27
+
28
+ ### 1.1 Completed phase files
29
+ If `archiveCompletedPhases` is true:
30
+ For each phase with Status "done" in PLAN.md:
31
+ - Check if `plans/phase-N.md` still exists (not already archived)
32
+ - Check if `plans/phase-N-context.md` exists
33
+ - Add to archive list
34
+ - NEVER archive the current phase or pending phases
35
+
36
+ ### 1.2 Quick log done entries
37
+ Read `.planning/quick/log.md` (if exists):
38
+ - Count entries with Status: done or dismissed
39
+ - If count > `keepQuickLogDone`: mark oldest excess entries for removal
40
+
41
+ ### 1.3 Resolved debug sessions
42
+ List `.planning/debug/resolved/` (if exists):
43
+ - Count files
44
+ - If count > `keepResolvedDebug`: mark oldest files for deletion (by filename date prefix)
45
+
46
+ ### 1.4 Applied learnings
47
+ Read `.planning/learnings/applied.md` (if exists):
48
+ - Count entries (each entry starts with `---`)
49
+ - If count > `keepAppliedLearnings`: mark oldest excess entries for trimming
50
+
51
+ ### 1.5 Stale files
52
+ - `.planning/handoff.md` — if it exists AND STATUS.md does NOT show a handoff in progress
53
+ - `.planning/uat.md` — if it exists AND all phases it references are done (no active UAT)
54
+
55
+ ## 2. Present cleanup plan
56
+
57
+ ```
58
+ Cleanup Summary:
59
+
60
+ ARCHIVE (move to .planning/archive/):
61
+ - plans/phase-0.md (6 steps, all done)
62
+ - plans/phase-0-context.md
63
+ - plans/phase-1.md (4 steps, all done)
64
+
65
+ TRIM:
66
+ - quick/log.md: remove N done entries (keeping last M)
67
+ - debug/resolved/: delete N old sessions (keeping last M)
68
+ - learnings/applied.md: trim N old entries (keeping last M)
69
+
70
+ DELETE:
71
+ - .planning/handoff.md (stale)
72
+
73
+ NO CHANGES:
74
+ - plans/phase-2.md (current phase)
75
+ - plans/decisions.md (cumulative, always kept)
76
+ - docs/* (living documentation, always kept)
77
+ ```
78
+
79
+ If nothing to clean in a category, omit it from the summary.
80
+
81
+ If `--execute`: show the summary and proceed to step 3.
82
+ Otherwise: ask "Proceed? (yes/no)". If no: STOP.
83
+
84
+ ## 3. Execute
85
+
86
+ ### 3.1 Archive phase files
87
+ ```bash
88
+ mkdir -p .planning/archive
89
+ ```
90
+ For each phase in the archive list:
91
+ - Move `plans/phase-N.md` to `.planning/archive/phase-N.md`
92
+ - Move `plans/phase-N-context.md` to `.planning/archive/phase-N-context.md` (if exists)
93
+
94
+ ### 3.2 Update PLAN.md
95
+ For each archived phase, change the sub-plan column from `plans/phase-N.md` to `(archived)`:
96
+ ```
97
+ | 0 | Stack and Scaffolding | plans/phase-0.md | done |
98
+ ```
99
+ becomes:
100
+ ```
101
+ | 0 | Stack and Scaffolding | (archived) | done |
102
+ ```
103
+
104
+ ### 3.3 Trim quick log
105
+ Remove done/dismissed entries beyond the keep limit from `.planning/quick/log.md`.
106
+ Keep the most recent N entries (by date). Preserve the table header.
107
+
108
+ ### 3.4 Delete old debug sessions
109
+ Delete files from `.planning/debug/resolved/` beyond the keep limit.
110
+ Delete the oldest by filename date prefix.
111
+
112
+ ### 3.5 Trim applied learnings
113
+ Remove the oldest entries from `.planning/learnings/applied.md` beyond the keep limit.
114
+ Keep the most recent N entries. Each entry is delimited by `---`.
115
+
116
+ ### 3.6 Delete stale files
117
+ Delete identified stale files (handoff.md, uat.md).
118
+
119
+ ### 3.7 Commit
120
+ Read `commitPlanning` from `.planning/config.json`.
121
+
122
+ Git add the changes:
123
+ - `PLAN.md` (always — sub-plan column updated)
124
+ - `plans/` (always — phase files removed)
125
+ - `.planning/` (only if `commitPlanning: true`)
126
+
127
+ `make commit m="chore: cleanup completed phases and accumulated state"`
128
+
129
+ ## 4. Report
130
+
131
+ ```
132
+ Cleanup complete.
133
+
134
+ Archived: N phase files → .planning/archive/
135
+ Trimmed: M quick log entries, K debug sessions, L learnings
136
+ Deleted: P stale files
137
+
138
+ Next: /cpw-next-step to continue.
139
+ ```
@@ -8,6 +8,10 @@ description: "Load context and execute the next pipeline stage"
8
8
 
9
9
  ## 0. Health check (session start)
10
10
 
11
+ ### Orphan phase-active cleanup
12
+ If `.planning/.phase-active` exists AND `--phase` flag is NOT active:
13
+ - Delete the file (leftover from interrupted session)
14
+
11
15
  ### Post-update detection
12
16
  If `.planning/.updated-from` exists:
13
17
  - Read the file — it contains the previous version
@@ -266,7 +270,7 @@ Estimated context resets: [N / based on step count, suggest /clear every 3 steps
266
270
  ```
267
271
 
268
272
  Ask: "Execute this plan? (yes / adjust / cancel)"
269
- - **yes**: proceed with auto-advance. When delegating to agents during --phase, spawn them with `permissionMode: bypassPermissions` to avoid permission interruptions.
273
+ - **yes**: create `.planning/.phase-active` (enables auto-approve for tool permissions via PreToolUse hook), then proceed with auto-advance.
270
274
  - **adjust**: ask what to change (skip a step, reorder, modify pipeline). Update sub-plan if needed, re-present.
271
275
  - **cancel**: exit --phase mode, continue as normal /cpw-next-step (step by step)
272
276
 
@@ -576,6 +580,7 @@ If all deliverables passed (or issues were fixed):
576
580
  ## Session notes
577
581
  - (empty)
578
582
  ```
583
+ - Delete `.planning/.phase-active` if it exists (re-enables normal tool permissions)
579
584
  - If `--phase` flag is active: STOP. Do NOT advance to next phase. Report:
580
585
  ```
581
586
  Phase N complete. UAT passed.
@@ -593,4 +598,13 @@ If all deliverables passed (or issues were fixed):
593
598
  " 3. `/cpw-next-step` — start directly"
594
599
  - If autoAdvance is **auto** or **yolo** (and no --phase): Suggest /clear for context refresh, then automatically continue with Phase N+1 (run tooling audit → first step).
595
600
 
601
+ ### Cleanup suggestion
602
+ After phase advancement, count completed phases in PLAN.md that still have sub-plan files in `plans/` (sub-plan column is NOT `(archived)`).
603
+ If count >= 3:
604
+ ```
605
+ Tip: You have N completed phase files that could be archived.
606
+ Run /cpw-cleanup to free up context.
607
+ ```
608
+ This is a suggestion only — do NOT block advancement.
609
+
596
610
  NEVER advance between phases without completing UAT first (in any mode).
@@ -0,0 +1,16 @@
1
+ #!/bin/bash
2
+ # Auto-approve tool calls during --phase execution
3
+ # Created by: /cpw-next-step --phase (creates .planning/.phase-active)
4
+ # Removed by: /cpw-next-step at UAT or phase end
5
+
6
+ PHASE_FILE=".planning/.phase-active"
7
+
8
+ if [ -f "$PHASE_FILE" ]; then
9
+ # Check for stale file (>24h)
10
+ if [ "$(find "$PHASE_FILE" -mmin +1440 2>/dev/null)" ]; then
11
+ rm -f "$PHASE_FILE"
12
+ exit 0
13
+ fi
14
+ echo '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"allow","permissionDecisionReason":"--phase active: plan approved by user"}}'
15
+ fi
16
+ exit 0
@@ -4,6 +4,15 @@
4
4
  "command": "node .claude/hooks/cpw-statusline.js"
5
5
  },
6
6
  "hooks": {
7
+ "PreToolUse": [
8
+ {
9
+ "matcher": "",
10
+ "hooks": [{
11
+ "type": "command",
12
+ "command": "bash .claude/hooks/cpw-phase-approve.sh"
13
+ }]
14
+ }
15
+ ],
7
16
  "UserPromptSubmit": [
8
17
  {
9
18
  "matcher": "",
@@ -7,5 +7,11 @@
7
7
  "toolingSources": ["skills.sh", "claude-code-templates"],
8
8
  "maxConsecutiveFailures": null,
9
9
  "gitStrategy": "trunk-based",
10
- "autoReflect": "remind"
10
+ "autoReflect": "remind",
11
+ "cleanupPolicy": {
12
+ "archiveCompletedPhases": true,
13
+ "keepAppliedLearnings": 20,
14
+ "keepResolvedDebug": 5,
15
+ "keepQuickLogDone": 10
16
+ }
11
17
  }