opencode-idea 0.0.2 → 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 +5 -0
- package/package.json +1 -1
- package/src/ide-guidance.js +13 -8
- package/src/idea-mcp.js +8 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
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
|
+
|
|
3
8
|
## 0.0.2
|
|
4
9
|
|
|
5
10
|
- **路由引导重写**:system prompt 明确写出项目绝对路径,并要求路径内的检索 / 读文件 / 目录浏览 / 改文件 / 新建文件 / 校验都使用 `idea_*` 工具,逐条点名禁止对应的原生工具(`grep` / `glob` / `read` / `edit` / `write` / `ls` / `find`)。
|
package/package.json
CHANGED
package/src/ide-guidance.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
// IDEA MCP routing guidance injected into the model's system prompt.
|
|
2
2
|
//
|
|
3
3
|
// Two rules for this file:
|
|
4
|
-
// 1. State requirements only. No explanations, no asides
|
|
5
|
-
// what NOT to do — every extra sentence weakens the instruction.
|
|
4
|
+
// 1. State requirements only. No explanations, no asides.
|
|
6
5
|
// 2. The boundary is the project path. Inside it -> idea_* tools.
|
|
7
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.
|
|
8
12
|
|
|
9
13
|
/** Build the guidance text for one project path. */
|
|
10
14
|
export function buildIdeGuidance(projectPath) {
|
|
@@ -15,15 +19,16 @@ export function buildIdeGuidance(projectPath) {
|
|
|
15
19
|
``,
|
|
16
20
|
`## 强制要求`,
|
|
17
21
|
`- 路径在 \`${projectPath}\` 内的所有操作,必须使用 \`idea_*\` 工具。`,
|
|
22
|
+
`- 直接调用工具,不要用 \`execute\` 包裹。`,
|
|
18
23
|
`- 检索内容用 \`idea_search_text\` / \`idea_search_regex\`,不要用 \`grep\`。`,
|
|
19
24
|
`- 查找文件名用 \`idea_search_file\`,不要用 \`glob\`。`,
|
|
20
|
-
`- 读文件用 \`idea_read_file
|
|
21
|
-
`- 浏览目录用 \`idea_list_directory_tree
|
|
22
|
-
`- 修改已有文件用 \`idea_apply_patch
|
|
23
|
-
`- 新建文件用 \`idea_create_new_file
|
|
24
|
-
`- 改完代码用 \`idea_lint_files\`
|
|
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\` 校验。`,
|
|
25
30
|
`- 看 git 状态用 \`idea_git_status\`。`,
|
|
26
|
-
`-
|
|
31
|
+
`- 工具参数按该工具的 schema 传。`,
|
|
27
32
|
``,
|
|
28
33
|
`## 范围`,
|
|
29
34
|
`- \`${projectPath}\` 内:只用 \`idea_*\` 工具。`,
|
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({
|