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 { fileOutline } from './file-outline';
/** django's .pre-commit-config.yaml as the hand test of 2026-10-04 read it. */
export const PRE_COMMIT = `repos:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.1.0
hooks:
- id: black
exclude: \\.py-tpl$
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.19.1
hooks:
- id: blacken-docs
additional_dependencies:
- black==25.1.0
files: 'docs/.*\\.txt$'
args: ["--rst-literal-block"]
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v9.12.0
hooks:
- id: eslint
`;
const WORKFLOW = 'name: New contributor message\n\non:\n pull_request_target:\n types: [opened]\n\njobs:\n build:\n name: Hello new contributor\n runs-on: ubuntu-latest\n steps:\n - uses: actions/first-interaction@v1\n';
describe('the outline of a configuration file, read from it (C7)', () => {
it('lists each repo of a pre-commit file with its revision and hooks', () => {
const outline = fileOutline('.pre-commit-config.yaml', PRE_COMMIT, 'en')!;
expect(outline).toContain('`.pre-commit-config.yaml`: YAML configuration, 26 lines.\n\npre-commit configuration: hooks that run before each commit.');
expect(outline).toContain('- `repos` (list of 5):');
expect(outline).toContain(' 1. repo `https://github.com/psf/black-pre-commit-mirror`; rev `25.1.0`; hooks (1): `black` (exclude `\\.py-tpl$`)');
expect(outline).toContain(' 2. repo `https://github.com/adamchainz/blacken-docs`; rev `1.19.1`; hooks (1): `blacken-docs` '
+ '(additional_dependencies: `black==25.1.0`; files `docs/.*\\.txt$`; args: `--rst-literal-block`)');
expect(outline).toContain(' 5. repo `https://github.com/pre-commit/mirrors-eslint`; rev `v9.12.0`; hooks (1): `eslint`');
expect(outline).toContain('_Read from the file; not generated by the model._');
});
it('writes the outline in German for a German question', () => {
const outline = fileOutline('.pre-commit-config.yaml', PRE_COMMIT, 'de')!;
expect(outline).toContain('`.pre-commit-config.yaml`: YAML-Konfiguration, 26 Zeilen.\n\npre-commit-Konfiguration: Hooks, die vor jedem Commit laufen.');
expect(outline).toContain('- `repos` (Liste mit 5 Einträgen):');
expect(outline).toContain(' 4. repo `https://github.com/PyCQA/flake8`; rev `7.1.1`; hooks (1): `flake8`');
expect(outline).toContain('_Aus der Datei gelesen, nicht vom Modell erzeugt._');
});
it('keeps mappings by their keys and bounds long lists with "+N more"', () => {
const docs = 'version: 2\nbuild:\n os: ubuntu-22.04\n tools:\n python: "3.12"\npython:\n install:\n - requirements: docs/requirements.txt\nformats:\n - pdf\n - epub\n';
const outline = fileOutline('.readthedocs.yml', docs, 'en')!;
// A single item without a naming field reads as its fields, without parentheses.
expect(outline).toContain('- `python`: install (1): requirements `docs/requirements.txt`');
expect(outline).toContain('- `version`: `2`');
expect(outline).toContain('- `build`: os `ubuntu-22.04`; tools: python `3.12`');
expect(outline).toContain('- `formats` (list of 2): `pdf`, `epub`');
const long = `items:\n${Array.from({ length: 30 }, (_, index) => ` - name: item${index}\n value: ${index}`).join('\n')}\n`;
const bounded = fileOutline('long.yaml', long, 'en')!;
expect(bounded).toContain(' 10. name `item9`; value `9`');
expect(bounded).not.toContain('item10`');
expect(bounded).toContain(' +20 more');
expect(fileOutline('long.yaml', long, 'de')).toContain(' +20 weitere');
});
it('reads JSON and TOML files the same way', () => {
const json = fileOutline('package.json', '{"name": "demo", "scripts": {"build": "tsc", "test": "vitest"}, "files": ["dist", "src"]}', 'en')!;
expect(json).toContain('- `name`: `demo`');
expect(json).toContain('- `scripts`: build `tsc`; test `vitest`');
expect(json).toContain('- `files` (list of 2): `dist`, `src`');
const toml = fileOutline('pyproject.toml', '[project]\nname = "demo"\nversion = "1.0"\n\n[tool.ruff]\nline-length = 88\n', 'en')!;
expect(toml).toContain('- `[project]`: name `demo`; version `1.0`');
expect(toml).toContain('- `[tool.ruff]`: line-length `88`');
});
it('gives a workflow its counted facts, in the language of the question', () => {
const english = fileOutline('.github/workflows/new_contributor_pr.yml', WORKFLOW, 'en')!;
expect(english).toContain('- Workflow name: `New contributor message`.');
expect(english).toContain('- 1 job: `build` ("Hello new contributor", runs on ubuntu-latest, 1 step).');
expect(english).toContain('- Actions used: `actions/first-interaction@v1`.');
const german = fileOutline('.github/workflows/new_contributor_pr.yml', WORKFLOW, 'de')!;
expect(german).toContain('- Name des Workflows: `New contributor message`.');
expect(german).toContain('- Auslöser: `pull_request_target` (Typen: opened).');
expect(german).toContain('- 1 Job: `build` ("Hello new contributor", läuft auf ubuntu-latest, 1 Schritt).');
expect(german).toContain('- Verwendete Actions: `actions/first-interaction@v1`.');
});
it('has no outline for program code, text files or JSON that does not parse', () => {
expect(fileOutline('django/contrib/postgres/aggregates/general.py', 'class JSONBAgg: pass', 'en')).toBeUndefined();
expect(fileOutline('README.md', '# Demo', 'en')).toBeUndefined();
expect(fileOutline('broken.json', '{"name":', 'en')).toBeUndefined();
});
});