MCPcopy Create free account
hub / github.com/apache/maka / appendEntrySection

Function appendEntrySection

packages/core/src/local-memory.ts:901–916  ·  view source on GitHub ↗
(
  currentDraft: string,
  title: string,
  meta: string,
  content: string,
)

Source from the content-addressed store, hash-verified

899}
900
901function 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
918function normalizeManualEntryTitle(input: string): string {
919 return input

Calls 2

joinMethod · 0.80
trimMethod · 0.45

Tested by

no test coverage detected