Elffuss BraidHub

kikocis/VibeCodeViewer public

main · 14.1 KiBRenderedRawPermalink
1# VibeCodeViewer — Technical reference
2
3[Home](../README.en.md) / Technical reference · [Español](technical-reference.md)
4
5A procedural **glass-building city** (Three.js) that visualizes a code repository
6as a sharp, nineties-hacker-style metropolis: cyan wireframes, a circuit-board
7floor, local-first folder scanning, Git/ownership layers, blast-radius analysis,
8and visual controls that increase drama without depending on HDR postprocessing.
9
10## Product presentation demo
11
12<p align="center">
13 <a href="assets/vibecodeviewer-hyperframes-presentation.web.mp4">
14 <img src="assets/vibecodeviewer-hyperframes-presentation-readme.gif" alt="VibeCodeViewer product presentation showing repository topology, navigation, search, Git, ownership, blast radius, themes and guided demo mode" width="900">
15 </a>
16</p>
17
18> GitHub README rendering is most reliable with animated GIF previews. Click the
19> animation to open the optimized web MP4.
20
21- [Watch optimized web MP4](assets/vibecodeviewer-hyperframes-presentation.web.mp4)
22- [Open static poster](assets/vibecodeviewer-hyperframes-presentation-poster.png)
23
24## Language support
25
26The application UI is available in **Spanish** and **English**.
27
28- Use the language selector in the left control stack.
29- The choice is stored in `localStorage` under `vcc.language.v1`.
30- You can force a language at startup with `?lang=es` or `?lang=en`.
31- User-facing HUD text, search placeholders, settings, loading progress,
32 disabled-mode tooltips, stats, Git labels, and Blast legends are translated.
33
34## Highlighted capabilities
35
36- **Repository-as-city topology:** folders become districts, nested modules become buildings, and files become luminous cells.
37- **Spatial architecture review:** aerial, skyline, and guided camera views make hierarchy depth and dense areas readable at a glance.
38- **File search and selection:** matching files pulse across the city; selecting a file lights its path through building and district.
39- **Git status layer:** colors modified, new, renamed, and deleted files with repository-aware metadata.
40- **Ownership layer:** visualizes CODEOWNERS and `metadata.owner` conventions as owner-specific color regions.
41- **Blast radius analysis:** combines imports and symbol usage to show dependencies and downstream impact with animated beams.
42- **Local-first scanning:** opens a folder directly in Chrome/Edge and rebuilds the city locally without regenerating checked-in data.
43- **Ignored-code basements:** maps ignored files below the ground plane and can hide/reveal them with ground controls.
44- **Themes and visual settings:** switches themes and tunes exposure, contrast, edges, labels, glass, fog, ground, and experimental bloom.
45- **Guided demo mode:** chains topology, navigation, search, layers, themes, settings, legend, and final overview.
46
47## Repository → city mapping
48
49- Repository root → city.
50- First-level folders → districts.
51- Second-level folders → buildings.
52- Very deep or dense subtrees → **developments** inside the district; their
53 subfolders become buildings recursively.
54- Interior nesting → floors → apartments → rooms → filing cabinets → drawers.
55- Files → luminous cells at any level.
56
57Sizing rules:
58
59- Building width/depth is proportional to folder byte size using a logarithmic scale.
60- Height is proportional to recursive file count.
61- The file tree is printed onto the glass façade of each large building.
62- Selecting a file highlights its path on the façade.
63- Inside a drawer, files render as hanging vertical sheets; elsewhere they render as cube grids.
64
65## Hierarchical density lighting
66
67Selecting a file (click or search) lights its cell at full intensity and the
68light decays level by level outward (`×0.56` per hop):
69
70```text
71file ▓▓▓▓▓▓ → drawer ▓▓▓▓ → cabinet ▓▓▓ → room ▓▓ → floor ▓ → building ░ → district ·
72```
73
74Lit interior levels receive a subtle volumetric fill. Buildings and districts
75only light edges and fresnel so the interior remains readable.
76
77## Anti-blur recipe
78
791. Thin edges in one `LineSegments` object, with color and opacity tunable from **Settings**.
802. Minimal-opacity **fresnel glass** (`α ≈ 0.02` in the face center).
813. No permanent additive volumes; fills exist only while a level is active.
824. Direct render by default. The old HDR/bloom composer remains experimental via `?bloom=1` because some drivers produce black screen-space rectangles while orbiting.
83
84## Extras
85
86- **Open Folder…** (Chrome/Edge): scans any local folder with the File System Access API and rebuilds the city live without regenerating `src/data.js`.
87- **Basements:** files hidden by `.gitignore`, `.dockerignore`, or `.npmignore` are mapped below the circuit-board plane. The side tree shows them as `folder · basement`. Fully ignored folders become lower, more opaque bunker slabs.
88- **Legend** (`L` or button): district names are silkscreened onto the floor like circuit traces, and folder names appear on building roofs.
89- **District pulse:** the district containing the current selection remains slightly brighter and pulses softly.
90- **Search suggestions:** matching files blink in the city and are highlighted on their buildings' façades as you type.
91- **Settings:** modal panel under Reset View with visual presets and persistent sliders for exposure, brightness, contrast, saturation, edges, cells, glass, façades, labels, ground, and fog. Includes a **Bloom HDR** toggle that reloads with/without `?bloom=1`.
92
93## Coloring modes
94
95The top-center selector exposes **Basic · Git · Owners · Blast**. File color is
96attenuated through the hierarchy: drawer, room, floor, building, and district.
97
98- **Basic:** the original cyan palette.
99- **Git:** colors each file by Git status. The browser scanner parses `.git/index` directly for local folders; checked-in snapshots can also include `git status` and `git diff --numstat` metadata.
100- **Owners:** parses `CODEOWNERS` and `package.yml` files with `metadata.owner`. Each owner gets a color and appears in a legend with file counts. See [Code Ownership reference](code-ownership.en.md).
101- **Blast:** estimates the impact of a change in two layers:
102 1. Path imports (`src/codeLinks.js`) across JS/TS, C/C++, Python, CSS, HTML, and shell.
103 2. Symbol index (`src/codeIndex.js`) for JS/TS(X), Python, Ruby, C/C++, and Bash.
104
105When a file is selected in Blast mode:
106
107- Files that depend on it (downstream impact) light up with `beamIn`.
108- Its dependencies light up with `beam`.
109- Animated beams show propagation direction and the legend shows both counts.
110
111The analysis is cached with key `version|path|size|mtime`: Node uses
112`.cache/analysis.json`; the browser uses IndexedDB. Re-scanning only reanalyzes
113changed files.
114
115## Color themes
116
117The selector displays `Theme · …`. Full palettes live in `src/themes.js`; changing
118theme rebuilds only the city while keeping the model, camera, and selection.
119
120- **Hacker** — original cyan/purple on black.
121- **Factorial** — dark corporate palette with dominant red `#E51943` and structural green `#007C85`; UI panels are light (`uiLight`).
122- **Synthwave** — magenta and sunset orange on deep purple.
123- **Matrix** — monochrome green phosphor on black.
124- **Glaciar** — ice blues and cool whites on navy.
125
126The **Opaque Ground** button (`G`) hides basements by writing depth; translucent
127ground lets you glimpse them.
128
129## Visual settings and bloom
130
131The **Settings** button opens four presets:
132
133- **Safe:** base values, direct render.
134- **Neon:** more saturation and brightness without using bloom.
135- **Cinema:** more contrast, denser fog, less dominant ground.
136- **Intense:** more exposure and stronger edges/cells; the most aggressive tested preset without black artifacts.
137
138Sliders apply live and persist in `localStorage` under `vcc.visualSettings.v1`.
139The HUD shows whether you are using direct render or `bloom ×N`.
140
141`?bloom=1` enables `EffectComposer` + `UnrealBloomPass`. It is kept for
142experimentation but is not the default because some GPU/driver combinations show
143black rectangles during orbit. Remove `bloom` from the URL or uncheck **Bloom HDR**
144to return to stable mode.
145
146## GPU diagnostics
147
148Detection uses the real WebGL renderer exposed by the browser
149(`WEBGL_debug_renderer_info` when available). On Windows/WSLg or virtualized
150layers it may show `D3D12 virtual`, `Mesa`, or `Microsoft` even when the host has
151an NVIDIA GPU. In that case the app treats it as hardware accelerated but cannot
152invent the hidden brand.
153
154Useful debug overrides:
155
156- `?gpu=nvidia` forces the NVIDIA label/profile when the host has NVIDIA but the browser reports a virtual layer.
157- `?msaa=N` and `?pr=N` force render-target multisampling and pixel ratio.
158- `?bloom=1` enables the experimental HDR composer.
159
160## Keyboard in the tree
161
162With the tree focused:
163
164- `↑` / `↓`: move cursor.
165- `→`: expand a folder or enter it.
166- `←`: collapse or jump to parent.
167- `PageDown` / `PageUp`: move one page.
168- `Enter` / `Space`: select the item and fly the camera to it.
169
170## Large monorepos
171
172Tested with a real monorepo of about 120k files and 42 first-level districts.
173
174- **Developments:** towers absorb up to 5 levels of interior nesting. Deeper or very dense subtrees become developments so the city spreads instead of compressing into one tower.
175- Large cities apply a smooth, uniform attenuation to edges, glass, and cells while keeping district and development perimeters bright.
176- The tree scan is complete and has no file-count limit.
177- Blast reads file contents only within a budget (20k files / 48 MB), ordered by priority, in resumable batches.
178- Edge LOD draws only the most relevant boxes; brightness is normalized per building.
179- Text façades are limited to the 250 largest buildings; roof labels to 400; slabs to 4000 floors.
180- The side tree is lazy: branches mount in the DOM only when expanded.
181- `node_modules` and `.git/objects` are always skipped.
182
183## Run
184
185A static server is required because ES modules and import maps do not work from
186`file://`:
187
188```bash
189./serve.sh # serves on localhost by default
190./serve.sh 9000 # alternate port
191VCC_HOST=0.0.0.0 ./serve.sh 8137 # explicit LAN exposure
192```
193
194The File System Access API (**Open Folder…**) requires a secure context.
195`http://localhost` works for local folder analysis. From another machine on the
196network, use HTTPS or a secure tunnel.
197
198No build step is required: Three.js r160 is vendored in `vendor/` for offline use.
199
200Regenerate the repository snapshot (`src/data.js`):
201
202```bash
203node scan.mjs # scans this repository
204node scan.mjs --no-git # public snapshot without local git status
205node scan.mjs /other/path # scans another tree
206```
207
208`scan.mjs` does not write absolute paths into `src/data.js` and omits version
209control directories such as `.git`, `.hg`, and `.svn` from the published tree.
210
211## Automated visual verification
212
213Use these tools to record orbits and detect black-frame regressions:
214
215```bash
216# 1. Start the app and a Chromium instance with remote DevTools.
217./serve.sh 8137
218chromium-browser --headless --disable-gpu-sandbox --no-sandbox \
219 --remote-debugging-port=9223 --window-size=2048,1152 about:blank
220
221# 2. Capture an orbit with a theme/preset.
222node tools/capture-orbit.mjs \
223 --url=http://localhost:8137/ \
224 --out=/tmp/vcc-orbit \
225 --frames=120 --width=2048 --height=1152 --port=9223 --theme=matrix \
226 --visuals='{"exposure":1.24,"brightness":1.08,"contrast":1.28,"saturate":1.65,"lines":1.22,"files":1.35,"glass":1.16,"facades":1.12,"labels":1.45,"ground":1.08,"fog":0.92}'
227
228# 3. Optionally generate a video.
229ffmpeg -y -framerate 30 -i /tmp/vcc-orbit/frame-%04d.png \
230 -pix_fmt yuv420p /tmp/vcc-orbit.mp4
231
232# 4. Detect black rectangles in an orbit.
233python3 tools/detect-black-rects.py /tmp/vcc-orbit
234
235# 5. Detect the case of one screenshot, more sensitive to black windows.
236python3 tools/detect-black-rects.py --scan-windows screenshot.png
237
238# 6. Compare a candidate against a stable baseline.
239python3 tools/compare-black-regressions.py /tmp/candidate /tmp/baseline
240```
241
242`tools/detect-black-rects.py` uses Pillow/NumPy instead of OpenCV to avoid new
243dependencies. It exits with code 1 when bad frames are found.
244
245## Test mode: `./serve.sh --test N M [K]`
246
247Generates deterministic synthetic `src/data.js` via `tools/gentest.mjs` for
248rendering tests with controlled geometry.
249
250- **Without K:** N independent chains; each file lives at the bottom of M nested folders.
251- **With K (development mode):** N files are grouped; each district contains an `urb_g` block with K development-level folders, each continuing to total depth M.
252
253Examples:
254
255```bash
256./serve.sh --test 2 3
257./serve.sh --test 500 8
258./serve.sh --test 1000 8 250
259./serve.sh --test 1000 4 250
260./serve.sh --test 2500 3 2500
261./serve.sh --test 9000 9 300
262./serve.sh 8200 --test 100 10
263```
264
265Restore the real snapshot with `git checkout -- src/data.js` or rerun `scan.mjs`.
266`./serve.sh --help` prints a summary.
267
268## Controls
269
270- Drag / wheel: orbit · zoom.
271- Click: select file or building; empty click clears selection.
272- Hover: highlights building under cursor.
273- `F`: **fly mode** with pointer lock; crosses walls.
274- `W A S D` / mouse: move · look in fly mode.
275- `Space` / `E` · `C` / `Q`: up · down · `Shift` turbo.
276- `1` `2` `3`: Reset View · Aerial View · Building Height View.
277- `L` · `G`: legend · opaque ground.
278- `X` · `/`: clear selection · focus search.
279- `Esc`: exit fly mode / close search / close Settings.
280
281## Structure
282
283```text
284index.html HTML shell + importmap
285scan.mjs repository scanner → src/data.js
286README.md Spanish documentation
287README.en.md English documentation
288src/
289 data.js tree snapshot (generated)
290 i18n.js Spanish/English UI strings and language persistence
291 model.js hierarchy + layout (nested boxes, urban packing)
292 builder.js scene: HDR edges, fresnel glass, façades, PCB ground
293 controls.js orbit + free flight + camera flights
294 ui.js side tree, search, path, stats, Settings, language selector
295 main.js hierarchical selection, raycast, render, visual settings
296tools/
297 capture-orbit.mjs captures orbits via Chrome DevTools Protocol
298 detect-black-rects.py detects black rectangles in frames/screenshots
299 compare-black-regressions.py compares orbits against a visual baseline
300vendor/ Three.js r160 + addons (offline)
301```