@fermindi/pwn-cli 0.4.0 β 0.5.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/cli/update.js +4 -3
- package/package.json +1 -1
- package/src/core/inject.js +8 -3
- package/templates/workspace/.ai/agents/claude.md +43 -13
- package/templates/workspace/.ai/memory/patterns.md +11 -57
- package/templates/workspace/.claude/commands/save.md +42 -0
- package/templates/workspace/.claude/settings.json +2 -11
package/cli/update.js
CHANGED
|
@@ -166,12 +166,13 @@ export default async function updateCommand(args = []) {
|
|
|
166
166
|
if (templateContent !== currentContent) {
|
|
167
167
|
if (dryRun) {
|
|
168
168
|
console.log(` π Would update: CLAUDE.md`);
|
|
169
|
-
if (
|
|
169
|
+
// Only mention backup if content is actually different (not empty)
|
|
170
|
+
if (currentContent && currentContent !== templateContent) {
|
|
170
171
|
console.log(` π¦ Would backup: CLAUDE.md β ~CLAUDE.md`);
|
|
171
172
|
}
|
|
172
173
|
} else {
|
|
173
|
-
// Backup existing CLAUDE.md
|
|
174
|
-
if (existsSync(claudeMdPath) && currentContent) {
|
|
174
|
+
// Backup existing CLAUDE.md only if it has custom content (different from template)
|
|
175
|
+
if (existsSync(claudeMdPath) && currentContent && currentContent !== templateContent) {
|
|
175
176
|
renameSync(claudeMdPath, backupClaudeMdPath);
|
|
176
177
|
console.log(` π¦ Backed up: CLAUDE.md β ~CLAUDE.md`);
|
|
177
178
|
backed_up.push('CLAUDE.md');
|
package/package.json
CHANGED
package/src/core/inject.js
CHANGED
|
@@ -175,23 +175,28 @@ export async function inject(options = {}) {
|
|
|
175
175
|
// Update .gitignore
|
|
176
176
|
updateGitignore(cwd, silent);
|
|
177
177
|
|
|
178
|
-
// Handle CLAUDE.md: backup existing and copy PWN template to root
|
|
178
|
+
// Handle CLAUDE.md: backup existing (only if different) and copy PWN template to root
|
|
179
179
|
let backupInfo = { backed_up: [] };
|
|
180
180
|
const claudeMdPath = join(cwd, 'CLAUDE.md');
|
|
181
181
|
const backupClaudeMdPath = join(cwd, '~CLAUDE.md');
|
|
182
182
|
const templateClaudeMd = join(targetDir, 'agents', 'claude.md');
|
|
183
|
+
const templateContent = existsSync(templateClaudeMd) ? readFileSync(templateClaudeMd, 'utf8') : '';
|
|
183
184
|
|
|
184
|
-
// Backup existing CLAUDE.md if present
|
|
185
|
+
// Backup existing CLAUDE.md if present AND different from template
|
|
185
186
|
if (backedUpContent['CLAUDE.md'] || backedUpContent['claude.md']) {
|
|
186
187
|
const originalName = backedUpContent['CLAUDE.md'] ? 'CLAUDE.md' : 'claude.md';
|
|
187
188
|
const originalPath = join(cwd, originalName);
|
|
189
|
+
const existingContent = backedUpContent[originalName]?.content || '';
|
|
188
190
|
|
|
189
|
-
if
|
|
191
|
+
// Only backup if content is different from PWN template
|
|
192
|
+
if (existsSync(originalPath) && existingContent !== templateContent) {
|
|
190
193
|
renameSync(originalPath, backupClaudeMdPath);
|
|
191
194
|
backupInfo.backed_up.push({ from: originalName, to: '~CLAUDE.md' });
|
|
192
195
|
if (!silent) {
|
|
193
196
|
console.log(`π¦ Backed up ${originalName} β ~CLAUDE.md`);
|
|
194
197
|
}
|
|
198
|
+
} else if (existsSync(originalPath) && !silent) {
|
|
199
|
+
console.log(`βοΈ Skipped backup: ${originalName} is identical to PWN template`);
|
|
195
200
|
}
|
|
196
201
|
}
|
|
197
202
|
|
|
@@ -38,9 +38,9 @@ Read these files in order:
|
|
|
38
38
|
- Ask user before deviating from active decisions
|
|
39
39
|
|
|
40
40
|
2. **`/.ai/memory/patterns.md`**
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
- Add
|
|
41
|
+
- Index of patterns documented in `.ai/patterns/`
|
|
42
|
+
- Check which patterns exist for this project
|
|
43
|
+
- Add index entry when creating new pattern files
|
|
44
44
|
|
|
45
45
|
3. **`/.ai/memory/deadends.md`**
|
|
46
46
|
- Failed approaches documented (DE-XXX)
|
|
@@ -208,6 +208,42 @@ If any gate fails:
|
|
|
208
208
|
- Ask user if unsure how to proceed
|
|
209
209
|
- Don't commit until gates pass
|
|
210
210
|
|
|
211
|
+
### Pattern Checkpoint (Mandatory Before Commit)
|
|
212
|
+
|
|
213
|
+
Before every commit, review the work done and check if any pattern should be documented.
|
|
214
|
+
|
|
215
|
+
**Document a pattern when ANY of these criteria are met:**
|
|
216
|
+
|
|
217
|
+
1. **User corrected your approach** - The user told you to do something differently. Document the correct approach so future sessions don't repeat the mistake.
|
|
218
|
+
2. **You chose between alternatives** - You evaluated 2+ options and picked one. Document what was chosen and why.
|
|
219
|
+
3. **Workaround for limitation** - A library, framework, or tool has a non-obvious limitation. Document the workaround.
|
|
220
|
+
4. **Convention established** - First time implementing a certain type of thing in this codebase (first API route, first test, first component). Document the convention for consistency.
|
|
221
|
+
5. **Repeated approach** - You used the same approach 2+ times in this session. Document it to avoid re-deriving it.
|
|
222
|
+
6. **Non-trivial solution** - The solution wasn't obvious or took investigation to find. Document it so it's immediately available next time.
|
|
223
|
+
|
|
224
|
+
**If a criterion is met:**
|
|
225
|
+
|
|
226
|
+
1. Create pattern file: `.ai/patterns/{category}/{pattern-name}.md`
|
|
227
|
+
```markdown
|
|
228
|
+
# Pattern Name
|
|
229
|
+
|
|
230
|
+
## Context
|
|
231
|
+
When to apply this pattern.
|
|
232
|
+
|
|
233
|
+
## Pattern
|
|
234
|
+
Description or code example.
|
|
235
|
+
|
|
236
|
+
## Rationale
|
|
237
|
+
Why this approach works better.
|
|
238
|
+
|
|
239
|
+
## Examples
|
|
240
|
+
- `src/path/file.ts:42`
|
|
241
|
+
```
|
|
242
|
+
2. Add index entry to `.ai/memory/patterns.md`
|
|
243
|
+
3. Commit pattern files together with the code change
|
|
244
|
+
|
|
245
|
+
**If no criteria are met:** proceed to commit normally. Don't force patterns that aren't there.
|
|
246
|
+
|
|
211
247
|
### Commit Message Format
|
|
212
248
|
|
|
213
249
|
Use conventional commits:
|
|
@@ -245,15 +281,9 @@ When completing work:
|
|
|
245
281
|
- [x] US-042: My completed task (YYYY-MM-DD)
|
|
246
282
|
```
|
|
247
283
|
|
|
248
|
-
2.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
### Pattern Name
|
|
253
|
-
**Context:** When to use
|
|
254
|
-
**Pattern:** Description
|
|
255
|
-
**Rationale:** Why it's better
|
|
256
|
-
```
|
|
284
|
+
2. Document patterns following the **Pattern Checkpoint** criteria above
|
|
285
|
+
- Create file in `.ai/patterns/{category}/{name}.md`
|
|
286
|
+
- Add index entry in `.ai/memory/patterns.md`
|
|
257
287
|
|
|
258
288
|
3. Add to `/.ai/memory/deadends.md` if approach failed
|
|
259
289
|
```
|
|
@@ -590,7 +620,7 @@ When finishing a session:
|
|
|
590
620
|
- Add completion date if done
|
|
591
621
|
|
|
592
622
|
3. **Document learnings**
|
|
593
|
-
-
|
|
623
|
+
- Document patterns in `.ai/patterns/` and index in `memory/patterns.md`
|
|
594
624
|
- Update `/.ai/memory/deadends.md` if failed approach
|
|
595
625
|
- Reference in commit messages
|
|
596
626
|
|
|
@@ -1,65 +1,19 @@
|
|
|
1
|
-
# Codebase Patterns
|
|
1
|
+
# Codebase Patterns Index
|
|
2
2
|
|
|
3
|
-
This file
|
|
3
|
+
This file is an index of patterns documented in `.ai/patterns/`.
|
|
4
|
+
Each entry links to the full pattern file.
|
|
4
5
|
|
|
5
|
-
##
|
|
6
|
+
## Registered Patterns
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
<!-- AI: Add entries here as you create pattern files -->
|
|
9
|
+
<!-- Format: - [{category}/{name}](.ai/patterns/{category}/{name}.md) - Brief description -->
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
## Pattern Category
|
|
11
|
-
|
|
12
|
-
### Pattern Name
|
|
13
|
-
**Context:** When this pattern applies
|
|
14
|
-
**Pattern:** Code example or description
|
|
15
|
-
**Rationale:** Why this is the better approach
|
|
16
|
-
**Example Location:** Where to find real examples
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Add New Patterns
|
|
22
|
-
|
|
23
|
-
When you discover a useful pattern:
|
|
24
|
-
|
|
25
|
-
1. Identify the category (Frontend, Backend, Testing, etc.)
|
|
26
|
-
2. Fill in all sections
|
|
27
|
-
3. Add code example if possible
|
|
28
|
-
4. Commit with message: `docs: add pattern - [name]`
|
|
29
|
-
5. Update `patterns/index.md` if this should be auto-applied
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## Pattern Categories
|
|
34
|
-
|
|
35
|
-
- **Frontend:** React, TypeScript, styling, component patterns
|
|
36
|
-
- **Backend:** API design, database queries, middleware
|
|
37
|
-
- **Testing:** Unit tests, integration tests, fixtures
|
|
38
|
-
- **Performance:** Caching, memoization, optimization
|
|
39
|
-
- **Security:** Input validation, authentication, authorization
|
|
40
|
-
- **Error Handling:** Exception patterns, recovery strategies
|
|
41
|
-
- **Data Structures:** Modeling domain objects effectively
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
## Template for New Pattern
|
|
46
|
-
|
|
47
|
-
```markdown
|
|
48
|
-
## [Category]
|
|
49
|
-
|
|
50
|
-
### [Pattern Name]
|
|
51
|
-
**Context:** (When to use this pattern)
|
|
52
|
-
**Pattern:** (Description or code example)
|
|
53
|
-
**Rationale:** (Why this is better)
|
|
54
|
-
**Example Location:** (Where in codebase)
|
|
55
|
-
```
|
|
11
|
+
_No patterns registered yet._
|
|
56
12
|
|
|
57
13
|
---
|
|
58
14
|
|
|
59
|
-
##
|
|
15
|
+
## How to Add
|
|
60
16
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
- Update this file as team learns new approaches
|
|
65
|
-
- Archive rarely-used patterns after 3 months of no references
|
|
17
|
+
1. Create pattern file: `.ai/patterns/{category}/{pattern-name}.md`
|
|
18
|
+
2. Add index entry here with link and brief description
|
|
19
|
+
3. Commit both files together
|
|
@@ -103,10 +103,50 @@ Create a session summary:
|
|
|
103
103
|
## Dead Ends
|
|
104
104
|
- DE-XXX: description (if any)
|
|
105
105
|
|
|
106
|
+
## Patterns Documented
|
|
107
|
+
- [{category}/{name}] - description (if any)
|
|
108
|
+
|
|
106
109
|
---
|
|
107
110
|
*Saved: {ISO timestamp}*
|
|
108
111
|
```
|
|
109
112
|
|
|
113
|
+
### 6. Pattern Extraction (.ai/patterns/)
|
|
114
|
+
|
|
115
|
+
Review the entire session and extract patterns. Check each criterion:
|
|
116
|
+
|
|
117
|
+
1. **User corrected your approach** β Document the correct approach
|
|
118
|
+
2. **You chose between alternatives** β Document what was chosen and why
|
|
119
|
+
3. **Workaround for limitation** β Document the workaround
|
|
120
|
+
4. **Convention established** β Document for consistency
|
|
121
|
+
5. **Repeated approach** β Document to avoid re-deriving
|
|
122
|
+
6. **Non-trivial solution** β Document for future sessions
|
|
123
|
+
|
|
124
|
+
**For each pattern found:**
|
|
125
|
+
|
|
126
|
+
1. Create file: `.ai/patterns/{category}/{pattern-name}.md`
|
|
127
|
+
```markdown
|
|
128
|
+
# Pattern Name
|
|
129
|
+
|
|
130
|
+
## Context
|
|
131
|
+
When to apply this pattern.
|
|
132
|
+
|
|
133
|
+
## Pattern
|
|
134
|
+
Description or code example.
|
|
135
|
+
|
|
136
|
+
## Rationale
|
|
137
|
+
Why this approach works better.
|
|
138
|
+
|
|
139
|
+
## Examples
|
|
140
|
+
- `src/path/file.ts:42`
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
2. Add index entry to `.ai/memory/patterns.md`:
|
|
144
|
+
```markdown
|
|
145
|
+
- [{category}/{name}](.ai/patterns/{category}/{name}.md) - Brief description
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**If no patterns found:** Confirm "Patterns: no new patterns this session"
|
|
149
|
+
|
|
110
150
|
---
|
|
111
151
|
|
|
112
152
|
## Output Format
|
|
@@ -119,6 +159,7 @@ PWN Save Complete:
|
|
|
119
159
|
- Tasks: {X} active, {Y} completed
|
|
120
160
|
- Dead Ends: {new count or "no new"}
|
|
121
161
|
- Decisions: {new count or "no new"}
|
|
162
|
+
- Patterns: {new count or "no new"}
|
|
122
163
|
- Archive: .ai/memory/archive/{filename}
|
|
123
164
|
- Last updated: {timestamp}
|
|
124
165
|
```
|
|
@@ -132,6 +173,7 @@ PWN Save Complete:
|
|
|
132
173
|
3. **decisions.md**: Organized entries with proper DEC-XXX IDs
|
|
133
174
|
4. **active.md**: Only current sprint tasks
|
|
134
175
|
5. **archive/**: One file per session with summary
|
|
176
|
+
6. **patterns/**: One file per pattern, indexed in memory/patterns.md
|
|
135
177
|
|
|
136
178
|
---
|
|
137
179
|
|
|
@@ -2,20 +2,11 @@
|
|
|
2
2
|
"hooks": {
|
|
3
3
|
"Notification": [
|
|
4
4
|
{
|
|
5
|
-
"matcher": "
|
|
5
|
+
"matcher": "",
|
|
6
6
|
"hooks": [
|
|
7
7
|
{
|
|
8
8
|
"type": "command",
|
|
9
|
-
"command": "pwn notify send \"Claude Code aguardando
|
|
10
|
-
}
|
|
11
|
-
]
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"matcher": "idle_prompt",
|
|
15
|
-
"hooks": [
|
|
16
|
-
{
|
|
17
|
-
"type": "command",
|
|
18
|
-
"command": "pwn notify send \"Claude Code aguardando input\" --title \"PWN\""
|
|
9
|
+
"command": "pwn notify send \"Claude Code aguardando permissao\" --title \"PWN\""
|
|
19
10
|
}
|
|
20
11
|
]
|
|
21
12
|
}
|