diff options
| author | Aiden Cline <[email protected]> | 2025-08-03 06:15:06 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-03 06:15:06 -0500 |
| commit | f90aa6278487c7469263b2c56a129540bb0325f7 (patch) | |
| tree | d08127160a2e9e48561ef5e475c14cd5310adace | |
| parent | 852191f6cb6b849e125a0003ea5338a34a3958de (diff) | |
| download | opencode-f90aa6278487c7469263b2c56a129540bb0325f7.tar.gz opencode-f90aa6278487c7469263b2c56a129540bb0325f7.zip | |
fix: expand tilde for file: references (#1553)
| -rw-r--r-- | packages/opencode/src/config/config.ts | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts index a7c2c962e..9f1c6bc3d 100644 --- a/packages/opencode/src/config/config.ts +++ b/packages/opencode/src/config/config.ts @@ -1,5 +1,6 @@ import { Log } from "../util/log" import path from "path" +import os from "os" import { z } from "zod" import { App } from "../app/app" import { Filesystem } from "../util/filesystem" @@ -403,7 +404,10 @@ export namespace Config { if (lineIndex !== -1 && lines[lineIndex].trim().startsWith("//")) { continue // Skip if line is commented } - const filePath = match.replace(/^\{file:/, "").replace(/\}$/, "") + let filePath = match.replace(/^\{file:/, "").replace(/\}$/, "") + if (filePath.startsWith("~/")) { + filePath = path.join(os.homedir(), filePath.slice(2)) + } const resolvedPath = path.isAbsolute(filePath) ? filePath : path.resolve(configDir, filePath) const fileContent = (await Bun.file(resolvedPath).text()).trim() // escape newlines/quotes, strip outer quotes |
