Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
import { describe, expect, it } from 'vitest';
import { generalQuestion, viewQuestion } from './question-intent';
import { readGalaxyEvidence } from './galaxy-evidence';
import { githubFolderEvidence } from './galaxy-evidence.fixture';
import { viewAnswer } from './view-answer';
import type { GraphEdge, GraphNode } from '../galaxy/types';
const names = ['.github', 'django-demo..github'];
/** With .github selected in the hierarchy, "kkannst du mir die heirarchie erklären" and "erkläre die
* aktuelle hierarchy" went to the free model, which only restated them (hand test of 2026-10-04, H1). */
describe('questions about the current view (H1)', () => {
it.each([
'kkannst du mir die heirarchie erklären', 'erkläre die aktuelle hierarchy', 'erkläre die aktuelle ansicht', 'was zeigt mir diese ansicht', 'kannst du mir den graphen erklären',
'Erklär mir den Ausschnitt', 'beschreibe die Struktur', 'was sehe ich hier?', 'Was sehe ich hier eigentlich?', 'Was zeigt der Graph?', 'Wie lese ich diese Hierarchie?',
'erkläre die hierarchie von .github', 'Hierarchie?', 'explain the hierarchy', 'what does this view show', 'Explain this graph', 'What am I looking at?',
'can you explain this view?', 'what is this view?', 'How do I read this hierarchy?', 'describe the structure please', 'explain the current scope', 'erklär mir die heirachie bitte',
])('reads %s as a question about the current view', prompt => {
expect(viewQuestion(prompt, names)).toBe('general');
});
it.each(['erkläre die hierarchie ausführlich', 'explain this view in detail', 'Erklär den Graphen Schritt für Schritt'])('reads %s as one that asks the model for detail', prompt => {
expect(viewQuestion(prompt, names)).toBe('detail');
});
it.each([
'erklär mir das', 'was macht diese klasse?', 'Who calls JSONBAgg?', 'warum ist die hierarchie so aufgebaut?', 'erkläre die Struktur von Aggregate', 'test', 'Hat diese Klasse Luft?',
'explain the hierarchy of Aggregate', 'Wie viele Dateien enthält .github?', 'what does this class do?', 'erkläre die absicht',
])('leaves %s to the other answers', prompt => {
expect(viewQuestion(prompt, names)).toBeUndefined();
});
it('still reads a general question about the selection as one', () => {
expect(generalQuestion('erklär mir das', names)).toBe('general');
expect(generalQuestion('kannst du mir das erklären', names)).toBe('general');
});
});
const evidence = (display?: 'galaxy' | 'hierarchy', overrides?: Parameters<typeof githubFolderEvidence>[1]) => readGalaxyEvidence(githubFolderEvidence(display, overrides).text)!;
describe('the listed answer about the current view (H1)', () => {
it('says what is in the middle, what comes in on the left and what goes out on the right, in German', () => {
const answer = viewAnswer(evidence('hierarchy'), 'de');
expect(answer.split('\n\n')).toEqual([
'`.github` (Ordner) steht in der Mitte; der Ausschnitt geht 1 Schritt in beide Richtungen.',
// The branch node is named as the Galaxy names it, not by its bare "DETACHED" (K47).
'Links, eingehend:\n- **CONTAINS_FOLDER (1):** `django-demo · detached HEAD`',
'Rechts, ausgehend:\n- **CONTAINS_FILE (4):** `CODE_OF_CONDUCT.md`, `FUNDING.yml`, `pull_request_template.md`, `SECURITY.md`\n- **CONTAINS_FOLDER (1):** `workflows`',
'So liest du die Hierarchie: eingehende Beziehungen stehen links, ausgehende rechts.',
'7 Symbole und 6 Beziehungen, alle Beziehungstypen; vollständig geladen.',
'_Aus dem indizierten Graphen gelistet, nicht vom Modell erzeugt._',
]);
});
it('says the galaxy view shows the same scope as a cloud, without left and right, in English', () => {
const answer = viewAnswer(evidence('galaxy'), 'en');
expect(answer.split('\n\n')).toEqual([
'`.github` (Folder) is in the middle; the scope reaches 1 hop in both directions.',
'Incoming:\n- **CONTAINS_FOLDER (1):** `django-demo · detached HEAD`',
'Outgoing:\n- **CONTAINS_FILE (4):** `CODE_OF_CONDUCT.md`, `FUNDING.yml`, `pull_request_template.md`, `SECURITY.md`\n- **CONTAINS_FOLDER (1):** `workflows`',
'The galaxy view shows this scope as a cloud. "hierarchy" at the top right lays the same scope out in columns: incoming on the left, outgoing on the right.',
'7 symbols and 6 relationships, all relationship types; fully loaded.',
'_Listed from the indexed graph; not generated by the model._',
]);
});
it('bounds long name lists with "+N more" and names the dashed band from two layers on', () => {
const extra: GraphNode[] = Array.from({ length: 12 }, (_, index) => ({ id: 100 + index, name: `doc_${String(index).padStart(2, '0')}.md`, label: 'File', file_path: `.github/doc_${String(index).padStart(2, '0')}.md`,
x: 0, y: 0, z: 0, size: 1, color: '#999' }));
const edges: GraphEdge[] = extra.map(node => ({ source: 1, target: node.id, type: 'CONTAINS_FILE' }));
const answer = viewAnswer(evidence('hierarchy', { depth: 2, nodes: extra, edges }), 'de');
expect(answer).toContain('- **CONTAINS_FILE (16):** `CODE_OF_CONDUCT.md`, `doc_00.md`, `doc_01.md`, `doc_02.md`, `doc_03.md`, `doc_04.md`, `doc_05.md`, `doc_06.md`; +8 weitere');
expect(answer).toContain('der Ausschnitt geht 2 Schritte in beide Richtungen.');
expect(answer).toContain('So liest du die Hierarchie: eingehende Beziehungen stehen links, ausgehende rechts, jede Spalte eine Ebene weiter in derselben Richtung. '
+ 'Was über beide Richtungen erreicht wird, etwa etwas, das ein Aufrufer sonst noch aufruft, steht im gestrichelten Band „Mixed directions“ darunter.');
});
it('reads a hierarchy that follows one direction only, and names the side that is not loaded', () => {
const answer = viewAnswer(evidence('hierarchy', { direction: 'outbound' }), 'en');
expect(answer).toContain('the scope reaches 1 hop, outgoing only.');
expect(answer).toContain('Incoming: not loaded; the scope does not follow incoming edges.');
expect(answer).toContain('How to read the hierarchy: the scope follows outgoing relationships only, so everything stands on the right of the middle.');
expect(answer).not.toContain('dashed band');
});
it('says nothing about left, right or a cloud when the evidence does not say which view is shown', () => {
const answer = viewAnswer(evidence(), 'en');
expect(answer).toContain('Incoming:\n- **CONTAINS_FOLDER (1):** `django-demo · detached HEAD`');
expect(answer).not.toMatch(/left|right|cloud/);
});
});