@maxanatsko/gemini-mcp-tool 2.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.
Files changed (119) hide show
  1. package/LICENSE +25 -0
  2. package/README.md +230 -0
  3. package/dist/constants.d.ts +153 -0
  4. package/dist/constants.d.ts.map +1 -0
  5. package/dist/constants.js +150 -0
  6. package/dist/constants.js.map +1 -0
  7. package/dist/index.d.ts +3 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +188 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/tools/ask-gemini.tool.d.ts +3 -0
  12. package/dist/tools/ask-gemini.tool.d.ts.map +1 -0
  13. package/dist/tools/ask-gemini.tool.js +74 -0
  14. package/dist/tools/ask-gemini.tool.js.map +1 -0
  15. package/dist/tools/brainstorm.tool.d.ts +3 -0
  16. package/dist/tools/brainstorm.tool.d.ts.map +1 -0
  17. package/dist/tools/brainstorm.tool.js +202 -0
  18. package/dist/tools/brainstorm.tool.js.map +1 -0
  19. package/dist/tools/fetch-chunk.tool.d.ts +3 -0
  20. package/dist/tools/fetch-chunk.tool.d.ts.map +1 -0
  21. package/dist/tools/fetch-chunk.tool.js +62 -0
  22. package/dist/tools/fetch-chunk.tool.js.map +1 -0
  23. package/dist/tools/index.d.ts +2 -0
  24. package/dist/tools/index.d.ts.map +1 -0
  25. package/dist/tools/index.js +11 -0
  26. package/dist/tools/index.js.map +1 -0
  27. package/dist/tools/registry.d.ts +25 -0
  28. package/dist/tools/registry.d.ts.map +1 -0
  29. package/dist/tools/registry.js +80 -0
  30. package/dist/tools/registry.js.map +1 -0
  31. package/dist/tools/review-code.tool.d.ts +3 -0
  32. package/dist/tools/review-code.tool.d.ts.map +1 -0
  33. package/dist/tools/review-code.tool.js +186 -0
  34. package/dist/tools/review-code.tool.js.map +1 -0
  35. package/dist/tools/simple-tools.d.ts +4 -0
  36. package/dist/tools/simple-tools.d.ts.map +1 -0
  37. package/dist/tools/simple-tools.js +32 -0
  38. package/dist/tools/simple-tools.js.map +1 -0
  39. package/dist/tools/test-tool.example.d.ts +13 -0
  40. package/dist/tools/test-tool.example.d.ts.map +1 -0
  41. package/dist/tools/test-tool.example.js +32 -0
  42. package/dist/tools/test-tool.example.js.map +1 -0
  43. package/dist/tools/timeout-test.tool.d.ts +3 -0
  44. package/dist/tools/timeout-test.tool.d.ts.map +1 -0
  45. package/dist/tools/timeout-test.tool.js +32 -0
  46. package/dist/tools/timeout-test.tool.js.map +1 -0
  47. package/dist/utils/askGeminiSessionManager.d.ts +57 -0
  48. package/dist/utils/askGeminiSessionManager.d.ts.map +1 -0
  49. package/dist/utils/askGeminiSessionManager.js +110 -0
  50. package/dist/utils/askGeminiSessionManager.js.map +1 -0
  51. package/dist/utils/brainstormSessionManager.d.ts +67 -0
  52. package/dist/utils/brainstormSessionManager.d.ts.map +1 -0
  53. package/dist/utils/brainstormSessionManager.js +165 -0
  54. package/dist/utils/brainstormSessionManager.js.map +1 -0
  55. package/dist/utils/changeModeChunker.d.ts +11 -0
  56. package/dist/utils/changeModeChunker.d.ts.map +1 -0
  57. package/dist/utils/changeModeChunker.js +89 -0
  58. package/dist/utils/changeModeChunker.js.map +1 -0
  59. package/dist/utils/changeModeParser.d.ts +15 -0
  60. package/dist/utils/changeModeParser.d.ts.map +1 -0
  61. package/dist/utils/changeModeParser.js +67 -0
  62. package/dist/utils/changeModeParser.js.map +1 -0
  63. package/dist/utils/changeModeTranslator.d.ts +8 -0
  64. package/dist/utils/changeModeTranslator.d.ts.map +1 -0
  65. package/dist/utils/changeModeTranslator.js +70 -0
  66. package/dist/utils/changeModeTranslator.js.map +1 -0
  67. package/dist/utils/chunkCache.d.ts +22 -0
  68. package/dist/utils/chunkCache.d.ts.map +1 -0
  69. package/dist/utils/chunkCache.js +161 -0
  70. package/dist/utils/chunkCache.js.map +1 -0
  71. package/dist/utils/commandExecutor.d.ts +2 -0
  72. package/dist/utils/commandExecutor.d.ts.map +1 -0
  73. package/dist/utils/commandExecutor.js +74 -0
  74. package/dist/utils/commandExecutor.js.map +1 -0
  75. package/dist/utils/geminiExecutor.d.ts +3 -0
  76. package/dist/utils/geminiExecutor.d.ts.map +1 -0
  77. package/dist/utils/geminiExecutor.js +170 -0
  78. package/dist/utils/geminiExecutor.js.map +1 -0
  79. package/dist/utils/gitStateDetector.d.ts +31 -0
  80. package/dist/utils/gitStateDetector.d.ts.map +1 -0
  81. package/dist/utils/gitStateDetector.js +67 -0
  82. package/dist/utils/gitStateDetector.js.map +1 -0
  83. package/dist/utils/logger.d.ts +13 -0
  84. package/dist/utils/logger.d.ts.map +1 -0
  85. package/dist/utils/logger.js +42 -0
  86. package/dist/utils/logger.js.map +1 -0
  87. package/dist/utils/reviewFormatter.d.ts +35 -0
  88. package/dist/utils/reviewFormatter.d.ts.map +1 -0
  89. package/dist/utils/reviewFormatter.js +198 -0
  90. package/dist/utils/reviewFormatter.js.map +1 -0
  91. package/dist/utils/reviewPromptBuilder.d.ts +35 -0
  92. package/dist/utils/reviewPromptBuilder.d.ts.map +1 -0
  93. package/dist/utils/reviewPromptBuilder.js +146 -0
  94. package/dist/utils/reviewPromptBuilder.js.map +1 -0
  95. package/dist/utils/reviewResponseParser.d.ts +20 -0
  96. package/dist/utils/reviewResponseParser.d.ts.map +1 -0
  97. package/dist/utils/reviewResponseParser.js +149 -0
  98. package/dist/utils/reviewResponseParser.js.map +1 -0
  99. package/dist/utils/reviewSessionCache.d.ts +81 -0
  100. package/dist/utils/reviewSessionCache.d.ts.map +1 -0
  101. package/dist/utils/reviewSessionCache.js +220 -0
  102. package/dist/utils/reviewSessionCache.js.map +1 -0
  103. package/dist/utils/reviewSessionManager.d.ts +52 -0
  104. package/dist/utils/reviewSessionManager.d.ts.map +1 -0
  105. package/dist/utils/reviewSessionManager.js +65 -0
  106. package/dist/utils/reviewSessionManager.js.map +1 -0
  107. package/dist/utils/sessionManager.d.ts +94 -0
  108. package/dist/utils/sessionManager.d.ts.map +1 -0
  109. package/dist/utils/sessionManager.js +374 -0
  110. package/dist/utils/sessionManager.js.map +1 -0
  111. package/dist/utils/sessionSchemas.d.ts +126 -0
  112. package/dist/utils/sessionSchemas.d.ts.map +1 -0
  113. package/dist/utils/sessionSchemas.js +2 -0
  114. package/dist/utils/sessionSchemas.js.map +1 -0
  115. package/dist/utils/timeoutManager.d.ts +2 -0
  116. package/dist/utils/timeoutManager.d.ts.map +1 -0
  117. package/dist/utils/timeoutManager.js +2 -0
  118. package/dist/utils/timeoutManager.js.map +1 -0
  119. package/package.json +71 -0
package/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ MIT License (Non-Commercial)
2
+
3
+ Copyright (c) 2025 jamubc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software for non-commercial purposes only, including without limitation
8
+ the rights to use, copy, modify, merge, publish, and distribute copies of the
9
+ Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ Commercial use of this software is prohibited without prior written permission
16
+ from the copyright holder. For commercial licensing, please contact the
17
+ copyright holder directly.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,230 @@
1
+
2
+ # Gemini MCP Tool v2.0.0 🚀
3
+
4
+ <div align="center">
5
+
6
+ [![GitHub Release](https://img.shields.io/github/v/release/maxanatsko/gemini-mcp-tool?logo=github&label=GitHub)](https://github.com/maxanatsko/gemini-mcp-tool/releases)
7
+ [![Version](https://img.shields.io/badge/version-2.0.0-blue.svg)](https://github.com/maxanatsko/gemini-mcp-tool)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
9
+ [![Open Source](https://img.shields.io/badge/Open%20Source-❤️-red.svg)](https://github.com/maxanatsko/gemini-mcp-tool)
10
+
11
+ </div>
12
+
13
+ > **🎉 v2.0.0 Release** - Major async refactor with improved performance, error handling, and code quality!
14
+
15
+ This is a Model Context Protocol (MCP) server that allows AI assistants to interact with the [Gemini CLI](https://github.com/google-gemini/gemini-cli). It enables the AI to leverage the power of Gemini's massive token window for large analysis, especially with large files and codebases using the `@` syntax for direction.
16
+
17
+ - Ask gemini natural questions, through claude or Brainstorm new ideas in a party of 3!
18
+
19
+ > 📚 **Original Documentation**: [View Full Documentation](https://jamubc.github.io/gemini-mcp-tool/) - Examples, FAQ, Troubleshooting, Best Practices
20
+
21
+ ## TLDR: [![Claude](https://img.shields.io/badge/Claude-D97757?logo=claude&logoColor=fff)](#) + [![Google Gemini](https://img.shields.io/badge/Google%20Gemini-886FBF?logo=googlegemini&logoColor=fff)](#)
22
+
23
+ **Goal**: Use Gemini's powerful analysis capabilities directly in Claude Code to save tokens and analyze large files.
24
+
25
+ ## 🎯 What's New in v2.0.0
26
+
27
+ This fork includes a **major async refactor** that addresses all code quality issues and modernizes the codebase:
28
+
29
+ ### ✅ **17 Improvements Implemented**
30
+ - **100% Async I/O**: All file operations converted from `fs` to `fs/promises` (no event loop blocking)
31
+ - **Robust Error Handling**: Fixed all empty catch blocks with proper logging and user feedback
32
+ - **Optimized Cleanup**: Session cleanup now runs at 80% threshold (not on every save)
33
+ - **Enhanced Security**: Improved session ID sanitization with 3-step regex validation
34
+ - **Graceful Degradation**: Session failures no longer break tool functionality
35
+ - **Consistent LRU**: All tools now use LRU eviction policy for better performance
36
+ - **Type Safety**: Maintained generic `SessionManager<T>` with full type safety
37
+ - **Better Logging**: Consistent log levels with tool-specific prefixes
38
+
39
+ ### 🔧 **Technical Highlights**
40
+ - Lazy initialization with race condition protection
41
+ - Helper methods to reduce code duplication
42
+ - Centralized configuration defaults
43
+ - `createdAt` field always guaranteed to be set
44
+ - Async error handling in tool integrations
45
+
46
+ ### 📊 **Test Results**
47
+ ✅ All 3 comprehensive integration tests pass
48
+ ✅ TypeScript compiles with zero errors
49
+ ✅ Gemini code review validates improvements
50
+
51
+ > **Breaking Change**: All SessionManager methods are now async. Update any custom code that directly uses SessionManager to use `await`.
52
+
53
+ ## Prerequisites
54
+
55
+ Before using this tool, ensure you have:
56
+
57
+ 1. **[Node.js](https://nodejs.org/)** (v16.0.0 or higher)
58
+ 2. **[Google Gemini CLI](https://github.com/google-gemini/gemini-cli)** installed and configured
59
+
60
+
61
+ ### Installation Options
62
+
63
+ #### Option 1: Install from GitHub Fork (Recommended for v2.0.0)
64
+
65
+ ```bash
66
+ claude mcp add gemini-cli -- npx -y maxanatsko/gemini-mcp-tool
67
+ ```
68
+
69
+ #### Option 2: Install Locally (For Development)
70
+
71
+ ```bash
72
+ # Clone the repository
73
+ git clone https://github.com/maxanatsko/gemini-mcp-tool.git
74
+ cd gemini-mcp-tool
75
+
76
+ # Build and link
77
+ npm install
78
+ npm run build
79
+ npm link
80
+
81
+ # Add to Claude
82
+ claude mcp add gemini-cli -- gemini-mcp
83
+ ```
84
+
85
+ #### Option 3: Original NPM Package (v1.1.4 - without async refactor)
86
+
87
+ ```bash
88
+ claude mcp add gemini-cli -- npx -y gemini-mcp-tool
89
+ ```
90
+
91
+ ### Verify Installation
92
+
93
+ Type `/mcp` inside Claude Code to verify the gemini-cli MCP is active.
94
+
95
+ ---
96
+
97
+ ### Alternative: Import from Claude Desktop
98
+
99
+ If you already have it configured in Claude Desktop:
100
+
101
+ 1. Add to your Claude Desktop config:
102
+ ```json
103
+ "gemini-cli": {
104
+ "command": "npx",
105
+ "args": ["-y", "maxanatsko/gemini-mcp-tool"]
106
+ }
107
+ ```
108
+
109
+ 2. Import to Claude Code:
110
+ ```bash
111
+ claude mcp add-from-claude-desktop
112
+ ```
113
+
114
+ ## Configuration
115
+
116
+ Register the MCP server with your MCP client:
117
+
118
+ ### For NPX Usage (Recommended)
119
+
120
+ Add this configuration to your Claude Desktop config file:
121
+
122
+ ```json
123
+ {
124
+ "mcpServers": {
125
+ "gemini-cli": {
126
+ "command": "npx",
127
+ "args": ["-y", "gemini-mcp-tool"]
128
+ }
129
+ }
130
+ }
131
+ ```
132
+
133
+ ### For Global Installation
134
+
135
+ If you installed globally, use this configuration instead:
136
+
137
+ ```json
138
+ {
139
+ "mcpServers": {
140
+ "gemini-cli": {
141
+ "command": "gemini-mcp"
142
+ }
143
+ }
144
+ }
145
+ ```
146
+
147
+ **Configuration File Locations:**
148
+
149
+ - **Claude Desktop**:
150
+ - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
151
+ - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
152
+ - **Linux**: `~/.config/claude/claude_desktop_config.json`
153
+
154
+ After updating the configuration, restart your terminal session.
155
+
156
+ ## Example Workflow
157
+
158
+ - **Natural language**: "use gemini to explain index.html", "understand the massive project using gemini", "ask gemini to search for latest news"
159
+ - **Claude Code**: Type `/gemini-cli` and commands will populate in Claude Code's interface.
160
+
161
+ ## Usage Examples
162
+
163
+ ### With File References (using @ syntax)
164
+
165
+ - `ask gemini to analyze @src/main.js and explain what it does`
166
+ - `use gemini to summarize @. the current directory`
167
+ - `analyze @package.json and tell me about dependencies`
168
+
169
+ ### General Questions (without files)
170
+
171
+ - `ask gemini to search for the latest tech news`
172
+ - `use gemini to explain div centering`
173
+ - `ask gemini about best practices for React development related to @file_im_confused_about`
174
+
175
+ ### Using Gemini CLI's Sandbox Mode (-s)
176
+
177
+ The sandbox mode allows you to safely test code changes, run scripts, or execute potentially risky operations in an isolated environment.
178
+
179
+ - `use gemini sandbox to create and run a Python script that processes data`
180
+ - `ask gemini to safely test @script.py and explain what it does`
181
+ - `use gemini sandbox to install numpy and create a data visualization`
182
+ - `test this code safely: Create a script that makes HTTP requests to an API`
183
+
184
+ ### Tools (for the AI)
185
+
186
+ These tools are designed to be used by the AI assistant.
187
+
188
+ - **`ask-gemini`**: Asks Google Gemini for its perspective. Can be used for general questions or complex analysis of files.
189
+ - **`prompt`** (required): The analysis request. Use the `@` syntax to include file or directory references (e.g., `@src/main.js explain this code`) or ask general questions (e.g., `Please use a web search to find the latest news stories`).
190
+ - **`model`** (optional): The Gemini model to use. Defaults to `gemini-2.5-pro`.
191
+ - **`sandbox`** (optional): Set to `true` to run in sandbox mode for safe code execution.
192
+ - **`sandbox-test`**: Safely executes code or commands in Gemini's sandbox environment. Always runs in sandbox mode.
193
+ - **`prompt`** (required): Code testing request (e.g., `Create and run a Python script that...` or `@script.py Run this safely`).
194
+ - **`model`** (optional): The Gemini model to use.
195
+ - **`Ping`**: A simple test tool that echoes back a message.
196
+ - **`Help`**: Shows the Gemini CLI help text.
197
+
198
+ ### Slash Commands (for the User)
199
+
200
+ You can use these commands directly in Claude Code's interface (compatibility with other clients has not been tested).
201
+
202
+ - **/analyze**: Analyzes files or directories using Gemini, or asks general questions.
203
+ - **`prompt`** (required): The analysis prompt. Use `@` syntax to include files (e.g., `/analyze prompt:@src/ summarize this directory`) or ask general questions (e.g., `/analyze prompt:Please use a web search to find the latest news stories`).
204
+ - **/sandbox**: Safely tests code or scripts in Gemini's sandbox environment.
205
+ - **`prompt`** (required): Code testing request (e.g., `/sandbox prompt:Create and run a Python script that processes CSV data` or `/sandbox prompt:@script.py Test this script safely`).
206
+ - **/help**: Displays the Gemini CLI help information.
207
+ - **/ping**: Tests the connection to the server.
208
+ - **`message`** (optional): A message to echo back.
209
+
210
+ ## About This Fork
211
+
212
+ This is a fork of [jamubc/gemini-mcp-tool](https://github.com/jamubc/gemini-mcp-tool) with significant improvements:
213
+
214
+ - **v2.0.0**: Complete async refactor addressing all 15 code review issues
215
+ - **Enhanced**: Better error handling, performance optimization, and code quality
216
+ - **Tested**: Comprehensive integration tests validate all improvements
217
+
218
+ ### Contributing to Original Project
219
+
220
+ The original project is maintained by [jamubc](https://github.com/jamubc). See their [Contributing Guidelines](https://github.com/jamubc/gemini-mcp-tool/blob/main/CONTRIBUTING.md) for details.
221
+
222
+ ### Contributing to This Fork
223
+
224
+ Issues and pull requests welcome at [maxanatsko/gemini-mcp-tool](https://github.com/maxanatsko/gemini-mcp-tool).
225
+
226
+ ## License
227
+
228
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
229
+
230
+ **Disclaimer:** This is an unofficial, third-party tool and is not affiliated with, endorsed, or sponsored by Google.
@@ -0,0 +1,153 @@
1
+ export declare const LOG_PREFIX = "[GMCPT]";
2
+ export declare const ERROR_MESSAGES: {
3
+ readonly QUOTA_EXCEEDED: "Quota exceeded for quota metric 'Gemini 2.5 Pro Requests'";
4
+ readonly QUOTA_EXCEEDED_SHORT: "⚠️ Gemini 2.5 Pro daily quota exceeded. Please retry with model: 'gemini-2.5-flash'";
5
+ readonly TOOL_NOT_FOUND: "not found in registry";
6
+ readonly NO_PROMPT_PROVIDED: "Please provide a prompt for analysis. Use @ syntax to include files (e.g., '@largefile.js explain what this does') or ask general questions";
7
+ };
8
+ export declare const STATUS_MESSAGES: {
9
+ readonly QUOTA_SWITCHING: "🚫 Gemini 2.5 Pro quota exceeded, switching to Flash model...";
10
+ readonly FLASH_RETRY: "⚡ Retrying with Gemini 2.5 Flash...";
11
+ readonly FLASH_SUCCESS: "✅ Flash model completed successfully";
12
+ readonly SANDBOX_EXECUTING: "🔒 Executing Gemini CLI command in sandbox mode...";
13
+ readonly GEMINI_RESPONSE: "Gemini response:";
14
+ readonly PROCESSING_START: "🔍 Starting analysis (may take 5-15 minutes for large codebases)";
15
+ readonly PROCESSING_CONTINUE: "⏳ Still processing... Gemini is working on your request";
16
+ readonly PROCESSING_COMPLETE: "✅ Analysis completed successfully";
17
+ };
18
+ export declare const MODELS: {
19
+ readonly PRO: "gemini-2.5-pro";
20
+ readonly FLASH: "gemini-2.5-flash";
21
+ };
22
+ export declare const PROTOCOL: {
23
+ readonly ROLES: {
24
+ readonly USER: "user";
25
+ readonly ASSISTANT: "assistant";
26
+ };
27
+ readonly CONTENT_TYPES: {
28
+ readonly TEXT: "text";
29
+ };
30
+ readonly STATUS: {
31
+ readonly SUCCESS: "success";
32
+ readonly ERROR: "error";
33
+ readonly FAILED: "failed";
34
+ readonly REPORT: "report";
35
+ };
36
+ readonly NOTIFICATIONS: {
37
+ readonly PROGRESS: "notifications/progress";
38
+ };
39
+ readonly KEEPALIVE_INTERVAL: 25000;
40
+ };
41
+ export declare const CLI: {
42
+ readonly COMMANDS: {
43
+ readonly GEMINI: "gemini";
44
+ readonly ECHO: "echo";
45
+ };
46
+ readonly FLAGS: {
47
+ readonly MODEL: "-m";
48
+ readonly SANDBOX: "-s";
49
+ readonly PROMPT: "-p";
50
+ readonly HELP: "-help";
51
+ };
52
+ readonly DEFAULTS: {
53
+ readonly MODEL: "default";
54
+ readonly BOOLEAN_TRUE: "true";
55
+ readonly BOOLEAN_FALSE: "false";
56
+ };
57
+ };
58
+ export declare const SESSION: {
59
+ readonly BASE_DIR: ".gemini-mcp/sessions";
60
+ readonly DEFAULT_TTL: number;
61
+ readonly DEFAULT_MAX_SESSIONS: 20;
62
+ readonly DEFAULT_EVICTION_POLICY: "lru";
63
+ readonly TOOL_CONFIGS: {
64
+ readonly 'review-code': {
65
+ readonly TTL: number;
66
+ readonly MAX_SESSIONS: 20;
67
+ readonly EVICTION_POLICY: "fifo";
68
+ };
69
+ readonly 'ask-gemini': {
70
+ readonly TTL: number;
71
+ readonly MAX_SESSIONS: 50;
72
+ readonly EVICTION_POLICY: "lru";
73
+ };
74
+ readonly brainstorm: {
75
+ readonly TTL: number;
76
+ readonly MAX_SESSIONS: 30;
77
+ readonly EVICTION_POLICY: "lru";
78
+ };
79
+ };
80
+ };
81
+ export declare const REVIEW: {
82
+ readonly SESSION: {
83
+ readonly TTL: number;
84
+ readonly MAX_SESSIONS: 20;
85
+ readonly CACHE_DIR_NAME: "gemini-mcp-review-sessions";
86
+ };
87
+ readonly TYPES: {
88
+ readonly SECURITY: "security";
89
+ readonly PERFORMANCE: "performance";
90
+ readonly QUALITY: "quality";
91
+ readonly ARCHITECTURE: "architecture";
92
+ readonly GENERAL: "general";
93
+ };
94
+ readonly SEVERITY: {
95
+ readonly CRITICAL: "critical";
96
+ readonly IMPORTANT: "important";
97
+ readonly SUGGESTION: "suggestion";
98
+ readonly QUESTION: "question";
99
+ };
100
+ readonly STATUS: {
101
+ readonly PENDING: "pending";
102
+ readonly ACCEPTED: "accepted";
103
+ readonly REJECTED: "rejected";
104
+ readonly MODIFIED: "modified";
105
+ readonly DEFERRED: "deferred";
106
+ };
107
+ readonly SESSION_STATE: {
108
+ readonly ACTIVE: "active";
109
+ readonly PAUSED: "paused";
110
+ readonly COMPLETED: "completed";
111
+ };
112
+ readonly SCOPE: {
113
+ readonly FULL: "full";
114
+ readonly CHANGES_ONLY: "changes-only";
115
+ readonly FOCUSED: "focused";
116
+ };
117
+ readonly MAX_HISTORY_ROUNDS: 3;
118
+ readonly SEVERITY_EMOJI: {
119
+ readonly critical: "🔴";
120
+ readonly important: "🟠";
121
+ readonly suggestion: "🟡";
122
+ readonly question: "💬";
123
+ };
124
+ };
125
+ export interface ToolArguments {
126
+ prompt?: string;
127
+ model?: string;
128
+ sandbox?: boolean | string;
129
+ changeMode?: boolean | string;
130
+ chunkIndex?: number | string;
131
+ chunkCacheKey?: string;
132
+ message?: string;
133
+ session?: string;
134
+ includeHistory?: boolean;
135
+ methodology?: string;
136
+ domain?: string;
137
+ constraints?: string;
138
+ existingContext?: string;
139
+ ideaCount?: number;
140
+ includeAnalysis?: boolean;
141
+ files?: string[];
142
+ sessionId?: string;
143
+ forceNewSession?: boolean;
144
+ reviewType?: string;
145
+ severity?: string;
146
+ commentDecisions?: Array<{
147
+ commentId: string;
148
+ decision: string;
149
+ notes?: string;
150
+ }>;
151
+ [key: string]: string | boolean | number | undefined | string[] | Array<any>;
152
+ }
153
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,YAAY,CAAC;AAGpC,eAAO,MAAM,cAAc;;;;;CAKjB,CAAC;AAGX,eAAO,MAAM,eAAe;;;;;;;;;CAUlB,CAAC;AAGX,eAAO,MAAM,MAAM;;;CAGT,CAAC;AAGX,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;CAuBX,CAAC;AAIX,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;CAmBN,CAAC;AAGX,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;CAwBV,CAAC;AAGX,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDT,CAAC;AAIX,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,CAAC;IAGzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAG1B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,KAAK,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;IAEH,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;CAC9E"}
@@ -0,0 +1,150 @@
1
+ // Logging
2
+ export const LOG_PREFIX = "[GMCPT]";
3
+ // Error messages
4
+ export const ERROR_MESSAGES = {
5
+ QUOTA_EXCEEDED: "Quota exceeded for quota metric 'Gemini 2.5 Pro Requests'",
6
+ QUOTA_EXCEEDED_SHORT: "⚠️ Gemini 2.5 Pro daily quota exceeded. Please retry with model: 'gemini-2.5-flash'",
7
+ TOOL_NOT_FOUND: "not found in registry",
8
+ NO_PROMPT_PROVIDED: "Please provide a prompt for analysis. Use @ syntax to include files (e.g., '@largefile.js explain what this does') or ask general questions",
9
+ };
10
+ // Status messages
11
+ export const STATUS_MESSAGES = {
12
+ QUOTA_SWITCHING: "🚫 Gemini 2.5 Pro quota exceeded, switching to Flash model...",
13
+ FLASH_RETRY: "⚡ Retrying with Gemini 2.5 Flash...",
14
+ FLASH_SUCCESS: "✅ Flash model completed successfully",
15
+ SANDBOX_EXECUTING: "🔒 Executing Gemini CLI command in sandbox mode...",
16
+ GEMINI_RESPONSE: "Gemini response:",
17
+ // Timeout prevention messages
18
+ PROCESSING_START: "🔍 Starting analysis (may take 5-15 minutes for large codebases)",
19
+ PROCESSING_CONTINUE: "⏳ Still processing... Gemini is working on your request",
20
+ PROCESSING_COMPLETE: "✅ Analysis completed successfully",
21
+ };
22
+ // Models
23
+ export const MODELS = {
24
+ PRO: "gemini-2.5-pro",
25
+ FLASH: "gemini-2.5-flash",
26
+ };
27
+ // MCP Protocol Constants
28
+ export const PROTOCOL = {
29
+ // Message roles
30
+ ROLES: {
31
+ USER: "user",
32
+ ASSISTANT: "assistant",
33
+ },
34
+ // Content types
35
+ CONTENT_TYPES: {
36
+ TEXT: "text",
37
+ },
38
+ // Status codes
39
+ STATUS: {
40
+ SUCCESS: "success",
41
+ ERROR: "error",
42
+ FAILED: "failed",
43
+ REPORT: "report",
44
+ },
45
+ // Notification methods
46
+ NOTIFICATIONS: {
47
+ PROGRESS: "notifications/progress",
48
+ },
49
+ // Timeout prevention
50
+ KEEPALIVE_INTERVAL: 25000, // 25 seconds
51
+ };
52
+ // CLI Constants
53
+ export const CLI = {
54
+ // Command names
55
+ COMMANDS: {
56
+ GEMINI: "gemini",
57
+ ECHO: "echo",
58
+ },
59
+ // Command flags
60
+ FLAGS: {
61
+ MODEL: "-m",
62
+ SANDBOX: "-s",
63
+ PROMPT: "-p",
64
+ HELP: "-help",
65
+ },
66
+ // Default values
67
+ DEFAULTS: {
68
+ MODEL: "default", // Fallback model used when no specific model is provided
69
+ BOOLEAN_TRUE: "true",
70
+ BOOLEAN_FALSE: "false",
71
+ },
72
+ };
73
+ // Shared Session Management Constants
74
+ export const SESSION = {
75
+ BASE_DIR: '.gemini-mcp/sessions', // Base directory in user's home
76
+ DEFAULT_TTL: 24 * 60 * 60 * 1000, // 24 hours default
77
+ DEFAULT_MAX_SESSIONS: 20,
78
+ DEFAULT_EVICTION_POLICY: 'lru',
79
+ // Per-tool configurations
80
+ TOOL_CONFIGS: {
81
+ 'review-code': {
82
+ TTL: 24 * 60 * 60 * 1000, // 24 hours
83
+ MAX_SESSIONS: 20,
84
+ EVICTION_POLICY: 'fifo'
85
+ },
86
+ 'ask-gemini': {
87
+ TTL: 7 * 24 * 60 * 60 * 1000, // 7 days
88
+ MAX_SESSIONS: 50,
89
+ EVICTION_POLICY: 'lru'
90
+ },
91
+ 'brainstorm': {
92
+ TTL: 14 * 24 * 60 * 60 * 1000, // 14 days
93
+ MAX_SESSIONS: 30,
94
+ EVICTION_POLICY: 'lru'
95
+ }
96
+ }
97
+ };
98
+ // Code Review Constants
99
+ export const REVIEW = {
100
+ // Session configuration (deprecated - use SESSION constants)
101
+ SESSION: {
102
+ TTL: 60 * 60 * 1000, // 60 minutes (deprecated)
103
+ MAX_SESSIONS: 20,
104
+ CACHE_DIR_NAME: 'gemini-mcp-review-sessions', // deprecated
105
+ },
106
+ // Review types
107
+ TYPES: {
108
+ SECURITY: 'security',
109
+ PERFORMANCE: 'performance',
110
+ QUALITY: 'quality',
111
+ ARCHITECTURE: 'architecture',
112
+ GENERAL: 'general',
113
+ },
114
+ // Comment severity levels
115
+ SEVERITY: {
116
+ CRITICAL: 'critical',
117
+ IMPORTANT: 'important',
118
+ SUGGESTION: 'suggestion',
119
+ QUESTION: 'question',
120
+ },
121
+ // Comment status
122
+ STATUS: {
123
+ PENDING: 'pending',
124
+ ACCEPTED: 'accepted',
125
+ REJECTED: 'rejected',
126
+ MODIFIED: 'modified',
127
+ DEFERRED: 'deferred',
128
+ },
129
+ // Session state
130
+ SESSION_STATE: {
131
+ ACTIVE: 'active',
132
+ PAUSED: 'paused',
133
+ COMPLETED: 'completed',
134
+ },
135
+ // Review scope
136
+ SCOPE: {
137
+ FULL: 'full',
138
+ CHANGES_ONLY: 'changes-only',
139
+ FOCUSED: 'focused',
140
+ },
141
+ // Formatting
142
+ MAX_HISTORY_ROUNDS: 3, // How many previous rounds to include in context
143
+ SEVERITY_EMOJI: {
144
+ critical: '🔴',
145
+ important: '🟠',
146
+ suggestion: '🟡',
147
+ question: '💬',
148
+ },
149
+ };
150
+ //# sourceMappingURL=constants.js.map
@@ -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Y,EAAE,EAAE;QAChB,cAAc,EAAE,4BAA4B,EAAE,aAAa;KAC5D;IACD,eAAe;IACf,KAAK,EAAE;QACL,QAAQ,EAAE,UAAU;QACpB,WAAW,EAAE,aAAa;QAC1B,OAAO,EAAE,SAAS;QAClB,YAAY,EAAE,cAAc;QAC5B,OAAO,EAAE,SAAS;KACnB;IACD,0BAA0B;IAC1B,QAAQ,EAAE;QACR,QAAQ,EAAE,UAAU;QACpB,SAAS,EAAE,WAAW;QACtB,UAAU,EAAE,YAAY;QACxB,QAAQ,EAAE,UAAU;KACrB;IACD,iBAAiB;IACjB,MAAM,EAAE;QACN,OAAO,EAAE,SAAS;QAClB,QAAQ,EAAE,UAAU;QACpB,QAAQ,EAAE,UAAU;QACpB,QAAQ,EAAE,UAAU;QACpB,QAAQ,EAAE,UAAU;KACrB;IACD,gBAAgB;IAChB,aAAa,EAAE;QACb,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,WAAW;KACvB;IACD,eAAe;IACf,KAAK,EAAE;QACL,IAAI,EAAE,MAAM;QACZ,YAAY,EAAE,cAAc;QAC5B,OAAO,EAAE,SAAS;KACnB;IACD,aAAa;IACb,kBAAkB,EAAE,CAAC,EAAE,iDAAiD;IACxE,cAAc,EAAE;QACd,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,IAAI;QACf,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,IAAI;KACN;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}