grok-cli-hurry-mode 1.0.3 → 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/agent/grok-agent.js.map +1 -1
- package/dist/hooks/use-input-handler.js +590 -2
- package/dist/hooks/use-input-handler.js.map +1 -1
- package/dist/mcp/client.js +6 -1
- package/dist/mcp/client.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 +37 -16
- 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 +42 -8
- 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,325 @@
|
|
1
|
+
import path from 'path';
|
2
|
+
import fs from 'fs/promises';
|
3
|
+
import { existsSync } from 'fs';
|
4
|
+
export class SmartPRDAssistant {
|
5
|
+
constructor(rootPath) {
|
6
|
+
this.rootPath = rootPath;
|
7
|
+
this.agentPath = path.join(rootPath, '.agent');
|
8
|
+
}
|
9
|
+
async analyzePRD(prdPath) {
|
10
|
+
const fileName = path.basename(prdPath);
|
11
|
+
const content = await fs.readFile(prdPath, 'utf-8');
|
12
|
+
const title = this.extractTitle(content);
|
13
|
+
// Load project context
|
14
|
+
const context = await this.loadProjectContext();
|
15
|
+
// Analyze the PRD
|
16
|
+
const analysis = {
|
17
|
+
fileName,
|
18
|
+
title,
|
19
|
+
content,
|
20
|
+
suggestions: [],
|
21
|
+
conflicts: [],
|
22
|
+
similarTasks: [],
|
23
|
+
missingContext: [],
|
24
|
+
architectureImpact: []
|
25
|
+
};
|
26
|
+
// Generate suggestions
|
27
|
+
analysis.suggestions = await this.generateSuggestions(content, context);
|
28
|
+
analysis.conflicts = await this.detectConflicts(content, context);
|
29
|
+
analysis.similarTasks = await this.findSimilarTasks(content, context);
|
30
|
+
analysis.missingContext = this.detectMissingContext(content, context);
|
31
|
+
analysis.architectureImpact = this.analyzeArchitectureImpact(content, context);
|
32
|
+
return analysis;
|
33
|
+
}
|
34
|
+
async monitorTasksFolder() {
|
35
|
+
const tasksPath = path.join(this.agentPath, 'tasks');
|
36
|
+
if (!existsSync(tasksPath)) {
|
37
|
+
return { newPRDs: [], analysisResults: [] };
|
38
|
+
}
|
39
|
+
try {
|
40
|
+
const files = await fs.readdir(tasksPath);
|
41
|
+
const prdFiles = files.filter(file => file.endsWith('.md') && !file.startsWith('example-'));
|
42
|
+
const newPRDs = [];
|
43
|
+
const analysisResults = [];
|
44
|
+
for (const file of prdFiles) {
|
45
|
+
const filePath = path.join(tasksPath, file);
|
46
|
+
const stats = await fs.stat(filePath);
|
47
|
+
// Check if file was created/modified in the last 10 minutes
|
48
|
+
const tenMinutesAgo = Date.now() - (10 * 60 * 1000);
|
49
|
+
if (stats.mtime.getTime() > tenMinutesAgo) {
|
50
|
+
newPRDs.push(file);
|
51
|
+
const analysis = await this.analyzePRD(filePath);
|
52
|
+
analysisResults.push(analysis);
|
53
|
+
}
|
54
|
+
}
|
55
|
+
return { newPRDs, analysisResults };
|
56
|
+
}
|
57
|
+
catch (error) {
|
58
|
+
return { newPRDs: [], analysisResults: [] };
|
59
|
+
}
|
60
|
+
}
|
61
|
+
async loadProjectContext() {
|
62
|
+
const context = {
|
63
|
+
architecture: [],
|
64
|
+
patterns: [],
|
65
|
+
dependencies: [],
|
66
|
+
existingTasks: [],
|
67
|
+
systemConstraints: []
|
68
|
+
};
|
69
|
+
try {
|
70
|
+
// Load architecture info
|
71
|
+
const archPath = path.join(this.agentPath, 'system', 'architecture.md');
|
72
|
+
if (existsSync(archPath)) {
|
73
|
+
const archContent = await fs.readFile(archPath, 'utf-8');
|
74
|
+
context.architecture = this.extractKeyPoints(archContent);
|
75
|
+
}
|
76
|
+
// Load critical state
|
77
|
+
const statePath = path.join(this.agentPath, 'system', 'critical-state.md');
|
78
|
+
if (existsSync(statePath)) {
|
79
|
+
const stateContent = await fs.readFile(statePath, 'utf-8');
|
80
|
+
context.systemConstraints = this.extractKeyPoints(stateContent);
|
81
|
+
}
|
82
|
+
// Load existing SOPs for patterns
|
83
|
+
const sopPath = path.join(this.agentPath, 'sop');
|
84
|
+
if (existsSync(sopPath)) {
|
85
|
+
const sopFiles = await fs.readdir(sopPath);
|
86
|
+
for (const file of sopFiles) {
|
87
|
+
if (file.endsWith('.md')) {
|
88
|
+
const sopContent = await fs.readFile(path.join(sopPath, file), 'utf-8');
|
89
|
+
context.patterns.push(...this.extractKeyPoints(sopContent));
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
// Load existing tasks
|
94
|
+
const tasksPath = path.join(this.agentPath, 'tasks');
|
95
|
+
if (existsSync(tasksPath)) {
|
96
|
+
const taskFiles = await fs.readdir(tasksPath);
|
97
|
+
for (const file of taskFiles) {
|
98
|
+
if (file.endsWith('.md') && !file.startsWith('example-')) {
|
99
|
+
context.existingTasks.push(file);
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
// Load dependencies from package.json
|
104
|
+
const packagePath = path.join(this.rootPath, 'package.json');
|
105
|
+
if (existsSync(packagePath)) {
|
106
|
+
const packageContent = await fs.readFile(packagePath, 'utf-8');
|
107
|
+
const packageData = JSON.parse(packageContent);
|
108
|
+
context.dependencies = [
|
109
|
+
...Object.keys(packageData.dependencies || {}),
|
110
|
+
...Object.keys(packageData.devDependencies || {})
|
111
|
+
];
|
112
|
+
}
|
113
|
+
}
|
114
|
+
catch (error) {
|
115
|
+
// Continue with empty context if loading fails
|
116
|
+
}
|
117
|
+
return context;
|
118
|
+
}
|
119
|
+
extractTitle(content) {
|
120
|
+
const titleMatch = content.match(/^#\s*(.+)$/m);
|
121
|
+
return titleMatch ? titleMatch[1].trim() : 'Untitled PRD';
|
122
|
+
}
|
123
|
+
extractKeyPoints(content) {
|
124
|
+
const lines = content.split('\n');
|
125
|
+
const keyPoints = [];
|
126
|
+
for (const line of lines) {
|
127
|
+
const trimmed = line.trim();
|
128
|
+
// Extract bullet points, headings, and important statements
|
129
|
+
if (trimmed.startsWith('- ') || trimmed.startsWith('* ') ||
|
130
|
+
trimmed.startsWith('#') || trimmed.includes('**')) {
|
131
|
+
keyPoints.push(trimmed.replace(/[#*-]/g, '').trim());
|
132
|
+
}
|
133
|
+
}
|
134
|
+
return keyPoints.filter(point => point.length > 10); // Filter out short points
|
135
|
+
}
|
136
|
+
async generateSuggestions(content, context) {
|
137
|
+
const suggestions = [];
|
138
|
+
// Check for missing architecture context
|
139
|
+
if (context.architecture.length > 0) {
|
140
|
+
const hasArchContext = context.architecture.some(arch => content.toLowerCase().includes(arch.toLowerCase()));
|
141
|
+
if (!hasArchContext) {
|
142
|
+
suggestions.push({
|
143
|
+
type: 'context',
|
144
|
+
priority: 'medium',
|
145
|
+
message: 'Consider referencing existing architecture patterns',
|
146
|
+
reference: '.agent/system/architecture.md'
|
147
|
+
});
|
148
|
+
}
|
149
|
+
}
|
150
|
+
// Check for established patterns
|
151
|
+
if (context.patterns.length > 0) {
|
152
|
+
const hasPatterns = context.patterns.some(pattern => content.toLowerCase().includes(pattern.toLowerCase()));
|
153
|
+
if (!hasPatterns) {
|
154
|
+
suggestions.push({
|
155
|
+
type: 'pattern',
|
156
|
+
priority: 'low',
|
157
|
+
message: 'Review existing SOPs for established patterns',
|
158
|
+
reference: '.agent/sop/'
|
159
|
+
});
|
160
|
+
}
|
161
|
+
}
|
162
|
+
// Check for dependency conflicts
|
163
|
+
const mentionedDeps = context.dependencies.filter(dep => content.toLowerCase().includes(dep.toLowerCase()));
|
164
|
+
if (mentionedDeps.length > 0) {
|
165
|
+
suggestions.push({
|
166
|
+
type: 'dependency',
|
167
|
+
priority: 'medium',
|
168
|
+
message: `References existing dependencies: ${mentionedDeps.slice(0, 3).join(', ')}`,
|
169
|
+
reference: 'package.json'
|
170
|
+
});
|
171
|
+
}
|
172
|
+
// Check for system constraints
|
173
|
+
const constraintConflicts = context.systemConstraints.filter(constraint => this.hasConflict(content, constraint));
|
174
|
+
if (constraintConflicts.length > 0) {
|
175
|
+
suggestions.push({
|
176
|
+
type: 'conflict',
|
177
|
+
priority: 'high',
|
178
|
+
message: 'Potential conflicts with system constraints detected',
|
179
|
+
reference: '.agent/system/critical-state.md'
|
180
|
+
});
|
181
|
+
}
|
182
|
+
return suggestions;
|
183
|
+
}
|
184
|
+
async detectConflicts(content, context) {
|
185
|
+
const conflicts = [];
|
186
|
+
// Check against system constraints
|
187
|
+
for (const constraint of context.systemConstraints) {
|
188
|
+
if (this.hasConflict(content, constraint)) {
|
189
|
+
conflicts.push(`Conflicts with: ${constraint}`);
|
190
|
+
}
|
191
|
+
}
|
192
|
+
return conflicts;
|
193
|
+
}
|
194
|
+
async findSimilarTasks(content, context) {
|
195
|
+
const similar = [];
|
196
|
+
const contentWords = this.extractKeywords(content);
|
197
|
+
// Load and analyze existing tasks
|
198
|
+
const tasksPath = path.join(this.agentPath, 'tasks');
|
199
|
+
if (existsSync(tasksPath)) {
|
200
|
+
for (const taskFile of context.existingTasks) {
|
201
|
+
try {
|
202
|
+
const taskPath = path.join(tasksPath, taskFile);
|
203
|
+
const taskContent = await fs.readFile(taskPath, 'utf-8');
|
204
|
+
const taskWords = this.extractKeywords(taskContent);
|
205
|
+
const similarity = this.calculateSimilarity(contentWords, taskWords);
|
206
|
+
if (similarity > 0.3) { // 30% similarity threshold
|
207
|
+
similar.push(`${taskFile} (${Math.round(similarity * 100)}% similar)`);
|
208
|
+
}
|
209
|
+
}
|
210
|
+
catch (error) {
|
211
|
+
// Skip files we can't read
|
212
|
+
}
|
213
|
+
}
|
214
|
+
}
|
215
|
+
return similar;
|
216
|
+
}
|
217
|
+
detectMissingContext(content, context) {
|
218
|
+
const missing = [];
|
219
|
+
// Check for common PRD sections
|
220
|
+
const requiredSections = [
|
221
|
+
'objective', 'requirements', 'technical approach', 'success criteria'
|
222
|
+
];
|
223
|
+
for (const section of requiredSections) {
|
224
|
+
if (!content.toLowerCase().includes(section)) {
|
225
|
+
missing.push(`Missing section: ${section}`);
|
226
|
+
}
|
227
|
+
}
|
228
|
+
// Check for architecture considerations
|
229
|
+
if (!content.toLowerCase().includes('architecture') && !content.toLowerCase().includes('component')) {
|
230
|
+
missing.push('No architecture impact discussed');
|
231
|
+
}
|
232
|
+
// Check for dependency analysis
|
233
|
+
if (!content.toLowerCase().includes('depend') && !content.toLowerCase().includes('integrat')) {
|
234
|
+
missing.push('Dependencies not analyzed');
|
235
|
+
}
|
236
|
+
return missing;
|
237
|
+
}
|
238
|
+
analyzeArchitectureImpact(content, context) {
|
239
|
+
const impacts = [];
|
240
|
+
// Detect potential architecture changes
|
241
|
+
const architectureKeywords = [
|
242
|
+
'new component', 'new service', 'new tool', 'new command',
|
243
|
+
'refactor', 'restructure', 'migrate', 'breaking change'
|
244
|
+
];
|
245
|
+
for (const keyword of architectureKeywords) {
|
246
|
+
if (content.toLowerCase().includes(keyword)) {
|
247
|
+
impacts.push(`May require: ${keyword}`);
|
248
|
+
}
|
249
|
+
}
|
250
|
+
// Check against current architecture
|
251
|
+
if (context.architecture.some(arch => content.toLowerCase().includes(arch.toLowerCase()))) {
|
252
|
+
impacts.push('Affects existing architecture components');
|
253
|
+
}
|
254
|
+
return impacts;
|
255
|
+
}
|
256
|
+
hasConflict(content, constraint) {
|
257
|
+
// Simple conflict detection - could be enhanced with NLP
|
258
|
+
const conflictKeywords = ['replace', 'remove', 'delete', 'deprecated', 'breaking'];
|
259
|
+
const contentLower = content.toLowerCase();
|
260
|
+
const constraintLower = constraint.toLowerCase();
|
261
|
+
return conflictKeywords.some(keyword => contentLower.includes(keyword) && contentLower.includes(constraintLower));
|
262
|
+
}
|
263
|
+
extractKeywords(content) {
|
264
|
+
// Simple keyword extraction
|
265
|
+
const words = content.toLowerCase()
|
266
|
+
.replace(/[^\w\s]/g, ' ')
|
267
|
+
.split(/\s+/)
|
268
|
+
.filter(word => word.length > 3);
|
269
|
+
// Remove common words
|
270
|
+
const commonWords = ['this', 'that', 'will', 'should', 'could', 'would', 'need', 'want'];
|
271
|
+
return words.filter(word => !commonWords.includes(word));
|
272
|
+
}
|
273
|
+
calculateSimilarity(words1, words2) {
|
274
|
+
const set1 = new Set(words1);
|
275
|
+
const set2 = new Set(words2);
|
276
|
+
const intersection = new Set([...set1].filter(x => set2.has(x)));
|
277
|
+
const union = new Set([...set1, ...set2]);
|
278
|
+
return intersection.size / union.size;
|
279
|
+
}
|
280
|
+
generateAnalysisReport(analysis) {
|
281
|
+
let report = `📋 **PRD Analysis: ${analysis.title}**\n\n`;
|
282
|
+
if (analysis.suggestions.length > 0) {
|
283
|
+
report += `💡 **Suggestions:**\n`;
|
284
|
+
analysis.suggestions.forEach(suggestion => {
|
285
|
+
const priority = suggestion.priority === 'high' ? '🔴' :
|
286
|
+
suggestion.priority === 'medium' ? '🟡' : '🟢';
|
287
|
+
report += `${priority} ${suggestion.message}`;
|
288
|
+
if (suggestion.reference) {
|
289
|
+
report += ` (see: ${suggestion.reference})`;
|
290
|
+
}
|
291
|
+
report += '\n';
|
292
|
+
});
|
293
|
+
report += '\n';
|
294
|
+
}
|
295
|
+
if (analysis.conflicts.length > 0) {
|
296
|
+
report += `⚠️ **Potential Conflicts:**\n`;
|
297
|
+
analysis.conflicts.forEach(conflict => {
|
298
|
+
report += `- ${conflict}\n`;
|
299
|
+
});
|
300
|
+
report += '\n';
|
301
|
+
}
|
302
|
+
if (analysis.similarTasks.length > 0) {
|
303
|
+
report += `🔗 **Similar Tasks:**\n`;
|
304
|
+
analysis.similarTasks.forEach(task => {
|
305
|
+
report += `- ${task}\n`;
|
306
|
+
});
|
307
|
+
report += '\n';
|
308
|
+
}
|
309
|
+
if (analysis.architectureImpact.length > 0) {
|
310
|
+
report += `🏗️ **Architecture Impact:**\n`;
|
311
|
+
analysis.architectureImpact.forEach(impact => {
|
312
|
+
report += `- ${impact}\n`;
|
313
|
+
});
|
314
|
+
report += '\n';
|
315
|
+
}
|
316
|
+
if (analysis.missingContext.length > 0) {
|
317
|
+
report += `📝 **Consider Adding:**\n`;
|
318
|
+
analysis.missingContext.forEach(missing => {
|
319
|
+
report += `- ${missing}\n`;
|
320
|
+
});
|
321
|
+
}
|
322
|
+
return report;
|
323
|
+
}
|
324
|
+
}
|
325
|
+
//# sourceMappingURL=smart-prd-assistant.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"smart-prd-assistant.js","sourceRoot":"","sources":["../../../src/tools/documentation/smart-prd-assistant.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AA4BhC,MAAM,OAAO,iBAAiB;IAI5B,YAAY,QAAgB;QAC1B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAe;QAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACxC,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAEzC,uBAAuB;QACvB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAEhD,kBAAkB;QAClB,MAAM,QAAQ,GAAgB;YAC5B,QAAQ;YACR,KAAK;YACL,OAAO;YACP,WAAW,EAAE,EAAE;YACf,SAAS,EAAE,EAAE;YACb,YAAY,EAAE,EAAE;YAChB,cAAc,EAAE,EAAE;YAClB,kBAAkB,EAAE,EAAE;SACvB,CAAC;QAEF,uBAAuB;QACvB,QAAQ,CAAC,WAAW,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxE,QAAQ,CAAC,SAAS,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAClE,QAAQ,CAAC,YAA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|
6
|
+
export interface ChangeAnalysis {
|
7
|
+
filesChanged: string[];
|
8
|
+
newFiles: string[];
|
9
|
+
deletedFiles: string[];
|
10
|
+
gitCommits: string[];
|
11
|
+
architectureChanges: boolean;
|
12
|
+
configChanges: boolean;
|
13
|
+
hasNewFeatures: boolean;
|
14
|
+
}
|
15
|
+
export interface UpdateResult {
|
16
|
+
success: boolean;
|
17
|
+
message: string;
|
18
|
+
updatedFiles: string[];
|
19
|
+
suggestions: string[];
|
20
|
+
}
|
21
|
+
export declare class UpdateAgentDocs {
|
22
|
+
private config;
|
23
|
+
constructor(config: UpdateConfig);
|
24
|
+
updateDocs(): Promise<UpdateResult>;
|
25
|
+
private analyzeChanges;
|
26
|
+
private getRecentlyModifiedFiles;
|
27
|
+
private detectArchitectureChanges;
|
28
|
+
private detectConfigChanges;
|
29
|
+
private detectNewFeatures;
|
30
|
+
private shouldUpdate;
|
31
|
+
private updateSystemDocs;
|
32
|
+
private updateCriticalState;
|
33
|
+
private updateArchitectureDoc;
|
34
|
+
private generateChangesSummary;
|
35
|
+
private generateSuggestions;
|
36
|
+
private generateUpdateMessage;
|
37
|
+
}
|
@@ -0,0 +1,275 @@
|
|
1
|
+
import path from 'path';
|
2
|
+
import fs from 'fs/promises';
|
3
|
+
import { existsSync } from 'fs';
|
4
|
+
export class UpdateAgentDocs {
|
5
|
+
constructor(config) {
|
6
|
+
this.config = config;
|
7
|
+
}
|
8
|
+
async updateDocs() {
|
9
|
+
try {
|
10
|
+
// Check if .agent system exists
|
11
|
+
const agentPath = path.join(this.config.rootPath, '.agent');
|
12
|
+
if (!existsSync(agentPath)) {
|
13
|
+
return {
|
14
|
+
success: false,
|
15
|
+
message: '❌ .agent documentation system not found. Run `/init-agent` first.',
|
16
|
+
updatedFiles: [],
|
17
|
+
suggestions: ['Run `/init-agent` to initialize the documentation system']
|
18
|
+
};
|
19
|
+
}
|
20
|
+
// Analyze recent changes
|
21
|
+
const analysis = await this.analyzeChanges();
|
22
|
+
if (analysis.filesChanged.length === 0 && analysis.gitCommits.length === 0) {
|
23
|
+
return {
|
24
|
+
success: true,
|
25
|
+
message: '✅ No significant changes detected. Documentation is up to date.',
|
26
|
+
updatedFiles: [],
|
27
|
+
suggestions: []
|
28
|
+
};
|
29
|
+
}
|
30
|
+
// Update documentation based on analysis
|
31
|
+
const updatedFiles = [];
|
32
|
+
const suggestions = [];
|
33
|
+
// Update system documentation if needed
|
34
|
+
if (this.shouldUpdate('system') && (analysis.architectureChanges || analysis.configChanges)) {
|
35
|
+
const systemUpdates = await this.updateSystemDocs(analysis);
|
36
|
+
updatedFiles.push(...systemUpdates);
|
37
|
+
}
|
38
|
+
// Update critical state
|
39
|
+
const criticalStateUpdate = await this.updateCriticalState(analysis);
|
40
|
+
if (criticalStateUpdate) {
|
41
|
+
updatedFiles.push('.agent/system/critical-state.md');
|
42
|
+
}
|
43
|
+
// Generate suggestions for manual updates
|
44
|
+
suggestions.push(...this.generateSuggestions(analysis));
|
45
|
+
const message = this.generateUpdateMessage(analysis, updatedFiles);
|
46
|
+
return {
|
47
|
+
success: true,
|
48
|
+
message,
|
49
|
+
updatedFiles,
|
50
|
+
suggestions
|
51
|
+
};
|
52
|
+
}
|
53
|
+
catch (error) {
|
54
|
+
return {
|
55
|
+
success: false,
|
56
|
+
message: `Failed to update agent docs: ${error.message}`,
|
57
|
+
updatedFiles: [],
|
58
|
+
suggestions: []
|
59
|
+
};
|
60
|
+
}
|
61
|
+
}
|
62
|
+
async analyzeChanges() {
|
63
|
+
const analysis = {
|
64
|
+
filesChanged: [],
|
65
|
+
newFiles: [],
|
66
|
+
deletedFiles: [],
|
67
|
+
gitCommits: [],
|
68
|
+
architectureChanges: false,
|
69
|
+
configChanges: false,
|
70
|
+
hasNewFeatures: false
|
71
|
+
};
|
72
|
+
try {
|
73
|
+
// Get git changes since last update
|
74
|
+
const { execSync } = require('child_process');
|
75
|
+
// Get recent commits (last 10)
|
76
|
+
try {
|
77
|
+
const commits = execSync('git log --oneline -10', {
|
78
|
+
cwd: this.config.rootPath,
|
79
|
+
encoding: 'utf-8'
|
80
|
+
});
|
81
|
+
analysis.gitCommits = commits.trim().split('\n').filter(Boolean);
|
82
|
+
}
|
83
|
+
catch (error) {
|
84
|
+
// Not a git repo or no commits
|
85
|
+
}
|
86
|
+
// Get changed files since last commit
|
87
|
+
try {
|
88
|
+
const changedFiles = execSync('git diff --name-only HEAD~5..HEAD', {
|
89
|
+
cwd: this.config.rootPath,
|
90
|
+
encoding: 'utf-8'
|
91
|
+
});
|
92
|
+
analysis.filesChanged = changedFiles.trim().split('\n').filter(Boolean);
|
93
|
+
}
|
94
|
+
catch (error) {
|
95
|
+
// Use file system timestamps as fallback
|
96
|
+
analysis.filesChanged = await this.getRecentlyModifiedFiles();
|
97
|
+
}
|
98
|
+
// Analyze types of changes
|
99
|
+
analysis.architectureChanges = this.detectArchitectureChanges(analysis.filesChanged);
|
100
|
+
analysis.configChanges = this.detectConfigChanges(analysis.filesChanged);
|
101
|
+
analysis.hasNewFeatures = this.detectNewFeatures(analysis.gitCommits);
|
102
|
+
return analysis;
|
103
|
+
}
|
104
|
+
catch (error) {
|
105
|
+
return analysis;
|
106
|
+
}
|
107
|
+
}
|
108
|
+
async getRecentlyModifiedFiles() {
|
109
|
+
// Fallback: get files modified in last 24 hours
|
110
|
+
const oneDayAgo = Date.now() - (24 * 60 * 60 * 1000);
|
111
|
+
const recentFiles = [];
|
112
|
+
const scanDir = async (dirPath) => {
|
113
|
+
try {
|
114
|
+
const entries = await fs.readdir(dirPath, { withFileTypes: true });
|
115
|
+
for (const entry of entries) {
|
116
|
+
const fullPath = path.join(dirPath, entry.name);
|
117
|
+
if (entry.isDirectory() && !entry.name.startsWith('.') && entry.name !== 'node_modules') {
|
118
|
+
await scanDir(fullPath);
|
119
|
+
}
|
120
|
+
else if (entry.isFile()) {
|
121
|
+
const stats = await fs.stat(fullPath);
|
122
|
+
if (stats.mtime.getTime() > oneDayAgo) {
|
123
|
+
recentFiles.push(path.relative(this.config.rootPath, fullPath));
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
}
|
128
|
+
catch (error) {
|
129
|
+
// Skip directories we can't read
|
130
|
+
}
|
131
|
+
};
|
132
|
+
await scanDir(this.config.rootPath);
|
133
|
+
return recentFiles;
|
134
|
+
}
|
135
|
+
detectArchitectureChanges(filesChanged) {
|
136
|
+
const architectureIndicators = [
|
137
|
+
'src/tools/', 'src/commands/', 'src/ui/', 'src/agent/',
|
138
|
+
'package.json', 'tsconfig.json', 'src/index.ts'
|
139
|
+
];
|
140
|
+
return filesChanged.some(file => architectureIndicators.some(indicator => file.includes(indicator)));
|
141
|
+
}
|
142
|
+
detectConfigChanges(filesChanged) {
|
143
|
+
const configFiles = [
|
144
|
+
'package.json', 'tsconfig.json', '.grok/', 'CLAUDE.md',
|
145
|
+
'.env', '.gitignore', 'README.md'
|
146
|
+
];
|
147
|
+
return filesChanged.some(file => configFiles.some(config => file.includes(config)));
|
148
|
+
}
|
149
|
+
detectNewFeatures(commits) {
|
150
|
+
const featureKeywords = ['feat:', 'add:', 'new:', 'feature:', 'implement:'];
|
151
|
+
return commits.some(commit => featureKeywords.some(keyword => commit.toLowerCase().includes(keyword)));
|
152
|
+
}
|
153
|
+
shouldUpdate(target) {
|
154
|
+
return this.config.updateTarget === 'all' || this.config.updateTarget === target;
|
155
|
+
}
|
156
|
+
async updateSystemDocs(analysis) {
|
157
|
+
const updatedFiles = [];
|
158
|
+
const systemPath = path.join(this.config.rootPath, '.agent', 'system');
|
159
|
+
// Update architecture.md if architecture changed
|
160
|
+
if (analysis.architectureChanges) {
|
161
|
+
try {
|
162
|
+
const archPath = path.join(systemPath, 'architecture.md');
|
163
|
+
if (existsSync(archPath)) {
|
164
|
+
const content = await fs.readFile(archPath, 'utf-8');
|
165
|
+
const updatedContent = await this.updateArchitectureDoc(content, analysis);
|
166
|
+
await fs.writeFile(archPath, updatedContent);
|
167
|
+
updatedFiles.push('.agent/system/architecture.md');
|
168
|
+
}
|
169
|
+
}
|
170
|
+
catch (error) {
|
171
|
+
// Continue with other updates
|
172
|
+
}
|
173
|
+
}
|
174
|
+
return updatedFiles;
|
175
|
+
}
|
176
|
+
async updateCriticalState(analysis) {
|
177
|
+
try {
|
178
|
+
const criticalStatePath = path.join(this.config.rootPath, '.agent', 'system', 'critical-state.md');
|
179
|
+
if (!existsSync(criticalStatePath)) {
|
180
|
+
return false;
|
181
|
+
}
|
182
|
+
const content = await fs.readFile(criticalStatePath, 'utf-8');
|
183
|
+
// Update timestamp and recent changes
|
184
|
+
const timestamp = new Date().toISOString();
|
185
|
+
const changesSummary = this.generateChangesSummary(analysis);
|
186
|
+
let updatedContent = content.replace(/Last Updated: .*/, `Last Updated: ${timestamp}`);
|
187
|
+
// Add recent changes section if significant changes detected
|
188
|
+
if (analysis.filesChanged.length > 0) {
|
189
|
+
const recentChangesSection = `
|
190
|
+
|
191
|
+
## Recent Changes
|
192
|
+
${changesSummary}`;
|
193
|
+
if (content.includes('## Recent Changes')) {
|
194
|
+
updatedContent = updatedContent.replace(/## Recent Changes[\s\S]*?(?=##|$)/, recentChangesSection);
|
195
|
+
}
|
196
|
+
else {
|
197
|
+
updatedContent = updatedContent.replace(/Last Updated: .*/, `Last Updated: ${timestamp}\nUpdated By: /update-agent-docs after detecting changes${recentChangesSection}`);
|
198
|
+
}
|
199
|
+
}
|
200
|
+
await fs.writeFile(criticalStatePath, updatedContent);
|
201
|
+
return true;
|
202
|
+
}
|
203
|
+
catch (error) {
|
204
|
+
return false;
|
205
|
+
}
|
206
|
+
}
|
207
|
+
async updateArchitectureDoc(content, analysis) {
|
208
|
+
// Simple update - add timestamp and recent changes note
|
209
|
+
const timestamp = new Date().toISOString().split('T')[0];
|
210
|
+
return content.replace(/\*Updated: .*/, `*Updated: ${timestamp} - Recent changes detected in: ${analysis.filesChanged.slice(0, 3).join(', ')}${analysis.filesChanged.length > 3 ? '...' : ''}*`);
|
211
|
+
}
|
212
|
+
generateChangesSummary(analysis) {
|
213
|
+
const lines = [];
|
214
|
+
if (analysis.gitCommits.length > 0) {
|
215
|
+
lines.push(`**Recent Commits (${analysis.gitCommits.length}):**`);
|
216
|
+
analysis.gitCommits.slice(0, 5).forEach(commit => {
|
217
|
+
lines.push(`- ${commit}`);
|
218
|
+
});
|
219
|
+
if (analysis.gitCommits.length > 5) {
|
220
|
+
lines.push(`- ... and ${analysis.gitCommits.length - 5} more`);
|
221
|
+
}
|
222
|
+
}
|
223
|
+
if (analysis.filesChanged.length > 0) {
|
224
|
+
lines.push(`\n**Files Modified (${analysis.filesChanged.length}):**`);
|
225
|
+
analysis.filesChanged.slice(0, 10).forEach(file => {
|
226
|
+
lines.push(`- ${file}`);
|
227
|
+
});
|
228
|
+
if (analysis.filesChanged.length > 10) {
|
229
|
+
lines.push(`- ... and ${analysis.filesChanged.length - 10} more files`);
|
230
|
+
}
|
231
|
+
}
|
232
|
+
if (analysis.architectureChanges) {
|
233
|
+
lines.push('\n**⚠️ Architecture changes detected**');
|
234
|
+
}
|
235
|
+
if (analysis.configChanges) {
|
236
|
+
lines.push('**⚙️ Configuration changes detected**');
|
237
|
+
}
|
238
|
+
return lines.join('\n');
|
239
|
+
}
|
240
|
+
generateSuggestions(analysis) {
|
241
|
+
const suggestions = [];
|
242
|
+
if (analysis.hasNewFeatures) {
|
243
|
+
suggestions.push('📝 Consider adding new features to .agent/tasks/ as PRDs');
|
244
|
+
suggestions.push('📖 Update README.md with new feature documentation');
|
245
|
+
}
|
246
|
+
if (analysis.architectureChanges) {
|
247
|
+
suggestions.push('🏗️ Review and update .agent/system/architecture.md manually');
|
248
|
+
suggestions.push('📋 Update API documentation if interfaces changed');
|
249
|
+
}
|
250
|
+
if (analysis.configChanges) {
|
251
|
+
suggestions.push('⚙️ Review configuration changes in .agent/system/');
|
252
|
+
}
|
253
|
+
if (analysis.filesChanged.length > 20) {
|
254
|
+
suggestions.push('🧹 Consider running /compact to optimize conversation history');
|
255
|
+
}
|
256
|
+
return suggestions;
|
257
|
+
}
|
258
|
+
generateUpdateMessage(analysis, updatedFiles) {
|
259
|
+
let message = `✅ **Agent Documentation Updated**\n\n`;
|
260
|
+
message += `📊 **Change Analysis:**\n`;
|
261
|
+
message += `- Files changed: ${analysis.filesChanged.length}\n`;
|
262
|
+
message += `- Recent commits: ${analysis.gitCommits.length}\n`;
|
263
|
+
message += `- Architecture changes: ${analysis.architectureChanges ? '✅' : '❌'}\n`;
|
264
|
+
message += `- Config changes: ${analysis.configChanges ? '✅' : '❌'}\n\n`;
|
265
|
+
if (updatedFiles.length > 0) {
|
266
|
+
message += `📝 **Updated Files:**\n`;
|
267
|
+
updatedFiles.forEach(file => {
|
268
|
+
message += `- ${file}\n`;
|
269
|
+
});
|
270
|
+
message += '\n';
|
271
|
+
}
|
272
|
+
return message;
|
273
|
+
}
|
274
|
+
}
|
275
|
+
//# sourceMappingURL=update-agent-docs.js.map
|