@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,450 @@
|
|
|
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
|
+
* ⚠️ CRITICAL: OUTPUT INSTRUCTIONS MUST USE NATURAL LANGUAGE, NOT JSON SCHEMAS! ⚠️
|
|
10
|
+
*
|
|
11
|
+
* The ResponseFactory automatically handles all JSON formatting. If you put JSON schemas
|
|
12
|
+
* in outputInstructions, you'll get double-processing and escaped content. Always use
|
|
13
|
+
* natural language instructions that describe WHAT you want, not HOW to format it.
|
|
14
|
+
*
|
|
15
|
+
* ✅ GOOD: "Provide a comprehensive analysis including structure, quality metrics..."
|
|
16
|
+
* ❌ BAD: '{ "summary": "...", "structure": {...} }' (causes escaping issues)
|
|
17
|
+
*/
|
|
18
|
+
// TEMPLATE: Update these import paths based on where you place your plugin:
|
|
19
|
+
// For analyze/ plugins: use '../../plugins/', '../shared/', '../../core/', etc.
|
|
20
|
+
// For generate/ plugins: use '../../plugins/', '../shared/', '../../core/', etc.
|
|
21
|
+
// For system/ plugins: use '../../plugins/', '../shared/', '../../core/', etc.
|
|
22
|
+
// For custom/ plugins: use '../../plugins/', '../shared/', '../../core/', etc.
|
|
23
|
+
// For fun/ plugins: use '../../plugins/', '../shared/', '../../core/', etc.
|
|
24
|
+
// THESE ARE TEMPLATE INSTRUCTIONS - The actual imports below are correct for this template file
|
|
25
|
+
import { BasePlugin } from '../plugins/base-plugin.js';
|
|
26
|
+
import { ThreeStagePromptManager } from '../core/ThreeStagePromptManager.js';
|
|
27
|
+
import { withSecurity } from '../security/integration-helpers.js';
|
|
28
|
+
import { readFileContent } from '../prompts/shared/helpers.js';
|
|
29
|
+
import { ModelSetup, ResponseProcessor, ParameterValidator, ErrorHandler, MultiFileAnalysis } from '../utils/plugin-utilities.js';
|
|
30
|
+
import { getAnalysisCache } from '../cache/index.js';
|
|
31
|
+
// Common Node.js modules - Use these instead of require()
|
|
32
|
+
import { basename, extname, relative } from 'path';
|
|
33
|
+
export class TEMPLATE_UniversalPlugin extends BasePlugin {
|
|
34
|
+
constructor() {
|
|
35
|
+
super();
|
|
36
|
+
this.name = 'TEMPLATE_function_name';
|
|
37
|
+
this.category = 'analyze'; // TEMPLATE: Change to 'analyze' | 'generate' | 'multifile' | 'system' | 'custom'
|
|
38
|
+
this.description = 'TEMPLATE: Describe what this plugin does (handles both single and multi-file)';
|
|
39
|
+
// Universal parameter set - supports both single and multi-file scenarios
|
|
40
|
+
this.parameters = {
|
|
41
|
+
// Single-file parameters
|
|
42
|
+
code: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
description: 'The code to analyze (for single-file analysis)',
|
|
45
|
+
required: false
|
|
46
|
+
},
|
|
47
|
+
filePath: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
description: 'Path to single file to analyze',
|
|
50
|
+
required: false
|
|
51
|
+
},
|
|
52
|
+
// Multi-file parameters
|
|
53
|
+
projectPath: {
|
|
54
|
+
type: 'string',
|
|
55
|
+
description: 'Path to project root (for multi-file analysis)',
|
|
56
|
+
required: false
|
|
57
|
+
},
|
|
58
|
+
files: {
|
|
59
|
+
type: 'array',
|
|
60
|
+
description: 'Array of specific file paths (for multi-file analysis)',
|
|
61
|
+
required: false,
|
|
62
|
+
items: { type: 'string' }
|
|
63
|
+
},
|
|
64
|
+
maxDepth: {
|
|
65
|
+
type: 'number',
|
|
66
|
+
description: 'Maximum directory depth for multi-file discovery (1-5)',
|
|
67
|
+
required: false,
|
|
68
|
+
default: 3
|
|
69
|
+
},
|
|
70
|
+
// Universal parameters
|
|
71
|
+
language: {
|
|
72
|
+
type: 'string',
|
|
73
|
+
description: 'Programming language',
|
|
74
|
+
required: false,
|
|
75
|
+
default: 'javascript'
|
|
76
|
+
},
|
|
77
|
+
analysisDepth: {
|
|
78
|
+
type: 'string',
|
|
79
|
+
description: 'Level of analysis detail',
|
|
80
|
+
enum: ['basic', 'detailed', 'comprehensive'],
|
|
81
|
+
default: 'detailed',
|
|
82
|
+
required: false
|
|
83
|
+
},
|
|
84
|
+
analysisType: {
|
|
85
|
+
type: 'string',
|
|
86
|
+
description: 'Type of analysis to perform',
|
|
87
|
+
enum: ['TEMPLATE_type1', 'TEMPLATE_type2', 'comprehensive'],
|
|
88
|
+
default: 'comprehensive',
|
|
89
|
+
required: false
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
this.analysisCache = getAnalysisCache();
|
|
93
|
+
this.multiFileAnalysis = new MultiFileAnalysis();
|
|
94
|
+
// Cache and analysis utilities are initialized above
|
|
95
|
+
}
|
|
96
|
+
async execute(params, llmClient) {
|
|
97
|
+
return await withSecurity(this, params, llmClient, async (secureParams) => {
|
|
98
|
+
try {
|
|
99
|
+
// 1. Auto-detect analysis mode based on parameters
|
|
100
|
+
const analysisMode = this.detectAnalysisMode(secureParams);
|
|
101
|
+
// 2. Validate parameters based on detected mode
|
|
102
|
+
this.validateParameters(secureParams, analysisMode);
|
|
103
|
+
// 3. Setup model
|
|
104
|
+
const { model, contextLength } = await ModelSetup.getReadyModel(llmClient);
|
|
105
|
+
// 4. Route to appropriate analysis method
|
|
106
|
+
if (analysisMode === 'single-file') {
|
|
107
|
+
return await this.executeSingleFileAnalysis(secureParams, model, contextLength);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
return await this.executeMultiFileAnalysis(secureParams, model, contextLength);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
return ErrorHandler.createExecutionError('TEMPLATE_function_name', error);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Auto-detect whether this is single-file or multi-file analysis
|
|
120
|
+
*
|
|
121
|
+
* DETECTION GUIDE:
|
|
122
|
+
* Single-file: code, filePath provided → analyze individual file
|
|
123
|
+
* Multi-file: projectPath, files, maxDepth provided → analyze project/multiple files
|
|
124
|
+
* Default: Choose based on your plugin's primary use case
|
|
125
|
+
*/
|
|
126
|
+
detectAnalysisMode(params) {
|
|
127
|
+
// Single-file indicators take priority (avoids default parameter issues)
|
|
128
|
+
if (params.code || params.filePath) {
|
|
129
|
+
return 'single-file';
|
|
130
|
+
}
|
|
131
|
+
// Multi-file indicators
|
|
132
|
+
if (params.projectPath || params.files) {
|
|
133
|
+
return 'multi-file';
|
|
134
|
+
}
|
|
135
|
+
// TEMPLATE: Choose your default based on plugin purpose
|
|
136
|
+
// For file-focused plugins: return 'single-file'
|
|
137
|
+
// For project-focused plugins: return 'multi-file'
|
|
138
|
+
return 'single-file';
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Validate parameters based on detected analysis mode
|
|
142
|
+
*/
|
|
143
|
+
validateParameters(params, mode) {
|
|
144
|
+
if (mode === 'single-file') {
|
|
145
|
+
ParameterValidator.validateCodeOrFile(params);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
ParameterValidator.validateProjectPath(params);
|
|
149
|
+
ParameterValidator.validateDepth(params);
|
|
150
|
+
}
|
|
151
|
+
// Universal validations
|
|
152
|
+
ParameterValidator.validateEnum(params, 'analysisType', ['TEMPLATE_type1', 'TEMPLATE_type2', 'comprehensive']);
|
|
153
|
+
ParameterValidator.validateEnum(params, 'analysisDepth', ['basic', 'detailed', 'comprehensive']);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Execute single-file analysis
|
|
157
|
+
*/
|
|
158
|
+
async executeSingleFileAnalysis(params, model, contextLength) {
|
|
159
|
+
// Process single file input
|
|
160
|
+
let codeToAnalyze = params.code;
|
|
161
|
+
if (params.filePath) {
|
|
162
|
+
codeToAnalyze = await readFileContent(params.filePath);
|
|
163
|
+
}
|
|
164
|
+
// Generate prompt stages for single file
|
|
165
|
+
const promptStages = this.getSingleFilePromptStages({
|
|
166
|
+
...params,
|
|
167
|
+
code: codeToAnalyze
|
|
168
|
+
});
|
|
169
|
+
// Execute with appropriate method
|
|
170
|
+
const promptManager = new ThreeStagePromptManager(contextLength);
|
|
171
|
+
const needsChunking = promptManager.needsChunking(promptStages);
|
|
172
|
+
if (needsChunking) {
|
|
173
|
+
const conversation = promptManager.createChunkedConversation(promptStages);
|
|
174
|
+
const messages = [
|
|
175
|
+
conversation.systemMessage,
|
|
176
|
+
...conversation.dataMessages,
|
|
177
|
+
conversation.analysisMessage
|
|
178
|
+
];
|
|
179
|
+
return await ResponseProcessor.executeChunked(messages, model, contextLength, 'TEMPLATE_function_name', 'single');
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
return await ResponseProcessor.executeDirect(promptStages, model, contextLength, 'TEMPLATE_function_name');
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Execute multi-file analysis
|
|
187
|
+
*/
|
|
188
|
+
async executeMultiFileAnalysis(params, model, contextLength) {
|
|
189
|
+
// Discover files
|
|
190
|
+
let filesToAnalyze = params.files ||
|
|
191
|
+
await this.discoverRelevantFiles(params.projectPath, params.maxDepth, params.analysisType);
|
|
192
|
+
// Perform multi-file analysis with caching
|
|
193
|
+
const analysisResult = await this.performMultiFileAnalysis(filesToAnalyze, params, model, contextLength);
|
|
194
|
+
// Generate prompt stages for multi-file
|
|
195
|
+
const promptStages = this.getMultiFilePromptStages({
|
|
196
|
+
...params,
|
|
197
|
+
analysisResult,
|
|
198
|
+
fileCount: filesToAnalyze.length
|
|
199
|
+
});
|
|
200
|
+
// Always use chunking for multi-file
|
|
201
|
+
const promptManager = new ThreeStagePromptManager(contextLength);
|
|
202
|
+
const conversation = promptManager.createChunkedConversation(promptStages);
|
|
203
|
+
const messages = [
|
|
204
|
+
conversation.systemMessage,
|
|
205
|
+
...conversation.dataMessages,
|
|
206
|
+
conversation.analysisMessage
|
|
207
|
+
];
|
|
208
|
+
return await ResponseProcessor.executeChunked(messages, model, contextLength, 'TEMPLATE_function_name', 'multifile');
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* TEMPLATE: Implement your single-file prompt stages
|
|
212
|
+
*/
|
|
213
|
+
getSingleFilePromptStages(params) {
|
|
214
|
+
const { code, language, analysisDepth, analysisType } = params;
|
|
215
|
+
const systemAndContext = `You are an expert code analyst specializing in ${analysisDepth} ${analysisType} analysis.
|
|
216
|
+
|
|
217
|
+
Analysis Context:
|
|
218
|
+
- Language: ${language}
|
|
219
|
+
- Analysis Depth: ${analysisDepth}
|
|
220
|
+
- Analysis Type: ${analysisType}
|
|
221
|
+
- Mode: Single File Analysis
|
|
222
|
+
|
|
223
|
+
TEMPLATE: Add your specific single-file system instructions here.
|
|
224
|
+
|
|
225
|
+
Your task is to provide actionable insights and recommendations for this individual file.`;
|
|
226
|
+
const dataPayload = `Code to analyze:
|
|
227
|
+
|
|
228
|
+
\`\`\`${language}
|
|
229
|
+
${code}
|
|
230
|
+
\`\`\``;
|
|
231
|
+
const outputInstructions = `TEMPLATE: Define your specific single-file output format here.
|
|
232
|
+
|
|
233
|
+
**IMPORTANT: Use natural language instructions, NOT JSON schemas!**
|
|
234
|
+
The ResponseFactory will handle all JSON formatting automatically.
|
|
235
|
+
|
|
236
|
+
Example single-file analysis format:
|
|
237
|
+
|
|
238
|
+
**File Overview:**
|
|
239
|
+
Provide a brief summary of what this file does and its overall quality.
|
|
240
|
+
|
|
241
|
+
**Structural Analysis:**
|
|
242
|
+
- **Components**: List key classes, functions, and their purposes
|
|
243
|
+
- **Dependencies**: Identify imports, exports, and external dependencies
|
|
244
|
+
- **Architecture**: Describe the code's architectural approach
|
|
245
|
+
|
|
246
|
+
**Quality Assessment:**
|
|
247
|
+
- **Code Quality**: Rate maintainability, testability, and reusability
|
|
248
|
+
- **Complexity**: Evaluate cyclomatic complexity and readability
|
|
249
|
+
- **Standards**: Adherence to language and framework best practices
|
|
250
|
+
|
|
251
|
+
**Issues & Recommendations:**
|
|
252
|
+
For each finding, provide:
|
|
253
|
+
- **Type**: Issue category (improvement, security, performance, etc.)
|
|
254
|
+
- **Severity**: Priority level (critical, high, medium, low)
|
|
255
|
+
- **Description**: Clear explanation of the problem or opportunity
|
|
256
|
+
- **Location**: Specific line numbers where applicable
|
|
257
|
+
- **Solution**: Actionable steps to address the issue
|
|
258
|
+
|
|
259
|
+
**Implementation Guidance:**
|
|
260
|
+
Organize recommendations by priority and provide specific, actionable steps that developers can implement immediately.
|
|
261
|
+
|
|
262
|
+
Focus on being constructive, specific, and actionable while maintaining professional quality suitable for production use.`;
|
|
263
|
+
return { systemAndContext, dataPayload, outputInstructions };
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* TEMPLATE: Implement your multi-file prompt stages
|
|
267
|
+
*/
|
|
268
|
+
getMultiFilePromptStages(params) {
|
|
269
|
+
const { analysisResult, analysisType, analysisDepth, fileCount } = params;
|
|
270
|
+
const systemAndContext = `You are an expert multi-file code analyst specializing in ${analysisDepth} ${analysisType} analysis.
|
|
271
|
+
|
|
272
|
+
Analysis Context:
|
|
273
|
+
- Analysis Type: ${analysisType}
|
|
274
|
+
- Analysis Depth: ${analysisDepth}
|
|
275
|
+
- Files Analyzed: ${fileCount}
|
|
276
|
+
- Mode: Multi-File Analysis
|
|
277
|
+
|
|
278
|
+
TEMPLATE: Add your specific multi-file system instructions here.
|
|
279
|
+
|
|
280
|
+
Your task is to provide comprehensive cross-file insights and architectural recommendations.`;
|
|
281
|
+
const dataPayload = `Multi-file analysis results:
|
|
282
|
+
|
|
283
|
+
${JSON.stringify(analysisResult, null, 2)}`;
|
|
284
|
+
const outputInstructions = `TEMPLATE: Define your specific multi-file output format here.
|
|
285
|
+
|
|
286
|
+
**IMPORTANT: Use natural language instructions, NOT JSON schemas!**
|
|
287
|
+
The ResponseFactory will handle all JSON formatting automatically.
|
|
288
|
+
|
|
289
|
+
Example multi-file analysis format:
|
|
290
|
+
|
|
291
|
+
**Project Overview:**
|
|
292
|
+
Provide a comprehensive summary of the project architecture and organization across all ${fileCount} analyzed files.
|
|
293
|
+
|
|
294
|
+
**Cross-File Analysis:**
|
|
295
|
+
- **Architecture Patterns**: Identify architectural patterns and their implementation
|
|
296
|
+
- **Dependencies**: Map inter-file dependencies and coupling issues
|
|
297
|
+
- **Consistency**: Assess coding style, naming conventions, and pattern consistency
|
|
298
|
+
- **Duplication**: Identify code duplication and reuse opportunities
|
|
299
|
+
|
|
300
|
+
**System-Wide Findings:**
|
|
301
|
+
For each cross-file issue, provide:
|
|
302
|
+
- **Issue Type**: Architecture, coupling, duplication, inconsistency, etc.
|
|
303
|
+
- **Severity**: Impact on system maintainability and scalability
|
|
304
|
+
- **Affected Files**: Specific files involved in the issue
|
|
305
|
+
- **System Impact**: How this affects overall architecture
|
|
306
|
+
- **Resolution Strategy**: Multi-file refactoring or improvement approach
|
|
307
|
+
|
|
308
|
+
**Architectural Recommendations:**
|
|
309
|
+
- **Immediate Actions**: Critical architectural fixes needed across files
|
|
310
|
+
- **Structural Improvements**: Medium-term refactoring opportunities
|
|
311
|
+
- **Long-term Enhancements**: Strategic architectural evolution suggestions
|
|
312
|
+
|
|
313
|
+
**Implementation Roadmap:**
|
|
314
|
+
Provide a prioritized plan for implementing cross-file improvements, considering dependencies between changes and minimizing disruption to existing functionality.
|
|
315
|
+
|
|
316
|
+
Focus on systemic issues that affect multiple files and provide architectural insights that individual file analysis cannot reveal.`;
|
|
317
|
+
return { systemAndContext, dataPayload, outputInstructions };
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* TEMPLATE: Implement for backwards compatibility
|
|
321
|
+
* The system still expects this method, so we intelligently route to the appropriate stages
|
|
322
|
+
*/
|
|
323
|
+
getPromptStages(params) {
|
|
324
|
+
const mode = this.detectAnalysisMode(params);
|
|
325
|
+
if (mode === 'single-file') {
|
|
326
|
+
return this.getSingleFilePromptStages(params);
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
return this.getMultiFilePromptStages(params);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
// Multi-file helper methods
|
|
333
|
+
async discoverRelevantFiles(projectPath, maxDepth, analysisType) {
|
|
334
|
+
const extensions = this.getFileExtensions(analysisType);
|
|
335
|
+
return await this.multiFileAnalysis.discoverFiles(projectPath, extensions, maxDepth);
|
|
336
|
+
}
|
|
337
|
+
async performMultiFileAnalysis(files, params, model, contextLength) {
|
|
338
|
+
const cacheKey = this.analysisCache.generateKey('TEMPLATE_function_name', params, files);
|
|
339
|
+
const cached = await this.analysisCache.get(cacheKey);
|
|
340
|
+
if (cached)
|
|
341
|
+
return cached;
|
|
342
|
+
const fileAnalysisResults = await this.multiFileAnalysis.analyzeBatch(files, (file) => this.analyzeIndividualFile(file, params, model), contextLength);
|
|
343
|
+
// Aggregate results into proper analysis result format
|
|
344
|
+
const aggregatedResult = {
|
|
345
|
+
summary: `Multi-file analysis of ${files.length} files`,
|
|
346
|
+
findings: fileAnalysisResults,
|
|
347
|
+
data: {
|
|
348
|
+
fileCount: files.length,
|
|
349
|
+
totalSize: fileAnalysisResults.reduce((sum, result) => sum + (result.size || 0), 0),
|
|
350
|
+
// TEMPLATE: Add your specific aggregation logic here
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
await this.analysisCache.cacheAnalysis(cacheKey, aggregatedResult, {
|
|
354
|
+
modelUsed: model.identifier || 'unknown',
|
|
355
|
+
executionTime: Date.now() - Date.now(), // TODO: Track actual execution time
|
|
356
|
+
timestamp: new Date().toISOString()
|
|
357
|
+
});
|
|
358
|
+
return aggregatedResult;
|
|
359
|
+
}
|
|
360
|
+
async analyzeIndividualFile(file, params, model) {
|
|
361
|
+
const content = await import('fs/promises').then(fs => fs.readFile(file, 'utf-8'));
|
|
362
|
+
const stats = await import('fs/promises').then(fs => fs.stat(file));
|
|
363
|
+
return {
|
|
364
|
+
filePath: file,
|
|
365
|
+
fileName: basename(file), // ✅ Use imported basename instead of require('path').basename
|
|
366
|
+
size: content.length,
|
|
367
|
+
lines: content.split('\n').length,
|
|
368
|
+
extension: extname(file), // ✅ Use imported extname
|
|
369
|
+
relativePath: relative(params.projectPath || '', file), // ✅ Use imported relative
|
|
370
|
+
// TEMPLATE: Add your specific individual file analysis here
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
getFileExtensions(analysisType) {
|
|
374
|
+
// TEMPLATE: Update these extensions to match your analysis needs
|
|
375
|
+
// Common extensions by category:
|
|
376
|
+
// Code: ['.js', '.ts', '.jsx', '.tsx', '.py', '.java', '.cs', '.php']
|
|
377
|
+
// Config: ['.json', '.yaml', '.yml', '.xml', '.toml', '.ini']
|
|
378
|
+
// Docs: ['.md', '.txt', '.rst', '.adoc']
|
|
379
|
+
// All: [...code, ...config, ...docs]
|
|
380
|
+
const extensionMap = {
|
|
381
|
+
'TEMPLATE_type1': ['.js', '.ts', '.jsx', '.tsx'],
|
|
382
|
+
'TEMPLATE_type2': ['.php', '.inc', '.module'],
|
|
383
|
+
'comprehensive': ['.js', '.ts', '.jsx', '.tsx', '.php', '.py', '.java']
|
|
384
|
+
};
|
|
385
|
+
return extensionMap[analysisType] || extensionMap.comprehensive;
|
|
386
|
+
}
|
|
387
|
+
generateCacheKey(files, params) {
|
|
388
|
+
const fileHash = files.join('|');
|
|
389
|
+
const paramHash = JSON.stringify(params);
|
|
390
|
+
return `${fileHash}_${paramHash}`.substring(0, 64);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
export default TEMPLATE_UniversalPlugin;
|
|
394
|
+
/*
|
|
395
|
+
PLUGIN TEMPLATE USAGE:
|
|
396
|
+
1. Copy this file to your plugin location (src/prompts/[category]/)
|
|
397
|
+
2. Replace all TEMPLATE_ placeholders:
|
|
398
|
+
- TEMPLATE_UniversalPlugin → Your class name
|
|
399
|
+
- TEMPLATE_function_name → Your MCP function name
|
|
400
|
+
- TEMPLATE_category → Your plugin category
|
|
401
|
+
- TEMPLATE_type1, TEMPLATE_type2 → Your analysis types
|
|
402
|
+
3. Choose your default mode in detectAnalysisMode():
|
|
403
|
+
- File-focused plugins: return 'single-file' (e.g., code analysis, linting)
|
|
404
|
+
- Project-focused plugins: return 'multi-file' (e.g., architecture, counting)
|
|
405
|
+
4. Implement getSingleFilePromptStages() for single-file logic
|
|
406
|
+
5. Implement getMultiFilePromptStages() for multi-file logic
|
|
407
|
+
6. Update individual file analysis logic if needed
|
|
408
|
+
7. Use provided Node.js imports (path, fs/promises) instead of require()
|
|
409
|
+
8. Build and restart Claude
|
|
410
|
+
|
|
411
|
+
⚠️ CRITICAL RULE: OUTPUT INSTRUCTIONS MUST BE NATURAL LANGUAGE ONLY! ⚠️
|
|
412
|
+
|
|
413
|
+
✅ DO: Use comprehensive natural language instructions describing what analysis to provide
|
|
414
|
+
❌ DON'T: Put JSON schemas in outputInstructions (causes double-processing & escaping)
|
|
415
|
+
|
|
416
|
+
The ResponseFactory automatically converts natural language responses to clean JSON.
|
|
417
|
+
If you specify JSON format in prompts, you get garbled, escaped content.
|
|
418
|
+
|
|
419
|
+
AUTOMATIC DETECTION:
|
|
420
|
+
✅ Single-file: When code/filePath provided
|
|
421
|
+
✅ Multi-file: When projectPath/files/maxDepth provided
|
|
422
|
+
✅ Intelligent parameter validation based on detected mode
|
|
423
|
+
✅ Appropriate execution path (direct/chunked) chosen automatically
|
|
424
|
+
✅ Same utilities used for both modes
|
|
425
|
+
|
|
426
|
+
BENEFITS:
|
|
427
|
+
✅ Single source of truth - one template for all scenarios
|
|
428
|
+
✅ Automatic mode detection - no need to choose
|
|
429
|
+
✅ Consistent behavior across single/multi-file
|
|
430
|
+
✅ Less maintenance - fix bugs once
|
|
431
|
+
✅ Flexible parameters - supports all use cases
|
|
432
|
+
✅ Code reuse - shared validation, processing, error handling
|
|
433
|
+
✅ Clean JSON responses - ResponseFactory handles all formatting
|
|
434
|
+
|
|
435
|
+
UTILITIES PROVIDED:
|
|
436
|
+
✅ ModelSetup - Model loading and context detection
|
|
437
|
+
✅ ResponseProcessor - Token calculation and execution
|
|
438
|
+
✅ ParameterValidator - Common validation patterns
|
|
439
|
+
✅ ErrorHandler - Standardized error responses
|
|
440
|
+
✅ ResponseFactory - Universal JSON formatting (don't duplicate this!)
|
|
441
|
+
✅ Common Node.js imports - path, fs/promises (use these instead of require)
|
|
442
|
+
|
|
443
|
+
COMMON MISTAKES TO AVOID:
|
|
444
|
+
❌ Don't use require() - use the provided ES module imports
|
|
445
|
+
❌ Don't hardcode single/multi-file - let detection handle it
|
|
446
|
+
❌ Don't duplicate template architecture - only replace designated areas
|
|
447
|
+
❌ Don't create custom utilities - use the provided ones
|
|
448
|
+
❌ DON'T PUT JSON SCHEMAS IN OUTPUT INSTRUCTIONS - use natural language only!
|
|
449
|
+
*/
|
|
450
|
+
//# sourceMappingURL=plugin-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-template.js","sourceRoot":"","sources":["../../src/templates/plugin-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,4EAA4E;AAC5E,gFAAgF;AAChF,mFAAmF;AACnF,+EAA+E;AAC/E,+EAA+E;AAC/E,4EAA4E;AAC5E,gGAAgG;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAE7E,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EAClB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,0DAA0D;AAC1D,OAAO,EAAE,QAAQ,EAAW,OAAO,EAAQ,QAAQ,EAAE,MAAM,MAAM,CAAC;AAGlE,MAAM,OAAO,wBAAyB,SAAQ,UAAU;IAgEtD;QACE,KAAK,EAAE,CAAC;QAhEV,SAAI,GAAG,wBAAwB,CAAC;QAChC,aAAQ,GAAG,SAAkB,CAAC,CAAC,iFAAiF;QAChH,gBAAW,GAAG,+EAA+E,CAAC;QAE9F,0EAA0E;QAC1E,eAAU,GAAG;YACX,yBAAyB;YACzB,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAiB;gBACvB,WAAW,EAAE,gDAAgD;gBAC7D,QAAQ,EAAE,KAAK;aAChB;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAiB;gBACvB,WAAW,EAAE,gCAAgC;gBAC7C,QAAQ,EA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,OAAO,CAAC;SACxE,CAAC;QAEF,OAAO,YAAY,CAAC,YAAY,CAAC,IAAI,YAAY,CAAC,aAAa,CAAC;IAClE,CAAC;IAEO,gBAAgB,CAAC,KAAe,EAAE,MAAW;QACnD,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACzC,OAAO,GAAG,QAAQ,IAAI,SAAS,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACrD,CAAC;CACF;AAED,eAAe,wBAAwB,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuDE"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript interfaces and types for Context Window Management and Chunking
|
|
3
|
+
*
|
|
4
|
+
* This file defines all the interfaces, types, and enums used by the
|
|
5
|
+
* Context Window Manager and related components.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Health check result structure from health_check function
|
|
9
|
+
*/
|
|
10
|
+
export interface HealthCheckResult {
|
|
11
|
+
status: 'healthy' | 'unhealthy';
|
|
12
|
+
connection: 'established' | 'failed';
|
|
13
|
+
lmStudioUrl: string;
|
|
14
|
+
timestamp: string;
|
|
15
|
+
contextLength?: number;
|
|
16
|
+
details?: {
|
|
17
|
+
loadedModels: Array<{
|
|
18
|
+
path: string;
|
|
19
|
+
identifier: string;
|
|
20
|
+
architecture: string;
|
|
21
|
+
contextLength?: number;
|
|
22
|
+
}>;
|
|
23
|
+
modelCount: number;
|
|
24
|
+
hasActiveModel: boolean;
|
|
25
|
+
contextLength?: number;
|
|
26
|
+
serverInfo: {
|
|
27
|
+
url: string;
|
|
28
|
+
protocol: string;
|
|
29
|
+
};
|
|
30
|
+
activeModel?: {
|
|
31
|
+
path: string;
|
|
32
|
+
identifier: string;
|
|
33
|
+
architecture: string;
|
|
34
|
+
contextLength?: number;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Context Window Manager configuration
|
|
40
|
+
*/
|
|
41
|
+
export interface ContextWindowConfig {
|
|
42
|
+
contextLimit: number;
|
|
43
|
+
safetyMargin: number;
|
|
44
|
+
notificationThreshold?: number;
|
|
45
|
+
enableUserNotifications?: boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Chunking strategy types
|
|
49
|
+
*/
|
|
50
|
+
export type ChunkingStrategyType = 'file-based' | 'token-based' | 'semantic' | 'sliding-window' | 'hierarchical';
|
|
51
|
+
/**
|
|
52
|
+
* Individual chunk of data for processing
|
|
53
|
+
*/
|
|
54
|
+
export interface Chunk {
|
|
55
|
+
id: string;
|
|
56
|
+
data: any;
|
|
57
|
+
metadata?: {
|
|
58
|
+
[key: string]: any;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Plugin execution context for chunking operations
|
|
63
|
+
*/
|
|
64
|
+
export interface PluginExecutionContext {
|
|
65
|
+
pluginName: string;
|
|
66
|
+
originalParams: any;
|
|
67
|
+
estimatedTokens: number;
|
|
68
|
+
chunkingStrategy: ChunkingStrategyType;
|
|
69
|
+
chunks: Chunk[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Chunking-specific error class
|
|
73
|
+
*/
|
|
74
|
+
export declare class ChunkingError extends Error {
|
|
75
|
+
readonly code: 'CHUNKING_FAILED' | 'STRATEGY_NOT_FOUND' | 'CHUNK_PROCESSING_FAILED';
|
|
76
|
+
readonly context?: any;
|
|
77
|
+
constructor(message: string, code: 'CHUNKING_FAILED' | 'STRATEGY_NOT_FOUND' | 'CHUNK_PROCESSING_FAILED', context?: any);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Token estimation configuration
|
|
81
|
+
*/
|
|
82
|
+
export interface TokenEstimationConfig {
|
|
83
|
+
averageTokensPerWord: number;
|
|
84
|
+
averageCharsPerToken: number;
|
|
85
|
+
estimationFactor: number;
|
|
86
|
+
maxCacheSize: number;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=chunking-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunking-types.d.ts","sourceRoot":"","sources":["../../src/types/chunking-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,SAAS,GAAG,WAAW,CAAC;IAChC,UAAU,EAAE,aAAa,GAAG,QAAQ,CAAC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE;QACR,YAAY,EAAE,KAAK,CAAC;YAClB,IAAI,EAAE,MAAM,CAAC;YACb,UAAU,EAAE,MAAM,CAAC;YACnB,YAAY,EAAE,MAAM,CAAC;YACrB,aAAa,CAAC,EAAE,MAAM,CAAC;SACxB,CAAC,CAAC;QACH,UAAU,EAAE,MAAM,CAAC;QACnB,cAAc,EAAE,OAAO,CAAC;QACxB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,UAAU,EAAE;YACV,GAAG,EAAE,MAAM,CAAC;YACZ,QAAQ,EAAE,MAAM,CAAC;SAClB,CAAC;QACF,WAAW,CAAC,EAAE;YACZ,IAAI,EAAE,MAAM,CAAC;YACb,UAAU,EAAE,MAAM,CAAC;YACnB,YAAY,EAAE,MAAM,CAAC;YACrB,aAAa,CAAC,EAAE,MAAM,CAAC;SACxB,CAAC;KACH,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAC5B,YAAY,GACZ,aAAa,GACb,UAAU,GACV,gBAAgB,GAChB,cAAc,CAAC;AAEnB;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,GAAG,CAAC;IACV,QAAQ,CAAC,EAAE;QACT,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,GAAG,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,oBAAoB,CAAC;IACvC,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAK;aAGpB,IAAI,EAAE,iBAAiB,GAAG,oBAAoB,GAAG,yBAAyB;aAC1E,OAAO,CAAC,EAAE,GAAG;gBAF7B,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,iBAAiB,GAAG,oBAAoB,GAAG,yBAAyB,EAC1E,OAAO,CAAC,EAAE,GAAG;CAKhC;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript interfaces and types for Context Window Management and Chunking
|
|
3
|
+
*
|
|
4
|
+
* This file defines all the interfaces, types, and enums used by the
|
|
5
|
+
* Context Window Manager and related components.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Chunking-specific error class
|
|
9
|
+
*/
|
|
10
|
+
export class ChunkingError extends Error {
|
|
11
|
+
constructor(message, code, context) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.context = context;
|
|
15
|
+
this.name = 'ChunkingError';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=chunking-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunking-types.js","sourceRoot":"","sources":["../../src/types/chunking-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA4EH;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YACE,OAAe,EACC,IAA0E,EAC1E,OAAa;QAE7B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAsE;QAC1E,YAAO,GAAP,OAAO,CAAM;QAG7B,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 3-Stage Prompt Architecture Types
|
|
3
|
+
* Enables clean separation of system context, data payload, and output instructions
|
|
4
|
+
*/
|
|
5
|
+
export interface PromptStages {
|
|
6
|
+
/** Stage 1: System instructions and task context */
|
|
7
|
+
systemAndContext: string;
|
|
8
|
+
/** Stage 2: Data payload (gets chunked when needed) */
|
|
9
|
+
dataPayload: string;
|
|
10
|
+
/** Stage 3: Output format instructions and analysis tasks */
|
|
11
|
+
outputInstructions: string;
|
|
12
|
+
}
|
|
13
|
+
export interface StageMetrics {
|
|
14
|
+
/** Token count for system + context stage */
|
|
15
|
+
systemTokens: number;
|
|
16
|
+
/** Token count for data payload */
|
|
17
|
+
dataTokens: number;
|
|
18
|
+
/** Token count for output instructions */
|
|
19
|
+
outputTokens: number;
|
|
20
|
+
/** Total fixed overhead (system + output) */
|
|
21
|
+
fixedOverhead: number;
|
|
22
|
+
/** Available tokens for data */
|
|
23
|
+
availableForData: number;
|
|
24
|
+
}
|
|
25
|
+
export interface ChunkedConversation {
|
|
26
|
+
/** System message with context */
|
|
27
|
+
systemMessage: {
|
|
28
|
+
role: 'system';
|
|
29
|
+
content: string;
|
|
30
|
+
};
|
|
31
|
+
/** Data messages (one per chunk) */
|
|
32
|
+
dataMessages: Array<{
|
|
33
|
+
role: 'user';
|
|
34
|
+
content: string;
|
|
35
|
+
}>;
|
|
36
|
+
/** Final analysis request */
|
|
37
|
+
analysisMessage: {
|
|
38
|
+
role: 'user';
|
|
39
|
+
content: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=prompt-stages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-stages.d.ts","sourceRoot":"","sources":["../../src/types/prompt-stages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,YAAY;IAC3B,oDAAoD;IACpD,gBAAgB,EAAE,MAAM,CAAC;IAEzB,uDAAuD;IACvD,WAAW,EAAE,MAAM,CAAC;IAEpB,6DAA6D;IAC7D,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,YAAY;IAC3B,6CAA6C;IAC7C,YAAY,EAAE,MAAM,CAAC;IAErB,mCAAmC;IACnC,UAAU,EAAE,MAAM,CAAC;IAEnB,0CAA0C;IAC1C,YAAY,EAAE,MAAM,CAAC;IAErB,6CAA6C;IAC7C,aAAa,EAAE,MAAM,CAAC;IAEtB,gCAAgC;IAChC,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,mBAAmB;IAClC,kCAAkC;IAClC,aAAa,EAAE;QACb,IAAI,EAAE,QAAQ,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IAEF,oCAAoC;IACpC,YAAY,EAAE,KAAK,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IAEH,6BAA6B;IAC7B,eAAe,EAAE;QACf,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-stages.js","sourceRoot":"","sources":["../../src/types/prompt-stages.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|