( currentDraft: string, title: string, meta: string, content: string, )
| 899 | } |
| 900 | |
| 901 | function appendEntrySection( |
| 902 | currentDraft: string, |
| 903 | title: string, |
| 904 | meta: string, |
| 905 | content: string, |
| 906 | ): |
| 907 | | { readonly ok: true; readonly draft: string } |
| 908 | | { readonly ok: false; readonly reason: 'oversize' } { |
| 909 | const entry = [`## ${title}`, `<!-- maka-memory: ${meta} -->`, content].join('\n'); |
| 910 | const draft = |
| 911 | currentDraft.trim().length > 0 ? `${currentDraft.trimEnd()}\n\n${entry}\n` : `${entry}\n`; |
| 912 | if (new TextEncoder().encode(draft).byteLength > LOCAL_MEMORY_MAX_BYTES) { |
| 913 | return { ok: false, reason: 'oversize' }; |
| 914 | } |
| 915 | return { ok: true, draft }; |
| 916 | } |
| 917 | |
| 918 | function normalizeManualEntryTitle(input: string): string { |
| 919 | return input |
no test coverage detected