From fcfd992df07569995c162be910e183a314ed20f1 Mon Sep 17 00:00:00 2001 From: rekram1-node Date: Thu, 28 Aug 2025 16:57:30 -0500 Subject: [PATCH] allow slash commands to resolve ~/ references --- packages/opencode/src/session/index.ts | 11 ++++++++--- 1 file 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", }) }