@fermindi/pwn-cli 0.1.1 → 0.2.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.
Files changed (46) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +265 -251
  3. package/cli/batch.js +333 -333
  4. package/cli/codespaces.js +303 -303
  5. package/cli/index.js +98 -91
  6. package/cli/inject.js +78 -67
  7. package/cli/knowledge.js +531 -531
  8. package/cli/migrate.js +466 -0
  9. package/cli/notify.js +135 -135
  10. package/cli/patterns.js +665 -665
  11. package/cli/status.js +91 -91
  12. package/cli/validate.js +61 -61
  13. package/package.json +70 -70
  14. package/src/core/inject.js +208 -204
  15. package/src/core/state.js +91 -91
  16. package/src/core/validate.js +202 -202
  17. package/src/core/workspace.js +176 -176
  18. package/src/index.js +20 -20
  19. package/src/knowledge/gc.js +308 -308
  20. package/src/knowledge/lifecycle.js +401 -401
  21. package/src/knowledge/promote.js +364 -364
  22. package/src/knowledge/references.js +342 -342
  23. package/src/patterns/matcher.js +218 -218
  24. package/src/patterns/registry.js +375 -375
  25. package/src/patterns/triggers.js +423 -423
  26. package/src/services/batch-service.js +849 -849
  27. package/src/services/notification-service.js +342 -342
  28. package/templates/codespaces/devcontainer.json +52 -52
  29. package/templates/codespaces/setup.sh +70 -70
  30. package/templates/workspace/.ai/README.md +164 -164
  31. package/templates/workspace/.ai/agents/README.md +204 -204
  32. package/templates/workspace/.ai/agents/claude.md +625 -625
  33. package/templates/workspace/.ai/config/README.md +79 -79
  34. package/templates/workspace/.ai/config/notifications.template.json +20 -20
  35. package/templates/workspace/.ai/memory/deadends.md +79 -79
  36. package/templates/workspace/.ai/memory/decisions.md +58 -58
  37. package/templates/workspace/.ai/memory/patterns.md +65 -65
  38. package/templates/workspace/.ai/patterns/backend/README.md +126 -126
  39. package/templates/workspace/.ai/patterns/frontend/README.md +103 -103
  40. package/templates/workspace/.ai/patterns/index.md +256 -256
  41. package/templates/workspace/.ai/patterns/triggers.json +1087 -1087
  42. package/templates/workspace/.ai/patterns/universal/README.md +141 -141
  43. package/templates/workspace/.ai/state.template.json +8 -8
  44. package/templates/workspace/.ai/tasks/active.md +77 -77
  45. package/templates/workspace/.ai/tasks/backlog.md +95 -95
  46. package/templates/workspace/.ai/workflows/batch-task.md +356 -356
