@vitest-agent/sdk 2.1.0 → 2.2.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 +83 -1
- package/index.js +3 -2
- package/layers/ProjectDiscoveryLive.js +2 -3
- package/package.json +4 -4
- package/utils/test-location.js +114 -0
package/index.d.ts
CHANGED
|
@@ -5228,6 +5228,88 @@ declare const resolveWorkspaceKey: (projectDir: string) => Effect.Effect<string,
|
|
|
5228
5228
|
*/
|
|
5229
5229
|
declare function safeFilename(name: string): string;
|
|
5230
5230
|
//#endregion
|
|
5231
|
+
//#region src/utils/test-location.d.ts
|
|
5232
|
+
/** Directory holding source files whose tests may be co-located. @public */
|
|
5233
|
+
declare const SRC_DIR = "src";
|
|
5234
|
+
/** Canonical test directory name. @public */
|
|
5235
|
+
declare const TEST_DIR = "__test__";
|
|
5236
|
+
/** Support directories under `__test__/` that are never collected. @public */
|
|
5237
|
+
declare const TEST_HELPER_DIRS: readonly ["fixtures", "snapshots", "utils"];
|
|
5238
|
+
/** Glob suffix matching every discoverable test file. @public */
|
|
5239
|
+
declare const TEST_FILE_GLOB_SUFFIX = "*.{test,spec}.{ts,tsx,js,jsx}";
|
|
5240
|
+
/**
|
|
5241
|
+
* Directory names discovery never walks into, and therefore never collects
|
|
5242
|
+
* tests from. Keep in step with {@link TEST_FILE_GLOB_SUFFIX}'s extension set:
|
|
5243
|
+
* this is the directory half of the same "what can Vitest reach" question.
|
|
5244
|
+
*
|
|
5245
|
+
* `@vitest-agent/plugin`'s test-file walker and its cache-signature walk both
|
|
5246
|
+
* prune these before recursing (pruning first, rather than filtering results
|
|
5247
|
+
* after, is what keeps a symlinked `node_modules` from dragging in the whole
|
|
5248
|
+
* pnpm store), and {@link classifyTestPath} declines to render a verdict for
|
|
5249
|
+
* any path that crosses one.
|
|
5250
|
+
* @public
|
|
5251
|
+
*/
|
|
5252
|
+
declare const NON_DISCOVERABLE_DIRS: ReadonlySet<string>;
|
|
5253
|
+
/**
|
|
5254
|
+
* True when `filePathOrName` ends in a discoverable test-file suffix — the
|
|
5255
|
+
* extension half of the layout rule, matching {@link TEST_FILE_GLOB_SUFFIX}.
|
|
5256
|
+
*
|
|
5257
|
+
* Says nothing about location: a `node_modules` copy of `foo.test.ts` passes
|
|
5258
|
+
* this and is still not discoverable. Pair it with {@link classifyTestPath}
|
|
5259
|
+
* when the answer has to account for where the file sits.
|
|
5260
|
+
* @public
|
|
5261
|
+
*/
|
|
5262
|
+
declare function isTestFileName(filePathOrName: string): boolean;
|
|
5263
|
+
/**
|
|
5264
|
+
* Outcome of classifying a path against the test-layout rule.
|
|
5265
|
+
*
|
|
5266
|
+
* - `valid` — discoverable by Vitest.
|
|
5267
|
+
* - `excluded` — deliberately not discovered, and correct where it is.
|
|
5268
|
+
* - `invalid` — not a legal test location.
|
|
5269
|
+
* @public
|
|
5270
|
+
*/
|
|
5271
|
+
type TestPathVerdict = "valid" | "excluded" | "invalid";
|
|
5272
|
+
/** Result of {@link classifyTestPath}. @public */
|
|
5273
|
+
interface TestPathClassification {
|
|
5274
|
+
readonly verdict: TestPathVerdict;
|
|
5275
|
+
readonly workspace: string | null;
|
|
5276
|
+
readonly suggestedPath: string | null;
|
|
5277
|
+
}
|
|
5278
|
+
/** Minimal workspace shape {@link classifyTestPath} needs to attribute a path. @public */
|
|
5279
|
+
interface WorkspaceLike {
|
|
5280
|
+
readonly name: string;
|
|
5281
|
+
readonly path: string;
|
|
5282
|
+
}
|
|
5283
|
+
/**
|
|
5284
|
+
* Returns the deepest supplied workspace containing `filePath`, or `null` when
|
|
5285
|
+
* none does. Attribution is by longest matching path, so a nested package wins
|
|
5286
|
+
* over the repository root that contains it.
|
|
5287
|
+
*
|
|
5288
|
+
* Exported because callers that need to reason about a path relative to its
|
|
5289
|
+
* owning package — walking down from the package root, for instance — must
|
|
5290
|
+
* agree with {@link classifyTestPath} about which package owns it.
|
|
5291
|
+
* @public
|
|
5292
|
+
*/
|
|
5293
|
+
declare function findOwningWorkspace(workspaces: ReadonlyArray<WorkspaceLike>, filePath: string): WorkspaceLike | null;
|
|
5294
|
+
/**
|
|
5295
|
+
* Classifies `filePath` against the test-layout rule: a test file is
|
|
5296
|
+
* discoverable only at `<workspace>/src/**` or `<workspace>/__test__/**`,
|
|
5297
|
+
* excluding the helper directories under `__test__/`.
|
|
5298
|
+
*
|
|
5299
|
+
* Returns `null` when no supplied workspace contains the path, and when the
|
|
5300
|
+
* path crosses one of the {@link NON_DISCOVERABLE_DIRS} discovery never walks
|
|
5301
|
+
* into. Neither is a verdict — it means the rule has nothing to say, and
|
|
5302
|
+
* callers must fail open rather than treat it as invalid.
|
|
5303
|
+
*
|
|
5304
|
+
* The rule is pure, so one boundary the walker honors cannot be checked here:
|
|
5305
|
+
* a nested `package.json` marks an independent unit whose tests belong to a
|
|
5306
|
+
* different discovery pass, and detecting one needs a filesystem probe. A
|
|
5307
|
+
* caller with filesystem access should apply that check itself and fail open
|
|
5308
|
+
* when it fires — `@vitest-agent/cli`'s `agent check-test-path` does.
|
|
5309
|
+
* @public
|
|
5310
|
+
*/
|
|
5311
|
+
declare function classifyTestPath(workspaces: ReadonlyArray<WorkspaceLike>, filePath: string): TestPathClassification | null;
|
|
5312
|
+
//#endregion
|
|
5231
5313
|
//#region src/utils/validate-coverage-targets-shape.d.ts
|
|
5232
5314
|
/** @public */
|
|
5233
5315
|
interface CoverageTargetsShapeError {
|
|
@@ -5281,5 +5363,5 @@ declare function validateCoverageTargetsShape(input: unknown): CoverageTargetsSh
|
|
|
5281
5363
|
*/
|
|
5282
5364
|
declare const CURRENT_SDK_VERSION: string;
|
|
5283
5365
|
//#endregion
|
|
5284
|
-
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, 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, SessionCompleteEvent, SessionContextRow, SessionDetail, SessionInput, SessionNotFoundError, SessionOutcome, SettingsInput, SettingsListEntry, SettingsRow, SidecarTimeoutError, SilentFormatter, StackFrameInput, SuggestedActionRecord, SuiteInput, SuiteListEntry, TagCountEntry, TagInventoryRow, TddArtifactDetail, TddArtifactRow, TddPhaseDetail, TddTaskAlreadyEndedError, TddTaskDetail, TddTaskEndOutcome, TddTaskId, TddTaskInput, TddTaskNotFoundError, TddTaskSummary, TerminalFormatter, TestCaseInput, TestClassification, TestError, TestErrorInput, TestFileEntry, TestHistory, TestListEntry, TestOutcome, 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, type WrapupKind, WriteCommitInput, WriteRunChangedFilesInput, WriteTddArtifactInput, WriteTddPhaseInput, WriteTddPhaseOutput, _resetMigrationCacheForTesting, ansi, assembleHistoryRecord, assembleManifest, buildAgentReport, buildConsoleLeaks, buildEnvPrefix, canonicalizeGitUrl, ciAnnotationsFormatter, classifyTest, coerceErrorField, coerceErrorText, collectConsoleLeakEntries, compressLines, computeFailureSignature, computeTrend, countSuiteFailures, deriveIdempotencyKey, detectPackageManager, detectVitestScripts, determineTier, ensureMigrated, extractSqlReason, findFunctionBoundary, formatConsoleMarkdown, formatFatalError, formatGfm, formatTriageEffect, formatWrapupEffect, getRecentDirection, getRunCommand, getWorstMetric, gitUrlToProjectKey, hashTargets, historyKey, initialRenderState, 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 };
|
|
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 };
|
|
5285
5367
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -49,6 +49,7 @@ import { PathResolutionLive } from "./layers/PathResolutionLive.js";
|
|
|
49
49
|
import { PerClientSessionMapReader, PerClientSessionMapWriter } from "./services/PerClientSessionMap.js";
|
|
50
50
|
import { PerClientSessionMapReaderLive, PerClientSessionMapWriterLive } from "./layers/PerClientSessionMapLive.js";
|
|
51
51
|
import { ProjectDiscovery } from "./services/ProjectDiscovery.js";
|
|
52
|
+
import { NON_DISCOVERABLE_DIRS, SRC_DIR, TEST_DIR, TEST_FILE_GLOB_SUFFIX, TEST_HELPER_DIRS, classifyTestPath, findOwningWorkspace, isTestFileName } from "./utils/test-location.js";
|
|
52
53
|
import { ProjectDiscoveryLive } from "./layers/ProjectDiscoveryLive.js";
|
|
53
54
|
import { ProjectDiscoveryTest } from "./layers/ProjectDiscoveryTest.js";
|
|
54
55
|
import { canonicalizeGitUrl, gitUrlToProjectKey } from "./utils/canonicalize-git-url.js";
|
|
@@ -116,7 +117,7 @@ import { requiredArtifactForTransition, transitionEnforcesBehaviorMatch, validat
|
|
|
116
117
|
* substituted yet. Exported for version introspection by downstream tooling.
|
|
117
118
|
* @public
|
|
118
119
|
*/
|
|
119
|
-
const CURRENT_SDK_VERSION = "2.1
|
|
120
|
+
const CURRENT_SDK_VERSION = "2.2.1";
|
|
120
121
|
|
|
121
122
|
//#endregion
|
|
122
|
-
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, 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, SessionCompleteEvent, SessionNotFoundError, SessionOutcome, SidecarTimeoutError, SilentFormatter, SuggestedActionRecord, 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, coerceErrorField, coerceErrorText, collectConsoleLeakEntries, compressLines, computeFailureSignature, computeTrend, countSuiteFailures, deriveIdempotencyKey, detectPackageManager, detectVitestScripts, determineTier, ensureMigrated, extractSqlReason, findFunctionBoundary, formatConsoleMarkdown, formatFatalError, formatGfm, formatTriageEffect, formatWrapupEffect, getRecentDirection, getRunCommand, getWorstMetric, gitUrlToProjectKey, hashTargets, historyKey, initialRenderState, 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 };
|
|
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 };
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { DiscoveryError } from "../errors/DiscoveryError.js";
|
|
2
2
|
import { ProjectDiscovery } from "../services/ProjectDiscovery.js";
|
|
3
|
+
import { NON_DISCOVERABLE_DIRS } from "../utils/test-location.js";
|
|
3
4
|
import { Effect, FileSystem, Layer } from "effect";
|
|
4
5
|
|
|
5
6
|
//#region src/layers/ProjectDiscoveryLive.ts
|
|
6
7
|
const TEST_FILE_PATTERN = /\.(test|spec)\.(ts|tsx)$/;
|
|
7
8
|
const SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
8
|
-
|
|
9
|
-
".git",
|
|
10
|
-
"dist",
|
|
9
|
+
...NON_DISCOVERABLE_DIRS,
|
|
11
10
|
"coverage",
|
|
12
11
|
".turbo",
|
|
13
12
|
".vite"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest-agent/sdk",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.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,13 +47,13 @@
|
|
|
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.
|
|
50
|
+
"@effected/config-file": "^0.3.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.
|
|
54
|
+
"@effected/workspaces": "^0.11.2",
|
|
55
55
|
"@effected/xdg": "^0.2.0",
|
|
56
|
-
"@effected/yaml": "^0.
|
|
56
|
+
"@effected/yaml": "^0.8.0",
|
|
57
57
|
"acorn": "^8.18.0",
|
|
58
58
|
"acorn-typescript": "^1.4.13",
|
|
59
59
|
"ajv": "^8.20.0",
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { basename, join, relative, sep } from "node:path";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/test-location.ts
|
|
4
|
+
/** Directory holding source files whose tests may be co-located. @public */
|
|
5
|
+
const SRC_DIR = "src";
|
|
6
|
+
/** Canonical test directory name. @public */
|
|
7
|
+
const TEST_DIR = "__test__";
|
|
8
|
+
/** Support directories under `__test__/` that are never collected. @public */
|
|
9
|
+
const TEST_HELPER_DIRS = [
|
|
10
|
+
"fixtures",
|
|
11
|
+
"snapshots",
|
|
12
|
+
"utils"
|
|
13
|
+
];
|
|
14
|
+
/** Glob suffix matching every discoverable test file. @public */
|
|
15
|
+
const TEST_FILE_GLOB_SUFFIX = "*.{test,spec}.{ts,tsx,js,jsx}";
|
|
16
|
+
/**
|
|
17
|
+
* Directory names discovery never walks into, and therefore never collects
|
|
18
|
+
* tests from. Keep in step with {@link TEST_FILE_GLOB_SUFFIX}'s extension set:
|
|
19
|
+
* this is the directory half of the same "what can Vitest reach" question.
|
|
20
|
+
*
|
|
21
|
+
* `@vitest-agent/plugin`'s test-file walker and its cache-signature walk both
|
|
22
|
+
* prune these before recursing (pruning first, rather than filtering results
|
|
23
|
+
* after, is what keeps a symlinked `node_modules` from dragging in the whole
|
|
24
|
+
* pnpm store), and {@link classifyTestPath} declines to render a verdict for
|
|
25
|
+
* any path that crosses one.
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
const NON_DISCOVERABLE_DIRS = /* @__PURE__ */ new Set([
|
|
29
|
+
"node_modules",
|
|
30
|
+
".git",
|
|
31
|
+
"dist"
|
|
32
|
+
]);
|
|
33
|
+
/**
|
|
34
|
+
* Regex form of {@link TEST_FILE_GLOB_SUFFIX}. Anchored at the end of the
|
|
35
|
+
* string, so it matches a bare basename and a full path alike. Change both
|
|
36
|
+
* together — they are the same extension set in two notations.
|
|
37
|
+
*/
|
|
38
|
+
const TEST_FILE_SUFFIX_RE = /\.(?:test|spec)\.(?:ts|tsx|js|jsx)$/;
|
|
39
|
+
/**
|
|
40
|
+
* True when `filePathOrName` ends in a discoverable test-file suffix — the
|
|
41
|
+
* extension half of the layout rule, matching {@link TEST_FILE_GLOB_SUFFIX}.
|
|
42
|
+
*
|
|
43
|
+
* Says nothing about location: a `node_modules` copy of `foo.test.ts` passes
|
|
44
|
+
* this and is still not discoverable. Pair it with {@link classifyTestPath}
|
|
45
|
+
* when the answer has to account for where the file sits.
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
function isTestFileName(filePathOrName) {
|
|
49
|
+
return TEST_FILE_SUFFIX_RE.test(filePathOrName);
|
|
50
|
+
}
|
|
51
|
+
/** True when `child` is `parent` or sits beneath it on a segment boundary. */
|
|
52
|
+
function contains(parent, child) {
|
|
53
|
+
return child === parent || child.startsWith(parent.endsWith(sep) ? parent : `${parent}${sep}`);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Returns the deepest supplied workspace containing `filePath`, or `null` when
|
|
57
|
+
* none does. Attribution is by longest matching path, so a nested package wins
|
|
58
|
+
* over the repository root that contains it.
|
|
59
|
+
*
|
|
60
|
+
* Exported because callers that need to reason about a path relative to its
|
|
61
|
+
* owning package — walking down from the package root, for instance — must
|
|
62
|
+
* agree with {@link classifyTestPath} about which package owns it.
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
function findOwningWorkspace(workspaces, filePath) {
|
|
66
|
+
let owner = null;
|
|
67
|
+
for (const ws of workspaces) {
|
|
68
|
+
if (!contains(ws.path, filePath)) continue;
|
|
69
|
+
if (owner === null || ws.path.length > owner.path.length) owner = ws;
|
|
70
|
+
}
|
|
71
|
+
return owner;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Classifies `filePath` against the test-layout rule: a test file is
|
|
75
|
+
* discoverable only at `<workspace>/src/**` or `<workspace>/__test__/**`,
|
|
76
|
+
* excluding the helper directories under `__test__/`.
|
|
77
|
+
*
|
|
78
|
+
* Returns `null` when no supplied workspace contains the path, and when the
|
|
79
|
+
* path crosses one of the {@link NON_DISCOVERABLE_DIRS} discovery never walks
|
|
80
|
+
* into. Neither is a verdict — it means the rule has nothing to say, and
|
|
81
|
+
* callers must fail open rather than treat it as invalid.
|
|
82
|
+
*
|
|
83
|
+
* The rule is pure, so one boundary the walker honors cannot be checked here:
|
|
84
|
+
* a nested `package.json` marks an independent unit whose tests belong to a
|
|
85
|
+
* different discovery pass, and detecting one needs a filesystem probe. A
|
|
86
|
+
* caller with filesystem access should apply that check itself and fail open
|
|
87
|
+
* when it fires — `@vitest-agent/cli`'s `agent check-test-path` does.
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
function classifyTestPath(workspaces, filePath) {
|
|
91
|
+
const owner = findOwningWorkspace(workspaces, filePath);
|
|
92
|
+
if (owner === null) return null;
|
|
93
|
+
const segments = relative(owner.path, filePath).split(sep);
|
|
94
|
+
if (segments.some((s) => NON_DISCOVERABLE_DIRS.has(s))) return null;
|
|
95
|
+
const [head] = segments;
|
|
96
|
+
if (head === "src") return {
|
|
97
|
+
verdict: "valid",
|
|
98
|
+
workspace: owner.name,
|
|
99
|
+
suggestedPath: null
|
|
100
|
+
};
|
|
101
|
+
if (head === "__test__") return {
|
|
102
|
+
verdict: segments.slice(1, -1).some((s) => TEST_HELPER_DIRS.includes(s)) ? "excluded" : "valid",
|
|
103
|
+
workspace: owner.name,
|
|
104
|
+
suggestedPath: null
|
|
105
|
+
};
|
|
106
|
+
return {
|
|
107
|
+
verdict: "invalid",
|
|
108
|
+
workspace: owner.name,
|
|
109
|
+
suggestedPath: join(owner.path, TEST_DIR, basename(filePath))
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
export { NON_DISCOVERABLE_DIRS, SRC_DIR, TEST_DIR, TEST_FILE_GLOB_SUFFIX, TEST_HELPER_DIRS, classifyTestPath, findOwningWorkspace, isTestFileName };
|