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

Function sourceTargetOf

graph-ui/src/browser-ai/symbol-source.ts:23–36  ·  view source on GitHub ↗
(context: BrowserChatContext | undefined)

Source from the content-addressed store, hash-verified

21
22/** The one symbol a Galaxy or Architecture selection stands for, if it is one. */
23export function sourceTargetOf(context: BrowserChatContext | undefined): SourceTarget | undefined {
24 if (!context || context.text.length > 128_000) return undefined;
25 const galaxy = readGalaxyEvidence(context.text);
26 if (galaxy) {
27 const [root] = galaxy.roots;
28 if (galaxy.rootCount !== 1 || !root?.qualifiedName || CONTAINERS.has((root.kind ?? '').toLowerCase())) return undefined;
29 return { qualifiedName: root.qualifiedName, name: root.name, kind: root.kind, path: root.filePath, startLine: root.startLine, endLine: root.endLine };
30 }
31 let parsed: Record<string, unknown> | undefined;
32 try { parsed = record(record(JSON.parse(context.text))?.evidence); } catch { return undefined; }
33 const facts = parsed?.kind === 'current-selection-evidence' ? architectureFacts(parsed) : undefined;
34 // Source the view already read needs no second read.
35 return facts?.source ? undefined : facts?.target;
36}
37
38function architectureTarget(context: BrowserChatContext): SourceTarget | undefined {
39 let parsed: Record<string, unknown> | undefined;

Callers 6

packetFunction · 0.90
sourceForFunction · 0.90
knownSourceFunction · 0.90
listSourceFunction · 0.90
explainFunction · 0.90

Calls 3

readGalaxyEvidenceFunction · 0.90
architectureFactsFunction · 0.90
recordFunction · 0.70

Tested by 1

packetFunction · 0.72