minovative-mind-cli 2.13.5 → 2.14.1

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.
@@ -1,9 +1,23 @@
1
1
  import { type Content, type FunctionCall } from '@google/generative-ai';
2
+ import { type ThinkingLevel } from '../utils/config.js';
2
3
  export declare function getMultiWorkspaceBlock(): string;
3
4
  export declare function setModelOverride(agent: 'context' | 'execution', overrideStr: string): void;
4
5
  export declare function clearModelOverrides(): void;
5
6
  export declare function setGlobalActiveModel(model: string): void;
6
7
  export declare function getGlobalActiveModel(): string;
8
+ /**
9
+ * Gets the thinking reasoning level configured for a specific model or active model.
10
+ * Falls back to default model thinking levels or 'MEDIUM' if not explicitly configured.
11
+ */
12
+ export declare function getModelThinkingLevel(model?: string): ThinkingLevel;
13
+ /**
14
+ * Sets the user-configured thinking reasoning level for a specific model.
15
+ */
16
+ export declare function setModelThinkingLevel(model: string, level: ThinkingLevel): void;
17
+ /**
18
+ * Resets user-configured thinking levels back to default model presets.
19
+ */
20
+ export declare function resetModelThinkingLevels(): void;
7
21
  export declare class ProxyChatSession {
8
22
  private history;
9
23
  private fullHistory;
@@ -12,6 +26,7 @@ export declare class ProxyChatSession {
12
26
  private tools;
13
27
  private toolConfig?;
14
28
  private generationConfig;
29
+ private configuredThinkingLevel?;
15
30
  private latestUsageMetadata;
16
31
  constructor(modelName: string, systemInstruction: string, tools: any[], generationConfig: any, toolConfig?: any);
17
32
  getLatestUsageMetadata(): any;
@@ -20,6 +35,10 @@ export declare class ProxyChatSession {
20
35
  getToolConfig(): any;
21
36
  setModel(modelName: string): void;
22
37
  getModel(): string;
38
+ setThinkingLevel(level: ThinkingLevel): void;
39
+ getThinkingLevel(): ThinkingLevel | undefined;
40
+ setGenerationConfig(generationConfig: any): void;
41
+ getGenerationConfig(): any;
23
42
  clearHistory(): void;
24
43
  getRawHistory(): Content[];
25
44
  getFullHistory(): Content[];
@@ -1,5 +1,5 @@
1
1
  import { SchemaType } from '@google/generative-ai';
2
- import { GEMINI_MODELS, DEFAULT_MODEL, MAX_OUTPUT_TOKENS, isByokEnabled } from '../utils/config.js';
2
+ import { GEMINI_MODELS, DEFAULT_MODEL, MAX_OUTPUT_TOKENS, isByokEnabled, DEFAULT_MODEL_THINKING_LEVELS, } from '../utils/config.js';
3
3
  import { getToolDeclarations } from './agent-tools.js';
4
4
  import { getMetricCollector } from './metrics.js';
5
5
  import { getAuthorizedIdToken, checkByokSubscription } from './auth.js';
@@ -56,12 +56,40 @@ export function clearModelOverrides() {
56
56
  }
57
57
  // ─── AI Service ──────────────────────────────────────────────────────
58
58
  let globalActiveModel = DEFAULT_MODEL;
59
+ const userModelThinkingLevels = new Map();
59
60
  export function setGlobalActiveModel(model) {
60
61
  globalActiveModel = model;
61
62
  }
62
63
  export function getGlobalActiveModel() {
63
64
  return globalActiveModel;
64
65
  }
66
+ /**
67
+ * Gets the thinking reasoning level configured for a specific model or active model.
68
+ * Falls back to default model thinking levels or 'MEDIUM' if not explicitly configured.
69
+ */
70
+ export function getModelThinkingLevel(model) {
71
+ const targetModel = model && model !== 'auto'
72
+ ? model
73
+ : globalActiveModel === 'auto'
74
+ ? GEMINI_MODELS.FLASH
75
+ : globalActiveModel;
76
+ if (userModelThinkingLevels.has(targetModel)) {
77
+ return userModelThinkingLevels.get(targetModel);
78
+ }
79
+ return DEFAULT_MODEL_THINKING_LEVELS[targetModel] || 'MEDIUM';
80
+ }
81
+ /**
82
+ * Sets the user-configured thinking reasoning level for a specific model.
83
+ */
84
+ export function setModelThinkingLevel(model, level) {
85
+ userModelThinkingLevels.set(model, level);
86
+ }
87
+ /**
88
+ * Resets user-configured thinking levels back to default model presets.
89
+ */
90
+ export function resetModelThinkingLevels() {
91
+ userModelThinkingLevels.clear();
92
+ }
65
93
  const proxyClient = new ProxyClient();
66
94
  // ─── History Limits ──────────────────────────────────────────────────
67
95
  /** Maximum number of Content entries to keep in the sliding history window. */
@@ -101,6 +129,7 @@ export class ProxyChatSession {
101
129
  tools;
102
130
  toolConfig;
103
131
  generationConfig;
132
+ configuredThinkingLevel;
104
133
  latestUsageMetadata = undefined;
105
134
  constructor(modelName, systemInstruction, tools, generationConfig, toolConfig) {
106
135
  this.modelName = modelName;
@@ -108,6 +137,9 @@ export class ProxyChatSession {
108
137
  this.tools = tools;
109
138
  this.generationConfig = generationConfig;
110
139
  this.toolConfig = toolConfig;
140
+ if (generationConfig?.thinkingConfig?.thinkingLevel) {
141
+ this.configuredThinkingLevel = generationConfig.thinkingConfig.thinkingLevel;
142
+ }
111
143
  }
112
144
  getLatestUsageMetadata() {
113
145
  return this.latestUsageMetadata;
@@ -129,6 +161,28 @@ export class ProxyChatSession {
129
161
  getModel() {
130
162
  return this.modelName;
131
163
  }
164
+ setThinkingLevel(level) {
165
+ this.configuredThinkingLevel = level;
166
+ this.generationConfig = {
167
+ ...(this.generationConfig || {}),
168
+ thinkingConfig: {
169
+ ...(this.generationConfig?.thinkingConfig || {}),
170
+ thinkingLevel: level,
171
+ },
172
+ };
173
+ }
174
+ getThinkingLevel() {
175
+ return this.configuredThinkingLevel || this.generationConfig?.thinkingConfig?.thinkingLevel;
176
+ }
177
+ setGenerationConfig(generationConfig) {
178
+ this.generationConfig = generationConfig;
179
+ if (generationConfig?.thinkingConfig?.thinkingLevel) {
180
+ this.configuredThinkingLevel = generationConfig.thinkingConfig.thinkingLevel;
181
+ }
182
+ }
183
+ getGenerationConfig() {
184
+ return this.generationConfig;
185
+ }
132
186
  clearHistory() {
133
187
  this.history = [];
134
188
  this.fullHistory = [];
@@ -309,6 +363,12 @@ export class ProxyChatSession {
309
363
  if (typeof respObj.result === 'string') {
310
364
  respObj.result = collapseHistoricalOutput(respObj.result, threshold);
311
365
  }
366
+ if (typeof respObj.stdout === 'string') {
367
+ respObj.stdout = collapseHistoricalOutput(respObj.stdout, threshold);
368
+ }
369
+ if (typeof respObj.stderr === 'string') {
370
+ respObj.stderr = collapseHistoricalOutput(respObj.stderr, threshold);
371
+ }
312
372
  }
313
373
  }
314
374
  }
@@ -461,11 +521,15 @@ export function createSharedChatSession() {
461
521
  let model = executionModelOverride || getGlobalActiveModel();
462
522
  if (model === 'auto')
463
523
  model = GEMINI_MODELS.FLASH; // Will be overridden per-turn in executeSingleTurn
524
+ const thinkingLevel = getModelThinkingLevel(model);
464
525
  return new ProxyChatSession(model, GENERAL_CHAT_INSTRUCTION.replace('{{MULTI_WORKSPACE_BLOCK}}', getMultiWorkspaceBlock()), [], {
465
526
  maxOutputTokens: MAX_OUTPUT_TOKENS,
466
527
  temperature: executionTempOverride !== null ? executionTempOverride : 1,
467
528
  topP: 0.95,
468
529
  topK: 40,
530
+ thinkingConfig: {
531
+ thinkingLevel,
532
+ },
469
533
  });
470
534
  }
471
535
  export function getGeneralChatConfig() {
@@ -509,11 +573,11 @@ export async function compressTextUsingFlashLite(text, instruction = "<directive
509
573
  }
510
574
  const creds = await loadCredentials();
511
575
  result = await proxyClient.generateViaBYOK(creds.geminiApiKey, model, contents, [], // no tools
512
- undefined, instruction, { temperature: 0.2 }, undefined, abortSignal);
576
+ undefined, instruction, { temperature: 0.2, thinkingConfig: { thinkingLevel: 'MINIMAL' } }, undefined, abortSignal);
513
577
  }
514
578
  else {
515
579
  result = await proxyClient.generateFunctionCallViaProxy(idToken, model, contents, [], // no tools
516
- undefined, instruction, { temperature: 0.2 }, // low temp for factual summary
580
+ undefined, instruction, { temperature: 0.2, thinkingConfig: { thinkingLevel: 'MINIMAL' } }, // low temp for factual summary
517
581
  undefined, abortSignal);
518
582
  }
519
583
  let textPart = '';
@@ -693,11 +757,15 @@ export function createContextAgentSession() {
693
757
  let model = contextModelOverride || getGlobalActiveModel();
694
758
  if (model === 'auto' || model.includes('claude'))
695
759
  model = GEMINI_MODELS.FLASH;
760
+ const thinkingLevel = getModelThinkingLevel(model);
696
761
  return new ProxyChatSession(model, CONTEXT_SYSTEM_INSTRUCTION.replace('{{MULTI_WORKSPACE_BLOCK}}', getMultiWorkspaceBlock()), contextTools, {
697
762
  maxOutputTokens: MAX_OUTPUT_TOKENS,
698
763
  temperature: contextTempOverride !== null ? contextTempOverride : 1,
699
764
  topP: 0.95,
700
765
  topK: 40,
766
+ thinkingConfig: {
767
+ thinkingLevel,
768
+ },
701
769
  }, {
702
770
  functionCallingConfig: {
703
771
  mode: 'ANY',
@@ -712,6 +780,9 @@ export function createIntentRouterSession() {
712
780
  return new ProxyChatSession(model, INTENT_ROUTER_SYSTEM_INSTRUCTION, [], // no tools
713
781
  {
714
782
  temperature: 0,
783
+ thinkingConfig: {
784
+ thinkingLevel: 'MINIMAL',
785
+ },
715
786
  responseMimeType: 'application/json',
716
787
  responseSchema: {
717
788
  type: SchemaType.OBJECT,
@@ -739,6 +810,9 @@ export function createExecutionComplexitySession() {
739
810
  return new ProxyChatSession(model, EXECUTION_COMPLEXITY_SYSTEM_INSTRUCTION, [], // no tools
740
811
  {
741
812
  temperature: 0,
813
+ thinkingConfig: {
814
+ thinkingLevel: 'MINIMAL',
815
+ },
742
816
  responseMimeType: 'application/json',
743
817
  responseSchema: {
744
818
  type: SchemaType.OBJECT,
@@ -761,6 +835,9 @@ export function createInvestigationComplexitySession() {
761
835
  return new ProxyChatSession(model, INVESTIGATION_COMPLEXITY_SYSTEM_INSTRUCTION, [], // no tools
762
836
  {
763
837
  temperature: 0,
838
+ thinkingConfig: {
839
+ thinkingLevel: 'MEDIUM',
840
+ },
764
841
  responseMimeType: 'application/json',
765
842
  responseSchema: {
766
843
  type: SchemaType.OBJECT,
@@ -824,6 +901,9 @@ export function createInvestigationSemanticSession() {
824
901
  return new ProxyChatSession(model, INVESTIGATION_SEMANTIC_SYSTEM_INSTRUCTION, [], // no tools
825
902
  {
826
903
  temperature: 0,
904
+ thinkingConfig: {
905
+ thinkingLevel: 'MINIMAL',
906
+ },
827
907
  responseMimeType: 'application/json',
828
908
  responseSchema: {
829
909
  type: SchemaType.OBJECT,
@@ -865,6 +945,9 @@ export function createWebSearchAgentSession() {
865
945
  temperature: 1,
866
946
  topP: 0.95,
867
947
  topK: 40,
948
+ thinkingConfig: {
949
+ thinkingLevel: 'MEDIUM',
950
+ },
868
951
  });
869
952
  }
870
953
  // ─── History Summarizer Agent Service ─────────────────────────────────
@@ -875,6 +958,9 @@ export function createHistorySummarizerSession() {
875
958
  return new ProxyChatSession(model, HISTORY_SUMMARIZER_SYSTEM_INSTRUCTION, [], {
876
959
  temperature: 0.2,
877
960
  maxOutputTokens: MAX_OUTPUT_TOKENS,
961
+ thinkingConfig: {
962
+ thinkingLevel: 'MINIMAL',
963
+ },
878
964
  });
879
965
  }
880
966
  /**
@@ -974,6 +1060,9 @@ export function createUserProfileExtractorSession() {
974
1060
  return new ProxyChatSession(model, USER_PROFILE_EXTRACTOR_SYSTEM_INSTRUCTION, [], // no tools
975
1061
  {
976
1062
  temperature: 0,
1063
+ thinkingConfig: {
1064
+ thinkingLevel: 'MINIMAL',
1065
+ },
977
1066
  responseMimeType: 'application/json',
978
1067
  responseSchema: {
979
1068
  type: SchemaType.OBJECT,
@@ -1094,6 +1183,9 @@ export function createTrivialMessageClassifierSession() {
1094
1183
  return new ProxyChatSession(model, TRIVIAL_MESSAGE_CLASSIFIER_SYSTEM_INSTRUCTION, [], // no tools
1095
1184
  {
1096
1185
  temperature: 0,
1186
+ thinkingConfig: {
1187
+ thinkingLevel: 'MINIMAL',
1188
+ },
1097
1189
  responseMimeType: 'application/json',
1098
1190
  responseSchema: {
1099
1191
  type: SchemaType.OBJECT,
@@ -1138,11 +1230,11 @@ export async function generateChatTitle(firstMessage, abortSignal) {
1138
1230
  }
1139
1231
  const creds = await loadCredentials();
1140
1232
  result = await proxyClient.generateViaBYOK(creds.geminiApiKey, model, contents, [], // no tools
1141
- undefined, instruction, { temperature: 0.2 }, undefined, abortSignal);
1233
+ undefined, instruction, { temperature: 0.2, thinkingConfig: { thinkingLevel: 'MINIMAL' } }, undefined, abortSignal);
1142
1234
  }
1143
1235
  else {
1144
1236
  result = await proxyClient.generateFunctionCallViaProxy(idToken, model, contents, [], // no tools
1145
- undefined, instruction, { temperature: 0.2 }, undefined, abortSignal);
1237
+ undefined, instruction, { temperature: 0.2, thinkingConfig: { thinkingLevel: 'MINIMAL' } }, undefined, abortSignal);
1146
1238
  }
1147
1239
  let title = '';
1148
1240
  if (result.parts) {
@@ -209,6 +209,7 @@ export async function routeIntent(userRequest, chatHistory = '', abortSignal) {
209
209
  }
210
210
  try {
211
211
  const session = createIntentRouterSession();
212
+ debugLog(`Intent Router evaluating intent [Model: ${session.getModel()}, Thinking: ${session.getThinkingLevel() || 'MINIMAL'}]`);
212
213
  let prompt = `User Request: "${userRequest}"`;
213
214
  if (chatHistory) {
214
215
  const prunedHistory = pruneTextToTokenBudget(chatHistory, MAX_CHAT_HISTORY_ROUTER_TOKENS, { fromStart: true });
@@ -242,6 +243,7 @@ export async function evaluateExecutionComplexity(userRequest, investigationSumm
242
243
  }
243
244
  try {
244
245
  const session = createExecutionComplexitySession();
246
+ debugLog(`Execution Complexity evaluating [Model: ${session.getModel()}, Thinking: ${session.getThinkingLevel() || 'MINIMAL'}]`);
245
247
  let prompt = `User Request: "${userRequest}"
246
248
  Investigation Summary: ${investigationSummary || 'None (0 files needed)'}
247
249
  Number of Relevant Files: ${numRelevantFiles}`;
@@ -418,6 +420,7 @@ export async function gatherContext(workspaceRoot, userRequest, chatHistory = ''
418
420
  }
419
421
  // ─── Single Context Agent (Unified Reconnaissance) ───────────
420
422
  const session = createContextAgentSession();
423
+ debugLog(`[Context Agent] Starting reconnaissance [Model: ${session.getModel()}, Thinking: ${session.getThinkingLevel() || 'MEDIUM'}]`);
421
424
  const relevantFiles = new Map();
422
425
  let summary = 'No relevant context found.';
423
426
  let isInvestigationFinished = false;
@@ -430,6 +433,26 @@ export async function gatherContext(workspaceRoot, userRequest, chatHistory = ''
430
433
  const prunedHistory = pruneTextToTokenBudget(chatHistory, MAX_CHAT_HISTORY_INVESTIGATION_TOKENS, { fromStart: true });
431
434
  currentMessage = `Previous Conversation Context:\n${prunedHistory}\n\n` + currentMessage;
432
435
  }
436
+ // Parse explicit context mentions from user request to prioritize referenced files
437
+ try {
438
+ const { mentionEngine } = await import('./mentionEngine.js');
439
+ const parsedMentions = mentionEngine.parseMentions(userRequest, workspaceRoot);
440
+ const explicitMentionedFiles = parsedMentions
441
+ .filter((m) => m.type === 'file' && m.valid)
442
+ .map((m) => m.target);
443
+ if (parsedMentions.length > 0) {
444
+ const validMentions = parsedMentions.filter((m) => m.valid);
445
+ if (validMentions.length > 0 && onProgress) {
446
+ const mentionLabels = validMentions.map((m) => m.raw).slice(0, 4).join(', ');
447
+ const overflow = validMentions.length > 4 ? ` (+${validMentions.length - 4} more)` : '';
448
+ onProgress(`Found explicit context: ${mentionLabels}${overflow}`);
449
+ }
450
+ }
451
+ if (explicitMentionedFiles.length > 0) {
452
+ currentMessage += `\n\nExplicit Mentioned Files from User Request:\n${explicitMentionedFiles.map((f) => `- ${f}`).join('\n')}`;
453
+ }
454
+ }
455
+ catch { }
433
456
  currentMessage += `\n\nStart investigating to find relevant files.`;
434
457
  const MAX_TURNS = Infinity;
435
458
  let textRetryCount = 0;
@@ -235,7 +235,7 @@ Approximate File Count: ${approximateFileCount}`;
235
235
  if (chatHistory.trim()) {
236
236
  prompt += `\n\nRecent Conversation:\n${chatHistory.trim()}`;
237
237
  }
238
- debugLog(`[InvestigationComplexity] Evaluating prompt complexity (autoFocus: ${activeSubPath || 'none'}, override: ${explicitOverride || 'none'})`);
238
+ debugLog(`[InvestigationComplexity] Evaluating prompt complexity (autoFocus: ${activeSubPath || 'none'}, override: ${explicitOverride || 'none'}) [Model: ${session.getModel()}, Thinking: ${session.getThinkingLevel() || 'MEDIUM'}]`);
239
239
  const response = await session.sendMessage(prompt, undefined, abortSignal);
240
240
  const rawText = typeof response?.response?.text === 'function'
241
241
  ? response.response.text()