fix(cli): align prompt attachment contract

This commit is contained in:
Aiden Cline 2026-07-06 14:52:12 -05:00
commit 627c0d0e93
3 changed files with 25 additions and 24 deletions

View file

@ -183,14 +183,14 @@ function wait(delay: number, signal: AbortSignal) {
}
async function prepareFile(file: RunFilePart) {
if (file.mime !== "text/plain") return { attachment: { uri: file.url, mime: file.mime, name: file.filename } }
if (file.mime !== "text/plain") return { attachment: { uri: file.url, name: file.filename } }
const content = file.url.startsWith("data:")
? Buffer.from(file.url.slice(file.url.indexOf(",") + 1), "base64").toString("utf8")
: await Bun.file(new URL(file.url)).text()
return { text: `<file name="${file.filename}">\n${content}\n</file>` }
}
function promptFileSource(part: PromptFilePart) {
function promptFileMention(part: PromptFilePart) {
if (!part.source?.text) return
return {
start: part.source.text.start,
@ -206,7 +206,7 @@ function promptFiles(next: SessionTurnInput) {
{
uri: part.url,
name: part.filename,
source: promptFileSource(part),
mention: promptFileMention(part),
},
]
: [],
@ -219,7 +219,7 @@ function promptAgents(next: SessionTurnInput) {
? [
{
name: part.name,
source: part.source
mention: part.source
? { start: part.source.start, end: part.source.end, text: part.source.value }
: undefined,
},