victorylap Devlog #2 (my analyzer thought the repo was 90% virtual environment)
TL;DR
- wrote analyze.js, the first real victorylap code. point it at any repo, get structured json back
- it reads package.json, pulls the first real sentence out of the readme, detects languages by walking the file tree, and reads git
history - zero dependencies. just node builtins: fs, path, child_process
- tested on two repos, one TypeScript and one Python. both came back clean
The Analyzer
this is the machine that replaces “ai looks at your repo and vibes.” victorylap needs facts about a project before it can make a video about it, so analyze.js collects them into one json report: name, description, first readme sentence, language breakdown, commit count, project dates, last 10 commit messages.
every source is its own function that returns null if the file isn’t there. repos are hostile territory. some have no package.json, some have no readme, some aren’t even git repos. the analyzer assumes nothing exists and survives all of it.
the readme part was more parsing than reading. readmes open with badges, logos and headings before any actual sentence, so the code skips every line that starts with #, ![ or < until it hits real prose. on site-slap that landed on “paste a url. get a score out of 100. get roasted.” which is exactly the tagline a video wants.
The venv Bug
first run on free-claude-code reported 1045 python files.
the repo has about 125.
the language detector walks the whole file tree and counts extensions, with a skip list for folders that aren’t your code: node_modules, .git, dist. my list had “.venv” in it. the folder in the repo was named “venv”. no dot, different string, the walker went right in and counted 928 files of installed packages as project code.
one word added to the skip list and python dropped to 125. the numbers always look right until you check them against reality.
git history had its own surprise. my hardcoded demo frame has said 107 COMMITS since day 1, a number i eyeballed. git rev-list says 494. the analyzer’s first real act was fact-checking my own video.
What I Learned
the file tree walk was my first recursive function, a function that calls itself.
walk() reads one folder. every file gets its extension counted. every subfolder triggers walk() on that subfolder, and here’s the part that made it click: every call receives the same counts object, passed down as an argument. there aren’t 50 tallies getting merged at the end, there is one shared tally that every level of the tree writes into. when the outermost call finishes, the whole repo is already counted.
recursion sounds like a trick until you need to handle “a folder can contain folders which contain folders.” then it’s just the honest shape of the problem.
Tip of the Day
try/catch will eat your typos, not just your expected errors. i wrapped the git code in try/catch so non-git folders return null
instead of crashing. then i typed “utf8 “ with a trailing space as the encoding. node rejected it, the catch swallowed it, and git
came back null with zero explanation. if a section of your output is mysteriously null, the first suspect is a typo hiding inside
your own safety net.
next up: feed this json to a free llm and get a video script back.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.