mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-10-09 15:58:34 +00:00
fe2f14f032
* fix(#3289): automated AI fix * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix: address Codex review on PR #3290 * fix(ai): apply note attachment budgets synchronously * fix(ai): reuse normalized note search fields while typing * fix(ai): retain draft state binding in panel host * fix(ai): reject carriage returns in note references * fix(ai): protect continuation before pruning note payloads * refactor(ai): keep note mentions as lightweight references * fix(ai): gate note references on reader availability * fix(ai): retain note references ahead of replay prose * refactor(ai): share one instruction across note references * fix(ai): keep accepted note references within replay space * Bound agent note reads and add resumable literal search * Preserve compact note requests and announce picker selection * Retain mixed attachment context in compact note replay * Keep imported long note identities readable * Keep note picker selection and untitled labels consistent --------- Co-authored-by: netcatty-bot <308658023+netcatty-bot@users.noreply.github.com> Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com>
39 lines
1.8 KiB
TypeScript
39 lines
1.8 KiB
TypeScript
import type { VaultNote } from "../../domain/models";
|
|
import type { ChatMessageAttachment, UploadedFile } from "../../infrastructure/ai/types";
|
|
|
|
/** A mention stores only identity; the agent reads current content through the Vault tool. */
|
|
export function createVaultNoteAttachment(note: Pick<VaultNote, "id" | "title">): UploadedFile | null {
|
|
// Preserve imported IDs exactly. Reject oversized IDs instead of changing their identity.
|
|
if (!note.id.trim() || note.id.length > 200) return null;
|
|
const title = Array.from(note.title.trim() || "Untitled note").slice(0, 120).join("");
|
|
return {
|
|
id: crypto.randomUUID(),
|
|
filename: title,
|
|
mediaType: "text/markdown",
|
|
base64Data: "",
|
|
dataUrl: "",
|
|
vaultNoteId: note.id,
|
|
vaultNoteTitle: title,
|
|
};
|
|
}
|
|
|
|
export function isVaultNoteAttachment(
|
|
attachment: Pick<ChatMessageAttachment | UploadedFile, "vaultNoteId">,
|
|
): boolean {
|
|
return typeof attachment.vaultNoteId === "string" && attachment.vaultNoteId.length > 0;
|
|
}
|
|
|
|
/** JSON preserves special characters and whitespace in exact note IDs. */
|
|
export function formatVaultNoteReferences(
|
|
attachments: Array<Pick<ChatMessageAttachment | UploadedFile, "vaultNoteId" | "vaultNoteTitle">>,
|
|
): string {
|
|
const notes = attachments.map((attachment) => ({ noteId: attachment.vaultNoteId, title: attachment.vaultNoteTitle }));
|
|
return `[Vault note references: ${JSON.stringify(notes)}]\nUse vault_notes_get with each exact noteId to read the latest content before summarizing or editing. If unavailable, report that instead of choosing another note.`;
|
|
}
|
|
|
|
/** Reserve at least half of external replay's 2,000 characters for the user's request. */
|
|
export function vaultNoteReferencesFit(attachments: UploadedFile[]): boolean {
|
|
const notes = attachments.filter(isVaultNoteAttachment);
|
|
return notes.length === 0 || formatVaultNoteReferences(notes).length <= 1000;
|
|
}
|