mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-22 18:24:21 +01:00
allow slash commands to resolve ~/ references (#2295)
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import path from "path"
|
import path from "path"
|
||||||
|
import os from "os"
|
||||||
import { spawn } from "child_process"
|
import { spawn } from "child_process"
|
||||||
import { Decimal } from "decimal.js"
|
import { Decimal } from "decimal.js"
|
||||||
import { z, ZodSchema } from "zod"
|
import { z, ZodSchema } from "zod"
|
||||||
@@ -1231,11 +1232,15 @@ export namespace Session {
|
|||||||
const app = App.info()
|
const app = App.info()
|
||||||
|
|
||||||
for (const match of fileMatches) {
|
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({
|
parts.push({
|
||||||
type: "file",
|
type: "file",
|
||||||
url: `file://${file}`,
|
url: `file://${filepath}`,
|
||||||
filename: match[1],
|
filename,
|
||||||
mime: "text/plain",
|
mime: "text/plain",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user