@j0hanz/code-review-analyst-mcp 1.4.3 → 1.4.4
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/lib/gemini.js +55 -11
- package/dist/lib/model-config.d.ts +22 -7
- package/dist/lib/model-config.js +68 -7
- package/dist/lib/tool-contracts.d.ts +24 -7
- package/dist/lib/tool-contracts.js +11 -1
- package/dist/lib/tool-factory.d.ts +7 -0
- package/dist/lib/tool-factory.js +3 -0
- package/dist/tools/analyze-complexity.js +3 -0
- package/dist/tools/analyze-pr-impact.js +6 -0
- package/dist/tools/detect-api-breaking.js +6 -0
- package/dist/tools/generate-review-summary.js +6 -0
- package/dist/tools/generate-test-plan.js +3 -0
- package/dist/tools/inspect-code-quality.js +3 -0
- package/dist/tools/suggest-search-replace.js +3 -0
- package/package.json +1 -1
package/dist/lib/gemini.js
CHANGED
|
@@ -36,8 +36,8 @@ const DIGITS_ONLY_PATTERN = /^\d+$/;
|
|
|
36
36
|
const SLEEP_UNREF_OPTIONS = { ref: false };
|
|
37
37
|
const maxConcurrentCallsConfig = createCachedEnvInt('MAX_CONCURRENT_CALLS', 10);
|
|
38
38
|
const concurrencyWaitMsConfig = createCachedEnvInt('MAX_CONCURRENT_CALLS_WAIT_MS', 2_000);
|
|
39
|
-
const concurrencyPollMsConfig = createCachedEnvInt('MAX_CONCURRENT_CALLS_POLL_MS', 25);
|
|
40
39
|
let activeCalls = 0;
|
|
40
|
+
const slotWaiters = [];
|
|
41
41
|
const RETRYABLE_TRANSIENT_CODES = new Set([
|
|
42
42
|
'RESOURCE_EXHAUSTED',
|
|
43
43
|
'UNAVAILABLE',
|
|
@@ -443,19 +443,62 @@ async function runWithRetries(request, model, timeoutMs, maxRetries, onLog) {
|
|
|
443
443
|
function canRetryAttempt(attempt, maxRetries, error) {
|
|
444
444
|
return attempt < maxRetries && shouldRetry(error);
|
|
445
445
|
}
|
|
446
|
+
function tryWakeNextWaiter() {
|
|
447
|
+
const next = slotWaiters.shift();
|
|
448
|
+
if (next !== undefined) {
|
|
449
|
+
next();
|
|
450
|
+
}
|
|
451
|
+
}
|
|
446
452
|
async function waitForConcurrencySlot(limit, requestSignal) {
|
|
453
|
+
if (activeCalls < limit) {
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
if (requestSignal?.aborted) {
|
|
457
|
+
throw new Error('Gemini request was cancelled.');
|
|
458
|
+
}
|
|
447
459
|
const waitLimitMs = concurrencyWaitMsConfig.get();
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
460
|
+
return new Promise((resolve, reject) => {
|
|
461
|
+
let settled = false;
|
|
462
|
+
const waiter = () => {
|
|
463
|
+
if (settled)
|
|
464
|
+
return;
|
|
465
|
+
settled = true;
|
|
466
|
+
clearTimeout(deadlineTimer);
|
|
467
|
+
if (requestSignal) {
|
|
468
|
+
requestSignal.removeEventListener('abort', onAbort);
|
|
469
|
+
}
|
|
470
|
+
resolve();
|
|
471
|
+
};
|
|
472
|
+
slotWaiters.push(waiter);
|
|
473
|
+
const deadlineTimer = setTimeout(() => {
|
|
474
|
+
if (settled)
|
|
475
|
+
return;
|
|
476
|
+
settled = true;
|
|
477
|
+
const idx = slotWaiters.indexOf(waiter);
|
|
478
|
+
if (idx !== -1) {
|
|
479
|
+
slotWaiters.splice(idx, 1);
|
|
480
|
+
}
|
|
481
|
+
if (requestSignal) {
|
|
482
|
+
requestSignal.removeEventListener('abort', onAbort);
|
|
483
|
+
}
|
|
484
|
+
reject(new Error(formatConcurrencyLimitErrorMessage(limit, waitLimitMs)));
|
|
485
|
+
}, waitLimitMs);
|
|
486
|
+
deadlineTimer.unref();
|
|
487
|
+
const onAbort = () => {
|
|
488
|
+
if (settled)
|
|
489
|
+
return;
|
|
490
|
+
settled = true;
|
|
491
|
+
const idx = slotWaiters.indexOf(waiter);
|
|
492
|
+
if (idx !== -1) {
|
|
493
|
+
slotWaiters.splice(idx, 1);
|
|
494
|
+
}
|
|
495
|
+
clearTimeout(deadlineTimer);
|
|
496
|
+
reject(new Error('Gemini request was cancelled.'));
|
|
497
|
+
};
|
|
498
|
+
if (requestSignal) {
|
|
499
|
+
requestSignal.addEventListener('abort', onAbort, { once: true });
|
|
456
500
|
}
|
|
457
|
-
|
|
458
|
-
}
|
|
501
|
+
});
|
|
459
502
|
}
|
|
460
503
|
export async function generateStructuredJson(request) {
|
|
461
504
|
const model = request.model ?? getDefaultModel();
|
|
@@ -470,5 +513,6 @@ export async function generateStructuredJson(request) {
|
|
|
470
513
|
}
|
|
471
514
|
finally {
|
|
472
515
|
activeCalls -= 1;
|
|
516
|
+
tryWakeNextWaiter();
|
|
473
517
|
}
|
|
474
518
|
}
|
|
@@ -2,24 +2,39 @@
|
|
|
2
2
|
export declare const FLASH_MODEL = "gemini-2.5-flash";
|
|
3
3
|
/** High-capability model for deep reasoning, quality inspection, and reliable code generation. */
|
|
4
4
|
export declare const PRO_MODEL = "gemini-2.5-pro";
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Thinking budget (tokens) for Flash triage tools (impact, summary, API-breaking).
|
|
7
|
+
* Explicitly disabled (0) — these are classification/extraction tasks that do not
|
|
8
|
+
* benefit from a reasoning chain. Avoids default dynamic-thinking overhead.
|
|
9
|
+
* Flash 2.5 range: 0–24_576.
|
|
10
|
+
*/
|
|
11
|
+
export declare const FLASH_TRIAGE_THINKING_BUDGET: 0;
|
|
12
|
+
/** Thinking budget (tokens) for Flash analysis tasks (test plans, complexity). */
|
|
13
|
+
export declare const FLASH_THINKING_BUDGET: 16384;
|
|
14
|
+
/** Thinking budget (tokens) for Pro model deep-analysis tasks (quality, patches). */
|
|
15
|
+
export declare const PRO_THINKING_BUDGET: 24576;
|
|
9
16
|
/** Output cap for Flash triage tools (impact, summary). */
|
|
10
17
|
export declare const FLASH_TRIAGE_MAX_OUTPUT_TOKENS: 4096;
|
|
11
18
|
/** Output cap for API breaking-change detection (migration guidance needs room). */
|
|
12
19
|
export declare const FLASH_API_BREAKING_MAX_OUTPUT_TOKENS: 4096;
|
|
13
20
|
/** Output cap for test-plan generation (includes pseudocode snippets). */
|
|
14
|
-
export declare const FLASH_TEST_PLAN_MAX_OUTPUT_TOKENS:
|
|
21
|
+
export declare const FLASH_TEST_PLAN_MAX_OUTPUT_TOKENS: 8192;
|
|
15
22
|
/** Output cap for Pro deep review findings. */
|
|
16
|
-
export declare const PRO_REVIEW_MAX_OUTPUT_TOKENS:
|
|
23
|
+
export declare const PRO_REVIEW_MAX_OUTPUT_TOKENS: 12288;
|
|
17
24
|
/** Output cap for Pro search/replace remediation blocks. */
|
|
18
|
-
export declare const PRO_PATCH_MAX_OUTPUT_TOKENS:
|
|
25
|
+
export declare const PRO_PATCH_MAX_OUTPUT_TOKENS: 8192;
|
|
19
26
|
/** Output cap for Flash complexity analysis reports. */
|
|
20
27
|
export declare const FLASH_COMPLEXITY_MAX_OUTPUT_TOKENS: 2048;
|
|
21
28
|
/** Extended timeout for Pro model calls (ms). Pro thinks longer than Flash. */
|
|
22
29
|
export declare const DEFAULT_TIMEOUT_PRO_MS = 120000;
|
|
30
|
+
/** Temperature for triage/classification tools (deterministic structured extraction). */
|
|
31
|
+
export declare const TRIAGE_TEMPERATURE: 0.1;
|
|
32
|
+
/** Temperature for analytical tools (consistent algorithmic reasoning). */
|
|
33
|
+
export declare const ANALYSIS_TEMPERATURE: 0.1;
|
|
34
|
+
/** Temperature for code patch generation (maximum precision for search blocks). */
|
|
35
|
+
export declare const PATCH_TEMPERATURE: 0;
|
|
36
|
+
/** Temperature for creative synthesis tools (test plan generation). */
|
|
37
|
+
export declare const CREATIVE_TEMPERATURE: 0.2;
|
|
23
38
|
export declare const MODEL_TIMEOUT_MS: {
|
|
24
39
|
readonly defaultPro: 120000;
|
|
25
40
|
};
|
package/dist/lib/model-config.js
CHANGED
|
@@ -3,21 +3,71 @@ export const FLASH_MODEL = 'gemini-2.5-flash';
|
|
|
3
3
|
/** High-capability model for deep reasoning, quality inspection, and reliable code generation. */
|
|
4
4
|
export const PRO_MODEL = 'gemini-2.5-pro';
|
|
5
5
|
const THINKING_BUDGET_TOKENS = {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Disabled (0): triage/classification tasks need no reasoning chain.
|
|
8
|
+
* Flash 2.5 range: 0–24_576; 0 explicitly disables thinking.
|
|
9
|
+
*/
|
|
10
|
+
flashTriage: 0,
|
|
11
|
+
/**
|
|
12
|
+
* Raised from 8_192 → half of Flash max (24_576).
|
|
13
|
+
* Used for analysis tasks (test plans, complexity) that benefit from
|
|
14
|
+
* multi-step reasoning but not from unbounded thinking tokens.
|
|
15
|
+
*/
|
|
16
|
+
flash: 16_384,
|
|
17
|
+
/**
|
|
18
|
+
* Raised from 16_384 → 75 % of Pro max (32_768).
|
|
19
|
+
* Gives deep-review and patch-generation tools genuine headroom for
|
|
20
|
+
* complex multi-file diffs without switching to cost-unpredictable dynamic.
|
|
21
|
+
*/
|
|
22
|
+
pro: 24_576,
|
|
8
23
|
};
|
|
9
24
|
const OUTPUT_TOKEN_BUDGET = {
|
|
10
25
|
flashTriage: 4_096,
|
|
11
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Raised from 4_096: 15 test cases × pseudoCode@2_000 chars ≈ 7_500 tokens;
|
|
28
|
+
* staying at 4_096 risked MAX_TOKENS truncation on moderate test plans.
|
|
29
|
+
*/
|
|
30
|
+
flashTestPlan: 8_192,
|
|
12
31
|
flashApiBreaking: 4_096,
|
|
13
32
|
flashComplexity: 2_048,
|
|
14
|
-
|
|
15
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Raised from 8_192: 25 findings × (title+explanation+recommendation) can
|
|
35
|
+
* exceed 8_192 tokens for rich, high-finding-count reviews.
|
|
36
|
+
*/
|
|
37
|
+
proReview: 12_288,
|
|
38
|
+
/**
|
|
39
|
+
* Raised from 4_096: 10 search/replace blocks with multi-line code context
|
|
40
|
+
* can exceed the previous cap and cause MAX_TOKENS truncation.
|
|
41
|
+
*/
|
|
42
|
+
proPatch: 8_192,
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Per-task temperature presets for structured JSON generation.
|
|
46
|
+
* These are intentionally low: the model is already heavily constrained by
|
|
47
|
+
* the responseSchema, so lower temperatures improve schema-validation
|
|
48
|
+
* pass-through rates and reduce hallucinated field values.
|
|
49
|
+
*/
|
|
50
|
+
const TOOL_TEMPERATURE = {
|
|
51
|
+
/** Triage/classification tasks — deterministic structured extraction. */
|
|
52
|
+
triage: 0.1,
|
|
53
|
+
/** Analytical reasoning — consistent algorithmic analysis. */
|
|
54
|
+
analysis: 0.1,
|
|
55
|
+
/** Code patch generation — maximum precision for exact-match search blocks. */
|
|
56
|
+
patch: 0.0,
|
|
57
|
+
/** Test plan generation — allow modest diversity in test-case synthesis. */
|
|
58
|
+
creative: 0.2,
|
|
16
59
|
};
|
|
17
60
|
const DEFAULT_DETECT_HINT = 'detect';
|
|
18
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* Thinking budget (tokens) for Flash triage tools (impact, summary, API-breaking).
|
|
63
|
+
* Explicitly disabled (0) — these are classification/extraction tasks that do not
|
|
64
|
+
* benefit from a reasoning chain. Avoids default dynamic-thinking overhead.
|
|
65
|
+
* Flash 2.5 range: 0–24_576.
|
|
66
|
+
*/
|
|
67
|
+
export const FLASH_TRIAGE_THINKING_BUDGET = THINKING_BUDGET_TOKENS.flashTriage;
|
|
68
|
+
/** Thinking budget (tokens) for Flash analysis tasks (test plans, complexity). */
|
|
19
69
|
export const FLASH_THINKING_BUDGET = THINKING_BUDGET_TOKENS.flash;
|
|
20
|
-
/** Thinking budget (tokens) for Pro model deep-analysis tasks (
|
|
70
|
+
/** Thinking budget (tokens) for Pro model deep-analysis tasks (quality, patches). */
|
|
21
71
|
export const PRO_THINKING_BUDGET = THINKING_BUDGET_TOKENS.pro;
|
|
22
72
|
/** Output cap for Flash triage tools (impact, summary). */
|
|
23
73
|
export const FLASH_TRIAGE_MAX_OUTPUT_TOKENS = OUTPUT_TOKEN_BUDGET.flashTriage;
|
|
@@ -33,6 +83,17 @@ export const PRO_PATCH_MAX_OUTPUT_TOKENS = OUTPUT_TOKEN_BUDGET.proPatch;
|
|
|
33
83
|
export const FLASH_COMPLEXITY_MAX_OUTPUT_TOKENS = OUTPUT_TOKEN_BUDGET.flashComplexity;
|
|
34
84
|
/** Extended timeout for Pro model calls (ms). Pro thinks longer than Flash. */
|
|
35
85
|
export const DEFAULT_TIMEOUT_PRO_MS = 120_000;
|
|
86
|
+
// ---------------------------------------------------------------------------
|
|
87
|
+
// Temperature presets — see TOOL_TEMPERATURE constant for rationale.
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
/** Temperature for triage/classification tools (deterministic structured extraction). */
|
|
90
|
+
export const TRIAGE_TEMPERATURE = TOOL_TEMPERATURE.triage;
|
|
91
|
+
/** Temperature for analytical tools (consistent algorithmic reasoning). */
|
|
92
|
+
export const ANALYSIS_TEMPERATURE = TOOL_TEMPERATURE.analysis;
|
|
93
|
+
/** Temperature for code patch generation (maximum precision for search blocks). */
|
|
94
|
+
export const PATCH_TEMPERATURE = TOOL_TEMPERATURE.patch;
|
|
95
|
+
/** Temperature for creative synthesis tools (test plan generation). */
|
|
96
|
+
export const CREATIVE_TEMPERATURE = TOOL_TEMPERATURE.creative;
|
|
36
97
|
export const MODEL_TIMEOUT_MS = {
|
|
37
98
|
defaultPro: DEFAULT_TIMEOUT_PRO_MS,
|
|
38
99
|
};
|
|
@@ -16,6 +16,13 @@ export interface ToolContract {
|
|
|
16
16
|
thinkingBudget?: number;
|
|
17
17
|
/** Set to 0 for synchronous (non-Gemini) tools. */
|
|
18
18
|
maxOutputTokens: number;
|
|
19
|
+
/**
|
|
20
|
+
* Sampling temperature for the Gemini call.
|
|
21
|
+
* Lower values (0.0–0.1) favour deterministic structured output;
|
|
22
|
+
* higher values (0.2) add diversity for creative synthesis tasks.
|
|
23
|
+
* Omit to use the global default (0.2).
|
|
24
|
+
*/
|
|
25
|
+
temperature?: number;
|
|
19
26
|
params: readonly ToolParameterContract[];
|
|
20
27
|
outputShape: string;
|
|
21
28
|
gotchas: readonly string[];
|
|
@@ -43,7 +50,9 @@ export declare const TOOL_CONTRACTS: readonly [{
|
|
|
43
50
|
readonly purpose: "Assess severity, categories, breaking changes, and rollback complexity.";
|
|
44
51
|
readonly model: "gemini-2.5-flash";
|
|
45
52
|
readonly timeoutMs: 90000;
|
|
53
|
+
readonly thinkingBudget: 0;
|
|
46
54
|
readonly maxOutputTokens: 4096;
|
|
55
|
+
readonly temperature: 0.1;
|
|
47
56
|
readonly params: readonly [{
|
|
48
57
|
readonly name: "repository";
|
|
49
58
|
readonly type: "string";
|
|
@@ -65,7 +74,9 @@ export declare const TOOL_CONTRACTS: readonly [{
|
|
|
65
74
|
readonly purpose: "Produce PR summary, risk rating, and merge recommendation.";
|
|
66
75
|
readonly model: "gemini-2.5-flash";
|
|
67
76
|
readonly timeoutMs: 90000;
|
|
77
|
+
readonly thinkingBudget: 0;
|
|
68
78
|
readonly maxOutputTokens: 4096;
|
|
79
|
+
readonly temperature: 0.1;
|
|
69
80
|
readonly params: readonly [{
|
|
70
81
|
readonly name: "repository";
|
|
71
82
|
readonly type: "string";
|
|
@@ -87,8 +98,9 @@ export declare const TOOL_CONTRACTS: readonly [{
|
|
|
87
98
|
readonly purpose: "Deep code review with optional full-file context.";
|
|
88
99
|
readonly model: "gemini-2.5-pro";
|
|
89
100
|
readonly timeoutMs: 120000;
|
|
90
|
-
readonly thinkingBudget:
|
|
91
|
-
readonly maxOutputTokens:
|
|
101
|
+
readonly thinkingBudget: 24576;
|
|
102
|
+
readonly maxOutputTokens: 12288;
|
|
103
|
+
readonly temperature: 0.1;
|
|
92
104
|
readonly params: readonly [{
|
|
93
105
|
readonly name: "repository";
|
|
94
106
|
readonly type: "string";
|
|
@@ -129,8 +141,9 @@ export declare const TOOL_CONTRACTS: readonly [{
|
|
|
129
141
|
readonly purpose: "Generate verbatim search/replace fix blocks for one finding.";
|
|
130
142
|
readonly model: "gemini-2.5-pro";
|
|
131
143
|
readonly timeoutMs: 120000;
|
|
132
|
-
readonly thinkingBudget:
|
|
133
|
-
readonly maxOutputTokens:
|
|
144
|
+
readonly thinkingBudget: 24576;
|
|
145
|
+
readonly maxOutputTokens: 8192;
|
|
146
|
+
readonly temperature: 0;
|
|
134
147
|
readonly params: readonly [{
|
|
135
148
|
readonly name: "findingTitle";
|
|
136
149
|
readonly type: "string";
|
|
@@ -153,8 +166,9 @@ export declare const TOOL_CONTRACTS: readonly [{
|
|
|
153
166
|
readonly purpose: "Generate prioritized test cases and coverage guidance.";
|
|
154
167
|
readonly model: "gemini-2.5-flash";
|
|
155
168
|
readonly timeoutMs: 90000;
|
|
156
|
-
readonly thinkingBudget:
|
|
157
|
-
readonly maxOutputTokens:
|
|
169
|
+
readonly thinkingBudget: 16384;
|
|
170
|
+
readonly maxOutputTokens: 8192;
|
|
171
|
+
readonly temperature: 0.2;
|
|
158
172
|
readonly params: readonly [{
|
|
159
173
|
readonly name: "repository";
|
|
160
174
|
readonly type: "string";
|
|
@@ -188,8 +202,9 @@ export declare const TOOL_CONTRACTS: readonly [{
|
|
|
188
202
|
readonly purpose: "Analyze Big-O complexity and detect degradations in changed code.";
|
|
189
203
|
readonly model: "gemini-2.5-flash";
|
|
190
204
|
readonly timeoutMs: 90000;
|
|
191
|
-
readonly thinkingBudget:
|
|
205
|
+
readonly thinkingBudget: 16384;
|
|
192
206
|
readonly maxOutputTokens: 2048;
|
|
207
|
+
readonly temperature: 0.1;
|
|
193
208
|
readonly params: readonly [{
|
|
194
209
|
readonly name: "language";
|
|
195
210
|
readonly type: "string";
|
|
@@ -205,7 +220,9 @@ export declare const TOOL_CONTRACTS: readonly [{
|
|
|
205
220
|
readonly purpose: "Detect breaking API/interface changes in a diff.";
|
|
206
221
|
readonly model: "gemini-2.5-flash";
|
|
207
222
|
readonly timeoutMs: 90000;
|
|
223
|
+
readonly thinkingBudget: 0;
|
|
208
224
|
readonly maxOutputTokens: 4096;
|
|
225
|
+
readonly temperature: 0.1;
|
|
209
226
|
readonly params: readonly [{
|
|
210
227
|
readonly name: "language";
|
|
211
228
|
readonly type: "string";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_TIMEOUT_PRO_MS, FLASH_API_BREAKING_MAX_OUTPUT_TOKENS, FLASH_COMPLEXITY_MAX_OUTPUT_TOKENS, FLASH_MODEL, FLASH_TEST_PLAN_MAX_OUTPUT_TOKENS, FLASH_THINKING_BUDGET, FLASH_TRIAGE_MAX_OUTPUT_TOKENS, PRO_MODEL, PRO_PATCH_MAX_OUTPUT_TOKENS, PRO_REVIEW_MAX_OUTPUT_TOKENS, PRO_THINKING_BUDGET, } from './model-config.js';
|
|
1
|
+
import { ANALYSIS_TEMPERATURE, CREATIVE_TEMPERATURE, DEFAULT_TIMEOUT_PRO_MS, FLASH_API_BREAKING_MAX_OUTPUT_TOKENS, FLASH_COMPLEXITY_MAX_OUTPUT_TOKENS, FLASH_MODEL, FLASH_TEST_PLAN_MAX_OUTPUT_TOKENS, FLASH_THINKING_BUDGET, FLASH_TRIAGE_MAX_OUTPUT_TOKENS, FLASH_TRIAGE_THINKING_BUDGET, PATCH_TEMPERATURE, PRO_MODEL, PRO_PATCH_MAX_OUTPUT_TOKENS, PRO_REVIEW_MAX_OUTPUT_TOKENS, PRO_THINKING_BUDGET, TRIAGE_TEMPERATURE, } from './model-config.js';
|
|
2
2
|
const DEFAULT_TIMEOUT_FLASH_MS = 90_000;
|
|
3
3
|
export const INSPECTION_FOCUS_AREAS = [
|
|
4
4
|
'security',
|
|
@@ -40,7 +40,9 @@ export const TOOL_CONTRACTS = [
|
|
|
40
40
|
purpose: 'Assess severity, categories, breaking changes, and rollback complexity.',
|
|
41
41
|
model: FLASH_MODEL,
|
|
42
42
|
timeoutMs: DEFAULT_TIMEOUT_FLASH_MS,
|
|
43
|
+
thinkingBudget: FLASH_TRIAGE_THINKING_BUDGET,
|
|
43
44
|
maxOutputTokens: FLASH_TRIAGE_MAX_OUTPUT_TOKENS,
|
|
45
|
+
temperature: TRIAGE_TEMPERATURE,
|
|
44
46
|
params: [
|
|
45
47
|
{
|
|
46
48
|
name: 'repository',
|
|
@@ -71,7 +73,9 @@ export const TOOL_CONTRACTS = [
|
|
|
71
73
|
purpose: 'Produce PR summary, risk rating, and merge recommendation.',
|
|
72
74
|
model: FLASH_MODEL,
|
|
73
75
|
timeoutMs: DEFAULT_TIMEOUT_FLASH_MS,
|
|
76
|
+
thinkingBudget: FLASH_TRIAGE_THINKING_BUDGET,
|
|
74
77
|
maxOutputTokens: FLASH_TRIAGE_MAX_OUTPUT_TOKENS,
|
|
78
|
+
temperature: TRIAGE_TEMPERATURE,
|
|
75
79
|
params: [
|
|
76
80
|
{
|
|
77
81
|
name: 'repository',
|
|
@@ -104,6 +108,7 @@ export const TOOL_CONTRACTS = [
|
|
|
104
108
|
timeoutMs: DEFAULT_TIMEOUT_PRO_MS,
|
|
105
109
|
thinkingBudget: PRO_THINKING_BUDGET,
|
|
106
110
|
maxOutputTokens: PRO_REVIEW_MAX_OUTPUT_TOKENS,
|
|
111
|
+
temperature: ANALYSIS_TEMPERATURE,
|
|
107
112
|
params: [
|
|
108
113
|
{
|
|
109
114
|
name: 'repository',
|
|
@@ -160,6 +165,7 @@ export const TOOL_CONTRACTS = [
|
|
|
160
165
|
timeoutMs: DEFAULT_TIMEOUT_PRO_MS,
|
|
161
166
|
thinkingBudget: PRO_THINKING_BUDGET,
|
|
162
167
|
maxOutputTokens: PRO_PATCH_MAX_OUTPUT_TOKENS,
|
|
168
|
+
temperature: PATCH_TEMPERATURE,
|
|
163
169
|
params: [
|
|
164
170
|
{
|
|
165
171
|
name: 'findingTitle',
|
|
@@ -194,6 +200,7 @@ export const TOOL_CONTRACTS = [
|
|
|
194
200
|
timeoutMs: DEFAULT_TIMEOUT_FLASH_MS,
|
|
195
201
|
thinkingBudget: FLASH_THINKING_BUDGET,
|
|
196
202
|
maxOutputTokens: FLASH_TEST_PLAN_MAX_OUTPUT_TOKENS,
|
|
203
|
+
temperature: CREATIVE_TEMPERATURE,
|
|
197
204
|
params: [
|
|
198
205
|
{
|
|
199
206
|
name: 'repository',
|
|
@@ -240,6 +247,7 @@ export const TOOL_CONTRACTS = [
|
|
|
240
247
|
timeoutMs: DEFAULT_TIMEOUT_FLASH_MS,
|
|
241
248
|
thinkingBudget: FLASH_THINKING_BUDGET,
|
|
242
249
|
maxOutputTokens: FLASH_COMPLEXITY_MAX_OUTPUT_TOKENS,
|
|
250
|
+
temperature: ANALYSIS_TEMPERATURE,
|
|
243
251
|
params: [
|
|
244
252
|
{
|
|
245
253
|
name: 'language',
|
|
@@ -261,7 +269,9 @@ export const TOOL_CONTRACTS = [
|
|
|
261
269
|
purpose: 'Detect breaking API/interface changes in a diff.',
|
|
262
270
|
model: FLASH_MODEL,
|
|
263
271
|
timeoutMs: DEFAULT_TIMEOUT_FLASH_MS,
|
|
272
|
+
thinkingBudget: FLASH_TRIAGE_THINKING_BUDGET,
|
|
264
273
|
maxOutputTokens: FLASH_API_BREAKING_MAX_OUTPUT_TOKENS,
|
|
274
|
+
temperature: TRIAGE_TEMPERATURE,
|
|
265
275
|
params: [
|
|
266
276
|
{
|
|
267
277
|
name: 'language',
|
|
@@ -63,6 +63,13 @@ export interface StructuredToolTaskConfig<TInput extends object = Record<string,
|
|
|
63
63
|
timeoutMs?: number;
|
|
64
64
|
/** Optional max output tokens for Gemini. */
|
|
65
65
|
maxOutputTokens?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Optional sampling temperature for this tool's Gemini call.
|
|
68
|
+
* Lower values (0.0–0.1) favour determinism for structured extraction;
|
|
69
|
+
* higher values (0.2) add useful diversity for creative synthesis tasks.
|
|
70
|
+
* Falls back to the global default (0.2) when omitted.
|
|
71
|
+
*/
|
|
72
|
+
temperature?: number;
|
|
66
73
|
/** Optional opt-in to Gemini thought output. Defaults to false. */
|
|
67
74
|
includeThoughts?: boolean;
|
|
68
75
|
/** Optional formatter for human-readable text output. */
|
package/dist/lib/tool-factory.js
CHANGED
|
@@ -40,6 +40,9 @@ function createGenerationRequest(config, promptParts, responseSchema, onLog, sig
|
|
|
40
40
|
if (config.maxOutputTokens !== undefined) {
|
|
41
41
|
request.maxOutputTokens = config.maxOutputTokens;
|
|
42
42
|
}
|
|
43
|
+
if (config.temperature !== undefined) {
|
|
44
|
+
request.temperature = config.temperature;
|
|
45
|
+
}
|
|
43
46
|
if (config.includeThoughts !== undefined) {
|
|
44
47
|
request.includeThoughts = config.includeThoughts;
|
|
45
48
|
}
|
|
@@ -26,6 +26,9 @@ export function registerAnalyzeComplexityTool(server) {
|
|
|
26
26
|
...(TOOL_CONTRACT.thinkingBudget !== undefined
|
|
27
27
|
? { thinkingBudget: TOOL_CONTRACT.thinkingBudget }
|
|
28
28
|
: undefined),
|
|
29
|
+
...(TOOL_CONTRACT.temperature !== undefined
|
|
30
|
+
? { temperature: TOOL_CONTRACT.temperature }
|
|
31
|
+
: undefined),
|
|
29
32
|
validateInput: (_input, ctx) => {
|
|
30
33
|
const slot = ctx.diffSlot;
|
|
31
34
|
if (!slot)
|
|
@@ -27,6 +27,12 @@ export function registerAnalyzePrImpactTool(server) {
|
|
|
27
27
|
model: TOOL_CONTRACT.model,
|
|
28
28
|
timeoutMs: TOOL_CONTRACT.timeoutMs,
|
|
29
29
|
maxOutputTokens: TOOL_CONTRACT.maxOutputTokens,
|
|
30
|
+
...(TOOL_CONTRACT.thinkingBudget !== undefined
|
|
31
|
+
? { thinkingBudget: TOOL_CONTRACT.thinkingBudget }
|
|
32
|
+
: undefined),
|
|
33
|
+
...(TOOL_CONTRACT.temperature !== undefined
|
|
34
|
+
? { temperature: TOOL_CONTRACT.temperature }
|
|
35
|
+
: undefined),
|
|
30
36
|
validateInput: (_input, ctx) => {
|
|
31
37
|
const slot = ctx.diffSlot;
|
|
32
38
|
if (!slot)
|
|
@@ -23,6 +23,12 @@ export function registerDetectApiBreakingTool(server) {
|
|
|
23
23
|
model: TOOL_CONTRACT.model,
|
|
24
24
|
timeoutMs: TOOL_CONTRACT.timeoutMs,
|
|
25
25
|
maxOutputTokens: TOOL_CONTRACT.maxOutputTokens,
|
|
26
|
+
...(TOOL_CONTRACT.thinkingBudget !== undefined
|
|
27
|
+
? { thinkingBudget: TOOL_CONTRACT.thinkingBudget }
|
|
28
|
+
: undefined),
|
|
29
|
+
...(TOOL_CONTRACT.temperature !== undefined
|
|
30
|
+
? { temperature: TOOL_CONTRACT.temperature }
|
|
31
|
+
: undefined),
|
|
26
32
|
validateInput: (_input, ctx) => {
|
|
27
33
|
const slot = ctx.diffSlot;
|
|
28
34
|
if (!slot)
|
|
@@ -34,6 +34,12 @@ export function registerGenerateReviewSummaryTool(server) {
|
|
|
34
34
|
model: TOOL_CONTRACT.model,
|
|
35
35
|
timeoutMs: TOOL_CONTRACT.timeoutMs,
|
|
36
36
|
maxOutputTokens: TOOL_CONTRACT.maxOutputTokens,
|
|
37
|
+
...(TOOL_CONTRACT.thinkingBudget !== undefined
|
|
38
|
+
? { thinkingBudget: TOOL_CONTRACT.thinkingBudget }
|
|
39
|
+
: undefined),
|
|
40
|
+
...(TOOL_CONTRACT.temperature !== undefined
|
|
41
|
+
? { temperature: TOOL_CONTRACT.temperature }
|
|
42
|
+
: undefined),
|
|
37
43
|
validateInput: (_input, ctx) => {
|
|
38
44
|
const slot = ctx.diffSlot;
|
|
39
45
|
if (!slot)
|
|
@@ -30,6 +30,9 @@ export function registerGenerateTestPlanTool(server) {
|
|
|
30
30
|
...(TOOL_CONTRACT.thinkingBudget !== undefined
|
|
31
31
|
? { thinkingBudget: TOOL_CONTRACT.thinkingBudget }
|
|
32
32
|
: undefined),
|
|
33
|
+
...(TOOL_CONTRACT.temperature !== undefined
|
|
34
|
+
? { temperature: TOOL_CONTRACT.temperature }
|
|
35
|
+
: undefined),
|
|
33
36
|
validateInput: (_input, ctx) => {
|
|
34
37
|
const slot = ctx.diffSlot;
|
|
35
38
|
if (!slot)
|
|
@@ -66,6 +66,9 @@ export function registerInspectCodeQualityTool(server) {
|
|
|
66
66
|
...(TOOL_CONTRACT.thinkingBudget !== undefined
|
|
67
67
|
? { thinkingBudget: TOOL_CONTRACT.thinkingBudget }
|
|
68
68
|
: undefined),
|
|
69
|
+
...(TOOL_CONTRACT.temperature !== undefined
|
|
70
|
+
? { temperature: TOOL_CONTRACT.temperature }
|
|
71
|
+
: undefined),
|
|
69
72
|
progressContext: (input) => {
|
|
70
73
|
const fileCount = input.files?.length;
|
|
71
74
|
return fileCount ? `+${fileCount} files` : '';
|
|
@@ -30,6 +30,9 @@ export function registerSuggestSearchReplaceTool(server) {
|
|
|
30
30
|
...(TOOL_CONTRACT.thinkingBudget !== undefined
|
|
31
31
|
? { thinkingBudget: TOOL_CONTRACT.thinkingBudget }
|
|
32
32
|
: undefined),
|
|
33
|
+
...(TOOL_CONTRACT.temperature !== undefined
|
|
34
|
+
? { temperature: TOOL_CONTRACT.temperature }
|
|
35
|
+
: undefined),
|
|
33
36
|
validateInput: (_input, ctx) => {
|
|
34
37
|
const slot = ctx.diffSlot;
|
|
35
38
|
if (!slot)
|