scai 0.1.178 → 1.0.0
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/README.md +162 -267
- package/dist/__tests__/CommitSuggesterCmd.test.js +112 -0
- package/dist/__tests__/CommitSuggesterCmd.test.js.map +1 -0
- package/dist/__tests__/EvalReportCmd.test.js +645 -0
- package/dist/__tests__/EvalReportCmd.test.js.map +1 -0
- package/dist/__tests__/ModelCmd.test.js +64 -0
- package/dist/__tests__/ModelCmd.test.js.map +1 -0
- package/dist/__tests__/agents/agentActions.test.js +345 -0
- package/dist/__tests__/agents/agentActions.test.js.map +1 -0
- package/dist/__tests__/agents/agentFeedback.test.js +118 -0
- package/dist/__tests__/agents/agentFeedback.test.js.map +1 -0
- package/dist/__tests__/agents/agentGeneralScope.test.js +74 -0
- package/dist/__tests__/agents/agentGeneralScope.test.js.map +1 -0
- package/dist/__tests__/agents/agentLoop.test.js +1723 -0
- package/dist/__tests__/agents/agentLoop.test.js.map +1 -0
- package/dist/__tests__/agents/agentPolicyState.test.js +948 -0
- package/dist/__tests__/agents/agentPolicyState.test.js.map +1 -0
- package/dist/__tests__/agents/agentReadEvidence.test.js +170 -0
- package/dist/__tests__/agents/agentReadEvidence.test.js.map +1 -0
- package/dist/__tests__/agents/agentReadPersistence.test.js +129 -0
- package/dist/__tests__/agents/agentReadPersistence.test.js.map +1 -0
- package/dist/__tests__/agents/agentResumeCheckpoint.test.js +90 -0
- package/dist/__tests__/agents/agentResumeCheckpoint.test.js.map +1 -0
- package/dist/__tests__/agents/agentSearchBatchPlanner.test.js +289 -0
- package/dist/__tests__/agents/agentSearchBatchPlanner.test.js.map +1 -0
- package/dist/__tests__/agents/agentSearchOwnership.test.js +166 -0
- package/dist/__tests__/agents/agentSearchOwnership.test.js.map +1 -0
- package/dist/__tests__/agents/agentSearchRanking.test.js +139 -0
- package/dist/__tests__/agents/agentSearchRanking.test.js.map +1 -0
- package/dist/__tests__/agents/agentSearchRouting.test.js +584 -0
- package/dist/__tests__/agents/agentSearchRouting.test.js.map +1 -0
- package/dist/__tests__/agents/agentSearchScoring.test.js +23 -0
- package/dist/__tests__/agents/agentSearchScoring.test.js.map +1 -0
- package/dist/__tests__/agents/agentSearchShared.test.js +78 -0
- package/dist/__tests__/agents/agentSearchShared.test.js.map +1 -0
- package/dist/__tests__/agents/agentStateMachine.test.js +58 -0
- package/dist/__tests__/agents/agentStateMachine.test.js.map +1 -0
- package/dist/__tests__/agents/agentTaskPersistence.test.js +156 -0
- package/dist/__tests__/agents/agentTaskPersistence.test.js.map +1 -0
- package/dist/__tests__/agents/agentTools.test.js +69 -0
- package/dist/__tests__/agents/agentTools.test.js.map +1 -0
- package/dist/__tests__/agents/agentTransform.test.js +779 -0
- package/dist/__tests__/agents/agentTransform.test.js.map +1 -0
- package/dist/__tests__/agents/analysisPlanGenStep.test.js +157 -0
- package/dist/__tests__/agents/analysisPlanGenStep.test.js.map +1 -0
- package/dist/__tests__/agents/answerOnlyCompletion.test.js +75 -0
- package/dist/__tests__/agents/answerOnlyCompletion.test.js.map +1 -0
- package/dist/__tests__/agents/decideNextAction.test.js +1662 -0
- package/dist/__tests__/agents/decideNextAction.test.js.map +1 -0
- package/dist/__tests__/agents/deriveFocusFromSearchStep.test.js +258 -0
- package/dist/__tests__/agents/deriveFocusFromSearchStep.test.js.map +1 -0
- package/dist/__tests__/agents/evidenceVerifierStep.test.js +113 -0
- package/dist/__tests__/agents/evidenceVerifierStep.test.js.map +1 -0
- package/dist/__tests__/agents/executionPolicyResolver.test.js +208 -0
- package/dist/__tests__/agents/executionPolicyResolver.test.js.map +1 -0
- package/dist/__tests__/agents/fileCheckStep.test.js +299 -0
- package/dist/__tests__/agents/fileCheckStep.test.js.map +1 -0
- package/dist/__tests__/agents/giveUpEvaluatorStep.test.js +35 -0
- package/dist/__tests__/agents/giveUpEvaluatorStep.test.js.map +1 -0
- package/dist/__tests__/agents/guardState.test.js +297 -0
- package/dist/__tests__/agents/guardState.test.js.map +1 -0
- package/dist/__tests__/agents/mainAgentHeuristics.test.js +72 -0
- package/dist/__tests__/agents/mainAgentHeuristics.test.js.map +1 -0
- package/dist/__tests__/agents/objectiveEvaluatorStep.test.js +60 -0
- package/dist/__tests__/agents/objectiveEvaluatorStep.test.js.map +1 -0
- package/dist/__tests__/agents/outerLoopRecoveryEvaluator.test.js +207 -0
- package/dist/__tests__/agents/outerLoopRecoveryEvaluator.test.js.map +1 -0
- package/dist/__tests__/agents/prompting.test.js +363 -0
- package/dist/__tests__/agents/prompting.test.js.map +1 -0
- package/dist/__tests__/agents/readinessGateStep.test.js +180 -0
- package/dist/__tests__/agents/readinessGateStep.test.js.map +1 -0
- package/dist/__tests__/agents/reasonNextStep.test.js +56 -0
- package/dist/__tests__/agents/reasonNextStep.test.js.map +1 -0
- package/dist/__tests__/agents/reasonNextTaskStep.test.js +284 -0
- package/dist/__tests__/agents/reasonNextTaskStep.test.js.map +1 -0
- package/dist/__tests__/agents/resolveAgentTargetClassification.test.js +170 -0
- package/dist/__tests__/agents/resolveAgentTargetClassification.test.js.map +1 -0
- package/dist/__tests__/agents/resolveProgressState.test.js +526 -0
- package/dist/__tests__/agents/resolveProgressState.test.js.map +1 -0
- package/dist/__tests__/agents/resumeCheckpoint.test.js +50 -0
- package/dist/__tests__/agents/resumeCheckpoint.test.js.map +1 -0
- package/dist/__tests__/agents/routingDecisionStep.test.js +134 -0
- package/dist/__tests__/agents/routingDecisionStep.test.js.map +1 -0
- package/dist/__tests__/agents/scopeClassificationStep.test.js +118 -0
- package/dist/__tests__/agents/scopeClassificationStep.test.js.map +1 -0
- package/dist/__tests__/agents/searchContext.test.js +97 -0
- package/dist/__tests__/agents/searchContext.test.js.map +1 -0
- package/dist/__tests__/agents/selectRelevantSourcesStep.test.js +73 -0
- package/dist/__tests__/agents/selectRelevantSourcesStep.test.js.map +1 -0
- package/dist/__tests__/agents/structuredOutput.test.js +45 -0
- package/dist/__tests__/agents/structuredOutput.test.js.map +1 -0
- package/dist/__tests__/agents/transformPlanGenStep.fallback.test.js +59 -0
- package/dist/__tests__/agents/transformPlanGenStep.fallback.test.js.map +1 -0
- package/dist/__tests__/agents/transformPlanGenStep.test.js +92 -0
- package/dist/__tests__/agents/transformPlanGenStep.test.js.map +1 -0
- package/dist/__tests__/agents/understandIntentStep.test.js +237 -0
- package/dist/__tests__/agents/understandIntentStep.test.js.map +1 -0
- package/dist/__tests__/agents/understandResumeContext.test.js +65 -0
- package/dist/__tests__/agents/understandResumeContext.test.js.map +1 -0
- package/dist/__tests__/agents/understandScope.test.js +227 -0
- package/dist/__tests__/agents/understandScope.test.js.map +1 -0
- package/dist/__tests__/agents/validateChangesStep.test.js +52 -0
- package/dist/__tests__/agents/validateChangesStep.test.js.map +1 -0
- package/dist/__tests__/askCommandTaskBinding.test.js +176 -0
- package/dist/__tests__/askCommandTaskBinding.test.js.map +1 -0
- package/dist/__tests__/commandVisibility.test.js +25 -0
- package/dist/__tests__/commandVisibility.test.js.map +1 -0
- package/dist/__tests__/config.devOutput.test.js +82 -0
- package/dist/__tests__/config.devOutput.test.js.map +1 -0
- package/dist/__tests__/currentContext.test.js +43 -0
- package/dist/__tests__/currentContext.test.js.map +1 -0
- package/dist/__tests__/daemonWorker.test.js +51 -0
- package/dist/__tests__/daemonWorker.test.js.map +1 -0
- package/dist/__tests__/dialogState.test.js +113 -0
- package/dist/__tests__/dialogState.test.js.map +1 -0
- package/dist/__tests__/evalCommands.test.js +506 -0
- package/dist/__tests__/evalCommands.test.js.map +1 -0
- package/dist/__tests__/evalCommandsSummary.test.js +68 -0
- package/dist/__tests__/evalCommandsSummary.test.js.map +1 -0
- package/dist/__tests__/example.test.js +1 -0
- package/dist/__tests__/example.test.js.map +1 -0
- package/dist/__tests__/factory.commitCommand.test.js +45 -0
- package/dist/__tests__/factory.commitCommand.test.js.map +1 -0
- package/dist/__tests__/factory.devOutputCommand.test.js +122 -0
- package/dist/__tests__/factory.devOutputCommand.test.js.map +1 -0
- package/dist/__tests__/factory.evalCommands.test.js +38 -0
- package/dist/__tests__/factory.evalCommands.test.js.map +1 -0
- package/dist/__tests__/factory.planCommand.test.js +35 -0
- package/dist/__tests__/factory.planCommand.test.js.map +1 -0
- package/dist/__tests__/factory.setupCommand.test.js +34 -0
- package/dist/__tests__/factory.setupCommand.test.js.map +1 -0
- package/dist/__tests__/factory.statusCommand.test.js +54 -0
- package/dist/__tests__/factory.statusCommand.test.js.map +1 -0
- package/dist/__tests__/fileRules/queryTokenRules.test.js +35 -0
- package/dist/__tests__/fileRules/queryTokenRules.test.js.map +1 -0
- package/dist/__tests__/fileRules/searchPathClassification.test.js +57 -0
- package/dist/__tests__/fileRules/searchPathClassification.test.js.map +1 -0
- package/dist/__tests__/generate.ollamaRecovery.test.js +344 -0
- package/dist/__tests__/generate.ollamaRecovery.test.js.map +1 -0
- package/dist/__tests__/index.modelStartup.test.js +24 -0
- package/dist/__tests__/index.modelStartup.test.js.map +1 -0
- package/dist/__tests__/indexCmd.test.js +85 -0
- package/dist/__tests__/indexCmd.test.js.map +1 -0
- package/dist/__tests__/indexSlashCommand.test.js +50 -0
- package/dist/__tests__/indexSlashCommand.test.js.map +1 -0
- package/dist/__tests__/ollamaService.test.js +103 -0
- package/dist/__tests__/ollamaService.test.js.map +1 -0
- package/dist/__tests__/pipeline/modules/codeTransformModule.small-file.test.js +68 -0
- package/dist/__tests__/pipeline/modules/codeTransformModule.small-file.test.js.map +1 -0
- package/dist/__tests__/pipeline/modules/commitSuggesterModule.test.js +68 -0
- package/dist/__tests__/pipeline/modules/commitSuggesterModule.test.js.map +1 -0
- package/dist/__tests__/pipeline/modules/fileSearchModule.test.js +284 -0
- package/dist/__tests__/pipeline/modules/fileSearchModule.test.js.map +1 -0
- package/dist/__tests__/pipeline/modules/finalAnswerModule.test.js +1139 -0
- package/dist/__tests__/pipeline/modules/finalAnswerModule.test.js.map +1 -0
- package/dist/__tests__/pipeline/modules/readFileModule.test.js +146 -0
- package/dist/__tests__/pipeline/modules/readFileModule.test.js.map +1 -0
- package/dist/__tests__/pipeline/modules/semanticAnalysisModule.test.js +192 -0
- package/dist/__tests__/pipeline/modules/semanticAnalysisModule.test.js.map +1 -0
- package/dist/__tests__/repoIdentity.test.js +31 -0
- package/dist/__tests__/repoIdentity.test.js.map +1 -0
- package/dist/__tests__/resumeContext.test.js +87 -0
- package/dist/__tests__/resumeContext.test.js.map +1 -0
- package/dist/__tests__/resumeState.test.js +239 -0
- package/dist/__tests__/resumeState.test.js.map +1 -0
- package/dist/__tests__/search/SearchOrchestrator.test.js +836 -0
- package/dist/__tests__/search/SearchOrchestrator.test.js.map +1 -0
- package/dist/__tests__/shellDialogUi.test.js +52 -0
- package/dist/__tests__/shellDialogUi.test.js.map +1 -0
- package/dist/__tests__/shellSession.test.js +102 -0
- package/dist/__tests__/shellSession.test.js.map +1 -0
- package/dist/__tests__/statusOwner.test.js +215 -0
- package/dist/__tests__/statusOwner.test.js.map +1 -0
- package/dist/__tests__/testing/contextEval.test.js +244 -0
- package/dist/__tests__/testing/contextEval.test.js.map +1 -0
- package/dist/__tests__/testing/harnessArtifacts.test.js +124 -0
- package/dist/__tests__/testing/harnessArtifacts.test.js.map +1 -0
- package/dist/__tests__/testing/llmTraceSession.test.js +67 -0
- package/dist/__tests__/testing/llmTraceSession.test.js.map +1 -0
- package/dist/__tests__/testing/registerDevCliCommands.test.js +35 -0
- package/dist/__tests__/testing/registerDevCliCommands.test.js.map +1 -0
- package/dist/__tests__/testing/runDiagnosis.test.js +159 -0
- package/dist/__tests__/testing/runDiagnosis.test.js.map +1 -0
- package/dist/__tests__/testing/runtimeLogReader.test.js +66 -0
- package/dist/__tests__/testing/runtimeLogReader.test.js.map +1 -0
- package/dist/__tests__/testing/testCommands.test.js +53 -0
- package/dist/__tests__/testing/testCommands.test.js.map +1 -0
- package/dist/__tests__/utils/compileSearchQuery.test.js +38 -0
- package/dist/__tests__/utils/compileSearchQuery.test.js.map +1 -0
- package/dist/__tests__/utils/consolePresentation.test.js +105 -0
- package/dist/__tests__/utils/consolePresentation.test.js.map +1 -0
- package/dist/__tests__/utils/extractFileReferences.test.js +41 -0
- package/dist/__tests__/utils/extractFileReferences.test.js.map +1 -0
- package/dist/__tests__/utils/log.test.js +34 -0
- package/dist/__tests__/utils/log.test.js.map +1 -0
- package/dist/__tests__/utils/runtimeLogger.test.js +200 -0
- package/dist/__tests__/utils/runtimeLogger.test.js.map +1 -0
- package/dist/__tests__/utils/spinner.test.js +31 -0
- package/dist/__tests__/utils/spinner.test.js.map +1 -0
- package/dist/__tests__/utils/verifyFocusPreference.test.js +41 -0
- package/dist/__tests__/utils/verifyFocusPreference.test.js.map +1 -0
- package/dist/agent/actions/index.js +301 -0
- package/dist/agent/actions/index.js.map +1 -0
- package/dist/agent/actions/normalize.js +360 -0
- package/dist/agent/actions/normalize.js.map +1 -0
- package/dist/agent/actions/schemas.js +129 -0
- package/dist/agent/actions/schemas.js.map +1 -0
- package/dist/agent/evidence/index.js +320 -0
- package/dist/agent/evidence/index.js.map +1 -0
- package/dist/agent/feedback/index.js +187 -0
- package/dist/agent/feedback/index.js.map +1 -0
- package/dist/agent/finalization/index.js +35 -0
- package/dist/agent/finalization/index.js.map +1 -0
- package/dist/agent/index.js +126 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/logging/index.js +350 -0
- package/dist/agent/logging/index.js.map +1 -0
- package/dist/agent/persistence/boot.js +58 -0
- package/dist/agent/persistence/boot.js.map +1 -0
- package/dist/agent/persistence/currentTask.js +36 -0
- package/dist/agent/persistence/currentTask.js.map +1 -0
- package/dist/agent/persistence/hydrate.js +42 -0
- package/dist/agent/persistence/hydrate.js.map +1 -0
- package/dist/agent/persistence/index.js +15 -0
- package/dist/agent/persistence/index.js.map +1 -0
- package/dist/agent/persistence/snapshots.js +97 -0
- package/dist/agent/persistence/snapshots.js.map +1 -0
- package/dist/agent/persistence/steps.js +95 -0
- package/dist/agent/persistence/steps.js.map +1 -0
- package/dist/agent/persistence/tasks.js +195 -0
- package/dist/agent/persistence/tasks.js.map +1 -0
- package/dist/agent/persistence/turns.js +92 -0
- package/dist/agent/persistence/turns.js.map +1 -0
- package/dist/agent/policy/ambiguityResolution.js +226 -0
- package/dist/agent/policy/ambiguityResolution.js.map +1 -0
- package/dist/agent/policy/contracts.js +2 -0
- package/dist/agent/policy/contracts.js.map +1 -0
- package/dist/agent/policy/coveragePolicy.js +309 -0
- package/dist/agent/policy/coveragePolicy.js.map +1 -0
- package/dist/agent/policy/endDecisionPolicy.js +31 -0
- package/dist/agent/policy/endDecisionPolicy.js.map +1 -0
- package/dist/agent/policy/index.js +344 -0
- package/dist/agent/policy/index.js.map +1 -0
- package/dist/agent/policy/loopReview.js +778 -0
- package/dist/agent/policy/loopReview.js.map +1 -0
- package/dist/agent/policy/readinessPolicy.js +108 -0
- package/dist/agent/policy/readinessPolicy.js.map +1 -0
- package/dist/agent/policy/resolutionPipeline.js +356 -0
- package/dist/agent/policy/resolutionPipeline.js.map +1 -0
- package/dist/agent/policy/targetClassification.js +33 -0
- package/dist/agent/policy/targetClassification.js.map +1 -0
- package/dist/agent/prompting/actionChoice.js +90 -0
- package/dist/agent/prompting/actionChoice.js.map +1 -0
- package/dist/agent/prompting/finalAnswer.js +38 -0
- package/dist/agent/prompting/finalAnswer.js.map +1 -0
- package/dist/agent/prompting/index.js +14 -0
- package/dist/agent/prompting/index.js.map +1 -0
- package/dist/agent/prompting/plan.js +59 -0
- package/dist/agent/prompting/plan.js.map +1 -0
- package/dist/agent/prompting/transform.js +175 -0
- package/dist/agent/prompting/transform.js.map +1 -0
- package/dist/agent/prompting/understand.js +70 -0
- package/dist/agent/prompting/understand.js.map +1 -0
- package/dist/agent/read/freshness.js +29 -0
- package/dist/agent/read/freshness.js.map +1 -0
- package/dist/agent/read/fullReadPrompt.js +43 -0
- package/dist/agent/read/fullReadPrompt.js.map +1 -0
- package/dist/agent/read/index.js +140 -0
- package/dist/agent/read/index.js.map +1 -0
- package/dist/agent/read/persistence.js +88 -0
- package/dist/agent/read/persistence.js.map +1 -0
- package/dist/agent/read/summarizeReadEvidence.js +733 -0
- package/dist/agent/read/summarizeReadEvidence.js.map +1 -0
- package/dist/agent/read/targetResolution.js +126 -0
- package/dist/agent/read/targetResolution.js.map +1 -0
- package/dist/agent/resume/checkpoint.js +41 -0
- package/dist/agent/resume/checkpoint.js.map +1 -0
- package/dist/agent/runtime/lifecycle.js +67 -0
- package/dist/agent/runtime/lifecycle.js.map +1 -0
- package/dist/agent/runtime/progress.js +178 -0
- package/dist/agent/runtime/progress.js.map +1 -0
- package/dist/agent/runtime/runAgentLoop.js +402 -0
- package/dist/agent/runtime/runAgentLoop.js.map +1 -0
- package/dist/agent/runtime/runAgentPlanOnly.js +127 -0
- package/dist/agent/runtime/runAgentPlanOnly.js.map +1 -0
- package/dist/agent/runtime/understand.js +336 -0
- package/dist/agent/runtime/understand.js.map +1 -0
- package/dist/agent/search/batchPlanner.js +274 -0
- package/dist/agent/search/batchPlanner.js.map +1 -0
- package/dist/agent/search/candidateRetentionPolicy.js +184 -0
- package/dist/agent/search/candidateRetentionPolicy.js.map +1 -0
- package/dist/agent/search/directory.js +51 -0
- package/dist/agent/search/directory.js.map +1 -0
- package/dist/agent/search/exactTarget.js +151 -0
- package/dist/agent/search/exactTarget.js.map +1 -0
- package/dist/agent/search/fragment.js +110 -0
- package/dist/agent/search/fragment.js.map +1 -0
- package/dist/agent/search/index.js +166 -0
- package/dist/agent/search/index.js.map +1 -0
- package/dist/agent/search/laneClassifier.js +119 -0
- package/dist/agent/search/laneClassifier.js.map +1 -0
- package/dist/agent/search/limits.js +10 -0
- package/dist/agent/search/limits.js.map +1 -0
- package/dist/agent/search/ranking.js +22 -0
- package/dist/agent/search/ranking.js.map +1 -0
- package/dist/agent/search/regex.js +83 -0
- package/dist/agent/search/regex.js.map +1 -0
- package/dist/agent/search/routePolicy.js +11 -0
- package/dist/agent/search/routePolicy.js.map +1 -0
- package/dist/agent/search/searchContext.js +128 -0
- package/dist/agent/search/searchContext.js.map +1 -0
- package/dist/agent/search/semantic.js +113 -0
- package/dist/agent/search/semantic.js.map +1 -0
- package/dist/agent/search/semanticIndexSearch.js +202 -0
- package/dist/agent/search/semanticIndexSearch.js.map +1 -0
- package/dist/agent/search/shared.js +283 -0
- package/dist/agent/search/shared.js.map +1 -0
- package/dist/agent/search/shell.js +202 -0
- package/dist/agent/search/shell.js.map +1 -0
- package/dist/agent/search/snippetEvidence.js +57 -0
- package/dist/agent/search/snippetEvidence.js.map +1 -0
- package/dist/agent/search/types.js +2 -0
- package/dist/agent/search/types.js.map +1 -0
- package/dist/agent/state/index.js +99 -0
- package/dist/agent/state/index.js.map +1 -0
- package/dist/agent/state/memory.js +56 -0
- package/dist/agent/state/memory.js.map +1 -0
- package/dist/agent/structuredOutput/index.js +28 -0
- package/dist/agent/structuredOutput/index.js.map +1 -0
- package/dist/agent/tools/index.js +199 -0
- package/dist/agent/tools/index.js.map +1 -0
- package/dist/agent/transform/index.js +519 -0
- package/dist/agent/transform/index.js.map +1 -0
- package/dist/agent/transform/syntax.js +49 -0
- package/dist/agent/transform/syntax.js.map +1 -0
- package/dist/agent/types.js +20 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/agents/actionRegistry.js +114 -0
- package/dist/agents/actionRegistry.js.map +1 -0
- package/dist/agents/agent.js +5 -0
- package/dist/agents/agent.js.map +1 -0
- package/dist/agents/agentActions.js +5 -0
- package/dist/agents/agentActions.js.map +1 -0
- package/dist/agents/agentEvidence.js +5 -0
- package/dist/agents/agentEvidence.js.map +1 -0
- package/dist/agents/agentFeedback.js +5 -0
- package/dist/agents/agentFeedback.js.map +1 -0
- package/dist/agents/agentLogging.js +5 -0
- package/dist/agents/agentLogging.js.map +1 -0
- package/dist/agents/agentLoop.js +5 -0
- package/dist/agents/agentLoop.js.map +1 -0
- package/dist/agents/agentMemory.js +5 -0
- package/dist/agents/agentMemory.js.map +1 -0
- package/dist/agents/agentPlanMode.js +5 -0
- package/dist/agents/agentPlanMode.js.map +1 -0
- package/dist/agents/agentPolicyState.js +5 -0
- package/dist/agents/agentPolicyState.js.map +1 -0
- package/dist/agents/agentProgress.js +93 -0
- package/dist/agents/agentProgress.js.map +1 -0
- package/dist/agents/agentSchemas.js +5 -0
- package/dist/agents/agentSchemas.js.map +1 -0
- package/dist/agents/agentSearchScoring.js +5 -0
- package/dist/agents/agentSearchScoring.js.map +1 -0
- package/dist/agents/agentStateMachine.js +5 -0
- package/dist/agents/agentStateMachine.js.map +1 -0
- package/dist/agents/agentTools.js +5 -0
- package/dist/agents/agentTools.js.map +1 -0
- package/dist/agents/agentTypes.js +5 -0
- package/dist/agents/agentTypes.js.map +1 -0
- package/dist/agents/agentUnderstand.js +5 -0
- package/dist/agents/agentUnderstand.js.map +1 -0
- package/dist/agents/analysisPlanGenStep.js +194 -17
- package/dist/agents/analysisPlanGenStep.js.map +1 -0
- package/dist/agents/answerOnlyCompletion.js +32 -0
- package/dist/agents/answerOnlyCompletion.js.map +1 -0
- package/dist/agents/collaboratorStep.js +1 -0
- package/dist/agents/collaboratorStep.js.map +1 -0
- package/dist/agents/decideNextAction.js +444 -0
- package/dist/agents/decideNextAction.js.map +1 -0
- package/dist/agents/deriveFocusFromSearchStep.js +83 -0
- package/dist/agents/deriveFocusFromSearchStep.js.map +1 -0
- package/dist/agents/evidenceVerifierStep.js +104 -13
- package/dist/agents/evidenceVerifierStep.js.map +1 -0
- package/dist/agents/fileCheckStep.js +381 -12
- package/dist/agents/fileCheckStep.js.map +1 -0
- package/dist/agents/giveUpEvaluatorStep.js +63 -0
- package/dist/agents/giveUpEvaluatorStep.js.map +1 -0
- package/dist/agents/guardPolicy.js +20 -0
- package/dist/agents/guardPolicy.js.map +1 -0
- package/dist/agents/guards/executionPolicyResolver.js +165 -0
- package/dist/agents/guards/executionPolicyResolver.js.map +1 -0
- package/dist/agents/guards/guardState.js +195 -0
- package/dist/agents/guards/guardState.js.map +1 -0
- package/dist/agents/guards/resolveProgressState.js +403 -0
- package/dist/agents/guards/resolveProgressState.js.map +1 -0
- package/dist/agents/infoPlanGenStep.js +66 -8
- package/dist/agents/infoPlanGenStep.js.map +1 -0
- package/dist/agents/integrateFeedbackStep.js +1 -0
- package/dist/agents/integrateFeedbackStep.js.map +1 -0
- package/dist/agents/iterationFileSelector.js +8 -7
- package/dist/agents/iterationFileSelector.js.map +1 -0
- package/dist/agents/mainAgentActivityLog.js +85 -0
- package/dist/agents/mainAgentActivityLog.js.map +1 -0
- package/dist/agents/mainAgentHeuristics.js +173 -0
- package/dist/agents/mainAgentHeuristics.js.map +1 -0
- package/dist/agents/mainAgentVerify.js +159 -0
- package/dist/agents/mainAgentVerify.js.map +1 -0
- package/dist/agents/objectiveEvaluatorStep.js +103 -0
- package/dist/agents/objectiveEvaluatorStep.js.map +1 -0
- package/dist/agents/outerLoopRecoveryEvaluator.js +108 -0
- package/dist/agents/outerLoopRecoveryEvaluator.js.map +1 -0
- package/dist/agents/readinessGateStep.js +95 -9
- package/dist/agents/readinessGateStep.js.map +1 -0
- package/dist/agents/reasonNextStep.js +9 -8
- package/dist/agents/reasonNextStep.js.map +1 -0
- package/dist/agents/reasonNextTaskStep.js +267 -144
- package/dist/agents/reasonNextTaskStep.js.map +1 -0
- package/dist/agents/researchPlanGenStep.js +61 -25
- package/dist/agents/researchPlanGenStep.js.map +1 -0
- package/dist/agents/resolveAgentTargetClassification.js +5 -0
- package/dist/agents/resolveAgentTargetClassification.js.map +1 -0
- package/dist/agents/resolveExecutionModeStep.js +1 -0
- package/dist/agents/resolveExecutionModeStep.js.map +1 -0
- package/dist/agents/resolveExplicitTargetsStep.js +74 -0
- package/dist/agents/resolveExplicitTargetsStep.js.map +1 -0
- package/dist/agents/routingDecisionStep.js +58 -11
- package/dist/agents/routingDecisionStep.js.map +1 -0
- package/dist/agents/scopeClassificationStep.js +66 -3
- package/dist/agents/scopeClassificationStep.js.map +1 -0
- package/dist/agents/selectRelevantSourcesStep.js +13 -5
- package/dist/agents/selectRelevantSourcesStep.js.map +1 -0
- package/dist/agents/structuralPreloadStep.js +3 -4
- package/dist/agents/structuralPreloadStep.js.map +1 -0
- package/dist/agents/transformPlanGenStep.js +105 -18
- package/dist/agents/transformPlanGenStep.js.map +1 -0
- package/dist/agents/understandIntentStep.js +237 -17
- package/dist/agents/understandIntentStep.js.map +1 -0
- package/dist/agents/validateChangesStep.js +16 -2
- package/dist/agents/validateChangesStep.js.map +1 -0
- package/dist/agents/writeFileStep.js +1 -0
- package/dist/agents/writeFileStep.js.map +1 -0
- package/dist/commands/AskCmd.js +139 -44
- package/dist/commands/AskCmd.js.map +1 -0
- package/dist/commands/BackupCmd.js +1 -0
- package/dist/commands/BackupCmd.js.map +1 -0
- package/dist/commands/ChangeLogUpdateCmd.js +1 -0
- package/dist/commands/ChangeLogUpdateCmd.js.map +1 -0
- package/dist/commands/CommitSuggesterCmd.js +55 -13
- package/dist/commands/CommitSuggesterCmd.js.map +1 -0
- package/dist/commands/DaemonCmd.js +52 -14
- package/dist/commands/DaemonCmd.js.map +1 -0
- package/dist/commands/DeleteIndex.js +1 -0
- package/dist/commands/DeleteIndex.js.map +1 -0
- package/dist/commands/EvalReportCmd.js +374 -0
- package/dist/commands/EvalReportCmd.js.map +1 -0
- package/dist/commands/FindCmd.js +1 -0
- package/dist/commands/FindCmd.js.map +1 -0
- package/dist/commands/GitCmd.js +1 -0
- package/dist/commands/GitCmd.js.map +1 -0
- package/dist/commands/IndexCmd.js +11 -79
- package/dist/commands/IndexCmd.js.map +1 -0
- package/dist/commands/InspectCmd.js +1 -0
- package/dist/commands/InspectCmd.js.map +1 -0
- package/dist/commands/ModelCmd.js +24 -0
- package/dist/commands/ModelCmd.js.map +1 -0
- package/dist/commands/ReadlineSingleton.js +1 -0
- package/dist/commands/ReadlineSingleton.js.map +1 -0
- package/dist/commands/ResetDbCmd.js +18 -1
- package/dist/commands/ResetDbCmd.js.map +1 -0
- package/dist/commands/ReviewCmd.js +1 -0
- package/dist/commands/ReviewCmd.js.map +1 -0
- package/dist/commands/StatusCmd.js +22 -0
- package/dist/commands/StatusCmd.js.map +1 -0
- package/dist/commands/StopDaemonCmd.js +1 -0
- package/dist/commands/StopDaemonCmd.js.map +1 -0
- package/dist/commands/SummaryCmd.js +1 -0
- package/dist/commands/SummaryCmd.js.map +1 -0
- package/dist/commands/SwitchCmd.js +9 -15
- package/dist/commands/SwitchCmd.js.map +1 -0
- package/dist/commands/TasksCmd.js +142 -57
- package/dist/commands/TasksCmd.js.map +1 -0
- package/dist/commands/TestCmd.js +66 -0
- package/dist/commands/TestCmd.js.map +1 -0
- package/dist/commands/WorkflowCmd.js +1 -0
- package/dist/commands/WorkflowCmd.js.map +1 -0
- package/dist/commands/commandVisibility.js +27 -0
- package/dist/commands/commandVisibility.js.map +1 -0
- package/dist/commands/evalCommands.js +1337 -0
- package/dist/commands/evalCommands.js.map +1 -0
- package/dist/commands/factory.js +206 -38
- package/dist/commands/factory.js.map +1 -0
- package/dist/config.js +62 -11
- package/dist/config.js.map +1 -0
- package/dist/constants.js +21 -3
- package/dist/constants.js.map +1 -0
- package/dist/context.js +33 -32
- package/dist/context.js.map +1 -0
- package/dist/daemon/daemonQueues.js +1 -20
- package/dist/daemon/daemonQueues.js.map +1 -0
- package/dist/daemon/daemonWorker.js +26 -37
- package/dist/daemon/daemonWorker.js.map +1 -0
- package/dist/daemon/generateSummaries.js +1 -0
- package/dist/daemon/generateSummaries.js.map +1 -0
- package/dist/daemon/runFolderCapsuleBatch.js +1 -0
- package/dist/daemon/runFolderCapsuleBatch.js.map +1 -0
- package/dist/daemon/runIndexingBatch.js +1 -0
- package/dist/daemon/runIndexingBatch.js.map +1 -0
- package/dist/daemon/runKgBatch.js +9 -1
- package/dist/daemon/runKgBatch.js.map +1 -0
- package/dist/db/backup.js +1 -0
- package/dist/db/backup.js.map +1 -0
- package/dist/db/client.js +18 -3
- package/dist/db/client.js.map +1 -0
- package/dist/db/fileIndex.js +110 -152
- package/dist/db/fileIndex.js.map +1 -0
- package/dist/db/functionExtractors/extractFromJava.js +1 -0
- package/dist/db/functionExtractors/extractFromJava.js.map +1 -0
- package/dist/db/functionExtractors/extractFromJs.js +1 -0
- package/dist/db/functionExtractors/extractFromJs.js.map +1 -0
- package/dist/db/functionExtractors/extractFromTs.js +1 -0
- package/dist/db/functionExtractors/extractFromTs.js.map +1 -0
- package/dist/db/functionExtractors/extractFromXML.js +1 -0
- package/dist/db/functionExtractors/extractFromXML.js.map +1 -0
- package/dist/db/functionExtractors/index.js +1 -0
- package/dist/db/functionExtractors/index.js.map +1 -0
- package/dist/db/functionIndex.js +9 -0
- package/dist/db/functionIndex.js.map +1 -0
- package/dist/db/schema.js +314 -99
- package/dist/db/schema.js.map +1 -0
- package/dist/db/sqlTemplates.js +1 -0
- package/dist/db/sqlTemplates.js.map +1 -0
- package/dist/fileRules/builtins.js +1 -0
- package/dist/fileRules/builtins.js.map +1 -0
- package/dist/fileRules/classifyFile.js +1 -0
- package/dist/fileRules/classifyFile.js.map +1 -0
- package/dist/fileRules/codeAllowedExtensions.js +1 -0
- package/dist/fileRules/codeAllowedExtensions.js.map +1 -0
- package/dist/fileRules/detectFileType.js +1 -0
- package/dist/fileRules/detectFileType.js.map +1 -0
- package/dist/fileRules/fileClassifier.js +1 -0
- package/dist/fileRules/fileClassifier.js.map +1 -0
- package/dist/fileRules/fileExceptions.js +1 -0
- package/dist/fileRules/fileExceptions.js.map +1 -0
- package/dist/fileRules/ignoredExtensions.js +1 -0
- package/dist/fileRules/ignoredExtensions.js.map +1 -0
- package/dist/fileRules/ignoredPaths.js +48 -5
- package/dist/fileRules/ignoredPaths.js.map +1 -0
- package/dist/fileRules/queryTokenRules.js +176 -0
- package/dist/fileRules/queryTokenRules.js.map +1 -0
- package/dist/fileRules/searchPathClassification.js +58 -0
- package/dist/fileRules/searchPathClassification.js.map +1 -0
- package/dist/fileRules/shouldIgnoreFiles.js +1 -0
- package/dist/fileRules/shouldIgnoreFiles.js.map +1 -0
- package/dist/fileRules/stopWords.js +9 -0
- package/dist/fileRules/stopWords.js.map +1 -0
- package/dist/fileRules/wellKnownRepoFiles.js +1 -0
- package/dist/fileRules/wellKnownRepoFiles.js.map +1 -0
- package/dist/git/commitSummary.js +227 -0
- package/dist/git/commitSummary.js.map +1 -0
- package/dist/github/api.js +1 -0
- package/dist/github/api.js.map +1 -0
- package/dist/github/auth.js +1 -0
- package/dist/github/auth.js.map +1 -0
- package/dist/github/github.js +1 -0
- package/dist/github/github.js.map +1 -0
- package/dist/github/githubAuthCheck.js +1 -0
- package/dist/github/githubAuthCheck.js.map +1 -0
- package/dist/github/postComments.js +1 -0
- package/dist/github/postComments.js.map +1 -0
- package/dist/github/repo.js +15 -24
- package/dist/github/repo.js.map +1 -0
- package/dist/github/token.js +1 -0
- package/dist/github/token.js.map +1 -0
- package/dist/github/types.js +1 -0
- package/dist/github/types.js.map +1 -0
- package/dist/index.js +318 -37
- package/dist/index.js.map +1 -0
- package/dist/lib/generate.js +264 -20
- package/dist/lib/generate.js.map +1 -0
- package/dist/lib/generateFolderCapsules.js +1 -0
- package/dist/lib/generateFolderCapsules.js.map +1 -0
- package/dist/lib/ollamaModelPolicy.js +59 -0
- package/dist/lib/ollamaModelPolicy.js.map +1 -0
- package/dist/lib/spinner.js +29 -9
- package/dist/lib/spinner.js.map +1 -0
- package/dist/modelSetup.js +25 -78
- package/dist/modelSetup.js.map +1 -0
- package/dist/pipeline/modules/changeLogModule.js +10 -1
- package/dist/pipeline/modules/changeLogModule.js.map +1 -0
- package/dist/pipeline/modules/cleanupModule.js +1 -0
- package/dist/pipeline/modules/cleanupModule.js.map +1 -0
- package/dist/pipeline/modules/codeTransformModule.js +10 -16
- package/dist/pipeline/modules/codeTransformModule.js.map +1 -0
- package/dist/pipeline/modules/commentModule.js +12 -0
- package/dist/pipeline/modules/commentModule.js.map +1 -0
- package/dist/pipeline/modules/commitSuggesterModule.js +82 -12
- package/dist/pipeline/modules/commitSuggesterModule.js.map +1 -0
- package/dist/pipeline/modules/contextReviewModule.js +12 -1
- package/dist/pipeline/modules/contextReviewModule.js.map +1 -0
- package/dist/pipeline/modules/dialogAnswerModule.js +58 -0
- package/dist/pipeline/modules/dialogAnswerModule.js.map +1 -0
- package/dist/pipeline/modules/fileSearchModule.js +5 -143
- package/dist/pipeline/modules/fileSearchModule.js.map +1 -0
- package/dist/pipeline/modules/finalAnswerModule.js +1176 -151
- package/dist/pipeline/modules/finalAnswerModule.js.map +1 -0
- package/dist/pipeline/modules/kgModule.js +18 -1
- package/dist/pipeline/modules/kgModule.js.map +1 -0
- package/dist/pipeline/modules/planAnswerModule.js +99 -0
- package/dist/pipeline/modules/planAnswerModule.js.map +1 -0
- package/dist/pipeline/modules/readFileModule.js +300 -0
- package/dist/pipeline/modules/readFileModule.js.map +1 -0
- package/dist/pipeline/modules/reviewModule.js +10 -1
- package/dist/pipeline/modules/reviewModule.js.map +1 -0
- package/dist/pipeline/modules/searchDbModule.js +159 -0
- package/dist/pipeline/modules/searchDbModule.js.map +1 -0
- package/dist/pipeline/modules/searchListDirectoryModule.js +62 -0
- package/dist/pipeline/modules/searchListDirectoryModule.js.map +1 -0
- package/dist/pipeline/modules/searchModuleShared.js +71 -0
- package/dist/pipeline/modules/searchModuleShared.js.map +1 -0
- package/dist/pipeline/modules/searchRegexModule.js +59 -0
- package/dist/pipeline/modules/searchRegexModule.js.map +1 -0
- package/dist/pipeline/modules/semanticAnalysisModule.js +185 -28
- package/dist/pipeline/modules/semanticAnalysisModule.js.map +1 -0
- package/dist/pipeline/modules/summaryModule.js +11 -1
- package/dist/pipeline/modules/summaryModule.js.map +1 -0
- package/dist/pipeline/registry/moduleRegistry.js +9 -0
- package/dist/pipeline/registry/moduleRegistry.js.map +1 -0
- package/dist/pipeline/runModulePipeline.js +1 -0
- package/dist/pipeline/runModulePipeline.js.map +1 -0
- package/dist/scripts/dbScriptSupport.js +172 -0
- package/dist/scripts/dbScriptSupport.js.map +1 -0
- package/dist/scripts/dbcheck.js +173 -267
- package/dist/scripts/dbcheck.js.map +1 -0
- package/dist/scripts/dboverview.js +161 -0
- package/dist/scripts/dboverview.js.map +1 -0
- package/dist/scripts/migrateDb.js +1 -0
- package/dist/scripts/migrateDb.js.map +1 -0
- package/dist/search/SearchOrchestrator.js +928 -0
- package/dist/search/SearchOrchestrator.js.map +1 -0
- package/dist/search/sharedRankingPolicy.js +283 -0
- package/dist/search/sharedRankingPolicy.js.map +1 -0
- package/dist/setup/reindexOwner.js +97 -0
- package/dist/setup/reindexOwner.js.map +1 -0
- package/dist/setup/setupOwner.js +100 -0
- package/dist/setup/setupOwner.js.map +1 -0
- package/dist/shell/dialogUi.js +81 -0
- package/dist/shell/dialogUi.js.map +1 -0
- package/dist/shellSession.js +126 -0
- package/dist/shellSession.js.map +1 -0
- package/dist/status/statusOwner.js +239 -0
- package/dist/status/statusOwner.js.map +1 -0
- package/dist/testing/contextEval.js +514 -0
- package/dist/testing/contextEval.js.map +1 -0
- package/dist/testing/fixtures/transform/small-file.input.js +5 -0
- package/dist/testing/fixtures/transform/small-file.input.js.map +1 -0
- package/dist/testing/harnessArtifacts.js +112 -0
- package/dist/testing/harnessArtifacts.js.map +1 -0
- package/dist/testing/llmTraceSession.js +67 -0
- package/dist/testing/llmTraceSession.js.map +1 -0
- package/dist/testing/registerDevCliCommands.js +43 -0
- package/dist/testing/registerDevCliCommands.js.map +1 -0
- package/dist/testing/runDiagnosis.js +248 -0
- package/dist/testing/runDiagnosis.js.map +1 -0
- package/dist/testing/runtimeLogReader.js +144 -0
- package/dist/testing/runtimeLogReader.js.map +1 -0
- package/dist/testing/testCommands.js +35 -303
- package/dist/testing/testCommands.js.map +1 -0
- package/dist/testing/testRegistry.js +233 -0
- package/dist/testing/testRegistry.js.map +1 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/buildContextualPrompt.js +26 -75
- package/dist/utils/buildContextualPrompt.js.map +1 -0
- package/dist/utils/changeLogPrompt.js +1 -0
- package/dist/utils/changeLogPrompt.js.map +1 -0
- package/dist/utils/checkModel.js +17 -92
- package/dist/utils/checkModel.js.map +1 -0
- package/dist/utils/commentMap.js +1 -0
- package/dist/utils/commentMap.js.map +1 -0
- package/dist/utils/compileSearchQuery.js +23 -9
- package/dist/utils/compileSearchQuery.js.map +1 -0
- package/dist/utils/consolePresentation.js +208 -0
- package/dist/utils/consolePresentation.js.map +1 -0
- package/dist/utils/contentUtils.js +17 -2
- package/dist/utils/contentUtils.js.map +1 -0
- package/dist/utils/debugContext.js +1 -0
- package/dist/utils/debugContext.js.map +1 -0
- package/dist/utils/dialogState.js +201 -0
- package/dist/utils/dialogState.js.map +1 -0
- package/dist/utils/editor.js +1 -0
- package/dist/utils/editor.js.map +1 -0
- package/dist/utils/executionEvidence.js +50 -0
- package/dist/utils/executionEvidence.js.map +1 -0
- package/dist/utils/extractFileReferences.js +140 -6
- package/dist/utils/extractFileReferences.js.map +1 -0
- package/dist/utils/fileEvidenceCache.js +50 -0
- package/dist/utils/fileEvidenceCache.js.map +1 -0
- package/dist/utils/fileTree.js +1 -0
- package/dist/utils/fileTree.js.map +1 -0
- package/dist/utils/loadRelevantFolderCapsules.js +35 -5
- package/dist/utils/loadRelevantFolderCapsules.js.map +1 -0
- package/dist/utils/log.js +10 -1
- package/dist/utils/log.js.map +1 -0
- package/dist/utils/normalizeData.js +1 -0
- package/dist/utils/normalizeData.js.map +1 -0
- package/dist/utils/ollamaModelStatus.js +28 -0
- package/dist/utils/ollamaModelStatus.js.map +1 -0
- package/dist/utils/ollamaService.js +294 -0
- package/dist/utils/ollamaService.js.map +1 -0
- package/dist/utils/outputFormatter.js +1 -0
- package/dist/utils/outputFormatter.js.map +1 -0
- package/dist/utils/parseTaggedContent.js +1 -0
- package/dist/utils/parseTaggedContent.js.map +1 -0
- package/dist/utils/planActions.js +27 -46
- package/dist/utils/planActions.js.map +1 -0
- package/dist/utils/promptBuilderHelper.js +1 -0
- package/dist/utils/promptBuilderHelper.js.map +1 -0
- package/dist/utils/promptLogHelper.js +29 -13
- package/dist/utils/promptLogHelper.js.map +1 -0
- package/dist/utils/queryAnchors.js +71 -0
- package/dist/utils/queryAnchors.js.map +1 -0
- package/dist/utils/repoIdentity.js +82 -0
- package/dist/utils/repoIdentity.js.map +1 -0
- package/dist/utils/repoKey.js +1 -0
- package/dist/utils/repoKey.js.map +1 -0
- package/dist/utils/resolveTargetsToFiles.js +1 -0
- package/dist/utils/resolveTargetsToFiles.js.map +1 -0
- package/dist/utils/resumeContext.js +219 -0
- package/dist/utils/resumeContext.js.map +1 -0
- package/dist/utils/resumeState.js +310 -0
- package/dist/utils/resumeState.js.map +1 -0
- package/dist/utils/rollingPlan.js +118 -0
- package/dist/utils/rollingPlan.js.map +1 -0
- package/dist/utils/runQueryWithDaemonControl.js +11 -3
- package/dist/utils/runQueryWithDaemonControl.js.map +1 -0
- package/dist/utils/runtimeLogger.js +252 -0
- package/dist/utils/runtimeLogger.js.map +1 -0
- package/dist/utils/sanitizeQuery.js +1 -0
- package/dist/utils/sanitizeQuery.js.map +1 -0
- package/dist/utils/sharedUtils.js +1 -0
- package/dist/utils/sharedUtils.js.map +1 -0
- package/dist/utils/sleep.js +1 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/splitCodeIntoChunk.js +1 -0
- package/dist/utils/splitCodeIntoChunk.js.map +1 -0
- package/dist/utils/time.js +66 -0
- package/dist/utils/time.js.map +1 -0
- package/dist/utils/verifyFocusPreference.js +107 -0
- package/dist/utils/verifyFocusPreference.js.map +1 -0
- package/dist/utils/vscode.js +1 -0
- package/dist/utils/vscode.js.map +1 -0
- package/dist/workflow/workflowResolver.js +1 -0
- package/dist/workflow/workflowResolver.js.map +1 -0
- package/dist/workflow/workflowRunner.js +1 -0
- package/dist/workflow/workflowRunner.js.map +1 -0
- package/package.json +3 -3
- package/dist/agents/MainAgent.js +0 -1886
- package/dist/agents/contextReviewStep.js +0 -101
- package/dist/agents/finalPlanGenStep.js +0 -107
- package/dist/agents/structuralAnalysisStep.js +0 -46
- package/dist/agents/validationAnalysisStep.js +0 -87
- package/dist/pipeline/modules/chunkManagerModule.js +0 -24
- package/dist/pipeline/modules/cleanGeneratedTestsModule.js +0 -33
- package/dist/pipeline/modules/fileReaderModule.js +0 -72
- package/dist/pipeline/modules/gatherInfoModule.js +0 -181
- package/dist/pipeline/modules/generateTestsModule.js +0 -68
- package/dist/pipeline/modules/preserveCodeModule.js +0 -195
- package/dist/pipeline/modules/refactorModule.js +0 -40
- package/dist/pipeline/modules/repairTestsModule.js +0 -48
- package/dist/pipeline/modules/runTestsModule.js +0 -37
|
@@ -0,0 +1,928 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs all repo search behind one discovery-only orchestrator.
|
|
3
|
+
*
|
|
4
|
+
* Why this file exists:
|
|
5
|
+
* - search used to be split across explicit target resolution, semantic bootstrap, and planner fallback
|
|
6
|
+
* - that mixed "what did we find" with downstream "what should we act on"
|
|
7
|
+
* - this file keeps search output in one packet so focus and execution can derive their own state later
|
|
8
|
+
*
|
|
9
|
+
* Boundary:
|
|
10
|
+
* - this file may resolve files, folders, symbols, snippets, and raw pattern hits
|
|
11
|
+
* - this file must not set `selectedFiles`, `candidateFiles`, or execution policy state
|
|
12
|
+
* - callers may keep temporary compatibility fields like `relatedFiles`, but only after search returns
|
|
13
|
+
*/
|
|
14
|
+
import fs from "fs";
|
|
15
|
+
import path from "path";
|
|
16
|
+
import { execFileSync } from "child_process";
|
|
17
|
+
import fg from "fast-glob";
|
|
18
|
+
import { getDbForRepo } from "../db/client.js";
|
|
19
|
+
import { plannerSearchFiles, resolveSymbolRows, resolveSymbolRowsByPattern, semanticSearchFiles, } from "../db/fileIndex.js";
|
|
20
|
+
import { IGNORED_EXTENSIONS } from "../fileRules/ignoredExtensions.js";
|
|
21
|
+
import { isPathIgnoredByFolderGlobs } from "../fileRules/ignoredPaths.js";
|
|
22
|
+
import { isExplicitRefCandidate, queryLooksLikeOperatorPattern, queryNeedsRegexMode, } from "../fileRules/queryTokenRules.js";
|
|
23
|
+
import { compileSearchQuery } from "../utils/compileSearchQuery.js";
|
|
24
|
+
import { extractFileReferences } from "../utils/extractFileReferences.js";
|
|
25
|
+
import { getContextExecutionPath, mapCanonicalPathToExecutionPath, } from "../utils/repoIdentity.js";
|
|
26
|
+
import { logInputOutput } from "../utils/promptLogHelper.js";
|
|
27
|
+
import { buildMethodSelectionRetrievalQuery, isMethodSelectionRetrievalQuery, scoreCandidateFiles, } from "./sharedRankingPolicy.js";
|
|
28
|
+
import { isVerifyFocusQueryText } from "../utils/verifyFocusPreference.js";
|
|
29
|
+
const DEFAULT_LIMIT = 8;
|
|
30
|
+
export class SearchOrchestrator {
|
|
31
|
+
async run(args) {
|
|
32
|
+
return this.runDbSearch(args);
|
|
33
|
+
}
|
|
34
|
+
async runDbSearch(args) {
|
|
35
|
+
const query = String(args.query ?? "").trim();
|
|
36
|
+
const mode = this.resolveMode(args);
|
|
37
|
+
const result = createEmptySearchResult(mode, [], "db");
|
|
38
|
+
if (!query) {
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
if (mode === "exact-target") {
|
|
42
|
+
const exact = await this.runExactTargetSearchWithSemanticFallback(args.context, query, args.plannerQuery, args.limit ?? DEFAULT_LIMIT);
|
|
43
|
+
logInputOutput("SearchOrchestrator", "output", exact);
|
|
44
|
+
return exact;
|
|
45
|
+
}
|
|
46
|
+
if (mode === "sentence-fragment") {
|
|
47
|
+
const fragment = await this.runSentenceFragmentSearch(args.context, query);
|
|
48
|
+
logInputOutput("SearchOrchestrator", "output", fragment);
|
|
49
|
+
return fragment;
|
|
50
|
+
}
|
|
51
|
+
if (mode === "operator-pattern") {
|
|
52
|
+
const pattern = await this.runOperatorPatternSearchWithSemanticFallback(args.context, query, args.plannerQuery, args.limit ?? DEFAULT_LIMIT);
|
|
53
|
+
logInputOutput("SearchOrchestrator", "output", pattern);
|
|
54
|
+
return pattern;
|
|
55
|
+
}
|
|
56
|
+
const semantic = await this.runSemanticRetrieval(args.context, query, args.plannerQuery, args.limit ?? DEFAULT_LIMIT);
|
|
57
|
+
logInputOutput("SearchOrchestrator", "output", semantic);
|
|
58
|
+
return semantic;
|
|
59
|
+
}
|
|
60
|
+
async runRegexSearch(args) {
|
|
61
|
+
const result = createEmptySearchResult("regex-execution", ["regex-searcher", "result-merger-and-ranker"], "regex");
|
|
62
|
+
result.regexSpec = args.spec;
|
|
63
|
+
const repoRoot = getContextExecutionPath(args.context);
|
|
64
|
+
if (!repoRoot || !fs.existsSync(repoRoot)) {
|
|
65
|
+
result.failure = {
|
|
66
|
+
status: "failed",
|
|
67
|
+
failureClass: "scope-missing",
|
|
68
|
+
message: "Repo root is missing for regex search.",
|
|
69
|
+
};
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
const flags = normalizeRegexFlags(args.spec.flags);
|
|
73
|
+
const regex = safeCreateRegex(args.spec.pattern, flags);
|
|
74
|
+
if (!regex) {
|
|
75
|
+
result.failure = {
|
|
76
|
+
status: "failed",
|
|
77
|
+
failureClass: "invalid-regex",
|
|
78
|
+
message: "Regex pattern could not be compiled.",
|
|
79
|
+
pattern: args.spec.pattern,
|
|
80
|
+
flags,
|
|
81
|
+
};
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
const scopedFiles = this.resolveRegexScopeFiles(args.context, args.spec.scope, repoRoot);
|
|
85
|
+
if (scopedFiles.length === 0) {
|
|
86
|
+
result.failure = {
|
|
87
|
+
status: "failed",
|
|
88
|
+
failureClass: "scope-missing",
|
|
89
|
+
message: "Regex search scope did not resolve to any searchable files.",
|
|
90
|
+
pattern: args.spec.pattern,
|
|
91
|
+
flags,
|
|
92
|
+
};
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
const pathMatches = args.spec.target === "content"
|
|
96
|
+
? []
|
|
97
|
+
: collectRegexPathMatches(scopedFiles, regex, repoRoot);
|
|
98
|
+
const contentMatches = args.spec.target === "path"
|
|
99
|
+
? []
|
|
100
|
+
: collectRegexContentMatches(scopedFiles, regex);
|
|
101
|
+
const fileCandidates = dedupeSearchResults([
|
|
102
|
+
...pathMatches.map(match => buildFsSearchResult(match.path)),
|
|
103
|
+
...contentMatches.map(match => buildFsSearchResult(match.path)),
|
|
104
|
+
]).slice(0, args.limit ?? DEFAULT_LIMIT);
|
|
105
|
+
result.patternMatches = contentMatches;
|
|
106
|
+
result.fileCandidates = fileCandidates;
|
|
107
|
+
result.resolvedFolders = dedupeStrings(args.spec.scope?.folders ?? []);
|
|
108
|
+
if (pathMatches.length === 0 && contentMatches.length === 0) {
|
|
109
|
+
result.failure = {
|
|
110
|
+
status: "failed",
|
|
111
|
+
failureClass: "no-match",
|
|
112
|
+
message: "Regex search found no matches in scope.",
|
|
113
|
+
pattern: args.spec.pattern,
|
|
114
|
+
flags,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
runDirectoryListing(args) {
|
|
120
|
+
const result = createEmptySearchResult("directory-listing", ["directory-listing"], "list-directory");
|
|
121
|
+
const repoRoot = getContextExecutionPath(args.context);
|
|
122
|
+
if (!repoRoot || !fs.existsSync(repoRoot)) {
|
|
123
|
+
result.failure = {
|
|
124
|
+
status: "failed",
|
|
125
|
+
failureClass: "scope-missing",
|
|
126
|
+
message: "Repo root is missing for directory listing.",
|
|
127
|
+
};
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
const folderPath = resolveDirectoryListingTarget(args.context, args.query, repoRoot);
|
|
131
|
+
if (!folderPath) {
|
|
132
|
+
result.failure = {
|
|
133
|
+
status: "failed",
|
|
134
|
+
failureClass: "scope-missing",
|
|
135
|
+
message: "Could not resolve a folder to list.",
|
|
136
|
+
};
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
result.resolvedFolders = [folderPath];
|
|
140
|
+
result.directoryEntries = collectDirectDirectoryEntries(folderPath);
|
|
141
|
+
result.folderCandidates = [folderPath];
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Keeps exact-target routing narrow, but avoids dead ends when nothing resolves at all.
|
|
146
|
+
* Example: "/resume" stays an explicit ref first, then falls back to semantic retrieval only if exact-target found nothing.
|
|
147
|
+
*/
|
|
148
|
+
async runExactTargetSearchWithSemanticFallback(context, query, plannerQuery, limit) {
|
|
149
|
+
const exact = this.runExactTargetSearch(context, query);
|
|
150
|
+
if (!shouldFallbackFromExactTarget(exact)) {
|
|
151
|
+
return exact;
|
|
152
|
+
}
|
|
153
|
+
const semantic = await this.runSemanticRetrieval(context, query, plannerQuery, limit);
|
|
154
|
+
exact.stagesRun.push("fallback-semantic-retriever");
|
|
155
|
+
exact.fallbackUsed = true;
|
|
156
|
+
exact.fileCandidates = semantic.fileCandidates;
|
|
157
|
+
exact.folderCandidates = semantic.folderCandidates;
|
|
158
|
+
exact.symbolCandidates = semantic.symbolCandidates;
|
|
159
|
+
exact.fragmentMatches = semantic.fragmentMatches;
|
|
160
|
+
exact.patternMatches = semantic.patternMatches;
|
|
161
|
+
exact.directoryEntries = semantic.directoryEntries;
|
|
162
|
+
exact.failure = semantic.failure;
|
|
163
|
+
return exact;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Keeps true operator queries narrow, but broadens once when the lane found nothing useful.
|
|
167
|
+
* Example: a regex-like snippet can fall back to semantic retrieval only after zero matches.
|
|
168
|
+
*/
|
|
169
|
+
async runOperatorPatternSearchWithSemanticFallback(context, query, plannerQuery, limit) {
|
|
170
|
+
const pattern = await this.runOperatorPatternSearch(context, query);
|
|
171
|
+
if (!shouldFallbackFromOperatorPattern(pattern)) {
|
|
172
|
+
return pattern;
|
|
173
|
+
}
|
|
174
|
+
const semantic = await this.runSemanticRetrieval(context, query, plannerQuery, limit);
|
|
175
|
+
pattern.stagesRun.push("fallback-semantic-retriever");
|
|
176
|
+
pattern.fallbackUsed = true;
|
|
177
|
+
pattern.fileCandidates = semantic.fileCandidates;
|
|
178
|
+
pattern.folderCandidates = semantic.folderCandidates;
|
|
179
|
+
pattern.symbolCandidates = semantic.symbolCandidates;
|
|
180
|
+
pattern.fragmentMatches = semantic.fragmentMatches;
|
|
181
|
+
pattern.directoryEntries = semantic.directoryEntries;
|
|
182
|
+
pattern.failure = semantic.failure;
|
|
183
|
+
return pattern;
|
|
184
|
+
}
|
|
185
|
+
resolveMode(args) {
|
|
186
|
+
if (args.mode && args.mode !== "auto") {
|
|
187
|
+
return args.mode;
|
|
188
|
+
}
|
|
189
|
+
const query = String(args.query ?? "").trim();
|
|
190
|
+
const intent = args.context.analysis?.intent;
|
|
191
|
+
const quotedFragments = extractQuotedFragments(query);
|
|
192
|
+
const explicitFileRefs = extractFileReferences(query);
|
|
193
|
+
// Keep pure quoted-code lookups on fragment search even when intent extraction found symbol-like tokens.
|
|
194
|
+
// Example: "const currentQuestionId = ..." should search for matching lines, not chase `currentQuestionId` as an explicit target.
|
|
195
|
+
if (quotedFragments.length > 0 && explicitFileRefs.length === 0) {
|
|
196
|
+
return "sentence-fragment";
|
|
197
|
+
}
|
|
198
|
+
if ((intent?.targetFiles?.length ?? 0) > 0 ||
|
|
199
|
+
(intent?.targetSymbols?.length ?? 0) > 0 ||
|
|
200
|
+
explicitFileRefs.length > 0) {
|
|
201
|
+
return "exact-target";
|
|
202
|
+
}
|
|
203
|
+
if (quotedFragments.length > 0) {
|
|
204
|
+
return "sentence-fragment";
|
|
205
|
+
}
|
|
206
|
+
if (queryLooksLikeOperatorPattern(query)) {
|
|
207
|
+
return "operator-pattern";
|
|
208
|
+
}
|
|
209
|
+
return "semantic-retrieval";
|
|
210
|
+
}
|
|
211
|
+
runExactTargetSearch(context, query) {
|
|
212
|
+
const stagesRun = ["explicit-target-resolver", "result-merger-and-ranker"];
|
|
213
|
+
const repoRoot = getContextExecutionPath(context);
|
|
214
|
+
const result = createEmptySearchResult("exact-target", stagesRun, "db");
|
|
215
|
+
if (!repoRoot || !fs.existsSync(repoRoot)) {
|
|
216
|
+
return result;
|
|
217
|
+
}
|
|
218
|
+
const allTargetRefs = dedupeStrings([
|
|
219
|
+
...(context.analysis?.intent?.targetFiles ?? []),
|
|
220
|
+
...extractFileReferences(query),
|
|
221
|
+
]);
|
|
222
|
+
const rawTargetRefs = allTargetRefs.filter(shouldTreatAsExplicitRef);
|
|
223
|
+
const symbolRefs = dedupeStrings(context.analysis?.intent?.targetSymbols ?? []);
|
|
224
|
+
const fileRows = [];
|
|
225
|
+
const resolvedFolders = [];
|
|
226
|
+
const unresolvedRefs = new Set(allTargetRefs.filter(ref => !shouldTreatAsExplicitRef(ref)));
|
|
227
|
+
const ambiguousRefs = new Set();
|
|
228
|
+
for (const rawRef of rawTargetRefs) {
|
|
229
|
+
const resolution = resolvePathReference(rawRef, repoRoot);
|
|
230
|
+
if (resolution.kind === "file" && resolution.path) {
|
|
231
|
+
fileRows.push(buildFsSearchResult(resolution.path));
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
if (resolution.kind === "folder" && resolution.path) {
|
|
235
|
+
resolvedFolders.push(resolution.path);
|
|
236
|
+
for (const childFile of collectSearchablePaths(resolution.path, {
|
|
237
|
+
includeIgnoredExtensions: true,
|
|
238
|
+
allowIgnoredPaths: true,
|
|
239
|
+
})) {
|
|
240
|
+
fileRows.push(buildFsSearchResult(childFile));
|
|
241
|
+
}
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (resolution.kind === "ambiguous") {
|
|
245
|
+
ambiguousRefs.add(rawRef);
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
unresolvedRefs.add(rawRef);
|
|
249
|
+
}
|
|
250
|
+
const db = getDbForRepo();
|
|
251
|
+
const resolvedSymbols = [];
|
|
252
|
+
const symbolCandidates = [];
|
|
253
|
+
for (const symbol of symbolRefs) {
|
|
254
|
+
const rows = resolveSymbolRowsWithFallback(db, symbol)
|
|
255
|
+
.map(row => this.remapSearchResult(row, context));
|
|
256
|
+
if (rows.length === 1) {
|
|
257
|
+
resolvedSymbols.push({ symbol, filePath: rows[0].path });
|
|
258
|
+
fileRows.push(rows[0]);
|
|
259
|
+
}
|
|
260
|
+
else if (rows.length > 1) {
|
|
261
|
+
ambiguousRefs.add(symbol);
|
|
262
|
+
for (const row of rows) {
|
|
263
|
+
symbolCandidates.push({ symbol, filePath: row.path });
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
unresolvedRefs.add(symbol);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
result.resolvedFiles = dedupeSearchResults(fileRows);
|
|
271
|
+
result.resolvedFolders = dedupeStrings(resolvedFolders);
|
|
272
|
+
result.resolvedSymbols = dedupeSymbolResolutions(resolvedSymbols);
|
|
273
|
+
result.unresolvedRefs = Array.from(unresolvedRefs);
|
|
274
|
+
result.ambiguousRefs = Array.from(ambiguousRefs);
|
|
275
|
+
result.fileCandidates = dedupeSearchResults([
|
|
276
|
+
...result.resolvedFiles,
|
|
277
|
+
...dedupeSearchResults(fileRows).filter(item => !result.resolvedFiles.some(resolved => resolved.path === item.path)),
|
|
278
|
+
]);
|
|
279
|
+
result.folderCandidates = result.resolvedFolders;
|
|
280
|
+
result.symbolCandidates = dedupeSymbolResolutions(symbolCandidates);
|
|
281
|
+
return result;
|
|
282
|
+
}
|
|
283
|
+
async runSemanticRetrieval(context, query, plannerQuery, limit) {
|
|
284
|
+
const result = createEmptySearchResult("semantic-retrieval", ["semantic-retriever"], "db");
|
|
285
|
+
const seen = new Map();
|
|
286
|
+
const addResults = (rows) => {
|
|
287
|
+
for (const row of rows.map(item => this.remapSearchResult(item, context))) {
|
|
288
|
+
if (!seen.has(row.path)) {
|
|
289
|
+
seen.set(row.path, row);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
if (plannerQuery?.trim()) {
|
|
294
|
+
addResults(await plannerSearchFiles(query, plannerQuery, limit));
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
addResults(await semanticSearchFiles(query, limit, context.analysis?.intent ?? {}));
|
|
298
|
+
const orderedQuestionQueries = collectOrderedQuestionQueries(context, query);
|
|
299
|
+
for (const orderedQuery of orderedQuestionQueries) {
|
|
300
|
+
addResults(await plannerSearchFiles(query, orderedQuery, Math.min(limit, 6)));
|
|
301
|
+
}
|
|
302
|
+
const methodSelectionQuery = buildMethodSelectionRetrievalQuery(query);
|
|
303
|
+
if (isMethodSelectionRetrievalQuery(query) && methodSelectionQuery) {
|
|
304
|
+
addResults(await plannerSearchFiles(query, methodSelectionQuery, 12));
|
|
305
|
+
const pathSupplement = collectMethodSelectionPathSupplement(context, query, new Set(seen.keys()));
|
|
306
|
+
addResults(pathSupplement);
|
|
307
|
+
}
|
|
308
|
+
const pathSupplementQueries = [
|
|
309
|
+
...(isVerifyFocusQueryText(query) ? [query] : []),
|
|
310
|
+
...orderedQuestionQueries,
|
|
311
|
+
];
|
|
312
|
+
const pathSupplement = collectScopedPathSupplements(context, pathSupplementQueries, new Set(seen.keys()));
|
|
313
|
+
addResults(pathSupplement);
|
|
314
|
+
}
|
|
315
|
+
if (seen.size === 0) {
|
|
316
|
+
const fallbackRows = await this.runFallbackContentScan(context, plannerQuery?.trim() || query, query);
|
|
317
|
+
if (fallbackRows.length > 0) {
|
|
318
|
+
result.stagesRun.push("fallback-content-scanner");
|
|
319
|
+
result.fallbackUsed = true;
|
|
320
|
+
addResults(fallbackRows);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
result.stagesRun.push("result-merger-and-ranker");
|
|
324
|
+
result.fileCandidates = rankMergedSearchResults(Array.from(seen.values()), query).slice(0, limit);
|
|
325
|
+
return result;
|
|
326
|
+
}
|
|
327
|
+
async runSentenceFragmentSearch(context, query) {
|
|
328
|
+
const result = createEmptySearchResult("sentence-fragment", [
|
|
329
|
+
"sentence-fragment-resolver",
|
|
330
|
+
"result-merger-and-ranker",
|
|
331
|
+
], "db");
|
|
332
|
+
const repoRoot = getContextExecutionPath(context);
|
|
333
|
+
if (!repoRoot || !fs.existsSync(repoRoot)) {
|
|
334
|
+
return result;
|
|
335
|
+
}
|
|
336
|
+
const fragments = extractQuotedFragments(query);
|
|
337
|
+
const matches = new Map();
|
|
338
|
+
const files = [];
|
|
339
|
+
for (const fragment of fragments) {
|
|
340
|
+
const fragmentMatches = await searchContentMatches({
|
|
341
|
+
repoRoot,
|
|
342
|
+
query: fragment,
|
|
343
|
+
fixed: true,
|
|
344
|
+
});
|
|
345
|
+
for (const match of fragmentMatches) {
|
|
346
|
+
const key = `${match.path}:${match.line}:${match.column}`;
|
|
347
|
+
if (!matches.has(key)) {
|
|
348
|
+
matches.set(key, match);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
for (const match of matches.values()) {
|
|
353
|
+
files.push(buildFsSearchResult(match.path));
|
|
354
|
+
}
|
|
355
|
+
result.fragmentMatches = Array.from(matches.values());
|
|
356
|
+
result.fileCandidates = dedupeSearchResults(files);
|
|
357
|
+
result.fallbackUsed = result.fragmentMatches.length > 0 && !isRipgrepAvailable();
|
|
358
|
+
return result;
|
|
359
|
+
}
|
|
360
|
+
async runOperatorPatternSearch(context, query) {
|
|
361
|
+
const result = createEmptySearchResult("operator-pattern", [
|
|
362
|
+
"operator-pattern-searcher",
|
|
363
|
+
"result-merger-and-ranker",
|
|
364
|
+
], "db");
|
|
365
|
+
const repoRoot = getContextExecutionPath(context);
|
|
366
|
+
if (!repoRoot || !fs.existsSync(repoRoot)) {
|
|
367
|
+
return result;
|
|
368
|
+
}
|
|
369
|
+
const compiled = compileSearchQuery({
|
|
370
|
+
query,
|
|
371
|
+
intent: context.analysis?.intent,
|
|
372
|
+
mode: queryNeedsRegexMode(query) ? "regex" : "auto",
|
|
373
|
+
});
|
|
374
|
+
const matches = await searchContentMatches({
|
|
375
|
+
repoRoot,
|
|
376
|
+
query: compiled.regex.enabled ? compiled.regex.terms[0] ?? query : query,
|
|
377
|
+
fixed: !compiled.regex.enabled && !query.includes("|"),
|
|
378
|
+
});
|
|
379
|
+
result.patternMatches = matches;
|
|
380
|
+
result.fileCandidates = dedupeSearchResults(matches.map(match => buildFsSearchResult(match.path)));
|
|
381
|
+
result.fallbackUsed = matches.length > 0 && !isRipgrepAvailable();
|
|
382
|
+
return result;
|
|
383
|
+
}
|
|
384
|
+
async runFallbackContentScan(context, query, rankingQuery) {
|
|
385
|
+
const repoRoot = getContextExecutionPath(context);
|
|
386
|
+
if (!repoRoot || !fs.existsSync(repoRoot))
|
|
387
|
+
return [];
|
|
388
|
+
const compiled = compileSearchQuery({ query, mode: "auto", intent: context.analysis?.intent });
|
|
389
|
+
const fallbackTerms = compiled.literal.terms.filter(term => term.length >= 2);
|
|
390
|
+
if (fallbackTerms.length === 0)
|
|
391
|
+
return [];
|
|
392
|
+
const scored = scoreCandidateFiles(collectSearchablePaths(repoRoot).filter(filePath => {
|
|
393
|
+
const content = safeReadFile(filePath);
|
|
394
|
+
if (!content)
|
|
395
|
+
return false;
|
|
396
|
+
return fallbackTerms.some(term => content.toLowerCase().includes(term.toLowerCase()));
|
|
397
|
+
}), {}, rankingQuery).slice(0, DEFAULT_LIMIT);
|
|
398
|
+
return scored.map(item => buildFsSearchResult(item.filePath));
|
|
399
|
+
}
|
|
400
|
+
remapSearchResult(result, context) {
|
|
401
|
+
return {
|
|
402
|
+
...result,
|
|
403
|
+
path: mapCanonicalPathToExecutionPath(result.path, context),
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
resolveRegexScopeFiles(context, scope, repoRoot) {
|
|
407
|
+
const scopedFiles = dedupeStrings([
|
|
408
|
+
...(scope?.files ?? []),
|
|
409
|
+
...(context.analysis?.focus?.resolvedTargetFiles ?? []),
|
|
410
|
+
]).filter(filePath => path.isAbsolute(filePath) && fs.existsSync(filePath));
|
|
411
|
+
if (scopedFiles.length > 0) {
|
|
412
|
+
return scopedFiles;
|
|
413
|
+
}
|
|
414
|
+
const scopedFolders = dedupeStrings([
|
|
415
|
+
...(scope?.folders ?? []),
|
|
416
|
+
...(context.analysis?.focus?.resolvedTargetFolders ?? []),
|
|
417
|
+
]).filter(folder => path.isAbsolute(folder) && fs.existsSync(folder));
|
|
418
|
+
if (scopedFolders.length > 0) {
|
|
419
|
+
return dedupeStrings(scopedFolders.flatMap(folder => collectSearchablePaths(folder)));
|
|
420
|
+
}
|
|
421
|
+
return collectSearchablePaths(repoRoot);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Resolves one target symbol with the same exact-then-pattern fallback the old path used.
|
|
426
|
+
* Example: `run search now` -> exact miss -> pattern rows from `runSearchNow`.
|
|
427
|
+
*/
|
|
428
|
+
function resolveSymbolRowsWithFallback(db, symbol) {
|
|
429
|
+
const exactRows = resolveSymbolRows(db, [symbol]);
|
|
430
|
+
if (exactRows.length > 0) {
|
|
431
|
+
return exactRows;
|
|
432
|
+
}
|
|
433
|
+
return resolveSymbolRowsByPattern(db, [symbol]);
|
|
434
|
+
}
|
|
435
|
+
function createEmptySearchResult(mode, stagesRun = [], route = "db") {
|
|
436
|
+
return {
|
|
437
|
+
route,
|
|
438
|
+
mode,
|
|
439
|
+
stagesRun,
|
|
440
|
+
resolvedFiles: [],
|
|
441
|
+
resolvedFolders: [],
|
|
442
|
+
resolvedSymbols: [],
|
|
443
|
+
unresolvedRefs: [],
|
|
444
|
+
ambiguousRefs: [],
|
|
445
|
+
fileCandidates: [],
|
|
446
|
+
folderCandidates: [],
|
|
447
|
+
symbolCandidates: [],
|
|
448
|
+
fragmentMatches: [],
|
|
449
|
+
patternMatches: [],
|
|
450
|
+
directoryEntries: [],
|
|
451
|
+
fallbackUsed: false,
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
function shouldFallbackFromExactTarget(result) {
|
|
455
|
+
return result.resolvedFiles.length === 0 &&
|
|
456
|
+
result.resolvedFolders.length === 0 &&
|
|
457
|
+
result.resolvedSymbols.length === 0 &&
|
|
458
|
+
result.fileCandidates.length === 0 &&
|
|
459
|
+
result.folderCandidates.length === 0 &&
|
|
460
|
+
result.symbolCandidates.length === 0 &&
|
|
461
|
+
result.ambiguousRefs.length === 0;
|
|
462
|
+
}
|
|
463
|
+
function shouldFallbackFromOperatorPattern(result) {
|
|
464
|
+
return result.fileCandidates.length === 0 && result.patternMatches.length === 0;
|
|
465
|
+
}
|
|
466
|
+
function shouldTreatAsExplicitRef(rawRef) {
|
|
467
|
+
return isExplicitRefCandidate(String(rawRef ?? "").trim());
|
|
468
|
+
}
|
|
469
|
+
function resolvePathReference(rawRef, repoRoot) {
|
|
470
|
+
const ref = String(rawRef ?? "").trim().replace(/\\/g, "/");
|
|
471
|
+
if (!ref)
|
|
472
|
+
return { kind: "unresolved", ref: rawRef };
|
|
473
|
+
const directCandidates = [
|
|
474
|
+
ref,
|
|
475
|
+
path.join(repoRoot, ref),
|
|
476
|
+
].map(candidate => path.isAbsolute(candidate) ? candidate : path.join(repoRoot, candidate));
|
|
477
|
+
for (const candidate of directCandidates) {
|
|
478
|
+
if (!fs.existsSync(candidate))
|
|
479
|
+
continue;
|
|
480
|
+
const normalized = path.normalize(candidate);
|
|
481
|
+
const stat = fs.statSync(normalized);
|
|
482
|
+
if (stat.isFile())
|
|
483
|
+
return { kind: "file", ref: rawRef, path: normalized };
|
|
484
|
+
if (stat.isDirectory())
|
|
485
|
+
return { kind: "folder", ref: rawRef, path: normalized };
|
|
486
|
+
}
|
|
487
|
+
if (ref.includes("/")) {
|
|
488
|
+
const fileMatches = fg.sync(`**/${ref}`, {
|
|
489
|
+
cwd: repoRoot,
|
|
490
|
+
absolute: true,
|
|
491
|
+
onlyFiles: true,
|
|
492
|
+
dot: false,
|
|
493
|
+
ignore: ["**/node_modules/**", "**/dist/**", "**/.git/**", "**/.scai-worktrees/**"],
|
|
494
|
+
}).map(path.normalize);
|
|
495
|
+
if (fileMatches.length === 1)
|
|
496
|
+
return { kind: "file", ref: rawRef, path: fileMatches[0] };
|
|
497
|
+
if (fileMatches.length > 1)
|
|
498
|
+
return { kind: "ambiguous", ref: rawRef, paths: fileMatches };
|
|
499
|
+
const folderMatches = fg.sync(`**/${ref}`, {
|
|
500
|
+
cwd: repoRoot,
|
|
501
|
+
absolute: true,
|
|
502
|
+
onlyDirectories: true,
|
|
503
|
+
dot: false,
|
|
504
|
+
ignore: ["**/node_modules/**", "**/dist/**", "**/.git/**", "**/.scai-worktrees/**"],
|
|
505
|
+
}).map(path.normalize);
|
|
506
|
+
if (folderMatches.length === 1)
|
|
507
|
+
return { kind: "folder", ref: rawRef, path: folderMatches[0] };
|
|
508
|
+
if (folderMatches.length > 1)
|
|
509
|
+
return { kind: "ambiguous", ref: rawRef, paths: folderMatches };
|
|
510
|
+
return { kind: "unresolved", ref: rawRef };
|
|
511
|
+
}
|
|
512
|
+
const fileMatches = fg.sync(`**/${ref}*`, {
|
|
513
|
+
cwd: repoRoot,
|
|
514
|
+
absolute: true,
|
|
515
|
+
onlyFiles: true,
|
|
516
|
+
dot: false,
|
|
517
|
+
ignore: ["**/node_modules/**", "**/dist/**", "**/.git/**", "**/.scai-worktrees/**"],
|
|
518
|
+
}).map(path.normalize).filter(candidate => {
|
|
519
|
+
const filename = path.basename(candidate);
|
|
520
|
+
return normalizeLookupToken(filename) === normalizeLookupToken(ref) ||
|
|
521
|
+
normalizeLookupToken(path.parse(filename).name) === normalizeLookupToken(ref);
|
|
522
|
+
});
|
|
523
|
+
if (fileMatches.length === 1)
|
|
524
|
+
return { kind: "file", ref: rawRef, path: fileMatches[0] };
|
|
525
|
+
if (fileMatches.length > 1)
|
|
526
|
+
return { kind: "ambiguous", ref: rawRef, paths: fileMatches };
|
|
527
|
+
const folderMatches = fg.sync(`**/${ref}*`, {
|
|
528
|
+
cwd: repoRoot,
|
|
529
|
+
absolute: true,
|
|
530
|
+
onlyDirectories: true,
|
|
531
|
+
dot: false,
|
|
532
|
+
ignore: ["**/node_modules/**", "**/dist/**", "**/.git/**", "**/.scai-worktrees/**"],
|
|
533
|
+
}).map(path.normalize).filter(candidate => {
|
|
534
|
+
return normalizeLookupToken(path.basename(candidate)) === normalizeLookupToken(ref);
|
|
535
|
+
});
|
|
536
|
+
if (folderMatches.length === 1)
|
|
537
|
+
return { kind: "folder", ref: rawRef, path: folderMatches[0] };
|
|
538
|
+
if (folderMatches.length > 1)
|
|
539
|
+
return { kind: "ambiguous", ref: rawRef, paths: folderMatches };
|
|
540
|
+
return { kind: "unresolved", ref: rawRef };
|
|
541
|
+
}
|
|
542
|
+
function normalizeLookupToken(value) {
|
|
543
|
+
return String(value ?? "").toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
544
|
+
}
|
|
545
|
+
function buildFsSearchResult(filePath) {
|
|
546
|
+
return {
|
|
547
|
+
id: -Math.abs(hashPath(filePath)),
|
|
548
|
+
path: path.normalize(filePath),
|
|
549
|
+
filename: path.basename(filePath),
|
|
550
|
+
summary: null,
|
|
551
|
+
type: path.extname(filePath).replace(/^\./, "") || "unknown",
|
|
552
|
+
lastModified: readLastModified(filePath),
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
function hashPath(filePath) {
|
|
556
|
+
let hash = 0;
|
|
557
|
+
for (const char of filePath) {
|
|
558
|
+
hash = ((hash << 5) - hash) + char.charCodeAt(0);
|
|
559
|
+
hash |= 0;
|
|
560
|
+
}
|
|
561
|
+
return hash === 0 ? 1 : hash;
|
|
562
|
+
}
|
|
563
|
+
function readLastModified(filePath) {
|
|
564
|
+
try {
|
|
565
|
+
return fs.statSync(filePath).mtime.toISOString();
|
|
566
|
+
}
|
|
567
|
+
catch {
|
|
568
|
+
return new Date(0).toISOString();
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
function extractQuotedFragments(query) {
|
|
572
|
+
const out = new Set();
|
|
573
|
+
const patterns = [
|
|
574
|
+
/"([^"\n]{4,})"/g,
|
|
575
|
+
/'([^'\n]{4,})'/g,
|
|
576
|
+
/`([^`\n]{4,})`/g,
|
|
577
|
+
];
|
|
578
|
+
for (const pattern of patterns) {
|
|
579
|
+
let match = null;
|
|
580
|
+
while ((match = pattern.exec(query)) !== null) {
|
|
581
|
+
const fragment = String(match[1] ?? "").trim();
|
|
582
|
+
if (fragment.length >= 4) {
|
|
583
|
+
out.add(fragment);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
return Array.from(out);
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* Keeps regex flags predictable and small.
|
|
591
|
+
* Example: "igx" -> "gi" because only supported JS flags are kept.
|
|
592
|
+
*/
|
|
593
|
+
function normalizeRegexFlags(flags) {
|
|
594
|
+
const allowed = new Set(["g", "i", "m", "s", "u", "y"]);
|
|
595
|
+
const normalized = String(flags ?? "")
|
|
596
|
+
.split("")
|
|
597
|
+
.filter(flag => allowed.has(flag));
|
|
598
|
+
return Array.from(new Set(normalized)).join("");
|
|
599
|
+
}
|
|
600
|
+
async function searchContentMatches(options) {
|
|
601
|
+
const rgMatches = runRipgrepContentSearch(options);
|
|
602
|
+
if (rgMatches.available) {
|
|
603
|
+
return rgMatches.matches;
|
|
604
|
+
}
|
|
605
|
+
return runNodeContentSearch(options);
|
|
606
|
+
}
|
|
607
|
+
function runRipgrepContentSearch(options) {
|
|
608
|
+
try {
|
|
609
|
+
const args = [
|
|
610
|
+
"--line-number",
|
|
611
|
+
"--column",
|
|
612
|
+
"--with-filename",
|
|
613
|
+
"--color",
|
|
614
|
+
"never",
|
|
615
|
+
options.fixed ? "--fixed-strings" : "--regexp",
|
|
616
|
+
options.query,
|
|
617
|
+
".",
|
|
618
|
+
];
|
|
619
|
+
const output = execFileSync("rg", args, {
|
|
620
|
+
cwd: options.repoRoot,
|
|
621
|
+
encoding: "utf8",
|
|
622
|
+
maxBuffer: 1024 * 1024 * 8,
|
|
623
|
+
});
|
|
624
|
+
const matches = String(output ?? "")
|
|
625
|
+
.split(/\r?\n/)
|
|
626
|
+
.map(line => line.trim())
|
|
627
|
+
.filter(Boolean)
|
|
628
|
+
.map(line => parseRipgrepLine(line, options.repoRoot))
|
|
629
|
+
.filter((match) => Boolean(match))
|
|
630
|
+
.filter(match => !isPathIgnoredByFolderGlobs(match.path));
|
|
631
|
+
return { available: true, matches };
|
|
632
|
+
}
|
|
633
|
+
catch (err) {
|
|
634
|
+
if (err?.code === "ENOENT") {
|
|
635
|
+
return { available: false, matches: [] };
|
|
636
|
+
}
|
|
637
|
+
if (err?.status === 1) {
|
|
638
|
+
return { available: true, matches: [] };
|
|
639
|
+
}
|
|
640
|
+
return { available: false, matches: [] };
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
function parseRipgrepLine(line, repoRoot) {
|
|
644
|
+
const match = line.match(/^(.*?):(\d+):(\d+):(.*)$/);
|
|
645
|
+
if (!match)
|
|
646
|
+
return undefined;
|
|
647
|
+
const [, rawPath, rawLine, rawColumn, snippet] = match;
|
|
648
|
+
return {
|
|
649
|
+
path: path.normalize(path.join(repoRoot, rawPath)),
|
|
650
|
+
line: Number(rawLine),
|
|
651
|
+
column: Number(rawColumn),
|
|
652
|
+
snippet: snippet.trim(),
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
function runNodeContentSearch(options) {
|
|
656
|
+
const files = collectSearchablePaths(options.repoRoot);
|
|
657
|
+
const matches = [];
|
|
658
|
+
const regex = options.fixed ? null : safeCreateRegex(options.query);
|
|
659
|
+
for (const filePath of files) {
|
|
660
|
+
const content = safeReadFile(filePath);
|
|
661
|
+
if (!content)
|
|
662
|
+
continue;
|
|
663
|
+
const lines = content.split(/\r?\n/);
|
|
664
|
+
lines.forEach((line, index) => {
|
|
665
|
+
const column = options.fixed
|
|
666
|
+
? line.indexOf(options.query)
|
|
667
|
+
: regex
|
|
668
|
+
? line.search(regex)
|
|
669
|
+
: -1;
|
|
670
|
+
if (column < 0)
|
|
671
|
+
return;
|
|
672
|
+
matches.push({
|
|
673
|
+
path: filePath,
|
|
674
|
+
line: index + 1,
|
|
675
|
+
column: column + 1,
|
|
676
|
+
snippet: line.trim(),
|
|
677
|
+
});
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
return matches;
|
|
681
|
+
}
|
|
682
|
+
function safeCreateRegex(pattern, flags = "i") {
|
|
683
|
+
try {
|
|
684
|
+
return new RegExp(pattern, flags);
|
|
685
|
+
}
|
|
686
|
+
catch {
|
|
687
|
+
return null;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
function safeReadFile(filePath) {
|
|
691
|
+
try {
|
|
692
|
+
return fs.readFileSync(filePath, "utf8");
|
|
693
|
+
}
|
|
694
|
+
catch {
|
|
695
|
+
return "";
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
function collectSearchablePaths(rootDir, options = {}) {
|
|
699
|
+
const files = [];
|
|
700
|
+
const stack = [rootDir];
|
|
701
|
+
while (stack.length > 0) {
|
|
702
|
+
const currentDir = stack.pop();
|
|
703
|
+
if (!currentDir)
|
|
704
|
+
continue;
|
|
705
|
+
let entries = [];
|
|
706
|
+
try {
|
|
707
|
+
entries = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
708
|
+
}
|
|
709
|
+
catch {
|
|
710
|
+
continue;
|
|
711
|
+
}
|
|
712
|
+
for (const entry of entries) {
|
|
713
|
+
if (shouldIgnoreDirectoryEntry(entry.name))
|
|
714
|
+
continue;
|
|
715
|
+
const fullPath = path.join(currentDir, entry.name);
|
|
716
|
+
if (!options.allowIgnoredPaths && isPathIgnoredByFolderGlobs(fullPath))
|
|
717
|
+
continue;
|
|
718
|
+
if (entry.isDirectory()) {
|
|
719
|
+
stack.push(fullPath);
|
|
720
|
+
continue;
|
|
721
|
+
}
|
|
722
|
+
const ext = path.extname(entry.name).toLowerCase();
|
|
723
|
+
if (!options.includeIgnoredExtensions && IGNORED_EXTENSIONS.includes(ext))
|
|
724
|
+
continue;
|
|
725
|
+
files.push(fullPath);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
return files;
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Returns direct child entries for lightweight folder listing answers.
|
|
732
|
+
* Example: `/repo/artifacts` -> `[{"name":"evals","kind":"folder"}, {"name":"run.md","kind":"file"}]`.
|
|
733
|
+
*/
|
|
734
|
+
function collectDirectDirectoryEntries(folderPath) {
|
|
735
|
+
let entries = [];
|
|
736
|
+
try {
|
|
737
|
+
entries = fs.readdirSync(folderPath, { withFileTypes: true });
|
|
738
|
+
}
|
|
739
|
+
catch {
|
|
740
|
+
return [];
|
|
741
|
+
}
|
|
742
|
+
return entries
|
|
743
|
+
.filter(entry => !shouldIgnoreDirectoryEntry(entry.name))
|
|
744
|
+
.map(entry => ({
|
|
745
|
+
path: path.join(folderPath, entry.name),
|
|
746
|
+
name: entry.name,
|
|
747
|
+
kind: entry.isDirectory() ? "folder" : "file",
|
|
748
|
+
}))
|
|
749
|
+
.sort((left, right) => {
|
|
750
|
+
if (left.kind !== right.kind) {
|
|
751
|
+
return left.kind === "folder" ? -1 : 1;
|
|
752
|
+
}
|
|
753
|
+
return left.name.localeCompare(right.name);
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
function shouldIgnoreDirectoryEntry(name) {
|
|
757
|
+
if (!name)
|
|
758
|
+
return true;
|
|
759
|
+
if (name.startsWith("."))
|
|
760
|
+
return true;
|
|
761
|
+
return false;
|
|
762
|
+
}
|
|
763
|
+
function resolveDirectoryListingTarget(context, query, repoRoot) {
|
|
764
|
+
const explicitFolders = dedupeStrings([
|
|
765
|
+
...(context.analysis?.focus?.resolvedTargetFolders ?? []),
|
|
766
|
+
...(context.analysis?.intent?.targetFiles ?? []),
|
|
767
|
+
...extractFileReferences(query),
|
|
768
|
+
]);
|
|
769
|
+
for (const ref of explicitFolders) {
|
|
770
|
+
const resolution = resolvePathReference(ref, repoRoot);
|
|
771
|
+
if (resolution.kind === "folder" && resolution.path) {
|
|
772
|
+
return resolution.path;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
return undefined;
|
|
776
|
+
}
|
|
777
|
+
function collectRegexPathMatches(files, regex, repoRoot) {
|
|
778
|
+
const matches = [];
|
|
779
|
+
for (const filePath of files) {
|
|
780
|
+
const relativePath = path.relative(repoRoot, filePath);
|
|
781
|
+
const basename = path.basename(filePath);
|
|
782
|
+
regex.lastIndex = 0;
|
|
783
|
+
const matchedText = regex.test(relativePath) || regex.test(basename) ? relativePath : null;
|
|
784
|
+
if (!matchedText)
|
|
785
|
+
continue;
|
|
786
|
+
matches.push({
|
|
787
|
+
path: filePath,
|
|
788
|
+
line: 1,
|
|
789
|
+
column: 1,
|
|
790
|
+
snippet: matchedText,
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
return matches;
|
|
794
|
+
}
|
|
795
|
+
function collectRegexContentMatches(files, regex) {
|
|
796
|
+
const matches = [];
|
|
797
|
+
for (const filePath of files) {
|
|
798
|
+
const content = safeReadFile(filePath);
|
|
799
|
+
if (!content)
|
|
800
|
+
continue;
|
|
801
|
+
const lines = content.split(/\r?\n/);
|
|
802
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
803
|
+
const line = lines[index];
|
|
804
|
+
regex.lastIndex = 0;
|
|
805
|
+
const match = regex.exec(line);
|
|
806
|
+
if (!match)
|
|
807
|
+
continue;
|
|
808
|
+
matches.push({
|
|
809
|
+
path: filePath,
|
|
810
|
+
line: index + 1,
|
|
811
|
+
column: (match.index ?? 0) + 1,
|
|
812
|
+
snippet: line.trim(),
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
return matches;
|
|
817
|
+
}
|
|
818
|
+
function isRipgrepAvailable() {
|
|
819
|
+
try {
|
|
820
|
+
execFileSync("rg", ["--version"], { encoding: "utf8" });
|
|
821
|
+
return true;
|
|
822
|
+
}
|
|
823
|
+
catch {
|
|
824
|
+
return false;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
function dedupeStrings(values) {
|
|
828
|
+
const out = [];
|
|
829
|
+
const seen = new Set();
|
|
830
|
+
for (const value of values) {
|
|
831
|
+
const normalized = String(value ?? "").trim();
|
|
832
|
+
if (!normalized)
|
|
833
|
+
continue;
|
|
834
|
+
if (seen.has(normalized))
|
|
835
|
+
continue;
|
|
836
|
+
seen.add(normalized);
|
|
837
|
+
out.push(normalized);
|
|
838
|
+
}
|
|
839
|
+
return out;
|
|
840
|
+
}
|
|
841
|
+
function dedupeSearchResults(results) {
|
|
842
|
+
const seen = new Set();
|
|
843
|
+
const out = [];
|
|
844
|
+
for (const result of results) {
|
|
845
|
+
if (seen.has(result.path))
|
|
846
|
+
continue;
|
|
847
|
+
seen.add(result.path);
|
|
848
|
+
out.push(result);
|
|
849
|
+
}
|
|
850
|
+
return out;
|
|
851
|
+
}
|
|
852
|
+
function dedupeSymbolResolutions(entries) {
|
|
853
|
+
const seen = new Set();
|
|
854
|
+
const out = [];
|
|
855
|
+
for (const entry of entries) {
|
|
856
|
+
const key = `${entry.symbol}::${entry.filePath}`;
|
|
857
|
+
if (seen.has(key))
|
|
858
|
+
continue;
|
|
859
|
+
seen.add(key);
|
|
860
|
+
out.push(entry);
|
|
861
|
+
}
|
|
862
|
+
return out;
|
|
863
|
+
}
|
|
864
|
+
function collectOrderedQuestionQueries(context, query) {
|
|
865
|
+
const orderedQuestions = context.analysis?.intent?.questions ?? [];
|
|
866
|
+
if (orderedQuestions.length <= 1) {
|
|
867
|
+
return [];
|
|
868
|
+
}
|
|
869
|
+
const seen = new Set();
|
|
870
|
+
const out = [];
|
|
871
|
+
for (const item of orderedQuestions) {
|
|
872
|
+
const text = String(item?.text ?? "").trim();
|
|
873
|
+
if (!text || text === query || seen.has(text))
|
|
874
|
+
continue;
|
|
875
|
+
seen.add(text);
|
|
876
|
+
out.push(text);
|
|
877
|
+
}
|
|
878
|
+
return out;
|
|
879
|
+
}
|
|
880
|
+
function rankMergedSearchResults(results, query) {
|
|
881
|
+
const relatedFileScores = Object.fromEntries(results.flatMap(result => typeof result.bm25Score === "number" && Number.isFinite(result.bm25Score)
|
|
882
|
+
? [[result.path, result.bm25Score]]
|
|
883
|
+
: []));
|
|
884
|
+
const ranked = scoreCandidateFiles(results.map(result => result.path), relatedFileScores, query);
|
|
885
|
+
const resultByPath = new Map(results.map(result => [result.path, result]));
|
|
886
|
+
return ranked
|
|
887
|
+
.map(item => resultByPath.get(item.filePath))
|
|
888
|
+
.filter((result) => Boolean(result));
|
|
889
|
+
}
|
|
890
|
+
function collectMethodSelectionPathSupplement(context, retrievalQuery, existingPaths) {
|
|
891
|
+
const repoRoot = getContextExecutionPath(context);
|
|
892
|
+
if (!repoRoot || !fs.existsSync(repoRoot))
|
|
893
|
+
return [];
|
|
894
|
+
const candidates = collectSearchablePaths(repoRoot)
|
|
895
|
+
.filter(filePath => !existingPaths.has(filePath));
|
|
896
|
+
const scored = scoreCandidateFiles(candidates, {}, retrievalQuery)
|
|
897
|
+
.filter(item => item.score >= 8)
|
|
898
|
+
.slice(0, 8);
|
|
899
|
+
return scored.map(item => buildFsSearchResult(item.filePath));
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* Adds a small path-scored supplement for broad queries whose first semantic hits skew toward docs.
|
|
903
|
+
* Example: ordered questions can add both routing and verify implementation files before file-check runs.
|
|
904
|
+
*/
|
|
905
|
+
function collectScopedPathSupplements(context, retrievalQueries, existingPaths) {
|
|
906
|
+
const repoRoot = getContextExecutionPath(context);
|
|
907
|
+
if (!repoRoot || !fs.existsSync(repoRoot))
|
|
908
|
+
return [];
|
|
909
|
+
const candidates = collectSearchablePaths(repoRoot)
|
|
910
|
+
.filter(filePath => !existingPaths.has(filePath));
|
|
911
|
+
const out = [];
|
|
912
|
+
const added = new Set();
|
|
913
|
+
for (const retrievalQuery of dedupeStrings(retrievalQueries)) {
|
|
914
|
+
if (!retrievalQuery.trim())
|
|
915
|
+
continue;
|
|
916
|
+
const scored = scoreCandidateFiles(candidates, {}, retrievalQuery)
|
|
917
|
+
.filter(item => item.score >= 12)
|
|
918
|
+
.slice(0, 3);
|
|
919
|
+
for (const item of scored) {
|
|
920
|
+
if (added.has(item.filePath))
|
|
921
|
+
continue;
|
|
922
|
+
added.add(item.filePath);
|
|
923
|
+
out.push(buildFsSearchResult(item.filePath));
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
return out;
|
|
927
|
+
}
|
|
928
|
+
//# sourceMappingURL=SearchOrchestrator.js.map
|