@vitest-agent/sdk 2.2.1 → 2.3.1

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/index.d.ts CHANGED
@@ -2812,6 +2812,42 @@ interface TurnSummary {
2812
2812
  readonly occurredAt: string;
2813
2813
  }
2814
2814
  /** @public */
2815
+ interface HistoryQueryOptions {
2816
+ /** Exact `full_name` match — narrows to a single test's history. */
2817
+ readonly testName?: string;
2818
+ /** Exact `module_path` match — narrows to tests in one file. */
2819
+ readonly modulePath?: string;
2820
+ /** Max runs kept per (module_path, full_name) pair, most-recent-first. Default 20. */
2821
+ readonly limit?: number;
2822
+ }
2823
+ /**
2824
+ * Narrowing options shared by the classification reads
2825
+ * ({@link DataReader.getFlaky} / `getPersistentFailures`). Mirrors the
2826
+ * `testName` / `modulePath` half of {@link HistoryQueryOptions} so a
2827
+ * caller that scoped `getHistory` to one test can scope the derived
2828
+ * classifications to the same test instead of receiving the whole
2829
+ * project's rows.
2830
+ *
2831
+ * @public
2832
+ */
2833
+ interface ClassificationQueryOptions {
2834
+ /** Exact `full_name` match — narrows to a single test's classification. */
2835
+ readonly testName?: string;
2836
+ /** Exact `module_path` match — narrows to tests in one file. */
2837
+ readonly modulePath?: string;
2838
+ }
2839
+ /**
2840
+ * Narrowing options for {@link DataReader.getTestByFullName}. A
2841
+ * `full_name` is not file-qualified (Decision D20), so the same name can
2842
+ * exist in more than one module; `modulePath` disambiguates.
2843
+ *
2844
+ * @public
2845
+ */
2846
+ interface TestLookupOptions {
2847
+ /** Exact `module_path` match — picks one variant of an ambiguous `full_name`. */
2848
+ readonly modulePath?: string;
2849
+ }
2850
+ /** @public */
2815
2851
  interface TurnSearchOptions {
2816
2852
  readonly sessionId?: number;
2817
2853
  readonly type?: string;
@@ -2966,11 +3002,11 @@ interface TagInventoryRow {
2966
3002
  declare const DataReader_base: Context.ServiceClass<DataReader, "vitest-agent/DataReader", {
2967
3003
  readonly getLatestRun: (project: string) => Effect.Effect<Option.Option<AgentReport>, DataStoreError>;
2968
3004
  readonly getRunsByProject: () => Effect.Effect<ReadonlyArray<ProjectRunSummary>, DataStoreError>;
2969
- readonly getHistory: (project: string) => Effect.Effect<HistoryRecord, DataStoreError>;
3005
+ readonly getHistory: (project: string, options?: HistoryQueryOptions) => Effect.Effect<HistoryRecord, DataStoreError>;
2970
3006
  readonly getBaselines: (project: string) => Effect.Effect<Option.Option<CoverageBaselines>, DataStoreError>;
2971
3007
  readonly getTrends: (project: string, limit?: number) => Effect.Effect<Option.Option<TrendRecord>, DataStoreError>;
2972
- readonly getFlaky: (project: string) => Effect.Effect<ReadonlyArray<FlakyTest>, DataStoreError>;
2973
- readonly getPersistentFailures: (project: string) => Effect.Effect<ReadonlyArray<PersistentFailure>, DataStoreError>;
3008
+ readonly getFlaky: (project: string, options?: ClassificationQueryOptions) => Effect.Effect<ReadonlyArray<FlakyTest>, DataStoreError>;
3009
+ readonly getPersistentFailures: (project: string, options?: ClassificationQueryOptions) => Effect.Effect<ReadonlyArray<PersistentFailure>, DataStoreError>;
2974
3010
  readonly getFileCoverage: (runId: number) => Effect.Effect<ReadonlyArray<FileCoverageReport>, DataStoreError>;
2975
3011
  readonly getCoverage: (project: string) => Effect.Effect<Option.Option<CoverageReport>, DataStoreError>;
2976
3012
  readonly getTestsForFile: (filePath: string) => Effect.Effect<ReadonlyArray<string>, DataStoreError>;
@@ -2981,7 +3017,14 @@ declare const DataReader_base: Context.ServiceClass<DataReader, "vitest-agent/Da
2981
3017
  readonly getManifest: () => Effect.Effect<Option.Option<CacheManifest>, DataStoreError>;
2982
3018
  readonly getSettings: (hash: string) => Effect.Effect<Option.Option<SettingsRow>, DataStoreError>;
2983
3019
  readonly getLatestSettings: () => Effect.Effect<Option.Option<SettingsRow>, DataStoreError>;
2984
- readonly getTestByFullName: (project: string, fullName: string) => Effect.Effect<Option.Option<TestListEntry>, DataStoreError>;
3020
+ readonly getTestByFullName: (project: string, fullName: string, options?: TestLookupOptions) => Effect.Effect<Option.Option<TestListEntry>, DataStoreError>;
3021
+ /**
3022
+ * Every module path in the project's latest run that carries a test
3023
+ * case with this exact `full_name`, ordered ascending. Length > 1
3024
+ * means the name is ambiguous and callers must disambiguate with
3025
+ * {@link TestLookupOptions.modulePath} rather than guess.
3026
+ */
3027
+ readonly getTestModulesByFullName: (project: string, fullName: string) => Effect.Effect<ReadonlyArray<string>, DataStoreError>;
2985
3028
  readonly listTests: (project: string, options?: {
2986
3029
  state?: string;
2987
3030
  module?: string;
@@ -5363,5 +5406,5 @@ declare function validateCoverageTargetsShape(input: unknown): CoverageTargetsSh
5363
5406
  */
5364
5407
  declare const CURRENT_SDK_VERSION: string;
5365
5408
  //#endregion
5366
- export { AcceptanceMetrics, ActionSeverity, ActorType, Agent, AgentConsoleMode, AgentContext, AgentId, AgentNotFoundError, AgentPluginOptions, AgentReport, AgentReporterOptions, AgentTreeNode, AnsiOptions, ArtifactKind, AssembledHistoryRecord, AssociateRunSessionInput, BehaviorAbandonedEvent, BehaviorAddedEvent, BehaviorCompletedEvent, BehaviorDetail, BehaviorNotFoundError, BehaviorRow, BehaviorScopedEventType, BehaviorScopedEventTypes, BehaviorStartedEvent, BehaviorStatus, BehaviorsReadyEvent, BlockedEvent, CURRENT_SDK_VERSION, CacheManifest, CacheManifestEntry, CandidateContext, CellOptions, ChangeKind, ChannelEvent, ChatId, CiConsoleMode, CitedArtifact, CitedArtifactRow, CommitChangesEntry, ConfigLive, ConsoleFormatOptions, ConsoleLeakEntry, ConsoleLeakFile, ConsoleLeakTask, ConsoleLeaks, ConsoleLogLevel, ConsoleMode, ConsoleOutputMode, ConsoleOutputs, ConversationId, ConversationNotFoundError, CoverageBaselines, FileCoverageReport as CoverageFile, FileCoverageReport, CoverageGap, CoverageInput, CoverageLevel, CoverageLevelName, CoverageMetric, CoverageRenderState, CoverageReport, CoverageTargets, CoverageTargetsMetrics, CoverageTargetsShapeError, CoverageTargetsShapeInfo, CoverageTargetsShapeResult, CoverageTargetsShapeWarning, CoverageTotals, CreateBehaviorInput, CreateGoalInput, CurrentTddPhase, DATABASE_FILENAME, DataReader, DataReaderLive, DataStore, DataStoreError, DataStoreLive, DenialReason, DetailLevel, DetailResolver, DetailResolverLive, DiscoveryError, DiscoveryRegistry, DiscoveryRegistryLive, DispatchInputs, EndTddTaskInput, Environment, EnvironmentDetector, EnvironmentDetectorLive, EnvironmentDetectorTest, Executor, ExecutorResolver, ExecutorResolverLive, FailureRecord, FailureSignatureDetail, FailureSignatureInput, FailureSignatureWriteInput, FileCoverageInput, FileEditPayload, FileSystemAdapter, FlakyTest, FormatSelector, FormatSelectorLive, type FormatTriageOptions, type FormatWrapupOptions, Formatter, FormatterContext, FunctionBoundary, GfmFormatter, GitCommandError, GoalAbandonedEvent, GoalAddedEvent, GoalCompletedEvent, GoalDetail, GoalNotFoundError, GoalRow, GoalStartedEvent, GoalStatus, GoalsReadyEvent, HistoryRecord, HistoryRow, HistoryTracker, HistoryTrackerLive, HistoryTrackerTest, HistoryTrackerTestState, HookFirePayload, HookStatus, HookType, HostKind, HostMetadataParseError, HostMetadataResult, HumanConsoleMode, HypothesisDetail, HypothesisInput, HypothesisPayload, IDEMPOTENCY_ROOT_SENTINEL, IdempotencyHit, IdempotencyInput, IdempotentResponseInput, IllegalStatusTransitionEntity, IllegalStatusTransitionError, JsonFormatter, KnownProject, KnownProjectInput, LoggerLive, ManifestRow, MapSessionInput, MapSessionOutput, MarkdownFormatter, MetricThresholds, ModuleInput, ModuleListEntry, ModuleRecord, ModuleReport, NON_DISCOVERABLE_DIRS, NoteInput, NotePayload, NoteRow, Osc8Options, OutputFormat, OutputPipelineLive, OutputRenderer, OutputRendererLive, PackageManager, PathResolutionError, PathResolutionLive, PatternThresholds, PerClientSessionMapReader, PerClientSessionMapReaderLive, PerClientSessionMapWriter, PerClientSessionMapWriterLive, PersistentFailure, Phase, PhaseTransitionContext, PhaseTransitionEvent, PhaseTransitionResult, ProbeMissError, ProjectDiscovery, ProjectDiscoveryLive, ProjectDiscoveryTest, ProjectIdentity, ProjectIdentityCandidate, ProjectIdentityCandidates, ProjectIdentityLive, ProjectIdentityNotResolvableError, ProjectIdentitySource, ProjectIdentityTest, ProjectKey, ProjectRunSummary, ProjectSummary, RegisterAgentInput, RegisterAgentResult, RegistrationConflictError, Remediation, RenderState, RenderTotals, RenderedOutput, ReportError, ReportSummary, ReporterKit, ReporterRenderInput, ResolveDataPathOptions, ResolveProjectIdentityOptions, ResolvedIdentity, ResolvedReporterConfig, ResolvedThresholds, RunChangedFile, RunContext, RunContext$, RunContextLive, RunContextService, RunContextTest, RunEvent, RunEventByTag, RunHealth, RunInvocationMethod, RunOutcome, RunShape, SRC_DIR, SessionCompleteEvent, SessionContextRow, SessionDetail, SessionInput, SessionNotFoundError, SessionOutcome, SettingsInput, SettingsListEntry, SettingsRow, SidecarTimeoutError, SilentFormatter, StackFrameInput, SuggestedActionRecord, SuiteInput, SuiteListEntry, TEST_DIR, TEST_FILE_GLOB_SUFFIX, TEST_HELPER_DIRS, TagCountEntry, TagInventoryRow, TddArtifactDetail, TddArtifactRow, TddPhaseDetail, TddTaskAlreadyEndedError, TddTaskDetail, TddTaskEndOutcome, TddTaskId, TddTaskInput, TddTaskNotFoundError, TddTaskSummary, TerminalFormatter, TestCaseInput, TestClassification, TestError, TestErrorInput, TestFileEntry, TestHistory, TestListEntry, TestOutcome, TestPathClassification, TestPathVerdict, TestRecord, TestReport, TestRun, TestRunInput, TestRunReason, TestState, ToolCallPayload, ToolResultPayload, Transport, TrendEntry, TrendRecord, TrendSummary, TurnInput, TurnPayload, TurnSearchOptions, TurnSummary, UpdateBehaviorInput, UpdateGoalInput, UserPromptPayload, ValidateHypothesisInput, VitestAgentConfig, VitestAgentConfigFile, VitestAgentConfigFileService, VitestAgentReporter, VitestAgentReporterFactory, VitestModuleDiagnostic, VitestModuleError, VitestParsedStack, VitestTestCase, VitestTestDiagnostic, VitestTestError, VitestTestModule, VitestTestResult, VitestTestSuite, WorkspaceLike, type WrapupKind, WriteCommitInput, WriteRunChangedFilesInput, WriteTddArtifactInput, WriteTddPhaseInput, WriteTddPhaseOutput, _resetMigrationCacheForTesting, ansi, assembleHistoryRecord, assembleManifest, buildAgentReport, buildConsoleLeaks, buildEnvPrefix, canonicalizeGitUrl, ciAnnotationsFormatter, classifyTest, classifyTestPath, coerceErrorField, coerceErrorText, collectConsoleLeakEntries, compressLines, computeFailureSignature, computeTrend, countSuiteFailures, deriveIdempotencyKey, detectPackageManager, detectVitestScripts, determineTier, ensureMigrated, extractSqlReason, findFunctionBoundary, findOwningWorkspace, formatConsoleMarkdown, formatFatalError, formatGfm, formatTriageEffect, formatWrapupEffect, getRecentDirection, getRunCommand, getWorstMetric, gitUrlToProjectKey, hashTargets, historyKey, initialRenderState, isTestFileName, isTimeoutError, isVitestInvocation, migration as migration0001, normalizeAssertionShape, normalizeWorkspaceKey, osc8, probeHostMetadataFromEnv, migration$1 as registryMigration0001, relativePath, requiredArtifactForTransition, resolveCoverageInput, resolveDataPath, resolveLogFile, resolveLogLevel, resolveProjectIdentityFromCandidates, resolveProjectKeyFromCwd, resolveWorkspaceKey, rewriteBashCommand, safeFilename, migration$2 as sessionMapMigration0001, stripAnsi, transitionEnforcesBehaviorMatch, validateCoverageConfig, validateCoverageTargetsShape, validatePhaseTransition };
5409
+ export { AcceptanceMetrics, ActionSeverity, ActorType, Agent, AgentConsoleMode, AgentContext, AgentId, AgentNotFoundError, AgentPluginOptions, AgentReport, AgentReporterOptions, AgentTreeNode, AnsiOptions, ArtifactKind, AssembledHistoryRecord, AssociateRunSessionInput, BehaviorAbandonedEvent, BehaviorAddedEvent, BehaviorCompletedEvent, BehaviorDetail, BehaviorNotFoundError, BehaviorRow, BehaviorScopedEventType, BehaviorScopedEventTypes, BehaviorStartedEvent, BehaviorStatus, BehaviorsReadyEvent, BlockedEvent, CURRENT_SDK_VERSION, CacheManifest, CacheManifestEntry, CandidateContext, CellOptions, ChangeKind, ChannelEvent, ChatId, CiConsoleMode, CitedArtifact, CitedArtifactRow, ClassificationQueryOptions, CommitChangesEntry, ConfigLive, ConsoleFormatOptions, ConsoleLeakEntry, ConsoleLeakFile, ConsoleLeakTask, ConsoleLeaks, ConsoleLogLevel, ConsoleMode, ConsoleOutputMode, ConsoleOutputs, ConversationId, ConversationNotFoundError, CoverageBaselines, FileCoverageReport as CoverageFile, FileCoverageReport, CoverageGap, CoverageInput, CoverageLevel, CoverageLevelName, CoverageMetric, CoverageRenderState, CoverageReport, CoverageTargets, CoverageTargetsMetrics, CoverageTargetsShapeError, CoverageTargetsShapeInfo, CoverageTargetsShapeResult, CoverageTargetsShapeWarning, CoverageTotals, CreateBehaviorInput, CreateGoalInput, CurrentTddPhase, DATABASE_FILENAME, DataReader, DataReaderLive, DataStore, DataStoreError, DataStoreLive, DenialReason, DetailLevel, DetailResolver, DetailResolverLive, DiscoveryError, DiscoveryRegistry, DiscoveryRegistryLive, DispatchInputs, EndTddTaskInput, Environment, EnvironmentDetector, EnvironmentDetectorLive, EnvironmentDetectorTest, Executor, ExecutorResolver, ExecutorResolverLive, FailureRecord, FailureSignatureDetail, FailureSignatureInput, FailureSignatureWriteInput, FileCoverageInput, FileEditPayload, FileSystemAdapter, FlakyTest, FormatSelector, FormatSelectorLive, type FormatTriageOptions, type FormatWrapupOptions, Formatter, FormatterContext, FunctionBoundary, GfmFormatter, GitCommandError, GoalAbandonedEvent, GoalAddedEvent, GoalCompletedEvent, GoalDetail, GoalNotFoundError, GoalRow, GoalStartedEvent, GoalStatus, GoalsReadyEvent, HistoryQueryOptions, HistoryRecord, HistoryRow, HistoryTracker, HistoryTrackerLive, HistoryTrackerTest, HistoryTrackerTestState, HookFirePayload, HookStatus, HookType, HostKind, HostMetadataParseError, HostMetadataResult, HumanConsoleMode, HypothesisDetail, HypothesisInput, HypothesisPayload, IDEMPOTENCY_ROOT_SENTINEL, IdempotencyHit, IdempotencyInput, IdempotentResponseInput, IllegalStatusTransitionEntity, IllegalStatusTransitionError, JsonFormatter, KnownProject, KnownProjectInput, LoggerLive, ManifestRow, MapSessionInput, MapSessionOutput, MarkdownFormatter, MetricThresholds, ModuleInput, ModuleListEntry, ModuleRecord, ModuleReport, NON_DISCOVERABLE_DIRS, NoteInput, NotePayload, NoteRow, Osc8Options, OutputFormat, OutputPipelineLive, OutputRenderer, OutputRendererLive, PackageManager, PathResolutionError, PathResolutionLive, PatternThresholds, PerClientSessionMapReader, PerClientSessionMapReaderLive, PerClientSessionMapWriter, PerClientSessionMapWriterLive, PersistentFailure, Phase, PhaseTransitionContext, PhaseTransitionEvent, PhaseTransitionResult, ProbeMissError, ProjectDiscovery, ProjectDiscoveryLive, ProjectDiscoveryTest, ProjectIdentity, ProjectIdentityCandidate, ProjectIdentityCandidates, ProjectIdentityLive, ProjectIdentityNotResolvableError, ProjectIdentitySource, ProjectIdentityTest, ProjectKey, ProjectRunSummary, ProjectSummary, RegisterAgentInput, RegisterAgentResult, RegistrationConflictError, Remediation, RenderState, RenderTotals, RenderedOutput, ReportError, ReportSummary, ReporterKit, ReporterRenderInput, ResolveDataPathOptions, ResolveProjectIdentityOptions, ResolvedIdentity, ResolvedReporterConfig, ResolvedThresholds, RunChangedFile, RunContext, RunContext$, RunContextLive, RunContextService, RunContextTest, RunEvent, RunEventByTag, RunHealth, RunInvocationMethod, RunOutcome, RunShape, SRC_DIR, SessionCompleteEvent, SessionContextRow, SessionDetail, SessionInput, SessionNotFoundError, SessionOutcome, SettingsInput, SettingsListEntry, SettingsRow, SidecarTimeoutError, SilentFormatter, StackFrameInput, SuggestedActionRecord, SuiteInput, SuiteListEntry, TEST_DIR, TEST_FILE_GLOB_SUFFIX, TEST_HELPER_DIRS, TagCountEntry, TagInventoryRow, TddArtifactDetail, TddArtifactRow, TddPhaseDetail, TddTaskAlreadyEndedError, TddTaskDetail, TddTaskEndOutcome, TddTaskId, TddTaskInput, TddTaskNotFoundError, TddTaskSummary, TerminalFormatter, TestCaseInput, TestClassification, TestError, TestErrorInput, TestFileEntry, TestHistory, TestListEntry, TestLookupOptions, TestOutcome, TestPathClassification, TestPathVerdict, TestRecord, TestReport, TestRun, TestRunInput, TestRunReason, TestState, ToolCallPayload, ToolResultPayload, Transport, TrendEntry, TrendRecord, TrendSummary, TurnInput, TurnPayload, TurnSearchOptions, TurnSummary, UpdateBehaviorInput, UpdateGoalInput, UserPromptPayload, ValidateHypothesisInput, VitestAgentConfig, VitestAgentConfigFile, VitestAgentConfigFileService, VitestAgentReporter, VitestAgentReporterFactory, VitestModuleDiagnostic, VitestModuleError, VitestParsedStack, VitestTestCase, VitestTestDiagnostic, VitestTestError, VitestTestModule, VitestTestResult, VitestTestSuite, WorkspaceLike, type WrapupKind, WriteCommitInput, WriteRunChangedFilesInput, WriteTddArtifactInput, WriteTddPhaseInput, WriteTddPhaseOutput, _resetMigrationCacheForTesting, ansi, assembleHistoryRecord, assembleManifest, buildAgentReport, buildConsoleLeaks, buildEnvPrefix, canonicalizeGitUrl, ciAnnotationsFormatter, classifyTest, classifyTestPath, coerceErrorField, coerceErrorText, collectConsoleLeakEntries, compressLines, computeFailureSignature, computeTrend, countSuiteFailures, deriveIdempotencyKey, detectPackageManager, detectVitestScripts, determineTier, ensureMigrated, extractSqlReason, findFunctionBoundary, findOwningWorkspace, formatConsoleMarkdown, formatFatalError, formatGfm, formatTriageEffect, formatWrapupEffect, getRecentDirection, getRunCommand, getWorstMetric, gitUrlToProjectKey, hashTargets, historyKey, initialRenderState, isTestFileName, isTimeoutError, isVitestInvocation, migration as migration0001, normalizeAssertionShape, normalizeWorkspaceKey, osc8, probeHostMetadataFromEnv, migration$1 as registryMigration0001, relativePath, requiredArtifactForTransition, resolveCoverageInput, resolveDataPath, resolveLogFile, resolveLogLevel, resolveProjectIdentityFromCandidates, resolveProjectKeyFromCwd, resolveWorkspaceKey, rewriteBashCommand, safeFilename, migration$2 as sessionMapMigration0001, stripAnsi, transitionEnforcesBehaviorMatch, validateCoverageConfig, validateCoverageTargetsShape, validatePhaseTransition };
5367
5410
  //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -117,7 +117,7 @@ import { requiredArtifactForTransition, transitionEnforcesBehaviorMatch, validat
117
117
  * substituted yet. Exported for version introspection by downstream tooling.
118
118
  * @public
119
119
  */
120
- const CURRENT_SDK_VERSION = "2.2.1";
120
+ const CURRENT_SDK_VERSION = "2.3.1";
121
121
 
122
122
  //#endregion
123
123
  export { ActionSeverity, ActorType, Agent, AgentConsoleMode, AgentContext, AgentId, AgentNotFoundError, AgentPluginOptions, AgentReport, AgentReporterOptions, BehaviorAbandonedEvent, BehaviorAddedEvent, BehaviorCompletedEvent, BehaviorDetail, BehaviorNotFoundError, BehaviorRow, BehaviorScopedEventTypes, BehaviorStartedEvent, BehaviorStatus, BehaviorsReadyEvent, BlockedEvent, CURRENT_SDK_VERSION, CacheManifest, CacheManifestEntry, ChannelEvent, ChatId, CiConsoleMode, ConfigLive, ConsoleLeakFile, ConsoleLeaks, ConsoleLogLevel, ConsoleMode, ConsoleOutputMode, ConsoleOutputs, ConversationId, ConversationNotFoundError, CoverageBaselines, FileCoverageReport as CoverageFile, CoverageGap, CoverageLevel, CoverageMetric, CoverageRenderState, CoverageReport, CoverageTargets, CoverageTargetsMetrics, CoverageTotals, DATABASE_FILENAME, DataReader, DataReaderLive, DataStore, DataStoreError, DataStoreLive, DetailLevel, DetailResolver, DetailResolverLive, DiscoveryError, DiscoveryRegistry, DiscoveryRegistryLive, Environment, EnvironmentDetector, EnvironmentDetectorLive, EnvironmentDetectorTest, Executor, ExecutorResolver, ExecutorResolverLive, FailureRecord, FileCoverageReport, FileEditPayload, FormatSelector, FormatSelectorLive, GfmFormatter, GitCommandError, GoalAbandonedEvent, GoalAddedEvent, GoalCompletedEvent, GoalDetail, GoalNotFoundError, GoalRow, GoalStartedEvent, GoalStatus, GoalsReadyEvent, HistoryRecord, HistoryTracker, HistoryTrackerLive, HistoryTrackerTest, HookFirePayload, HookStatus, HookType, HostKind, HostMetadataParseError, HumanConsoleMode, HypothesisPayload, IDEMPOTENCY_ROOT_SENTINEL, IdempotencyHit, IllegalStatusTransitionError, JsonFormatter, LoggerLive, MarkdownFormatter, MetricThresholds, ModuleRecord, ModuleReport, NON_DISCOVERABLE_DIRS, NotePayload, OutputFormat, OutputPipelineLive, OutputRenderer, OutputRendererLive, PackageManager, PathResolutionError, PathResolutionLive, PatternThresholds, PerClientSessionMapReader, PerClientSessionMapReaderLive, PerClientSessionMapWriter, PerClientSessionMapWriterLive, PhaseTransitionEvent, ProbeMissError, ProjectDiscovery, ProjectDiscoveryLive, ProjectDiscoveryTest, ProjectIdentity, ProjectIdentityLive, ProjectIdentityNotResolvableError, ProjectIdentityTest, ProjectKey, RegistrationConflictError, RenderState, RenderTotals, ReportError, ReportSummary, ResolvedThresholds, RunContext, RunContext$, RunContextLive, RunContextService, RunContextTest, RunEvent, SRC_DIR, SessionCompleteEvent, SessionNotFoundError, SessionOutcome, SidecarTimeoutError, SilentFormatter, SuggestedActionRecord, TEST_DIR, TEST_FILE_GLOB_SUFFIX, TEST_HELPER_DIRS, TagCountEntry, TddTaskAlreadyEndedError, TddTaskId, TddTaskNotFoundError, TerminalFormatter, TestClassification, TestHistory, TestRecord, TestReport, TestRun, TestRunReason, TestState, ToolCallPayload, ToolResultPayload, Transport, TrendEntry, TrendRecord, TurnPayload, UserPromptPayload, VitestAgentConfig, VitestAgentConfigFile, _resetMigrationCacheForTesting, ansi, assembleHistoryRecord, assembleManifest, buildAgentReport, buildConsoleLeaks, buildEnvPrefix, canonicalizeGitUrl, ciAnnotationsFormatter, classifyTest, classifyTestPath, coerceErrorField, coerceErrorText, collectConsoleLeakEntries, compressLines, computeFailureSignature, computeTrend, countSuiteFailures, deriveIdempotencyKey, detectPackageManager, detectVitestScripts, determineTier, ensureMigrated, extractSqlReason, findFunctionBoundary, findOwningWorkspace, formatConsoleMarkdown, formatFatalError, formatGfm, formatTriageEffect, formatWrapupEffect, getRecentDirection, getRunCommand, getWorstMetric, gitUrlToProjectKey, hashTargets, historyKey, initialRenderState, isTestFileName, isTimeoutError, isVitestInvocation, migration as migration0001, normalizeAssertionShape, normalizeWorkspaceKey, osc8, probeHostMetadataFromEnv, migration$1 as registryMigration0001, relativePath, requiredArtifactForTransition, resolveCoverageInput, resolveDataPath, resolveLogFile, resolveLogLevel, resolveProjectIdentityFromCandidates, resolveProjectKeyFromCwd, resolveWorkspaceKey, rewriteBashCommand, safeFilename, migration$2 as sessionMapMigration0001, stripAnsi, transitionEnforcesBehaviorMatch, validateCoverageConfig, validateCoverageTargetsShape, validatePhaseTransition };
@@ -194,11 +194,28 @@ const DataReaderLive = Layer.effect(DataReader, Effect.gen(function* () {
194
194
  table: "test_runs",
195
195
  reason: extractSqlReason(e)
196
196
  })));
197
- const getHistory = (project) => Effect.gen(function* () {
198
- yield* Effect.logDebug("getHistory").pipe(Effect.annotateLogs({ project }));
199
- const rows = yield* sql`SELECT module_path, full_name, timestamp, state
200
- FROM test_history
201
- WHERE project = ${project}
197
+ const getHistory = (project, options) => Effect.gen(function* () {
198
+ yield* Effect.logDebug("getHistory").pipe(Effect.annotateLogs({
199
+ project,
200
+ ...options
201
+ }));
202
+ const testName = options?.testName ?? null;
203
+ const modulePath = options?.modulePath ?? null;
204
+ const limit = options?.limit ?? 20;
205
+ const rows = yield* sql`WITH ranked AS (
206
+ SELECT module_path, full_name, timestamp, state,
207
+ ROW_NUMBER() OVER (
208
+ PARTITION BY module_path, full_name
209
+ ORDER BY timestamp DESC
210
+ ) AS rn
211
+ FROM test_history
212
+ WHERE project = ${project}
213
+ AND (${testName} IS NULL OR full_name = ${testName})
214
+ AND (${modulePath} IS NULL OR module_path = ${modulePath})
215
+ )
216
+ SELECT module_path, full_name, timestamp, state
217
+ FROM ranked
218
+ WHERE rn <= ${limit}
202
219
  ORDER BY module_path, full_name, timestamp DESC`;
203
220
  const testsMap = /* @__PURE__ */ new Map();
204
221
  for (const row of rows) {
@@ -310,8 +327,13 @@ const DataReaderLive = Layer.effect(DataReader, Effect.gen(function* () {
310
327
  table: "coverage_trends",
311
328
  reason: extractSqlReason(e)
312
329
  })));
313
- const getFlaky = (project) => Effect.gen(function* () {
314
- yield* Effect.logDebug("getFlaky").pipe(Effect.annotateLogs({ project }));
330
+ const getFlaky = (project, options) => Effect.gen(function* () {
331
+ yield* Effect.logDebug("getFlaky").pipe(Effect.annotateLogs({
332
+ project,
333
+ ...options
334
+ }));
335
+ const testName = options?.testName ?? null;
336
+ const modulePath = options?.modulePath ?? null;
315
337
  return (yield* sql`SELECT
316
338
  th1.full_name,
317
339
  th1.module_path,
@@ -326,6 +348,8 @@ const DataReaderLive = Layer.effect(DataReader, Effect.gen(function* () {
326
348
  MAX(th1.timestamp) as last_timestamp
327
349
  FROM test_history th1
328
350
  WHERE th1.project = ${project}
351
+ AND (${testName} IS NULL OR th1.full_name = ${testName})
352
+ AND (${modulePath} IS NULL OR th1.module_path = ${modulePath})
329
353
  GROUP BY th1.full_name, th1.module_path, th1.project
330
354
  -- Flaky means oscillation, not a clean recovery. A test with both
331
355
  -- passes and fails is only flaky when at least one failure occurs at
@@ -350,8 +374,13 @@ const DataReaderLive = Layer.effect(DataReader, Effect.gen(function* () {
350
374
  table: "test_history",
351
375
  reason: extractSqlReason(e)
352
376
  })));
353
- const getPersistentFailures = (project) => Effect.gen(function* () {
354
- yield* Effect.logDebug("getPersistentFailures").pipe(Effect.annotateLogs({ project }));
377
+ const getPersistentFailures = (project, options) => Effect.gen(function* () {
378
+ yield* Effect.logDebug("getPersistentFailures").pipe(Effect.annotateLogs({
379
+ project,
380
+ ...options
381
+ }));
382
+ const testName = options?.testName ?? null;
383
+ const modulePath = options?.modulePath ?? null;
355
384
  return (yield* sql`WITH ranked AS (
356
385
  SELECT full_name, module_path, project, state, timestamp, error_message,
357
386
  ROW_NUMBER() OVER (
@@ -360,6 +389,8 @@ const DataReaderLive = Layer.effect(DataReader, Effect.gen(function* () {
360
389
  ) as rn
361
390
  FROM test_history
362
391
  WHERE project = ${project}
392
+ AND (${testName} IS NULL OR full_name = ${testName})
393
+ AND (${modulePath} IS NULL OR module_path = ${modulePath})
363
394
  ),
364
395
  streak AS (
365
396
  SELECT full_name, module_path, project, state, timestamp, error_message, rn,
@@ -509,7 +540,7 @@ const DataReaderLive = Layer.effect(DataReader, Effect.gen(function* () {
509
540
  f.path as module_file
510
541
  FROM test_errors te
511
542
  LEFT JOIN test_cases tc ON tc.id = te.test_case_id
512
- LEFT JOIN test_modules tm ON tm.id = te.module_id
543
+ LEFT JOIN test_modules tm ON tm.id = COALESCE(te.module_id, tc.module_id)
513
544
  LEFT JOIN files f ON f.id = tm.file_id
514
545
  LEFT JOIN stack_frames sf ON sf.error_id = te.id AND sf.ordinal = 0
515
546
  WHERE te.run_id = ${runId} AND te.name = ${errorName}` : sql`SELECT te.id, sf.id AS top_stack_frame_id,
@@ -518,7 +549,7 @@ const DataReaderLive = Layer.effect(DataReader, Effect.gen(function* () {
518
549
  f.path as module_file
519
550
  FROM test_errors te
520
551
  LEFT JOIN test_cases tc ON tc.id = te.test_case_id
521
- LEFT JOIN test_modules tm ON tm.id = te.module_id
552
+ LEFT JOIN test_modules tm ON tm.id = COALESCE(te.module_id, tc.module_id)
522
553
  LEFT JOIN files f ON f.id = tm.file_id
523
554
  LEFT JOIN stack_frames sf ON sf.error_id = te.id AND sf.ordinal = 0
524
555
  WHERE te.run_id = ${runId}`).map((r) => ({
@@ -679,21 +710,25 @@ const DataReaderLive = Layer.effect(DataReader, Effect.gen(function* () {
679
710
  table: "settings",
680
711
  reason: extractSqlReason(e)
681
712
  })));
682
- const getTestByFullName = (project, fullName) => Effect.gen(function* () {
713
+ const getTestByFullName = (project, fullName, options) => Effect.gen(function* () {
683
714
  yield* Effect.logDebug("getTestByFullName").pipe(Effect.annotateLogs({
684
715
  project,
685
- fullName
716
+ fullName,
717
+ ...options
686
718
  }));
687
719
  const runs = yield* sql`SELECT id FROM test_runs
688
720
  WHERE project = ${project}
689
721
  ORDER BY timestamp DESC LIMIT 1`;
690
722
  if (runs.length === 0) return Option.none();
691
723
  const runId = runs[0].id;
724
+ const modulePath = options?.modulePath ?? null;
692
725
  const rows = yield* sql`SELECT tc.id, tc.full_name, tc.state, tc.duration, f.path as relative_module_id, tc.classification
693
726
  FROM test_cases tc
694
727
  JOIN test_modules tm ON tm.id = tc.module_id
695
728
  JOIN files f ON f.id = tm.file_id
696
729
  WHERE tm.run_id = ${runId} AND tc.full_name = ${fullName}
730
+ AND (${modulePath} IS NULL OR f.path = ${modulePath})
731
+ ORDER BY f.path ASC, tc.id ASC
697
732
  LIMIT 1`;
698
733
  if (rows.length === 0) return Option.none();
699
734
  const r = rows[0];
@@ -710,6 +745,27 @@ const DataReaderLive = Layer.effect(DataReader, Effect.gen(function* () {
710
745
  table: "test_cases",
711
746
  reason: extractSqlReason(e)
712
747
  })));
748
+ const getTestModulesByFullName = (project, fullName) => Effect.gen(function* () {
749
+ yield* Effect.logDebug("getTestModulesByFullName").pipe(Effect.annotateLogs({
750
+ project,
751
+ fullName
752
+ }));
753
+ const runs = yield* sql`SELECT id FROM test_runs
754
+ WHERE project = ${project}
755
+ ORDER BY timestamp DESC LIMIT 1`;
756
+ if (runs.length === 0) return [];
757
+ const runId = runs[0].id;
758
+ return (yield* sql`SELECT DISTINCT f.path as relative_module_id
759
+ FROM test_cases tc
760
+ JOIN test_modules tm ON tm.id = tc.module_id
761
+ JOIN files f ON f.id = tm.file_id
762
+ WHERE tm.run_id = ${runId} AND tc.full_name = ${fullName}
763
+ ORDER BY f.path ASC`).map((r) => r.relative_module_id);
764
+ }).pipe(Effect.annotateLogs("service", "DataReader"), Effect.mapError((e) => new DataStoreError({
765
+ operation: "read",
766
+ table: "test_cases",
767
+ reason: extractSqlReason(e)
768
+ })));
713
769
  const listTests = (project, options) => Effect.gen(function* () {
714
770
  yield* Effect.logDebug("listTests").pipe(Effect.annotateLogs({ project }));
715
771
  const runs = yield* sql`SELECT id FROM test_runs
@@ -1633,6 +1689,7 @@ const DataReaderLive = Layer.effect(DataReader, Effect.gen(function* () {
1633
1689
  getSettings,
1634
1690
  getLatestSettings,
1635
1691
  getTestByFullName,
1692
+ getTestModulesByFullName,
1636
1693
  listTests,
1637
1694
  listModules,
1638
1695
  listSuites,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitest-agent/sdk",
3
- "version": "2.2.1",
3
+ "version": "2.3.1",
4
4
  "private": false,
5
5
  "description": "Shared Effect Schema, SQLite migrations, data layer, services, formatters, and utilities for vitest-agent packages.",
6
6
  "keywords": [
@@ -47,12 +47,12 @@
47
47
  "dependencies": {
48
48
  "@effect/platform-node": "4.0.0-beta.107",
49
49
  "@effect/sql-sqlite-node": "4.0.0-beta.107",
50
- "@effected/config-file": "^0.3.1",
50
+ "@effected/config-file": "^0.4.1",
51
51
  "@effected/jsonc": "^0.6.0",
52
52
  "@effected/toml": "^0.4.0",
53
53
  "@effected/walker": "^0.4.0",
54
- "@effected/workspaces": "^0.11.2",
55
- "@effected/xdg": "^0.2.0",
54
+ "@effected/workspaces": "^0.13.0",
55
+ "@effected/xdg": "^0.2.1",
56
56
  "@effected/yaml": "^0.8.0",
57
57
  "acorn": "^8.18.0",
58
58
  "acorn-typescript": "^1.4.13",
package/testing.d.ts CHANGED
@@ -1236,6 +1236,42 @@ interface TurnSummary {
1236
1236
  readonly occurredAt: string;
1237
1237
  }
1238
1238
  /** @public */
1239
+ interface HistoryQueryOptions {
1240
+ /** Exact `full_name` match — narrows to a single test's history. */
1241
+ readonly testName?: string;
1242
+ /** Exact `module_path` match — narrows to tests in one file. */
1243
+ readonly modulePath?: string;
1244
+ /** Max runs kept per (module_path, full_name) pair, most-recent-first. Default 20. */
1245
+ readonly limit?: number;
1246
+ }
1247
+ /**
1248
+ * Narrowing options shared by the classification reads
1249
+ * ({@link DataReader.getFlaky} / `getPersistentFailures`). Mirrors the
1250
+ * `testName` / `modulePath` half of {@link HistoryQueryOptions} so a
1251
+ * caller that scoped `getHistory` to one test can scope the derived
1252
+ * classifications to the same test instead of receiving the whole
1253
+ * project's rows.
1254
+ *
1255
+ * @public
1256
+ */
1257
+ interface ClassificationQueryOptions {
1258
+ /** Exact `full_name` match — narrows to a single test's classification. */
1259
+ readonly testName?: string;
1260
+ /** Exact `module_path` match — narrows to tests in one file. */
1261
+ readonly modulePath?: string;
1262
+ }
1263
+ /**
1264
+ * Narrowing options for {@link DataReader.getTestByFullName}. A
1265
+ * `full_name` is not file-qualified (Decision D20), so the same name can
1266
+ * exist in more than one module; `modulePath` disambiguates.
1267
+ *
1268
+ * @public
1269
+ */
1270
+ interface TestLookupOptions {
1271
+ /** Exact `module_path` match — picks one variant of an ambiguous `full_name`. */
1272
+ readonly modulePath?: string;
1273
+ }
1274
+ /** @public */
1239
1275
  interface TurnSearchOptions {
1240
1276
  readonly sessionId?: number;
1241
1277
  readonly type?: string;
@@ -1390,11 +1426,11 @@ interface TagInventoryRow {
1390
1426
  declare const DataReader_base: Context.ServiceClass<DataReader, "vitest-agent/DataReader", {
1391
1427
  readonly getLatestRun: (project: string) => Effect.Effect<Option.Option<AgentReport>, DataStoreError>;
1392
1428
  readonly getRunsByProject: () => Effect.Effect<ReadonlyArray<ProjectRunSummary>, DataStoreError>;
1393
- readonly getHistory: (project: string) => Effect.Effect<HistoryRecord, DataStoreError>;
1429
+ readonly getHistory: (project: string, options?: HistoryQueryOptions) => Effect.Effect<HistoryRecord, DataStoreError>;
1394
1430
  readonly getBaselines: (project: string) => Effect.Effect<Option.Option<CoverageBaselines>, DataStoreError>;
1395
1431
  readonly getTrends: (project: string, limit?: number) => Effect.Effect<Option.Option<TrendRecord>, DataStoreError>;
1396
- readonly getFlaky: (project: string) => Effect.Effect<ReadonlyArray<FlakyTest>, DataStoreError>;
1397
- readonly getPersistentFailures: (project: string) => Effect.Effect<ReadonlyArray<PersistentFailure>, DataStoreError>;
1432
+ readonly getFlaky: (project: string, options?: ClassificationQueryOptions) => Effect.Effect<ReadonlyArray<FlakyTest>, DataStoreError>;
1433
+ readonly getPersistentFailures: (project: string, options?: ClassificationQueryOptions) => Effect.Effect<ReadonlyArray<PersistentFailure>, DataStoreError>;
1398
1434
  readonly getFileCoverage: (runId: number) => Effect.Effect<ReadonlyArray<FileCoverageReport>, DataStoreError>;
1399
1435
  readonly getCoverage: (project: string) => Effect.Effect<Option.Option<CoverageReport>, DataStoreError>;
1400
1436
  readonly getTestsForFile: (filePath: string) => Effect.Effect<ReadonlyArray<string>, DataStoreError>;
@@ -1405,7 +1441,14 @@ declare const DataReader_base: Context.ServiceClass<DataReader, "vitest-agent/Da
1405
1441
  readonly getManifest: () => Effect.Effect<Option.Option<CacheManifest>, DataStoreError>;
1406
1442
  readonly getSettings: (hash: string) => Effect.Effect<Option.Option<SettingsRow>, DataStoreError>;
1407
1443
  readonly getLatestSettings: () => Effect.Effect<Option.Option<SettingsRow>, DataStoreError>;
1408
- readonly getTestByFullName: (project: string, fullName: string) => Effect.Effect<Option.Option<TestListEntry>, DataStoreError>;
1444
+ readonly getTestByFullName: (project: string, fullName: string, options?: TestLookupOptions) => Effect.Effect<Option.Option<TestListEntry>, DataStoreError>;
1445
+ /**
1446
+ * Every module path in the project's latest run that carries a test
1447
+ * case with this exact `full_name`, ordered ascending. Length > 1
1448
+ * means the name is ambiguous and callers must disambiguate with
1449
+ * {@link TestLookupOptions.modulePath} rather than guess.
1450
+ */
1451
+ readonly getTestModulesByFullName: (project: string, fullName: string) => Effect.Effect<ReadonlyArray<string>, DataStoreError>;
1409
1452
  readonly listTests: (project: string, options?: {
1410
1453
  state?: string;
1411
1454
  module?: string;
@@ -1535,5 +1578,5 @@ declare function flaky(filename: string): Layer.Layer<DataReader | DataStore | i
1535
1578
  /** @public */
1536
1579
  declare function withTddTask(filename: string): Layer.Layer<DataReader | DataStore | import("effect/unstable/sql/SqlClient").SqlClient | import("@effect/sql-sqlite-node/SqliteClient").SqliteClient | import("@effect/platform-node/NodeServices").NodeServices, BehaviorNotFoundError | DataStoreError | GoalNotFoundError | IllegalStatusTransitionError | import("@effect/sql-sqlite-node/SqliteMigrator").MigrationError | import("effect/unstable/sql/SqlError").SqlError | TddTaskAlreadyEndedError | TddTaskNotFoundError, never>;
1537
1580
  //#endregion
1538
- export { type AcceptanceMetrics, Agent, AgentId, AgentNotFoundError, AgentReport, type ArtifactKind, type AssociateRunSessionInput, BehaviorDetail, BehaviorNotFoundError, BehaviorRow, BehaviorStatus, CacheManifest, type ChangeKind, ChatId, type CitedArtifact, type CitedArtifactRow, type CommitChangesEntry, CoverageBaselines, CoverageReport, type CreateBehaviorInput, type CreateGoalInput, type CurrentTddPhase, DataReader, DataStore, DataStoreError, DataStoreTestLayer, type EndTddTaskInput, type FailureSignatureDetail, type FailureSignatureWriteInput, type FileCoverageInput, FileCoverageReport, type FlakyTest, GoalDetail, GoalNotFoundError, GoalRow, GoalStatus, HistoryRecord, type HypothesisDetail, type HypothesisInput, IdempotencyHit, type IdempotentResponseInput, type IllegalStatusTransitionEntity, IllegalStatusTransitionError, type ModuleInput, type ModuleListEntry, type NoteInput, type NoteRow, type PersistentFailure, type Phase, type ProjectRunSummary, type RegisterAgentInput, RegistrationConflictError, type RunChangedFile, type RunInvocationMethod, type SessionDetail, type SessionInput, type SettingsInput, type SettingsListEntry, type SettingsRow, type StackFrameInput, type SuiteInput, type SuiteListEntry, type TagInventoryRow, type TddArtifactDetail, type TddArtifactRow, type TddPhaseDetail, TddTaskAlreadyEndedError, type TddTaskDetail, type TddTaskEndOutcome, type TddTaskInput, TddTaskNotFoundError, type TddTaskSummary, type TestCaseInput, type TestError, type TestErrorInput, type TestListEntry, type TestRunInput, TrendEntry, TrendRecord, type TurnInput, type TurnSearchOptions, type TurnSummary, type UpdateBehaviorInput, type UpdateGoalInput, type ValidateHypothesisInput, type WriteCommitInput, type WriteRunChangedFilesInput, type WriteTddArtifactInput, type WriteTddPhaseInput, type WriteTddPhaseOutput, empty, flaky, makeTestLayer, singlePassingRun, withFailures, withTddTask };
1581
+ export { type AcceptanceMetrics, Agent, AgentId, AgentNotFoundError, AgentReport, type ArtifactKind, type AssociateRunSessionInput, BehaviorDetail, BehaviorNotFoundError, BehaviorRow, BehaviorStatus, CacheManifest, type ChangeKind, ChatId, type CitedArtifact, type CitedArtifactRow, type ClassificationQueryOptions, type CommitChangesEntry, CoverageBaselines, CoverageReport, type CreateBehaviorInput, type CreateGoalInput, type CurrentTddPhase, DataReader, DataStore, DataStoreError, DataStoreTestLayer, type EndTddTaskInput, type FailureSignatureDetail, type FailureSignatureWriteInput, type FileCoverageInput, FileCoverageReport, type FlakyTest, GoalDetail, GoalNotFoundError, GoalRow, GoalStatus, type HistoryQueryOptions, HistoryRecord, type HypothesisDetail, type HypothesisInput, IdempotencyHit, type IdempotentResponseInput, type IllegalStatusTransitionEntity, IllegalStatusTransitionError, type ModuleInput, type ModuleListEntry, type NoteInput, type NoteRow, type PersistentFailure, type Phase, type ProjectRunSummary, type RegisterAgentInput, RegistrationConflictError, type RunChangedFile, type RunInvocationMethod, type SessionDetail, type SessionInput, type SettingsInput, type SettingsListEntry, type SettingsRow, type StackFrameInput, type SuiteInput, type SuiteListEntry, type TagInventoryRow, type TddArtifactDetail, type TddArtifactRow, type TddPhaseDetail, TddTaskAlreadyEndedError, type TddTaskDetail, type TddTaskEndOutcome, type TddTaskInput, TddTaskNotFoundError, type TddTaskSummary, type TestCaseInput, type TestError, type TestErrorInput, type TestListEntry, type TestLookupOptions, type TestRunInput, TrendEntry, TrendRecord, type TurnInput, type TurnSearchOptions, type TurnSummary, type UpdateBehaviorInput, type UpdateGoalInput, type ValidateHypothesisInput, type WriteCommitInput, type WriteRunChangedFilesInput, type WriteTddArtifactInput, type WriteTddPhaseInput, type WriteTddPhaseOutput, empty, flaky, makeTestLayer, singlePassingRun, withFailures, withTddTask };
1539
1582
  //# sourceMappingURL=testing.d.ts.map