[REL-13574] Implement SDK detection and installation#709
Open
dakotasanchez wants to merge 10 commits into
Open
[REL-13574] Implement SDK detection and installation#709dakotasanchez wants to merge 10 commits into
dakotasanchez wants to merge 10 commits into
Conversation
ari-launchdarkly
requested changes
May 13, 2026
Contributor
ari-launchdarkly
left a comment
There was a problem hiding this comment.
This is really great work. I've got questions around whether we can make this a little more deterministic around some of the edges if we're leaning away from an agent to determine some of the dependencies. If it's not abundantly obvious for us, we can also punt on that
71c2501 to
2e055cf
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default mode and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f60f9d1. Configure here.
Co-authored-by: ari-launchdarkly <asalem@launchdarkly.com>
Co-authored-by: ari-launchdarkly <asalem@launchdarkly.com>
Co-authored-by: ari-launchdarkly <asalem@launchdarkly.com>
Co-authored-by: ari-launchdarkly <asalem@launchdarkly.com>
f60f9d1 to
d3d26dc
Compare
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
Implements the
DetectorandInstallerinterfaces that were stubbed in the base branch, wiring up real filesystem-based SDK detection and package-manager-based installation into theldcli setupwizard and hidden subcommands.FileDetector— scans the working directory for project indicators and returns language, framework, package manager, recommended SDK ID, and entry point filePackageInstaller— maps SDK IDs to their install commands and shells out to the appropriate package managerAPIClientsgainsDetectorandInstallerfields for test injection, withFileDetector/PackageInstalleras production defaultsinstall.gooutput:Package: pkg@versionwas printing a trailing@whenVersionis emptycmd/root.goimport ordering (gofmt)com.launchdarkly:launchdarkly-java-server-sdketc.) rather than the raw SDK IDHow SDK Detection and Installation Work
Detection (
FileDetector)FileDetector.Detect(dir)runs four probes in priority order against the project directory:package.jsonand inspectsdependencies+devDependencies:next→node-serverSDK, framework = "Next.js"react→react-client-sdk, framework = "React"node-server(plain Node)pnpm-lock.yaml→ pnpm,yarn.lock→ yarn, default → npmgo.mod→go-server-sdkrequirements.txt,pyproject.toml, orsetup.py→python-server-sdkpom.xml(→ mvn) orbuild.gradle/build.gradle.kts(→ gradle) →java-server-sdkIf nothing matches, returns an error; the wizard surfaces it and halts.
Entry point detection walks a prioritized candidate list per SDK (e.g. for React:
src/App.tsx→src/App.jsx→src/index.tsx→ ... →index.js) and returns the first path that exists on disk, or the last candidate as a suggested path if none do. The returned path is absolute and passed directly toInitializer.InjectIntoFile.Installation (
PackageInstaller)PackageInstaller.Install(dir, detectResult)callsInstallArgs(sdkID, packageManager)which maps each SDK to its install command:react-client-sdknpm/yarn/pnpm install launchdarkly-react-client-sdknode-servernpm/yarn/pnpm install @launchdarkly/node-server-sdkpython-server-sdkpip install launchdarkly-server-sdkgo-server-sdkgo get github.com/launchdarkly/go-server-sdk/v7ruby-server-sdkgem install launchdarkly-server-sdkdotnet-server-sdkdotnet add package LaunchDarkly.ServerSdkSuccess: false, no errorFor SDKs with a command, it shells out via
exec.Commandin the project directory and captures combined output. A non-zero exit wraps the error and output into the returned error. For SDKs without a command, it returnsSuccess: falsewith no error so the wizard proceeds (the user still needs to add the dependency manually, but flag creation and code injection remain valid).Wizard Integration
detectResult.SDKIDflows into both the installer (command selection) and the initializer (template selection).detectResult.EntryPointis passed directly toInjectIntoFile. All five SDKs the detector can return have init templates, so thestepWaitForAppfile path display is always valid.Test plan
go build ./...passesgo test ./internal/setup/...— 26 tests covering all detection scenarios, package managers, entry point fallback,firstExistingInedge cases,InstallArgsfor all SDK types, andPackageInstallerwith mock runnergo test ./cmd/setup/...— detect error/success/JSON, install error/success/JSON/version pathsgo test ./...— all 28 packages passgofmtclean on all changed filesgolangci-lint— no new issues introduced (6 pre-existingerrcheckfindings in ari's files)ldcli setup detect --path /path/to/react/projectreturns language/framework/SDK infoldcli setup detect --path /tmp/emptyreturns "could not detect" errorldcli setup install --sdk-id node-serverrunsnpm install @launchdarkly/node-server-sdkldcli setup install --sdk-id java-server-sdkreturnsSuccess: falsewith packagecom.launchdarkly:launchdarkly-java-server-sdkRequirements
Note
Medium Risk
Adds real project detection and shells out to system package managers during
ldcli setup, which can affect local environments and introduces platform/command-failure edge cases. Wizard flow changes also alter user interaction and error handling paths.Overview
ldcli setupnow uses real implementations for SDK detection and installation:internal/setup.FileDetectorinfers language/framework/package manager/entry point from project files, andinternal/setup.PackageInstallermaps SDK IDs to package-manager commands and executes them (with manual-install SDKs returningSuccess=falseplus meaningful package identifiers).The setup wizard flow is updated to include an explicit SDK selection step (prioritizing detected SDK, falling back when detection fails) and to deep-link the final “toggle your flag” URL. Initialization handling is tightened by correctly mapping
android-client-sdkand by merging Go imports via AST rewriting to avoid breakingpackagedeclarations.CLI wiring and output are adjusted:
cmd.APIClientsgains injectableDetector/Installerwith production defaults,setup installno longer prints a trailing@when no version is present, and extensive new tests cover detection/install behavior and wizard transitions.Reviewed by Cursor Bugbot for commit 32f1834. Bugbot is set up for automated code reviews on this repo. Configure here.