@fermindi/pwn-cli 0.1.1 → 0.3.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 (48) 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 +112 -91
  6. package/cli/inject.js +90 -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/save.js +206 -0
  12. package/cli/status.js +91 -91
  13. package/cli/update.js +189 -0
  14. package/cli/validate.js +61 -61
  15. package/package.json +70 -70
  16. package/src/core/inject.js +300 -204
  17. package/src/core/state.js +91 -91
  18. package/src/core/validate.js +202 -202
  19. package/src/core/workspace.js +176 -176
  20. package/src/index.js +20 -20
  21. package/src/knowledge/gc.js +308 -308
  22. package/src/knowledge/lifecycle.js +401 -401
  23. package/src/knowledge/promote.js +364 -364
  24. package/src/knowledge/references.js +342 -342
  25. package/src/patterns/matcher.js +218 -218
  26. package/src/patterns/registry.js +375 -375
  27. package/src/patterns/triggers.js +423 -423
  28. package/src/services/batch-service.js +849 -849
  29. package/src/services/notification-service.js +342 -342
  30. package/templates/codespaces/devcontainer.json +52 -52
  31. package/templates/codespaces/setup.sh +70 -70
  32. package/templates/workspace/.ai/README.md +164 -164
  33. package/templates/workspace/.ai/agents/README.md +204 -204
  34. package/templates/workspace/.ai/agents/claude.md +625 -625
  35. package/templates/workspace/.ai/config/README.md +79 -79
  36. package/templates/workspace/.ai/config/notifications.template.json +20 -20
  37. package/templates/workspace/.ai/memory/deadends.md +79 -79
  38. package/templates/workspace/.ai/memory/decisions.md +58 -58
  39. package/templates/workspace/.ai/memory/patterns.md +65 -65
  40. package/templates/workspace/.ai/patterns/backend/README.md +126 -126
  41. package/templates/workspace/.ai/patterns/frontend/README.md +103 -103
  42. package/templates/workspace/.ai/patterns/index.md +256 -256
  43. package/templates/workspace/.ai/patterns/triggers.json +1087 -1087
  44. package/templates/workspace/.ai/patterns/universal/README.md +141 -141
  45. package/templates/workspace/.ai/state.template.json +8 -8
  46. package/templates/workspace/.ai/tasks/active.md +77 -77
  47. package/templates/workspace/.ai/tasks/backlog.md +95 -95
  48. package/templates/workspace/.ai/workflows/batch-task.md +356 -356
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Diego Fernandes
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Diego Fernandes
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,251 +1,265 @@
1
- # PWN - Professional AI Workspace
2
-
3
- **Inject structured memory and automation into any project for AI-powered development.**
4
-
5
- PWN gives AI agents like Claude Code persistent memory, auto-applied patterns, and batch execution capabilities.
6
-
7
- ## Quick Start
8
-
9
- ```bash
10
- # Install globally
11
- npm install -g pwn-cli
12
-
13
- # Inject into your project
14
- cd your-project
15
- pwn inject
16
-
17
- # Check status
18
- pwn status
19
-
20
- # Add Codespaces support (optional)
21
- pwn codespaces init
22
- ```
23
-
24
- ## What PWN Does
25
-
26
- | Without PWN | With PWN |
27
- |-------------|----------|
28
- | AI forgets decisions between sessions | Decisions persist in `.ai/memory/` |
29
- | Repeats failed approaches | Dead-ends documented and avoided |
30
- | No project-specific patterns | Auto-applies patterns by context |
31
- | Manual task tracking | Structured task management |
32
- | No learning consolidation | Knowledge promotes to patterns |
33
-
34
- ## Commands
35
-
36
- ```bash
37
- # Core
38
- pwn inject # Inject .ai/ workspace
39
- pwn status # Show workspace status
40
- pwn validate # Validate structure
41
-
42
- # Notifications
43
- pwn notify test # Test notification channels
44
- pwn notify send "msg" # Send notification
45
-
46
- # Batch Execution
47
- pwn batch # Execute next task
48
- pwn batch --count 5 # Execute 5 tasks
49
- pwn batch status # Show progress
50
-
51
- # Patterns
52
- pwn patterns list # List all patterns
53
- pwn patterns eval file # Check triggers for file
54
- pwn patterns search q # Search patterns
55
-
56
- # Knowledge Lifecycle
57
- pwn knowledge status # Show knowledge stats
58
- pwn knowledge sync # Sync with markdown
59
- pwn knowledge gc # Garbage collection
60
- pwn knowledge promote # Promote to pattern
61
-
62
- # Codespaces
63
- pwn codespaces init # Add devcontainer
64
- pwn codespaces status # Check config
65
- pwn codespaces open # Open in Codespace
66
- ```
67
-
68
- ## Project Structure After Injection
69
-
70
- ```
71
- your-project/
72
- ├── .ai/
73
- │ ├── state.json # Session state (git-ignored)
74
- │ ├── memory/
75
- │ │ ├── decisions.md # Architectural decisions (DEC-XXX)
76
- │ │ ├── patterns.md # Learned patterns
77
- │ │ └── deadends.md # Failed approaches (DE-XXX)
78
- │ ├── tasks/
79
- │ │ ├── active.md # Current work
80
- │ │ └── backlog.md # Future work
81
- │ ├── patterns/
82
- ├── index.md # Trigger mappings
83
- │ │ ├── frontend/ # React, Vue, etc.
84
- │ │ ├── backend/ # Express, FastAPI, etc.
85
- │ │ └── universal/ # Testing, TypeScript, etc.
86
- │ ├── workflows/
87
- │ │ └── batch-task.md # Batch execution guide
88
- ├── agents/
89
- │ └── claude.md # Claude Code bootstrap (600+ lines)
90
- └── config/ # Local config (git-ignored)
91
- └── ... your project files
92
- ```
93
-
94
- ## Features
95
-
96
- ### Memory System
97
-
98
- Document decisions that AI agents will remember:
99
-
100
- ```markdown
101
- ## DEC-001: Use TypeScript Strict Mode
102
- **Date:** 2026-01-22
103
- **Status:** Active
104
- **Context:** Need better type safety
105
- **Decision:** Enable strict mode in tsconfig
106
- **Rationale:** Catches bugs at compile time
107
- ```
108
-
109
- ### Pattern Auto-Apply
110
-
111
- Triggers automatically load relevant patterns:
112
-
113
- ```
114
- *.tsx → frontend/react/
115
- *.test.ts → universal/testing/
116
- routes/*.ts → backend/express/
117
- prisma/schema → backend/prisma/
118
- ```
119
-
120
- ### Knowledge Lifecycle
121
-
122
- Knowledge evolves based on usage:
123
-
124
- ```
125
- CREATE REFERENCE → EVOLVE → PROMOTE/GC
126
- │ │ │ │
127
- ▼ ▼ ▼ ▼
128
- decisions tracking patterns cleanup
129
- ```
130
-
131
- - **Promote:** Applied 3+ times in 2+ contexts → becomes pattern
132
- - **Archive:** No references for 30+ days
133
- - **GC:** Orphaned with no related code
134
-
135
- ### Batch Execution
136
-
137
- Execute tasks autonomously:
138
-
139
- ```bash
140
- pwn batch --count 5 --priority high
141
- ```
142
-
143
- Features:
144
- - Quality gates (lint, test, typecheck)
145
- - Checkpoint-based pause/resume
146
- - Auto-commit after each task
147
- - Notifications on completion
148
-
149
- ### Codespaces Integration
150
-
151
- Work from anywhere (including mobile):
152
-
153
- ```bash
154
- pwn codespaces init
155
- git push
156
- # Open in GitHub Codespaces
157
- ```
158
-
159
- Pre-configured with:
160
- - Node.js 22
161
- - VSCode extensions (ESLint, Prettier, GitLens, Copilot, Claude)
162
- - Bash aliases (`p`, `ps`, `pb`, `pk`)
163
- - Auto PWN setup
164
-
165
- ## Usage with Claude Code
166
-
167
- After `pwn inject`, Claude Code will:
168
-
169
- 1. Read `.ai/agents/claude.md` for bootstrap protocol
170
- 2. Load memory (decisions, patterns, dead-ends)
171
- 3. Check active tasks
172
- 4. Auto-apply patterns based on context
173
- 5. Reference decisions in responses
174
-
175
- ## Installation
176
-
177
- ```bash
178
- # npm
179
- npm install -g pwn-cli
180
-
181
- # Or run directly
182
- npx pwn-cli inject
183
- ```
184
-
185
- Requirements:
186
- - Node.js 18+
187
- - Git (for username detection)
188
-
189
- ## Configuration
190
-
191
- ### Notifications
192
-
193
- Edit `.ai/config/notifications.json`:
194
-
195
- ```json
196
- {
197
- "channels": {
198
- "ntfy": {
199
- "enabled": true,
200
- "topic": "pwn-abc123"
201
- }
202
- }
203
- }
204
- ```
205
-
206
- ### Quality Gates
207
-
208
- Configure in `.ai/workflows/batch-task.md`:
209
-
210
- ```yaml
211
- gates:
212
- typecheck: true
213
- lint: true
214
- test: true
215
- build: false
216
- ```
217
-
218
- ## Development
219
-
220
- ```bash
221
- git clone https://github.com/diegofornalha/pwn.git
222
- cd pwn
223
- pnpm install
224
- pnpm test
225
- npm link # For local testing
226
- ```
227
-
228
- ## Roadmap
229
-
230
- - [x] Phase 0: Core workspace injection
231
- - [x] Phase 1: Multi-channel notifications
232
- - [x] Phase 2: GitHub Codespaces integration
233
- - [x] Phase 3: Autonomous batch execution
234
- - [x] Phase 4: Advanced pattern system
235
- - [x] Phase 5: Knowledge lifecycle
236
- - [x] Phase 6: npm publish
237
- - [ ] `pwn create` - Scaffold new projects
238
- - [ ] `pwn upgrade` - Update existing workspaces
239
- - [ ] Docker support
240
-
241
- ## Contributing
242
-
243
- Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md).
244
-
245
- ## License
246
-
247
- MIT - see [LICENSE](LICENSE)
248
-
249
- ---
250
-
251
- **Version:** 0.1.0 | **Status:** Production Ready
1
+ # PWN - Professional AI Workspace
2
+
3
+ **Inject structured memory and automation into any project for AI-powered development.**
4
+
5
+ PWN gives AI agents like Claude Code persistent memory, auto-applied patterns, and batch execution capabilities.
6
+
7
+ ## Quick Start
8
+
9
+ ```bash
10
+ # Install globally
11
+ npm install -g @fermindi/pwn-cli
12
+
13
+ # Inject into your project
14
+ cd your-project
15
+ pwn inject
16
+
17
+ # Check status
18
+ pwn status
19
+
20
+ # Add Codespaces support (optional)
21
+ pwn codespaces init
22
+ ```
23
+
24
+ Or use directly with npx:
25
+
26
+ ```bash
27
+ cd your-project
28
+ npx @fermindi/pwn-cli inject
29
+ ```
30
+
31
+ ## What PWN Does
32
+
33
+ | Without PWN | With PWN |
34
+ |-------------|----------|
35
+ | AI forgets decisions between sessions | Decisions persist in `.ai/memory/` |
36
+ | Repeats failed approaches | Dead-ends documented and avoided |
37
+ | No project-specific patterns | Auto-applies patterns by context |
38
+ | Manual task tracking | Structured task management |
39
+ | No learning consolidation | Knowledge promotes to patterns |
40
+
41
+ ## Commands
42
+
43
+ ```bash
44
+ # Core
45
+ pwn inject # Inject .ai/ workspace
46
+ pwn migrate # Migrate existing AI files (CLAUDE.md, memory-bank/, etc.)
47
+ pwn status # Show workspace status
48
+ pwn validate # Validate structure
49
+
50
+ # Notifications
51
+ pwn notify test # Test notification channels
52
+ pwn notify send "msg" # Send notification
53
+
54
+ # Batch Execution
55
+ pwn batch # Execute next task
56
+ pwn batch --count 5 # Execute 5 tasks
57
+ pwn batch status # Show progress
58
+
59
+ # Patterns
60
+ pwn patterns list # List all patterns
61
+ pwn patterns eval file # Check triggers for file
62
+ pwn patterns search q # Search patterns
63
+
64
+ # Knowledge Lifecycle
65
+ pwn knowledge status # Show knowledge stats
66
+ pwn knowledge sync # Sync with markdown
67
+ pwn knowledge gc # Garbage collection
68
+ pwn knowledge promote # Promote to pattern
69
+
70
+ # Codespaces
71
+ pwn codespaces init # Add devcontainer
72
+ pwn codespaces status # Check config
73
+ pwn codespaces open # Open in Codespace
74
+ ```
75
+
76
+ ## Project Structure After Injection
77
+
78
+ ```
79
+ your-project/
80
+ ├── .ai/
81
+ │ ├── state.json # Session state (git-ignored)
82
+ │ ├── memory/
83
+ │ │ ├── decisions.md # Architectural decisions (DEC-XXX)
84
+ │ │ ├── patterns.md # Learned patterns
85
+ │ │ └── deadends.md # Failed approaches (DE-XXX)
86
+ │ ├── tasks/
87
+ │ │ ├── active.md # Current work
88
+ │ └── backlog.md # Future work
89
+ ├── patterns/
90
+ │ ├── index.md # Trigger mappings
91
+ │ │ ├── frontend/ # React, Vue, etc.
92
+ │ │ ├── backend/ # Express, FastAPI, etc.
93
+ │ │ └── universal/ # Testing, TypeScript, etc.
94
+ │ ├── workflows/
95
+ │ │ └── batch-task.md # Batch execution guide
96
+ │ ├── agents/
97
+ │ │ └── claude.md # Claude Code bootstrap (600+ lines)
98
+ │ └── config/ # Local config (git-ignored)
99
+ └── ... your project files
100
+ ```
101
+
102
+ ## Features
103
+
104
+ ### Memory System
105
+
106
+ Document decisions that AI agents will remember:
107
+
108
+ ```markdown
109
+ ## DEC-001: Use TypeScript Strict Mode
110
+ **Date:** 2026-01-22
111
+ **Status:** Active
112
+ **Context:** Need better type safety
113
+ **Decision:** Enable strict mode in tsconfig
114
+ **Rationale:** Catches bugs at compile time
115
+ ```
116
+
117
+ ### Pattern Auto-Apply
118
+
119
+ Triggers automatically load relevant patterns:
120
+
121
+ ```
122
+ *.tsx → frontend/react/
123
+ *.test.ts → universal/testing/
124
+ routes/*.ts → backend/express/
125
+ prisma/schema backend/prisma/
126
+ ```
127
+
128
+ ### Knowledge Lifecycle
129
+
130
+ Knowledge evolves based on usage:
131
+
132
+ ```
133
+ CREATE REFERENCE EVOLVE PROMOTE/GC
134
+ │ │ │ │
135
+ ▼ ▼ ▼ ▼
136
+ decisions tracking patterns cleanup
137
+ ```
138
+
139
+ - **Promote:** Applied 3+ times in 2+ contexts → becomes pattern
140
+ - **Archive:** No references for 30+ days
141
+ - **GC:** Orphaned with no related code
142
+
143
+ ### Batch Execution
144
+
145
+ Execute tasks autonomously:
146
+
147
+ ```bash
148
+ pwn batch --count 5 --priority high
149
+ ```
150
+
151
+ Features:
152
+ - Quality gates (lint, test, typecheck)
153
+ - Checkpoint-based pause/resume
154
+ - Auto-commit after each task
155
+ - Notifications on completion
156
+
157
+ ### Codespaces Integration
158
+
159
+ Work from anywhere (including mobile):
160
+
161
+ ```bash
162
+ pwn codespaces init
163
+ git push
164
+ # Open in GitHub Codespaces
165
+ ```
166
+
167
+ Pre-configured with:
168
+ - Node.js 22
169
+ - VSCode extensions (ESLint, Prettier, GitLens, Copilot, Claude)
170
+ - Bash aliases (`p`, `ps`, `pb`, `pk`)
171
+ - Auto PWN setup
172
+
173
+ ## Usage with Claude Code
174
+
175
+ After `pwn inject`, Claude Code will:
176
+
177
+ 1. Read `.ai/agents/claude.md` for bootstrap protocol
178
+ 2. Load memory (decisions, patterns, dead-ends)
179
+ 3. Check active tasks
180
+ 4. Auto-apply patterns based on context
181
+ 5. Reference decisions in responses
182
+
183
+ ## Installation
184
+
185
+ ```bash
186
+ # npm (global)
187
+ npm install -g @fermindi/pwn-cli
188
+
189
+ # Or run directly with npx
190
+ npx @fermindi/pwn-cli inject
191
+ ```
192
+
193
+ Requirements:
194
+ - Node.js 18+
195
+ - Git (for username detection)
196
+
197
+ ## Configuration
198
+
199
+ ### Notifications
200
+
201
+ Edit `.ai/config/notifications.json`:
202
+
203
+ ```json
204
+ {
205
+ "channels": {
206
+ "ntfy": {
207
+ "enabled": true,
208
+ "topic": "pwn-abc123"
209
+ }
210
+ }
211
+ }
212
+ ```
213
+
214
+ ### Quality Gates
215
+
216
+ Configure in `.ai/workflows/batch-task.md`:
217
+
218
+ ```yaml
219
+ gates:
220
+ typecheck: true
221
+ lint: true
222
+ test: true
223
+ build: false
224
+ ```
225
+
226
+ ## Development
227
+
228
+ ```bash
229
+ git clone https://github.com/diegofornalha/pwn.git
230
+ cd pwn
231
+ pnpm install
232
+ pnpm test
233
+ npm link # For local testing
234
+ ```
235
+
236
+ ## Roadmap
237
+
238
+ - [x] Phase 0: Core workspace injection
239
+ - [x] Phase 1: Multi-channel notifications
240
+ - [x] Phase 2: GitHub Codespaces integration
241
+ - [x] Phase 3: Autonomous batch execution
242
+ - [x] Phase 4: Advanced pattern system
243
+ - [x] Phase 5: Knowledge lifecycle
244
+ - [x] Phase 6: npm publish
245
+ - [ ] `pwn create` - Scaffold new projects
246
+ - [ ] `pwn upgrade` - Update existing workspaces
247
+ - [ ] Docker support
248
+
249
+ ## Documentation
250
+
251
+ - [Getting Started](docs/getting-started.md) - Installation, setup, and first steps
252
+ - [Commands Reference](docs/commands.md) - Complete CLI command reference
253
+ - [Migration Guide](docs/migration.md) - Migrate from CLAUDE.md, memory-bank, Cursor, etc.
254
+
255
+ ## Contributing
256
+
257
+ Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md).
258
+
259
+ ## License
260
+
261
+ MIT - see [LICENSE](LICENSE)
262
+
263
+ ---
264
+
265
+ **Version:** 0.1.0 | **Status:** Production Ready