opencode-idea 0.0.6 → 0.0.7

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.0.7
4
+
5
+ - **修复:0.0.6 因 skill schema 校验失败导致整个插件被禁用**。`idea-run-config` skill 的定义用了 `location` 字段,而 `Skill.Info` 要求的是 `path` (AbsolutePath);`ctx.skill.transform` 因此抛 `SchemaError(Missing key at ["path"])`。OpenCode 的策略是**任何 transform 失败都会禁用整个插件**,所以 0.0.6 里 `/open-in-idea` 命令和 IDE MCP 注册都没能生效 (日志:`disabled plugin after transform failure plugin.id=opencode-idea state=skill`)。现在改用 `path`,并在测试里钉死字段集合 (`content` / `description` / `id` / `name` / `path`)。
6
+ - **skill 注册改为尽力而为**:`runConfigSkill()` 或 `ctx.skill.transform` 抛错时只放弃 skill,不再中断 `setup` —— 可选知识不该拖垮命令与 MCP 接线。
7
+ - **新增回归测试**:skill transform 被拒时 `/open-in-idea` 仍然注册。
8
+
3
9
  ## 0.0.6
4
10
 
5
11
  - **修复:工具报错不再注销 IDE MCP**。旧实现在 `tool.execute.after` 里把**任何** `idea_*` 报错都当成「端点已死」并注销整个注册 —— 业务错误 (例如路径不存在返回 `File not found`) 和一次传输抖动都会触发;注销后紧跟的 `ctx.mcp.reload()` 还会掐断同一批正在执行的其他调用。现在插件**不注册**该钩子:连接状态以 OpenCode 自己维护的工具快照为准 (`context` 钩子收到的 `event.tools` 里有没有 `idea_*`),只有 `/open-in-idea` 会 (重新) 连接。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-idea",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
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",
@@ -41,17 +41,21 @@ export function readRunConfigSkillContent() {
41
41
  /**
42
42
  * Build the skill definition registered through `ctx.skill.transform`.
43
43
  *
44
- * `location` points at the shipped `.md` — the real skill document — so any
45
- * path-shaped validation is satisfied without inventing a virtual filename.
44
+ * The schema (`Skill.Info` in `@opencode/schema/skill`) requires the field to be
45
+ * named `path` and to hold an absolute path. Point it at the shipped `.md` — the
46
+ * real skill document — rather than inventing a virtual filename.
46
47
  *
47
- * @returns {{ id: string, name: string, description: string, location: string, content: string }}
48
+ * @returns {{ id: string, name: string, description: string, path: string, content: string }}
48
49
  */
49
50
  export function runConfigSkill() {
50
51
  return {
51
52
  id: RUN_CONFIG_SKILL_ID,
52
53
  name: 'idea-run-config',
53
54
  description: RUN_CONFIG_SKILL_DESCRIPTION,
54
- location: fileURLToPath(SKILL_FILE),
55
+ // Field names are schema-critical: `Skill.Info` requires `path`
56
+ // (AbsolutePath). A wrong key fails validation and takes the whole plugin
57
+ // down, not just the skill.
58
+ path: fileURLToPath(SKILL_FILE),
55
59
  content: readRunConfigSkillContent(),
56
60
  };
57
61
  }
package/src/idea-mcp.js CHANGED
@@ -81,7 +81,7 @@ export async function probePort(port, options = {}) {
81
81
  params: {
82
82
  protocolVersion: PROTOCOL_VERSION,
83
83
  capabilities: {},
84
- clientInfo: { name: 'opencode-idea', version: '0.0.6' },
84
+ clientInfo: { name: 'opencode-idea', version: '0.0.7' },
85
85
  },
86
86
  }),
87
87
  signal: controller.signal,
@@ -151,7 +151,7 @@ export async function callTool(port, projectPath, name, args = {}, options = {})
151
151
  params: {
152
152
  protocolVersion: PROTOCOL_VERSION,
153
153
  capabilities: {},
154
- clientInfo: { name: 'opencode-idea', version: '0.0.6' },
154
+ clientInfo: { name: 'opencode-idea', version: '0.0.7' },
155
155
  },
156
156
  });
157
157
  const response = await post({
package/src/plugin.js CHANGED
@@ -507,12 +507,20 @@ export default {
507
507
  // The run-configuration skill is static knowledge — where `.run/*.run.xml`
508
508
  // live, how to bootstrap a schema from a real example, and how to verify a
509
509
  // write. JetBrains projects only, and independent of `/open-in-idea`.
510
+ //
511
+ // Best effort on purpose: optional knowledge must never take the command and
512
+ // the MCP wiring down with it. A rejected definition fails the transform, and
513
+ // a transform failure disables this plugin entirely.
510
514
  if (isIdeaProject && typeof ctx.skill?.transform === 'function') {
511
- // Read the document before the transform: callbacks must stay synchronous.
512
- const runConfigSkillDefinition = runConfigSkill();
513
- skillRegistration = await ctx.skill.transform((editor) => {
514
- editor.add(runConfigSkillDefinition);
515
- });
515
+ try {
516
+ // Read the document before the transform: callbacks must stay synchronous.
517
+ const runConfigSkillDefinition = runConfigSkill();
518
+ skillRegistration = await ctx.skill.transform((editor) => {
519
+ editor.add(runConfigSkillDefinition);
520
+ });
521
+ } catch {
522
+ skillRegistration = undefined;
523
+ }
516
524
  }
517
525
 
518
526
  // `/open-in-idea`: manual, re-entrant trigger that also loads the IDE