From 074127bf4c918feb708c21ed435061b3f990d077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=86=9D=E7=9B=96=E4=B8=AD=E7=AE=AD=E5=8D=AB=E5=85=B5?= <148407233+skyrim-dev@users.noreply.github.com> Date: Fri, 1 May 2026 23:36:31 +0800 Subject: [PATCH 1/2] Respect custom command mode when starting OpenCode Use a stricter runtime check before entering custom command mode. ServerManager.start() now derives a local useCustomCommand flag from: - settings.useCustomCommand - a non-empty trimmed customCommand That flag is then used consistently for startup branching, startup mode logging, and ENOENT error reporting. This makes startup behavior more predictable when OpenCode is launched through a wrapper command instead of a direct executable path, including Windows Obsidian setups that start WSL-hosted OpenCode via wsl.exe. --- src/server/ServerManager.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/server/ServerManager.ts b/src/server/ServerManager.ts index aac8c92..ce5cb55 100644 --- a/src/server/ServerManager.ts +++ b/src/server/ServerManager.ts @@ -64,8 +64,11 @@ export class ServerManager extends EventEmitter { // Determine execution mode and resolve executable path let executablePath: string; let spawnOptions: SpawnOptions; - - if (this.settings.useCustomCommand) { + const useCustomCommand = + Boolean(this.settings.useCustomCommand) && + this.settings.customCommand.trim().length > 0; + + if (useCustomCommand) { // Custom command mode: use custom command directly with shell executablePath = this.settings.customCommand; spawnOptions = { @@ -101,7 +104,7 @@ export class ServerManager extends EventEmitter { } console.log("[OpenCode] Starting server:", { - mode: this.settings.useCustomCommand ? "custom" : "path", + mode: useCustomCommand ? "custom" : "path", command: executablePath, port: this.settings.port, hostname: this.settings.hostname, @@ -109,7 +112,7 @@ export class ServerManager extends EventEmitter { projectDirectory: this.projectDirectory, }); - if (this.settings.useCustomCommand) { + if (useCustomCommand) { // Custom command mode: spawn with shell, no args appended this.process = this.processImpl.start( executablePath, @@ -163,8 +166,8 @@ export class ServerManager extends EventEmitter { this.process = null; if (err.code === "ENOENT") { - const command = this.settings.useCustomCommand - ? this.settings.customCommand + const command = useCustomCommand + ? this.settings.customCommand : this.settings.opencodePath; this.setError( `Executable not found: '${command}'` From e9b6ec042e4f38c45316ab4fb5ab484d134feb6c Mon Sep 17 00:00:00 2001 From: shf <2755991965@qq.com> Date: Sun, 10 May 2026 08:40:25 +0800 Subject: [PATCH 2/2] =?UTF-8?q?docs:=20=E6=B7=BB=E5=8A=A0=E5=B7=B2?= =?UTF-8?q?=E7=9F=A5=E9=97=AE=E9=A2=98=E8=AD=A6=E5=91=8A=20-=20=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E8=BF=90=E8=A1=8C=E4=BC=9A=E5=AF=BC=E8=87=B4=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E6=8D=9F=E5=9D=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 7b0c8a8..dd1f722 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,14 @@ # OpenCode plugin for Obsidian +> ⚠️ **已知问题(重要)** +> +> 在 Windows 上使用 WSL 时,**同时在 Obsidian 中启动 OpenCode 和在 WSL 中启动 OpenCode 会导致 OpenCode 数据库损坏**。 +> +> **请避免同时运行两个实例!** 如果需要在 WSL 中使用 OpenCode,请先关闭 Obsidian 中的 OpenCode 面板,反之亦然。 +> +> 本插件已解决 WSL 上的 OpenCode 作为插件嵌入到 Windows 上的 Obsidian 中无法正常使用的问题,但上述并发问题仍需注意。 + +--- Give your notes AI capability by embedding Opencode [OpenCode](https://opencode.ai) AI assistant directly in Obsidian: