├── .husky └── pre-push ├── .nvmrc ├── packages ├── kodus-flow │ ├── .nvmrc │ ├── src │ │ ├── adapters │ │ │ ├── index.ts │ │ │ └── llm │ │ │ │ └── index.ts │ │ ├── orchestration │ │ │ └── index.ts │ │ ├── context │ │ │ ├── core │ │ │ │ ├── runtime.ts │ │ │ │ ├── utils │ │ │ │ │ └── budget.ts │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ ├── observability │ │ │ └── core │ │ │ │ └── index.ts │ │ ├── core │ │ │ ├── memory │ │ │ │ └── index.ts │ │ │ └── storage │ │ │ │ └── index.ts │ │ ├── utils │ │ │ └── index.ts │ │ ├── kernel │ │ │ └── index.ts │ │ ├── runtime │ │ │ └── middleware │ │ │ │ └── index.ts │ │ └── engine │ │ │ ├── strategies │ │ │ └── prompts │ │ │ │ └── index.ts │ │ │ └── index.ts │ ├── .prettierrc │ ├── .cursor │ │ └── rules │ │ │ └── kodyflow.mdc │ ├── tsconfig.examples.json │ ├── .editorconfig │ ├── tsconfig.vitest.json │ ├── env.example │ ├── .prettierignore │ ├── tests │ │ └── observability │ │ │ └── presets.unit.test.ts │ ├── .env.example │ └── .gitignore └── kodus-common │ ├── src │ ├── interfaces │ │ ├── clonable.ts │ │ └── index.ts │ ├── types │ │ ├── index.ts │ │ └── organization-team-data.ts │ ├── utils │ │ ├── index.ts │ │ └── error │ │ │ └── index.ts │ └── llm │ │ ├── index.ts │ │ └── providerAdapters │ │ ├── jsonMode.ts │ │ ├── modelTypes.ts │ │ └── types.ts │ ├── .gitignore │ ├── .prettierrc │ ├── .npmignore │ ├── barrelsby.json │ ├── tsconfig.build.json │ ├── .npmrc │ ├── .npmrc.bak │ ├── README.md │ └── .env.example ├── src ├── shared │ ├── scriptsDemo │ │ └── teamMetrics │ │ │ ├── leadTimeByItemType.sql │ │ │ └── leadTimeInWipByItemType.sql │ ├── interfaces │ │ ├── enrich-suggestions-review.interface.ts │ │ ├── kody-ast-analyze-context-preparation.interface.ts │ │ └── file-review-context-preparation.interface.ts │ ├── domain │ │ ├── json.ts │ │ ├── enums │ │ │ ├── agent-execute-type.enum.ts │ │ │ ├── team-methodology.enum.ts │ │ │ ├── automations-level.enum.ts │ │ │ ├── communication-style.enum.ts │ │ │ ├── jira-columns.enum.ts │ │ │ ├── github-installation-status.enum.ts │ │ │ ├── metric-category.enum.ts │ │ │ ├── artifacts-tool-type.enum.ts │ │ │ ├── metrics-variation-status.enum.ts │ │ │ ├── timezones.enum.ts │ │ │ ├── automations.enum.ts │ │ │ ├── global-parameters-key.enum.ts │ │ │ ├── auth-provider.enum.ts │ │ │ ├── board-priority-type.enum.ts │ │ │ ├── create-auth-integration-status.enum.ts │ │ │ ├── integration-category.enum.ts │ │ │ ├── programming-language.enum.ts │ │ │ ├── verify-communication-connection-type.enum.ts │ │ │ ├── status-category-jira.enum.ts │ │ │ ├── good-practice-type.enum.ts │ │ │ ├── status-category-azure-boards.enum.ts │ │ │ ├── platform-type.enum.ts │ │ │ ├── parameters-key.enum.ts │ │ │ ├── organization-parameters-key.enum.ts │ │ │ └── pullRequestState.enum.ts │ │ ├── interfaces │ │ │ ├── entity.ts │ │ │ ├── use-case.interface.ts │ │ │ └── data-point.interface.ts │ │ └── contracts │ │ │ ├── execute.automation.service.contracts.ts │ │ │ ├── getAdditionalInfo.helper.contract.ts │ │ │ └── message-broker.service.contracts.ts │ ├── infrastructure │ │ ├── repositories │ │ │ └── model │ │ │ │ ├── mongodb │ │ │ │ └── index.ts │ │ │ │ └── typeOrm │ │ │ │ └── index.ts │ │ ├── filters │ │ │ ├── configuration-missing.exception.ts │ │ │ ├── duplicate-record.exception.ts │ │ │ └── repository-with-directories.exception.ts │ │ └── interceptors │ │ │ └── timeout.interceptor.ts │ └── utils │ │ ├── enums │ │ ├── repositoryTree.enum.ts │ │ ├── severityLevel.enum.ts │ │ └── severityMatrix.enum.ts │ │ ├── langchainCommon │ │ ├── prompts │ │ │ ├── genericAgent.ts │ │ │ ├── codeBaseConversation.ts │ │ │ ├── kodyRulesRecommendation.ts │ │ │ ├── configuration │ │ │ │ └── predictDeployType │ │ │ │ │ ├── getProductionReleases.ts │ │ │ │ │ └── getProductionWorkflows.ts │ │ │ ├── rewriteArtifactsForCheckin.ts │ │ │ └── projectInsights.ts │ │ └── customStringOutputParser.ts │ │ ├── index.ts │ │ ├── codeManagement │ │ └── codeReviewBadge.ts │ │ ├── getTypes.ts │ │ ├── safelyParseMessageContent.ts │ │ ├── decorators │ │ └── integration-service.decorator.ts │ │ ├── buffer │ │ └── arrays.ts │ │ ├── polling │ │ └── index.ts │ │ ├── formatters │ │ ├── leadTime.ts │ │ └── leadTimeForChange.ts │ │ ├── helpers │ │ └── rankScore.helper.ts │ │ ├── benchmark.util.ts │ │ ├── kody-rules │ │ └── file-patterns.ts │ │ └── googleGenAI.ts ├── ee │ ├── codeReview │ │ └── enrichesSuggestionsReview │ │ │ ├── enrich-suggestions-review.module.ts │ │ │ └── enrich-suggestions-review.service.ts │ ├── configs │ │ └── environment │ │ │ ├── types.ts │ │ │ ├── environment.template.ts │ │ │ └── environment.dev.ts │ ├── kodyRules │ │ └── kody-rules-validation.module.ts │ ├── shared │ │ └── permission-validation.module.ts │ └── codeReviewSettingsLog │ │ ├── domain │ │ └── codeReviewSettingsLog │ │ │ ├── contracts │ │ │ └── codeReviewSettingsLog.repository.contract.ts │ │ │ └── interfaces │ │ │ └── codeReviewSettingsLog.interface.ts │ │ └── types │ │ └── logParams.types.ts ├── core │ ├── infrastructure │ │ ├── adapters │ │ │ ├── mcp │ │ │ │ ├── utils │ │ │ │ │ └── index.ts │ │ │ │ ├── tools │ │ │ │ │ └── index.ts │ │ │ │ └── guards │ │ │ │ │ └── mcp-enabled.guard.ts │ │ │ ├── services │ │ │ │ ├── pipeline │ │ │ │ │ └── interfaces │ │ │ │ │ │ ├── pipeline.interface.ts │ │ │ │ │ │ ├── pipeline-strategy.interface.ts │ │ │ │ │ │ └── pipeline-context.interface.ts │ │ │ │ ├── codeBase │ │ │ │ │ └── codeReviewPipeline │ │ │ │ │ │ └── stages │ │ │ │ │ │ └── contracts │ │ │ │ │ │ └── loadExternalContextStage.contract.ts │ │ │ │ ├── bcrypt.service.ts │ │ │ │ └── platformIntegration │ │ │ │ │ └── platformIntegration.factory.ts │ │ │ └── repositories │ │ │ │ ├── mongoose │ │ │ │ └── schema │ │ │ │ │ ├── kodyRules.model.ts │ │ │ │ │ ├── observabilityTelemetry.model.ts │ │ │ │ │ └── dryRun.model.ts │ │ │ │ └── typeorm │ │ │ │ └── schema │ │ │ │ ├── global-parameters.model.ts │ │ │ │ ├── permissions.model.ts │ │ │ │ └── profileConfig.model.ts │ │ └── http │ │ │ ├── dtos │ │ │ ├── jira.dto.ts │ │ │ ├── github.dto.ts │ │ │ ├── platformIntegration │ │ │ │ └── integration-common.dto.ts │ │ │ ├── profile.dto.ts │ │ │ ├── integration-slack.dto.ts │ │ │ ├── teamId-query-dto.ts │ │ │ ├── organizationId-query.dto.ts │ │ │ ├── update-conversation-dto.ts │ │ │ ├── update-team.dto.ts │ │ │ ├── create-team.dto.ts │ │ │ ├── find-suggestions-by-rule.dto.ts │ │ │ ├── join-organization.dto.ts │ │ │ ├── platform-type.dto.ts │ │ │ ├── update-conversation-title-dto.ts │ │ │ ├── create-conversation.dto.ts │ │ │ ├── update-pull-request.dto.ts │ │ │ ├── execute-dry-run.dto.ts │ │ │ ├── organizationAndTeamData.dto.ts │ │ │ ├── delete-repository-code-review-parameter.dto.ts │ │ │ ├── review-fast-kody-rules.dto.ts │ │ │ ├── find-recommended-kody-rules.dto.ts │ │ │ ├── create-user.dto.ts │ │ │ ├── webhook-status-query.dto.ts │ │ │ ├── change-status-kody-rules.dto.ts │ │ │ ├── set-rule-feedback.dto.ts │ │ │ ├── copy-code-review-parameter.dto.ts │ │ │ ├── updateInfoOrgAndPhone.dto.ts │ │ │ ├── update-another-user.dto.ts │ │ │ ├── paginated-library-kody-rules.dto.ts │ │ │ ├── finish-onboarding.dto.ts │ │ │ ├── backfill-prs.dto.ts │ │ │ ├── create-user-organization-oauth.dto.ts │ │ │ ├── paginated-enriched-pull-requests.dto.ts │ │ │ ├── generate-kody-rules.dto.ts │ │ │ ├── apply-code-review-preset.dto.ts │ │ │ ├── get-repository-tree.dto.ts │ │ │ ├── automation-run.dto.ts │ │ │ ├── update.dto.ts │ │ │ ├── execute-router.dto.ts │ │ │ ├── user-status-change.dto.ts │ │ │ ├── pagination.dto.ts │ │ │ ├── accept-user-invitation.dto.ts │ │ │ ├── pull-request-messages.dto.ts │ │ │ ├── generate-code-review-parameter.dto.ts │ │ │ ├── create-user-organization.dto.ts │ │ │ ├── preview-pr-summary.dto.ts │ │ │ ├── token-usage.dto.ts │ │ │ └── onboarding-review-mode-signals-query.dto.ts │ │ │ └── controllers │ │ │ ├── segment.controller.ts │ │ │ └── team.controller.ts │ ├── application │ │ └── use-cases │ │ │ ├── organizationParameters │ │ │ ├── index.ts │ │ │ └── delete-byok-config.use-case.ts │ │ │ ├── segment │ │ │ ├── index.ts │ │ │ └── track.use-case.ts │ │ │ ├── platformIntegration │ │ │ └── index.ts │ │ │ ├── ssoConfig │ │ │ └── index.ts │ │ │ ├── profile │ │ │ ├── index.ts │ │ │ └── update.use-case.ts │ │ │ ├── rule-like │ │ │ └── index.ts │ │ │ ├── codeReviewFeedback │ │ │ └── index.ts │ │ │ ├── github │ │ │ ├── index.ts │ │ │ └── get-integration-github.ts │ │ │ ├── agent │ │ │ └── index.ts │ │ │ ├── team │ │ │ └── index.ts │ │ │ ├── usage │ │ │ └── index.ts │ │ │ ├── teamMembers │ │ │ └── index.ts │ │ │ ├── pullRequests │ │ │ └── index.ts │ │ │ ├── permissions │ │ │ └── index.ts │ │ │ ├── dryRun │ │ │ └── index.ts │ │ │ ├── organization │ │ │ └── index.ts │ │ │ ├── issues │ │ │ └── index.ts │ │ │ ├── pullRequestMessages │ │ │ └── index.ts │ │ │ ├── integrations │ │ │ ├── get-organization-id.use-case.ts │ │ │ └── index.ts │ │ │ ├── auth │ │ │ ├── logout.use-case.ts │ │ │ └── refresh-toke.use-case.ts │ │ │ ├── teamAutomation │ │ │ └── index.ts │ │ │ ├── user │ │ │ ├── index.ts │ │ │ └── delete.use-case.ts │ │ │ └── parameters │ │ │ └── get-default-config.use-case.ts │ └── domain │ │ ├── agents │ │ ├── interfaces │ │ │ └── toolResult.interface.ts │ │ └── types │ │ │ └── auth-details-params.type.ts │ │ ├── profileConfigs │ │ ├── enum │ │ │ └── profileConfigKey.enum.ts │ │ ├── interfaces │ │ │ └── profileConfig.interface.ts │ │ └── contracts │ │ │ └── profileConfig.repository.contract.ts │ │ ├── platformIntegrations │ │ ├── enums │ │ │ └── codeManagement │ │ │ │ └── authMode.enum.ts │ │ ├── types │ │ │ └── codeManagement │ │ │ │ ├── workflow.type.ts │ │ │ │ ├── organization.type.ts │ │ │ │ ├── deployFrequency.type.ts │ │ │ │ ├── repositoryFile.type.ts │ │ │ │ ├── commitLeadTimeForChange.type.ts │ │ │ │ ├── gitCloneParams.type.ts │ │ │ │ └── repositories.type.ts │ │ └── interfaces │ │ │ └── common.interface.ts │ │ ├── authIntegrations │ │ ├── types │ │ │ ├── teams-auth.detail.type.ts │ │ │ ├── azure-repos-auth-detail.ts │ │ │ ├── bitbucket-auth-detail.type.ts │ │ │ ├── slack-auth-detail.type.ts │ │ │ ├── gitlab-auth-detail.type.ts │ │ │ ├── jira-auth-details.ts │ │ │ └── github-auth-detail.type.ts │ │ ├── contracts │ │ │ └── auth-integration.service.contracts.ts │ │ └── interfaces │ │ │ └── auth-integration.interface.ts │ │ ├── kodyFineTuning │ │ ├── enums │ │ │ ├── fineTuningType.enum.ts │ │ │ ├── fineTuningDecision.enum.ts │ │ │ └── feedbackType.enum.ts │ │ └── suggestionEmbedded │ │ │ └── interfaces │ │ │ └── suggestionEmbedded.interface.ts │ │ ├── teamMembers │ │ ├── enums │ │ │ └── teamMemberRole.enum.ts │ │ └── interfaces │ │ │ ├── projectManagementMemberConfig.ts │ │ │ ├── codeManagementMemberConfig.interface.ts │ │ │ └── communicationMemberConfig.interface.ts │ │ ├── pullRequests │ │ ├── interfaces │ │ │ └── authorContributor.interface.ts │ │ └── enums │ │ │ ├── deliveryStatus.enum.ts │ │ │ ├── implementationStatus.enum.ts │ │ │ └── priorityStatus.enum.ts │ │ ├── codeReviewExecutions │ │ ├── enum │ │ │ └── codeReviewExecution.enum.ts │ │ ├── interfaces │ │ │ └── codeReviewExecution.interface.ts │ │ └── contracts │ │ │ └── codeReviewExecution.service.contract.ts │ │ ├── integrationConfigs │ │ ├── enums │ │ │ ├── moduleWorkItemTypes.enum.ts │ │ │ └── stringTimeInterval.enum.ts │ │ ├── types │ │ │ └── codeManagement │ │ │ │ └── repositories.type.ts │ │ └── interfaces │ │ │ └── integration-config.interface.ts │ │ ├── codeBase │ │ └── contracts │ │ │ ├── CodeReviewService.contract.ts │ │ │ ├── SecurityAnalysisService.contract.ts │ │ │ ├── LintingService.contract.ts │ │ │ └── KodyRulesAnalysisService.contract.ts │ │ ├── automation │ │ ├── contracts │ │ │ ├── automation-dailycheckin.service.ts │ │ │ ├── automation_weeklyCheckin.service.ts │ │ │ ├── memory.service.ts │ │ │ ├── automation-executiveCheckin.service.ts │ │ │ ├── automation.service.ts │ │ │ ├── adapters │ │ │ │ └── communication.adapter.ts │ │ │ ├── processAutomation │ │ │ │ ├── automation.factory.ts │ │ │ │ └── automation.strategy.ts │ │ │ ├── team-automation.service.ts │ │ │ ├── session.service.contracts.ts │ │ │ ├── memory.repository.ts │ │ │ ├── session.repository.contracts.ts │ │ │ ├── team-automation.repository.ts │ │ │ └── automation.repository.ts │ │ ├── interfaces │ │ │ ├── session.interface.ts │ │ │ ├── memory.interface.ts │ │ │ ├── team-automation.interface.ts │ │ │ ├── automation.interface.ts │ │ │ └── automation-execution.interface.ts │ │ └── entities │ │ │ └── memory.entity.ts │ │ ├── issues │ │ ├── contracts │ │ │ └── issues.service.contract.ts │ │ └── entities │ │ │ └── issue-creation-config.entity.ts │ │ ├── auth │ │ ├── contracts │ │ │ ├── ssoConfig.service.contract.ts │ │ │ └── auth.repository.contracts.ts │ │ └── interfaces │ │ │ └── auth.interface.ts │ │ ├── azureRepos │ │ ├── entities │ │ │ ├── azureReposProject.type.ts │ │ │ └── azureReposRepository.type.ts │ │ └── contracts │ │ │ └── azure-repos.service.contract.ts │ │ ├── tokenUsage │ │ └── contracts │ │ │ ├── tokenUsage.service.contract.ts │ │ │ └── tokenUsage.repository.contract.ts │ │ ├── global-parameters │ │ ├── interfaces │ │ │ └── global-parameters.interface.ts │ │ └── contracts │ │ │ └── global-parameters.service.contract.ts │ │ ├── user │ │ ├── contracts │ │ │ ├── password.service.contract.ts │ │ │ └── user.service.contract.ts │ │ └── interfaces │ │ │ └── user.interface.ts │ │ ├── permissions │ │ ├── contracts │ │ │ ├── permissions.service.contract.ts │ │ │ └── permissions.repository.contract.ts │ │ ├── types │ │ │ ├── permissions.types.ts │ │ │ └── policy.types.ts │ │ └── enums │ │ │ └── permissions.enum.ts │ │ ├── msTeams │ │ └── msTeams.service.contract.ts │ │ ├── interactions │ │ ├── contracts │ │ │ ├── interaction.service.contracts.ts │ │ │ └── interaction.repository.contracts.ts │ │ └── interfaces │ │ │ └── interactions-execution.interface.ts │ │ ├── profile │ │ ├── interfaces │ │ │ └── profile.interface.ts │ │ └── contracts │ │ │ ├── profile.service.contract.ts │ │ │ └── profile.repository.contract.ts │ │ ├── organizationParameters │ │ ├── types │ │ │ └── organizationParameters.types.ts │ │ └── interfaces │ │ │ └── organizationParameters.interface.ts │ │ ├── bitbucket │ │ └── contracts │ │ │ └── bitbucket.service.contract.ts │ │ ├── pullRequestMessages │ │ ├── contracts │ │ │ └── pullRequestMessages.service.contract.ts │ │ └── interfaces │ │ │ └── pullRequestMessages.interface.ts │ │ ├── webhookLog │ │ ├── interfaces │ │ │ └── webhook-log.interface.ts │ │ └── contracts │ │ │ └── webhook-log.service.contract.ts │ │ ├── log │ │ ├── contracts │ │ │ ├── log.service.contracts.ts │ │ │ └── log.repository.contracts.ts │ │ └── interfaces │ │ │ └── log.interface.ts │ │ ├── organization │ │ ├── interfaces │ │ │ └── organization.interface.ts │ │ └── contracts │ │ │ └── organization.service.contract.ts │ │ ├── parameters │ │ ├── interfaces │ │ │ └── parameters.interface.ts │ │ └── contracts │ │ │ └── parameters.service.contract.ts │ │ ├── codeReviewFeedback │ │ ├── interfaces │ │ │ └── codeReviewFeedback.interface.ts │ │ └── enums │ │ │ └── codeReviewCommentReaction.enum.ts │ │ └── dryRun │ │ └── contracts │ │ └── dryRun.repository.contract.ts ├── config │ ├── types │ │ ├── general │ │ │ ├── json.type.ts │ │ │ ├── issues.type.ts │ │ │ ├── organizationAndTeamData.ts │ │ │ ├── tree.type.ts │ │ │ ├── diagnostic.type.ts │ │ │ ├── dataPoint.type.ts │ │ │ ├── changelog.type.ts │ │ │ ├── selectedCategory.type.ts │ │ │ ├── query-parser.type.ts │ │ │ ├── pullRequestMessages.type.ts │ │ │ └── commit.type.ts │ │ ├── environment │ │ │ ├── environment.type.ts │ │ │ └── rabbitMQ.type.ts │ │ ├── index.ts │ │ ├── database │ │ │ ├── findOptions.type.ts │ │ │ ├── database-connection.type.ts │ │ │ └── status.type.ts │ │ ├── http │ │ │ ├── http-server.type.ts │ │ │ └── user-request.type.ts │ │ ├── jwt │ │ │ └── jwt.ts │ │ └── integrations.type.ts │ ├── schemas │ │ ├── config.schema.ts │ │ └── database.schema.ts │ ├── database │ │ ├── typeorm │ │ │ └── seed │ │ │ │ └── seed.ts │ │ └── mongodb │ │ │ └── mongoose-connection.factory.ts │ ├── loaders │ │ ├── server.loader.ts │ │ ├── environment.loader.ts │ │ ├── rabbitmq.loader.ts │ │ ├── jwt.config.loader.ts │ │ ├── index.ts │ │ ├── mongodb.config.loader.ts │ │ └── postgres.config.loader.ts │ └── index.ts └── modules │ ├── amazonS3.module.ts │ ├── tokenChunking.module.ts │ ├── segment.module.ts │ ├── cache.module.ts │ ├── health.module.ts │ ├── kodyFineTuningContext.module.ts │ └── pipeline.module.ts ├── .cursor └── rules │ └── run.mdc ├── docker-entrypoint-initdb.d └── enable_pgvector.sql ├── . eslintignore ├── .prettierrc ├── test ├── mocks │ └── data │ │ └── bugTypeIdentifier.ts ├── unit │ └── shared │ │ └── utils │ │ └── transforms │ │ └── example.json └── jest-e2e.json ├── tsconfig.build.json ├── tsconfig.spec.json ├── tsconfig.eslint.json ├── .github └── ISSUE_TEMPLATE │ └── config.yml ├── .npmrc ├── nodemon.json ├── docker ├── postgres │ └── Dockerfile ├── prod-entrypoint.sh └── dev-entrypoint.sh ├── .editorconfig ├── nest-cli.json ├── ecosystem.config.js ├── tsconfig-paths-bootstrap.js ├── jest.config.ts ├── license.md ├── docker-compose.qa.yml ├── DockerFiles └── Dockerfile.dev.small ├── .dockerignore ├── docker-compose.prod.yml └── docker-compose.test.yml /.husky/pre-push: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | lts/* 2 | -------------------------------------------------------------------------------- /packages/kodus-flow/.nvmrc: -------------------------------------------------------------------------------- 1 | lts/* 2 | -------------------------------------------------------------------------------- /src/shared/scriptsDemo/teamMetrics/leadTimeByItemType.sql: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/shared/interfaces/enrich-suggestions-review.interface.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/shared/scriptsDemo/teamMetrics/leadTimeInWipByItemType.sql: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ee/codeReview/enrichesSuggestionsReview/enrich-suggestions-review.module.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ee/codeReview/enrichesSuggestionsReview/enrich-suggestions-review.service.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.cursor/rules/run.mdc: -------------------------------------------------------------------------------- 1 | --- 2 | description: 3 | globs: 4 | alwaysApply: true 5 | --- 6 | -------------------------------------------------------------------------------- /docker-entrypoint-initdb.d/enable_pgvector.sql: -------------------------------------------------------------------------------- 1 | CREATE EXTENSION IF NOT EXISTS vector; 2 | -------------------------------------------------------------------------------- /src/core/infrastructure/adapters/mcp/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './mcp-protocol.utils'; 2 | -------------------------------------------------------------------------------- /src/shared/domain/json.ts: -------------------------------------------------------------------------------- 1 | export type Json = { 2 | [key: string]: unknown; 3 | }; 4 | -------------------------------------------------------------------------------- /packages/kodus-flow/src/adapters/index.ts: -------------------------------------------------------------------------------- 1 | export { createMCPAdapter } from './mcp/index.js'; 2 | -------------------------------------------------------------------------------- /src/config/types/general/json.type.ts: -------------------------------------------------------------------------------- 1 | export type Json = { 2 | [key: string]: any; 3 | }; 4 | -------------------------------------------------------------------------------- /src/core/application/use-cases/organizationParameters/index.ts: -------------------------------------------------------------------------------- 1 | export const UseCases = [ 2 | ]; 3 | -------------------------------------------------------------------------------- /packages/kodus-common/src/interfaces/clonable.ts: -------------------------------------------------------------------------------- 1 | export interface Clonable { 2 | clone(): T; 3 | } 4 | -------------------------------------------------------------------------------- /packages/kodus-common/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | tsconfig.tsbuildinfo 4 | tsconfig.build.tsbuildinfo 5 | -------------------------------------------------------------------------------- /src/config/types/environment/environment.type.ts: -------------------------------------------------------------------------------- 1 | export type EnvironmentConfig = { 2 | nodeEnv: string; 3 | }; 4 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/jira.dto.ts: -------------------------------------------------------------------------------- 1 | export interface JiraAccessTokenDTO { 2 | code: string; 3 | } 4 | -------------------------------------------------------------------------------- /packages/kodus-common/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all", 4 | "tabWidth": 4 5 | } 6 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/github.dto.ts: -------------------------------------------------------------------------------- 1 | export interface GithubAccessTokenDTO { 2 | code: string; 3 | } 4 | -------------------------------------------------------------------------------- /packages/kodus-flow/src/orchestration/index.ts: -------------------------------------------------------------------------------- 1 | export { createOrchestration, SDKOrchestrator } from './sdk-orchestrator.js'; 2 | -------------------------------------------------------------------------------- /. eslintignore: -------------------------------------------------------------------------------- 1 | **/tsconfig-paths-bootstrap.js 2 | ee/configs/environment/environment.ts 3 | ee/configs/environment/environment.dev.ts 4 | -------------------------------------------------------------------------------- /packages/kodus-flow/src/context/core/runtime.ts: -------------------------------------------------------------------------------- 1 | export * from './interfaces.js'; 2 | export * from './sandbox/in-process-runtime.js'; 3 | -------------------------------------------------------------------------------- /src/shared/domain/enums/agent-execute-type.enum.ts: -------------------------------------------------------------------------------- 1 | export enum AgentExecutionType { 2 | CODE_REVIEW = 'CodeReviewAgent', 3 | } 4 | -------------------------------------------------------------------------------- /src/shared/domain/interfaces/entity.ts: -------------------------------------------------------------------------------- 1 | export interface Entity { 2 | toObject(): T; 3 | toJson(): T | Partial; 4 | } 5 | -------------------------------------------------------------------------------- /src/shared/domain/enums/team-methodology.enum.ts: -------------------------------------------------------------------------------- 1 | export enum TeamMethodology { 2 | KANBAN = 'kanban', 3 | SCRUM = 'scrum', 4 | } 5 | -------------------------------------------------------------------------------- /packages/kodus-common/.npmignore: -------------------------------------------------------------------------------- 1 | * 2 | 3 | !package.json 4 | !README.md 5 | !LICENSE 6 | !.npmignore 7 | 8 | !dist/ 9 | !dist/** 10 | -------------------------------------------------------------------------------- /src/ee/configs/environment/types.ts: -------------------------------------------------------------------------------- 1 | export interface Environment { 2 | API_CLOUD_MODE: boolean; 3 | API_DEVELOPMENT_MODE: boolean; 4 | } 5 | -------------------------------------------------------------------------------- /src/shared/domain/interfaces/use-case.interface.ts: -------------------------------------------------------------------------------- 1 | export interface IUseCase { 2 | execute(...params: unknown[]): Promise; 3 | } 4 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all", 4 | "tabWidth": 4, 5 | "semi": true, 6 | "quoteProps": "consistent" 7 | } -------------------------------------------------------------------------------- /packages/kodus-common/src/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Automatically generated by barrelsby. 3 | */ 4 | 5 | export * from './clonable'; 6 | -------------------------------------------------------------------------------- /packages/kodus-flow/src/context/index.ts: -------------------------------------------------------------------------------- 1 | export * from './core/index.js'; 2 | export { ContextSandboxHost } from './host/context-sandbox-host.js'; 3 | -------------------------------------------------------------------------------- /src/core/application/use-cases/segment/index.ts: -------------------------------------------------------------------------------- 1 | import { TrackUseCase } from './track.use-case'; 2 | 3 | export const UseCases = [TrackUseCase]; 4 | -------------------------------------------------------------------------------- /src/core/domain/agents/interfaces/toolResult.interface.ts: -------------------------------------------------------------------------------- 1 | export interface IToolResult { 2 | stringResult: string; 3 | jsonResult: any; 4 | } 5 | -------------------------------------------------------------------------------- /src/core/domain/profileConfigs/enum/profileConfigKey.enum.ts: -------------------------------------------------------------------------------- 1 | export enum ProfileConfigKey { 2 | USER_NOTIFICATIONS = 'user_notifications', 3 | } 4 | -------------------------------------------------------------------------------- /src/shared/domain/enums/automations-level.enum.ts: -------------------------------------------------------------------------------- 1 | export enum AutomationLevel { 2 | ORGANIZATION = 'ORGANIZATION', 3 | TEAM = 'TEAM' 4 | } 5 | -------------------------------------------------------------------------------- /packages/kodus-common/barrelsby.json: -------------------------------------------------------------------------------- 1 | { 2 | "directory": ["src/types", "src/llm", "src/utils", "src/interfaces"], 3 | "singleQuotes": true 4 | } 5 | -------------------------------------------------------------------------------- /packages/kodus-common/src/types/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Automatically generated by barrelsby. 3 | */ 4 | 5 | export * from './organization-team-data'; 6 | -------------------------------------------------------------------------------- /src/config/types/general/issues.type.ts: -------------------------------------------------------------------------------- 1 | export enum IssueStatus { 2 | OPEN = 'open', 3 | RESOLVED = 'resolved', 4 | DISMISSED = 'dismissed', 5 | } -------------------------------------------------------------------------------- /src/core/domain/platformIntegrations/enums/codeManagement/authMode.enum.ts: -------------------------------------------------------------------------------- 1 | export enum AuthMode { 2 | OAUTH = 'oauth', 3 | TOKEN = 'token', 4 | } 5 | -------------------------------------------------------------------------------- /src/shared/domain/enums/communication-style.enum.ts: -------------------------------------------------------------------------------- 1 | export enum CommunicationStyle { 2 | CONCISE = 'concise', 3 | PROFESSOR = 'professor', 4 | } 5 | -------------------------------------------------------------------------------- /src/shared/domain/enums/jira-columns.enum.ts: -------------------------------------------------------------------------------- 1 | export enum JIRA_COLUMN_TYPES_ENUM { 2 | TODO = 'todo', 3 | WIP = 'wip', 4 | DONE = 'done', 5 | } 6 | -------------------------------------------------------------------------------- /src/shared/infrastructure/repositories/model/mongodb/index.ts: -------------------------------------------------------------------------------- 1 | import { Document } from 'mongoose'; 2 | 3 | export class CoreDocument extends Document {} 4 | -------------------------------------------------------------------------------- /src/config/types/environment/rabbitMQ.type.ts: -------------------------------------------------------------------------------- 1 | export type RabbitMQConfig = { 2 | API_RABBITMQ_URI: string; 3 | API_RABBITMQ_ENABLED: boolean; 4 | }; 5 | -------------------------------------------------------------------------------- /src/core/domain/authIntegrations/types/teams-auth.detail.type.ts: -------------------------------------------------------------------------------- 1 | export type TeamsAuthDetail = { 2 | tenantId: string; 3 | authToken: string; 4 | }; 5 | -------------------------------------------------------------------------------- /src/core/domain/kodyFineTuning/enums/fineTuningType.enum.ts: -------------------------------------------------------------------------------- 1 | export enum FineTuningType { 2 | GLOBAL = 'global', 3 | REPOSITORY = 'repository', 4 | } 5 | -------------------------------------------------------------------------------- /src/shared/domain/enums/github-installation-status.enum.ts: -------------------------------------------------------------------------------- 1 | export enum InstallationStatus { 2 | PENDING = 'PENDING', 3 | SUCCESS = 'SUCCESS', 4 | } 5 | -------------------------------------------------------------------------------- /src/core/domain/teamMembers/enums/teamMemberRole.enum.ts: -------------------------------------------------------------------------------- 1 | export enum TeamMemberRole { 2 | TEAM_LEADER = 'team_leader', 3 | MEMBER = 'team_member', 4 | } 5 | -------------------------------------------------------------------------------- /src/shared/domain/enums/metric-category.enum.ts: -------------------------------------------------------------------------------- 1 | export enum MetricsCategory { 2 | FLOW_METRICS = 'flow metrics', 3 | DORA_METRICS = 'dora metrics', 4 | } 5 | -------------------------------------------------------------------------------- /packages/kodus-flow/src/observability/core/index.ts: -------------------------------------------------------------------------------- 1 | export { SimpleTracer } from './tracer.js'; 2 | export { Span } from './span.js'; 3 | export * from '../types.js'; 4 | -------------------------------------------------------------------------------- /src/config/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from './database/database-connection.type'; 2 | export * from './http/http-server.type'; 3 | export * from './database/options.type'; 4 | -------------------------------------------------------------------------------- /src/core/domain/teamMembers/interfaces/projectManagementMemberConfig.ts: -------------------------------------------------------------------------------- 1 | export interface IProjectManagementMemberConfig { 2 | name: string; 3 | id: string; 4 | } 5 | -------------------------------------------------------------------------------- /src/shared/utils/enums/repositoryTree.enum.ts: -------------------------------------------------------------------------------- 1 | export enum RepositoryTreeType { 2 | ALL = 'all', 3 | DIRECTORIES = 'directories', 4 | FILES = 'files', 5 | } 6 | -------------------------------------------------------------------------------- /test/mocks/data/bugTypeIdentifier.ts: -------------------------------------------------------------------------------- 1 | const bugTypeIdentifiers = () => { 2 | return [{ id: '10007', name: 'Bug' }]; 3 | }; 4 | 5 | export { bugTypeIdentifiers }; 6 | -------------------------------------------------------------------------------- /src/core/domain/platformIntegrations/types/codeManagement/workflow.type.ts: -------------------------------------------------------------------------------- 1 | export type Workflow = { 2 | id: string; 3 | name: string; 4 | repo: string; 5 | }; 6 | -------------------------------------------------------------------------------- /src/core/domain/teamMembers/interfaces/codeManagementMemberConfig.interface.ts: -------------------------------------------------------------------------------- 1 | export interface ICodeManagementMemberConfig { 2 | name: string; 3 | id: string; 4 | } 5 | -------------------------------------------------------------------------------- /src/shared/utils/langchainCommon/prompts/genericAgent.ts: -------------------------------------------------------------------------------- 1 | export const prompt_genericAgent = `{prompt_kodyContext} 2 | Always try to help users. 3 | 4 | Input Data: 5 | `; 6 | -------------------------------------------------------------------------------- /packages/kodus-common/src/utils/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Automatically generated by barrelsby. 3 | */ 4 | 5 | export * from './error/index'; 6 | export * from './json/index'; 7 | -------------------------------------------------------------------------------- /src/core/application/use-cases/platformIntegration/index.ts: -------------------------------------------------------------------------------- 1 | import codeManagementUseCases from './codeManagement'; 2 | 3 | export const UseCases = [...codeManagementUseCases]; 4 | -------------------------------------------------------------------------------- /packages/kodus-flow/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all", 4 | "tabWidth": 4, 5 | "semi": true, 6 | "quoteProps": "consistent" 7 | } 8 | -------------------------------------------------------------------------------- /src/shared/domain/enums/artifacts-tool-type.enum.ts: -------------------------------------------------------------------------------- 1 | export enum ArtifactsToolType { 2 | PROJECT_MANAGEMENT = 'projectManagement', 3 | CODE_MANAGEMENT = 'codeManagement', 4 | } 5 | -------------------------------------------------------------------------------- /packages/kodus-flow/.cursor/rules/kodyflow.mdc: -------------------------------------------------------------------------------- 1 | --- 2 | description: 3 | globs: 4 | alwaysApply: false 5 | --- 6 | Conversa em pt-br. 7 | Usar typescript boas praticas 8 | Não usar any 9 | -------------------------------------------------------------------------------- /src/core/domain/kodyFineTuning/enums/fineTuningDecision.enum.ts: -------------------------------------------------------------------------------- 1 | export enum FineTuningDecision { 2 | KEEP = 'KEEP', 3 | DISCARD = 'DISCARD', 4 | UNCERTAIN = 'UNCERTAIN', 5 | } 6 | -------------------------------------------------------------------------------- /src/core/domain/pullRequests/interfaces/authorContributor.interface.ts: -------------------------------------------------------------------------------- 1 | export interface AuthorContribution { 2 | id: string; 3 | name: string; 4 | contributions: number; 5 | } 6 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/platformIntegration/integration-common.dto.ts: -------------------------------------------------------------------------------- 1 | export type IntegrationsCommon = { 2 | name: string; 3 | id: string; 4 | key?: string; 5 | }; 6 | -------------------------------------------------------------------------------- /src/shared/domain/enums/metrics-variation-status.enum.ts: -------------------------------------------------------------------------------- 1 | export enum MetricsVariationStatus { 2 | IMPROVES = 'improves', 3 | WORSENS = 'worsens', 4 | NEUTRAL = 'neutral', 5 | } 6 | -------------------------------------------------------------------------------- /src/core/application/use-cases/ssoConfig/index.ts: -------------------------------------------------------------------------------- 1 | import { CreateOrUpdateSSOConfigUseCase } from './create-or-update.use-case'; 2 | 3 | export const UseCases = [CreateOrUpdateSSOConfigUseCase]; 4 | -------------------------------------------------------------------------------- /src/core/domain/teamMembers/interfaces/communicationMemberConfig.interface.ts: -------------------------------------------------------------------------------- 1 | export interface ICommuminicationMemberConfig { 2 | name: string; 3 | id: string; 4 | chatId?: string; 5 | } 6 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/profile.dto.ts: -------------------------------------------------------------------------------- 1 | export class ProfileDto { 2 | public readonly name: string; 3 | public readonly phone: string; 4 | public readonly img?: string; 5 | } 6 | -------------------------------------------------------------------------------- /src/core/domain/platformIntegrations/types/codeManagement/organization.type.ts: -------------------------------------------------------------------------------- 1 | export type Organization = { 2 | id: string; 3 | name: string; 4 | url: string; 5 | selected: boolean; 6 | }; 7 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/integration-slack.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString } from 'class-validator'; 2 | 3 | export class IntegrationSlackDto { 4 | @IsString() 5 | public code: string; 6 | } 7 | -------------------------------------------------------------------------------- /src/shared/domain/enums/timezones.enum.ts: -------------------------------------------------------------------------------- 1 | export enum Timezone { 2 | NEW_YORK = 'America/New_York', 3 | SAO_PAULO = 'America/Sao_Paulo', 4 | DEFAULT_TIMEZONE = 'America/New_York' 5 | } 6 | 7 | -------------------------------------------------------------------------------- /src/config/types/database/findOptions.type.ts: -------------------------------------------------------------------------------- 1 | export type FindOptions = { 2 | orderBy?: { [key: string]: 'ASC' | 'DESC' }; 3 | limit?: number; 4 | offset?: number; 5 | relations?: string[]; 6 | }; 7 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/teamId-query-dto.ts: -------------------------------------------------------------------------------- 1 | import { IsNotEmpty, IsString, IsUUID } from 'class-validator'; 2 | 3 | export class TeamQueryDto { 4 | @IsString() 5 | readonly teamId: string; 6 | } 7 | -------------------------------------------------------------------------------- /src/shared/domain/enums/automations.enum.ts: -------------------------------------------------------------------------------- 1 | export const AUTOMATIONS_ENUM = { 2 | CREATION_OF_DETAILED_ISSUES_WITH_ACCEPTANCE_CRITERIA: 3 | 'Creation of Detailed Issues with Acceptance Criteria', 4 | }; 5 | -------------------------------------------------------------------------------- /src/shared/domain/enums/global-parameters-key.enum.ts: -------------------------------------------------------------------------------- 1 | export enum GlobalParametersKey { 2 | KODY_FINE_TUNING_CONFIG = 'kody_fine_tuning_config', 3 | CODE_REVIEW_MAX_FILES = 'code_review_max_files', 4 | } 5 | -------------------------------------------------------------------------------- /src/config/types/general/organizationAndTeamData.ts: -------------------------------------------------------------------------------- 1 | export type OrganizationAndTeamData = { 2 | organizationId?: string; 3 | organizationName?: string; 4 | teamId?: string; 5 | teamName?: string; 6 | }; 7 | -------------------------------------------------------------------------------- /src/config/types/general/tree.type.ts: -------------------------------------------------------------------------------- 1 | export interface TreeItem { 2 | path: string; 3 | type: 'file' | 'directory'; 4 | sha: string; 5 | size?: number; 6 | url: string; 7 | hasChildren: boolean; 8 | } -------------------------------------------------------------------------------- /src/core/domain/codeReviewExecutions/enum/codeReviewExecution.enum.ts: -------------------------------------------------------------------------------- 1 | export enum CodeReviewExecutionTrigger { 2 | AUTOMATIC = 'AUTOMATIC', 3 | COMMAND = 'COMMAND', 4 | COMMIT_PUSH = 'COMMIT_PUSH', 5 | } 6 | -------------------------------------------------------------------------------- /src/core/domain/integrationConfigs/enums/moduleWorkItemTypes.enum.ts: -------------------------------------------------------------------------------- 1 | export enum MODULE_WORKITEMS_TYPES { 2 | DEFAULT = 'default', 3 | IMPROVE_TASK_DESCRIPTION = 'automation__improve_task_description', 4 | } 5 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/organizationId-query.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString } from "class-validator"; 2 | 3 | export class OrganizationQueryDto { 4 | @IsString() 5 | readonly organizationId: string; 6 | } 7 | -------------------------------------------------------------------------------- /src/shared/domain/enums/auth-provider.enum.ts: -------------------------------------------------------------------------------- 1 | export enum AuthProvider { 2 | CREDENTIALS = 'credentials', 3 | GOOGLE = 'google', 4 | GITHUB = 'github', 5 | GITLAB = 'gitlab', 6 | SSO = 'sso', 7 | } 8 | -------------------------------------------------------------------------------- /src/shared/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './transforms/arrays'; 2 | export * from './transforms/file'; 3 | export * from './transforms/objects'; 4 | export * from './transforms/strings'; 5 | export * from './openAI'; 6 | -------------------------------------------------------------------------------- /src/config/types/database/database-connection.type.ts: -------------------------------------------------------------------------------- 1 | export type DatabaseConnection = { 2 | host: string; 3 | port?: number; 4 | username?: string; 5 | password?: string; 6 | database?: string; 7 | }; 8 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/update-conversation-dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString, IsNotEmpty } from 'class-validator'; 2 | 3 | export class UpdateConversationDto { 4 | @IsString() 5 | public message: string; 6 | } 7 | -------------------------------------------------------------------------------- /src/shared/domain/enums/board-priority-type.enum.ts: -------------------------------------------------------------------------------- 1 | export enum BoardPriorityType { 2 | LEXORANK_PRIORITY = 'lexorank_priority', 3 | PRIORITY_FIELD = 'priority_field', 4 | KANBAN_PRIORITY = 'kanban_priority', 5 | } 6 | -------------------------------------------------------------------------------- /src/shared/domain/enums/create-auth-integration-status.enum.ts: -------------------------------------------------------------------------------- 1 | export enum CreateAuthIntegrationStatus { 2 | SUCCESS = 'SUCCESS', 3 | NO_ORGANIZATION = 'NO_ORGANIZATION', 4 | NO_REPOSITORIES = 'NO_REPOSITORIES', 5 | } 6 | -------------------------------------------------------------------------------- /src/shared/domain/enums/integration-category.enum.ts: -------------------------------------------------------------------------------- 1 | export enum IntegrationCategory { 2 | CODE_MANAGEMENT = 'CODE_MANAGEMENT', 3 | PROJECT_MANAGEMENT = 'PROJECT_MANAGEMENT', 4 | COMMUNICATION = 'COMMUNICATION', 5 | } 6 | -------------------------------------------------------------------------------- /src/core/domain/pullRequests/enums/deliveryStatus.enum.ts: -------------------------------------------------------------------------------- 1 | export enum DeliveryStatus { 2 | SENT = 'sent', 3 | NOT_SENT = 'not_sent', 4 | FAILED_LINES_MISMATCH = 'failed_lines_mismatch', 5 | FAILED = 'failed', 6 | } 7 | -------------------------------------------------------------------------------- /src/core/domain/codeBase/contracts/CodeReviewService.contract.ts: -------------------------------------------------------------------------------- 1 | export const CODE_REVIEW_SERVICE_TOKEN = 'CODE_REVIEW_SERVICE_TOKEN'; 2 | 3 | export interface ICodeReviewService { 4 | handlePullRequest(...args): Promise; 5 | } 6 | -------------------------------------------------------------------------------- /src/shared/domain/enums/programming-language.enum.ts: -------------------------------------------------------------------------------- 1 | export enum ProgrammingLanguage { 2 | JSTS = 'JSTS', 3 | PYTHON = 'PYTHON', 4 | JAVA = 'JAVA', 5 | CSHARP = 'CSHARP', 6 | DART = 'DART', 7 | RUBY = 'RUBY' 8 | } 9 | -------------------------------------------------------------------------------- /src/core/domain/automation/contracts/automation-dailycheckin.service.ts: -------------------------------------------------------------------------------- 1 | export const AUTOMATION_DAILY_CHECKIN_SERVICE_TOKEN = Symbol( 2 | 'AutomationDailyCheckinService', 3 | ); 4 | 5 | export interface IAutomationDailyCheckinService {} 6 | -------------------------------------------------------------------------------- /src/core/domain/pullRequests/enums/implementationStatus.enum.ts: -------------------------------------------------------------------------------- 1 | export enum ImplementationStatus { 2 | IMPLEMENTED = 'implemented', 3 | PARTIALLY_IMPLEMENTED = 'partially_implemented', 4 | NOT_IMPLEMENTED = 'not_implemented', 5 | } 6 | -------------------------------------------------------------------------------- /src/shared/utils/codeManagement/codeReviewBadge.ts: -------------------------------------------------------------------------------- 1 | const getCodeReviewBadge = () => { 2 | return `![kody code-review](https://img.shields.io/badge/kody-code--review-312B4B?labelColor=C9BBF2)`; 3 | }; 4 | 5 | export { getCodeReviewBadge }; 6 | -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": [ 4 | "node_modules", 5 | "test", 6 | "dist", 7 | "**/*spec.ts", 8 | "packages/kodus-flow/src" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "isolatedModules": true 5 | }, 6 | "include": ["src/**/*.ts", "test/**/*.ts"], 7 | "exclude": ["node_modules", "dist"] 8 | } 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/core/application/use-cases/profile/index.ts: -------------------------------------------------------------------------------- 1 | import { CreateProfileUseCase } from './create.use-case'; 2 | import { UpdateProfileUseCase } from './update.use-case'; 3 | 4 | export const UseCases = [CreateProfileUseCase, UpdateProfileUseCase]; 5 | -------------------------------------------------------------------------------- /src/core/domain/automation/contracts/automation_weeklyCheckin.service.ts: -------------------------------------------------------------------------------- 1 | export const AUTOMATION_WEEKLY_CHECKIN_SERVICE_TOKEN = Symbol( 2 | 'AutomationWeeklyCheckinService', 3 | ); 4 | 5 | export interface IAutomationWeeklyCheckinService {} 6 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/update-team.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString } from 'class-validator'; 2 | 3 | export class UpdateTeamDto { 4 | @IsString() 5 | teamName: string; 6 | 7 | @IsString() 8 | teamId: string; 9 | } 10 | -------------------------------------------------------------------------------- /src/core/domain/automation/contracts/memory.service.ts: -------------------------------------------------------------------------------- 1 | import { IMemoryRepository } from './memory.repository'; 2 | 3 | export const MEMORY_SERVICE_TOKEN = Symbol('MemoryService'); 4 | 5 | export interface IMemoryService extends IMemoryRepository {} 6 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/create-team.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString } from 'class-validator'; 2 | 3 | export class CreateTeamDto { 4 | @IsString() 5 | teamName: string; 6 | 7 | @IsString() 8 | organizationId: string; 9 | } 10 | -------------------------------------------------------------------------------- /packages/kodus-common/src/types/organization-team-data.ts: -------------------------------------------------------------------------------- 1 | export type OrganizationAndTeamData = { 2 | readonly organizationId: string; 3 | readonly organizationName?: string; 4 | readonly teamId: string; 5 | readonly teamName?: string; 6 | }; 7 | -------------------------------------------------------------------------------- /src/config/types/general/diagnostic.type.ts: -------------------------------------------------------------------------------- 1 | export type EvaluationResult = { 2 | score?: number; 3 | dataAnalyzed?: any; 4 | errorMessage?: string; 5 | }; 6 | 7 | export type rawData = { 8 | data: any; 9 | params?: any; 10 | }; 11 | -------------------------------------------------------------------------------- /src/core/domain/automation/contracts/automation-executiveCheckin.service.ts: -------------------------------------------------------------------------------- 1 | export const AUTOMATION_EXECUTIVE_CHECKIN_SERVICE_TOKEN = Symbol( 2 | 'AutomationExecutiveCheckinService', 3 | ); 4 | 5 | export interface IAutomationExecutiveCheckinService { } 6 | -------------------------------------------------------------------------------- /src/core/domain/codeBase/contracts/SecurityAnalysisService.contract.ts: -------------------------------------------------------------------------------- 1 | import { FileChange } from "@/config/types/general/codeReview.type"; 2 | 3 | export interface ISecurityAnalysisService { 4 | analyzeSecurity(file: FileChange): Promise; 5 | } 6 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/find-suggestions-by-rule.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsNotEmpty, IsString } from 'class-validator'; 2 | 3 | export class FindSuggestionsByRuleDto { 4 | @IsNotEmpty() 5 | @IsString() 6 | readonly ruleId: string; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/join-organization.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsUUID } from 'class-validator'; 2 | 3 | export class JoinOrganizationDto { 4 | @IsUUID() 5 | userId: string; 6 | 7 | @IsUUID() 8 | organizationId: string; 9 | } 10 | -------------------------------------------------------------------------------- /src/shared/domain/interfaces/data-point.interface.ts: -------------------------------------------------------------------------------- 1 | import { PlatformType } from '../enums/platform-type.enum'; 2 | 3 | export class IDataPoint { 4 | content: string; 5 | timestamp: Date; 6 | sender: string; 7 | platform: PlatformType; 8 | } 9 | -------------------------------------------------------------------------------- /tsconfig.eslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": [ 4 | "src/**/*.ts", 5 | "test/**/*.ts", 6 | "tsconfig-paths-bootstrap.js", 7 | "prebuild.ts" 8 | ], 9 | "exclude": [] 10 | } 11 | -------------------------------------------------------------------------------- /src/core/application/use-cases/rule-like/index.ts: -------------------------------------------------------------------------------- 1 | import { RemoveRuleLikeUseCase } from './remove-rule-like.use-case'; 2 | import { SetRuleLikeUseCase } from './set-rule-like.use-case'; 3 | 4 | export const UseCases = [RemoveRuleLikeUseCase, SetRuleLikeUseCase]; 5 | -------------------------------------------------------------------------------- /src/core/domain/integrationConfigs/types/codeManagement/repositories.type.ts: -------------------------------------------------------------------------------- 1 | export type Repository = { 2 | id: string; 3 | name: string; 4 | http_url: string; 5 | selected: boolean; 6 | avatar_url: string; 7 | visibility: string; 8 | }; 9 | -------------------------------------------------------------------------------- /src/core/domain/issues/contracts/issues.service.contract.ts: -------------------------------------------------------------------------------- 1 | import { IIssuesRepository } from './issues.repository'; 2 | 3 | export const ISSUES_SERVICE_TOKEN = Symbol('IssuesService'); 4 | 5 | export interface IIssuesService extends IIssuesRepository { 6 | 7 | } -------------------------------------------------------------------------------- /src/ee/configs/environment/environment.template.ts: -------------------------------------------------------------------------------- 1 | // @ts-nocheck 2 | 3 | import { Environment } from './types'; 4 | 5 | export const environment: Environment = { 6 | API_CLOUD_MODE: __CLOUD_MODE__, 7 | API_DEVELOPMENT_MODE: __DEVELOPMENT_MODE__, 8 | }; 9 | -------------------------------------------------------------------------------- /packages/kodus-flow/src/core/memory/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | MemoryManager, 3 | getGlobalMemoryManager, 4 | setGlobalMemoryManager, 5 | resetGlobalMemoryManager, 6 | } from './memory-manager.js'; 7 | 8 | export { VectorStore } from './vector-store.js'; 9 | -------------------------------------------------------------------------------- /packages/kodus-flow/tsconfig.examples.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "noImplicitAny": false, 5 | "strict": false 6 | }, 7 | "include": [ 8 | "examples/**/*.ts" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /src/config/types/database/status.type.ts: -------------------------------------------------------------------------------- 1 | export enum STATUS { 2 | ACTIVE = 'active', 3 | INACTIVE = 'inactive', 4 | PENDING = 'pending', 5 | AWAITING_APPROVAL = 'awaiting_approval', 6 | REMOVED = 'removed', 7 | PENDING_EMAIL = 'pending_email', 8 | } 9 | -------------------------------------------------------------------------------- /src/core/domain/kodyFineTuning/enums/feedbackType.enum.ts: -------------------------------------------------------------------------------- 1 | export enum FeedbackType { 2 | POSITIVE_REACTION = 'positiveReaction', 3 | NEGATIVE_REACTION = 'negativeReaction', 4 | SUGGESTION_IMPLEMENTED = 'suggestionImplemented', 5 | NEUTRAL = 'neutral', 6 | } 7 | -------------------------------------------------------------------------------- /src/shared/utils/getTypes.ts: -------------------------------------------------------------------------------- 1 | export const getTypeNames = (bugTypeIdentifiers) => { 2 | const bugTypes = bugTypeIdentifiers?.configValue as { 3 | id: string; 4 | name: string; 5 | }[]; 6 | 7 | return bugTypes?.map((type) => type?.name); 8 | }; 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Questions / Discord 4 | url: https://discord.com/invite/TFZBRk9fT6 5 | about: Need help selfhosting or ask a general question about the project? Join our Discord server 6 | -------------------------------------------------------------------------------- /src/config/types/general/dataPoint.type.ts: -------------------------------------------------------------------------------- 1 | export type PayloadItem = { 2 | narrativeEntityExtraction: any; 3 | questionNarrative: any; 4 | }; 5 | 6 | export type DictionaryTransformResult = { 7 | payload: PayloadItem[]; 8 | metaData: string[]; 9 | }; 10 | -------------------------------------------------------------------------------- /src/core/domain/automation/contracts/automation.service.ts: -------------------------------------------------------------------------------- 1 | import { IAutomationRepository } from './automation.repository'; 2 | 3 | export const AUTOMATION_SERVICE_TOKEN = Symbol('AutomationService'); 4 | 5 | export interface IAutomationService extends IAutomationRepository {} 6 | -------------------------------------------------------------------------------- /src/modules/amazonS3.module.ts: -------------------------------------------------------------------------------- 1 | import { S3Service } from '@/core/infrastructure/adapters/services/amazonS3.service'; 2 | import { Module } from '@nestjs/common'; 3 | 4 | @Module({ 5 | providers: [S3Service], 6 | exports: [S3Service], 7 | }) 8 | export class S3Module {} 9 | -------------------------------------------------------------------------------- /src/core/domain/platformIntegrations/types/codeManagement/deployFrequency.type.ts: -------------------------------------------------------------------------------- 1 | export type DeployFrequency = { 2 | id: number; 3 | repository: string; 4 | created_at: string; 5 | teamConfig?: any; 6 | tag_name?: string; 7 | published_at?: string; 8 | }; 9 | -------------------------------------------------------------------------------- /src/core/application/use-cases/codeReviewFeedback/index.ts: -------------------------------------------------------------------------------- 1 | import { GetReactionsUseCase } from './get-reactions.use-case'; 2 | import { SaveCodeReviewFeedbackUseCase } from './save-feedback.use-case'; 3 | 4 | export const UseCases = [GetReactionsUseCase, SaveCodeReviewFeedbackUseCase]; 5 | -------------------------------------------------------------------------------- /src/core/domain/auth/contracts/ssoConfig.service.contract.ts: -------------------------------------------------------------------------------- 1 | import { ISSOConfigRepository } from './ssoConfig.repository.contract'; 2 | 3 | export const SSO_CONFIG_SERVICE_TOKEN = Symbol('SSOConfigService'); 4 | 5 | export interface ISSOConfigService extends ISSOConfigRepository {} 6 | -------------------------------------------------------------------------------- /src/core/domain/automation/interfaces/session.interface.ts: -------------------------------------------------------------------------------- 1 | export interface ISession { 2 | uuid: string; 3 | platformUserId: string; 4 | platformName: string; 5 | date: number; 6 | route: string; 7 | organizationId: string; 8 | teamId: string; 9 | } 10 | -------------------------------------------------------------------------------- /src/core/domain/azureRepos/entities/azureReposProject.type.ts: -------------------------------------------------------------------------------- 1 | export interface AzureReposProject { 2 | id: string; 3 | name: string; 4 | url: string; 5 | state: string; 6 | revision: number; 7 | visibility: string; 8 | lastUpdateTime: string; 9 | } 10 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/platform-type.dto.ts: -------------------------------------------------------------------------------- 1 | import { PlatformType } from '@/shared/domain/enums/platform-type.enum'; 2 | import { IsEnum, } from 'class-validator'; 3 | 4 | export class PlatformTypeDto { 5 | @IsEnum(PlatformType) 6 | platformType: PlatformType; 7 | } 8 | -------------------------------------------------------------------------------- /packages/kodus-common/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | }, 6 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"], 7 | "include": [ 8 | "src/**/*", 9 | ], 10 | } 11 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/update-conversation-title-dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString, IsNotEmpty } from 'class-validator'; 2 | 3 | export class UpdateConversationTitleDto { 4 | @IsString() 5 | @IsNotEmpty({ message: 'Title should not be empty' }) 6 | public title: string; 7 | } 8 | -------------------------------------------------------------------------------- /src/core/domain/automation/interfaces/memory.interface.ts: -------------------------------------------------------------------------------- 1 | export interface IMemoryMessage { 2 | type: string; 3 | data: { content: string }; 4 | additional_kwargs: any; 5 | } 6 | 7 | export interface IMemory { 8 | uuid: string; 9 | messages: IMemoryMessage[]; 10 | } 11 | -------------------------------------------------------------------------------- /src/core/domain/codeBase/contracts/LintingService.contract.ts: -------------------------------------------------------------------------------- 1 | import { FileChange } from '@/config/types/general/codeReview.type'; 2 | 3 | export const LINTING_SERVICE_TOKEN = Symbol('LintingService'); 4 | export interface ILintingService { 5 | lintCode(file: FileChange): Promise; 6 | } 7 | -------------------------------------------------------------------------------- /src/core/domain/tokenUsage/contracts/tokenUsage.service.contract.ts: -------------------------------------------------------------------------------- 1 | import { ITokenUsageRepository } from './tokenUsage.repository.contract'; 2 | 3 | export const TOKEN_USAGE_SERVICE_TOKEN = Symbol('TokenUsageService'); 4 | 5 | export interface ITokenUsageService extends ITokenUsageRepository {} 6 | -------------------------------------------------------------------------------- /src/core/domain/global-parameters/interfaces/global-parameters.interface.ts: -------------------------------------------------------------------------------- 1 | import { GlobalParametersKey } from '@/shared/domain/enums/global-parameters-key.enum'; 2 | 3 | export interface IGlobalParameters { 4 | uuid: string; 5 | configKey: GlobalParametersKey; 6 | configValue: any; 7 | } 8 | -------------------------------------------------------------------------------- /src/core/domain/user/contracts/password.service.contract.ts: -------------------------------------------------------------------------------- 1 | export const PASSWORD_SERVICE_TOKEN = Symbol('PasswordService'); 2 | 3 | export interface IPasswordService { 4 | generate(value: string, salts?: number): Promise; 5 | match(source: string, hash: string): Promise; 6 | } 7 | -------------------------------------------------------------------------------- /src/core/application/use-cases/github/index.ts: -------------------------------------------------------------------------------- 1 | import { GetOrganizationNameUseCase } from './GetOrganizationName'; 2 | import { GetIntegrationGithubUseCase } from './get-integration-github'; 3 | 4 | export const UseCases = [ 5 | GetOrganizationNameUseCase, 6 | GetIntegrationGithubUseCase, 7 | ]; 8 | -------------------------------------------------------------------------------- /src/core/domain/authIntegrations/types/azure-repos-auth-detail.ts: -------------------------------------------------------------------------------- 1 | import { AuthMode } from '../../platformIntegrations/enums/codeManagement/authMode.enum'; 2 | 3 | export type AzureReposAuthDetail = { 4 | orgUrl: string; 5 | token: string; 6 | orgName: string; 7 | authMode: AuthMode; 8 | }; 9 | -------------------------------------------------------------------------------- /src/core/domain/permissions/contracts/permissions.service.contract.ts: -------------------------------------------------------------------------------- 1 | import { IPermissionsRepository } from './permissions.repository.contract'; 2 | 3 | export const PERMISSIONS_SERVICE_TOKEN = Symbol('PermissionsService'); 4 | 5 | export interface IPermissionsService extends IPermissionsRepository {} 6 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/create-conversation.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString, MinLength } from 'class-validator'; 2 | 3 | export class CreateConversationDto { 4 | @IsString() 5 | @MinLength(3) 6 | public prompt: string; 7 | 8 | @IsString() 9 | public teamId: string; 10 | } 11 | -------------------------------------------------------------------------------- /src/core/domain/msTeams/msTeams.service.contract.ts: -------------------------------------------------------------------------------- 1 | export const MSTEAMS_SERVICE_TOKEN = Symbol('MSTeamsService'); 2 | 3 | export interface IMSTeamsService { 4 | installBotInTeamMembers(params: any): Promise; 5 | getTeamsStoryUrl(); 6 | sendMessageToMemberID(params: any): Promise; 7 | } 8 | -------------------------------------------------------------------------------- /src/core/domain/platformIntegrations/interfaces/common.interface.ts: -------------------------------------------------------------------------------- 1 | export interface ICommonPlatformIntegrationService { 2 | createAuthIntegration(params: any): Promise; 3 | updateAuthIntegration(params: any): Promise; 4 | createOrUpdateIntegrationConfig(params: any): Promise; 5 | } 6 | -------------------------------------------------------------------------------- /src/config/types/http/http-server.type.ts: -------------------------------------------------------------------------------- 1 | export type HttpServerConfiguration = { 2 | host?: string; 3 | name?: string; 4 | tz?: string; 5 | port: number; 6 | debug?: boolean; 7 | rateLimit: { 8 | rateMaxRequest?: number; 9 | rateInterval?: number; 10 | }; 11 | }; 12 | -------------------------------------------------------------------------------- /src/core/domain/authIntegrations/types/bitbucket-auth-detail.type.ts: -------------------------------------------------------------------------------- 1 | import { AuthMode } from '../../platformIntegrations/enums/codeManagement/authMode.enum'; 2 | 3 | export type BitbucketAuthDetail = { 4 | username: string; 5 | appPassword: string; 6 | authMode: AuthMode; 7 | email?: string; 8 | }; 9 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/update-pull-request.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsOptional, IsString } from 'class-validator'; 2 | 3 | export class updatePullRequestDto { 4 | @IsString() 5 | @IsOptional() 6 | public teamId?: string; 7 | 8 | @IsString() 9 | public organizationId: string; 10 | } 11 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | # Google Artifact Registry Configuration 2 | @kodus:registry=https://us-central1-npm.pkg.dev/kodus-infra-prod/kodus-pkg/ 3 | 4 | # Fallback para npm público (para outras dependências) 5 | registry=https://registry.npmjs.org/ 6 | 7 | # Configurações de segurança 8 | audit-level=moderate 9 | fund=false 10 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/execute-dry-run.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsNumber, IsString } from 'class-validator'; 2 | 3 | export class ExecuteDryRunDto { 4 | @IsString() 5 | teamId: string; 6 | 7 | @IsString() 8 | repositoryId: string; 9 | 10 | @IsNumber() 11 | prNumber: number; 12 | } 13 | -------------------------------------------------------------------------------- /src/modules/tokenChunking.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { TokenChunkingService } from '@/shared/utils/tokenChunking/tokenChunking.service'; 3 | 4 | @Module({ 5 | providers: [TokenChunkingService], 6 | exports: [TokenChunkingService], 7 | }) 8 | export class TokenChunkingModule {} 9 | -------------------------------------------------------------------------------- /nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": [ 3 | "src", 4 | ".yalc/@kodus/flow", 5 | "node_modules/@kodus/flow/dist" 6 | ], 7 | "ext": "ts,js,json", 8 | "ignore": [ 9 | "dist", 10 | "**/*.spec.ts" 11 | ], 12 | "exec": "nest start --watch --debug 0.0.0.0:9229" 13 | } 14 | -------------------------------------------------------------------------------- /src/config/schemas/config.schema.ts: -------------------------------------------------------------------------------- 1 | import * as Joi from 'joi'; 2 | 3 | export const configSchema = Joi.object({ 4 | API_HOST: Joi.string().default('localhost'), 5 | API_PORT: Joi.number().required(), 6 | API_RATE_MAX_REQUEST: Joi.number().default(100), 7 | API_RATE_INTERVAL: Joi.number().default(60), 8 | }); 9 | -------------------------------------------------------------------------------- /src/core/domain/authIntegrations/types/slack-auth-detail.type.ts: -------------------------------------------------------------------------------- 1 | export type SlackAuthDetail = { 2 | botToken: string; 3 | authToken: string; 4 | slackTeamId: string; 5 | botInfo?: BotInfo; 6 | }; 7 | 8 | export type BotInfo = { 9 | botUserId: string; 10 | botId: string; 11 | name: string; 12 | }; 13 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/organizationAndTeamData.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsOptional, IsString } from 'class-validator'; 2 | 3 | export class OrganizationAndTeamDataDto { 4 | @IsOptional() 5 | @IsString() 6 | teamId?: string; 7 | 8 | @IsOptional() 9 | @IsString() 10 | organizationId?: string; 11 | } 12 | -------------------------------------------------------------------------------- /packages/kodus-common/src/utils/error/index.ts: -------------------------------------------------------------------------------- 1 | export function handleError(error: unknown): Error { 2 | if (error instanceof Error) { 3 | return error; 4 | } 5 | 6 | if (typeof error === 'string') { 7 | return new Error(error); 8 | } 9 | 10 | return new Error('An unknown error occurred'); 11 | } 12 | -------------------------------------------------------------------------------- /src/config/types/http/user-request.type.ts: -------------------------------------------------------------------------------- 1 | import { Role } from '@/core/domain/permissions/enums/permissions.enum'; 2 | import { IUser } from '@/core/domain/user/interfaces/user.interface'; 3 | import { Request } from 'express'; 4 | 5 | type User = Partial>; 6 | 7 | export type UserRequest = Request & { user: User }; 8 | -------------------------------------------------------------------------------- /src/core/application/use-cases/agent/index.ts: -------------------------------------------------------------------------------- 1 | import { BusinessRulesValidationAgentUseCase } from './business-rules-validation-agent.use-case'; 2 | import { ConversationAgentUseCase } from './conversation-agent.use-case'; 3 | 4 | export const UseCases = [ 5 | BusinessRulesValidationAgentUseCase, 6 | ConversationAgentUseCase, 7 | ]; 8 | -------------------------------------------------------------------------------- /src/core/domain/platformIntegrations/types/codeManagement/repositoryFile.type.ts: -------------------------------------------------------------------------------- 1 | export type RepositoryFile = { 2 | path: string; 3 | type: string; 4 | filename: string; 5 | sha: string; 6 | size: number; 7 | }; 8 | 9 | export type RepositoryFileWithContent = RepositoryFile & { 10 | content: string; 11 | }; 12 | -------------------------------------------------------------------------------- /src/shared/infrastructure/filters/configuration-missing.exception.ts: -------------------------------------------------------------------------------- 1 | import { HttpException, HttpStatus } from '@nestjs/common'; 2 | 3 | export class ConfigurationMissingException extends HttpException { 4 | constructor(message: string, code: string) { 5 | super({ message, code }, HttpStatus.UNPROCESSABLE_ENTITY); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/config/types/general/changelog.type.ts: -------------------------------------------------------------------------------- 1 | export type ChangelogEntry = { 2 | id: string; 3 | created: Date; 4 | items: Array<{ 5 | field: string; 6 | fieldtype: string; 7 | from?: string; 8 | fromString?: string; 9 | to?: string; 10 | toString?: string; 11 | }>; 12 | }; 13 | -------------------------------------------------------------------------------- /src/config/types/jwt/jwt.ts: -------------------------------------------------------------------------------- 1 | import type { StringValue } from 'ms'; 2 | 3 | export type JWT = { 4 | secret: string; 5 | expiresIn: StringValue; 6 | refreshSecret: string; 7 | refreshExpiresIn: StringValue; 8 | }; 9 | 10 | export type TokenResponse = { 11 | accessToken: string; 12 | refreshToken: string; 13 | }; 14 | -------------------------------------------------------------------------------- /src/core/domain/interactions/contracts/interaction.service.contracts.ts: -------------------------------------------------------------------------------- 1 | import { InteractionDto } from '@/shared/domain/dtos/interaction.dtos'; 2 | 3 | export const INTERACTION_SERVICE_TOKEN = Symbol('InteractionService'); 4 | 5 | export interface IInteractionService { 6 | createInteraction(interaction: InteractionDto): Promise; 7 | } 8 | -------------------------------------------------------------------------------- /packages/kodus-flow/src/utils/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | IdGenerator, 3 | SequentialIdGenerator, 4 | HighThroughputIdGenerator, 5 | } from './id-generator.js'; 6 | 7 | export { 8 | ConcurrentStateManager, 9 | SimpleStateManager, 10 | StateManagerFactory, 11 | StateManagerError, 12 | } from './thread-safe-state.js'; 13 | -------------------------------------------------------------------------------- /src/core/domain/automation/contracts/adapters/communication.adapter.ts: -------------------------------------------------------------------------------- 1 | export const COMMUNICATION_PLATFORM_ADAPTER_TOKEN = Symbol( 2 | 'CommunicationPlatformAdapter', 3 | ); 4 | 5 | export interface CommunicationPlatformAdapter { 6 | sendMessage(channel: string, message: string): Promise; 7 | receiveMessage(): Promise; 8 | } 9 | -------------------------------------------------------------------------------- /src/core/domain/profile/interfaces/profile.interface.ts: -------------------------------------------------------------------------------- 1 | import { IUser } from '@/core/domain/user/interfaces/user.interface'; 2 | 3 | export interface IProfile { 4 | uuid: string; 5 | name: string; 6 | phone?: string; 7 | img?: string; 8 | status: boolean; 9 | position?: string; 10 | user?: Partial; 11 | } 12 | -------------------------------------------------------------------------------- /src/config/database/typeorm/seed/seed.ts: -------------------------------------------------------------------------------- 1 | import 'reflect-metadata'; 2 | import { runSeeders } from 'typeorm-extension'; 3 | import { dataSourceInstance } from '../ormconfig'; 4 | 5 | const dataSource = dataSourceInstance; 6 | 7 | dataSource.initialize().then(async () => { 8 | await runSeeders(dataSource); 9 | process.exit(); 10 | }); 11 | -------------------------------------------------------------------------------- /src/config/loaders/server.loader.ts: -------------------------------------------------------------------------------- 1 | import { registerAs } from '@nestjs/config'; 2 | 3 | import { HttpServerConfiguration } from '@/config/types/http/http-server.type'; 4 | import { configLoader } from '.'; 5 | 6 | export const serverConfigLoader = registerAs( 7 | 'server', 8 | (): HttpServerConfiguration => configLoader().server, 9 | ); 10 | -------------------------------------------------------------------------------- /src/config/schemas/database.schema.ts: -------------------------------------------------------------------------------- 1 | import * as Joi from 'joi'; 2 | 3 | export const databaseSchema = Joi.object({ 4 | DB_HOST: Joi.string().hostname, 5 | DB_PORT: Joi.number().optional(), 6 | DB_USERNAME: Joi.string().optional(), 7 | DB_PASSWORD: Joi.string().optional(), 8 | DB_DATABASE: Joi.string().optional(), 9 | }); 10 | -------------------------------------------------------------------------------- /src/core/domain/automation/contracts/processAutomation/automation.factory.ts: -------------------------------------------------------------------------------- 1 | export const AUTOMATION_FACTORY_TOKEN = Symbol('AutomationFactory'); 2 | 3 | export interface IAutomationFactory { 4 | automationType: string; 5 | setup(payload?: any): Promise; 6 | run?(payload?: any): Promise; 7 | stop(payload?: any): Promise; 8 | } 9 | -------------------------------------------------------------------------------- /src/core/domain/organizationParameters/types/organizationParameters.types.ts: -------------------------------------------------------------------------------- 1 | export type OrganizationParametersAutoJoinConfig = { 2 | enabled: boolean; 3 | domains: string[]; 4 | }; 5 | 6 | export type OrganizationParametersAutoAssignConfig = { 7 | enabled: boolean; 8 | ignoredUsers: string[]; 9 | allowedUsers?: string[]; 10 | }; 11 | -------------------------------------------------------------------------------- /test/unit/shared/utils/transforms/example.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "John Doe", 3 | "age": 30, 4 | "email": "johndoe@example.com", 5 | "address": { 6 | "street": "123 Main St", 7 | "city": "New York", 8 | "state": "NY", 9 | "zip": "10001" 10 | }, 11 | "hobbies": ["reading", "traveling", "cooking"] 12 | } 13 | -------------------------------------------------------------------------------- /src/core/domain/automation/interfaces/team-automation.interface.ts: -------------------------------------------------------------------------------- 1 | import { ITeam } from '../../team/interfaces/team.interface'; 2 | import { IAutomation } from './automation.interface'; 3 | 4 | export interface ITeamAutomation { 5 | uuid?: string; 6 | status: boolean; 7 | automation?: Partial; 8 | team?: Partial; 9 | } 10 | -------------------------------------------------------------------------------- /src/core/domain/bitbucket/contracts/bitbucket.service.contract.ts: -------------------------------------------------------------------------------- 1 | import { OrganizationAndTeamData } from '@/config/types/general/organizationAndTeamData'; 2 | import { InstallationStatus } from '@/shared/domain/enums/github-installation-status.enum'; 3 | 4 | export const BITBUCKET_SERVICE_TOKEN = Symbol('BitbucketService'); 5 | 6 | export interface IBitbucketService {} 7 | -------------------------------------------------------------------------------- /src/core/domain/platformIntegrations/types/codeManagement/commitLeadTimeForChange.type.ts: -------------------------------------------------------------------------------- 1 | import { Commit } from "@/config/types/general/commit.type" 2 | import { DeployFrequency } from "./deployFrequency.type" 3 | 4 | export type CommitLeadTimeForChange = { 5 | commit: Commit, 6 | lastDeploy: DeployFrequency, 7 | secondToLastDeploy: DeployFrequency 8 | } 9 | -------------------------------------------------------------------------------- /src/shared/utils/enums/severityLevel.enum.ts: -------------------------------------------------------------------------------- 1 | import z from 'zod'; 2 | 3 | export enum SeverityLevel { 4 | CRITICAL = 'critical', 5 | HIGH = 'high', 6 | MEDIUM = 'medium', 7 | LOW = 'low', 8 | } 9 | 10 | export const severityLevelSchema = z.enum([...Object.values(SeverityLevel)] as [ 11 | SeverityLevel, 12 | ...SeverityLevel[], 13 | ]); 14 | -------------------------------------------------------------------------------- /src/core/domain/authIntegrations/types/gitlab-auth-detail.type.ts: -------------------------------------------------------------------------------- 1 | import { AuthMode } from '../../platformIntegrations/enums/codeManagement/authMode.enum'; 2 | 3 | export type GitlabAuthDetail = { 4 | accessToken: string; 5 | refreshToken?: string; 6 | tokenType?: string; 7 | scope?: string; 8 | authMode?: AuthMode; 9 | host?: string; 10 | }; 11 | -------------------------------------------------------------------------------- /src/shared/utils/safelyParseMessageContent.ts: -------------------------------------------------------------------------------- 1 | export const safelyParseMessageContent = (messageContent) => { 2 | try { 3 | // Then, parse this string back into a JavaScript object 4 | return JSON.parse(messageContent); 5 | } catch (e) { 6 | console.error('Error handling MessageContent:', e); 7 | return null; 8 | } 9 | }; 10 | -------------------------------------------------------------------------------- /packages/kodus-flow/src/core/storage/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | StorageAdapterFactory, 3 | getGlobalStorageAdapter, 4 | setGlobalStorageAdapter, 5 | resetGlobalStorageAdapter, 6 | } from './factory.js'; 7 | 8 | export { InMemoryStorageAdapter } from './adapters/in-memory-adapter.js'; 9 | export { MongoDBStorageAdapter } from './adapters/mongodb-adapter.js'; 10 | -------------------------------------------------------------------------------- /src/config/loaders/environment.loader.ts: -------------------------------------------------------------------------------- 1 | import { registerAs } from '@nestjs/config'; 2 | import { EnvironmentConfig } from '@/config/types/environment/environment.type'; 3 | 4 | export const environmentConfigLoader = registerAs( 5 | 'environment', 6 | (): EnvironmentConfig => ({ 7 | nodeEnv: process.env.API_NODE_ENV || 'development', 8 | }), 9 | ); 10 | -------------------------------------------------------------------------------- /src/core/domain/authIntegrations/types/jira-auth-details.ts: -------------------------------------------------------------------------------- 1 | export type JiraAuthDetail = { 2 | baseUrl: string; 3 | boardId: string; 4 | cloudId: string; 5 | platform: string; 6 | authToken: string; 7 | projectId: string; 8 | projectKey: string; 9 | refreshToken: string; 10 | expiresIn: number; 11 | lastRefreshedAt: number; 12 | }; 13 | -------------------------------------------------------------------------------- /src/core/domain/azureRepos/contracts/azure-repos.service.contract.ts: -------------------------------------------------------------------------------- 1 | import { OrganizationAndTeamData } from '@/config/types/general/organizationAndTeamData'; 2 | import { InstallationStatus } from '@/shared/domain/enums/github-installation-status.enum'; 3 | 4 | export const AZURE_REPOS_SERVICE_TOKEN = Symbol('AzureReposService'); 5 | 6 | export interface IAzureReposService {} 7 | -------------------------------------------------------------------------------- /docker/postgres/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM postgres:latest 2 | RUN apt-get update && apt-get install -y git build-essential postgresql-server-dev-$(pg_config --version | sed 's/[^0-9]*\([0-9]*\).*/\1/') \ 3 | && cd /tmp \ 4 | && rm -rf pgvector || true \ 5 | && git clone --branch v0.5.1 https://github.com/pgvector/pgvector.git \ 6 | && cd pgvector \ 7 | && make \ 8 | && make install -------------------------------------------------------------------------------- /src/config/types/general/selectedCategory.type.ts: -------------------------------------------------------------------------------- 1 | export type SelectedCategories = { 2 | security?: boolean; 3 | code_style?: boolean; 4 | performance_and_optimization?: boolean; 5 | documentation_and_comments?: boolean; 6 | error_handling?: boolean; 7 | potential_issues?: boolean; 8 | maintainability?: boolean; 9 | refactoring?: boolean; 10 | }; 11 | -------------------------------------------------------------------------------- /src/core/application/use-cases/team/index.ts: -------------------------------------------------------------------------------- 1 | import { CreateTeamUseCase } from './create.use-case'; 2 | import { ListTeamsWithIntegrationsUseCase } from './list-with-integrations.use-case'; 3 | import { ListTeamsUseCase } from './list.use-case'; 4 | 5 | export const UseCases = [ 6 | CreateTeamUseCase, 7 | ListTeamsUseCase, 8 | ListTeamsWithIntegrationsUseCase, 9 | ]; 10 | -------------------------------------------------------------------------------- /src/core/domain/pullRequestMessages/contracts/pullRequestMessages.service.contract.ts: -------------------------------------------------------------------------------- 1 | import { IPullRequestMessagesRepository } from './pullRequestMessages.repository.contract'; 2 | 3 | export const PULL_REQUEST_MESSAGES_SERVICE_TOKEN = Symbol( 4 | 'PullRequestMessagesService', 5 | ); 6 | 7 | export interface IPullRequestMessagesService 8 | extends IPullRequestMessagesRepository {} 9 | -------------------------------------------------------------------------------- /src/core/domain/webhookLog/interfaces/webhook-log.interface.ts: -------------------------------------------------------------------------------- 1 | import { PlatformType } from '@/shared/domain/enums/platform-type.enum'; 2 | 3 | export interface IWebhookLog { 4 | uuid: string; 5 | createdAt: Date; 6 | updatedAt: Date; 7 | platform: PlatformType; 8 | event: string; 9 | payload: Record; 10 | meta?: Record; 11 | } 12 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/delete-repository-code-review-parameter.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsOptional, IsString } from 'class-validator'; 2 | 3 | export class DeleteRepositoryCodeReviewParameterDto { 4 | @IsString() 5 | teamId: string; 6 | 7 | @IsString() 8 | repositoryId: string; 9 | 10 | @IsOptional() 11 | @IsString() 12 | directoryId: string; 13 | } 14 | -------------------------------------------------------------------------------- /src/shared/domain/enums/verify-communication-connection-type.enum.ts: -------------------------------------------------------------------------------- 1 | import { IntegrationCategory } from '@/shared/domain/enums/integration-category.enum'; 2 | 3 | export type VerifyCommunicationConnectionType = { 4 | isSetupComplete: boolean; 5 | hasConnection: boolean; 6 | config?: object; 7 | platformName: string; 8 | category?: IntegrationCategory; 9 | }; 10 | -------------------------------------------------------------------------------- /packages/kodus-common/.npmrc: -------------------------------------------------------------------------------- 1 | # Google Artifact Registry Configuration 2 | # Público para uso, autenticação apenas para publicação 3 | # @kodus:registry=https://us-central1-npm.pkg.dev/${GAR_PROJECT_ID}/kodus-pkg/ 4 | 5 | # Fallback para npm público (para dependências) 6 | registry=https://registry.npmjs.org/ 7 | 8 | # Configurações de segurança 9 | audit-level=moderate 10 | fund=false 11 | -------------------------------------------------------------------------------- /src/core/application/use-cases/usage/index.ts: -------------------------------------------------------------------------------- 1 | import { CostEstimateUseCase } from './cost-estimate.use-case'; 2 | import { TokenPricingUseCase } from './token-pricing.use-case'; 3 | import { TokensByDeveloperUseCase } from './tokens-developer.use-case'; 4 | 5 | export const UseCases = [ 6 | TokensByDeveloperUseCase, 7 | TokenPricingUseCase, 8 | CostEstimateUseCase, 9 | ]; 10 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 4 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | # The JSON files contain newlines inconsistently 13 | [*.json] 14 | insert_final_newline = ignore 15 | 16 | [*.md] 17 | trim_trailing_whitespace = false 18 | 19 | -------------------------------------------------------------------------------- /packages/kodus-common/.npmrc.bak: -------------------------------------------------------------------------------- 1 | # Google Artifact Registry Configuration 2 | # Público para uso, autenticação apenas para publicação 3 | @kodus:registry=https://us-central1-npm.pkg.dev/kodus-infra-prod/kodus-pkg/ 4 | 5 | # Fallback para npm público (para dependências) 6 | registry=https://registry.npmjs.org/ 7 | 8 | # Configurações de segurança 9 | audit-level=moderate 10 | fund=false 11 | -------------------------------------------------------------------------------- /src/core/domain/automation/contracts/processAutomation/automation.strategy.ts: -------------------------------------------------------------------------------- 1 | export const AUTOMATION_STRATEGY_TOKEN = Symbol('AutomationStrategy'); 2 | 3 | export interface IAutomationStrategy { 4 | route( 5 | message: string, 6 | userId: string, 7 | channel: string, 8 | sessionId?: string, 9 | userName?: string, 10 | ): Promise; 11 | } 12 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/review-fast-kody-rules.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsArray, IsOptional, IsString } from 'class-validator'; 2 | 3 | export class ReviewFastKodyRulesDto { 4 | @IsString() 5 | teamId: string; 6 | 7 | @IsOptional() 8 | @IsArray() 9 | activateRuleIds?: string[]; 10 | 11 | @IsOptional() 12 | @IsArray() 13 | deleteRuleIds?: string[]; 14 | } 15 | -------------------------------------------------------------------------------- /src/shared/domain/enums/status-category-jira.enum.ts: -------------------------------------------------------------------------------- 1 | export enum StatusCategoryJira { 2 | NEW = 'new', 3 | INDETERMINATE = 'indeterminate', 4 | DONE = 'done', 5 | } 6 | 7 | export const StatusCategoryToColumn = { 8 | // [StatusCategoryJira.NEW]: 'todo', // not used for now 9 | [StatusCategoryJira.INDETERMINATE]: 'wip', 10 | [StatusCategoryJira.DONE]: 'done', 11 | }; 12 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/find-recommended-kody-rules.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsOptional, IsNumber, Min } from 'class-validator'; 2 | import { Transform } from 'class-transformer'; 3 | 4 | export class FindRecommendedKodyRulesDto { 5 | @IsOptional() 6 | @IsNumber() 7 | @Min(1) 8 | @Transform(({ value }) => (value ? parseInt(value, 10) : undefined)) 9 | limit?: number; 10 | } 11 | -------------------------------------------------------------------------------- /src/modules/segment.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { SegmentController } from '@/core/infrastructure/http/controllers/segment.controller'; 3 | import { UseCases } from '@/core/application/use-cases/segment'; 4 | 5 | @Module({ 6 | controllers: [SegmentController], 7 | providers: [...UseCases], 8 | exports: [], 9 | }) 10 | export class SegmentModule {} 11 | -------------------------------------------------------------------------------- /src/core/application/use-cases/teamMembers/index.ts: -------------------------------------------------------------------------------- 1 | import { CreateOrUpdateTeamMembersUseCase } from './create.use-case'; 2 | import { DeleteTeamMembersUseCase } from './delete.use-case'; 3 | import { GetTeamMembersUseCase } from './get-team-members.use-case'; 4 | 5 | export const UseCases = [ 6 | CreateOrUpdateTeamMembersUseCase, 7 | GetTeamMembersUseCase, 8 | DeleteTeamMembersUseCase, 9 | ]; 10 | -------------------------------------------------------------------------------- /src/core/domain/authIntegrations/types/github-auth-detail.type.ts: -------------------------------------------------------------------------------- 1 | import { AuthMode } from '../../platformIntegrations/enums/codeManagement/authMode.enum'; 2 | 3 | export type GithubAuthDetail = { 4 | authToken: string; 5 | installationId?: string; 6 | org: string; 7 | authMode?: AuthMode; 8 | accountType?: 'organization' | 'user'; // Cache para evitar verificações repetidas 9 | }; 10 | -------------------------------------------------------------------------------- /src/core/domain/profileConfigs/interfaces/profileConfig.interface.ts: -------------------------------------------------------------------------------- 1 | import { IProfile } from "../../profile/interfaces/profile.interface"; 2 | import { ProfileConfigKey } from "../enum/profileConfigKey.enum"; 3 | 4 | export interface IProfileConfig { 5 | uuid: string; 6 | configKey: ProfileConfigKey; 7 | configValue: any; 8 | status: boolean; 9 | profile?: Partial; 10 | } 11 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/create-user.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsBoolean, IsEmail, IsOptional, IsString } from 'class-validator'; 2 | 3 | export class CreateUserDto { 4 | @IsString() 5 | @IsEmail() 6 | public email: string; 7 | 8 | @IsString() 9 | @IsOptional() 10 | public password: string; 11 | 12 | @IsBoolean() 13 | @IsOptional() 14 | public status?: boolean; 15 | } 16 | -------------------------------------------------------------------------------- /packages/kodus-flow/.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 4 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | # The JSON files contain newlines inconsistently 13 | [*.json] 14 | insert_final_newline = ignore 15 | 16 | [*.md] 17 | trim_trailing_whitespace = false 18 | 19 | -------------------------------------------------------------------------------- /src/shared/utils/langchainCommon/prompts/codeBaseConversation.ts: -------------------------------------------------------------------------------- 1 | export const prompt_codebase_conversation_system = () => { 2 | return ` You are an AI assistant specialized in answering questions about the team codebase. 3 | `; 4 | }; 5 | 6 | export const prompt_codebase_conversation_user = (payload: any) => { 7 | return ` 8 | User question about codebase: ${payload.question} 9 | `; 10 | }; 11 | -------------------------------------------------------------------------------- /packages/kodus-flow/tsconfig.vitest.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "types": ["node", "vitest/globals"], 5 | "esModuleInterop": true, 6 | "moduleResolution": "node" 7 | }, 8 | "include": [ 9 | "tests/**/*.ts", 10 | "**/*.test.ts", 11 | "**/*.spec.ts" 12 | ], 13 | "exclude": ["node_modules", "dist"] 14 | } 15 | -------------------------------------------------------------------------------- /src/core/domain/auth/interfaces/auth.interface.ts: -------------------------------------------------------------------------------- 1 | import { AuthProvider } from '@/shared/domain/enums/auth-provider.enum'; 2 | import { IUser } from '../../user/interfaces/user.interface'; 3 | 4 | export interface IAuth { 5 | uuid: string; 6 | user?: IUser; 7 | refreshToken: string; 8 | used: boolean; 9 | expiryDate: Date; 10 | authDetails?: any; 11 | authProvider: AuthProvider; 12 | } 13 | -------------------------------------------------------------------------------- /src/shared/domain/enums/good-practice-type.enum.ts: -------------------------------------------------------------------------------- 1 | export enum GoodPracticeType { 2 | ISSUES_WITH_ASSIGNED_OWNER = 'IssuesWithAssignedOwner', 3 | CLEAR_DESCRIPTION = 'ClearDescription', 4 | COMMITS_LINKED_TO_ISSUE = 'CommitsLinkedToIssue', 5 | CONSISTENCY_ISSUE_SIZES = 'ConsistencyIssueSizes', 6 | DEFINED_WIP_LIMIT = 'DefinedWipLimit', 7 | ENSURE_ACCEPTANCE_CRITERIA = 'EnsureAcceptanceCriteria', 8 | } 9 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/webhook-status-query.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsNotEmpty, IsString } from 'class-validator'; 2 | 3 | export class WebhookStatusQueryDto { 4 | @IsString() 5 | @IsNotEmpty() 6 | readonly organizationId: string; 7 | 8 | @IsString() 9 | @IsNotEmpty() 10 | readonly teamId: string; 11 | 12 | @IsString() 13 | @IsNotEmpty() 14 | readonly repositoryId: string; 15 | } 16 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/change-status-kody-rules.dto.ts: -------------------------------------------------------------------------------- 1 | import { KodyRulesStatus } from '@/core/domain/kodyRules/interfaces/kodyRules.interface'; 2 | import { IsArray, IsEnum, IsString } from 'class-validator'; 3 | 4 | export class ChangeStatusKodyRulesDTO { 5 | @IsArray() 6 | @IsString({ each: true }) 7 | ruleIds: string[]; 8 | 9 | @IsEnum(KodyRulesStatus) 10 | status: KodyRulesStatus; 11 | } 12 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/set-rule-feedback.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsEnum, IsNotEmpty } from 'class-validator'; 2 | import { RuleFeedbackType } from '@/core/domain/kodyRules/entities/ruleLike.entity'; 3 | 4 | export class SetRuleFeedbackDto { 5 | @IsNotEmpty() 6 | @IsEnum(RuleFeedbackType, { 7 | message: 'feedback must be either "positive" or "negative"' 8 | }) 9 | feedback: RuleFeedbackType; 10 | } 11 | -------------------------------------------------------------------------------- /src/shared/utils/decorators/integration-service.decorator.ts: -------------------------------------------------------------------------------- 1 | import { PlatformType } from '@/shared/domain/enums/platform-type.enum'; 2 | import { SetMetadata } from '@nestjs/common'; 3 | 4 | export const IntegrationServiceDecorator = ( 5 | type: PlatformType, 6 | serviceType: 'projectManagement' | 'codeManagement' | 'communication', 7 | ) => { 8 | return SetMetadata('integration', { type, serviceType }); 9 | }; 10 | -------------------------------------------------------------------------------- /src/core/domain/log/contracts/log.service.contracts.ts: -------------------------------------------------------------------------------- 1 | import { LogEntity } from '../entities/log.entity'; 2 | import { ILog } from '../interfaces/log.interface'; 3 | import { ILogRepository } from './log.repository.contracts'; 4 | 5 | export const LOG_SERVICE_TOKEN = Symbol('LogService'); 6 | 7 | export interface ILogService extends ILogRepository { 8 | register(session: Omit): Promise; 9 | } 10 | -------------------------------------------------------------------------------- /src/core/domain/organization/interfaces/organization.interface.ts: -------------------------------------------------------------------------------- 1 | import { IUser } from '@/core/domain/user/interfaces/user.interface'; 2 | import { ITeam } from '../../team/interfaces/team.interface'; 3 | 4 | export interface IOrganization { 5 | uuid: string; 6 | name: string; 7 | tenantName: string; 8 | status: boolean; 9 | users?: Partial[] | null; 10 | teams?: Partial[] | null; 11 | } 12 | -------------------------------------------------------------------------------- /src/core/domain/profile/contracts/profile.service.contract.ts: -------------------------------------------------------------------------------- 1 | import { IProfile } from '@/core/domain/profile/interfaces/profile.interface'; 2 | import { IProfileRepository } from './profile.repository.contract'; 3 | 4 | export const PROFILE_SERVICE_TOKEN = Symbol('ProfileService'); 5 | 6 | export interface IProfileService extends IProfileRepository { 7 | updateByUserId(user_id: string, data: Partial): Promise; 8 | } 9 | -------------------------------------------------------------------------------- /src/shared/utils/enums/severityMatrix.enum.ts: -------------------------------------------------------------------------------- 1 | export enum SeverityMatrixType { 2 | SECURITY = 'security', 3 | CODE_STYLE = 'code_style', 4 | REFACTORING = 'refactoring', 5 | ERROR_HANDLING = 'error_handling', 6 | MAINTAINABILITY = 'maintainability', 7 | POTENTIAL_ISSUES = 'potential_issues', 8 | DOCUMENTATION = 'documentation_and_comments', 9 | PERFORMANCE = 'performance_and_optimization', 10 | } 11 | -------------------------------------------------------------------------------- /src/core/domain/agents/types/auth-details-params.type.ts: -------------------------------------------------------------------------------- 1 | export type AuthDetailsParams = { 2 | authIntegration?: { 3 | identifierKey: string; 4 | identifierValue: string; 5 | }; 6 | integrationConfig?: { 7 | identifierKey: string; 8 | identifierValue: string; 9 | }; 10 | userCommunicationData?: { 11 | communicationId: string; 12 | userName?: string; 13 | }; 14 | }; 15 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/copy-code-review-parameter.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsOptional, IsString } from 'class-validator'; 2 | 3 | export class CopyCodeReviewParameterDTO { 4 | @IsString() 5 | sourceRepositoryId: string; 6 | 7 | @IsString() 8 | targetRepositoryId: string; 9 | 10 | @IsString() 11 | @IsOptional() 12 | targetDirectoryPath: string; 13 | 14 | @IsString() 15 | teamId: string; 16 | } 17 | -------------------------------------------------------------------------------- /src/shared/domain/enums/status-category-azure-boards.enum.ts: -------------------------------------------------------------------------------- 1 | export enum StatusCategoryAzureBoards { 2 | TODO = 'incoming', 3 | INDETERMINATE = 'inProgress', 4 | DONE = 'outgoing', 5 | } 6 | 7 | export const StatusCategoryToColumn = { 8 | // [StatusCategoryAzureBoards.TODO]: 'todo', // not used for now 9 | [StatusCategoryAzureBoards.INDETERMINATE]: 'wip', 10 | [StatusCategoryAzureBoards.DONE]: 'done', 11 | }; 12 | -------------------------------------------------------------------------------- /test/jest-e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleFileExtensions": ["js", "json", "ts"], 3 | "rootDir": ".", 4 | "testEnvironment": "node", 5 | "testRegex": ".e2e-spec.ts$", 6 | "transform": { 7 | "^.+\\.(t|j)s$": [ 8 | "ts-jest", 9 | { 10 | "diagnostics": false, 11 | "isolatedModules": true 12 | } 13 | ] 14 | }, 15 | "moduleNameMapper": { 16 | "^@/(.*)$": "/src/$1" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/kodus-flow/src/kernel/index.ts: -------------------------------------------------------------------------------- 1 | export { ExecutionKernel, createKernel } from './kernel.js'; 2 | 3 | export { 4 | createSnapshot, 5 | restoreSnapshot, 6 | validateSnapshot, 7 | validateDeltaSnapshot, 8 | diffSnapshot, 9 | stableHash, 10 | } from './snapshot.js'; 11 | 12 | export { 13 | createPersistor, 14 | getPersistor, 15 | setPersistor, 16 | BasePersistor, 17 | } from './persistor.js'; 18 | -------------------------------------------------------------------------------- /src/core/application/use-cases/pullRequests/index.ts: -------------------------------------------------------------------------------- 1 | import { BackfillHistoricalPRsUseCase } from './backfill-historical-prs.use-case'; 2 | import { GetEnrichedPullRequestsUseCase } from './get-enriched-pull-requests.use-case'; 3 | import { SavePullRequestUseCase } from './save.use-case'; 4 | 5 | export const UseCases = [ 6 | SavePullRequestUseCase, 7 | GetEnrichedPullRequestsUseCase, 8 | BackfillHistoricalPRsUseCase, 9 | ]; 10 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/updateInfoOrgAndPhone.dto.ts: -------------------------------------------------------------------------------- 1 | import { 2 | IsNotEmpty, 3 | IsOptional, 4 | IsString, 5 | IsPhoneNumber, 6 | } from 'class-validator'; 7 | 8 | export class UpdateInfoOrganizationAndPhoneDto { 9 | @IsString() 10 | @IsNotEmpty({ message: 'The name field is required.' }) 11 | public name: string; 12 | 13 | @IsString() 14 | @IsOptional() 15 | public phone?: string; 16 | } 17 | -------------------------------------------------------------------------------- /src/shared/domain/enums/platform-type.enum.ts: -------------------------------------------------------------------------------- 1 | export enum PlatformType { 2 | INTERNAL = 'INTERNAL', 3 | GITHUB = 'GITHUB', 4 | GITLAB = 'GITLAB', 5 | JIRA = 'JIRA', 6 | SLACK = 'SLACK', 7 | NOTION = 'NOTION', 8 | MSTEAMS = 'MSTEAMS', 9 | DISCORD = 'DISCORD', 10 | AZURE_BOARDS = 'AZURE_BOARDS', 11 | AZURE_REPOS = 'AZURE_REPOS', 12 | KODUS_WEB = 'KODUS_WEB', 13 | BITBUCKET = 'BITBUCKET', 14 | } 15 | -------------------------------------------------------------------------------- /docker/prod-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e # Exit immediately if a command exits with a non-zero status 3 | 4 | echo "▶ Starting deployment entrypoint..." 5 | 6 | # Run Migrations 7 | echo "▶ Running Migrations..." 8 | npm run migration:run:prod 9 | 10 | echo "▶ Running Seeds..." 11 | npm run seed:prod 12 | 13 | echo "▶ Starting Application..." 14 | # exec "$@" executes the CMD defined in the Dockerfile (pm2-runtime ...) 15 | exec "$@" 16 | -------------------------------------------------------------------------------- /packages/kodus-common/README.md: -------------------------------------------------------------------------------- 1 | # Kodus Common 2 | 3 | This repository contains common utilities and components used across Kodus projects. It is designed to be a shared library that can be easily integrated into various applications. 4 | 5 | ## Usage 6 | 7 | Simply import the components or utilities you need from the package. 8 | 9 | For LLM related utilities you also need to fill your `.env` file with the variables in `.env.example` file. 10 | -------------------------------------------------------------------------------- /packages/kodus-common/src/llm/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Automatically generated by barrelsby. 3 | */ 4 | 5 | export * from './builder'; 6 | export * from './byokProvider.service'; 7 | export * from './callback'; 8 | export * from './helper'; 9 | export * from './llm.module'; 10 | export * from './llmModelProvider.service'; 11 | export * from './parser'; 12 | export * from './promptRunner.service'; 13 | export * from './providerAdapters/index'; 14 | -------------------------------------------------------------------------------- /nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/nest-cli", 3 | "collection": "@nestjs/schematics", 4 | "sourceRoot": "src", 5 | "compilerOptions": { 6 | "deleteOutDir": true, 7 | "assets": [ 8 | { 9 | "include": "shared/utils/translations/dictionaries/**", 10 | "outDir": "dist" 11 | } 12 | ], 13 | "watchAssets": true 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/core/domain/integrationConfigs/enums/stringTimeInterval.enum.ts: -------------------------------------------------------------------------------- 1 | export enum STRING_TIME_INTERVAL { 2 | LAST_12_HOURS = '-12h', 3 | LAST_24_HOURS = '-24h', 4 | LAST_48_HOURS = '-48h', 5 | LAST_72_HOURS = '-72h', 6 | LAST_7_DAYS = '-7d', 7 | LAST_14_DAYS = '-14d', 8 | LAST_20_DAYS = '-20d', 9 | LAST_21_DAYS = '-21d', 10 | LAST_1_MONTH = '-1M', 11 | LAST_2_MONTHS = '-2M', 12 | LAST_3_MONTHS = '-3M', 13 | } 14 | -------------------------------------------------------------------------------- /src/core/domain/log/interfaces/log.interface.ts: -------------------------------------------------------------------------------- 1 | export interface ILog { 2 | uuid: string; 3 | timestamp?: string; 4 | level: 'info' | 'error' | 'warn' | 'debug' | 'verbose'; 5 | message: string; 6 | stack: any; 7 | metadata?: Record; 8 | requestId?: string; 9 | executionId?: string; 10 | serviceName?: string; 11 | traceId?: string; 12 | spanId?: string; 13 | environment?: string; 14 | } 15 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/update-another-user.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsEnum, IsOptional } from 'class-validator'; 2 | import { Role } from '@/core/domain/permissions/enums/permissions.enum'; 3 | import { STATUS } from '@/config/types/database/status.type'; 4 | 5 | export class UpdateAnotherUserDto { 6 | @IsOptional() 7 | @IsEnum(STATUS) 8 | status?: STATUS; 9 | 10 | @IsOptional() 11 | @IsEnum(Role) 12 | role?: Role; 13 | } 14 | -------------------------------------------------------------------------------- /src/config/loaders/rabbitmq.loader.ts: -------------------------------------------------------------------------------- 1 | import { registerAs } from '@nestjs/config'; 2 | import { RabbitMQConfig } from '../types/environment/rabbitMQ.type'; 3 | 4 | export const RabbitMQLoader = registerAs( 5 | 'rabbitMQConfig', 6 | (): RabbitMQConfig => ({ 7 | API_RABBITMQ_URI: process.env.API_RABBITMQ_URI || 'amqp://localhost:5672/', 8 | API_RABBITMQ_ENABLED: process.env.API_RABBITMQ_ENABLED === 'true' || true, 9 | }), 10 | ); 11 | -------------------------------------------------------------------------------- /src/config/types/integrations.type.ts: -------------------------------------------------------------------------------- 1 | export type IntegrationSelected = { 2 | id: string; 3 | name?: string | undefined; 4 | key?: string | undefined; 5 | url?: string | undefined; 6 | type?: string | undefined; 7 | }; 8 | 9 | export type SaveIntegrationSelected = { 10 | userId?: string; 11 | domainSelected?: IntegrationSelected; 12 | projectSelected?: IntegrationSelected; 13 | channelSelected?: IntegrationSelected; 14 | }; 15 | -------------------------------------------------------------------------------- /src/core/domain/interactions/interfaces/interactions-execution.interface.ts: -------------------------------------------------------------------------------- 1 | export interface IInteractionExecution { 2 | uuid?: string; 3 | interactionDate: Date; 4 | platformUserId: string; 5 | interactionType: string; // 'chat' or 'button' 6 | interactionCommand?: string; // Command typed for chat interactions 7 | buttonLabel?: string; // Button text for button interactions 8 | teamId: string; 9 | organizationId: string; 10 | } 11 | -------------------------------------------------------------------------------- /packages/kodus-common/.env.example: -------------------------------------------------------------------------------- 1 | # API Keys 2 | API_OPEN_AI_API_KEY= 3 | API_GOOGLE_AI_API_KEY= 4 | API_ANTHROPIC_API_KEY= 5 | API_FIREWORKS_API_KEY= 6 | API_NOVITA_AI_API_KEY= 7 | API_VERTEX_AI_API_KEY= 8 | 9 | # LangChain 10 | LANGCHAIN_TRACING_V2=true 11 | LANGCHAIN_ENDPOINT=https://api.smith.langchain.com 12 | LANGCHAIN_HUB_API_URL=https://api.smith.langchain.com 13 | LANGCHAIN_API_KEY= 14 | LANGCHAIN_PROJECT=my-project 15 | LANGCHAIN_CALLBACKS_BACKGROUND=true 16 | -------------------------------------------------------------------------------- /src/core/domain/organizationParameters/interfaces/organizationParameters.interface.ts: -------------------------------------------------------------------------------- 1 | import { OrganizationParametersKey } from '@/shared/domain/enums/organization-parameters-key.enum'; 2 | import { IOrganization } from '../../organization/interfaces/organization.interface'; 3 | 4 | export interface IOrganizationParameters { 5 | uuid: string; 6 | configKey: OrganizationParametersKey; 7 | configValue: any; 8 | organization?: Partial; 9 | } 10 | -------------------------------------------------------------------------------- /src/shared/utils/langchainCommon/prompts/kodyRulesRecommendation.ts: -------------------------------------------------------------------------------- 1 | import z from 'zod'; 2 | 3 | export const kodyRulesRecommendationSchema = z.object({ 4 | recommendations: z.array( 5 | z.object({ 6 | uuid: z.string(), 7 | reason: z.string(), 8 | relevanceScore: z.number().min(1).max(10), 9 | }) 10 | ), 11 | }); 12 | 13 | export type KodyRulesRecommendation = z.infer; 14 | -------------------------------------------------------------------------------- /src/core/domain/azureRepos/entities/azureReposRepository.type.ts: -------------------------------------------------------------------------------- 1 | import { AzureReposProject } from './azureReposProject.type'; 2 | 3 | export interface AzureReposRepository { 4 | id: string; 5 | name: string; 6 | url: string; 7 | project: AzureReposProject; 8 | defaultBranch: string; 9 | size: number; 10 | remoteUrl: string; 11 | sshUrl: string; 12 | webUrl: string; 13 | isDisabled: boolean; 14 | isInMaintenance: boolean; 15 | } 16 | -------------------------------------------------------------------------------- /src/core/infrastructure/adapters/mcp/tools/index.ts: -------------------------------------------------------------------------------- 1 | // Export all tool definitions 2 | export { CodeManagementTools } from './codeManagement.tools'; 3 | export { KodyRulesTools } from './kodyRules.tools'; 4 | export { KodyIssuesTools } from './kodyIssues.tools'; 5 | 6 | // Tool categories for easy discovery 7 | export const TOOL_CATEGORIES = { 8 | CODE_MANAGEMENT: 'codeManagement', 9 | KODY_RULES: 'kodyRules', 10 | KODY_ISSUES: 'kodyIssues', 11 | } as const; 12 | -------------------------------------------------------------------------------- /src/core/infrastructure/adapters/services/pipeline/interfaces/pipeline.interface.ts: -------------------------------------------------------------------------------- 1 | import { PipelineContext } from './pipeline-context.interface'; 2 | 3 | export interface PipelineStage { 4 | stageName: string; 5 | execute(context: TContext): Promise; 6 | } 7 | 8 | export interface IPipeline { 9 | pipeLineName: string; 10 | execute(context: TContext): Promise; 11 | } 12 | -------------------------------------------------------------------------------- /src/core/domain/automation/interfaces/automation.interface.ts: -------------------------------------------------------------------------------- 1 | import { AutomationLevel } from '@/shared/domain/enums/automations-level.enum'; 2 | import { AutomationType } from '../enums/automation-type'; 3 | 4 | export interface IAutomation { 5 | uuid: string; 6 | name: string; 7 | description: string; 8 | tags: string[]; 9 | antiPatterns: string[]; 10 | status: boolean; 11 | automationType: AutomationType; 12 | level: AutomationLevel; 13 | } 14 | -------------------------------------------------------------------------------- /src/shared/domain/contracts/execute.automation.service.contracts.ts: -------------------------------------------------------------------------------- 1 | export const EXECUTE_AUTOMATION_SERVICE_TOKEN = Symbol( 2 | 'ExecuteAutomationService', 3 | ); 4 | 5 | export interface IExecuteAutomationService { 6 | executeStrategy(name: string, payload?: any): Promise; 7 | setupStrategy(name: string, payload?: any): Promise; 8 | stopStrategy(name: string, payload?: any): Promise; 9 | getAutomationMethods(name: string): Promise; 10 | } 11 | -------------------------------------------------------------------------------- /src/core/application/use-cases/permissions/index.ts: -------------------------------------------------------------------------------- 1 | import { AssignReposUseCase } from './assign-repos.use-case'; 2 | import { CanAccessUseCase } from './can-access.use-case'; 3 | import { GetAssignedReposUseCase } from './get-assigned-repos.use-case'; 4 | import { GetPermissionsUseCase } from './get-permissions.use-case'; 5 | 6 | export const UseCases = [ 7 | GetPermissionsUseCase, 8 | CanAccessUseCase, 9 | GetAssignedReposUseCase, 10 | AssignReposUseCase, 11 | ]; 12 | -------------------------------------------------------------------------------- /packages/kodus-flow/src/runtime/middleware/index.ts: -------------------------------------------------------------------------------- 1 | export { withRetry } from './retry.js'; 2 | export { withTimeout } from './timeout.js'; 3 | export { withConcurrency } from './concurrency.js'; 4 | export { schedule } from './schedule.js'; 5 | export { withValidate, withValidateMiddleware } from './validate.js'; 6 | export { withObservability } from './observability.js'; 7 | 8 | export { createStandardMiddleware } from './composites.js'; 9 | 10 | export * from './circuit-breaker.js'; 11 | -------------------------------------------------------------------------------- /src/core/domain/interactions/contracts/interaction.repository.contracts.ts: -------------------------------------------------------------------------------- 1 | import { IInteractionExecution } from '@/core/domain/interactions/interfaces/interactions-execution.interface'; 2 | 3 | export const INTERACTION_EXECUTION_REPOSITORY_TOKEN = Symbol( 4 | 'InteractionExecutionRepository', 5 | ); 6 | 7 | export interface IInteractionExecutionRepository { 8 | create( 9 | interactionExecution: IInteractionExecution, 10 | ): Promise; 11 | } 12 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/controllers/segment.controller.ts: -------------------------------------------------------------------------------- 1 | import { TrackUseCase } from '@/core/application/use-cases/segment/track.use-case'; 2 | import { Body, Controller, Post } from '@nestjs/common'; 3 | 4 | @Controller('segment') 5 | export class SegmentController { 6 | constructor(private readonly trackUseCase: TrackUseCase) {} 7 | 8 | @Post('/track') 9 | public async track(@Body() body: any) { 10 | return this.trackUseCase.execute(body); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/config/types/general/query-parser.type.ts: -------------------------------------------------------------------------------- 1 | import { Json } from './json.type'; 2 | 3 | export type QueryParser = { 4 | filter: Json; 5 | options: QueryParserOptions; 6 | }; 7 | 8 | export type PopulatePath = { 9 | path: string; 10 | populate: string | PopulatePath; 11 | }; 12 | 13 | export type QueryParserOptions = { 14 | select?: Json; 15 | populate?: PopulatePath[]; 16 | limit?: number; 17 | page?: number; 18 | sort?: Json; 19 | lean?: boolean; 20 | }; 21 | -------------------------------------------------------------------------------- /packages/kodus-flow/src/engine/strategies/prompts/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | StrategyFormatters, 3 | ToolParameterFormatter, 4 | ContextFormatter, 5 | SchemaFormatter, 6 | } from './strategy-formatters.js'; 7 | 8 | export type { RewooEvidenceItem } from './strategy-formatters.js'; 9 | 10 | export { 11 | StrategyPromptFactory, 12 | ReWooPrompts, 13 | ReActPrompts, 14 | } from './strategy-prompts.js'; 15 | 16 | export { default as StrategyPrompts } from './strategy-prompts.js'; 17 | -------------------------------------------------------------------------------- /src/config/database/mongodb/mongoose-connection.factory.ts: -------------------------------------------------------------------------------- 1 | import { mongooseHideObjectId } from '@/shared/utils/mongo-utils'; 2 | import { Connection } from 'mongoose'; 3 | import * as mongoosePaginate from 'mongoose-paginate'; 4 | 5 | export class MongooseConnectionFactory { 6 | public static createForInstance(connection: Connection): Connection { 7 | connection.plugin(mongooseHideObjectId); 8 | connection.plugin(mongoosePaginate); 9 | return connection; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/paginated-library-kody-rules.dto.ts: -------------------------------------------------------------------------------- 1 | import { LibraryKodyRule } from '@/config/types/kodyRules.type'; 2 | 3 | export class PaginationMetadata { 4 | currentPage: number; 5 | totalPages: number; 6 | totalItems: number; 7 | itemsPerPage: number; 8 | hasNextPage: boolean; 9 | hasPreviousPage: boolean; 10 | } 11 | 12 | export class PaginatedLibraryKodyRulesResponse { 13 | data: LibraryKodyRule[]; 14 | pagination: PaginationMetadata; 15 | } 16 | -------------------------------------------------------------------------------- /packages/kodus-flow/env.example: -------------------------------------------------------------------------------- 1 | # Kodus Flow Environment Configuration 2 | # Copy this file to .env and fill in your actual values 3 | 4 | # LLM Configuration 5 | GEMINI_API_KEY=your_gemini_api_key_here 6 | GOOGLE_API_KEY=your_google_api_key_here 7 | 8 | # OpenAI Configuration (optional) 9 | OPENAI_API_KEY=your_openai_api_key_here 10 | 11 | # Environment 12 | NODE_ENV=development 13 | 14 | # Observability 15 | LOG_LEVEL=debug 16 | TELEMETRY_ENABLED=true 17 | 18 | # Test Configuration 19 | VITEST_ENV=test 20 | -------------------------------------------------------------------------------- /src/core/application/use-cases/segment/track.use-case.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { track } from '@/shared/utils/segment'; 3 | 4 | @Injectable() 5 | export class TrackUseCase { 6 | constructor() {} 7 | 8 | async execute(data: { 9 | userId: string; 10 | event: string; 11 | properties?: any; 12 | }): Promise { 13 | const { userId, event, properties } = data; 14 | 15 | track(userId, event, properties); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/shared/utils/buffer/arrays.ts: -------------------------------------------------------------------------------- 1 | export function concatUint8Arrays(...arrays: Uint8Array[]): Uint8Array { 2 | if (arrays.length === 0) { 3 | return new Uint8Array(0); 4 | } 5 | 6 | const totalLength = arrays.reduce((sum, arr) => sum + arr.length, 0); 7 | const result = new Uint8Array(totalLength); 8 | 9 | let offset = 0; 10 | for (const arr of arrays) { 11 | result.set(arr, offset); 12 | offset += arr.length; 13 | } 14 | 15 | return result; 16 | } 17 | -------------------------------------------------------------------------------- /src/core/domain/user/contracts/user.service.contract.ts: -------------------------------------------------------------------------------- 1 | import { UserEntity } from '../entities/user.entity'; 2 | import { IUser } from '../interfaces/user.interface'; 3 | import { IUserRepository } from './user.repository.contract'; 4 | 5 | export const USER_SERVICE_TOKEN = Symbol('UserService'); 6 | 7 | export interface IUsersService extends IUserRepository { 8 | checkPassword(email: string, password: string): Promise; 9 | register(payload: Omit): Promise; 10 | } 11 | -------------------------------------------------------------------------------- /src/shared/utils/polling/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | // Main functions 3 | calculateBackoffInterval, 4 | calculateBackoffIntervalExact, 5 | calculateBackoffWithMetadata, 6 | 7 | // Helpers 8 | createBackoffCalculator, 9 | generateBackoffSequence, 10 | generateBackoffSequenceWithMetadata, 11 | printBackoffSequence, 12 | 13 | // Presets 14 | BackoffPresets, 15 | 16 | // Types 17 | type BackoffOptions, 18 | type BackoffResult, 19 | } from './exponential-backoff'; 20 | -------------------------------------------------------------------------------- /src/core/domain/codeReviewExecutions/interfaces/codeReviewExecution.interface.ts: -------------------------------------------------------------------------------- 1 | import { AutomationStatus } from '../../automation/enums/automation-status'; 2 | import { IAutomationExecution } from '../../automation/interfaces/automation-execution.interface'; 3 | 4 | export type CodeReviewExecution = { 5 | uuid: string; 6 | createdAt: Date; 7 | updatedAt: Date; 8 | 9 | automationExecution: Partial; 10 | status: AutomationStatus; 11 | message?: string | undefined; 12 | }; 13 | -------------------------------------------------------------------------------- /src/config/types/general/pullRequestMessages.type.ts: -------------------------------------------------------------------------------- 1 | export enum PullRequestMessageType { 2 | START_REVIEW = 'start_review', 3 | END_REVIEW = 'end_review', 4 | } 5 | 6 | export enum PullRequestMessageStatus { 7 | EVERY_PUSH = 'every_push', 8 | ONLY_WHEN_OPENED = 'only_when_opened', 9 | OFF = 'off', 10 | ACTIVE = 'active', 11 | INACTIVE = 'inactive', 12 | } 13 | 14 | export enum ConfigLevel { 15 | GLOBAL = 'global', 16 | REPOSITORY = 'repository', 17 | DIRECTORY = 'directory', 18 | } 19 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/finish-onboarding.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsBoolean, IsNumber, IsOptional, IsString } from 'class-validator'; 2 | 3 | export class FinishOnboardingDTO { 4 | @IsString() 5 | teamId: string; 6 | 7 | @IsBoolean() 8 | reviewPR: boolean; 9 | 10 | @IsOptional() 11 | @IsString() 12 | repositoryId?: string; 13 | 14 | @IsOptional() 15 | @IsString() 16 | repositoryName?: string; 17 | 18 | @IsOptional() 19 | @IsNumber() 20 | pullNumber?: number; 21 | } 22 | -------------------------------------------------------------------------------- /ecosystem.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | apps: [ 3 | { 4 | name: 'kodus-orchestrator', 5 | script: './dist/src/main.js', 6 | out_file: '/app/logs/kodus-orchestrator/out.log', 7 | error_file: '/app/logs/kodus-orchestrator/error.log', 8 | env_homolog: { 9 | API_NODE_ENV: 'homolog', 10 | }, 11 | env_production: { 12 | API_NODE_ENV: 'production', 13 | }, 14 | }, 15 | ], 16 | }; 17 | -------------------------------------------------------------------------------- /packages/kodus-flow/src/adapters/llm/index.ts: -------------------------------------------------------------------------------- 1 | import { LLMAdapter, LLMConfig } from '../../core/types/allTypes.js'; 2 | 3 | export function createLLMAdapter(_config: LLMConfig): LLMAdapter { 4 | throw new Error( 5 | 'LLM Adapter não implementado no SDK. O provider de LLM deve ser fornecido externamente pelo projeto principal.', 6 | ); 7 | } 8 | 9 | export function createDefaultLLMAdapter(): LLMAdapter | null { 10 | return null; 11 | } 12 | 13 | export { createMockLLMProvider } from './mock-provider.js'; 14 | -------------------------------------------------------------------------------- /packages/kodus-flow/src/engine/index.ts: -------------------------------------------------------------------------------- 1 | // Removido - dependências de kernel simplificadas 2 | 3 | export { AgentEngine, createAgent } from './agents/agent-engine.js'; 4 | 5 | export { AgentCore, createAgentCore } from './agents/agent-core.js'; 6 | 7 | export { 8 | AgentLifecycleHandler, 9 | createAgentLifecycleHandler, 10 | } from './agents/agent-lifecycle.js'; 11 | 12 | export { AgentExecutor, createWorkflowAgent } from './agents/agent-executor.js'; 13 | 14 | export { ToolEngine } from './tools/tool-engine.js'; 15 | -------------------------------------------------------------------------------- /tsconfig-paths-bootstrap.js: -------------------------------------------------------------------------------- 1 | import { compilerOptions } from './tsconfig.json'; 2 | import { register } from 'tsconfig-paths'; 3 | 4 | const paths = compilerOptions.paths; 5 | 6 | register({ 7 | baseUrl: compilerOptions.outDir, 8 | paths: Object.keys(paths).reduce( 9 | (agg, key) => ({ 10 | ...agg, 11 | [key]: paths[key].map((p) => 12 | p.replace(compilerOptions.baseUrl, compilerOptions.outDir), 13 | ), 14 | }), 15 | {}, 16 | ), 17 | }); 18 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/backfill-prs.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsString, IsOptional, IsArray, IsDateString } from 'class-validator'; 2 | 3 | export class BackfillPRsDto { 4 | @IsString() 5 | public teamId: string; 6 | 7 | @IsOptional() 8 | @IsArray() 9 | @IsString({ each: true }) 10 | public repositoryIds?: string[]; 11 | 12 | @IsOptional() 13 | @IsDateString() 14 | public startDate?: string; 15 | 16 | @IsOptional() 17 | @IsDateString() 18 | public endDate?: string; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /packages/kodus-flow/src/context/core/utils/budget.ts: -------------------------------------------------------------------------------- 1 | import type { ContextLayer, TokenBudget } from '../interfaces.js'; 2 | 3 | export function computeBudget( 4 | limit: number, 5 | layers: ContextLayer[], 6 | ): TokenBudget { 7 | return { 8 | limit, 9 | usage: layers.reduce((acc, layer) => acc + layer.tokens, 0), 10 | breakdown: layers.reduce>((acc, layer) => { 11 | acc[layer.kind] = layer.tokens; 12 | return acc; 13 | }, {}), 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /src/core/domain/integrationConfigs/interfaces/integration-config.interface.ts: -------------------------------------------------------------------------------- 1 | import { IntegrationConfigKey } from '@/shared/domain/enums/Integration-config-key.enum'; 2 | import { IIntegration } from '../../integrations/interfaces/integration.interface'; 3 | import { ITeam } from '../../team/interfaces/team.interface'; 4 | 5 | export interface IIntegrationConfig { 6 | uuid: string; 7 | configKey: IntegrationConfigKey; 8 | configValue: any; 9 | integration?: Partial; 10 | team?: Partial; 11 | } 12 | -------------------------------------------------------------------------------- /src/core/domain/issues/entities/issue-creation-config.entity.ts: -------------------------------------------------------------------------------- 1 | import { SeverityLevel } from '@/shared/utils/enums/severityLevel.enum'; 2 | 3 | export interface IssueCreationConfig { 4 | automaticCreationEnabled: boolean; 5 | sourceFilters: { 6 | includeKodyRules: boolean; 7 | includeCodeReviewEngine: boolean; 8 | }; 9 | severityFilters: { 10 | minimumSeverity: SeverityLevel; 11 | allowedSeverities: SeverityLevel[]; 12 | }; 13 | organizationId: string; 14 | teamId?: string; 15 | } -------------------------------------------------------------------------------- /src/core/infrastructure/adapters/services/codeBase/codeReviewPipeline/stages/contracts/loadExternalContextStage.contract.ts: -------------------------------------------------------------------------------- 1 | import { BasePipelineStage } from '../../../../pipeline/base-stage.abstract'; 2 | import { CodeReviewPipelineContext } from '../../context/code-review-pipeline.context'; 3 | 4 | export const LOAD_EXTERNAL_CONTEXT_STAGE_TOKEN = 'LOAD_EXTERNAL_CONTEXT_STAGE_TOKEN'; 5 | 6 | export interface ILoadExternalContextStage extends BasePipelineStage { 7 | readonly stageName: string; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/create-user-organization-oauth.dto.ts: -------------------------------------------------------------------------------- 1 | import { AuthProvider } from '@/shared/domain/enums/auth-provider.enum'; 2 | import { IsEmail, IsString, IsEnum } from 'class-validator'; 3 | 4 | export class CreateUserOrganizationOAuthDto { 5 | @IsString() 6 | public name: string; 7 | 8 | @IsString() 9 | @IsEmail() 10 | public email: string; 11 | 12 | @IsString() 13 | public refreshToken: string; 14 | 15 | @IsEnum(AuthProvider) 16 | public authProvider: AuthProvider; 17 | } 18 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/paginated-enriched-pull-requests.dto.ts: -------------------------------------------------------------------------------- 1 | import { EnrichedPullRequestResponse } from './enriched-pull-request-response.dto'; 2 | 3 | export class PaginationMetadata { 4 | currentPage: number; 5 | totalPages: number; 6 | totalItems: number; 7 | itemsPerPage: number; 8 | hasNextPage: boolean; 9 | hasPreviousPage: boolean; 10 | } 11 | 12 | export class PaginatedEnrichedPullRequestsResponse { 13 | data: EnrichedPullRequestResponse[]; 14 | pagination: PaginationMetadata; 15 | } 16 | -------------------------------------------------------------------------------- /src/modules/cache.module.ts: -------------------------------------------------------------------------------- 1 | import { CacheService } from '@/shared/utils/cache/cache.service'; 2 | import { CacheModule } from '@nestjs/cache-manager'; 3 | import { Global, Module } from '@nestjs/common'; 4 | 5 | @Global() 6 | @Module({ 7 | imports: [ 8 | CacheModule.register({ 9 | store: 'memory', 10 | max: 50000, 11 | isGlobal: true, 12 | }), 13 | ], 14 | providers: [CacheService], 15 | exports: [CacheService, CacheModule], 16 | }) 17 | export class GlobalCacheModule {} 18 | -------------------------------------------------------------------------------- /src/shared/utils/formatters/leadTime.ts: -------------------------------------------------------------------------------- 1 | export function LeadTimeFormat(leadView) { 2 | const days = Math.floor(leadView / 24); 3 | let hours = Math.floor(leadView % 24); 4 | let minutes = Math.round((leadView % 1) * 60); 5 | 6 | if (minutes >= 60) { 7 | minutes -= 60; 8 | hours += 1; 9 | } 10 | 11 | let result = ''; 12 | if (days > 0) result += `${days}d `; 13 | if (hours > 0) result += `${hours}h `; 14 | if (minutes > 0) result += `${minutes}m`; 15 | 16 | return result.trim(); 17 | } 18 | -------------------------------------------------------------------------------- /src/config/loaders/jwt.config.loader.ts: -------------------------------------------------------------------------------- 1 | import { registerAs } from '@nestjs/config'; 2 | import { JWT } from '../types/jwt/jwt'; 3 | import type { StringValue } from 'ms'; 4 | 5 | export const jwtConfigLoader = registerAs( 6 | 'jwtConfig', 7 | (): JWT => ({ 8 | secret: process.env.API_JWT_SECRET, 9 | expiresIn: process.env.API_JWT_EXPIRES_IN as StringValue, 10 | refreshSecret: process.env.API_JWT_REFRESH_SECRET, 11 | refreshExpiresIn: process.env.API_JWT_REFRESH_EXPIRES_IN as StringValue, 12 | }), 13 | ); 14 | -------------------------------------------------------------------------------- /src/core/domain/authIntegrations/contracts/auth-integration.service.contracts.ts: -------------------------------------------------------------------------------- 1 | import { OrganizationAndTeamData } from '@/config/types/general/organizationAndTeamData'; 2 | import { IAuthIntegrationRepository } from './auth-integration.repository.contracts'; 3 | 4 | export const AUTH_INTEGRATION_SERVICE_TOKEN = Symbol('AuthIntegrationService'); 5 | 6 | export interface IAuthIntegrationService extends IAuthIntegrationRepository { 7 | getPlatformAuthDetails( 8 | organizationAndTeamData: OrganizationAndTeamData, 9 | ): Promise; 10 | } 11 | -------------------------------------------------------------------------------- /src/core/domain/authIntegrations/interfaces/auth-integration.interface.ts: -------------------------------------------------------------------------------- 1 | import { IIntegration } from '../../integrations/interfaces/integration.interface'; 2 | import { IOrganization } from '../../organization/interfaces/organization.interface'; 3 | import { ITeam } from '../../team/interfaces/team.interface'; 4 | 5 | export interface IAuthIntegration { 6 | uuid: string; 7 | status: boolean; 8 | authDetails?: any; 9 | organization?: Partial; 10 | team?: Partial; 11 | integration?: Partial; 12 | } 13 | -------------------------------------------------------------------------------- /src/core/domain/pullRequests/enums/priorityStatus.enum.ts: -------------------------------------------------------------------------------- 1 | export enum PriorityStatus { 2 | PRIORITIZED = 'prioritized', 3 | PRIORITIZED_BY_CLUSTERING = 'prioritized-by-clustering', 4 | DISCARDED_BY_SEVERITY = 'discarded-by-severity', 5 | DISCARDED_BY_QUANTITY = 'discarded-by-quantity', 6 | DISCARDED_BY_CLUSTERING = 'discarded-by-clustering', 7 | DISCARDED_BY_SAFEGUARD = 'discarded-by-safeguard', 8 | DISCARDED_BY_CODE_DIFF = 'discarded-by-code-diff', 9 | DISCARDED_BY_KODY_FINE_TUNING = 'discarded-by-kody-fine-tuning', 10 | } 11 | -------------------------------------------------------------------------------- /src/config/types/general/commit.type.ts: -------------------------------------------------------------------------------- 1 | export type Commit = { 2 | sha: string; 3 | commit: { 4 | author: { 5 | id?: string; 6 | name: string; 7 | email: string; 8 | // This field represents the timestamp when the author made the commit locally. Wereas created_at (from the commit) typically represents the timestamp when the commit was created in the repository. 9 | date: string; 10 | }; 11 | message: string; 12 | }; 13 | parents?: Array<{ sha: string }>; 14 | }; 15 | -------------------------------------------------------------------------------- /src/core/domain/webhookLog/contracts/webhook-log.service.contract.ts: -------------------------------------------------------------------------------- 1 | import { PlatformType } from '@/shared/domain/enums/platform-type.enum'; 2 | import { IWebhookLogRepository } from './webhook-log.repository.contract'; 3 | 4 | export const WEBHOOK_LOG_SERVICE = Symbol('WEBHOOK_LOG_SERVICE'); 5 | 6 | export interface IWebhookLogService extends IWebhookLogRepository { 7 | log( 8 | platform: PlatformType, 9 | event: string, 10 | payload: Record, 11 | meta?: Record, 12 | ): Promise; 13 | } 14 | -------------------------------------------------------------------------------- /src/shared/interfaces/kody-ast-analyze-context-preparation.interface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Kodus Tech. All rights reserved. 4 | */ 5 | 6 | import { AIAnalysisResult, AnalysisContext } from '@/config/types/general/codeReview.type'; 7 | 8 | export const KODY_AST_ANALYZE_CONTEXT_PREPARATION_TOKEN = Symbol( 9 | 'KodyASTAnalyzeContextPreparation', 10 | ); 11 | 12 | export interface IKodyASTAnalyzeContextPreparationService { 13 | prepareKodyASTAnalyzeContext( 14 | context: AnalysisContext, 15 | ): Promise 16 | } 17 | -------------------------------------------------------------------------------- /src/shared/utils/formatters/leadTimeForChange.ts: -------------------------------------------------------------------------------- 1 | export function LeadTimeForChangeFormat(leadView) { 2 | const days = Math.floor(leadView / 24); 3 | let hours = Math.floor(leadView % 24); 4 | let minutes = Math.round((leadView % 1) * 60); 5 | 6 | if (minutes >= 60) { 7 | minutes -= 60; 8 | hours += 1; 9 | } 10 | 11 | let result = ''; 12 | if (days > 0) result += `${days}d `; 13 | if (hours > 0) result += `${hours}h `; 14 | if (minutes > 0) result += `${minutes}m`; 15 | 16 | return result.trim(); 17 | } 18 | -------------------------------------------------------------------------------- /src/shared/utils/langchainCommon/customStringOutputParser.ts: -------------------------------------------------------------------------------- 1 | import { MessageContentComplex } from '@langchain/core/messages'; 2 | import { StringOutputParser } from '@langchain/core/output_parsers'; 3 | 4 | export class CustomStringOutputParser extends StringOutputParser { 5 | protected _messageContentComplexToString( 6 | content: MessageContentComplex, 7 | ): string { 8 | if (content?.type === 'reasoning') { 9 | return ''; 10 | } 11 | return super._messageContentComplexToString(content); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /docker/dev-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -eu 3 | 4 | echo "▶ dev-entrypoint: starting (NODE_ENV=${NODE_ENV:-})" 5 | 6 | if [ ! -x node_modules/.bin/nest ]; then 7 | echo "▶ Installing deps (yarn --frozen-lockfile)…" 8 | yarn install --frozen-lockfile 9 | fi 10 | 11 | echo "▶ Running Migrations..." 12 | npm run migration:run:internal 13 | 14 | echo "▶ Running Seeds..." 15 | npm run seed:internal 16 | 17 | [ -d ".yalc/@kodus/flow" ] && echo "▶ yalc detected: using .yalc/@kodus/flow" 18 | 19 | echo "▶ starting nodemon…" 20 | exec nodemon --config nodemon.json 21 | -------------------------------------------------------------------------------- /jest.config.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | preset: 'ts-jest', 3 | testEnvironment: 'node', 4 | moduleFileExtensions: ['ts', 'js', 'json'], 5 | testMatch: ['**/*.spec.ts', '**/*.integration.spec.ts', '**/*.e2e-spec.ts'], 6 | transform: { 7 | '^.+\\.(t|j)s$': ['ts-jest', { tsconfig: 'tsconfig.spec.json', diagnostics: false }], 8 | }, 9 | moduleNameMapper: { 10 | '^@/(.*)$': '/src/$1', 11 | '^@context-os-core/(.*)$': '/packages/kodus-flow/src/context/core/$1', 12 | }, 13 | modulePathIgnorePatterns: ['/.yalc'], 14 | }; 15 | -------------------------------------------------------------------------------- /src/core/application/use-cases/dryRun/index.ts: -------------------------------------------------------------------------------- 1 | import { ExecuteDryRunUseCase } from './execute-dry-run.use-case'; 2 | import { GetDryRunUseCase } from './get-dry-run.use-case'; 3 | import { GetStatusDryRunUseCase } from './get-status-dry-run.use-case'; 4 | import { ListDryRunsUseCase } from './list-dry-runs.use-case'; 5 | import { SseDryRunUseCase } from './sse-dry-run.use-case'; 6 | 7 | export const UseCases = [ 8 | ExecuteDryRunUseCase, 9 | GetStatusDryRunUseCase, 10 | SseDryRunUseCase, 11 | GetDryRunUseCase, 12 | ListDryRunsUseCase, 13 | ]; 14 | -------------------------------------------------------------------------------- /src/core/domain/codeReviewExecutions/contracts/codeReviewExecution.service.contract.ts: -------------------------------------------------------------------------------- 1 | import { OrganizationAndTeamData } from '@/config/types/general/organizationAndTeamData'; 2 | import { ICodeReviewExecutionRepository } from './codeReviewExecution.repository.contract'; 3 | import { CodeReviewExecution } from '../interfaces/codeReviewExecution.interface'; 4 | 5 | export const CODE_REVIEW_EXECUTION_SERVICE = Symbol( 6 | 'CODE_REVIEW_EXECUTION_SERVICE', 7 | ); 8 | 9 | export interface ICodeReviewExecutionService 10 | extends ICodeReviewExecutionRepository {} 11 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/generate-kody-rules.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsArray, IsNumber, IsOptional, IsString } from 'class-validator'; 2 | 3 | export class GenerateKodyRulesDTO { 4 | @IsString() 5 | teamId: string; 6 | 7 | @IsNumber() 8 | @IsOptional() 9 | months?: number; 10 | 11 | @IsNumber() 12 | @IsOptional() 13 | weeks?: number; 14 | 15 | @IsNumber() 16 | @IsOptional() 17 | days?: number; 18 | 19 | @IsArray() 20 | @IsString({ each: true }) 21 | @IsOptional() 22 | repositoriesIds?: string[]; 23 | } 24 | -------------------------------------------------------------------------------- /src/shared/infrastructure/interceptors/timeout.interceptor.ts: -------------------------------------------------------------------------------- 1 | import { 2 | CallHandler, 3 | ExecutionContext, 4 | Injectable, 5 | NestInterceptor, 6 | } from '@nestjs/common'; 7 | import { Observable } from 'rxjs'; 8 | 9 | @Injectable() 10 | export class TimeoutInterceptor implements NestInterceptor { 11 | intercept(context: ExecutionContext, next: CallHandler): Observable { 12 | const response = context.switchToHttp().getResponse(); 13 | 14 | response.setTimeout(50000); 15 | 16 | return next.handle(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/apply-code-review-preset.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsEnum, IsNotEmpty, IsOptional, IsString } from 'class-validator'; 2 | 3 | import { ReviewPreset } from '@/config/types/general/codeReview.type'; 4 | import { OrganizationAndTeamDataDto } from './organizationAndTeamData.dto'; 5 | 6 | export class ApplyCodeReviewPresetDto { 7 | @IsEnum(ReviewPreset) 8 | preset: ReviewPreset; 9 | 10 | @IsNotEmpty() 11 | @IsString() 12 | teamId: string; 13 | 14 | @IsOptional() 15 | organizationAndTeamData?: OrganizationAndTeamDataDto; 16 | } 17 | -------------------------------------------------------------------------------- /src/config/loaders/index.ts: -------------------------------------------------------------------------------- 1 | import { HttpServerConfiguration } from '@/config/types/http/http-server.type'; 2 | 3 | export const configLoader = (): ConfigLoader => ({ 4 | server: { 5 | host: process.env.API_HOST, 6 | port: parseInt(process.env.API_PORT, 10), 7 | rateLimit: { 8 | rateMaxRequest: parseInt(process.env.API_RATE_MAX_REQUEST, 10) || 15, 9 | rateInterval: parseInt(process.env.API_RATE_INTERVAL, 10) || 30, 10 | }, 11 | }, 12 | }); 13 | 14 | type ConfigLoader = { 15 | server: HttpServerConfiguration; 16 | }; 17 | -------------------------------------------------------------------------------- /src/core/domain/parameters/interfaces/parameters.interface.ts: -------------------------------------------------------------------------------- 1 | import { ITeam } from '../../team/interfaces/team.interface'; 2 | import { ParametersKey } from '@/shared/domain/enums/parameters-key.enum'; 3 | import { ConfigValueMap } from '../types/configValue.type'; 4 | 5 | export interface IParameters { 6 | uuid: string; 7 | team?: Partial; 8 | configKey: K; 9 | configValue: ConfigValueMap[K]; 10 | createdAt?: Date; 11 | updatedAt?: Date; 12 | active: boolean; 13 | description?: string; 14 | version: number; 15 | } 16 | -------------------------------------------------------------------------------- /src/core/infrastructure/adapters/services/bcrypt.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import * as bcrypt from 'bcryptjs'; 3 | import { IPasswordService } from '@/core/domain/user/contracts/password.service.contract'; 4 | 5 | @Injectable() 6 | export class BcryptService implements IPasswordService { 7 | public generate(value: string, salts = 1): Promise { 8 | return bcrypt.hash(value, salts); 9 | } 10 | 11 | public match(source: string, hash: string): Promise { 12 | return bcrypt.compare(source, hash); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/core/application/use-cases/organization/index.ts: -------------------------------------------------------------------------------- 1 | import { GetOrganizationNameUseCase } from './get-organization-name'; 2 | import { GetOrganizationLanguageUseCase } from './get-organization-language.use-case'; 3 | import { GetOrganizationsByDomainUseCase } from './get-organizations-domain.use-case'; 4 | import { UpdateInfoOrganizationAndPhoneUseCase } from './update-infos.use-case'; 5 | 6 | export const UseCases = [ 7 | GetOrganizationNameUseCase, 8 | GetOrganizationLanguageUseCase, 9 | UpdateInfoOrganizationAndPhoneUseCase, 10 | GetOrganizationsByDomainUseCase, 11 | ]; 12 | -------------------------------------------------------------------------------- /src/core/domain/platformIntegrations/types/codeManagement/gitCloneParams.type.ts: -------------------------------------------------------------------------------- 1 | import { PlatformType } from '@/shared/domain/enums/platform-type.enum'; 2 | import { AuthMode } from '../../enums/codeManagement/authMode.enum'; 3 | 4 | export type GitCloneParams = { 5 | url: string; 6 | provider: PlatformType; 7 | branch?: string; 8 | auth?: { 9 | type?: AuthMode; 10 | username?: string; 11 | token?: string; 12 | org?: string; 13 | }; 14 | organizationId: string; 15 | repositoryId: string; 16 | repositoryName: string; 17 | }; 18 | -------------------------------------------------------------------------------- /src/ee/kodyRules/kody-rules-validation.module.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Kodus Tech. All rights reserved. 4 | */ 5 | 6 | import { forwardRef, Module } from '@nestjs/common'; 7 | import { PermissionValidationModule } from '../shared/permission-validation.module'; 8 | import { KodyRulesValidationService } from './service/kody-rules-validation.service'; 9 | 10 | @Module({ 11 | imports: [forwardRef(() => PermissionValidationModule)], 12 | providers: [KodyRulesValidationService], 13 | exports: [KodyRulesValidationService], 14 | }) 15 | export class KodyRulesValidationModule {} 16 | -------------------------------------------------------------------------------- /packages/kodus-common/src/llm/providerAdapters/jsonMode.ts: -------------------------------------------------------------------------------- 1 | export function buildJsonModeOptions( 2 | providerId: string, 3 | jsonMode?: boolean, 4 | ): Record { 5 | if (!jsonMode) { 6 | return {}; 7 | } 8 | 9 | // Google Gemini and Vertex use responseMimeType for JSON mode 10 | if (providerId === 'google_gemini' || providerId === 'google_vertex') { 11 | return { responseMimeType: 'application/json' }; 12 | } 13 | 14 | // OpenAI-based providers use response_format, which we set via withConfig elsewhere 15 | return {}; 16 | } 17 | -------------------------------------------------------------------------------- /src/shared/domain/enums/parameters-key.enum.ts: -------------------------------------------------------------------------------- 1 | export enum ParametersKey { 2 | BOARD_PRIORITY_TYPE = 'board_priority_type', 3 | CHECKIN_CONFIG = 'checkin_config', 4 | CODE_REVIEW_CONFIG = 'code_review_config', 5 | COMMUNICATION_STYLE = 'communication_style', 6 | DEPLOYMENT_TYPE = 'deployment_type', 7 | ORGANIZATION_ARTIFACTS_CONFIG = 'organization_artifacts_config', 8 | TEAM_ARTIFACTS_CONFIG = 'team_artifacts_config', 9 | PLATFORM_CONFIGS = 'platform_configs', 10 | LANGUAGE_CONFIG = 'language_config', 11 | ISSUE_CREATION_CONFIG = 'issue_creation_config' 12 | } 13 | -------------------------------------------------------------------------------- /packages/kodus-common/src/llm/providerAdapters/modelTypes.ts: -------------------------------------------------------------------------------- 1 | // Pure type module for model capabilities (no runtime exports) 2 | 3 | export type ReasoningConfig = 4 | | { 5 | type: 'level'; 6 | options: Array<'low' | 'medium' | 'high'>; 7 | } 8 | | { 9 | type: 'budget'; 10 | options: { min: number; max?: number; default: number }; 11 | }; 12 | 13 | export interface ModelCapabilities { 14 | supportsTemperature: boolean; 15 | supportsReasoning: boolean; 16 | reasoningConfig?: ReasoningConfig; 17 | defaultMaxTokens?: number; 18 | } 19 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/get-repository-tree.dto.ts: -------------------------------------------------------------------------------- 1 | import { RepositoryTreeType } from '@/shared/utils/enums/repositoryTree.enum'; 2 | import { IsBoolean, IsEnum, IsOptional, IsString } from 'class-validator'; 3 | 4 | export class GetRepositoryTreeDto { 5 | @IsString() 6 | organizationId: string; 7 | 8 | @IsString() 9 | teamId: string; 10 | 11 | @IsString() 12 | repositoryId: string; 13 | 14 | @IsEnum(RepositoryTreeType) 15 | @IsOptional() 16 | treeType?: RepositoryTreeType; 17 | 18 | @IsBoolean() 19 | @IsOptional() 20 | useCache?: boolean; 21 | } 22 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/automation-run.dto.ts: -------------------------------------------------------------------------------- 1 | import { AutomationType } from '@/core/domain/automation/enums/automation-type'; 2 | import { 3 | IsEnum, 4 | IsNotEmpty, 5 | IsOptional, 6 | IsString, 7 | IsUUID, 8 | } from 'class-validator'; 9 | 10 | export class AutomationRunDto { 11 | @IsEnum(AutomationType) 12 | automationName: AutomationType; 13 | 14 | @IsNotEmpty() 15 | @IsUUID() 16 | teamId: string; 17 | 18 | @IsString() 19 | @IsOptional() 20 | channelId?: string; 21 | 22 | @IsString() 23 | @IsOptional() 24 | organizationId?: string; 25 | } 26 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/update.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsEmail, IsEnum, IsOptional, IsString } from 'class-validator'; 2 | import { Role } from '@/core/domain/permissions/enums/permissions.enum'; 3 | import { STATUS } from '@/config/types/database/status.type'; 4 | 5 | export class UpdateUserDto { 6 | @IsString() 7 | @IsOptional() 8 | @IsEmail() 9 | email?: string; 10 | 11 | @IsString() 12 | @IsOptional() 13 | password?: string; 14 | 15 | @IsOptional() 16 | @IsEnum(STATUS) 17 | status?: STATUS; 18 | 19 | @IsOptional() 20 | @IsEnum(Role) 21 | role?: Role; 22 | } 23 | -------------------------------------------------------------------------------- /src/shared/infrastructure/filters/duplicate-record.exception.ts: -------------------------------------------------------------------------------- 1 | import { HttpException, HttpStatus } from '@nestjs/common'; 2 | 3 | export class DuplicateRecordException extends HttpException { 4 | constructor(message: string, error_key: string = 'error_key', code: string = 'DUPLICATE_RECORD') { 5 | super( 6 | { 7 | error_key: error_key, 8 | message, 9 | code, 10 | statusCode: HttpStatus.CONFLICT, 11 | error: 'Duplicate Record' 12 | }, 13 | HttpStatus.CONFLICT 14 | ); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/core/domain/permissions/types/permissions.types.ts: -------------------------------------------------------------------------------- 1 | import { IUser } from '../../user/interfaces/user.interface'; 2 | import { Action, ResourceType } from '../enums/permissions.enum'; 3 | import { MongoAbility } from '@casl/ability'; 4 | 5 | export type Subject = ResourceType | 'all'; 6 | 7 | export type AppAbility = MongoAbility<[Action, Subject]>; // has nothing to do with mongo as a database 8 | 9 | export type IPermissions = { 10 | uuid: string; 11 | permissions: { 12 | assignedRepositoryIds: string[]; // list of repository IDs assigned to the user 13 | }; 14 | user: Partial; 15 | }; 16 | -------------------------------------------------------------------------------- /src/shared/domain/enums/organization-parameters-key.enum.ts: -------------------------------------------------------------------------------- 1 | export enum OrganizationParametersKey { 2 | CATEGORY_WORKITEM_TYPES = 'category_workitems_type', 3 | TIMEZONE_CONFIG = 'timezone_config', 4 | REVIEW_MODE_CONFIG = 'review_mode_config', 5 | KODY_FINE_TUNING_CONFIG = 'kody_fine_tuning_config', 6 | AUTO_JOIN_CONFIG = 'auto_join_config', 7 | BYOK_CONFIG = 'byok_config', 8 | COCKPIT_METRICS_VISIBILITY = 'cockpit_metrics_visibility', 9 | DRY_RUN_LIMIT = 'dry_run_limit', 10 | AUTO_LICENSE_ASSIGNMENT = 'auto_license_assignment', 11 | CODE_REVIEW_PRESET = 'code_review_preset', 12 | } 13 | -------------------------------------------------------------------------------- /src/shared/domain/enums/pullRequestState.enum.ts: -------------------------------------------------------------------------------- 1 | export enum PullRequestState { 2 | OPENED = 'open', 3 | CLOSED = 'closed', 4 | ALL = 'all', 5 | MERGED = 'merged', 6 | } 7 | 8 | export enum GithubPullRequestState { 9 | OPENED = 'open', 10 | CLOSED = 'closed', 11 | ALL = 'all', 12 | } 13 | 14 | export enum GitlabPullRequestState { 15 | OPENED = 'opened', 16 | CLOSED = 'closed', 17 | LOCKED = 'locked', 18 | MERGED = 'merged', 19 | } 20 | 21 | export enum AzureGitPullRequestState { 22 | ACTIVE = 'active', 23 | COMPLETED = 'completed', 24 | ABANDONED = 'abandoned', 25 | } 26 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/execute-router.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsObject, IsOptional, IsString, IsUUID } from 'class-validator'; 2 | 3 | export class ExecuteRouterDto { 4 | @IsObject() 5 | router: any; 6 | 7 | @IsString() 8 | message: string; 9 | 10 | @IsString() 11 | userId: string; 12 | 13 | @IsString() 14 | channel: string; 15 | 16 | @IsString() 17 | sessionId: string; 18 | 19 | @IsString() 20 | userName: string; 21 | 22 | @IsUUID() 23 | @IsOptional() 24 | teamId?: string; 25 | 26 | @IsUUID() 27 | @IsOptional() 28 | organizationId?: string; 29 | } 30 | -------------------------------------------------------------------------------- /packages/kodus-flow/.prettierignore: -------------------------------------------------------------------------------- 1 | # Dependências 2 | node_modules/ 3 | dist/ 4 | 5 | # Arquivos de build 6 | build/ 7 | coverage/ 8 | 9 | # Configurações 10 | .eslintcache 11 | .prettiercache 12 | 13 | # Outros 14 | *.md 15 | *.mdx 16 | *.svg 17 | *.png 18 | *.jpg 19 | *.jpeg 20 | *.gif 21 | *.eot 22 | *.ttf 23 | *.woff 24 | *.woff2 25 | 26 | # Arquivos de ambiente 27 | .env* 28 | !.env.example 29 | 30 | # Arquivos de configuração do editor 31 | .vscode/ 32 | .idea/ 33 | 34 | # Logs 35 | logs 36 | *.log 37 | npm-debug.log* 38 | yarn-debug.log* 39 | yarn-error.log* 40 | 41 | # Sistema operacional 42 | .DS_Store 43 | Thumbs.db 44 | -------------------------------------------------------------------------------- /src/core/application/use-cases/issues/index.ts: -------------------------------------------------------------------------------- 1 | import { GenerateIssuesFromPrClosedUseCase } from './generate-issues-from-pr-closed.use-case'; 2 | import { GetIssueByIdUseCase } from './get-issue-by-id.use-case'; 3 | import { GetIssuesUseCase } from './get-issues.use-case'; 4 | import { GetTotalIssuesUseCase } from './get-total-issues.use-case'; 5 | import { UpdateIssuePropertyUseCase } from './update-issue-property.use-case'; 6 | 7 | export const UseCases = [ 8 | GenerateIssuesFromPrClosedUseCase, 9 | GetIssuesUseCase, 10 | GetTotalIssuesUseCase, 11 | GetIssueByIdUseCase, 12 | UpdateIssuePropertyUseCase, 13 | ]; 14 | -------------------------------------------------------------------------------- /src/core/domain/codeReviewFeedback/interfaces/codeReviewFeedback.interface.ts: -------------------------------------------------------------------------------- 1 | export interface ICodeReviewFeedback { 2 | uuid: string; 3 | organizationId: string; 4 | reactions: { 5 | thumbsUp: number; 6 | thumbsDown: number; 7 | }; 8 | comment: { 9 | id: number; 10 | pullRequestReviewId?: string; 11 | }; 12 | suggestionId: string; 13 | pullRequest: { 14 | id: string; 15 | number: number; 16 | repository: { 17 | id: string; 18 | fullName: string; 19 | }; 20 | }; 21 | syncedEmbeddedSuggestions: boolean; 22 | } 23 | -------------------------------------------------------------------------------- /src/shared/utils/langchainCommon/prompts/configuration/predictDeployType/getProductionReleases.ts: -------------------------------------------------------------------------------- 1 | export const prompt_getProductionReleases = (payload: string) => { 2 | return `Identify which releases are for production for each repository I provide. Return a JSON in the following format: 3 | 4 | "repos": [{ 5 | "repo": "string", 6 | "productionReleases": boolean 7 | }] 8 | 9 | Production releases may be referenced as main, prod, production, release, etc. 10 | 11 | If there are no workflows you consider production releases, return an empty array. 12 | 13 | 14 | Input data: 15 | ${payload}`; 16 | }; 17 | -------------------------------------------------------------------------------- /src/shared/utils/langchainCommon/prompts/rewriteArtifactsForCheckin.ts: -------------------------------------------------------------------------------- 1 | export const prompt_rewriteArtifactsForCheckin = (payload: any) => { 2 | return `{prompt_kodyContext} 3 | I want you to rewrite artifacts giving more context based on previous check-in, for example if a problems is repeating is a bigger problem. Use emojis (with caution, do not overload) to emphasize information. Keep the description short. 4 | 5 | Respond in JSON format, for example: 6 | \`\`\` 7 | {artifacts: [{description: "", "category: "", name: ""},{description: "', category: "", name: ""}...] 8 | \`\`\` 9 | 10 | Input Data: 11 | ${payload} 12 | `; 13 | }; 14 | -------------------------------------------------------------------------------- /src/core/application/use-cases/pullRequestMessages/index.ts: -------------------------------------------------------------------------------- 1 | import { CreateOrUpdatePullRequestMessagesUseCase } from './create-or-update-pull-request-messages.use-case'; 2 | import { DeleteByRepositoryOrDirectoryPullRequestMessagesUseCase } from './delete-by-repository-or-directory.use-case'; 3 | import { FindByRepositoryOrDirectoryIdPullRequestMessagesUseCase } from './find-by-repo-or-directory.use-case'; 4 | 5 | export const PullRequestMessagesUseCases = [ 6 | CreateOrUpdatePullRequestMessagesUseCase, 7 | DeleteByRepositoryOrDirectoryPullRequestMessagesUseCase, 8 | FindByRepositoryOrDirectoryIdPullRequestMessagesUseCase, 9 | ]; 10 | -------------------------------------------------------------------------------- /src/core/infrastructure/adapters/repositories/mongoose/schema/kodyRules.model.ts: -------------------------------------------------------------------------------- 1 | import { IKodyRule } from '@/core/domain/kodyRules/interfaces/kodyRules.interface'; 2 | import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; 3 | 4 | @Schema({ 5 | collection: 'kodyRules', 6 | timestamps: true, 7 | autoIndex: true, 8 | }) 9 | export class KodyRulesModel { 10 | @Prop({ type: String, required: true }) 11 | public organizationId: string; 12 | 13 | @Prop({ type: Array, required: true }) 14 | public rules: IKodyRule[]; 15 | } 16 | 17 | export const KodyRulesSchema = SchemaFactory.createForClass(KodyRulesModel); 18 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/user-status-change.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsObject, IsString } from 'class-validator'; 2 | 3 | export class UserStatusDto { 4 | @IsString() 5 | public gitId: string; 6 | 7 | @IsString() 8 | public gitTool: string; 9 | 10 | @IsString() 11 | public licenseStatus: "active" | "inactive"; 12 | 13 | @IsString() 14 | public teamId: string; 15 | 16 | @IsString() 17 | public organizationId: string; 18 | 19 | @IsObject() 20 | public editedBy: { 21 | userId: string; 22 | email: string; 23 | }; 24 | 25 | @IsString() 26 | public userName: string; 27 | } 28 | -------------------------------------------------------------------------------- /src/ee/shared/permission-validation.module.ts: -------------------------------------------------------------------------------- 1 | import { LicenseModule } from '@/ee/license/license.module'; 2 | import { OrganizationParametersModule } from '@/modules/organizationParameters.module'; 3 | import { Module, forwardRef } from '@nestjs/common'; 4 | import { PermissionValidationService } from './services/permissionValidation.service'; 5 | 6 | @Module({ 7 | imports: [ 8 | forwardRef(() => LicenseModule), 9 | forwardRef(() => OrganizationParametersModule), 10 | ], 11 | providers: [PermissionValidationService], 12 | exports: [PermissionValidationService], 13 | }) 14 | export class PermissionValidationModule {} 15 | -------------------------------------------------------------------------------- /src/core/application/use-cases/integrations/get-organization-id.use-case.ts: -------------------------------------------------------------------------------- 1 | import { IUseCase } from '@/shared/domain/interfaces/use-case.interface'; 2 | import { Inject } from '@nestjs/common'; 3 | import { REQUEST } from '@nestjs/core'; 4 | import { Request } from 'express'; 5 | 6 | export class GetOrganizationIdUseCase implements IUseCase { 7 | constructor( 8 | @Inject(REQUEST) 9 | private readonly request: Request & { 10 | user: { organization: { uuid: string } }; 11 | }, 12 | ) {} 13 | public async execute(): Promise { 14 | return this.request.user.organization.uuid; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/pagination.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsOptional, IsNumber, Min, Max } from 'class-validator'; 2 | import { Transform } from 'class-transformer'; 3 | 4 | export class PaginationDto { 5 | @IsOptional() 6 | @Transform(({ value }) => parseInt(value)) 7 | @IsNumber() 8 | @Min(1) 9 | page?: number = 1; 10 | 11 | @IsOptional() 12 | @Transform(({ value }) => parseInt(value)) 13 | @IsNumber() 14 | @Min(1) 15 | @Max(1000) 16 | limit?: number = 100; 17 | 18 | @IsOptional() 19 | @Transform(({ value }) => parseInt(value)) 20 | @IsNumber() 21 | @Min(0) 22 | skip?: number; 23 | } 24 | -------------------------------------------------------------------------------- /src/shared/utils/helpers/rankScore.helper.ts: -------------------------------------------------------------------------------- 1 | const categoryMapping: Record = { 2 | security: 'security', 3 | code_style: 'code_style', 4 | performance_and_optimization: 'performance_and_optimization', 5 | documentation_and_comments: 'documentation_and_comments', 6 | error_handling: 'error_handling', 7 | potential_issues: 'potential_issues', 8 | maintainability: 'maintainability', 9 | refactoring: 'refactoring', 10 | }; 11 | 12 | export const normalizeCategory = (category: string): string => { 13 | if (!category) return 'unknown'; 14 | return categoryMapping[category.toLowerCase()] || category; 15 | }; 16 | -------------------------------------------------------------------------------- /src/core/infrastructure/adapters/services/pipeline/interfaces/pipeline-strategy.interface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Kodus Tech. All rights reserved. 4 | */ 5 | 6 | import { PipelineContext } from "./pipeline-context.interface"; 7 | import { PipelineStage } from "./pipeline.interface"; 8 | 9 | export interface IPipelineStrategy { 10 | /** 11 | * Configura os estágios do pipeline 12 | * @returns Array de PipelineStage 13 | */ 14 | configureStages(): PipelineStage[]; 15 | 16 | /** 17 | * Nome do pipeline 18 | * @returns string 19 | */ 20 | getPipelineName(): string; 21 | } 22 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/accept-user-invitation.dto.ts: -------------------------------------------------------------------------------- 1 | import { 2 | IsNotEmpty, 3 | IsOptional, 4 | IsString, 5 | IsStrongPassword, 6 | } from 'class-validator'; 7 | 8 | export class AcceptUserInvitationDto { 9 | @IsNotEmpty() 10 | public uuid: string; 11 | 12 | @IsString() 13 | public name: string; 14 | 15 | @IsString() 16 | @IsStrongPassword({ 17 | minLength: 8, 18 | minLowercase: 1, 19 | minUppercase: 1, 20 | minNumbers: 1, 21 | minSymbols: 1, 22 | }) 23 | public password: string; 24 | 25 | @IsString() 26 | @IsOptional() 27 | public phone?: string; 28 | } 29 | -------------------------------------------------------------------------------- /src/shared/utils/benchmark.util.ts: -------------------------------------------------------------------------------- 1 | import { PinoLoggerService } from '@/core/infrastructure/adapters/services/logger/pino.service'; 2 | 3 | export async function benchmark( 4 | payload: { label: string; metadata?: any }, 5 | logger: PinoLoggerService, 6 | fn: () => Promise, 7 | ): Promise { 8 | const start = performance.now(); 9 | const result = await fn(); 10 | const duration = (performance.now() - start).toFixed(2); 11 | 12 | logger.log({ 13 | message: `⏱️ ${payload?.label} - ${duration}ms`, 14 | context: 'Benchmark', 15 | metadata: { ...payload?.metadata }, 16 | }); 17 | 18 | return result; 19 | } 20 | -------------------------------------------------------------------------------- /src/core/domain/platformIntegrations/types/codeManagement/repositories.type.ts: -------------------------------------------------------------------------------- 1 | export type Repositories = { 2 | id: string; 3 | name: string; 4 | full_name?: string; 5 | http_url: string; 6 | avatar_url: string; 7 | organizationName: string; 8 | visibility: 'public' | 'private'; 9 | selected: boolean; 10 | default_branch?: string; 11 | language?: string; 12 | lastActivityAt?: string; 13 | project?: { 14 | id: string; 15 | name: string; 16 | }; 17 | workspaceId?: string; 18 | directories?: Array; 19 | recentPullRequestsCount?: number; 20 | recentPullRequestsWindowDays?: number; 21 | }; 22 | -------------------------------------------------------------------------------- /src/core/infrastructure/adapters/repositories/typeorm/schema/global-parameters.model.ts: -------------------------------------------------------------------------------- 1 | import { CoreModel } from '@/shared/infrastructure/repositories/model/typeOrm'; 2 | import { Column, Entity } from 'typeorm'; 3 | import { GlobalParametersKey } from '@/shared/domain/enums/global-parameters-key.enum'; 4 | 5 | @Entity('global_parameters') 6 | export class GlobalParametersModel extends CoreModel { 7 | @Column({ 8 | type: 'enum', 9 | enum: GlobalParametersKey, 10 | }) 11 | configKey: GlobalParametersKey; 12 | 13 | @Column({ type: 'jsonb' }) 14 | configValue: any; 15 | 16 | @Column({ nullable: true }) 17 | description: string; 18 | } 19 | -------------------------------------------------------------------------------- /src/shared/infrastructure/repositories/model/typeOrm/index.ts: -------------------------------------------------------------------------------- 1 | import { 2 | CreateDateColumn, 3 | Entity, 4 | PrimaryGeneratedColumn, 5 | UpdateDateColumn, 6 | } from 'typeorm'; 7 | 8 | @Entity() 9 | export class CoreModel { 10 | @PrimaryGeneratedColumn('uuid') 11 | public uuid: string; 12 | 13 | @CreateDateColumn({ 14 | type: 'timestamp', 15 | default: () => 'CURRENT_TIMESTAMP(6)', 16 | }) 17 | public createdAt: Date; 18 | 19 | @UpdateDateColumn({ 20 | type: 'timestamp', 21 | default: () => 'CURRENT_TIMESTAMP(6)', 22 | onUpdate: 'CURRENT_TIMESTAMP(6)', 23 | }) 24 | public updatedAt: Date; 25 | } 26 | -------------------------------------------------------------------------------- /src/shared/utils/langchainCommon/prompts/configuration/predictDeployType/getProductionWorkflows.ts: -------------------------------------------------------------------------------- 1 | export const prompt_getProductionWorkflows = (payload: string) => { 2 | return `Identify which deployments are for production for each repository I provide. Return a JSON in the following format: 3 | 4 | "repos": [{ 5 | 6 | "repo": "string", 7 | 8 | "productionWorkflows": [{id: "", name: ""}] 9 | 10 | }] 11 | 12 | Production deployments may be referenced as main, prod, production, release, etc. 13 | 14 | If there are no workflows you consider production deployments, return an empty array. 15 | 16 | 17 | Input data: 18 | ${payload}`; 19 | }; 20 | -------------------------------------------------------------------------------- /src/core/domain/organization/contracts/organization.service.contract.ts: -------------------------------------------------------------------------------- 1 | import { OrganizationEntity } from '../entities/organization.entity'; 2 | import { IOrganization } from '../interfaces/organization.interface'; 3 | import { IOrganizationRepository } from './organization.repository.contract'; 4 | 5 | export const ORGANIZATION_SERVICE_TOKEN = Symbol('OrganizationService'); 6 | 7 | export interface IOrganizationService extends IOrganizationRepository { 8 | createOrganizationWithTenant( 9 | organizationData: Partial, 10 | ): Promise; 11 | findOneByUserId(user_id: string): Promise; 12 | } 13 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/pull-request-messages.dto.ts: -------------------------------------------------------------------------------- 1 | import { PullRequestMessageStatus, PullRequestMessageType } from '@/config/types/general/pullRequestMessages.type'; 2 | import { IsObject, IsOptional, IsString } from 'class-validator'; 3 | 4 | export class PullRequestMessagesDto { 5 | @IsString() 6 | public organizationId?: string; 7 | 8 | @IsString() 9 | public pullRequestMessageType: PullRequestMessageType; 10 | 11 | @IsString() 12 | public status: PullRequestMessageStatus; 13 | 14 | @IsOptional() 15 | @IsString() 16 | public content: string; 17 | 18 | @IsObject() 19 | public repository?: { id: string; name: string }; 20 | } 21 | -------------------------------------------------------------------------------- /src/modules/health.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { TerminusModule } from '@nestjs/terminus'; 3 | import { HealthController } from '@/core/infrastructure/http/controllers/health.controller'; 4 | import { DatabaseHealthIndicator } from '@/core/infrastructure/adapters/services/health/database.health'; 5 | import { ApplicationHealthIndicator } from '@/core/infrastructure/adapters/services/health/application.health'; 6 | 7 | @Module({ 8 | imports: [TerminusModule], 9 | controllers: [HealthController], 10 | providers: [ 11 | DatabaseHealthIndicator, 12 | ApplicationHealthIndicator, 13 | ], 14 | }) 15 | export class HealthModule {} 16 | -------------------------------------------------------------------------------- /src/config/index.ts: -------------------------------------------------------------------------------- 1 | import { ConfigModuleOptions } from '@nestjs/config/dist/interfaces'; 2 | import * as Joi from 'joi'; 3 | import { environmentConfigLoader } from './loaders/environment.loader'; 4 | import { serverConfigLoader } from './loaders/server.loader'; 5 | import { configSchema } from './schemas/config.schema'; 6 | 7 | export const configOptions: ConfigModuleOptions = { 8 | cache: true, 9 | isGlobal: true, 10 | load: [serverConfigLoader, environmentConfigLoader], 11 | validationSchema: Joi.object().keys({ 12 | ...configSchema.keys, 13 | }), 14 | validationOptions: { 15 | allowUnknown: true, 16 | abortEarly: true, 17 | }, 18 | }; 19 | -------------------------------------------------------------------------------- /src/core/domain/kodyFineTuning/suggestionEmbedded/interfaces/suggestionEmbedded.interface.ts: -------------------------------------------------------------------------------- 1 | import { IOrganization } from '@/core/domain/organization/interfaces/organization.interface'; 2 | 3 | export interface ISuggestionEmbedded { 4 | uuid?: string; 5 | suggestionId: string; 6 | suggestionEmbed: number[]; 7 | pullRequestNumber: number; 8 | repositoryId: string; 9 | repositoryFullName: string; 10 | organization?: Partial | null; 11 | label: string; 12 | severity: string; 13 | feedbackType: string; 14 | improvedCode: string; 15 | suggestionContent: string; 16 | oneSentenceSummary?: string; 17 | language: string; 18 | } 19 | -------------------------------------------------------------------------------- /packages/kodus-common/src/llm/providerAdapters/types.ts: -------------------------------------------------------------------------------- 1 | import { BaseChatModel } from '@langchain/core/language_models/chat_models'; 2 | import { Callbacks } from '@langchain/core/callbacks/manager'; 3 | 4 | export interface AdapterBuildParams { 5 | model: string; 6 | apiKey: string; 7 | baseURL?: string; 8 | options?: { 9 | temperature?: number; 10 | maxTokens?: number; 11 | jsonMode?: boolean; 12 | maxReasoningTokens?: number; 13 | reasoningLevel?: 'low' | 'medium' | 'high'; 14 | callbacks?: Callbacks; 15 | }; 16 | } 17 | 18 | export interface ProviderAdapter { 19 | build(params: AdapterBuildParams): BaseChatModel; 20 | } 21 | -------------------------------------------------------------------------------- /src/core/infrastructure/adapters/repositories/typeorm/schema/permissions.model.ts: -------------------------------------------------------------------------------- 1 | import { CoreModel } from '@/shared/infrastructure/repositories/model/typeOrm'; 2 | import { Column, Entity, JoinColumn, OneToOne } from 'typeorm'; 3 | import { UserModel } from './user.model'; 4 | import { IPermissions } from '@/core/domain/permissions/types/permissions.types'; 5 | 6 | @Entity('permissions') 7 | export class PermissionsModel extends CoreModel { 8 | @OneToOne(() => UserModel, (user) => user.permissions) 9 | @JoinColumn({ name: 'user_id', referencedColumnName: 'uuid' }) 10 | user: UserModel; 11 | 12 | @Column({ type: 'jsonb' }) 13 | permissions: IPermissions['permissions']; 14 | } 15 | -------------------------------------------------------------------------------- /src/core/domain/global-parameters/contracts/global-parameters.service.contract.ts: -------------------------------------------------------------------------------- 1 | import { IGlobalParametersRepository } from './global-parameters.repository.contracts'; 2 | import { GlobalParametersKey } from '@/shared/domain/enums/global-parameters-key.enum'; 3 | import { GlobalParametersEntity } from '../entities/global-parameters.entity'; 4 | 5 | export const GLOBAL_PARAMETERS_SERVICE_TOKEN = Symbol( 6 | 'GlobalParametersService', 7 | ); 8 | 9 | export interface IGlobalParametersService extends IGlobalParametersRepository { 10 | createOrUpdateConfig( 11 | parametersKey: GlobalParametersKey, 12 | configValue: any, 13 | ): Promise; 14 | } 15 | -------------------------------------------------------------------------------- /src/shared/domain/contracts/getAdditionalInfo.helper.contract.ts: -------------------------------------------------------------------------------- 1 | export const GET_ADDITIONAL_INFO_HELPER_TOKEN = 'GET_ADDITIONAL_INFO_HELPER_TOKEN'; 2 | 3 | export interface IGetAdditionalInfoHelper { 4 | getTeamIdByOrganizationAndRepository( 5 | organizationId: string, 6 | repositoryId: string, 7 | ): Promise; 8 | 9 | getDirectoryPathByOrganizationAndRepository( 10 | organizationId: string, 11 | repositoryId: string, 12 | directoryId: string, 13 | ): Promise; 14 | 15 | getRepositoryNameByOrganizationAndRepository( 16 | organizationId: string, 17 | repositoryId: string, 18 | ): Promise; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/core/domain/auth/contracts/auth.repository.contracts.ts: -------------------------------------------------------------------------------- 1 | import { AuthModel } from '@/core/infrastructure/adapters/repositories/typeorm/schema/auth.model'; 2 | import { AuthEntity } from '../entities/auth.entity'; 3 | import { IAuth } from '../interfaces/auth.interface'; 4 | 5 | export const AUTH_REPOSITORY_TOKEN = Symbol('AuthRepository'); 6 | 7 | export interface IAuthRepository { 8 | saveRefreshToken(auth: IAuth): Promise; 9 | 10 | updateRefreshToken(auth: Partial): Promise; 11 | 12 | findRefreshToken(auth: Partial): Promise; 13 | 14 | deactivateRefreshToken(auth: Partial): Promise; 15 | } 16 | -------------------------------------------------------------------------------- /src/core/domain/automation/contracts/team-automation.service.ts: -------------------------------------------------------------------------------- 1 | import { TeamAutomationEntity } from '../entities/team-automation.entity'; 2 | import { ITeamAutomation } from '../interfaces/team-automation.interface'; 3 | import { ITeamAutomationRepository } from './team-automation.repository'; 4 | 5 | export const TEAM_AUTOMATION_SERVICE_TOKEN = Symbol('TeamAutomationService'); 6 | 7 | export interface ITeamAutomationService extends ITeamAutomationRepository { 8 | register( 9 | teamAutomation: Omit, 10 | ): Promise; 11 | hasActiveTeamAutomation( 12 | teamId: string, 13 | automation: string, 14 | ): Promise; 15 | } 16 | -------------------------------------------------------------------------------- /src/core/application/use-cases/auth/logout.use-case.ts: -------------------------------------------------------------------------------- 1 | import { 2 | AUTH_SERVICE_TOKEN, 3 | IAuthService, 4 | } from '@/core/domain/auth/contracts/auth.service.contracts'; 5 | import { Inject, Injectable, UnauthorizedException } from '@nestjs/common'; 6 | 7 | @Injectable() 8 | export class LogoutUseCase { 9 | constructor( 10 | @Inject(AUTH_SERVICE_TOKEN) 11 | private readonly authService: IAuthService, 12 | ) {} 13 | 14 | async execute(refreshToken: string) { 15 | try { 16 | return await this.authService.logout(refreshToken); 17 | } catch (error) { 18 | throw new UnauthorizedException('api.users.unauthorized'); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/core/domain/permissions/contracts/permissions.repository.contract.ts: -------------------------------------------------------------------------------- 1 | import { IPermissions } from '../types/permissions.types'; 2 | 3 | export const PERMISSIONS_REPOSITORY_TOKEN = Symbol('PermissionsRepository'); 4 | 5 | export interface IPermissionsRepository { 6 | find(filter: Partial): Promise; 7 | findOne(filter: Partial): Promise; 8 | create( 9 | permissions: Omit, 10 | ): Promise; 11 | update( 12 | uuid: string, 13 | permissions: Omit, 'uuid'>, 14 | ): Promise; 15 | delete(uuid: string): Promise; 16 | } 17 | -------------------------------------------------------------------------------- /license.md: -------------------------------------------------------------------------------- 1 | # License 2 | 3 | Kodus is available under a **dual license** model: 4 | 5 | - **Open Source License (AGPL-3.0):** 6 | All source code **except** files or directories marked as "enterprise edition" is licensed under the [GNU Affero General Public License v3.0 (AGPL-3.0)](https://www.gnu.org/licenses/agpl-3.0.html). 7 | 8 | - **Enterprise License (Commercial):** 9 | Any file or directory that includes `.ee.` in its filename or `ee/` in its path is **not** covered by the AGPL license and is subject to a **commercial license agreement**. 10 | See [LICENSE_EE.md](./license_ee.md) for more information. 11 | 12 | By using or distributing this software, you agree to the terms of the applicable licenses. 13 | -------------------------------------------------------------------------------- /src/core/domain/permissions/types/policy.types.ts: -------------------------------------------------------------------------------- 1 | import { Type } from '@nestjs/common'; 2 | import { AppAbility, Subject } from './permissions.types'; 3 | import { Action } from '../enums/permissions.enum'; 4 | import { UserRequest } from '@/config/types/http/user-request.type'; 5 | 6 | export interface IPolicyHandler { 7 | handle( 8 | ability: AppAbility, 9 | request?: UserRequest, 10 | ): Promise | boolean; 11 | } 12 | 13 | export type PolicyHandlerCallback = ( 14 | ability: AppAbility, 15 | request?: UserRequest, 16 | ) => Promise | boolean; 17 | 18 | export type PolicyHandler = 19 | | IPolicyHandler 20 | | PolicyHandlerCallback 21 | | Type; 22 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/generate-code-review-parameter.dto.ts: -------------------------------------------------------------------------------- 1 | import { 2 | IsArray, 3 | IsEnum, 4 | IsNumber, 5 | IsOptional, 6 | IsString, 7 | } from 'class-validator'; 8 | import { AlignmentLevel } from '../../adapters/services/codeBase/types/commentAnalysis.type'; 9 | 10 | export class GenerateCodeReviewParameterDTO { 11 | @IsString() 12 | teamId: string; 13 | 14 | @IsEnum(AlignmentLevel) 15 | @IsOptional() 16 | alignmentLevel?: AlignmentLevel; 17 | 18 | @IsNumber() 19 | @IsOptional() 20 | months?: number; 21 | 22 | @IsNumber() 23 | @IsOptional() 24 | weeks?: number; 25 | 26 | @IsNumber() 27 | @IsOptional() 28 | days?: number; 29 | } 30 | -------------------------------------------------------------------------------- /src/ee/configs/environment/environment.dev.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Kodus Tech. All rights reserved. 4 | * 5 | * This file is generated at Docker image build time. 6 | * Once compiled, the value of `API_CLOUD_MODE` is hardcoded and cannot be changed using .env, 7 | * docker run, or docker-compose overrides. 8 | */ 9 | 10 | export const environment = { 11 | /** 12 | * Enables cloud mode when running locally. 13 | * Can be overridden with process.env.API_CLOUD_MODE=true/false 14 | */ 15 | API_CLOUD_MODE: 16 | (process.env.API_CLOUD_MODE || 'true').toLowerCase() === 'true', 17 | API_DEVELOPMENT_MODE: 18 | (process.env.API_DEVELOPMENT_MODE || 'false').toLowerCase() === 'true', 19 | }; 20 | -------------------------------------------------------------------------------- /src/core/domain/automation/entities/memory.entity.ts: -------------------------------------------------------------------------------- 1 | import { IMemory, IMemoryMessage } from '../interfaces/memory.interface'; 2 | 3 | export class MemoryEntity implements IMemory { 4 | private _uuid: string; 5 | private _messages: IMemoryMessage[]; 6 | 7 | constructor(memory: IMemory | Partial) { 8 | this._uuid = memory.uuid; 9 | this._messages = memory.messages; 10 | } 11 | 12 | static create(memory: IMemory | Partial): MemoryEntity { 13 | return new MemoryEntity(memory); 14 | } 15 | 16 | public get uuid(): string { 17 | return this.uuid; 18 | } 19 | 20 | public get messages(): IMemoryMessage[] { 21 | return this.messages; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/core/domain/automation/contracts/session.service.contracts.ts: -------------------------------------------------------------------------------- 1 | import { OrganizationAndTeamData } from '@/config/types/general/organizationAndTeamData'; 2 | import { SessionEntity } from '../entities/session.entity'; 3 | import { ISession } from '../interfaces/session.interface'; 4 | import { ISessionRepository } from './session.repository.contracts'; 5 | 6 | export const SESSION_SERVICE_TOKEN = Symbol('SessionService'); 7 | 8 | export interface ISessionService extends ISessionRepository { 9 | register(session: Omit): Promise; 10 | checkIfHasActiveSessions( 11 | platformUserId: string, 12 | organizationAndTeamData?: OrganizationAndTeamData, 13 | ): Promise; 14 | } 15 | -------------------------------------------------------------------------------- /src/core/domain/automation/interfaces/automation-execution.interface.ts: -------------------------------------------------------------------------------- 1 | import { CodeReviewExecution } from '../../codeReviewExecutions/interfaces/codeReviewExecution.interface'; 2 | import { AutomationStatus } from '../enums/automation-status'; 3 | import { ITeamAutomation } from './team-automation.interface'; 4 | 5 | export interface IAutomationExecution { 6 | uuid: string; 7 | createdAt?: Date; 8 | updatedAt?: Date; 9 | status: AutomationStatus; 10 | errorMessage?: string; 11 | dataExecution?: any; 12 | pullRequestNumber?: number; 13 | repositoryId?: string; 14 | teamAutomation?: Partial; 15 | codeReviewExecutions?: Array>; 16 | origin: string; 17 | } 18 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/create-user-organization.dto.ts: -------------------------------------------------------------------------------- 1 | import { 2 | IsEmail, 3 | IsNotEmpty, 4 | IsOptional, 5 | IsPhoneNumber, 6 | IsString, 7 | IsStrongPassword, 8 | IsUUID, 9 | } from 'class-validator'; 10 | 11 | export class SignUpDTO { 12 | @IsString() 13 | public name: string; 14 | 15 | @IsString() 16 | @IsEmail() 17 | public email: string; 18 | 19 | @IsString() 20 | @IsStrongPassword({ 21 | minLength: 8, 22 | minLowercase: 1, 23 | minUppercase: 1, 24 | minNumbers: 1, 25 | minSymbols: 1, 26 | }) 27 | public password: string; 28 | 29 | @IsString() 30 | @IsOptional() 31 | public organizationId?: string; 32 | } 33 | -------------------------------------------------------------------------------- /src/ee/codeReviewSettingsLog/domain/codeReviewSettingsLog/contracts/codeReviewSettingsLog.repository.contract.ts: -------------------------------------------------------------------------------- 1 | import { CodeReviewSettingsLogEntity } from '../entities/codeReviewSettingsLog.entity'; 2 | import { ICodeReviewSettingsLog } from '../interfaces/codeReviewSettingsLog.interface'; 3 | 4 | export const CODE_REVIEW_SETTINGS_LOG_REPOSITORY_TOKEN = Symbol( 5 | 'CodeReviewSettingsLogRepository', 6 | ); 7 | 8 | export interface ICodeReviewSettingsLogRepository { 9 | create( 10 | codeReviewSettingsLog: Omit, 11 | ): Promise; 12 | 13 | find( 14 | filter?: Partial, 15 | ): Promise; 16 | } 17 | -------------------------------------------------------------------------------- /docker-compose.qa.yml: -------------------------------------------------------------------------------- 1 | services: 2 | kodus-orchestrator: 3 | image: ${IMAGE_NAME} 4 | container_name: ${CONTAINER_NAME} 5 | volumes: 6 | - log_volume:/app/logs 7 | logging: 8 | driver: json-file 9 | options: 10 | max-size: '200m' 11 | max-file: '10' 12 | ports: 13 | - '3001:3001' 14 | environment: 15 | - ENV=homolog 16 | - API_NODE_ENV=homolog 17 | env_file: 18 | - .env.qa 19 | networks: 20 | - shared-network 21 | restart: unless-stopped 22 | 23 | volumes: 24 | log_volume: 25 | 26 | networks: 27 | shared-network: 28 | external: true 29 | -------------------------------------------------------------------------------- /src/core/domain/user/interfaces/user.interface.ts: -------------------------------------------------------------------------------- 1 | import { STATUS } from '@/config/types/database/status.type'; 2 | import { IOrganization } from '../../organization/interfaces/organization.interface'; 3 | import { ITeamMember } from '../../teamMembers/interfaces/team-members.interface'; 4 | import { Role } from '../../permissions/enums/permissions.enum'; 5 | import { IPermissions } from '../../permissions/types/permissions.types'; 6 | 7 | export interface IUser { 8 | uuid: string; 9 | password: string; 10 | email: string; 11 | status: STATUS; 12 | role: Role; 13 | organization?: Partial | null; 14 | teamMember?: Partial[] | null; 15 | permissions?: Partial | null; 16 | } 17 | -------------------------------------------------------------------------------- /src/shared/domain/contracts/message-broker.service.contracts.ts: -------------------------------------------------------------------------------- 1 | export type MessagePayload = { 2 | event_version: number; 3 | occurred_on: Date; 4 | payload: T; 5 | event_name: string; 6 | messageId: string; 7 | }; 8 | 9 | export type BrokerConfig = { 10 | exchange: string; 11 | routingKey: string; 12 | }; 13 | 14 | export const MESSAGE_BROKER_SERVICE_TOKEN = Symbol('MessageBrokerService'); 15 | 16 | export interface IMessageBrokerService { 17 | publishMessage( 18 | config: BrokerConfig, 19 | message: MessagePayload, 20 | ): Promise; 21 | 22 | transformMessageToMessageBroker( 23 | eventName: string, 24 | message: T, 25 | ): MessagePayload; 26 | } 27 | -------------------------------------------------------------------------------- /src/shared/infrastructure/filters/repository-with-directories.exception.ts: -------------------------------------------------------------------------------- 1 | import { HttpException, HttpStatus } from '@nestjs/common'; 2 | 3 | export class RepositoryWithDirectoriesException extends HttpException { 4 | constructor(message: string = 'Cannot delete repository with configured directories. Please delete all directories first before removing the repository.', error_key: string = 'REPOSITORY_WITH_DIRECTORIES') { 5 | super( 6 | { 7 | error_key: error_key, 8 | message, 9 | statusCode: HttpStatus.UNPROCESSABLE_ENTITY, 10 | error: 'Repository With Directories' 11 | }, 12 | HttpStatus.UNPROCESSABLE_ENTITY 13 | ); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/ee/codeReviewSettingsLog/domain/codeReviewSettingsLog/interfaces/codeReviewSettingsLog.interface.ts: -------------------------------------------------------------------------------- 1 | import { ActionType, ChangedData, ConfigLevel } from "@/config/types/general/codeReviewSettingsLog.type"; 2 | 3 | export interface ICodeReviewSettingsLog { 4 | uuid: string; 5 | organizationId: string; 6 | teamId: string; 7 | action: ActionType; 8 | userInfo: { 9 | userId: string; 10 | userEmail: string; 11 | }; 12 | configLevel?: ConfigLevel; 13 | repository?: { 14 | id: string; 15 | name?: string; 16 | }; 17 | directory?: { 18 | id?: string; 19 | path?: string; 20 | }; 21 | changedData: ChangedData[]; 22 | createdAt?: Date; 23 | updatedAt?: Date; 24 | } 25 | -------------------------------------------------------------------------------- /src/core/application/use-cases/organizationParameters/delete-byok-config.use-case.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, Inject } from "@nestjs/common"; 2 | import { ORGANIZATION_PARAMETERS_SERVICE_TOKEN, IOrganizationParametersService } from "@/core/domain/organizationParameters/contracts/organizationParameters.service.contract"; 3 | 4 | @Injectable() 5 | export class DeleteByokConfigUseCase { 6 | constructor( 7 | @Inject(ORGANIZATION_PARAMETERS_SERVICE_TOKEN) 8 | private readonly organizationParametersService: IOrganizationParametersService, 9 | ) {} 10 | 11 | async execute(organizationId: string, configType: 'main' | 'fallback') { 12 | return await this.organizationParametersService.deleteByokConfig(organizationId, configType); 13 | } 14 | } -------------------------------------------------------------------------------- /src/core/domain/codeReviewFeedback/enums/codeReviewCommentReaction.enum.ts: -------------------------------------------------------------------------------- 1 | export enum GitHubReaction { 2 | THUMBS_UP = '+1', 3 | THUMBS_DOWN = '-1', 4 | EYES = 'eyes', 5 | HOORAY = 'hooray', 6 | CONFUSED = 'confused', 7 | ROCKET = 'rocket', 8 | } 9 | 10 | export enum GitlabReaction { 11 | THUMBS_UP = 'thumbsup', 12 | THUMBS_DOWN = 'thumbsdown', 13 | EYES = 'eyes', 14 | TADA = 'tada', 15 | CONFUSED = 'confused', 16 | ROCKET = 'rocket', 17 | LOCK = 'lock', 18 | } 19 | 20 | export enum CountingType { 21 | CREATE = 'create', 22 | REVOKE = 'revoke', 23 | } 24 | 25 | export enum ReviewStatusReaction { 26 | START = 'start', 27 | SUCCESS = 'success', 28 | ERROR = 'error', 29 | SKIP = 'skip', 30 | } 31 | -------------------------------------------------------------------------------- /src/core/domain/automation/contracts/memory.repository.ts: -------------------------------------------------------------------------------- 1 | import { MemoryEntity } from '../entities/memory.entity'; 2 | import { IMemory } from '../interfaces/memory.interface'; 3 | 4 | export const MEMORY_REPOSITORY_TOKEN = Symbol('MemoryRepository'); 5 | 6 | export interface IMemoryRepository { 7 | create(memory: IMemory): Promise; 8 | update( 9 | filter: Partial, 10 | data: Partial, 11 | ): Promise; 12 | delete(uuid: string): Promise; 13 | findById(uuid: string): Promise; 14 | findBySessionId(sessionId: string): Promise; 15 | find(filter?: Partial): Promise; 16 | getNativeCollection(): any; 17 | } 18 | -------------------------------------------------------------------------------- /src/core/domain/pullRequestMessages/interfaces/pullRequestMessages.interface.ts: -------------------------------------------------------------------------------- 1 | import { 2 | ConfigLevel, 3 | PullRequestMessageStatus, 4 | } from '@/config/types/general/pullRequestMessages.type'; 5 | 6 | export interface IPullRequestMessageContent { 7 | content: string; 8 | status: PullRequestMessageStatus; 9 | } 10 | 11 | export interface IPullRequestMessages { 12 | uuid?: string; 13 | organizationId: string; 14 | configLevel: ConfigLevel; 15 | repositoryId?: string; 16 | startReviewMessage?: IPullRequestMessageContent; 17 | endReviewMessage?: IPullRequestMessageContent; 18 | directoryId?: string; 19 | globalSettings?: { 20 | hideComments?: boolean; 21 | suggestionCopyPrompt?: boolean; 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /src/core/infrastructure/adapters/mcp/guards/mcp-enabled.guard.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Injectable, 3 | CanActivate, 4 | ExecutionContext, 5 | ForbiddenException, 6 | } from '@nestjs/common'; 7 | import { ConfigService } from '@nestjs/config'; 8 | 9 | @Injectable() 10 | export class McpEnabledGuard implements CanActivate { 11 | constructor(private readonly configService: ConfigService) {} 12 | 13 | canActivate(context: ExecutionContext): boolean { 14 | const mcpEnabled = this.configService.get( 15 | 'API_MCP_SERVER_ENABLED', 16 | false, 17 | ); 18 | 19 | if (!mcpEnabled) { 20 | throw new ForbiddenException('MCP Service is disabled'); 21 | } 22 | 23 | return true; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/shared/interfaces/file-review-context-preparation.interface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * © Kodus Tech. All rights reserved. 4 | */ 5 | 6 | import { 7 | AnalysisContext, 8 | FileChange, 9 | FileChangeContext, 10 | } from '@/config/types/general/codeReview.type'; 11 | 12 | export const FILE_REVIEW_CONTEXT_PREPARATION_TOKEN = Symbol( 13 | 'FileReviewContextPreparation', 14 | ); 15 | 16 | export interface ReviewModeOptions { 17 | fileChangeContext?: FileChangeContext; 18 | patch?: string; 19 | context?: AnalysisContext; 20 | } 21 | 22 | export interface IFileReviewContextPreparation { 23 | prepareFileContext( 24 | file: FileChange, 25 | context: AnalysisContext, 26 | ): Promise<{ fileContext: AnalysisContext } | null>; 27 | } 28 | -------------------------------------------------------------------------------- /src/core/infrastructure/adapters/services/pipeline/interfaces/pipeline-context.interface.ts: -------------------------------------------------------------------------------- 1 | import { AutomationStatus } from '@/core/domain/automation/enums/automation-status'; 2 | 3 | export interface PipelineContext { 4 | statusInfo: { 5 | status: AutomationStatus; 6 | message?: string; 7 | }; 8 | pipelineVersion: string; 9 | errors: PipelineError[]; 10 | pipelineMetadata?: { 11 | pipelineId?: string; 12 | pipelineName?: string; 13 | parentPipelineId?: string; 14 | rootPipelineId?: string; 15 | [key: string]: any; 16 | }; 17 | } 18 | 19 | export interface PipelineError { 20 | pipelineId?: string; 21 | stage: string; 22 | substage?: string; 23 | error: Error; 24 | metadata?: any; 25 | } 26 | -------------------------------------------------------------------------------- /src/core/application/use-cases/teamAutomation/index.ts: -------------------------------------------------------------------------------- 1 | import { ActiveCodeManagementTeamAutomationsUseCase } from './active-code-manegement-automations.use-case'; 2 | import { ActiveCodeReviewAutomationUseCase } from './active-code-review-automation.use-case'; 3 | import { ActiveTeamAutomationsUseCase } from './activeTeamAutomationsUseCase'; 4 | import { UpdateOrCreateTeamAutomationUseCase } from './updateOrCreateTeamAutomationUseCase'; 5 | import { UpdateTeamAutomationStatusUseCase } from './updateTeamAutomationStatusUseCase'; 6 | 7 | export const UseCases = [ 8 | UpdateOrCreateTeamAutomationUseCase, 9 | UpdateTeamAutomationStatusUseCase, 10 | ActiveTeamAutomationsUseCase, 11 | ActiveCodeManagementTeamAutomationsUseCase, 12 | ActiveCodeReviewAutomationUseCase, 13 | ]; 14 | -------------------------------------------------------------------------------- /src/core/domain/dryRun/contracts/dryRun.repository.contract.ts: -------------------------------------------------------------------------------- 1 | import { OrganizationAndTeamData } from '@/config/types/general/organizationAndTeamData'; 2 | import { DryRunEntity } from '../entities/dryRun.entity'; 3 | import { IDryRun } from '../interfaces/dryRun.interface'; 4 | 5 | export const DRY_RUN_REPOSITORY_TOKEN = Symbol('DRY_RUN_REPOSITORY_TOKEN'); 6 | 7 | export interface IDryRunRepository { 8 | create( 9 | dryRun: Omit, 10 | ): Promise; 11 | update(uuid: string, dryRun: Partial): Promise; 12 | findOne(filter: Partial): Promise; 13 | find(filter: Partial): Promise; 14 | delete(uuid: string): Promise; 15 | } 16 | -------------------------------------------------------------------------------- /DockerFiles/Dockerfile.dev.small: -------------------------------------------------------------------------------- 1 | ARG API_CLOUD_MODE=false 2 | 3 | FROM node:22.14.0-slim 4 | 5 | ARG API_CLOUD_MODE 6 | ENV API_CLOUD_MODE=${API_CLOUD_MODE} 7 | 8 | WORKDIR /usr/src/app 9 | ENV NODE_ENV=development 10 | ENV NODE_OPTIONS="--max-old-space-size=4096" 11 | 12 | RUN corepack disable \ 13 | && npm i -g yarn@1.22.22 14 | 15 | RUN apt-get update && apt-get install -y --no-install-recommends \ 16 | ca-certificates python3 make g++ procps \ 17 | && rm -rf /var/lib/apt/lists/* 18 | 19 | RUN npm i -g yalc chokidar-cli nodemon 20 | 21 | COPY package.json yarn.lock ./ 22 | COPY nest-cli.json tsconfig*.json ./ 23 | RUN mkdir -p /usr/src/app/certs 24 | 25 | COPY --chmod=0755 docker/dev-entrypoint.sh /usr/local/bin/dev-entrypoint 26 | 27 | ENTRYPOINT ["/usr/local/bin/dev-entrypoint"] 28 | -------------------------------------------------------------------------------- /src/core/domain/parameters/contracts/parameters.service.contract.ts: -------------------------------------------------------------------------------- 1 | import { OrganizationAndTeamData } from '@/config/types/general/organizationAndTeamData'; 2 | import { IParametersRepository } from './parameters.repository.contracts'; 3 | import { ParametersKey } from '@/shared/domain/enums/parameters-key.enum'; 4 | import { ParametersEntity } from '../entities/parameters.entity'; 5 | 6 | export const PARAMETERS_SERVICE_TOKEN = Symbol('ParametersService'); 7 | 8 | export interface IParametersService extends IParametersRepository { 9 | createOrUpdateConfig( 10 | parametersKey: K, 11 | configValue: ParametersEntity['configValue'], 12 | organizationAndTeamData: OrganizationAndTeamData, 13 | ): Promise | boolean>; 14 | } 15 | -------------------------------------------------------------------------------- /src/core/application/use-cases/integrations/index.ts: -------------------------------------------------------------------------------- 1 | import { CheckHasIntegrationByPlatformUseCase } from './check-has-connection.use-case'; 2 | import { CloneIntegrationUseCase } from './clone-integration.use-case'; 3 | import { GetConnectionsUseCase } from './get-connections.use-case'; 4 | import { GetOrganizationIdUseCase } from './get-organization-id.use-case'; 5 | import { GetIntegrationConfigsByIntegrationCategoryUseCase } from './integrationConfig/getIntegrationConfigsByIntegrationCategory.use-case'; 6 | 7 | export const UseCases = [ 8 | GetOrganizationIdUseCase, 9 | CloneIntegrationUseCase, 10 | CheckHasIntegrationByPlatformUseCase, 11 | GetConnectionsUseCase, 12 | ]; 13 | 14 | export const UseCasesIntegrationConfig = [ 15 | GetIntegrationConfigsByIntegrationCategoryUseCase, 16 | ]; 17 | -------------------------------------------------------------------------------- /src/core/domain/log/contracts/log.repository.contracts.ts: -------------------------------------------------------------------------------- 1 | import { LogEntity } from '../entities/log.entity'; 2 | import { ILog } from '../interfaces/log.interface'; 3 | 4 | export const LOG_REPOSITORY_TOKEN = Symbol('LogRepository'); 5 | 6 | export interface ILogRepository { 7 | create(log: Omit): Promise; 8 | createMany(logs: Array>): Promise; 9 | update( 10 | filter: Partial, 11 | data: Partial, 12 | ): Promise; 13 | delete(uuid: string): Promise; 14 | findById(uuid: string): Promise; 15 | find(filter?: Partial): Promise; 16 | getNativeCollection(): any; 17 | findOne(filter?: Partial): Promise; 18 | } 19 | -------------------------------------------------------------------------------- /src/config/loaders/mongodb.config.loader.ts: -------------------------------------------------------------------------------- 1 | import { registerAs } from '@nestjs/config'; 2 | import { DatabaseConnection } from '@/config/types'; 3 | 4 | export const mongoDBConfigLoader = registerAs( 5 | 'mongoDatabase', 6 | (): DatabaseConnection => { 7 | const env = process.env.API_DATABASE_ENV ?? process.env.API_NODE_ENV; 8 | return { 9 | host: ['homolog', 'production'].includes(env ?? '') 10 | ? process.env.API_MG_DB_HOST 11 | : process.env.API_MG_DB_HOST ?? 'localhost', 12 | port: parseInt(process.env.API_MG_DB_PORT, 10), 13 | username: process.env.API_MG_DB_USERNAME, 14 | password: process.env.API_MG_DB_PASSWORD, 15 | database: process.env.API_MG_DB_DATABASE, 16 | }; 17 | }, 18 | ); 19 | -------------------------------------------------------------------------------- /src/core/domain/codeBase/contracts/KodyRulesAnalysisService.contract.ts: -------------------------------------------------------------------------------- 1 | import { FileChangeContext, ReviewModeResponse, AnalysisContext, AIAnalysisResult, AIAnalysisResultPrLevel } from "@/config/types/general/codeReview.type"; 2 | import { OrganizationAndTeamData } from "@/config/types/general/organizationAndTeamData"; 3 | import { IKodyRule } from "../../kodyRules/interfaces/kodyRules.interface"; 4 | 5 | export interface IKodyRulesAnalysisService { 6 | analyzeCodeWithAI( 7 | organizationAndTeamData: OrganizationAndTeamData, 8 | prNumber: number, 9 | fileContext: FileChangeContext, 10 | reviewModeResponse: ReviewModeResponse, 11 | context: AnalysisContext, 12 | suggestions?: AIAnalysisResult, 13 | ): Promise; 14 | } 15 | -------------------------------------------------------------------------------- /src/config/loaders/postgres.config.loader.ts: -------------------------------------------------------------------------------- 1 | import { registerAs } from '@nestjs/config'; 2 | import { DatabaseConnection } from '@/config/types'; 3 | 4 | export const postgresConfigLoader = registerAs( 5 | 'postgresDatabase', 6 | (): DatabaseConnection => { 7 | const env = process.env.API_DATABASE_ENV ?? process.env.API_NODE_ENV; 8 | return { 9 | host: ['homolog', 'production'].includes(env ?? '') 10 | ? process.env.API_PG_DB_HOST 11 | : process.env.API_PG_DB_HOST ?? 'localhost', 12 | port: parseInt(process.env.API_PG_DB_PORT, 10), 13 | username: process.env.API_PG_DB_USERNAME, 14 | password: process.env.API_PG_DB_PASSWORD, 15 | database: process.env.API_PG_DB_DATABASE, 16 | }; 17 | }, 18 | ); 19 | -------------------------------------------------------------------------------- /src/core/domain/automation/contracts/session.repository.contracts.ts: -------------------------------------------------------------------------------- 1 | import { SessionEntity } from '../entities/session.entity'; 2 | import { ISession } from '../interfaces/session.interface'; 3 | 4 | export const SESSION_REPOSITORY_TOKEN = Symbol('SessionRepository'); 5 | 6 | export interface ISessionRepository { 7 | create(session: Omit): Promise; 8 | update( 9 | filter: Partial, 10 | data: Partial, 11 | ): Promise; 12 | delete(uuid: string): Promise; 13 | findById(uuid: string): Promise; 14 | find(filter?: Partial): Promise; 15 | getNativeCollection(): any; 16 | findOne(filter?: Partial): Promise; 17 | } 18 | -------------------------------------------------------------------------------- /src/core/domain/automation/contracts/team-automation.repository.ts: -------------------------------------------------------------------------------- 1 | import { TeamAutomationEntity } from '../entities/team-automation.entity'; 2 | import { ITeamAutomation } from '../interfaces/team-automation.interface'; 3 | 4 | export const TEAM_AUTOMATION_REPOSITORY_TOKEN = Symbol( 5 | 'TeamAutomationRepository', 6 | ); 7 | 8 | export interface ITeamAutomationRepository { 9 | create(teamAutomation: ITeamAutomation): Promise; 10 | update( 11 | filter: Partial, 12 | data: Partial, 13 | ): Promise; 14 | delete(uuid: string): Promise; 15 | findById(uuid: string): Promise; 16 | find(filter?: Partial): Promise; 17 | } 18 | -------------------------------------------------------------------------------- /src/shared/utils/langchainCommon/prompts/projectInsights.ts: -------------------------------------------------------------------------------- 1 | export const prompt_projectInsights = `{prompt_kodyContext} 2 | 3 | Instruct for response: 4 | - Ensure focus and brevity. 5 | - If you have any files generated by functions, send them in markdown format. Always use files if they are available They are in ###Data Analyst Tool Response section. 6 | - Use only the data you received during a conversation, never invent anything. 7 | - Use input data to answer the user question. 8 | - **If there as error in some function execution, tell the user that you are sorry and to try again.** 9 | - You dont have power to process data async; 10 | - Always tell the user the truth; 11 | - Do not send quickchart links; 12 | - If there is any file under Data Analyst Tool Response, always send to user; 13 | 14 | Input Data: 15 | `; 16 | -------------------------------------------------------------------------------- /src/core/application/use-cases/auth/refresh-toke.use-case.ts: -------------------------------------------------------------------------------- 1 | import { 2 | AUTH_SERVICE_TOKEN, 3 | IAuthService, 4 | } from '@/core/domain/auth/contracts/auth.service.contracts'; 5 | import { AuthProvider } from '@/shared/domain/enums/auth-provider.enum'; 6 | import { Inject, Injectable, UnauthorizedException } from '@nestjs/common'; 7 | 8 | @Injectable() 9 | export class RefreshTokenUseCase { 10 | constructor( 11 | @Inject(AUTH_SERVICE_TOKEN) 12 | private readonly authService: IAuthService, 13 | ) {} 14 | 15 | async execute(oldRefreshToken: string) { 16 | const newTokens = await this.authService.refreshToken(oldRefreshToken); 17 | 18 | if (!newTokens) { 19 | throw new Error('Invalid refresh token'); 20 | } 21 | 22 | return newTokens; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/modules/kodyFineTuningContext.module.ts: -------------------------------------------------------------------------------- 1 | import { forwardRef, Module } from '@nestjs/common'; 2 | 3 | import { CodebaseModule } from '@/modules/codeBase.module'; 4 | import { KodyFineTuningContextPreparationService } from '@/core/infrastructure/adapters/services/kodyFineTuning/fineTuningContext/fine-tuning.service'; 5 | import { KODY_FINE_TUNING_CONTEXT_PREPARATION_TOKEN } from '@/shared/interfaces/kody-fine-tuning-context-preparation.interface'; 6 | 7 | @Module({ 8 | imports: [forwardRef(() => CodebaseModule)], 9 | providers: [ 10 | { 11 | provide: KODY_FINE_TUNING_CONTEXT_PREPARATION_TOKEN, 12 | useClass: KodyFineTuningContextPreparationService, 13 | }, 14 | ], 15 | exports: [KODY_FINE_TUNING_CONTEXT_PREPARATION_TOKEN], 16 | }) 17 | export class KodyFineTuningContextModule {} 18 | -------------------------------------------------------------------------------- /src/core/application/use-cases/user/index.ts: -------------------------------------------------------------------------------- 1 | import { AcceptUserInvitationUseCase } from './accept-user-invitation.use-case'; 2 | import { CheckUserWithEmailUserUseCase } from './check-user-email.use-case'; 3 | import { DeleteUserUseCase } from './delete.use-case'; 4 | import { InviteDataUserUseCase } from './invite-data.use-case'; 5 | import { JoinOrganizationUseCase } from './join-organization.use-case'; 6 | import { RegisterUserStatusLogUseCase } from './register-user-status-log.use-case'; 7 | import { UpdateAnotherUserUseCase } from './update-another.use-case'; 8 | 9 | export const UseCases = [ 10 | DeleteUserUseCase, 11 | InviteDataUserUseCase, 12 | AcceptUserInvitationUseCase, 13 | CheckUserWithEmailUserUseCase, 14 | JoinOrganizationUseCase, 15 | UpdateAnotherUserUseCase, 16 | RegisterUserStatusLogUseCase 17 | ]; 18 | -------------------------------------------------------------------------------- /src/core/domain/automation/contracts/automation.repository.ts: -------------------------------------------------------------------------------- 1 | import { AutomationEntity } from '../entities/automation.entity'; 2 | import { IAutomation } from '../interfaces/automation.interface'; 3 | 4 | export const AUTOMATION_REPOSITORY_TOKEN = Symbol('AutomationRepository'); 5 | 6 | export interface IAutomationRepository { 7 | create(automation: IAutomation): Promise; 8 | update( 9 | filter: Partial, 10 | data: Partial, 11 | ): Promise; 12 | delete(uuid: string): Promise; 13 | findById(uuid: string): Promise; 14 | find(filter?: Partial): Promise; 15 | findOne( 16 | filter: Partial, 17 | ): Promise; 18 | } 19 | -------------------------------------------------------------------------------- /packages/kodus-flow/src/context/core/index.ts: -------------------------------------------------------------------------------- 1 | export * from './interfaces.js'; 2 | export * from './runtime.js'; 3 | export * from './builders/token-utils.js'; 4 | export * from './builders/core-layer-builder.js'; 5 | export * from './builders/catalog-layer-builder.js'; 6 | export * from './builders/active-layer-builder.js'; 7 | export * from './materializers/core-default.js'; 8 | export * from './materializers/catalog-default.js'; 9 | export * from './selectors/active-default.js'; 10 | export * from './pipeline/sequential-pack-pipeline.js'; 11 | export * from './pipeline/tri-layer-pack-builder.js'; 12 | export * from './mcp/registry.js'; 13 | export * from './mcp/orchestrator.js'; 14 | export * from './mcp/sanitizer.js'; 15 | export * from './mcp/utils.js'; 16 | export * from './utils/budget.js'; 17 | export * from './utils/context-requirements.js'; 18 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/preview-pr-summary.dto.ts: -------------------------------------------------------------------------------- 1 | import { BehaviourForExistingDescription } from '@/config/types/general/codeReview.type'; 2 | import { 3 | IsEnum, 4 | IsNotEmpty, 5 | IsObject, 6 | IsOptional, 7 | IsString, 8 | } from 'class-validator'; 9 | 10 | export class PreviewPrSummaryDto { 11 | @IsNotEmpty() 12 | @IsString() 13 | prNumber: string; 14 | 15 | @IsNotEmpty() 16 | @IsObject() 17 | repository: { 18 | id: string; 19 | name: string; 20 | }; 21 | 22 | @IsNotEmpty() 23 | @IsString() 24 | teamId: string; 25 | 26 | @IsNotEmpty() 27 | @IsEnum(BehaviourForExistingDescription) 28 | behaviourForExistingDescription: BehaviourForExistingDescription; 29 | 30 | @IsOptional() 31 | @IsString() 32 | customInstructions: string; 33 | } 34 | -------------------------------------------------------------------------------- /packages/kodus-flow/tests/observability/presets.unit.test.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file presets.unit.test.ts 3 | */ 4 | 5 | import { describe, it, expect } from 'vitest'; 6 | import { 7 | setupProductionObservability, 8 | setupDebugObservability, 9 | } from '../../src/observability/index.js'; 10 | 11 | describe('Observability presets', () => { 12 | it('setupProductionObservability aplica sampling default <= 0.1', async () => { 13 | const obs = await setupProductionObservability(); 14 | expect(obs.telemetry.getConfig().sampling.rate).toBeLessThanOrEqual( 15 | 0.1, 16 | ); 17 | }); 18 | 19 | it('setupDebugObservability mantém ambiente development', async () => { 20 | const obs = await setupDebugObservability(); 21 | expect(obs['config'].environment).toBe('development'); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /src/core/application/use-cases/github/get-integration-github.ts: -------------------------------------------------------------------------------- 1 | import { IUseCase } from '@/shared/domain/interfaces/use-case.interface'; 2 | import { Inject } from '@nestjs/common'; 3 | import { 4 | GITHUB_SERVICE_TOKEN, 5 | IGithubService, 6 | } from '@/core/domain/github/contracts/github.service.contract'; 7 | 8 | export class GetIntegrationGithubUseCase implements IUseCase { 9 | constructor( 10 | @Inject(GITHUB_SERVICE_TOKEN) 11 | private readonly githubService: IGithubService, 12 | ) {} 13 | 14 | public async execute(installId) { 15 | const integration = 16 | await this.githubService.findOneByInstallId(installId); 17 | 18 | return { 19 | status: integration?.installationStatus, 20 | organizationName: integration?.organizationName, 21 | }; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/core/application/use-cases/parameters/get-default-config.use-case.ts: -------------------------------------------------------------------------------- 1 | import { PinoLoggerService } from '@/core/infrastructure/adapters/services/logger/pino.service'; 2 | import { getDefaultKodusConfigFile } from '@/shared/utils/validateCodeReviewConfigFile'; 3 | import { Injectable } from '@nestjs/common'; 4 | 5 | @Injectable() 6 | export class GetDefaultConfigUseCase { 7 | constructor(private readonly logger: PinoLoggerService) {} 8 | 9 | async execute() { 10 | try { 11 | return getDefaultKodusConfigFile(); 12 | } catch (error) { 13 | this.logger.error({ 14 | message: 'Error getting default Kodus config file', 15 | context: GetDefaultConfigUseCase.name, 16 | metadata: { error }, 17 | }); 18 | throw error; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/kodus-flow/.env.example: -------------------------------------------------------------------------------- 1 | # Kodus Flow Environment Variables 2 | # Copy this file to .env and fill in your actual values 3 | 4 | # Google Gemini Configuration 5 | GEMINI_API_KEY=your_google_ai_studio_api_key_here 6 | GEMINI_MODEL=gemini-1.5-flash 7 | GEMINI_TEMPERATURE=0.7 8 | GEMINI_MAX_TOKENS=1000 9 | GEMINI_TOP_P=0.9 10 | GEMINI_TOP_K=40 11 | 12 | # Alternative naming (either works) 13 | # GOOGLE_API_KEY=your_google_ai_studio_api_key_here 14 | 15 | # OpenAI Configuration (if you want to use OpenAI instead) 16 | # OPENAI_API_KEY=your_openai_api_key_here 17 | # OPENAI_MODEL=gpt-4o-mini 18 | # OPENAI_TEMPERATURE=0.7 19 | # OPENAI_MAX_TOKENS=1000 20 | 21 | # Framework Configuration 22 | NODE_ENV=development 23 | LOG_LEVEL=debug 24 | 25 | # Optional: Custom URLs 26 | # GEMINI_BASE_URL=https://api.example.com/v1 27 | # OPENAI_BASE_URL=https://api.example.com/v1 -------------------------------------------------------------------------------- /src/core/domain/profileConfigs/contracts/profileConfig.repository.contract.ts: -------------------------------------------------------------------------------- 1 | import { ProfileConfigEntity } from '../entities/profileConfig.entity'; 2 | import { IProfileConfig } from '../interfaces/profileConfig.interface'; 3 | 4 | export const PROFILE_CONFIG_REPOSITORY_TOKEN = Symbol( 5 | 'ProfileConfigRepository', 6 | ); 7 | 8 | export interface IProfileConfigRepository { 9 | find(filter?: Partial): Promise; 10 | findOne(filter?: Partial): Promise; 11 | create( 12 | profileConfig: IProfileConfig, 13 | ): Promise; 14 | update( 15 | filter: Partial, 16 | data: Partial, 17 | ): Promise; 18 | delete(uuid: string): Promise; 19 | } 20 | -------------------------------------------------------------------------------- /src/modules/pipeline.module.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Kodus Tech. All rights reserved. 4 | */ 5 | import { Module } from '@nestjs/common'; 6 | import { PipelineFactory } from '@/core/infrastructure/adapters/services/pipeline/pipeline-factory.service'; 7 | import { pipelineProvider } from '@/core/infrastructure/providers/pipeline.provider.ee'; 8 | import { codeReviewPipelineProvider } from '@/core/infrastructure/providers/code-review-pipeline.provider.ee'; 9 | import { CodeReviewPipelineModule } from './codeReviewPipeline.module'; 10 | 11 | @Module({ 12 | imports: [ 13 | CodeReviewPipelineModule, 14 | ], 15 | providers: [ 16 | PipelineFactory, 17 | pipelineProvider, 18 | codeReviewPipelineProvider, 19 | ], 20 | exports: [ 21 | pipelineProvider, 22 | ], 23 | }) 24 | export class PipelineModule {} 25 | -------------------------------------------------------------------------------- /src/core/domain/tokenUsage/contracts/tokenUsage.repository.contract.ts: -------------------------------------------------------------------------------- 1 | import { 2 | TokenUsageQueryContract, 3 | DailyUsageResultContract, 4 | UsageSummaryContract, 5 | DailyUsageByPrResultContract, 6 | UsageByPrResultContract, 7 | } from '../types/tokenUsage.types'; 8 | 9 | export const TOKEN_USAGE_REPOSITORY_TOKEN = Symbol('TokenUsageRepository'); 10 | 11 | export interface ITokenUsageRepository { 12 | getSummary(query: TokenUsageQueryContract): Promise; 13 | 14 | getDailyUsage( 15 | query: TokenUsageQueryContract, 16 | ): Promise; 17 | 18 | getUsageByPr( 19 | query: TokenUsageQueryContract, 20 | ): Promise; 21 | 22 | getDailyUsageByPr( 23 | query: TokenUsageQueryContract, 24 | ): Promise; 25 | } 26 | -------------------------------------------------------------------------------- /src/core/infrastructure/adapters/repositories/mongoose/schema/observabilityTelemetry.model.ts: -------------------------------------------------------------------------------- 1 | import { CoreDocument } from '@/shared/infrastructure/repositories/model/mongodb'; 2 | import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; 3 | 4 | @Schema({ 5 | collection: 'observability_telemetry', 6 | timestamps: true, 7 | }) 8 | export class ObservabilityTelemetryModel extends CoreDocument { 9 | @Prop({ type: String, required: true }) 10 | name: string; 11 | 12 | @Prop({ type: String, required: true }) 13 | correlationId: string; 14 | 15 | @Prop({ type: Number, required: true }) 16 | duration: number; 17 | 18 | @Prop({ type: Object, required: true }) 19 | attributes: Record; 20 | } 21 | 22 | export const ObservabilityTelemetryModelSchema = SchemaFactory.createForClass( 23 | ObservabilityTelemetryModel, 24 | ); 25 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/controllers/team.controller.ts: -------------------------------------------------------------------------------- 1 | import { ListTeamsWithIntegrationsUseCase } from '@/core/application/use-cases/team/list-with-integrations.use-case'; 2 | import { ListTeamsUseCase } from '@/core/application/use-cases/team/list.use-case'; 3 | import { Controller, Get } from '@nestjs/common'; 4 | 5 | @Controller('team') 6 | export class TeamController { 7 | constructor( 8 | private readonly listTeamsUseCase: ListTeamsUseCase, 9 | private readonly listTeamsWithIntegrationsUseCase: ListTeamsWithIntegrationsUseCase, 10 | ) {} 11 | 12 | @Get('/') 13 | public async list() { 14 | return await this.listTeamsUseCase.execute(); 15 | } 16 | 17 | @Get('/list-with-integrations') 18 | public async listWithIntegrations() { 19 | return await this.listTeamsWithIntegrationsUseCase.execute(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/token-usage.dto.ts: -------------------------------------------------------------------------------- 1 | import { IsISO8601, IsNumber, IsOptional, IsString } from 'class-validator'; 2 | 3 | export class TokenUsageQueryDto { 4 | @IsISO8601() 5 | startDate: string; // ISO date string 6 | 7 | @IsISO8601() 8 | endDate: string; // ISO date string 9 | 10 | @IsOptional() 11 | @IsString() 12 | models?: string; 13 | 14 | @IsOptional() 15 | @IsNumber() 16 | prNumber?: number; 17 | 18 | @IsOptional() 19 | @IsString() 20 | timezone?: string; // e.g., 'UTC' or 'America/Sao_Paulo' 21 | 22 | @IsOptional() 23 | @IsString() 24 | developer?: string; 25 | 26 | @IsString() 27 | byok: string; 28 | } 29 | 30 | export class TokenPricingQueryDto { 31 | @IsString() 32 | model: string; 33 | 34 | @IsString() 35 | @IsOptional() 36 | provider?: string; 37 | } 38 | -------------------------------------------------------------------------------- /src/core/domain/profile/contracts/profile.repository.contract.ts: -------------------------------------------------------------------------------- 1 | import { ProfileEntity } from '../entities/profile.entity'; 2 | import { IProfile } from '../interfaces/profile.interface'; 3 | 4 | export const PROFILE_REPOSITORY_TOKEN = Symbol('ProfileRepository'); 5 | 6 | export interface IProfileRepository { 7 | find(filter: Partial): Promise; 8 | findOne(filter: Partial): Promise; 9 | findById(uuid: string): Promise; 10 | updateByUserId(user_id: string, data: Partial): Promise; 11 | create(profileEntity: IProfile): Promise; 12 | deleteOne(filter: Partial): Promise; 13 | update( 14 | filter: Partial, 15 | data: Partial, 16 | ): Promise; 17 | } 18 | -------------------------------------------------------------------------------- /src/core/infrastructure/adapters/repositories/mongoose/schema/dryRun.model.ts: -------------------------------------------------------------------------------- 1 | import { CodeReviewConfig } from '@/config/types/general/codeReview.type'; 2 | import { IDryRunData } from '@/core/domain/dryRun/interfaces/dryRun.interface'; 3 | import { CoreDocument } from '@/shared/infrastructure/repositories/model/mongodb'; 4 | import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; 5 | 6 | @Schema({ 7 | collection: 'dryRun', 8 | timestamps: true, 9 | autoIndex: true, 10 | }) 11 | export class DryRunModel extends CoreDocument { 12 | @Prop({ type: String, required: true }) 13 | public organizationId: string; 14 | 15 | @Prop({ type: String, required: true }) 16 | public teamId: string; 17 | 18 | @Prop({ type: Array, required: true }) 19 | public runs: Array; 20 | } 21 | 22 | export const DryRunSchema = SchemaFactory.createForClass(DryRunModel); 23 | -------------------------------------------------------------------------------- /src/shared/utils/kody-rules/file-patterns.ts: -------------------------------------------------------------------------------- 1 | export const RULE_FILE_PATTERNS = [ 2 | // Cursor 3 | '.cursorrules', 4 | '.cursor/rules/**/*.mdc', 5 | 6 | // GitHub Copilot 7 | '.github/copilot-instructions.md', 8 | '.github/instructions/**/*.instructions.md', 9 | 10 | // Agentic 11 | '.agents.md', 12 | '.agent.md', 13 | 14 | // Claude 15 | 'CLAUDE.md', 16 | '.claude/settings.json', 17 | 18 | // Windsurf 19 | '.windsurfrules', 20 | 21 | // Sourcegraph Cody 22 | '.sourcegraph/**/*.rule.md', 23 | 24 | // OpenCode 25 | '.opencode.json', 26 | 27 | // Aider 28 | '.aider.conf.yml', 29 | '.aiderignore', 30 | 31 | // Generic / internal 32 | '.rules/**/*', 33 | '.kody/rules/**', 34 | 'docs/coding-standards/**/*', 35 | ] as const; 36 | 37 | export type RuleFilePattern = (typeof RULE_FILE_PATTERNS)[number]; 38 | -------------------------------------------------------------------------------- /src/core/infrastructure/http/dtos/onboarding-review-mode-signals-query.dto.ts: -------------------------------------------------------------------------------- 1 | import { Transform } from 'class-transformer'; 2 | import { IsArray, IsNotEmpty, IsOptional, IsString, Min, Max } from 'class-validator'; 3 | 4 | export class OnboardingReviewModeSignalsQueryDto { 5 | @IsNotEmpty() 6 | @IsString() 7 | teamId: string; 8 | 9 | @IsArray() 10 | @IsString({ each: true }) 11 | @Transform(({ value }) => { 12 | if (Array.isArray(value)) return value; 13 | if (typeof value === 'string') { 14 | return value 15 | .split(',') 16 | .map((v) => v.trim()) 17 | .filter(Boolean); 18 | } 19 | return []; 20 | }) 21 | repositoryIds: string[]; 22 | 23 | @IsOptional() 24 | @Transform(({ value }) => parseInt(value)) 25 | @Min(1) 26 | @Max(50) 27 | limit?: number = 10; 28 | } 29 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | # Ignora dependências locais 2 | node_modules 3 | lib/ 4 | dist/ 5 | DockerFiles 6 | docker-entrypoint-initdb.d 7 | 8 | # Logs e arquivos temporários 9 | npm-debug.log 10 | *.log 11 | *.test.js 12 | .DS_Store 13 | 14 | # Infra de dev 15 | .dockerignore 16 | Dockerfile 17 | docker-compose.yml 18 | docker-compose.*.yml 19 | 20 | # Git e outros 21 | .git 22 | .github 23 | .husky 24 | 25 | # Testes 26 | test/ 27 | coverage/ 28 | *.spec.ts 29 | *.test.ts 30 | 31 | # Documentação 32 | *.md 33 | docs/ 34 | 35 | # Configurações de IDE 36 | .vscode/ 37 | .idea/ 38 | 39 | # Arquivos temporários 40 | temp/ 41 | tmp/ 42 | *.tmp 43 | 44 | # Ignora apenas o arquivo gerado no build (não o template!) 45 | ee/configs/environment/environment.ts 46 | src/ee/configs/environment/environment.ts 47 | 48 | # Arquivos de build 49 | .nyc_output/ 50 | .eslintcache 51 | 52 | # Arquivos de sistema 53 | Thumbs.db 54 | -------------------------------------------------------------------------------- /docker-compose.prod.yml: -------------------------------------------------------------------------------- 1 | services: 2 | kodus-orchestrator: 3 | image: ${IMAGE_NAME_PROD} 4 | container_name: ${CONTAINER_NAME} 5 | volumes: 6 | - log_volume:/app/logs 7 | logging: 8 | driver: json-file 9 | options: 10 | max-size: '200m' 11 | max-file: '10' 12 | ports: 13 | - '3001:3001' 14 | environment: 15 | - ENV=production 16 | - API_NODE_ENV=production 17 | - NODE_OPTIONS=--max-old-space-size=8192 --max-semi-space-size=128 18 | - API_LOG_LEVEL=warn 19 | - API_LOG_PRETTY=false 20 | env_file: 21 | - .env.prod 22 | networks: 23 | - shared-network 24 | restart: unless-stopped 25 | 26 | volumes: 27 | log_volume: 28 | 29 | networks: 30 | shared-network: 31 | external: true 32 | -------------------------------------------------------------------------------- /src/core/application/use-cases/profile/update.use-case.ts: -------------------------------------------------------------------------------- 1 | import { IUseCase } from '@/shared/domain/interfaces/use-case.interface'; 2 | import { Inject } from '@nestjs/common'; 3 | 4 | import { 5 | IProfileService, 6 | PROFILE_SERVICE_TOKEN, 7 | } from '@/core/domain/profile/contracts/profile.service.contract'; 8 | import { IProfile } from '@/core/domain/profile/interfaces/profile.interface'; 9 | 10 | export class UpdateProfileUseCase implements IUseCase { 11 | constructor( 12 | @Inject(PROFILE_SERVICE_TOKEN) 13 | private readonly profileService: IProfileService, 14 | ) {} 15 | 16 | public async execute(payload: Partial): Promise { 17 | await this.profileService.update( 18 | { user: { uuid: payload.user.uuid } }, 19 | { 20 | ...payload, 21 | status: true, 22 | }, 23 | ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/core/application/use-cases/user/delete.use-case.ts: -------------------------------------------------------------------------------- 1 | import { IUseCase } from '@/shared/domain/interfaces/use-case.interface'; 2 | import { Inject, Injectable, NotFoundException } from '@nestjs/common'; 3 | import { USER_SERVICE_TOKEN } from '@/core/domain/user/contracts/user.service.contract'; 4 | import { UsersService } from '@/core/infrastructure/adapters/services/users.service'; 5 | 6 | @Injectable() 7 | export class DeleteUserUseCase implements IUseCase { 8 | constructor( 9 | @Inject(USER_SERVICE_TOKEN) 10 | private readonly usersService: UsersService, 11 | ) {} 12 | 13 | public async execute(uuid: string): Promise { 14 | const userExists = await this.usersService.count({ uuid }); 15 | 16 | if (!userExists) { 17 | throw new NotFoundException('api.users.not_found'); 18 | } 19 | 20 | await this.usersService.delete(uuid); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/core/infrastructure/adapters/repositories/typeorm/schema/profileConfig.model.ts: -------------------------------------------------------------------------------- 1 | import { ProfileConfigKey } from "@/core/domain/profileConfigs/enum/profileConfigKey.enum"; 2 | import { CoreModel } from "@/shared/infrastructure/repositories/model/typeOrm"; 3 | import { Column, Entity, JoinColumn, ManyToOne } from "typeorm"; 4 | import { ProfileModel } from "./profile.model"; 5 | 6 | @Entity('profile_configs') 7 | export class ProfileConfigModel extends CoreModel { 8 | @Column({ 9 | type: 'enum', 10 | enum: ProfileConfigKey, 11 | }) 12 | configKey: ProfileConfigKey; 13 | 14 | @Column({ type: 'jsonb' }) 15 | configValue: any; 16 | 17 | @Column({ default: true }) 18 | public status: boolean; 19 | 20 | @ManyToOne(() => ProfileModel, (profile) => profile.profileConfigs) 21 | @JoinColumn({ name: 'profile_id', referencedColumnName: 'uuid' }) 22 | profile: ProfileModel; 23 | } 24 | -------------------------------------------------------------------------------- /src/core/infrastructure/adapters/services/platformIntegration/platformIntegration.factory.ts: -------------------------------------------------------------------------------- 1 | import { ICodeManagementService } from '@/core/domain/platformIntegrations/interfaces/code-management.interface'; 2 | import { Injectable } from '@nestjs/common'; 3 | 4 | @Injectable() 5 | export class PlatformIntegrationFactory { 6 | private codeManagementServices = new Map(); 7 | 8 | registerCodeManagementService( 9 | type: string, 10 | service: ICodeManagementService, 11 | ) { 12 | this.codeManagementServices.set(type, service); 13 | } 14 | 15 | getCodeManagementService(type: string): ICodeManagementService { 16 | const service = this.codeManagementServices.get(type); 17 | 18 | if (!service) { 19 | throw new Error(`Repository service for type '${type}' not found.`); 20 | } 21 | return service; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/shared/utils/googleGenAI.ts: -------------------------------------------------------------------------------- 1 | import { MODEL_STRATEGIES, LLMModelProvider } from '@kodus/kodus-common/llm'; 2 | 3 | const { 4 | GoogleGenerativeAI, 5 | HarmCategory, 6 | HarmBlockThreshold, 7 | } = require('@google/generative-ai'); 8 | 9 | export const getGemini = async (params?: { 10 | model?: string; 11 | temperature?: number; 12 | responseMimeType?: string; 13 | }) => { 14 | const genAI = new GoogleGenerativeAI(process.env.API_GOOGLE_AI_API_KEY); 15 | 16 | const llm = genAI.getGenerativeModel({ 17 | model: 18 | params.model || 19 | MODEL_STRATEGIES[LLMModelProvider.GEMINI_2_5_PRO].modelName, 20 | }); 21 | 22 | return llm.startChat({ 23 | generationConfig: { 24 | temperature: params.temperature || 0, 25 | responseMimeType: params.responseMimeType || 'text/plain', 26 | }, 27 | history: [], 28 | }); 29 | }; 30 | -------------------------------------------------------------------------------- /src/ee/codeReviewSettingsLog/types/logParams.types.ts: -------------------------------------------------------------------------------- 1 | import { OrganizationAndTeamData } from '@/config/types/general/organizationAndTeamData'; 2 | import { ActionType, UserInfo } from '@/config/types/general/codeReviewSettingsLog.type'; 3 | 4 | export interface IntegrationLogParams { 5 | organizationAndTeamData: OrganizationAndTeamData; 6 | userInfo: UserInfo; 7 | integration: { 8 | platform: string; 9 | integrationCategory: string; 10 | status: boolean; 11 | authIntegration: any; 12 | }; 13 | actionType: ActionType; 14 | } 15 | 16 | export interface UserStatusLogParams { 17 | organizationAndTeamData: OrganizationAndTeamData; 18 | userInfo: UserInfo; 19 | actionType: ActionType; 20 | userStatusChanges: Array<{ 21 | gitId: string; 22 | gitTool: string; 23 | licenseStatus: "active" | "inactive"; 24 | userName: string; 25 | }>; 26 | } 27 | -------------------------------------------------------------------------------- /docker-compose.test.yml: -------------------------------------------------------------------------------- 1 | services: 2 | db_postgres: 3 | image: postgres:latest 4 | container_name: postgres 5 | ports: 6 | - '5432:5432' 7 | environment: 8 | POSTGRES_USER: ${API_PG_DB_USERNAME} 9 | POSTGRES_PASSWORD: ${API_PG_DB_PASSWORD} 10 | POSTGRES_DB: ${API_PG_DB_DATABASE} 11 | networks: 12 | - kodus-backend-services-test 13 | 14 | db_mongodb: 15 | image: mongo:6 16 | container_name: mongodb 17 | ports: 18 | - '27017:27017' 19 | environment: 20 | MONGO_INITDB_ROOT_USERNAME: ${API_MG_DB_USERNAME} 21 | MONGO_INITDB_ROOT_PASSWORD: ${API_MG_DB_PASSWORD} 22 | MONGO_INITDB_DATABASE: ${API_MG_DB_DATABASE} 23 | networks: 24 | - kodus-backend-services-test 25 | 26 | networks: 27 | kodus-backend-services-test: 28 | external: true 29 | 30 | -------------------------------------------------------------------------------- /packages/kodus-flow/.gitignore: -------------------------------------------------------------------------------- 1 | # Dependências 2 | node_modules/ 3 | .pnp 4 | .pnp.js 5 | 6 | # Build 7 | dist/ 8 | build/ 9 | coverage/ 10 | 11 | # Testes 12 | __tests__/__snapshots__/ 13 | *.test.ts.snap 14 | 15 | # Configurações locais 16 | .env 17 | .env.local 18 | .env.*.local 19 | 20 | # Editor/IDE 21 | .vscode/* 22 | !.vscode/extensions.json 23 | .idea 24 | *.suo 25 | *.ntvs* 26 | *.njsproj 27 | *.sln 28 | *.sw? 29 | 30 | # Logs 31 | logs 32 | *.log 33 | npm-debug.log* 34 | yarn-debug.log* 35 | yarn-error.log* 36 | lerna-debug.log* 37 | 38 | # Sistema operacional 39 | .DS_Store 40 | Thumbs.db 41 | 42 | # Outros 43 | .cache/ 44 | .temp/ 45 | .tmp/ 46 | .vercel 47 | .next 48 | out 49 | 50 | # Configurações específicas do projeto 51 | kodus.config.json 52 | *.log.* 53 | 54 | # TypeScript 55 | *.tsbuildinfo 56 | 57 | # Google Artifact Registry 58 | .npmrc.bak 59 | .npmrc 60 | 61 | # Folder para projetos clonados (análise) 62 | trd/ 63 | -------------------------------------------------------------------------------- /src/core/domain/permissions/enums/permissions.enum.ts: -------------------------------------------------------------------------------- 1 | export enum Action { 2 | Manage = 'manage', // wildcard for any action 3 | Create = 'create', 4 | Read = 'read', 5 | Update = 'update', 6 | Delete = 'delete', 7 | } 8 | 9 | export enum Role { 10 | OWNER = 'owner', 11 | BILLING_MANAGER = 'billing_manager', 12 | REPO_ADMIN = 'repo_admin', 13 | CONTRIBUTOR = 'contributor', 14 | } 15 | 16 | export enum ResourceType { 17 | All = 'all', 18 | PullRequests = 'pull_requests', 19 | Issues = 'issues', 20 | Cockpit = 'cockpit', 21 | Billing = 'billing', 22 | CodeReviewSettings = 'code_review_settings', 23 | IssuesSettings = 'issues_settings', 24 | GitSettings = 'git_settings', 25 | UserSettings = 'user_settings', 26 | OrganizationSettings = 'organization_settings', 27 | PluginSettings = 'plugin_settings', 28 | Logs = 'logs', 29 | KodyRules = 'kody_rules', 30 | } 31 | --------------------------------------------------------------------------------