@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,136 @@
|
|
|
1
|
+
import { readdirSync, readFileSync } from 'fs';
|
|
2
|
+
import { join, basename, dirname } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
// ES module equivalent of __dirname
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = dirname(__filename);
|
|
7
|
+
/**
|
|
8
|
+
* Discover all available Houtini LM functions by scanning prompt directories
|
|
9
|
+
*/
|
|
10
|
+
export async function discoverAvailableFunctions() {
|
|
11
|
+
const functions = [];
|
|
12
|
+
const promptsDir = join(__dirname, '../prompts');
|
|
13
|
+
// Known prompt categories
|
|
14
|
+
const categories = ['analyze', 'generate', 'system', 'custom', 'fun'];
|
|
15
|
+
for (const category of categories) {
|
|
16
|
+
const categoryPath = join(promptsDir, category);
|
|
17
|
+
try {
|
|
18
|
+
const files = readdirSync(categoryPath);
|
|
19
|
+
for (const file of files) {
|
|
20
|
+
if (file.endsWith('.js') && !file.includes('legacy') && !file.includes('.d.ts')) {
|
|
21
|
+
try {
|
|
22
|
+
const functionInfo = await extractFunctionInfo(categoryPath, file, category);
|
|
23
|
+
if (functionInfo) {
|
|
24
|
+
functions.push(functionInfo);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
// Skip files that can't be analyzed
|
|
29
|
+
console.warn(`Could not analyze ${file}:`, error.message);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
// Category directory doesn't exist or can't be read, skip
|
|
36
|
+
console.warn(`Could not read category ${category}:`, error.message);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return functions.sort((a, b) => a.name.localeCompare(b.name));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Extract function information from a compiled plugin file
|
|
43
|
+
*/
|
|
44
|
+
async function extractFunctionInfo(categoryPath, file, category) {
|
|
45
|
+
const filePath = join(categoryPath, file);
|
|
46
|
+
try {
|
|
47
|
+
const content = readFileSync(filePath, 'utf8');
|
|
48
|
+
// Extract function name (look for name = 'function_name' pattern)
|
|
49
|
+
const nameMatch = content.match(/name\s*=\s*['"']([^'"]+)['"']/);
|
|
50
|
+
const functionName = nameMatch ? nameMatch[1] : basename(file, '.js').replace(/-/g, '_');
|
|
51
|
+
// Extract description (look for description = 'text' pattern)
|
|
52
|
+
const descMatch = content.match(/description\s*=\s*['"']([^'"]+)['"']/);
|
|
53
|
+
const description = descMatch ? descMatch[1] : `${category} function`;
|
|
54
|
+
// Detect supported modes by looking for mode detection logic
|
|
55
|
+
const supportedModes = detectSupportedModes(content);
|
|
56
|
+
const primaryMode = determinePrimaryMode(content, category);
|
|
57
|
+
// Generate example usage
|
|
58
|
+
const exampleUsage = generateExampleUsage(functionName, supportedModes);
|
|
59
|
+
return {
|
|
60
|
+
name: functionName,
|
|
61
|
+
category,
|
|
62
|
+
file,
|
|
63
|
+
description,
|
|
64
|
+
supportedModes,
|
|
65
|
+
primaryMode,
|
|
66
|
+
exampleUsage
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
console.warn(`Error reading ${file}:`, error.message);
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Detect which modes a function supports by analyzing its code
|
|
76
|
+
*/
|
|
77
|
+
function detectSupportedModes(content) {
|
|
78
|
+
const modes = [];
|
|
79
|
+
// Check for single-file support
|
|
80
|
+
if (content.includes('getSingleFile') || content.includes("'single-file'") || content.includes('params.code') || content.includes('params.filePath')) {
|
|
81
|
+
modes.push('single-file');
|
|
82
|
+
}
|
|
83
|
+
// Check for multi-file support
|
|
84
|
+
if (content.includes('getMultiFile') || content.includes("'multi-file'") || content.includes('params.projectPath') || content.includes('params.files')) {
|
|
85
|
+
modes.push('multi-file');
|
|
86
|
+
}
|
|
87
|
+
// Default if we can't detect
|
|
88
|
+
if (modes.length === 0) {
|
|
89
|
+
modes.push('single-file'); // Conservative default
|
|
90
|
+
}
|
|
91
|
+
return modes;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Determine the primary mode based on function purpose and defaults
|
|
95
|
+
*/
|
|
96
|
+
function determinePrimaryMode(content, category) {
|
|
97
|
+
// Look for explicit default return in detectAnalysisMode
|
|
98
|
+
const defaultMatch = content.match(/return\s+['"'](single-file|multi-file)['"'];?\s*$/m);
|
|
99
|
+
if (defaultMatch) {
|
|
100
|
+
return defaultMatch[1];
|
|
101
|
+
}
|
|
102
|
+
// Category-based heuristics
|
|
103
|
+
if (category === 'system') {
|
|
104
|
+
return 'multi-file'; // System functions typically work on projects
|
|
105
|
+
}
|
|
106
|
+
if (category === 'generate') {
|
|
107
|
+
return 'single-file'; // Generation typically creates single items
|
|
108
|
+
}
|
|
109
|
+
// Default fallback
|
|
110
|
+
return 'single-file';
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Generate helpful example usage for different modes
|
|
114
|
+
*/
|
|
115
|
+
function generateExampleUsage(functionName, supportedModes) {
|
|
116
|
+
const examples = {};
|
|
117
|
+
if (supportedModes.includes('single-file')) {
|
|
118
|
+
examples.singleFile = `houtini-lm:${functionName} filePath="C:/project/src/file.ts"`;
|
|
119
|
+
}
|
|
120
|
+
if (supportedModes.includes('multi-file')) {
|
|
121
|
+
examples.multiFile = `houtini-lm:${functionName} projectPath="C:/project/src"`;
|
|
122
|
+
}
|
|
123
|
+
return examples;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Get function categories with counts
|
|
127
|
+
*/
|
|
128
|
+
export async function getFunctionCategories() {
|
|
129
|
+
const functions = await discoverAvailableFunctions();
|
|
130
|
+
const categories = {};
|
|
131
|
+
functions.forEach(func => {
|
|
132
|
+
categories[func.category] = (categories[func.category] || 0) + 1;
|
|
133
|
+
});
|
|
134
|
+
return categories;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=function-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-registry.js","sourceRoot":"","sources":["../../src/system/function-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAW,QAAQ,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,oCAAoC;AACpC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,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AAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,YAAY,CAAC,CAAC,8CAA8C;IACrE,CAAC;IAED,IAAI,QAAQ,KAAK,UAAU,EAAE,CAAC;QAC5B,OAAO,aAAa,CAAC,CAAC,4CAA4C;IACpE,CAAC;IAED,mBAAmB;IACnB,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,SAAS,oBAAoB,CAAC,YAAoB,EAAE,cAAwB;IAC1E,MAAM,QAAQ,GAAQ,EAAE,CAAC;IAEzB,IAAI,cAAc,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;QAC3C,QAAQ,CAAC,UAAU,GAAG,cAAc,YAAY,oCAAoC,CAAC;IACvF,CAAC;IAED,IAAI,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QAC1C,QAAQ,CAAC,SAAS,GAAG,cAAc,YAAY,+BAA+B,CAAC;IACjF,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB;IACzC,MAAM,SAAS,GAAG,MAAM,0BAA0B,EAAE,CAAC;IACrD,MAAM,UAAU,GAAmC,EAAE,CAAC;IAEtD,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACvB,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Health Check Plugin - Modern v4.2 Pattern
|
|
3
|
+
* Checks if LM Studio is running and responding
|
|
4
|
+
*/
|
|
5
|
+
import { BasePlugin } from '../plugins/base-plugin.js';
|
|
6
|
+
import { IPromptPlugin } from '../prompts/shared/types.js';
|
|
7
|
+
import { PromptStages } from '../types/prompt-stages.js';
|
|
8
|
+
export declare class HealthCheckPlugin extends BasePlugin implements IPromptPlugin {
|
|
9
|
+
name: string;
|
|
10
|
+
category: "system";
|
|
11
|
+
description: string;
|
|
12
|
+
parameters: {
|
|
13
|
+
detailed: {
|
|
14
|
+
type: "boolean";
|
|
15
|
+
description: string;
|
|
16
|
+
default: boolean;
|
|
17
|
+
required: boolean;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
execute(params: any, llmClient: any): Promise<import("../validation/schemas.js").HealthCheckResponse>;
|
|
21
|
+
/**
|
|
22
|
+
* MODERN v4.2: 3-stage prompt architecture
|
|
23
|
+
* Note: Health check is a system utility that doesn't use prompts
|
|
24
|
+
*/
|
|
25
|
+
getPromptStages(params: any): PromptStages;
|
|
26
|
+
/**
|
|
27
|
+
* LEGACY: Backwards compatibility
|
|
28
|
+
* DEPRECATED: Will be removed in v5.0
|
|
29
|
+
*/
|
|
30
|
+
getPrompt(params: any): string;
|
|
31
|
+
}
|
|
32
|
+
export default HealthCheckPlugin;
|
|
33
|
+
//# sourceMappingURL=health-check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health-check.d.ts","sourceRoot":"","sources":["../../src/system/health-check.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAIzD,qBAAa,iBAAkB,SAAQ,UAAW,YAAW,aAAa;IACxE,IAAI,SAAkB;IACtB,QAAQ,EAAG,QAAQ,CAAU;IAC7B,WAAW,SAAkD;IAE7D,UAAU;;;;;;;MAOR;IAEI,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG;IAkEzC;;;OAGG;IACH,eAAe,CAAC,MAAM,EAAE,GAAG,GAAG,YAAY;IAQ1C;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM;CAI/B;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Health Check Plugin - Modern v4.2 Pattern
|
|
3
|
+
* Checks if LM Studio is running and responding
|
|
4
|
+
*/
|
|
5
|
+
import { BasePlugin } from '../plugins/base-plugin.js';
|
|
6
|
+
import { ResponseFactory } from '../validation/response-factory.js';
|
|
7
|
+
import { withSecurity } from '../security/integration-helpers.js';
|
|
8
|
+
import { LMStudioClient } from '@lmstudio/sdk';
|
|
9
|
+
import { config } from '../config.js';
|
|
10
|
+
export class HealthCheckPlugin extends BasePlugin {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.name = 'health_check';
|
|
14
|
+
this.category = 'system';
|
|
15
|
+
this.description = 'Check if LM Studio is running and responding';
|
|
16
|
+
this.parameters = {
|
|
17
|
+
detailed: {
|
|
18
|
+
type: 'boolean',
|
|
19
|
+
description: 'Include detailed information about the loaded model and server status',
|
|
20
|
+
default: false,
|
|
21
|
+
required: false
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
async execute(params, llmClient) {
|
|
26
|
+
return await withSecurity(this, params, llmClient, async (secureParams) => {
|
|
27
|
+
try {
|
|
28
|
+
const client = new LMStudioClient({
|
|
29
|
+
baseUrl: config.lmStudioUrl || 'ws://localhost:1234',
|
|
30
|
+
});
|
|
31
|
+
// Try to connect and get basic info
|
|
32
|
+
const models = await client.llm.listLoaded();
|
|
33
|
+
// Get context length from the active model if available
|
|
34
|
+
let contextLength = undefined;
|
|
35
|
+
if (models.length > 0) {
|
|
36
|
+
try {
|
|
37
|
+
const activeModel = models[0];
|
|
38
|
+
// Try to get context length using LM Studio SDK
|
|
39
|
+
contextLength = await activeModel.getContextLength();
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
// If getContextLength fails, try alternative method or leave undefined
|
|
43
|
+
console.warn('Could not retrieve context length from model:', error);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Use ResponseFactory for consistent, spec-compliant output
|
|
47
|
+
ResponseFactory.setStartTime();
|
|
48
|
+
return ResponseFactory.createHealthCheckResponse('healthy', 'established', config.lmStudioUrl || 'ws://localhost:1234', undefined, undefined, secureParams.detailed ? {
|
|
49
|
+
loadedModels: models.map(model => ({
|
|
50
|
+
path: model.path,
|
|
51
|
+
identifier: model.identifier,
|
|
52
|
+
architecture: model.architecture || 'unknown',
|
|
53
|
+
contextLength: contextLength // Will be the same for all models since we only check the first one
|
|
54
|
+
})),
|
|
55
|
+
modelCount: models.length,
|
|
56
|
+
hasActiveModel: models.length > 0,
|
|
57
|
+
contextLength: contextLength, // Add context length to response
|
|
58
|
+
serverInfo: {
|
|
59
|
+
url: config.lmStudioUrl,
|
|
60
|
+
protocol: 'websocket'
|
|
61
|
+
},
|
|
62
|
+
activeModel: models.length > 0 ? {
|
|
63
|
+
path: models[0].path,
|
|
64
|
+
identifier: models[0].identifier,
|
|
65
|
+
architecture: models[0].architecture || 'unknown',
|
|
66
|
+
contextLength: contextLength // Add context length to active model
|
|
67
|
+
} : undefined
|
|
68
|
+
} : undefined, // Don't provide details in non-detailed mode
|
|
69
|
+
contextLength // Pass contextLength as separate parameter
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
return ResponseFactory.createHealthCheckResponse('unhealthy', 'failed', config.lmStudioUrl || 'ws://localhost:1234', error.message || 'Failed to connect to LM Studio', 'Please ensure LM Studio is running and a model is loaded');
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* MODERN v4.2: 3-stage prompt architecture
|
|
79
|
+
* Note: Health check is a system utility that doesn't use prompts
|
|
80
|
+
*/
|
|
81
|
+
getPromptStages(params) {
|
|
82
|
+
return {
|
|
83
|
+
systemAndContext: 'Health check system utility - no prompt required',
|
|
84
|
+
dataPayload: 'Checking LM Studio connection and model status',
|
|
85
|
+
outputInstructions: 'Return connection status and model information'
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* LEGACY: Backwards compatibility
|
|
90
|
+
* DEPRECATED: Will be removed in v5.0
|
|
91
|
+
*/
|
|
92
|
+
getPrompt(params) {
|
|
93
|
+
// Health check is a utility function, no prompt needed
|
|
94
|
+
return 'Health check - no prompt required for system utilities';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export default HealthCheckPlugin;
|
|
98
|
+
//# sourceMappingURL=health-check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health-check.js","sourceRoot":"","sources":["../../src/system/health-check.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IAAjD;;QACE,SAAI,GAAG,cAAc,CAAC;QACtB,aAAQ,GAAG,QAAiB,CAAC;QAC7B,gBAAW,GAAG,8CAA8C,CAAC;QAE7D,eAAU,GAAG;YACX,QAAQ,EAAE;gBACR,IAAI,EAAE,SAAkB;gBACxB,WAAW,EAAE,uEAAuE;gBACpF,OAAO,EAAE,KAAK;gBACd,QAAQ,EAAE,KAAK;aAChB;SACF,CAAC;IAwFJ,CAAC;IAtFC,KAAK,CAAC,OAAO,CAAC,MAAW,EAAE,SAAc;QACvC,OAAO,MAAM,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,YA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iCAAiC;oBAC/D,UAAU,EAAE;wBACV,GAAG,EAAE,MAAM,CAAC,WAAW;wBACvB,QAAQ,EAAE,WAAW;qBACtB;oBACD,WAAW,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;wBAC/B,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI;wBACpB,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU;wBAChC,YAAY,EAAG,MAAM,CAAC,CAAC,CAAS,CAAC,YAAY,IAAI,SAAS;wBAC1D,aAAa,EAAE,aAAa,CAAC,qCAAqC;qBACnE,CAAC,CAAC,CAAC,SAAS;iBACd,CAAC,CAAC,CAAC,SAAS,EAAE,6CAA6C;gBAC5D,aAAa,CAAC,2CAA2C;iBAC1D,CAAC;YACJ,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,OAAO,eAAe,CAAC,yBAAyB,CAC9C,WAAW,EACX,QAAQ,EACR,MAAM,CAAC,WAAW,IAAI,qBAAqB,EAC3C,KAAK,CAAC,OAAO,IAAI,gCAAgC,EACjD,0DAA0D,CAC3D,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,eAAe,CAAC,MAAW;QACzB,OAAO;YACL,gBAAgB,EAAE,kDAAkD;YACpE,WAAW,EAAE,gDAAgD;YAC7D,kBAAkB,EAAE,gDAAgD;SACrE,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,SAAS,CAAC,MAAW;QACnB,uDAAuD;QACvD,OAAO,wDAAwD,CAAC;IAClE,CAAC;CACF;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path Resolution Plugin - Smart path analysis for MCP usage
|
|
3
|
+
* Helps users understand file vs directory paths and suggests correct parameters
|
|
4
|
+
*/
|
|
5
|
+
import { BasePlugin } from '../plugins/base-plugin.js';
|
|
6
|
+
import { IPromptPlugin } from '../prompts/shared/types.js';
|
|
7
|
+
export declare class PathResolverPlugin extends BasePlugin implements IPromptPlugin {
|
|
8
|
+
name: string;
|
|
9
|
+
category: "system";
|
|
10
|
+
description: string;
|
|
11
|
+
parameters: {
|
|
12
|
+
path: {
|
|
13
|
+
type: "string";
|
|
14
|
+
description: string;
|
|
15
|
+
required: boolean;
|
|
16
|
+
};
|
|
17
|
+
suggestions: {
|
|
18
|
+
type: "boolean";
|
|
19
|
+
description: string;
|
|
20
|
+
default: boolean;
|
|
21
|
+
required: boolean;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
execute(params: any, llmClient: any): Promise<{
|
|
25
|
+
success: boolean;
|
|
26
|
+
timestamp: string;
|
|
27
|
+
modelUsed: string;
|
|
28
|
+
executionTimeMs: number;
|
|
29
|
+
data: {
|
|
30
|
+
content: any;
|
|
31
|
+
metadata: {
|
|
32
|
+
functionName: string;
|
|
33
|
+
parsedAt: string;
|
|
34
|
+
responseLength: number;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
error?: undefined;
|
|
38
|
+
} | {
|
|
39
|
+
success: boolean;
|
|
40
|
+
timestamp: string;
|
|
41
|
+
modelUsed: string;
|
|
42
|
+
executionTimeMs: number;
|
|
43
|
+
error: {
|
|
44
|
+
code: string;
|
|
45
|
+
message: any;
|
|
46
|
+
details: {
|
|
47
|
+
originalError: any;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
data?: undefined;
|
|
51
|
+
}>;
|
|
52
|
+
getPromptStages(params: any): any;
|
|
53
|
+
}
|
|
54
|
+
export default PathResolverPlugin;
|
|
55
|
+
//# sourceMappingURL=path-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-resolver.d.ts","sourceRoot":"","sources":["../../src/system/path-resolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAI3D,qBAAa,kBAAmB,SAAQ,UAAW,YAAW,aAAa;IACzE,IAAI,SAAkB;IACtB,QAAQ,EAAG,QAAQ,CAAU;IAC7B,WAAW,SAAmE;IAE9E,UAAU;;;;;;;;;;;;MAYR;IAEI,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAwDzC,eAAe,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG;CAOlC;AAGD,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path Resolution Plugin - Smart path analysis for MCP usage
|
|
3
|
+
* Helps users understand file vs directory paths and suggests correct parameters
|
|
4
|
+
*/
|
|
5
|
+
import { BasePlugin } from '../plugins/base-plugin.js';
|
|
6
|
+
import { withSecurity } from '../security/integration-helpers.js';
|
|
7
|
+
import { analyzePathForMCP } from '../utils/path-resolver.js';
|
|
8
|
+
export class PathResolverPlugin extends BasePlugin {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.name = 'resolve_path';
|
|
12
|
+
this.category = 'system';
|
|
13
|
+
this.description = 'Analyze a file system path and suggest correct MCP parameters';
|
|
14
|
+
this.parameters = {
|
|
15
|
+
path: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
description: 'File system path to analyze (file or directory)',
|
|
18
|
+
required: true
|
|
19
|
+
},
|
|
20
|
+
suggestions: {
|
|
21
|
+
type: 'boolean',
|
|
22
|
+
description: 'Include parameter suggestions and usage examples',
|
|
23
|
+
default: true,
|
|
24
|
+
required: false
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
async execute(params, llmClient) {
|
|
29
|
+
return await withSecurity(this, params, llmClient, async (secureParams) => {
|
|
30
|
+
try {
|
|
31
|
+
const pathAnalysis = await analyzePathForMCP(secureParams.path);
|
|
32
|
+
const result = {
|
|
33
|
+
path: secureParams.path,
|
|
34
|
+
analysis: pathAnalysis,
|
|
35
|
+
timestamp: new Date().toISOString()
|
|
36
|
+
};
|
|
37
|
+
// Add usage suggestions if requested
|
|
38
|
+
if (secureParams.suggestions !== false) {
|
|
39
|
+
result.suggestions = {
|
|
40
|
+
recommendedParameter: pathAnalysis.suggestedParameter,
|
|
41
|
+
exampleUsage: pathAnalysis.type === 'directory'
|
|
42
|
+
? `houtini-lm:count_files projectPath="${secureParams.path}"`
|
|
43
|
+
: `houtini-lm:analyze_single_file filePath="${secureParams.path}"`,
|
|
44
|
+
alternativeUsage: pathAnalysis.type === 'directory'
|
|
45
|
+
? `houtini-lm:security_audit projectPath="${secureParams.path}"`
|
|
46
|
+
: `houtini-lm:generate_unit_tests filePath="${secureParams.path}"`
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
success: true,
|
|
51
|
+
timestamp: new Date().toISOString(),
|
|
52
|
+
modelUsed: 'system-utility',
|
|
53
|
+
executionTimeMs: 0,
|
|
54
|
+
data: {
|
|
55
|
+
content: result,
|
|
56
|
+
metadata: {
|
|
57
|
+
functionName: 'resolve_path',
|
|
58
|
+
parsedAt: new Date().toISOString(),
|
|
59
|
+
responseLength: JSON.stringify(result).length
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
return {
|
|
66
|
+
success: false,
|
|
67
|
+
timestamp: new Date().toISOString(),
|
|
68
|
+
modelUsed: 'system-utility',
|
|
69
|
+
executionTimeMs: 0,
|
|
70
|
+
error: {
|
|
71
|
+
code: 'PATH_RESOLUTION_ERROR',
|
|
72
|
+
message: error.message || 'Failed to analyze path',
|
|
73
|
+
details: { originalError: error.message }
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
// Not used for system functions, but required by interface
|
|
80
|
+
getPromptStages(params) {
|
|
81
|
+
return {
|
|
82
|
+
systemAndContext: 'Path resolution system function',
|
|
83
|
+
dataPayload: `Path: ${params.path}`,
|
|
84
|
+
outputInstructions: 'Return path analysis and suggestions'
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Export as default for plugin loader
|
|
89
|
+
export default PathResolverPlugin;
|
|
90
|
+
//# sourceMappingURL=path-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-resolver.js","sourceRoot":"","sources":["../../src/system/path-resolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,MAAM,OAAO,kBAAmB,SAAQ,UAAU;IAAlD;;QACE,SAAI,GAAG,cAAc,CAAC;QACtB,aAAQ,GAAG,QAAiB,CAAC;QAC7B,gBAAW,GAAG,+DAA+D,CAAC;QAE9E,eAAU,GAAG;YACX,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAiB;gBACvB,WAAW,EAAE,iDAAiD;gBAC9D,QAAQ,EAAE,IAAI;aACf;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,SAAkB;gBACxB,WAAW,EAAE,kDAAkD;gBAC/D,OAAO,EAAE,IAAI;gBACb,QAAQ,EAAE,KAAK;aAChB;SACF,CAAC;IAiEJ,CAAC;IA/DC,KAAK,CAAC,OAAO,CAAC,MAAW,EAAE,SAAc;QACvC,OAAO,MAAM,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE;YACxE,IAAI,CAAC;gBACH,MAAM,YAAY,GAAG,MAAM,iBAAiB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;gBAEhE,MAAM,MAAM,G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AAuB;wBAC7B,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,wBAAwB;wBAClD,OAAO,EAAE,EAAE,aAAa,EAAE,KAAK,CAAC,OAAO,EAAE;qBAC1C;iBACF,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,2DAA2D;IAC3D,eAAe,CAAC,MAAW;QACzB,OAAO;YACL,gBAAgB,EAAE,iCAAiC;YACnD,WAAW,EAAE,SAAS,MAAM,CAAC,IAAI,EAAE;YACnC,kBAAkB,EAAE,sCAAsC;SAC3D,CAAC;IACJ,CAAC;CACF;AAED,sCAAsC;AACtC,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
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
|
+
import { BasePlugin } from '../plugins/base-plugin.js';
|
|
19
|
+
import { IPromptPlugin } from '../prompts/shared/types.js';
|
|
20
|
+
import { PromptStages } from '../types/prompt-stages.js';
|
|
21
|
+
export declare class TEMPLATE_UniversalPlugin extends BasePlugin implements IPromptPlugin {
|
|
22
|
+
name: string;
|
|
23
|
+
category: "analyze";
|
|
24
|
+
description: string;
|
|
25
|
+
parameters: {
|
|
26
|
+
code: {
|
|
27
|
+
type: "string";
|
|
28
|
+
description: string;
|
|
29
|
+
required: boolean;
|
|
30
|
+
};
|
|
31
|
+
filePath: {
|
|
32
|
+
type: "string";
|
|
33
|
+
description: string;
|
|
34
|
+
required: boolean;
|
|
35
|
+
};
|
|
36
|
+
projectPath: {
|
|
37
|
+
type: "string";
|
|
38
|
+
description: string;
|
|
39
|
+
required: boolean;
|
|
40
|
+
};
|
|
41
|
+
files: {
|
|
42
|
+
type: "array";
|
|
43
|
+
description: string;
|
|
44
|
+
required: boolean;
|
|
45
|
+
items: {
|
|
46
|
+
type: "string";
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
maxDepth: {
|
|
50
|
+
type: "number";
|
|
51
|
+
description: string;
|
|
52
|
+
required: boolean;
|
|
53
|
+
default: number;
|
|
54
|
+
};
|
|
55
|
+
language: {
|
|
56
|
+
type: "string";
|
|
57
|
+
description: string;
|
|
58
|
+
required: boolean;
|
|
59
|
+
default: string;
|
|
60
|
+
};
|
|
61
|
+
analysisDepth: {
|
|
62
|
+
type: "string";
|
|
63
|
+
description: string;
|
|
64
|
+
enum: string[];
|
|
65
|
+
default: string;
|
|
66
|
+
required: boolean;
|
|
67
|
+
};
|
|
68
|
+
analysisType: {
|
|
69
|
+
type: "string";
|
|
70
|
+
description: string;
|
|
71
|
+
enum: string[];
|
|
72
|
+
default: string;
|
|
73
|
+
required: boolean;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
private analysisCache;
|
|
77
|
+
private multiFileAnalysis;
|
|
78
|
+
constructor();
|
|
79
|
+
execute(params: any, llmClient: any): Promise<any>;
|
|
80
|
+
/**
|
|
81
|
+
* Auto-detect whether this is single-file or multi-file analysis
|
|
82
|
+
*
|
|
83
|
+
* DETECTION GUIDE:
|
|
84
|
+
* Single-file: code, filePath provided → analyze individual file
|
|
85
|
+
* Multi-file: projectPath, files, maxDepth provided → analyze project/multiple files
|
|
86
|
+
* Default: Choose based on your plugin's primary use case
|
|
87
|
+
*/
|
|
88
|
+
private detectAnalysisMode;
|
|
89
|
+
/**
|
|
90
|
+
* Validate parameters based on detected analysis mode
|
|
91
|
+
*/
|
|
92
|
+
private validateParameters;
|
|
93
|
+
/**
|
|
94
|
+
* Execute single-file analysis
|
|
95
|
+
*/
|
|
96
|
+
private executeSingleFileAnalysis;
|
|
97
|
+
/**
|
|
98
|
+
* Execute multi-file analysis
|
|
99
|
+
*/
|
|
100
|
+
private executeMultiFileAnalysis;
|
|
101
|
+
/**
|
|
102
|
+
* TEMPLATE: Implement your single-file prompt stages
|
|
103
|
+
*/
|
|
104
|
+
private getSingleFilePromptStages;
|
|
105
|
+
/**
|
|
106
|
+
* TEMPLATE: Implement your multi-file prompt stages
|
|
107
|
+
*/
|
|
108
|
+
private getMultiFilePromptStages;
|
|
109
|
+
/**
|
|
110
|
+
* TEMPLATE: Implement for backwards compatibility
|
|
111
|
+
* The system still expects this method, so we intelligently route to the appropriate stages
|
|
112
|
+
*/
|
|
113
|
+
getPromptStages(params: any): PromptStages;
|
|
114
|
+
private discoverRelevantFiles;
|
|
115
|
+
private performMultiFileAnalysis;
|
|
116
|
+
private analyzeIndividualFile;
|
|
117
|
+
private getFileExtensions;
|
|
118
|
+
private generateCacheKey;
|
|
119
|
+
}
|
|
120
|
+
export default TEMPLATE_UniversalPlugin;
|
|
121
|
+
//# sourceMappingURL=plugin-template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-template.d.ts","sourceRoot":"","sources":["../../src/templates/plugin-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AASH,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAgBzD,qBAAa,wBAAyB,SAAQ,UAAW,YAAW,aAAa;IAC/E,IAAI,SAA4B;IAChC,QAAQ,EAAG,SAAS,CAAU;IAC9B,WAAW,SAAmF;IAG9F,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAqDR;IAEF,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,iBAAiB,CAA2B;;IAO9C,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG;IAyBzC;;;;;;;OAOG;IACH,OAAO,CAAC,kBAAkB;IAiB1B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAa1B;;OAEG;YACW,yBAAyB;IA0CvC;;OAEG;YACW,wBAAwB;IA0CtC;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAyDjC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAwDhC;;;OAGG;IACH,eAAe,CAAC,MAAM,EAAE,GAAG,GAAG,YAAY;YAW5B,qBAAqB;YASrB,wBAAwB;YAyCxB,qBAAqB;IAenC,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,gBAAgB;CAKzB;AAED,eAAe,wBAAwB,CAAC"}
|