@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.
- package/LICENSE +21 -21
- package/README.md +265 -251
- package/cli/batch.js +333 -333
- package/cli/codespaces.js +303 -303
- package/cli/index.js +98 -91
- package/cli/inject.js +78 -67
- package/cli/knowledge.js +531 -531
- package/cli/migrate.js +466 -0
- package/cli/notify.js +135 -135
- package/cli/patterns.js +665 -665
- package/cli/status.js +91 -91
- package/cli/validate.js +61 -61
- package/package.json +70 -70
- package/src/core/inject.js +208 -204
- package/src/core/state.js +91 -91
- package/src/core/validate.js +202 -202
- package/src/core/workspace.js +176 -176
- package/src/index.js +20 -20
- package/src/knowledge/gc.js +308 -308
- package/src/knowledge/lifecycle.js +401 -401
- package/src/knowledge/promote.js +364 -364
- package/src/knowledge/references.js +342 -342
- package/src/patterns/matcher.js +218 -218
- package/src/patterns/registry.js +375 -375
- package/src/patterns/triggers.js +423 -423
- package/src/services/batch-service.js +849 -849
- package/src/services/notification-service.js +342 -342
- package/templates/codespaces/devcontainer.json +52 -52
- package/templates/codespaces/setup.sh +70 -70
- package/templates/workspace/.ai/README.md +164 -164
- package/templates/workspace/.ai/agents/README.md +204 -204
- package/templates/workspace/.ai/agents/claude.md +625 -625
- package/templates/workspace/.ai/config/README.md +79 -79
- package/templates/workspace/.ai/config/notifications.template.json +20 -20
- package/templates/workspace/.ai/memory/deadends.md +79 -79
- package/templates/workspace/.ai/memory/decisions.md +58 -58
- package/templates/workspace/.ai/memory/patterns.md +65 -65
- package/templates/workspace/.ai/patterns/backend/README.md +126 -126
- package/templates/workspace/.ai/patterns/frontend/README.md +103 -103
- package/templates/workspace/.ai/patterns/index.md +256 -256
- package/templates/workspace/.ai/patterns/triggers.json +1087 -1087
- package/templates/workspace/.ai/patterns/universal/README.md +141 -141
- package/templates/workspace/.ai/state.template.json +8 -8
- package/templates/workspace/.ai/tasks/active.md +77 -77
- package/templates/workspace/.ai/tasks/backlog.md +95 -95
- package/templates/workspace/.ai/workflows/batch-task.md +356 -356
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
# Backend Patterns
|
|
2
|
-
|
|
3
|
-
This directory contains design patterns and best practices for backend development.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
Backend patterns cover:
|
|
8
|
-
- Express.js route structure
|
|
9
|
-
- REST API design
|
|
10
|
-
- Database queries and migrations
|
|
11
|
-
- Error handling and logging
|
|
12
|
-
- Authentication and authorization
|
|
13
|
-
- Data validation
|
|
14
|
-
- Performance optimization
|
|
15
|
-
- Middleware patterns
|
|
16
|
-
- Integration patterns
|
|
17
|
-
|
|
18
|
-
## Structure
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
backend/
|
|
22
|
-
├── README.md # This file
|
|
23
|
-
├── express/ # Express.js patterns
|
|
24
|
-
│ └── README.md # Express routing and middleware
|
|
25
|
-
├── database/ # Database patterns
|
|
26
|
-
│ └── README.md # Query and ORM patterns
|
|
27
|
-
├── api-design/ # REST API patterns
|
|
28
|
-
│ └── README.md # API structure and conventions
|
|
29
|
-
├── security/ # Security patterns
|
|
30
|
-
│ └── README.md # Auth, validation, sanitization
|
|
31
|
-
└── integration/ # Integration patterns
|
|
32
|
-
└── README.md # Working with external services
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Auto-Apply Triggers
|
|
36
|
-
|
|
37
|
-
These patterns are automatically loaded when:
|
|
38
|
-
|
|
39
|
-
- **File:** `*.routes.ts`, `routes/*.ts` (Express routes)
|
|
40
|
-
- **Import:** `from.*express`, `import.*Router`
|
|
41
|
-
- **Path:** `src/routes/`, `src/api/`
|
|
42
|
-
- **Keyword:** `app.get`, `app.post`, `router.use`
|
|
43
|
-
|
|
44
|
-
See `patterns/index.md` for trigger configuration.
|
|
45
|
-
|
|
46
|
-
## Common Patterns
|
|
47
|
-
|
|
48
|
-
### Route Structure
|
|
49
|
-
```typescript
|
|
50
|
-
// Group related routes together
|
|
51
|
-
// Use middleware for common operations (auth, logging)
|
|
52
|
-
// Keep route handlers thin, logic in services
|
|
53
|
-
// Consistent error handling
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### Express Middleware
|
|
57
|
-
- Authentication middleware early in chain
|
|
58
|
-
- Error handling middleware last
|
|
59
|
-
- Logging middleware for all requests
|
|
60
|
-
- Request validation middleware
|
|
61
|
-
- CORS middleware appropriately configured
|
|
62
|
-
|
|
63
|
-
### API Design
|
|
64
|
-
- RESTful conventions (GET, POST, PUT, DELETE)
|
|
65
|
-
- Consistent response format
|
|
66
|
-
- Proper HTTP status codes
|
|
67
|
-
- Pagination for list endpoints
|
|
68
|
-
- Filtering and sorting support
|
|
69
|
-
|
|
70
|
-
### Database Queries
|
|
71
|
-
- Use ORM/query builder (not raw SQL)
|
|
72
|
-
- Eager load relationships when needed
|
|
73
|
-
- Avoid N+1 query problems
|
|
74
|
-
- Index frequently-queried columns
|
|
75
|
-
- Use transactions for multi-step operations
|
|
76
|
-
|
|
77
|
-
### Error Handling
|
|
78
|
-
- Custom error classes for different error types
|
|
79
|
-
- Consistent error response format
|
|
80
|
-
- Log errors with full context
|
|
81
|
-
- Don't expose internal errors to clients
|
|
82
|
-
- Use HTTP status codes correctly
|
|
83
|
-
|
|
84
|
-
### Validation
|
|
85
|
-
- Validate all user input
|
|
86
|
-
- Use schema validation (Zod, Joi, etc.)
|
|
87
|
-
- Sanitize input to prevent injection
|
|
88
|
-
- Custom validation rules for domain logic
|
|
89
|
-
- Clear error messages for users
|
|
90
|
-
|
|
91
|
-
### Authentication
|
|
92
|
-
- Use industry-standard auth (JWT, OAuth, etc.)
|
|
93
|
-
- Secure token storage
|
|
94
|
-
- Token expiration and refresh strategy
|
|
95
|
-
- Role-based access control (RBAC)
|
|
96
|
-
- Audit logging of auth events
|
|
97
|
-
|
|
98
|
-
## Usage
|
|
99
|
-
|
|
100
|
-
1. Read the relevant sub-directory README for your task
|
|
101
|
-
2. Check code examples for reference implementations
|
|
102
|
-
3. Follow patterns in new routes and services
|
|
103
|
-
4. Update patterns if you discover improvements
|
|
104
|
-
|
|
105
|
-
## Contributing
|
|
106
|
-
|
|
107
|
-
Found a better pattern?
|
|
108
|
-
|
|
109
|
-
1. Document it with examples
|
|
110
|
-
2. Add to appropriate subdirectory
|
|
111
|
-
3. Update this README
|
|
112
|
-
4. Commit with message: `docs: add [pattern name] pattern`
|
|
113
|
-
5. Update triggers in `patterns/index.md` if widely applicable
|
|
114
|
-
|
|
115
|
-
## Links
|
|
116
|
-
|
|
117
|
-
- [Express Patterns](express/README.md)
|
|
118
|
-
- [Database Patterns](database/README.md)
|
|
119
|
-
- [API Design](api-design/README.md)
|
|
120
|
-
- [Security Patterns](security/README.md)
|
|
121
|
-
- [Integration Patterns](integration/README.md)
|
|
122
|
-
|
|
123
|
-
## Version
|
|
124
|
-
|
|
125
|
-
**Last Updated:** (Set on template injection)
|
|
126
|
-
**Maintained By:** Development Team
|
|
1
|
+
# Backend Patterns
|
|
2
|
+
|
|
3
|
+
This directory contains design patterns and best practices for backend development.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Backend patterns cover:
|
|
8
|
+
- Express.js route structure
|
|
9
|
+
- REST API design
|
|
10
|
+
- Database queries and migrations
|
|
11
|
+
- Error handling and logging
|
|
12
|
+
- Authentication and authorization
|
|
13
|
+
- Data validation
|
|
14
|
+
- Performance optimization
|
|
15
|
+
- Middleware patterns
|
|
16
|
+
- Integration patterns
|
|
17
|
+
|
|
18
|
+
## Structure
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
backend/
|
|
22
|
+
├── README.md # This file
|
|
23
|
+
├── express/ # Express.js patterns
|
|
24
|
+
│ └── README.md # Express routing and middleware
|
|
25
|
+
├── database/ # Database patterns
|
|
26
|
+
│ └── README.md # Query and ORM patterns
|
|
27
|
+
├── api-design/ # REST API patterns
|
|
28
|
+
│ └── README.md # API structure and conventions
|
|
29
|
+
├── security/ # Security patterns
|
|
30
|
+
│ └── README.md # Auth, validation, sanitization
|
|
31
|
+
└── integration/ # Integration patterns
|
|
32
|
+
└── README.md # Working with external services
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Auto-Apply Triggers
|
|
36
|
+
|
|
37
|
+
These patterns are automatically loaded when:
|
|
38
|
+
|
|
39
|
+
- **File:** `*.routes.ts`, `routes/*.ts` (Express routes)
|
|
40
|
+
- **Import:** `from.*express`, `import.*Router`
|
|
41
|
+
- **Path:** `src/routes/`, `src/api/`
|
|
42
|
+
- **Keyword:** `app.get`, `app.post`, `router.use`
|
|
43
|
+
|
|
44
|
+
See `patterns/index.md` for trigger configuration.
|
|
45
|
+
|
|
46
|
+
## Common Patterns
|
|
47
|
+
|
|
48
|
+
### Route Structure
|
|
49
|
+
```typescript
|
|
50
|
+
// Group related routes together
|
|
51
|
+
// Use middleware for common operations (auth, logging)
|
|
52
|
+
// Keep route handlers thin, logic in services
|
|
53
|
+
// Consistent error handling
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Express Middleware
|
|
57
|
+
- Authentication middleware early in chain
|
|
58
|
+
- Error handling middleware last
|
|
59
|
+
- Logging middleware for all requests
|
|
60
|
+
- Request validation middleware
|
|
61
|
+
- CORS middleware appropriately configured
|
|
62
|
+
|
|
63
|
+
### API Design
|
|
64
|
+
- RESTful conventions (GET, POST, PUT, DELETE)
|
|
65
|
+
- Consistent response format
|
|
66
|
+
- Proper HTTP status codes
|
|
67
|
+
- Pagination for list endpoints
|
|
68
|
+
- Filtering and sorting support
|
|
69
|
+
|
|
70
|
+
### Database Queries
|
|
71
|
+
- Use ORM/query builder (not raw SQL)
|
|
72
|
+
- Eager load relationships when needed
|
|
73
|
+
- Avoid N+1 query problems
|
|
74
|
+
- Index frequently-queried columns
|
|
75
|
+
- Use transactions for multi-step operations
|
|
76
|
+
|
|
77
|
+
### Error Handling
|
|
78
|
+
- Custom error classes for different error types
|
|
79
|
+
- Consistent error response format
|
|
80
|
+
- Log errors with full context
|
|
81
|
+
- Don't expose internal errors to clients
|
|
82
|
+
- Use HTTP status codes correctly
|
|
83
|
+
|
|
84
|
+
### Validation
|
|
85
|
+
- Validate all user input
|
|
86
|
+
- Use schema validation (Zod, Joi, etc.)
|
|
87
|
+
- Sanitize input to prevent injection
|
|
88
|
+
- Custom validation rules for domain logic
|
|
89
|
+
- Clear error messages for users
|
|
90
|
+
|
|
91
|
+
### Authentication
|
|
92
|
+
- Use industry-standard auth (JWT, OAuth, etc.)
|
|
93
|
+
- Secure token storage
|
|
94
|
+
- Token expiration and refresh strategy
|
|
95
|
+
- Role-based access control (RBAC)
|
|
96
|
+
- Audit logging of auth events
|
|
97
|
+
|
|
98
|
+
## Usage
|
|
99
|
+
|
|
100
|
+
1. Read the relevant sub-directory README for your task
|
|
101
|
+
2. Check code examples for reference implementations
|
|
102
|
+
3. Follow patterns in new routes and services
|
|
103
|
+
4. Update patterns if you discover improvements
|
|
104
|
+
|
|
105
|
+
## Contributing
|
|
106
|
+
|
|
107
|
+
Found a better pattern?
|
|
108
|
+
|
|
109
|
+
1. Document it with examples
|
|
110
|
+
2. Add to appropriate subdirectory
|
|
111
|
+
3. Update this README
|
|
112
|
+
4. Commit with message: `docs: add [pattern name] pattern`
|
|
113
|
+
5. Update triggers in `patterns/index.md` if widely applicable
|
|
114
|
+
|
|
115
|
+
## Links
|
|
116
|
+
|
|
117
|
+
- [Express Patterns](express/README.md)
|
|
118
|
+
- [Database Patterns](database/README.md)
|
|
119
|
+
- [API Design](api-design/README.md)
|
|
120
|
+
- [Security Patterns](security/README.md)
|
|
121
|
+
- [Integration Patterns](integration/README.md)
|
|
122
|
+
|
|
123
|
+
## Version
|
|
124
|
+
|
|
125
|
+
**Last Updated:** (Set on template injection)
|
|
126
|
+
**Maintained By:** Development Team
|
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
# Frontend Patterns
|
|
2
|
-
|
|
3
|
-
This directory contains design patterns and best practices for frontend development.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
Frontend patterns cover:
|
|
8
|
-
- React component architecture
|
|
9
|
-
- TypeScript type definitions
|
|
10
|
-
- Styling and CSS strategies
|
|
11
|
-
- State management
|
|
12
|
-
- Performance optimization
|
|
13
|
-
- Accessibility (a11y)
|
|
14
|
-
- Component composition
|
|
15
|
-
- Hook patterns
|
|
16
|
-
|
|
17
|
-
## Structure
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
frontend/
|
|
21
|
-
├── README.md # This file
|
|
22
|
-
├── react/ # React-specific patterns
|
|
23
|
-
│ └── README.md # React component patterns
|
|
24
|
-
├── styling/ # CSS and styling patterns
|
|
25
|
-
│ └── README.md # Styling strategies
|
|
26
|
-
├── component-libs/ # UI component library patterns
|
|
27
|
-
│ └── README.md # Working with component libraries
|
|
28
|
-
└── accessibility/ # A11y patterns
|
|
29
|
-
└── README.md # Accessibility patterns
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Auto-Apply Triggers
|
|
33
|
-
|
|
34
|
-
These patterns are automatically loaded when:
|
|
35
|
-
|
|
36
|
-
- **File:** `*.tsx`, `*.jsx` (React components)
|
|
37
|
-
- **Import:** `import.*React`, `from.*react`
|
|
38
|
-
- **Path:** `src/components/`
|
|
39
|
-
- **Keyword:** `function Component`, `export default`
|
|
40
|
-
|
|
41
|
-
See `patterns/index.md` for trigger configuration.
|
|
42
|
-
|
|
43
|
-
## Common Patterns
|
|
44
|
-
|
|
45
|
-
### Component Architecture
|
|
46
|
-
- Functional components with hooks (not class components)
|
|
47
|
-
- One component per file
|
|
48
|
-
- Props interfaces at top of file
|
|
49
|
-
- Hooks (useState, useEffect, useContext)
|
|
50
|
-
- Custom hooks for reusable logic
|
|
51
|
-
|
|
52
|
-
### TypeScript
|
|
53
|
-
- Define interfaces for component props
|
|
54
|
-
- Use `React.FC<Props>` for component type
|
|
55
|
-
- Strict null checks enabled
|
|
56
|
-
- Export types alongside components
|
|
57
|
-
|
|
58
|
-
### State Management
|
|
59
|
-
- Local state with `useState` for component-only state
|
|
60
|
-
- Context API for shared state
|
|
61
|
-
- Consider Redux/Zustand for complex state
|
|
62
|
-
- Avoid prop drilling (use Context instead)
|
|
63
|
-
|
|
64
|
-
### Performance
|
|
65
|
-
- Memoize expensive components with `React.memo`
|
|
66
|
-
- Use `useCallback` for stable function references
|
|
67
|
-
- Use `useMemo` for expensive computations
|
|
68
|
-
- Lazy load routes with `React.lazy`
|
|
69
|
-
|
|
70
|
-
### Styling
|
|
71
|
-
- TailwindCSS for utility-first styling
|
|
72
|
-
- CSS modules for scoped styles
|
|
73
|
-
- Avoid inline styles except for dynamic values
|
|
74
|
-
- Use design tokens for consistency
|
|
75
|
-
|
|
76
|
-
## Usage
|
|
77
|
-
|
|
78
|
-
1. Read the relevant sub-directory README for your task
|
|
79
|
-
2. Check code examples for reference implementations
|
|
80
|
-
3. Follow patterns in new components
|
|
81
|
-
4. Update patterns if you discover improvements
|
|
82
|
-
|
|
83
|
-
## Contributing
|
|
84
|
-
|
|
85
|
-
Found a better pattern?
|
|
86
|
-
|
|
87
|
-
1. Document it with examples
|
|
88
|
-
2. Add to appropriate subdirectory
|
|
89
|
-
3. Update this README
|
|
90
|
-
4. Commit with message: `docs: add [pattern name] pattern`
|
|
91
|
-
5. Update triggers in `patterns/index.md` if widely applicable
|
|
92
|
-
|
|
93
|
-
## Links
|
|
94
|
-
|
|
95
|
-
- [React Component Patterns](react/README.md)
|
|
96
|
-
- [Styling Strategies](styling/README.md)
|
|
97
|
-
- [Component Libraries](component-libs/README.md)
|
|
98
|
-
- [Accessibility Patterns](accessibility/README.md)
|
|
99
|
-
|
|
100
|
-
## Version
|
|
101
|
-
|
|
102
|
-
**Last Updated:** (Set on template injection)
|
|
103
|
-
**Maintained By:** Development Team
|
|
1
|
+
# Frontend Patterns
|
|
2
|
+
|
|
3
|
+
This directory contains design patterns and best practices for frontend development.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Frontend patterns cover:
|
|
8
|
+
- React component architecture
|
|
9
|
+
- TypeScript type definitions
|
|
10
|
+
- Styling and CSS strategies
|
|
11
|
+
- State management
|
|
12
|
+
- Performance optimization
|
|
13
|
+
- Accessibility (a11y)
|
|
14
|
+
- Component composition
|
|
15
|
+
- Hook patterns
|
|
16
|
+
|
|
17
|
+
## Structure
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
frontend/
|
|
21
|
+
├── README.md # This file
|
|
22
|
+
├── react/ # React-specific patterns
|
|
23
|
+
│ └── README.md # React component patterns
|
|
24
|
+
├── styling/ # CSS and styling patterns
|
|
25
|
+
│ └── README.md # Styling strategies
|
|
26
|
+
├── component-libs/ # UI component library patterns
|
|
27
|
+
│ └── README.md # Working with component libraries
|
|
28
|
+
└── accessibility/ # A11y patterns
|
|
29
|
+
└── README.md # Accessibility patterns
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Auto-Apply Triggers
|
|
33
|
+
|
|
34
|
+
These patterns are automatically loaded when:
|
|
35
|
+
|
|
36
|
+
- **File:** `*.tsx`, `*.jsx` (React components)
|
|
37
|
+
- **Import:** `import.*React`, `from.*react`
|
|
38
|
+
- **Path:** `src/components/`
|
|
39
|
+
- **Keyword:** `function Component`, `export default`
|
|
40
|
+
|
|
41
|
+
See `patterns/index.md` for trigger configuration.
|
|
42
|
+
|
|
43
|
+
## Common Patterns
|
|
44
|
+
|
|
45
|
+
### Component Architecture
|
|
46
|
+
- Functional components with hooks (not class components)
|
|
47
|
+
- One component per file
|
|
48
|
+
- Props interfaces at top of file
|
|
49
|
+
- Hooks (useState, useEffect, useContext)
|
|
50
|
+
- Custom hooks for reusable logic
|
|
51
|
+
|
|
52
|
+
### TypeScript
|
|
53
|
+
- Define interfaces for component props
|
|
54
|
+
- Use `React.FC<Props>` for component type
|
|
55
|
+
- Strict null checks enabled
|
|
56
|
+
- Export types alongside components
|
|
57
|
+
|
|
58
|
+
### State Management
|
|
59
|
+
- Local state with `useState` for component-only state
|
|
60
|
+
- Context API for shared state
|
|
61
|
+
- Consider Redux/Zustand for complex state
|
|
62
|
+
- Avoid prop drilling (use Context instead)
|
|
63
|
+
|
|
64
|
+
### Performance
|
|
65
|
+
- Memoize expensive components with `React.memo`
|
|
66
|
+
- Use `useCallback` for stable function references
|
|
67
|
+
- Use `useMemo` for expensive computations
|
|
68
|
+
- Lazy load routes with `React.lazy`
|
|
69
|
+
|
|
70
|
+
### Styling
|
|
71
|
+
- TailwindCSS for utility-first styling
|
|
72
|
+
- CSS modules for scoped styles
|
|
73
|
+
- Avoid inline styles except for dynamic values
|
|
74
|
+
- Use design tokens for consistency
|
|
75
|
+
|
|
76
|
+
## Usage
|
|
77
|
+
|
|
78
|
+
1. Read the relevant sub-directory README for your task
|
|
79
|
+
2. Check code examples for reference implementations
|
|
80
|
+
3. Follow patterns in new components
|
|
81
|
+
4. Update patterns if you discover improvements
|
|
82
|
+
|
|
83
|
+
## Contributing
|
|
84
|
+
|
|
85
|
+
Found a better pattern?
|
|
86
|
+
|
|
87
|
+
1. Document it with examples
|
|
88
|
+
2. Add to appropriate subdirectory
|
|
89
|
+
3. Update this README
|
|
90
|
+
4. Commit with message: `docs: add [pattern name] pattern`
|
|
91
|
+
5. Update triggers in `patterns/index.md` if widely applicable
|
|
92
|
+
|
|
93
|
+
## Links
|
|
94
|
+
|
|
95
|
+
- [React Component Patterns](react/README.md)
|
|
96
|
+
- [Styling Strategies](styling/README.md)
|
|
97
|
+
- [Component Libraries](component-libs/README.md)
|
|
98
|
+
- [Accessibility Patterns](accessibility/README.md)
|
|
99
|
+
|
|
100
|
+
## Version
|
|
101
|
+
|
|
102
|
+
**Last Updated:** (Set on template injection)
|
|
103
|
+
**Maintained By:** Development Team
|