claudedesk 1.0.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 +431 -0
- package/config/repos.example.json +128 -0
- package/config/settings.example.json +64 -0
- package/config/skills/code-review.md +76 -0
- package/config/skills/full-check.md +26 -0
- package/config/skills/lint-fix.md +23 -0
- package/dist/api/agent-routes.d.ts +2 -0
- package/dist/api/agent-routes.d.ts.map +1 -0
- package/dist/api/agent-routes.js +251 -0
- package/dist/api/agent-routes.js.map +1 -0
- package/dist/api/app-routes.d.ts +2 -0
- package/dist/api/app-routes.d.ts.map +1 -0
- package/dist/api/app-routes.js +150 -0
- package/dist/api/app-routes.js.map +1 -0
- package/dist/api/docker-routes.d.ts +2 -0
- package/dist/api/docker-routes.d.ts.map +1 -0
- package/dist/api/docker-routes.js +167 -0
- package/dist/api/docker-routes.js.map +1 -0
- package/dist/api/middleware.d.ts +6 -0
- package/dist/api/middleware.d.ts.map +1 -0
- package/dist/api/middleware.js +293 -0
- package/dist/api/middleware.js.map +1 -0
- package/dist/api/pin-auth.d.ts +65 -0
- package/dist/api/pin-auth.d.ts.map +1 -0
- package/dist/api/pin-auth.js +218 -0
- package/dist/api/pin-auth.js.map +1 -0
- package/dist/api/routes.d.ts +2 -0
- package/dist/api/routes.d.ts.map +1 -0
- package/dist/api/routes.js +473 -0
- package/dist/api/routes.js.map +1 -0
- package/dist/api/settings-routes.d.ts +2 -0
- package/dist/api/settings-routes.d.ts.map +1 -0
- package/dist/api/settings-routes.js +570 -0
- package/dist/api/settings-routes.js.map +1 -0
- package/dist/api/skill-routes.d.ts +2 -0
- package/dist/api/skill-routes.d.ts.map +1 -0
- package/dist/api/skill-routes.js +88 -0
- package/dist/api/skill-routes.js.map +1 -0
- package/dist/api/terminal-routes.d.ts +2 -0
- package/dist/api/terminal-routes.d.ts.map +1 -0
- package/dist/api/terminal-routes.js +3524 -0
- package/dist/api/terminal-routes.js.map +1 -0
- package/dist/api/tunnel-routes.d.ts +2 -0
- package/dist/api/tunnel-routes.d.ts.map +1 -0
- package/dist/api/tunnel-routes.js +196 -0
- package/dist/api/tunnel-routes.js.map +1 -0
- package/dist/api/workspace-routes.d.ts +3 -0
- package/dist/api/workspace-routes.d.ts.map +1 -0
- package/dist/api/workspace-routes.js +649 -0
- package/dist/api/workspace-routes.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +276 -0
- package/dist/cli.js.map +1 -0
- package/dist/client/assets/index-B4r0njGe.js +780 -0
- package/dist/client/assets/index-CY_9MyE0.css +1 -0
- package/dist/client/favicon.svg +5 -0
- package/dist/client/icons/icon-192.svg +5 -0
- package/dist/client/icons/icon-512.svg +5 -0
- package/dist/client/icons/logo-with-message.png +0 -0
- package/dist/client/icons/logo.png +0 -0
- package/dist/client/index.html +25 -0
- package/dist/client/manifest.json +62 -0
- package/dist/client/sw.js +243 -0
- package/dist/config/agent-usage.d.ts +34 -0
- package/dist/config/agent-usage.d.ts.map +1 -0
- package/dist/config/agent-usage.js +87 -0
- package/dist/config/agent-usage.js.map +1 -0
- package/dist/config/repos.d.ts +34 -0
- package/dist/config/repos.d.ts.map +1 -0
- package/dist/config/repos.js +412 -0
- package/dist/config/repos.js.map +1 -0
- package/dist/config/settings.d.ts +634 -0
- package/dist/config/settings.d.ts.map +1 -0
- package/dist/config/settings.js +459 -0
- package/dist/config/settings.js.map +1 -0
- package/dist/config/skills.d.ts +18 -0
- package/dist/config/skills.d.ts.map +1 -0
- package/dist/config/skills.js +174 -0
- package/dist/config/skills.js.map +1 -0
- package/dist/config/workspaces.d.ts +961 -0
- package/dist/config/workspaces.d.ts.map +1 -0
- package/dist/config/workspaces.js +482 -0
- package/dist/config/workspaces.js.map +1 -0
- package/dist/core/app-manager.d.ts +85 -0
- package/dist/core/app-manager.d.ts.map +1 -0
- package/dist/core/app-manager.js +447 -0
- package/dist/core/app-manager.js.map +1 -0
- package/dist/core/claude-invoker.d.ts +49 -0
- package/dist/core/claude-invoker.d.ts.map +1 -0
- package/dist/core/claude-invoker.js +583 -0
- package/dist/core/claude-invoker.js.map +1 -0
- package/dist/core/claude-session-reader.d.ts +25 -0
- package/dist/core/claude-session-reader.d.ts.map +1 -0
- package/dist/core/claude-session-reader.js +184 -0
- package/dist/core/claude-session-reader.js.map +1 -0
- package/dist/core/claude-usage-query.d.ts +78 -0
- package/dist/core/claude-usage-query.d.ts.map +1 -0
- package/dist/core/claude-usage-query.js +294 -0
- package/dist/core/claude-usage-query.js.map +1 -0
- package/dist/core/git-credential-helper.d.ts +57 -0
- package/dist/core/git-credential-helper.d.ts.map +1 -0
- package/dist/core/git-credential-helper.js +176 -0
- package/dist/core/git-credential-helper.js.map +1 -0
- package/dist/core/git-sandbox.d.ts +135 -0
- package/dist/core/git-sandbox.d.ts.map +1 -0
- package/dist/core/git-sandbox.js +907 -0
- package/dist/core/git-sandbox.js.map +1 -0
- package/dist/core/github-integration.d.ts +66 -0
- package/dist/core/github-integration.d.ts.map +1 -0
- package/dist/core/github-integration.js +350 -0
- package/dist/core/github-integration.js.map +1 -0
- package/dist/core/github-oauth.d.ts +88 -0
- package/dist/core/github-oauth.d.ts.map +1 -0
- package/dist/core/github-oauth.js +244 -0
- package/dist/core/github-oauth.js.map +1 -0
- package/dist/core/gitlab-integration.d.ts +66 -0
- package/dist/core/gitlab-integration.d.ts.map +1 -0
- package/dist/core/gitlab-integration.js +353 -0
- package/dist/core/gitlab-integration.js.map +1 -0
- package/dist/core/gitlab-oauth.d.ts +100 -0
- package/dist/core/gitlab-oauth.d.ts.map +1 -0
- package/dist/core/gitlab-oauth.js +366 -0
- package/dist/core/gitlab-oauth.js.map +1 -0
- package/dist/core/insights-extractor.d.ts +68 -0
- package/dist/core/insights-extractor.d.ts.map +1 -0
- package/dist/core/insights-extractor.js +402 -0
- package/dist/core/insights-extractor.js.map +1 -0
- package/dist/core/logger.d.ts +27 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +70 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/process-runner.d.ts +27 -0
- package/dist/core/process-runner.d.ts.map +1 -0
- package/dist/core/process-runner.js +147 -0
- package/dist/core/process-runner.js.map +1 -0
- package/dist/core/project-detector.d.ts +30 -0
- package/dist/core/project-detector.d.ts.map +1 -0
- package/dist/core/project-detector.js +482 -0
- package/dist/core/project-detector.js.map +1 -0
- package/dist/core/qr-generator.d.ts +18 -0
- package/dist/core/qr-generator.d.ts.map +1 -0
- package/dist/core/qr-generator.js +61 -0
- package/dist/core/qr-generator.js.map +1 -0
- package/dist/core/remote-tunnel-manager.d.ts +59 -0
- package/dist/core/remote-tunnel-manager.d.ts.map +1 -0
- package/dist/core/remote-tunnel-manager.js +235 -0
- package/dist/core/remote-tunnel-manager.js.map +1 -0
- package/dist/core/shared-docker-manager.d.ts +41 -0
- package/dist/core/shared-docker-manager.d.ts.map +1 -0
- package/dist/core/shared-docker-manager.js +409 -0
- package/dist/core/shared-docker-manager.js.map +1 -0
- package/dist/core/skill-executor.d.ts +25 -0
- package/dist/core/skill-executor.d.ts.map +1 -0
- package/dist/core/skill-executor.js +171 -0
- package/dist/core/skill-executor.js.map +1 -0
- package/dist/core/terminal-session.d.ts +149 -0
- package/dist/core/terminal-session.d.ts.map +1 -0
- package/dist/core/terminal-session.js +2340 -0
- package/dist/core/terminal-session.js.map +1 -0
- package/dist/core/tunnel-manager.d.ts +35 -0
- package/dist/core/tunnel-manager.d.ts.map +1 -0
- package/dist/core/tunnel-manager.js +137 -0
- package/dist/core/tunnel-manager.js.map +1 -0
- package/dist/core/usage-manager.d.ts +57 -0
- package/dist/core/usage-manager.d.ts.map +1 -0
- package/dist/core/usage-manager.js +363 -0
- package/dist/core/usage-manager.js.map +1 -0
- package/dist/core/ws-manager.d.ts +39 -0
- package/dist/core/ws-manager.d.ts.map +1 -0
- package/dist/core/ws-manager.js +190 -0
- package/dist/core/ws-manager.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +229 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +868 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +119 -0
- package/dist/types.js.map +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, existsSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* Extracts insights from Claude's output to explain what was done and why.
|
|
5
|
+
* Parses the conversational output and structures it into actionable insights.
|
|
6
|
+
*/
|
|
7
|
+
export class InsightsExtractor {
|
|
8
|
+
/**
|
|
9
|
+
* Extract insights from a job's Claude output
|
|
10
|
+
*/
|
|
11
|
+
extractFromJob(artifactsDir, changedFiles) {
|
|
12
|
+
const claudeOutputPath = join(artifactsDir, 'claude', 'output.txt');
|
|
13
|
+
const promptPath = join(artifactsDir, 'claude', 'prompt.md');
|
|
14
|
+
if (!existsSync(claudeOutputPath)) {
|
|
15
|
+
console.log('[InsightsExtractor] No Claude output found');
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const output = readFileSync(claudeOutputPath, 'utf-8');
|
|
19
|
+
const prompt = existsSync(promptPath) ? readFileSync(promptPath, 'utf-8') : '';
|
|
20
|
+
if (!output || output.trim().length === 0) {
|
|
21
|
+
console.log('[InsightsExtractor] Claude output is empty');
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
console.log(`[InsightsExtractor] Extracting insights from ${output.length} chars of output`);
|
|
25
|
+
const insights = this.parseOutput(output, prompt, changedFiles || []);
|
|
26
|
+
// Save insights to file
|
|
27
|
+
const insightsPath = join(artifactsDir, 'insights.json');
|
|
28
|
+
writeFileSync(insightsPath, JSON.stringify(insights, null, 2));
|
|
29
|
+
console.log(`[InsightsExtractor] Saved insights to ${insightsPath}`);
|
|
30
|
+
return insights;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Extract insights from a create-repo workflow (scaffolded projects)
|
|
34
|
+
*/
|
|
35
|
+
extractFromCreateRepo(artifactsDir, params) {
|
|
36
|
+
const claudeOutputPath = join(artifactsDir, 'claude', 'output.txt');
|
|
37
|
+
if (!existsSync(claudeOutputPath)) {
|
|
38
|
+
console.log('[InsightsExtractor] No Claude output found for create-repo');
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const output = readFileSync(claudeOutputPath, 'utf-8');
|
|
42
|
+
if (!output || output.trim().length === 0) {
|
|
43
|
+
console.log('[InsightsExtractor] Claude output is empty');
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
console.log(`[InsightsExtractor] Extracting creation insights from ${output.length} chars of output`);
|
|
47
|
+
const templateId = params?.templateId || 'unknown';
|
|
48
|
+
const repoName = params?.repoName || 'new project';
|
|
49
|
+
const featureDescription = params?.featureDescription || params?.prompt || '';
|
|
50
|
+
const insights = {
|
|
51
|
+
summary: `Created ${repoName} using ${templateId} template`,
|
|
52
|
+
problem: featureDescription || `Scaffold a new ${templateId} project`,
|
|
53
|
+
solution: this.extractCreationSolution(output, templateId),
|
|
54
|
+
reasoning: this.extractCreationReasoning(output, templateId),
|
|
55
|
+
filesChanged: this.extractCreatedFiles(output),
|
|
56
|
+
patterns: ['Project scaffolding', 'Template-based setup'],
|
|
57
|
+
};
|
|
58
|
+
// Save insights to file
|
|
59
|
+
const insightsPath = join(artifactsDir, 'insights.json');
|
|
60
|
+
writeFileSync(insightsPath, JSON.stringify(insights, null, 2));
|
|
61
|
+
console.log(`[InsightsExtractor] Saved creation insights to ${insightsPath}`);
|
|
62
|
+
return insights;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Extract what was created in a scaffolded project
|
|
66
|
+
*/
|
|
67
|
+
extractCreationSolution(output, templateId) {
|
|
68
|
+
const solutions = [];
|
|
69
|
+
// Look for file creation patterns
|
|
70
|
+
const filePatterns = [
|
|
71
|
+
/(?:created?|wrote?|generated?|added?)\s+(?:file\s+)?[`']?([^\s`']+\.[a-z]+)[`']?/gi,
|
|
72
|
+
/(?:setting up|configured?|initialized?)\s+(.+?)(?:\.|$)/gi,
|
|
73
|
+
];
|
|
74
|
+
for (const pattern of filePatterns) {
|
|
75
|
+
let match;
|
|
76
|
+
while ((match = pattern.exec(output)) !== null) {
|
|
77
|
+
const item = match[1].trim();
|
|
78
|
+
if (item.length > 3 && item.length < 100 && !solutions.includes(item)) {
|
|
79
|
+
solutions.push(`Created ${item}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Add template-specific defaults if nothing found
|
|
84
|
+
if (solutions.length === 0) {
|
|
85
|
+
const templateDefaults = {
|
|
86
|
+
'nextjs-web': [
|
|
87
|
+
'Set up Next.js project structure',
|
|
88
|
+
'Configured TypeScript',
|
|
89
|
+
'Added Tailwind CSS styling',
|
|
90
|
+
'Created initial page components',
|
|
91
|
+
],
|
|
92
|
+
'default': [
|
|
93
|
+
'Scaffolded project structure',
|
|
94
|
+
'Created configuration files',
|
|
95
|
+
'Set up development environment',
|
|
96
|
+
],
|
|
97
|
+
};
|
|
98
|
+
return templateDefaults[templateId] || templateDefaults['default'];
|
|
99
|
+
}
|
|
100
|
+
return solutions.slice(0, 5);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Extract reasoning for architectural decisions in scaffolded project
|
|
104
|
+
*/
|
|
105
|
+
extractCreationReasoning(output, templateId) {
|
|
106
|
+
// Look for reasoning patterns
|
|
107
|
+
const reasoningPatterns = [
|
|
108
|
+
/(?:because|since|to)\s+(.+?)(?:\.|$)/gi,
|
|
109
|
+
/(?:this|the)\s+(?:template|setup|structure)\s+(?:provides?|enables?|allows?)\s+(.+?)(?:\.|$)/gi,
|
|
110
|
+
];
|
|
111
|
+
for (const pattern of reasoningPatterns) {
|
|
112
|
+
const match = output.match(pattern);
|
|
113
|
+
if (match) {
|
|
114
|
+
const reason = match[1].trim();
|
|
115
|
+
if (reason.length > 20 && reason.length < 200) {
|
|
116
|
+
return this.capitalizeFirst(reason);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Template-specific default reasoning
|
|
121
|
+
const defaultReasoning = {
|
|
122
|
+
'nextjs-web': 'Next.js provides server-side rendering, file-based routing, and excellent TypeScript support for modern web applications',
|
|
123
|
+
'default': 'Template provides a solid foundation with best practices and common configurations pre-configured',
|
|
124
|
+
};
|
|
125
|
+
return defaultReasoning[templateId] || defaultReasoning['default'];
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Extract list of created files from output
|
|
129
|
+
*/
|
|
130
|
+
extractCreatedFiles(output) {
|
|
131
|
+
const files = [];
|
|
132
|
+
// Look for file paths in output
|
|
133
|
+
const filePattern = /(?:created?|wrote?|generated?)\s+[`']?([^\s`']+\.[a-z]+)[`']?/gi;
|
|
134
|
+
let match;
|
|
135
|
+
while ((match = filePattern.exec(output)) !== null) {
|
|
136
|
+
const filePath = match[1];
|
|
137
|
+
if (!files.find(f => f.path === filePath)) {
|
|
138
|
+
files.push({
|
|
139
|
+
path: filePath,
|
|
140
|
+
changes: this.generateFileChangeDescription(filePath),
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return files.slice(0, 10);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Parse Claude's output and extract structured insights
|
|
148
|
+
*/
|
|
149
|
+
parseOutput(output, prompt, changedFiles) {
|
|
150
|
+
// Extract problem from prompt
|
|
151
|
+
const problem = this.extractProblem(prompt, output);
|
|
152
|
+
// Extract what was done
|
|
153
|
+
const solution = this.extractSolution(output);
|
|
154
|
+
// Extract reasoning
|
|
155
|
+
const reasoning = this.extractReasoning(output);
|
|
156
|
+
// Generate summary
|
|
157
|
+
const summary = this.generateSummary(problem, solution);
|
|
158
|
+
// Extract per-file changes
|
|
159
|
+
const filesChanged = this.extractFileChanges(output, changedFiles);
|
|
160
|
+
// Identify patterns
|
|
161
|
+
const patterns = this.identifyPatterns(output, problem);
|
|
162
|
+
// Generate prevention tips
|
|
163
|
+
const preventionTips = this.generatePreventionTips(patterns, problem);
|
|
164
|
+
return {
|
|
165
|
+
summary,
|
|
166
|
+
problem,
|
|
167
|
+
solution,
|
|
168
|
+
reasoning,
|
|
169
|
+
filesChanged,
|
|
170
|
+
patterns: patterns.length > 0 ? patterns : undefined,
|
|
171
|
+
preventionTips: preventionTips.length > 0 ? preventionTips : undefined,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Extract the problem description from prompt and output
|
|
176
|
+
*/
|
|
177
|
+
extractProblem(prompt, output) {
|
|
178
|
+
// Try to extract from prompt first
|
|
179
|
+
const promptMatch = prompt.match(/## Failed Step Output[\s\S]*?```([\s\S]*?)```/);
|
|
180
|
+
if (promptMatch) {
|
|
181
|
+
const errorLog = promptMatch[1].trim();
|
|
182
|
+
// Extract first meaningful error line
|
|
183
|
+
const errorLines = errorLog.split('\n').filter(line => line.includes('error') ||
|
|
184
|
+
line.includes('Error') ||
|
|
185
|
+
line.includes('failed') ||
|
|
186
|
+
line.includes('Failed') ||
|
|
187
|
+
line.includes('TypeError') ||
|
|
188
|
+
line.includes('ReferenceError') ||
|
|
189
|
+
line.includes('SyntaxError'));
|
|
190
|
+
if (errorLines.length > 0) {
|
|
191
|
+
return this.cleanErrorMessage(errorLines[0]);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
// Try to extract from Claude's analysis in output
|
|
195
|
+
const analysisPatterns = [
|
|
196
|
+
/(?:the (?:issue|problem|error|bug) (?:is|was))\s+(.+?)(?:\.|$)/i,
|
|
197
|
+
/(?:found|identified|discovered)\s+(?:a|an|the)?\s*(.+?)(?:error|issue|problem|bug)(.+?)(?:\.|$)/i,
|
|
198
|
+
/(?:this|the)\s+(?:error|issue|problem|bug)\s+(?:is|was)\s+(?:caused by|due to)\s+(.+?)(?:\.|$)/i,
|
|
199
|
+
];
|
|
200
|
+
for (const pattern of analysisPatterns) {
|
|
201
|
+
const match = output.match(pattern);
|
|
202
|
+
if (match) {
|
|
203
|
+
return this.cleanErrorMessage(match[1] + (match[2] || ''));
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return 'Issue identified and resolved by Claude';
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Extract what Claude did to fix the issue
|
|
210
|
+
*/
|
|
211
|
+
extractSolution(output) {
|
|
212
|
+
const solutions = [];
|
|
213
|
+
// Look for explicit "I did X" or "Fixed by" patterns
|
|
214
|
+
const actionPatterns = [
|
|
215
|
+
/(?:I |I've |I have )?(added|created|updated|modified|fixed|changed|removed|replaced|implemented|refactored)\s+(.+?)(?:\.|$)/gi,
|
|
216
|
+
/(?:by |through )(adding|creating|updating|modifying|fixing|changing|removing|replacing|implementing)\s+(.+?)(?:\.|$)/gi,
|
|
217
|
+
];
|
|
218
|
+
for (const pattern of actionPatterns) {
|
|
219
|
+
let match;
|
|
220
|
+
while ((match = pattern.exec(output)) !== null) {
|
|
221
|
+
const action = match[1].toLowerCase();
|
|
222
|
+
const target = match[2].trim();
|
|
223
|
+
if (target.length > 5 && target.length < 150) {
|
|
224
|
+
solutions.push(`${this.capitalizeFirst(action)} ${target}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
// Look for bullet-point style lists
|
|
229
|
+
const bulletMatches = output.match(/^[\s]*[-•*]\s+(.+?)$/gm);
|
|
230
|
+
if (bulletMatches) {
|
|
231
|
+
for (const bullet of bulletMatches) {
|
|
232
|
+
const text = bullet.replace(/^[\s]*[-•*]\s+/, '').trim();
|
|
233
|
+
if (text.length > 10 && text.length < 150 && !solutions.includes(text)) {
|
|
234
|
+
solutions.push(text);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
// Deduplicate and limit
|
|
239
|
+
const uniqueSolutions = [...new Set(solutions)].slice(0, 5);
|
|
240
|
+
if (uniqueSolutions.length === 0) {
|
|
241
|
+
return ['Applied fixes based on error analysis'];
|
|
242
|
+
}
|
|
243
|
+
return uniqueSolutions;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Extract reasoning for why this approach was chosen
|
|
247
|
+
*/
|
|
248
|
+
extractReasoning(output) {
|
|
249
|
+
const reasoningPatterns = [
|
|
250
|
+
/(?:because|since|as)\s+(.+?)(?:\.|$)/gi,
|
|
251
|
+
/(?:this approach|this solution|this fix)\s+(?:is|was)\s+(?:chosen|used|preferred)\s+(?:because|since|as)\s+(.+?)(?:\.|$)/gi,
|
|
252
|
+
/(?:the reason|reasoning)\s+(?:is|was|for this)\s+(.+?)(?:\.|$)/gi,
|
|
253
|
+
/(?:I chose|I decided|I opted)\s+(?:to|for)\s+(.+?)\s+(?:because|since|as)\s+(.+?)(?:\.|$)/gi,
|
|
254
|
+
];
|
|
255
|
+
for (const pattern of reasoningPatterns) {
|
|
256
|
+
const match = output.match(pattern);
|
|
257
|
+
if (match) {
|
|
258
|
+
const reason = (match[1] + (match[2] || '')).trim();
|
|
259
|
+
if (reason.length > 20 && reason.length < 300) {
|
|
260
|
+
return this.capitalizeFirst(reason);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return 'Minimal changes applied to fix the identified issue while preserving existing functionality';
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Extract per-file change explanations
|
|
268
|
+
*/
|
|
269
|
+
extractFileChanges(output, changedFiles) {
|
|
270
|
+
const fileChanges = [];
|
|
271
|
+
for (const file of changedFiles) {
|
|
272
|
+
const fileName = file.split('/').pop() || file;
|
|
273
|
+
const filePattern = new RegExp(`(?:in|to|for|modified|updated|changed|edited)\\s+[\`']?${this.escapeRegex(fileName)}[\`']?[^.]*?(?:to|by|:)?\\s*([^.]+)`, 'i');
|
|
274
|
+
const match = output.match(filePattern);
|
|
275
|
+
if (match) {
|
|
276
|
+
fileChanges.push({
|
|
277
|
+
path: file,
|
|
278
|
+
changes: this.capitalizeFirst(match[1].trim()),
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
// Generate generic description based on file type
|
|
283
|
+
fileChanges.push({
|
|
284
|
+
path: file,
|
|
285
|
+
changes: this.generateFileChangeDescription(file),
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return fileChanges;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Identify common patterns/issues from the output
|
|
293
|
+
*/
|
|
294
|
+
identifyPatterns(output, problem) {
|
|
295
|
+
const patterns = [];
|
|
296
|
+
const combined = (output + ' ' + problem).toLowerCase();
|
|
297
|
+
const patternKeywords = {
|
|
298
|
+
'null': 'Null/undefined check',
|
|
299
|
+
'undefined': 'Null/undefined check',
|
|
300
|
+
'type error': 'Type mismatch',
|
|
301
|
+
'typeerror': 'Type mismatch',
|
|
302
|
+
'missing import': 'Missing import',
|
|
303
|
+
'import': 'Import issue',
|
|
304
|
+
'async': 'Async/await handling',
|
|
305
|
+
'await': 'Async/await handling',
|
|
306
|
+
'race condition': 'Race condition',
|
|
307
|
+
'timeout': 'Timeout handling',
|
|
308
|
+
'memory': 'Memory management',
|
|
309
|
+
'syntax': 'Syntax error',
|
|
310
|
+
'lint': 'Linting issue',
|
|
311
|
+
'deprecated': 'Deprecated API usage',
|
|
312
|
+
'version': 'Version compatibility',
|
|
313
|
+
'dependency': 'Dependency issue',
|
|
314
|
+
'circular': 'Circular dependency',
|
|
315
|
+
'permission': 'Permission issue',
|
|
316
|
+
'authentication': 'Authentication issue',
|
|
317
|
+
'authorization': 'Authorization issue',
|
|
318
|
+
};
|
|
319
|
+
for (const [keyword, pattern] of Object.entries(patternKeywords)) {
|
|
320
|
+
if (combined.includes(keyword) && !patterns.includes(pattern)) {
|
|
321
|
+
patterns.push(pattern);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
return patterns.slice(0, 3);
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Generate prevention tips based on identified patterns
|
|
328
|
+
*/
|
|
329
|
+
generatePreventionTips(patterns, problem) {
|
|
330
|
+
const tips = [];
|
|
331
|
+
const tipMap = {
|
|
332
|
+
'Null/undefined check': 'Use optional chaining (?.) and nullish coalescing (??) operators for safer property access',
|
|
333
|
+
'Type mismatch': 'Enable strict TypeScript mode and add explicit type annotations',
|
|
334
|
+
'Missing import': 'Configure your IDE to auto-import and catch missing imports at lint time',
|
|
335
|
+
'Import issue': 'Organize imports consistently and use absolute imports where possible',
|
|
336
|
+
'Async/await handling': 'Always handle promise rejections with try/catch or .catch()',
|
|
337
|
+
'Race condition': 'Use proper synchronization mechanisms or sequential execution for dependent operations',
|
|
338
|
+
'Timeout handling': 'Implement retry logic with exponential backoff for network operations',
|
|
339
|
+
'Memory management': 'Clean up subscriptions and event listeners in component unmount/cleanup',
|
|
340
|
+
'Syntax error': 'Enable auto-formatting and lint-on-save in your editor',
|
|
341
|
+
'Linting issue': 'Run linter as part of your pre-commit hooks',
|
|
342
|
+
'Deprecated API usage': 'Keep dependencies up to date and monitor deprecation warnings',
|
|
343
|
+
'Version compatibility': 'Pin dependency versions and test upgrades in isolation',
|
|
344
|
+
'Dependency issue': 'Regularly audit and update dependencies with npm audit',
|
|
345
|
+
'Circular dependency': 'Use dependency injection or restructure modules to break cycles',
|
|
346
|
+
'Permission issue': 'Implement proper role-based access control from the start',
|
|
347
|
+
'Authentication issue': 'Use established auth libraries and follow security best practices',
|
|
348
|
+
'Authorization issue': 'Implement authorization checks at both API and UI layers',
|
|
349
|
+
};
|
|
350
|
+
for (const pattern of patterns) {
|
|
351
|
+
if (tipMap[pattern]) {
|
|
352
|
+
tips.push(tipMap[pattern]);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return tips.slice(0, 2);
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Generate a one-line summary
|
|
359
|
+
*/
|
|
360
|
+
generateSummary(problem, solution) {
|
|
361
|
+
if (solution.length > 0) {
|
|
362
|
+
return `${solution[0]} to resolve: ${problem.slice(0, 80)}${problem.length > 80 ? '...' : ''}`;
|
|
363
|
+
}
|
|
364
|
+
return `Resolved: ${problem.slice(0, 100)}${problem.length > 100 ? '...' : ''}`;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Generate generic file change description based on file type
|
|
368
|
+
*/
|
|
369
|
+
generateFileChangeDescription(filePath) {
|
|
370
|
+
const ext = filePath.split('.').pop()?.toLowerCase();
|
|
371
|
+
const descriptions = {
|
|
372
|
+
'ts': 'Updated TypeScript code',
|
|
373
|
+
'tsx': 'Updated React component',
|
|
374
|
+
'js': 'Updated JavaScript code',
|
|
375
|
+
'jsx': 'Updated React component',
|
|
376
|
+
'json': 'Updated configuration',
|
|
377
|
+
'css': 'Updated styles',
|
|
378
|
+
'scss': 'Updated styles',
|
|
379
|
+
'html': 'Updated markup',
|
|
380
|
+
'md': 'Updated documentation',
|
|
381
|
+
'yml': 'Updated configuration',
|
|
382
|
+
'yaml': 'Updated configuration',
|
|
383
|
+
};
|
|
384
|
+
return descriptions[ext || ''] || 'Modified file';
|
|
385
|
+
}
|
|
386
|
+
// Utility functions
|
|
387
|
+
cleanErrorMessage(msg) {
|
|
388
|
+
return msg
|
|
389
|
+
.replace(/^\s*(?:error|Error|ERROR):\s*/i, '')
|
|
390
|
+
.replace(/\s+/g, ' ')
|
|
391
|
+
.trim()
|
|
392
|
+
.slice(0, 200);
|
|
393
|
+
}
|
|
394
|
+
capitalizeFirst(str) {
|
|
395
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
396
|
+
}
|
|
397
|
+
escapeRegex(str) {
|
|
398
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
export const insightsExtractor = new InsightsExtractor();
|
|
402
|
+
//# sourceMappingURL=insights-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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9B,MAAM,EAAE,uBAAuB;SAChC,CAAC;QACF,OAAO,YAAY,CAAC,GAAG,IAAI,EAAE,CAAC,IAAI,eAAe,CAAC;IACpD,CAAC;IAED,oBAAoB;IACZ,iBAAiB,CAAC,GAAW;QACnC,OAAO,GAAG;aACP,OAAO,CAAC,gCAAgC,EAAE,EAAE,CAAC;aAC7C,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;aACpB,IAAI,EAAE;aACN,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACnB,CAAC;IAEO,eAAe,CAAC,GAAW;QACjC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC;IAEO,WAAW,CAAC,GAAW;QAC7B,OAAO,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;CACF;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OPS-01: Simple structured logger for better observability.
|
|
3
|
+
* Provides consistent log formatting with timestamps and levels.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* import { logger } from './logger.js';
|
|
7
|
+
* logger.info('Server started', { port: 8787 });
|
|
8
|
+
* logger.error('Failed to connect', { error: err.message });
|
|
9
|
+
*/
|
|
10
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
11
|
+
/**
|
|
12
|
+
* Create a logger instance for a specific module.
|
|
13
|
+
* This provides consistent logging with the module name automatically included.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createLogger(module: string): {
|
|
16
|
+
debug: (message: string, data?: Record<string, unknown>) => void;
|
|
17
|
+
info: (message: string, data?: Record<string, unknown>) => void;
|
|
18
|
+
warn: (message: string, data?: Record<string, unknown>) => void;
|
|
19
|
+
error: (message: string, data?: Record<string, unknown>) => void;
|
|
20
|
+
};
|
|
21
|
+
export declare const logger: {
|
|
22
|
+
debug: (message: string, data?: Record<string, unknown>) => void;
|
|
23
|
+
info: (message: string, data?: Record<string, unknown>) => void;
|
|
24
|
+
warn: (message: string, data?: Record<string, unknown>) => void;
|
|
25
|
+
error: (message: string, data?: Record<string, unknown>) => void;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAiE3D;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM;qBAEtB,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;oBACvC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;oBACtC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;qBACrC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;EAE1D;AAGD,eAAO,MAAM,MAAM;qBARE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;oBACvC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;oBACtC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;qBACrC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAKlB,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OPS-01: Simple structured logger for better observability.
|
|
3
|
+
* Provides consistent log formatting with timestamps and levels.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* import { logger } from './logger.js';
|
|
7
|
+
* logger.info('Server started', { port: 8787 });
|
|
8
|
+
* logger.error('Failed to connect', { error: err.message });
|
|
9
|
+
*/
|
|
10
|
+
// Log level priority (lower = more verbose)
|
|
11
|
+
const LOG_LEVELS = {
|
|
12
|
+
debug: 0,
|
|
13
|
+
info: 1,
|
|
14
|
+
warn: 2,
|
|
15
|
+
error: 3,
|
|
16
|
+
};
|
|
17
|
+
// Current log level from environment (default: info)
|
|
18
|
+
const currentLevel = process.env.LOG_LEVEL || 'info';
|
|
19
|
+
const currentLevelPriority = LOG_LEVELS[currentLevel] ?? LOG_LEVELS.info;
|
|
20
|
+
// Output format: 'json' for structured, 'text' for human-readable
|
|
21
|
+
const outputFormat = process.env.LOG_FORMAT || 'text';
|
|
22
|
+
function formatLogEntry(entry) {
|
|
23
|
+
if (outputFormat === 'json') {
|
|
24
|
+
return JSON.stringify(entry);
|
|
25
|
+
}
|
|
26
|
+
// Text format: [timestamp] [LEVEL] [module] message {data}
|
|
27
|
+
const levelStr = entry.level.toUpperCase().padEnd(5);
|
|
28
|
+
const dataStr = entry.data ? ` ${JSON.stringify(entry.data)}` : '';
|
|
29
|
+
return `[${entry.timestamp}] [${levelStr}] [${entry.module}] ${entry.message}${dataStr}`;
|
|
30
|
+
}
|
|
31
|
+
function log(level, module, message, data) {
|
|
32
|
+
// Skip if below current log level
|
|
33
|
+
if (LOG_LEVELS[level] < currentLevelPriority) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const entry = {
|
|
37
|
+
timestamp: new Date().toISOString(),
|
|
38
|
+
level,
|
|
39
|
+
module,
|
|
40
|
+
message,
|
|
41
|
+
...(data && { data }),
|
|
42
|
+
};
|
|
43
|
+
const formatted = formatLogEntry(entry);
|
|
44
|
+
// Use appropriate console method
|
|
45
|
+
switch (level) {
|
|
46
|
+
case 'error':
|
|
47
|
+
console.error(formatted);
|
|
48
|
+
break;
|
|
49
|
+
case 'warn':
|
|
50
|
+
console.warn(formatted);
|
|
51
|
+
break;
|
|
52
|
+
default:
|
|
53
|
+
console.log(formatted);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Create a logger instance for a specific module.
|
|
58
|
+
* This provides consistent logging with the module name automatically included.
|
|
59
|
+
*/
|
|
60
|
+
export function createLogger(module) {
|
|
61
|
+
return {
|
|
62
|
+
debug: (message, data) => log('debug', module, message, data),
|
|
63
|
+
info: (message, data) => log('info', module, message, data),
|
|
64
|
+
warn: (message, data) => log('warn', module, message, data),
|
|
65
|
+
error: (message, data) => log('error', module, message, data),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
// Default logger for quick usage
|
|
69
|
+
export const logger = createLogger('app');
|
|
70
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAYH,4CAA4C;AAC5C,MAAM,UAAU,GAA6B;IAC3C,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;CACT,CAAC;AAEF,qDAAqD;AACrD,MAAM,YAAY,GAAI,OAAO,CAAC,GAAG,CAAC,SAAsB,IAAI,MAAM,CAAC;AACnE,MAAM,oBAAoB,GAAG,UAAU,CAAC,YAAY,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC;AAEzE,kEAAkE;AAClE,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,MAAM,CAAC;AAEtD,SAAS,cAAc,CAAC,KAAe;IACrC,IAAI,YAAY,KAAK,MAAM,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,2DAA2D;IAC3D,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;I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E,OAAO,EAAE,IAAI,CAAC;QAC7F,IAAI,EAAE,CAAC,OAAe,EAAE,IAA8B,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;QAC7F,KAAK,EAAE,CAAC,OAAe,EAAE,IAA8B,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;KAChG,CAAC;AACJ,CAAC;AAED,iCAAiC;AACjC,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ChildProcess } from 'child_process';
|
|
2
|
+
export interface RunOptions {
|
|
3
|
+
cwd: string;
|
|
4
|
+
timeout?: number;
|
|
5
|
+
logFile?: string;
|
|
6
|
+
env?: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
export interface RunResult {
|
|
9
|
+
exitCode: number | null;
|
|
10
|
+
stdout: string;
|
|
11
|
+
stderr: string;
|
|
12
|
+
killed: boolean;
|
|
13
|
+
error?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare class ProcessRunner {
|
|
16
|
+
private runningProcesses;
|
|
17
|
+
run(command: string, options: RunOptions): Promise<RunResult>;
|
|
18
|
+
startServer(command: string, options: RunOptions): {
|
|
19
|
+
processId: string;
|
|
20
|
+
process: ChildProcess;
|
|
21
|
+
};
|
|
22
|
+
killProcess(processId: string): Promise<void>;
|
|
23
|
+
killAllProcesses(): Promise<void[]>;
|
|
24
|
+
getRunningProcessIds(): string[];
|
|
25
|
+
}
|
|
26
|
+
export declare const processRunner: ProcessRunner;
|
|
27
|
+
//# sourceMappingURL=process-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-runner.d.ts","sourceRoot":"","sources":["../../src/core/process-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,YAAY,EAAE,MAAM,eAAe,CAAC;AAKpD,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,gBAAgB,CAAwC;IAE1D,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;IAsFnE,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,YAAY,CAAA;KAAE;IA0C/F,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA0B7C,gBAAgB,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAOnC,oBAAoB,IAAI,MAAM,EAAE;CAGjC;AAED,eAAO,MAAM,aAAa,eAAsB,CAAC"}
|