Count untracked files in the Stop hook diff analysis (#61) - #79
Open
1st1 wants to merge 1 commit into
Open
Conversation
analyzeDiff only ran `git diff HEAD --numstat`, which lists tracked files only. A freshly scaffolded, never-committed `lat.md/` is untracked, so its edits counted as zero lat.md churn — the sync reminder then fired on every turn until the user committed `lat.md/`. Add `git ls-files --others --exclude-standard`, counting each untracked file's lines toward code or lat.md totals (respecting .gitignore, so `.cache/` is excluded). Export analyzeDiff and unit-test it via the fake-git harness, extended to dispatch diff vs ls-files. Docs updated in cli.md and the hook test spec. Fixes #61 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #61.
The bug
After
lat initon an existing repo, the Stop hook nagged the agent to write functionality intolat.md/on every turn — and only stopped once the user committedlat.md/.analyzeDiff(src/cli/hook.ts) measured churn with just:which reports tracked files only. A freshly scaffolded
lat.md/that's never beengit added is untracked, so all the agent'slat.md/edits counted as 0 lat.md lines while code churn piled up →needsSyncfired every turn. Committinglat.md/made its edits tracked, so the nagging stopped — exactly what the reporter observed.The fix
analyzeDiffnow also runs:and adds each untracked file's line count to the totals — untracked
lat.md/**→ lat.md lines, untracked source → code lines.--exclude-standardrespects.gitignore, solat.md/.cache/is excluded. Tracked and untracked sets are disjoint, so nothing is double-counted. As a bonus, the tracked-diff failure (a repo with no commits / no HEAD) no longer zeroes everything — the untracked scan still runs.Test
Exported
analyzeDiffand added a unit test reproducing the issue #61 scenario: an untracked 60-linelat.md/feature.md+ untracked 20-line source file + a 110-line tracked code diff → assertslatMdLines = 60,codeLines = 130. Before the fix this returnedlatMdLines = 0(perpetual nag). The fake-githarness now dispatches on the subcommand to serve bothdiffandls-files(cross-platform:gitsh script +git.cmd).Docs updated in
lat.md/cli.md(Stop hook) and thehook.mdtest spec. 162 tests pass;lat checkclean.🤖 Generated with Claude Code