Skip to content

Classifier: match markers on token/basename boundaries, tighten ProjectNamer - #3

Open
AadhilFarhan wants to merge 1 commit into
mainfrom
fix/classifier-false-positives
Open

Classifier: match markers on token/basename boundaries, tighten ProjectNamer#3
AadhilFarhan wants to merge 1 commit into
mainfrom
fix/classifier-false-positives

Conversation

@AadhilFarhan

Copy link
Copy Markdown
Owner

What

Two related classification-accuracy bugs, both in Classifier.swift:

  1. framework() false positives from substring matching. Single-word markers (rails, webpack, vite, ...) were matched with a raw .contains against the entire lowercased args string — full executable path plus all CLI args. A project directory that happens to contain the marker's text (~/my-rails-experiments, ~/webpack-notes) got misclassified as that framework even when run through an unrelated interpreter. Multi-word markers ("next dev", "manage.py runserver") keep the substring check since they're specific consecutive phrases with low false-positive risk. Single-word markers now must match a whole token or a token's path basename.

  2. ProjectNamer.projectName's undocumented broad fallback. Beyond the two documented cases (package.json name, or folder name when a manifest/project file exists), the code had a third: any cwd under the user's home directory returned its folder name as a "project," even with zero manifest files present. CLAUDE.md already documented only the narrower, manifest-gated behavior — this brings the code back in line with what was already written there rather than changing the docs to match the looser code.

Test plan

  • Added testDoesNotMatchMarkerAsSubstringOfUnrelatedPath and testFolderUnderHomeWithoutManifestIsNotAProject.
  • Confirmed both fail on the old code first (stashed the fix, ran just the new tests — all 3 assertions failed with exactly the wrong values .rails/.webpack/a leaked folder name), then confirmed they pass with the fix.
  • Full suite: 11/11 passing.

…ctNamer

framework() checked whether a marker like "rails" or "webpack" was a
substring anywhere in the full lowercased args string, including the
executable's whole path. A project directory that happens to contain
the marker's text (~/my-rails-experiments, ~/webpack-notes) got
misclassified as that framework even when run through an unrelated
runtime. Single-word markers now must match a whole token or a
token's path basename; multi-word markers ("next dev", "manage.py
runserver") keep the substring check, since they're specific enough
phrases that a false positive is unlikely.

ProjectNamer.projectName also had a third, undocumented fallback:
any cwd under the user's home directory returned the folder name as
a "project" even with zero manifest or project files present.
CLAUDE.md already documented the narrower, manifest-gated behavior —
removed the fallback so the code matches what was already written
there.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant