Skip to content

Commit 2e4aaff

Browse files
committed
push up incorrect mime types to call sites
1 parent bb7a6a5 commit 2e4aaff

File tree

3 files changed

+7
-18
lines changed

3 files changed

+7
-18
lines changed

packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ export function Prompt(props: PromptProps) {
203203
}
204204
: {
205205
type: "file" as const,
206-
mime: mention.mime,
206+
mime: mention.type === "directory" ? "application/x-directory" : "text/plain",
207207
filename: mention.filename,
208208
url: mention.url,
209209
source: {

packages/opencode/src/session/prompt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,7 @@ export namespace SessionPrompt {
16371637
type: "file" as const,
16381638
url: mention.url,
16391639
filename: mention.filename,
1640-
mime: mention.mime,
1640+
mime: mention.type === "directory" ? "application/x-directory" : "text/plain",
16411641
}
16421642
))
16431643

packages/opencode/src/util/mentions.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ import { ConfigMarkdown } from "@/config/markdown"
66
import { Agent } from "@/agent/agent"
77

88
export interface FileMention {
9-
type: "file"
9+
type: "file" | "directory"
1010
url: string
1111
filename: string
12-
mime: string
1312
start: number
1413
end: number
1514
}
@@ -23,6 +22,9 @@ export interface AgentMention {
2322

2423
export type Mention = FileMention | AgentMention
2524

25+
/**
26+
* Resolves mentions matched in the command template to agents, directories or files.
27+
*/
2628
export async function resolveMentions(text: string): Promise<Mention[]> {
2729
const files = ConfigMarkdown.files(text)
2830
const parts: Mention[] = []
@@ -49,23 +51,10 @@ export async function resolveMentions(text: string): Promise<Mention[]> {
4951
return
5052
}
5153

52-
if (stats.isDirectory()) {
53-
parts.push({
54-
type: "file",
55-
url: `file://${filepath}`,
56-
filename: name,
57-
mime: "application/x-directory",
58-
start: match.index,
59-
end: match.index + match[0].length,
60-
})
61-
return
62-
}
63-
6454
parts.push({
65-
type: "file",
55+
type: stats.isDirectory() ? "directory" : "file",
6656
url: `file://${filepath}`,
6757
filename: name,
68-
mime: "text/plain",
6958
start: match.index,
7059
end: match.index + match[0].length,
7160
})

0 commit comments

Comments
 (0)