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

Function fallbackTarget

graph-ui/src/twin/mini-understanding.ts:151–191  ·  view source on GitHub ↗

* Where a category's line goes when its checklist items carry no target. * * The generator attaches a target to every item it emits, so this is no longer * the usual path: it is reached only for an IR built before it did, or by a * consumer assembling a checklist of its own. The checklist item a

(ir: SemanticIR, category: ChecklistCategory)

Source from the content-addressed store, hash-verified

149 * which one of several this line stands for.
150 */
151function fallbackTarget(ir: SemanticIR, category: ChecklistCategory): SymbolRef | undefined {
152 switch (category) {
153 case 'core-logic': {
154 const call = ir.steps.value[0];
155 return call ? stepTarget(call) : undefined;
156 }
157 case 'implementations': {
158 const call = ir.steps.value.find(entry => entry.strategy === CONSTRUCTION_STRATEGY);
159 return call ? stepTarget(call) : undefined;
160 }
161 case 'inputs': {
162 const type = (ir.typeRefs?.value ?? []).find(entry => entry.file !== undefined);
163 return type?.file ? refAt(type.file, type.line, type.name, type.qualifiedName) : undefined;
164 }
165 case 'callers': {
166 const caller = ir.calledBy.value.find(entry => entry.file !== undefined);
167 return caller?.file ? refAt(caller.file, caller.line, caller.name, caller.qualifiedName) : undefined;
168 }
169 case 'error-handling': {
170 const raise = ir.throws.value.find(entry => entry.file !== undefined);
171 if (raise?.file) {
172 return refAt(raise.file, raise.line, raise.type);
173 }
174 // The engine records no raise-site line, so the citation on the
175 // throws family points at the error type's own declaration, which
176 // is the one place worth opening.
177 const citation = ir.throws.evidence[0];
178 return citation ? evidenceTarget(citation, ir.throws.value[0]?.type ?? '') : undefined;
179 }
180 case 'config': {
181 const read = ir.reads.value.find(entry => entry.file !== undefined);
182 return read?.file ? refAt(read.file, read.line, read.name, read.qualifiedName) : undefined;
183 }
184 case 'tests': {
185 const test = ir.tests.value.find(entry => entry.file !== undefined);
186 return test?.file ? refAt(test.file, test.line, test.name) : undefined;
187 }
188 default:
189 return undefined;
190 }
191}
192
193/** One sentence per category, counting the checklist and naming the facts. */
194function labelFor(category: ChecklistCategory, items: ChecklistItem[], ir: SemanticIR): string {

Callers 1

buildMiniUnderstandingFunction · 0.85

Calls 3

stepTargetFunction · 0.90
refAtFunction · 0.90
evidenceTargetFunction · 0.90

Tested by

no test coverage detected