rlm-analyzer 1.1.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/dist/index.js ADDED
@@ -0,0 +1,142 @@
1
+ /**
2
+ * RLM Analyzer
3
+ * Recursive Language Model code analysis tool
4
+ *
5
+ * Based on MIT CSAIL research: arXiv:2512.24601v1
6
+ * "Recursive Language Models: A Paradigm for Processing Arbitrarily Long Inputs"
7
+ */
8
+ // Types
9
+ export * from './types.js';
10
+ // Configuration
11
+ export { getApiKey, getAIClient, initConfig, hasApiKey } from './config.js';
12
+ // Model configuration (new in v1.1)
13
+ export {
14
+ // Resolution functions
15
+ resolveModelConfig, getDefaultModel, getFallbackModel, resolveModelAlias, isModelAlias,
16
+ // Display helpers
17
+ getModelConfigDisplay, getAliasesDisplay,
18
+ // Constants
19
+ MODEL_ALIASES, AVAILABLE_MODELS,
20
+ // Backward compatibility (deprecated)
21
+ DEFAULT_MODEL, FALLBACK_MODEL, } from './models.js';
22
+ // Core components
23
+ export { RLMExecutor } from './executor.js';
24
+ export { RLMOrchestrator } from './orchestrator.js';
25
+ // High-level analysis functions
26
+ export { loadFiles, analyzeCodebase, analyzeArchitecture, analyzeDependencies, analyzeSecurity, analyzePerformance, analyzeRefactoring, summarizeCodebase, findUsages, explainFile, askQuestion, } from './analyzer.js';
27
+ // Prompts
28
+ export { CODE_ANALYSIS_PROMPT, ARCHITECTURE_PROMPT, DEPENDENCY_PROMPT, SECURITY_PROMPT, PERFORMANCE_PROMPT, REFACTOR_PROMPT, SUMMARY_PROMPT, getSystemPrompt, getAnalysisPrompt, buildContextMessage, } from './prompts.js';
29
+ // ============================================================================
30
+ // Factory Functions for IDE Integration (Claude Code, Codex, Cursor)
31
+ // ============================================================================
32
+ import { RLMOrchestrator } from './orchestrator.js';
33
+ import { analyzeCodebase } from './analyzer.js';
34
+ import { resolveModelConfig } from './models.js';
35
+ import { getDefaultRLMConfig } from './types.js';
36
+ /**
37
+ * Create an analyzer instance for IDE integration
38
+ *
39
+ * This is the recommended way to use RLM Analyzer programmatically.
40
+ * It handles model resolution using the priority chain and returns
41
+ * a configured analyzer ready for use.
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * import { createAnalyzer } from 'rlm-analyzer';
46
+ *
47
+ * // Use default configuration
48
+ * const analyzer = createAnalyzer();
49
+ * const result = await analyzer.analyze('./my-project');
50
+ *
51
+ * // Use specific model
52
+ * const fastAnalyzer = createAnalyzer({ model: 'fast' });
53
+ * const result = await fastAnalyzer.analyze('./my-project');
54
+ *
55
+ * // Access the orchestrator directly
56
+ * const orchestrator = analyzer.orchestrator;
57
+ * ```
58
+ *
59
+ * @param options - Configuration options
60
+ * @returns Analyzer instance with analyze function and orchestrator
61
+ */
62
+ export function createAnalyzer(options = {}) {
63
+ const modelConfig = resolveModelConfig({
64
+ model: options.model,
65
+ fallbackModel: options.fallbackModel,
66
+ });
67
+ const config = getDefaultRLMConfig(modelConfig.defaultModel);
68
+ // Apply any config overrides
69
+ if (options.config) {
70
+ Object.assign(config, options.config);
71
+ }
72
+ const orchestrator = new RLMOrchestrator(config, options.verbose);
73
+ const analyze = async (directory, analysisOptions = {}) => {
74
+ return analyzeCodebase({
75
+ directory,
76
+ ...analysisOptions,
77
+ model: modelConfig.defaultModel,
78
+ verbose: options.verbose,
79
+ });
80
+ };
81
+ return {
82
+ analyze,
83
+ orchestrator,
84
+ config,
85
+ modelConfig,
86
+ };
87
+ }
88
+ /**
89
+ * Create a configured RLMOrchestrator instance
90
+ *
91
+ * Use this when you need direct access to the orchestrator
92
+ * for custom workflows or advanced use cases.
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * import { createOrchestrator, loadFiles } from 'rlm-analyzer';
97
+ *
98
+ * const orchestrator = createOrchestrator({ model: 'smart' });
99
+ * const files = await loadFiles('./src');
100
+ * const result = await orchestrator.processQuery(
101
+ * 'Explain this codebase',
102
+ * { files, variables: {}, mode: 'code-analysis' }
103
+ * );
104
+ * ```
105
+ *
106
+ * @param options - Configuration options
107
+ * @returns Configured RLMOrchestrator instance
108
+ */
109
+ export function createOrchestrator(options = {}) {
110
+ const modelConfig = resolveModelConfig({ model: options.model });
111
+ const config = getDefaultRLMConfig(modelConfig.defaultModel);
112
+ // Apply any config overrides
113
+ if (options.config) {
114
+ Object.assign(config, options.config);
115
+ }
116
+ return new RLMOrchestrator(config, options.verbose);
117
+ }
118
+ /**
119
+ * Get resolved model configuration
120
+ *
121
+ * Use this to check what models will be used based on
122
+ * the current environment, config file, and any overrides.
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * import { getModelConfig } from 'rlm-analyzer';
127
+ *
128
+ * const config = getModelConfig();
129
+ * console.log(`Default model: ${config.defaultModel}`);
130
+ * console.log(`Source: ${config.defaultSource}`);
131
+ *
132
+ * // With override
133
+ * const custom = getModelConfig({ model: 'fast' });
134
+ * ```
135
+ *
136
+ * @param options - Optional model overrides
137
+ * @returns Resolved model configuration with source information
138
+ */
139
+ export function getModelConfig(options = {}) {
140
+ return resolveModelConfig(options);
141
+ }
142
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,QAAQ;AACR,cAAc,YAAY,CAAC;AAE3B,gBAAgB;AAChB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE5E,oCAAoC;AACpC,OAAO;AACL,uBAAuB;AACvB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,YAAY;AAEZ,kBAAkB;AAClB,qBAAqB,EACrB,iBAAiB;AAEjB,YAAY;AACZ,aAAa,EACb,gBAAgB;AAEhB,sCAAsC;AACtC,aAAa,EACb,cAAc,GAKf,MAAM,aAAa,CAAC;AAErB,kBAAkB;AAClB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OA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C,EAAE;QAC/B,OAAO,eAAe,CAAC;YACrB,SAAS;YACT,GAAG,eAAe;YAClB,KAAK,EAAE,WAAW,CAAC,YAAY;YAC/B,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO;QACL,OAAO;QACP,YAAY;QACZ,MAAM;QACN,WAAW;KACZ,CAAC;AACJ,CAAC;AAcD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAAqC,EAAE;IACxE,MAAM,WAAW,GAAG,kBAAkB,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;IACjE,MAAM,MAAM,GAAG,mBAAmB,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAE7D,6BAA6B;IAC7B,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,IAAI,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;AACtD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,cAAc,CAAC,UAA8B,EAAE;IAC7D,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC"}
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * RLM Analyzer MCP Server
4
+ * Exposes RLM analysis capabilities via Model Context Protocol
5
+ *
6
+ * Usage with Claude Code:
7
+ * Add to ~/.claude/claude_desktop_config.json:
8
+ * {
9
+ * "mcpServers": {
10
+ * "rlm-analyzer": {
11
+ * "command": "npx",
12
+ * "args": ["rlm-analyzer-mcp"],
13
+ * "env": { "GEMINI_API_KEY": "your_key" }
14
+ * }
15
+ * }
16
+ * }
17
+ */
18
+ export {};
19
+ //# sourceMappingURL=mcp-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;GAeG"}
@@ -0,0 +1,336 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * RLM Analyzer MCP Server
4
+ * Exposes RLM analysis capabilities via Model Context Protocol
5
+ *
6
+ * Usage with Claude Code:
7
+ * Add to ~/.claude/claude_desktop_config.json:
8
+ * {
9
+ * "mcpServers": {
10
+ * "rlm-analyzer": {
11
+ * "command": "npx",
12
+ * "args": ["rlm-analyzer-mcp"],
13
+ * "env": { "GEMINI_API_KEY": "your_key" }
14
+ * }
15
+ * }
16
+ * }
17
+ */
18
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
19
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
20
+ import { ListToolsRequestSchema, CallToolRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
21
+ import { analyzeCodebase, analyzeArchitecture, analyzeDependencies, analyzeSecurity, analyzeRefactoring, summarizeCodebase, askQuestion, } from './analyzer.js';
22
+ import { resolveModelConfig, resolveModelAlias } from './models.js';
23
+ import { hasApiKey } from './config.js';
24
+ // Tool definitions
25
+ const TOOLS = [
26
+ {
27
+ name: 'rlm_analyze',
28
+ description: 'Analyze a codebase using recursive LLM analysis. Can answer complex questions about code architecture, patterns, and implementation details by recursively examining files.',
29
+ inputSchema: {
30
+ type: 'object',
31
+ properties: {
32
+ directory: {
33
+ type: 'string',
34
+ description: 'Absolute path to the directory to analyze',
35
+ },
36
+ query: {
37
+ type: 'string',
38
+ description: 'Question or analysis request about the codebase',
39
+ },
40
+ analysisType: {
41
+ type: 'string',
42
+ enum: ['architecture', 'dependencies', 'security', 'performance', 'refactor', 'summary', 'custom'],
43
+ description: 'Type of analysis to perform (default: custom if query provided, summary otherwise)',
44
+ },
45
+ model: {
46
+ type: 'string',
47
+ description: 'Model to use: fast, smart, or full model ID (default: from environment)',
48
+ },
49
+ },
50
+ required: ['directory'],
51
+ },
52
+ },
53
+ {
54
+ name: 'rlm_summarize',
55
+ description: 'Get a comprehensive summary of a codebase including purpose, tech stack, architecture, and key components.',
56
+ inputSchema: {
57
+ type: 'object',
58
+ properties: {
59
+ directory: {
60
+ type: 'string',
61
+ description: 'Absolute path to the directory to analyze',
62
+ },
63
+ model: {
64
+ type: 'string',
65
+ description: 'Model to use: fast, smart, or full model ID',
66
+ },
67
+ },
68
+ required: ['directory'],
69
+ },
70
+ },
71
+ {
72
+ name: 'rlm_architecture',
73
+ description: 'Analyze the architecture and structure of a codebase. Identifies patterns, layers, components, and their relationships.',
74
+ inputSchema: {
75
+ type: 'object',
76
+ properties: {
77
+ directory: {
78
+ type: 'string',
79
+ description: 'Absolute path to the directory to analyze',
80
+ },
81
+ model: {
82
+ type: 'string',
83
+ description: 'Model to use: fast, smart, or full model ID',
84
+ },
85
+ },
86
+ required: ['directory'],
87
+ },
88
+ },
89
+ {
90
+ name: 'rlm_security',
91
+ description: 'Perform security analysis on a codebase. Identifies potential vulnerabilities, insecure patterns, and security best practice violations.',
92
+ inputSchema: {
93
+ type: 'object',
94
+ properties: {
95
+ directory: {
96
+ type: 'string',
97
+ description: 'Absolute path to the directory to analyze',
98
+ },
99
+ model: {
100
+ type: 'string',
101
+ description: 'Model to use: fast, smart, or full model ID',
102
+ },
103
+ },
104
+ required: ['directory'],
105
+ },
106
+ },
107
+ {
108
+ name: 'rlm_dependencies',
109
+ description: 'Analyze dependencies in a codebase. Maps internal and external dependencies, identifies circular dependencies and coupling issues.',
110
+ inputSchema: {
111
+ type: 'object',
112
+ properties: {
113
+ directory: {
114
+ type: 'string',
115
+ description: 'Absolute path to the directory to analyze',
116
+ },
117
+ model: {
118
+ type: 'string',
119
+ description: 'Model to use: fast, smart, or full model ID',
120
+ },
121
+ },
122
+ required: ['directory'],
123
+ },
124
+ },
125
+ {
126
+ name: 'rlm_refactor',
127
+ description: 'Find refactoring opportunities in a codebase. Identifies code duplication, complex functions, and improvement opportunities.',
128
+ inputSchema: {
129
+ type: 'object',
130
+ properties: {
131
+ directory: {
132
+ type: 'string',
133
+ description: 'Absolute path to the directory to analyze',
134
+ },
135
+ model: {
136
+ type: 'string',
137
+ description: 'Model to use: fast, smart, or full model ID',
138
+ },
139
+ },
140
+ required: ['directory'],
141
+ },
142
+ },
143
+ {
144
+ name: 'rlm_ask',
145
+ description: 'Ask a specific question about a codebase. The AI will analyze relevant files to answer your question.',
146
+ inputSchema: {
147
+ type: 'object',
148
+ properties: {
149
+ directory: {
150
+ type: 'string',
151
+ description: 'Absolute path to the directory to analyze',
152
+ },
153
+ question: {
154
+ type: 'string',
155
+ description: 'The question to answer about the codebase',
156
+ },
157
+ model: {
158
+ type: 'string',
159
+ description: 'Model to use: fast, smart, or full model ID',
160
+ },
161
+ },
162
+ required: ['directory', 'question'],
163
+ },
164
+ },
165
+ {
166
+ name: 'rlm_config',
167
+ description: 'Get current RLM Analyzer configuration including model settings and API key status.',
168
+ inputSchema: {
169
+ type: 'object',
170
+ properties: {},
171
+ },
172
+ },
173
+ ];
174
+ // Create server
175
+ const server = new Server({ name: 'rlm-analyzer', version: '1.1.0' }, { capabilities: { tools: {} } });
176
+ // Handle tool listing
177
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
178
+ return { tools: TOOLS };
179
+ });
180
+ // Handle tool calls
181
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
182
+ const { name, arguments: args } = request.params;
183
+ try {
184
+ // Check API key for analysis tools
185
+ if (name !== 'rlm_config' && !hasApiKey()) {
186
+ return {
187
+ content: [{
188
+ type: 'text',
189
+ text: 'Error: GEMINI_API_KEY not configured. Set it in the MCP server environment.',
190
+ }],
191
+ isError: true,
192
+ };
193
+ }
194
+ const model = args?.model ? resolveModelAlias(args.model) : undefined;
195
+ const options = model ? { model } : {};
196
+ switch (name) {
197
+ case 'rlm_analyze': {
198
+ const { directory, query, analysisType } = args;
199
+ const result = await analyzeCodebase({
200
+ directory,
201
+ query,
202
+ analysisType: analysisType || (query ? 'custom' : 'summary'),
203
+ ...options,
204
+ });
205
+ return {
206
+ content: [{
207
+ type: 'text',
208
+ text: result.success
209
+ ? result.answer || 'Analysis complete but no answer generated.'
210
+ : `Error: ${result.error}`,
211
+ }],
212
+ isError: !result.success,
213
+ };
214
+ }
215
+ case 'rlm_summarize': {
216
+ const { directory } = args;
217
+ const result = await summarizeCodebase(directory, options);
218
+ return {
219
+ content: [{
220
+ type: 'text',
221
+ text: result.success
222
+ ? result.answer || 'Summary complete but no content generated.'
223
+ : `Error: ${result.error}`,
224
+ }],
225
+ isError: !result.success,
226
+ };
227
+ }
228
+ case 'rlm_architecture': {
229
+ const { directory } = args;
230
+ const result = await analyzeArchitecture(directory, options);
231
+ return {
232
+ content: [{
233
+ type: 'text',
234
+ text: result.success
235
+ ? result.answer || 'Architecture analysis complete.'
236
+ : `Error: ${result.error}`,
237
+ }],
238
+ isError: !result.success,
239
+ };
240
+ }
241
+ case 'rlm_security': {
242
+ const { directory } = args;
243
+ const result = await analyzeSecurity(directory, options);
244
+ return {
245
+ content: [{
246
+ type: 'text',
247
+ text: result.success
248
+ ? result.answer || 'Security analysis complete.'
249
+ : `Error: ${result.error}`,
250
+ }],
251
+ isError: !result.success,
252
+ };
253
+ }
254
+ case 'rlm_dependencies': {
255
+ const { directory } = args;
256
+ const result = await analyzeDependencies(directory, options);
257
+ return {
258
+ content: [{
259
+ type: 'text',
260
+ text: result.success
261
+ ? result.answer || 'Dependency analysis complete.'
262
+ : `Error: ${result.error}`,
263
+ }],
264
+ isError: !result.success,
265
+ };
266
+ }
267
+ case 'rlm_refactor': {
268
+ const { directory } = args;
269
+ const result = await analyzeRefactoring(directory, options);
270
+ return {
271
+ content: [{
272
+ type: 'text',
273
+ text: result.success
274
+ ? result.answer || 'Refactoring analysis complete.'
275
+ : `Error: ${result.error}`,
276
+ }],
277
+ isError: !result.success,
278
+ };
279
+ }
280
+ case 'rlm_ask': {
281
+ const { directory, question } = args;
282
+ const result = await askQuestion(directory, question, options);
283
+ return {
284
+ content: [{
285
+ type: 'text',
286
+ text: result.success
287
+ ? result.answer || 'Question answered but no content generated.'
288
+ : `Error: ${result.error}`,
289
+ }],
290
+ isError: !result.success,
291
+ };
292
+ }
293
+ case 'rlm_config': {
294
+ const config = resolveModelConfig();
295
+ const apiKeyStatus = hasApiKey() ? 'configured' : 'NOT CONFIGURED';
296
+ return {
297
+ content: [{
298
+ type: 'text',
299
+ text: `RLM Analyzer Configuration:
300
+ - API Key: ${apiKeyStatus}
301
+ - Default Model: ${config.defaultModel} (source: ${config.defaultSource})
302
+ - Fallback Model: ${config.fallbackModel} (source: ${config.fallbackSource})
303
+
304
+ Model Aliases:
305
+ - fast → gemini-3-flash-preview
306
+ - smart → gemini-3-pro-preview
307
+ - pro → gemini-3-pro-preview`,
308
+ }],
309
+ };
310
+ }
311
+ default:
312
+ return {
313
+ content: [{ type: 'text', text: `Unknown tool: ${name}` }],
314
+ isError: true,
315
+ };
316
+ }
317
+ }
318
+ catch (error) {
319
+ const message = error instanceof Error ? error.message : String(error);
320
+ return {
321
+ content: [{ type: 'text', text: `Error: ${message}` }],
322
+ isError: true,
323
+ };
324
+ }
325
+ });
326
+ // Start server
327
+ async function main() {
328
+ const transport = new StdioServerTransport();
329
+ await server.connect(transport);
330
+ console.error('RLM Analyzer MCP server running on stdio');
331
+ }
332
+ main().catch((error) => {
333
+ console.error('Failed to start MCP server:', error);
334
+ process.exit(1);
335
+ });
336
+ //# sourceMappingURL=mcp-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,sBAAsB,EACtB,qBAAqB,GAEtB,MAAM,oCAAoC,CAAC;AAE5C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C,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Model Configuration Module
3
+ * Handles model resolution with configurable priority chain
4
+ *
5
+ * Priority chain for model resolution:
6
+ * 1. CLI --model flag (highest)
7
+ * 2. Environment variables: RLM_DEFAULT_MODEL, RLM_FALLBACK_MODEL
8
+ * 3. Config file: ~/.rlm-analyzer/config.json
9
+ * 4. Programmatic API: createAnalyzer({ model: '...' })
10
+ * 5. Built-in defaults (lowest, internal only)
11
+ */
12
+ /**
13
+ * Model aliases for convenience
14
+ * Users can specify aliases instead of full model IDs
15
+ */
16
+ export declare const MODEL_ALIASES: Record<string, string>;
17
+ /**
18
+ * Available model options (for display in help)
19
+ */
20
+ export declare const AVAILABLE_MODELS: {
21
+ id: string;
22
+ description: string;
23
+ }[];
24
+ export interface ModelConfigOptions {
25
+ /** Model specified via CLI flag or programmatic API */
26
+ model?: string;
27
+ /** Fallback model specified via CLI flag or programmatic API */
28
+ fallbackModel?: string;
29
+ }
30
+ export interface ResolvedModelConfig {
31
+ /** The resolved default model ID */
32
+ defaultModel: string;
33
+ /** The resolved fallback model ID */
34
+ fallbackModel: string;
35
+ /** Source of the default model resolution */
36
+ defaultSource: 'cli' | 'env' | 'config' | 'api' | 'builtin';
37
+ /** Source of the fallback model resolution */
38
+ fallbackSource: 'cli' | 'env' | 'config' | 'api' | 'builtin';
39
+ }
40
+ /**
41
+ * Resolve a model alias to its full model ID
42
+ * If the input is not an alias, returns it unchanged
43
+ *
44
+ * @param modelOrAlias - Model ID or alias
45
+ * @returns Full model ID
46
+ */
47
+ export declare function resolveModelAlias(modelOrAlias: string): string;
48
+ /**
49
+ * Check if a string is a known model alias
50
+ */
51
+ export declare function isModelAlias(value: string): boolean;
52
+ /**
53
+ * Resolve full model configuration using priority chain
54
+ *
55
+ * Priority:
56
+ * 1. CLI/API options (highest)
57
+ * 2. Environment variables: RLM_DEFAULT_MODEL, RLM_FALLBACK_MODEL
58
+ * 3. Config file: ~/.rlm-analyzer/config.json
59
+ * 4. Built-in defaults (lowest)
60
+ *
61
+ * @param options - Optional overrides from CLI or programmatic API
62
+ * @returns Resolved model configuration with source information
63
+ */
64
+ export declare function resolveModelConfig(options?: ModelConfigOptions): ResolvedModelConfig;
65
+ /**
66
+ * Get the default model ID using the priority chain
67
+ * Convenience function for getting just the default model
68
+ *
69
+ * @param options - Optional overrides
70
+ * @returns Resolved default model ID
71
+ */
72
+ export declare function getDefaultModel(options?: ModelConfigOptions): string;
73
+ /**
74
+ * Get the fallback model ID using the priority chain
75
+ * Convenience function for getting just the fallback model
76
+ *
77
+ * @param options - Optional overrides
78
+ * @returns Resolved fallback model ID
79
+ */
80
+ export declare function getFallbackModel(options?: ModelConfigOptions): string;
81
+ /**
82
+ * @deprecated Use `getDefaultModel()` instead for dynamic resolution
83
+ * This is computed at import time and won't reflect runtime changes
84
+ */
85
+ export declare const DEFAULT_MODEL: string;
86
+ /**
87
+ * @deprecated Use `getFallbackModel()` instead for dynamic resolution
88
+ * This is computed at import time and won't reflect runtime changes
89
+ */
90
+ export declare const FALLBACK_MODEL: string;
91
+ /**
92
+ * Get formatted string showing current model configuration
93
+ * Useful for CLI help text and debugging
94
+ */
95
+ export declare function getModelConfigDisplay(options?: ModelConfigOptions): string;
96
+ /**
97
+ * Get formatted string showing available aliases
98
+ * Useful for CLI help text
99
+ */
100
+ export declare function getAliasesDisplay(): string;
101
+ //# sourceMappingURL=models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAiBH;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAQhD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;GAK5B,CAAC;AAMF,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,g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