diff --git a/README.ja.md b/README.ja.md index 9e56555..bd64ddf 100644 --- a/README.ja.md +++ b/README.ja.md @@ -643,7 +643,7 @@ Oh My OpenCode は以下の場所からフックを読み込んで実行しま | プラットフォーム | ユーザー設定パス | |------------------|------------------| -| **Windows** | `%APPDATA%\opencode\oh-my-opencode.json` | +| **Windows** | `~/.config/opencode/oh-my-opencode.json` (優先) または `%APPDATA%\opencode\oh-my-opencode.json` (フォールバック) | | **macOS/Linux** | `~/.config/opencode/oh-my-opencode.json` | スキーマ自動補完がサポートされています: diff --git a/README.ko.md b/README.ko.md index 87a71a7..9fd732b 100644 --- a/README.ko.md +++ b/README.ko.md @@ -637,7 +637,7 @@ Oh My OpenCode는 다음 위치의 훅을 읽고 실행합니다: | 플랫폼 | 사용자 설정 경로 | |--------|------------------| -| **Windows** | `%APPDATA%\opencode\oh-my-opencode.json` | +| **Windows** | `~/.config/opencode/oh-my-opencode.json` (우선) 또는 `%APPDATA%\opencode\oh-my-opencode.json` (fallback) | | **macOS/Linux** | `~/.config/opencode/oh-my-opencode.json` | Schema 자동 완성이 지원됩니다: diff --git a/README.md b/README.md index 7ffb693..55b1111 100644 --- a/README.md +++ b/README.md @@ -703,7 +703,7 @@ Config file locations (priority order): | Platform | User Config Path | |----------|------------------| -| **Windows** | `%APPDATA%\opencode\oh-my-opencode.json` | +| **Windows** | `~/.config/opencode/oh-my-opencode.json` (preferred) or `%APPDATA%\opencode\oh-my-opencode.json` (fallback) | | **macOS/Linux** | `~/.config/opencode/oh-my-opencode.json` | Schema autocomplete supported: diff --git a/src/shared/config-path.ts b/src/shared/config-path.ts index 05606cb..7c12a4b 100644 --- a/src/shared/config-path.ts +++ b/src/shared/config-path.ts @@ -1,17 +1,34 @@ import * as path from "path" import * as os from "os" +import * as fs from "fs" /** * Returns the user-level config directory based on the OS. * - Linux/macOS: XDG_CONFIG_HOME or ~/.config - * - Windows: %APPDATA% + * - Windows: Checks ~/.config first (cross-platform), then %APPDATA% (fallback) + * + * On Windows, prioritizes ~/.config for cross-platform consistency. + * Falls back to %APPDATA% for backward compatibility with existing installations. */ export function getUserConfigDir(): string { if (process.platform === "win32") { - return process.env.APPDATA || path.join(os.homedir(), "AppData", "Roaming") + const crossPlatformDir = path.join(os.homedir(), ".config") + const crossPlatformConfigPath = path.join(crossPlatformDir, "opencode", "oh-my-opencode.json") + + const appdataDir = process.env.APPDATA || path.join(os.homedir(), "AppData", "Roaming") + const appdataConfigPath = path.join(appdataDir, "opencode", "oh-my-opencode.json") + + if (fs.existsSync(crossPlatformConfigPath)) { + return crossPlatformDir + } + + if (fs.existsSync(appdataConfigPath)) { + return appdataDir + } + + return crossPlatformDir } - // Linux, macOS, and other Unix-like systems: respect XDG_CONFIG_HOME return process.env.XDG_CONFIG_HOME || path.join(os.homedir(), ".config") }