gemini-helper-friend 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.
- package/LICENSE +25 -0
- package/README.md +216 -0
- package/dist/config/index.d.ts +6 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +6 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +22 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +193 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/templates/completion-inspector.mdx +648 -0
- package/dist/config/templates/helper-friend.mdx +763 -0
- package/dist/config/templates/manual-tester.mdx +950 -0
- package/dist/config/types.d.ts +90 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +6 -0
- package/dist/config/types.js.map +1 -0
- package/dist/config/yaml/subagents.yaml +449 -0
- package/dist/config/yaml/tools.yaml +0 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +2 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +253 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/agentic-task.tool.d.ts +2 -0
- package/dist/tools/agentic-task.tool.d.ts.map +1 -0
- package/dist/tools/agentic-task.tool.js +2 -0
- package/dist/tools/agentic-task.tool.js.map +1 -0
- package/dist/tools/extension-manager.tool.d.ts +2 -0
- package/dist/tools/extension-manager.tool.d.ts.map +1 -0
- package/dist/tools/extension-manager.tool.js +2 -0
- package/dist/tools/extension-manager.tool.js.map +1 -0
- package/dist/tools/gemini-task.tool.d.ts +2 -0
- package/dist/tools/gemini-task.tool.d.ts.map +1 -0
- package/dist/tools/gemini-task.tool.js +2 -0
- package/dist/tools/gemini-task.tool.js.map +1 -0
- package/dist/tools/index.d.ts +5 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +5 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/session-manager.tool.d.ts +2 -0
- package/dist/tools/session-manager.tool.d.ts.map +1 -0
- package/dist/tools/session-manager.tool.js +2 -0
- package/dist/tools/session-manager.tool.js.map +1 -0
- package/dist/tools/structured-query.tool.d.ts +2 -0
- package/dist/tools/structured-query.tool.d.ts.map +1 -0
- package/dist/tools/structured-query.tool.js +2 -0
- package/dist/tools/structured-query.tool.js.map +1 -0
- package/dist/tools/subagent.tool.d.ts +75 -0
- package/dist/tools/subagent.tool.d.ts.map +1 -0
- package/dist/tools/subagent.tool.js +604 -0
- package/dist/tools/subagent.tool.js.map +1 -0
- package/dist/utils/geminiExecutor.d.ts +2 -0
- package/dist/utils/geminiExecutor.d.ts.map +1 -0
- package/dist/utils/geminiExecutor.js +2 -0
- package/dist/utils/geminiExecutor.js.map +1 -0
- package/package.json +62 -0
- package/src/config/templates/completion-inspector.mdx +648 -0
- package/src/config/templates/helper-friend.mdx +763 -0
- package/src/config/templates/manual-tester.mdx +950 -0
- package/src/config/yaml/subagents.yaml +449 -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,216 @@
|
|
|
1
|
+
# Gemini - Helper Friend MCP
|
|
2
|
+
|
|
3
|
+
> Your autonomous AI helper that works on your codebase using Gemini CLI
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/gemini-helper-friend-mcp)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## What is This?
|
|
9
|
+
|
|
10
|
+
**Gemini Helper Friend** is a Model Context Protocol (MCP) server that gives AI assistants like Claude the ability to delegate complex analysis tasks to Google's Gemini CLI. Think of it as your AI assistant calling in a specialist consultant for deep codebase analysis.
|
|
11
|
+
|
|
12
|
+
### Why Use This?
|
|
13
|
+
|
|
14
|
+
- **🤖 Autonomous Execution**: YOLO mode enabled by default - Gemini works independently
|
|
15
|
+
- **📖 Deep Code Analysis**: Gemini reads and analyzes your entire codebase
|
|
16
|
+
- **🔍 Comprehensive Research**: Uses 100+ tool calls for thorough investigation
|
|
17
|
+
- **📝 Structured Documentation**: Creates organized reports in `helper-friend-docs/`
|
|
18
|
+
- **⚡ Auto-Model Selection**: Gemini CLI picks the best model (gemini-3-pro or gemini-3-flash)
|
|
19
|
+
|
|
20
|
+
## Prerequisites
|
|
21
|
+
|
|
22
|
+
1. **Node.js** 16.0.0 or higher
|
|
23
|
+
2. **Gemini CLI** installed and authenticated:
|
|
24
|
+
```bash
|
|
25
|
+
npm install -g @google/generative-ai-cli
|
|
26
|
+
gemini auth login
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install -g gemini-helper-friend-mcp
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Configuration
|
|
36
|
+
|
|
37
|
+
Add to your MCP client config (e.g., Claude Desktop):
|
|
38
|
+
|
|
39
|
+
### macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
40
|
+
### Windows: `%APPDATA%/Claude/claude_desktop_config.json`
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"mcpServers": {
|
|
45
|
+
"gemini-helper-friend": {
|
|
46
|
+
"command": "gemini-helper-friend"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Or use npx (no installation required):
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"mcpServers": {
|
|
57
|
+
"gemini-helper-friend": {
|
|
58
|
+
"command": "npx",
|
|
59
|
+
"args": ["-y", "gemini-helper-friend-mcp"]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Usage
|
|
66
|
+
|
|
67
|
+
The MCP exposes a single powerful tool: `gemini-task`
|
|
68
|
+
|
|
69
|
+
### Basic Usage
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
Ask Claude: "Use gemini-task to analyze the authentication flow in @src/auth/"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Structured Task Format (Recommended)
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
🎯 OBJECTIVE: Perform comprehensive security audit of API endpoints
|
|
79
|
+
|
|
80
|
+
📁 SCOPE: Analyze @src/routes/ @src/controllers/ @src/middleware/auth.ts
|
|
81
|
+
|
|
82
|
+
❓ QUESTIONS:
|
|
83
|
+
1. Are all endpoints properly authenticated?
|
|
84
|
+
2. Is input validation sufficient?
|
|
85
|
+
3. Are there SQL injection or XSS vulnerabilities?
|
|
86
|
+
4. How is rate limiting implemented?
|
|
87
|
+
5. Are sensitive data properly encrypted?
|
|
88
|
+
|
|
89
|
+
📤 OUTPUT: Create detailed security report in helper-friend-docs/security-audit/
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Common Use Cases
|
|
93
|
+
|
|
94
|
+
**Code Analysis:**
|
|
95
|
+
```
|
|
96
|
+
"Analyze the data flow from API request to database in @src/"
|
|
97
|
+
"Map all dependencies and their versions in this project"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Architecture Review:**
|
|
101
|
+
```
|
|
102
|
+
"Document the overall architecture of this codebase"
|
|
103
|
+
"Identify patterns and anti-patterns in @src/services/"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Security Audit:**
|
|
107
|
+
```
|
|
108
|
+
"Find potential security vulnerabilities in @src/auth/"
|
|
109
|
+
"Review all API endpoints for proper authentication"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Documentation:**
|
|
113
|
+
```
|
|
114
|
+
"Generate API documentation from @src/routes/"
|
|
115
|
+
"Create onboarding guide for new developers"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## How It Works
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
You (via Claude) → gemini-task → Gemini CLI (YOLO mode) → Analysis Results
|
|
122
|
+
↓
|
|
123
|
+
Reads your codebase
|
|
124
|
+
Uses MCP tools
|
|
125
|
+
Creates documentation
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Default Execution:**
|
|
129
|
+
```bash
|
|
130
|
+
gemini --yolo -p "[your task + MANDATORY PROTOCOL suffix]"
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Features
|
|
134
|
+
|
|
135
|
+
### YOLO Mode (Default)
|
|
136
|
+
Gemini automatically approves all actions for autonomous execution. Safe for read-only analysis tasks.
|
|
137
|
+
|
|
138
|
+
### Mandatory Protocol Suffix
|
|
139
|
+
Every task includes instructions for Gemini to:
|
|
140
|
+
- Act as VP-level software architect
|
|
141
|
+
- Use 100+ tool calls for thoroughness
|
|
142
|
+
- Create structured docs in `helper-friend-docs/`
|
|
143
|
+
- Never edit code, only analyze and document
|
|
144
|
+
- Cite all sources and ground in evidence
|
|
145
|
+
|
|
146
|
+
### LLM-Friendly Error Handling
|
|
147
|
+
Errors are formatted with:
|
|
148
|
+
- **Error Code**: `QUOTA_EXCEEDED`, `CLI_NOT_FOUND`, `TIMEOUT`, etc.
|
|
149
|
+
- **Message**: Detailed error description
|
|
150
|
+
- **Suggestion**: Actionable fix
|
|
151
|
+
- **Retryable**: Whether you can retry
|
|
152
|
+
|
|
153
|
+
## Tool Parameters
|
|
154
|
+
|
|
155
|
+
| Parameter | Type | Required | Default | Description |
|
|
156
|
+
|-----------|------|----------|---------|-------------|
|
|
157
|
+
| `task` | string | ✅ Yes | - | Your task for Gemini (min 10 chars) |
|
|
158
|
+
| `model` | string | No | auto | Override model: `gemini-3-pro` or `gemini-3-flash` |
|
|
159
|
+
| `sandbox` | boolean | No | false | Run in sandbox mode |
|
|
160
|
+
| `include_suffix` | boolean | No | true | Append MANDATORY PROTOCOL |
|
|
161
|
+
|
|
162
|
+
## Configuration (YAML)
|
|
163
|
+
|
|
164
|
+
Tool configuration is defined in `src/config/yaml/tools.yaml`:
|
|
165
|
+
|
|
166
|
+
```yaml
|
|
167
|
+
settings:
|
|
168
|
+
defaults:
|
|
169
|
+
model: "" # Auto-select
|
|
170
|
+
yolo_mode: true
|
|
171
|
+
append_suffix: true
|
|
172
|
+
|
|
173
|
+
prompt_suffix:
|
|
174
|
+
enabled: true
|
|
175
|
+
content: |
|
|
176
|
+
[MANDATORY PROTOCOL instructions...]
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Development
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
# Clone and install
|
|
183
|
+
git clone https://github.com/jamubc/gemini-mcp-tool.git
|
|
184
|
+
cd gemini-mcp-tool
|
|
185
|
+
npm install
|
|
186
|
+
|
|
187
|
+
# Build
|
|
188
|
+
npm run build
|
|
189
|
+
|
|
190
|
+
# Test with MCP Inspector
|
|
191
|
+
npx @modelcontextprotocol/inspector --cli node dist/index.js --method tools/list
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Troubleshooting
|
|
195
|
+
|
|
196
|
+
**"Gemini CLI not found"**
|
|
197
|
+
```bash
|
|
198
|
+
npm install -g @google/generative-ai-cli
|
|
199
|
+
which gemini # Should show path
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**"API quota exceeded"**
|
|
203
|
+
- Wait for quota reset (daily limit)
|
|
204
|
+
- Gemini CLI has generous free tier limits
|
|
205
|
+
|
|
206
|
+
**"Request timed out"**
|
|
207
|
+
- Try simpler task or reduce file scope
|
|
208
|
+
- Set `include_suffix: false` for quick queries
|
|
209
|
+
|
|
210
|
+
## License
|
|
211
|
+
|
|
212
|
+
MIT © jamubc
|
|
213
|
+
|
|
214
|
+
## Contributing
|
|
215
|
+
|
|
216
|
+
Issues and PRs welcome at [github.com/jamubc/gemini-mcp-tool](https://github.com/jamubc/gemini-mcp-tool)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* YAML Configuration Loader
|
|
3
|
+
* Loads tools.yaml and generates MCP-compatible tool definitions
|
|
4
|
+
*/
|
|
5
|
+
import type { YamlConfig, McpTool } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Load and parse subagents.yaml
|
|
8
|
+
*/
|
|
9
|
+
export declare function loadYamlConfig(): YamlConfig;
|
|
10
|
+
/**
|
|
11
|
+
* Get metadata from YAML config
|
|
12
|
+
*/
|
|
13
|
+
export declare function getMetadata(): {
|
|
14
|
+
name: string;
|
|
15
|
+
displayName: string;
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Generate MCP tools list from YAML
|
|
20
|
+
*/
|
|
21
|
+
export declare function generateMcpTools(): McpTool[];
|
|
22
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,KAAK,EACV,UAAU,EAIV,OAAO,EACR,MAAM,YAAY,CAAC;AAkIpB;;GAEG;AACH,wBAAgB,cAAc,IAAI,UAAU,CAO3C;AAED;;GAEG;AACH,wBAAgB,WAAW;;;;EAE1B;AAwBD;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,EAAE,CAG5C"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* YAML Configuration Loader
|
|
3
|
+
* Loads tools.yaml and generates MCP-compatible tool definitions
|
|
4
|
+
*/
|
|
5
|
+
import { readFileSync } from 'fs';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
import { dirname, join } from 'path';
|
|
8
|
+
import { parse as parseYaml } from 'yaml';
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
11
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
+
const __dirname = dirname(__filename);
|
|
13
|
+
// Cached config
|
|
14
|
+
let cachedConfig = null;
|
|
15
|
+
/**
|
|
16
|
+
* Apply string validation rules to Zod schema
|
|
17
|
+
*/
|
|
18
|
+
function applyStringValidation(schema, validation) {
|
|
19
|
+
if (!validation)
|
|
20
|
+
return schema;
|
|
21
|
+
let result = schema;
|
|
22
|
+
if (validation.minLength !== undefined)
|
|
23
|
+
result = result.min(validation.minLength);
|
|
24
|
+
if (validation.maxLength !== undefined)
|
|
25
|
+
result = result.max(validation.maxLength);
|
|
26
|
+
if (validation.pattern)
|
|
27
|
+
result = result.regex(new RegExp(validation.pattern));
|
|
28
|
+
if (validation.format === 'uri')
|
|
29
|
+
result = result.url();
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Apply number validation rules to Zod schema
|
|
34
|
+
*/
|
|
35
|
+
function applyNumberValidation(schema, validation) {
|
|
36
|
+
if (!validation)
|
|
37
|
+
return schema;
|
|
38
|
+
let result = schema;
|
|
39
|
+
if (validation.min !== undefined)
|
|
40
|
+
result = result.min(validation.min);
|
|
41
|
+
if (validation.max !== undefined)
|
|
42
|
+
result = result.max(validation.max);
|
|
43
|
+
if (validation.int)
|
|
44
|
+
result = result.int();
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Convert YAML parameter to Zod schema
|
|
49
|
+
*/
|
|
50
|
+
function yamlParamToZod(param) {
|
|
51
|
+
let schema;
|
|
52
|
+
switch (param.type) {
|
|
53
|
+
case 'string': {
|
|
54
|
+
let strSchema = z.string();
|
|
55
|
+
strSchema = applyStringValidation(strSchema, param.validation);
|
|
56
|
+
if (param.description)
|
|
57
|
+
strSchema = strSchema.describe(param.description);
|
|
58
|
+
schema = strSchema;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
case 'number': {
|
|
62
|
+
let numSchema = z.number();
|
|
63
|
+
numSchema = applyNumberValidation(numSchema, param.validation);
|
|
64
|
+
if (param.description)
|
|
65
|
+
numSchema = numSchema.describe(param.description);
|
|
66
|
+
schema = numSchema;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
case 'integer': {
|
|
70
|
+
let intSchema = z.number().int();
|
|
71
|
+
intSchema = applyNumberValidation(intSchema, param.validation);
|
|
72
|
+
if (param.description)
|
|
73
|
+
intSchema = intSchema.describe(param.description);
|
|
74
|
+
schema = intSchema;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
case 'boolean': {
|
|
78
|
+
let boolSchema = z.boolean();
|
|
79
|
+
if (param.description)
|
|
80
|
+
boolSchema = boolSchema.describe(param.description);
|
|
81
|
+
schema = boolSchema;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
case 'array': {
|
|
85
|
+
if (!param.items)
|
|
86
|
+
throw new Error('Array parameter must have items definition');
|
|
87
|
+
const itemSchema = yamlParamToZod(param.items);
|
|
88
|
+
let arrSchema = z.array(itemSchema);
|
|
89
|
+
if (param.validation?.minItems)
|
|
90
|
+
arrSchema = arrSchema.min(param.validation.minItems);
|
|
91
|
+
if (param.validation?.maxItems)
|
|
92
|
+
arrSchema = arrSchema.max(param.validation.maxItems);
|
|
93
|
+
if (param.description)
|
|
94
|
+
arrSchema = arrSchema.describe(param.description);
|
|
95
|
+
schema = arrSchema;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
case 'object': {
|
|
99
|
+
if (!param.properties)
|
|
100
|
+
throw new Error('Object parameter must have properties');
|
|
101
|
+
const shape = {};
|
|
102
|
+
for (const [key, propDef] of Object.entries(param.properties)) {
|
|
103
|
+
let propSchema = yamlParamToZod(propDef);
|
|
104
|
+
if (propDef.required === false)
|
|
105
|
+
propSchema = propSchema.optional();
|
|
106
|
+
shape[key] = propSchema;
|
|
107
|
+
}
|
|
108
|
+
let objSchema = z.object(shape);
|
|
109
|
+
if (param.description)
|
|
110
|
+
objSchema = objSchema.describe(param.description);
|
|
111
|
+
schema = objSchema;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
default:
|
|
115
|
+
throw new Error(`Unknown parameter type: ${param.type}`);
|
|
116
|
+
}
|
|
117
|
+
if (param.required === false && param.default !== undefined) {
|
|
118
|
+
schema = schema.default(param.default);
|
|
119
|
+
}
|
|
120
|
+
else if (param.required === false) {
|
|
121
|
+
schema = schema.optional();
|
|
122
|
+
}
|
|
123
|
+
return schema;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Convert YAML parameters to Zod object schema
|
|
127
|
+
*/
|
|
128
|
+
function yamlParamsToZodSchema(params) {
|
|
129
|
+
const shape = {};
|
|
130
|
+
for (const [key, param] of Object.entries(params)) {
|
|
131
|
+
shape[key] = yamlParamToZod(param);
|
|
132
|
+
}
|
|
133
|
+
return z.object(shape);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Convert Zod schema to MCP inputSchema
|
|
137
|
+
*/
|
|
138
|
+
function zodToMcpInputSchema(schema) {
|
|
139
|
+
const jsonSchema = zodToJsonSchema(schema, { $refStrategy: 'none' });
|
|
140
|
+
if (typeof jsonSchema === 'object' && jsonSchema !== null) {
|
|
141
|
+
const obj = jsonSchema;
|
|
142
|
+
return {
|
|
143
|
+
type: 'object',
|
|
144
|
+
properties: obj.properties || {},
|
|
145
|
+
required: obj.required,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
return { type: 'object', properties: {} };
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Load and parse subagents.yaml
|
|
152
|
+
*/
|
|
153
|
+
export function loadYamlConfig() {
|
|
154
|
+
if (cachedConfig)
|
|
155
|
+
return cachedConfig;
|
|
156
|
+
const yamlPath = join(__dirname, 'yaml', 'subagents.yaml');
|
|
157
|
+
const yamlContent = readFileSync(yamlPath, 'utf8');
|
|
158
|
+
cachedConfig = parseYaml(yamlContent);
|
|
159
|
+
return cachedConfig;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Get metadata from YAML config
|
|
163
|
+
*/
|
|
164
|
+
export function getMetadata() {
|
|
165
|
+
return loadYamlConfig().metadata;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Convert a YAML tool config to MCP Tool
|
|
169
|
+
*/
|
|
170
|
+
function yamlToolToMcpTool(toolConfig) {
|
|
171
|
+
if (!toolConfig.parameters) {
|
|
172
|
+
return {
|
|
173
|
+
name: toolConfig.name,
|
|
174
|
+
description: toolConfig.description.trim(),
|
|
175
|
+
inputSchema: { type: 'object', properties: {} },
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
const zodSchema = yamlParamsToZodSchema(toolConfig.parameters);
|
|
179
|
+
const inputSchema = zodToMcpInputSchema(zodSchema);
|
|
180
|
+
return {
|
|
181
|
+
name: toolConfig.name,
|
|
182
|
+
description: toolConfig.description.trim(),
|
|
183
|
+
inputSchema,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Generate MCP tools list from YAML
|
|
188
|
+
*/
|
|
189
|
+
export function generateMcpTools() {
|
|
190
|
+
const config = loadYamlConfig();
|
|
191
|
+
return config.tools.map(yamlToolToMcpTool);
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAUrD,MAAM,UAAU,G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