Skip to content

Commit bf4ddc7

Browse files
committed
add text source indexes to resolve prompt parts
1 parent d93cefd commit bf4ddc7

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

packages/opencode/src/session/prompt.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -207,28 +207,32 @@ export namespace SessionPrompt {
207207
const agent = await Agent.get(name)
208208
if (agent) {
209209
parts.push({
210-
type: "agent",
210+
type: "agent" as const,
211211
name: agent.name,
212+
source: {
213+
start: match.index!,
214+
end: match.index! + match[0].length,
215+
value: match[0],
216+
},
212217
})
213218
}
214219
return
215220
}
216221

217-
if (stats.isDirectory()) {
218-
parts.push({
219-
type: "file",
220-
url: pathToFileURL(filepath).href,
221-
filename: name,
222-
mime: "application/x-directory",
223-
})
224-
return
225-
}
226-
227222
parts.push({
228-
type: "file",
229-
url: pathToFileURL(filepath).href,
223+
type: "file" as const,
224+
mime: stats.isDirectory() ? "application/x-directory" : "text/plain",
230225
filename: name,
231-
mime: "text/plain",
226+
url: pathToFileURL(filepath).href,
227+
source: {
228+
type: "file" as const,
229+
path: name,
230+
text: {
231+
start: match.index!,
232+
end: match.index! + match[0].length,
233+
value: match[0],
234+
},
235+
},
232236
})
233237
}),
234238
)

0 commit comments

Comments
 (0)