-
Notifications
You must be signed in to change notification settings - Fork 173
Add CLI validation for Desktop app alignment #3535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add pkg/desktop/ package to detect and validate when ToolHive Desktop manages CLI installation via marker file at ~/.toolhive/.cli-source. - types.go: CliSourceMarker and ValidationResult structs - marker.go: marker file reading and path utilities - validation.go: path comparison and conflict detection logic Related to: toolhive-studio#1512 RFC: THV-0020
Add PersistentPreRunE hook to validate desktop alignment before every CLI command. Returns hard stop error when conflict detected between standalone CLI and Desktop-managed installation.
- Unit tests for marker file parsing, path comparison, symlink resolution - E2E tests for conflict scenarios, stale markers, and skip override
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Large PR Detected
This PR exceeds 1000 lines of changes and requires justification before it can be reviewed.
How to unblock this PR:
Add a section to your PR description with the following format:
## Large PR Justification
[Explain why this PR must be large, such as:]
- Generated code that cannot be split
- Large refactoring that must be atomic
- Multiple related changes that would break if separated
- Migration or data transformationAlternative:
Consider splitting this PR into smaller, focused changes (< 1000 lines each) for easier review and reduced risk.
See our Contributing Guidelines for more details.
This review will be automatically dismissed once you add the justification section.
- Simplify if-return in commands.go (revive) - Add gosec nolint for marker file read (G304) - Add paralleltest nolint for tests that modify HOME env - Add goconst nolint for platform checks - Fix gci import ordering and struct formatting
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3535 +/- ##
==========================================
+ Coverage 65.34% 65.38% +0.04%
==========================================
Files 403 405 +2
Lines 39206 39319 +113
==========================================
+ Hits 25618 25709 +91
- Misses 11607 11614 +7
- Partials 1981 1996 +15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Add CLI validation to detect when ToolHive Desktop manages CLI installation, preventing version conflicts that cause API incompatibilities.
When the Desktop app installs the CLI, it creates a marker file at
~/.toolhive/.cli-source. This PR adds validation that runs before every CLI command to detect conflicts between standalone CLI and Desktop-managed installations.Validation Flow
flowchart TD A[CLI Command Invoked] --> B[Read ~/.toolhive/.cli-source] B -->|Not Found| C[Proceed Normally] B -->|Found| D[Check symlink_target exists] D -->|Missing| C D -->|Exists| E{Current CLI matches target?} E -->|Yes| C E -->|No| F[Hard Stop with Error]Key Changes
pkg/desktop/package - Types, marker file reading, and validation logicPersistentPreRunEhook validates desktop alignment before every commandTOOLHIVE_SKIP_DESKTOP_CHECK=1bypasses validation for debuggingScenarios Handled
Related