orchid-ai 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/README.md +225 -0
- package/dist/components/ChatPanel.d.ts +123 -0
- package/dist/components/Conversation.d.ts +75 -0
- package/dist/components/ErrorBoundary.d.ts +16 -0
- package/dist/components/Icon.d.ts +84 -0
- package/dist/components/ModelSwitcher.d.ts +24 -0
- package/dist/components/SuggestionsPanel.d.ts +27 -0
- package/dist/constants.d.ts +353 -0
- package/dist/hooks/useAiMerge.d.ts +20 -0
- package/dist/hooks/useModelSwitcher.d.ts +65 -0
- package/dist/hooks/useStreamingAI.d.ts +29 -0
- package/dist/hooks/useSuggestions.d.ts +48 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.esm.js +3385 -0
- package/dist/index.js +3400 -0
- package/dist/server/components/ChatPanel.d.ts +123 -0
- package/dist/server/components/Conversation.d.ts +75 -0
- package/dist/server/components/ErrorBoundary.d.ts +16 -0
- package/dist/server/components/Icon.d.ts +84 -0
- package/dist/server/components/ModelSwitcher.d.ts +24 -0
- package/dist/server/components/SuggestionsPanel.d.ts +27 -0
- package/dist/server/constants.d.ts +353 -0
- package/dist/server/contextual-service.d.ts +59 -0
- package/dist/server/document-processor.d.ts +60 -0
- package/dist/server/hooks/useAiMerge.d.ts +20 -0
- package/dist/server/hooks/useModelSwitcher.d.ts +65 -0
- package/dist/server/hooks/useStreamingAI.d.ts +29 -0
- package/dist/server/hooks/useSuggestions.d.ts +48 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.esm.js +14008 -0
- package/dist/server/index.js +14019 -0
- package/dist/server/server/contextual-service.d.ts +59 -0
- package/dist/server/server/document-processor.d.ts +60 -0
- package/dist/server/server/index.d.ts +7 -0
- package/dist/server/server/server.d.ts +32 -0
- package/dist/server/server/service.d.ts +267 -0
- package/dist/server/server/training-schema.d.ts +17 -0
- package/dist/server/server/training.d.ts +231 -0
- package/dist/server/server/utils.d.ts +209 -0
- package/dist/server/server.d.ts +32 -0
- package/dist/server/service.d.ts +267 -0
- package/dist/server/training-schema.d.ts +17 -0
- package/dist/server/training.d.ts +231 -0
- package/dist/server/types/types.d.ts +481 -0
- package/dist/server/utils/fileHandler.d.ts +20 -0
- package/dist/server/utils/mergeWithAi.d.ts +19 -0
- package/dist/server/utils.d.ts +209 -0
- package/dist/types/types.d.ts +481 -0
- package/dist/utils/fileHandler.d.ts +20 -0
- package/dist/utils/mergeWithAi.d.ts +19 -0
- package/dist/utils.d.ts +19 -0
- package/package.json +137 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ContextualServiceConfig, ContextualRequest } from '../types/types.js';
|
|
2
|
+
export declare class ContextualCommandService {
|
|
3
|
+
private config;
|
|
4
|
+
private verboseLogging;
|
|
5
|
+
private usage;
|
|
6
|
+
constructor(config: ContextualServiceConfig);
|
|
7
|
+
private autoConfigureProviders;
|
|
8
|
+
private log;
|
|
9
|
+
private handleError;
|
|
10
|
+
/**
|
|
11
|
+
* Build a focused system prompt based on schema and chat level
|
|
12
|
+
*/
|
|
13
|
+
private buildContextualSystemPrompt;
|
|
14
|
+
/**
|
|
15
|
+
* Format schema fields into readable descriptions
|
|
16
|
+
*/
|
|
17
|
+
private formatSchemaFields;
|
|
18
|
+
/**
|
|
19
|
+
* Create a model instance for a specific request
|
|
20
|
+
*/
|
|
21
|
+
private createModelForRequest;
|
|
22
|
+
private createModelInstance;
|
|
23
|
+
private getApiKeyForProvider;
|
|
24
|
+
/**
|
|
25
|
+
* Stream suggestions with contextual schema information
|
|
26
|
+
*/
|
|
27
|
+
streamSuggestions(request: ContextualRequest, onData: (data: any) => void, onDone: () => void, onError: (error: Error) => void): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Get non-streaming suggestions
|
|
30
|
+
*/
|
|
31
|
+
getSuggestions(request: ContextualRequest): Promise<any[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Get available models
|
|
34
|
+
*/
|
|
35
|
+
getAvailableModels(): Promise<{
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
provider: string;
|
|
39
|
+
available: boolean;
|
|
40
|
+
}[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Get usage statistics
|
|
43
|
+
*/
|
|
44
|
+
getUsageStats(): {
|
|
45
|
+
requests: number;
|
|
46
|
+
totalTokens: number;
|
|
47
|
+
totalComputeUnits: number;
|
|
48
|
+
providers: {
|
|
49
|
+
name: string;
|
|
50
|
+
requests: number;
|
|
51
|
+
computeUnits: number;
|
|
52
|
+
models: string[];
|
|
53
|
+
}[];
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Track request for usage stats
|
|
57
|
+
*/
|
|
58
|
+
private trackRequest;
|
|
59
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export interface ProcessedFile {
|
|
2
|
+
name: string;
|
|
3
|
+
type: string;
|
|
4
|
+
size: number;
|
|
5
|
+
content: string;
|
|
6
|
+
isImage: boolean;
|
|
7
|
+
originalData?: string;
|
|
8
|
+
fileData?: string;
|
|
9
|
+
metadata?: {
|
|
10
|
+
dimensions?: {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
};
|
|
14
|
+
encoding?: string;
|
|
15
|
+
pages?: number;
|
|
16
|
+
sheets?: string[];
|
|
17
|
+
rows?: number;
|
|
18
|
+
columns?: string[];
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export declare class DocumentProcessor {
|
|
22
|
+
/**
|
|
23
|
+
* Process a single file and extract its content
|
|
24
|
+
*/
|
|
25
|
+
static processFile(file: {
|
|
26
|
+
name: string;
|
|
27
|
+
type: string;
|
|
28
|
+
size: number;
|
|
29
|
+
data: string;
|
|
30
|
+
}, aiService?: string): Promise<ProcessedFile>;
|
|
31
|
+
/**
|
|
32
|
+
* Process multiple files and return both processed files and image data for AI
|
|
33
|
+
*/
|
|
34
|
+
static processFiles(files: Array<{
|
|
35
|
+
name: string;
|
|
36
|
+
type: string;
|
|
37
|
+
size: number;
|
|
38
|
+
data: string;
|
|
39
|
+
}>, aiService?: string): Promise<{
|
|
40
|
+
processedFiles: ProcessedFile[];
|
|
41
|
+
imageData: Array<{
|
|
42
|
+
data: string;
|
|
43
|
+
type: string;
|
|
44
|
+
name: string;
|
|
45
|
+
}>;
|
|
46
|
+
fileData: string[];
|
|
47
|
+
textContent: string;
|
|
48
|
+
}>;
|
|
49
|
+
private static getSupportedFormats;
|
|
50
|
+
private static processImage;
|
|
51
|
+
private static isImageFile;
|
|
52
|
+
private static processPDF;
|
|
53
|
+
private static processTextFile;
|
|
54
|
+
private static processRTF;
|
|
55
|
+
private static processCSV;
|
|
56
|
+
private static formatFileSize;
|
|
57
|
+
private static processJSON;
|
|
58
|
+
private static processXML;
|
|
59
|
+
private static isValidUTF8Text;
|
|
60
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TrainingConfig, ServerOptions, AIProvider, CommandServer, ContextualServiceConfig, ContextualRequest, SchemaDefinition, SchemaProperty } from '../types/types.js';
|
|
2
|
+
export type { ServerOptions, CommandServer, TrainingConfig, AIProvider, ContextualServiceConfig, ContextualRequest, SchemaDefinition, SchemaProperty, };
|
|
3
|
+
export { setupCommandServer, createCommandConfig, formatErrorForUser, } from './server';
|
|
4
|
+
export { CommandService, } from './service';
|
|
5
|
+
export { ContextualCommandService, } from './contextual-service';
|
|
6
|
+
export { getTrainingDataConfig, CommandTrainingCollector, } from './training';
|
|
7
|
+
export { createTrainingConfig, validateTrainingConfig, getExpectedFileStructure, } from './training-schema';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CommandConfig, RouteConfig, TrainingCustomData, AIProvider, AIServiceConfig } from '../types/types.js';
|
|
2
|
+
export interface ServerOptions extends AIServiceConfig {
|
|
3
|
+
port?: number;
|
|
4
|
+
baseDir?: string;
|
|
5
|
+
service?: AIProvider;
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
customTrainingData?: TrainingCustomData;
|
|
8
|
+
routes?: (string | RouteConfig)[];
|
|
9
|
+
}
|
|
10
|
+
export interface CommandServer {
|
|
11
|
+
app: any;
|
|
12
|
+
start: () => void;
|
|
13
|
+
stop: () => void;
|
|
14
|
+
getConfig: () => CommandConfig;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Helper function to format error messages for user-friendly display
|
|
18
|
+
*/
|
|
19
|
+
export declare function formatErrorForUser(error: Error): {
|
|
20
|
+
message: string;
|
|
21
|
+
type: string;
|
|
22
|
+
retryAfter?: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Setup a command server with training data collection and streaming support.
|
|
26
|
+
* Works both as a standalone server and as middleware for existing Express apps.
|
|
27
|
+
*/
|
|
28
|
+
export declare function setupCommandServer(options?: ServerOptions): Promise<CommandServer>;
|
|
29
|
+
/**
|
|
30
|
+
* Create a command configuration by merging training data from multiple sources
|
|
31
|
+
*/
|
|
32
|
+
export declare function createCommandConfig(options: ServerOptions): Promise<CommandConfig>;
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { OpenAI } from 'openai';
|
|
2
|
+
import { GoogleGenerativeAI } from '@google/generative-ai';
|
|
3
|
+
import Anthropic from '@anthropic-ai/sdk';
|
|
4
|
+
import { TrainingDataPaths, AIServiceConfig, ImageContent } from '../types/types.js';
|
|
5
|
+
export declare class CommandService {
|
|
6
|
+
private aiConfig;
|
|
7
|
+
private verboseLogging;
|
|
8
|
+
private model;
|
|
9
|
+
private modelConfig;
|
|
10
|
+
private usage;
|
|
11
|
+
constructor(config: AIServiceConfig, verboseLogging?: boolean);
|
|
12
|
+
private autoConfigureProviders;
|
|
13
|
+
private log;
|
|
14
|
+
private handleError;
|
|
15
|
+
/**
|
|
16
|
+
* Initialize the service with training data
|
|
17
|
+
* This must be called before using the service
|
|
18
|
+
*/
|
|
19
|
+
initialize(): Promise<void>;
|
|
20
|
+
initializeTrainingData(): Promise<void>;
|
|
21
|
+
writeConfigToFile(): Promise<void>;
|
|
22
|
+
writeFailedJsonToFile(failedJson: string, errorMessage: string): Promise<void>;
|
|
23
|
+
tryPrettifyJson(jsonStr: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Build model configuration with current training data
|
|
26
|
+
*/
|
|
27
|
+
buildModelConfig(): {
|
|
28
|
+
claude: {
|
|
29
|
+
model: string | null | undefined;
|
|
30
|
+
system: string;
|
|
31
|
+
max_tokens: number;
|
|
32
|
+
temperature: number;
|
|
33
|
+
};
|
|
34
|
+
openai: {
|
|
35
|
+
model: string | null | undefined;
|
|
36
|
+
messages: {
|
|
37
|
+
role: string;
|
|
38
|
+
content: string;
|
|
39
|
+
}[];
|
|
40
|
+
temperature: number;
|
|
41
|
+
max_tokens: number;
|
|
42
|
+
};
|
|
43
|
+
gemini: {
|
|
44
|
+
model: string | null | undefined;
|
|
45
|
+
systemInstruction: string;
|
|
46
|
+
generationConfig: {
|
|
47
|
+
temperature: number;
|
|
48
|
+
maxOutputTokens: number;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
extractPatterns(data: TrainingDataPaths): Map<string, Set<string>>;
|
|
53
|
+
updateSystemPrompt(patterns: Map<string, Set<string>>): string;
|
|
54
|
+
getAvailableModels(): Promise<any[]>;
|
|
55
|
+
createModelInstance(provider: string, apiKey: string): OpenAI | GoogleGenerativeAI | Anthropic;
|
|
56
|
+
getModelDisplayName(modelId: string): string;
|
|
57
|
+
getSingleProviderModels(): Promise<any>;
|
|
58
|
+
/**
|
|
59
|
+
* Get complete model state (models, current, capabilities, usage) in one call
|
|
60
|
+
* This reduces API calls and ensures data consistency
|
|
61
|
+
*/
|
|
62
|
+
getModelState(): Promise<{
|
|
63
|
+
models: any[];
|
|
64
|
+
current: {
|
|
65
|
+
provider: string;
|
|
66
|
+
model: string;
|
|
67
|
+
};
|
|
68
|
+
capabilities: {
|
|
69
|
+
supportsImages: string;
|
|
70
|
+
};
|
|
71
|
+
usage: {
|
|
72
|
+
requests: number;
|
|
73
|
+
totalTokens: number;
|
|
74
|
+
totalComputeUnits: number;
|
|
75
|
+
modelSwitches: number;
|
|
76
|
+
uptime: number;
|
|
77
|
+
providers: {
|
|
78
|
+
name: string;
|
|
79
|
+
requests: number;
|
|
80
|
+
models: string[];
|
|
81
|
+
}[];
|
|
82
|
+
};
|
|
83
|
+
timestamp: number;
|
|
84
|
+
}>;
|
|
85
|
+
/**
|
|
86
|
+
* Create a model instance for a specific request without changing global state
|
|
87
|
+
*/
|
|
88
|
+
createModelForRequest(modelSelection: {
|
|
89
|
+
provider: string;
|
|
90
|
+
model: string;
|
|
91
|
+
} | undefined): {
|
|
92
|
+
model: OpenAI | GoogleGenerativeAI | Anthropic;
|
|
93
|
+
config: {
|
|
94
|
+
openai: {
|
|
95
|
+
model: string;
|
|
96
|
+
temperature: number;
|
|
97
|
+
max_tokens: number;
|
|
98
|
+
messages: {
|
|
99
|
+
role: string;
|
|
100
|
+
content: string;
|
|
101
|
+
}[];
|
|
102
|
+
};
|
|
103
|
+
claude?: undefined;
|
|
104
|
+
gemini?: undefined;
|
|
105
|
+
} | {
|
|
106
|
+
claude: {
|
|
107
|
+
model: string;
|
|
108
|
+
temperature: number;
|
|
109
|
+
max_tokens: number;
|
|
110
|
+
system: string;
|
|
111
|
+
messages: never[];
|
|
112
|
+
};
|
|
113
|
+
openai?: undefined;
|
|
114
|
+
gemini?: undefined;
|
|
115
|
+
} | {
|
|
116
|
+
gemini: {
|
|
117
|
+
model: string;
|
|
118
|
+
temperature: number;
|
|
119
|
+
maxOutputTokens: number;
|
|
120
|
+
systemInstruction: string;
|
|
121
|
+
generationConfig: {
|
|
122
|
+
temperature: number;
|
|
123
|
+
maxOutputTokens: number;
|
|
124
|
+
candidateCount: number;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
openai?: undefined;
|
|
128
|
+
claude?: undefined;
|
|
129
|
+
};
|
|
130
|
+
provider: string;
|
|
131
|
+
modelId: string;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Get API key for a specific provider
|
|
135
|
+
*/
|
|
136
|
+
getApiKeyForProvider(provider: string): string | null | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* Build model configuration for a specific request
|
|
139
|
+
*/
|
|
140
|
+
buildModelConfigForRequest(provider: string, model: string): {
|
|
141
|
+
openai: {
|
|
142
|
+
model: string;
|
|
143
|
+
temperature: number;
|
|
144
|
+
max_tokens: number;
|
|
145
|
+
messages: {
|
|
146
|
+
role: string;
|
|
147
|
+
content: string;
|
|
148
|
+
}[];
|
|
149
|
+
};
|
|
150
|
+
claude?: undefined;
|
|
151
|
+
gemini?: undefined;
|
|
152
|
+
} | {
|
|
153
|
+
claude: {
|
|
154
|
+
model: string;
|
|
155
|
+
temperature: number;
|
|
156
|
+
max_tokens: number;
|
|
157
|
+
system: string;
|
|
158
|
+
messages: never[];
|
|
159
|
+
};
|
|
160
|
+
openai?: undefined;
|
|
161
|
+
gemini?: undefined;
|
|
162
|
+
} | {
|
|
163
|
+
gemini: {
|
|
164
|
+
model: string;
|
|
165
|
+
temperature: number;
|
|
166
|
+
maxOutputTokens: number;
|
|
167
|
+
systemInstruction: string;
|
|
168
|
+
generationConfig: {
|
|
169
|
+
temperature: number;
|
|
170
|
+
maxOutputTokens: number;
|
|
171
|
+
candidateCount: number;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
openai?: undefined;
|
|
175
|
+
claude?: undefined;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Get suggestions for a command
|
|
179
|
+
* @param command - The command to get suggestions for
|
|
180
|
+
* @param chatHistory - The chat history
|
|
181
|
+
* @param retryCount - The number of retries
|
|
182
|
+
* @param chatLevel - The chat level
|
|
183
|
+
* @param modelSelection - The model selection
|
|
184
|
+
* @returns The suggestions
|
|
185
|
+
*/
|
|
186
|
+
getSuggestions(command: string, chatHistory: any[] | undefined, retryCount: number | undefined, chatLevel: 'full' | 'basic' | 'none' | undefined, modelSelection: {
|
|
187
|
+
provider: string;
|
|
188
|
+
model: string;
|
|
189
|
+
} | undefined, context?: string): Promise<Array<{
|
|
190
|
+
action?: string;
|
|
191
|
+
path?: string;
|
|
192
|
+
formState?: Record<string, any>;
|
|
193
|
+
[key: string]: any;
|
|
194
|
+
}>>;
|
|
195
|
+
/**
|
|
196
|
+
* Check if a response is effectively empty and needs retry
|
|
197
|
+
*/
|
|
198
|
+
isEmptyResponse(text: string, suggestions?: any[] | null): boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Create a retry prompt that encourages more helpful responses
|
|
201
|
+
*/
|
|
202
|
+
createRetryPrompt(originalCommand: string, retryCount: number): string;
|
|
203
|
+
streamSuggestions(command: string, userId: string, chatHistory: any[], onData: (data: any) => void, onDone: () => void, onError: (error: Error) => void, images?: any[], retryCount?: number, chatLevel?: 'full' | 'basic' | 'none' | undefined, modelSelection?: {
|
|
204
|
+
provider: string;
|
|
205
|
+
model: string;
|
|
206
|
+
capabilities: {
|
|
207
|
+
computeWeight: number;
|
|
208
|
+
imageSupport: boolean;
|
|
209
|
+
};
|
|
210
|
+
}, context?: string): Promise<void>;
|
|
211
|
+
getSuggestionsWithImages(command: string, chatHistory: any[], images: any[], modelSelection?: {
|
|
212
|
+
provider: string;
|
|
213
|
+
model: string;
|
|
214
|
+
} | undefined): Promise<{
|
|
215
|
+
formState: Record<string, any>;
|
|
216
|
+
action?: string;
|
|
217
|
+
actionType: import("../types/types.js").Action;
|
|
218
|
+
path?: string;
|
|
219
|
+
queryParams?: Record<string, string>;
|
|
220
|
+
message?: string;
|
|
221
|
+
user?: import("../types/types.js").User;
|
|
222
|
+
initials?: string;
|
|
223
|
+
color?: string;
|
|
224
|
+
shortcut?: string;
|
|
225
|
+
title?: string;
|
|
226
|
+
description?: string;
|
|
227
|
+
}[]>;
|
|
228
|
+
getUsageStats(): {
|
|
229
|
+
requests: number;
|
|
230
|
+
totalTokens: number;
|
|
231
|
+
totalComputeUnits: number;
|
|
232
|
+
modelSwitches: number;
|
|
233
|
+
uptime: number;
|
|
234
|
+
providers: {
|
|
235
|
+
name: string;
|
|
236
|
+
requests: number;
|
|
237
|
+
models: string[];
|
|
238
|
+
}[];
|
|
239
|
+
};
|
|
240
|
+
resetUsageStats(): void;
|
|
241
|
+
trackRequest(provider: string, tokenCount?: number): void;
|
|
242
|
+
/**
|
|
243
|
+
* Helper: Refine fields that require refinement
|
|
244
|
+
*/
|
|
245
|
+
refineFieldsIfNeeded(suggestions: any, context: any, messages?: any[], provider?: string | null): Promise<any>;
|
|
246
|
+
/**
|
|
247
|
+
* Helper: Get raw response content from any provider
|
|
248
|
+
*/
|
|
249
|
+
getProviderResponse(command: string | ImageContent[], chatHistory: any[] | undefined, messages?: any[], provider?: string | null): Promise<any>;
|
|
250
|
+
/**
|
|
251
|
+
* Helper: Process suggestions with full pipeline
|
|
252
|
+
*/
|
|
253
|
+
processSuggestionsPipeline(suggestions: any[], context: any, messages?: any[], provider?: string | null): Promise<{
|
|
254
|
+
formState: Record<string, any>;
|
|
255
|
+
action?: string;
|
|
256
|
+
actionType: import("../types/types.js").Action;
|
|
257
|
+
path?: string;
|
|
258
|
+
queryParams?: Record<string, string>;
|
|
259
|
+
message?: string;
|
|
260
|
+
user?: import("../types/types.js").User;
|
|
261
|
+
initials?: string;
|
|
262
|
+
color?: string;
|
|
263
|
+
shortcut?: string;
|
|
264
|
+
title?: string;
|
|
265
|
+
description?: string;
|
|
266
|
+
}[]>;
|
|
267
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TrainingConfig } from '../types/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validate training configuration
|
|
4
|
+
*/
|
|
5
|
+
export declare function validateTrainingConfig(config: TrainingConfig): {
|
|
6
|
+
isValid: boolean;
|
|
7
|
+
errors: string[];
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Create a normalized training configuration
|
|
11
|
+
*/
|
|
12
|
+
export declare function createTrainingConfig(options?: Partial<TrainingConfig>): TrainingConfig;
|
|
13
|
+
/**
|
|
14
|
+
* Gets the expected file structure for training data
|
|
15
|
+
* @returns Expected file structure
|
|
16
|
+
*/
|
|
17
|
+
export declare function getExpectedFileStructure(): Record<string, string>;
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import type { TrainingConfig, ProcessedTrainingData } from '../types/types.js';
|
|
2
|
+
interface CollectedFile {
|
|
3
|
+
filePath: string;
|
|
4
|
+
path: string;
|
|
5
|
+
content: any;
|
|
6
|
+
}
|
|
7
|
+
export declare function getTrainingDataConfig(chatLevel?: string): TrainingConfig;
|
|
8
|
+
export declare class CommandTrainingCollector {
|
|
9
|
+
private rootDir;
|
|
10
|
+
private config;
|
|
11
|
+
private verboseLogging;
|
|
12
|
+
private rules;
|
|
13
|
+
private structuredData;
|
|
14
|
+
constructor(rootDir: string, config: TrainingConfig, verboseLogging?: boolean);
|
|
15
|
+
log(...args: any[]): void;
|
|
16
|
+
collectTrainingData(): Promise<ProcessedTrainingData>;
|
|
17
|
+
private collectRawData;
|
|
18
|
+
private buildStructuredData;
|
|
19
|
+
private buildDataModels;
|
|
20
|
+
private buildComponents;
|
|
21
|
+
private buildNavigation;
|
|
22
|
+
private buildBusinessRules;
|
|
23
|
+
private buildExamples;
|
|
24
|
+
private updateOverview;
|
|
25
|
+
private generateProviderFormats;
|
|
26
|
+
private guessEntityFromComponent;
|
|
27
|
+
private guessEntitiesFromComponent;
|
|
28
|
+
private extractRouteParams;
|
|
29
|
+
private guessEntityFromPath;
|
|
30
|
+
getTrainingConfig(): TrainingConfig;
|
|
31
|
+
collectFiles(fieldName: string, filePaths?: string[]): Promise<CollectedFile[]>;
|
|
32
|
+
expandGlobPatterns(patterns: string[]): Promise<string[]>;
|
|
33
|
+
extractFileInfo(fieldName: string, content: string): {
|
|
34
|
+
componentName: string | null;
|
|
35
|
+
props: Array<{
|
|
36
|
+
interfaceName: string;
|
|
37
|
+
properties: Array<{
|
|
38
|
+
name: string;
|
|
39
|
+
type: string;
|
|
40
|
+
optional: boolean;
|
|
41
|
+
}>;
|
|
42
|
+
}>;
|
|
43
|
+
state: Array<{
|
|
44
|
+
type: string;
|
|
45
|
+
variable: string | null;
|
|
46
|
+
}>;
|
|
47
|
+
functions: Array<{
|
|
48
|
+
name: string;
|
|
49
|
+
signature: string;
|
|
50
|
+
}>;
|
|
51
|
+
routes: string[];
|
|
52
|
+
formFields: string[];
|
|
53
|
+
imports: string[];
|
|
54
|
+
exports: string[];
|
|
55
|
+
hooks: string[];
|
|
56
|
+
eventHandlers: string[];
|
|
57
|
+
} | {
|
|
58
|
+
modelName: string | null;
|
|
59
|
+
fields: Array<{
|
|
60
|
+
name: string;
|
|
61
|
+
type: string;
|
|
62
|
+
required: boolean;
|
|
63
|
+
dataType: string;
|
|
64
|
+
transform: any;
|
|
65
|
+
validation: any;
|
|
66
|
+
}>;
|
|
67
|
+
indexes: Array<{
|
|
68
|
+
field: string;
|
|
69
|
+
direction: string;
|
|
70
|
+
}>;
|
|
71
|
+
validations: Array<{
|
|
72
|
+
field: string;
|
|
73
|
+
rule: string;
|
|
74
|
+
}>;
|
|
75
|
+
} | {
|
|
76
|
+
definitions: string[];
|
|
77
|
+
constValues: Array<{
|
|
78
|
+
name: string;
|
|
79
|
+
value: any;
|
|
80
|
+
type: string;
|
|
81
|
+
}>;
|
|
82
|
+
enums: Array<{
|
|
83
|
+
name: string;
|
|
84
|
+
members: Array<{
|
|
85
|
+
name: string;
|
|
86
|
+
value: string;
|
|
87
|
+
}>;
|
|
88
|
+
}>;
|
|
89
|
+
enumValues: string[];
|
|
90
|
+
} | {
|
|
91
|
+
types: string[];
|
|
92
|
+
typeDefinitions: Array<{
|
|
93
|
+
name: string;
|
|
94
|
+
definition: string;
|
|
95
|
+
}>;
|
|
96
|
+
interfaces: string[];
|
|
97
|
+
interfaceDefinitions: Array<{
|
|
98
|
+
name: string;
|
|
99
|
+
properties: Array<{
|
|
100
|
+
name: string;
|
|
101
|
+
type: string;
|
|
102
|
+
optional: boolean;
|
|
103
|
+
}>;
|
|
104
|
+
}>;
|
|
105
|
+
enums: Array<{
|
|
106
|
+
name: string;
|
|
107
|
+
members: Array<{
|
|
108
|
+
name: string;
|
|
109
|
+
value: string;
|
|
110
|
+
}>;
|
|
111
|
+
}>;
|
|
112
|
+
enumMembers: string[];
|
|
113
|
+
} | {
|
|
114
|
+
content: string;
|
|
115
|
+
};
|
|
116
|
+
collectComponents(): Promise<CollectedFile[]>;
|
|
117
|
+
collectSchemas(): Promise<CollectedFile[]>;
|
|
118
|
+
collectConstants(): Promise<CollectedFile[]>;
|
|
119
|
+
collectTypes(): Promise<CollectedFile[]>;
|
|
120
|
+
extractComponentInfo(content: string): {
|
|
121
|
+
componentName: string | null;
|
|
122
|
+
props: Array<{
|
|
123
|
+
interfaceName: string;
|
|
124
|
+
properties: Array<{
|
|
125
|
+
name: string;
|
|
126
|
+
type: string;
|
|
127
|
+
optional: boolean;
|
|
128
|
+
}>;
|
|
129
|
+
}>;
|
|
130
|
+
state: Array<{
|
|
131
|
+
type: string;
|
|
132
|
+
variable: string | null;
|
|
133
|
+
}>;
|
|
134
|
+
functions: Array<{
|
|
135
|
+
name: string;
|
|
136
|
+
signature: string;
|
|
137
|
+
}>;
|
|
138
|
+
routes: string[];
|
|
139
|
+
formFields: string[];
|
|
140
|
+
imports: string[];
|
|
141
|
+
exports: string[];
|
|
142
|
+
hooks: string[];
|
|
143
|
+
eventHandlers: string[];
|
|
144
|
+
};
|
|
145
|
+
extractSchemaInfo(content: string): {
|
|
146
|
+
modelName: string | null;
|
|
147
|
+
fields: Array<{
|
|
148
|
+
name: string;
|
|
149
|
+
type: string;
|
|
150
|
+
required: boolean;
|
|
151
|
+
dataType: string;
|
|
152
|
+
transform: any;
|
|
153
|
+
validation: any;
|
|
154
|
+
}>;
|
|
155
|
+
indexes: Array<{
|
|
156
|
+
field: string;
|
|
157
|
+
direction: string;
|
|
158
|
+
}>;
|
|
159
|
+
validations: Array<{
|
|
160
|
+
field: string;
|
|
161
|
+
rule: string;
|
|
162
|
+
}>;
|
|
163
|
+
};
|
|
164
|
+
extractConstantsInfo(content: string): {
|
|
165
|
+
definitions: string[];
|
|
166
|
+
constValues: Array<{
|
|
167
|
+
name: string;
|
|
168
|
+
value: any;
|
|
169
|
+
type: string;
|
|
170
|
+
}>;
|
|
171
|
+
enums: Array<{
|
|
172
|
+
name: string;
|
|
173
|
+
members: Array<{
|
|
174
|
+
name: string;
|
|
175
|
+
value: string;
|
|
176
|
+
}>;
|
|
177
|
+
}>;
|
|
178
|
+
enumValues: string[];
|
|
179
|
+
};
|
|
180
|
+
extractTypeInfo(content: string): {
|
|
181
|
+
types: string[];
|
|
182
|
+
typeDefinitions: Array<{
|
|
183
|
+
name: string;
|
|
184
|
+
definition: string;
|
|
185
|
+
}>;
|
|
186
|
+
interfaces: string[];
|
|
187
|
+
interfaceDefinitions: Array<{
|
|
188
|
+
name: string;
|
|
189
|
+
properties: Array<{
|
|
190
|
+
name: string;
|
|
191
|
+
type: string;
|
|
192
|
+
optional: boolean;
|
|
193
|
+
}>;
|
|
194
|
+
}>;
|
|
195
|
+
enums: Array<{
|
|
196
|
+
name: string;
|
|
197
|
+
members: Array<{
|
|
198
|
+
name: string;
|
|
199
|
+
value: string;
|
|
200
|
+
}>;
|
|
201
|
+
}>;
|
|
202
|
+
enumMembers: string[];
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* Parse interface properties from a TypeScript interface
|
|
206
|
+
* @param {string} propertiesText - The properties section of an interface
|
|
207
|
+
* @returns {Array<{name: string, type: string, optional: boolean}>}
|
|
208
|
+
*/
|
|
209
|
+
parseInterfaceProperties(propertiesText: string): {
|
|
210
|
+
name: string;
|
|
211
|
+
type: string;
|
|
212
|
+
optional: boolean;
|
|
213
|
+
}[];
|
|
214
|
+
/**
|
|
215
|
+
* Parse enum members from a TypeScript enum
|
|
216
|
+
* @param {string} membersText - The members section of an enum
|
|
217
|
+
* @returns {Array<{name: string, value: string}>}
|
|
218
|
+
*/
|
|
219
|
+
parseEnumMembers(membersText: string): {
|
|
220
|
+
name: string;
|
|
221
|
+
value: string;
|
|
222
|
+
}[];
|
|
223
|
+
/**
|
|
224
|
+
* Extract state variable name from useState hook
|
|
225
|
+
* @param {string} content - File content
|
|
226
|
+
* @param {number} stateIndex - Index of useState match
|
|
227
|
+
* @returns {string|null}
|
|
228
|
+
*/
|
|
229
|
+
extractStateVariable(content: string, stateIndex: number): string | null;
|
|
230
|
+
}
|
|
231
|
+
export {};
|