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

Function readWhyAnswer

graph-ui/src/why/why-store.ts:51–76  ·  view source on GitHub ↗
(store: KeyValueStore, project: string)

Source from the content-addressed store, hash-verified

49 * silently withholding the only way into the modes.
50 */
51export function readWhyAnswer(store: KeyValueStore, project: string): WhyAnswer {
52 if (project.length === 0) {
53 return NEVER_ASKED;
54 }
55 let raw: string | null;
56 try {
57 raw = store.getItem(whyKey(project));
58 } catch {
59 return NEVER_ASKED;
60 }
61 if (raw === null) {
62 return NEVER_ASKED;
63 }
64 try {
65 const parsed = JSON.parse(raw) as Record<string, unknown>;
66 if (parsed['asked'] !== true) {
67 return NEVER_ASKED;
68 }
69 const intent = parsed['intent'];
70 return typeof intent === 'string' && INTENTS.includes(intent)
71 ? { asked: true, intent: intent as WhyIntent }
72 : { asked: true };
73 } catch {
74 return NEVER_ASKED;
75 }
76}
77
78/** Record the answer, or the decline. Returns what now stands. */
79export function recordWhyAnswer(store: KeyValueStore, project: string, intent?: WhyIntent): WhyAnswer {

Callers 2

ProjectWindowViewFunction · 0.90
why-store.test.tsFile · 0.90

Calls 2

whyKeyFunction · 0.85
getItemMethod · 0.65

Tested by

no test coverage detected