MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / readAdrDraft

Function readAdrDraft

graph-ui/src/adr/adr-model.ts:26–42  ·  view source on GitHub ↗
(project: string)

Source from the content-addressed store, hash-verified

24}
25
26export function readAdrDraft(project: string): AdrDraft | undefined {
27 const key = draftKey(project);
28 const inMemory = memoryDrafts.get(key);
29 if (inMemory) return inMemory;
30 try {
31 const value: unknown = JSON.parse(sessionStorage.getItem(key) ?? 'null');
32 if (!value || typeof value !== 'object') return;
33 const draft = value as Partial<AdrDraft>;
34 if (draft.version !== 1 || typeof draft.content !== 'string' || !draft.base
35 || typeof draft.base.hasAdr !== 'boolean' || typeof draft.base.content !== 'string'
36 || typeof draft.base.updatedAt !== 'string') return;
37 if (draft.content === draft.base.content) return;
38 const restored: AdrDraft = { version: 1, content: draft.content, base: { ...draft.base } };
39 memoryDrafts.set(key, restored);
40 return restored;
41 } catch { return; }
42}
43
44/** Memory also retains drafts across project switches when browser storage is unavailable. */
45export function storeAdrDraft(project: string, draft: AdrDraft): boolean {

Callers 2

ProjectAdrWorkspaceFunction · 0.90

Calls 3

draftKeyFunction · 0.85
getMethod · 0.65
getItemMethod · 0.65

Tested by

no test coverage detected