diff options
| author | Aiden Cline <[email protected]> | 2025-08-28 17:31:03 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-28 17:31:03 -0500 |
| commit | 6daf0fdb2b68bae213328c208fc8ba54944d561d (patch) | |
| tree | d7bf2c39d1349e80a78eb7c81936935e3630785c | |
| parent | f2f4d87cc0d0a0466ce1efdac73c55de5693b483 (diff) | |
| download | opencode-6daf0fdb2b68bae213328c208fc8ba54944d561d.tar.gz opencode-6daf0fdb2b68bae213328c208fc8ba54944d561d.zip | |
allow slash commands to resolve ~/ references (#2295)
| -rw-r--r-- | packages/opencode/src/session/index.ts | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/packages/opencode/src/session/index.ts b/packages/opencode/src/session/index.ts index 41f85b6ea..5cd76124f 100644 --- a/packages/opencode/src/session/index.ts +++ b/packages/opencode/src/session/index.ts @@ -1,4 +1,5 @@ import path from "path" +import os from "os" import { spawn } from "child_process" import { Decimal } from "decimal.js" import { z, ZodSchema } from "zod" @@ -1231,11 +1232,15 @@ export namespace Session { const app = App.info() for (const match of fileMatches) { - const file = path.join(app.path.cwd, match[1]) + const filename = match[1] + const filepath = filename.startsWith("~/") + ? path.join(os.homedir(), filename.slice(2)) + : path.join(app.path.cwd, filename) + parts.push({ type: "file", - url: `file://${file}`, - filename: match[1], + url: `file://${filepath}`, + filename, mime: "text/plain", }) } |
