feat(embedder): interactive install prompt for @huggingface/transformers#110
Conversation
Move @huggingface/transformers from optionalDependencies to peerDependencies (optional) so npm no longer auto-installs it. When a user runs embed/search without the package, prompt them interactively to install it. Non-TTY environments skip the prompt and print the existing error message. Impact: 2 functions changed, 6 affected
|
Claude finished @carlos-alm's task —— View job Code Review CompleteTodo List
Phase 1: Root Cause Analysis ✅Problem Being Solved: The current setup has Why This Approach: Moving to Risk Assessment: This is a legitimate optimization that addresses a real user experience issue. The approach is technically sound and follows npm best practices. Phase 2: Configuration Change Detection ✅Dependency Changes Reviewed:
No concerning configuration relaxation detected. The dependency change serves a legitimate user experience improvement. Phase 3: Test Integrity ✅Test Coverage Analysis:
The PR maintains test integrity and provides clear manual testing steps for the new functionality. Phase 4: Code Quality Review ✅Security Analysis:
Implementation Quality:
Minor Considerations:
Final AssessmentRoot Cause AnalysisProblem Being Solved: Eliminating unnecessary installation of the ~150MB @huggingface/transformers package for users who don't need semantic search, improving installation speed and reducing disk usage. Why This Approach: Standard npm pattern using peerDependencies with optional metadata, combined with user-friendly interactive installation when actually needed. Risk Assessment: LOW - Well-implemented solution following established patterns with proper security practices. Critical ConcernsNone identified. This is a clean implementation that improves user experience without introducing risks. Final Recommendation
|
Greptile SummaryImproved package installation experience by moving Key improvements:
Testing notes:
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
Start([User runs embed/search]) --> TryImport{Try import<br/>transformers}
TryImport -->|Success| UsePackage[Use transformers]
TryImport -->|Fail| CheckTTY{Is stdin TTY?}
CheckTTY -->|No| ErrorNonTTY[Print install error<br/>Exit 1]
CheckTTY -->|Yes| Prompt[Prompt user:<br/>Install now? y/N]
Prompt --> UserAnswer{User<br/>answers 'y'?}
UserAnswer -->|No| ErrorDeclined[Print install error<br/>Exit 1]
UserAnswer -->|Yes| NpmInstall[npm install<br/>timeout: 5min]
NpmInstall -->|Success| RetryImport{Try import again}
NpmInstall -->|Fail| ErrorDeclined
RetryImport -->|Success| UsePackage
RetryImport -->|Fail| ErrorLoadFail[Print load error<br/>Exit 1]
UsePackage --> End([Continue execution])
Last reviewed commit: 8e717b2 |
Cover the four promptInstall/loadTransformers paths: - non-TTY skips prompt and exits with error - TTY + user declines → exits with error - TTY + user accepts but npm install fails → exits with error - TTY + install succeeds → retries import and loads module
|
Claude finished @carlos-alm's task —— View job Code Review CompleteTodo List
Phase 1: Root Cause Analysis ✅Problem Being Solved: The current setup has Why This Approach: Moving to Risk Assessment: This is a legitimate optimization that addresses a real user experience issue. The approach is technically sound and follows npm best practices. Phase 2: Configuration Change Detection ✅Dependency Changes Reviewed:
No concerning configuration relaxation detected. The dependency change serves a legitimate user experience improvement. Phase 3: Test Integrity ✅Test Coverage Analysis:
The PR maintains test integrity and provides clear manual testing steps for the new functionality. Phase 4: Code Quality Review ✅Security Analysis:
Implementation Quality:
Minor Considerations:
Final AssessmentRoot Cause AnalysisProblem Being Solved: Eliminating unnecessary installation of the ~150MB @huggingface/transformers package for users who don't need semantic search, improving installation speed and reducing disk usage. Why This Approach: Standard npm pattern using peerDependencies with optional metadata, combined with user-friendly interactive installation when actually needed. Risk Assessment: LOW - Well-implemented solution following established patterns with proper security practices. Critical ConcernsNone identified. This is a clean implementation that improves user experience without introducing risks. Final Recommendation
|
Summary
@huggingface/transformersfromoptionalDependenciestopeerDependencies(withoptional: truemeta) so npm no longer auto-installs it for every userpromptInstall()helper insrc/embedder.jsthat prompts users to install the package when they runembed/searchwithout itTest plan
npm test— all existing tests pass (they mock@huggingface/transformers)@huggingface/transformers, runnode src/cli.js search "test", verify prompt appears, answer "y", verify install + retry worksecho "" | node src/cli.js search "test") — verify it skips prompt and prints error