codereview-aia 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +0 -7
- package/dist/index.js.map +1 -1
- package/dist/runtime/api/batcher.d.ts +20 -0
- package/dist/runtime/api/batcher.js +52 -0
- package/dist/runtime/api/batcher.js.map +1 -0
- package/dist/runtime/api/edgeClient.d.ts +102 -0
- package/dist/runtime/api/edgeClient.js +162 -0
- package/dist/runtime/api/edgeClient.js.map +1 -0
- package/dist/runtime/api/index.d.ts +2 -0
- package/dist/runtime/api/index.js +9 -0
- package/dist/runtime/api/index.js.map +1 -0
- package/dist/runtime/cliEntry.js +24 -76
- package/dist/runtime/cliEntry.js.map +1 -1
- package/dist/runtime/errors.d.ts +13 -3
- package/dist/runtime/errors.js +31 -8
- package/dist/runtime/errors.js.map +1 -1
- package/dist/runtime/llm/index.d.ts +1 -0
- package/dist/runtime/llm/index.js +6 -0
- package/dist/runtime/llm/index.js.map +1 -0
- package/dist/runtime/llm/openRouterClient.d.ts +13 -0
- package/dist/runtime/llm/openRouterClient.js +187 -0
- package/dist/runtime/llm/openRouterClient.js.map +1 -0
- package/dist/runtime/phpFileResolver.d.ts +14 -0
- package/dist/runtime/phpFileResolver.js +231 -0
- package/dist/runtime/phpFileResolver.js.map +1 -0
- package/dist/runtime/phpcsParser.d.ts +10 -0
- package/dist/runtime/phpcsParser.js +35 -0
- package/dist/runtime/phpcsParser.js.map +1 -0
- package/dist/runtime/phpcsRunner.d.ts +32 -0
- package/dist/runtime/phpcsRunner.js +62 -0
- package/dist/runtime/phpcsRunner.js.map +1 -0
- package/dist/runtime/reportWriter.d.ts +17 -0
- package/dist/runtime/reportWriter.js +80 -0
- package/dist/runtime/reportWriter.js.map +1 -0
- package/dist/runtime/reviewPipeline.d.ts +14 -36
- package/dist/runtime/reviewPipeline.js +146 -199
- package/dist/runtime/reviewPipeline.js.map +1 -1
- package/dist/runtime/ui/RuntimeApp.js +23 -154
- package/dist/runtime/ui/RuntimeApp.js.map +1 -1
- package/dist/runtime/ui/screens/AuthScreen.d.ts +2 -3
- package/dist/runtime/ui/screens/AuthScreen.js +7 -53
- package/dist/runtime/ui/screens/AuthScreen.js.map +1 -1
- package/dist/runtime/ui/screens/ModeSelection.d.ts +1 -2
- package/dist/runtime/ui/screens/ModeSelection.js +14 -139
- package/dist/runtime/ui/screens/ModeSelection.js.map +1 -1
- package/dist/runtime/ui/screens/ProgressScreen.d.ts +5 -13
- package/dist/runtime/ui/screens/ProgressScreen.js +24 -61
- package/dist/runtime/ui/screens/ProgressScreen.js.map +1 -1
- package/dist/runtime/ui/screens/ResultsScreen.js +7 -17
- package/dist/runtime/ui/screens/ResultsScreen.js.map +1 -1
- package/package.json +3 -43
- package/dist/analysis/FindingsExtractor.d.ts +0 -105
- package/dist/analysis/FindingsExtractor.js +0 -363
- package/dist/analysis/FindingsExtractor.js.map +0 -1
- package/dist/analysis/ai-detection/analyzers/BaseAnalyzer.d.ts +0 -111
- package/dist/analysis/ai-detection/analyzers/BaseAnalyzer.js +0 -215
- package/dist/analysis/ai-detection/analyzers/BaseAnalyzer.js.map +0 -1
- package/dist/analysis/ai-detection/analyzers/DocumentationAnalyzer.d.ts +0 -142
- package/dist/analysis/ai-detection/analyzers/DocumentationAnalyzer.js +0 -503
- package/dist/analysis/ai-detection/analyzers/DocumentationAnalyzer.js.map +0 -1
- package/dist/analysis/ai-detection/analyzers/GitHistoryAnalyzer.d.ts +0 -88
- package/dist/analysis/ai-detection/analyzers/GitHistoryAnalyzer.js +0 -343
- package/dist/analysis/ai-detection/analyzers/GitHistoryAnalyzer.js.map +0 -1
- package/dist/analysis/ai-detection/core/AIDetectionEngine.d.ts +0 -104
- package/dist/analysis/ai-detection/core/AIDetectionEngine.js +0 -369
- package/dist/analysis/ai-detection/core/AIDetectionEngine.js.map +0 -1
- package/dist/analysis/ai-detection/types/DetectionTypes.d.ts +0 -364
- package/dist/analysis/ai-detection/types/DetectionTypes.js +0 -32
- package/dist/analysis/ai-detection/types/DetectionTypes.js.map +0 -1
- package/dist/analysis/ai-detection/utils/SubmissionConverter.d.ts +0 -97
- package/dist/analysis/ai-detection/utils/SubmissionConverter.js +0 -339
- package/dist/analysis/ai-detection/utils/SubmissionConverter.js.map +0 -1
- package/dist/analysis/context/ReviewContext.d.ts +0 -184
- package/dist/analysis/context/ReviewContext.js +0 -294
- package/dist/analysis/context/ReviewContext.js.map +0 -1
- package/dist/analysis/context/index.d.ts +0 -6
- package/dist/analysis/context/index.js +0 -23
- package/dist/analysis/context/index.js.map +0 -1
- package/dist/analysis/index.d.ts +0 -7
- package/dist/analysis/index.js +0 -24
- package/dist/analysis/index.js.map +0 -1
- package/dist/analysis/static/wpPhpcsRunner.d.ts +0 -11
- package/dist/analysis/static/wpPhpcsRunner.js +0 -219
- package/dist/analysis/static/wpPhpcsRunner.js.map +0 -1
- package/dist/analysis/tokens/TokenAnalysisFormatter.d.ts +0 -27
- package/dist/analysis/tokens/TokenAnalysisFormatter.js +0 -143
- package/dist/analysis/tokens/TokenAnalysisFormatter.js.map +0 -1
- package/dist/analysis/tokens/TokenAnalyzer.d.ts +0 -155
- package/dist/analysis/tokens/TokenAnalyzer.js +0 -502
- package/dist/analysis/tokens/TokenAnalyzer.js.map +0 -1
- package/dist/analysis/tokens/index.d.ts +0 -7
- package/dist/analysis/tokens/index.js +0 -24
- package/dist/analysis/tokens/index.js.map +0 -1
- package/dist/clients/base/abstractClient.d.ts +0 -99
- package/dist/clients/base/abstractClient.js +0 -98
- package/dist/clients/base/abstractClient.js.map +0 -1
- package/dist/clients/base/httpClient.d.ts +0 -24
- package/dist/clients/base/httpClient.js +0 -147
- package/dist/clients/base/httpClient.js.map +0 -1
- package/dist/clients/base/index.d.ts +0 -11
- package/dist/clients/base/index.js +0 -28
- package/dist/clients/base/index.js.map +0 -1
- package/dist/clients/base/modelDetection.d.ts +0 -41
- package/dist/clients/base/modelDetection.js +0 -88
- package/dist/clients/base/modelDetection.js.map +0 -1
- package/dist/clients/base/responseProcessor.d.ts +0 -45
- package/dist/clients/base/responseProcessor.js +0 -495
- package/dist/clients/base/responseProcessor.js.map +0 -1
- package/dist/clients/factory/clientFactory.d.ts +0 -23
- package/dist/clients/factory/clientFactory.js +0 -50
- package/dist/clients/factory/clientFactory.js.map +0 -1
- package/dist/clients/factory/index.d.ts +0 -7
- package/dist/clients/factory/index.js +0 -24
- package/dist/clients/factory/index.js.map +0 -1
- package/dist/clients/implementations/index.d.ts +0 -7
- package/dist/clients/implementations/index.js +0 -24
- package/dist/clients/implementations/index.js.map +0 -1
- package/dist/clients/implementations/openRouterClient.d.ts +0 -69
- package/dist/clients/implementations/openRouterClient.js +0 -294
- package/dist/clients/implementations/openRouterClient.js.map +0 -1
- package/dist/clients/openRouterClient.d.ts +0 -42
- package/dist/clients/openRouterClient.js +0 -580
- package/dist/clients/openRouterClient.js.map +0 -1
- package/dist/clients/openRouterClientWrapper.d.ts +0 -22
- package/dist/clients/openRouterClientWrapper.js +0 -64
- package/dist/clients/openRouterClientWrapper.js.map +0 -1
- package/dist/clients/utils/directoryStructure.d.ts +0 -14
- package/dist/clients/utils/directoryStructure.js +0 -48
- package/dist/clients/utils/directoryStructure.js.map +0 -1
- package/dist/clients/utils/index.d.ts +0 -10
- package/dist/clients/utils/index.js +0 -31
- package/dist/clients/utils/index.js.map +0 -1
- package/dist/clients/utils/languageDetection.d.ts +0 -13
- package/dist/clients/utils/languageDetection.js +0 -46
- package/dist/clients/utils/languageDetection.js.map +0 -1
- package/dist/clients/utils/promptFormatter.d.ts +0 -37
- package/dist/clients/utils/promptFormatter.js +0 -186
- package/dist/clients/utils/promptFormatter.js.map +0 -1
- package/dist/clients/utils/promptLoader.d.ts +0 -27
- package/dist/clients/utils/promptLoader.js +0 -49
- package/dist/clients/utils/promptLoader.js.map +0 -1
- package/dist/clients/utils/tokenCounter.d.ts +0 -81
- package/dist/clients/utils/tokenCounter.js +0 -184
- package/dist/clients/utils/tokenCounter.js.map +0 -1
- package/dist/core/ApiClientSelector.d.ts +0 -8
- package/dist/core/ApiClientSelector.js +0 -29
- package/dist/core/ApiClientSelector.js.map +0 -1
- package/dist/core/ConfigurationService.d.ts +0 -307
- package/dist/core/ConfigurationService.js +0 -516
- package/dist/core/ConfigurationService.js.map +0 -1
- package/dist/core/ConsolidationService.d.ts +0 -99
- package/dist/core/ConsolidationService.js +0 -341
- package/dist/core/ConsolidationService.js.map +0 -1
- package/dist/core/InteractiveDisplayManager.d.ts +0 -22
- package/dist/core/InteractiveDisplayManager.js +0 -70
- package/dist/core/InteractiveDisplayManager.js.map +0 -1
- package/dist/core/OutputManager.d.ts +0 -26
- package/dist/core/OutputManager.js +0 -217
- package/dist/core/OutputManager.js.map +0 -1
- package/dist/core/ReviewGenerator.d.ts +0 -13
- package/dist/core/ReviewGenerator.js +0 -102
- package/dist/core/ReviewGenerator.js.map +0 -1
- package/dist/core/fileDiscovery.d.ts +0 -35
- package/dist/core/fileDiscovery.js +0 -202
- package/dist/core/fileDiscovery.js.map +0 -1
- package/dist/core/handlers/EstimationHandler.d.ts +0 -18
- package/dist/core/handlers/EstimationHandler.js +0 -110
- package/dist/core/handlers/EstimationHandler.js.map +0 -1
- package/dist/core/handlers/FileProcessingHandler.d.ts +0 -31
- package/dist/core/handlers/FileProcessingHandler.js +0 -164
- package/dist/core/handlers/FileProcessingHandler.js.map +0 -1
- package/dist/core/handlers/OutputHandler.d.ts +0 -27
- package/dist/core/handlers/OutputHandler.js +0 -127
- package/dist/core/handlers/OutputHandler.js.map +0 -1
- package/dist/core/handlers/ReviewExecutor.d.ts +0 -32
- package/dist/core/handlers/ReviewExecutor.js +0 -111
- package/dist/core/handlers/ReviewExecutor.js.map +0 -1
- package/dist/core/reviewOrchestrator.d.ts +0 -24
- package/dist/core/reviewOrchestrator.js +0 -354
- package/dist/core/reviewOrchestrator.js.map +0 -1
- package/dist/core/utils/ModelInfoUtils.d.ts +0 -16
- package/dist/core/utils/ModelInfoUtils.js +0 -54
- package/dist/core/utils/ModelInfoUtils.js.map +0 -1
- package/dist/formatters/outputFormatter.d.ts +0 -31
- package/dist/formatters/outputFormatter.js +0 -65
- package/dist/formatters/outputFormatter.js.map +0 -1
- package/dist/formatters/utils/IssueFormatters.d.ts +0 -20
- package/dist/formatters/utils/IssueFormatters.js +0 -67
- package/dist/formatters/utils/IssueFormatters.js.map +0 -1
- package/dist/formatters/utils/JsonFormatter.d.ts +0 -13
- package/dist/formatters/utils/JsonFormatter.js +0 -57
- package/dist/formatters/utils/JsonFormatter.js.map +0 -1
- package/dist/formatters/utils/MarkdownFormatters.d.ts +0 -51
- package/dist/formatters/utils/MarkdownFormatters.js +0 -456
- package/dist/formatters/utils/MarkdownFormatters.js.map +0 -1
- package/dist/formatters/utils/MetadataFormatter.d.ts +0 -65
- package/dist/formatters/utils/MetadataFormatter.js +0 -219
- package/dist/formatters/utils/MetadataFormatter.js.map +0 -1
- package/dist/formatters/utils/ModelInfoExtractor.d.ts +0 -33
- package/dist/formatters/utils/ModelInfoExtractor.js +0 -111
- package/dist/formatters/utils/ModelInfoExtractor.js.map +0 -1
- package/dist/plugins/PluginInterface.d.ts +0 -44
- package/dist/plugins/PluginInterface.js +0 -9
- package/dist/plugins/PluginInterface.js.map +0 -1
- package/dist/plugins/PluginManager.d.ts +0 -51
- package/dist/plugins/PluginManager.js +0 -151
- package/dist/plugins/PluginManager.js.map +0 -1
- package/dist/prompts/PromptManager.d.ts +0 -30
- package/dist/prompts/PromptManager.js +0 -62
- package/dist/prompts/PromptManager.js.map +0 -1
- package/dist/prompts/cache/PromptCache.d.ts +0 -32
- package/dist/prompts/cache/PromptCache.js +0 -48
- package/dist/prompts/cache/PromptCache.js.map +0 -1
- package/dist/runtime/auth/service.d.ts +0 -2
- package/dist/runtime/auth/service.js +0 -41
- package/dist/runtime/auth/service.js.map +0 -1
- package/dist/runtime/auth/session.d.ts +0 -5
- package/dist/runtime/auth/session.js +0 -87
- package/dist/runtime/auth/session.js.map +0 -1
- package/dist/runtime/auth/types.d.ts +0 -9
- package/dist/runtime/auth/types.js +0 -3
- package/dist/runtime/auth/types.js.map +0 -1
- package/dist/runtime/fileCollector.d.ts +0 -14
- package/dist/runtime/fileCollector.js +0 -383
- package/dist/runtime/fileCollector.js.map +0 -1
- package/dist/runtime/manifest.d.ts +0 -1
- package/dist/runtime/manifest.js +0 -65
- package/dist/runtime/manifest.js.map +0 -1
- package/dist/runtime/openrouterProxy.d.ts +0 -4
- package/dist/runtime/openrouterProxy.js +0 -43
- package/dist/runtime/openrouterProxy.js.map +0 -1
- package/dist/runtime/preprod/batchStreamer.d.ts +0 -54
- package/dist/runtime/preprod/batchStreamer.js +0 -159
- package/dist/runtime/preprod/batchStreamer.js.map +0 -1
- package/dist/runtime/preprod/crEdgeServiceClient.d.ts +0 -30
- package/dist/runtime/preprod/crEdgeServiceClient.js +0 -133
- package/dist/runtime/preprod/crEdgeServiceClient.js.map +0 -1
- package/dist/runtime/preprod/progressTracker.d.ts +0 -21
- package/dist/runtime/preprod/progressTracker.js +0 -80
- package/dist/runtime/preprod/progressTracker.js.map +0 -1
- package/dist/runtime/preprod/webCheck.d.ts +0 -1
- package/dist/runtime/preprod/webCheck.js +0 -102
- package/dist/runtime/preprod/webCheck.js.map +0 -1
- package/dist/runtime/proxyConfig.d.ts +0 -6
- package/dist/runtime/proxyConfig.js +0 -86
- package/dist/runtime/proxyConfig.js.map +0 -1
- package/dist/runtime/proxyEnvironment.d.ts +0 -3
- package/dist/runtime/proxyEnvironment.js +0 -63
- package/dist/runtime/proxyEnvironment.js.map +0 -1
- package/dist/runtime/reportMerge.d.ts +0 -30
- package/dist/runtime/reportMerge.js +0 -70
- package/dist/runtime/reportMerge.js.map +0 -1
- package/dist/runtime/reporting/markdownReportBuilder.d.ts +0 -17
- package/dist/runtime/reporting/markdownReportBuilder.js +0 -154
- package/dist/runtime/reporting/markdownReportBuilder.js.map +0 -1
- package/dist/runtime/reporting/reportDataCollector.d.ts +0 -31
- package/dist/runtime/reporting/reportDataCollector.js +0 -170
- package/dist/runtime/reporting/reportDataCollector.js.map +0 -1
- package/dist/runtime/reporting/summaryGenerator.d.ts +0 -10
- package/dist/runtime/reporting/summaryGenerator.js +0 -67
- package/dist/runtime/reporting/summaryGenerator.js.map +0 -1
- package/dist/runtime/runAiCodeReview.d.ts +0 -36
- package/dist/runtime/runAiCodeReview.js +0 -409
- package/dist/runtime/runAiCodeReview.js.map +0 -1
- package/dist/runtime/runtimeConfig.d.ts +0 -4
- package/dist/runtime/runtimeConfig.js +0 -7
- package/dist/runtime/runtimeConfig.js.map +0 -1
- package/dist/strategies/ArchitecturalReviewStrategy.d.ts +0 -29
- package/dist/strategies/ArchitecturalReviewStrategy.js +0 -42
- package/dist/strategies/ArchitecturalReviewStrategy.js.map +0 -1
- package/dist/strategies/CodingTestReviewStrategy.d.ts +0 -194
- package/dist/strategies/CodingTestReviewStrategy.js +0 -681
- package/dist/strategies/CodingTestReviewStrategy.js.map +0 -1
- package/dist/strategies/ConsolidatedReviewStrategy.d.ts +0 -25
- package/dist/strategies/ConsolidatedReviewStrategy.js +0 -45
- package/dist/strategies/ConsolidatedReviewStrategy.js.map +0 -1
- package/dist/strategies/ExtractPatternsReviewStrategy.d.ts +0 -30
- package/dist/strategies/ExtractPatternsReviewStrategy.js +0 -51
- package/dist/strategies/ExtractPatternsReviewStrategy.js.map +0 -1
- package/dist/strategies/MultiPassReviewStrategy.d.ts +0 -86
- package/dist/strategies/MultiPassReviewStrategy.js +0 -590
- package/dist/strategies/MultiPassReviewStrategy.js.map +0 -1
- package/dist/strategies/ReviewStrategy.d.ts +0 -45
- package/dist/strategies/ReviewStrategy.js +0 -24
- package/dist/strategies/ReviewStrategy.js.map +0 -1
- package/dist/strategies/StrategyFactory.d.ts +0 -19
- package/dist/strategies/StrategyFactory.js +0 -72
- package/dist/strategies/StrategyFactory.js.map +0 -1
- package/dist/strategies/index.d.ts +0 -13
- package/dist/strategies/index.js +0 -30
- package/dist/strategies/index.js.map +0 -1
- package/dist/tokenizers/baseTokenizer.d.ts +0 -25
- package/dist/tokenizers/baseTokenizer.js +0 -48
- package/dist/tokenizers/baseTokenizer.js.map +0 -1
- package/dist/tokenizers/gptTokenizer.d.ts +0 -7
- package/dist/tokenizers/gptTokenizer.js +0 -28
- package/dist/tokenizers/gptTokenizer.js.map +0 -1
- package/dist/tokenizers/index.d.ts +0 -7
- package/dist/tokenizers/index.js +0 -24
- package/dist/tokenizers/index.js.map +0 -1
- package/dist/types/apiResponses.d.ts +0 -39
- package/dist/types/apiResponses.js +0 -9
- package/dist/types/apiResponses.js.map +0 -1
- package/dist/types/cli.d.ts +0 -22
- package/dist/types/cli.js +0 -3
- package/dist/types/cli.js.map +0 -1
- package/dist/types/common.d.ts +0 -22
- package/dist/types/common.js +0 -14
- package/dist/types/common.js.map +0 -1
- package/dist/types/configuration.d.ts +0 -682
- package/dist/types/configuration.js +0 -65
- package/dist/types/configuration.js.map +0 -1
- package/dist/types/review.d.ts +0 -318
- package/dist/types/review.js +0 -8
- package/dist/types/review.js.map +0 -1
- package/dist/types/reviewSchema.d.ts +0 -543
- package/dist/types/reviewSchema.js +0 -121
- package/dist/types/reviewSchema.js.map +0 -1
- package/dist/types/structuredReview.d.ts +0 -119
- package/dist/types/structuredReview.js +0 -6
- package/dist/types/structuredReview.js.map +0 -1
- package/dist/types/tokenAnalysis.d.ts +0 -44
- package/dist/types/tokenAnalysis.js +0 -4
- package/dist/types/tokenAnalysis.js.map +0 -1
- package/dist/utils/FileReader.d.ts +0 -33
- package/dist/utils/FileReader.js +0 -88
- package/dist/utils/FileReader.js.map +0 -1
- package/dist/utils/FileWriter.d.ts +0 -26
- package/dist/utils/FileWriter.js +0 -76
- package/dist/utils/FileWriter.js.map +0 -1
- package/dist/utils/PathGenerator.d.ts +0 -30
- package/dist/utils/PathGenerator.js +0 -82
- package/dist/utils/PathGenerator.js.map +0 -1
- package/dist/utils/api/apiUtils.d.ts +0 -3
- package/dist/utils/api/apiUtils.js +0 -20
- package/dist/utils/api/apiUtils.js.map +0 -1
- package/dist/utils/api/index.d.ts +0 -1
- package/dist/utils/api/index.js +0 -18
- package/dist/utils/api/index.js.map +0 -1
- package/dist/utils/apiErrorHandler.d.ts +0 -130
- package/dist/utils/apiErrorHandler.js +0 -256
- package/dist/utils/apiErrorHandler.js.map +0 -1
- package/dist/utils/ciDataCollector.d.ts +0 -51
- package/dist/utils/ciDataCollector.js +0 -197
- package/dist/utils/ciDataCollector.js.map +0 -1
- package/dist/utils/codingTestConfigLoader.d.ts +0 -66
- package/dist/utils/codingTestConfigLoader.js +0 -420
- package/dist/utils/codingTestConfigLoader.js.map +0 -1
- package/dist/utils/dependencies/aiDependencyAnalyzer.d.ts +0 -30
- package/dist/utils/dependencies/aiDependencyAnalyzer.js +0 -343
- package/dist/utils/dependencies/aiDependencyAnalyzer.js.map +0 -1
- package/dist/utils/detection/frameworkDetector.d.ts +0 -43
- package/dist/utils/detection/frameworkDetector.js +0 -850
- package/dist/utils/detection/frameworkDetector.js.map +0 -1
- package/dist/utils/detection/index.d.ts +0 -9
- package/dist/utils/detection/index.js +0 -28
- package/dist/utils/detection/index.js.map +0 -1
- package/dist/utils/detection/projectTypeDetector.d.ts +0 -27
- package/dist/utils/detection/projectTypeDetector.js +0 -469
- package/dist/utils/detection/projectTypeDetector.js.map +0 -1
- package/dist/utils/diagramGenerator.d.ts +0 -49
- package/dist/utils/diagramGenerator.js +0 -218
- package/dist/utils/diagramGenerator.js.map +0 -1
- package/dist/utils/errorLogger.d.ts +0 -24
- package/dist/utils/errorLogger.js +0 -59
- package/dist/utils/errorLogger.js.map +0 -1
- package/dist/utils/estimationUtils.d.ts +0 -139
- package/dist/utils/estimationUtils.js +0 -329
- package/dist/utils/estimationUtils.js.map +0 -1
- package/dist/utils/fileFilters.d.ts +0 -72
- package/dist/utils/fileFilters.js +0 -350
- package/dist/utils/fileFilters.js.map +0 -1
- package/dist/utils/fileSystem.d.ts +0 -22
- package/dist/utils/fileSystem.js +0 -45
- package/dist/utils/fileSystem.js.map +0 -1
- package/dist/utils/index.d.ts +0 -22
- package/dist/utils/index.js +0 -52
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/pathValidator.d.ts +0 -40
- package/dist/utils/pathValidator.js +0 -98
- package/dist/utils/pathValidator.js.map +0 -1
- package/dist/utils/priorityFilter.d.ts +0 -34
- package/dist/utils/priorityFilter.js +0 -54
- package/dist/utils/priorityFilter.js.map +0 -1
- package/dist/utils/projectDocs.d.ts +0 -47
- package/dist/utils/projectDocs.js +0 -158
- package/dist/utils/projectDocs.js.map +0 -1
- package/dist/utils/promptPaths.d.ts +0 -6
- package/dist/utils/promptPaths.js +0 -33
- package/dist/utils/promptPaths.js.map +0 -1
- package/dist/utils/promptTemplateManager.d.ts +0 -34
- package/dist/utils/promptTemplateManager.js +0 -141
- package/dist/utils/promptTemplateManager.js.map +0 -1
- package/dist/utils/review/consolidateReview.d.ts +0 -15
- package/dist/utils/review/consolidateReview.js +0 -481
- package/dist/utils/review/consolidateReview.js.map +0 -1
- package/dist/utils/review/fixDisplay.d.ts +0 -20
- package/dist/utils/review/fixDisplay.js +0 -84
- package/dist/utils/review/fixDisplay.js.map +0 -1
- package/dist/utils/review/fixImplementation.d.ts +0 -28
- package/dist/utils/review/fixImplementation.js +0 -60
- package/dist/utils/review/fixImplementation.js.map +0 -1
- package/dist/utils/review/index.d.ts +0 -13
- package/dist/utils/review/index.js +0 -50
- package/dist/utils/review/index.js.map +0 -1
- package/dist/utils/review/interactiveProcessing.d.ts +0 -25
- package/dist/utils/review/interactiveProcessing.js +0 -251
- package/dist/utils/review/interactiveProcessing.js.map +0 -1
- package/dist/utils/review/progressTracker.d.ts +0 -106
- package/dist/utils/review/progressTracker.js +0 -227
- package/dist/utils/review/progressTracker.js.map +0 -1
- package/dist/utils/review/reviewExtraction.d.ts +0 -31
- package/dist/utils/review/reviewExtraction.js +0 -324
- package/dist/utils/review/reviewExtraction.js.map +0 -1
- package/dist/utils/review/types.d.ts +0 -45
- package/dist/utils/review/types.js +0 -18
- package/dist/utils/review/types.js.map +0 -1
- package/dist/utils/reviewActionHandler.d.ts +0 -16
- package/dist/utils/reviewActionHandler.js +0 -34
- package/dist/utils/reviewActionHandler.js.map +0 -1
- package/dist/utils/reviewParser.d.ts +0 -34
- package/dist/utils/reviewParser.js +0 -218
- package/dist/utils/reviewParser.js.map +0 -1
- package/dist/utils/sanitizer.d.ts +0 -82
- package/dist/utils/sanitizer.js +0 -239
- package/dist/utils/sanitizer.js.map +0 -1
- package/dist/utils/smartFileSelector.d.ts +0 -50
- package/dist/utils/smartFileSelector.js +0 -261
- package/dist/utils/smartFileSelector.js.map +0 -1
- package/dist/utils/templateLoader.d.ts +0 -44
- package/dist/utils/templateLoader.js +0 -431
- package/dist/utils/templateLoader.js.map +0 -1
- package/dist/utils/treeGenerator.d.ts +0 -12
- package/dist/utils/treeGenerator.js +0 -133
- package/dist/utils/treeGenerator.js.map +0 -1
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Type definitions for review action modules
|
|
4
|
-
*
|
|
5
|
-
* This module provides shared types used across the review action modules.
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.FixPriority = void 0;
|
|
9
|
-
/**
|
|
10
|
-
* Priority levels for code review fixes
|
|
11
|
-
*/
|
|
12
|
-
var FixPriority;
|
|
13
|
-
(function (FixPriority) {
|
|
14
|
-
FixPriority["HIGH"] = "high";
|
|
15
|
-
FixPriority["MEDIUM"] = "medium";
|
|
16
|
-
FixPriority["LOW"] = "low";
|
|
17
|
-
})(FixPriority || (exports.FixPriority = FixPriority = {}));
|
|
18
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/review/types.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH;;GAEG;AACH,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,4BAAa,CAAA;IACb,gCAAiB,CAAA;IACjB,0BAAW,CAAA;AACb,CAAC,EAJW,WAAW,2BAAX,WAAW,QAItB"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Utilities for parsing and acting on code review results.
|
|
3
|
-
*
|
|
4
|
-
* This module provides functions for parsing code review results and automatically
|
|
5
|
-
* implementing suggested fixes based on priority levels. It can extract code snippets,
|
|
6
|
-
* identify file locations, and apply changes to the codebase.
|
|
7
|
-
*
|
|
8
|
-
* Key responsibilities:
|
|
9
|
-
* - Parsing review results to extract actionable items
|
|
10
|
-
* - Categorizing fixes by priority (high, medium, low)
|
|
11
|
-
* - Implementing high priority fixes automatically
|
|
12
|
-
* - Prompting for confirmation on medium and low priority fixes
|
|
13
|
-
* - Tracking changes made to files
|
|
14
|
-
* - Providing summary reports of actions taken
|
|
15
|
-
*/
|
|
16
|
-
export * from './review';
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Utilities for parsing and acting on code review results.
|
|
4
|
-
*
|
|
5
|
-
* This module provides functions for parsing code review results and automatically
|
|
6
|
-
* implementing suggested fixes based on priority levels. It can extract code snippets,
|
|
7
|
-
* identify file locations, and apply changes to the codebase.
|
|
8
|
-
*
|
|
9
|
-
* Key responsibilities:
|
|
10
|
-
* - Parsing review results to extract actionable items
|
|
11
|
-
* - Categorizing fixes by priority (high, medium, low)
|
|
12
|
-
* - Implementing high priority fixes automatically
|
|
13
|
-
* - Prompting for confirmation on medium and low priority fixes
|
|
14
|
-
* - Tracking changes made to files
|
|
15
|
-
* - Providing summary reports of actions taken
|
|
16
|
-
*/
|
|
17
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
-
}
|
|
23
|
-
Object.defineProperty(o, k2, desc);
|
|
24
|
-
}) : (function(o, m, k, k2) {
|
|
25
|
-
if (k2 === undefined) k2 = k;
|
|
26
|
-
o[k2] = m[k];
|
|
27
|
-
}));
|
|
28
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
29
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
30
|
-
};
|
|
31
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
// Re-export all functionality from the review modules
|
|
33
|
-
__exportStar(require("./review"), exports);
|
|
34
|
-
//# sourceMappingURL=reviewActionHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reviewActionHandler.js","sourceRoot":"","sources":["../../src/utils/reviewActionHandler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAEH,sDAAsD;AACtD,2CAAyB"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Utilities for parsing structured review output.
|
|
3
|
-
*
|
|
4
|
-
* This module provides functions for parsing and processing structured review output
|
|
5
|
-
* in interactive mode. It handles JSON parsing, validation, and extraction of review
|
|
6
|
-
* information from the AI's response.
|
|
7
|
-
*/
|
|
8
|
-
import { type ReviewIssue, type ReviewSchema } from '../types/reviewSchema';
|
|
9
|
-
/**
|
|
10
|
-
* Parse a JSON string into a ReviewSchema object
|
|
11
|
-
* @param jsonString The JSON string to parse
|
|
12
|
-
* @returns The parsed ReviewSchema object or null if parsing fails
|
|
13
|
-
*/
|
|
14
|
-
export declare function parseReviewJson(jsonString: string): ReviewSchema | null;
|
|
15
|
-
/**
|
|
16
|
-
* Extract the review content from a string that might contain JSON
|
|
17
|
-
* @param content The content to extract from
|
|
18
|
-
* @returns The extracted review content
|
|
19
|
-
*/
|
|
20
|
-
export declare function extractReviewContent(content: string): string;
|
|
21
|
-
/**
|
|
22
|
-
* Format an issue for display in the console
|
|
23
|
-
* @param issue The issue to format
|
|
24
|
-
* @param filePath Path to the file containing the issue
|
|
25
|
-
* @param fileIndex Index of the file
|
|
26
|
-
* @param issueIndex Index of the issue
|
|
27
|
-
* @returns Formatted issue string
|
|
28
|
-
*/
|
|
29
|
-
export declare function formatIssueForDisplay(issue: ReviewIssue, filePath: string, fileIndex: number, issueIndex: number): string;
|
|
30
|
-
/**
|
|
31
|
-
* Display a structured review in the console
|
|
32
|
-
* @param parsedReview The parsed review object
|
|
33
|
-
*/
|
|
34
|
-
export declare function displayStructuredReview(parsedReview: ReviewSchema): void;
|
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Utilities for parsing structured review output.
|
|
4
|
-
*
|
|
5
|
-
* This module provides functions for parsing and processing structured review output
|
|
6
|
-
* in interactive mode. It handles JSON parsing, validation, and extraction of review
|
|
7
|
-
* information from the AI's response.
|
|
8
|
-
*/
|
|
9
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.parseReviewJson = parseReviewJson;
|
|
14
|
-
exports.extractReviewContent = extractReviewContent;
|
|
15
|
-
exports.formatIssueForDisplay = formatIssueForDisplay;
|
|
16
|
-
exports.displayStructuredReview = displayStructuredReview;
|
|
17
|
-
// import { z } from 'zod'; // Not currently used
|
|
18
|
-
const reviewSchema_1 = require("../types/reviewSchema");
|
|
19
|
-
const logger_1 = __importDefault(require("./logger"));
|
|
20
|
-
/**
|
|
21
|
-
* Parse a JSON string into a ReviewSchema object
|
|
22
|
-
* @param jsonString The JSON string to parse
|
|
23
|
-
* @returns The parsed ReviewSchema object or null if parsing fails
|
|
24
|
-
*/
|
|
25
|
-
function parseReviewJson(jsonString) {
|
|
26
|
-
try {
|
|
27
|
-
// Step 1: First attempt to parse as direct JSON if the string is already properly formatted
|
|
28
|
-
// This should be the fast path for models that correctly return structured JSON
|
|
29
|
-
if (jsonString.trim().startsWith('{') && jsonString.trim().endsWith('}')) {
|
|
30
|
-
try {
|
|
31
|
-
// Try to parse directly first - this is the ideal case and should work with the
|
|
32
|
-
// updated model instructions that request structured JSON
|
|
33
|
-
const directJson = JSON.parse(jsonString);
|
|
34
|
-
// Validate using Zod schema
|
|
35
|
-
const directValidation = reviewSchema_1.reviewSchema.safeParse(directJson);
|
|
36
|
-
if (directValidation.success) {
|
|
37
|
-
logger_1.default.debug('Successfully parsed direct JSON response');
|
|
38
|
-
return directValidation.data;
|
|
39
|
-
}
|
|
40
|
-
if (directJson.review) {
|
|
41
|
-
// Basic validation passed
|
|
42
|
-
logger_1.default.debug('Direct JSON has review property but failed schema validation, using fallback');
|
|
43
|
-
return directJson;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
catch (_e) {
|
|
47
|
-
// If direct parsing fails, continue with the extraction approaches
|
|
48
|
-
logger_1.default.debug('Direct parsing failed, attempting extraction patterns');
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
// Step 2: If direct parsing fails, try various extraction patterns
|
|
52
|
-
// Try to extract JSON from the response with improved language marker handling
|
|
53
|
-
// Handle various formats:
|
|
54
|
-
// 1. ```json {...}```
|
|
55
|
-
// 2. ```typescript {...}``` or other language markers
|
|
56
|
-
// 3. ```{...}```
|
|
57
|
-
// 4. Plain JSON outside code blocks
|
|
58
|
-
// First try to find code blocks with JSON content
|
|
59
|
-
const jsonBlockMatch = jsonString.match(/```(?:json)?\s*({[\s\S]*?})\s*```/);
|
|
60
|
-
// If no JSON block, look for any code block (could have typescript or other language marker)
|
|
61
|
-
const anyCodeBlockMatch = !jsonBlockMatch
|
|
62
|
-
? jsonString.match(/```(?:[\w]*)?[\s\n]*({[\s\S]*?})[\s\n]*```/)
|
|
63
|
-
: null;
|
|
64
|
-
// Check for code blocks with language markers that aren't proper JSON
|
|
65
|
-
const languageBlockRegex = /```(typescript|javascript|js|ts|jsx|tsx|java|python|ruby|go|rust|c|cpp|csharp|php)\s*([\s\S]*?)\s*```/;
|
|
66
|
-
const languageBlockMatch = !jsonBlockMatch && !anyCodeBlockMatch ? jsonString.match(languageBlockRegex) : null;
|
|
67
|
-
if (languageBlockMatch) {
|
|
68
|
-
// Don't treat language-specific code blocks as JSON - log a warning
|
|
69
|
-
const language = languageBlockMatch[1];
|
|
70
|
-
logger_1.default.warn(`Found ${language} code block but not valid JSON. Skipping JSON parsing attempt for this block.`);
|
|
71
|
-
// Return early with null to avoid trying to parse code as JSON
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
// If no code block match at all, try other patterns for JSON outside code blocks
|
|
75
|
-
// First look for review patterns - the most likely structure
|
|
76
|
-
const reviewJsonPattern = /({[\s\S]*?"review"[\s\S]*?})/;
|
|
77
|
-
const reviewJsonMatch = jsonString.match(reviewJsonPattern);
|
|
78
|
-
// Then fall back to any JSON-like patterns
|
|
79
|
-
const anyJsonPattern = /({[\s\S]*?})/;
|
|
80
|
-
const anyJsonMatch = !reviewJsonMatch ? jsonString.match(anyJsonPattern) : null;
|
|
81
|
-
// Determine which match to use
|
|
82
|
-
let jsonContent = jsonString; // default to full string
|
|
83
|
-
if (jsonBlockMatch) {
|
|
84
|
-
logger_1.default.debug('Found JSON code block, extracting content');
|
|
85
|
-
jsonContent = jsonBlockMatch[1];
|
|
86
|
-
}
|
|
87
|
-
else if (anyCodeBlockMatch) {
|
|
88
|
-
logger_1.default.debug('Found code block with JSON-like content, attempting to parse');
|
|
89
|
-
jsonContent = anyCodeBlockMatch[1];
|
|
90
|
-
}
|
|
91
|
-
else if (reviewJsonMatch) {
|
|
92
|
-
logger_1.default.debug('Found review JSON content outside code blocks');
|
|
93
|
-
jsonContent = reviewJsonMatch[1];
|
|
94
|
-
}
|
|
95
|
-
else if (anyJsonMatch) {
|
|
96
|
-
logger_1.default.debug('Found generic JSON-like content');
|
|
97
|
-
jsonContent = anyJsonMatch[1];
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
logger_1.default.debug('No JSON content patterns found, attempting to parse raw content');
|
|
101
|
-
}
|
|
102
|
-
// Clean up the content - remove comments that might be in the JSON
|
|
103
|
-
// Remove both single-line and inline comments
|
|
104
|
-
jsonContent = jsonContent
|
|
105
|
-
.replace(/\/\/.*?(?=\n|$)/g, '') // Remove inline comments (// style)
|
|
106
|
-
.replace(/^\s*\/\/.*$/gm, '') // Remove single-line comments
|
|
107
|
-
.replace(/\/\*[\s\S]*?\*\//g, '') // Remove multi-line comments
|
|
108
|
-
.replace(/,\s*}/g, '}') // Fix trailing commas that might appear after removing comments
|
|
109
|
-
.replace(/,\s*]/g, ']'); // Fix trailing commas in arrays
|
|
110
|
-
// Additional cleanup for specific JSON parsing issues
|
|
111
|
-
jsonContent = jsonContent
|
|
112
|
-
.replace(/([{,])\s*"(\w+)":\s*"([^"]*)",\s*\/\/.*?(?=\n|$)/g, '$1"$2":"$3",') // Clean inline comments after values
|
|
113
|
-
.replace(/([{,])\s*"(\w+)":\s*(\d+),\s*\/\/.*?(?=\n|$)/g, '$1"$2":$3,'); // Clean inline comments after numeric values
|
|
114
|
-
// Parse the JSON
|
|
115
|
-
const parsedJson = JSON.parse(jsonContent);
|
|
116
|
-
// Validate using Zod schema
|
|
117
|
-
const validationResult = reviewSchema_1.reviewSchema.safeParse(parsedJson);
|
|
118
|
-
if (validationResult.success) {
|
|
119
|
-
logger_1.default.debug('Successfully validated review JSON with Zod schema');
|
|
120
|
-
return validationResult.data;
|
|
121
|
-
}
|
|
122
|
-
logger_1.default.warn('Failed to validate review JSON schema:', validationResult.error.errors);
|
|
123
|
-
// Fallback to basic validation if the schema doesn't match exactly
|
|
124
|
-
// This helps with backward compatibility
|
|
125
|
-
if (parsedJson.review) {
|
|
126
|
-
logger_1.default.warn('Using fallback validation for review JSON');
|
|
127
|
-
return parsedJson;
|
|
128
|
-
}
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
catch (error) {
|
|
132
|
-
logger_1.default.error('Error parsing review JSON:', error);
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Extract the review content from a string that might contain JSON
|
|
138
|
-
* @param content The content to extract from
|
|
139
|
-
* @returns The extracted review content
|
|
140
|
-
*/
|
|
141
|
-
function extractReviewContent(content) {
|
|
142
|
-
// Try to find JSON in the content
|
|
143
|
-
const parsedReview = parseReviewJson(content);
|
|
144
|
-
if (parsedReview) {
|
|
145
|
-
// If we successfully parsed the JSON, return it formatted
|
|
146
|
-
return JSON.stringify(parsedReview, null, 2);
|
|
147
|
-
}
|
|
148
|
-
// Otherwise, return the original content
|
|
149
|
-
return content;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Format an issue for display in the console
|
|
153
|
-
* @param issue The issue to format
|
|
154
|
-
* @param filePath Path to the file containing the issue
|
|
155
|
-
* @param fileIndex Index of the file
|
|
156
|
-
* @param issueIndex Index of the issue
|
|
157
|
-
* @returns Formatted issue string
|
|
158
|
-
*/
|
|
159
|
-
function formatIssueForDisplay(issue, filePath, fileIndex, issueIndex) {
|
|
160
|
-
const priorityColors = {
|
|
161
|
-
[reviewSchema_1.IssuePriority.HIGH]: '\x1b[31m', // Red
|
|
162
|
-
[reviewSchema_1.IssuePriority.MEDIUM]: '\x1b[33m', // Yellow
|
|
163
|
-
[reviewSchema_1.IssuePriority.LOW]: '\x1b[32m', // Green
|
|
164
|
-
};
|
|
165
|
-
const priorityColor = priorityColors[issue.priority] || '\x1b[37m'; // Default to white
|
|
166
|
-
const reset = '\x1b[0m';
|
|
167
|
-
const bold = '\x1b[1m';
|
|
168
|
-
let output = `\n${bold}Issue ${fileIndex + 1}.${issueIndex + 1}: ${priorityColor}[${issue.priority}]${reset}${bold} ${issue.id}${reset}\n`;
|
|
169
|
-
output += `${bold}Description:${reset} ${issue.description}\n`;
|
|
170
|
-
output += `${bold}File:${reset} ${filePath}\n`;
|
|
171
|
-
output += `${bold}Location:${reset} Lines ${issue.location.startLine}-${issue.location.endLine}\n\n`;
|
|
172
|
-
output += `${bold}Current Code:${reset}\n`;
|
|
173
|
-
output += '```\n';
|
|
174
|
-
output += issue.currentCode;
|
|
175
|
-
output += '\n```\n\n';
|
|
176
|
-
output += `${bold}Suggested Code:${reset}\n`;
|
|
177
|
-
output += '```\n';
|
|
178
|
-
output += issue.suggestedCode;
|
|
179
|
-
output += '\n```\n\n';
|
|
180
|
-
if (issue.explanation) {
|
|
181
|
-
output += `${bold}Explanation:${reset}\n`;
|
|
182
|
-
output += issue.explanation;
|
|
183
|
-
output += '\n\n';
|
|
184
|
-
}
|
|
185
|
-
return output;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Display a structured review in the console
|
|
189
|
-
* @param parsedReview The parsed review object
|
|
190
|
-
*/
|
|
191
|
-
function displayStructuredReview(parsedReview) {
|
|
192
|
-
const { review } = parsedReview;
|
|
193
|
-
logger_1.default.info('\n=== Structured Code Review Results ===\n');
|
|
194
|
-
// Display files one by one
|
|
195
|
-
review.files.forEach((file, fileIndex) => {
|
|
196
|
-
logger_1.default.info(`\n${'-'.repeat(80)}`);
|
|
197
|
-
logger_1.default.info(`File ${fileIndex + 1}: ${file.filePath}`);
|
|
198
|
-
logger_1.default.info(`${'-'.repeat(80)}`);
|
|
199
|
-
if (file.issues.length === 0) {
|
|
200
|
-
logger_1.default.info('No issues found in this file.');
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
// Display issues for this file
|
|
204
|
-
file.issues.forEach((issue, issueIndex) => {
|
|
205
|
-
const formattedIssue = formatIssueForDisplay(issue, file.filePath, fileIndex, issueIndex);
|
|
206
|
-
logger_1.default.info(formattedIssue);
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
// Display summary
|
|
210
|
-
logger_1.default.info(`\n${'-'.repeat(80)}`);
|
|
211
|
-
logger_1.default.info('Summary:');
|
|
212
|
-
logger_1.default.info(`${'-'.repeat(80)}`);
|
|
213
|
-
logger_1.default.info(`High Priority Issues: ${review.summary.highPriorityIssues}`);
|
|
214
|
-
logger_1.default.info(`Medium Priority Issues: ${review.summary.mediumPriorityIssues}`);
|
|
215
|
-
logger_1.default.info(`Low Priority Issues: ${review.summary.lowPriorityIssues}`);
|
|
216
|
-
logger_1.default.info(`Total Issues: ${review.summary.totalIssues}`);
|
|
217
|
-
}
|
|
218
|
-
//# sourceMappingURL=reviewParser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reviewParser.js","sourceRoot":"","sources":["../../src/utils/reviewParser.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;AAgBH,0CA+HC;AAOD,oDAWC;AAUD,sDAsCC;AAMD,0DA+BC;AApPD,iDAAiD;AACjD,wDAK+B;AAC/B,sDAA8B;AAE9B;;;;GAIG;AACH,SAAgB,eAAe,CAAC,UAAkB;IAChD,IAAI,CAAC;QACH,4FAA4F;QAC5F,gFAAgF;QAChF,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACzE,IAAI,CAAC;gBACH,gFAAgF;gBAChF,0DAA0D;gBAC1D,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;gBAE1C,4BAA4B;gBAC5B,MAAM,gBAAgB,GAAG,2BAAY,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;gBAC5D,IAAI,gBAAgB,CAAC,OAAO,EAAE,CAAC;oBAC7B,gBAAM,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;oBAC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BAAM,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACnC,gBAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACxB,gBAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACjC,gBAAM,CAAC,IAAI,CAAC,yBAAyB,MAAM,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAC1E,gBAAM,CAAC,IAAI,CAAC,2BAA2B,MAAM,CAAC,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC9E,gBAAM,CAAC,IAAI,CAAC,wBAAwB,MAAM,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACxE,gBAAM,CAAC,IAAI,CAAC,iBAAiB,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Content sanitization utilities for preventing XSS attacks.
|
|
3
|
-
*
|
|
4
|
-
* This module provides sanitization functions to clean user-generated or AI-generated
|
|
5
|
-
* content before rendering or storing it. It uses DOMPurify to remove potentially
|
|
6
|
-
* malicious HTML, JavaScript, and other harmful content while preserving legitimate
|
|
7
|
-
* formatting elements. It also includes utilities for sanitizing filenames to ensure
|
|
8
|
-
* they are safe for use in file systems.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Sanitizes HTML content to prevent Cross-Site Scripting (XSS) attacks.
|
|
12
|
-
*
|
|
13
|
-
* This function uses DOMPurify to clean HTML content by:
|
|
14
|
-
* 1. Allowing only safe HTML tags (h1-h6, p, lists, tables, etc.)
|
|
15
|
-
* 2. Allowing only safe attributes (href, class, id, etc.)
|
|
16
|
-
* 3. Explicitly forbidding dangerous tags (script, iframe, svg, etc.)
|
|
17
|
-
* 4. Explicitly forbidding dangerous attributes (onerror, onclick, etc.)
|
|
18
|
-
*
|
|
19
|
-
* If sanitization fails for any reason, it returns an empty string for safety.
|
|
20
|
-
*
|
|
21
|
-
* @param {string} content - The HTML content to sanitize
|
|
22
|
-
* @returns {string} Sanitized HTML with potentially dangerous content removed
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* const unsafeHtml = '<div>Safe content</div><script>alert("XSS")</script>';
|
|
26
|
-
* const safeHtml = sanitizeHtml(unsafeHtml);
|
|
27
|
-
* // Returns: "<div>Safe content</div>"
|
|
28
|
-
*
|
|
29
|
-
* @throws Catches internally and returns empty string if DOMPurify fails
|
|
30
|
-
*/
|
|
31
|
-
export declare function sanitizeHtml(content: string): string;
|
|
32
|
-
/**
|
|
33
|
-
* Sanitize Markdown content
|
|
34
|
-
* @param content Markdown content to sanitize
|
|
35
|
-
* @returns Sanitized Markdown content
|
|
36
|
-
*/
|
|
37
|
-
export declare function sanitizeMarkdown(content: string): string;
|
|
38
|
-
/**
|
|
39
|
-
* Sanitize JSON content
|
|
40
|
-
* @param content JSON content to sanitize
|
|
41
|
-
* @returns Sanitized JSON content
|
|
42
|
-
*/
|
|
43
|
-
export declare function sanitizeJson(content: string): string;
|
|
44
|
-
/**
|
|
45
|
-
* Sanitizes content based on its type to prevent security vulnerabilities.
|
|
46
|
-
*
|
|
47
|
-
* This function acts as a dispatcher that routes the content to the appropriate
|
|
48
|
-
* specialized sanitization function based on the content type. It supports
|
|
49
|
-
* HTML, Markdown, JSON, and plain text formats, each with type-specific
|
|
50
|
-
* sanitization rules.
|
|
51
|
-
*
|
|
52
|
-
* @param {string} content - The content to sanitize
|
|
53
|
-
* @param {('html'|'markdown'|'json'|'text')} [contentType='text'] - The type of content
|
|
54
|
-
* @returns {string} Sanitized content safe for rendering or storage
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* // Sanitize HTML content
|
|
58
|
-
* const safeHtml = sanitizeContent('<script>alert("XSS")</script><p>Hello</p>', 'html');
|
|
59
|
-
* // Returns: "<p>Hello</p>"
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* // Sanitize Markdown content
|
|
63
|
-
* const safeMarkdown = sanitizeContent('# Title\n<script>alert("XSS")</script>', 'markdown');
|
|
64
|
-
* // Returns: "# Title\n"
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* // Sanitize JSON content
|
|
68
|
-
* const safeJson = sanitizeContent('{"key": "value"}', 'json');
|
|
69
|
-
* // Returns: '{"key":"value"}'
|
|
70
|
-
*/
|
|
71
|
-
export declare function sanitizeContent(content: string, contentType?: 'html' | 'markdown' | 'json' | 'text'): string;
|
|
72
|
-
/**
|
|
73
|
-
* Sanitize a filename to ensure it's safe for use in file systems
|
|
74
|
-
*
|
|
75
|
-
* This function removes or replaces characters that are not safe for use in filenames
|
|
76
|
-
* across different operating systems. It handles null/undefined inputs and preserves
|
|
77
|
-
* spaces and non-ASCII characters that are generally safe for modern file systems.
|
|
78
|
-
*
|
|
79
|
-
* @param filename The filename to sanitize
|
|
80
|
-
* @returns A sanitized filename safe for use in file systems
|
|
81
|
-
*/
|
|
82
|
-
export declare function sanitizeFilename(filename: string | null | undefined): string;
|
package/dist/utils/sanitizer.js
DELETED
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Content sanitization utilities for preventing XSS attacks.
|
|
4
|
-
*
|
|
5
|
-
* This module provides sanitization functions to clean user-generated or AI-generated
|
|
6
|
-
* content before rendering or storing it. It uses DOMPurify to remove potentially
|
|
7
|
-
* malicious HTML, JavaScript, and other harmful content while preserving legitimate
|
|
8
|
-
* formatting elements. It also includes utilities for sanitizing filenames to ensure
|
|
9
|
-
* they are safe for use in file systems.
|
|
10
|
-
*/
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.sanitizeHtml = sanitizeHtml;
|
|
16
|
-
exports.sanitizeMarkdown = sanitizeMarkdown;
|
|
17
|
-
exports.sanitizeJson = sanitizeJson;
|
|
18
|
-
exports.sanitizeContent = sanitizeContent;
|
|
19
|
-
exports.sanitizeFilename = sanitizeFilename;
|
|
20
|
-
const dompurify_1 = __importDefault(require("dompurify"));
|
|
21
|
-
const jsdom_1 = require("jsdom");
|
|
22
|
-
const logger_1 = __importDefault(require("./logger"));
|
|
23
|
-
// Create a DOM window for DOMPurify
|
|
24
|
-
const { window } = new jsdom_1.JSDOM('');
|
|
25
|
-
// Cast window for DOMPurify compatibility
|
|
26
|
-
const DOMPurify = (0, dompurify_1.default)(window);
|
|
27
|
-
/**
|
|
28
|
-
* Sanitizes HTML content to prevent Cross-Site Scripting (XSS) attacks.
|
|
29
|
-
*
|
|
30
|
-
* This function uses DOMPurify to clean HTML content by:
|
|
31
|
-
* 1. Allowing only safe HTML tags (h1-h6, p, lists, tables, etc.)
|
|
32
|
-
* 2. Allowing only safe attributes (href, class, id, etc.)
|
|
33
|
-
* 3. Explicitly forbidding dangerous tags (script, iframe, svg, etc.)
|
|
34
|
-
* 4. Explicitly forbidding dangerous attributes (onerror, onclick, etc.)
|
|
35
|
-
*
|
|
36
|
-
* If sanitization fails for any reason, it returns an empty string for safety.
|
|
37
|
-
*
|
|
38
|
-
* @param {string} content - The HTML content to sanitize
|
|
39
|
-
* @returns {string} Sanitized HTML with potentially dangerous content removed
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* const unsafeHtml = '<div>Safe content</div><script>alert("XSS")</script>';
|
|
43
|
-
* const safeHtml = sanitizeHtml(unsafeHtml);
|
|
44
|
-
* // Returns: "<div>Safe content</div>"
|
|
45
|
-
*
|
|
46
|
-
* @throws Catches internally and returns empty string if DOMPurify fails
|
|
47
|
-
*/
|
|
48
|
-
function sanitizeHtml(content) {
|
|
49
|
-
try {
|
|
50
|
-
// Configure DOMPurify to allow certain tags and attributes
|
|
51
|
-
const sanitized = DOMPurify.sanitize(content, {
|
|
52
|
-
ALLOWED_TAGS: [
|
|
53
|
-
'h1',
|
|
54
|
-
'h2',
|
|
55
|
-
'h3',
|
|
56
|
-
'h4',
|
|
57
|
-
'h5',
|
|
58
|
-
'h6',
|
|
59
|
-
'p',
|
|
60
|
-
'br',
|
|
61
|
-
'hr',
|
|
62
|
-
'ul',
|
|
63
|
-
'ol',
|
|
64
|
-
'li',
|
|
65
|
-
'b',
|
|
66
|
-
'i',
|
|
67
|
-
'strong',
|
|
68
|
-
'em',
|
|
69
|
-
'code',
|
|
70
|
-
'pre',
|
|
71
|
-
'a',
|
|
72
|
-
'span',
|
|
73
|
-
'div',
|
|
74
|
-
'table',
|
|
75
|
-
'thead',
|
|
76
|
-
'tbody',
|
|
77
|
-
'tr',
|
|
78
|
-
'th',
|
|
79
|
-
'td',
|
|
80
|
-
],
|
|
81
|
-
ALLOWED_ATTR: ['href', 'target', 'rel', 'class', 'id', 'style'],
|
|
82
|
-
FORBID_TAGS: [
|
|
83
|
-
'script',
|
|
84
|
-
'iframe',
|
|
85
|
-
'object',
|
|
86
|
-
'embed',
|
|
87
|
-
'form',
|
|
88
|
-
'input',
|
|
89
|
-
'button',
|
|
90
|
-
'style',
|
|
91
|
-
'link',
|
|
92
|
-
'meta',
|
|
93
|
-
'base',
|
|
94
|
-
'applet',
|
|
95
|
-
'math',
|
|
96
|
-
'svg',
|
|
97
|
-
],
|
|
98
|
-
FORBID_ATTR: [
|
|
99
|
-
'onerror',
|
|
100
|
-
'onload',
|
|
101
|
-
'onclick',
|
|
102
|
-
'onmouseover',
|
|
103
|
-
'onmouseout',
|
|
104
|
-
'onmousedown',
|
|
105
|
-
'onmouseup',
|
|
106
|
-
'onkeydown',
|
|
107
|
-
'onkeyup',
|
|
108
|
-
'onkeypress',
|
|
109
|
-
'onfocus',
|
|
110
|
-
'onblur',
|
|
111
|
-
'onchange',
|
|
112
|
-
'onsubmit',
|
|
113
|
-
'onreset',
|
|
114
|
-
'javascript:',
|
|
115
|
-
'data:',
|
|
116
|
-
'vbscript:',
|
|
117
|
-
],
|
|
118
|
-
});
|
|
119
|
-
return sanitized;
|
|
120
|
-
}
|
|
121
|
-
catch (error) {
|
|
122
|
-
logger_1.default.error('Error sanitizing HTML content:', error);
|
|
123
|
-
// Return a safe fallback if sanitization fails
|
|
124
|
-
return '';
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Sanitize Markdown content
|
|
129
|
-
* @param content Markdown content to sanitize
|
|
130
|
-
* @returns Sanitized Markdown content
|
|
131
|
-
*/
|
|
132
|
-
function sanitizeMarkdown(content) {
|
|
133
|
-
try {
|
|
134
|
-
// Remove potentially harmful content
|
|
135
|
-
const sanitized = content
|
|
136
|
-
// Remove HTML comments
|
|
137
|
-
.replace(/<!--[\s\S]*?-->/g, '')
|
|
138
|
-
// Remove script tags and their content
|
|
139
|
-
.replace(/<script[\s\S]*?<\/script>/gi, '')
|
|
140
|
-
// Remove iframe tags and their content
|
|
141
|
-
.replace(/<iframe[\s\S]*?<\/iframe>/gi, '')
|
|
142
|
-
// Remove style tags and their content
|
|
143
|
-
.replace(/<style[\s\S]*?<\/style>/gi, '')
|
|
144
|
-
// Remove event handlers
|
|
145
|
-
.replace(/\son\w+\s*=\s*["']?[^"']*["']?/gi, '')
|
|
146
|
-
// Remove javascript: URLs
|
|
147
|
-
.replace(/javascript\s*:/gi, 'removed:')
|
|
148
|
-
// Remove data: URLs
|
|
149
|
-
.replace(/data\s*:/gi, 'removed:')
|
|
150
|
-
// Remove vbscript: URLs
|
|
151
|
-
.replace(/vbscript\s*:/gi, 'removed:');
|
|
152
|
-
return sanitized;
|
|
153
|
-
}
|
|
154
|
-
catch (error) {
|
|
155
|
-
logger_1.default.error('Error sanitizing Markdown content:', error);
|
|
156
|
-
// Return a safe fallback if sanitization fails
|
|
157
|
-
return '';
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Sanitize JSON content
|
|
162
|
-
* @param content JSON content to sanitize
|
|
163
|
-
* @returns Sanitized JSON content
|
|
164
|
-
*/
|
|
165
|
-
function sanitizeJson(content) {
|
|
166
|
-
try {
|
|
167
|
-
// Parse and stringify to ensure valid JSON
|
|
168
|
-
const parsed = JSON.parse(content);
|
|
169
|
-
return JSON.stringify(parsed);
|
|
170
|
-
}
|
|
171
|
-
catch (error) {
|
|
172
|
-
logger_1.default.error('Error sanitizing JSON content:', error);
|
|
173
|
-
// Return a safe fallback if sanitization fails
|
|
174
|
-
return '{}';
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Sanitizes content based on its type to prevent security vulnerabilities.
|
|
179
|
-
*
|
|
180
|
-
* This function acts as a dispatcher that routes the content to the appropriate
|
|
181
|
-
* specialized sanitization function based on the content type. It supports
|
|
182
|
-
* HTML, Markdown, JSON, and plain text formats, each with type-specific
|
|
183
|
-
* sanitization rules.
|
|
184
|
-
*
|
|
185
|
-
* @param {string} content - The content to sanitize
|
|
186
|
-
* @param {('html'|'markdown'|'json'|'text')} [contentType='text'] - The type of content
|
|
187
|
-
* @returns {string} Sanitized content safe for rendering or storage
|
|
188
|
-
*
|
|
189
|
-
* @example
|
|
190
|
-
* // Sanitize HTML content
|
|
191
|
-
* const safeHtml = sanitizeContent('<script>alert("XSS")</script><p>Hello</p>', 'html');
|
|
192
|
-
* // Returns: "<p>Hello</p>"
|
|
193
|
-
*
|
|
194
|
-
* @example
|
|
195
|
-
* // Sanitize Markdown content
|
|
196
|
-
* const safeMarkdown = sanitizeContent('# Title\n<script>alert("XSS")</script>', 'markdown');
|
|
197
|
-
* // Returns: "# Title\n"
|
|
198
|
-
*
|
|
199
|
-
* @example
|
|
200
|
-
* // Sanitize JSON content
|
|
201
|
-
* const safeJson = sanitizeContent('{"key": "value"}', 'json');
|
|
202
|
-
* // Returns: '{"key":"value"}'
|
|
203
|
-
*/
|
|
204
|
-
function sanitizeContent(content, contentType = 'text') {
|
|
205
|
-
switch (contentType) {
|
|
206
|
-
case 'html':
|
|
207
|
-
return sanitizeHtml(content);
|
|
208
|
-
case 'markdown':
|
|
209
|
-
return sanitizeMarkdown(content);
|
|
210
|
-
case 'json':
|
|
211
|
-
return sanitizeJson(content);
|
|
212
|
-
default:
|
|
213
|
-
// For plain text, just remove control characters except for newlines and tabs
|
|
214
|
-
// eslint-disable-next-line no-control-regex
|
|
215
|
-
return content.replace(/[\x00-\x09\x0B-\x1F\x7F]/g, '');
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Sanitize a filename to ensure it's safe for use in file systems
|
|
220
|
-
*
|
|
221
|
-
* This function removes or replaces characters that are not safe for use in filenames
|
|
222
|
-
* across different operating systems. It handles null/undefined inputs and preserves
|
|
223
|
-
* spaces and non-ASCII characters that are generally safe for modern file systems.
|
|
224
|
-
*
|
|
225
|
-
* @param filename The filename to sanitize
|
|
226
|
-
* @returns A sanitized filename safe for use in file systems
|
|
227
|
-
*/
|
|
228
|
-
function sanitizeFilename(filename) {
|
|
229
|
-
// Handle null or undefined
|
|
230
|
-
if (filename === null || filename === undefined) {
|
|
231
|
-
return '';
|
|
232
|
-
}
|
|
233
|
-
// Replace invalid characters with underscores
|
|
234
|
-
// This regex matches characters that are generally unsafe in filenames across platforms:
|
|
235
|
-
// / \ : * ? " < > | and control characters
|
|
236
|
-
// eslint-disable-next-line no-control-regex
|
|
237
|
-
return filename.replace(/[/\\:*?"<>|\x00-\x1F\x7F]/g, '_');
|
|
238
|
-
}
|
|
239
|
-
//# sourceMappingURL=sanitizer.js.map
|