@fermindi/pwn-cli 0.1.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 -0
- package/README.md +251 -0
- package/cli/batch.js +333 -0
- package/cli/codespaces.js +303 -0
- package/cli/index.js +91 -0
- package/cli/inject.js +53 -0
- package/cli/knowledge.js +531 -0
- package/cli/notify.js +135 -0
- package/cli/patterns.js +665 -0
- package/cli/status.js +91 -0
- package/cli/validate.js +61 -0
- package/package.json +70 -0
- package/src/core/inject.js +128 -0
- package/src/core/state.js +91 -0
- package/src/core/validate.js +202 -0
- package/src/core/workspace.js +176 -0
- package/src/index.js +20 -0
- package/src/knowledge/gc.js +308 -0
- package/src/knowledge/lifecycle.js +401 -0
- package/src/knowledge/promote.js +364 -0
- package/src/knowledge/references.js +342 -0
- package/src/patterns/matcher.js +218 -0
- package/src/patterns/registry.js +375 -0
- package/src/patterns/triggers.js +423 -0
- package/src/services/batch-service.js +849 -0
- package/src/services/notification-service.js +342 -0
- package/templates/codespaces/devcontainer.json +52 -0
- package/templates/codespaces/setup.sh +70 -0
- package/templates/workspace/.ai/README.md +164 -0
- package/templates/workspace/.ai/agents/README.md +204 -0
- package/templates/workspace/.ai/agents/claude.md +625 -0
- package/templates/workspace/.ai/config/.gitkeep +0 -0
- package/templates/workspace/.ai/config/README.md +79 -0
- package/templates/workspace/.ai/config/notifications.template.json +20 -0
- package/templates/workspace/.ai/memory/deadends.md +79 -0
- package/templates/workspace/.ai/memory/decisions.md +58 -0
- package/templates/workspace/.ai/memory/patterns.md +65 -0
- package/templates/workspace/.ai/patterns/backend/README.md +126 -0
- package/templates/workspace/.ai/patterns/frontend/README.md +103 -0
- package/templates/workspace/.ai/patterns/index.md +256 -0
- package/templates/workspace/.ai/patterns/triggers.json +1087 -0
- package/templates/workspace/.ai/patterns/universal/README.md +141 -0
- package/templates/workspace/.ai/state.template.json +8 -0
- package/templates/workspace/.ai/tasks/active.md +77 -0
- package/templates/workspace/.ai/tasks/backlog.md +95 -0
- package/templates/workspace/.ai/workflows/batch-task.md +356 -0
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PWN Notification Service
|
|
3
|
+
*
|
|
4
|
+
* Multi-channel notification system for task completion alerts.
|
|
5
|
+
* Supports: ntfy.sh, desktop notifications, and extensible channels.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { existsSync, readFileSync } from 'fs';
|
|
9
|
+
import { join } from 'path';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {Object} NotificationConfig
|
|
13
|
+
* @property {boolean} enabled - Global enable/disable
|
|
14
|
+
* @property {string} defaultChannel - Default channel to use
|
|
15
|
+
* @property {Object} channels - Channel-specific configurations
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {Object} NotificationPayload
|
|
20
|
+
* @property {string} title - Notification title
|
|
21
|
+
* @property {string} message - Notification body
|
|
22
|
+
* @property {string} [priority] - Priority level (low, default, high, urgent)
|
|
23
|
+
* @property {string[]} [tags] - Tags/emojis for the notification
|
|
24
|
+
* @property {string} [url] - Click action URL
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Default configuration
|
|
29
|
+
*/
|
|
30
|
+
const DEFAULT_CONFIG = {
|
|
31
|
+
enabled: true,
|
|
32
|
+
defaultChannel: 'desktop',
|
|
33
|
+
channels: {
|
|
34
|
+
ntfy: {
|
|
35
|
+
enabled: false,
|
|
36
|
+
server: 'https://ntfy.sh',
|
|
37
|
+
topic: '',
|
|
38
|
+
priority: 'default'
|
|
39
|
+
},
|
|
40
|
+
desktop: {
|
|
41
|
+
enabled: true
|
|
42
|
+
},
|
|
43
|
+
pushover: {
|
|
44
|
+
enabled: false,
|
|
45
|
+
userKey: '',
|
|
46
|
+
apiToken: ''
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Load notification configuration from workspace
|
|
53
|
+
* @param {string} cwd - Working directory
|
|
54
|
+
* @returns {NotificationConfig}
|
|
55
|
+
*/
|
|
56
|
+
export function loadConfig(cwd = process.cwd()) {
|
|
57
|
+
const configPath = join(cwd, '.ai', 'config', 'notifications.json');
|
|
58
|
+
|
|
59
|
+
if (!existsSync(configPath)) {
|
|
60
|
+
return DEFAULT_CONFIG;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
const content = readFileSync(configPath, 'utf8');
|
|
65
|
+
const userConfig = JSON.parse(content);
|
|
66
|
+
|
|
67
|
+
// Merge with defaults
|
|
68
|
+
return {
|
|
69
|
+
...DEFAULT_CONFIG,
|
|
70
|
+
...userConfig,
|
|
71
|
+
channels: {
|
|
72
|
+
...DEFAULT_CONFIG.channels,
|
|
73
|
+
...userConfig.channels
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
} catch {
|
|
77
|
+
return DEFAULT_CONFIG;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Send notification through configured channels
|
|
83
|
+
* @param {NotificationPayload} payload - Notification data
|
|
84
|
+
* @param {Object} options - Send options
|
|
85
|
+
* @param {string} [options.channel] - Specific channel to use
|
|
86
|
+
* @param {string} [options.cwd] - Working directory
|
|
87
|
+
* @returns {Promise<{success: boolean, channel: string, error?: string}>}
|
|
88
|
+
*/
|
|
89
|
+
export async function send(payload, options = {}) {
|
|
90
|
+
const { channel: specificChannel, cwd = process.cwd() } = options;
|
|
91
|
+
const config = loadConfig(cwd);
|
|
92
|
+
|
|
93
|
+
if (!config.enabled) {
|
|
94
|
+
return { success: false, channel: 'none', error: 'Notifications disabled' };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const channelName = specificChannel || config.defaultChannel;
|
|
98
|
+
const channelConfig = config.channels[channelName];
|
|
99
|
+
|
|
100
|
+
if (!channelConfig) {
|
|
101
|
+
return { success: false, channel: channelName, error: `Unknown channel: ${channelName}` };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (!channelConfig.enabled) {
|
|
105
|
+
return { success: false, channel: channelName, error: `Channel ${channelName} is disabled` };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
try {
|
|
109
|
+
switch (channelName) {
|
|
110
|
+
case 'ntfy':
|
|
111
|
+
return await sendNtfy(payload, channelConfig);
|
|
112
|
+
case 'desktop':
|
|
113
|
+
return await sendDesktop(payload, channelConfig);
|
|
114
|
+
case 'pushover':
|
|
115
|
+
return await sendPushover(payload, channelConfig);
|
|
116
|
+
default:
|
|
117
|
+
return { success: false, channel: channelName, error: `No handler for channel: ${channelName}` };
|
|
118
|
+
}
|
|
119
|
+
} catch (error) {
|
|
120
|
+
return { success: false, channel: channelName, error: error.message };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Send notification via ntfy.sh
|
|
126
|
+
* @param {NotificationPayload} payload
|
|
127
|
+
* @param {Object} config
|
|
128
|
+
*/
|
|
129
|
+
async function sendNtfy(payload, config) {
|
|
130
|
+
const { server = 'https://ntfy.sh', topic, priority = 'default' } = config;
|
|
131
|
+
|
|
132
|
+
if (!topic) {
|
|
133
|
+
return { success: false, channel: 'ntfy', error: 'ntfy topic not configured' };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const url = `${server}/${topic}`;
|
|
137
|
+
|
|
138
|
+
const headers = {
|
|
139
|
+
'Title': payload.title,
|
|
140
|
+
'Priority': payload.priority || priority,
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
if (payload.tags && payload.tags.length > 0) {
|
|
144
|
+
headers['Tags'] = payload.tags.join(',');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (payload.url) {
|
|
148
|
+
headers['Click'] = payload.url;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const response = await fetch(url, {
|
|
152
|
+
method: 'POST',
|
|
153
|
+
headers,
|
|
154
|
+
body: payload.message
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
if (!response.ok) {
|
|
158
|
+
return { success: false, channel: 'ntfy', error: `HTTP ${response.status}` };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return { success: true, channel: 'ntfy' };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Send desktop notification
|
|
166
|
+
* Uses native OS notifications via child process
|
|
167
|
+
* @param {NotificationPayload} payload
|
|
168
|
+
* @param {Object} config
|
|
169
|
+
*/
|
|
170
|
+
async function sendDesktop(payload, config) {
|
|
171
|
+
const { title, message } = payload;
|
|
172
|
+
|
|
173
|
+
// Use PowerShell on Windows for native toast notifications
|
|
174
|
+
if (process.platform === 'win32') {
|
|
175
|
+
const { exec } = await import('child_process');
|
|
176
|
+
const { promisify } = await import('util');
|
|
177
|
+
const execAsync = promisify(exec);
|
|
178
|
+
|
|
179
|
+
// Escape quotes in message
|
|
180
|
+
const escapedTitle = title.replace(/"/g, '`"');
|
|
181
|
+
const escapedMessage = message.replace(/"/g, '`"');
|
|
182
|
+
|
|
183
|
+
const script = `
|
|
184
|
+
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
|
|
185
|
+
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null
|
|
186
|
+
$template = @"
|
|
187
|
+
<toast>
|
|
188
|
+
<visual>
|
|
189
|
+
<binding template="ToastText02">
|
|
190
|
+
<text id="1">${escapedTitle}</text>
|
|
191
|
+
<text id="2">${escapedMessage}</text>
|
|
192
|
+
</binding>
|
|
193
|
+
</visual>
|
|
194
|
+
</toast>
|
|
195
|
+
"@
|
|
196
|
+
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
|
|
197
|
+
$xml.LoadXml($template)
|
|
198
|
+
$toast = [Windows.UI.Notifications.ToastNotification]::new($xml)
|
|
199
|
+
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("PWN").Show($toast)
|
|
200
|
+
`;
|
|
201
|
+
|
|
202
|
+
try {
|
|
203
|
+
await execAsync(`powershell -Command "${script.replace(/\n/g, ' ')}"`, {
|
|
204
|
+
windowsHide: true
|
|
205
|
+
});
|
|
206
|
+
return { success: true, channel: 'desktop' };
|
|
207
|
+
} catch (error) {
|
|
208
|
+
// Fallback to simple msg command
|
|
209
|
+
try {
|
|
210
|
+
await execAsync(`msg %username% "${escapedTitle}: ${escapedMessage}"`, {
|
|
211
|
+
windowsHide: true
|
|
212
|
+
});
|
|
213
|
+
return { success: true, channel: 'desktop' };
|
|
214
|
+
} catch {
|
|
215
|
+
return { success: false, channel: 'desktop', error: 'Desktop notifications not available' };
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// macOS
|
|
221
|
+
if (process.platform === 'darwin') {
|
|
222
|
+
const { exec } = await import('child_process');
|
|
223
|
+
const { promisify } = await import('util');
|
|
224
|
+
const execAsync = promisify(exec);
|
|
225
|
+
|
|
226
|
+
const escapedTitle = title.replace(/"/g, '\\"');
|
|
227
|
+
const escapedMessage = message.replace(/"/g, '\\"');
|
|
228
|
+
|
|
229
|
+
try {
|
|
230
|
+
await execAsync(`osascript -e 'display notification "${escapedMessage}" with title "${escapedTitle}"'`);
|
|
231
|
+
return { success: true, channel: 'desktop' };
|
|
232
|
+
} catch (error) {
|
|
233
|
+
return { success: false, channel: 'desktop', error: error.message };
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Linux (notify-send)
|
|
238
|
+
if (process.platform === 'linux') {
|
|
239
|
+
const { exec } = await import('child_process');
|
|
240
|
+
const { promisify } = await import('util');
|
|
241
|
+
const execAsync = promisify(exec);
|
|
242
|
+
|
|
243
|
+
try {
|
|
244
|
+
await execAsync(`notify-send "${title}" "${message}"`);
|
|
245
|
+
return { success: true, channel: 'desktop' };
|
|
246
|
+
} catch (error) {
|
|
247
|
+
return { success: false, channel: 'desktop', error: 'notify-send not available' };
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return { success: false, channel: 'desktop', error: `Unsupported platform: ${process.platform}` };
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Send notification via Pushover
|
|
256
|
+
* @param {NotificationPayload} payload
|
|
257
|
+
* @param {Object} config
|
|
258
|
+
*/
|
|
259
|
+
async function sendPushover(payload, config) {
|
|
260
|
+
const { userKey, apiToken } = config;
|
|
261
|
+
|
|
262
|
+
if (!userKey || !apiToken) {
|
|
263
|
+
return { success: false, channel: 'pushover', error: 'Pushover credentials not configured' };
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const priorityMap = {
|
|
267
|
+
'low': -1,
|
|
268
|
+
'default': 0,
|
|
269
|
+
'high': 1,
|
|
270
|
+
'urgent': 2
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
const body = new URLSearchParams({
|
|
274
|
+
token: apiToken,
|
|
275
|
+
user: userKey,
|
|
276
|
+
title: payload.title,
|
|
277
|
+
message: payload.message,
|
|
278
|
+
priority: priorityMap[payload.priority || 'default'] || 0
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
if (payload.url) {
|
|
282
|
+
body.append('url', payload.url);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const response = await fetch('https://api.pushover.net/1/messages.json', {
|
|
286
|
+
method: 'POST',
|
|
287
|
+
body
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
if (!response.ok) {
|
|
291
|
+
const data = await response.json().catch(() => ({}));
|
|
292
|
+
return { success: false, channel: 'pushover', error: data.errors?.join(', ') || `HTTP ${response.status}` };
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
return { success: true, channel: 'pushover' };
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Test notification configuration
|
|
300
|
+
* @param {string} channel - Channel to test
|
|
301
|
+
* @param {string} cwd - Working directory
|
|
302
|
+
* @returns {Promise<{success: boolean, channel: string, error?: string}>}
|
|
303
|
+
*/
|
|
304
|
+
export async function test(channel, cwd = process.cwd()) {
|
|
305
|
+
return send({
|
|
306
|
+
title: 'PWN Test Notification',
|
|
307
|
+
message: 'If you see this, notifications are working!',
|
|
308
|
+
tags: ['white_check_mark', 'robot']
|
|
309
|
+
}, { channel, cwd });
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Send task completion notification
|
|
314
|
+
* @param {string} taskId - Task identifier
|
|
315
|
+
* @param {string} taskName - Task description
|
|
316
|
+
* @param {Object} options - Additional options
|
|
317
|
+
*/
|
|
318
|
+
export async function notifyTaskComplete(taskId, taskName, options = {}) {
|
|
319
|
+
return send({
|
|
320
|
+
title: 'Task Completed',
|
|
321
|
+
message: `${taskId}: ${taskName}`,
|
|
322
|
+
tags: ['white_check_mark'],
|
|
323
|
+
priority: 'default',
|
|
324
|
+
...options
|
|
325
|
+
}, options);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Send error notification
|
|
330
|
+
* @param {string} title - Error title
|
|
331
|
+
* @param {string} message - Error details
|
|
332
|
+
* @param {Object} options - Additional options
|
|
333
|
+
*/
|
|
334
|
+
export async function notifyError(title, message, options = {}) {
|
|
335
|
+
return send({
|
|
336
|
+
title,
|
|
337
|
+
message,
|
|
338
|
+
tags: ['x', 'warning'],
|
|
339
|
+
priority: 'high',
|
|
340
|
+
...options
|
|
341
|
+
}, options);
|
|
342
|
+
}
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +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 ""
|
|
@@ -0,0 +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)
|