feat(server): add hints for context files (#13444)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Attachments (files) are now included in the conversation context,
allowing users to reference files during chat sessions.
* Added a new "blobRead" tool enabling secure, permission-checked
reading of attachment content in chat sessions.

* **Improvements**
* Enhanced chat session preparation to always include relevant context
files.
* System messages now clearly display attached files and selected
content only when available, improving context clarity for users.
* Updated tool-calling guidelines to ensure user workspace is searched
even when attachment content suffices.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
DarkSky
2025-08-08 17:32:52 +08:00
committed by GitHub
parent 4005f40b16
commit 3cfb0a43af
9 changed files with 172 additions and 14 deletions
@@ -203,6 +203,18 @@ export class CopilotContextModel extends BaseModel {
return Prisma.join(groups.map(row => Prisma.sql`(${Prisma.join(row)})`));
}
async getFileContent(
contextId: string,
fileId: string,
chunk?: number
): Promise<string | undefined> {
const file = await this.db.aiContextEmbedding.findMany({
where: { contextId, fileId, chunk },
select: { content: true },
orderBy: { chunk: 'asc' },
});
return file?.map(f => f.content).join('\n');
}
async insertFileEmbedding(
contextId: string,
fileId: string,