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,733 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds grounded triage and fallback read evidence for the modular agent runtime.
|
|
3
|
+
*
|
|
4
|
+
* Why this file exists:
|
|
5
|
+
* - file-aware extraction should stay separate from read execution and loop control
|
|
6
|
+
* - cheap triage reads should preserve more real code shape than single matching lines
|
|
7
|
+
* - deterministic fallback data should use the same evidence shape as model-backed reads
|
|
8
|
+
*/
|
|
9
|
+
import fs from "fs";
|
|
10
|
+
import path from "path";
|
|
11
|
+
import { computeContentFingerprint, computeQueryFingerprint } from "../../utils/fileEvidenceCache.js";
|
|
12
|
+
import { nowLocalIso } from "../../utils/time.js";
|
|
13
|
+
const MAX_QUERY_TERMS = 6;
|
|
14
|
+
const MAX_SUMMARY_CHARS = 240;
|
|
15
|
+
const MAX_KEY_SYMBOLS = 8;
|
|
16
|
+
const MAX_SNIPPETS = 4;
|
|
17
|
+
const MAX_EXCERPTS = 3;
|
|
18
|
+
const MAX_EXCERPT_LINES = 40;
|
|
19
|
+
const BLOCK_SEARCH_RADIUS = 8;
|
|
20
|
+
const MAX_FULL_READ_BLOCKS = 4;
|
|
21
|
+
export function nowIso() {
|
|
22
|
+
return nowLocalIso();
|
|
23
|
+
}
|
|
24
|
+
export function uniqueStrings(values) {
|
|
25
|
+
const seen = new Set();
|
|
26
|
+
const out = [];
|
|
27
|
+
for (const value of values) {
|
|
28
|
+
const trimmed = String(value ?? "").trim();
|
|
29
|
+
if (!trimmed || seen.has(trimmed))
|
|
30
|
+
continue;
|
|
31
|
+
seen.add(trimmed);
|
|
32
|
+
out.push(trimmed);
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
export function dedupePaths(paths) {
|
|
37
|
+
return uniqueStrings(paths.map((filePath) => path.normalize(filePath)));
|
|
38
|
+
}
|
|
39
|
+
function escapeRegex(text) {
|
|
40
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Treats real folders as folders when they exist.
|
|
44
|
+
* Example: "cli/src/agents" -> true, "agentLoop.ts" -> false.
|
|
45
|
+
*/
|
|
46
|
+
export function looksLikeDirectoryTarget(target, executionPath) {
|
|
47
|
+
const absolute = path.isAbsolute(target) ? target : path.join(executionPath, target);
|
|
48
|
+
try {
|
|
49
|
+
return fs.existsSync(absolute) && fs.statSync(absolute).isDirectory();
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return !path.extname(target);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function extractQueryTerms(query) {
|
|
56
|
+
return uniqueStrings(query
|
|
57
|
+
.split(/[^A-Za-z0-9_./-]+/)
|
|
58
|
+
.map((part) => part.trim().toLowerCase())
|
|
59
|
+
.filter((part) => part.length >= 4 && !part.includes("/"))).slice(0, MAX_QUERY_TERMS);
|
|
60
|
+
}
|
|
61
|
+
function firstNonEmptyLine(lines) {
|
|
62
|
+
return lines.find((line) => line.trim().length > 0)?.trim() ?? "[empty file]";
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Pulls the first doc block near the top of the file into one compact summary line.
|
|
66
|
+
* Example: a top doc comment becomes one plain summary string.
|
|
67
|
+
*/
|
|
68
|
+
function extractTopCommentBlock(code) {
|
|
69
|
+
const match = code.match(/^\s*\/\*\*([\s\S]*?)\*\//);
|
|
70
|
+
if (!match)
|
|
71
|
+
return undefined;
|
|
72
|
+
const text = match[1]
|
|
73
|
+
.split("\n")
|
|
74
|
+
.map((line) => line.replace(/^\s*\*\s?/, "").trim())
|
|
75
|
+
.filter(Boolean)
|
|
76
|
+
.join(" ")
|
|
77
|
+
.trim();
|
|
78
|
+
return text.length > 0 ? text.slice(0, MAX_SUMMARY_CHARS) : undefined;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Extracts readable exported contract names from common TS declarations.
|
|
82
|
+
* Example: an exported interface yields its symbol name.
|
|
83
|
+
*/
|
|
84
|
+
function extractExportNames(code) {
|
|
85
|
+
const matches = Array.from(code.matchAll(/^\s*export\s+(?:default\s+)?(?:async\s+)?(?:type|interface|class|function|const|let|var|enum)\s+([A-Za-z0-9_$]+)/gm));
|
|
86
|
+
return uniqueStrings(matches.map((match) => match[1] ?? "").filter(Boolean)).slice(0, MAX_KEY_SYMBOLS);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Extracts local declaration names from one file.
|
|
90
|
+
* Example: `function buildFinalAnswer()` -> `buildFinalAnswer`.
|
|
91
|
+
*/
|
|
92
|
+
function extractLocalDeclarationNames(code) {
|
|
93
|
+
const matches = Array.from(code.matchAll(/^\s*(?:export\s+)?(?:default\s+)?(?:async\s+)?(?:function|class|interface|type|const|let|var|enum)\s+([A-Za-z0-9_$]+)/gm));
|
|
94
|
+
return uniqueStrings(matches.map((match) => match[1] ?? "").filter(Boolean)).slice(0, 20);
|
|
95
|
+
}
|
|
96
|
+
function isCommentOnlyLine(line) {
|
|
97
|
+
const trimmed = line.trim();
|
|
98
|
+
return trimmed.startsWith("//") || trimmed === "/**" || trimmed === "*/" || trimmed.startsWith("*");
|
|
99
|
+
}
|
|
100
|
+
function isImportLine(line) {
|
|
101
|
+
const trimmed = line.trim();
|
|
102
|
+
return /^import\s+(?:type\s+)?/.test(trimmed) || /^const\s+[A-Za-z0-9_$]+\s*=\s*require\(/.test(trimmed);
|
|
103
|
+
}
|
|
104
|
+
function isBridgeLine(line) {
|
|
105
|
+
return /^export\s+(?:\*|\{[\s\S]+?\})\s+from\s+["'][^"']+["'];?$/.test(line.trim());
|
|
106
|
+
}
|
|
107
|
+
function isTypeOnlyLine(line) {
|
|
108
|
+
return /^(?:export\s+)?type\s+[A-Za-z0-9_$]+\s*=/.test(line.trim());
|
|
109
|
+
}
|
|
110
|
+
function isNoiseLine(line) {
|
|
111
|
+
const trimmed = line.trim();
|
|
112
|
+
return (trimmed.length === 0 ||
|
|
113
|
+
/^\/\/\s*File:/.test(trimmed) ||
|
|
114
|
+
/^[{}[\]]\s*;?$/.test(trimmed));
|
|
115
|
+
}
|
|
116
|
+
function scoreSnippetLine(line, queryTerms, keySymbols) {
|
|
117
|
+
const trimmed = line.trim();
|
|
118
|
+
const lowered = trimmed.toLowerCase();
|
|
119
|
+
const matchedTermCount = queryTerms.filter((term) => lowered.includes(term)).length
|
|
120
|
+
+ keySymbols.filter((symbol) => lowered.includes(symbol.toLowerCase())).length;
|
|
121
|
+
let kind = "other";
|
|
122
|
+
let score = matchedTermCount * 25;
|
|
123
|
+
if (isNoiseLine(trimmed)) {
|
|
124
|
+
kind = "noise";
|
|
125
|
+
score -= 90;
|
|
126
|
+
}
|
|
127
|
+
else if (isCommentOnlyLine(trimmed)) {
|
|
128
|
+
kind = "comment";
|
|
129
|
+
score -= 45;
|
|
130
|
+
}
|
|
131
|
+
else if (isImportLine(trimmed)) {
|
|
132
|
+
kind = "import";
|
|
133
|
+
score -= 35;
|
|
134
|
+
}
|
|
135
|
+
else if (isBridgeLine(trimmed)) {
|
|
136
|
+
kind = "bridge";
|
|
137
|
+
score -= 8;
|
|
138
|
+
}
|
|
139
|
+
else if (isTypeOnlyLine(trimmed)) {
|
|
140
|
+
kind = "type";
|
|
141
|
+
score -= 16;
|
|
142
|
+
}
|
|
143
|
+
else if (/\.(?:command|action)\s*\(/.test(trimmed)) {
|
|
144
|
+
kind = "command-registration";
|
|
145
|
+
score += 60;
|
|
146
|
+
}
|
|
147
|
+
else if (/\bprepare\(.+\)\s*\.\s*(?:all|get|run)\(/.test(trimmed) || /\.prepare\(/.test(trimmed)) {
|
|
148
|
+
kind = "query-execution";
|
|
149
|
+
score += 55;
|
|
150
|
+
}
|
|
151
|
+
else if (/\b(?:export\s+)?(?:async\s+)?function\b/.test(trimmed)) {
|
|
152
|
+
kind = "function";
|
|
153
|
+
score += 50;
|
|
154
|
+
}
|
|
155
|
+
else if (/\bclass\s+[A-Za-z0-9_$]+/.test(trimmed)) {
|
|
156
|
+
kind = "class";
|
|
157
|
+
score += 45;
|
|
158
|
+
}
|
|
159
|
+
else if (/\bprocess\.env\b/.test(trimmed) || /^[A-Za-z0-9_$"'`.-]+\s*:\s*(?:["'`[{]|true\b|false\b|null\b|\d)/.test(trimmed)) {
|
|
160
|
+
kind = "config";
|
|
161
|
+
score += 35;
|
|
162
|
+
}
|
|
163
|
+
else if (/\b(?:export\s+)?(?:const|let|var)\s+[A-Za-z0-9_$]+\s*=/.test(trimmed)) {
|
|
164
|
+
kind = "object";
|
|
165
|
+
score += 28;
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
score += 8;
|
|
169
|
+
}
|
|
170
|
+
if (trimmed.length > 140) {
|
|
171
|
+
score -= 6;
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
index: 0,
|
|
175
|
+
line,
|
|
176
|
+
score,
|
|
177
|
+
matchedTermCount,
|
|
178
|
+
kind,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function isImplementationCandidateKind(kind) {
|
|
182
|
+
return kind === "command-registration"
|
|
183
|
+
|| kind === "function"
|
|
184
|
+
|| kind === "class"
|
|
185
|
+
|| kind === "config"
|
|
186
|
+
|| kind === "query-execution"
|
|
187
|
+
|| kind === "object";
|
|
188
|
+
}
|
|
189
|
+
function classifyGroundingDepth(code) {
|
|
190
|
+
const codeLines = code
|
|
191
|
+
.split("\n")
|
|
192
|
+
.map((line) => line.trim())
|
|
193
|
+
.filter((line) => line.length > 0)
|
|
194
|
+
.filter((line) => !isCommentOnlyLine(line));
|
|
195
|
+
if (codeLines.length === 0) {
|
|
196
|
+
return "wrapper";
|
|
197
|
+
}
|
|
198
|
+
const realBodyCount = codeLines.filter((line) => /\.(?:command|action)\s*\(/.test(line) ||
|
|
199
|
+
/\b(?:export\s+)?(?:async\s+)?function\b/.test(line) ||
|
|
200
|
+
/\bclass\s+[A-Za-z0-9_$]+/.test(line) ||
|
|
201
|
+
/\b(?:export\s+)?(?:const|let|var)\s+[A-Za-z0-9_$]+\s*=/.test(line) ||
|
|
202
|
+
/\bprocess\.env\b/.test(line)).length;
|
|
203
|
+
const bridgeCount = codeLines.filter((line) => isBridgeLine(line)).length;
|
|
204
|
+
const importishCount = codeLines.filter((line) => isImportLine(line) || isTypeOnlyLine(line)).length;
|
|
205
|
+
if (realBodyCount === 0 && bridgeCount > 0 && bridgeCount + importishCount === codeLines.length) {
|
|
206
|
+
return "wrapper";
|
|
207
|
+
}
|
|
208
|
+
if (realBodyCount > 0 && bridgeCount > 0) {
|
|
209
|
+
return "mixed";
|
|
210
|
+
}
|
|
211
|
+
return "direct";
|
|
212
|
+
}
|
|
213
|
+
function clamp(value, min, max) {
|
|
214
|
+
return Math.max(min, Math.min(max, value));
|
|
215
|
+
}
|
|
216
|
+
function pickGroundingSnippets(lines, query, keySymbols, groundingDepth) {
|
|
217
|
+
const terms = extractQueryTerms(query);
|
|
218
|
+
const candidates = lines
|
|
219
|
+
.map((line, index) => {
|
|
220
|
+
const candidate = scoreSnippetLine(line, terms, keySymbols);
|
|
221
|
+
return { ...candidate, index };
|
|
222
|
+
})
|
|
223
|
+
.filter((candidate) => candidate.line.trim().length > 0);
|
|
224
|
+
if (groundingDepth === "wrapper") {
|
|
225
|
+
const bridge = candidates
|
|
226
|
+
.filter((candidate) => candidate.kind === "bridge")
|
|
227
|
+
.sort((left, right) => right.score - left.score || left.index - right.index)[0];
|
|
228
|
+
if (bridge) {
|
|
229
|
+
return [`${bridge.index + 1}: ${bridge.line.trim()}`];
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const matchingCandidates = candidates
|
|
233
|
+
.filter((candidate) => candidate.matchedTermCount > 0)
|
|
234
|
+
.sort((left, right) => right.score - left.score || right.matchedTermCount - left.matchedTermCount || left.index - right.index);
|
|
235
|
+
const fallbackCandidates = candidates
|
|
236
|
+
.filter((candidate) => candidate.kind !== "noise")
|
|
237
|
+
.sort((left, right) => right.score - left.score || left.index - right.index);
|
|
238
|
+
const selected = uniqueStrings([...matchingCandidates, ...fallbackCandidates]
|
|
239
|
+
.filter((candidate) => candidate.score > -10)
|
|
240
|
+
.slice(0, MAX_SNIPPETS)
|
|
241
|
+
.map((candidate) => `${candidate.index + 1}: ${candidate.line.trim()}`));
|
|
242
|
+
if (selected.length > 0) {
|
|
243
|
+
return selected;
|
|
244
|
+
}
|
|
245
|
+
return lines
|
|
246
|
+
.map((line, index) => ({ line, index }))
|
|
247
|
+
.filter(({ line }) => line.trim().length > 0)
|
|
248
|
+
.slice(0, 1)
|
|
249
|
+
.map(({ line, index }) => `${index + 1}: ${line.trim()}`);
|
|
250
|
+
}
|
|
251
|
+
function findMatchingLineIndexes(lines, query, keySymbols) {
|
|
252
|
+
const terms = extractQueryTerms(query);
|
|
253
|
+
const symbolTerms = keySymbols.map((symbol) => symbol.toLowerCase());
|
|
254
|
+
const indexes = [];
|
|
255
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
256
|
+
const lowered = lines[index].toLowerCase();
|
|
257
|
+
if (terms.some((term) => lowered.includes(term)) || symbolTerms.some((term) => lowered.includes(term))) {
|
|
258
|
+
indexes.push(index);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return indexes;
|
|
262
|
+
}
|
|
263
|
+
function trimTrailingBlankLines(lines) {
|
|
264
|
+
let end = lines.length;
|
|
265
|
+
while (end > 0 && lines[end - 1].trim().length === 0) {
|
|
266
|
+
end -= 1;
|
|
267
|
+
}
|
|
268
|
+
return lines.slice(0, end);
|
|
269
|
+
}
|
|
270
|
+
function resolveBlockStart(lines, seedIndex) {
|
|
271
|
+
const seedLine = lines[seedIndex]?.trim() ?? "";
|
|
272
|
+
if (seedLine.startsWith("/**") || seedLine.startsWith("/*") || seedLine.startsWith("*")) {
|
|
273
|
+
for (let cursor = seedIndex; cursor >= Math.max(0, seedIndex - BLOCK_SEARCH_RADIUS); cursor -= 1) {
|
|
274
|
+
const line = lines[cursor].trim();
|
|
275
|
+
if (line.startsWith("/**") || line.startsWith("/*")) {
|
|
276
|
+
return cursor;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
for (let cursor = seedIndex; cursor >= Math.max(0, seedIndex - BLOCK_SEARCH_RADIUS); cursor -= 1) {
|
|
281
|
+
const line = lines[cursor];
|
|
282
|
+
if (/^\s*(export\s+)?(async\s+)?(function|class|interface|type|enum)\b/.test(line)) {
|
|
283
|
+
return cursor;
|
|
284
|
+
}
|
|
285
|
+
if (/^\s*(export\s+)?(const|let|var)\s+[A-Za-z0-9_$]+\s*=/.test(line)) {
|
|
286
|
+
return cursor;
|
|
287
|
+
}
|
|
288
|
+
if (/\.(?:command|action)\s*\(/.test(line)) {
|
|
289
|
+
return cursor;
|
|
290
|
+
}
|
|
291
|
+
if (/^\s*[A-Za-z0-9_$"'`.-]+\s*:\s*(?:["'`[{]|true\b|false\b|null\b|\d)/.test(line)) {
|
|
292
|
+
return cursor;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return seedIndex;
|
|
296
|
+
}
|
|
297
|
+
function resolveBlockEnd(lines, startIndex) {
|
|
298
|
+
const startLine = lines[startIndex]?.trim() ?? "";
|
|
299
|
+
if (startLine.startsWith("/**") || startLine.startsWith("/*")) {
|
|
300
|
+
for (let cursor = startIndex; cursor < Math.min(lines.length, startIndex + MAX_EXCERPT_LINES); cursor += 1) {
|
|
301
|
+
if (lines[cursor].trim().endsWith("*/")) {
|
|
302
|
+
return cursor;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
let balance = 0;
|
|
307
|
+
let opened = false;
|
|
308
|
+
for (let cursor = startIndex; cursor < lines.length; cursor += 1) {
|
|
309
|
+
const line = lines[cursor];
|
|
310
|
+
if (cursor > startIndex && /\.(?:command|action)\s*\(/.test(lines[startIndex]) && !/\.(?:command|action)\s*\(/.test(line) && line.trim().length === 0) {
|
|
311
|
+
return cursor - 1;
|
|
312
|
+
}
|
|
313
|
+
for (const char of line) {
|
|
314
|
+
if (char === "{") {
|
|
315
|
+
balance += 1;
|
|
316
|
+
opened = true;
|
|
317
|
+
}
|
|
318
|
+
else if (char === "}") {
|
|
319
|
+
balance -= 1;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (opened && balance <= 0) {
|
|
323
|
+
return cursor;
|
|
324
|
+
}
|
|
325
|
+
if (!opened && /;\s*$/.test(line.trim())) {
|
|
326
|
+
return cursor;
|
|
327
|
+
}
|
|
328
|
+
if (cursor - startIndex >= MAX_EXCERPT_LINES - 1) {
|
|
329
|
+
return cursor;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return Math.min(lines.length - 1, startIndex + MAX_EXCERPT_LINES - 1);
|
|
333
|
+
}
|
|
334
|
+
function extractSymbolsFromHeader(headerLine, knownSymbols) {
|
|
335
|
+
const symbols = new Set();
|
|
336
|
+
const declarationMatch = headerLine.match(/\b(?:function|class|interface|type|enum|const|let|var)\s+([A-Za-z0-9_$]+)/);
|
|
337
|
+
if (declarationMatch?.[1]) {
|
|
338
|
+
symbols.add(declarationMatch[1]);
|
|
339
|
+
}
|
|
340
|
+
for (const symbol of knownSymbols) {
|
|
341
|
+
if (headerLine.includes(symbol)) {
|
|
342
|
+
symbols.add(symbol);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return Array.from(symbols);
|
|
346
|
+
}
|
|
347
|
+
function isConceptExcerpt(excerpt) {
|
|
348
|
+
const description = excerpt.description.toLowerCase();
|
|
349
|
+
const code = excerpt.code.trim();
|
|
350
|
+
return description.includes("overview")
|
|
351
|
+
|| description.includes("responsibilities")
|
|
352
|
+
|| description.includes("boundary")
|
|
353
|
+
|| /^\/\*\*/.test(code)
|
|
354
|
+
|| /^\/\*/.test(code);
|
|
355
|
+
}
|
|
356
|
+
function isImplementationExcerpt(excerpt) {
|
|
357
|
+
const description = excerpt.description.toLowerCase();
|
|
358
|
+
const code = excerpt.code;
|
|
359
|
+
return description.startsWith("implementation block")
|
|
360
|
+
|| description.includes("query execution")
|
|
361
|
+
|| description.includes("command registration")
|
|
362
|
+
|| /\b(?:export\s+)?(?:async\s+)?function\b/.test(code)
|
|
363
|
+
|| /\bclass\s+[A-Za-z0-9_$]+/.test(code)
|
|
364
|
+
|| /\b(?:export\s+)?(?:const|let|var)\s+[A-Za-z0-9_$]+\s*=/.test(code)
|
|
365
|
+
|| /\.command\(/.test(code)
|
|
366
|
+
|| /\.prepare\(/.test(code);
|
|
367
|
+
}
|
|
368
|
+
function buildExcerptFromSeed(lines, seedIndex, keySymbols) {
|
|
369
|
+
const startIndex = resolveBlockStart(lines, seedIndex);
|
|
370
|
+
const endIndex = resolveBlockEnd(lines, startIndex);
|
|
371
|
+
const blockLines = trimTrailingBlankLines(lines.slice(startIndex, endIndex + 1));
|
|
372
|
+
if (blockLines.length === 0) {
|
|
373
|
+
return undefined;
|
|
374
|
+
}
|
|
375
|
+
const headerLine = blockLines[0];
|
|
376
|
+
const symbols = extractSymbolsFromHeader(headerLine, keySymbols);
|
|
377
|
+
return {
|
|
378
|
+
description: buildExcerptDescription(symbols, headerLine, blockLines),
|
|
379
|
+
startLine: startIndex + 1,
|
|
380
|
+
endLine: startIndex + blockLines.length,
|
|
381
|
+
...(symbols.length > 0 ? { symbols } : {}),
|
|
382
|
+
code: blockLines.join("\n"),
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
function isExplanationLikeQuery(query) {
|
|
386
|
+
return /\b(explain|summary|summarize|architecture|module|how|purpose|responsibilit)/i.test(query);
|
|
387
|
+
}
|
|
388
|
+
function prioritizeExcerptsForAnswer(excerpts, query) {
|
|
389
|
+
if (excerpts.length <= 1) {
|
|
390
|
+
return excerpts;
|
|
391
|
+
}
|
|
392
|
+
if (!isExplanationLikeQuery(query)) {
|
|
393
|
+
return excerpts;
|
|
394
|
+
}
|
|
395
|
+
const bestConcept = excerpts.find((excerpt) => isConceptExcerpt(excerpt));
|
|
396
|
+
const bestImplementation = excerpts.find((excerpt) => isImplementationExcerpt(excerpt));
|
|
397
|
+
const ordered = [];
|
|
398
|
+
if (bestConcept) {
|
|
399
|
+
ordered.push(bestConcept);
|
|
400
|
+
}
|
|
401
|
+
if (bestImplementation && !ordered.some((excerpt) => excerpt.startLine === bestImplementation.startLine && excerpt.endLine === bestImplementation.endLine)) {
|
|
402
|
+
ordered.push(bestImplementation);
|
|
403
|
+
}
|
|
404
|
+
for (const excerpt of excerpts) {
|
|
405
|
+
if (!ordered.some((entry) => entry.startLine === excerpt.startLine && entry.endLine === excerpt.endLine)) {
|
|
406
|
+
ordered.push(excerpt);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return ordered.slice(0, MAX_EXCERPTS);
|
|
410
|
+
}
|
|
411
|
+
function buildExcerptDescription(symbols, startLine, blockLines) {
|
|
412
|
+
const blockText = blockLines.join("\n");
|
|
413
|
+
if (/^\s*\/\*\*/.test(startLine) && /\b(?:responsibilit|overview|final answer module|phase boundary)\b/i.test(blockText)) {
|
|
414
|
+
return "Module overview and key responsibilities";
|
|
415
|
+
}
|
|
416
|
+
if (/^\s*\/\*/.test(startLine) && /\b(?:boundary|grounding rule)\b/i.test(blockText)) {
|
|
417
|
+
return "Boundary conditions and grounding rules";
|
|
418
|
+
}
|
|
419
|
+
const commandLiteral = blockText.match(/\.command\(\s*["'`]([^"'`]+)["'`]\s*\)/)?.[1];
|
|
420
|
+
if (commandLiteral) {
|
|
421
|
+
return `CLI command registration for ${commandLiteral}`;
|
|
422
|
+
}
|
|
423
|
+
if (/prepare\([^)]+\)\s*\.\s*(?:all|get|run)\(/.test(blockText) || /\.prepare\([^)]+\)/.test(blockText)) {
|
|
424
|
+
const symbol = symbols[0];
|
|
425
|
+
return symbol ? `SQLite query execution in ${symbol}` : "SQLite query execution block";
|
|
426
|
+
}
|
|
427
|
+
const bridgeTarget = startLine.match(/^export\s+(?:\*|\{[\s\S]+?\})\s+from\s+["'][^"']*\/([^/"']+)\.[^/"']+["'];?$/)?.[1];
|
|
428
|
+
if (bridgeTarget) {
|
|
429
|
+
return `Legacy bridge re-export to ${bridgeTarget}`;
|
|
430
|
+
}
|
|
431
|
+
if (symbols.length > 0 && /\bcreateProgram\b/.test(blockText)) {
|
|
432
|
+
return "Program factory wiring for top-level CLI commands";
|
|
433
|
+
}
|
|
434
|
+
if (symbols.length > 0 && /\bdefineConfig\b/.test(blockText)) {
|
|
435
|
+
return `Configuration block for ${symbols[0]}`;
|
|
436
|
+
}
|
|
437
|
+
if (symbols.length > 0) {
|
|
438
|
+
return `Implementation block for ${symbols.slice(0, 3).join(", ")}`;
|
|
439
|
+
}
|
|
440
|
+
if (/^\s*export\b/.test(startLine)) {
|
|
441
|
+
return "Relevant exported declaration block";
|
|
442
|
+
}
|
|
443
|
+
return "Relevant code block near the strongest query match";
|
|
444
|
+
}
|
|
445
|
+
function buildBlockExcerpts(code, query, keySymbols) {
|
|
446
|
+
const lines = code.split("\n");
|
|
447
|
+
const queryTerms = extractQueryTerms(query);
|
|
448
|
+
const matchIndexes = findMatchingLineIndexes(lines, query, keySymbols);
|
|
449
|
+
const fallbackBlockSeeds = lines
|
|
450
|
+
.map((line, index) => ({ ...scoreSnippetLine(line, queryTerms, keySymbols), index }))
|
|
451
|
+
.filter((candidate) => candidate.kind !== "noise" && candidate.kind !== "comment" && candidate.kind !== "import")
|
|
452
|
+
.sort((left, right) => right.score - left.score || left.index - right.index)
|
|
453
|
+
.slice(0, MAX_FULL_READ_BLOCKS)
|
|
454
|
+
.map((candidate) => candidate.index);
|
|
455
|
+
const seedIndexes = uniqueStrings((matchIndexes.length > 0 ? matchIndexes : keySymbols.map((symbol) => {
|
|
456
|
+
const index = lines.findIndex((line) => line.includes(symbol));
|
|
457
|
+
return index >= 0 ? String(index) : "";
|
|
458
|
+
}))
|
|
459
|
+
.map((value) => String(value))
|
|
460
|
+
.filter((value) => value.length > 0)).map((value) => Number(value)).filter((value) => Number.isInteger(value) && value >= 0);
|
|
461
|
+
const orderedSeedIndexes = uniqueStrings([
|
|
462
|
+
...seedIndexes.map(String),
|
|
463
|
+
...fallbackBlockSeeds.map(String),
|
|
464
|
+
]).map(Number);
|
|
465
|
+
const excerpts = [];
|
|
466
|
+
const seenRanges = new Set();
|
|
467
|
+
for (const seedIndex of orderedSeedIndexes) {
|
|
468
|
+
const excerpt = buildExcerptFromSeed(lines, seedIndex, keySymbols);
|
|
469
|
+
if (!excerpt) {
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
472
|
+
const rangeKey = `${excerpt.startLine ?? 0}:${excerpt.endLine ?? 0}`;
|
|
473
|
+
if (seenRanges.has(rangeKey)) {
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
seenRanges.add(rangeKey);
|
|
477
|
+
excerpts.push(excerpt);
|
|
478
|
+
if (excerpts.length >= MAX_EXCERPTS) {
|
|
479
|
+
break;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
if (isExplanationLikeQuery(query) && excerpts.some((excerpt) => isConceptExcerpt(excerpt)) && !excerpts.some((excerpt) => isImplementationExcerpt(excerpt))) {
|
|
483
|
+
const implementationSeed = lines
|
|
484
|
+
.map((line, index) => ({ ...scoreSnippetLine(line, queryTerms, keySymbols), index }))
|
|
485
|
+
.filter((candidate) => isImplementationCandidateKind(candidate.kind))
|
|
486
|
+
.sort((left, right) => right.score - left.score || left.index - right.index)[0];
|
|
487
|
+
if (implementationSeed) {
|
|
488
|
+
const implementationExcerpt = buildExcerptFromSeed(lines, implementationSeed.index, keySymbols);
|
|
489
|
+
if (implementationExcerpt) {
|
|
490
|
+
const exists = excerpts.some((excerpt) => excerpt.startLine === implementationExcerpt.startLine && excerpt.endLine === implementationExcerpt.endLine);
|
|
491
|
+
if (!exists) {
|
|
492
|
+
excerpts.push(implementationExcerpt);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
return prioritizeExcerptsForAnswer(excerpts, query);
|
|
498
|
+
}
|
|
499
|
+
function determineRole(hardTarget, excerpts, matchedTerms, keySymbols) {
|
|
500
|
+
if (hardTarget) {
|
|
501
|
+
return "primary";
|
|
502
|
+
}
|
|
503
|
+
if (excerpts.length >= 2 || matchedTerms.length >= 2) {
|
|
504
|
+
return "primary";
|
|
505
|
+
}
|
|
506
|
+
if (excerpts.length > 0 || keySymbols.length > 0) {
|
|
507
|
+
return "supporting";
|
|
508
|
+
}
|
|
509
|
+
return "contextual";
|
|
510
|
+
}
|
|
511
|
+
function buildRelevantContext(code, query, summary, keySymbols, relevanceExplanation) {
|
|
512
|
+
const terms = extractQueryTerms(query);
|
|
513
|
+
const context = [];
|
|
514
|
+
const docBlock = extractTopCommentBlock(code);
|
|
515
|
+
if (docBlock) {
|
|
516
|
+
context.push({
|
|
517
|
+
kind: "purpose",
|
|
518
|
+
text: docBlock.slice(0, MAX_SUMMARY_CHARS),
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
else if (summary.trim().length > 0) {
|
|
522
|
+
context.push({
|
|
523
|
+
kind: "purpose",
|
|
524
|
+
text: summary.slice(0, MAX_SUMMARY_CHARS),
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
const matchedTerms = terms.filter((term) => code.toLowerCase().includes(term));
|
|
528
|
+
if (matchedTerms.length > 0) {
|
|
529
|
+
context.push({
|
|
530
|
+
kind: "query-match",
|
|
531
|
+
text: `Matches query terms: ${matchedTerms.slice(0, 4).join(", ")}.`,
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
else if (relevanceExplanation.trim().length > 0) {
|
|
535
|
+
context.push({
|
|
536
|
+
kind: "query-match",
|
|
537
|
+
text: relevanceExplanation.slice(0, MAX_SUMMARY_CHARS),
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
if (keySymbols.length > 0) {
|
|
541
|
+
context.push({
|
|
542
|
+
kind: "dependency",
|
|
543
|
+
text: `Defines exported symbols: ${keySymbols.slice(0, 4).join(", ")}.`,
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
return context.slice(0, 3);
|
|
547
|
+
}
|
|
548
|
+
function buildRelevanceExplanation(docBlock, matchedTerms, keySymbols, excerpts, role) {
|
|
549
|
+
const reasons = [];
|
|
550
|
+
if (docBlock) {
|
|
551
|
+
reasons.push(`The top file comment describes ${docBlock.slice(0, 90)}.`);
|
|
552
|
+
}
|
|
553
|
+
if (matchedTerms.length > 0) {
|
|
554
|
+
reasons.push(`It directly matches query terms: ${matchedTerms.slice(0, 4).join(", ")}.`);
|
|
555
|
+
}
|
|
556
|
+
if (keySymbols.length > 0) {
|
|
557
|
+
reasons.push(`It exports relevant symbols: ${keySymbols.slice(0, 4).join(", ")}.`);
|
|
558
|
+
}
|
|
559
|
+
if (excerpts.length > 0) {
|
|
560
|
+
const excerpt = excerpts[0];
|
|
561
|
+
const span = excerpt.startLine && excerpt.endLine
|
|
562
|
+
? `lines ${excerpt.startLine}-${excerpt.endLine}`
|
|
563
|
+
: "the extracted block";
|
|
564
|
+
reasons.push(`The strongest grounded block is in ${span}.`);
|
|
565
|
+
}
|
|
566
|
+
if (reasons.length === 0) {
|
|
567
|
+
reasons.push(`This file looks ${role ?? "contextual"} to the query from its visible declarations and path shape.`);
|
|
568
|
+
}
|
|
569
|
+
return reasons.join(" ");
|
|
570
|
+
}
|
|
571
|
+
function collectCommandFacts(excerpts) {
|
|
572
|
+
const facts = new Set();
|
|
573
|
+
for (const excerpt of excerpts) {
|
|
574
|
+
const code = String(excerpt.code ?? "");
|
|
575
|
+
const commandPattern = /\.command\(\s*["'`]([^"'`]+)["'`]\s*\)(?:[\s\S]{0,240}?)\.description\(\s*["'`]([^"'`]+)["'`]\s*\)/g;
|
|
576
|
+
let describedMatch;
|
|
577
|
+
while ((describedMatch = commandPattern.exec(code)) !== null) {
|
|
578
|
+
facts.add(`CLI command: ${describedMatch[1]}`);
|
|
579
|
+
facts.add(`The CLI registers "${describedMatch[1]}" to ${describedMatch[2].replace(/\.$/, "").toLowerCase()}.`);
|
|
580
|
+
}
|
|
581
|
+
const bareCommandPattern = /\.command\(\s*["'`]([^"'`]+)["'`]\s*\)/g;
|
|
582
|
+
let bareMatch;
|
|
583
|
+
while ((bareMatch = bareCommandPattern.exec(code)) !== null) {
|
|
584
|
+
facts.add(`CLI command: ${bareMatch[1]}`);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
return Array.from(facts).slice(0, 6);
|
|
588
|
+
}
|
|
589
|
+
function collectExactTargetPhrases(code, explicitTargets) {
|
|
590
|
+
const phrases = [];
|
|
591
|
+
for (const target of explicitTargets) {
|
|
592
|
+
const trimmed = String(target ?? "").trim();
|
|
593
|
+
if (!trimmed) {
|
|
594
|
+
continue;
|
|
595
|
+
}
|
|
596
|
+
const match = code.match(new RegExp(escapeRegex(trimmed), "i"));
|
|
597
|
+
if (match?.[0]) {
|
|
598
|
+
phrases.push(match[0]);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
return uniqueStrings(phrases).slice(0, 6);
|
|
602
|
+
}
|
|
603
|
+
function pickStrongestConceptExcerpt(excerpts) {
|
|
604
|
+
return excerpts.find((excerpt) => isConceptExcerpt(excerpt));
|
|
605
|
+
}
|
|
606
|
+
function pickStrongestImplementationExcerpt(excerpts) {
|
|
607
|
+
return excerpts.find((excerpt) => isImplementationExcerpt(excerpt));
|
|
608
|
+
}
|
|
609
|
+
function buildStrengthSignals(code, explicitTargets, excerpts) {
|
|
610
|
+
const strongestConceptExcerpt = pickStrongestConceptExcerpt(excerpts);
|
|
611
|
+
const strongestImplementationExcerpt = pickStrongestImplementationExcerpt(excerpts);
|
|
612
|
+
const implementationSymbols = uniqueStrings([
|
|
613
|
+
...(strongestImplementationExcerpt?.symbols ?? []),
|
|
614
|
+
...extractLocalDeclarationNames(code),
|
|
615
|
+
]).slice(0, 8);
|
|
616
|
+
return {
|
|
617
|
+
exactTargetPhrases: collectExactTargetPhrases(code, explicitTargets),
|
|
618
|
+
implementationSymbols,
|
|
619
|
+
directAnswerFacts: collectCommandFacts(excerpts),
|
|
620
|
+
...(strongestConceptExcerpt ? {
|
|
621
|
+
strongestConceptExcerpt: {
|
|
622
|
+
description: strongestConceptExcerpt.description,
|
|
623
|
+
startLine: strongestConceptExcerpt.startLine,
|
|
624
|
+
endLine: strongestConceptExcerpt.endLine,
|
|
625
|
+
symbols: strongestConceptExcerpt.symbols,
|
|
626
|
+
},
|
|
627
|
+
} : {}),
|
|
628
|
+
...(strongestImplementationExcerpt ? {
|
|
629
|
+
strongestImplementationExcerpt: {
|
|
630
|
+
description: strongestImplementationExcerpt.description,
|
|
631
|
+
startLine: strongestImplementationExcerpt.startLine,
|
|
632
|
+
endLine: strongestImplementationExcerpt.endLine,
|
|
633
|
+
symbols: strongestImplementationExcerpt.symbols,
|
|
634
|
+
},
|
|
635
|
+
} : {}),
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
function buildRisks(matchedTerms, excerpts, readMode) {
|
|
639
|
+
const risks = [];
|
|
640
|
+
if (matchedTerms.length === 0) {
|
|
641
|
+
risks.push("No direct query-term matches; relevance was inferred from declarations or nearby context.");
|
|
642
|
+
}
|
|
643
|
+
if (excerpts.length === 0) {
|
|
644
|
+
risks.push("No stable block excerpt was found; grounding relies on lighter line-level evidence.");
|
|
645
|
+
}
|
|
646
|
+
if (readMode === "triage") {
|
|
647
|
+
risks.push("This is a deterministic triage read, not a full model-backed file analysis.");
|
|
648
|
+
}
|
|
649
|
+
return risks.slice(0, 3);
|
|
650
|
+
}
|
|
651
|
+
function computeTriageScore(matchedTerms, keySymbols, excerpts, hardTarget) {
|
|
652
|
+
const raw = (hardTarget ? 0.35 : 0) + matchedTerms.length * 0.14 + keySymbols.length * 0.05 + excerpts.length * 0.18;
|
|
653
|
+
return clamp(Number(raw.toFixed(2)), 0, 1);
|
|
654
|
+
}
|
|
655
|
+
function buildDeterministicReadEvidence(filePath, code, query, options = {}) {
|
|
656
|
+
const readMode = options.readMode ?? "full";
|
|
657
|
+
const hardTarget = options.hardTarget === true;
|
|
658
|
+
const lines = code.split("\n");
|
|
659
|
+
const terms = extractQueryTerms(query);
|
|
660
|
+
const docBlock = extractTopCommentBlock(code);
|
|
661
|
+
const keySymbols = extractExportNames(code);
|
|
662
|
+
const groundingDepth = classifyGroundingDepth(code);
|
|
663
|
+
const snippets = pickGroundingSnippets(lines, query, keySymbols, groundingDepth);
|
|
664
|
+
const excerpts = buildBlockExcerpts(code, query, keySymbols);
|
|
665
|
+
const strengthSignals = buildStrengthSignals(code, options.explicitTargets ?? [], excerpts);
|
|
666
|
+
const summarySource = excerpts[0]?.description ?? docBlock ?? snippets[0] ?? firstNonEmptyLine(lines);
|
|
667
|
+
const matchedTerms = terms.filter((term) => code.toLowerCase().includes(term));
|
|
668
|
+
const role = determineRole(hardTarget, excerpts, matchedTerms, keySymbols);
|
|
669
|
+
const relevanceExplanation = buildRelevanceExplanation(docBlock, matchedTerms, keySymbols, excerpts, role);
|
|
670
|
+
const relevantContext = buildRelevantContext(code, query, summarySource, keySymbols, relevanceExplanation);
|
|
671
|
+
const triageScore = computeTriageScore(matchedTerms, keySymbols, excerpts, hardTarget);
|
|
672
|
+
const risks = buildRisks(matchedTerms, excerpts, readMode);
|
|
673
|
+
return {
|
|
674
|
+
filePath,
|
|
675
|
+
readMode,
|
|
676
|
+
summary: summarySource.slice(0, MAX_SUMMARY_CHARS),
|
|
677
|
+
snippets,
|
|
678
|
+
keySymbols,
|
|
679
|
+
matchedTerms,
|
|
680
|
+
relevanceExplanation,
|
|
681
|
+
role,
|
|
682
|
+
excerpts,
|
|
683
|
+
strengthSignals,
|
|
684
|
+
risks,
|
|
685
|
+
triageScore,
|
|
686
|
+
relevantContext,
|
|
687
|
+
contentFingerprint: computeContentFingerprint(code),
|
|
688
|
+
queryFingerprint: computeQueryFingerprint(query),
|
|
689
|
+
recordedAt: nowIso(),
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Selects a compact, code-shaped prompt slice for full reads.
|
|
694
|
+
* Example: keep the top docblock plus the strongest command/config/function blocks.
|
|
695
|
+
*/
|
|
696
|
+
export function selectCodeForFullReadPrompt(code, query, maxChars) {
|
|
697
|
+
if (code.length <= maxChars) {
|
|
698
|
+
return code;
|
|
699
|
+
}
|
|
700
|
+
const keySymbols = extractExportNames(code);
|
|
701
|
+
const docBlockMatch = code.match(/^\s*\/\*\*[\s\S]*?\*\//)?.[0]?.trim();
|
|
702
|
+
const excerpts = buildBlockExcerpts(code, query, keySymbols).slice(0, MAX_FULL_READ_BLOCKS);
|
|
703
|
+
const parts = [];
|
|
704
|
+
if (docBlockMatch && docBlockMatch.length <= Math.floor(maxChars * 0.3)) {
|
|
705
|
+
parts.push(docBlockMatch);
|
|
706
|
+
}
|
|
707
|
+
for (const excerpt of excerpts) {
|
|
708
|
+
const block = `// ${excerpt.description}\n${excerpt.code.trim()}`;
|
|
709
|
+
if (parts.join("\n\n").length + block.length > maxChars) {
|
|
710
|
+
break;
|
|
711
|
+
}
|
|
712
|
+
parts.push(block);
|
|
713
|
+
}
|
|
714
|
+
const selected = parts.join("\n\n").trim();
|
|
715
|
+
if (selected.length > 0) {
|
|
716
|
+
return selected.length <= maxChars
|
|
717
|
+
? selected
|
|
718
|
+
: `${selected.slice(0, maxChars - 40)}\n/* … file truncated for agent full read … */`;
|
|
719
|
+
}
|
|
720
|
+
const head = code.slice(0, Math.floor(maxChars * 0.6));
|
|
721
|
+
const tail = code.slice(-Math.floor(maxChars * 0.4));
|
|
722
|
+
return [head, "\n/* … file truncated for agent full read … */\n", tail].join("");
|
|
723
|
+
}
|
|
724
|
+
export function summarizeFileRead(filePath, code, query, options = {}) {
|
|
725
|
+
return buildDeterministicReadEvidence(filePath, code, query, options);
|
|
726
|
+
}
|
|
727
|
+
export function buildDeterministicFullReadFallback(filePath, code, query, options = {}) {
|
|
728
|
+
return buildDeterministicReadEvidence(filePath, code, query, {
|
|
729
|
+
...options,
|
|
730
|
+
readMode: "full",
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
//# sourceMappingURL=summarizeReadEvidence.js.map
|