@houtini/lm 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/CHANGELOG.md +273 -0
- package/LICENSE +21 -0
- package/README.md +203 -0
- package/dist/cache/analysis-cache.d.ts +33 -0
- package/dist/cache/analysis-cache.d.ts.map +1 -0
- package/dist/cache/analysis-cache.js +56 -0
- package/dist/cache/analysis-cache.js.map +1 -0
- package/dist/cache/cache-manager.d.ts +29 -0
- package/dist/cache/cache-manager.d.ts.map +1 -0
- package/dist/cache/cache-manager.js +85 -0
- package/dist/cache/cache-manager.js.map +1 -0
- package/dist/cache/index.d.ts +16 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +17 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/prompt-cache.d.ts +33 -0
- package/dist/cache/prompt-cache.d.ts.map +1 -0
- package/dist/cache/prompt-cache.js +61 -0
- package/dist/cache/prompt-cache.js.map +1 -0
- package/dist/config.d.ts +43 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +70 -0
- package/dist/config.js.map +1 -0
- package/dist/core/ThreeStagePromptManager.d.ts +39 -0
- package/dist/core/ThreeStagePromptManager.d.ts.map +1 -0
- package/dist/core/ThreeStagePromptManager.js +176 -0
- package/dist/core/ThreeStagePromptManager.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +230 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/base-plugin.d.ts +47 -0
- package/dist/plugins/base-plugin.d.ts.map +1 -0
- package/dist/plugins/base-plugin.js +90 -0
- package/dist/plugins/base-plugin.js.map +1 -0
- package/dist/plugins/index.d.ts +58 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +161 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/types.d.ts +5 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +5 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/prompts/analyze/code-quality.d.ts +116 -0
- package/dist/prompts/analyze/code-quality.d.ts.map +1 -0
- package/dist/prompts/analyze/code-quality.js +433 -0
- package/dist/prompts/analyze/code-quality.js.map +1 -0
- package/dist/prompts/analyze/compare-integration.d.ts +130 -0
- package/dist/prompts/analyze/compare-integration.d.ts.map +1 -0
- package/dist/prompts/analyze/compare-integration.js +543 -0
- package/dist/prompts/analyze/compare-integration.js.map +1 -0
- package/dist/prompts/analyze/count-files.d.ts +109 -0
- package/dist/prompts/analyze/count-files.d.ts.map +1 -0
- package/dist/prompts/analyze/count-files.js +399 -0
- package/dist/prompts/analyze/count-files.js.map +1 -0
- package/dist/prompts/analyze/database-queries.d.ts +156 -0
- package/dist/prompts/analyze/database-queries.d.ts.map +1 -0
- package/dist/prompts/analyze/database-queries.js +759 -0
- package/dist/prompts/analyze/database-queries.js.map +1 -0
- package/dist/prompts/analyze/dependencies.d.ts +97 -0
- package/dist/prompts/analyze/dependencies.d.ts.map +1 -0
- package/dist/prompts/analyze/dependencies.js +333 -0
- package/dist/prompts/analyze/dependencies.js.map +1 -0
- package/dist/prompts/analyze/diff-signatures.d.ts +139 -0
- package/dist/prompts/analyze/diff-signatures.d.ts.map +1 -0
- package/dist/prompts/analyze/diff-signatures.js +702 -0
- package/dist/prompts/analyze/diff-signatures.js.map +1 -0
- package/dist/prompts/analyze/find-patterns.d.ts +128 -0
- package/dist/prompts/analyze/find-patterns.d.ts.map +1 -0
- package/dist/prompts/analyze/find-patterns.js +520 -0
- package/dist/prompts/analyze/find-patterns.js.map +1 -0
- package/dist/prompts/analyze/find-unused-css.d.ts +151 -0
- package/dist/prompts/analyze/find-unused-css.d.ts.map +1 -0
- package/dist/prompts/analyze/find-unused-css.js +754 -0
- package/dist/prompts/analyze/find-unused-css.js.map +1 -0
- package/dist/prompts/analyze/n8n-workflow.d.ts +137 -0
- package/dist/prompts/analyze/n8n-workflow.d.ts.map +1 -0
- package/dist/prompts/analyze/n8n-workflow.js +529 -0
- package/dist/prompts/analyze/n8n-workflow.js.map +1 -0
- package/dist/prompts/analyze/project-structure.d.ts +126 -0
- package/dist/prompts/analyze/project-structure.d.ts.map +1 -0
- package/dist/prompts/analyze/project-structure.js +569 -0
- package/dist/prompts/analyze/project-structure.js.map +1 -0
- package/dist/prompts/analyze/security-audit.d.ts +142 -0
- package/dist/prompts/analyze/security-audit.d.ts.map +1 -0
- package/dist/prompts/analyze/security-audit.js +637 -0
- package/dist/prompts/analyze/security-audit.js.map +1 -0
- package/dist/prompts/analyze/single-file.d.ts +162 -0
- package/dist/prompts/analyze/single-file.d.ts.map +1 -0
- package/dist/prompts/analyze/single-file.js +665 -0
- package/dist/prompts/analyze/single-file.js.map +1 -0
- package/dist/prompts/analyze/trace-execution.d.ts +126 -0
- package/dist/prompts/analyze/trace-execution.d.ts.map +1 -0
- package/dist/prompts/analyze/trace-execution.js +609 -0
- package/dist/prompts/analyze/trace-execution.js.map +1 -0
- package/dist/prompts/analyze/wordpress-plugin-audit.d.ts +116 -0
- package/dist/prompts/analyze/wordpress-plugin-audit.d.ts.map +1 -0
- package/dist/prompts/analyze/wordpress-plugin-audit.js +454 -0
- package/dist/prompts/analyze/wordpress-plugin-audit.js.map +1 -0
- package/dist/prompts/analyze/wordpress-security.d.ts +146 -0
- package/dist/prompts/analyze/wordpress-security.d.ts.map +1 -0
- package/dist/prompts/analyze/wordpress-security.js +698 -0
- package/dist/prompts/analyze/wordpress-security.js.map +1 -0
- package/dist/prompts/analyze/wordpress-theme-audit.d.ts +114 -0
- package/dist/prompts/analyze/wordpress-theme-audit.d.ts.map +1 -0
- package/dist/prompts/analyze/wordpress-theme-audit.js +538 -0
- package/dist/prompts/analyze/wordpress-theme-audit.js.map +1 -0
- package/dist/prompts/custom/custom-prompt.d.ts +135 -0
- package/dist/prompts/custom/custom-prompt.d.ts.map +1 -0
- package/dist/prompts/custom/custom-prompt.js +419 -0
- package/dist/prompts/custom/custom-prompt.js.map +1 -0
- package/dist/prompts/fun/arcade-game.d.ts +152 -0
- package/dist/prompts/fun/arcade-game.d.ts.map +1 -0
- package/dist/prompts/fun/arcade-game.js +653 -0
- package/dist/prompts/fun/arcade-game.js.map +1 -0
- package/dist/prompts/fun/create_text_adventure.d.ts +100 -0
- package/dist/prompts/fun/create_text_adventure.d.ts.map +1 -0
- package/dist/prompts/fun/create_text_adventure.js +397 -0
- package/dist/prompts/fun/create_text_adventure.js.map +1 -0
- package/dist/prompts/fun/css-art-generator.d.ts +168 -0
- package/dist/prompts/fun/css-art-generator.d.ts.map +1 -0
- package/dist/prompts/fun/css-art-generator.js +827 -0
- package/dist/prompts/fun/css-art-generator.js.map +1 -0
- package/dist/prompts/generate/project-documentation.d.ts +137 -0
- package/dist/prompts/generate/project-documentation.d.ts.map +1 -0
- package/dist/prompts/generate/project-documentation.js +666 -0
- package/dist/prompts/generate/project-documentation.js.map +1 -0
- package/dist/prompts/generate/refactoring.d.ts +164 -0
- package/dist/prompts/generate/refactoring.d.ts.map +1 -0
- package/dist/prompts/generate/refactoring.js +621 -0
- package/dist/prompts/generate/refactoring.js.map +1 -0
- package/dist/prompts/generate/responsive-component.d.ts +147 -0
- package/dist/prompts/generate/responsive-component.d.ts.map +1 -0
- package/dist/prompts/generate/responsive-component.js +955 -0
- package/dist/prompts/generate/responsive-component.js.map +1 -0
- package/dist/prompts/generate/typescript-conversion.d.ts +144 -0
- package/dist/prompts/generate/typescript-conversion.d.ts.map +1 -0
- package/dist/prompts/generate/typescript-conversion.js +527 -0
- package/dist/prompts/generate/typescript-conversion.js.map +1 -0
- package/dist/prompts/generate/unit-tests.d.ts +139 -0
- package/dist/prompts/generate/unit-tests.d.ts.map +1 -0
- package/dist/prompts/generate/unit-tests.js +578 -0
- package/dist/prompts/generate/unit-tests.js.map +1 -0
- package/dist/prompts/generate/wordpress-plugin.d.ts +179 -0
- package/dist/prompts/generate/wordpress-plugin.d.ts.map +1 -0
- package/dist/prompts/generate/wordpress-plugin.js +763 -0
- package/dist/prompts/generate/wordpress-plugin.js.map +1 -0
- package/dist/prompts/generate/wordpress-theme-from-static.d.ts +177 -0
- package/dist/prompts/generate/wordpress-theme-from-static.d.ts.map +1 -0
- package/dist/prompts/generate/wordpress-theme-from-static.js +695 -0
- package/dist/prompts/generate/wordpress-theme-from-static.js.map +1 -0
- package/dist/prompts/shared/cache-manager.d.ts +45 -0
- package/dist/prompts/shared/cache-manager.d.ts.map +1 -0
- package/dist/prompts/shared/cache-manager.js +129 -0
- package/dist/prompts/shared/cache-manager.js.map +1 -0
- package/dist/prompts/shared/helpers.d.ts +39 -0
- package/dist/prompts/shared/helpers.d.ts.map +1 -0
- package/dist/prompts/shared/helpers.js +151 -0
- package/dist/prompts/shared/helpers.js.map +1 -0
- package/dist/prompts/shared/templates.d.ts +35 -0
- package/dist/prompts/shared/templates.d.ts.map +1 -0
- package/dist/prompts/shared/templates.js +77 -0
- package/dist/prompts/shared/templates.js.map +1 -0
- package/dist/prompts/shared/types.d.ts +112 -0
- package/dist/prompts/shared/types.d.ts.map +1 -0
- package/dist/prompts/shared/types.js +5 -0
- package/dist/prompts/shared/types.js.map +1 -0
- package/dist/prompts/system/find-unused-files.d.ts +106 -0
- package/dist/prompts/system/find-unused-files.d.ts.map +1 -0
- package/dist/prompts/system/find-unused-files.js +353 -0
- package/dist/prompts/system/find-unused-files.js.map +1 -0
- package/dist/security/index.d.ts +39 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +46 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/integration-helpers.d.ts +121 -0
- package/dist/security/integration-helpers.d.ts.map +1 -0
- package/dist/security/integration-helpers.js +190 -0
- package/dist/security/integration-helpers.js.map +1 -0
- package/dist/security/output-encoder.d.ts +94 -0
- package/dist/security/output-encoder.d.ts.map +1 -0
- package/dist/security/output-encoder.js +295 -0
- package/dist/security/output-encoder.js.map +1 -0
- package/dist/security/prompt-injection-guard.d.ts +59 -0
- package/dist/security/prompt-injection-guard.d.ts.map +1 -0
- package/dist/security/prompt-injection-guard.js +249 -0
- package/dist/security/prompt-injection-guard.js.map +1 -0
- package/dist/security/sanitisation.d.ts +67 -0
- package/dist/security/sanitisation.d.ts.map +1 -0
- package/dist/security/sanitisation.js +398 -0
- package/dist/security/sanitisation.js.map +1 -0
- package/dist/security/security-service.d.ts +103 -0
- package/dist/security/security-service.d.ts.map +1 -0
- package/dist/security/security-service.js +303 -0
- package/dist/security/security-service.js.map +1 -0
- package/dist/security-config.d.ts +45 -0
- package/dist/security-config.d.ts.map +1 -0
- package/dist/security-config.js +63 -0
- package/dist/security-config.js.map +1 -0
- package/dist/system/function-list.d.ts +61 -0
- package/dist/system/function-list.d.ts.map +1 -0
- package/dist/system/function-list.js +111 -0
- package/dist/system/function-list.js.map +1 -0
- package/dist/system/function-registry.d.ts +23 -0
- package/dist/system/function-registry.d.ts.map +1 -0
- package/dist/system/function-registry.js +136 -0
- package/dist/system/function-registry.js.map +1 -0
- package/dist/system/health-check.d.ts +33 -0
- package/dist/system/health-check.d.ts.map +1 -0
- package/dist/system/health-check.js +98 -0
- package/dist/system/health-check.js.map +1 -0
- package/dist/system/path-resolver.d.ts +55 -0
- package/dist/system/path-resolver.d.ts.map +1 -0
- package/dist/system/path-resolver.js +90 -0
- package/dist/system/path-resolver.js.map +1 -0
- package/dist/templates/plugin-template.d.ts +121 -0
- package/dist/templates/plugin-template.d.ts.map +1 -0
- package/dist/templates/plugin-template.js +450 -0
- package/dist/templates/plugin-template.js.map +1 -0
- package/dist/types/chunking-types.d.ts +88 -0
- package/dist/types/chunking-types.d.ts.map +1 -0
- package/dist/types/chunking-types.js +18 -0
- package/dist/types/chunking-types.js.map +1 -0
- package/dist/types/prompt-stages.d.ts +42 -0
- package/dist/types/prompt-stages.d.ts.map +1 -0
- package/dist/types/prompt-stages.js +6 -0
- package/dist/types/prompt-stages.js.map +1 -0
- package/dist/types.d.ts +46 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/css-parser.d.ts +26 -0
- package/dist/utils/css-parser.d.ts.map +1 -0
- package/dist/utils/css-parser.js +117 -0
- package/dist/utils/css-parser.js.map +1 -0
- package/dist/utils/path-resolver.d.ts +13 -0
- package/dist/utils/path-resolver.d.ts.map +1 -0
- package/dist/utils/path-resolver.js +78 -0
- package/dist/utils/path-resolver.js.map +1 -0
- package/dist/utils/plugin-utilities.d.ts +171 -0
- package/dist/utils/plugin-utilities.d.ts.map +1 -0
- package/dist/utils/plugin-utilities.js +221 -0
- package/dist/utils/plugin-utilities.js.map +1 -0
- package/dist/utils/streamHandler.d.ts +3 -0
- package/dist/utils/streamHandler.d.ts.map +1 -0
- package/dist/utils/streamHandler.js +137 -0
- package/dist/utils/streamHandler.js.map +1 -0
- package/dist/validation/output-validator.d.ts +136 -0
- package/dist/validation/output-validator.d.ts.map +1 -0
- package/dist/validation/output-validator.js +262 -0
- package/dist/validation/output-validator.js.map +1 -0
- package/dist/validation/response-factory.d.ts +44 -0
- package/dist/validation/response-factory.d.ts.map +1 -0
- package/dist/validation/response-factory.js +202 -0
- package/dist/validation/response-factory.js.map +1 -0
- package/dist/validation/schemas.d.ts +519 -0
- package/dist/validation/schemas.d.ts.map +1 -0
- package/dist/validation/schemas.js +6 -0
- package/dist/validation/schemas.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,621 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin Template - Modern v4.2 (Single Source of Truth)
|
|
3
|
+
*
|
|
4
|
+
* Universal template that intelligently handles both single-file and multi-file analysis
|
|
5
|
+
* Automatically detects analysis type based on provided parameters
|
|
6
|
+
*
|
|
7
|
+
* Copy this template for creating any new plugin - it adapts to your needs
|
|
8
|
+
*/
|
|
9
|
+
import { BasePlugin } from '../../plugins/base-plugin.js';
|
|
10
|
+
import { ThreeStagePromptManager } from '../../core/ThreeStagePromptManager.js';
|
|
11
|
+
import { withSecurity } from '../../security/integration-helpers.js';
|
|
12
|
+
import { readFileContent } from '../shared/helpers.js';
|
|
13
|
+
import { ModelSetup, ResponseProcessor, ParameterValidator, ErrorHandler, MultiFileAnalysis } from '../../utils/plugin-utilities.js';
|
|
14
|
+
import { getAnalysisCache } from '../../cache/index.js';
|
|
15
|
+
// Common Node.js modules - Use these instead of require()
|
|
16
|
+
import { basename, dirname, extname, relative } from 'path';
|
|
17
|
+
import { readFile, stat } from 'fs/promises';
|
|
18
|
+
export class RefactoringAnalyzer extends BasePlugin {
|
|
19
|
+
constructor() {
|
|
20
|
+
super();
|
|
21
|
+
this.name = 'suggest_refactoring';
|
|
22
|
+
this.category = 'generate';
|
|
23
|
+
this.description = 'Analyze code and suggest refactoring improvements with project-specific patterns (handles both single and multi-file)';
|
|
24
|
+
// Universal parameter set - supports both single and multi-file scenarios
|
|
25
|
+
this.parameters = {
|
|
26
|
+
// Single-file parameters
|
|
27
|
+
code: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
description: 'The code to analyze for refactoring (for single-file analysis)',
|
|
30
|
+
required: false
|
|
31
|
+
},
|
|
32
|
+
filePath: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
description: 'Path to single file to refactor',
|
|
35
|
+
required: false
|
|
36
|
+
},
|
|
37
|
+
// Multi-file parameters
|
|
38
|
+
projectPath: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
description: 'Path to project root (for multi-file refactoring analysis)',
|
|
41
|
+
required: false
|
|
42
|
+
},
|
|
43
|
+
files: {
|
|
44
|
+
type: 'array',
|
|
45
|
+
description: 'Array of specific file paths (for multi-file analysis)',
|
|
46
|
+
required: false,
|
|
47
|
+
items: { type: 'string' }
|
|
48
|
+
},
|
|
49
|
+
maxDepth: {
|
|
50
|
+
type: 'number',
|
|
51
|
+
description: 'Maximum directory depth for multi-file discovery (1-5)',
|
|
52
|
+
required: false,
|
|
53
|
+
default: 3
|
|
54
|
+
},
|
|
55
|
+
// Universal parameters
|
|
56
|
+
language: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
description: 'Programming language',
|
|
59
|
+
required: false,
|
|
60
|
+
default: 'javascript'
|
|
61
|
+
},
|
|
62
|
+
analysisDepth: {
|
|
63
|
+
type: 'string',
|
|
64
|
+
description: 'Level of analysis detail',
|
|
65
|
+
enum: ['basic', 'detailed', 'comprehensive'],
|
|
66
|
+
default: 'detailed',
|
|
67
|
+
required: false
|
|
68
|
+
},
|
|
69
|
+
analysisType: {
|
|
70
|
+
type: 'string',
|
|
71
|
+
description: 'Type of refactoring to focus on',
|
|
72
|
+
enum: ['readability', 'performance', 'comprehensive'],
|
|
73
|
+
default: 'comprehensive',
|
|
74
|
+
required: false
|
|
75
|
+
},
|
|
76
|
+
// Refactoring-specific parameters
|
|
77
|
+
focusAreas: {
|
|
78
|
+
type: 'array',
|
|
79
|
+
description: 'Areas to focus on for refactoring',
|
|
80
|
+
required: false,
|
|
81
|
+
items: {
|
|
82
|
+
type: 'string',
|
|
83
|
+
enum: ['readability', 'performance', 'maintainability', 'testability', 'security', 'type-safety', 'error-handling', 'logging', 'documentation']
|
|
84
|
+
},
|
|
85
|
+
default: ['readability', 'maintainability']
|
|
86
|
+
},
|
|
87
|
+
context: {
|
|
88
|
+
type: 'object',
|
|
89
|
+
description: 'Optional context for project-specific refactoring',
|
|
90
|
+
required: false,
|
|
91
|
+
properties: {
|
|
92
|
+
projectType: {
|
|
93
|
+
type: 'string',
|
|
94
|
+
enum: ['wordpress-plugin', 'wordpress-theme', 'react-app', 'react-component', 'node-api', 'n8n-node', 'n8n-workflow', 'html-component', 'browser-extension', 'cli-tool', 'generic'],
|
|
95
|
+
description: 'Project type for appropriate patterns'
|
|
96
|
+
},
|
|
97
|
+
preserveApi: {
|
|
98
|
+
type: 'boolean',
|
|
99
|
+
description: 'Maintain backward compatibility',
|
|
100
|
+
default: true
|
|
101
|
+
},
|
|
102
|
+
modernizationLevel: {
|
|
103
|
+
type: 'string',
|
|
104
|
+
enum: ['conservative', 'moderate', 'aggressive'],
|
|
105
|
+
description: 'How aggressively to modernize code',
|
|
106
|
+
default: 'moderate'
|
|
107
|
+
},
|
|
108
|
+
targetComplexity: {
|
|
109
|
+
type: 'number',
|
|
110
|
+
description: 'Target cyclomatic complexity',
|
|
111
|
+
default: 10
|
|
112
|
+
},
|
|
113
|
+
standards: {
|
|
114
|
+
type: 'array',
|
|
115
|
+
items: { type: 'string' },
|
|
116
|
+
description: 'Coding standards to follow'
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
this.analysisCache = getAnalysisCache();
|
|
122
|
+
this.multiFileAnalysis = new MultiFileAnalysis();
|
|
123
|
+
// Cache and analysis utilities are initialized above
|
|
124
|
+
}
|
|
125
|
+
async execute(params, llmClient) {
|
|
126
|
+
return await withSecurity(this, params, llmClient, async (secureParams) => {
|
|
127
|
+
try {
|
|
128
|
+
// 1. Auto-detect analysis mode based on parameters
|
|
129
|
+
const analysisMode = this.detectAnalysisMode(secureParams);
|
|
130
|
+
// 2. Validate parameters based on detected mode
|
|
131
|
+
this.validateParameters(secureParams, analysisMode);
|
|
132
|
+
// 3. Setup model
|
|
133
|
+
const { model, contextLength } = await ModelSetup.getReadyModel(llmClient);
|
|
134
|
+
// 4. Route to appropriate analysis method
|
|
135
|
+
if (analysisMode === 'single-file') {
|
|
136
|
+
return await this.executeSingleFileAnalysis(secureParams, model, contextLength);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
return await this.executeMultiFileAnalysis(secureParams, model, contextLength);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
return ErrorHandler.createExecutionError('suggest_refactoring', error);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Auto-detect whether this is single-file or multi-file analysis
|
|
149
|
+
*
|
|
150
|
+
* For refactoring: Single-file is primary use case, multi-file for project-wide patterns
|
|
151
|
+
*/
|
|
152
|
+
detectAnalysisMode(params) {
|
|
153
|
+
// Single-file indicators take priority (avoids default parameter issues)
|
|
154
|
+
if (params.code || params.filePath) {
|
|
155
|
+
return 'single-file';
|
|
156
|
+
}
|
|
157
|
+
// Multi-file indicators
|
|
158
|
+
if (params.projectPath || params.files) {
|
|
159
|
+
return 'multi-file';
|
|
160
|
+
}
|
|
161
|
+
// Default to single-file for refactoring (most common use case)
|
|
162
|
+
return 'single-file';
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Validate parameters based on detected analysis mode
|
|
166
|
+
*/
|
|
167
|
+
validateParameters(params, mode) {
|
|
168
|
+
if (mode === 'single-file') {
|
|
169
|
+
ParameterValidator.validateCodeOrFile(params);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
ParameterValidator.validateProjectPath(params);
|
|
173
|
+
ParameterValidator.validateDepth(params);
|
|
174
|
+
}
|
|
175
|
+
// Universal validations
|
|
176
|
+
ParameterValidator.validateEnum(params, 'analysisType', ['readability', 'performance', 'comprehensive']);
|
|
177
|
+
ParameterValidator.validateEnum(params, 'analysisDepth', ['basic', 'detailed', 'comprehensive']);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Execute single-file analysis
|
|
181
|
+
*/
|
|
182
|
+
async executeSingleFileAnalysis(params, model, contextLength) {
|
|
183
|
+
// Process single file input
|
|
184
|
+
let codeToAnalyze = params.code;
|
|
185
|
+
if (params.filePath) {
|
|
186
|
+
codeToAnalyze = await readFileContent(params.filePath);
|
|
187
|
+
}
|
|
188
|
+
// Generate prompt stages for single file
|
|
189
|
+
const promptStages = this.getSingleFilePromptStages({
|
|
190
|
+
...params,
|
|
191
|
+
code: codeToAnalyze
|
|
192
|
+
});
|
|
193
|
+
// Execute with appropriate method
|
|
194
|
+
const promptManager = new ThreeStagePromptManager(contextLength);
|
|
195
|
+
const needsChunking = promptManager.needsChunking(promptStages);
|
|
196
|
+
if (needsChunking) {
|
|
197
|
+
const conversation = promptManager.createChunkedConversation(promptStages);
|
|
198
|
+
const messages = [
|
|
199
|
+
conversation.systemMessage,
|
|
200
|
+
...conversation.dataMessages,
|
|
201
|
+
conversation.analysisMessage
|
|
202
|
+
];
|
|
203
|
+
return await ResponseProcessor.executeChunked(messages, model, contextLength, 'suggest_refactoring', 'single');
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
return await ResponseProcessor.executeDirect(promptStages, model, contextLength, 'suggest_refactoring');
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Execute multi-file analysis
|
|
211
|
+
*/
|
|
212
|
+
async executeMultiFileAnalysis(params, model, contextLength) {
|
|
213
|
+
// Discover files
|
|
214
|
+
let filesToAnalyze = params.files ||
|
|
215
|
+
await this.discoverRelevantFiles(params.projectPath, params.maxDepth, params.analysisType);
|
|
216
|
+
// Perform multi-file analysis with caching
|
|
217
|
+
const analysisResult = await this.performMultiFileAnalysis(filesToAnalyze, params, model, contextLength);
|
|
218
|
+
// Generate prompt stages for multi-file
|
|
219
|
+
const promptStages = this.getMultiFilePromptStages({
|
|
220
|
+
...params,
|
|
221
|
+
analysisResult,
|
|
222
|
+
fileCount: filesToAnalyze.length
|
|
223
|
+
});
|
|
224
|
+
// Always use chunking for multi-file
|
|
225
|
+
const promptManager = new ThreeStagePromptManager(contextLength);
|
|
226
|
+
const conversation = promptManager.createChunkedConversation(promptStages);
|
|
227
|
+
const messages = [
|
|
228
|
+
conversation.systemMessage,
|
|
229
|
+
...conversation.dataMessages,
|
|
230
|
+
conversation.analysisMessage
|
|
231
|
+
];
|
|
232
|
+
return await ResponseProcessor.executeChunked(messages, model, contextLength, 'suggest_refactoring', 'multifile');
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Implement single-file refactoring prompt stages
|
|
236
|
+
*/
|
|
237
|
+
getSingleFilePromptStages(params) {
|
|
238
|
+
const { code, language, analysisDepth, analysisType, focusAreas, context } = params;
|
|
239
|
+
const projectType = context?.projectType || 'generic';
|
|
240
|
+
const modernizationLevel = context?.modernizationLevel || 'moderate';
|
|
241
|
+
const preserveApi = context?.preserveApi !== false;
|
|
242
|
+
const targetComplexity = context?.targetComplexity || 10;
|
|
243
|
+
const systemAndContext = `You are a world-class software architect and refactoring expert with 20+ years of experience. Your mission is to transform code into masterpieces of clarity, performance, and maintainability.
|
|
244
|
+
|
|
245
|
+
**REFACTORING CONTEXT:**
|
|
246
|
+
- Language: ${language}
|
|
247
|
+
- Project Type: ${projectType}
|
|
248
|
+
- Analysis Focus: ${analysisType} (${analysisDepth} analysis)
|
|
249
|
+
- Focus Areas: ${focusAreas?.join(', ') || 'readability, maintainability'}
|
|
250
|
+
- API Preservation: ${preserveApi ? 'CRITICAL - Maintain backward compatibility' : 'Breaking changes allowed'}
|
|
251
|
+
- Modernization Level: ${modernizationLevel}
|
|
252
|
+
- Target Complexity: ≤${targetComplexity} cyclomatic complexity
|
|
253
|
+
- Standards: ${context?.standards?.join(', ') || 'Clean Code, SOLID principles'}
|
|
254
|
+
|
|
255
|
+
**YOUR EXPERTISE:**
|
|
256
|
+
${this.getProjectSpecificExpertise(projectType, language)}
|
|
257
|
+
|
|
258
|
+
**REFACTORING PHILOSOPHY:**
|
|
259
|
+
- Code should read like well-written prose
|
|
260
|
+
- Every line should have a clear purpose
|
|
261
|
+
- Complexity is the enemy of maintainability
|
|
262
|
+
- Performance optimizations must be measurable
|
|
263
|
+
- Security should be built-in, not bolted-on
|
|
264
|
+
|
|
265
|
+
You identify anti-patterns like a detective finds clues, and you craft solutions that developers will thank you for years later.`;
|
|
266
|
+
const dataPayload = `**CODE TO REFACTOR:**
|
|
267
|
+
|
|
268
|
+
\`\`\`${language}
|
|
269
|
+
${code}
|
|
270
|
+
\`\`\`
|
|
271
|
+
|
|
272
|
+
**CONTEXT CLUES:**
|
|
273
|
+
- File appears to be: ${this.inferCodePurpose(code, language)}
|
|
274
|
+
- Estimated complexity: ${this.estimateComplexity(code)}
|
|
275
|
+
- Key patterns detected: ${this.detectPatterns(code, language)}`;
|
|
276
|
+
const outputInstructions = `**DELIVER COMPREHENSIVE REFACTORING ANALYSIS:**
|
|
277
|
+
|
|
278
|
+
## 🔍 Code Health Assessment
|
|
279
|
+
**Current State Analysis:**
|
|
280
|
+
- Code smells identified (be specific with line references)
|
|
281
|
+
- Complexity metrics (cyclomatic, cognitive load)
|
|
282
|
+
- Maintainability score and reasoning
|
|
283
|
+
- Performance bottlenecks (if ${focusAreas?.includes('performance') ? 'applicable' : 'obvious'})
|
|
284
|
+
- Security vulnerabilities (if ${focusAreas?.includes('security') ? 'applicable' : 'critical'})
|
|
285
|
+
|
|
286
|
+
## ✨ Refactoring Roadmap
|
|
287
|
+
**Priority 1 (Critical Issues):**
|
|
288
|
+
- Issue: [Specific problem with line numbers]
|
|
289
|
+
- Impact: [How it hurts ${focusAreas?.join(', ')}]
|
|
290
|
+
- Solution: [Exact refactoring technique]
|
|
291
|
+
- Code Example: [Before/after snippet]
|
|
292
|
+
|
|
293
|
+
**Priority 2 (Significant Improvements):**
|
|
294
|
+
[Same structure as Priority 1]
|
|
295
|
+
|
|
296
|
+
**Priority 3 (Polish & Optimization):**
|
|
297
|
+
[Same structure as Priority 1]
|
|
298
|
+
|
|
299
|
+
## 🏗️ Architecture Recommendations
|
|
300
|
+
${this.getArchitectureGuidelines(projectType, modernizationLevel)}
|
|
301
|
+
|
|
302
|
+
## 📝 Refactored Code Examples
|
|
303
|
+
Show complete before/after examples for major improvements:
|
|
304
|
+
|
|
305
|
+
\`\`\`${language}
|
|
306
|
+
// BEFORE (problematic)
|
|
307
|
+
[original code section]
|
|
308
|
+
|
|
309
|
+
// AFTER (refactored)
|
|
310
|
+
[improved code section]
|
|
311
|
+
\`\`\`
|
|
312
|
+
|
|
313
|
+
## 📊 Improvement Metrics
|
|
314
|
+
- Complexity reduction: [current] → [target]
|
|
315
|
+
- Readability improvement: [specific gains]
|
|
316
|
+
- Performance impact: ${focusAreas?.includes('performance') ? '[measurable improvements]' : '[maintainability focused]'}
|
|
317
|
+
- Test coverage considerations
|
|
318
|
+
- ${preserveApi ? 'Backward compatibility: [how preserved]' : 'Breaking changes: [migration path]'}
|
|
319
|
+
|
|
320
|
+
## 🚀 Implementation Strategy
|
|
321
|
+
**Phase 1 (Foundation):** [Safe, non-breaking improvements]
|
|
322
|
+
**Phase 2 (Enhancement):** [Structural improvements]
|
|
323
|
+
**Phase 3 (Optimization):** [Performance and advanced patterns]
|
|
324
|
+
|
|
325
|
+
**Migration Notes:** ${preserveApi ? 'All changes maintain API compatibility' : 'Breaking changes documented with migration guide'}
|
|
326
|
+
|
|
327
|
+
Focus on providing actionable, copy-paste ready improvements that make developers say "Wow, this is so much cleaner!"`;
|
|
328
|
+
return { systemAndContext, dataPayload, outputInstructions };
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Implement multi-file refactoring prompt stages
|
|
332
|
+
*/
|
|
333
|
+
getMultiFilePromptStages(params) {
|
|
334
|
+
const { analysisResult, analysisType, analysisDepth, fileCount, focusAreas, context } = params;
|
|
335
|
+
const projectType = context?.projectType || 'generic';
|
|
336
|
+
const systemAndContext = `You are a senior software architect specializing in large-scale refactoring and system design. Your expertise lies in identifying cross-file patterns, architectural debt, and system-wide improvements.
|
|
337
|
+
|
|
338
|
+
**PROJECT-WIDE REFACTORING CONTEXT:**
|
|
339
|
+
- Project Type: ${projectType}
|
|
340
|
+
- Files Analyzed: ${fileCount}
|
|
341
|
+
- Analysis Focus: ${analysisType} (${analysisDepth} analysis)
|
|
342
|
+
- Focus Areas: ${focusAreas?.join(', ') || 'architecture, maintainability'}
|
|
343
|
+
- Scope: Cross-file patterns and system architecture
|
|
344
|
+
|
|
345
|
+
**YOUR ARCHITECTURAL EXPERTISE:**
|
|
346
|
+
${this.getProjectSpecificExpertise(projectType, 'multi-file')}
|
|
347
|
+
|
|
348
|
+
**SYSTEM-LEVEL REFACTORING PHILOSOPHY:**
|
|
349
|
+
- Architecture should support change, not resist it
|
|
350
|
+
- Coupling should be loose, cohesion should be high
|
|
351
|
+
- Patterns should emerge naturally, not be forced
|
|
352
|
+
- Dependencies should flow in one direction
|
|
353
|
+
- Complexity should be managed, not just moved around
|
|
354
|
+
|
|
355
|
+
You see the forest, not just the trees, and you design systems that scale gracefully.`;
|
|
356
|
+
const dataPayload = `**PROJECT ANALYSIS RESULTS:**
|
|
357
|
+
|
|
358
|
+
${JSON.stringify(analysisResult, null, 2)}
|
|
359
|
+
|
|
360
|
+
**SYSTEM OVERVIEW:**
|
|
361
|
+
- Total Files: ${fileCount}
|
|
362
|
+
- Project Structure: ${this.analyzeProjectStructure(analysisResult)}
|
|
363
|
+
- Key Dependencies: ${this.identifyKeyDependencies(analysisResult)}`;
|
|
364
|
+
const outputInstructions = `**DELIVER PROJECT-WIDE REFACTORING STRATEGY:**
|
|
365
|
+
|
|
366
|
+
## 🏗️ Architectural Assessment
|
|
367
|
+
**Current Architecture Analysis:**
|
|
368
|
+
- System boundaries and responsibilities
|
|
369
|
+
- Coupling and cohesion patterns
|
|
370
|
+
- Dependency direction and cycles
|
|
371
|
+
- Cross-cutting concerns identification
|
|
372
|
+
|
|
373
|
+
## 🎯 Cross-File Refactoring Opportunities
|
|
374
|
+
**Pattern-Level Issues:**
|
|
375
|
+
- Anti-pattern: [Specific architectural problem]
|
|
376
|
+
- Affected Files: [List of files showing this pattern]
|
|
377
|
+
- Impact: [How it hurts system ${focusAreas?.join(', ')}]
|
|
378
|
+
- Solution: [Architectural refactoring approach]
|
|
379
|
+
- Migration Strategy: [Step-by-step approach]
|
|
380
|
+
|
|
381
|
+
## 📁 File Organization Recommendations
|
|
382
|
+
**Directory Structure Improvements:**
|
|
383
|
+
- Current issues with organization
|
|
384
|
+
- Proposed structure changes
|
|
385
|
+
- File naming conventions
|
|
386
|
+
- Module boundary definitions
|
|
387
|
+
|
|
388
|
+
## 🔄 Dependency Refactoring
|
|
389
|
+
**Dependency Health:**
|
|
390
|
+
- Circular dependency issues
|
|
391
|
+
- Missing abstractions
|
|
392
|
+
- Coupling hotspots
|
|
393
|
+
- Dependency injection opportunities
|
|
394
|
+
|
|
395
|
+
## 📋 System-Wide Improvements
|
|
396
|
+
**Cross-Cutting Refactoring:**
|
|
397
|
+
1. **Error Handling Standardization**
|
|
398
|
+
2. **Logging Strategy Unification**
|
|
399
|
+
3. **Configuration Management**
|
|
400
|
+
4. **Testing Strategy Alignment**
|
|
401
|
+
5. **Performance Monitoring Integration**
|
|
402
|
+
|
|
403
|
+
## 🚀 Implementation Roadmap
|
|
404
|
+
**Phase 1 (Foundation):** [Architecture groundwork]
|
|
405
|
+
- Files to refactor: [specific list]
|
|
406
|
+
- Dependencies to restructure
|
|
407
|
+
- New abstractions to introduce
|
|
408
|
+
|
|
409
|
+
**Phase 2 (Systematization):** [Pattern application]
|
|
410
|
+
- Cross-file pattern implementation
|
|
411
|
+
- Interface standardization
|
|
412
|
+
- Testing infrastructure
|
|
413
|
+
|
|
414
|
+
**Phase 3 (Optimization):** [Performance and scaling]
|
|
415
|
+
- Performance bottleneck resolution
|
|
416
|
+
- Scalability improvements
|
|
417
|
+
- Monitoring and observability
|
|
418
|
+
|
|
419
|
+
## 📊 Project Health Metrics
|
|
420
|
+
- Architecture debt reduction
|
|
421
|
+
- Coupling metrics improvement
|
|
422
|
+
- Code reuse opportunities
|
|
423
|
+
- Maintainability index gains
|
|
424
|
+
|
|
425
|
+
Provide a roadmap that transforms the entire codebase into a well-architected, maintainable system that developers love working with.`;
|
|
426
|
+
return { systemAndContext, dataPayload, outputInstructions };
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Implement for backwards compatibility
|
|
430
|
+
* The system still expects this method, so we intelligently route to the appropriate stages
|
|
431
|
+
*/
|
|
432
|
+
getPromptStages(params) {
|
|
433
|
+
const mode = this.detectAnalysisMode(params);
|
|
434
|
+
if (mode === 'single-file') {
|
|
435
|
+
return this.getSingleFilePromptStages(params);
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
return this.getMultiFilePromptStages(params);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
// Multi-file helper methods
|
|
442
|
+
async discoverRelevantFiles(projectPath, maxDepth, analysisType) {
|
|
443
|
+
const extensions = this.getFileExtensions(analysisType);
|
|
444
|
+
return await this.multiFileAnalysis.discoverFiles(projectPath, extensions, maxDepth);
|
|
445
|
+
}
|
|
446
|
+
async performMultiFileAnalysis(files, params, model, contextLength) {
|
|
447
|
+
const cacheKey = this.analysisCache.generateKey('suggest_refactoring', params, files);
|
|
448
|
+
const cached = await this.analysisCache.get(cacheKey);
|
|
449
|
+
if (cached)
|
|
450
|
+
return cached;
|
|
451
|
+
const fileAnalysisResults = await this.multiFileAnalysis.analyzeBatch(files, (file) => this.analyzeIndividualFile(file, params, model), contextLength);
|
|
452
|
+
// Aggregate results into proper analysis result format
|
|
453
|
+
const aggregatedResult = {
|
|
454
|
+
summary: `Refactoring analysis of ${files.length} files`,
|
|
455
|
+
findings: fileAnalysisResults,
|
|
456
|
+
data: {
|
|
457
|
+
fileCount: files.length,
|
|
458
|
+
totalSize: fileAnalysisResults.reduce((sum, result) => sum + (result.size || 0), 0),
|
|
459
|
+
codeHealth: this.assessCodeHealth(fileAnalysisResults),
|
|
460
|
+
architecturalPatterns: this.identifyArchitecturalPatterns(fileAnalysisResults)
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
await this.analysisCache.cacheAnalysis(cacheKey, aggregatedResult, {
|
|
464
|
+
modelUsed: model.identifier || 'unknown',
|
|
465
|
+
executionTime: Date.now() - Date.now(), // TODO: Track actual execution time
|
|
466
|
+
timestamp: new Date().toISOString()
|
|
467
|
+
});
|
|
468
|
+
return aggregatedResult;
|
|
469
|
+
}
|
|
470
|
+
async analyzeIndividualFile(file, params, model) {
|
|
471
|
+
const content = await readFile(file, 'utf-8');
|
|
472
|
+
const stats = await stat(file);
|
|
473
|
+
return {
|
|
474
|
+
filePath: file,
|
|
475
|
+
fileName: basename(file),
|
|
476
|
+
size: content.length,
|
|
477
|
+
lines: content.split('\n').length,
|
|
478
|
+
extension: extname(file),
|
|
479
|
+
relativePath: relative(params.projectPath || '', file),
|
|
480
|
+
complexity: this.estimateComplexity(content),
|
|
481
|
+
patterns: this.detectPatterns(content, extname(file).substring(1)),
|
|
482
|
+
purpose: this.inferCodePurpose(content, extname(file).substring(1))
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
getFileExtensions(analysisType) {
|
|
486
|
+
const extensionMap = {
|
|
487
|
+
'readability': ['.js', '.ts', '.jsx', '.tsx', '.py', '.java', '.cs', '.php', '.rb'],
|
|
488
|
+
'performance': ['.js', '.ts', '.py', '.java', '.cs', '.cpp', '.c', '.php'],
|
|
489
|
+
'comprehensive': ['.js', '.ts', '.jsx', '.tsx', '.py', '.java', '.cs', '.php', '.rb', '.go', '.rs', '.cpp', '.c']
|
|
490
|
+
};
|
|
491
|
+
return extensionMap[analysisType] || extensionMap.comprehensive;
|
|
492
|
+
}
|
|
493
|
+
// Helper methods for intelligent analysis
|
|
494
|
+
getProjectSpecificExpertise(projectType, language) {
|
|
495
|
+
const expertise = {
|
|
496
|
+
'wordpress-plugin': 'WordPress hooks, actions, filters, security (nonces, sanitization), database optimization, WP coding standards',
|
|
497
|
+
'wordpress-theme': 'Template hierarchy, theme.json, block patterns, accessibility, performance optimization, SEO',
|
|
498
|
+
'react-app': 'Component composition, hooks optimization, state management, performance (memoization, lazy loading)',
|
|
499
|
+
'react-component': 'Reusable patterns, prop design, accessibility, testing strategies, Storybook integration',
|
|
500
|
+
'node-api': 'RESTful design, middleware patterns, error handling, security (authentication, validation), performance',
|
|
501
|
+
'n8n-node': 'Webhook handling, credential management, error recovery, data transformation, batch processing',
|
|
502
|
+
'n8n-workflow': 'Node orchestration, error handling, data flow optimization, conditional logic, loop efficiency',
|
|
503
|
+
'html-component': 'Semantic HTML, CSS architecture, accessibility (ARIA), progressive enhancement, performance',
|
|
504
|
+
'browser-extension': 'Content scripts, message passing, permission management, security, cross-browser compatibility',
|
|
505
|
+
'cli-tool': 'Argument parsing, error handling, progress indication, cross-platform compatibility, performance',
|
|
506
|
+
'generic': 'Clean code principles, SOLID design, design patterns, testing strategies, documentation'
|
|
507
|
+
};
|
|
508
|
+
return expertise[projectType] || expertise.generic;
|
|
509
|
+
}
|
|
510
|
+
getArchitectureGuidelines(projectType, modernizationLevel) {
|
|
511
|
+
const base = `**Design Patterns to Consider:**
|
|
512
|
+
- Strategy Pattern for algorithm variations
|
|
513
|
+
- Observer Pattern for event handling
|
|
514
|
+
- Factory Pattern for object creation
|
|
515
|
+
- Repository Pattern for data access`;
|
|
516
|
+
const modernization = modernizationLevel === 'aggressive' ? `
|
|
517
|
+
**Modernization Opportunities:**
|
|
518
|
+
- Latest language features and syntax
|
|
519
|
+
- Modern async patterns (async/await over callbacks)
|
|
520
|
+
- Module system upgrades
|
|
521
|
+
- Framework pattern updates` : '';
|
|
522
|
+
const projectSpecific = {
|
|
523
|
+
'wordpress-plugin': `
|
|
524
|
+
**WordPress Architecture:**
|
|
525
|
+
- Proper hook organization and priority
|
|
526
|
+
- Object-oriented plugin structure
|
|
527
|
+
- Namespace implementation
|
|
528
|
+
- Admin interface separation`,
|
|
529
|
+
'react-app': `
|
|
530
|
+
**React Architecture:**
|
|
531
|
+
- Component composition patterns
|
|
532
|
+
- Custom hooks for logic reuse
|
|
533
|
+
- Context API for state management
|
|
534
|
+
- Error boundary implementation`,
|
|
535
|
+
'node-api': `
|
|
536
|
+
**API Architecture:**
|
|
537
|
+
- Layered architecture (controller, service, repository)
|
|
538
|
+
- Middleware chain optimization
|
|
539
|
+
- Input validation strategies
|
|
540
|
+
- Response consistency patterns`
|
|
541
|
+
};
|
|
542
|
+
return base + modernization + (projectSpecific[projectType] || '');
|
|
543
|
+
}
|
|
544
|
+
estimateComplexity(code) {
|
|
545
|
+
const lines = code.split('\n').length;
|
|
546
|
+
const functions = (code.match(/function|=>|def |class /g) || []).length;
|
|
547
|
+
const conditions = (code.match(/if|else|switch|case|for|while|catch/g) || []).length;
|
|
548
|
+
if (conditions > functions * 3)
|
|
549
|
+
return 'High';
|
|
550
|
+
if (conditions > functions * 1.5)
|
|
551
|
+
return 'Moderate';
|
|
552
|
+
return 'Low';
|
|
553
|
+
}
|
|
554
|
+
detectPatterns(code, language) {
|
|
555
|
+
const patterns = [];
|
|
556
|
+
if (code.includes('class ') || code.includes('function '))
|
|
557
|
+
patterns.push('Object-Oriented');
|
|
558
|
+
if (code.includes('=>') || code.includes('map(') || code.includes('filter('))
|
|
559
|
+
patterns.push('Functional');
|
|
560
|
+
if (code.includes('async') || code.includes('await') || code.includes('Promise'))
|
|
561
|
+
patterns.push('Asynchronous');
|
|
562
|
+
if (code.includes('try') || code.includes('catch'))
|
|
563
|
+
patterns.push('Error-Handling');
|
|
564
|
+
if (code.includes('test(') || code.includes('describe(') || code.includes('it('))
|
|
565
|
+
patterns.push('Testing');
|
|
566
|
+
return patterns;
|
|
567
|
+
}
|
|
568
|
+
inferCodePurpose(code, language) {
|
|
569
|
+
if (code.includes('router') || code.includes('app.get') || code.includes('express'))
|
|
570
|
+
return 'API/Server';
|
|
571
|
+
if (code.includes('component') || code.includes('jsx') || code.includes('useState'))
|
|
572
|
+
return 'UI Component';
|
|
573
|
+
if (code.includes('test') || code.includes('spec') || code.includes('describe'))
|
|
574
|
+
return 'Test Suite';
|
|
575
|
+
if (code.includes('config') || code.includes('settings') || code.includes('env'))
|
|
576
|
+
return 'Configuration';
|
|
577
|
+
if (code.includes('util') || code.includes('helper') || code.includes('lib'))
|
|
578
|
+
return 'Utility/Helper';
|
|
579
|
+
return 'Business Logic';
|
|
580
|
+
}
|
|
581
|
+
assessCodeHealth(results) {
|
|
582
|
+
return {
|
|
583
|
+
averageComplexity: results.reduce((sum, r) => sum + (r.complexity === 'High' ? 3 : r.complexity === 'Moderate' ? 2 : 1), 0) / results.length,
|
|
584
|
+
largestFiles: results.sort((a, b) => b.size - a.size).slice(0, 3),
|
|
585
|
+
patternDistribution: this.aggregatePatterns(results)
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
identifyArchitecturalPatterns(results) {
|
|
589
|
+
const allPatterns = results.flatMap(r => r.patterns || []);
|
|
590
|
+
const uniquePatterns = [...new Set(allPatterns)];
|
|
591
|
+
return uniquePatterns;
|
|
592
|
+
}
|
|
593
|
+
aggregatePatterns(results) {
|
|
594
|
+
const patternCount = {};
|
|
595
|
+
results.forEach(result => {
|
|
596
|
+
(result.patterns || []).forEach((pattern) => {
|
|
597
|
+
patternCount[pattern] = (patternCount[pattern] || 0) + 1;
|
|
598
|
+
});
|
|
599
|
+
});
|
|
600
|
+
return patternCount;
|
|
601
|
+
}
|
|
602
|
+
analyzeProjectStructure(analysisResult) {
|
|
603
|
+
// Simple structure analysis based on file paths
|
|
604
|
+
const files = analysisResult.findings || [];
|
|
605
|
+
const directories = [...new Set(files.map((f) => dirname(f.relativePath || f.filePath)))];
|
|
606
|
+
return `${directories.length} directories, organized by ${directories.includes('src') ? 'source structure' : 'functional areas'}`;
|
|
607
|
+
}
|
|
608
|
+
identifyKeyDependencies(analysisResult) {
|
|
609
|
+
// Extract patterns that suggest dependencies
|
|
610
|
+
const findings = analysisResult.findings || [];
|
|
611
|
+
const imports = findings.flatMap((f) => f.patterns || []).filter((p) => p.includes('import') || p.includes('require'));
|
|
612
|
+
return imports.length > 0 ? `${imports.length} import patterns detected` : 'Self-contained modules';
|
|
613
|
+
}
|
|
614
|
+
generateCacheKey(files, params) {
|
|
615
|
+
const fileHash = files.join('|');
|
|
616
|
+
const paramHash = JSON.stringify(params);
|
|
617
|
+
return `${fileHash}_${paramHash}`.substring(0, 64);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
export default RefactoringAnalyzer;
|
|
621
|
+
//# sourceMappingURL=refactoring.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refactoring.js","sourceRoot":"","sources":["../../../src/prompts/generate/refactoring.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EA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