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,1662 @@
|
|
|
1
|
+
// Verifies the typed next-action bridge normalizes selector output and can trigger initial search/verify/research/plan seeding.
|
|
2
|
+
// Pass example: missing bootstrap evidence becomes run-search before deeper loop work.
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
import { buildAllowedNextActions, buildNextActionInput, decideNextAction, validateNextActionDecision, } from "../../agents/decideNextAction.js";
|
|
5
|
+
describe("decideNextAction", () => {
|
|
6
|
+
it("returns complete when the selector marks the task complete", async () => {
|
|
7
|
+
const context = {
|
|
8
|
+
task: {
|
|
9
|
+
id: 1,
|
|
10
|
+
projectId: 1,
|
|
11
|
+
status: "active",
|
|
12
|
+
initialQuery: "Explain MainAgent.ts",
|
|
13
|
+
createdAt: "now",
|
|
14
|
+
updatedAt: "now",
|
|
15
|
+
currentStep: { taskId: 1, filePath: "/repo/MainAgent.ts", status: "pending" },
|
|
16
|
+
steps: [
|
|
17
|
+
{ taskId: 1, filePath: "__research__/impact-map", status: "completed", action: "research-impact-map" },
|
|
18
|
+
{ taskId: 1, filePath: "/repo/MainAgent.ts", status: "pending", action: "work" },
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
initContext: {
|
|
22
|
+
userQuery: "Explain MainAgent.ts",
|
|
23
|
+
relatedFiles: ["/repo/MainAgent.ts"],
|
|
24
|
+
},
|
|
25
|
+
analysis: {
|
|
26
|
+
runtimeState: {
|
|
27
|
+
phase: "execute",
|
|
28
|
+
lane: "explicit-target",
|
|
29
|
+
status: "active",
|
|
30
|
+
},
|
|
31
|
+
readiness: {
|
|
32
|
+
decision: "ready",
|
|
33
|
+
confidence: 0.95,
|
|
34
|
+
},
|
|
35
|
+
executionPolicy: {
|
|
36
|
+
phaseAllowed: { analysis: true, planning: true, transform: false, write: false },
|
|
37
|
+
routeAllowed: { searchExpand: false, research: true, transform: false },
|
|
38
|
+
scopeType: "single-file",
|
|
39
|
+
scopeBand: "single-file",
|
|
40
|
+
executionRequired: ["/repo/MainAgent.ts"],
|
|
41
|
+
explorationCandidates: [],
|
|
42
|
+
executionLock: { enabled: false, files: [] },
|
|
43
|
+
executionReady: true,
|
|
44
|
+
explorationReady: false,
|
|
45
|
+
policyNotes: [],
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
const decision = await decideNextAction(context, {
|
|
50
|
+
runSelection: async (ctx) => {
|
|
51
|
+
ctx.analysis || (ctx.analysis = {});
|
|
52
|
+
ctx.analysis.iterationReasoning = {
|
|
53
|
+
summary: "done",
|
|
54
|
+
nextAction: "complete",
|
|
55
|
+
rationale: "Objective satisfied.",
|
|
56
|
+
confidence: 0.99,
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
expect(decision.action).toBe("complete");
|
|
61
|
+
expect(decision.reason).toBe("Objective satisfied.");
|
|
62
|
+
expect(context.analysis.nextActionDecision).toEqual(decision);
|
|
63
|
+
expect(context.analysis.nextActionValidation).toEqual({
|
|
64
|
+
accepted: true,
|
|
65
|
+
normalizedAction: "complete",
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
it("normalizes invalid selector actions to continue", async () => {
|
|
69
|
+
const context = {
|
|
70
|
+
task: {
|
|
71
|
+
id: 1,
|
|
72
|
+
projectId: 1,
|
|
73
|
+
status: "active",
|
|
74
|
+
initialQuery: "Explain MainAgent.ts",
|
|
75
|
+
createdAt: "now",
|
|
76
|
+
updatedAt: "now",
|
|
77
|
+
currentStep: { taskId: 1, filePath: "/repo/MainAgent.ts", status: "pending" },
|
|
78
|
+
steps: [
|
|
79
|
+
{ taskId: 1, filePath: "__research__/impact-map", status: "completed", action: "research-impact-map" },
|
|
80
|
+
{ taskId: 1, filePath: "/repo/MainAgent.ts", status: "pending", action: "work" },
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
initContext: {
|
|
84
|
+
userQuery: "Explain MainAgent.ts",
|
|
85
|
+
relatedFiles: ["/repo/MainAgent.ts"],
|
|
86
|
+
},
|
|
87
|
+
analysis: {
|
|
88
|
+
runtimeState: {
|
|
89
|
+
phase: "execute",
|
|
90
|
+
lane: "coding",
|
|
91
|
+
status: "active",
|
|
92
|
+
},
|
|
93
|
+
readiness: {
|
|
94
|
+
decision: "ready",
|
|
95
|
+
confidence: 0.95,
|
|
96
|
+
},
|
|
97
|
+
executionPolicy: {
|
|
98
|
+
phaseAllowed: { analysis: true, planning: true, transform: true, write: true },
|
|
99
|
+
routeAllowed: { searchExpand: false, research: true, transform: true },
|
|
100
|
+
scopeType: "single-file",
|
|
101
|
+
scopeBand: "single-file",
|
|
102
|
+
executionRequired: ["/repo/MainAgent.ts"],
|
|
103
|
+
explorationCandidates: [],
|
|
104
|
+
executionLock: { enabled: false, files: [] },
|
|
105
|
+
executionReady: true,
|
|
106
|
+
explorationReady: false,
|
|
107
|
+
policyNotes: [],
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
const decision = await decideNextAction(context, {
|
|
112
|
+
runSelection: async (ctx) => {
|
|
113
|
+
ctx.analysis || (ctx.analysis = {});
|
|
114
|
+
ctx.analysis.iterationReasoning = {
|
|
115
|
+
summary: "bad",
|
|
116
|
+
nextAction: "redo-step",
|
|
117
|
+
rationale: "Validation wants a redo.",
|
|
118
|
+
confidence: 0.6,
|
|
119
|
+
};
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
expect(decision.action).toBe("continue");
|
|
123
|
+
expect(decision.reason).toBe("Validation wants a redo.");
|
|
124
|
+
expect(context.analysis.nextActionValidation).toEqual({
|
|
125
|
+
accepted: false,
|
|
126
|
+
normalizedAction: "continue",
|
|
127
|
+
rejectionReason: "Unsupported next action: redo-step",
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
it("returns run-search when initial search is still needed", async () => {
|
|
131
|
+
const context = {
|
|
132
|
+
task: {
|
|
133
|
+
id: 1,
|
|
134
|
+
projectId: 1,
|
|
135
|
+
status: "active",
|
|
136
|
+
initialQuery: "Refactor MainAgent.ts",
|
|
137
|
+
createdAt: "now",
|
|
138
|
+
updatedAt: "now",
|
|
139
|
+
steps: [],
|
|
140
|
+
},
|
|
141
|
+
analysis: {
|
|
142
|
+
runtimeState: {
|
|
143
|
+
phase: "execute",
|
|
144
|
+
lane: "coding",
|
|
145
|
+
status: "active",
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
const decision = await decideNextAction(context, {
|
|
150
|
+
runSelection: async (ctx) => {
|
|
151
|
+
ctx.analysis || (ctx.analysis = {});
|
|
152
|
+
ctx.analysis.iterationReasoning = {
|
|
153
|
+
summary: "continue",
|
|
154
|
+
nextAction: "continue",
|
|
155
|
+
rationale: "Need the initial bootstrap search first.",
|
|
156
|
+
confidence: 0.7,
|
|
157
|
+
};
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
expect(decision).toEqual({
|
|
161
|
+
action: "run-search",
|
|
162
|
+
reason: "Initial evidence bootstrap has not run yet; run search before verify or execution seeding.",
|
|
163
|
+
confidence: 0.93,
|
|
164
|
+
source: "reason-next-step-selection",
|
|
165
|
+
});
|
|
166
|
+
expect(buildAllowedNextActions(context)).toEqual(["run-search"]);
|
|
167
|
+
});
|
|
168
|
+
it("suppresses repeated empty search and advances to verify instead", () => {
|
|
169
|
+
const context = {
|
|
170
|
+
task: {
|
|
171
|
+
id: 1,
|
|
172
|
+
projectId: 1,
|
|
173
|
+
status: "active",
|
|
174
|
+
initialQuery: "summarize architecture",
|
|
175
|
+
createdAt: "now",
|
|
176
|
+
updatedAt: "now",
|
|
177
|
+
steps: [],
|
|
178
|
+
},
|
|
179
|
+
initContext: {
|
|
180
|
+
userQuery: "summarize architecture",
|
|
181
|
+
},
|
|
182
|
+
analysis: {
|
|
183
|
+
recentActionWindow: {
|
|
184
|
+
entries: [{
|
|
185
|
+
taskId: 1,
|
|
186
|
+
actionKind: "search-db",
|
|
187
|
+
target: "summarize architecture",
|
|
188
|
+
reason: "Initial search",
|
|
189
|
+
outcome: "empty",
|
|
190
|
+
summary: "Search found nothing useful.",
|
|
191
|
+
touchedFiles: [],
|
|
192
|
+
createdAt: "now",
|
|
193
|
+
}],
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
expect(buildAllowedNextActions(context)).toEqual(["run-verify"]);
|
|
198
|
+
});
|
|
199
|
+
it("forces rework-scope only when recovery evaluation explicitly requests it", async () => {
|
|
200
|
+
const targetFile = "/repo/README.md";
|
|
201
|
+
const context = {
|
|
202
|
+
task: {
|
|
203
|
+
id: 1,
|
|
204
|
+
projectId: 1,
|
|
205
|
+
status: "active",
|
|
206
|
+
initialQuery: "Refactor MainAgent.ts",
|
|
207
|
+
createdAt: "now",
|
|
208
|
+
updatedAt: "now",
|
|
209
|
+
currentStep: { taskId: 1, filePath: targetFile, status: "pending" },
|
|
210
|
+
steps: [],
|
|
211
|
+
},
|
|
212
|
+
analysis: {
|
|
213
|
+
recoveryEvaluation: {
|
|
214
|
+
decision: "rework-scope",
|
|
215
|
+
reason: "Quick read shows the target is wrong.",
|
|
216
|
+
targetFile,
|
|
217
|
+
evaluatedAt: "now",
|
|
218
|
+
sourceAction: "read-file",
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
const decision = await decideNextAction(context, {
|
|
223
|
+
runSelection: async (ctx) => {
|
|
224
|
+
ctx.analysis || (ctx.analysis = {});
|
|
225
|
+
ctx.analysis.iterationReasoning = {
|
|
226
|
+
summary: "continue",
|
|
227
|
+
nextAction: "continue",
|
|
228
|
+
rationale: "Keep going.",
|
|
229
|
+
confidence: 0.3,
|
|
230
|
+
};
|
|
231
|
+
},
|
|
232
|
+
});
|
|
233
|
+
expect(buildAllowedNextActions(context)).toEqual(["rework-scope"]);
|
|
234
|
+
expect(decision.action).toBe("rework-scope");
|
|
235
|
+
expect(decision.reason).toContain("wrong");
|
|
236
|
+
});
|
|
237
|
+
it("includes recent action history in next-action input", () => {
|
|
238
|
+
const context = {
|
|
239
|
+
task: {
|
|
240
|
+
id: 1,
|
|
241
|
+
projectId: 1,
|
|
242
|
+
status: "active",
|
|
243
|
+
initialQuery: "Explain MainAgent.ts",
|
|
244
|
+
createdAt: "now",
|
|
245
|
+
updatedAt: "now",
|
|
246
|
+
steps: [],
|
|
247
|
+
},
|
|
248
|
+
analysis: {
|
|
249
|
+
recentActionWindow: {
|
|
250
|
+
entries: [{
|
|
251
|
+
taskId: 1,
|
|
252
|
+
actionKind: "semanticAnalysis",
|
|
253
|
+
target: "/repo/MainAgent.ts",
|
|
254
|
+
reason: "Inspect current file",
|
|
255
|
+
outcome: "success",
|
|
256
|
+
summary: "Semantic analysis completed.",
|
|
257
|
+
touchedFiles: ["/repo/MainAgent.ts"],
|
|
258
|
+
createdAt: "now",
|
|
259
|
+
}],
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
expect(buildNextActionInput(context).recentActionWindow?.entries).toHaveLength(1);
|
|
264
|
+
});
|
|
265
|
+
it("uses guardState as the authoritative source for forced bridge actions", () => {
|
|
266
|
+
const context = {
|
|
267
|
+
task: {
|
|
268
|
+
id: 1,
|
|
269
|
+
projectId: 1,
|
|
270
|
+
status: "active",
|
|
271
|
+
initialQuery: "summarize architecture",
|
|
272
|
+
createdAt: "now",
|
|
273
|
+
updatedAt: "now",
|
|
274
|
+
steps: [],
|
|
275
|
+
},
|
|
276
|
+
analysis: {
|
|
277
|
+
guardState: {
|
|
278
|
+
lane: "evidence",
|
|
279
|
+
readiness: "ready",
|
|
280
|
+
continuationMode: "can-research",
|
|
281
|
+
allowSearchExpand: true,
|
|
282
|
+
allowResearch: true,
|
|
283
|
+
allowTransform: false,
|
|
284
|
+
executionReady: false,
|
|
285
|
+
executionLockEnabled: false,
|
|
286
|
+
executionRequired: [],
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
expect(buildAllowedNextActions(context)).toEqual(["seed-research"]);
|
|
291
|
+
expect(buildNextActionInput(context).guardState?.continuationMode).toBe("can-research");
|
|
292
|
+
});
|
|
293
|
+
it("keeps forced run-search when the selector tries to complete with no scoped files", async () => {
|
|
294
|
+
const context = {
|
|
295
|
+
task: {
|
|
296
|
+
id: 1,
|
|
297
|
+
projectId: 1,
|
|
298
|
+
status: "active",
|
|
299
|
+
initialQuery: "summarize this repo architecture and identify weak coupling points",
|
|
300
|
+
createdAt: "now",
|
|
301
|
+
updatedAt: "now",
|
|
302
|
+
steps: [],
|
|
303
|
+
},
|
|
304
|
+
initContext: {
|
|
305
|
+
userQuery: "summarize this repo architecture and identify weak coupling points",
|
|
306
|
+
relatedFiles: [],
|
|
307
|
+
},
|
|
308
|
+
analysis: {
|
|
309
|
+
guardState: {
|
|
310
|
+
lane: "evidence",
|
|
311
|
+
readiness: "ready",
|
|
312
|
+
continuationMode: "need-search",
|
|
313
|
+
allowSearchExpand: true,
|
|
314
|
+
allowResearch: true,
|
|
315
|
+
allowTransform: false,
|
|
316
|
+
executionReady: false,
|
|
317
|
+
executionLockEnabled: false,
|
|
318
|
+
executionRequired: [],
|
|
319
|
+
},
|
|
320
|
+
runtimeState: {
|
|
321
|
+
phase: "execute",
|
|
322
|
+
lane: "evidence",
|
|
323
|
+
status: "active",
|
|
324
|
+
},
|
|
325
|
+
scopeType: "repo-wide",
|
|
326
|
+
focus: {
|
|
327
|
+
selectedFiles: [],
|
|
328
|
+
candidateFiles: [],
|
|
329
|
+
executionRequired: [],
|
|
330
|
+
explorationCandidates: [],
|
|
331
|
+
},
|
|
332
|
+
routingDecision: {
|
|
333
|
+
decision: "needs-info",
|
|
334
|
+
allowSearch: true,
|
|
335
|
+
allowResearch: true,
|
|
336
|
+
allowTransform: false,
|
|
337
|
+
scopeLocked: false,
|
|
338
|
+
confidence: 0.88,
|
|
339
|
+
rationale: "repo-wide needs info",
|
|
340
|
+
},
|
|
341
|
+
executionPolicy: {
|
|
342
|
+
phaseAllowed: { analysis: true, planning: true, transform: false, write: false },
|
|
343
|
+
routeAllowed: { searchExpand: true, research: true, transform: false },
|
|
344
|
+
scopeType: "repo-wide",
|
|
345
|
+
scopeBand: "repo-wide",
|
|
346
|
+
executionRequired: [],
|
|
347
|
+
explorationCandidates: [],
|
|
348
|
+
executionLock: { enabled: false, files: [], reason: "transform-blocked-by-guards" },
|
|
349
|
+
executionReady: false,
|
|
350
|
+
explorationReady: false,
|
|
351
|
+
policyNotes: [],
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
workingFiles: [],
|
|
355
|
+
};
|
|
356
|
+
const decision = await decideNextAction(context);
|
|
357
|
+
expect(buildAllowedNextActions(context)).toEqual(["run-search"]);
|
|
358
|
+
expect(decision).toEqual({
|
|
359
|
+
action: "run-search",
|
|
360
|
+
reason: "Initial evidence bootstrap has not run yet; run search before verify or execution seeding.",
|
|
361
|
+
confidence: 0.93,
|
|
362
|
+
source: "reason-next-step-selection",
|
|
363
|
+
});
|
|
364
|
+
expect(context.analysis.nextActionValidation).toEqual({
|
|
365
|
+
accepted: true,
|
|
366
|
+
normalizedAction: "run-search",
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
it("keeps forced run-search when the selector tries to expand scope", async () => {
|
|
370
|
+
const context = {
|
|
371
|
+
task: {
|
|
372
|
+
id: 1,
|
|
373
|
+
projectId: 1,
|
|
374
|
+
status: "active",
|
|
375
|
+
initialQuery: "Refactor MainAgent.ts",
|
|
376
|
+
createdAt: "now",
|
|
377
|
+
updatedAt: "now",
|
|
378
|
+
steps: [],
|
|
379
|
+
},
|
|
380
|
+
analysis: {
|
|
381
|
+
runtimeState: {
|
|
382
|
+
phase: "execute",
|
|
383
|
+
lane: "coding",
|
|
384
|
+
status: "active",
|
|
385
|
+
},
|
|
386
|
+
},
|
|
387
|
+
};
|
|
388
|
+
const decision = await decideNextAction(context, {
|
|
389
|
+
runSelection: async (ctx) => {
|
|
390
|
+
ctx.analysis || (ctx.analysis = {});
|
|
391
|
+
ctx.analysis.iterationReasoning = {
|
|
392
|
+
summary: "expand",
|
|
393
|
+
nextAction: "expand-scope",
|
|
394
|
+
rationale: "Try broader exploration first.",
|
|
395
|
+
confidence: 0.8,
|
|
396
|
+
};
|
|
397
|
+
},
|
|
398
|
+
});
|
|
399
|
+
expect(decision.action).toBe("run-search");
|
|
400
|
+
expect(context.analysis.nextActionValidation).toEqual({
|
|
401
|
+
accepted: true,
|
|
402
|
+
normalizedAction: "run-search",
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
it("returns run-verify when execution is not ready yet", async () => {
|
|
406
|
+
const context = {
|
|
407
|
+
task: {
|
|
408
|
+
id: 1,
|
|
409
|
+
projectId: 1,
|
|
410
|
+
status: "active",
|
|
411
|
+
initialQuery: "Refactor MainAgent.ts",
|
|
412
|
+
createdAt: "now",
|
|
413
|
+
updatedAt: "now",
|
|
414
|
+
steps: [],
|
|
415
|
+
},
|
|
416
|
+
initContext: {
|
|
417
|
+
userQuery: "Refactor MainAgent.ts",
|
|
418
|
+
relatedFiles: ["/repo/a.ts"],
|
|
419
|
+
},
|
|
420
|
+
analysis: {
|
|
421
|
+
runtimeState: {
|
|
422
|
+
phase: "execute",
|
|
423
|
+
lane: "coding",
|
|
424
|
+
status: "active",
|
|
425
|
+
},
|
|
426
|
+
readiness: {
|
|
427
|
+
decision: "not-ready",
|
|
428
|
+
confidence: 0.45,
|
|
429
|
+
},
|
|
430
|
+
executionPolicy: {
|
|
431
|
+
phaseAllowed: { analysis: true, planning: true, transform: true, write: true },
|
|
432
|
+
routeAllowed: { searchExpand: false, research: true, transform: true },
|
|
433
|
+
scopeType: "single-file",
|
|
434
|
+
scopeBand: "single-file",
|
|
435
|
+
executionRequired: ["/repo/a.ts"],
|
|
436
|
+
explorationCandidates: [],
|
|
437
|
+
executionLock: { enabled: false, files: [] },
|
|
438
|
+
executionReady: false,
|
|
439
|
+
explorationReady: false,
|
|
440
|
+
policyNotes: [],
|
|
441
|
+
},
|
|
442
|
+
},
|
|
443
|
+
};
|
|
444
|
+
const decision = await decideNextAction(context, {
|
|
445
|
+
runSelection: async (ctx) => {
|
|
446
|
+
ctx.analysis || (ctx.analysis = {});
|
|
447
|
+
ctx.analysis.iterationReasoning = {
|
|
448
|
+
summary: "continue",
|
|
449
|
+
nextAction: "continue",
|
|
450
|
+
rationale: "Need stronger evidence first.",
|
|
451
|
+
confidence: 0.7,
|
|
452
|
+
};
|
|
453
|
+
},
|
|
454
|
+
});
|
|
455
|
+
expect(decision).toEqual({
|
|
456
|
+
action: "run-verify",
|
|
457
|
+
reason: "Execution is not ready yet; run verify before seeding research or execution work.",
|
|
458
|
+
confidence: 0.92,
|
|
459
|
+
source: "reason-next-step-selection",
|
|
460
|
+
});
|
|
461
|
+
expect(buildAllowedNextActions(context)).toEqual(["run-verify"]);
|
|
462
|
+
});
|
|
463
|
+
it("does not return run-verify when readiness is ready and research is still allowed", async () => {
|
|
464
|
+
const context = {
|
|
465
|
+
task: {
|
|
466
|
+
id: 1,
|
|
467
|
+
projectId: 1,
|
|
468
|
+
status: "active",
|
|
469
|
+
initialQuery: "summarize this repo architecture and identify weak coupling points",
|
|
470
|
+
createdAt: "now",
|
|
471
|
+
updatedAt: "now",
|
|
472
|
+
steps: [],
|
|
473
|
+
},
|
|
474
|
+
initContext: {
|
|
475
|
+
userQuery: "summarize this repo architecture and identify weak coupling points",
|
|
476
|
+
relatedFiles: ["/repo/README.md"],
|
|
477
|
+
},
|
|
478
|
+
analysis: {
|
|
479
|
+
scopeType: "repo-wide",
|
|
480
|
+
runtimeState: {
|
|
481
|
+
phase: "execute",
|
|
482
|
+
lane: "evidence",
|
|
483
|
+
status: "active",
|
|
484
|
+
},
|
|
485
|
+
readiness: {
|
|
486
|
+
decision: "ready",
|
|
487
|
+
confidence: 0.95,
|
|
488
|
+
},
|
|
489
|
+
executionPolicy: {
|
|
490
|
+
phaseAllowed: { analysis: true, planning: true, transform: false, write: false },
|
|
491
|
+
routeAllowed: { searchExpand: true, research: true, transform: false },
|
|
492
|
+
scopeType: "repo-wide",
|
|
493
|
+
scopeBand: "single-file",
|
|
494
|
+
executionRequired: ["/repo/README.md"],
|
|
495
|
+
explorationCandidates: ["/repo/AGENTS.md"],
|
|
496
|
+
executionLock: { enabled: false, files: [], reason: "transform-blocked-by-guards" },
|
|
497
|
+
executionReady: false,
|
|
498
|
+
explorationReady: true,
|
|
499
|
+
policyNotes: [],
|
|
500
|
+
},
|
|
501
|
+
},
|
|
502
|
+
};
|
|
503
|
+
const decision = await decideNextAction(context, {
|
|
504
|
+
runSelection: async (ctx) => {
|
|
505
|
+
ctx.analysis || (ctx.analysis = {});
|
|
506
|
+
ctx.analysis.iterationReasoning = {
|
|
507
|
+
summary: "continue",
|
|
508
|
+
nextAction: "continue",
|
|
509
|
+
rationale: "Research should run next.",
|
|
510
|
+
confidence: 0.8,
|
|
511
|
+
};
|
|
512
|
+
},
|
|
513
|
+
});
|
|
514
|
+
expect(buildAllowedNextActions(context)).toEqual(["seed-research"]);
|
|
515
|
+
expect(decision.action).toBe("seed-research");
|
|
516
|
+
});
|
|
517
|
+
it("does not return run-verify when readiness is ready and transform is disallowed", async () => {
|
|
518
|
+
const context = {
|
|
519
|
+
task: {
|
|
520
|
+
id: 1,
|
|
521
|
+
projectId: 1,
|
|
522
|
+
status: "active",
|
|
523
|
+
initialQuery: "Explain architecture",
|
|
524
|
+
createdAt: "now",
|
|
525
|
+
updatedAt: "now",
|
|
526
|
+
steps: [
|
|
527
|
+
{ taskId: 1, filePath: "__research__/impact-map", status: "pending", action: "research-impact-map" },
|
|
528
|
+
],
|
|
529
|
+
},
|
|
530
|
+
initContext: {
|
|
531
|
+
userQuery: "Explain architecture",
|
|
532
|
+
relatedFiles: ["/repo/README.md"],
|
|
533
|
+
},
|
|
534
|
+
analysis: {
|
|
535
|
+
scopeType: "repo-wide",
|
|
536
|
+
runtimeState: {
|
|
537
|
+
phase: "execute",
|
|
538
|
+
lane: "evidence",
|
|
539
|
+
status: "active",
|
|
540
|
+
},
|
|
541
|
+
readiness: {
|
|
542
|
+
decision: "ready",
|
|
543
|
+
confidence: 0.95,
|
|
544
|
+
},
|
|
545
|
+
executionPolicy: {
|
|
546
|
+
phaseAllowed: { analysis: true, planning: true, transform: false, write: false },
|
|
547
|
+
routeAllowed: { searchExpand: true, research: false, transform: false },
|
|
548
|
+
scopeType: "repo-wide",
|
|
549
|
+
scopeBand: "single-file",
|
|
550
|
+
executionRequired: ["/repo/README.md"],
|
|
551
|
+
explorationCandidates: [],
|
|
552
|
+
executionLock: { enabled: false, files: [], reason: "transform-blocked-by-guards" },
|
|
553
|
+
executionReady: false,
|
|
554
|
+
explorationReady: false,
|
|
555
|
+
policyNotes: [],
|
|
556
|
+
},
|
|
557
|
+
},
|
|
558
|
+
};
|
|
559
|
+
expect(buildAllowedNextActions(context)).toEqual(["seed-plan"]);
|
|
560
|
+
});
|
|
561
|
+
it("keeps forced run-verify when the selector tries to complete without grounded evidence", async () => {
|
|
562
|
+
const context = {
|
|
563
|
+
task: {
|
|
564
|
+
id: 1,
|
|
565
|
+
projectId: 1,
|
|
566
|
+
status: "active",
|
|
567
|
+
initialQuery: "Refactor MainAgent.ts",
|
|
568
|
+
createdAt: "now",
|
|
569
|
+
updatedAt: "now",
|
|
570
|
+
steps: [],
|
|
571
|
+
},
|
|
572
|
+
initContext: {
|
|
573
|
+
userQuery: "Refactor MainAgent.ts",
|
|
574
|
+
relatedFiles: ["/repo/a.ts"],
|
|
575
|
+
},
|
|
576
|
+
analysis: {
|
|
577
|
+
runtimeState: {
|
|
578
|
+
phase: "execute",
|
|
579
|
+
lane: "evidence",
|
|
580
|
+
status: "active",
|
|
581
|
+
},
|
|
582
|
+
readiness: {
|
|
583
|
+
decision: "not-ready",
|
|
584
|
+
confidence: 0.45,
|
|
585
|
+
},
|
|
586
|
+
executionPolicy: {
|
|
587
|
+
phaseAllowed: { analysis: true, planning: true, transform: true, write: true },
|
|
588
|
+
routeAllowed: { searchExpand: false, research: true, transform: true },
|
|
589
|
+
scopeType: "single-file",
|
|
590
|
+
scopeBand: "single-file",
|
|
591
|
+
executionRequired: ["/repo/a.ts"],
|
|
592
|
+
explorationCandidates: [],
|
|
593
|
+
executionLock: { enabled: false, files: [] },
|
|
594
|
+
executionReady: false,
|
|
595
|
+
explorationReady: false,
|
|
596
|
+
policyNotes: [],
|
|
597
|
+
},
|
|
598
|
+
},
|
|
599
|
+
};
|
|
600
|
+
const decision = await decideNextAction(context, {
|
|
601
|
+
runSelection: async (ctx) => {
|
|
602
|
+
ctx.analysis || (ctx.analysis = {});
|
|
603
|
+
ctx.analysis.iterationReasoning = {
|
|
604
|
+
summary: "done",
|
|
605
|
+
nextAction: "complete",
|
|
606
|
+
rationale: "Pretend we are already done.",
|
|
607
|
+
confidence: 0.8,
|
|
608
|
+
};
|
|
609
|
+
},
|
|
610
|
+
});
|
|
611
|
+
expect(decision.action).toBe("run-verify");
|
|
612
|
+
expect(decision.reason).toBe("Execution is not ready yet; run verify before seeding research or execution work.");
|
|
613
|
+
expect(context.analysis.nextActionValidation).toEqual({
|
|
614
|
+
accepted: true,
|
|
615
|
+
normalizedAction: "run-verify",
|
|
616
|
+
});
|
|
617
|
+
});
|
|
618
|
+
it("returns seed-research when research is allowed and no research step exists yet", async () => {
|
|
619
|
+
const context = {
|
|
620
|
+
task: {
|
|
621
|
+
id: 1,
|
|
622
|
+
projectId: 1,
|
|
623
|
+
status: "active",
|
|
624
|
+
initialQuery: "Refactor MainAgent.ts",
|
|
625
|
+
createdAt: "now",
|
|
626
|
+
updatedAt: "now",
|
|
627
|
+
steps: [],
|
|
628
|
+
},
|
|
629
|
+
initContext: {
|
|
630
|
+
userQuery: "Refactor MainAgent.ts",
|
|
631
|
+
relatedFiles: ["/repo/a.ts"],
|
|
632
|
+
},
|
|
633
|
+
analysis: {
|
|
634
|
+
runtimeState: {
|
|
635
|
+
phase: "execute",
|
|
636
|
+
lane: "coding",
|
|
637
|
+
status: "active",
|
|
638
|
+
},
|
|
639
|
+
readiness: {
|
|
640
|
+
decision: "ready",
|
|
641
|
+
confidence: 0.95,
|
|
642
|
+
},
|
|
643
|
+
executionPolicy: {
|
|
644
|
+
phaseAllowed: { analysis: true, planning: true, transform: true, write: true },
|
|
645
|
+
routeAllowed: { searchExpand: false, research: true, transform: true },
|
|
646
|
+
scopeType: "single-file",
|
|
647
|
+
scopeBand: "single-file",
|
|
648
|
+
executionRequired: ["/repo/a.ts"],
|
|
649
|
+
explorationCandidates: [],
|
|
650
|
+
executionLock: { enabled: false, files: [] },
|
|
651
|
+
executionReady: true,
|
|
652
|
+
explorationReady: false,
|
|
653
|
+
policyNotes: [],
|
|
654
|
+
},
|
|
655
|
+
},
|
|
656
|
+
executionControl: {
|
|
657
|
+
mode: "transform",
|
|
658
|
+
constraints: {
|
|
659
|
+
allowFileWrites: true,
|
|
660
|
+
allowPlanning: true,
|
|
661
|
+
allowAnalysis: true,
|
|
662
|
+
},
|
|
663
|
+
},
|
|
664
|
+
};
|
|
665
|
+
const decision = await decideNextAction(context, {
|
|
666
|
+
runSelection: async (ctx) => {
|
|
667
|
+
ctx.analysis || (ctx.analysis = {});
|
|
668
|
+
ctx.analysis.iterationReasoning = {
|
|
669
|
+
summary: "keep going",
|
|
670
|
+
nextAction: "continue",
|
|
671
|
+
rationale: "Work can continue after research.",
|
|
672
|
+
confidence: 0.7,
|
|
673
|
+
};
|
|
674
|
+
},
|
|
675
|
+
});
|
|
676
|
+
expect(decision).toEqual({
|
|
677
|
+
action: "seed-research",
|
|
678
|
+
reason: "No research step exists yet; seed research before execution planning.",
|
|
679
|
+
confidence: 0.9,
|
|
680
|
+
source: "reason-next-step-selection",
|
|
681
|
+
});
|
|
682
|
+
expect(buildAllowedNextActions(context)).toEqual(["seed-research"]);
|
|
683
|
+
});
|
|
684
|
+
it("preserves give-up when the selector explicitly bypasses a singleton seed-research menu", async () => {
|
|
685
|
+
const context = {
|
|
686
|
+
task: {
|
|
687
|
+
id: 1,
|
|
688
|
+
projectId: 1,
|
|
689
|
+
status: "active",
|
|
690
|
+
initialQuery: "Refactor MainAgent.ts",
|
|
691
|
+
createdAt: "now",
|
|
692
|
+
updatedAt: "now",
|
|
693
|
+
steps: [],
|
|
694
|
+
},
|
|
695
|
+
initContext: {
|
|
696
|
+
userQuery: "Refactor MainAgent.ts",
|
|
697
|
+
relatedFiles: ["/repo/a.ts"],
|
|
698
|
+
},
|
|
699
|
+
analysis: {
|
|
700
|
+
runtimeState: {
|
|
701
|
+
phase: "execute",
|
|
702
|
+
lane: "coding",
|
|
703
|
+
status: "active",
|
|
704
|
+
},
|
|
705
|
+
readiness: {
|
|
706
|
+
decision: "ready",
|
|
707
|
+
confidence: 0.95,
|
|
708
|
+
},
|
|
709
|
+
executionPolicy: {
|
|
710
|
+
phaseAllowed: { analysis: true, planning: true, transform: true, write: true },
|
|
711
|
+
routeAllowed: { searchExpand: false, research: true, transform: true },
|
|
712
|
+
scopeType: "single-file",
|
|
713
|
+
scopeBand: "single-file",
|
|
714
|
+
executionRequired: ["/repo/a.ts"],
|
|
715
|
+
explorationCandidates: [],
|
|
716
|
+
executionLock: { enabled: false, files: [] },
|
|
717
|
+
executionReady: true,
|
|
718
|
+
explorationReady: false,
|
|
719
|
+
policyNotes: [],
|
|
720
|
+
},
|
|
721
|
+
},
|
|
722
|
+
};
|
|
723
|
+
const decision = await decideNextAction(context, {
|
|
724
|
+
runSelection: async (ctx) => {
|
|
725
|
+
ctx.analysis || (ctx.analysis = {});
|
|
726
|
+
ctx.analysis.iterationReasoning = {
|
|
727
|
+
summary: "give-up",
|
|
728
|
+
nextAction: "give-up",
|
|
729
|
+
rationale: "Abort before research starts.",
|
|
730
|
+
confidence: 0.8,
|
|
731
|
+
};
|
|
732
|
+
},
|
|
733
|
+
});
|
|
734
|
+
expect(decision.action).toBe("seed-research");
|
|
735
|
+
expect(decision.reason).toBe("No research step exists yet; seed research before execution planning.");
|
|
736
|
+
expect(context.analysis.nextActionValidation).toEqual({
|
|
737
|
+
accepted: true,
|
|
738
|
+
normalizedAction: "seed-research",
|
|
739
|
+
});
|
|
740
|
+
});
|
|
741
|
+
it("returns seed-plan only after research seeding is not needed", async () => {
|
|
742
|
+
const context = {
|
|
743
|
+
task: {
|
|
744
|
+
id: 1,
|
|
745
|
+
projectId: 1,
|
|
746
|
+
status: "active",
|
|
747
|
+
initialQuery: "Refactor MainAgent.ts",
|
|
748
|
+
createdAt: "now",
|
|
749
|
+
updatedAt: "now",
|
|
750
|
+
steps: [
|
|
751
|
+
{ taskId: 1, filePath: "__research__/impact-map", status: "pending", action: "research-impact-map" },
|
|
752
|
+
],
|
|
753
|
+
},
|
|
754
|
+
initContext: {
|
|
755
|
+
userQuery: "Refactor MainAgent.ts",
|
|
756
|
+
relatedFiles: ["/repo/a.ts"],
|
|
757
|
+
},
|
|
758
|
+
analysis: {
|
|
759
|
+
runtimeState: {
|
|
760
|
+
phase: "execute",
|
|
761
|
+
lane: "coding",
|
|
762
|
+
status: "active",
|
|
763
|
+
},
|
|
764
|
+
readiness: {
|
|
765
|
+
decision: "ready",
|
|
766
|
+
confidence: 0.95,
|
|
767
|
+
},
|
|
768
|
+
executionPolicy: {
|
|
769
|
+
phaseAllowed: { analysis: true, planning: true, transform: true, write: true },
|
|
770
|
+
routeAllowed: { searchExpand: false, research: true, transform: true },
|
|
771
|
+
scopeType: "single-file",
|
|
772
|
+
scopeBand: "single-file",
|
|
773
|
+
executionRequired: ["/repo/a.ts"],
|
|
774
|
+
explorationCandidates: [],
|
|
775
|
+
executionLock: { enabled: false, files: [] },
|
|
776
|
+
executionReady: true,
|
|
777
|
+
explorationReady: false,
|
|
778
|
+
policyNotes: [],
|
|
779
|
+
},
|
|
780
|
+
},
|
|
781
|
+
executionControl: {
|
|
782
|
+
mode: "transform",
|
|
783
|
+
constraints: {
|
|
784
|
+
allowFileWrites: true,
|
|
785
|
+
allowPlanning: true,
|
|
786
|
+
allowAnalysis: true,
|
|
787
|
+
},
|
|
788
|
+
},
|
|
789
|
+
};
|
|
790
|
+
const decision = await decideNextAction(context, {
|
|
791
|
+
runSelection: async (ctx) => {
|
|
792
|
+
ctx.analysis || (ctx.analysis = {});
|
|
793
|
+
ctx.analysis.iterationReasoning = {
|
|
794
|
+
summary: "continue",
|
|
795
|
+
nextAction: "continue",
|
|
796
|
+
rationale: "Research exists, so planning should seed execution work next.",
|
|
797
|
+
confidence: 0.88,
|
|
798
|
+
};
|
|
799
|
+
},
|
|
800
|
+
});
|
|
801
|
+
expect(decision.action).toBe("seed-plan");
|
|
802
|
+
expect(decision.reason).toBe("No eligible execution step exists yet; seed the current execution plan first.");
|
|
803
|
+
expect(buildAllowedNextActions(context)).toEqual(["seed-plan"]);
|
|
804
|
+
});
|
|
805
|
+
it("returns continue when research steps already exist", async () => {
|
|
806
|
+
const context = {
|
|
807
|
+
task: {
|
|
808
|
+
id: 1,
|
|
809
|
+
projectId: 1,
|
|
810
|
+
status: "active",
|
|
811
|
+
initialQuery: "Refactor MainAgent.ts",
|
|
812
|
+
createdAt: "now",
|
|
813
|
+
updatedAt: "now",
|
|
814
|
+
currentStep: { taskId: 1, filePath: "/repo/a.ts", status: "pending" },
|
|
815
|
+
steps: [
|
|
816
|
+
{ taskId: 1, filePath: "__research__/impact-map", status: "completed", action: "research-impact-map" },
|
|
817
|
+
{ taskId: 1, filePath: "/repo/a.ts", status: "pending", action: "work" },
|
|
818
|
+
],
|
|
819
|
+
},
|
|
820
|
+
initContext: {
|
|
821
|
+
userQuery: "Refactor MainAgent.ts",
|
|
822
|
+
relatedFiles: ["/repo/a.ts"],
|
|
823
|
+
},
|
|
824
|
+
analysis: {
|
|
825
|
+
runtimeState: {
|
|
826
|
+
phase: "execute",
|
|
827
|
+
lane: "coding",
|
|
828
|
+
status: "active",
|
|
829
|
+
},
|
|
830
|
+
readiness: {
|
|
831
|
+
decision: "ready",
|
|
832
|
+
confidence: 0.95,
|
|
833
|
+
},
|
|
834
|
+
executionPolicy: {
|
|
835
|
+
phaseAllowed: { analysis: true, planning: true, transform: true, write: true },
|
|
836
|
+
routeAllowed: { searchExpand: false, research: true, transform: true },
|
|
837
|
+
scopeType: "single-file",
|
|
838
|
+
scopeBand: "single-file",
|
|
839
|
+
executionRequired: ["/repo/a.ts"],
|
|
840
|
+
explorationCandidates: [],
|
|
841
|
+
executionLock: { enabled: false, files: [] },
|
|
842
|
+
executionReady: true,
|
|
843
|
+
explorationReady: false,
|
|
844
|
+
policyNotes: [],
|
|
845
|
+
},
|
|
846
|
+
},
|
|
847
|
+
executionControl: {
|
|
848
|
+
mode: "transform",
|
|
849
|
+
constraints: {
|
|
850
|
+
allowFileWrites: true,
|
|
851
|
+
allowPlanning: true,
|
|
852
|
+
allowAnalysis: true,
|
|
853
|
+
},
|
|
854
|
+
},
|
|
855
|
+
};
|
|
856
|
+
const decision = await decideNextAction(context, {
|
|
857
|
+
runSelection: async (ctx) => {
|
|
858
|
+
ctx.analysis || (ctx.analysis = {});
|
|
859
|
+
ctx.analysis.iterationReasoning = {
|
|
860
|
+
summary: "continue",
|
|
861
|
+
nextAction: "continue",
|
|
862
|
+
rationale: "Pending execution step is ready.",
|
|
863
|
+
confidence: 0.88,
|
|
864
|
+
};
|
|
865
|
+
},
|
|
866
|
+
});
|
|
867
|
+
expect(decision.action).toBe("continue");
|
|
868
|
+
expect(decision.reason).toBe("Pending execution step is ready.");
|
|
869
|
+
expect(decision.targetFile).toBe("/repo/a.ts");
|
|
870
|
+
});
|
|
871
|
+
it("does not return run-verify once the initial verify bridge has been consumed", async () => {
|
|
872
|
+
const context = {
|
|
873
|
+
task: {
|
|
874
|
+
id: 1,
|
|
875
|
+
projectId: 1,
|
|
876
|
+
status: "active",
|
|
877
|
+
initialQuery: "Refactor MainAgent.ts",
|
|
878
|
+
createdAt: "now",
|
|
879
|
+
updatedAt: "now",
|
|
880
|
+
steps: [],
|
|
881
|
+
},
|
|
882
|
+
initContext: {
|
|
883
|
+
userQuery: "Refactor MainAgent.ts",
|
|
884
|
+
relatedFiles: ["/repo/a.ts"],
|
|
885
|
+
},
|
|
886
|
+
analysis: {
|
|
887
|
+
runtimeState: {
|
|
888
|
+
phase: "execute",
|
|
889
|
+
lane: "coding",
|
|
890
|
+
status: "active",
|
|
891
|
+
},
|
|
892
|
+
readiness: {
|
|
893
|
+
decision: "not-ready",
|
|
894
|
+
confidence: 0.4,
|
|
895
|
+
},
|
|
896
|
+
executionPolicy: {
|
|
897
|
+
phaseAllowed: { analysis: true, planning: true, transform: true, write: true },
|
|
898
|
+
routeAllowed: { searchExpand: false, research: true, transform: true },
|
|
899
|
+
scopeType: "single-file",
|
|
900
|
+
scopeBand: "single-file",
|
|
901
|
+
executionRequired: ["/repo/a.ts"],
|
|
902
|
+
explorationCandidates: [],
|
|
903
|
+
executionLock: { enabled: false, files: [] },
|
|
904
|
+
executionReady: false,
|
|
905
|
+
explorationReady: false,
|
|
906
|
+
policyNotes: [],
|
|
907
|
+
},
|
|
908
|
+
},
|
|
909
|
+
executionControl: {
|
|
910
|
+
mode: "transform",
|
|
911
|
+
constraints: {
|
|
912
|
+
allowFileWrites: true,
|
|
913
|
+
allowPlanning: true,
|
|
914
|
+
allowAnalysis: true,
|
|
915
|
+
},
|
|
916
|
+
},
|
|
917
|
+
};
|
|
918
|
+
const decision = await decideNextAction(context, {
|
|
919
|
+
allowRunSearch: false,
|
|
920
|
+
allowRunVerify: false,
|
|
921
|
+
runSelection: async (ctx) => {
|
|
922
|
+
ctx.analysis || (ctx.analysis = {});
|
|
923
|
+
ctx.analysis.iterationReasoning = {
|
|
924
|
+
summary: "continue",
|
|
925
|
+
nextAction: "continue",
|
|
926
|
+
rationale: "No execution step exists yet.",
|
|
927
|
+
confidence: 0.5,
|
|
928
|
+
};
|
|
929
|
+
},
|
|
930
|
+
});
|
|
931
|
+
expect(decision.action).toBe("seed-research");
|
|
932
|
+
expect(decision.reason).toBe("No research step exists yet; seed research before execution planning.");
|
|
933
|
+
});
|
|
934
|
+
it("returns run-search before run-verify when both would otherwise apply", async () => {
|
|
935
|
+
const context = {
|
|
936
|
+
task: {
|
|
937
|
+
id: 1,
|
|
938
|
+
projectId: 1,
|
|
939
|
+
status: "active",
|
|
940
|
+
initialQuery: "Refactor MainAgent.ts",
|
|
941
|
+
createdAt: "now",
|
|
942
|
+
updatedAt: "now",
|
|
943
|
+
steps: [],
|
|
944
|
+
},
|
|
945
|
+
analysis: {
|
|
946
|
+
runtimeState: {
|
|
947
|
+
phase: "execute",
|
|
948
|
+
lane: "coding",
|
|
949
|
+
status: "active",
|
|
950
|
+
},
|
|
951
|
+
readiness: {
|
|
952
|
+
decision: "not-ready",
|
|
953
|
+
confidence: 0.4,
|
|
954
|
+
},
|
|
955
|
+
executionPolicy: {
|
|
956
|
+
phaseAllowed: { analysis: true, planning: true, transform: true, write: true },
|
|
957
|
+
routeAllowed: { searchExpand: false, research: true, transform: true },
|
|
958
|
+
scopeType: "single-file",
|
|
959
|
+
scopeBand: "single-file",
|
|
960
|
+
executionRequired: ["/repo/a.ts"],
|
|
961
|
+
explorationCandidates: [],
|
|
962
|
+
executionLock: { enabled: false, files: [] },
|
|
963
|
+
executionReady: false,
|
|
964
|
+
explorationReady: false,
|
|
965
|
+
policyNotes: [],
|
|
966
|
+
},
|
|
967
|
+
},
|
|
968
|
+
};
|
|
969
|
+
const decision = await decideNextAction(context, {
|
|
970
|
+
runSelection: async (ctx) => {
|
|
971
|
+
ctx.analysis || (ctx.analysis = {});
|
|
972
|
+
ctx.analysis.iterationReasoning = {
|
|
973
|
+
summary: "continue",
|
|
974
|
+
nextAction: "continue",
|
|
975
|
+
rationale: "Bootstrap search should happen before verify.",
|
|
976
|
+
confidence: 0.7,
|
|
977
|
+
};
|
|
978
|
+
},
|
|
979
|
+
});
|
|
980
|
+
expect(decision.action).toBe("run-search");
|
|
981
|
+
});
|
|
982
|
+
it("returns seed-research before seed-plan once verify is ready", async () => {
|
|
983
|
+
const context = {
|
|
984
|
+
task: {
|
|
985
|
+
id: 1,
|
|
986
|
+
projectId: 1,
|
|
987
|
+
status: "active",
|
|
988
|
+
initialQuery: "Refactor MainAgent.ts",
|
|
989
|
+
createdAt: "now",
|
|
990
|
+
updatedAt: "now",
|
|
991
|
+
steps: [],
|
|
992
|
+
},
|
|
993
|
+
initContext: {
|
|
994
|
+
userQuery: "Refactor MainAgent.ts",
|
|
995
|
+
relatedFiles: ["/repo/a.ts"],
|
|
996
|
+
},
|
|
997
|
+
analysis: {
|
|
998
|
+
runtimeState: {
|
|
999
|
+
phase: "execute",
|
|
1000
|
+
lane: "coding",
|
|
1001
|
+
status: "active",
|
|
1002
|
+
},
|
|
1003
|
+
readiness: {
|
|
1004
|
+
decision: "ready",
|
|
1005
|
+
confidence: 0.95,
|
|
1006
|
+
},
|
|
1007
|
+
executionPolicy: {
|
|
1008
|
+
phaseAllowed: { analysis: true, planning: true, transform: true, write: true },
|
|
1009
|
+
routeAllowed: { searchExpand: false, research: true, transform: true },
|
|
1010
|
+
scopeType: "single-file",
|
|
1011
|
+
scopeBand: "single-file",
|
|
1012
|
+
executionRequired: ["/repo/a.ts"],
|
|
1013
|
+
explorationCandidates: [],
|
|
1014
|
+
executionLock: { enabled: false, files: [] },
|
|
1015
|
+
executionReady: true,
|
|
1016
|
+
explorationReady: false,
|
|
1017
|
+
policyNotes: [],
|
|
1018
|
+
},
|
|
1019
|
+
},
|
|
1020
|
+
executionControl: {
|
|
1021
|
+
mode: "transform",
|
|
1022
|
+
constraints: {
|
|
1023
|
+
allowFileWrites: true,
|
|
1024
|
+
allowPlanning: true,
|
|
1025
|
+
allowAnalysis: true,
|
|
1026
|
+
},
|
|
1027
|
+
},
|
|
1028
|
+
};
|
|
1029
|
+
const decision = await decideNextAction(context, {
|
|
1030
|
+
runSelection: async (ctx) => {
|
|
1031
|
+
ctx.analysis || (ctx.analysis = {});
|
|
1032
|
+
ctx.analysis.iterationReasoning = {
|
|
1033
|
+
summary: "continue",
|
|
1034
|
+
nextAction: "continue",
|
|
1035
|
+
rationale: "Verify is done, so seed research next.",
|
|
1036
|
+
confidence: 0.7,
|
|
1037
|
+
};
|
|
1038
|
+
},
|
|
1039
|
+
});
|
|
1040
|
+
expect(decision.action).toBe("seed-research");
|
|
1041
|
+
});
|
|
1042
|
+
it("does not return run-verify once readiness is already ready", async () => {
|
|
1043
|
+
const context = {
|
|
1044
|
+
task: {
|
|
1045
|
+
id: 1,
|
|
1046
|
+
projectId: 1,
|
|
1047
|
+
status: "active",
|
|
1048
|
+
initialQuery: "Refactor MainAgent.ts",
|
|
1049
|
+
createdAt: "now",
|
|
1050
|
+
updatedAt: "now",
|
|
1051
|
+
steps: [
|
|
1052
|
+
{ taskId: 1, filePath: "__research__/impact-map", status: "pending", action: "research-impact-map" },
|
|
1053
|
+
],
|
|
1054
|
+
},
|
|
1055
|
+
initContext: {
|
|
1056
|
+
userQuery: "Refactor MainAgent.ts",
|
|
1057
|
+
relatedFiles: ["/repo/a.ts"],
|
|
1058
|
+
},
|
|
1059
|
+
analysis: {
|
|
1060
|
+
runtimeState: {
|
|
1061
|
+
phase: "execute",
|
|
1062
|
+
lane: "coding",
|
|
1063
|
+
status: "active",
|
|
1064
|
+
},
|
|
1065
|
+
readiness: {
|
|
1066
|
+
decision: "ready",
|
|
1067
|
+
confidence: 0.95,
|
|
1068
|
+
},
|
|
1069
|
+
executionPolicy: {
|
|
1070
|
+
phaseAllowed: { analysis: true, planning: true, transform: true, write: true },
|
|
1071
|
+
routeAllowed: { searchExpand: false, research: true, transform: true },
|
|
1072
|
+
scopeType: "single-file",
|
|
1073
|
+
scopeBand: "single-file",
|
|
1074
|
+
executionRequired: ["/repo/a.ts"],
|
|
1075
|
+
explorationCandidates: [],
|
|
1076
|
+
executionLock: { enabled: false, files: [] },
|
|
1077
|
+
executionReady: true,
|
|
1078
|
+
explorationReady: false,
|
|
1079
|
+
policyNotes: [],
|
|
1080
|
+
},
|
|
1081
|
+
},
|
|
1082
|
+
executionControl: {
|
|
1083
|
+
mode: "transform",
|
|
1084
|
+
constraints: {
|
|
1085
|
+
allowFileWrites: true,
|
|
1086
|
+
allowPlanning: true,
|
|
1087
|
+
allowAnalysis: true,
|
|
1088
|
+
},
|
|
1089
|
+
},
|
|
1090
|
+
};
|
|
1091
|
+
const decision = await decideNextAction(context, {
|
|
1092
|
+
runSelection: async (ctx) => {
|
|
1093
|
+
ctx.analysis || (ctx.analysis = {});
|
|
1094
|
+
ctx.analysis.iterationReasoning = {
|
|
1095
|
+
summary: "continue",
|
|
1096
|
+
nextAction: "continue",
|
|
1097
|
+
rationale: "Verify is already ready.",
|
|
1098
|
+
confidence: 0.7,
|
|
1099
|
+
};
|
|
1100
|
+
},
|
|
1101
|
+
});
|
|
1102
|
+
expect(decision.action).toBe("seed-plan");
|
|
1103
|
+
expect(decision.reason).toBe("No eligible execution step exists yet; seed the current execution plan first.");
|
|
1104
|
+
});
|
|
1105
|
+
it("does not return run-search once the initial search bridge has been consumed", async () => {
|
|
1106
|
+
const context = {
|
|
1107
|
+
task: {
|
|
1108
|
+
id: 1,
|
|
1109
|
+
projectId: 1,
|
|
1110
|
+
status: "active",
|
|
1111
|
+
initialQuery: "Refactor MainAgent.ts",
|
|
1112
|
+
createdAt: "now",
|
|
1113
|
+
updatedAt: "now",
|
|
1114
|
+
steps: [],
|
|
1115
|
+
},
|
|
1116
|
+
initContext: {
|
|
1117
|
+
userQuery: "Refactor MainAgent.ts",
|
|
1118
|
+
relatedFiles: ["/repo/a.ts"],
|
|
1119
|
+
},
|
|
1120
|
+
analysis: {
|
|
1121
|
+
runtimeState: {
|
|
1122
|
+
phase: "execute",
|
|
1123
|
+
lane: "coding",
|
|
1124
|
+
status: "active",
|
|
1125
|
+
},
|
|
1126
|
+
readiness: {
|
|
1127
|
+
decision: "not-ready",
|
|
1128
|
+
confidence: 0.4,
|
|
1129
|
+
},
|
|
1130
|
+
executionPolicy: {
|
|
1131
|
+
phaseAllowed: { analysis: true, planning: true, transform: true, write: true },
|
|
1132
|
+
routeAllowed: { searchExpand: false, research: true, transform: true },
|
|
1133
|
+
scopeType: "single-file",
|
|
1134
|
+
scopeBand: "single-file",
|
|
1135
|
+
executionRequired: ["/repo/a.ts"],
|
|
1136
|
+
explorationCandidates: [],
|
|
1137
|
+
executionLock: { enabled: false, files: [] },
|
|
1138
|
+
executionReady: false,
|
|
1139
|
+
explorationReady: false,
|
|
1140
|
+
policyNotes: [],
|
|
1141
|
+
},
|
|
1142
|
+
},
|
|
1143
|
+
};
|
|
1144
|
+
const decision = await decideNextAction(context, {
|
|
1145
|
+
allowRunSearch: false,
|
|
1146
|
+
runSelection: async (ctx) => {
|
|
1147
|
+
ctx.analysis || (ctx.analysis = {});
|
|
1148
|
+
ctx.analysis.iterationReasoning = {
|
|
1149
|
+
summary: "continue",
|
|
1150
|
+
nextAction: "continue",
|
|
1151
|
+
rationale: "Search already happened, so verify should run next.",
|
|
1152
|
+
confidence: 0.7,
|
|
1153
|
+
};
|
|
1154
|
+
},
|
|
1155
|
+
});
|
|
1156
|
+
expect(decision.action).toBe("run-verify");
|
|
1157
|
+
});
|
|
1158
|
+
it("does not return run-search when explicit-target seeding already satisfies bootstrap", async () => {
|
|
1159
|
+
const context = {
|
|
1160
|
+
task: {
|
|
1161
|
+
id: 1,
|
|
1162
|
+
projectId: 1,
|
|
1163
|
+
status: "active",
|
|
1164
|
+
initialQuery: "Refactor MainAgent.ts",
|
|
1165
|
+
createdAt: "now",
|
|
1166
|
+
updatedAt: "now",
|
|
1167
|
+
steps: [],
|
|
1168
|
+
},
|
|
1169
|
+
analysis: {
|
|
1170
|
+
intent: {
|
|
1171
|
+
resolvedTargetFiles: ["/repo/a.ts"],
|
|
1172
|
+
},
|
|
1173
|
+
runtimeState: {
|
|
1174
|
+
phase: "execute",
|
|
1175
|
+
lane: "explicit-target",
|
|
1176
|
+
status: "active",
|
|
1177
|
+
},
|
|
1178
|
+
readiness: {
|
|
1179
|
+
decision: "not-ready",
|
|
1180
|
+
confidence: 0.4,
|
|
1181
|
+
},
|
|
1182
|
+
executionPolicy: {
|
|
1183
|
+
phaseAllowed: { analysis: true, planning: true, transform: true, write: true },
|
|
1184
|
+
routeAllowed: { searchExpand: false, research: true, transform: true },
|
|
1185
|
+
scopeType: "single-file",
|
|
1186
|
+
scopeBand: "single-file",
|
|
1187
|
+
executionRequired: ["/repo/a.ts"],
|
|
1188
|
+
explorationCandidates: [],
|
|
1189
|
+
executionLock: { enabled: false, files: [] },
|
|
1190
|
+
executionReady: false,
|
|
1191
|
+
explorationReady: false,
|
|
1192
|
+
policyNotes: [],
|
|
1193
|
+
},
|
|
1194
|
+
},
|
|
1195
|
+
};
|
|
1196
|
+
const decision = await decideNextAction(context, {
|
|
1197
|
+
runSelection: async (ctx) => {
|
|
1198
|
+
ctx.analysis || (ctx.analysis = {});
|
|
1199
|
+
ctx.analysis.iterationReasoning = {
|
|
1200
|
+
summary: "continue",
|
|
1201
|
+
nextAction: "continue",
|
|
1202
|
+
rationale: "Explicit target already supplies the bootstrap path.",
|
|
1203
|
+
confidence: 0.7,
|
|
1204
|
+
};
|
|
1205
|
+
},
|
|
1206
|
+
});
|
|
1207
|
+
expect(decision.action).toBe("run-verify");
|
|
1208
|
+
});
|
|
1209
|
+
it("does not return seed-plan once the loop has already consumed the initial planning bridge", async () => {
|
|
1210
|
+
const context = {
|
|
1211
|
+
task: {
|
|
1212
|
+
id: 1,
|
|
1213
|
+
projectId: 1,
|
|
1214
|
+
status: "active",
|
|
1215
|
+
initialQuery: "Refactor MainAgent.ts",
|
|
1216
|
+
createdAt: "now",
|
|
1217
|
+
updatedAt: "now",
|
|
1218
|
+
steps: [
|
|
1219
|
+
{ taskId: 1, filePath: "__research__/impact-map", status: "pending", action: "research-impact-map" },
|
|
1220
|
+
],
|
|
1221
|
+
},
|
|
1222
|
+
initContext: {
|
|
1223
|
+
userQuery: "Refactor MainAgent.ts",
|
|
1224
|
+
relatedFiles: ["/repo/a.ts"],
|
|
1225
|
+
},
|
|
1226
|
+
analysis: {
|
|
1227
|
+
runtimeState: {
|
|
1228
|
+
phase: "execute",
|
|
1229
|
+
lane: "coding",
|
|
1230
|
+
status: "active",
|
|
1231
|
+
},
|
|
1232
|
+
readiness: {
|
|
1233
|
+
decision: "ready",
|
|
1234
|
+
confidence: 0.95,
|
|
1235
|
+
},
|
|
1236
|
+
executionPolicy: {
|
|
1237
|
+
phaseAllowed: { analysis: true, planning: true, transform: true, write: true },
|
|
1238
|
+
routeAllowed: { searchExpand: false, research: true, transform: true },
|
|
1239
|
+
scopeType: "single-file",
|
|
1240
|
+
scopeBand: "single-file",
|
|
1241
|
+
executionRequired: ["/repo/a.ts"],
|
|
1242
|
+
explorationCandidates: [],
|
|
1243
|
+
executionLock: { enabled: false, files: [] },
|
|
1244
|
+
executionReady: true,
|
|
1245
|
+
explorationReady: false,
|
|
1246
|
+
policyNotes: [],
|
|
1247
|
+
},
|
|
1248
|
+
},
|
|
1249
|
+
executionControl: {
|
|
1250
|
+
mode: "transform",
|
|
1251
|
+
constraints: {
|
|
1252
|
+
allowFileWrites: true,
|
|
1253
|
+
allowPlanning: true,
|
|
1254
|
+
allowAnalysis: true,
|
|
1255
|
+
},
|
|
1256
|
+
},
|
|
1257
|
+
};
|
|
1258
|
+
const decision = await decideNextAction(context, {
|
|
1259
|
+
allowSeedPlan: false,
|
|
1260
|
+
runSelection: async (ctx) => {
|
|
1261
|
+
ctx.analysis || (ctx.analysis = {});
|
|
1262
|
+
ctx.analysis.iterationReasoning = {
|
|
1263
|
+
summary: "continue",
|
|
1264
|
+
nextAction: "continue",
|
|
1265
|
+
rationale: "No execution step exists yet.",
|
|
1266
|
+
confidence: 0.5,
|
|
1267
|
+
};
|
|
1268
|
+
},
|
|
1269
|
+
});
|
|
1270
|
+
expect(decision.action).toBe("continue");
|
|
1271
|
+
});
|
|
1272
|
+
it("captures pending and completed steps in the typed next-action input", () => {
|
|
1273
|
+
const input = buildNextActionInput({
|
|
1274
|
+
task: {
|
|
1275
|
+
id: 1,
|
|
1276
|
+
projectId: 1,
|
|
1277
|
+
status: "active",
|
|
1278
|
+
initialQuery: "Explain MainAgent.ts",
|
|
1279
|
+
createdAt: "now",
|
|
1280
|
+
updatedAt: "now",
|
|
1281
|
+
currentStep: { taskId: 1, filePath: "/repo/a.ts", status: "pending" },
|
|
1282
|
+
steps: [
|
|
1283
|
+
{ taskId: 1, filePath: "/repo/a.ts", status: "pending", action: "work" },
|
|
1284
|
+
{ taskId: 1, filePath: "/repo/b.ts", status: "completed", action: "work" },
|
|
1285
|
+
],
|
|
1286
|
+
},
|
|
1287
|
+
analysis: {
|
|
1288
|
+
runtimeState: {
|
|
1289
|
+
phase: "execute",
|
|
1290
|
+
lane: "coding",
|
|
1291
|
+
status: "active",
|
|
1292
|
+
},
|
|
1293
|
+
attemptCounters: {
|
|
1294
|
+
retriesByTarget: {
|
|
1295
|
+
"/repo/a.ts": 2,
|
|
1296
|
+
},
|
|
1297
|
+
},
|
|
1298
|
+
},
|
|
1299
|
+
});
|
|
1300
|
+
expect(input.allowedActions).toEqual([
|
|
1301
|
+
"run-search",
|
|
1302
|
+
]);
|
|
1303
|
+
expect(input.pendingSteps).toEqual([
|
|
1304
|
+
{ filePath: "/repo/a.ts", action: "work", status: "pending" },
|
|
1305
|
+
]);
|
|
1306
|
+
expect(input.completedSteps).toEqual([
|
|
1307
|
+
{ filePath: "/repo/b.ts", action: "work", status: "completed" },
|
|
1308
|
+
]);
|
|
1309
|
+
expect(input.retryCounters).toEqual({ "/repo/a.ts": 2 });
|
|
1310
|
+
});
|
|
1311
|
+
it("uses the non-bridge control menu once no bridge action applies", () => {
|
|
1312
|
+
const context = {
|
|
1313
|
+
task: {
|
|
1314
|
+
id: 1,
|
|
1315
|
+
projectId: 1,
|
|
1316
|
+
status: "active",
|
|
1317
|
+
initialQuery: "Refactor MainAgent.ts",
|
|
1318
|
+
createdAt: "now",
|
|
1319
|
+
updatedAt: "now",
|
|
1320
|
+
currentStep: { taskId: 1, filePath: "/repo/a.ts", status: "pending" },
|
|
1321
|
+
steps: [
|
|
1322
|
+
{ taskId: 1, filePath: "__research__/impact-map", status: "completed", action: "research-impact-map" },
|
|
1323
|
+
{ taskId: 1, filePath: "/repo/a.ts", status: "pending", action: "work" },
|
|
1324
|
+
],
|
|
1325
|
+
},
|
|
1326
|
+
initContext: {
|
|
1327
|
+
userQuery: "Refactor MainAgent.ts",
|
|
1328
|
+
relatedFiles: ["/repo/a.ts"],
|
|
1329
|
+
},
|
|
1330
|
+
analysis: {
|
|
1331
|
+
runtimeState: {
|
|
1332
|
+
phase: "execute",
|
|
1333
|
+
lane: "coding",
|
|
1334
|
+
status: "active",
|
|
1335
|
+
},
|
|
1336
|
+
readiness: {
|
|
1337
|
+
decision: "ready",
|
|
1338
|
+
confidence: 0.95,
|
|
1339
|
+
},
|
|
1340
|
+
executionPolicy: {
|
|
1341
|
+
phaseAllowed: { analysis: true, planning: true, transform: true, write: true },
|
|
1342
|
+
routeAllowed: { searchExpand: false, research: true, transform: true },
|
|
1343
|
+
scopeType: "single-file",
|
|
1344
|
+
scopeBand: "single-file",
|
|
1345
|
+
executionRequired: ["/repo/a.ts"],
|
|
1346
|
+
explorationCandidates: [],
|
|
1347
|
+
executionLock: { enabled: false, files: [] },
|
|
1348
|
+
executionReady: true,
|
|
1349
|
+
explorationReady: false,
|
|
1350
|
+
policyNotes: [],
|
|
1351
|
+
},
|
|
1352
|
+
},
|
|
1353
|
+
};
|
|
1354
|
+
expect(buildAllowedNextActions(context)).toEqual([
|
|
1355
|
+
"continue",
|
|
1356
|
+
"expand-scope",
|
|
1357
|
+
"rework-scope",
|
|
1358
|
+
"request-feedback",
|
|
1359
|
+
"complete",
|
|
1360
|
+
"give-up",
|
|
1361
|
+
]);
|
|
1362
|
+
});
|
|
1363
|
+
it("normalizes globally valid but disallowed selector actions to continue", async () => {
|
|
1364
|
+
const context = {
|
|
1365
|
+
task: {
|
|
1366
|
+
id: 1,
|
|
1367
|
+
projectId: 1,
|
|
1368
|
+
status: "active",
|
|
1369
|
+
initialQuery: "Refactor MainAgent.ts",
|
|
1370
|
+
createdAt: "now",
|
|
1371
|
+
updatedAt: "now",
|
|
1372
|
+
currentStep: { taskId: 1, filePath: "/repo/a.ts", status: "pending" },
|
|
1373
|
+
steps: [
|
|
1374
|
+
{ taskId: 1, filePath: "__research__/impact-map", status: "completed", action: "research-impact-map" },
|
|
1375
|
+
{ taskId: 1, filePath: "/repo/a.ts", status: "pending", action: "work" },
|
|
1376
|
+
],
|
|
1377
|
+
},
|
|
1378
|
+
initContext: {
|
|
1379
|
+
userQuery: "Refactor MainAgent.ts",
|
|
1380
|
+
relatedFiles: ["/repo/a.ts"],
|
|
1381
|
+
},
|
|
1382
|
+
analysis: {
|
|
1383
|
+
runtimeState: {
|
|
1384
|
+
phase: "execute",
|
|
1385
|
+
lane: "coding",
|
|
1386
|
+
status: "active",
|
|
1387
|
+
},
|
|
1388
|
+
readiness: {
|
|
1389
|
+
decision: "ready",
|
|
1390
|
+
confidence: 0.95,
|
|
1391
|
+
},
|
|
1392
|
+
executionPolicy: {
|
|
1393
|
+
phaseAllowed: { analysis: true, planning: true, transform: true, write: true },
|
|
1394
|
+
routeAllowed: { searchExpand: false, research: true, transform: true },
|
|
1395
|
+
scopeType: "single-file",
|
|
1396
|
+
scopeBand: "single-file",
|
|
1397
|
+
executionRequired: ["/repo/a.ts"],
|
|
1398
|
+
explorationCandidates: [],
|
|
1399
|
+
executionLock: { enabled: false, files: [] },
|
|
1400
|
+
executionReady: true,
|
|
1401
|
+
explorationReady: false,
|
|
1402
|
+
policyNotes: [],
|
|
1403
|
+
},
|
|
1404
|
+
},
|
|
1405
|
+
};
|
|
1406
|
+
const decision = await decideNextAction(context, {
|
|
1407
|
+
runSelection: async (ctx) => {
|
|
1408
|
+
ctx.analysis || (ctx.analysis = {});
|
|
1409
|
+
ctx.analysis.iterationReasoning = {
|
|
1410
|
+
summary: "bad",
|
|
1411
|
+
nextAction: "run-verify",
|
|
1412
|
+
rationale: "Try to force verify anyway.",
|
|
1413
|
+
confidence: 0.7,
|
|
1414
|
+
};
|
|
1415
|
+
},
|
|
1416
|
+
});
|
|
1417
|
+
expect(decision.action).toBe("continue");
|
|
1418
|
+
expect(context.analysis.nextActionValidation).toEqual({
|
|
1419
|
+
accepted: false,
|
|
1420
|
+
normalizedAction: "continue",
|
|
1421
|
+
rejectionReason: "Action not allowed in current menu: run-verify",
|
|
1422
|
+
});
|
|
1423
|
+
});
|
|
1424
|
+
it("keeps forced run-search when the selector tries to complete in an evidence lane", async () => {
|
|
1425
|
+
const context = {
|
|
1426
|
+
task: {
|
|
1427
|
+
id: 1,
|
|
1428
|
+
projectId: 1,
|
|
1429
|
+
status: "active",
|
|
1430
|
+
initialQuery: "Summarize architecture",
|
|
1431
|
+
createdAt: "now",
|
|
1432
|
+
updatedAt: "now",
|
|
1433
|
+
steps: [],
|
|
1434
|
+
},
|
|
1435
|
+
analysis: {
|
|
1436
|
+
runtimeState: {
|
|
1437
|
+
phase: "execute",
|
|
1438
|
+
lane: "evidence",
|
|
1439
|
+
status: "active",
|
|
1440
|
+
},
|
|
1441
|
+
},
|
|
1442
|
+
};
|
|
1443
|
+
const decision = await decideNextAction(context, {
|
|
1444
|
+
runSelection: async (ctx) => {
|
|
1445
|
+
ctx.analysis || (ctx.analysis = {});
|
|
1446
|
+
ctx.analysis.iterationReasoning = {
|
|
1447
|
+
summary: "done",
|
|
1448
|
+
nextAction: "complete",
|
|
1449
|
+
rationale: "No further loop work is needed.",
|
|
1450
|
+
confidence: 0.99,
|
|
1451
|
+
};
|
|
1452
|
+
},
|
|
1453
|
+
});
|
|
1454
|
+
expect(decision.action).toBe("run-search");
|
|
1455
|
+
expect(decision.reason).toBe("Initial evidence bootstrap has not run yet; run search before verify or execution seeding.");
|
|
1456
|
+
expect(context.analysis.nextActionValidation).toEqual({
|
|
1457
|
+
accepted: true,
|
|
1458
|
+
normalizedAction: "run-search",
|
|
1459
|
+
});
|
|
1460
|
+
});
|
|
1461
|
+
it("allows terminal bypass for continuity-local answers", async () => {
|
|
1462
|
+
const context = {
|
|
1463
|
+
task: {
|
|
1464
|
+
id: 1,
|
|
1465
|
+
projectId: 1,
|
|
1466
|
+
status: "active",
|
|
1467
|
+
initialQuery: "what should we do next?",
|
|
1468
|
+
createdAt: "now",
|
|
1469
|
+
updatedAt: "now",
|
|
1470
|
+
steps: [],
|
|
1471
|
+
},
|
|
1472
|
+
analysis: {
|
|
1473
|
+
guardState: {
|
|
1474
|
+
lane: "resume-continuity",
|
|
1475
|
+
readiness: "ready",
|
|
1476
|
+
continuationMode: "need-search",
|
|
1477
|
+
allowSearchExpand: true,
|
|
1478
|
+
allowResearch: false,
|
|
1479
|
+
allowTransform: false,
|
|
1480
|
+
executionReady: false,
|
|
1481
|
+
executionLockEnabled: false,
|
|
1482
|
+
executionRequired: [],
|
|
1483
|
+
},
|
|
1484
|
+
resumeIntent: {
|
|
1485
|
+
kind: "continuity-next-step",
|
|
1486
|
+
fastTrackEligible: true,
|
|
1487
|
+
answerFromResumeOnly: false,
|
|
1488
|
+
relevantResumeFiles: ["/repo/cli/src/agents/MainAgent.ts"],
|
|
1489
|
+
rationale: "resume",
|
|
1490
|
+
},
|
|
1491
|
+
continuityDecision: {
|
|
1492
|
+
kind: "direct-synthesized-answer",
|
|
1493
|
+
answerNow: true,
|
|
1494
|
+
fallbackRequired: false,
|
|
1495
|
+
rationale: "resume answer is local",
|
|
1496
|
+
},
|
|
1497
|
+
},
|
|
1498
|
+
};
|
|
1499
|
+
const decision = await decideNextAction(context, {
|
|
1500
|
+
runSelection: async (ctx) => {
|
|
1501
|
+
ctx.analysis || (ctx.analysis = {});
|
|
1502
|
+
ctx.analysis.iterationReasoning = {
|
|
1503
|
+
summary: "done",
|
|
1504
|
+
nextAction: "complete",
|
|
1505
|
+
rationale: "Resume state already answers this.",
|
|
1506
|
+
confidence: 0.99,
|
|
1507
|
+
};
|
|
1508
|
+
},
|
|
1509
|
+
});
|
|
1510
|
+
expect(decision.action).toBe("complete");
|
|
1511
|
+
expect(decision.reason).toBe("Resume state already answers this.");
|
|
1512
|
+
});
|
|
1513
|
+
it("allows terminal bypass for explicit-target answers that already have grounded evidence", async () => {
|
|
1514
|
+
const targetFile = "/repo/MainAgent.ts";
|
|
1515
|
+
const context = {
|
|
1516
|
+
task: {
|
|
1517
|
+
id: 1,
|
|
1518
|
+
projectId: 1,
|
|
1519
|
+
status: "active",
|
|
1520
|
+
initialQuery: "Explain MainAgent.ts",
|
|
1521
|
+
createdAt: "now",
|
|
1522
|
+
updatedAt: "now",
|
|
1523
|
+
steps: [],
|
|
1524
|
+
},
|
|
1525
|
+
initContext: {
|
|
1526
|
+
userQuery: "Explain MainAgent.ts",
|
|
1527
|
+
relatedFiles: [targetFile],
|
|
1528
|
+
},
|
|
1529
|
+
analysis: {
|
|
1530
|
+
focus: {
|
|
1531
|
+
selectedFiles: [targetFile],
|
|
1532
|
+
resolvedTargetFiles: [targetFile],
|
|
1533
|
+
candidateFiles: [],
|
|
1534
|
+
},
|
|
1535
|
+
guardState: {
|
|
1536
|
+
lane: "explicit-target",
|
|
1537
|
+
readiness: "not-ready",
|
|
1538
|
+
continuationMode: "need-verify",
|
|
1539
|
+
allowSearchExpand: false,
|
|
1540
|
+
allowResearch: false,
|
|
1541
|
+
allowTransform: false,
|
|
1542
|
+
executionReady: false,
|
|
1543
|
+
executionLockEnabled: false,
|
|
1544
|
+
executionRequired: [targetFile],
|
|
1545
|
+
},
|
|
1546
|
+
readiness: {
|
|
1547
|
+
decision: "not-ready",
|
|
1548
|
+
confidence: 0.45,
|
|
1549
|
+
},
|
|
1550
|
+
executionPolicy: {
|
|
1551
|
+
phaseAllowed: { analysis: true, planning: true, transform: false, write: false },
|
|
1552
|
+
routeAllowed: { searchExpand: false, research: false, transform: false },
|
|
1553
|
+
scopeType: "single-file",
|
|
1554
|
+
scopeBand: "single-file",
|
|
1555
|
+
executionRequired: [targetFile],
|
|
1556
|
+
explorationCandidates: [],
|
|
1557
|
+
executionLock: { enabled: false, files: [] },
|
|
1558
|
+
executionReady: false,
|
|
1559
|
+
explorationReady: false,
|
|
1560
|
+
policyNotes: [],
|
|
1561
|
+
},
|
|
1562
|
+
verify: {
|
|
1563
|
+
byFile: {
|
|
1564
|
+
[targetFile]: {
|
|
1565
|
+
isRelevant: true,
|
|
1566
|
+
fileConfidence: 0.91,
|
|
1567
|
+
},
|
|
1568
|
+
},
|
|
1569
|
+
},
|
|
1570
|
+
},
|
|
1571
|
+
};
|
|
1572
|
+
const decision = await decideNextAction(context, {
|
|
1573
|
+
runSelection: async (ctx) => {
|
|
1574
|
+
ctx.analysis || (ctx.analysis = {});
|
|
1575
|
+
ctx.analysis.iterationReasoning = {
|
|
1576
|
+
summary: "done",
|
|
1577
|
+
nextAction: "complete",
|
|
1578
|
+
rationale: "Exact-target evidence is already grounded enough.",
|
|
1579
|
+
confidence: 0.96,
|
|
1580
|
+
};
|
|
1581
|
+
},
|
|
1582
|
+
});
|
|
1583
|
+
expect(decision.action).toBe("complete");
|
|
1584
|
+
expect(decision.reason).toBe("Exact-target evidence is already grounded enough.");
|
|
1585
|
+
});
|
|
1586
|
+
it("forces the singleton bridge when the selector emits a disallowed global action", async () => {
|
|
1587
|
+
const context = {
|
|
1588
|
+
task: {
|
|
1589
|
+
id: 1,
|
|
1590
|
+
projectId: 1,
|
|
1591
|
+
status: "active",
|
|
1592
|
+
initialQuery: "Summarize architecture",
|
|
1593
|
+
createdAt: "now",
|
|
1594
|
+
updatedAt: "now",
|
|
1595
|
+
steps: [],
|
|
1596
|
+
},
|
|
1597
|
+
analysis: {
|
|
1598
|
+
runtimeState: {
|
|
1599
|
+
phase: "execute",
|
|
1600
|
+
lane: "evidence",
|
|
1601
|
+
status: "active",
|
|
1602
|
+
},
|
|
1603
|
+
},
|
|
1604
|
+
};
|
|
1605
|
+
const decision = await decideNextAction(context, {
|
|
1606
|
+
runSelection: async (ctx) => {
|
|
1607
|
+
ctx.analysis || (ctx.analysis = {});
|
|
1608
|
+
ctx.analysis.iterationReasoning = {
|
|
1609
|
+
summary: "bad",
|
|
1610
|
+
nextAction: "expand-scope",
|
|
1611
|
+
rationale: "Try to skip straight to expansion.",
|
|
1612
|
+
confidence: 0.6,
|
|
1613
|
+
};
|
|
1614
|
+
},
|
|
1615
|
+
});
|
|
1616
|
+
expect(decision).toEqual({
|
|
1617
|
+
action: "run-search",
|
|
1618
|
+
reason: "Initial evidence bootstrap has not run yet; run search before verify or execution seeding.",
|
|
1619
|
+
confidence: 0.93,
|
|
1620
|
+
source: "reason-next-step-selection",
|
|
1621
|
+
});
|
|
1622
|
+
expect(context.analysis.nextActionValidation).toEqual({
|
|
1623
|
+
accepted: true,
|
|
1624
|
+
normalizedAction: "run-search",
|
|
1625
|
+
});
|
|
1626
|
+
});
|
|
1627
|
+
});
|
|
1628
|
+
describe("validateNextActionDecision", () => {
|
|
1629
|
+
it("accepts current loop actions and defaults missing actions to continue", () => {
|
|
1630
|
+
expect(validateNextActionDecision("give-up")).toEqual({
|
|
1631
|
+
accepted: true,
|
|
1632
|
+
normalizedAction: "give-up",
|
|
1633
|
+
});
|
|
1634
|
+
expect(validateNextActionDecision("run-search")).toEqual({
|
|
1635
|
+
accepted: true,
|
|
1636
|
+
normalizedAction: "run-search",
|
|
1637
|
+
});
|
|
1638
|
+
expect(validateNextActionDecision("run-verify", ["continue"])).toEqual({
|
|
1639
|
+
accepted: false,
|
|
1640
|
+
normalizedAction: "continue",
|
|
1641
|
+
rejectionReason: "Action not allowed in current menu: run-verify",
|
|
1642
|
+
});
|
|
1643
|
+
expect(validateNextActionDecision("run-verify")).toEqual({
|
|
1644
|
+
accepted: true,
|
|
1645
|
+
normalizedAction: "run-verify",
|
|
1646
|
+
});
|
|
1647
|
+
expect(validateNextActionDecision("seed-research")).toEqual({
|
|
1648
|
+
accepted: true,
|
|
1649
|
+
normalizedAction: "seed-research",
|
|
1650
|
+
});
|
|
1651
|
+
expect(validateNextActionDecision("seed-plan")).toEqual({
|
|
1652
|
+
accepted: true,
|
|
1653
|
+
normalizedAction: "seed-plan",
|
|
1654
|
+
});
|
|
1655
|
+
expect(validateNextActionDecision(undefined)).toEqual({
|
|
1656
|
+
accepted: false,
|
|
1657
|
+
normalizedAction: "continue",
|
|
1658
|
+
rejectionReason: "Missing next action from iteration reasoning",
|
|
1659
|
+
});
|
|
1660
|
+
});
|
|
1661
|
+
});
|
|
1662
|
+
//# sourceMappingURL=decideNextAction.test.js.map
|