Skip to content

Commit 52e986e

Browse files
committed
add text source indexes to resolve prompt parts
1 parent 2e340d9 commit 52e986e

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
@@ -132,15 +132,34 @@ export namespace SessionPrompt {
132132
const info = yield* fsys.stat(filepath).pipe(Effect.option)
133133
if (Option.isNone(info)) {
134134
const found = yield* agents.get(name)
135-
if (found) parts.push({ type: "agent", name: found.name })
135+
if (found) {
136+
parts.push({
137+
type: "agent" as const,
138+
name: found.name,
139+
source: {
140+
start: match.index!,
141+
end: match.index! + match[0].length,
142+
value: match[0],
143+
},
144+
})
145+
}
136146
return
137147
}
138148
const stat = info.value
139149
parts.push({
140-
type: "file",
141-
url: pathToFileURL(filepath).href,
142-
filename: name,
150+
type: "file" as const,
143151
mime: stat.type === "Directory" ? "application/x-directory" : "text/plain",
152+
filename: name,
153+
url: pathToFileURL(filepath).href,
154+
source: {
155+
type: "file" as const,
156+
path: name,
157+
text: {
158+
start: match.index!,
159+
end: match.index! + match[0].length,
160+
value: match[0],
161+
},
162+
},
144163
})
145164
}),
146165
{ concurrency: "unbounded", discard: true },

0 commit comments

Comments
 (0)