Repository navigation
Fix agent scan silent about projects below (#2125) - #2126
Mikola Lysenko (mikolalysenko) merged 4 commits into
Conversation
Assisted-by: Claude Code:claude-fable-5-2
A bare agent-mode scan above Bundler or PyPI projects with their own install directories must name the ones it left (#2125). These fail until the scan looks for them. Assisted-by: Claude Code:claude-fable-5-2
A bare agent-mode scan patches the installed packages its crawl of --cwd reads, so it covers one project. It never looked for project directories below --cwd: from a monorepo root it printed "No packages found. Run your package manager's install first.", or a success summary for the root alone, and left api/ and web/ unpatched without a word (#2125). After the crawl it now finds the project directories below (the search a bare hosted scan uses) and keeps the ones where a crawl would read a PyPI, Cargo, RubyGems, Go or Composer install directory the crawl from --cwd did not. It names them in a projects_not_scanned warning with the command that reaches the first, on stderr and in --json warnings[]. An empty scan with such a warning points at it instead of telling the user to run an install. npm is not compared: its crawl walks every node_modules below --cwd. Assisted-by: Claude Code:claude-fable-5-2
Review of the first cut found it too loose and too narrow at once. A Python project with no environment fell back to the machine's site-packages and was named on every scan, while an npm project the walk from --cwd skips (a hidden or build-output directory) never was. A directory is now named when it has an install directory of its own that the crawl from --cwd did not read: a node_modules, a Python environment or a Composer vendor directory inside the project, or a gem home (Bundler installs into the user-wide ones by default). The user-wide Python, Cargo and Go stores are not compared. Also: resolve the directories a few at a time, say when the tree was too large to search, list at most 10 directories, and suggest the command as the run was asked (--sync, an inferred mode). Assisted-by: Claude Code:claude-fable-5-2
|
bugbot run Generated by Claude Code |
PR SummaryLow Risk Overview Those directories get the existing Implementation adds Reviewed by Cursor Bugbot for commit 300c75a. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 300c75a. Configure here.
|
[agent] PR shepherd: review brief for the approver What it does Risk: low. It only adds output: no new writes, and exit code and status stay the same. The one cost is runtime: every bare agent scan inside a git checkout now runs the discovery walk plus a short probe of each project's install directories (at most 8 at a time, 1 under a tight fd limit). The PR measured 60 Bundler projects at about 2.5 s. Look here
Verified
Changes I made: none. Open questions: none blocking. Possible follow-up: the npm Generated by Claude Code |

LLM Description written by Claude Code:claude-fable-5-2
Fixes #2125
Summary
A bare agent-mode
scanrun from a monorepo root covered the rootdirectory only and said nothing about the projects below it. With no
project at the root it printed
No packages found. Run your package manager's install first.; with one it printed a success summary whileapi/andweb/kept the unpatched gem.The scan's coverage is unchanged (it is by design, see
CLI_CONTRACT.md).What changes is that the run now says what it left:
The same text is a
projects_not_scannedentry in--jsonwarnings[]. Exit code and status are unchanged, nothing new iswritten, and a checkout with no such directory prints what it always did.
Root cause
A bare hosted or vendored scan looks for the project directories below
--cwd(projects_below::discovered) and scans each. Agent modepatches the installed copies its crawl of
--cwdreads, and it neverran that search, so it could not tell an empty directory from a monorepo
root.
The fix
After the crawl, a bare agent-mode scan in a git checkout runs the same
search and keeps the directories that have an install directory of their
own which the crawl from
--cwddid not read(
projects_below::not_crawled):vendor/bundle, or the user-wide gem homes--cwddid not read that gem home.venv, ...)--cwd's only)node_modulesinside the project--cwdskipped it (hidden or build-output directory)A directory whose packages the run did read is not named: an ordinary
nested npm project, or a Bundler project sharing the gem home
--cwdreads. The user-wide Python, Cargo and Go stores are never compared, so a
docs/requirements.txtwith no environment does not warn on every scan.Details: the command is suggested as the run was asked (
--mode agent,--sync, or a barescanwhen the mode was inferred, since anexplicit
--modeconverts a project); more than 10 directories arelisted as the first 10 and a count; a tree too large to search adds a
projects_below_not_searchedwarning; directories are resolved 8 at atime (60 Bundler projects with no store of their own: 2.5 s, most of it
gem env).Evidence
Tests in
crates/socket-patch-cli/tests/scan/scan_project_discovery_e2e.rs(the real binary against a mock patch API). The first commit adds them;
without the fix the three marked red fail.
agent_scan_names_the_projects_below_it_left--jsonoutput, said once, no install hint,--synccommand,--cwd apiscans and does not warnagent_scan_of_a_root_project_names_the_projects_below_it_leftagent_scan_names_a_python_project_below_with_its_own_venv.venvagent_scan_names_an_npm_project_its_walk_skips.github/agent_scan_does_not_name_a_project_it_reachedAlso run by hand with Bundler 4.0.18 / Ruby 3.3.6 on the issue's repro
(
bundle installintovendor/bundleinapi/andweb/): bothshapes print the warning once; a third project using the user-wide gem
home is named from a root with no Gemfile and not named from a root that
reads the same gem home. Real npm, pnpm and Yarn installs (a workspace
plus nested independent projects) produce no warning, except for a project
under
tools/build, which the npm walk skips.Local checks:
cargo clippy --locked --workspace --all-features -- -D warnings: cleancargo test -p socket-patch-cli --lib: 950 passedcargo test -p socket-patch-cli --test scan: 262 passedcargo test -p socket-patch-cli --test cli,command_module_layering,cli_scan_silent,cli_parse_scan: all passedcargo clippy -p socket-patch-cli --all-targets ...reports lints intest helpers this PR does not touch (
tests/prebuilt_common/mod.rs,tests/common/mod.rs, and others); the same onmain. None is in afile changed here.
CLI_CONTRACT.mdanddocs/usage.mddescribe the new warning.Review
/code-review highran on the first cut and its findings drove thethird commit (false warnings for a Python project with no environment,
npm projects the walk skips, serial probes, a dropped truncation flag, an
uncapped list, the suggested command, contradictory contract text). One
finding is not fixed:
tools/, eachwith its own
go.sum/Cargo.lock) share one user-wide cache, andthe root crawl looks up only the root's packages.
toolsis not named,as before this PR. Naming it needs a comparison of lockfiles rather than
of directories, and would also name a project with nothing installed.
Cursor Bugbot reviewed
300c75aand raised one finding (an activatedvenv hides a nested project's own
.venv). It is answered in its threadand resolved without a change: a scan from that directory reads the
activated env too, so naming it would point at a run that patches nothing
more.
Follow-ups (not in this PR)
scan --mode agent api(a PATH) still answersNo installed packages found under the given path: api.: agent PATHs are globs under theroot's own install. The issue lists it as "the obvious next try".
scan --vexabove other projects prints itsprojects_not_scannedwarning twice on stderr (aneprintln!plusprint_layout_refusals). It predates this PR.https://claude.ai/code/session_011f9aePXwxoYZmCDiJZRdmL
Generated by Claude Code