Audit fixes: empty-dir handling, recursive scan, weave clean, hardened lock and hooks#10
Merged
Conversation
Removed command/script enumerations, file-by-file inventory, and specific config values that mirror code — those will drift as the project evolves. Kept conceptual descriptions and pointers to the source-of-truth files. Also gitignore .claude/ so per-developer agent config doesn't get committed.
…ned lock and hooks
Bug fixes
- syncRepo: when targetDir exists but has no .git, simple-git would walk
up and run against the parent repo (reporting the parent's dirty state
on the child). Now detect that case: remove if the dir is empty, else
abort cleanly so user data isn't wiped.
- syncRepo: pass --branch on first clone so the child lands on
thread.branch rather than the remote's default HEAD.
- checkDirtyState / checkRepo: guard against the same parent-walk by
requiring .git in the target dir.
- scanThreadFiles: recurse into subdirectories (skipping .git,
node_modules, and any nested git repo) so the README's documented
layout works with default scan ['.']. Dedupe results by file path.
New: weave clean
- Diff the exclude block against current .thread files; for orphans,
report status (clean / dirty / unpushed / non-git / missing).
- Default to dry run. --apply removes clean orphans, --force removes
dirty/unpushed/non-git ones. Rebuilds the exclude block after.
Ergonomic guards
- weave lock: refuse to pin HEAD unless the commit is reachable from a
remote branch (`git branch -r --contains`). Avoids the common footgun
of pinning to a local-only commit no coworker can sync to. --force
overrides.
- post-checkout hook: guard on $3 = 1 so it only fires on branch
checkouts, not file-level `git checkout <file>`.
- weave init: when no .thread files are found, name the scan paths
and show an example, instead of a bare "No .thread files found."
Cleanup
- Consolidate four copies of targetDirForThread into src/sync/targetDir.ts.
The previous lastIndexOf('/') implementation broke on Windows paths;
the shared helper uses path.dirname.
Tests
- tests/init-scenarios.sh exercises all of the above end-to-end against
a local bare repo (no test framework dependency). 46 assertions
across 17 scenarios; run with `./tests/init-scenarios.sh`.
simple-git < 3.36.0 has a high-severity RCE advisory. CI's `npm audit --audit-level=high` step rejects the previous 3.33.0 pin. Switched from exact pin to caret range so future patch releases of simple-git flow in automatically — pinning is what allowed the vulnerable version to linger here. Lockfile still pins exactly for reproducible installs. Verified: `npm audit --audit-level=high` reports 0 vulnerabilities; `./tests/init-scenarios.sh` still 46/46 green.
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.
Summary
Bug audit pass triggered by the empty-child-dir hang on first init. Found and fixed several adjacent issues along the way. Single commit, fully tested end-to-end against real git repos.
Bug fixes
New: `weave clean`
Removes cloned child directories whose `.thread` file no longer exists.
Ergonomic guards
Cleanup
Test plan
End-to-end tests live at `tests/init-scenarios.sh` — no test framework, just bash + git + a local bare repo. 46 assertions across 17 scenarios.
Deliberately out of scope
These came up in the brainstorm but weren't touched — call-out so they don't get lost: