Skip to content
Merged
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
2 changes: 2 additions & 0 deletions deployment/config/rag-pipeline/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ OPENROUTER_MODEL=qwen/qwen3-embedding-8b
#================================================================================================
#================================================================================================

# QDRANT_VECTORS_ON_DISK=true

## === Path Traversal Guard ===
## Root directory that repo_path arguments are allowed under.
## The rag-pipeline will reject any index/query request whose resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public interface AiAnalysisRequest {

boolean getUseLocalMcp();

boolean getUseMcpTools();

AnalysisType getAnalysisType();

String getVcsProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class AiAnalysisRequestImpl implements AiAnalysisRequest {
protected final int maxAllowedTokens;
protected final List<AiRequestPreviousIssueDTO> previousCodeAnalysisIssues;
protected final boolean useLocalMcp;
protected final boolean useMcpTools;
protected final AnalysisType analysisType;
protected final String prTitle;
protected final String prDescription;
Expand Down Expand Up @@ -67,6 +68,7 @@ protected AiAnalysisRequestImpl(Builder<?> builder) {
this.maxAllowedTokens = builder.maxAllowedTokens;
this.previousCodeAnalysisIssues = builder.previousCodeAnalysisIssues;
this.useLocalMcp = builder.useLocalMcp;
this.useMcpTools = builder.useMcpTools;
this.analysisType = builder.analysisType;
this.prTitle = builder.prTitle;
this.prDescription = builder.prDescription;
Expand Down Expand Up @@ -229,6 +231,7 @@ public static class Builder<T extends Builder<T>> {
private int maxAllowedTokens;
private List<AiRequestPreviousIssueDTO> previousCodeAnalysisIssues;
private boolean useLocalMcp;
private boolean useMcpTools;
private AnalysisType analysisType;
private String prTitle;
private String prDescription;
Expand Down Expand Up @@ -431,6 +434,11 @@ public T withUseLocalMcp(boolean useLocalMcp) {
return self();
}

public T withUseMcpTools(boolean useMcpTools) {
this.useMcpTools = useMcpTools;
return self();
}

public T withAnalysisType(AnalysisType analysisType) {
this.analysisType = analysisType;
return self();
Expand Down Expand Up @@ -520,4 +528,9 @@ public AiAnalysisRequestImpl build() {
public boolean getUseLocalMcp() {
return useLocalMcp;
}

@Override
public boolean getUseMcpTools() {
return useMcpTools;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public record ProjectDTO(
Long aiConnectionId,
String namespace,
String mainBranch,
String defaultBranch, // Deprecated: use mainBranch. Kept for backward compatibility.
String defaultBranch, // Deprecated: use mainBranch. Kept for backward compatibility.
Long defaultBranchId,
DefaultBranchStats defaultBranchStats,
RagConfigDTO ragConfig,
Expand All @@ -35,16 +35,17 @@ public record ProjectDTO(
Boolean webhooksConfigured,
Long qualityGateId,
Integer maxAnalysisTokenLimit,
ProjectRulesConfigDTO projectRulesConfig
) {
Boolean useMcpTools,
ProjectRulesConfigDTO projectRulesConfig) {
public static ProjectDTO fromProject(Project project) {
Long vcsConnectionId = null;
String vcsConnectionType = null;
String vcsProvider = null;
String vcsWorkspace = null;
String repoSlug = null;

// Use unified method to get VCS info (prefers VcsRepoBinding over legacy vcsBinding)

// Use unified method to get VCS info (prefers VcsRepoBinding over legacy
// vcsBinding)
VcsRepoInfo vcsInfo = project.getEffectiveVcsRepoInfo();
if (vcsInfo != null) {
VcsConnection conn = vcsInfo.getVcsConnection();
Expand Down Expand Up @@ -80,8 +81,7 @@ public static ProjectDTO fromProject(Project project) {
branch.getHighSeverityCount(),
branch.getMediumSeverityCount(),
branch.getLowSeverityCount(),
branch.getResolvedCount()
);
branch.getResolvedCount());
}

String mainBranch = null;
Expand All @@ -90,21 +90,21 @@ public static ProjectDTO fromProject(Project project) {
Boolean prAnalysisEnabled = project.isPrAnalysisEnabled();
Boolean branchAnalysisEnabled = project.isBranchAnalysisEnabled();
String installationMethod = null;

Boolean useMcpTools = false;

ProjectConfig config = project.getConfiguration();
if (config != null) {
mainBranch = config.mainBranch();

if (config.ragConfig() != null) {
RagConfig rc = config.ragConfig();
ragConfigDTO = new RagConfigDTO(
rc.enabled(),
rc.branch(),
rc.enabled(),
rc.branch(),
rc.includePatterns(),
rc.excludePatterns(),
rc.multiBranchEnabled(),
rc.branchRetentionDays()
);
rc.branchRetentionDays());
}
if (config.prAnalysisEnabled() != null) {
prAnalysisEnabled = config.prAnalysisEnabled();
Expand All @@ -115,8 +115,9 @@ public static ProjectDTO fromProject(Project project) {
if (config.installationMethod() != null) {
installationMethod = config.installationMethod().name();
}
useMcpTools = config.useMcpTools();
}

CommentCommandsConfigDTO commentCommandsConfigDTO = null;
if (config != null) {
commentCommandsConfigDTO = CommentCommandsConfigDTO.fromConfig(config.getCommentCommandsConfig());
Expand All @@ -127,9 +128,10 @@ public static ProjectDTO fromProject(Project project) {
if (project.getVcsRepoBinding() != null) {
webhooksConfigured = project.getVcsRepoBinding().isWebhooksConfigured();
}

// Get maxAnalysisTokenLimit from config
Integer maxAnalysisTokenLimit = config != null ? config.maxAnalysisTokenLimit() : ProjectConfig.DEFAULT_MAX_ANALYSIS_TOKEN_LIMIT;
Integer maxAnalysisTokenLimit = config != null ? config.maxAnalysisTokenLimit()
: ProjectConfig.DEFAULT_MAX_ANALYSIS_TOKEN_LIMIT;

// Get project rules config
ProjectRulesConfigDTO projectRulesConfigDTO = null;
Expand Down Expand Up @@ -161,8 +163,8 @@ public static ProjectDTO fromProject(Project project) {
webhooksConfigured,
project.getQualityGate() != null ? project.getQualityGate().getId() : null,
maxAnalysisTokenLimit,
projectRulesConfigDTO
);
useMcpTools,
projectRulesConfigDTO);
}

public record DefaultBranchStats(
Expand All @@ -171,8 +173,7 @@ public record DefaultBranchStats(
int highSeverityCount,
int mediumSeverityCount,
int lowSeverityCount,
int resolvedCount
) {
int resolvedCount) {
}

public record RagConfigDTO(
Expand All @@ -181,41 +182,39 @@ public record RagConfigDTO(
java.util.List<String> includePatterns,
java.util.List<String> excludePatterns,
Boolean multiBranchEnabled,
Integer branchRetentionDays
) {
Integer branchRetentionDays) {
/**
* Backward-compatible constructor without include patterns and multi-branch fields.
* Backward-compatible constructor without include patterns and multi-branch
* fields.
*/
public RagConfigDTO(boolean enabled, String branch, java.util.List<String> excludePatterns) {
this(enabled, branch, null, excludePatterns, null, null);
}
}

public record CommentCommandsConfigDTO(
boolean enabled,
Integer rateLimit,
Integer rateLimitWindowMinutes,
Boolean allowPublicRepoCommands,
List<String> allowedCommands,
String authorizationMode,
Boolean allowPrAuthor
) {
Boolean allowPrAuthor) {
public static CommentCommandsConfigDTO fromConfig(CommentCommandsConfig config) {
if (config == null) {
return new CommentCommandsConfigDTO(false, null, null, null, null, null, null);
}
String authMode = config.authorizationMode() != null
? config.authorizationMode().name()
: CommentCommandsConfig.DEFAULT_AUTHORIZATION_MODE.name();
String authMode = config.authorizationMode() != null
? config.authorizationMode().name()
: CommentCommandsConfig.DEFAULT_AUTHORIZATION_MODE.name();
return new CommentCommandsConfigDTO(
config.enabled(),
config.rateLimit(),
config.rateLimitWindowMinutes(),
config.allowPublicRepoCommands(),
config.allowedCommands(),
authMode,
config.allowPrAuthor()
);
config.allowPrAuthor());
}
}

Expand Down
Loading