Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion application/di/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"github.com/snyk/snyk-ls/domain/ide/treeview"
"github.com/snyk/snyk-ls/domain/ide/workspace"
"github.com/snyk/snyk-ls/domain/snyk"
"github.com/snyk/snyk-ls/domain/snyk/remediation"
scanner2 "github.com/snyk/snyk-ls/domain/snyk/scanner"
"github.com/snyk/snyk-ls/infrastructure/authentication"
"github.com/snyk/snyk-ls/infrastructure/cli"
Expand Down Expand Up @@ -227,10 +228,26 @@ func initApplication(conf configuration.Configuration, engine workflow.Engine, l
w := workspace.New(conf, logger, instrumentor, scanner, hoverService, scanNotifier, notifier, scanPersister, scanStateAggregator, featureFlagService, configResolver, engine) // don't use getters or it'll deadlock
config.SetWorkspace(conf, w)
fileWatcher = watcher.NewFileWatcher()
codeActionService = codeaction.NewService(engine, w, fileWatcher, notifier, featureFlagService, configResolver, nil)

var remediationProvider remediation.RemediationProvider
if conf.GetBool(remediationAgentEnabledKey) {
lp := engine.GetLogger().With().Str("provider", "remy").Logger()
remediationProvider = remediation.NewRemyProvider(remediation.RemyOptions{
CliPath: config.GetCliPath(conf),
Logger: &lp,
}, nil)
}

codeActionService = codeaction.NewService(engine, w, fileWatcher, notifier, featureFlagService, configResolver, remediationProvider)
command.SetService(command.NewService(engine, logger, authenticationService, featureFlagService, notifier, learnService, w, snykCodeScanner, snykCli, ldxSyncService, configResolver, scanStateAggregator.StateSnapshot))
}

// remediationAgentEnabledKey is the configuration key that gates the remy-backed
// remediation provider. The feature ships off by default; set this key to true
// only when the host CLI bundles the remy subcommand and an LLM API key is
// available.
const remediationAgentEnabledKey = "remediation_agent_enabled"

/*
TODO Accessors: This should go away, since all dependencies should be satisfied at startup-time, if needed for testing
they can be returned by the test helper for unit/integration tests
Expand Down
4 changes: 4 additions & 0 deletions domain/snyk/remediation/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ type RemediationRequest struct {

// RemediationProvider computes an autonomous fix for a single finding.
// Returns nil when no fix can be computed; callers treat nil as "no fix available".
//
// Isolation contract: implementations may mutate ContentRoot in place.
// Callers must supply an isolated copy of the workspace (e.g. a git worktree)
// as ContentRoot and are responsible for post-fix verification and rollback.
type RemediationProvider interface {
Remediate(ctx context.Context, req RemediationRequest) (*types.WorkspaceEdit, error)
}
Loading
Loading