grok-cli-hurry-mode 1.0.4 → 1.0.5
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/dist/hooks/use-input-handler.js +588 -0
- package/dist/hooks/use-input-handler.js.map +1 -1
- package/dist/subagents/subagent-framework.d.ts +66 -0
- package/dist/subagents/subagent-framework.js +349 -0
- package/dist/subagents/subagent-framework.js.map +1 -0
- package/dist/tools/documentation/agent-system-generator.d.ts +30 -0
- package/dist/tools/documentation/agent-system-generator.js +816 -0
- package/dist/tools/documentation/agent-system-generator.js.map +1 -0
- package/dist/tools/documentation/api-docs-generator.d.ts +89 -0
- package/dist/tools/documentation/api-docs-generator.js +344 -0
- package/dist/tools/documentation/api-docs-generator.js.map +1 -0
- package/dist/tools/documentation/auto-update-system.d.ts +47 -0
- package/dist/tools/documentation/auto-update-system.js +278 -0
- package/dist/tools/documentation/auto-update-system.js.map +1 -0
- package/dist/tools/documentation/changelog-generator.d.ts +39 -0
- package/dist/tools/documentation/changelog-generator.js +255 -0
- package/dist/tools/documentation/changelog-generator.js.map +1 -0
- package/dist/tools/documentation/claude-md-parser.d.ts +25 -0
- package/dist/tools/documentation/claude-md-parser.js +108 -0
- package/dist/tools/documentation/claude-md-parser.js.map +1 -0
- package/dist/tools/documentation/comments-generator.d.ts +55 -0
- package/dist/tools/documentation/comments-generator.js +238 -0
- package/dist/tools/documentation/comments-generator.js.map +1 -0
- package/dist/tools/documentation/docs-menu.d.ts +9 -0
- package/dist/tools/documentation/docs-menu.js +57 -0
- package/dist/tools/documentation/docs-menu.js.map +1 -0
- package/dist/tools/documentation/readme-generator.d.ts +31 -0
- package/dist/tools/documentation/readme-generator.js +244 -0
- package/dist/tools/documentation/readme-generator.js.map +1 -0
- package/dist/tools/documentation/self-healing-system.d.ts +66 -0
- package/dist/tools/documentation/self-healing-system.js +444 -0
- package/dist/tools/documentation/self-healing-system.js.map +1 -0
- package/dist/tools/documentation/smart-prd-assistant.d.ts +45 -0
- package/dist/tools/documentation/smart-prd-assistant.js +325 -0
- package/dist/tools/documentation/smart-prd-assistant.js.map +1 -0
- package/dist/tools/documentation/update-agent-docs.d.ts +37 -0
- package/dist/tools/documentation/update-agent-docs.js +275 -0
- package/dist/tools/documentation/update-agent-docs.js.map +1 -0
- package/dist/tools/intelligence/ast-parser.js +22 -4
- package/dist/tools/intelligence/ast-parser.js.map +1 -1
- package/dist/ui/app.d.ts +2 -1
- package/dist/ui/app.js +27 -6
- package/dist/ui/app.js.map +1 -1
- package/dist/ui/components/api-key-input.d.ts +2 -1
- package/dist/ui/components/api-key-input.js +18 -3
- package/dist/ui/components/api-key-input.js.map +1 -1
- package/dist/ui/components/chat-history.d.ts +2 -1
- package/dist/ui/components/chat-history.js +35 -13
- package/dist/ui/components/chat-history.js.map +1 -1
- package/dist/ui/components/chat-input.d.ts +2 -1
- package/dist/ui/components/chat-input.js +36 -15
- package/dist/ui/components/chat-input.js.map +1 -1
- package/dist/ui/components/chat-interface.d.ts +2 -1
- package/dist/ui/components/chat-interface.js +39 -5
- package/dist/ui/components/chat-interface.js.map +1 -1
- package/dist/ui/components/command-suggestions.d.ts +2 -1
- package/dist/ui/components/command-suggestions.js +8 -3
- package/dist/ui/components/command-suggestions.js.map +1 -1
- package/dist/ui/components/confirmation-dialog.d.ts +2 -1
- package/dist/ui/components/confirmation-dialog.js +39 -4
- package/dist/ui/components/confirmation-dialog.js.map +1 -1
- package/dist/ui/components/diff-renderer.js +66 -57
- package/dist/ui/components/diff-renderer.js.map +1 -1
- package/dist/ui/components/loading-spinner.d.ts +2 -1
- package/dist/ui/components/loading-spinner.js +13 -3
- package/dist/ui/components/loading-spinner.js.map +1 -1
- package/dist/ui/components/mcp-status.d.ts +2 -1
- package/dist/ui/components/mcp-status.js +6 -3
- package/dist/ui/components/mcp-status.js.map +1 -1
- package/dist/ui/components/model-selection.d.ts +2 -1
- package/dist/ui/components/model-selection.js +11 -2
- package/dist/ui/components/model-selection.js.map +1 -1
- package/dist/ui/shared/max-sized-box.js +2 -2
- package/dist/ui/shared/max-sized-box.js.map +1 -1
- package/dist/ui/utils/code-colorizer.js +2 -2
- package/dist/ui/utils/code-colorizer.js.map +1 -1
- package/dist/ui/utils/markdown-renderer.d.ts +2 -1
- package/dist/ui/utils/markdown-renderer.js +3 -3
- package/dist/ui/utils/markdown-renderer.js.map +1 -1
- package/package.json +21 -12
@@ -0,0 +1,444 @@
|
|
1
|
+
import path from 'path';
|
2
|
+
import fs from 'fs/promises';
|
3
|
+
import { existsSync } from 'fs';
|
4
|
+
export class SelfHealingSystem {
|
5
|
+
constructor(rootPath, config) {
|
6
|
+
this.rootPath = rootPath;
|
7
|
+
this.agentPath = path.join(rootPath, '.agent');
|
8
|
+
this.config = {
|
9
|
+
enabled: true,
|
10
|
+
onErrorPrompt: 'gentle',
|
11
|
+
enforceGuardrails: true,
|
12
|
+
simulateOnPlan: 'smart',
|
13
|
+
...config
|
14
|
+
};
|
15
|
+
}
|
16
|
+
async captureIncident(error, context) {
|
17
|
+
try {
|
18
|
+
const incident = await this.analyzeAndCreateIncident(error, context);
|
19
|
+
const incidentPath = path.join(this.agentPath, 'incidents', `${incident.id}.md`);
|
20
|
+
// Ensure incidents directory exists
|
21
|
+
await fs.mkdir(path.dirname(incidentPath), { recursive: true });
|
22
|
+
// Write incident documentation
|
23
|
+
const incidentContent = this.generateIncidentContent(incident);
|
24
|
+
await fs.writeFile(incidentPath, incidentContent);
|
25
|
+
// Try to create a guardrail
|
26
|
+
const guardrail = await this.generateGuardrailFromIncident(incident);
|
27
|
+
if (guardrail) {
|
28
|
+
await this.saveGuardrail(guardrail);
|
29
|
+
incident.guardrailCreated = guardrail.id;
|
30
|
+
}
|
31
|
+
return {
|
32
|
+
success: true,
|
33
|
+
incidentId: incident.id,
|
34
|
+
message: `✅ Incident documented: ${incident.title}\n${guardrail ? `🛡️ Guardrail created: ${guardrail.name}` : ''}\n📁 Saved to: .agent/incidents/${incident.id}.md`
|
35
|
+
};
|
36
|
+
}
|
37
|
+
catch (error) {
|
38
|
+
return {
|
39
|
+
success: false,
|
40
|
+
message: `Failed to capture incident: ${error.message}`
|
41
|
+
};
|
42
|
+
}
|
43
|
+
}
|
44
|
+
async analyzeAndCreateIncident(error, context) {
|
45
|
+
const id = this.generateIncidentId();
|
46
|
+
const now = new Date();
|
47
|
+
// Extract information from error
|
48
|
+
const errorMessage = error?.message || error?.toString() || 'Unknown error';
|
49
|
+
const title = this.extractErrorTitle(errorMessage);
|
50
|
+
const trigger = this.extractTrigger(error, context);
|
51
|
+
const rootCause = this.analyzeRootCause(error, context);
|
52
|
+
const fix = this.suggestFix(error, context);
|
53
|
+
const impact = this.assessImpact(error, context);
|
54
|
+
const relatedFiles = this.extractRelatedFiles(error, context);
|
55
|
+
// Check for previous occurrences
|
56
|
+
const recurrenceCount = await this.countPreviousOccurrences(title);
|
57
|
+
return {
|
58
|
+
id,
|
59
|
+
title,
|
60
|
+
date: now.toISOString(),
|
61
|
+
trigger,
|
62
|
+
rootCause,
|
63
|
+
fix,
|
64
|
+
impact,
|
65
|
+
recurrenceCount,
|
66
|
+
relatedFiles
|
67
|
+
};
|
68
|
+
}
|
69
|
+
extractErrorTitle(errorMessage) {
|
70
|
+
// Extract a clean title from error message
|
71
|
+
const cleaned = errorMessage
|
72
|
+
.replace(/^Error:\s*/i, '')
|
73
|
+
.replace(/\s+at\s+.*$/, '')
|
74
|
+
.replace(/\s+\(.*\)$/, '')
|
75
|
+
.substring(0, 100);
|
76
|
+
return cleaned || 'Unknown Error';
|
77
|
+
}
|
78
|
+
extractTrigger(error, context) {
|
79
|
+
if (context?.command) {
|
80
|
+
return `Command: ${context.command}`;
|
81
|
+
}
|
82
|
+
if (context?.operation) {
|
83
|
+
return `Operation: ${context.operation}`;
|
84
|
+
}
|
85
|
+
if (error?.stack) {
|
86
|
+
const stackLine = error.stack.split('\n')[1];
|
87
|
+
return stackLine ? `Code: ${stackLine.trim()}` : 'Unknown trigger';
|
88
|
+
}
|
89
|
+
return 'Unknown trigger';
|
90
|
+
}
|
91
|
+
analyzeRootCause(error, context) {
|
92
|
+
const errorMessage = error?.message || '';
|
93
|
+
// Common patterns
|
94
|
+
if (errorMessage.includes('ENOENT') || errorMessage.includes('not found')) {
|
95
|
+
return 'File or resource not found';
|
96
|
+
}
|
97
|
+
if (errorMessage.includes('permission denied') || errorMessage.includes('EACCES')) {
|
98
|
+
return 'Permission denied - insufficient access rights';
|
99
|
+
}
|
100
|
+
if (errorMessage.includes('timeout')) {
|
101
|
+
return 'Operation timed out - possible network or performance issue';
|
102
|
+
}
|
103
|
+
if (errorMessage.includes('Cannot find module')) {
|
104
|
+
return 'Missing dependency or incorrect import path';
|
105
|
+
}
|
106
|
+
if (errorMessage.includes('syntax error') || errorMessage.includes('unexpected token')) {
|
107
|
+
return 'Code syntax error';
|
108
|
+
}
|
109
|
+
return 'Root cause requires investigation';
|
110
|
+
}
|
111
|
+
suggestFix(error, context) {
|
112
|
+
const errorMessage = error?.message || '';
|
113
|
+
if (errorMessage.includes('ENOENT')) {
|
114
|
+
return 'Ensure the required file or directory exists before accessing it';
|
115
|
+
}
|
116
|
+
if (errorMessage.includes('permission denied')) {
|
117
|
+
return 'Check file permissions or run with appropriate privileges';
|
118
|
+
}
|
119
|
+
if (errorMessage.includes('Cannot find module')) {
|
120
|
+
return 'Install missing dependency or correct the import path';
|
121
|
+
}
|
122
|
+
if (errorMessage.includes('timeout')) {
|
123
|
+
return 'Increase timeout value or optimize the operation';
|
124
|
+
}
|
125
|
+
return 'Investigate error details and apply appropriate fix';
|
126
|
+
}
|
127
|
+
assessImpact(error, context) {
|
128
|
+
const errorMessage = error?.message || '';
|
129
|
+
if (errorMessage.includes('fatal') || errorMessage.includes('critical')) {
|
130
|
+
return 'high';
|
131
|
+
}
|
132
|
+
if (context?.operation && ['build', 'deploy', 'init'].includes(context.operation)) {
|
133
|
+
return 'high';
|
134
|
+
}
|
135
|
+
if (errorMessage.includes('warning')) {
|
136
|
+
return 'low';
|
137
|
+
}
|
138
|
+
return 'medium';
|
139
|
+
}
|
140
|
+
extractRelatedFiles(error, context) {
|
141
|
+
const files = [];
|
142
|
+
if (context?.files) {
|
143
|
+
files.push(...context.files);
|
144
|
+
}
|
145
|
+
if (error?.stack) {
|
146
|
+
const stackLines = error.stack.split('\n');
|
147
|
+
for (const line of stackLines) {
|
148
|
+
const fileMatch = line.match(/\((.*?):\d+:\d+\)/);
|
149
|
+
if (fileMatch && fileMatch[1]) {
|
150
|
+
files.push(fileMatch[1]);
|
151
|
+
}
|
152
|
+
}
|
153
|
+
}
|
154
|
+
return [...new Set(files)]; // Remove duplicates
|
155
|
+
}
|
156
|
+
async countPreviousOccurrences(title) {
|
157
|
+
try {
|
158
|
+
const incidentsPath = path.join(this.agentPath, 'incidents');
|
159
|
+
if (!existsSync(incidentsPath)) {
|
160
|
+
return 0;
|
161
|
+
}
|
162
|
+
const files = await fs.readdir(incidentsPath);
|
163
|
+
let count = 0;
|
164
|
+
for (const file of files) {
|
165
|
+
if (file.endsWith('.md')) {
|
166
|
+
const filePath = path.join(incidentsPath, file);
|
167
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
168
|
+
if (content.includes(title)) {
|
169
|
+
count++;
|
170
|
+
}
|
171
|
+
}
|
172
|
+
}
|
173
|
+
return Math.max(0, count - 1); // Subtract 1 for current incident
|
174
|
+
}
|
175
|
+
catch (error) {
|
176
|
+
return 0;
|
177
|
+
}
|
178
|
+
}
|
179
|
+
generateIncidentContent(incident) {
|
180
|
+
return `# ${incident.title} - ${incident.date.split('T')[0]}
|
181
|
+
|
182
|
+
## 📊 Incident Summary
|
183
|
+
- **ID**: ${incident.id}
|
184
|
+
- **Date**: ${incident.date}
|
185
|
+
- **Impact**: ${incident.impact.toUpperCase()}
|
186
|
+
- **Recurrence**: ${incident.recurrenceCount > 0 ? `${incident.recurrenceCount} previous occurrences` : 'First occurrence'}
|
187
|
+
|
188
|
+
## 🔥 Trigger
|
189
|
+
${incident.trigger}
|
190
|
+
|
191
|
+
## 🔍 Root Cause
|
192
|
+
${incident.rootCause}
|
193
|
+
|
194
|
+
## ✅ Fix Applied
|
195
|
+
${incident.fix}
|
196
|
+
|
197
|
+
## 📁 Related Files
|
198
|
+
${incident.relatedFiles.length > 0 ? incident.relatedFiles.map(f => `- ${f}`).join('\n') : 'None identified'}
|
199
|
+
|
200
|
+
## 🛡️ Prevention
|
201
|
+
${incident.guardrailCreated ? `Guardrail created: ${incident.guardrailCreated}` : 'Manual prevention required'}
|
202
|
+
|
203
|
+
## 📚 Related Documentation
|
204
|
+
- [Self-Healing SOP](../sop/self-healing-workflow.md)
|
205
|
+
- [Guardrails](../guardrails/)
|
206
|
+
- [System Critical State](../system/critical-state.md)
|
207
|
+
|
208
|
+
---
|
209
|
+
*Generated by Grok CLI Self-Healing System*
|
210
|
+
*Incident ID: ${incident.id}*
|
211
|
+
`;
|
212
|
+
}
|
213
|
+
async generateGuardrailFromIncident(incident) {
|
214
|
+
// Only create guardrails for recurring issues or high-impact incidents
|
215
|
+
if (incident.recurrenceCount === 0 && incident.impact !== 'high') {
|
216
|
+
return null;
|
217
|
+
}
|
218
|
+
const id = `guard_${incident.id}`;
|
219
|
+
const category = this.determineGuardrailCategory(incident);
|
220
|
+
const pattern = this.createGuardrailPattern(incident);
|
221
|
+
if (!pattern) {
|
222
|
+
return null;
|
223
|
+
}
|
224
|
+
return {
|
225
|
+
id,
|
226
|
+
name: `Prevent: ${incident.title}`,
|
227
|
+
description: `Automatically generated from incident ${incident.id}. ${incident.rootCause}`,
|
228
|
+
category,
|
229
|
+
severity: incident.impact === 'high' ? 'error' : 'warning',
|
230
|
+
pattern,
|
231
|
+
enabled: true,
|
232
|
+
createdFrom: incident.id
|
233
|
+
};
|
234
|
+
}
|
235
|
+
determineGuardrailCategory(incident) {
|
236
|
+
if (incident.trigger.includes('file') || incident.trigger.includes('path')) {
|
237
|
+
return 'configuration';
|
238
|
+
}
|
239
|
+
if (incident.trigger.includes('command') || incident.trigger.includes('operation')) {
|
240
|
+
return 'process';
|
241
|
+
}
|
242
|
+
if (incident.relatedFiles.some(f => f.includes('src/') || f.includes('lib/'))) {
|
243
|
+
return 'architecture';
|
244
|
+
}
|
245
|
+
return 'process';
|
246
|
+
}
|
247
|
+
createGuardrailPattern(incident) {
|
248
|
+
// Create simple patterns based on common error types
|
249
|
+
const errorMessage = incident.trigger.toLowerCase();
|
250
|
+
if (errorMessage.includes('enoent') || errorMessage.includes('not found')) {
|
251
|
+
return 'check_file_exists';
|
252
|
+
}
|
253
|
+
if (errorMessage.includes('permission')) {
|
254
|
+
return 'check_permissions';
|
255
|
+
}
|
256
|
+
if (errorMessage.includes('module')) {
|
257
|
+
return 'check_dependencies';
|
258
|
+
}
|
259
|
+
return null;
|
260
|
+
}
|
261
|
+
async saveGuardrail(guardrail) {
|
262
|
+
const guardrailsPath = path.join(this.agentPath, 'guardrails');
|
263
|
+
await fs.mkdir(guardrailsPath, { recursive: true });
|
264
|
+
const filePath = path.join(guardrailsPath, `${guardrail.id}.md`);
|
265
|
+
const content = this.generateGuardrailContent(guardrail);
|
266
|
+
await fs.writeFile(filePath, content);
|
267
|
+
}
|
268
|
+
generateGuardrailContent(guardrail) {
|
269
|
+
return `# ${guardrail.name}
|
270
|
+
|
271
|
+
## 📋 Rule Details
|
272
|
+
- **ID**: ${guardrail.id}
|
273
|
+
- **Category**: ${guardrail.category}
|
274
|
+
- **Severity**: ${guardrail.severity}
|
275
|
+
- **Status**: ${guardrail.enabled ? 'Enabled' : 'Disabled'}
|
276
|
+
|
277
|
+
## 📝 Description
|
278
|
+
${guardrail.description}
|
279
|
+
|
280
|
+
## 🔍 Pattern
|
281
|
+
\`${guardrail.pattern}\`
|
282
|
+
|
283
|
+
## 🛠️ Implementation
|
284
|
+
This guardrail checks for the following conditions:
|
285
|
+
- Pattern: ${guardrail.pattern}
|
286
|
+
- Action: ${guardrail.severity === 'error' ? 'Block operation' : 'Show warning'}
|
287
|
+
|
288
|
+
## 📚 Related
|
289
|
+
${guardrail.createdFrom ? `- Created from incident: ${guardrail.createdFrom}` : ''}
|
290
|
+
- Category: ${guardrail.category}
|
291
|
+
|
292
|
+
---
|
293
|
+
*Generated by Grok CLI Self-Healing System*
|
294
|
+
`;
|
295
|
+
}
|
296
|
+
async checkGuardrails(operation, context) {
|
297
|
+
const violations = [];
|
298
|
+
const warnings = [];
|
299
|
+
try {
|
300
|
+
const guardrails = await this.loadAllGuardrails();
|
301
|
+
for (const guardrail of guardrails) {
|
302
|
+
if (!guardrail.enabled)
|
303
|
+
continue;
|
304
|
+
const violated = this.checkGuardrailPattern(guardrail.pattern, operation, context);
|
305
|
+
if (violated) {
|
306
|
+
if (guardrail.severity === 'error') {
|
307
|
+
violations.push(guardrail);
|
308
|
+
}
|
309
|
+
else {
|
310
|
+
warnings.push(guardrail);
|
311
|
+
}
|
312
|
+
}
|
313
|
+
}
|
314
|
+
}
|
315
|
+
catch (error) {
|
316
|
+
// If we can't load guardrails, allow operation to proceed
|
317
|
+
}
|
318
|
+
return {
|
319
|
+
violations,
|
320
|
+
warnings,
|
321
|
+
passed: violations.length === 0
|
322
|
+
};
|
323
|
+
}
|
324
|
+
async loadAllGuardrails() {
|
325
|
+
const guardrailsPath = path.join(this.agentPath, 'guardrails');
|
326
|
+
if (!existsSync(guardrailsPath)) {
|
327
|
+
return [];
|
328
|
+
}
|
329
|
+
const files = await fs.readdir(guardrailsPath);
|
330
|
+
const guardrails = [];
|
331
|
+
for (const file of files) {
|
332
|
+
if (file.endsWith('.md')) {
|
333
|
+
try {
|
334
|
+
const content = await fs.readFile(path.join(guardrailsPath, file), 'utf-8');
|
335
|
+
const guardrail = this.parseGuardrailFromContent(content);
|
336
|
+
if (guardrail) {
|
337
|
+
guardrails.push(guardrail);
|
338
|
+
}
|
339
|
+
}
|
340
|
+
catch (error) {
|
341
|
+
// Skip files we can't parse
|
342
|
+
}
|
343
|
+
}
|
344
|
+
}
|
345
|
+
return guardrails;
|
346
|
+
}
|
347
|
+
parseGuardrailFromContent(content) {
|
348
|
+
try {
|
349
|
+
const idMatch = content.match(/\*\*ID\*\*:\s*(.+)/);
|
350
|
+
const nameMatch = content.match(/^#\s*(.+)/m);
|
351
|
+
const categoryMatch = content.match(/\*\*Category\*\*:\s*(.+)/);
|
352
|
+
const severityMatch = content.match(/\*\*Severity\*\*:\s*(.+)/);
|
353
|
+
const statusMatch = content.match(/\*\*Status\*\*:\s*(.+)/);
|
354
|
+
const patternMatch = content.match(/`([^`]+)`/);
|
355
|
+
const descMatch = content.match(/## 📝 Description\n(.+)/);
|
356
|
+
if (!idMatch || !nameMatch || !patternMatch) {
|
357
|
+
return null;
|
358
|
+
}
|
359
|
+
return {
|
360
|
+
id: idMatch[1].trim(),
|
361
|
+
name: nameMatch[1].trim(),
|
362
|
+
description: descMatch ? descMatch[1].trim() : '',
|
363
|
+
category: (categoryMatch ? categoryMatch[1].trim() : 'process'),
|
364
|
+
severity: (severityMatch ? severityMatch[1].trim() : 'warning'),
|
365
|
+
pattern: patternMatch[1],
|
366
|
+
enabled: statusMatch ? statusMatch[1].includes('Enabled') : true
|
367
|
+
};
|
368
|
+
}
|
369
|
+
catch (error) {
|
370
|
+
return null;
|
371
|
+
}
|
372
|
+
}
|
373
|
+
checkGuardrailPattern(pattern, operation, context) {
|
374
|
+
// Simple pattern matching - could be enhanced
|
375
|
+
switch (pattern) {
|
376
|
+
case 'check_file_exists':
|
377
|
+
return context?.files && context.files.some((f) => !existsSync(f));
|
378
|
+
case 'check_permissions':
|
379
|
+
return false; // Would need actual permission check
|
380
|
+
case 'check_dependencies':
|
381
|
+
return false; // Would need dependency analysis
|
382
|
+
default:
|
383
|
+
return operation.toLowerCase().includes(pattern.toLowerCase());
|
384
|
+
}
|
385
|
+
}
|
386
|
+
generateIncidentId() {
|
387
|
+
const timestamp = Date.now().toString(36);
|
388
|
+
const random = Math.random().toString(36).substr(2, 5);
|
389
|
+
return `incident_${timestamp}_${random}`;
|
390
|
+
}
|
391
|
+
async listIncidents() {
|
392
|
+
const incidentsPath = path.join(this.agentPath, 'incidents');
|
393
|
+
if (!existsSync(incidentsPath)) {
|
394
|
+
return [];
|
395
|
+
}
|
396
|
+
const files = await fs.readdir(incidentsPath);
|
397
|
+
const incidents = [];
|
398
|
+
for (const file of files) {
|
399
|
+
if (file.endsWith('.md')) {
|
400
|
+
try {
|
401
|
+
const content = await fs.readFile(path.join(incidentsPath, file), 'utf-8');
|
402
|
+
const incident = this.parseIncidentFromContent(content);
|
403
|
+
if (incident) {
|
404
|
+
incidents.push(incident);
|
405
|
+
}
|
406
|
+
}
|
407
|
+
catch (error) {
|
408
|
+
// Skip files we can't parse
|
409
|
+
}
|
410
|
+
}
|
411
|
+
}
|
412
|
+
return incidents.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
|
413
|
+
}
|
414
|
+
parseIncidentFromContent(content) {
|
415
|
+
// Basic parsing - could be enhanced
|
416
|
+
try {
|
417
|
+
const idMatch = content.match(/\*\*ID\*\*:\s*(.+)/);
|
418
|
+
const titleMatch = content.match(/^#\s*(.+)/m);
|
419
|
+
const dateMatch = content.match(/\*\*Date\*\*:\s*(.+)/);
|
420
|
+
const impactMatch = content.match(/\*\*Impact\*\*:\s*(.+)/);
|
421
|
+
if (!idMatch || !titleMatch) {
|
422
|
+
return null;
|
423
|
+
}
|
424
|
+
return {
|
425
|
+
id: idMatch[1].trim(),
|
426
|
+
title: titleMatch[1].split(' - ')[0].trim(),
|
427
|
+
date: dateMatch ? dateMatch[1].trim() : '',
|
428
|
+
trigger: 'Unknown',
|
429
|
+
rootCause: 'Unknown',
|
430
|
+
fix: 'Unknown',
|
431
|
+
impact: (impactMatch ? impactMatch[1].toLowerCase().trim() : 'medium'),
|
432
|
+
recurrenceCount: 0,
|
433
|
+
relatedFiles: []
|
434
|
+
};
|
435
|
+
}
|
436
|
+
catch (error) {
|
437
|
+
return null;
|
438
|
+
}
|
439
|
+
}
|
440
|
+
getConfig() {
|
441
|
+
return { ...this.config };
|
442
|
+
}
|
443
|
+
}
|
444
|
+
//# sourceMappingURL=self-healing-system.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"self-healing-system.js","sourceRoot":"","sources":["../../../src/tools/documentation/self-healing-system.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAkChC,MAAM,OAAO,iBAAiB;IAK5B,YAAY,QAAgB,EAAE,MAAmC;QAC/D,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,GAAG;YACZ,OAAO,EAAE,IAAI;YACb,aAAa,EAAE,QAAQ;YACvB,iBAAiB,EAAE,IAAI;YACvB,cAAc,EAAE,OAAO;YACvB,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,KAAU,EAAE,OAAa;QAC7C,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,wBAAwB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YACrE,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC;YAEjF,oCAAoC;YACpC,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAEhE,+BAA+B;YAC/B,MAAM,eAAe,GAAG,IAAI,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC;YAC/D,MAAM,EAAE,CAAC,SAAS,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;YAElD,4BAA4B;YAC5B,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;YACpD,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;YAC/C,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;YACxD,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;YAE5D,IAAI,CAAC,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;gBAC5B,OAAO,IAAI,CAAC;YACd,CAAC;YAED,OAAO;gBACL,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;gBACrB,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;gBAC3C,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE;gBAC1C,OAAO,EAAE,SAAS;gBAClB,SAAS,EAAE,SAAS;gBACpB,GAAG,EAAE,SAAS;gBACd,MAAM,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAQ;gBAC7E,eAAe,EAAE,CAAC;gBAClB,YAAY,EAAE,EAAE;aACjB,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,SAAS;QACP,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC5B,CAAC;CACF"}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
export interface PRDAnalysis {
|
2
|
+
fileName: string;
|
3
|
+
title: string;
|
4
|
+
content: string;
|
5
|
+
suggestions: PRDSuggestion[];
|
6
|
+
conflicts: string[];
|
7
|
+
similarTasks: string[];
|
8
|
+
missingContext: string[];
|
9
|
+
architectureImpact: string[];
|
10
|
+
}
|
11
|
+
export interface PRDSuggestion {
|
12
|
+
type: 'context' | 'pattern' | 'dependency' | 'conflict' | 'architecture';
|
13
|
+
priority: 'low' | 'medium' | 'high';
|
14
|
+
message: string;
|
15
|
+
reference?: string;
|
16
|
+
}
|
17
|
+
export interface ProjectContext {
|
18
|
+
architecture: string[];
|
19
|
+
patterns: string[];
|
20
|
+
dependencies: string[];
|
21
|
+
existingTasks: string[];
|
22
|
+
systemConstraints: string[];
|
23
|
+
}
|
24
|
+
export declare class SmartPRDAssistant {
|
25
|
+
private rootPath;
|
26
|
+
private agentPath;
|
27
|
+
constructor(rootPath: string);
|
28
|
+
analyzePRD(prdPath: string): Promise<PRDAnalysis>;
|
29
|
+
monitorTasksFolder(): Promise<{
|
30
|
+
newPRDs: string[];
|
31
|
+
analysisResults: PRDAnalysis[];
|
32
|
+
}>;
|
33
|
+
private loadProjectContext;
|
34
|
+
private extractTitle;
|
35
|
+
private extractKeyPoints;
|
36
|
+
private generateSuggestions;
|
37
|
+
private detectConflicts;
|
38
|
+
private findSimilarTasks;
|
39
|
+
private detectMissingContext;
|
40
|
+
private analyzeArchitectureImpact;
|
41
|
+
private hasConflict;
|
42
|
+
private extractKeywords;
|
43
|
+
private calculateSimilarity;
|
44
|
+
generateAnalysisReport(analysis: PRDAnalysis): string;
|
45
|
+
}
|