@fermindi/pwn-cli 0.1.0 → 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 -53
  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 -128
  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,52 +1,52 @@
1
- {
2
- "name": "PWN Development Environment",
3
- "image": "mcr.microsoft.com/devcontainers/javascript-node:22",
4
-
5
- "features": {
6
- "ghcr.io/devcontainers/features/github-cli:1": {},
7
- "ghcr.io/devcontainers/features/git:1": {}
8
- },
9
-
10
- "customizations": {
11
- "vscode": {
12
- "settings": {
13
- "terminal.integrated.defaultProfile.linux": "bash",
14
- "editor.formatOnSave": true,
15
- "editor.tabSize": 2,
16
- "files.trimTrailingWhitespace": true,
17
- "files.insertFinalNewline": true,
18
- "javascript.preferences.importModuleSpecifierEnding": "js",
19
- "typescript.preferences.importModuleSpecifierEnding": "js"
20
- },
21
- "extensions": [
22
- "dbaeumer.vscode-eslint",
23
- "esbenp.prettier-vscode",
24
- "bradlc.vscode-tailwindcss",
25
- "formulahendry.auto-rename-tag",
26
- "christian-kohler.path-intellisense",
27
- "usernamehw.errorlens",
28
- "eamodio.gitlens",
29
- "github.copilot",
30
- "anthropics.claude-code"
31
- ]
32
- }
33
- },
34
-
35
- "postCreateCommand": "bash .devcontainer/setup.sh",
36
- "postStartCommand": "echo '🚀 Development environment ready!'",
37
-
38
- "forwardPorts": [3000, 5173, 8080],
39
-
40
- "portsAttributes": {
41
- "3000": { "label": "App", "onAutoForward": "notify" },
42
- "5173": { "label": "Vite", "onAutoForward": "notify" },
43
- "8080": { "label": "Server", "onAutoForward": "notify" }
44
- },
45
-
46
- "remoteUser": "node",
47
-
48
- "containerEnv": {
49
- "PWN_CODESPACE": "true",
50
- "NODE_ENV": "development"
51
- }
52
- }
1
+ {
2
+ "name": "PWN Development Environment",
3
+ "image": "mcr.microsoft.com/devcontainers/javascript-node:22",
4
+
5
+ "features": {
6
+ "ghcr.io/devcontainers/features/github-cli:1": {},
7
+ "ghcr.io/devcontainers/features/git:1": {}
8
+ },
9
+
10
+ "customizations": {
11
+ "vscode": {
12
+ "settings": {
13
+ "terminal.integrated.defaultProfile.linux": "bash",
14
+ "editor.formatOnSave": true,
15
+ "editor.tabSize": 2,
16
+ "files.trimTrailingWhitespace": true,
17
+ "files.insertFinalNewline": true,
18
+ "javascript.preferences.importModuleSpecifierEnding": "js",
19
+ "typescript.preferences.importModuleSpecifierEnding": "js"
20
+ },
21
+ "extensions": [
22
+ "dbaeumer.vscode-eslint",
23
+ "esbenp.prettier-vscode",
24
+ "bradlc.vscode-tailwindcss",
25
+ "formulahendry.auto-rename-tag",
26
+ "christian-kohler.path-intellisense",
27
+ "usernamehw.errorlens",
28
+ "eamodio.gitlens",
29
+ "github.copilot",
30
+ "anthropics.claude-code"
31
+ ]
32
+ }
33
+ },
34
+
35
+ "postCreateCommand": "bash .devcontainer/setup.sh",
36
+ "postStartCommand": "echo '🚀 Development environment ready!'",
37
+
38
+ "forwardPorts": [3000, 5173, 8080],
39
+
40
+ "portsAttributes": {
41
+ "3000": { "label": "App", "onAutoForward": "notify" },
42
+ "5173": { "label": "Vite", "onAutoForward": "notify" },
43
+ "8080": { "label": "Server", "onAutoForward": "notify" }
44
+ },
45
+
46
+ "remoteUser": "node",
47
+
48
+ "containerEnv": {
49
+ "PWN_CODESPACE": "true",
50
+ "NODE_ENV": "development"
51
+ }
52
+ }
@@ -1,70 +1,70 @@
1
- #!/bin/bash
2
- # PWN Codespace Setup Script
3
- # Runs automatically when codespace is created
4
-
5
- set -e
6
-
7
- echo "=========================================="
8
- echo " Setting up development environment"
9
- echo "=========================================="
10
-
11
- # Colors
12
- GREEN='\033[0;32m'
13
- BLUE='\033[0;34m'
14
- NC='\033[0m'
15
-
16
- print_step() { echo -e "${BLUE}>>>${NC} $1"; }
17
- print_ok() { echo -e "${GREEN}[OK]${NC} $1"; }
18
-
19
- # 1. Install dependencies
20
- print_step "Installing dependencies..."
21
- if [ -f "pnpm-lock.yaml" ]; then
22
- npm install -g pnpm 2>/dev/null || true
23
- pnpm install
24
- elif [ -f "package-lock.json" ]; then
25
- npm ci
26
- elif [ -f "yarn.lock" ]; then
27
- npm install -g yarn 2>/dev/null || true
28
- yarn install --frozen-lockfile
29
- elif [ -f "package.json" ]; then
30
- npm install
31
- fi
32
- print_ok "Dependencies installed"
33
-
34
- # 2. Setup PWN if available
35
- if command -v pwn &> /dev/null; then
36
- print_step "Initializing PWN workspace..."
37
- if [ ! -d ".ai" ]; then
38
- pwn inject
39
- fi
40
- pwn knowledge sync 2>/dev/null || true
41
- print_ok "PWN workspace ready"
42
- fi
43
-
44
- # 3. Configure git
45
- print_step "Configuring git..."
46
- if [ -n "$GITHUB_USER" ]; then
47
- git config --global user.name "${GITHUB_USER}" 2>/dev/null || true
48
- git config --global user.email "${GITHUB_USER}@users.noreply.github.com" 2>/dev/null || true
49
- fi
50
- print_ok "Git configured"
51
-
52
- # 4. Setup aliases
53
- cat >> ~/.bashrc << 'ALIASES'
54
-
55
- # Quick aliases
56
- alias dev='npm run dev'
57
- alias build='npm run build'
58
- alias test='npm test'
59
- alias gs='git status'
60
- alias gd='git diff'
61
- alias gc='git commit'
62
- alias gp='git push'
63
- ALIASES
64
- print_ok "Aliases configured"
65
-
66
- echo ""
67
- echo "=========================================="
68
- echo -e "${GREEN} Setup complete!${NC}"
69
- echo "=========================================="
70
- echo ""
1
+ #!/bin/bash
2
+ # PWN Codespace Setup Script
3
+ # Runs automatically when codespace is created
4
+
5
+ set -e
6
+
7
+ echo "=========================================="
8
+ echo " Setting up development environment"
9
+ echo "=========================================="
10
+
11
+ # Colors
12
+ GREEN='\033[0;32m'
13
+ BLUE='\033[0;34m'
14
+ NC='\033[0m'
15
+
16
+ print_step() { echo -e "${BLUE}>>>${NC} $1"; }
17
+ print_ok() { echo -e "${GREEN}[OK]${NC} $1"; }
18
+
19
+ # 1. Install dependencies
20
+ print_step "Installing dependencies..."
21
+ if [ -f "pnpm-lock.yaml" ]; then
22
+ npm install -g pnpm 2>/dev/null || true
23
+ pnpm install
24
+ elif [ -f "package-lock.json" ]; then
25
+ npm ci
26
+ elif [ -f "yarn.lock" ]; then
27
+ npm install -g yarn 2>/dev/null || true
28
+ yarn install --frozen-lockfile
29
+ elif [ -f "package.json" ]; then
30
+ npm install
31
+ fi
32
+ print_ok "Dependencies installed"
33
+
34
+ # 2. Setup PWN if available
35
+ if command -v pwn &> /dev/null; then
36
+ print_step "Initializing PWN workspace..."
37
+ if [ ! -d ".ai" ]; then
38
+ pwn inject
39
+ fi
40
+ pwn knowledge sync 2>/dev/null || true
41
+ print_ok "PWN workspace ready"
42
+ fi
43
+
44
+ # 3. Configure git
45
+ print_step "Configuring git..."
46
+ if [ -n "$GITHUB_USER" ]; then
47
+ git config --global user.name "${GITHUB_USER}" 2>/dev/null || true
48
+ git config --global user.email "${GITHUB_USER}@users.noreply.github.com" 2>/dev/null || true
49
+ fi
50
+ print_ok "Git configured"
51
+
52
+ # 4. Setup aliases
53
+ cat >> ~/.bashrc << 'ALIASES'
54
+
55
+ # Quick aliases
56
+ alias dev='npm run dev'
57
+ alias build='npm run build'
58
+ alias test='npm test'
59
+ alias gs='git status'
60
+ alias gd='git diff'
61
+ alias gc='git commit'
62
+ alias gp='git push'
63
+ ALIASES
64
+ print_ok "Aliases configured"
65
+
66
+ echo ""
67
+ echo "=========================================="
68
+ echo -e "${GREEN} Setup complete!${NC}"
69
+ echo "=========================================="
70
+ echo ""
@@ -1,164 +1,164 @@
1
- # AI Workspace
2
-
3
- This directory contains all AI-related context, memory, and configuration for this project.
4
-
5
- ## 📁 Structure
6
-
7
- ```
8
- .ai/
9
- ├── README.md # This file
10
- ├── state.json # Current session state (git-ignored)
11
- ├── memory/ # Persistent knowledge
12
- │ ├── decisions.md # Architectural decisions
13
- │ ├── patterns.md # Codebase patterns
14
- │ ├── deadends.md # Failed approaches
15
- │ └── archive/ # Historical context
16
- ├── tasks/ # Work tracking
17
- │ ├── active.md # Current tasks
18
- │ └── backlog.md # Future tasks
19
- ├── patterns/ # Auto-applied patterns
20
- │ ├── index.md # Trigger map
21
- │ ├── frontend/ # Frontend patterns
22
- │ ├── backend/ # Backend patterns
23
- │ └── universal/ # Cross-cutting patterns
24
- ├── config/ # Configurations (git-ignored)
25
- │ └── notifications.json # Notification settings
26
- ├── workflows/ # Automation templates
27
- │ └── batch-task.md # Batch execution prompt
28
- └── agents/ # AI agent configs
29
- ├── README.md # Agent documentation
30
- └── claude.md # Claude Code bootstrap
31
- ```
32
-
33
- ## 🧠 Memory System
34
-
35
- ### decisions.md
36
- Tracks major architectural decisions with rationale and impact.
37
-
38
- **Format:**
39
- ```markdown
40
- ## DEC-001: Decision Title
41
- **Date:** YYYY-MM-DD
42
- **Context:** Why this decision was needed
43
- **Decision:** What was decided
44
- **Rationale:** Why this is the best choice
45
- **Impact:** What this affects
46
- ```
47
-
48
- ### patterns.md
49
- Captures recurring patterns learned during development.
50
-
51
- **Format:**
52
- ```markdown
53
- ## Pattern Category
54
-
55
- ### Pattern Name
56
- **Context:** When this applies
57
- **Pattern:** Code example or description
58
- **Rationale:** Why this is better
59
- ```
60
-
61
- ### deadends.md
62
- Documents approaches that failed to avoid repeating mistakes.
63
-
64
- **Format:**
65
- ```markdown
66
- ## DE-001: Failed Approach
67
- **Date:** YYYY-MM-DD
68
- **Attempted:** What we tried
69
- **Problem:** Why it failed
70
- **Solution:** What worked instead
71
- ```
72
-
73
- ## 📋 Tasks System
74
-
75
- ### active.md
76
- Current work in progress. Use checkboxes for tracking:
77
- ```markdown
78
- - [ ] US-001: Pending task
79
- - [x] US-002: Completed task
80
- ```
81
-
82
- ### backlog.md
83
- Future tasks, prioritized from top to bottom.
84
-
85
- ## 🎯 Patterns System
86
-
87
- Patterns are auto-applied based on triggers defined in `patterns/index.md`.
88
-
89
- **How it works:**
90
- 1. AI reads `patterns/index.md` on session start
91
- 2. Registers triggers (file extensions, imports, commands)
92
- 3. Auto-loads relevant patterns when triggered
93
- 4. Applies patterns to current work
94
-
95
- **Example:**
96
- ```
97
- User edits: src/components/Button.tsx
98
- → Triggers: *.tsx
99
- → Auto-loads: patterns/frontend/react/
100
- → Applies React patterns automatically
101
- ```
102
-
103
- ## 🔄 Workflows
104
-
105
- ### batch-task.md
106
- Template for autonomous batch execution. Used by `pwn batch` command.
107
-
108
- Defines:
109
- - Task selection logic
110
- - Quality gates (tests, lint, typecheck)
111
- - Commit patterns
112
- - Completion signals
113
-
114
- ## 🤖 Agents
115
-
116
- ### agent/claude.md
117
- Bootstrap instructions for Claude Code.
118
-
119
- Contains:
120
- - Session start protocol
121
- - Context loading order
122
- - Pattern auto-application rules
123
- - Batch execution mode
124
-
125
- ### Adding New Agents
126
- Copy `agents/claude.md` as template for other AI agents (Cursor, Copilot, etc).
127
-
128
- ## 🔒 Git Ignore
129
-
130
- **Tracked (committed):**
131
- - memory/ (shared team knowledge)
132
- - tasks/ (work visibility)
133
- - patterns/ (team patterns)
134
- - workflows/ (team automation)
135
- - agents/ (team AI configs)
136
-
137
- **Ignored (local only):**
138
- - state.json (personal session state)
139
- - config/notifications.json (personal notification settings)
140
-
141
- ## 🚀 Getting Started
142
-
143
- ### For AI Agents
144
- 1. Read `agents/<your-agent>.md` for bootstrap instructions
145
- 2. Load `memory/` files for context
146
- 3. Register patterns from `patterns/index.md`
147
- 4. Check `tasks/active.md` for current work
148
-
149
- ### For Humans
150
- 1. Review `memory/decisions.md` for architectural context
151
- 2. Check `tasks/active.md` for team's current work
152
- 3. Add tasks to `tasks/backlog.md` for AI to pick up
153
- 4. Update patterns in `memory/patterns.md` when you discover new ones
154
-
155
- ## 📚 Learn More
156
-
157
- - [PWN Documentation](https://github.com/yourusername/pwn)
158
- - [Quick Start Guide](https://github.com/yourusername/pwn/docs/quick-start.md)
159
- - [Pattern Guide](https://github.com/yourusername/pwn/docs/patterns-guide.md)
160
-
161
- ---
162
-
163
- **PWN Version:** 1.0.0
164
- **Injected:** (automatically set on injection)
1
+ # AI Workspace
2
+
3
+ This directory contains all AI-related context, memory, and configuration for this project.
4
+
5
+ ## 📁 Structure
6
+
7
+ ```
8
+ .ai/
9
+ ├── README.md # This file
10
+ ├── state.json # Current session state (git-ignored)
11
+ ├── memory/ # Persistent knowledge
12
+ │ ├── decisions.md # Architectural decisions
13
+ │ ├── patterns.md # Codebase patterns
14
+ │ ├── deadends.md # Failed approaches
15
+ │ └── archive/ # Historical context
16
+ ├── tasks/ # Work tracking
17
+ │ ├── active.md # Current tasks
18
+ │ └── backlog.md # Future tasks
19
+ ├── patterns/ # Auto-applied patterns
20
+ │ ├── index.md # Trigger map
21
+ │ ├── frontend/ # Frontend patterns
22
+ │ ├── backend/ # Backend patterns
23
+ │ └── universal/ # Cross-cutting patterns
24
+ ├── config/ # Configurations (git-ignored)
25
+ │ └── notifications.json # Notification settings
26
+ ├── workflows/ # Automation templates
27
+ │ └── batch-task.md # Batch execution prompt
28
+ └── agents/ # AI agent configs
29
+ ├── README.md # Agent documentation
30
+ └── claude.md # Claude Code bootstrap
31
+ ```
32
+
33
+ ## 🧠 Memory System
34
+
35
+ ### decisions.md
36
+ Tracks major architectural decisions with rationale and impact.
37
+
38
+ **Format:**
39
+ ```markdown
40
+ ## DEC-001: Decision Title
41
+ **Date:** YYYY-MM-DD
42
+ **Context:** Why this decision was needed
43
+ **Decision:** What was decided
44
+ **Rationale:** Why this is the best choice
45
+ **Impact:** What this affects
46
+ ```
47
+
48
+ ### patterns.md
49
+ Captures recurring patterns learned during development.
50
+
51
+ **Format:**
52
+ ```markdown
53
+ ## Pattern Category
54
+
55
+ ### Pattern Name
56
+ **Context:** When this applies
57
+ **Pattern:** Code example or description
58
+ **Rationale:** Why this is better
59
+ ```
60
+
61
+ ### deadends.md
62
+ Documents approaches that failed to avoid repeating mistakes.
63
+
64
+ **Format:**
65
+ ```markdown
66
+ ## DE-001: Failed Approach
67
+ **Date:** YYYY-MM-DD
68
+ **Attempted:** What we tried
69
+ **Problem:** Why it failed
70
+ **Solution:** What worked instead
71
+ ```
72
+
73
+ ## 📋 Tasks System
74
+
75
+ ### active.md
76
+ Current work in progress. Use checkboxes for tracking:
77
+ ```markdown
78
+ - [ ] US-001: Pending task
79
+ - [x] US-002: Completed task
80
+ ```
81
+
82
+ ### backlog.md
83
+ Future tasks, prioritized from top to bottom.
84
+
85
+ ## 🎯 Patterns System
86
+
87
+ Patterns are auto-applied based on triggers defined in `patterns/index.md`.
88
+
89
+ **How it works:**
90
+ 1. AI reads `patterns/index.md` on session start
91
+ 2. Registers triggers (file extensions, imports, commands)
92
+ 3. Auto-loads relevant patterns when triggered
93
+ 4. Applies patterns to current work
94
+
95
+ **Example:**
96
+ ```
97
+ User edits: src/components/Button.tsx
98
+ → Triggers: *.tsx
99
+ → Auto-loads: patterns/frontend/react/
100
+ → Applies React patterns automatically
101
+ ```
102
+
103
+ ## 🔄 Workflows
104
+
105
+ ### batch-task.md
106
+ Template for autonomous batch execution. Used by `pwn batch` command.
107
+
108
+ Defines:
109
+ - Task selection logic
110
+ - Quality gates (tests, lint, typecheck)
111
+ - Commit patterns
112
+ - Completion signals
113
+
114
+ ## 🤖 Agents
115
+
116
+ ### agent/claude.md
117
+ Bootstrap instructions for Claude Code.
118
+
119
+ Contains:
120
+ - Session start protocol
121
+ - Context loading order
122
+ - Pattern auto-application rules
123
+ - Batch execution mode
124
+
125
+ ### Adding New Agents
126
+ Copy `agents/claude.md` as template for other AI agents (Cursor, Copilot, etc).
127
+
128
+ ## 🔒 Git Ignore
129
+
130
+ **Tracked (committed):**
131
+ - memory/ (shared team knowledge)
132
+ - tasks/ (work visibility)
133
+ - patterns/ (team patterns)
134
+ - workflows/ (team automation)
135
+ - agents/ (team AI configs)
136
+
137
+ **Ignored (local only):**
138
+ - state.json (personal session state)
139
+ - config/notifications.json (personal notification settings)
140
+
141
+ ## 🚀 Getting Started
142
+
143
+ ### For AI Agents
144
+ 1. Read `agents/<your-agent>.md` for bootstrap instructions
145
+ 2. Load `memory/` files for context
146
+ 3. Register patterns from `patterns/index.md`
147
+ 4. Check `tasks/active.md` for current work
148
+
149
+ ### For Humans
150
+ 1. Review `memory/decisions.md` for architectural context
151
+ 2. Check `tasks/active.md` for team's current work
152
+ 3. Add tasks to `tasks/backlog.md` for AI to pick up
153
+ 4. Update patterns in `memory/patterns.md` when you discover new ones
154
+
155
+ ## 📚 Learn More
156
+
157
+ - [PWN Documentation](https://github.com/yourusername/pwn)
158
+ - [Quick Start Guide](https://github.com/yourusername/pwn/docs/quick-start.md)
159
+ - [Pattern Guide](https://github.com/yourusername/pwn/docs/patterns-guide.md)
160
+
161
+ ---
162
+
163
+ **PWN Version:** 1.0.0
164
+ **Injected:** (automatically set on injection)