opencode-idea 0.0.1 → 0.0.3
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/CHANGELOG.md +14 -0
- package/README.md +28 -18
- package/package.json +6 -4
- package/src/ide-guidance.js +43 -30
- package/src/idea-mcp.js +8 -2
- package/src/plugin.js +2 -6
- package/UPGRADING.md +0 -8
- package/skills/jetbrains-mcp-setup/SKILL.md +0 -36
- package/src/idea-tool-descriptions.js +0 -39
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.0.3
|
|
4
|
+
|
|
5
|
+
- **直接暴露 IDEA MCP 工具**:注册 MCP 服务器时设置 `codemode: false`,让 `idea_*` 工具直接出现在原生工具表(而非 Code Mode 的 `tools.idea.*`)。模型可以直接调用并看到完整参数 schema,不再需要先探索、也不会猜错参数名。
|
|
6
|
+
- **引导补充**:明确要求「直接调用工具,不要用 `execute` 包裹」。
|
|
7
|
+
|
|
8
|
+
## 0.0.2
|
|
9
|
+
|
|
10
|
+
- **路由引导重写**:system prompt 明确写出项目绝对路径,并要求路径内的检索 / 读文件 / 目录浏览 / 改文件 / 新建文件 / 校验都使用 `idea_*` 工具,逐条点名禁止对应的原生工具(`grep` / `glob` / `read` / `edit` / `write` / `ls` / `find`)。
|
|
11
|
+
- **不再修改任何工具描述**:移除对 IDEA MCP 工具描述的前缀改写(`src/idea-tool-descriptions.js` 已删除),插件不再调用 `ctx.tool.transform`;IDEA 工具与原生工具的描述均保持原样。
|
|
12
|
+
- **引导文案精简**:删除解释性内容和宽泛的「例外」条款,只保留要求与项目内 / 外边界。
|
|
13
|
+
- **移除无用文件**:删除 `skills/`(setup skill)与 `UPGRADING.md`。
|
|
14
|
+
- **安装文档更新**:README 的安装与配置示例改为 V2 的 `plugins` 对象写法。
|
|
15
|
+
|
|
3
16
|
## 0.0.1
|
|
4
17
|
|
|
5
18
|
首个版本(包名 `opencode-idea`,从 `opencode-jetbrains-mcp` 重命名而来)。
|
|
@@ -28,5 +41,6 @@
|
|
|
28
41
|
|
|
29
42
|
- **纯手动**:启动不探测、不连接 IDE MCP;IDE MCP 注册、环境重读、引导注入全部由 `/open-in-idea` 触发。
|
|
30
43
|
- **根级 `index.js` 转发入口**:使仓库可作为 V2 本地目录插件直接加载(`plugins: [{ "package": "<repo>" }]`)。
|
|
44
|
+
- **发布脚本** (`scripts/release.mjs`):`npm run release` 自动递增 patch、同步版本文件、跑测试并发布。
|
|
31
45
|
- **配置项**:`ports` / `injectEnv` / `injectGuidance` / `openInIde` / `launchCooldownMs` / `launchMaxAttempts` / `mcpProbeTimeoutMs` / `feedback`。
|
|
32
46
|
- 仅支持 **OpenCode V2**;非 JetBrains 项目完全不受影响。
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
OpenCode 插件,面向 JetBrains 项目(IntelliJ IDEA / PyCharm / WebStorm 等),做三件事:
|
|
4
4
|
|
|
5
5
|
1. **接入 IDE MCP** —— 用 `/open-in-idea` 把当前项目在 IntelliJ IDEA 中打开,并把这个 IDE 的 MCP 服务(60 个工具:检索、读、改、构建、重构、调试、数据库……)注册进 OpenCode。
|
|
6
|
-
2. **优先使用 IDE 工具** —— IDE 可用时,向模型注入"
|
|
6
|
+
2. **优先使用 IDE 工具** —— IDE 可用时,向模型注入"项目内操作优先使用 IDEA MCP"的系统提示引导 + 能力映射;IDE 不可用时回退原生工具(正常回退,无需声明)。
|
|
7
7
|
3. **注入 IDE 环境变量** —— 从 IDE 集成终端读取它实际运行的环境(版本化管理的 Node、goenv 的 Go、SDKMAN 的 Java、Maven……)注入每个 OpenCode shell。
|
|
8
8
|
|
|
9
9
|
非 JetBrains 项目完全不受影响。**全部手动**:插件启动不探测、不连接 IDE,只有跑 `/open-in-idea` 时才连接。
|
|
@@ -95,12 +95,26 @@ IDE MCP 可用时,插件通过两层轻量引导提高模型主动使用 IDEA MC
|
|
|
95
95
|
|
|
96
96
|
## 安装
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
推荐用 CLI 安装,它会写入全局配置 `~/.config/opencode/opencode.json`:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
opencode plugin add opencode-idea
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
等价的配置写法(V2 使用 `plugins` 数组):
|
|
105
|
+
|
|
106
|
+
```jsonc
|
|
99
107
|
{
|
|
100
|
-
"
|
|
108
|
+
"plugins": ["opencode-idea"],
|
|
101
109
|
}
|
|
102
110
|
```
|
|
103
111
|
|
|
112
|
+
安装后确认:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
opencode plugin list
|
|
116
|
+
```
|
|
117
|
+
|
|
104
118
|
> 仅支持 **OpenCode V2**。若你日常跑的是 1.x 的 `opencode-ai`,它用的是旧插件 API,本插件不会生效;真机验证请用 V2 运行时。
|
|
105
119
|
|
|
106
120
|
### 本地开发 / 真机验证
|
|
@@ -115,14 +129,6 @@ IDE MCP 可用时,插件通过两层轻量引导提高模型主动使用 IDEA MC
|
|
|
115
129
|
}
|
|
116
130
|
```
|
|
117
131
|
|
|
118
|
-
也可以沿用旧键 `plugin` 的元组写法:
|
|
119
|
-
|
|
120
|
-
```jsonc
|
|
121
|
-
{
|
|
122
|
-
"plugin": [["/Users/yutao/Projects/opencode-idea", {}]],
|
|
123
|
-
}
|
|
124
|
-
```
|
|
125
|
-
|
|
126
132
|
配置保存后 V2 会监听并自动重载(日志里能看到它开始 watch `index.js` / `src/*.js`),无需重启。改插件源码也会触发重载(此时需重跑 `/open-in-idea`)。
|
|
127
133
|
|
|
128
134
|
另一种零配置方式:在 `~/.config/opencode/plugins/` 放一个转发文件(自动发现,但不能传 options):
|
|
@@ -134,31 +140,35 @@ export { default } from "/Users/yutao/Projects/opencode-idea/src/index.js";
|
|
|
134
140
|
|
|
135
141
|
## 配置
|
|
136
142
|
|
|
143
|
+
用 CLI 安装只会写入包名。要传 options,把 `plugins` 数组里的字符串改成对象:
|
|
144
|
+
|
|
137
145
|
```jsonc
|
|
138
146
|
{
|
|
139
|
-
"
|
|
140
|
-
|
|
141
|
-
"opencode-idea",
|
|
142
|
-
{
|
|
147
|
+
"plugins": [
|
|
148
|
+
{
|
|
149
|
+
"package": "opencode-idea",
|
|
150
|
+
"options": {
|
|
143
151
|
"ports": [64342, 6420, 6421, 63342],
|
|
144
152
|
"injectEnv": true,
|
|
145
|
-
"injectGuidance": true, // IDE
|
|
153
|
+
"injectGuidance": true, // IDE 可用时向系统提示注入「优先使用 IDEA MCP」引导
|
|
146
154
|
"openInIde": "idea", // false 关闭;或任意 macOS 应用名(如 "IntelliJ IDEA")
|
|
147
155
|
"launchCooldownMs": 120000, // 启动保护冷却
|
|
148
156
|
"launchMaxAttempts": 5,
|
|
149
157
|
"mcpProbeTimeoutMs": 1000, // 单个 MCP 端口的短探测超时
|
|
150
158
|
"feedback": "message", // "message"(默认,会话通知,AI 只回"收到")| false(静默)
|
|
151
159
|
},
|
|
152
|
-
|
|
160
|
+
},
|
|
153
161
|
],
|
|
154
162
|
}
|
|
155
163
|
```
|
|
156
164
|
|
|
165
|
+
不传 options 时全部使用下表默认值。
|
|
166
|
+
|
|
157
167
|
| 选项 | 类型 | 默认 | 说明 |
|
|
158
168
|
| ------------------- | -------------------- | ---------------------------- | ---------------------------------------------------------------- |
|
|
159
169
|
| `ports` | `number[]` | `[64342, 6420, 6421, 63342]` | 依次探测的 IDE MCP 端口 |
|
|
160
170
|
| `injectEnv` | `boolean` | `true` | 是否注入 IDE 终端环境变量 |
|
|
161
|
-
| `injectGuidance` | `boolean` | `true` | IDE
|
|
171
|
+
| `injectGuidance` | `boolean` | `true` | IDE 可用时是否向系统提示注入「优先使用 IDEA MCP」引导 |
|
|
162
172
|
| `openInIde` | `boolean \| string` | `"idea"` | 拉起哪个 IDE;`false` 关闭,`"idea"` 映射到 IntelliJ IDEA |
|
|
163
173
|
| `launchCooldownMs` | `number` | `120000` | 启动保护冷却:冷却期内不重复 spawn |
|
|
164
174
|
| `launchMaxAttempts` | `number` | `5` | 单次会话内最多 spawn 次数,超出后停止重试 |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-idea",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "OpenCode plugin that connects to JetBrains IDE MCP servers and prefers IDE tools when the current project is open in the IDE",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -15,13 +15,15 @@
|
|
|
15
15
|
"src/ide-launcher.js",
|
|
16
16
|
"src/ide-guidance.js",
|
|
17
17
|
"src/idea-tool-descriptions.js",
|
|
18
|
-
"skills",
|
|
19
18
|
"README.md",
|
|
20
|
-
"CHANGELOG.md"
|
|
21
|
-
"UPGRADING.md"
|
|
19
|
+
"CHANGELOG.md"
|
|
22
20
|
],
|
|
23
21
|
"scripts": {
|
|
24
22
|
"test": "vitest run",
|
|
23
|
+
"release": "node scripts/release.mjs",
|
|
24
|
+
"release:dry": "node scripts/release.mjs --dry-run",
|
|
25
|
+
"release:bump": "node scripts/release.mjs --bump",
|
|
26
|
+
"release:check": "node scripts/release.mjs --check",
|
|
25
27
|
"prepublishOnly": "npm test"
|
|
26
28
|
},
|
|
27
29
|
"keywords": [
|
package/src/ide-guidance.js
CHANGED
|
@@ -1,31 +1,41 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
1
|
+
// IDEA MCP routing guidance injected into the model's system prompt.
|
|
2
|
+
//
|
|
3
|
+
// Two rules for this file:
|
|
4
|
+
// 1. State requirements only. No explanations, no asides.
|
|
5
|
+
// 2. The boundary is the project path. Inside it -> idea_* tools.
|
|
6
|
+
// Outside it -> whatever else is available.
|
|
7
|
+
//
|
|
8
|
+
// The IDE MCP server is registered with `codemode: false`, so every idea_*
|
|
9
|
+
// tool is exposed directly on the provider tool list with its full schema.
|
|
10
|
+
// Parameter names therefore come from the tool definitions; this text only
|
|
11
|
+
// states which tool to use for which operation.
|
|
3
12
|
|
|
4
|
-
/**
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
].join('\n');
|
|
13
|
+
/** Build the guidance text for one project path. */
|
|
14
|
+
export function buildIdeGuidance(projectPath) {
|
|
15
|
+
return [
|
|
16
|
+
`# 项目内操作必须使用 IDEA MCP 工具`,
|
|
17
|
+
``,
|
|
18
|
+
`项目路径: \`${projectPath}\``,
|
|
19
|
+
``,
|
|
20
|
+
`## 强制要求`,
|
|
21
|
+
`- 路径在 \`${projectPath}\` 内的所有操作,必须使用 \`idea_*\` 工具。`,
|
|
22
|
+
`- 直接调用工具,不要用 \`execute\` 包裹。`,
|
|
23
|
+
`- 检索内容用 \`idea_search_text\` / \`idea_search_regex\`,不要用 \`grep\`。`,
|
|
24
|
+
`- 查找文件名用 \`idea_search_file\`,不要用 \`glob\`。`,
|
|
25
|
+
`- 读文件用 \`idea_read_file\`,不要用 \`read\`。`,
|
|
26
|
+
`- 浏览目录用 \`idea_list_directory_tree\`,不要用 \`ls\` / \`find\`。`,
|
|
27
|
+
`- 修改已有文件用 \`idea_apply_patch\`,不要用 \`edit\` / \`patch\`。`,
|
|
28
|
+
`- 新建文件用 \`idea_create_new_file\`,不要用 \`write\`。`,
|
|
29
|
+
`- 改完代码用 \`idea_lint_files\` 或 \`idea_get_file_problems\` 校验。`,
|
|
30
|
+
`- 看 git 状态用 \`idea_git_status\`。`,
|
|
31
|
+
`- 工具参数按该工具的 schema 传。`,
|
|
32
|
+
``,
|
|
33
|
+
`## 范围`,
|
|
34
|
+
`- \`${projectPath}\` 内:只用 \`idea_*\` 工具。`,
|
|
35
|
+
`- \`${projectPath}\` 外:用其他可用工具。`,
|
|
36
|
+
`- \`idea_*\` 工具缺失、连接失败或超时:提示用户执行 \`/open-in-idea\`,不要重试。`,
|
|
37
|
+
].join('\n');
|
|
38
|
+
}
|
|
29
39
|
|
|
30
40
|
export const MCP_RECOVERY_GUIDANCE = [
|
|
31
41
|
'### IDEA MCP failure recovery',
|
|
@@ -37,11 +47,14 @@ export const MCP_RECOVERY_GUIDANCE = [
|
|
|
37
47
|
* model request, so it stays idempotent per request.
|
|
38
48
|
*
|
|
39
49
|
* @param {unknown} system
|
|
50
|
+
* @param {string} projectPath
|
|
40
51
|
*/
|
|
41
|
-
export function appendIdeGuidance(system) {
|
|
52
|
+
export function appendIdeGuidance(system, projectPath) {
|
|
42
53
|
if (!Array.isArray(system)) return;
|
|
43
|
-
if (
|
|
44
|
-
|
|
54
|
+
if (!projectPath) return;
|
|
55
|
+
const text = buildIdeGuidance(projectPath);
|
|
56
|
+
if (system.some((part) => part?.text === text)) return;
|
|
57
|
+
system.push({ type: 'text', text });
|
|
45
58
|
}
|
|
46
59
|
|
|
47
60
|
/** @param {unknown} system */
|
package/src/idea-mcp.js
CHANGED
|
@@ -37,6 +37,11 @@ const CALL_TIMEOUT_MS = 15000;
|
|
|
37
37
|
/**
|
|
38
38
|
* Build the OpenCode MCP server config for a given IDE port + project.
|
|
39
39
|
*
|
|
40
|
+
* `codemode: false` exposes the IDE tools directly on the provider tool list
|
|
41
|
+
* (as `idea_<tool>`) instead of routing them through Code Mode. Direct exposure
|
|
42
|
+
* passes each tool's full schema to the model, so parameter names are known
|
|
43
|
+
* without exploration. The rest of an MCP server's options are unchanged.
|
|
44
|
+
*
|
|
40
45
|
* @param {number} port
|
|
41
46
|
* @param {string} projectPath
|
|
42
47
|
*/
|
|
@@ -45,6 +50,7 @@ export function serverConfig(port, projectPath) {
|
|
|
45
50
|
type: 'remote',
|
|
46
51
|
url: `http://127.0.0.1:${port}${MCP_STREAM_PATH}`,
|
|
47
52
|
headers: { [PROJECT_HEADER]: projectPath },
|
|
53
|
+
codemode: false,
|
|
48
54
|
};
|
|
49
55
|
}
|
|
50
56
|
|
|
@@ -75,7 +81,7 @@ export async function probePort(port, options = {}) {
|
|
|
75
81
|
params: {
|
|
76
82
|
protocolVersion: PROTOCOL_VERSION,
|
|
77
83
|
capabilities: {},
|
|
78
|
-
clientInfo: { name: 'opencode-idea', version: '0.0.
|
|
84
|
+
clientInfo: { name: 'opencode-idea', version: '0.0.3' },
|
|
79
85
|
},
|
|
80
86
|
}),
|
|
81
87
|
signal: controller.signal,
|
|
@@ -145,7 +151,7 @@ export async function callTool(port, projectPath, name, args = {}, options = {})
|
|
|
145
151
|
params: {
|
|
146
152
|
protocolVersion: PROTOCOL_VERSION,
|
|
147
153
|
capabilities: {},
|
|
148
|
-
clientInfo: { name: 'opencode-idea', version: '0.0.
|
|
154
|
+
clientInfo: { name: 'opencode-idea', version: '0.0.3' },
|
|
149
155
|
},
|
|
150
156
|
});
|
|
151
157
|
const response = await post({
|
package/src/plugin.js
CHANGED
|
@@ -28,7 +28,6 @@ import {
|
|
|
28
28
|
import { readIdeTerminalEnv } from './ide-env.js';
|
|
29
29
|
import { currentProjectPath, hasIdeaDirectory } from './project.js';
|
|
30
30
|
import { applyEnv, mergeEnv } from './env.js';
|
|
31
|
-
import { applyIdeaToolGuidance } from './idea-tool-descriptions.js';
|
|
32
31
|
import {
|
|
33
32
|
createLaunchGuard,
|
|
34
33
|
openInIde,
|
|
@@ -187,13 +186,10 @@ export default {
|
|
|
187
186
|
};
|
|
188
187
|
|
|
189
188
|
const activateIde = async (port) => {
|
|
190
|
-
const toolRegistration = await ctx.tool.transform((editor) => {
|
|
191
|
-
applyIdeaToolGuidance(editor);
|
|
192
|
-
});
|
|
193
189
|
const mcpRegistration = await ctx.mcp.transform((editor) => {
|
|
194
190
|
editor.set(IDEA_SERVER_NAME, serverConfig(port, projectPath));
|
|
195
191
|
});
|
|
196
|
-
registrations = [
|
|
192
|
+
registrations = [mcpRegistration];
|
|
197
193
|
activePort = port;
|
|
198
194
|
if (typeof ctx.mcp.reload === 'function') await ctx.mcp.reload();
|
|
199
195
|
};
|
|
@@ -356,7 +352,7 @@ export default {
|
|
|
356
352
|
sessionRegistration = await ctx.session.hook('context', (event) => {
|
|
357
353
|
appendIdeRecoveryGuidance(event?.system);
|
|
358
354
|
if (activePort === undefined) return;
|
|
359
|
-
appendIdeGuidance(event?.system);
|
|
355
|
+
appendIdeGuidance(event?.system, projectPath);
|
|
360
356
|
});
|
|
361
357
|
}
|
|
362
358
|
|
package/UPGRADING.md
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: jetbrains-mcp-setup
|
|
3
|
-
description: 配置并验证 opencode-idea 插件:开启 JetBrains IDE 的 MCP 服务、找到端口、写入 opencode.json、验证 OpenCode 能连上并优先使用 IDE 工具。当用户要「接入 IDEA/JetBrains 的 MCP」「让 OpenCode 用 IDE 工具编辑/构建」或排查插件不生效时使用。
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# JetBrains MCP 接入配置
|
|
7
|
-
|
|
8
|
-
## 步骤
|
|
9
|
-
|
|
10
|
-
1. **确认 IDE 侧已开启 MCP 服务**
|
|
11
|
-
- 在 JetBrains IDE 中打开 Settings → Tools → MCP Server(或 AI Assistant 的 MCP 设置),启用。
|
|
12
|
-
- 让用户在 IDE 里打开要操作的项目。
|
|
13
|
-
|
|
14
|
-
2. **拿到 MCP 端口**
|
|
15
|
-
- IDE 通常显示形如 `http://127.0.0.1:<port>/sse` 的地址;记录 `<port>`。
|
|
16
|
-
- 若用户不确定,可用 `ports` 默认列表让插件自动探测。
|
|
17
|
-
|
|
18
|
-
3. **在项目 `opencode.json` 注册插件**
|
|
19
|
-
|
|
20
|
-
```jsonc
|
|
21
|
-
{
|
|
22
|
-
"plugin": [
|
|
23
|
-
["opencode-idea", { "ports": [<port>] }]
|
|
24
|
-
]
|
|
25
|
-
}
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
4. **验证**
|
|
29
|
-
- 重启 OpenCode(或触发插件重载)。
|
|
30
|
-
- 让用户确认:当前项目在 IDE 中打开时,OpenCode 是否优先用 IDE 工具;关闭项目后是否回退原生。
|
|
31
|
-
|
|
32
|
-
## 排查
|
|
33
|
-
|
|
34
|
-
- 插件不生效:确认 OpenCode 是 **V2**(需要 `ctx.tool` / `ctx.mcp`)。
|
|
35
|
-
- 一直探测失败:确认 IDE MCP 在跑、端口正确、当前项目确实在 IDE 中打开。
|
|
36
|
-
- 判断依据:IDE MCP 的 `tools/call get_project_modules` 在项目打开时成功、未打开时返回 `isError`。
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// Adds concise, direct-call guidance to IDEA MCP tool descriptions.
|
|
2
|
-
//
|
|
3
|
-
// This transform only targets tools whose effective IDs belong to the IDEA MCP
|
|
4
|
-
// namespace. Native OpenCode tools are intentionally left untouched.
|
|
5
|
-
|
|
6
|
-
const IDEA_TOOL_PREFIX = /^(idea_|idea\.)/;
|
|
7
|
-
const IDEA_EDITING_TOOLS = new Set(['idea_apply_patch', 'idea_create_new_file']);
|
|
8
|
-
|
|
9
|
-
export const IDEA_DIRECT_NOTE =
|
|
10
|
-
'【IDEA MCP】项目内操作请直接调用本工具;参数严格按当前工具 schema,不要猜测参数名。';
|
|
11
|
-
|
|
12
|
-
export const IDEA_EDIT_NOTE =
|
|
13
|
-
'【IDEA MCP 编辑】项目内文件编辑请直接调用本工具;已有文件使用 idea_apply_patch,新文件使用 idea_create_new_file;不要用 shell 写项目文件。';
|
|
14
|
-
|
|
15
|
-
const isIdeaTool = (id) => typeof id === 'string' && IDEA_TOOL_PREFIX.test(id);
|
|
16
|
-
|
|
17
|
-
const noteFor = (id) => IDEA_EDITING_TOOLS.has(id) ? IDEA_EDIT_NOTE : IDEA_DIRECT_NOTE;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Prepend direct-call guidance to IDEA MCP tool descriptions only.
|
|
21
|
-
* The transform is idempotent and ignores missing descriptions.
|
|
22
|
-
*
|
|
23
|
-
* @param {{
|
|
24
|
-
* list: () => ReadonlyArray<{ id?: string }>,
|
|
25
|
-
* update: (id: string, update: (tool: { description?: string }) => void) => void,
|
|
26
|
-
* }} editor
|
|
27
|
-
*/
|
|
28
|
-
export function applyIdeaToolGuidance(editor) {
|
|
29
|
-
for (const tool of editor.list()) {
|
|
30
|
-
const id = tool?.id;
|
|
31
|
-
if (!isIdeaTool(id)) continue;
|
|
32
|
-
editor.update(id, (draft) => {
|
|
33
|
-
if (typeof draft.description !== 'string') return;
|
|
34
|
-
const note = noteFor(id);
|
|
35
|
-
if (draft.description.startsWith(note)) return;
|
|
36
|
-
draft.description = note + draft.description;
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|