Skip to content

Commit 8a039e2

Browse files
committed
add text source indexes to resolve prompt parts
1 parent 6bfa82d commit 8a039e2

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

packages/opencode/src/session/prompt.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,34 @@ export namespace SessionPrompt {
170170
const info = yield* fsys.stat(filepath).pipe(Effect.option)
171171
if (Option.isNone(info)) {
172172
const found = yield* agents.get(name)
173-
if (found) parts.push({ type: "agent", name: found.name })
173+
if (found) {
174+
parts.push({
175+
type: "agent" as const,
176+
name: found.name,
177+
source: {
178+
start: match.index!,
179+
end: match.index! + match[0].length,
180+
value: match[0],
181+
},
182+
})
183+
}
174184
return
175185
}
176186
const stat = info.value
177187
parts.push({
178-
type: "file",
179-
url: pathToFileURL(filepath).href,
180-
filename: name,
188+
type: "file" as const,
181189
mime: stat.type === "Directory" ? "application/x-directory" : "text/plain",
190+
filename: name,
191+
url: pathToFileURL(filepath).href,
192+
source: {
193+
type: "file" as const,
194+
path: name,
195+
text: {
196+
start: match.index!,
197+
end: match.index! + match[0].length,
198+
value: match[0],
199+
},
200+
},
182201
})
183202
}),
184203
{ concurrency: "unbounded", discard: true },

0 commit comments

Comments
 (0)