atlas-pipeline-mcp 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/.env.example +21 -0
- package/LICENSE +21 -0
- package/README.md +175 -0
- package/dist/mcp.d.ts +21 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +404 -0
- package/dist/mcp.js.map +1 -0
- package/dist/pipeline.d.ts +39 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +355 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/providers/index.d.ts +14 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +13 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/llm-provider.d.ts +71 -0
- package/dist/providers/llm-provider.d.ts.map +1 -0
- package/dist/providers/llm-provider.js +357 -0
- package/dist/providers/llm-provider.js.map +1 -0
- package/dist/server.d.ts +27 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +312 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/context.d.ts +23 -0
- package/dist/tools/context.d.ts.map +1 -0
- package/dist/tools/context.js +363 -0
- package/dist/tools/context.js.map +1 -0
- package/dist/tools/critique.d.ts +40 -0
- package/dist/tools/critique.d.ts.map +1 -0
- package/dist/tools/critique.js +315 -0
- package/dist/tools/critique.js.map +1 -0
- package/dist/tools/decompose.d.ts +34 -0
- package/dist/tools/decompose.d.ts.map +1 -0
- package/dist/tools/decompose.js +328 -0
- package/dist/tools/decompose.js.map +1 -0
- package/dist/tools/git.d.ts +66 -0
- package/dist/tools/git.d.ts.map +1 -0
- package/dist/tools/git.js +333 -0
- package/dist/tools/git.js.map +1 -0
- package/dist/tools/intent.d.ts +24 -0
- package/dist/tools/intent.d.ts.map +1 -0
- package/dist/tools/intent.js +245 -0
- package/dist/tools/intent.js.map +1 -0
- package/dist/tools/ollama.d.ts +104 -0
- package/dist/tools/ollama.d.ts.map +1 -0
- package/dist/tools/ollama.js +299 -0
- package/dist/tools/ollama.js.map +1 -0
- package/dist/tools/optimize.d.ts +64 -0
- package/dist/tools/optimize.d.ts.map +1 -0
- package/dist/tools/optimize.js +302 -0
- package/dist/tools/optimize.js.map +1 -0
- package/dist/tools/variants.d.ts +49 -0
- package/dist/tools/variants.d.ts.map +1 -0
- package/dist/tools/variants.js +252 -0
- package/dist/tools/variants.js.map +1 -0
- package/dist/types.d.ts +447 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +25 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +117 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +279 -0
- package/dist/utils.js.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Atlas Server - Ollama API Wrapper
|
|
3
|
+
*
|
|
4
|
+
* Provides a typed, resilient interface to the Ollama API with:
|
|
5
|
+
* - Automatic model detection and selection
|
|
6
|
+
* - Automatic retries with exponential backoff
|
|
7
|
+
* - Structured prompt building
|
|
8
|
+
* - Response parsing and validation
|
|
9
|
+
* - Timeout handling
|
|
10
|
+
*/
|
|
11
|
+
import type { OllamaConfig, GenerationOptions, GenerationResponse } from '../types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Wrapper around the Ollama API providing structured generation
|
|
14
|
+
* Automatically detects and uses available models from user's Ollama installation
|
|
15
|
+
*/
|
|
16
|
+
export declare class OllamaClient {
|
|
17
|
+
private client;
|
|
18
|
+
private config;
|
|
19
|
+
private initialized;
|
|
20
|
+
constructor(config?: Partial<OllamaConfig>);
|
|
21
|
+
/**
|
|
22
|
+
* Initialize the client and auto-detect model if not specified
|
|
23
|
+
*/
|
|
24
|
+
initialize(): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Check if Ollama service is available and initialize
|
|
27
|
+
*/
|
|
28
|
+
healthCheck(): Promise<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* List available models
|
|
31
|
+
*/
|
|
32
|
+
listModels(): Promise<string[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Ensure client is initialized before generating
|
|
35
|
+
*/
|
|
36
|
+
private ensureInitialized;
|
|
37
|
+
/**
|
|
38
|
+
* Generate text completion with retry logic
|
|
39
|
+
*/
|
|
40
|
+
generate(prompt: string, options?: GenerationOptions): Promise<GenerationResponse>;
|
|
41
|
+
/**
|
|
42
|
+
* Generate structured JSON output
|
|
43
|
+
*
|
|
44
|
+
* Instructs the model to output valid JSON and attempts to parse it.
|
|
45
|
+
*/
|
|
46
|
+
generateJson<T>(prompt: string, options?: GenerationOptions): Promise<{
|
|
47
|
+
data: T | null;
|
|
48
|
+
raw: string;
|
|
49
|
+
stats: GenerationResponse['stats'];
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Chat-style generation with message history
|
|
53
|
+
*/
|
|
54
|
+
chat(messages: Array<{
|
|
55
|
+
role: 'system' | 'user' | 'assistant';
|
|
56
|
+
content: string;
|
|
57
|
+
}>, options?: GenerationOptions): Promise<GenerationResponse>;
|
|
58
|
+
/**
|
|
59
|
+
* Build a prompt with optional system context
|
|
60
|
+
*/
|
|
61
|
+
private buildPrompt;
|
|
62
|
+
/**
|
|
63
|
+
* Get the current model name
|
|
64
|
+
*/
|
|
65
|
+
get model(): string;
|
|
66
|
+
/**
|
|
67
|
+
* Update the model to use
|
|
68
|
+
*/
|
|
69
|
+
setModel(model: string): void;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Collection of reusable prompt templates for different stages
|
|
73
|
+
*/
|
|
74
|
+
export declare const PromptTemplates: {
|
|
75
|
+
/**
|
|
76
|
+
* System prompt for intent analysis
|
|
77
|
+
*/
|
|
78
|
+
intentAnalysis: string;
|
|
79
|
+
/**
|
|
80
|
+
* System prompt for task decomposition
|
|
81
|
+
*/
|
|
82
|
+
taskDecomposition: string;
|
|
83
|
+
/**
|
|
84
|
+
* System prompt for code generation variants
|
|
85
|
+
*/
|
|
86
|
+
variantGeneration: string;
|
|
87
|
+
/**
|
|
88
|
+
* System prompt for code critique
|
|
89
|
+
*/
|
|
90
|
+
codeCritique: string;
|
|
91
|
+
/**
|
|
92
|
+
* System prompt for optimization
|
|
93
|
+
*/
|
|
94
|
+
optimization: string;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Get or create the Ollama client singleton
|
|
98
|
+
*/
|
|
99
|
+
export declare function getOllamaClient(config?: Partial<OllamaConfig>): OllamaClient;
|
|
100
|
+
/**
|
|
101
|
+
* Reset the client instance (useful for testing)
|
|
102
|
+
*/
|
|
103
|
+
export declare function resetOllamaClient(): void;
|
|
104
|
+
//# sourceMappingURL=ollama.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ollama.d.ts","sourceRoot":"","sources":["../../src/tools/ollama.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAkBrB;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,WAAW,CAAkB;gBAEzB,MAAM,GAAE,OAAO,CAAC,YAAY,CAAM;IAK9C;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAsCjC;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAmBrC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAKrC;;OAEG;YACW,iBAAiB;IAM/B;;OAEG;IACG,QAAQ,CACZ,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,kBAAkB,CAAC;IA6C9B;;;;OAIG;IACG,YAAY,CAAC,CAAC,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC;QAAE,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAA;KAAE,CAAC;IA0B/E;;OAEG;IACG,IAAI,CACR,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,EAC3E,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,kBAAkB,CAAC;IAkC9B;;OAEG;IACH,OAAO,CAAC,WAAW;IAUnB;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAI9B;AAMD;;GAEG;AACH,eAAO,MAAM,eAAe;IAC1B;;OAEG;;IASH;;OAEG;;IAUH;;OAEG;;IAUH;;OAEG;;IAWH;;OAEG;;CASJ,CAAC;AAQF;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,YAAY,CAK5E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC"}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Atlas Server - Ollama API Wrapper
|
|
3
|
+
*
|
|
4
|
+
* Provides a typed, resilient interface to the Ollama API with:
|
|
5
|
+
* - Automatic model detection and selection
|
|
6
|
+
* - Automatic retries with exponential backoff
|
|
7
|
+
* - Structured prompt building
|
|
8
|
+
* - Response parsing and validation
|
|
9
|
+
* - Timeout handling
|
|
10
|
+
*/
|
|
11
|
+
import { Ollama } from 'ollama';
|
|
12
|
+
import { logger, retry, extractJson, getErrorMessage } from '../utils.js';
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// Default Configuration
|
|
15
|
+
// ============================================================================
|
|
16
|
+
const DEFAULT_CONFIG = {
|
|
17
|
+
baseUrl: process.env['OLLAMA_BASE_URL'] ?? 'http://localhost:11434',
|
|
18
|
+
model: process.env['OLLAMA_MODEL'] ?? '', // Empty = auto-detect
|
|
19
|
+
timeoutMs: 120000,
|
|
20
|
+
maxRetries: 3,
|
|
21
|
+
};
|
|
22
|
+
// ============================================================================
|
|
23
|
+
// Ollama Client Class
|
|
24
|
+
// ============================================================================
|
|
25
|
+
/**
|
|
26
|
+
* Wrapper around the Ollama API providing structured generation
|
|
27
|
+
* Automatically detects and uses available models from user's Ollama installation
|
|
28
|
+
*/
|
|
29
|
+
export class OllamaClient {
|
|
30
|
+
client;
|
|
31
|
+
config;
|
|
32
|
+
initialized = false;
|
|
33
|
+
constructor(config = {}) {
|
|
34
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
35
|
+
this.client = new Ollama({ host: this.config.baseUrl });
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Initialize the client and auto-detect model if not specified
|
|
39
|
+
*/
|
|
40
|
+
async initialize() {
|
|
41
|
+
if (this.initialized)
|
|
42
|
+
return;
|
|
43
|
+
try {
|
|
44
|
+
const models = await this.listModels();
|
|
45
|
+
if (models.length === 0) {
|
|
46
|
+
logger.error('No models available in Ollama. Please pull a model first: ollama pull <model-name>');
|
|
47
|
+
throw new Error('No models available in Ollama');
|
|
48
|
+
}
|
|
49
|
+
// If no model specified, use the first available one
|
|
50
|
+
if (!this.config.model) {
|
|
51
|
+
this.config.model = models[0];
|
|
52
|
+
logger.info({ model: this.config.model }, 'Auto-selected first available model');
|
|
53
|
+
}
|
|
54
|
+
// Check if the specified model is available
|
|
55
|
+
else if (!models.some(m => m.startsWith(this.config.model.split(':')[0]))) {
|
|
56
|
+
const originalModel = this.config.model;
|
|
57
|
+
this.config.model = models[0];
|
|
58
|
+
logger.warn({ requested: originalModel, using: this.config.model, available: models }, 'Requested model not found, falling back to first available model');
|
|
59
|
+
}
|
|
60
|
+
logger.info({ baseUrl: this.config.baseUrl, model: this.config.model, availableModels: models }, 'Ollama client initialized');
|
|
61
|
+
this.initialized = true;
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
logger.error({ error: getErrorMessage(error) }, 'Failed to initialize Ollama client');
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Check if Ollama service is available and initialize
|
|
70
|
+
*/
|
|
71
|
+
async healthCheck() {
|
|
72
|
+
try {
|
|
73
|
+
const response = await this.client.list();
|
|
74
|
+
const hasModels = response.models.length > 0;
|
|
75
|
+
if (!hasModels) {
|
|
76
|
+
logger.warn('Ollama is running but no models are available. Run: ollama pull <model-name>');
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
// Auto-initialize on health check
|
|
80
|
+
await this.initialize();
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
logger.error({ error: getErrorMessage(error) }, 'Ollama health check failed');
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* List available models
|
|
91
|
+
*/
|
|
92
|
+
async listModels() {
|
|
93
|
+
const response = await this.client.list();
|
|
94
|
+
return response.models.map((m) => m.name);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Ensure client is initialized before generating
|
|
98
|
+
*/
|
|
99
|
+
async ensureInitialized() {
|
|
100
|
+
if (!this.initialized) {
|
|
101
|
+
await this.initialize();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Generate text completion with retry logic
|
|
106
|
+
*/
|
|
107
|
+
async generate(prompt, options = {}) {
|
|
108
|
+
await this.ensureInitialized();
|
|
109
|
+
const startTime = performance.now();
|
|
110
|
+
const response = await retry(async () => {
|
|
111
|
+
const result = await this.client.generate({
|
|
112
|
+
model: this.config.model,
|
|
113
|
+
prompt: this.buildPrompt(prompt, options.systemPrompt),
|
|
114
|
+
options: {
|
|
115
|
+
temperature: options.temperature ?? 0.7,
|
|
116
|
+
num_predict: options.maxTokens ?? 2048,
|
|
117
|
+
stop: options.stop,
|
|
118
|
+
},
|
|
119
|
+
stream: false,
|
|
120
|
+
});
|
|
121
|
+
return result;
|
|
122
|
+
}, { maxAttempts: this.config.maxRetries });
|
|
123
|
+
const totalDurationMs = Math.round(performance.now() - startTime);
|
|
124
|
+
logger.debug({
|
|
125
|
+
model: this.config.model,
|
|
126
|
+
promptLength: prompt.length,
|
|
127
|
+
responseLength: response.response.length,
|
|
128
|
+
durationMs: totalDurationMs
|
|
129
|
+
}, 'Generation completed');
|
|
130
|
+
return {
|
|
131
|
+
text: response.response,
|
|
132
|
+
model: response.model,
|
|
133
|
+
stats: {
|
|
134
|
+
promptTokens: response.prompt_eval_count ?? 0,
|
|
135
|
+
completionTokens: response.eval_count ?? 0,
|
|
136
|
+
totalDurationMs,
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Generate structured JSON output
|
|
142
|
+
*
|
|
143
|
+
* Instructs the model to output valid JSON and attempts to parse it.
|
|
144
|
+
*/
|
|
145
|
+
async generateJson(prompt, options = {}) {
|
|
146
|
+
const jsonPrompt = `${prompt}
|
|
147
|
+
|
|
148
|
+
IMPORTANT: Respond with valid JSON only. No markdown, no explanation, just the JSON object.`;
|
|
149
|
+
const response = await this.generate(jsonPrompt, {
|
|
150
|
+
...options,
|
|
151
|
+
temperature: options.temperature ?? 0.3, // Lower temp for structured output
|
|
152
|
+
});
|
|
153
|
+
const data = extractJson(response.text);
|
|
154
|
+
if (!data) {
|
|
155
|
+
logger.warn({ responsePreview: response.text.substring(0, 200) }, 'Failed to parse JSON from response');
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
data,
|
|
159
|
+
raw: response.text,
|
|
160
|
+
stats: response.stats,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Chat-style generation with message history
|
|
165
|
+
*/
|
|
166
|
+
async chat(messages, options = {}) {
|
|
167
|
+
await this.ensureInitialized();
|
|
168
|
+
const startTime = performance.now();
|
|
169
|
+
const response = await retry(async () => {
|
|
170
|
+
const result = await this.client.chat({
|
|
171
|
+
model: this.config.model,
|
|
172
|
+
messages,
|
|
173
|
+
options: {
|
|
174
|
+
temperature: options.temperature ?? 0.7,
|
|
175
|
+
num_predict: options.maxTokens ?? 2048,
|
|
176
|
+
},
|
|
177
|
+
stream: false,
|
|
178
|
+
});
|
|
179
|
+
return result;
|
|
180
|
+
}, { maxAttempts: this.config.maxRetries });
|
|
181
|
+
const totalDurationMs = Math.round(performance.now() - startTime);
|
|
182
|
+
return {
|
|
183
|
+
text: response.message.content,
|
|
184
|
+
model: response.model,
|
|
185
|
+
stats: {
|
|
186
|
+
promptTokens: response.prompt_eval_count ?? 0,
|
|
187
|
+
completionTokens: response.eval_count ?? 0,
|
|
188
|
+
totalDurationMs,
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Build a prompt with optional system context
|
|
194
|
+
*/
|
|
195
|
+
buildPrompt(userPrompt, systemPrompt) {
|
|
196
|
+
if (!systemPrompt) {
|
|
197
|
+
return userPrompt;
|
|
198
|
+
}
|
|
199
|
+
return `${systemPrompt}
|
|
200
|
+
|
|
201
|
+
${userPrompt}`;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Get the current model name
|
|
205
|
+
*/
|
|
206
|
+
get model() {
|
|
207
|
+
return this.config.model;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Update the model to use
|
|
211
|
+
*/
|
|
212
|
+
setModel(model) {
|
|
213
|
+
this.config.model = model;
|
|
214
|
+
logger.info({ model }, 'Model updated');
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
// ============================================================================
|
|
218
|
+
// Prompt Templates
|
|
219
|
+
// ============================================================================
|
|
220
|
+
/**
|
|
221
|
+
* Collection of reusable prompt templates for different stages
|
|
222
|
+
*/
|
|
223
|
+
export const PromptTemplates = {
|
|
224
|
+
/**
|
|
225
|
+
* System prompt for intent analysis
|
|
226
|
+
*/
|
|
227
|
+
intentAnalysis: `You are an expert at understanding developer intent.
|
|
228
|
+
Analyze the user's query and extract:
|
|
229
|
+
- The primary intent (what they want to accomplish)
|
|
230
|
+
- Key entities (languages, frameworks, files, functions, concepts)
|
|
231
|
+
- Whether clarification is needed
|
|
232
|
+
|
|
233
|
+
Be precise and concise.`,
|
|
234
|
+
/**
|
|
235
|
+
* System prompt for task decomposition
|
|
236
|
+
*/
|
|
237
|
+
taskDecomposition: `You are a senior software architect.
|
|
238
|
+
Break down the given task into smaller, actionable subtasks.
|
|
239
|
+
For each subtask, identify:
|
|
240
|
+
- Dependencies on other subtasks
|
|
241
|
+
- Complexity (low/medium/high)
|
|
242
|
+
- Type (research/design/implementation/testing/documentation/review)
|
|
243
|
+
|
|
244
|
+
Output a structured plan.`,
|
|
245
|
+
/**
|
|
246
|
+
* System prompt for code generation variants
|
|
247
|
+
*/
|
|
248
|
+
variantGeneration: `You are an expert programmer.
|
|
249
|
+
Generate multiple solution variants for the given problem.
|
|
250
|
+
For each variant:
|
|
251
|
+
- Use a different approach or trade-off
|
|
252
|
+
- Explain pros and cons
|
|
253
|
+
- Identify the best use case
|
|
254
|
+
|
|
255
|
+
Aim for 2-3 meaningfully different solutions.`,
|
|
256
|
+
/**
|
|
257
|
+
* System prompt for code critique
|
|
258
|
+
*/
|
|
259
|
+
codeCritique: `You are a thorough code reviewer.
|
|
260
|
+
Analyze the provided code for:
|
|
261
|
+
- Correctness: Does it solve the problem?
|
|
262
|
+
- Performance: Are there efficiency issues?
|
|
263
|
+
- Maintainability: Is it readable and well-structured?
|
|
264
|
+
- Security: Are there vulnerabilities?
|
|
265
|
+
- Best Practices: Does it follow conventions?
|
|
266
|
+
|
|
267
|
+
Provide specific, actionable feedback.`,
|
|
268
|
+
/**
|
|
269
|
+
* System prompt for optimization
|
|
270
|
+
*/
|
|
271
|
+
optimization: `You are an optimization specialist.
|
|
272
|
+
Given the code and critique, produce an optimized version that:
|
|
273
|
+
- Addresses all identified issues
|
|
274
|
+
- Maintains correctness
|
|
275
|
+
- Improves performance where possible
|
|
276
|
+
- Follows best practices
|
|
277
|
+
|
|
278
|
+
Explain what optimizations were applied.`,
|
|
279
|
+
};
|
|
280
|
+
// ============================================================================
|
|
281
|
+
// Singleton Instance
|
|
282
|
+
// ============================================================================
|
|
283
|
+
let clientInstance = null;
|
|
284
|
+
/**
|
|
285
|
+
* Get or create the Ollama client singleton
|
|
286
|
+
*/
|
|
287
|
+
export function getOllamaClient(config) {
|
|
288
|
+
if (!clientInstance) {
|
|
289
|
+
clientInstance = new OllamaClient(config);
|
|
290
|
+
}
|
|
291
|
+
return clientInstance;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Reset the client instance (useful for testing)
|
|
295
|
+
*/
|
|
296
|
+
export function resetOllamaClient() {
|
|
297
|
+
clientInstance = null;
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=ollama.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ollama.js","sourceRoot":"","sources":["../../src/tools/ollama.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMhC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE1E,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAE/E,MAAM,cAAc,GAAiB;IACnC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,wBAAwB;IACnE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE,sBAAsB;IAChE,SAAS,EAAE,MAAM;IACjB,UAAU,EAAE,CAAC;CAC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CAAC,KAAa;QACpB,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;QAC1B,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,eAAe,CAAC,CAAC;IAC1C,CAAC;CACF;AAED,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B;;OAEG;IACH,cAAc,EAAE;;;;;;wBAMM;IAEtB;;OAEG;IACH,iBAAiB,EAAE;;;;;;;0BAOK;IAExB;;OAEG;IACH,iBAAiB,EAAE;;;;;;;8CAOyB;IAE5C;;OAEG;IACH,YAAY,EAAE;;;;;;;;uCAQuB;IAErC;;OAEG;IACH,YAAY,EAAE;;;;;;;yCAOyB;CACxC,CAAC;AAEF,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E,IAAI,cAAc,GAAwB,IAAI,CAAC;AAE/C;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAA8B;IAC5D,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,cAAc,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAC/B,cAAc,GAAG,IAAI,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Atlas Server - Optimization Tool
|
|
3
|
+
*
|
|
4
|
+
* Takes the best variant and critique, then produces an optimized final output:
|
|
5
|
+
* - Addresses identified issues
|
|
6
|
+
* - Applies performance improvements
|
|
7
|
+
* - Enhances readability and maintainability
|
|
8
|
+
* - Follows best practices
|
|
9
|
+
*/
|
|
10
|
+
import type { SolutionVariant, Critique, OptimizedOutput, Optimization } from '../types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Optimize the best variant based on critique feedback
|
|
13
|
+
*/
|
|
14
|
+
export declare function optimizeVariant(variant: SolutionVariant, critique: Critique): Promise<OptimizedOutput>;
|
|
15
|
+
/**
|
|
16
|
+
* Apply multiple optimization passes
|
|
17
|
+
*/
|
|
18
|
+
export declare function multiPassOptimization(variant: SolutionVariant, critique: Critique, maxPasses?: number): Promise<OptimizedOutput>;
|
|
19
|
+
/**
|
|
20
|
+
* Optimization presets for common scenarios
|
|
21
|
+
*/
|
|
22
|
+
export declare const OptimizationPresets: {
|
|
23
|
+
/**
|
|
24
|
+
* Focus on performance optimizations
|
|
25
|
+
*/
|
|
26
|
+
performance: {
|
|
27
|
+
focus: Optimization["type"][];
|
|
28
|
+
minScoreThreshold: number;
|
|
29
|
+
maxIterations: number;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Focus on code quality and maintainability
|
|
33
|
+
*/
|
|
34
|
+
quality: {
|
|
35
|
+
focus: Optimization["type"][];
|
|
36
|
+
minScoreThreshold: number;
|
|
37
|
+
maxIterations: number;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Focus on security hardening
|
|
41
|
+
*/
|
|
42
|
+
security: {
|
|
43
|
+
focus: Optimization["type"][];
|
|
44
|
+
minScoreThreshold: number;
|
|
45
|
+
maxIterations: number;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Balanced optimization
|
|
49
|
+
*/
|
|
50
|
+
balanced: {
|
|
51
|
+
focus: Optimization["type"][];
|
|
52
|
+
minScoreThreshold: number;
|
|
53
|
+
maxIterations: number;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Get optimization recommendations based on critique
|
|
58
|
+
*/
|
|
59
|
+
export declare function getOptimizationRecommendations(critique: Critique): {
|
|
60
|
+
preset: keyof typeof OptimizationPresets;
|
|
61
|
+
reason: string;
|
|
62
|
+
focusAreas: string[];
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=optimize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optimize.d.ts","sourceRoot":"","sources":["../../src/tools/optimize.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,QAAQ,EACR,eAAe,EACf,YAAY,EAEb,MAAM,aAAa,CAAC;AAQrB;;GAEG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,eAAe,CAAC,CAqD1B;AA6JD;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,QAAQ,EAClB,SAAS,GAAE,MAAU,GACpB,OAAO,CAAC,eAAe,CAAC,CAwC1B;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB;IAC9B;;OAEG;;eAE2C,YAAY,CAAC,MAAM,CAAC,EAAE;;;;IAKpE;;OAEG;;eAE0C,YAAY,CAAC,MAAM,CAAC,EAAE;;;;IAKnE;;OAEG;;eAEsB,YAAY,CAAC,MAAM,CAAC,EAAE;;;;IAK/C;;OAEG;;eAEqE,YAAY,CAAC,MAAM,CAAC,EAAE;;;;CAI/F,CAAC;AAEF;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,QAAQ,GACjB;IACD,MAAM,EAAE,MAAM,OAAO,mBAAmB,CAAC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAqCA"}
|