@@ -1,256 +1,256 @@
1
- # Pattern Auto-Apply Trigger Map
2
-
3
- This file defines triggers that automatically load relevant patterns during AI sessions.
4
-
5
- ## How It Works
6
-
7
- 1. AI agent starts session
8
- 2. Reads this file to register triggers
9
- 3. Monitors file changes, imports, and commands
10
- 4. When trigger matches, loads relevant patterns from `patterns/` subdirectories
11
- 5. Applies patterns to current work
12
-
13
- ---
14
-
15
- ## Trigger Types
16
-
17
- - **`fileExt`** - File extension patterns (e.g., `*.tsx`, `*.py`)
18
- - **`import`** - Import statements (e.g., `from react import`)
19
- - **`command`** - CLI commands (e.g., `pnpm dev`, `npm test`)
20
- - **`path`** - Directory path patterns (e.g., `src/components/`)
21
- - **`keyword`** - Code keywords (e.g., `interface`, `class`)
22
-
23
- ---
24
-
25
- ## Trigger Format
26
-
27
- ```yaml
28
- triggers:
29
- - name: "Pattern Name"
30
- type: "fileExt | import | command | path | keyword"
31
- value: "*.tsx"
32
- patterns:
33
- - "frontend/react"
34
- - "universal/typescript"
35
- description: "Loads when working with React components"
36
- ```
37
-
38
- ---
39
-
40
- ## Trigger Registry
41
-
42
- ### Frontend Triggers
43
-
44
- ```yaml
45
- triggers:
46
- - name: "React Components"
47
- type: "fileExt"
48
- value: "*.tsx"
49
- patterns:
50
- - "frontend/react"
51
- - "universal/typescript"
52
- description: "Auto-loads React component patterns"
53
-
54
- - name: "React Hooks"
55
- type: "import"
56
- value: "import.*useEffect|useState|useContext"
57
- patterns:
58
- - "frontend/react/hooks"
59
- description: "Loads when using React hooks"
60
-
61
- - name: "Styling"
62
- type: "fileExt"
63
- value: "*.css,*.scss,*.tailwind"
64
- patterns:
65
- - "frontend/styling"
66
- description: "CSS/styling patterns"
67
-
68
- - name: "Component Library"
69
- type: "import"
70
- value: "from.*@shadcn|from.*@mui"
71
- patterns:
72
- - "frontend/component-libs"
73
- description: "Component library patterns"
74
- ```
75
-
76
- ### Backend Triggers
77
-
78
- ```yaml
79
- triggers:
80
- - name: "Express Routes"
81
- type: "fileExt"
82
- value: "*.routes.ts,routes/*.ts"
83
- patterns:
84
- - "backend/express"
85
- - "universal/rest-api"
86
- description: "Express route patterns"
87
-
88
- - name: "Database Queries"
89
- type: "import"
90
- value: "from.*prisma|from.*knex|from.*typeorm"
91
- patterns:
92
- - "backend/database"
93
- description: "Database query patterns"
94
-
95
- - name: "API Endpoints"
96
- type: "keyword"
97
- value: "app.get|app.post|router.put"
98
- patterns:
99
- - "backend/express"
100
- - "universal/rest-api"
101
- description: "REST API patterns"
102
-
103
- - name: "Error Handling"
104
- type: "keyword"
105
- value: "try|catch|throw|Error"
106
- patterns:
107
- - "universal/error-handling"
108
- description: "Error handling patterns"
109
- ```
110
-
111
- ### Testing Triggers
112
-
113
- ```yaml
114
- triggers:
115
- - name: "Unit Tests"
116
- type: "import"
117
- value: "from.*jest|from.*vitest|describe|it"
118
- patterns:
119
- - "universal/testing/unit"
120
- description: "Unit test patterns"
121
-
122
- - name: "Integration Tests"
123
- type: "path"
124
- value: "**/*.integration.test.ts"
125
- patterns:
126
- - "universal/testing/integration"
127
- description: "Integration test patterns"
128
-
129
- - name: "E2E Tests"
130
- type: "path"
131
- value: "**/*.e2e.test.ts,cypress/**/*,playwright/**/*"
132
- patterns:
133
- - "universal/testing/e2e"
134
- description: "End-to-end test patterns"
135
- ```
136
-
137
- ### Universal Triggers
138
-
139
- ```yaml
140
- triggers:
141
- - name: "TypeScript"
142
- type: "fileExt"
143
- value: "*.ts,*.tsx"
144
- patterns:
145
- - "universal/typescript"
146
- description: "TypeScript patterns"
147
-
148
- - name: "Git Workflow"
149
- type: "command"
150
- value: "git commit|git push|git pull"
151
- patterns:
152
- - "universal/git"
153
- description: "Git workflow patterns"
154
-
155
- - name: "Build Tools"
156
- type: "command"
157
- value: "npm|pnpm|yarn|webpack|vite"
158
- patterns:
159
- - "universal/build-tools"
160
- description: "Build and package patterns"
161
- ```
162
-
163
- ---
164
-
165
- ## Priority Order
166
-
167
- Triggers are applied in priority order:
168
- 1. **Highest:** `fileExt` (most specific)
169
- 2. **High:** `path` (directory context)
170
- 3. **Medium:** `import` (code context)
171
- 4. **Low:** `keyword` (broad matches)
172
- 5. **Lowest:** `command` (least specific)
173
-
174
- If multiple triggers match, load all associated patterns.
175
-
176
- ---
177
-
178
- ## Adding New Triggers
179
-
180
- 1. Identify the pattern category
181
- 2. Determine trigger type
182
- 3. Define pattern value
183
- 4. Link to pattern files in `patterns/` subdirectories
184
- 5. Add entry to appropriate section
185
- 6. Commit with message: `docs: add trigger for [pattern]`
186
-
187
- ---
188
-
189
- ## Pattern Directory Structure
190
-
191
- Patterns are organized in subdirectories matching triggers:
192
-
193
- ```
194
- patterns/
195
- ├── frontend/
196
- │ ├── react/
197
- │ ├── styling/
198
- │ └── component-libs/
199
- ├── backend/
200
- │ ├── express/
201
- │ └── database/
202
- └── universal/
203
- ├── typescript/
204
- ├── testing/
205
- ├── error-handling/
206
- ├── git/
207
- └── build-tools/
208
- ```
209
-
210
- Each directory contains:
211
- - `README.md` - Pattern documentation
212
- - `*.example.ts` - Code examples (optional)
213
- - `checklist.md` - Verification checklist (optional)
214
-
215
- ---
216
-
217
- ## Examples
218
-
219
- ### Example 1: React Component Trigger
220
-
221
- **Condition:** User edits `src/components/Button.tsx`
222
- **Triggers:** `*.tsx` matches
223
- **Load:** `patterns/frontend/react/README.md`
224
- **Apply:** React component best practices to Button component
225
-
226
- ### Example 2: API Endpoint Trigger
227
-
228
- **Condition:** User imports `from 'express'`
229
- **Triggers:** `import.*express` matches
230
- **Load:** `patterns/backend/express/README.md` + `patterns/universal/rest-api/README.md`
231
- **Apply:** Express + REST API patterns to new route
232
-
233
- ### Example 3: Test File Trigger
234
-
235
- **Condition:** User creates `src/__tests__/utils.test.ts`
236
- **Triggers:** `*.test.ts` matches + `import jest` matches
237
- **Load:** `patterns/universal/testing/unit/README.md`
238
- **Apply:** Unit test patterns and Jest best practices
239
-
240
- ---
241
-
242
- ## Disabling Triggers
243
-
244
- To temporarily disable pattern auto-apply:
245
-
246
- 1. Add to `state.json`: `"auto_patterns_enabled": false`
247
- 2. Manually import patterns as needed
248
- 3. Re-enable: `"auto_patterns_enabled": true`
249
-
250
- ---
251
-
252
- ## Feedback
253
-
254
- - If pattern is irrelevant, note in `state.json` to refine triggers
255
- - Patterns that save time: commit and document
256
- - Patterns that cause friction: update or disable
1
+ # Pattern Auto-Apply Trigger Map
2
+
3
+ This file defines triggers that automatically load relevant patterns during AI sessions.
4
+
5
+ ## How It Works
6
+
7
+ 1. AI agent starts session
8
+ 2. Reads this file to register triggers
9
+ 3. Monitors file changes, imports, and commands
10
+ 4. When trigger matches, loads relevant patterns from `patterns/` subdirectories
11
+ 5. Applies patterns to current work
12
+
13
+ ---
14
+
15
+ ## Trigger Types
16
+
17
+ - **`fileExt`** - File extension patterns (e.g., `*.tsx`, `*.py`)
18
+ - **`import`** - Import statements (e.g., `from react import`)
19
+ - **`command`** - CLI commands (e.g., `pnpm dev`, `npm test`)
20
+ - **`path`** - Directory path patterns (e.g., `src/components/`)
21
+ - **`keyword`** - Code keywords (e.g., `interface`, `class`)
22
+
23
+ ---
24
+
25
+ ## Trigger Format
26
+
27
+ ```yaml
28
+ triggers:
29
+ - name: "Pattern Name"
30
+ type: "fileExt | import | command | path | keyword"
31
+ value: "*.tsx"
32
+ patterns:
33
+ - "frontend/react"
34
+ - "universal/typescript"
35
+ description: "Loads when working with React components"
36
+ ```
37
+
38
+ ---
39
+
40
+ ## Trigger Registry
41
+
42
+ ### Frontend Triggers
43
+
44
+ ```yaml
45
+ triggers:
46
+ - name: "React Components"
47
+ type: "fileExt"
48
+ value: "*.tsx"
49
+ patterns:
50
+ - "frontend/react"
51
+ - "universal/typescript"
52
+ description: "Auto-loads React component patterns"
53
+
54
+ - name: "React Hooks"
55
+ type: "import"
56
+ value: "import.*useEffect|useState|useContext"
57
+ patterns:
58
+ - "frontend/react/hooks"
59
+ description: "Loads when using React hooks"
60
+
61
+ - name: "Styling"
62
+ type: "fileExt"
63
+ value: "*.css,*.scss,*.tailwind"
64
+ patterns:
65
+ - "frontend/styling"
66
+ description: "CSS/styling patterns"
67
+
68
+ - name: "Component Library"
69
+ type: "import"
70
+ value: "from.*@shadcn|from.*@mui"
71
+ patterns:
72
+ - "frontend/component-libs"
73
+ description: "Component library patterns"
74
+ ```
75
+
76
+ ### Backend Triggers
77
+
78
+ ```yaml
79
+ triggers:
80
+ - name: "Express Routes"
81
+ type: "fileExt"
82
+ value: "*.routes.ts,routes/*.ts"
83
+ patterns:
84
+ - "backend/express"
85
+ - "universal/rest-api"
86
+ description: "Express route patterns"
87
+
88
+ - name: "Database Queries"
89
+ type: "import"
90
+ value: "from.*prisma|from.*knex|from.*typeorm"
91
+ patterns:
92
+ - "backend/database"
93
+ description: "Database query patterns"
94
+
95
+ - name: "API Endpoints"
96
+ type: "keyword"
97
+ value: "app.get|app.post|router.put"
98
+ patterns:
99
+ - "backend/express"
100
+ - "universal/rest-api"
101
+ description: "REST API patterns"
102
+
103
+ - name: "Error Handling"
104
+ type: "keyword"
105
+ value: "try|catch|throw|Error"
106
+ patterns:
107
+ - "universal/error-handling"
108
+ description: "Error handling patterns"
109
+ ```
110
+
111
+ ### Testing Triggers
112
+
113
+ ```yaml
114
+ triggers:
115
+ - name: "Unit Tests"
116
+ type: "import"
117
+ value: "from.*jest|from.*vitest|describe|it"
118
+ patterns:
119
+ - "universal/testing/unit"
120
+ description: "Unit test patterns"
121
+
122
+ - name: "Integration Tests"
123
+ type: "path"
124
+ value: "**/*.integration.test.ts"
125
+ patterns:
126
+ - "universal/testing/integration"
127
+ description: "Integration test patterns"
128
+
129
+ - name: "E2E Tests"
130
+ type: "path"
131
+ value: "**/*.e2e.test.ts,cypress/**/*,playwright/**/*"
132
+ patterns:
133
+ - "universal/testing/e2e"
134
+ description: "End-to-end test patterns"
135
+ ```
136
+
137
+ ### Universal Triggers
138
+
139
+ ```yaml
140
+ triggers:
141
+ - name: "TypeScript"
142
+ type: "fileExt"
143
+ value: "*.ts,*.tsx"
144
+ patterns:
145
+ - "universal/typescript"
146
+ description: "TypeScript patterns"
147
+
148
+ - name: "Git Workflow"
149
+ type: "command"
150
+ value: "git commit|git push|git pull"
151
+ patterns:
152
+ - "universal/git"
153
+ description: "Git workflow patterns"
154
+
155
+ - name: "Build Tools"
156
+ type: "command"
157
+ value: "npm|pnpm|yarn|webpack|vite"
158
+ patterns:
159
+ - "universal/build-tools"
160
+ description: "Build and package patterns"
161
+ ```
162
+
163
+ ---
164
+
165
+ ## Priority Order
166
+
167
+ Triggers are applied in priority order:
168
+ 1. **Highest:** `fileExt` (most specific)
169
+ 2. **High:** `path` (directory context)
170
+ 3. **Medium:** `import` (code context)
171
+ 4. **Low:** `keyword` (broad matches)
172
+ 5. **Lowest:** `command` (least specific)
173
+
174
+ If multiple triggers match, load all associated patterns.
175
+
176
+ ---
177
+
178
+ ## Adding New Triggers
179
+
180
+ 1. Identify the pattern category
181
+ 2. Determine trigger type
182
+ 3. Define pattern value
183
+ 4. Link to pattern files in `patterns/` subdirectories
184
+ 5. Add entry to appropriate section
185
+ 6. Commit with message: `docs: add trigger for [pattern]`
186
+
187
+ ---
188
+
189
+ ## Pattern Directory Structure
190
+
191
+ Patterns are organized in subdirectories matching triggers:
192
+
193
+ ```
194
+ patterns/
195
+ ├── frontend/
196
+ │ ├── react/
197
+ │ ├── styling/
198
+ │ └── component-libs/
199
+ ├── backend/
200
+ │ ├── express/
201
+ │ └── database/
202
+ └── universal/
203
+ ├── typescript/
204
+ ├── testing/
205
+ ├── error-handling/
206
+ ├── git/
207
+ └── build-tools/
208
+ ```
209
+
210
+ Each directory contains:
211
+ - `README.md` - Pattern documentation
212
+ - `*.example.ts` - Code examples (optional)
213
+ - `checklist.md` - Verification checklist (optional)
214
+
215
+ ---
216
+
217
+ ## Examples
218
+
219
+ ### Example 1: React Component Trigger
220
+
221
+ **Condition:** User edits `src/components/Button.tsx`
222
+ **Triggers:** `*.tsx` matches
223
+ **Load:** `patterns/frontend/react/README.md`
224
+ **Apply:** React component best practices to Button component
225
+
226
+ ### Example 2: API Endpoint Trigger
227
+
228
+ **Condition:** User imports `from 'express'`
229
+ **Triggers:** `import.*express` matches
230
+ **Load:** `patterns/backend/express/README.md` + `patterns/universal/rest-api/README.md`
231
+ **Apply:** Express + REST API patterns to new route
232
+
233
+ ### Example 3: Test File Trigger
234
+
235
+ **Condition:** User creates `src/__tests__/utils.test.ts`
236
+ **Triggers:** `*.test.ts` matches + `import jest` matches
237
+ **Load:** `patterns/universal/testing/unit/README.md`
238
+ **Apply:** Unit test patterns and Jest best practices
239
+
240
+ ---
241
+
242
+ ## Disabling Triggers
243
+
244
+ To temporarily disable pattern auto-apply:
245
+
246
+ 1. Add to `state.json`: `"auto_patterns_enabled": false`
247
+ 2. Manually import patterns as needed
248
+ 3. Re-enable: `"auto_patterns_enabled": true`
249
+
250
+ ---
251
+
252
+ ## Feedback
253
+
254
+ - If pattern is irrelevant, note in `state.json` to refine triggers
255
+ - Patterns that save time: commit and document
256
+ - Patterns that cause friction: update or disable